@@ -141,32 +141,22 @@ static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtempl
141141 *
142142 * @param integer $forms_id id of the parent form
143143 * @param array $form_profile the validator data (match the validator table)
144- * @return integer the validator's id
144+ * @return integer|false the form_Profile ID or false on error
145145 */
146146 public static function import ($ forms_id = 0 , $ form_profile = []) {
147147 $ item = new self ;
148148 $ profile = new Profile ;
149- $ form_profile ['plugin_formcreator_forms_id ' ] = $ forms_id ;
149+ $ formFk = PluginFormcreatorForm::getForeignKeyField ();
150+ $ form_profile [$ formFk ] = $ forms_id ;
150151
151- // retrieve foreign key
152- if (!isset ($ form ['_profile ' ])
153- || !$ form ['profiles_id ' ]
154- = plugin_formcreator_getFromDBByField ($ profile , 'name ' , $ form ['_profile ' ])) {
155- $ form ['profiles_id ' ] = $ _SESSION ['glpiactive_entity ' ];
156- }
157-
158- if ($ form_profiles_id = plugin_formcreator_getFromDBByField ($ item , 'uuid ' , $ form_profile ['uuid ' ])) {
159- // add id key
160- $ form_profile ['id ' ] = $ form_profiles_id ;
152+ if ($ form_profiles_id = plugin_formcreator_getFromDBByField ($ profile , 'name ' , $ form_profile ['_profile ' ])) {
153+ $ form_profile [Profile::getForeignKeyField ()] = $ form_profiles_id ;
154+ $ item ->add ($ form_profile );
161155
162- // update section
163- $ item ->update ($ form_profile );
164- } else {
165- //create section
166- $ form_profiles_id = $ item ->add ($ form_profile );
156+ return $ item ->getID ();
167157 }
168158
169- return $ validators_id ;
159+ return false ;
170160 }
171161
172162 /**
0 commit comments