@@ -34,8 +34,11 @@ |
||
34 | 34 | |
35 | 35 | $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; |
36 | 36 | |
37 | - if (GETPOST("selectedfields")) $tabparam["MAIN_SELECTEDFIELDS_".$varpage]=GETPOST("selectedfields"); |
|
38 | - else $tabparam["MAIN_SELECTEDFIELDS_".$varpage]=''; |
|
37 | + if (GETPOST("selectedfields")) { |
|
38 | + $tabparam["MAIN_SELECTEDFIELDS_".$varpage]=GETPOST("selectedfields"); |
|
39 | + } else { |
|
40 | + $tabparam["MAIN_SELECTEDFIELDS_".$varpage]=''; |
|
41 | + } |
|
39 | 42 | |
40 | 43 | include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
41 | 44 |
@@ -41,6 +41,8 @@ |
||
41 | 41 | if ($action == 'dellink' && ! empty($permissiondellink) && ! GETPOST('cancel','alpha') && $dellinkid > 0) |
42 | 42 | { |
43 | 43 | $result=$object->deleteObjectLinked(0, '', 0, '', $dellinkid); |
44 | - if ($result < 0) setEventMessages($object->error,$object->errors,'errors'); |
|
45 | -} |
|
44 | + if ($result < 0) { |
|
45 | + setEventMessages($object->error,$object->errors,'errors'); |
|
46 | + } |
|
47 | + } |
|
46 | 48 |
@@ -30,24 +30,28 @@ |
||
30 | 30 | |
31 | 31 | if (($id > 0 || (! empty($ref) && ! in_array($action, array('create', 'createtask', 'add')))) && (empty($cancel) || $id > 0)) |
32 | 32 | { |
33 | - if (($id > 0 && is_numeric($id)) || ! empty($ref)) // To discard case when id is list of ids like '1,2,3...' |
|
33 | + if (($id > 0 && is_numeric($id)) || ! empty($ref)) { |
|
34 | + // To discard case when id is list of ids like '1,2,3...' |
|
34 | 35 | { |
35 | 36 | $ret = $object->fetch($id, $ref); |
37 | + } |
|
36 | 38 | if ($ret > 0) |
37 | 39 | { |
38 | 40 | $object->fetch_thirdparty(); |
39 | 41 | $id = $object->id; |
40 | - } |
|
41 | - else |
|
42 | + } else |
|
42 | 43 | { |
43 | 44 | if (empty($object->error) && ! count($object->errors)) |
44 | 45 | { |
45 | - if ($ret < 0) // if $ret == 0, it means not found. |
|
46 | + if ($ret < 0) { |
|
47 | + // if $ret == 0, it means not found. |
|
46 | 48 | { |
47 | 49 | setEventMessages('Fetch on object (type '.get_class($object).') return an error without filling $object->error nor $object->errors', null, 'errors'); |
48 | 50 | } |
49 | - } |
|
50 | - else setEventMessages($object->error, $object->errors, 'errors'); |
|
51 | + } |
|
52 | + } else { |
|
53 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
54 | + } |
|
51 | 55 | $action=''; |
52 | 56 | } |
53 | 57 | } |
@@ -26,15 +26,26 @@ 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 | 43 | |
35 | -if (! isset($mode) || $mode != 'noajax') // For ajax call |
|
44 | +if (! isset($mode) || $mode != 'noajax') { |
|
45 | + // For ajax call |
|
36 | 46 | { |
37 | 47 | $res=@include '../../main.inc.php'; |
48 | +} |
|
38 | 49 | include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
39 | 50 | include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
40 | 51 | include_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; |
@@ -49,9 +60,11 @@ discard block |
||
49 | 60 | |
50 | 61 | $preopened = GETPOST('preopened'); |
51 | 62 | |
52 | - if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/','',$selecteddir); // We removed last '/' except if it is '/' |
|
53 | -} |
|
54 | -else // For no ajax call |
|
63 | + if ($selecteddir != '/') { |
|
64 | + $selecteddir = preg_replace('/\/$/','',$selecteddir); |
|
65 | + } |
|
66 | + // We removed last '/' except if it is '/' |
|
67 | +} else // For no ajax call |
|
55 | 68 | { |
56 | 69 | //if (GETPOST('preopened')) { $_GET['dir'] = $_POST['dir'] = GETPOST('preopened'); } |
57 | 70 | |
@@ -61,9 +74,14 @@ discard block |
||
61 | 74 | |
62 | 75 | $preopened = GETPOST('preopened'); |
63 | 76 | |
64 | - if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/','',$selecteddir); // We removed last '/' except if it is '/' |
|
65 | - if (empty($url)) $url=DOL_URL_ROOT.'/ecm/index.php'; |
|
66 | -} |
|
77 | + if ($selecteddir != '/') { |
|
78 | + $selecteddir = preg_replace('/\/$/','',$selecteddir); |
|
79 | + } |
|
80 | + // We removed last '/' except if it is '/' |
|
81 | + if (empty($url)) { |
|
82 | + $url=DOL_URL_ROOT.'/ecm/index.php'; |
|
83 | + } |
|
84 | + } |
|
67 | 85 | |
68 | 86 | // Load translation files required by the page |
69 | 87 | $langs->load("ecm"); |
@@ -74,8 +92,7 @@ discard block |
||
74 | 92 | { |
75 | 93 | $fullpathselecteddir=$conf->ecm->dir_output.'/'.($selecteddir != '/' ? $selecteddir : ''); |
76 | 94 | $fullpathpreopened=$conf->ecm->dir_output.'/'.($preopened != '/' ? $preopened : ''); |
77 | -} |
|
78 | -elseif ($modulepart == 'medias') |
|
95 | +} elseif ($modulepart == 'medias') |
|
79 | 96 | { |
80 | 97 | $fullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($selecteddir != '/' ? $selecteddir : ''); |
81 | 98 | $fullpathpreopened=$dolibarr_main_data_root.'/medias/'.($preopened != '/' ? $preopened : ''); |
@@ -95,9 +112,10 @@ discard block |
||
95 | 112 | // Check permissions |
96 | 113 | if ($modulepart == 'ecm') |
97 | 114 | { |
98 | - if (! $user->rights->ecm->read) accessforbidden(); |
|
99 | -} |
|
100 | -elseif ($modulepart == 'medias') |
|
115 | + if (! $user->rights->ecm->read) { |
|
116 | + accessforbidden(); |
|
117 | + } |
|
118 | + } elseif ($modulepart == 'medias') |
|
101 | 119 | { |
102 | 120 | // Always allowed |
103 | 121 | } |
@@ -107,10 +125,12 @@ discard block |
||
107 | 125 | * View |
108 | 126 | */ |
109 | 127 | |
110 | -if (! isset($mode) || $mode != 'noajax') // if ajax mode |
|
128 | +if (! isset($mode) || $mode != 'noajax') { |
|
129 | + // if ajax mode |
|
111 | 130 | { |
112 | 131 | top_httphead(); |
113 | 132 | } |
133 | +} |
|
114 | 134 | |
115 | 135 | //print '<!-- selecteddir (relative dir we click on) = '.$selecteddir.', openeddir = '.$openeddir.', modulepart='.$modulepart.', preopened='.$preopened.' -->'."\n"; |
116 | 136 | $userstatic=new User($db); |
@@ -118,7 +138,9 @@ discard block |
||
118 | 138 | $ecmdirstatic = new EcmDirectory($db); |
119 | 139 | |
120 | 140 | // Load full tree of ECM module from database. We will use it to define nbofsubdir and nboffilesinsubdir |
121 | -if (empty($sqltree)) $sqltree=$ecmdirstatic->get_full_arbo(0); |
|
141 | +if (empty($sqltree)) { |
|
142 | + $sqltree=$ecmdirstatic->get_full_arbo(0); |
|
143 | +} |
|
122 | 144 | |
123 | 145 | // Try to find selected dir id into $sqltree and save it into $current_ecmdir_id |
124 | 146 | $current_ecmdir_id=-1; |
@@ -164,7 +186,10 @@ discard block |
||
164 | 186 | print '<ul class="ecmjqft">'; |
165 | 187 | |
166 | 188 | // Load full tree from database. We will use it to define nbofsubdir and nboffilesinsubdir |
167 | - if (empty($sqltree)) $sqltree=$ecmdirstatic->get_full_arbo(0); // Slow |
|
189 | + if (empty($sqltree)) { |
|
190 | + $sqltree=$ecmdirstatic->get_full_arbo(0); |
|
191 | + } |
|
192 | + // Slow |
|
168 | 193 | |
169 | 194 | // ----- This section will show a tree from a fulltree array ----- |
170 | 195 | // $section must also be defined |
@@ -185,7 +210,9 @@ discard block |
||
185 | 210 | |
186 | 211 | // Update expandedsectionarray in session |
187 | 212 | $expandedsectionarray=array(); |
188 | - if (isset($_SESSION['dol_ecmexpandedsectionarray'])) $expandedsectionarray=explode(',',$_SESSION['dol_ecmexpandedsectionarray']); |
|
213 | + if (isset($_SESSION['dol_ecmexpandedsectionarray'])) { |
|
214 | + $expandedsectionarray=explode(',',$_SESSION['dol_ecmexpandedsectionarray']); |
|
215 | + } |
|
189 | 216 | |
190 | 217 | if ($section && GETPOST('sectionexpand') == 'true') |
191 | 218 | { |
@@ -193,10 +220,12 @@ discard block |
||
193 | 220 | $pathtosection=explode('_',$fullpathselected); |
194 | 221 | foreach($pathtosection as $idcursor) |
195 | 222 | { |
196 | - if ($idcursor && ! in_array($idcursor,$expandedsectionarray)) // Not already in array |
|
223 | + if ($idcursor && ! in_array($idcursor,$expandedsectionarray)) { |
|
224 | + // Not already in array |
|
197 | 225 | { |
198 | 226 | $expandedsectionarray[]=$idcursor; |
199 | 227 | } |
228 | + } |
|
200 | 229 | } |
201 | 230 | $_SESSION['dol_ecmexpandedsectionarray']=join(',',$expandedsectionarray); |
202 | 231 | } |
@@ -238,18 +267,29 @@ discard block |
||
238 | 267 | $showline=0; |
239 | 268 | |
240 | 269 | // If directory is son of expanded directory, we show line |
241 | - if (in_array($val['id_mere'],$expandedsectionarray)) $showline=4; |
|
270 | + if (in_array($val['id_mere'],$expandedsectionarray)) { |
|
271 | + $showline=4; |
|
272 | + } |
|
242 | 273 | // If directory is brother of selected directory, we show line |
243 | - elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) $showline=3; |
|
274 | + elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) { |
|
275 | + $showline=3; |
|
276 | + } |
|
244 | 277 | // If directory is parent of selected directory or is selected directory, we show line |
245 | - elseif (preg_match('/'.$val['fullpath'].'_/i',$fullpathselected.'_')) $showline=2; |
|
278 | + elseif (preg_match('/'.$val['fullpath'].'_/i',$fullpathselected.'_')) { |
|
279 | + $showline=2; |
|
280 | + } |
|
246 | 281 | // If we are level one we show line |
247 | - elseif ($val['level'] < 2) $showline=1; |
|
282 | + elseif ($val['level'] < 2) { |
|
283 | + $showline=1; |
|
284 | + } |
|
248 | 285 | |
249 | 286 | if ($showline) |
250 | 287 | { |
251 | - if (in_array($val['id'],$expandedsectionarray)) $option='indexexpanded'; |
|
252 | - else $option='indexnotexpanded'; |
|
288 | + if (in_array($val['id'],$expandedsectionarray)) { |
|
289 | + $option='indexexpanded'; |
|
290 | + } else { |
|
291 | + $option='indexnotexpanded'; |
|
292 | + } |
|
253 | 293 | //print $option; |
254 | 294 | |
255 | 295 | print '<li class="directory collapsed">'; |
@@ -276,7 +316,9 @@ discard block |
||
276 | 316 | print $val['cachenbofdoc']; |
277 | 317 | print '</td>'; |
278 | 318 | print '<td align="left">'; |
279 | - if ($nbofsubdir && $nboffilesinsubdir) print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> '; |
|
319 | + if ($nbofsubdir && $nboffilesinsubdir) { |
|
320 | + print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> '; |
|
321 | + } |
|
280 | 322 | print '</td>'; |
281 | 323 | |
282 | 324 | // Info |
@@ -289,8 +331,11 @@ discard block |
||
289 | 331 | $htmltooltip.='<b>'.$langs->trans("ECMCreationDate").'</b>: '.dol_print_date($val['date_c'],"dayhour").'<br>'; |
290 | 332 | $htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>'; |
291 | 333 | $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInDir").'</b>: '.$val['cachenbofdoc'].'<br>'; |
292 | - if ($nbofsubdir) $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir; |
|
293 | - else $htmltooltip.='<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.$nbofsubdir.'<br>'; |
|
334 | + if ($nbofsubdir) { |
|
335 | + $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir; |
|
336 | + } else { |
|
337 | + $htmltooltip.='<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.$nbofsubdir.'<br>'; |
|
338 | + } |
|
294 | 339 | print $form->textwithpicto('', $htmltooltip, 1, 'info'); |
295 | 340 | print "</td>"; |
296 | 341 | |
@@ -320,7 +365,9 @@ discard block |
||
320 | 365 | |
321 | 366 | |
322 | 367 | // Close db if mode is not noajax |
323 | -if ((! isset($mode) || $mode != 'noajax') && is_object($db)) $db->close(); |
|
368 | +if ((! isset($mode) || $mode != 'noajax') && is_object($db)) { |
|
369 | + $db->close(); |
|
370 | +} |
|
324 | 371 | |
325 | 372 | |
326 | 373 | |
@@ -353,14 +400,18 @@ discard block |
||
353 | 400 | if (! empty($files)) |
354 | 401 | { |
355 | 402 | natcasesort($files); |
356 | - if (count($files) > 2) /* The 2 accounts for . and .. */ |
|
403 | + if (count($files) > 2) { |
|
404 | + /* The 2 accounts for . and .. */ |
|
357 | 405 | { |
358 | 406 | echo '<ul class="ecmjqft" style="display: none;">'."\n"; |
407 | + } |
|
359 | 408 | |
360 | 409 | // All dirs |
361 | - foreach ($files as $file) // $file can be '.', '..', or 'My dir' or 'My file' |
|
410 | + foreach ($files as $file) { |
|
411 | + // $file can be '.', '..', or 'My dir' or 'My file' |
|
362 | 412 | { |
363 | 413 | if ($file == 'temp') continue; |
414 | + } |
|
364 | 415 | |
365 | 416 | $nbofsubdir=0; |
366 | 417 | $nboffilesinsubdir=0; |
@@ -371,15 +422,19 @@ discard block |
||
371 | 422 | foreach($sqltree as $key => $tmpval) |
372 | 423 | { |
373 | 424 | //print "-- key=".$key." - ".$tmpval['fullrelativename']." vs ".(($selecteddir != '/'?$selecteddir.'/':'').$file)."<br>\n"; |
374 | - if ($tmpval['fullrelativename'] == (($selecteddir != '/'?$selecteddir.'/':'').$file)) // We found equivalent record into database |
|
425 | + if ($tmpval['fullrelativename'] == (($selecteddir != '/'?$selecteddir.'/':'').$file)) { |
|
426 | + // We found equivalent record into database |
|
375 | 427 | { |
376 | 428 | $val=$tmpval; |
429 | + } |
|
377 | 430 | $resarray=tree_showpad($sqltree,$key,1); |
378 | 431 | |
379 | 432 | // Refresh cache for this subdir |
380 | - if (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] < 0) // Cache is not up to date, so we update it for this directory t |
|
433 | + if (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] < 0) { |
|
434 | + // Cache is not up to date, so we update it for this directory t |
|
381 | 435 | { |
382 | 436 | $result=$ecmdirstatic->fetch($val['id']); |
437 | + } |
|
383 | 438 | $ecmdirstatic->ref=$ecmdirstatic->label; |
384 | 439 | |
385 | 440 | $result=$ecmdirstatic->refreshcachenboffile(0); |
@@ -396,9 +451,11 @@ discard block |
||
396 | 451 | //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"; |
397 | 452 | if ($file != '.' && $file != '..' && ((! empty($val['fullrelativename']) && $val['id'] >= 0) || dol_is_dir($fullpathselecteddir . (preg_match('/\/$/',$fullpathselecteddir)?'':'/') . $file))) |
398 | 453 | { |
399 | - if (empty($val['fullrelativename'])) // If we did not find entry into database, but found a directory (dol_is_dir was ok at previous test) |
|
454 | + if (empty($val['fullrelativename'])) { |
|
455 | + // If we did not find entry into database, but found a directory (dol_is_dir was ok at previous test) |
|
400 | 456 | { |
401 | 457 | $val['fullrelativename']=(($selecteddir && $selecteddir != '/')?$selecteddir.'/':'').$file; |
458 | + } |
|
402 | 459 | $val['id']=0; |
403 | 460 | $val['label']=$file; |
404 | 461 | $val['description']=''; |
@@ -406,7 +463,9 @@ discard block |
||
406 | 463 | } |
407 | 464 | |
408 | 465 | $collapsedorexpanded='collapsed'; |
409 | - if (preg_match('/^'.preg_quote($val['fullrelativename'].'/', '/').'/', $preopened)) $collapsedorexpanded='expanded'; |
|
466 | + if (preg_match('/^'.preg_quote($val['fullrelativename'].'/', '/').'/', $preopened)) { |
|
467 | + $collapsedorexpanded='expanded'; |
|
468 | + } |
|
410 | 469 | print '<li class="directory '.$collapsedorexpanded.'">'; // collapsed is opposite if expanded |
411 | 470 | |
412 | 471 | print "<a class=\"fmdirlia jqft ecmjqft\" href=\""; |
@@ -430,7 +489,9 @@ discard block |
||
430 | 489 | print (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0)?$val['cachenbofdoc']:' '; |
431 | 490 | print '</td>'; |
432 | 491 | print '<td align="left">'; |
433 | - if ($nbofsubdir > 0 && $nboffilesinsubdir > 0) print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> '; |
|
492 | + if ($nbofsubdir > 0 && $nboffilesinsubdir > 0) { |
|
493 | + print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> '; |
|
494 | + } |
|
434 | 495 | print '</td>'; |
435 | 496 | |
436 | 497 | // Edit link |
@@ -455,8 +516,11 @@ discard block |
||
455 | 516 | $htmltooltip.='<b>'.$langs->trans("ECMCreationDate").'</b>: '.(isset($val['date_c'])?dol_print_date($val['date_c'],"dayhour"):$langs->trans("NeedRefresh")).'<br>'; |
456 | 517 | $htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>'; |
457 | 518 | $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInDir").'</b>: '.((isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0)?$val['cachenbofdoc']:$langs->trans("NeedRefresh")).'<br>'; |
458 | - if ($nboffilesinsubdir > 0) $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir; |
|
459 | - else $htmltooltip.='<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.($nbofsubdir >= 0 ? $nbofsubdir : $langs->trans("NeedRefresh")).'<br>'; |
|
519 | + if ($nboffilesinsubdir > 0) { |
|
520 | + $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir; |
|
521 | + } else { |
|
522 | + $htmltooltip.='<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.($nbofsubdir >= 0 ? $nbofsubdir : $langs->trans("NeedRefresh")).'<br>'; |
|
523 | + } |
|
460 | 524 | print $form->textwithpicto('',$htmltooltip,1,"info"); |
461 | 525 | print "</td>"; |
462 | 526 | } |
@@ -473,13 +537,14 @@ discard block |
||
473 | 537 | if ($modulepart == 'ecm') |
474 | 538 | { |
475 | 539 | $newfullpathselecteddir=$conf->ecm->dir_output.'/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : ''); |
476 | - } |
|
477 | - elseif ($modulepart == 'medias') |
|
540 | + } elseif ($modulepart == 'medias') |
|
478 | 541 | { |
479 | 542 | $newfullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : ''); |
480 | 543 | } |
481 | 544 | |
482 | - if ($newfullpathselecteddir) treeOutputForAbsoluteDir($sqltree, $newselecteddir, $newfullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth+1); |
|
545 | + if ($newfullpathselecteddir) { |
|
546 | + treeOutputForAbsoluteDir($sqltree, $newselecteddir, $newfullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth+1); |
|
547 | + } |
|
483 | 548 | } |
484 | 549 | |
485 | 550 | print "</li>\n"; |
@@ -488,8 +553,9 @@ discard block |
||
488 | 553 | |
489 | 554 | echo "</ul>\n"; |
490 | 555 | } |
556 | + } else { |
|
557 | + print "PermissionDenied"; |
|
491 | 558 | } |
492 | - else print "PermissionDenied"; |
|
493 | 559 | } |
494 | 560 | } |
495 | 561 |
@@ -27,14 +27,25 @@ discard block |
||
27 | 27 | * ajaxdirpreview.php?mode=nojs&action=preview&module=ecm§ion=0&file=xxx |
28 | 28 | */ |
29 | 29 | |
30 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal |
|
31 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); |
|
32 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); |
|
33 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
30 | +if (! defined('NOTOKENRENEWAL')) { |
|
31 | + define('NOTOKENRENEWAL',1); |
|
32 | +} |
|
33 | +// Disables token renewal |
|
34 | +if (! defined('NOREQUIREMENU')) { |
|
35 | + define('NOREQUIREMENU','1'); |
|
36 | +} |
|
37 | +if (! defined('NOREQUIREHTML')) { |
|
38 | + define('NOREQUIREHTML','1'); |
|
39 | +} |
|
40 | +if (! defined('NOREQUIREAJAX')) { |
|
41 | + define('NOREQUIREAJAX','1'); |
|
42 | +} |
|
34 | 43 | |
35 | -if (! isset($mode) || $mode != 'noajax') // For ajax call |
|
44 | +if (! isset($mode) || $mode != 'noajax') { |
|
45 | + // For ajax call |
|
36 | 46 | { |
37 | 47 | require_once '../../main.inc.php'; |
48 | +} |
|
38 | 49 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
39 | 50 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; |
40 | 51 | require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; |
@@ -53,8 +64,12 @@ discard block |
||
53 | 64 | $offset = $conf->liste_limit * $page; |
54 | 65 | $pageprev = $page - 1; |
55 | 66 | $pagenext = $page + 1; |
56 | - if (! $sortorder) $sortorder="ASC"; |
|
57 | - if (! $sortfield) $sortfield="name"; |
|
67 | + if (! $sortorder) { |
|
68 | + $sortorder="ASC"; |
|
69 | + } |
|
70 | + if (! $sortfield) { |
|
71 | + $sortfield="name"; |
|
72 | + } |
|
58 | 73 | |
59 | 74 | $rootdirfordoc = $conf->ecm->dir_output; |
60 | 75 | |
@@ -67,8 +82,7 @@ discard block |
||
67 | 82 | //dol_print_error($db,$ecmdir->error); |
68 | 83 | //exit; |
69 | 84 | } |
70 | -} |
|
71 | -else // For no ajax call |
|
85 | +} else // For no ajax call |
|
72 | 86 | { |
73 | 87 | $rootdirfordoc = $conf->ecm->dir_output; |
74 | 88 | |
@@ -84,8 +98,7 @@ discard block |
||
84 | 98 | } |
85 | 99 | |
86 | 100 | $relativepath=$ecmdir->getRelativePath(); // Example 'mydir/' |
87 | - } |
|
88 | - elseif (GETPOST('section_dir')) |
|
101 | + } elseif (GETPOST('section_dir')) |
|
89 | 102 | { |
90 | 103 | $relativepath=GETPOST('section_dir'); |
91 | 104 | } |
@@ -96,15 +109,20 @@ discard block |
||
96 | 109 | |
97 | 110 | if (empty($url)) |
98 | 111 | { |
99 | - if (GETPOSTISSET('website')) $url=DOL_URL_ROOT.'/website/index.php'; |
|
100 | - else $url=DOL_URL_ROOT.'/ecm/index.php'; |
|
101 | -} |
|
112 | + if (GETPOSTISSET('website')) { |
|
113 | + $url=DOL_URL_ROOT.'/website/index.php'; |
|
114 | + } else { |
|
115 | + $url=DOL_URL_ROOT.'/ecm/index.php'; |
|
116 | + } |
|
117 | + } |
|
102 | 118 | |
103 | 119 | // Load translation files required by the page |
104 | 120 | $langs->loadLangs(array("ecm","companies","other")); |
105 | 121 | |
106 | 122 | // Security check |
107 | -if ($user->societe_id > 0) $socid = $user->societe_id; |
|
123 | +if ($user->societe_id > 0) { |
|
124 | + $socid = $user->societe_id; |
|
125 | +} |
|
108 | 126 | |
109 | 127 | //print 'xxx'.$upload_dir; |
110 | 128 | |
@@ -121,8 +139,10 @@ discard block |
||
121 | 139 | // Check permissions |
122 | 140 | if ($modulepart == 'ecm') |
123 | 141 | { |
124 | - if (! $user->rights->ecm->read) accessforbidden(); |
|
125 | -} |
|
142 | + if (! $user->rights->ecm->read) { |
|
143 | + accessforbidden(); |
|
144 | + } |
|
145 | + } |
|
126 | 146 | if ($modulepart == 'medias') |
127 | 147 | { |
128 | 148 | // Always allowed |
@@ -165,8 +185,12 @@ discard block |
||
165 | 185 | //print '<!-- Page called with mode='.dol_escape_htmltag(isset($mode)?$mode:'').' type='.dol_escape_htmltag($type).' module='.dol_escape_htmltag($module).' url='.dol_escape_htmltag($url).' '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n"; |
166 | 186 | |
167 | 187 | $param=($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:''); |
168 | -if (! empty($websitekey)) $param.='&website='.$websitekey; |
|
169 | -if (! empty($pageid)) $param.='&pageid='.$pageid; |
|
188 | +if (! empty($websitekey)) { |
|
189 | + $param.='&website='.$websitekey; |
|
190 | +} |
|
191 | +if (! empty($pageid)) { |
|
192 | + $param.='&pageid='.$pageid; |
|
193 | +} |
|
170 | 194 | |
171 | 195 | |
172 | 196 | // Dir scan |
@@ -183,45 +207,80 @@ discard block |
||
183 | 207 | |
184 | 208 | // TODO change for multicompany sharing |
185 | 209 | // Auto area for suppliers invoices |
186 | - if ($module == 'company') $upload_dir = $conf->societe->dir_output; |
|
210 | + if ($module == 'company') { |
|
211 | + $upload_dir = $conf->societe->dir_output; |
|
212 | + } |
|
187 | 213 | // Auto area for suppliers invoices |
188 | - else if ($module == 'invoice') $upload_dir = $conf->facture->dir_output; |
|
214 | + else if ($module == 'invoice') { |
|
215 | + $upload_dir = $conf->facture->dir_output; |
|
216 | + } |
|
189 | 217 | // Auto area for suppliers invoices |
190 | - else if ($module == 'invoice_supplier') $upload_dir = $conf->fournisseur->facture->dir_output; |
|
218 | + else if ($module == 'invoice_supplier') { |
|
219 | + $upload_dir = $conf->fournisseur->facture->dir_output; |
|
220 | + } |
|
191 | 221 | // Auto area for customers proposal |
192 | - else if ($module == 'propal') $upload_dir = $conf->propal->dir_output; |
|
222 | + else if ($module == 'propal') { |
|
223 | + $upload_dir = $conf->propal->dir_output; |
|
224 | + } |
|
193 | 225 | // Auto area for suppliers proposal |
194 | - else if ($module == 'supplier_proposal') $upload_dir = $conf->supplier_proposal->dir_output; |
|
226 | + else if ($module == 'supplier_proposal') { |
|
227 | + $upload_dir = $conf->supplier_proposal->dir_output; |
|
228 | + } |
|
195 | 229 | // Auto area for customers orders |
196 | - else if ($module == 'order') $upload_dir = $conf->commande->dir_output; |
|
230 | + else if ($module == 'order') { |
|
231 | + $upload_dir = $conf->commande->dir_output; |
|
232 | + } |
|
197 | 233 | // Auto area for suppliers orders |
198 | - else if ($module == 'order_supplier') $upload_dir = $conf->fournisseur->commande->dir_output; |
|
234 | + else if ($module == 'order_supplier') { |
|
235 | + $upload_dir = $conf->fournisseur->commande->dir_output; |
|
236 | + } |
|
199 | 237 | // Auto area for suppliers invoices |
200 | - else if ($module == 'contract') $upload_dir = $conf->contrat->dir_output; |
|
238 | + else if ($module == 'contract') { |
|
239 | + $upload_dir = $conf->contrat->dir_output; |
|
240 | + } |
|
201 | 241 | // Auto area for products |
202 | - else if ($module == 'product') $upload_dir = $conf->product->dir_output; |
|
242 | + else if ($module == 'product') { |
|
243 | + $upload_dir = $conf->product->dir_output; |
|
244 | + } |
|
203 | 245 | // Auto area for suppliers invoices |
204 | - else if ($module == 'tax') $upload_dir = $conf->tax->dir_output; |
|
246 | + else if ($module == 'tax') { |
|
247 | + $upload_dir = $conf->tax->dir_output; |
|
248 | + } |
|
205 | 249 | // Auto area for projects |
206 | - else if ($module == 'project') $upload_dir = $conf->projet->dir_output; |
|
250 | + else if ($module == 'project') { |
|
251 | + $upload_dir = $conf->projet->dir_output; |
|
252 | + } |
|
207 | 253 | // Auto area for interventions |
208 | - else if ($module == 'fichinter') $upload_dir = $conf->ficheinter->dir_output; |
|
254 | + else if ($module == 'fichinter') { |
|
255 | + $upload_dir = $conf->ficheinter->dir_output; |
|
256 | + } |
|
209 | 257 | // Auto area for users |
210 | - else if ($module == 'user') $upload_dir = $conf->user->dir_output; |
|
258 | + else if ($module == 'user') { |
|
259 | + $upload_dir = $conf->user->dir_output; |
|
260 | + } |
|
211 | 261 | // Auto area for expense report |
212 | - else if ($module == 'expensereport') $upload_dir = $conf->expensereport->dir_output; |
|
262 | + else if ($module == 'expensereport') { |
|
263 | + $upload_dir = $conf->expensereport->dir_output; |
|
264 | + } |
|
213 | 265 | // Auto area for holiday |
214 | - else if ($module == 'holiday') $upload_dir = $conf->holiday->dir_output; |
|
266 | + else if ($module == 'holiday') { |
|
267 | + $upload_dir = $conf->holiday->dir_output; |
|
268 | + } |
|
215 | 269 | |
216 | 270 | // Automatic list |
217 | 271 | if (in_array($module, $automodules)) |
218 | 272 | { |
219 | 273 | $param.='&module='.$module; |
220 | - if (isset($search_doc_ref) && $search_doc_ref != '') $param.='&search_doc_ref='.$search_doc_ref; |
|
274 | + if (isset($search_doc_ref) && $search_doc_ref != '') { |
|
275 | + $param.='&search_doc_ref='.$search_doc_ref; |
|
276 | + } |
|
221 | 277 | |
222 | 278 | $textifempty=($section?$langs->trans("NoFileFound"):($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("NoFileFound"))); |
223 | 279 | |
224 | - if ($module == 'company') $excludefiles[]='^contact$'; // The subdir 'contact' contains files of contacts with no id of thirdparty. |
|
280 | + if ($module == 'company') { |
|
281 | + $excludefiles[]='^contact$'; |
|
282 | + } |
|
283 | + // The subdir 'contact' contains files of contacts with no id of thirdparty. |
|
225 | 284 | |
226 | 285 | $filter=preg_quote($search_doc_ref, '/'); |
227 | 286 | $filearray=dol_dir_list($upload_dir, "files", 1, $filter, $excludefiles, $sortfield, $sorting,1); |
@@ -247,17 +306,22 @@ discard block |
||
247 | 306 | 'sendit' => string 'Envoyer fichier' (length=15) |
248 | 307 | */ |
249 | 308 | $relativepath=GETPOST('file','alpha')?GETPOST('file','alpha'):GETPOST('section_dir','alpha'); |
250 | - if ($relativepath && $relativepath!= '/') $relativepath.='/'; |
|
309 | + if ($relativepath && $relativepath!= '/') { |
|
310 | + $relativepath.='/'; |
|
311 | + } |
|
251 | 312 | $upload_dir = $dolibarr_main_data_root.'/'.$module.'/'.$relativepath; |
252 | 313 | if (GETPOSTISSET('website') || GETPOSTISSET('file_manager')) |
253 | 314 | { |
254 | 315 | $param.='&file_manager=1'; |
255 | - if (!preg_match('/website=/',$param)) $param.='&website='.urlencode(GETPOST('website','alpha')); |
|
256 | - if (!preg_match('/pageid=/',$param)) $param.='&pageid='.urlencode(GETPOST('pageid','int')); |
|
316 | + if (!preg_match('/website=/',$param)) { |
|
317 | + $param.='&website='.urlencode(GETPOST('website','alpha')); |
|
318 | + } |
|
319 | + if (!preg_match('/pageid=/',$param)) { |
|
320 | + $param.='&pageid='.urlencode(GETPOST('pageid','int')); |
|
321 | + } |
|
257 | 322 | //if (!preg_match('/backtopage=/',$param)) $param.='&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid); |
258 | 323 | } |
259 | - } |
|
260 | - else |
|
324 | + } else |
|
261 | 325 | { |
262 | 326 | $relativepath=$ecmdir->getRelativePath(); |
263 | 327 | $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; |
@@ -267,8 +331,7 @@ discard block |
||
267 | 331 | if (($section === '0' || empty($section)) && ($module != 'medias')) |
268 | 332 | { |
269 | 333 | $filearray=array(); |
270 | - } |
|
271 | - else |
|
334 | + } else |
|
272 | 335 | { |
273 | 336 | $filearray=dol_dir_list($upload_dir,"files",0,'',array('^\.','(\.meta|_preview.*\.png)$','^temp$','^CVS$'),$sortfield, $sorting,1); |
274 | 337 | } |
@@ -276,16 +339,21 @@ discard block |
||
276 | 339 | if ($section) |
277 | 340 | { |
278 | 341 | $param.='§ion='.$section; |
279 | - if (isset($search_doc_ref) && $search_doc_ref != '') $param.='&search_doc_ref='.$search_doc_ref; |
|
342 | + if (isset($search_doc_ref) && $search_doc_ref != '') { |
|
343 | + $param.='&search_doc_ref='.$search_doc_ref; |
|
344 | + } |
|
280 | 345 | |
281 | 346 | $textifempty = $langs->trans('NoFileFound'); |
282 | - } |
|
283 | - else if ($section === '0') |
|
347 | + } else if ($section === '0') |
|
284 | 348 | { |
285 | - if ($module == 'ecm') $textifempty='<br><div align="center"><font class="warning">'.$langs->trans("DirNotSynchronizedSyncFirst").'</font></div><br>'; |
|
286 | - else $textifempty = $langs->trans('NoFileFound'); |
|
349 | + if ($module == 'ecm') { |
|
350 | + $textifempty='<br><div align="center"><font class="warning">'.$langs->trans("DirNotSynchronizedSyncFirst").'</font></div><br>'; |
|
351 | + } else { |
|
352 | + $textifempty = $langs->trans('NoFileFound'); |
|
353 | + } |
|
354 | + } else { |
|
355 | + $textifempty=($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("ECMSelectASection")); |
|
287 | 356 | } |
288 | - else $textifempty=($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("ECMSelectASection")); |
|
289 | 357 | |
290 | 358 | if ($module == 'medias') |
291 | 359 | { |
@@ -293,8 +361,7 @@ discard block |
||
293 | 361 | $modulepart='medias'; |
294 | 362 | $perm=($user->rights->website->write || $user->rights->emailing->creer); |
295 | 363 | $title='none'; |
296 | - } |
|
297 | - else |
|
364 | + } else |
|
298 | 365 | { |
299 | 366 | $useinecm = 1; |
300 | 367 | $modulepart='ecm'; |
@@ -313,18 +380,28 @@ discard block |
||
313 | 380 | |
314 | 381 | // Bottom of page |
315 | 382 | $useajax=1; |
316 | -if (! empty($conf->dol_use_jmobile)) $useajax=0; |
|
317 | -if (empty($conf->use_javascript_ajax)) $useajax=0; |
|
318 | -if (! empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax=0; |
|
383 | +if (! empty($conf->dol_use_jmobile)) { |
|
384 | + $useajax=0; |
|
385 | +} |
|
386 | +if (empty($conf->use_javascript_ajax)) { |
|
387 | + $useajax=0; |
|
388 | +} |
|
389 | +if (! empty($conf->global->MAIN_ECM_DISABLE_JS)) { |
|
390 | + $useajax=0; |
|
391 | +} |
|
319 | 392 | |
320 | 393 | //$param.=($param?'?':'').(preg_replace('/^&/','',$param)); |
321 | 394 | |
322 | 395 | if ($useajax || $action == 'delete') |
323 | 396 | { |
324 | 397 | $urlfile=''; |
325 | - if ($action == 'delete') $urlfile=GETPOST('urlfile','alpha'); |
|
398 | + if ($action == 'delete') { |
|
399 | + $urlfile=GETPOST('urlfile','alpha'); |
|
400 | + } |
|
326 | 401 | |
327 | - if (empty($section_dir)) $section_dir=GETPOST("file","alpha"); |
|
402 | + if (empty($section_dir)) { |
|
403 | + $section_dir=GETPOST("file","alpha"); |
|
404 | + } |
|
328 | 405 | $section_id=$section; |
329 | 406 | |
330 | 407 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; |
@@ -334,9 +411,15 @@ discard block |
||
334 | 411 | $formquestion['section']=array('type'=>'hidden','value'=>$section,'name'=>'section'); // We must always put field, even if empty because it is fille by javascript later |
335 | 412 | $formquestion['section_id']=array('type'=>'hidden','value'=>$section_id,'name'=>'section_id'); // We must always put field, even if empty because it is fille by javascript later |
336 | 413 | $formquestion['section_dir']=array('type'=>'hidden','value'=>$section_dir,'name'=>'section_dir'); // We must always put field, even if empty because it is fille by javascript later |
337 | - if (! empty($action) && $action == 'file_manager') $formquestion['file_manager']=array('type'=>'hidden','value'=>1,'name'=>'file_manager'); |
|
338 | - if (! empty($websitekey)) $formquestion['website']=array('type'=>'hidden','value'=>$websitekey,'name'=>'website'); |
|
339 | - if (! empty($pageid) && $pageid > 0) $formquestion['pageid']=array('type'=>'hidden','value'=>$pageid,'name'=>'pageid'); |
|
414 | + if (! empty($action) && $action == 'file_manager') { |
|
415 | + $formquestion['file_manager']=array('type'=>'hidden','value'=>1,'name'=>'file_manager'); |
|
416 | + } |
|
417 | + if (! empty($websitekey)) { |
|
418 | + $formquestion['website']=array('type'=>'hidden','value'=>$websitekey,'name'=>'website'); |
|
419 | + } |
|
420 | + if (! empty($pageid) && $pageid > 0) { |
|
421 | + $formquestion['pageid']=array('type'=>'hidden','value'=>$pageid,'name'=>'pageid'); |
|
422 | + } |
|
340 | 423 | |
341 | 424 | print $form->formconfirm($url,$langs->trans("DeleteFile"),$langs->trans("ConfirmDeleteFile"),'confirm_deletefile',$formquestion,"no",($useajax?'deletefile':0)); |
342 | 425 | } |
@@ -376,4 +459,6 @@ discard block |
||
376 | 459 | } |
377 | 460 | |
378 | 461 | // Close db if mode is not noajax |
379 | -if ((! isset($mode) || $mode != 'noajax') && is_object($db)) $db->close(); |
|
462 | +if ((! isset($mode) || $mode != 'noajax') && is_object($db)) { |
|
463 | + $db->close(); |
|
464 | +} |
@@ -26,11 +26,22 @@ discard block |
||
26 | 26 | |
27 | 27 | if (! isset($usedbyinclude) || empty($usedbyinclude)) |
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'); |
|
33 | - if (! defined('NOREDIRECTBYMAINTOLOGIN')) define('NOREDIRECTBYMAINTOLOGIN','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 | + } |
|
42 | + if (! defined('NOREDIRECTBYMAINTOLOGIN')) { |
|
43 | + define('NOREDIRECTBYMAINTOLOGIN','1'); |
|
44 | + } |
|
34 | 45 | |
35 | 46 | $res=@include '../../main.inc.php'; |
36 | 47 | if ($res == 'ERROR_NOT_LOGGED') |
@@ -38,7 +49,9 @@ discard block |
||
38 | 49 | $langs->load("other"); |
39 | 50 | $arrayresult['jumptologin']=array('img'=>'object_generic', 'label'=>$langs->trans("JumpToLogin"), 'text'=>'<span class="fa fa-sign-in"></span> '.$langs->trans("JumpToLogin"), 'url'=>DOL_URL_ROOT.'/index.php'); |
40 | 51 | print json_encode($arrayresult); |
41 | - if (is_object($db)) $db->close(); |
|
52 | + if (is_object($db)) { |
|
53 | + $db->close(); |
|
54 | + } |
|
42 | 55 | exit; |
43 | 56 | } |
44 | 57 | } |
@@ -152,14 +165,17 @@ discard block |
||
152 | 165 | if (empty($reshook)) |
153 | 166 | { |
154 | 167 | $arrayresult=array_merge($arrayresult, $hookmanager->resArray); |
168 | +} else { |
|
169 | + $arrayresult=$hookmanager->resArray; |
|
155 | 170 | } |
156 | -else $arrayresult=$hookmanager->resArray; |
|
157 | 171 | |
158 | 172 | // This allow to keep a search entry to the top |
159 | 173 | if(! empty($conf->global->DEFAULT_SEARCH_INTO_MODULE)) { |
160 | 174 | $key = 'searchinto'.$conf->global->DEFAULT_SEARCH_INTO_MODULE; |
161 | - if(array_key_exists($key, $arrayresult)) $arrayresult[$key]['position'] = -10; |
|
162 | -} |
|
175 | + if(array_key_exists($key, $arrayresult)) { |
|
176 | + $arrayresult[$key]['position'] = -10; |
|
177 | + } |
|
178 | + } |
|
163 | 179 | |
164 | 180 | // Sort on position |
165 | 181 | $arrayresult = dol_sort_array($arrayresult, 'position'); |
@@ -168,6 +184,8 @@ discard block |
||
168 | 184 | if (! isset($usedbyinclude) || empty($usedbyinclude)) |
169 | 185 | { |
170 | 186 | print json_encode($arrayresult); |
171 | - if (is_object($db)) $db->close(); |
|
172 | -} |
|
187 | + if (is_object($db)) { |
|
188 | + $db->close(); |
|
189 | + } |
|
190 | + } |
|
173 | 191 |
@@ -20,11 +20,22 @@ discard block |
||
20 | 20 | * \brief File to return Ajax response on set 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 | |
@@ -51,20 +62,13 @@ discard block |
||
51 | 62 | $classpath = $subelement = $element; |
52 | 63 | |
53 | 64 | // For compatibility |
54 | - if ($element == 'order' || $element == 'commande') { $classpath = $subelement = 'commande'; } |
|
55 | - else if ($element == 'propal') { $classpath = 'comm/propal'; $subelement = 'propal'; } |
|
56 | - else if ($element == 'facture') { $classpath = 'compta/facture'; $subelement = 'facture'; } |
|
57 | - else if ($element == 'contract') { $classpath = $subelement = 'contrat'; } |
|
58 | - else if ($element == 'shipping') { $classpath = $subelement = 'expedition'; } |
|
59 | - else if ($element == 'deplacement') { $classpath = 'compta/deplacement'; $subelement = 'deplacement'; } |
|
60 | - else if ($element == 'order_supplier') { $classpath = 'fourn'; $subelement = 'fournisseur.commande'; } |
|
61 | - else if ($element == 'invoice_supplier') { $classpath = 'fourn'; $subelement = 'fournisseur.facture'; } |
|
65 | + if ($element == 'order' || $element == 'commande') { $classpath = $subelement = 'commande'; } else if ($element == 'propal') { $classpath = 'comm/propal'; $subelement = 'propal'; } else if ($element == 'facture') { $classpath = 'compta/facture'; $subelement = 'facture'; } else if ($element == 'contract') { $classpath = $subelement = 'contrat'; } else if ($element == 'shipping') { $classpath = $subelement = 'expedition'; } else if ($element == 'deplacement') { $classpath = 'compta/deplacement'; $subelement = 'deplacement'; } else if ($element == 'order_supplier') { $classpath = 'fourn'; $subelement = 'fournisseur.commande'; } else if ($element == 'invoice_supplier') { $classpath = 'fourn'; $subelement = 'fournisseur.facture'; } |
|
62 | 66 | |
63 | 67 | dol_include_once('/'.$classpath.'/class/'.$subelement.'.class.php'); |
64 | 68 | |
65 | - if ($element == 'order_supplier') { $classname = 'CommandeFournisseur'; } |
|
66 | - else if ($element == 'invoice_supplier') { $classname = 'FactureFournisseur'; } |
|
67 | - else $classname = ucfirst($subelement); |
|
69 | + if ($element == 'order_supplier') { $classname = 'CommandeFournisseur'; } else if ($element == 'invoice_supplier') { $classname = 'FactureFournisseur'; } else { |
|
70 | + $classname = ucfirst($subelement); |
|
71 | + } |
|
68 | 72 | |
69 | 73 | $object = new $classname($db); |
70 | 74 | $object->fetch($id); |
@@ -75,15 +75,16 @@ |
||
75 | 75 | setEventMessages($printer->error, $printer->errors); |
76 | 76 | setEventMessages($langs->transnoentitiesnoconv("FileWasSentToPrinter", basename(GETPOST('file', 'alpha'))).' '.$langs->transnoentitiesnoconv("ViaModule").' '.$printer->name, null); |
77 | 77 | } |
78 | - } |
|
79 | - catch(Exception $e) |
|
78 | + } catch(Exception $e) |
|
80 | 79 | { |
81 | 80 | $ret = 1; |
82 | 81 | setEventMessages($e->getMessage(), null, 'errors'); |
83 | 82 | } |
84 | 83 | } |
85 | 84 | } |
86 | - if ($printerfound==0) setEventMessages($langs->trans("NoActivePrintingModuleFound", $langs->transnoentities("Module64000Name")), null, 'warnings'); |
|
85 | + if ($printerfound==0) { |
|
86 | + setEventMessages($langs->trans("NoActivePrintingModuleFound", $langs->transnoentities("Module64000Name")), null, 'warnings'); |
|
87 | + } |
|
87 | 88 | } else { |
88 | 89 | setEventMessages($langs->trans("NoModuleFound"), null, 'warnings'); |
89 | 90 | } |
@@ -23,12 +23,24 @@ |
||
23 | 23 | |
24 | 24 | define('NOLOGIN',1); |
25 | 25 | |
26 | -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER',1); |
|
27 | -if (! defined('NOREQUIREDB')) define('NOREQUIREDB',1); |
|
28 | -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN',1); |
|
29 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); |
|
30 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC',1); |
|
31 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); |
|
26 | +if (! defined('NOREQUIREUSER')) { |
|
27 | + define('NOREQUIREUSER',1); |
|
28 | +} |
|
29 | +if (! defined('NOREQUIREDB')) { |
|
30 | + define('NOREQUIREDB',1); |
|
31 | +} |
|
32 | +if (! defined('NOREQUIRETRAN')) { |
|
33 | + define('NOREQUIRETRAN',1); |
|
34 | +} |
|
35 | +if (! defined('NOREQUIREMENU')) { |
|
36 | + define('NOREQUIREMENU',1); |
|
37 | +} |
|
38 | +if (! defined('NOREQUIRESOC')) { |
|
39 | + define('NOREQUIRESOC',1); |
|
40 | +} |
|
41 | +if (! defined('NOTOKENRENEWAL')) { |
|
42 | + define('NOTOKENRENEWAL',1); |
|
43 | +} |
|
32 | 44 | |
33 | 45 | require_once '../main.inc.php'; |
34 | 46 |