@@ -29,15 +29,15 @@ discard block |
||
29 | 29 | |
30 | 30 | // Load Dolibarr environment |
31 | 31 | require '../main.inc.php'; |
32 | -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php'; |
|
33 | -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php'; |
|
34 | -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; |
|
35 | -require_once DOL_DOCUMENT_ROOT . '/hrm/class/skill.class.php'; |
|
36 | -require_once DOL_DOCUMENT_ROOT . '/hrm/lib/hrm_skill.lib.php'; |
|
32 | +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; |
|
33 | +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; |
|
34 | +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; |
|
35 | +require_once DOL_DOCUMENT_ROOT.'/hrm/class/skill.class.php'; |
|
36 | +require_once DOL_DOCUMENT_ROOT.'/hrm/lib/hrm_skill.lib.php'; |
|
37 | 37 | |
38 | 38 | |
39 | 39 | // Load translation files required by the page |
40 | -$langs->loadLangs(array('hrm', 'other', 'products')); // why products? |
|
40 | +$langs->loadLangs(array('hrm', 'other', 'products')); // why products? |
|
41 | 41 | |
42 | 42 | // Get parameters |
43 | 43 | $id = GETPOST('id', 'int'); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'skillcard'; // To manage different context of search |
49 | 49 | $backtopage = GETPOST('backtopage', 'alpha'); |
50 | 50 | $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); |
51 | -$lineid = GETPOST('lineid', 'int'); |
|
51 | +$lineid = GETPOST('lineid', 'int'); |
|
52 | 52 | |
53 | 53 | // Initialize technical objects |
54 | 54 | $object = new Skill($db); |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | $search_all = GETPOST("search_all", 'alpha'); |
67 | 67 | $search = array(); |
68 | 68 | foreach ($object->fields as $key => $val) { |
69 | - if (GETPOST('search_' . $key, 'alpha')) { |
|
70 | - $search[$key] = GETPOST('search_' . $key, 'alpha'); |
|
69 | + if (GETPOST('search_'.$key, 'alpha')) { |
|
70 | + $search[$key] = GETPOST('search_'.$key, 'alpha'); |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
@@ -76,13 +76,13 @@ discard block |
||
76 | 76 | } |
77 | 77 | |
78 | 78 | // Load object |
79 | -include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once. |
|
79 | +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. |
|
80 | 80 | |
81 | 81 | // Permissions |
82 | 82 | $permissiontoread = $user->rights->hrm->all->read; |
83 | 83 | $permissiontoadd = $user->rights->hrm->all->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php |
84 | 84 | $permissiontodelete = $user->rights->hrm->all->delete; |
85 | -$upload_dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->entity : 1] . '/skill'; |
|
85 | +$upload_dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->entity : 1].'/skill'; |
|
86 | 86 | |
87 | 87 | // Security check (enable the most restrictive one) |
88 | 88 | //if ($user->socid > 0) accessforbidden(); |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { |
116 | 116 | $backtopage = $backurlforlist; |
117 | 117 | } else { |
118 | - $backtopage = DOL_URL_ROOT.'/hrm/skill_card.php?id=' . ($id > 0 ? $id : '__ID__'); |
|
118 | + $backtopage = DOL_URL_ROOT.'/hrm/skill_card.php?id='.($id > 0 ? $id : '__ID__'); |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | } |
@@ -148,16 +148,16 @@ discard block |
||
148 | 148 | |
149 | 149 | |
150 | 150 | // Actions when linking object each other |
151 | - include DOL_DOCUMENT_ROOT . '/core/actions_dellink.inc.php'; |
|
151 | + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; |
|
152 | 152 | |
153 | 153 | // Actions when printing a doc from card |
154 | - include DOL_DOCUMENT_ROOT . '/core/actions_printing.inc.php'; |
|
154 | + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; |
|
155 | 155 | |
156 | 156 | // Action to move up and down lines of object |
157 | 157 | //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; |
158 | 158 | |
159 | 159 | // Action to build doc |
160 | - include DOL_DOCUMENT_ROOT . '/core/actions_builddoc.inc.php'; |
|
160 | + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; |
|
161 | 161 | |
162 | 162 | if ($action == 'set_thirdparty' && $permissiontoadd) { |
163 | 163 | $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, $triggermodname); |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | // Actions to send emails |
170 | 170 | $triggersendname = 'hrm_SKILL_SENTBYMAIL'; |
171 | 171 | $autocopy = 'MAIN_MAIL_AUTOCOPY_SKILL_TO'; |
172 | - $trackid = 'skill' . $object->id; |
|
173 | - include DOL_DOCUMENT_ROOT . '/core/actions_sendmails.inc.php'; |
|
172 | + $trackid = 'skill'.$object->id; |
|
173 | + include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | |
@@ -189,25 +189,25 @@ discard block |
||
189 | 189 | |
190 | 190 | // Part to create |
191 | 191 | if ($action == 'create') { |
192 | - print load_fiche_titre($langs->trans("NewSkill"), '', 'object_' . $object->picto); |
|
192 | + print load_fiche_titre($langs->trans("NewSkill"), '', 'object_'.$object->picto); |
|
193 | 193 | |
194 | - print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">'; |
|
195 | - print '<input type="hidden" name="token" value="' . newToken() . '">'; |
|
194 | + print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; |
|
195 | + print '<input type="hidden" name="token" value="'.newToken().'">'; |
|
196 | 196 | print '<input type="hidden" name="action" value="add">'; |
197 | - $backtopage .= (strpos($backtopage, '?') > 0 ? '&' : '?' ) ."objecttype=job"; |
|
197 | + $backtopage .= (strpos($backtopage, '?') > 0 ? '&' : '?')."objecttype=job"; |
|
198 | 198 | if ($backtopage) { |
199 | - print '<input type="hidden" name="backtopage" value="' . $backtopage . '">'; |
|
199 | + print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; |
|
200 | 200 | } |
201 | 201 | if ($backtopageforcancel) { |
202 | - print '<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel . '">'; |
|
202 | + print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">'; |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | print dol_get_fiche_head(array(), ''); |
206 | 206 | |
207 | - print '<table class="border centpercent tableforfieldcreate">' . "\n"; |
|
207 | + print '<table class="border centpercent tableforfieldcreate">'."\n"; |
|
208 | 208 | |
209 | 209 | // Common attributes |
210 | - include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php'; |
|
210 | + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; |
|
211 | 211 | |
212 | 212 | // Other attributes |
213 | 213 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; |
@@ -217,15 +217,15 @@ discard block |
||
217 | 217 | //@todo je stop ici ... à continuer (affichage des 5 skilled input pour create action |
218 | 218 | //print $object->showInputField($val, $key, $value, '', '['']', '', 0); |
219 | 219 | |
220 | - print '</table>' . "\n"; |
|
220 | + print '</table>'."\n"; |
|
221 | 221 | |
222 | 222 | print dol_get_fiche_end(); |
223 | 223 | |
224 | 224 | print '<div class="center">'; |
225 | - print '<input type="submit" class="button" name="add" value="' . dol_escape_htmltag($langs->trans("Create")) . '">'; |
|
225 | + print '<input type="submit" class="button" name="add" value="'.dol_escape_htmltag($langs->trans("Create")).'">'; |
|
226 | 226 | print ' '; |
227 | 227 | |
228 | - print '<input type="' . ($backtopage ? "submit" : "button") . '" class="button button-cancel" name="cancel" value="' . dol_escape_htmltag($langs->trans("Cancel")) . '"' . ($backtopage ? '' : ' onclick="history.go(-1)"') . '>'; // Cancel for create does not post form if we don't know the backtopage |
|
228 | + print '<input type="'.($backtopage ? "submit" : "button").'" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'"'.($backtopage ? '' : ' onclick="history.go(-1)"').'>'; // Cancel for create does not post form if we don't know the backtopage |
|
229 | 229 | print '</div>'; |
230 | 230 | |
231 | 231 | print '</form>'; |
@@ -236,25 +236,25 @@ discard block |
||
236 | 236 | // Part to edit record |
237 | 237 | // and skilldet edition |
238 | 238 | if (($id || $ref) && $action == 'edit') { |
239 | - print load_fiche_titre($langs->trans("Skill"), '', 'object_' . $object->picto); |
|
239 | + print load_fiche_titre($langs->trans("Skill"), '', 'object_'.$object->picto); |
|
240 | 240 | |
241 | - print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">'; |
|
242 | - print '<input type="hidden" name="token" value="' . newToken() . '">'; |
|
241 | + print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; |
|
242 | + print '<input type="hidden" name="token" value="'.newToken().'">'; |
|
243 | 243 | print '<input type="hidden" name="action" value="update">'; |
244 | - print '<input type="hidden" name="id" value="' . $object->id . '">'; |
|
244 | + print '<input type="hidden" name="id" value="'.$object->id.'">'; |
|
245 | 245 | if ($backtopage) { |
246 | - print '<input type="hidden" name="backtopage" value="' . $backtopage . '">'; |
|
246 | + print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; |
|
247 | 247 | } |
248 | 248 | if ($backtopageforcancel) { |
249 | - print '<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel . '">'; |
|
249 | + print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">'; |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | print dol_get_fiche_head(); |
253 | 253 | |
254 | - print '<table class="border centpercent tableforfieldedit">' . "\n"; |
|
254 | + print '<table class="border centpercent tableforfieldedit">'."\n"; |
|
255 | 255 | |
256 | 256 | // Common attributes |
257 | - include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php'; |
|
257 | + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; |
|
258 | 258 | |
259 | 259 | // Other attributes |
260 | 260 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | continue; |
278 | 278 | } |
279 | 279 | |
280 | - print '<table class="border centpercent =">' . "\n"; |
|
280 | + print '<table class="border centpercent =">'."\n"; |
|
281 | 281 | $sk->fields = dol_sort_array($sk->fields, 'position'); |
282 | 282 | foreach ($sk->fields as $key => $val) { |
283 | 283 | if (abs($val['visible']) != 1 && abs($val['visible']) != 3 && abs($val['visible']) != 4) { |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | continue; // We don't want this field |
289 | 289 | } |
290 | 290 | |
291 | - print '<tr class="field_' . $key . '"><td'; |
|
291 | + print '<tr class="field_'.$key.'"><td'; |
|
292 | 292 | print ' class="titlefieldcreate'; |
293 | 293 | if (isset($val['notnull']) && $val['notnull'] > 0) { |
294 | 294 | print ' fieldrequired'; |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | if (empty($skilldetArray)) { |
324 | 324 | $value = GETPOSTISSET($key) ? GETPOST($key, $check) : $sk->$key; |
325 | 325 | } else { |
326 | - $value=$skilldetArray[$sk->id]; |
|
326 | + $value = $skilldetArray[$sk->id]; |
|
327 | 327 | } |
328 | 328 | // |
329 | 329 | // } elseif ($val['type'] == 'price') { |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | print $sk->showOutputField($val, $key, $value, '', '', '', 0); |
337 | 337 | } else { |
338 | 338 | /** @var Skilldet $sk */ |
339 | - print $sk->showInputField($val, $key, $value, "", "line[" . $sk->id . "]", "", ""); |
|
339 | + print $sk->showInputField($val, $key, $value, "", "line[".$sk->id."]", "", ""); |
|
340 | 340 | } |
341 | 341 | print '</td>'; |
342 | 342 | print '</tr>'; |
@@ -348,8 +348,8 @@ discard block |
||
348 | 348 | |
349 | 349 | print dol_get_fiche_end(); |
350 | 350 | |
351 | - print '<div class="center"><input type="submit" class="button button-save" name="save" value="' . $langs->trans("Save") . '">'; |
|
352 | - print ' <input type="submit" class="button button-cancel" name="cancel" value="' . $langs->trans("Cancel") . '">'; |
|
351 | + print '<div class="center"><input type="submit" class="button button-save" name="save" value="'.$langs->trans("Save").'">'; |
|
352 | + print ' <input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">'; |
|
353 | 353 | print '</div>'; |
354 | 354 | |
355 | 355 | print '</form>'; |
@@ -367,17 +367,17 @@ discard block |
||
367 | 367 | |
368 | 368 | // Confirmation to delete |
369 | 369 | if ($action == 'delete') { |
370 | - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteSkill'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1); |
|
370 | + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteSkill'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1); |
|
371 | 371 | } |
372 | 372 | // Confirmation to delete line |
373 | 373 | if ($action == 'deleteline') { |
374 | - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id . '&lineid=' . $lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); |
|
374 | + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); |
|
375 | 375 | } |
376 | 376 | // Clone confirmation |
377 | 377 | if ($action == 'clone') { |
378 | 378 | // Create an array for form |
379 | 379 | $formquestion = array(); |
380 | - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); |
|
380 | + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | // Confirmation of action xxxx |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) |
394 | 394 | ); |
395 | 395 | */ |
396 | - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); |
|
396 | + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | // Call Hook formConfirm |
@@ -411,11 +411,11 @@ discard block |
||
411 | 411 | |
412 | 412 | // Object card |
413 | 413 | // ------------------------------------------------------------ |
414 | - $linkback = '<a href="' . DOL_URL_ROOT.'/hrm/skill_list.php?restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; |
|
414 | + $linkback = '<a href="'.DOL_URL_ROOT.'/hrm/skill_list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; |
|
415 | 415 | |
416 | 416 | |
417 | 417 | $morehtmlref = '<div class="refid">'; |
418 | - $morehtmlref.= $object->label; |
|
418 | + $morehtmlref .= $object->label; |
|
419 | 419 | $morehtmlref .= '</div>'; |
420 | 420 | dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'rowid', $morehtmlref); |
421 | 421 | |
@@ -423,10 +423,10 @@ discard block |
||
423 | 423 | print '<div class="fichecenter">'; |
424 | 424 | print '<div class="fichehalfleft">'; |
425 | 425 | print '<div class="underbanner clearboth"></div>'; |
426 | - print '<table class="border centpercent tableforfield">' . "\n"; |
|
426 | + print '<table class="border centpercent tableforfield">'."\n"; |
|
427 | 427 | |
428 | - $object->fields['label']['visible']=0; // Already in banner |
|
429 | - include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; |
|
428 | + $object->fields['label']['visible'] = 0; // Already in banner |
|
429 | + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; |
|
430 | 430 | |
431 | 431 | // Other attributes. Fields from hook formObjectOptions and Extrafields. |
432 | 432 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | // Buttons for actions |
447 | 447 | |
448 | 448 | if ($action != 'presend' && $action != 'editline') { |
449 | - print '<div class="tabsAction">' . "\n"; |
|
449 | + print '<div class="tabsAction">'."\n"; |
|
450 | 450 | $parameters = array(); |
451 | 451 | $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
452 | 452 | if ($reshook < 0) { |
@@ -456,15 +456,15 @@ discard block |
||
456 | 456 | if (empty($reshook)) { |
457 | 457 | // Back to draft |
458 | 458 | if ($object->status == $object::STATUS_VALIDATED) { |
459 | - print dolGetButtonAction($langs->trans('SetToDraft'), '', 'default', $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=confirm_setdraft&confirm=yes&token=' . newToken(), '', $permissiontoadd); |
|
459 | + print dolGetButtonAction($langs->trans('SetToDraft'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes&token='.newToken(), '', $permissiontoadd); |
|
460 | 460 | } |
461 | 461 | |
462 | - print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=edit&token=' . newToken(), '', $permissiontoadd); |
|
462 | + print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd); |
|
463 | 463 | |
464 | 464 | // Delete (need delete permission, or if draft, just need create/modify permission) |
465 | - print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=delete&token=' . newToken(), '', $permissiontodelete); |
|
465 | + print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete&token='.newToken(), '', $permissiontodelete); |
|
466 | 466 | } |
467 | - print '</div>' . "\n"; |
|
467 | + print '</div>'."\n"; |
|
468 | 468 | } |
469 | 469 | } |
470 | 470 | |
@@ -475,12 +475,12 @@ discard block |
||
475 | 475 | //*--------------------------------------------------------------------------- |
476 | 476 | |
477 | 477 | if ($action != "create" && $action != "edit") { |
478 | - require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php'; |
|
479 | - require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; |
|
480 | - require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; |
|
478 | + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; |
|
479 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; |
|
480 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; |
|
481 | 481 | |
482 | 482 | // load hrm libraries |
483 | - require_once __DIR__ . '/class/skilldet.class.php'; |
|
483 | + require_once __DIR__.'/class/skilldet.class.php'; |
|
484 | 484 | |
485 | 485 | // for other modules |
486 | 486 | //dol_include_once('/othermodule/class/otherobject.class.php'); |
@@ -517,8 +517,8 @@ discard block |
||
517 | 517 | |
518 | 518 | // Default sort order (if not yet defined by previous GETPOST) |
519 | 519 | if (!$sortfield) { |
520 | - reset($objectline->fields); // Reset is required to avoid key() to return null. |
|
521 | - $sortfield = "t." . key($objectline->fields); // Set here default search field. By default 1st field in definition. |
|
520 | + reset($objectline->fields); // Reset is required to avoid key() to return null. |
|
521 | + $sortfield = "t.".key($objectline->fields); // Set here default search field. By default 1st field in definition. |
|
522 | 522 | } |
523 | 523 | if (!$sortorder) { |
524 | 524 | $sortorder = "ASC"; |
@@ -528,12 +528,12 @@ discard block |
||
528 | 528 | $search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'); |
529 | 529 | $search = array(); |
530 | 530 | foreach ($objectline->fields as $key => $val) { |
531 | - if (GETPOST('search_' . $key, 'alpha') !== '') { |
|
532 | - $search[$key] = GETPOST('search_' . $key, 'alpha'); |
|
531 | + if (GETPOST('search_'.$key, 'alpha') !== '') { |
|
532 | + $search[$key] = GETPOST('search_'.$key, 'alpha'); |
|
533 | 533 | } |
534 | 534 | if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { |
535 | - $search[$key . '_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_' . $key . '_dtstartmonth', 'int'), GETPOST('search_' . $key . '_dtstartday', 'int'), GETPOST('search_' . $key . '_dtstartyear', 'int')); |
|
536 | - $search[$key . '_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_' . $key . '_dtendmonth', 'int'), GETPOST('search_' . $key . '_dtendday', 'int'), GETPOST('search_' . $key . '_dtendyear', 'int')); |
|
535 | + $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int')); |
|
536 | + $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int')); |
|
537 | 537 | } |
538 | 538 | } |
539 | 539 | |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | $fieldstosearchall = array(); |
542 | 542 | foreach ($objectline->fields as $key => $val) { |
543 | 543 | if (!empty($val['searchall'])) { |
544 | - $fieldstosearchall['t.' . $key] = $val['label']; |
|
544 | + $fieldstosearchall['t.'.$key] = $val['label']; |
|
545 | 545 | } |
546 | 546 | } |
547 | 547 | |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | // If $val['visible']==0, then we never show the field |
552 | 552 | if (!empty($val['visible'])) { |
553 | 553 | $visible = (int) dol_eval($val['visible'], 1, 1, '1'); |
554 | - $arrayfields['t.' . $key] = array( |
|
554 | + $arrayfields['t.'.$key] = array( |
|
555 | 555 | 'label' => $val['label'], |
556 | 556 | 'checked' => (($visible < 0) ? 0 : 1), |
557 | 557 | 'enabled' => ($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')), |
@@ -583,15 +583,15 @@ discard block |
||
583 | 583 | // -------------------------------------------------------------------- |
584 | 584 | $sql = 'SELECT '; |
585 | 585 | $sql .= $objectline->getFieldList('t'); |
586 | - $sql .= " FROM " . MAIN_DB_PREFIX . $objectline->table_element . " as t"; |
|
586 | + $sql .= " FROM ".MAIN_DB_PREFIX.$objectline->table_element." as t"; |
|
587 | 587 | if ($objectline->ismultientitymanaged == 1) { |
588 | - $sql .= " WHERE t.entity IN (" . getEntity($objectline->element) . ")"; |
|
588 | + $sql .= " WHERE t.entity IN (".getEntity($objectline->element).")"; |
|
589 | 589 | } else { |
590 | 590 | $sql .= " WHERE 1 = 1 "; |
591 | 591 | } |
592 | 592 | |
593 | 593 | if (!empty($id)) { |
594 | - $sql .= " AND fk_skill = " . ((int) $id) . " "; |
|
594 | + $sql .= " AND fk_skill = ".((int) $id)." "; |
|
595 | 595 | } |
596 | 596 | |
597 | 597 | // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. |
@@ -611,41 +611,41 @@ discard block |
||
611 | 611 | $num = $db->num_rows($resql); |
612 | 612 | } |
613 | 613 | |
614 | - print '<form method="POST" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">' . "\n"; |
|
614 | + print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n"; |
|
615 | 615 | if ($optioncss != '') { |
616 | - print '<input type="hidden" name="optioncss" value="' . $optioncss . '">'; |
|
616 | + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
617 | 617 | } |
618 | - print '<input type="hidden" name="token" value="' . newToken() . '">'; |
|
618 | + print '<input type="hidden" name="token" value="'.newToken().'">'; |
|
619 | 619 | print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; |
620 | 620 | print '<input type="hidden" name="action" value="list">'; |
621 | - print '<input type="hidden" name="sortfield" value="' . $sortfield . '">'; |
|
622 | - print '<input type="hidden" name="sortorder" value="' . $sortorder . '">'; |
|
623 | - print '<input type="hidden" name="page" value="' . $page . '">'; |
|
624 | - print '<input type="hidden" name="contextpage" value="' . $contextpage . '">'; |
|
621 | + print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; |
|
622 | + print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; |
|
623 | + print '<input type="hidden" name="page" value="'.$page.'">'; |
|
624 | + print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; |
|
625 | 625 | if (!empty($id)) { |
626 | - print '<input type="hidden" name="id" value="' . $id . '">'; |
|
626 | + print '<input type="hidden" name="id" value="'.$id.'">'; |
|
627 | 627 | } |
628 | 628 | |
629 | - $param_fk = "&fk_skill=" . $id . "&fk_user_creat=" . (!empty($user->rowid) ? $user->rowid :0); |
|
630 | - $backtopage = dol_buildpath('/hrm/skill_card.php', 1) . '?id=' . $id; |
|
629 | + $param_fk = "&fk_skill=".$id."&fk_user_creat=".(!empty($user->rowid) ? $user->rowid : 0); |
|
630 | + $backtopage = dol_buildpath('/hrm/skill_card.php', 1).'?id='.$id; |
|
631 | 631 | $param = ""; |
632 | 632 | $massactionbutton = ""; |
633 | 633 | //$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/hrm/skilldet_card.php', 1) . '?action=create&backtopage=' . urlencode($_SERVER['PHP_SELF']) . $param_fk . '&backtopage=' . $backtopage, '', $permissiontoadd); |
634 | 634 | |
635 | - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_' . $object->picto, 0, "", '', '', 0, 0, 1); |
|
635 | + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, "", '', '', 0, 0, 1); |
|
636 | 636 | |
637 | 637 | // Add code for pre mass action (confirmation or email presend form) |
638 | 638 | $topicmail = "SendSkilldetRef"; |
639 | 639 | $modelmail = "skilldet"; |
640 | 640 | $objecttmp = new Skilldet($db); |
641 | - $trackid = 'xxxx' . $object->id; |
|
641 | + $trackid = 'xxxx'.$object->id; |
|
642 | 642 | //include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; |
643 | 643 | |
644 | 644 | if ($search_all) { |
645 | 645 | foreach ($fieldstosearchall as $key => $val) { |
646 | 646 | $fieldstosearchall[$key] = $langs->trans($val); |
647 | 647 | } |
648 | - print '<div class="divsearchfieldfilter">' . $langs->trans("FilterOnInto", $search_all) . join(', ', $fieldstosearchall) . '</div>'; |
|
648 | + print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'; |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | $moreforfilter = ''; |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | // $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); |
673 | 673 | |
674 | 674 | print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table |
675 | - print '<table class="tagtable nobottomiftotal liste' . ($moreforfilter ? " listwithfilterbefore" : "") . '">' . "\n"; |
|
675 | + print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; |
|
676 | 676 | |
677 | 677 | |
678 | 678 | // Fields title label |
@@ -689,13 +689,13 @@ discard block |
||
689 | 689 | // } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { |
690 | 690 | // $cssforfield .= ($cssforfield ? ' ' : '') . 'right'; |
691 | 691 | // } |
692 | - if (!empty($arrayfields['t.' . $key]['checked'])) { |
|
693 | - print getTitleFieldOfList($arrayfields['t.' . $key]['label'], 0, $_SERVER['PHP_SELF'], 't.' . $key, '', $param, (!empty($cssforfield) ? 'class="' . $cssforfield . '"' : ''), $sortfield, $sortorder, (!empty($cssforfield) ? $cssforfield . ' ' : '')) . "\n"; |
|
692 | + if (!empty($arrayfields['t.'.$key]['checked'])) { |
|
693 | + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, (!empty($cssforfield) ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, (!empty($cssforfield) ? $cssforfield.' ' : ''))."\n"; |
|
694 | 694 | } |
695 | 695 | } |
696 | 696 | print '<td></td>'; |
697 | 697 | print '<td></td>'; |
698 | - print '</tr>' . "\n"; |
|
698 | + print '</tr>'."\n"; |
|
699 | 699 | |
700 | 700 | |
701 | 701 | // Display all ranks of skill |
@@ -738,14 +738,14 @@ discard block |
||
738 | 738 | // } |
739 | 739 | //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; |
740 | 740 | |
741 | - if (!empty($arrayfields['t.' . $key]['checked'])) { |
|
742 | - print '<td' . ($cssforfield ? ' class="' . $cssforfield . '"' : '') . '>'; |
|
741 | + if (!empty($arrayfields['t.'.$key]['checked'])) { |
|
742 | + print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>'; |
|
743 | 743 | if ($key == 'status') { |
744 | 744 | print $objectline->getLibStatut(5); |
745 | 745 | } elseif ($key == 'rowid') { |
746 | 746 | print $objectline->showOutputField($val, $key, $objectline->id, ''); |
747 | 747 | // ajout pencil |
748 | - print '<a class="timeline-btn" href="' . DOL_MAIN_URL_ROOT . '/comm/action/skilldet_card.php?action=edit&id=' . $objectline->id . '"><i class="fa fa-pencil" title="' . $langs->trans("Modify") . '" ></i></a>'; |
|
748 | + print '<a class="timeline-btn" href="'.DOL_MAIN_URL_ROOT.'/comm/action/skilldet_card.php?action=edit&id='.$objectline->id.'"><i class="fa fa-pencil" title="'.$langs->trans("Modify").'" ></i></a>'; |
|
749 | 749 | } else { |
750 | 750 | print $objectline->showOutputField($val, $key, $objectline->$key, ''); |
751 | 751 | } |
@@ -757,15 +757,15 @@ discard block |
||
757 | 757 | } |
758 | 758 | if (!empty($val['isameasure']) && $val['isameasure'] == 1) { |
759 | 759 | if (!$i) { |
760 | - $totalarray['pos'][$totalarray['nbfield']] = 't.' . $key; |
|
760 | + $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; |
|
761 | 761 | } |
762 | 762 | if (!isset($totalarray['val'])) { |
763 | 763 | $totalarray['val'] = array(); |
764 | 764 | } |
765 | - if (!isset($totalarray['val']['t.' . $key])) { |
|
766 | - $totalarray['val']['t.' . $key] = 0; |
|
765 | + if (!isset($totalarray['val']['t.'.$key])) { |
|
766 | + $totalarray['val']['t.'.$key] = 0; |
|
767 | 767 | } |
768 | - $totalarray['val']['t.' . $key] += $objectline->$key; |
|
768 | + $totalarray['val']['t.'.$key] += $objectline->$key; |
|
769 | 769 | } |
770 | 770 | } |
771 | 771 | } |
@@ -798,7 +798,7 @@ discard block |
||
798 | 798 | $totalarray['nbfield']++; |
799 | 799 | } |
800 | 800 | |
801 | - print '</tr>' . "\n"; |
|
801 | + print '</tr>'."\n"; |
|
802 | 802 | |
803 | 803 | $i++; |
804 | 804 | } |
@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | $colspan++; |
814 | 814 | } |
815 | 815 | } |
816 | - print '<tr><td colspan="' . $colspan . '"><span class="opacitymedium">' . $langs->trans("NoRecordFound") . '</span></td></tr>'; |
|
816 | + print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>'; |
|
817 | 817 | } |
818 | 818 | |
819 | 819 | if (!empty($resql)) $db->free($resql); |
@@ -822,10 +822,10 @@ discard block |
||
822 | 822 | $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $objectline); // Note that $action and $objectline may have been modified by hook |
823 | 823 | print $hookmanager->resPrint; |
824 | 824 | |
825 | - print '</table>' . "\n"; |
|
826 | - print '</div>' . "\n"; |
|
825 | + print '</table>'."\n"; |
|
826 | + print '</div>'."\n"; |
|
827 | 827 | |
828 | - print '</form>' . "\n"; |
|
828 | + print '</form>'."\n"; |
|
829 | 829 | |
830 | 830 | // if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { |
831 | 831 | // $hidegeneratedfilelistifempty = 1; |
@@ -860,9 +860,9 @@ discard block |
||
860 | 860 | $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/hrm/skill_agenda.php?id='.$object->id); |
861 | 861 | |
862 | 862 | // List of actions on element |
863 | - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; |
|
863 | + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; |
|
864 | 864 | $formactions = new FormActions($db); |
865 | - $somethingshown = $formactions->showactions($object, $object->element . '@' . $object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter); |
|
865 | + $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter); |
|
866 | 866 | |
867 | 867 | print '</div></div>'; |
868 | 868 | } |
@@ -89,8 +89,12 @@ discard block |
||
89 | 89 | //if ($user->socid > 0) $socid = $user->socid; |
90 | 90 | //$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); |
91 | 91 | //restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); |
92 | -if (empty($conf->hrm->enabled)) accessforbidden(); |
|
93 | -if (!$permissiontoread || ($action === 'create' && !$permissiontoadd)) accessforbidden(); |
|
92 | +if (empty($conf->hrm->enabled)) { |
|
93 | + accessforbidden(); |
|
94 | +} |
|
95 | +if (!$permissiontoread || ($action === 'create' && !$permissiontoadd)) { |
|
96 | + accessforbidden(); |
|
97 | +} |
|
94 | 98 | |
95 | 99 | $MaxNumberSkill = isset($conf->global->HRM_MAXRANK) ? $conf->global->HRM_MAXRANK : Skill::DEFAULT_MAX_RANK_PER_SKILL; |
96 | 100 | |
@@ -816,7 +820,9 @@ discard block |
||
816 | 820 | print '<tr><td colspan="' . $colspan . '"><span class="opacitymedium">' . $langs->trans("NoRecordFound") . '</span></td></tr>'; |
817 | 821 | } |
818 | 822 | |
819 | - if (!empty($resql)) $db->free($resql); |
|
823 | + if (!empty($resql)) { |
|
824 | + $db->free($resql); |
|
825 | + } |
|
820 | 826 | |
821 | 827 | $parameters = array('arrayfields' => $arrayfields, 'sql' => $sql); |
822 | 828 | $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $objectline); // Note that $action and $objectline may have been modified by hook |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | // Default sort order (if not yet defined by previous GETPOST) |
86 | 86 | if (!$sortfield) { |
87 | - reset($object->fields); // Reset is required to avoid key() to return null. |
|
87 | + reset($object->fields); // Reset is required to avoid key() to return null. |
|
88 | 88 | $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. |
89 | 89 | } |
90 | 90 | if (!$sortorder) { |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | $sql .= $object->getFieldList('t'); |
222 | 222 | $sql .= ','; |
223 | 223 | $sql .= $userstatic->getFieldList('u', array('rowid')); |
224 | -$sql .= ', u.email, u.statut, u.photo, u.login'; // Add more field not yet into the user->fields |
|
224 | +$sql .= ', u.email, u.statut, u.photo, u.login'; // Add more field not yet into the user->fields |
|
225 | 225 | $sql .= ', j.rowid as job_id, j.label as job_label'; |
226 | 226 | // Add fields from extrafields |
227 | 227 | if (!empty($extrafields->attributes[$object->table_element]['label'])) { |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | } |
266 | 266 | } else { |
267 | 267 | if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') { |
268 | - $columnName=preg_replace('/(_dtstart|_dtend)$/', '', $key); |
|
268 | + $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key); |
|
269 | 269 | if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) { |
270 | 270 | if (preg_match('/_dtstart$/', $key)) { |
271 | 271 | $sql .= " AND t.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'"; |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { |
565 | 565 | $cssforfield .= ($cssforfield ? ' ' : '').'right'; |
566 | 566 | } |
567 | - $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label |
|
567 | + $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label |
|
568 | 568 | if (!empty($arrayfields['t.'.$key]['checked'])) { |
569 | 569 | print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; |
570 | 570 | $totalarray['nbfield']++; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | $dateendvalidity = dol_mktime(0, 0, 0, GETPOST('dateendvaliditymonth', 'int'), GETPOST('dateendvalidityday', 'int'), GETPOST('dateendvalidityyear', 'int')); |
85 | 85 | $dateofbirth = dol_mktime(0, 0, 0, GETPOST('dateofbirthmonth', 'int'), GETPOST('dateofbirthday', 'int'), GETPOST('dateofbirthyear', 'int')); |
86 | 86 | |
87 | -$childids = $user->getAllChildIds(1); // For later, test on salary visibility |
|
87 | +$childids = $user->getAllChildIds(1); // For later, test on salary visibility |
|
88 | 88 | |
89 | 89 | $object = new User($db); |
90 | 90 | $extrafields = new ExtraFields($db); |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | // Define value to know what current user can do on users |
117 | 117 | $canadduser = (!empty($user->admin) || $user->hasRight("user", "user", "write")); |
118 | 118 | $canreaduser = (!empty($user->admin) || $user->hasRight("user", "user", "read")); |
119 | -$canedituser = (!empty($user->admin) || $user->hasRight("user", "user", "write")); // edit other user |
|
119 | +$canedituser = (!empty($user->admin) || $user->hasRight("user", "user", "write")); // edit other user |
|
120 | 120 | $candisableuser = (!empty($user->admin) || $user->hasRight("user", "user", "delete")); |
121 | 121 | $canreadgroup = $canreaduser; |
122 | 122 | $caneditgroup = $canedituser; |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | } |
442 | 442 | $object->gender = GETPOST("gender", 'aZ09'); |
443 | 443 | if ($caneditpasswordandsee) { |
444 | - $object->pass = GETPOST("password", 'none'); // We can keep 'none' for password fields |
|
444 | + $object->pass = GETPOST("password", 'none'); // We can keep 'none' for password fields |
|
445 | 445 | } |
446 | 446 | if ($caneditpasswordandsee || $user->hasRight("api", "apikey", "generate")) { |
447 | 447 | $object->api_key = (GETPOST("api_key", 'alphanohtml')) ? GETPOST("api_key", 'alphanohtml') : $object->api_key; |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | } |
550 | 550 | } |
551 | 551 | |
552 | - $ret = $object->update($user); // This may include call to setPassword if password has changed |
|
552 | + $ret = $object->update($user); // This may include call to setPassword if password has changed |
|
553 | 553 | if ($ret < 0) { |
554 | 554 | $error++; |
555 | 555 | if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { |
@@ -678,7 +678,7 @@ discard block |
||
678 | 678 | ) { |
679 | 679 | $object->fetch($id); |
680 | 680 | |
681 | - $newpassword = $object->setPassword($user, ''); // This will generate a new password |
|
681 | + $newpassword = $object->setPassword($user, ''); // This will generate a new password |
|
682 | 682 | if ($newpassword < 0) { |
683 | 683 | // Echec |
684 | 684 | setEventMessages($langs->trans("ErrorFailedToSetNewPassword"), null, 'errors'); |
@@ -1906,7 +1906,7 @@ discard block |
||
1906 | 1906 | print '<td>'; |
1907 | 1907 | if (!empty($object->api_key)) { |
1908 | 1908 | print '<span class="opacitymedium">'; |
1909 | - print showValueWithClipboardCPButton($object->api_key, 1, $langs->trans("Hidden")); // TODO Add an option to also reveal the hash, not only copy paste |
|
1909 | + print showValueWithClipboardCPButton($object->api_key, 1, $langs->trans("Hidden")); // TODO Add an option to also reveal the hash, not only copy paste |
|
1910 | 1910 | print '</span>'; |
1911 | 1911 | } |
1912 | 1912 | print '</td></tr>'; |
@@ -1958,7 +1958,7 @@ discard block |
||
1958 | 1958 | $langs->load("mails"); |
1959 | 1959 | $params['attr']['title'] = $langs->trans('NoEMail'); |
1960 | 1960 | } |
1961 | - print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle', '', $canSendMail, $params); |
|
1961 | + print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle', '', $canSendMail, $params); |
|
1962 | 1962 | } |
1963 | 1963 | |
1964 | 1964 | if ($caneditfield && (!isModEnabled('multicompany') || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) { |
@@ -2024,12 +2024,12 @@ discard block |
||
2024 | 2024 | ); |
2025 | 2025 | if ($user->id <> $id && $candisableuser && $object->statut == 0 && |
2026 | 2026 | ((!isModEnabled('multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) { |
2027 | - print dolGetButtonAction($langs->trans('Reactivate'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=enable&token='.newToken(), '', true, $params); |
|
2027 | + print dolGetButtonAction($langs->trans('Reactivate'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=enable&token='.newToken(), '', true, $params); |
|
2028 | 2028 | } |
2029 | 2029 | // Disable user |
2030 | 2030 | if ($user->id <> $id && $candisableuser && $object->statut == 1 && |
2031 | 2031 | ((!isModEnabled('multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) { |
2032 | - print dolGetButtonAction($langs->trans('DisableUser'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=disable&token='.newToken(), '', true, $params); |
|
2032 | + print dolGetButtonAction($langs->trans('DisableUser'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=disable&token='.newToken(), '', true, $params); |
|
2033 | 2033 | } else { |
2034 | 2034 | if ($user->id == $id) { |
2035 | 2035 | $params['attr']['title'] = $langs->trans('CantDisableYourself'); |
@@ -2616,7 +2616,7 @@ discard block |
||
2616 | 2616 | print '<span class="fa '.$value['icon'].' pictofixedwidth"></span>'; |
2617 | 2617 | } |
2618 | 2618 | if ($caneditfield && empty($object->ldap_sid)) { |
2619 | - print '<input type="text" name="'.$key.'" class="flat maxwidth200" value="'.(isset($object->socialnetworks[$key])?$object->socialnetworks[$key]:'').'">'; |
|
2619 | + print '<input type="text" name="'.$key.'" class="flat maxwidth200" value="'.(isset($object->socialnetworks[$key]) ? $object->socialnetworks[$key] : '').'">'; |
|
2620 | 2620 | } else { |
2621 | 2621 | print '<input type="hidden" name="'.$key.'" value="'.$object->socialnetworks[$key].'">'; |
2622 | 2622 | print $object->socialnetworks[$key]; |
@@ -2624,7 +2624,7 @@ discard block |
||
2624 | 2624 | print '</td></tr>'; |
2625 | 2625 | } else { |
2626 | 2626 | // if social network is not active but value exist we do not want to loose it |
2627 | - print '<input type="hidden" name="'.$key.'" value="'.(isset($object->socialnetworks[$key])?$object->socialnetworks[$key]:'').'">'; |
|
2627 | + print '<input type="hidden" name="'.$key.'" value="'.(isset($object->socialnetworks[$key]) ? $object->socialnetworks[$key] : '').'">'; |
|
2628 | 2628 | } |
2629 | 2629 | } |
2630 | 2630 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * \remarks To run this script as CLI: phpunit filename.php |
25 | 25 | */ |
26 | 26 | |
27 | -global $conf,$user,$langs,$db; |
|
27 | +global $conf, $user, $langs, $db; |
|
28 | 28 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
29 | 29 | //require_once 'PHPUnit/Autoload.php'; |
30 | 30 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | $user->fetch(1); |
38 | 38 | $user->getrights(); |
39 | 39 | } |
40 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
41 | -$conf->global->MAIN_UMASK='0666'; |
|
40 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
41 | +$conf->global->MAIN_UMASK = '0666'; |
|
42 | 42 | |
43 | 43 | |
44 | 44 | /** |
@@ -69,11 +69,11 @@ discard block |
||
69 | 69 | parent::__construct($name); |
70 | 70 | |
71 | 71 | //$this->sharedFixture |
72 | - global $conf,$user,$langs,$db; |
|
73 | - $this->savconf=$conf; |
|
74 | - $this->savuser=$user; |
|
75 | - $this->savlangs=$langs; |
|
76 | - $this->savdb=$db; |
|
72 | + global $conf, $user, $langs, $db; |
|
73 | + $this->savconf = $conf; |
|
74 | + $this->savuser = $user; |
|
75 | + $this->savlangs = $langs; |
|
76 | + $this->savdb = $db; |
|
77 | 77 | |
78 | 78 | if (!isModEnabled('api')) { |
79 | 79 | print __METHOD__." module api must be enabled.\n"; die(1); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public static function setUpBeforeClass(): void |
93 | 93 | { |
94 | - global $conf,$user,$langs,$db; |
|
94 | + global $conf, $user, $langs, $db; |
|
95 | 95 | $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
96 | 96 | |
97 | 97 | print __METHOD__."\n"; |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public static function tearDownAfterClass(): void |
106 | 106 | { |
107 | - global $conf,$user,$langs,$db; |
|
107 | + global $conf, $user, $langs, $db; |
|
108 | 108 | $db->rollback(); |
109 | 109 | |
110 | 110 | print __METHOD__."\n"; |
@@ -117,24 +117,24 @@ discard block |
||
117 | 117 | */ |
118 | 118 | protected function setUp(): void |
119 | 119 | { |
120 | - global $conf,$user,$langs,$db; |
|
121 | - $conf=$this->savconf; |
|
122 | - $user=$this->savuser; |
|
123 | - $langs=$this->savlangs; |
|
124 | - $db=$this->savdb; |
|
120 | + global $conf, $user, $langs, $db; |
|
121 | + $conf = $this->savconf; |
|
122 | + $user = $this->savuser; |
|
123 | + $langs = $this->savlangs; |
|
124 | + $db = $this->savdb; |
|
125 | 125 | |
126 | 126 | $this->api_url = DOL_MAIN_URL_ROOT.'/api/index.php'; |
127 | 127 | |
128 | - $login='admin'; |
|
129 | - $password='admin'; |
|
130 | - $url=$this->api_url.'/login?login='.$login.'&password='.$password; |
|
128 | + $login = 'admin'; |
|
129 | + $password = 'admin'; |
|
130 | + $url = $this->api_url.'/login?login='.$login.'&password='.$password; |
|
131 | 131 | // Call the API login method to save api_key for this test class. |
132 | 132 | // At first call, if token is not defined a random value is generated and returned. |
133 | - $result=getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); |
|
133 | + $result = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); |
|
134 | 134 | print __METHOD__." result = ".var_export($result, true)."\n"; |
135 | 135 | print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; |
136 | 136 | $this->assertEquals($result['curl_error_no'], ''); |
137 | - $object = json_decode($result['content'], true); // If success content is just an id, if not an array |
|
137 | + $object = json_decode($result['content'], true); // If success content is just an id, if not an array |
|
138 | 138 | |
139 | 139 | $this->assertNotNull($object, "Parsing of json result must not be null"); |
140 | 140 | $this->assertNotEquals(500, (empty($object['error']['code']) ? 0 : $object['error']['code']), 'Error'.(empty($object['error']['message']) ? '' : ' '.$object['error']['message'])); |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | */ |
164 | 164 | public function testRestGetContact() |
165 | 165 | { |
166 | - global $conf,$user,$langs,$db; |
|
166 | + global $conf, $user, $langs, $db; |
|
167 | 167 | //fetch Non-Existent contact |
168 | 168 | $url = $this->api_url.'/contacts/123456789?api_key='.$this->api_key; |
169 | 169 | //$addheaders=array('Content-Type: application/json'); |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | print __METHOD__." result for get on unexisting contact: ".var_export($result, true)."\n"; |
174 | 174 | print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; |
175 | 175 | $this->assertEquals($result['curl_error_no'], ''); |
176 | - $object=json_decode($result['content'], true); |
|
176 | + $object = json_decode($result['content'], true); |
|
177 | 177 | $this->assertNotNull($object, "Parsing of json result must not be null"); |
178 | 178 | $this->assertEquals(404, $object['error']['code'], 'Error code is not 404'); |
179 | 179 | |
@@ -181,11 +181,11 @@ discard block |
||
181 | 181 | $url = $this->api_url.'/contacts/1?api_key='.$this->api_key; |
182 | 182 | |
183 | 183 | print __METHOD__." Request GET url=".$url."\n"; |
184 | - $result=getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); |
|
184 | + $result = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); |
|
185 | 185 | print __METHOD__." result for get on an existing contact: ".var_export($result, true)."\n"; |
186 | 186 | print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; |
187 | 187 | $this->assertEquals($result['curl_error_no'], ''); |
188 | - $object=json_decode($result['content'], true); |
|
188 | + $object = json_decode($result['content'], true); |
|
189 | 189 | $this->assertNotNull($object, "Parsing of json result must not be null"); |
190 | 190 | $this->assertEquals(1, $object['statut']); |
191 | 191 | } |
@@ -200,23 +200,23 @@ discard block |
||
200 | 200 | */ |
201 | 201 | public function testRestCreateContact() |
202 | 202 | { |
203 | - global $conf,$user,$langs,$db; |
|
203 | + global $conf, $user, $langs, $db; |
|
204 | 204 | // attempt to create without mandatory fields |
205 | 205 | $url = $this->api_url.'/contacts?api_key='.$this->api_key; |
206 | - $addheaders=array('Content-Type: application/json'); |
|
206 | + $addheaders = array('Content-Type: application/json'); |
|
207 | 207 | |
208 | - $bodyobj= array( |
|
208 | + $bodyobj = array( |
|
209 | 209 | "firstname" => "firstname" |
210 | 210 | ); |
211 | 211 | |
212 | 212 | $body = json_encode($bodyobj); |
213 | 213 | |
214 | 214 | //print __METHOD__." Request POST url=".$url."\n"; |
215 | - $result=getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2); |
|
215 | + $result = getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2); |
|
216 | 216 | //print __METHOD__." Result for creating incomplete contact".var_export($result, true)."\n"; |
217 | 217 | //print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; |
218 | 218 | $this->assertEquals($result['curl_error_no'], ''); |
219 | - $object = json_decode($result['content'], true); // If success content is just an id, if not an array |
|
219 | + $object = json_decode($result['content'], true); // If success content is just an id, if not an array |
|
220 | 220 | $this->assertNotNull($object, "Parsing of json result must no be null"); |
221 | 221 | $this->assertEquals(400, (empty($object['error']['code']) ? 0 : $object['error']['code']), 'Error'.(empty($object['error']['message']) ? '' : ' '.$object['error']['message'])); |
222 | 222 | |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | unset($result); |
227 | 227 | // Creating a Contact |
228 | 228 | $bodyobj = array( |
229 | - "firstname" => "testRestContact" . mt_rand(), |
|
229 | + "firstname" => "testRestContact".mt_rand(), |
|
230 | 230 | "lastname" => "testRestContact", |
231 | 231 | ); |
232 | 232 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | |
237 | 237 | $this->assertEquals($result['curl_error_no'], ''); |
238 | 238 | |
239 | - $object = json_decode($result['content'], true); // If success content is just an id, if not an array |
|
239 | + $object = json_decode($result['content'], true); // If success content is just an id, if not an array |
|
240 | 240 | $this->assertNotNull($object, "Parsing of json result must not be null"); |
241 | 241 | $this->assertNotEquals(500, (empty($object['error']['code']) ? 0 : $object['error']['code']), 'Error'.(empty($object['error']['message']) ? '' : ' '.$object['error']['message'])); |
242 | 242 | $this->assertGreaterThan(0, $object, 'ID return is no > 0'); |
@@ -255,10 +255,10 @@ discard block |
||
255 | 255 | */ |
256 | 256 | public function testRestUpdateContact($objid) |
257 | 257 | { |
258 | - global $conf,$user,$langs,$db; |
|
258 | + global $conf, $user, $langs, $db; |
|
259 | 259 | // attempt to create without mandatory fields |
260 | 260 | $url = $this->api_url.'/contacts?api_key='.$this->api_key; |
261 | - $addheaders=array('Content-Type: application/json'); |
|
261 | + $addheaders = array('Content-Type: application/json'); |
|
262 | 262 | |
263 | 263 | //update the contact |
264 | 264 | |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | ); |
269 | 269 | |
270 | 270 | $updateRequestBody = json_encode($updateBody); |
271 | - $updateUrl = $this->api_url . '/contacts/' . $objid. '?api_key=' . $this->api_key; |
|
271 | + $updateUrl = $this->api_url.'/contacts/'.$objid.'?api_key='.$this->api_key; |
|
272 | 272 | $updateResult = getURLContent($updateUrl, 'PUTALREADYFORMATED', $updateRequestBody, 1, $addheaders, array('http', 'https'), 2); |
273 | 273 | $this->assertEquals($updateResult['curl_error_no'], ''); |
274 | 274 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * \remarks To run this script as CLI: phpunit filename.php |
25 | 25 | */ |
26 | 26 | |
27 | -global $conf,$user,$langs,$db; |
|
27 | +global $conf, $user, $langs, $db; |
|
28 | 28 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
29 | 29 | //require_once 'PHPUnit/Autoload.php'; |
30 | 30 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | $user->fetch(1); |
38 | 38 | $user->getrights(); |
39 | 39 | } |
40 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
41 | -$conf->global->MAIN_UMASK='0666'; |
|
40 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
41 | +$conf->global->MAIN_UMASK = '0666'; |
|
42 | 42 | |
43 | 43 | |
44 | 44 | /** |
@@ -69,11 +69,11 @@ discard block |
||
69 | 69 | parent::__construct($name); |
70 | 70 | |
71 | 71 | //$this->sharedFixture |
72 | - global $conf,$user,$langs,$db; |
|
73 | - $this->savconf=$conf; |
|
74 | - $this->savuser=$user; |
|
75 | - $this->savlangs=$langs; |
|
76 | - $this->savdb=$db; |
|
72 | + global $conf, $user, $langs, $db; |
|
73 | + $this->savconf = $conf; |
|
74 | + $this->savuser = $user; |
|
75 | + $this->savlangs = $langs; |
|
76 | + $this->savdb = $db; |
|
77 | 77 | |
78 | 78 | if (!isModEnabled('api')) { |
79 | 79 | print __METHOD__." module api must be enabled.\n"; die(1); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public static function setUpBeforeClass(): void |
93 | 93 | { |
94 | - global $conf,$user,$langs,$db; |
|
94 | + global $conf, $user, $langs, $db; |
|
95 | 95 | $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
96 | 96 | |
97 | 97 | print __METHOD__."\n"; |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public static function tearDownAfterClass(): void |
106 | 106 | { |
107 | - global $conf,$user,$langs,$db; |
|
107 | + global $conf, $user, $langs, $db; |
|
108 | 108 | $db->rollback(); |
109 | 109 | |
110 | 110 | print __METHOD__."\n"; |
@@ -117,24 +117,24 @@ discard block |
||
117 | 117 | */ |
118 | 118 | protected function setUp(): void |
119 | 119 | { |
120 | - global $conf,$user,$langs,$db; |
|
121 | - $conf=$this->savconf; |
|
122 | - $user=$this->savuser; |
|
123 | - $langs=$this->savlangs; |
|
124 | - $db=$this->savdb; |
|
120 | + global $conf, $user, $langs, $db; |
|
121 | + $conf = $this->savconf; |
|
122 | + $user = $this->savuser; |
|
123 | + $langs = $this->savlangs; |
|
124 | + $db = $this->savdb; |
|
125 | 125 | |
126 | 126 | $this->api_url = DOL_MAIN_URL_ROOT.'/api/index.php'; |
127 | 127 | |
128 | - $login='admin'; |
|
129 | - $password='admin'; |
|
130 | - $url=$this->api_url.'/login?login='.$login.'&password='.$password; |
|
128 | + $login = 'admin'; |
|
129 | + $password = 'admin'; |
|
130 | + $url = $this->api_url.'/login?login='.$login.'&password='.$password; |
|
131 | 131 | // Call the API login method to save api_key for this test class. |
132 | 132 | // At first call, if token is not defined a random value is generated and returned. |
133 | - $result=getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); |
|
133 | + $result = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); |
|
134 | 134 | print __METHOD__." result = ".var_export($result, true)."\n"; |
135 | 135 | print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; |
136 | 136 | $this->assertEquals($result['curl_error_no'], ''); |
137 | - $object = json_decode($result['content'], true); // If success content is just an id, if not an array |
|
137 | + $object = json_decode($result['content'], true); // If success content is just an id, if not an array |
|
138 | 138 | |
139 | 139 | $this->assertNotNull($object, "Parsing of json result must not be null"); |
140 | 140 | $this->assertNotEquals(500, (empty($object['error']['code']) ? 0 : $object['error']['code']), 'Error'.(empty($object['error']['message']) ? '' : ' '.$object['error']['message'])); |
@@ -163,28 +163,28 @@ discard block |
||
163 | 163 | */ |
164 | 164 | public function testRestGetUser() |
165 | 165 | { |
166 | - global $conf,$user,$langs,$db; |
|
166 | + global $conf, $user, $langs, $db; |
|
167 | 167 | |
168 | 168 | $url = $this->api_url.'/users/123456789?api_key='.$this->api_key; |
169 | 169 | //$addheaders=array('Content-Type: application/json'); |
170 | 170 | |
171 | 171 | print __METHOD__." Request GET url=".$url."\n"; |
172 | - $result=getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); |
|
172 | + $result = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); |
|
173 | 173 | //print __METHOD__." result for get on unexisting user: ".var_export($result, true)."\n"; |
174 | 174 | print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; |
175 | 175 | $this->assertEquals($result['curl_error_no'], ''); |
176 | - $object=json_decode($result['content'], true); |
|
176 | + $object = json_decode($result['content'], true); |
|
177 | 177 | $this->assertNotNull($object, "Parsing of json result must not be null"); |
178 | 178 | $this->assertEquals(404, (empty($object['error']['code']) ? 0 : $object['error']['code']), 'Error code is not 404'); |
179 | 179 | |
180 | 180 | $url = $this->api_url.'/users/1?api_key='.$this->api_key; |
181 | 181 | |
182 | 182 | print __METHOD__." Request GET url=".$url."\n"; |
183 | - $result=getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); |
|
183 | + $result = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); |
|
184 | 184 | print __METHOD__." result for get on an existing user: ".var_export($result, true)."\n"; |
185 | 185 | print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; |
186 | 186 | $this->assertEquals($result['curl_error_no'], ''); |
187 | - $object=json_decode($result['content'], true); |
|
187 | + $object = json_decode($result['content'], true); |
|
188 | 188 | $this->assertNotNull($object, "Parsing of json result must not be null"); |
189 | 189 | $this->assertEquals(1, $object['statut']); |
190 | 190 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | { |
204 | 204 | // attemp to create without mandatory fields : |
205 | 205 | $url = $this->api_url.'/users?api_key='.$this->api_key; |
206 | - $addheaders=array('Content-Type: application/json'); |
|
206 | + $addheaders = array('Content-Type: application/json'); |
|
207 | 207 | |
208 | 208 | $bodyobj = array( |
209 | 209 | "lastname"=>"testRestUser", |
@@ -213,11 +213,11 @@ discard block |
||
213 | 213 | $body = json_encode($bodyobj); |
214 | 214 | |
215 | 215 | print __METHOD__." Request POST url=".$url."\n"; |
216 | - $result=getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2); |
|
216 | + $result = getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2); |
|
217 | 217 | //print __METHOD__." Result for creating incomplete user".var_export($result, true)."\n"; |
218 | 218 | print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; |
219 | 219 | $this->assertEquals($result['curl_error_no'], ''); |
220 | - $object=json_decode($result['content'], true); |
|
220 | + $object = json_decode($result['content'], true); |
|
221 | 221 | $this->assertNotNull($object, "Parsing of json result must no be null"); |
222 | 222 | $this->assertEquals(500, (empty($object['error']['code']) ? 0 : $object['error']['code']), 'Error'.(empty($object['error']['message']) ? '' : ' '.$object['error']['message'])); |
223 | 223 | |
@@ -231,11 +231,11 @@ discard block |
||
231 | 231 | ); |
232 | 232 | $body = json_encode($bodyobj); |
233 | 233 | print __METHOD__." Request POST url=".$url."\n"; |
234 | - $result=getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2); |
|
234 | + $result = getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2); |
|
235 | 235 | print __METHOD__." result code for creating non existing user = ".var_export($result, true)."\n"; |
236 | 236 | print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; |
237 | 237 | $this->assertEquals($result['curl_error_no'], ''); |
238 | - $object = json_decode($result['content'], true); // If success content is just an id, if not an array |
|
238 | + $object = json_decode($result['content'], true); // If success content is just an id, if not an array |
|
239 | 239 | |
240 | 240 | $this->assertNotNull($object, "Parsing of json result must no be null"); |
241 | 241 | $this->assertNotEquals(500, ((is_scalar($object) || empty($object['error']) || empty($object['error']['code'])) ? 0 : $object['error']['code']), 'Error'.(empty($object['error']['message']) ? '' : ' '.$object['error']['message'])); |
@@ -243,11 +243,11 @@ discard block |
||
243 | 243 | |
244 | 244 | // attempt to create duplicated user |
245 | 245 | print __METHOD__." Request POST url=".$url."\n"; |
246 | - $result=getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2); |
|
246 | + $result = getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2); |
|
247 | 247 | //print __METHOD__." Result for creating duplicate user".var_export($result, true)."\n"; |
248 | 248 | print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; |
249 | 249 | $this->assertEquals($result['curl_error_no'], ''); |
250 | - $object=json_decode($result['content'], true); |
|
250 | + $object = json_decode($result['content'], true); |
|
251 | 251 | $this->assertNotNull($object, "Parsing of json result must no be null"); |
252 | 252 | $this->assertEquals(500, (empty($object['error']['code']) ? 0 : $object['error']['code']), 'Error'.(empty($object['error']['message']) ? '' : ' '.$object['error']['message'])); |
253 | 253 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \brief PHPUnit test |
24 | 24 | * \remarks To run this script as CLI: phpunit filename.php. |
25 | 25 | */ |
26 | -global $conf,$user,$langs,$db; |
|
26 | +global $conf, $user, $langs, $db; |
|
27 | 27 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | parent::__construct($name); |
68 | 68 | |
69 | 69 | //$this->sharedFixture |
70 | - global $conf,$user,$langs,$db; |
|
70 | + global $conf, $user, $langs, $db; |
|
71 | 71 | $this->savconf = $conf; |
72 | 72 | $this->savuser = $user; |
73 | 73 | $this->savlangs = $langs; |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public static function setUpBeforeClass(): void |
87 | 87 | { |
88 | - global $conf,$user,$langs,$db; |
|
88 | + global $conf, $user, $langs, $db; |
|
89 | 89 | $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
90 | 90 | |
91 | 91 | echo __METHOD__."\n"; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | */ |
99 | 99 | public static function tearDownAfterClass(): void |
100 | 100 | { |
101 | - global $conf,$user,$langs,$db; |
|
101 | + global $conf, $user, $langs, $db; |
|
102 | 102 | $db->rollback(); |
103 | 103 | |
104 | 104 | echo __METHOD__."\n"; |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | protected function setUp(): void |
113 | 113 | { |
114 | - global $conf,$user,$langs,$db; |
|
114 | + global $conf, $user, $langs, $db; |
|
115 | 115 | $conf = $this->savconf; |
116 | 116 | $user = $this->savuser; |
117 | 117 | $langs = $this->savlangs; |
@@ -119,16 +119,16 @@ discard block |
||
119 | 119 | |
120 | 120 | $this->api_url = DOL_MAIN_URL_ROOT.'/api/index.php'; |
121 | 121 | |
122 | - $login='admin'; |
|
123 | - $password='admin'; |
|
124 | - $url=$this->api_url.'/login?login='.$login.'&password='.$password; |
|
122 | + $login = 'admin'; |
|
123 | + $password = 'admin'; |
|
124 | + $url = $this->api_url.'/login?login='.$login.'&password='.$password; |
|
125 | 125 | // Call the API login method to save api_key for this test class. |
126 | 126 | // At first call, if token is not defined a random value is generated and returned. |
127 | - $result=getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); |
|
127 | + $result = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); |
|
128 | 128 | print __METHOD__." result = ".var_export($result, true)."\n"; |
129 | 129 | print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; |
130 | 130 | $this->assertEquals($result['curl_error_no'], ''); |
131 | - $object = json_decode($result['content'], true); // If success content is just an id, if not an array |
|
131 | + $object = json_decode($result['content'], true); // If success content is just an id, if not an array |
|
132 | 132 | |
133 | 133 | $this->assertNotNull($object, "Parsing of json result must not be null"); |
134 | 134 | $this->assertNotEquals(500, (empty($object['error']['code']) ? 0 : $object['error']['code']), 'Error'.(empty($object['error']['message']) ? '' : ' '.$object['error']['message'])); |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public function testPushDocument() |
158 | 158 | { |
159 | - global $conf,$user,$langs,$db; |
|
159 | + global $conf, $user, $langs, $db; |
|
160 | 160 | |
161 | 161 | $url = $this->api_url.'/documents/upload?api_key='.$this->api_key; |
162 | 162 |