@@ -20,7 +20,9 @@ discard block |
||
20 | 20 | * \brief File that is entry point to call Dolibarr WebServices |
21 | 21 | */ |
22 | 22 | |
23 | -if (!defined("NOCSRFCHECK")) define("NOCSRFCHECK", '1'); |
|
23 | +if (!defined("NOCSRFCHECK")) { |
|
24 | + define("NOCSRFCHECK", '1'); |
|
25 | +} |
|
24 | 26 | |
25 | 27 | require '../master.inc.php'; |
26 | 28 | require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP |
@@ -149,7 +151,9 @@ discard block |
||
149 | 151 | |
150 | 152 | dol_syslog("Function: getVersions login=".$authentication['login']); |
151 | 153 | |
152 | - if ($authentication['entity']) $conf->entity = $authentication['entity']; |
|
154 | + if ($authentication['entity']) { |
|
155 | + $conf->entity = $authentication['entity']; |
|
156 | + } |
|
153 | 157 | |
154 | 158 | // Init and check authentication |
155 | 159 | $objectresp = array(); |
@@ -192,7 +196,9 @@ discard block |
||
192 | 196 | |
193 | 197 | dol_syslog("Function: getDocument login=".$authentication['login'].' - modulepart='.$modulepart.' - file='.$file); |
194 | 198 | |
195 | - if ($authentication['entity']) $conf->entity = $authentication['entity']; |
|
199 | + if ($authentication['entity']) { |
|
200 | + $conf->entity = $authentication['entity']; |
|
201 | + } |
|
196 | 202 | |
197 | 203 | $objectresp = array(); |
198 | 204 | $errorcode = ''; $errorlabel = ''; |
@@ -208,7 +214,9 @@ discard block |
||
208 | 214 | |
209 | 215 | $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); |
210 | 216 | |
211 | - if ($fuser->societe_id) $socid = $fuser->societe_id; |
|
217 | + if ($fuser->societe_id) { |
|
218 | + $socid = $fuser->societe_id; |
|
219 | + } |
|
212 | 220 | |
213 | 221 | // Check parameters |
214 | 222 | if (!$error && (!$file || !$modulepart)) |
@@ -225,7 +233,9 @@ discard block |
||
225 | 233 | $original_file = str_replace("../", "/", $original_file); |
226 | 234 | |
227 | 235 | // find the subdirectory name as the reference |
228 | - if (empty($refname)) $refname = basename(dirname($original_file)."/"); |
|
236 | + if (empty($refname)) { |
|
237 | + $refname = basename(dirname($original_file)."/"); |
|
238 | + } |
|
229 | 239 | |
230 | 240 | // Security check |
231 | 241 | $check_access = dol_check_secure_access_document($modulepart, $original_file, $conf->entity, $fuser, $refname); |
@@ -303,8 +313,7 @@ discard block |
||
303 | 313 | 'result'=>array('result_code'=>'OK', 'result_label'=>''), |
304 | 314 | 'document'=>$objectret |
305 | 315 | ); |
306 | - } |
|
307 | - else { |
|
316 | + } else { |
|
308 | 317 | dol_syslog("File doesn't exist ".$original_file); |
309 | 318 | $errorcode = 'NOT_FOUND'; |
310 | 319 | $errorlabel = ''; |
@@ -26,14 +26,25 @@ discard block |
||
26 | 26 | // This script is called with a POST method. |
27 | 27 | // Directory to scan (full path) is inside POST['dir'] and encode by js escape() if ajax is used or encoded by urlencode if mode=noajax |
28 | 28 | |
29 | -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal |
|
30 | -if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); |
|
31 | -if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); |
|
32 | -if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
29 | +if (!defined('NOTOKENRENEWAL')) { |
|
30 | + define('NOTOKENRENEWAL', 1); |
|
31 | +} |
|
32 | +// Disables token renewal |
|
33 | +if (!defined('NOREQUIREMENU')) { |
|
34 | + define('NOREQUIREMENU', '1'); |
|
35 | +} |
|
36 | +if (!defined('NOREQUIREHTML')) { |
|
37 | + define('NOREQUIREHTML', '1'); |
|
38 | +} |
|
39 | +if (!defined('NOREQUIREAJAX')) { |
|
40 | + define('NOREQUIREAJAX', '1'); |
|
41 | +} |
|
33 | 42 | |
34 | -if (!isset($mode) || $mode != 'noajax') // For ajax call |
|
43 | +if (!isset($mode) || $mode != 'noajax') { |
|
44 | + // For ajax call |
|
35 | 45 | { |
36 | 46 | $res = @include '../../main.inc.php'; |
47 | +} |
|
37 | 48 | include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
38 | 49 | include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
39 | 50 | include_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; |
@@ -48,7 +59,10 @@ discard block |
||
48 | 59 | |
49 | 60 | $preopened = GETPOST('preopened'); |
50 | 61 | |
51 | - if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/', '', $selecteddir); // We removed last '/' except if it is '/' |
|
62 | + if ($selecteddir != '/') { |
|
63 | + $selecteddir = preg_replace('/\/$/', '', $selecteddir); |
|
64 | + } |
|
65 | + // We removed last '/' except if it is '/' |
|
52 | 66 | } else // For no ajax call |
53 | 67 | { |
54 | 68 | //if (GETPOST('preopened')) { $_GET['dir'] = $_POST['dir'] = GETPOST('preopened'); } |
@@ -59,9 +73,14 @@ discard block |
||
59 | 73 | |
60 | 74 | $preopened = GETPOST('preopened'); |
61 | 75 | |
62 | - if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/', '', $selecteddir); // We removed last '/' except if it is '/' |
|
63 | - if (empty($url)) $url = DOL_URL_ROOT.'/ecm/index.php'; |
|
64 | -} |
|
76 | + if ($selecteddir != '/') { |
|
77 | + $selecteddir = preg_replace('/\/$/', '', $selecteddir); |
|
78 | + } |
|
79 | + // We removed last '/' except if it is '/' |
|
80 | + if (empty($url)) { |
|
81 | + $url = DOL_URL_ROOT.'/ecm/index.php'; |
|
82 | + } |
|
83 | + } |
|
65 | 84 | |
66 | 85 | // Load translation files required by the page |
67 | 86 | $langs->load("ecm"); |
@@ -92,8 +111,10 @@ discard block |
||
92 | 111 | // Check permissions |
93 | 112 | if ($modulepart == 'ecm') |
94 | 113 | { |
95 | - if (!$user->rights->ecm->read) accessforbidden(); |
|
96 | -} elseif ($modulepart == 'medias') |
|
114 | + if (!$user->rights->ecm->read) { |
|
115 | + accessforbidden(); |
|
116 | + } |
|
117 | + } elseif ($modulepart == 'medias') |
|
97 | 118 | { |
98 | 119 | // Always allowed |
99 | 120 | } |
@@ -103,10 +124,12 @@ discard block |
||
103 | 124 | * View |
104 | 125 | */ |
105 | 126 | |
106 | -if (!isset($mode) || $mode != 'noajax') // if ajax mode |
|
127 | +if (!isset($mode) || $mode != 'noajax') { |
|
128 | + // if ajax mode |
|
107 | 129 | { |
108 | 130 | top_httphead(); |
109 | 131 | } |
132 | +} |
|
110 | 133 | |
111 | 134 | //print '<!-- selecteddir (relative dir we click on) = '.$selecteddir.', openeddir = '.$openeddir.', modulepart='.$modulepart.', preopened='.$preopened.' -->'."\n"; |
112 | 135 | $userstatic = new User($db); |
@@ -114,7 +137,9 @@ discard block |
||
114 | 137 | $ecmdirstatic = new EcmDirectory($db); |
115 | 138 | |
116 | 139 | // Load full tree of ECM module from database. We will use it to define nbofsubdir and nboffilesinsubdir |
117 | -if (empty($sqltree)) $sqltree = $ecmdirstatic->get_full_arbo(0); |
|
140 | +if (empty($sqltree)) { |
|
141 | + $sqltree = $ecmdirstatic->get_full_arbo(0); |
|
142 | +} |
|
118 | 143 | |
119 | 144 | // Try to find selected dir id into $sqltree and save it into $current_ecmdir_id |
120 | 145 | $current_ecmdir_id = -1; |
@@ -160,7 +185,10 @@ discard block |
||
160 | 185 | print '<ul class="ecmjqft">'; |
161 | 186 | |
162 | 187 | // Load full tree from database. We will use it to define nbofsubdir and nboffilesinsubdir |
163 | - if (empty($sqltree)) $sqltree = $ecmdirstatic->get_full_arbo(0); // Slow |
|
188 | + if (empty($sqltree)) { |
|
189 | + $sqltree = $ecmdirstatic->get_full_arbo(0); |
|
190 | + } |
|
191 | + // Slow |
|
164 | 192 | |
165 | 193 | // ----- This section will show a tree from a fulltree array ----- |
166 | 194 | // $section must also be defined |
@@ -181,7 +209,9 @@ discard block |
||
181 | 209 | |
182 | 210 | // Update expandedsectionarray in session |
183 | 211 | $expandedsectionarray = array(); |
184 | - if (isset($_SESSION['dol_ecmexpandedsectionarray'])) $expandedsectionarray = explode(',', $_SESSION['dol_ecmexpandedsectionarray']); |
|
212 | + if (isset($_SESSION['dol_ecmexpandedsectionarray'])) { |
|
213 | + $expandedsectionarray = explode(',', $_SESSION['dol_ecmexpandedsectionarray']); |
|
214 | + } |
|
185 | 215 | |
186 | 216 | if ($section && GETPOST('sectionexpand') == 'true') |
187 | 217 | { |
@@ -189,10 +219,12 @@ discard block |
||
189 | 219 | $pathtosection = explode('_', $fullpathselected); |
190 | 220 | foreach ($pathtosection as $idcursor) |
191 | 221 | { |
192 | - if ($idcursor && !in_array($idcursor, $expandedsectionarray)) // Not already in array |
|
222 | + if ($idcursor && !in_array($idcursor, $expandedsectionarray)) { |
|
223 | + // Not already in array |
|
193 | 224 | { |
194 | 225 | $expandedsectionarray[] = $idcursor; |
195 | 226 | } |
227 | + } |
|
196 | 228 | } |
197 | 229 | $_SESSION['dol_ecmexpandedsectionarray'] = join(',', $expandedsectionarray); |
198 | 230 | } |
@@ -233,18 +265,29 @@ discard block |
||
233 | 265 | $showline = 0; |
234 | 266 | |
235 | 267 | // If directory is son of expanded directory, we show line |
236 | - if (in_array($val['id_mere'], $expandedsectionarray)) $showline = 4; |
|
268 | + if (in_array($val['id_mere'], $expandedsectionarray)) { |
|
269 | + $showline = 4; |
|
270 | + } |
|
237 | 271 | // If directory is brother of selected directory, we show line |
238 | - elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) $showline = 3; |
|
272 | + elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) { |
|
273 | + $showline = 3; |
|
274 | + } |
|
239 | 275 | // If directory is parent of selected directory or is selected directory, we show line |
240 | - elseif (preg_match('/'.$val['fullpath'].'_/i', $fullpathselected.'_')) $showline = 2; |
|
276 | + elseif (preg_match('/'.$val['fullpath'].'_/i', $fullpathselected.'_')) { |
|
277 | + $showline = 2; |
|
278 | + } |
|
241 | 279 | // If we are level one we show line |
242 | - elseif ($val['level'] < 2) $showline = 1; |
|
280 | + elseif ($val['level'] < 2) { |
|
281 | + $showline = 1; |
|
282 | + } |
|
243 | 283 | |
244 | 284 | if ($showline) |
245 | 285 | { |
246 | - if (in_array($val['id'], $expandedsectionarray)) $option = 'indexexpanded'; |
|
247 | - else $option = 'indexnotexpanded'; |
|
286 | + if (in_array($val['id'], $expandedsectionarray)) { |
|
287 | + $option = 'indexexpanded'; |
|
288 | + } else { |
|
289 | + $option = 'indexnotexpanded'; |
|
290 | + } |
|
248 | 291 | //print $option; |
249 | 292 | |
250 | 293 | print '<li class="directory collapsed">'; |
@@ -271,7 +314,9 @@ discard block |
||
271 | 314 | print $val['cachenbofdoc']; |
272 | 315 | print '</td>'; |
273 | 316 | print '<td class="left">'; |
274 | - if ($nbofsubdir && $nboffilesinsubdir) print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> '; |
|
317 | + if ($nbofsubdir && $nboffilesinsubdir) { |
|
318 | + print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> '; |
|
319 | + } |
|
275 | 320 | print '</td>'; |
276 | 321 | |
277 | 322 | // Info |
@@ -284,8 +329,11 @@ discard block |
||
284 | 329 | $htmltooltip .= '<b>'.$langs->trans("ECMCreationDate").'</b>: '.dol_print_date($val['date_c'], "dayhour").'<br>'; |
285 | 330 | $htmltooltip .= '<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>'; |
286 | 331 | $htmltooltip .= '<b>'.$langs->trans("ECMNbOfFilesInDir").'</b>: '.$val['cachenbofdoc'].'<br>'; |
287 | - if ($nbofsubdir) $htmltooltip .= '<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir; |
|
288 | - else $htmltooltip .= '<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.$nbofsubdir.'<br>'; |
|
332 | + if ($nbofsubdir) { |
|
333 | + $htmltooltip .= '<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir; |
|
334 | + } else { |
|
335 | + $htmltooltip .= '<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.$nbofsubdir.'<br>'; |
|
336 | + } |
|
289 | 337 | print $form->textwithpicto('', $htmltooltip, 1, 'info'); |
290 | 338 | print "</td>"; |
291 | 339 | |
@@ -315,7 +363,9 @@ discard block |
||
315 | 363 | |
316 | 364 | |
317 | 365 | // Close db if mode is not noajax |
318 | -if ((!isset($mode) || $mode != 'noajax') && is_object($db)) $db->close(); |
|
366 | +if ((!isset($mode) || $mode != 'noajax') && is_object($db)) { |
|
367 | + $db->close(); |
|
368 | +} |
|
319 | 369 | |
320 | 370 | |
321 | 371 | |
@@ -348,14 +398,18 @@ discard block |
||
348 | 398 | if (!empty($files)) |
349 | 399 | { |
350 | 400 | natcasesort($files); |
351 | - if (count($files) > 2) /* The 2 accounts for . and .. */ |
|
401 | + if (count($files) > 2) { |
|
402 | + /* The 2 accounts for . and .. */ |
|
352 | 403 | { |
353 | 404 | echo '<ul class="ecmjqft" style="display: none;">'."\n"; |
405 | + } |
|
354 | 406 | |
355 | 407 | // All dirs |
356 | - foreach ($files as $file) // $file can be '.', '..', or 'My dir' or 'My file' |
|
408 | + foreach ($files as $file) { |
|
409 | + // $file can be '.', '..', or 'My dir' or 'My file' |
|
357 | 410 | { |
358 | 411 | if ($file == 'temp') continue; |
412 | + } |
|
359 | 413 | |
360 | 414 | $nbofsubdir = 0; |
361 | 415 | $nboffilesinsubdir = 0; |
@@ -366,15 +420,19 @@ discard block |
||
366 | 420 | foreach ($sqltree as $key => $tmpval) |
367 | 421 | { |
368 | 422 | //print "-- key=".$key." - ".$tmpval['fullrelativename']." vs ".(($selecteddir != '/'?$selecteddir.'/':'').$file)."<br>\n"; |
369 | - if ($tmpval['fullrelativename'] == (($selecteddir != '/' ? $selecteddir.'/' : '').$file)) // We found equivalent record into database |
|
423 | + if ($tmpval['fullrelativename'] == (($selecteddir != '/' ? $selecteddir.'/' : '').$file)) { |
|
424 | + // We found equivalent record into database |
|
370 | 425 | { |
371 | 426 | $val = $tmpval; |
427 | + } |
|
372 | 428 | $resarray = tree_showpad($sqltree, $key, 1); |
373 | 429 | |
374 | 430 | // Refresh cache for this subdir |
375 | - if (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] < 0) // Cache is not up to date, so we update it for this directory t |
|
431 | + if (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] < 0) { |
|
432 | + // Cache is not up to date, so we update it for this directory t |
|
376 | 433 | { |
377 | 434 | $result = $ecmdirstatic->fetch($val['id']); |
435 | + } |
|
378 | 436 | $ecmdirstatic->ref = $ecmdirstatic->label; |
379 | 437 | |
380 | 438 | $result = $ecmdirstatic->refreshcachenboffile(0); |
@@ -391,9 +449,11 @@ discard block |
||
391 | 449 | //print 'modulepart='.$modulepart.' fullpathselecteddir='.$fullpathselecteddir.' - val[fullrelativename] (in database)='.$val['fullrelativename'].' - val[id]='.$val['id'].' - is_dir='.dol_is_dir($fullpathselecteddir . $file).' - file='.$file."\n"; |
392 | 450 | if ($file != '.' && $file != '..' && ((!empty($val['fullrelativename']) && $val['id'] >= 0) || dol_is_dir($fullpathselecteddir.(preg_match('/\/$/', $fullpathselecteddir) ? '' : '/').$file))) |
393 | 451 | { |
394 | - if (empty($val['fullrelativename'])) // If we did not find entry into database, but found a directory (dol_is_dir was ok at previous test) |
|
452 | + if (empty($val['fullrelativename'])) { |
|
453 | + // If we did not find entry into database, but found a directory (dol_is_dir was ok at previous test) |
|
395 | 454 | { |
396 | 455 | $val['fullrelativename'] = (($selecteddir && $selecteddir != '/') ? $selecteddir.'/' : '').$file; |
456 | + } |
|
397 | 457 | $val['id'] = 0; |
398 | 458 | $val['label'] = $file; |
399 | 459 | $val['description'] = ''; |
@@ -401,7 +461,9 @@ discard block |
||
401 | 461 | } |
402 | 462 | |
403 | 463 | $collapsedorexpanded = 'collapsed'; |
404 | - if (preg_match('/^'.preg_quote($val['fullrelativename'].'/', '/').'/', $preopened)) $collapsedorexpanded = 'expanded'; |
|
464 | + if (preg_match('/^'.preg_quote($val['fullrelativename'].'/', '/').'/', $preopened)) { |
|
465 | + $collapsedorexpanded = 'expanded'; |
|
466 | + } |
|
405 | 467 | print '<li class="directory '.$collapsedorexpanded.'">'; // collapsed is opposite if expanded |
406 | 468 | |
407 | 469 | print "<a class=\"fmdirlia jqft ecmjqft\" href=\""; |
@@ -425,7 +487,9 @@ discard block |
||
425 | 487 | print (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0) ? $val['cachenbofdoc'] : ' '; |
426 | 488 | print '</td>'; |
427 | 489 | print '<td class="left">'; |
428 | - if ($nbofsubdir > 0 && $nboffilesinsubdir > 0) print '<font class="opacitymedium">+'.$nboffilesinsubdir.'</font> '; |
|
490 | + if ($nbofsubdir > 0 && $nboffilesinsubdir > 0) { |
|
491 | + print '<font class="opacitymedium">+'.$nboffilesinsubdir.'</font> '; |
|
492 | + } |
|
429 | 493 | print '</td>'; |
430 | 494 | |
431 | 495 | // Edit link |
@@ -450,8 +514,11 @@ discard block |
||
450 | 514 | $htmltooltip .= '<b>'.$langs->trans("ECMCreationDate").'</b>: '.(isset($val['date_c']) ?dol_print_date($val['date_c'], "dayhour") : $langs->trans("NeedRefresh")).'<br>'; |
451 | 515 | $htmltooltip .= '<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>'; |
452 | 516 | $htmltooltip .= '<b>'.$langs->trans("ECMNbOfFilesInDir").'</b>: '.((isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0) ? $val['cachenbofdoc'] : $langs->trans("NeedRefresh")).'<br>'; |
453 | - if ($nboffilesinsubdir > 0) $htmltooltip .= '<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir; |
|
454 | - else $htmltooltip .= '<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.($nbofsubdir >= 0 ? $nbofsubdir : $langs->trans("NeedRefresh")).'<br>'; |
|
517 | + if ($nboffilesinsubdir > 0) { |
|
518 | + $htmltooltip .= '<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir; |
|
519 | + } else { |
|
520 | + $htmltooltip .= '<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.($nbofsubdir >= 0 ? $nbofsubdir : $langs->trans("NeedRefresh")).'<br>'; |
|
521 | + } |
|
455 | 522 | print $form->textwithpicto('', $htmltooltip, 1, "info"); |
456 | 523 | print "</td>"; |
457 | 524 | } |
@@ -473,7 +540,9 @@ discard block |
||
473 | 540 | $newfullpathselecteddir = $dolibarr_main_data_root.'/medias/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : ''); |
474 | 541 | } |
475 | 542 | |
476 | - if ($newfullpathselecteddir) treeOutputForAbsoluteDir($sqltree, $newselecteddir, $newfullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth + 1); |
|
543 | + if ($newfullpathselecteddir) { |
|
544 | + treeOutputForAbsoluteDir($sqltree, $newselecteddir, $newfullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth + 1); |
|
545 | + } |
|
477 | 546 | } |
478 | 547 | |
479 | 548 | print "</li>\n"; |
@@ -482,6 +551,8 @@ discard block |
||
482 | 551 | |
483 | 552 | echo "</ul>\n"; |
484 | 553 | } |
485 | - } else print "PermissionDenied"; |
|
554 | + } else { |
|
555 | + print "PermissionDenied"; |
|
556 | + } |
|
486 | 557 | } |
487 | 558 | } |
@@ -20,10 +20,19 @@ discard block |
||
20 | 20 | * \brief File to save field value |
21 | 21 | */ |
22 | 22 | |
23 | -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal |
|
24 | -if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); |
|
25 | -if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
26 | -if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
23 | +if (!defined('NOTOKENRENEWAL')) { |
|
24 | + define('NOTOKENRENEWAL', '1'); |
|
25 | +} |
|
26 | +// Disables token renewal |
|
27 | +if (!defined('NOREQUIREMENU')) { |
|
28 | + define('NOREQUIREMENU', '1'); |
|
29 | +} |
|
30 | +if (!defined('NOREQUIREAJAX')) { |
|
31 | + define('NOREQUIREAJAX', '1'); |
|
32 | +} |
|
33 | +if (!defined('NOREQUIRESOC')) { |
|
34 | + define('NOREQUIRESOC', '1'); |
|
35 | +} |
|
27 | 36 | |
28 | 37 | require '../../main.inc.php'; |
29 | 38 | require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; |
@@ -197,7 +206,9 @@ discard block |
||
197 | 206 | |
198 | 207 | if (!$error) |
199 | 208 | { |
200 | - if ((isset($object) && !is_object($object)) || empty($savemethod)) $object = new GenericObject($db); |
|
209 | + if ((isset($object) && !is_object($object)) || empty($savemethod)) { |
|
210 | + $object = new GenericObject($db); |
|
211 | + } |
|
201 | 212 | |
202 | 213 | // Specific for add_object_linked() |
203 | 214 | // TODO add a function for variable treatment |
@@ -209,8 +220,11 @@ discard block |
||
209 | 220 | $ret = $object->$savemethodname($field, $newvalue, $table_element, $fk_element, $format); |
210 | 221 | if ($ret > 0) |
211 | 222 | { |
212 | - if ($type == 'numeric') $value = price($newvalue); |
|
213 | - elseif ($type == 'textarea') $value = dol_nl2br($newvalue); |
|
223 | + if ($type == 'numeric') { |
|
224 | + $value = price($newvalue); |
|
225 | + } elseif ($type == 'textarea') { |
|
226 | + $value = dol_nl2br($newvalue); |
|
227 | + } |
|
214 | 228 | |
215 | 229 | $return['value'] = $value; |
216 | 230 | $return['view'] = (!empty($view) ? $view : $value); |
@@ -20,12 +20,25 @@ discard block |
||
20 | 20 | * This Ajax service is called when option MAIN_DIRECT_STATUS_UPDATE is set. |
21 | 21 | */ |
22 | 22 | |
23 | -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal |
|
24 | -if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); |
|
25 | -if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); |
|
26 | -if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
27 | -if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
28 | -if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); |
|
23 | +if (!defined('NOTOKENRENEWAL')) { |
|
24 | + define('NOTOKENRENEWAL', '1'); |
|
25 | +} |
|
26 | +// Disables token renewal |
|
27 | +if (!defined('NOREQUIREMENU')) { |
|
28 | + define('NOREQUIREMENU', '1'); |
|
29 | +} |
|
30 | +if (!defined('NOREQUIREHTML')) { |
|
31 | + define('NOREQUIREHTML', '1'); |
|
32 | +} |
|
33 | +if (!defined('NOREQUIREAJAX')) { |
|
34 | + define('NOREQUIREAJAX', '1'); |
|
35 | +} |
|
36 | +if (!defined('NOREQUIRESOC')) { |
|
37 | + define('NOREQUIRESOC', '1'); |
|
38 | +} |
|
39 | +if (!defined('NOREQUIRETRAN')) { |
|
40 | + define('NOREQUIRETRAN', '1'); |
|
41 | +} |
|
29 | 42 | |
30 | 43 | require '../../main.inc.php'; |
31 | 44 | require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; |
@@ -74,7 +87,9 @@ discard block |
||
74 | 87 | } |
75 | 88 | |
76 | 89 | $tablename = $element; |
77 | - if ($tablename == 'websitepage') $tablename = 'website_page'; |
|
90 | + if ($tablename == 'websitepage') { |
|
91 | + $tablename = 'website_page'; |
|
92 | + } |
|
78 | 93 | |
79 | 94 | $format = 'int'; |
80 | 95 |
@@ -20,9 +20,16 @@ |
||
20 | 20 | * \brief File to load vat rates combobox |
21 | 21 | */ |
22 | 22 | |
23 | -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal |
|
24 | -if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); |
|
25 | -if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
23 | +if (!defined('NOTOKENRENEWAL')) { |
|
24 | + define('NOTOKENRENEWAL', '1'); |
|
25 | +} |
|
26 | +// Disables token renewal |
|
27 | +if (!defined('NOREQUIREMENU')) { |
|
28 | + define('NOREQUIREMENU', '1'); |
|
29 | +} |
|
30 | +if (!defined('NOREQUIREAJAX')) { |
|
31 | + define('NOREQUIREAJAX', '1'); |
|
32 | +} |
|
26 | 33 | |
27 | 34 | require '../../main.inc.php'; |
28 | 35 |
@@ -20,10 +20,19 @@ discard block |
||
20 | 20 | * \brief File to load field value |
21 | 21 | */ |
22 | 22 | |
23 | -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal |
|
24 | -if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); |
|
25 | -if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
26 | -if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
23 | +if (!defined('NOTOKENRENEWAL')) { |
|
24 | + define('NOTOKENRENEWAL', '1'); |
|
25 | +} |
|
26 | +// Disables token renewal |
|
27 | +if (!defined('NOREQUIREMENU')) { |
|
28 | + define('NOREQUIREMENU', '1'); |
|
29 | +} |
|
30 | +if (!defined('NOREQUIREAJAX')) { |
|
31 | + define('NOREQUIREAJAX', '1'); |
|
32 | +} |
|
33 | +if (!defined('NOREQUIRESOC')) { |
|
34 | + define('NOREQUIRESOC', '1'); |
|
35 | +} |
|
27 | 36 | |
28 | 37 | require '../../main.inc.php'; |
29 | 38 | require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; |
@@ -55,11 +64,15 @@ discard block |
||
55 | 64 | $subelement = $regs[2]; |
56 | 65 | } |
57 | 66 | |
58 | - if ($element == 'propal') $element = 'propale'; |
|
59 | - elseif ($element == 'fichinter') $element = 'ficheinter'; |
|
60 | - elseif ($element == 'product') $element = 'produit'; |
|
61 | - elseif ($element == 'member') $element = 'adherent'; |
|
62 | - elseif ($element == 'order_supplier') { |
|
67 | + if ($element == 'propal') { |
|
68 | + $element = 'propale'; |
|
69 | + } elseif ($element == 'fichinter') { |
|
70 | + $element = 'ficheinter'; |
|
71 | + } elseif ($element == 'product') { |
|
72 | + $element = 'produit'; |
|
73 | + } elseif ($element == 'member') { |
|
74 | + $element = 'adherent'; |
|
75 | + } elseif ($element == 'order_supplier') { |
|
63 | 76 | $element = 'fournisseur'; |
64 | 77 | $subelement = 'commande'; |
65 | 78 | } elseif ($element == 'invoice_supplier') { |
@@ -81,7 +94,9 @@ discard block |
||
81 | 94 | if (method_exists($form, $methodname)) |
82 | 95 | { |
83 | 96 | $ret = $form->$methodname(); |
84 | - if ($ret > 0) echo json_encode($form->$cachename); |
|
97 | + if ($ret > 0) { |
|
98 | + echo json_encode($form->$cachename); |
|
99 | + } |
|
85 | 100 | } elseif (!empty($ext_element)) |
86 | 101 | { |
87 | 102 | $module = $subelement = $ext_element; |
@@ -95,7 +110,9 @@ discard block |
||
95 | 110 | $classname = 'Actions'.ucfirst($subelement); |
96 | 111 | $object = new $classname($db); |
97 | 112 | $ret = $object->$methodname($fk_element); |
98 | - if ($ret > 0) echo json_encode($object->$cachename); |
|
113 | + if ($ret > 0) { |
|
114 | + echo json_encode($object->$cachename); |
|
115 | + } |
|
99 | 116 | } |
100 | 117 | } else { |
101 | 118 | $object = new GenericObject($db); |
@@ -20,11 +20,22 @@ |
||
20 | 20 | * \brief File to make Ajax action on setting extra parameters of elements |
21 | 21 | */ |
22 | 22 | |
23 | -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal |
|
24 | -if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); |
|
25 | -if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); |
|
26 | -if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
27 | -if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
23 | +if (!defined('NOTOKENRENEWAL')) { |
|
24 | + define('NOTOKENRENEWAL', '1'); |
|
25 | +} |
|
26 | +// Disables token renewal |
|
27 | +if (!defined('NOREQUIREMENU')) { |
|
28 | + define('NOREQUIREMENU', '1'); |
|
29 | +} |
|
30 | +if (!defined('NOREQUIREHTML')) { |
|
31 | + define('NOREQUIREHTML', '1'); |
|
32 | +} |
|
33 | +if (!defined('NOREQUIREAJAX')) { |
|
34 | + define('NOREQUIREAJAX', '1'); |
|
35 | +} |
|
36 | +if (!defined('NOREQUIRESOC')) { |
|
37 | + define('NOREQUIRESOC', '1'); |
|
38 | +} |
|
28 | 39 | |
29 | 40 | include '../../main.inc.php'; |
30 | 41 |
@@ -20,10 +20,19 @@ |
||
20 | 20 | * \brief File to get ht and ttc |
21 | 21 | */ |
22 | 22 | |
23 | -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal |
|
24 | -if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); |
|
25 | -if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
26 | -if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
23 | +if (!defined('NOTOKENRENEWAL')) { |
|
24 | + define('NOTOKENRENEWAL', '1'); |
|
25 | +} |
|
26 | +// Disables token renewal |
|
27 | +if (!defined('NOREQUIREMENU')) { |
|
28 | + define('NOREQUIREMENU', '1'); |
|
29 | +} |
|
30 | +if (!defined('NOREQUIREAJAX')) { |
|
31 | + define('NOREQUIREAJAX', '1'); |
|
32 | +} |
|
33 | +if (!defined('NOREQUIRESOC')) { |
|
34 | + define('NOREQUIRESOC', '1'); |
|
35 | +} |
|
27 | 36 | |
28 | 37 | require '../../main.inc.php'; |
29 | 38 |
@@ -22,12 +22,25 @@ discard block |
||
22 | 22 | * \brief File to return Ajax response on zipcode or town request |
23 | 23 | */ |
24 | 24 | |
25 | -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal |
|
26 | -if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); |
|
27 | -if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); |
|
28 | -if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
29 | -if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
30 | -if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); |
|
25 | +if (!defined('NOTOKENRENEWAL')) { |
|
26 | + define('NOTOKENRENEWAL', 1); |
|
27 | +} |
|
28 | +// Disables token renewal |
|
29 | +if (!defined('NOREQUIREMENU')) { |
|
30 | + define('NOREQUIREMENU', '1'); |
|
31 | +} |
|
32 | +if (!defined('NOREQUIREHTML')) { |
|
33 | + define('NOREQUIREHTML', '1'); |
|
34 | +} |
|
35 | +if (!defined('NOREQUIREAJAX')) { |
|
36 | + define('NOREQUIREAJAX', '1'); |
|
37 | +} |
|
38 | +if (!defined('NOREQUIRESOC')) { |
|
39 | + define('NOREQUIRESOC', '1'); |
|
40 | +} |
|
41 | +if (!defined('NOCSRFCHECK')) { |
|
42 | + define('NOCSRFCHECK', '1'); |
|
43 | +} |
|
31 | 44 | |
32 | 45 | require '../../main.inc.php'; |
33 | 46 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; |
@@ -60,9 +73,11 @@ discard block |
||
60 | 73 | $zipcode = $_GET['zipcode'] ? $_GET['zipcode'] : ''; |
61 | 74 | $town = $_GET['town'] ? $_GET['town'] : ''; |
62 | 75 | |
63 | - if (!empty($conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) // Use zip-town table |
|
76 | + if (!empty($conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) { |
|
77 | + // Use zip-town table |
|
64 | 78 | { |
65 | 79 | $sql = "SELECT z.rowid, z.zip, z.town, z.fk_county, z.fk_pays as fk_country"; |
80 | + } |
|
66 | 81 | $sql .= ", c.rowid as fk_country, c.code as country_code, c.label as country"; |
67 | 82 | $sql .= ", d.rowid as fk_county, d.code_departement as county_code, d.nom as county"; |
68 | 83 | $sql .= " FROM ".MAIN_DB_PREFIX."c_ziptown as z"; |
@@ -71,8 +86,12 @@ discard block |
||
71 | 86 | $sql .= " ".MAIN_DB_PREFIX."c_country as c"; |
72 | 87 | $sql .= " WHERE z.fk_pays = c.rowid"; |
73 | 88 | $sql .= " AND z.active = 1 AND c.active = 1"; |
74 | - if ($zipcode) $sql .= " AND z.zip LIKE '".$db->escape($zipcode)."%'"; |
|
75 | - if ($town) $sql .= " AND z.town LIKE '%".$db->escape($town)."%'"; |
|
89 | + if ($zipcode) { |
|
90 | + $sql .= " AND z.zip LIKE '".$db->escape($zipcode)."%'"; |
|
91 | + } |
|
92 | + if ($town) { |
|
93 | + $sql .= " AND z.town LIKE '%".$db->escape($town)."%'"; |
|
94 | + } |
|
76 | 95 | $sql .= " ORDER BY z.zip, z.town"; |
77 | 96 | $sql .= $db->plimit(100); // Avoid pb with bad criteria |
78 | 97 | } else // Use table of third parties |
@@ -84,8 +103,12 @@ discard block |
||
84 | 103 | $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON s.fk_departement = d.rowid"; |
85 | 104 | $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid'; |
86 | 105 | $sql .= " WHERE"; |
87 | - if ($zipcode) $sql .= " s.zip LIKE '".$db->escape($zipcode)."%'"; |
|
88 | - if ($town) $sql .= " s.town LIKE '%".$db->escape($town)."%'"; |
|
106 | + if ($zipcode) { |
|
107 | + $sql .= " s.zip LIKE '".$db->escape($zipcode)."%'"; |
|
108 | + } |
|
109 | + if ($town) { |
|
110 | + $sql .= " s.town LIKE '%".$db->escape($town)."%'"; |
|
111 | + } |
|
89 | 112 | $sql .= " ORDER BY s.fk_pays, s.zip, s.town"; |
90 | 113 | $sql .= $db->plimit(100); // Avoid pb with bad criteria |
91 | 114 | } |