Skip to content

Commit

Permalink
fix(import): more explicit error message
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
btry committed Jun 12, 2020

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
1 parent 475e190 commit 8bb3c3d
Showing 12 changed files with 38 additions and 12 deletions.
7 changes: 6 additions & 1 deletion inc/condition.class.php
Original file line number Diff line number Diff line change
@@ -58,6 +58,11 @@ class PluginFormcreatorCondition extends CommonDBChild implements PluginFormcrea
const SHOW_CONDITION_QUESTION_VISIBLE = 7;
const SHOW_CONDITION_QUESTION_INVISIBLE = 8;

public static function getTypeName($nb = 0) {
return _n('Condition', 'Conditions', $nb, 'formcreator');
}


public function prepareInputForAdd($input) {
// generate a unique id
if (!isset($input['uuid'])
@@ -100,7 +105,7 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con
global $DB;

if (!isset($input['uuid']) && !isset($input['id'])) {
throw new ImportFailureException('UUID or ID is mandatory');
throw new ImportFailureException(sprintf('UUID or ID is mandatory for %1$s', static::getTypeName(1)));
}

// restore key and FK
2 changes: 1 addition & 1 deletion inc/form.class.php
Original file line number Diff line number Diff line change
@@ -1823,7 +1823,7 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con
global $DB;

if (!isset($input['uuid']) && !isset($input['id'])) {
throw new ImportFailureException('UUID or ID is mandatory');
throw new ImportFailureException(sprintf('UUID or ID is mandatory for %1$s', static::getTypeName(1)));
}

$input['_skip_checks'] = true;
2 changes: 1 addition & 1 deletion inc/form_profile.class.php
Original file line number Diff line number Diff line change
@@ -166,7 +166,7 @@ public static function showForForm(CommonDBTM $item, $withtemplate = '') {
*/
public static function import(PluginFormcreatorLinker $linker, $input = [], $containerId = 0) {
if (!isset($input['uuid']) && !isset($input['id'])) {
throw new ImportFailureException('UUID or ID is mandatory');
throw new ImportFailureException(sprintf('UUID or ID is mandatory for %1$s', static::getTypeName(1)));
}

$formFk = PluginFormcreatorForm::getForeignKeyField();
6 changes: 5 additions & 1 deletion inc/item_targetticket.class.php
Original file line number Diff line number Diff line change
@@ -47,6 +47,10 @@ class PluginFormcreatorItem_TargetTicket extends CommonDBRelation

static public $logs_for_item_1 = false;

public static function getTypeName($nb = 0) {
return _n('Composite ticket relation', 'Composite ticket relations', $nb, 'formcreator');
}

public function export($remove_uuid = false) {
if ($this->isNewItem()) {
return false;
@@ -88,7 +92,7 @@ public function export($remove_uuid = false) {

public static function import(PluginFormcreatorLinker $linker, $input = [], $containerId = 0) {
if (!isset($input['uuid']) && !isset($input['id'])) {
throw new ImportFailureException('UUID or ID is mandatory');
throw new ImportFailureException(sprintf('UUID or ID is mandatory for %1$s', static::getTypeName(1)));
}

$targetTicketFk = PluginFormcreatorTargetTicket::getForeignKeyField();
2 changes: 1 addition & 1 deletion inc/question.class.php
Original file line number Diff line number Diff line change
@@ -901,7 +901,7 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con
global $DB;

if (!isset($input['uuid']) && !isset($input['id'])) {
throw new ImportFailureException('UUID or ID is mandatory');
throw new ImportFailureException(sprintf('UUID or ID is mandatory for %1$s', static::getTypeName(1)));
}

// restore key and FK
6 changes: 5 additions & 1 deletion inc/questiondependency.class.php
Original file line number Diff line number Diff line change
@@ -62,6 +62,10 @@ public function __construct(PluginFormcreatorFieldInterface $field, array $optio
$this->fieldtype = isset($options['fieldType']) ? $options['fieldType'] : [];
}

public static function getTypeName($nb = 0) {
return _n('Question dependency', 'Question dependencies', $nb, 'formcreator');
}

public function getParameterFormSize() {
return 0;
}
@@ -133,7 +137,7 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con
global $DB;

if (!isset($input['uuid']) && !isset($input['id'])) {
throw new ImportFailureException('UUID or ID is mandatory');
throw new ImportFailureException(sprintf('UUID or ID is mandatory for %1$s', static::getTypeName(1)));
}

$questionFk = PluginFormcreatorQuestion::getForeignKeyField();
6 changes: 5 additions & 1 deletion inc/questionrange.class.php
Original file line number Diff line number Diff line change
@@ -47,6 +47,10 @@ class PluginFormcreatorQuestionRange

protected $domId = 'plugin_formcreator_questionRange';

public static function getTypeName($nb = 0) {
return _n('Question range', 'Question ranges', $nb, 'formcreator');
}

public function getParameterFormSize() {
return 0;
}
@@ -125,7 +129,7 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con
global $DB;

if (!isset($input['uuid']) && !isset($input['id'])) {
throw new ImportFailureException('UUID or ID is mandatory');
throw new ImportFailureException(sprintf('UUID or ID is mandatory for %1$s', static::getTypeName(1)));
}

$questionFk = PluginFormcreatorQuestion::getForeignKeyField();
6 changes: 5 additions & 1 deletion inc/questionregex.class.php
Original file line number Diff line number Diff line change
@@ -47,6 +47,10 @@ class PluginFormcreatorQuestionRegex

protected $domId = 'plugin_formcreator_questionRegex';

public static function getTypeName($nb = 0) {
return _n('Question regular expression', 'Question regular expressions', $nb, 'formcreator');
}

public function getParameterFormSize() {
return 1;
}
@@ -120,7 +124,7 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con
global $DB;

if (!isset($input['uuid']) && !isset($input['id'])) {
throw new ImportFailureException('UUID or ID is mandatory');
throw new ImportFailureException(sprintf('UUID or ID is mandatory for %1$s', static::getTypeName(1)));
}

$questionFk = PluginFormcreatorQuestion::getForeignKeyField();
2 changes: 1 addition & 1 deletion inc/section.class.php
Original file line number Diff line number Diff line change
@@ -226,7 +226,7 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con
global $DB;

if (!isset($input['uuid']) && !isset($input['id'])) {
throw new ImportFailureException('UUID or ID is mandatory');
throw new ImportFailureException(sprintf('UUID or ID is mandatory for %1$s', static::getTypeName(1)));
}

// restore key and FK
7 changes: 6 additions & 1 deletion inc/target_actor.class.php
Original file line number Diff line number Diff line change
@@ -80,6 +80,11 @@ static function getEnumRole() {
// TODO : support ACTOR_ROLE_SUPPLIER
];
}

public static function getTypeName($nb = 0) {
return _n('Target actor', 'Target actors', $nb, 'formcreator');
}

public function prepareInputForAdd($input) {

// generate a unique id
@@ -92,7 +97,7 @@ public function prepareInputForAdd($input) {

public static function import(PluginFormcreatorLinker $linker, $input = [], $containerId = 0) {
if (!isset($input['uuid']) && !isset($input['id'])) {
throw new ImportFailureException('UUID or ID is mandatory');
throw new ImportFailureException(sprintf('UUID or ID is mandatory for %1$s', static::getTypeName(1)));
}

$input[static::$items_id] = $containerId;
2 changes: 1 addition & 1 deletion inc/targetchange.class.php
Original file line number Diff line number Diff line change
@@ -135,7 +135,7 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con
global $DB;

if (!isset($input['uuid']) && !isset($input['id'])) {
throw new ImportFailureException('UUID or ID is mandatory');
throw new ImportFailureException(sprintf('UUID or ID is mandatory for %1$s', static::getTypeName(1)));
}

$formFk = PluginFormcreatorForm::getForeignKeyField();
2 changes: 1 addition & 1 deletion inc/targetticket.class.php
Original file line number Diff line number Diff line change
@@ -1030,7 +1030,7 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con
global $DB;

if (!isset($input['uuid']) && !isset($input['id'])) {
throw new ImportFailureException('UUID or ID is mandatory');
throw new ImportFailureException(sprintf('UUID or ID is mandatory for %1$s', static::getTypeName(1)));
}

$formFk = PluginFormcreatorForm::getForeignKeyField();

0 comments on commit 8bb3c3d

Please sign in to comment.