@@ -34,35 +34,35 @@ discard block |
||
34 | 34 | |
35 | 35 | if (! isset($mode) || $mode != 'noajax') // For ajax call |
36 | 36 | { |
37 | - $res=@include '../../main.inc.php'; |
|
38 | - include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
39 | - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
40 | - include_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; |
|
41 | - include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; |
|
42 | - include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; |
|
37 | + $res=@include '../../main.inc.php'; |
|
38 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
39 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
40 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; |
|
41 | + include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; |
|
42 | + include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; |
|
43 | 43 | |
44 | - //if (GETPOST('preopened')) { $_GET['dir'] = $_POST['dir'] = '/bbb/'; } |
|
44 | + //if (GETPOST('preopened')) { $_GET['dir'] = $_POST['dir'] = '/bbb/'; } |
|
45 | 45 | |
46 | - $openeddir = GETPOST('openeddir'); |
|
47 | - $modulepart= GETPOST('modulepart'); |
|
48 | - $selecteddir = jsUnEscape(GETPOST('dir')); // relative path. We must decode using same encoding function used by javascript: escape() |
|
46 | + $openeddir = GETPOST('openeddir'); |
|
47 | + $modulepart= GETPOST('modulepart'); |
|
48 | + $selecteddir = jsUnEscape(GETPOST('dir')); // relative path. We must decode using same encoding function used by javascript: escape() |
|
49 | 49 | |
50 | - $preopened = GETPOST('preopened'); |
|
50 | + $preopened = GETPOST('preopened'); |
|
51 | 51 | |
52 | - if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/','',$selecteddir); // We removed last '/' except if it is '/' |
|
52 | + if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/','',$selecteddir); // We removed last '/' except if it is '/' |
|
53 | 53 | } |
54 | 54 | else // For no ajax call |
55 | 55 | { |
56 | - //if (GETPOST('preopened')) { $_GET['dir'] = $_POST['dir'] = GETPOST('preopened'); } |
|
56 | + //if (GETPOST('preopened')) { $_GET['dir'] = $_POST['dir'] = GETPOST('preopened'); } |
|
57 | 57 | |
58 | - $openeddir = GETPOST('openeddir'); |
|
59 | - $modulepart= GETPOST('modulepart'); |
|
60 | - $selecteddir = GETPOST('dir'); |
|
58 | + $openeddir = GETPOST('openeddir'); |
|
59 | + $modulepart= GETPOST('modulepart'); |
|
60 | + $selecteddir = GETPOST('dir'); |
|
61 | 61 | |
62 | - $preopened = GETPOST('preopened'); |
|
62 | + $preopened = GETPOST('preopened'); |
|
63 | 63 | |
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'; |
|
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 | 66 | } |
67 | 67 | |
68 | 68 | // Load translation files required by the page |
@@ -72,13 +72,13 @@ discard block |
||
72 | 72 | $fullpathselecteddir='<none>'; |
73 | 73 | if ($modulepart == 'ecm') |
74 | 74 | { |
75 | - $fullpathselecteddir=$conf->ecm->dir_output.'/'.($selecteddir != '/' ? $selecteddir : ''); |
|
76 | - $fullpathpreopened=$conf->ecm->dir_output.'/'.($preopened != '/' ? $preopened : ''); |
|
75 | + $fullpathselecteddir=$conf->ecm->dir_output.'/'.($selecteddir != '/' ? $selecteddir : ''); |
|
76 | + $fullpathpreopened=$conf->ecm->dir_output.'/'.($preopened != '/' ? $preopened : ''); |
|
77 | 77 | } |
78 | 78 | elseif ($modulepart == 'medias') |
79 | 79 | { |
80 | - $fullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($selecteddir != '/' ? $selecteddir : ''); |
|
81 | - $fullpathpreopened=$dolibarr_main_data_root.'/medias/'.($preopened != '/' ? $preopened : ''); |
|
80 | + $fullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($selecteddir != '/' ? $selecteddir : ''); |
|
81 | + $fullpathpreopened=$dolibarr_main_data_root.'/medias/'.($preopened != '/' ? $preopened : ''); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | |
@@ -95,11 +95,11 @@ discard block |
||
95 | 95 | // Check permissions |
96 | 96 | if ($modulepart == 'ecm') |
97 | 97 | { |
98 | - if (! $user->rights->ecm->read) accessforbidden(); |
|
98 | + if (! $user->rights->ecm->read) accessforbidden(); |
|
99 | 99 | } |
100 | 100 | elseif ($modulepart == 'medias') |
101 | 101 | { |
102 | - // Always allowed |
|
102 | + // Always allowed |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | |
110 | 110 | if (! isset($mode) || $mode != 'noajax') // if ajax mode |
111 | 111 | { |
112 | - top_httphead(); |
|
112 | + top_httphead(); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | //print '<!-- selecteddir (relative dir we click on) = '.$selecteddir.', openeddir = '.$openeddir.', modulepart='.$modulepart.', preopened='.$preopened.' -->'."\n"; |
@@ -133,13 +133,13 @@ discard block |
||
133 | 133 | |
134 | 134 | if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) |
135 | 135 | { |
136 | - treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened); |
|
136 | + treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened); |
|
137 | 137 | |
138 | - // TODO Find a solution to not output this code for each leaf we open |
|
139 | - // Enable jquery handlers on new generated HTML objects (same code than into lib_footer.js.php) |
|
140 | - // Because the content is reloaded by ajax call, we must also reenable some jquery hooks |
|
141 | - print "\n<!-- JS CODE TO ENABLE Tooltips on all object with class classfortooltip (reload into ajaxdirtree) -->\n"; |
|
142 | - print '<script type="text/javascript"> |
|
138 | + // TODO Find a solution to not output this code for each leaf we open |
|
139 | + // Enable jquery handlers on new generated HTML objects (same code than into lib_footer.js.php) |
|
140 | + // Because the content is reloaded by ajax call, we must also reenable some jquery hooks |
|
141 | + print "\n<!-- JS CODE TO ENABLE Tooltips on all object with class classfortooltip (reload into ajaxdirtree) -->\n"; |
|
142 | + print '<script type="text/javascript"> |
|
143 | 143 | jQuery(document).ready(function () { |
144 | 144 | jQuery(".classfortooltip").tooltip({ |
145 | 145 | show: { collision: "flipfit", effect:\'toggle\', delay:50 }, |
@@ -152,170 +152,170 @@ discard block |
||
152 | 152 | }); |
153 | 153 | </script>'; |
154 | 154 | |
155 | - // This ajax service is called only when a directory $selecteddir is opened but not when closed. |
|
156 | - //print '<script language="javascript">'; |
|
157 | - //print "loadandshowpreview('".dol_escape_js($selecteddir)."');"; |
|
158 | - //print '</script>'; |
|
155 | + // This ajax service is called only when a directory $selecteddir is opened but not when closed. |
|
156 | + //print '<script language="javascript">'; |
|
157 | + //print "loadandshowpreview('".dol_escape_js($selecteddir)."');"; |
|
158 | + //print '</script>'; |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | |
162 | 162 | if (empty($conf->use_javascript_ajax) || ! empty($conf->global->MAIN_ECM_DISABLE_JS)) |
163 | 163 | { |
164 | - print '<ul class="ecmjqft">'; |
|
165 | - |
|
166 | - // 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 |
|
168 | - |
|
169 | - // ----- This section will show a tree from a fulltree array ----- |
|
170 | - // $section must also be defined |
|
171 | - // ---------------------------------------------------------------- |
|
172 | - |
|
173 | - // Define fullpathselected ( _x_y_z ) of $section parameter (!! not into ajaxdirtree) |
|
174 | - $fullpathselected=''; |
|
175 | - foreach($sqltree as $key => $val) |
|
176 | - { |
|
177 | - //print $val['id']."-".$section."<br>"; |
|
178 | - if ($val['id'] == $section) |
|
179 | - { |
|
180 | - $fullpathselected=$val['fullpath']; |
|
181 | - break; |
|
182 | - } |
|
183 | - } |
|
184 | - //print "fullpathselected=".$fullpathselected."<br>"; |
|
185 | - |
|
186 | - // Update expandedsectionarray in session |
|
187 | - $expandedsectionarray=array(); |
|
188 | - if (isset($_SESSION['dol_ecmexpandedsectionarray'])) $expandedsectionarray=explode(',',$_SESSION['dol_ecmexpandedsectionarray']); |
|
189 | - |
|
190 | - if ($section && GETPOST('sectionexpand') == 'true') |
|
191 | - { |
|
192 | - // We add all sections that are parent of opened section |
|
193 | - $pathtosection=explode('_',$fullpathselected); |
|
194 | - foreach($pathtosection as $idcursor) |
|
195 | - { |
|
196 | - if ($idcursor && ! in_array($idcursor,$expandedsectionarray)) // Not already in array |
|
197 | - { |
|
198 | - $expandedsectionarray[]=$idcursor; |
|
199 | - } |
|
200 | - } |
|
201 | - $_SESSION['dol_ecmexpandedsectionarray']=join(',',$expandedsectionarray); |
|
202 | - } |
|
203 | - if ($section && GETPOST('sectionexpand') == 'false') |
|
204 | - { |
|
205 | - // We removed all expanded sections that are child of the closed section |
|
206 | - $oldexpandedsectionarray=$expandedsectionarray; |
|
207 | - $expandedsectionarray=array(); // Reset |
|
208 | - foreach($oldexpandedsectionarray as $sectioncursor) |
|
209 | - { |
|
210 | - // TODO is_in_subtree(fulltree,sectionparent,sectionchild) does nox exists. Enable or remove this... |
|
211 | - //if ($sectioncursor && ! is_in_subtree($sqltree,$section,$sectioncursor)) $expandedsectionarray[]=$sectioncursor; |
|
212 | - } |
|
213 | - $_SESSION['dol_ecmexpandedsectionarray']=join(',',$expandedsectionarray); |
|
214 | - } |
|
215 | - //print $_SESSION['dol_ecmexpandedsectionarray'].'<br>'; |
|
216 | - |
|
217 | - $nbofentries=0; |
|
218 | - $oldvallevel=0; |
|
219 | - foreach($sqltree as $key => $val) |
|
220 | - { |
|
221 | - |
|
222 | - $ecmdirstatic->id=$val['id']; |
|
223 | - $ecmdirstatic->ref=$val['label']; |
|
224 | - |
|
225 | - // Refresh cache |
|
226 | - if (preg_match('/refresh/i',$action)) |
|
227 | - { |
|
228 | - $result=$ecmdirstatic->fetch($val['id']); |
|
229 | - $ecmdirstatic->ref=$ecmdirstatic->label; |
|
230 | - |
|
231 | - $result=$ecmdirstatic->refreshcachenboffile(0); |
|
232 | - $val['cachenbofdoc']=$result; |
|
233 | - } |
|
234 | - |
|
235 | - //$fullpathparent=preg_replace('/(_[^_]+)$/i','',$val['fullpath']); |
|
236 | - |
|
237 | - // Define showline |
|
238 | - $showline=0; |
|
239 | - |
|
240 | - // If directory is son of expanded directory, we show line |
|
241 | - if (in_array($val['id_mere'],$expandedsectionarray)) $showline=4; |
|
242 | - // If directory is brother of selected directory, we show line |
|
243 | - elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) $showline=3; |
|
244 | - // If directory is parent of selected directory or is selected directory, we show line |
|
245 | - elseif (preg_match('/'.$val['fullpath'].'_/i',$fullpathselected.'_')) $showline=2; |
|
246 | - // If we are level one we show line |
|
247 | - elseif ($val['level'] < 2) $showline=1; |
|
248 | - |
|
249 | - if ($showline) |
|
250 | - { |
|
251 | - if (in_array($val['id'],$expandedsectionarray)) $option='indexexpanded'; |
|
252 | - else $option='indexnotexpanded'; |
|
253 | - //print $option; |
|
254 | - |
|
255 | - print '<li class="directory collapsed">'; |
|
256 | - |
|
257 | - // Show tree graph pictos |
|
258 | - $cpt=1; |
|
259 | - while ($cpt < $sqltree[$key]['level']) |
|
260 | - { |
|
261 | - print ' '; |
|
262 | - $cpt++; |
|
263 | - } |
|
264 | - $resarray=tree_showpad($sqltree,$key,1); |
|
265 | - $a=$resarray[0]; |
|
266 | - $nbofsubdir=$resarray[1]; |
|
267 | - $nboffilesinsubdir=$resarray[2]; |
|
268 | - |
|
269 | - // Show link |
|
270 | - print $ecmdirstatic->getNomUrl(0,$option,32,'class="fmdirlia jqft ecmjqft"'); |
|
271 | - |
|
272 | - print '<div class="ecmjqft">'; |
|
273 | - |
|
274 | - // Nb of docs |
|
275 | - print '<table class="nobordernopadding"><tr><td>'; |
|
276 | - print $val['cachenbofdoc']; |
|
277 | - print '</td>'; |
|
278 | - print '<td align="left">'; |
|
279 | - if ($nbofsubdir && $nboffilesinsubdir) print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> '; |
|
280 | - print '</td>'; |
|
281 | - |
|
282 | - // Info |
|
283 | - print '<td align="center">'; |
|
284 | - $userstatic->id=$val['fk_user_c']; |
|
285 | - $userstatic->lastname=$val['login_c']; |
|
286 | - $htmltooltip='<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>'; |
|
287 | - $htmltooltip='<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionManual").'<br>'; |
|
288 | - $htmltooltip.='<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1, '', false, 1).'<br>'; |
|
289 | - $htmltooltip.='<b>'.$langs->trans("ECMCreationDate").'</b>: '.dol_print_date($val['date_c'],"dayhour").'<br>'; |
|
290 | - $htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>'; |
|
291 | - $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>'; |
|
294 | - print $form->textwithpicto('', $htmltooltip, 1, 'info'); |
|
295 | - print "</td>"; |
|
296 | - |
|
297 | - print '</tr></table>'; |
|
298 | - |
|
299 | - print '</div>'; |
|
300 | - |
|
301 | - print "</li>\n"; |
|
302 | - } |
|
303 | - |
|
304 | - $oldvallevel=$val['level']; |
|
305 | - $nbofentries++; |
|
306 | - } |
|
307 | - |
|
308 | - // If nothing to show |
|
309 | - if ($nbofentries == 0) |
|
310 | - { |
|
311 | - print '<li class="directory collapsed">'; |
|
312 | - print '<div class="ecmjqft">'; |
|
313 | - print $langs->trans("ECMNoDirectoryYet"); |
|
314 | - print '</div>'; |
|
315 | - print "</li>\n"; |
|
316 | - } |
|
317 | - |
|
318 | - print '</ul>'; |
|
164 | + print '<ul class="ecmjqft">'; |
|
165 | + |
|
166 | + // 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 |
|
168 | + |
|
169 | + // ----- This section will show a tree from a fulltree array ----- |
|
170 | + // $section must also be defined |
|
171 | + // ---------------------------------------------------------------- |
|
172 | + |
|
173 | + // Define fullpathselected ( _x_y_z ) of $section parameter (!! not into ajaxdirtree) |
|
174 | + $fullpathselected=''; |
|
175 | + foreach($sqltree as $key => $val) |
|
176 | + { |
|
177 | + //print $val['id']."-".$section."<br>"; |
|
178 | + if ($val['id'] == $section) |
|
179 | + { |
|
180 | + $fullpathselected=$val['fullpath']; |
|
181 | + break; |
|
182 | + } |
|
183 | + } |
|
184 | + //print "fullpathselected=".$fullpathselected."<br>"; |
|
185 | + |
|
186 | + // Update expandedsectionarray in session |
|
187 | + $expandedsectionarray=array(); |
|
188 | + if (isset($_SESSION['dol_ecmexpandedsectionarray'])) $expandedsectionarray=explode(',',$_SESSION['dol_ecmexpandedsectionarray']); |
|
189 | + |
|
190 | + if ($section && GETPOST('sectionexpand') == 'true') |
|
191 | + { |
|
192 | + // We add all sections that are parent of opened section |
|
193 | + $pathtosection=explode('_',$fullpathselected); |
|
194 | + foreach($pathtosection as $idcursor) |
|
195 | + { |
|
196 | + if ($idcursor && ! in_array($idcursor,$expandedsectionarray)) // Not already in array |
|
197 | + { |
|
198 | + $expandedsectionarray[]=$idcursor; |
|
199 | + } |
|
200 | + } |
|
201 | + $_SESSION['dol_ecmexpandedsectionarray']=join(',',$expandedsectionarray); |
|
202 | + } |
|
203 | + if ($section && GETPOST('sectionexpand') == 'false') |
|
204 | + { |
|
205 | + // We removed all expanded sections that are child of the closed section |
|
206 | + $oldexpandedsectionarray=$expandedsectionarray; |
|
207 | + $expandedsectionarray=array(); // Reset |
|
208 | + foreach($oldexpandedsectionarray as $sectioncursor) |
|
209 | + { |
|
210 | + // TODO is_in_subtree(fulltree,sectionparent,sectionchild) does nox exists. Enable or remove this... |
|
211 | + //if ($sectioncursor && ! is_in_subtree($sqltree,$section,$sectioncursor)) $expandedsectionarray[]=$sectioncursor; |
|
212 | + } |
|
213 | + $_SESSION['dol_ecmexpandedsectionarray']=join(',',$expandedsectionarray); |
|
214 | + } |
|
215 | + //print $_SESSION['dol_ecmexpandedsectionarray'].'<br>'; |
|
216 | + |
|
217 | + $nbofentries=0; |
|
218 | + $oldvallevel=0; |
|
219 | + foreach($sqltree as $key => $val) |
|
220 | + { |
|
221 | + |
|
222 | + $ecmdirstatic->id=$val['id']; |
|
223 | + $ecmdirstatic->ref=$val['label']; |
|
224 | + |
|
225 | + // Refresh cache |
|
226 | + if (preg_match('/refresh/i',$action)) |
|
227 | + { |
|
228 | + $result=$ecmdirstatic->fetch($val['id']); |
|
229 | + $ecmdirstatic->ref=$ecmdirstatic->label; |
|
230 | + |
|
231 | + $result=$ecmdirstatic->refreshcachenboffile(0); |
|
232 | + $val['cachenbofdoc']=$result; |
|
233 | + } |
|
234 | + |
|
235 | + //$fullpathparent=preg_replace('/(_[^_]+)$/i','',$val['fullpath']); |
|
236 | + |
|
237 | + // Define showline |
|
238 | + $showline=0; |
|
239 | + |
|
240 | + // If directory is son of expanded directory, we show line |
|
241 | + if (in_array($val['id_mere'],$expandedsectionarray)) $showline=4; |
|
242 | + // If directory is brother of selected directory, we show line |
|
243 | + elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) $showline=3; |
|
244 | + // If directory is parent of selected directory or is selected directory, we show line |
|
245 | + elseif (preg_match('/'.$val['fullpath'].'_/i',$fullpathselected.'_')) $showline=2; |
|
246 | + // If we are level one we show line |
|
247 | + elseif ($val['level'] < 2) $showline=1; |
|
248 | + |
|
249 | + if ($showline) |
|
250 | + { |
|
251 | + if (in_array($val['id'],$expandedsectionarray)) $option='indexexpanded'; |
|
252 | + else $option='indexnotexpanded'; |
|
253 | + //print $option; |
|
254 | + |
|
255 | + print '<li class="directory collapsed">'; |
|
256 | + |
|
257 | + // Show tree graph pictos |
|
258 | + $cpt=1; |
|
259 | + while ($cpt < $sqltree[$key]['level']) |
|
260 | + { |
|
261 | + print ' '; |
|
262 | + $cpt++; |
|
263 | + } |
|
264 | + $resarray=tree_showpad($sqltree,$key,1); |
|
265 | + $a=$resarray[0]; |
|
266 | + $nbofsubdir=$resarray[1]; |
|
267 | + $nboffilesinsubdir=$resarray[2]; |
|
268 | + |
|
269 | + // Show link |
|
270 | + print $ecmdirstatic->getNomUrl(0,$option,32,'class="fmdirlia jqft ecmjqft"'); |
|
271 | + |
|
272 | + print '<div class="ecmjqft">'; |
|
273 | + |
|
274 | + // Nb of docs |
|
275 | + print '<table class="nobordernopadding"><tr><td>'; |
|
276 | + print $val['cachenbofdoc']; |
|
277 | + print '</td>'; |
|
278 | + print '<td align="left">'; |
|
279 | + if ($nbofsubdir && $nboffilesinsubdir) print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> '; |
|
280 | + print '</td>'; |
|
281 | + |
|
282 | + // Info |
|
283 | + print '<td align="center">'; |
|
284 | + $userstatic->id=$val['fk_user_c']; |
|
285 | + $userstatic->lastname=$val['login_c']; |
|
286 | + $htmltooltip='<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>'; |
|
287 | + $htmltooltip='<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionManual").'<br>'; |
|
288 | + $htmltooltip.='<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1, '', false, 1).'<br>'; |
|
289 | + $htmltooltip.='<b>'.$langs->trans("ECMCreationDate").'</b>: '.dol_print_date($val['date_c'],"dayhour").'<br>'; |
|
290 | + $htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>'; |
|
291 | + $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>'; |
|
294 | + print $form->textwithpicto('', $htmltooltip, 1, 'info'); |
|
295 | + print "</td>"; |
|
296 | + |
|
297 | + print '</tr></table>'; |
|
298 | + |
|
299 | + print '</div>'; |
|
300 | + |
|
301 | + print "</li>\n"; |
|
302 | + } |
|
303 | + |
|
304 | + $oldvallevel=$val['level']; |
|
305 | + $nbofentries++; |
|
306 | + } |
|
307 | + |
|
308 | + // If nothing to show |
|
309 | + if ($nbofentries == 0) |
|
310 | + { |
|
311 | + print '<li class="directory collapsed">'; |
|
312 | + print '<div class="ecmjqft">'; |
|
313 | + print $langs->trans("ECMNoDirectoryYet"); |
|
314 | + print '</div>'; |
|
315 | + print "</li>\n"; |
|
316 | + } |
|
317 | + |
|
318 | + print '</ul>'; |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | |
@@ -340,156 +340,156 @@ discard block |
||
340 | 340 | */ |
341 | 341 | function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth=0) |
342 | 342 | { |
343 | - global $conf, $db, $langs, $form; |
|
344 | - global $dolibarr_main_data_root; |
|
345 | - |
|
346 | - $ecmdirstatic = new EcmDirectory($db); |
|
347 | - $userstatic = new User($db); |
|
348 | - |
|
349 | - if (file_exists($fullpathselecteddir)) |
|
350 | - { |
|
351 | - $files = @scandir($fullpathselecteddir); |
|
352 | - |
|
353 | - if (! empty($files)) |
|
354 | - { |
|
355 | - natcasesort($files); |
|
356 | - if (count($files) > 2) /* The 2 accounts for . and .. */ |
|
357 | - { |
|
358 | - echo '<ul class="ecmjqft" style="display: none;">'."\n"; |
|
359 | - |
|
360 | - // All dirs |
|
361 | - foreach ($files as $file) // $file can be '.', '..', or 'My dir' or 'My file' |
|
362 | - { |
|
363 | - if ($file == 'temp') continue; |
|
364 | - |
|
365 | - $nbofsubdir=0; |
|
366 | - $nboffilesinsubdir=0; |
|
367 | - |
|
368 | - $val=array(); |
|
369 | - |
|
370 | - // Loop on all database entries (sqltree) to find the one matching the subdir found into dir to scan |
|
371 | - foreach($sqltree as $key => $tmpval) |
|
372 | - { |
|
373 | - //print "-- key=".$key." - ".$tmpval['fullrelativename']." vs ".(($selecteddir != '/'?$selecteddir.'/':'').$file)."<br>\n"; |
|
374 | - if ($tmpval['fullrelativename'] == (($selecteddir != '/'?$selecteddir.'/':'').$file)) // We found equivalent record into database |
|
375 | - { |
|
376 | - $val=$tmpval; |
|
377 | - $resarray=tree_showpad($sqltree,$key,1); |
|
378 | - |
|
379 | - // 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 |
|
381 | - { |
|
382 | - $result=$ecmdirstatic->fetch($val['id']); |
|
383 | - $ecmdirstatic->ref=$ecmdirstatic->label; |
|
384 | - |
|
385 | - $result=$ecmdirstatic->refreshcachenboffile(0); |
|
386 | - $val['cachenbofdoc']=$result; |
|
387 | - } |
|
388 | - |
|
389 | - $a=$resarray[0]; |
|
390 | - $nbofsubdir=$resarray[1]; |
|
391 | - $nboffilesinsubdir=$resarray[2]; |
|
392 | - break; |
|
393 | - } |
|
394 | - } |
|
395 | - |
|
396 | - //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 | - if ($file != '.' && $file != '..' && ((! empty($val['fullrelativename']) && $val['id'] >= 0) || dol_is_dir($fullpathselecteddir . (preg_match('/\/$/',$fullpathselecteddir)?'':'/') . $file))) |
|
398 | - { |
|
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) |
|
400 | - { |
|
401 | - $val['fullrelativename']=(($selecteddir && $selecteddir != '/')?$selecteddir.'/':'').$file; |
|
402 | - $val['id']=0; |
|
403 | - $val['label']=$file; |
|
404 | - $val['description']=''; |
|
405 | - $nboffilesinsubdir=$langs->trans("Unknown"); |
|
406 | - } |
|
407 | - |
|
408 | - $collapsedorexpanded='collapsed'; |
|
409 | - if (preg_match('/^'.preg_quote($val['fullrelativename'].'/', '/').'/', $preopened)) $collapsedorexpanded='expanded'; |
|
410 | - print '<li class="directory '.$collapsedorexpanded.'">'; // collapsed is opposite if expanded |
|
411 | - |
|
412 | - print "<a class=\"fmdirlia jqft ecmjqft\" href=\""; |
|
413 | - print "#"; |
|
414 | - print "\" rel=\"" . dol_escape_htmltag($val['fullrelativename'].'/') . "\" id=\"fmdirlia_id_".$val['id']."\""; |
|
415 | - print " onClick=\"loadandshowpreview('".dol_escape_js($val['fullrelativename'])."',".$val['id'].")"; |
|
416 | - print "\">"; |
|
417 | - print dol_escape_htmltag($file); |
|
418 | - print "</a>"; |
|
419 | - |
|
420 | - print '<div class="ecmjqft">'; |
|
421 | - |
|
422 | - print '<table class="nobordernopadding"><tr>'; |
|
423 | - |
|
424 | - /*print '<td align="left">'; |
|
343 | + global $conf, $db, $langs, $form; |
|
344 | + global $dolibarr_main_data_root; |
|
345 | + |
|
346 | + $ecmdirstatic = new EcmDirectory($db); |
|
347 | + $userstatic = new User($db); |
|
348 | + |
|
349 | + if (file_exists($fullpathselecteddir)) |
|
350 | + { |
|
351 | + $files = @scandir($fullpathselecteddir); |
|
352 | + |
|
353 | + if (! empty($files)) |
|
354 | + { |
|
355 | + natcasesort($files); |
|
356 | + if (count($files) > 2) /* The 2 accounts for . and .. */ |
|
357 | + { |
|
358 | + echo '<ul class="ecmjqft" style="display: none;">'."\n"; |
|
359 | + |
|
360 | + // All dirs |
|
361 | + foreach ($files as $file) // $file can be '.', '..', or 'My dir' or 'My file' |
|
362 | + { |
|
363 | + if ($file == 'temp') continue; |
|
364 | + |
|
365 | + $nbofsubdir=0; |
|
366 | + $nboffilesinsubdir=0; |
|
367 | + |
|
368 | + $val=array(); |
|
369 | + |
|
370 | + // Loop on all database entries (sqltree) to find the one matching the subdir found into dir to scan |
|
371 | + foreach($sqltree as $key => $tmpval) |
|
372 | + { |
|
373 | + //print "-- key=".$key." - ".$tmpval['fullrelativename']." vs ".(($selecteddir != '/'?$selecteddir.'/':'').$file)."<br>\n"; |
|
374 | + if ($tmpval['fullrelativename'] == (($selecteddir != '/'?$selecteddir.'/':'').$file)) // We found equivalent record into database |
|
375 | + { |
|
376 | + $val=$tmpval; |
|
377 | + $resarray=tree_showpad($sqltree,$key,1); |
|
378 | + |
|
379 | + // 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 |
|
381 | + { |
|
382 | + $result=$ecmdirstatic->fetch($val['id']); |
|
383 | + $ecmdirstatic->ref=$ecmdirstatic->label; |
|
384 | + |
|
385 | + $result=$ecmdirstatic->refreshcachenboffile(0); |
|
386 | + $val['cachenbofdoc']=$result; |
|
387 | + } |
|
388 | + |
|
389 | + $a=$resarray[0]; |
|
390 | + $nbofsubdir=$resarray[1]; |
|
391 | + $nboffilesinsubdir=$resarray[2]; |
|
392 | + break; |
|
393 | + } |
|
394 | + } |
|
395 | + |
|
396 | + //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 | + if ($file != '.' && $file != '..' && ((! empty($val['fullrelativename']) && $val['id'] >= 0) || dol_is_dir($fullpathselecteddir . (preg_match('/\/$/',$fullpathselecteddir)?'':'/') . $file))) |
|
398 | + { |
|
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) |
|
400 | + { |
|
401 | + $val['fullrelativename']=(($selecteddir && $selecteddir != '/')?$selecteddir.'/':'').$file; |
|
402 | + $val['id']=0; |
|
403 | + $val['label']=$file; |
|
404 | + $val['description']=''; |
|
405 | + $nboffilesinsubdir=$langs->trans("Unknown"); |
|
406 | + } |
|
407 | + |
|
408 | + $collapsedorexpanded='collapsed'; |
|
409 | + if (preg_match('/^'.preg_quote($val['fullrelativename'].'/', '/').'/', $preopened)) $collapsedorexpanded='expanded'; |
|
410 | + print '<li class="directory '.$collapsedorexpanded.'">'; // collapsed is opposite if expanded |
|
411 | + |
|
412 | + print "<a class=\"fmdirlia jqft ecmjqft\" href=\""; |
|
413 | + print "#"; |
|
414 | + print "\" rel=\"" . dol_escape_htmltag($val['fullrelativename'].'/') . "\" id=\"fmdirlia_id_".$val['id']."\""; |
|
415 | + print " onClick=\"loadandshowpreview('".dol_escape_js($val['fullrelativename'])."',".$val['id'].")"; |
|
416 | + print "\">"; |
|
417 | + print dol_escape_htmltag($file); |
|
418 | + print "</a>"; |
|
419 | + |
|
420 | + print '<div class="ecmjqft">'; |
|
421 | + |
|
422 | + print '<table class="nobordernopadding"><tr>'; |
|
423 | + |
|
424 | + /*print '<td align="left">'; |
|
425 | 425 | print dol_escape_htmltag($file); |
426 | 426 | print '</td>';*/ |
427 | 427 | |
428 | - // Nb of docs |
|
429 | - print '<td align="right">'; |
|
430 | - print (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0)?$val['cachenbofdoc']:' '; |
|
431 | - print '</td>'; |
|
432 | - print '<td align="left">'; |
|
433 | - if ($nbofsubdir > 0 && $nboffilesinsubdir > 0) print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> '; |
|
434 | - print '</td>'; |
|
435 | - |
|
436 | - // Edit link |
|
437 | - print '<td align="right" width="18"><a href="'; |
|
438 | - print DOL_URL_ROOT.'/ecm/dir_card.php?module='.urlencode($modulepart).'§ion='.$val['id'].'&relativedir='.urlencode($val['fullrelativename']); |
|
439 | - print '&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid); |
|
440 | - print '">'.img_edit($langs->trans("Edit").' - '.$langs->trans("View"), 0, 'class="valignmiddle opacitymedium"').'</a></td>'; |
|
441 | - |
|
442 | - // Add link |
|
443 | - //print '<td align="right"><a href="'.DOL_URL_ROOT.'/ecm/dir_add_card.php?action=create&catParent='.$val['id'].'">'.img_edit_add().'</a></td>'; |
|
444 | - //print '<td align="right" width="14"> </td>'; |
|
445 | - |
|
446 | - // Info |
|
447 | - if ($modulepart == 'ecm') |
|
448 | - { |
|
449 | - print '<td align="right" width="18">'; |
|
450 | - $userstatic->id=isset($val['fk_user_c'])?$val['fk_user_c']:0; |
|
451 | - $userstatic->lastname=isset($val['login_c'])?$val['login_c']:0; |
|
452 | - $htmltooltip='<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>'; |
|
453 | - $htmltooltip='<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionManual").'<br>'; |
|
454 | - $htmltooltip.='<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1, '', false, 1).'<br>'; |
|
455 | - $htmltooltip.='<b>'.$langs->trans("ECMCreationDate").'</b>: '.(isset($val['date_c'])?dol_print_date($val['date_c'],"dayhour"):$langs->trans("NeedRefresh")).'<br>'; |
|
456 | - $htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>'; |
|
457 | - $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>'; |
|
460 | - print $form->textwithpicto('',$htmltooltip,1,"info"); |
|
461 | - print "</td>"; |
|
462 | - } |
|
463 | - |
|
464 | - print "</tr></table>\n"; |
|
465 | - print '</div>'; |
|
466 | - |
|
467 | - //print 'selecteddir='.$selecteddir.' preopened='.$preopened.' $val[\'fullrelativename\']='.$val['fullrelativename']."<br>\n"; |
|
468 | - if (preg_match('/^'.preg_quote($val['fullrelativename'].'/', '/').'/', $preopened)) |
|
469 | - { |
|
470 | - //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"; |
|
471 | - $newselecteddir = $val['fullrelativename']; |
|
472 | - $newfullpathselecteddir=''; |
|
473 | - if ($modulepart == 'ecm') |
|
474 | - { |
|
475 | - $newfullpathselecteddir=$conf->ecm->dir_output.'/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : ''); |
|
476 | - } |
|
477 | - elseif ($modulepart == 'medias') |
|
478 | - { |
|
479 | - $newfullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : ''); |
|
480 | - } |
|
481 | - |
|
482 | - if ($newfullpathselecteddir) treeOutputForAbsoluteDir($sqltree, $newselecteddir, $newfullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth+1); |
|
483 | - } |
|
484 | - |
|
485 | - print "</li>\n"; |
|
486 | - } |
|
487 | - } |
|
488 | - |
|
489 | - echo "</ul>\n"; |
|
490 | - } |
|
491 | - } |
|
492 | - else print "PermissionDenied"; |
|
493 | - } |
|
428 | + // Nb of docs |
|
429 | + print '<td align="right">'; |
|
430 | + print (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0)?$val['cachenbofdoc']:' '; |
|
431 | + print '</td>'; |
|
432 | + print '<td align="left">'; |
|
433 | + if ($nbofsubdir > 0 && $nboffilesinsubdir > 0) print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> '; |
|
434 | + print '</td>'; |
|
435 | + |
|
436 | + // Edit link |
|
437 | + print '<td align="right" width="18"><a href="'; |
|
438 | + print DOL_URL_ROOT.'/ecm/dir_card.php?module='.urlencode($modulepart).'§ion='.$val['id'].'&relativedir='.urlencode($val['fullrelativename']); |
|
439 | + print '&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid); |
|
440 | + print '">'.img_edit($langs->trans("Edit").' - '.$langs->trans("View"), 0, 'class="valignmiddle opacitymedium"').'</a></td>'; |
|
441 | + |
|
442 | + // Add link |
|
443 | + //print '<td align="right"><a href="'.DOL_URL_ROOT.'/ecm/dir_add_card.php?action=create&catParent='.$val['id'].'">'.img_edit_add().'</a></td>'; |
|
444 | + //print '<td align="right" width="14"> </td>'; |
|
445 | + |
|
446 | + // Info |
|
447 | + if ($modulepart == 'ecm') |
|
448 | + { |
|
449 | + print '<td align="right" width="18">'; |
|
450 | + $userstatic->id=isset($val['fk_user_c'])?$val['fk_user_c']:0; |
|
451 | + $userstatic->lastname=isset($val['login_c'])?$val['login_c']:0; |
|
452 | + $htmltooltip='<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>'; |
|
453 | + $htmltooltip='<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionManual").'<br>'; |
|
454 | + $htmltooltip.='<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1, '', false, 1).'<br>'; |
|
455 | + $htmltooltip.='<b>'.$langs->trans("ECMCreationDate").'</b>: '.(isset($val['date_c'])?dol_print_date($val['date_c'],"dayhour"):$langs->trans("NeedRefresh")).'<br>'; |
|
456 | + $htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>'; |
|
457 | + $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>'; |
|
460 | + print $form->textwithpicto('',$htmltooltip,1,"info"); |
|
461 | + print "</td>"; |
|
462 | + } |
|
463 | + |
|
464 | + print "</tr></table>\n"; |
|
465 | + print '</div>'; |
|
466 | + |
|
467 | + //print 'selecteddir='.$selecteddir.' preopened='.$preopened.' $val[\'fullrelativename\']='.$val['fullrelativename']."<br>\n"; |
|
468 | + if (preg_match('/^'.preg_quote($val['fullrelativename'].'/', '/').'/', $preopened)) |
|
469 | + { |
|
470 | + //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"; |
|
471 | + $newselecteddir = $val['fullrelativename']; |
|
472 | + $newfullpathselecteddir=''; |
|
473 | + if ($modulepart == 'ecm') |
|
474 | + { |
|
475 | + $newfullpathselecteddir=$conf->ecm->dir_output.'/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : ''); |
|
476 | + } |
|
477 | + elseif ($modulepart == 'medias') |
|
478 | + { |
|
479 | + $newfullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : ''); |
|
480 | + } |
|
481 | + |
|
482 | + if ($newfullpathselecteddir) treeOutputForAbsoluteDir($sqltree, $newselecteddir, $newfullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth+1); |
|
483 | + } |
|
484 | + |
|
485 | + print "</li>\n"; |
|
486 | + } |
|
487 | + } |
|
488 | + |
|
489 | + echo "</ul>\n"; |
|
490 | + } |
|
491 | + } |
|
492 | + else print "PermissionDenied"; |
|
493 | + } |
|
494 | 494 | } |
495 | 495 |
@@ -26,15 +26,15 @@ 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')) 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 | 33 | |
34 | 34 | |
35 | -if (! isset($mode) || $mode != 'noajax') // For ajax call |
|
35 | +if (!isset($mode) || $mode != 'noajax') // For ajax call |
|
36 | 36 | { |
37 | - $res=@include '../../main.inc.php'; |
|
37 | + $res = @include '../../main.inc.php'; |
|
38 | 38 | include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
39 | 39 | include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
40 | 40 | include_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; |
@@ -44,58 +44,58 @@ discard block |
||
44 | 44 | //if (GETPOST('preopened')) { $_GET['dir'] = $_POST['dir'] = '/bbb/'; } |
45 | 45 | |
46 | 46 | $openeddir = GETPOST('openeddir'); |
47 | - $modulepart= GETPOST('modulepart'); |
|
48 | - $selecteddir = jsUnEscape(GETPOST('dir')); // relative path. We must decode using same encoding function used by javascript: escape() |
|
47 | + $modulepart = GETPOST('modulepart'); |
|
48 | + $selecteddir = jsUnEscape(GETPOST('dir')); // relative path. We must decode using same encoding function used by javascript: escape() |
|
49 | 49 | |
50 | 50 | $preopened = GETPOST('preopened'); |
51 | 51 | |
52 | - if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/','',$selecteddir); // We removed last '/' except if it is '/' |
|
52 | + if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/', '', $selecteddir); // We removed last '/' except if it is '/' |
|
53 | 53 | } |
54 | 54 | else // For no ajax call |
55 | 55 | { |
56 | 56 | //if (GETPOST('preopened')) { $_GET['dir'] = $_POST['dir'] = GETPOST('preopened'); } |
57 | 57 | |
58 | 58 | $openeddir = GETPOST('openeddir'); |
59 | - $modulepart= GETPOST('modulepart'); |
|
59 | + $modulepart = GETPOST('modulepart'); |
|
60 | 60 | $selecteddir = GETPOST('dir'); |
61 | 61 | |
62 | 62 | $preopened = GETPOST('preopened'); |
63 | 63 | |
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'; |
|
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 | 66 | } |
67 | 67 | |
68 | 68 | // Load translation files required by the page |
69 | 69 | $langs->load("ecm"); |
70 | 70 | |
71 | 71 | // Define fullpathselecteddir. |
72 | -$fullpathselecteddir='<none>'; |
|
72 | +$fullpathselecteddir = '<none>'; |
|
73 | 73 | if ($modulepart == 'ecm') |
74 | 74 | { |
75 | - $fullpathselecteddir=$conf->ecm->dir_output.'/'.($selecteddir != '/' ? $selecteddir : ''); |
|
76 | - $fullpathpreopened=$conf->ecm->dir_output.'/'.($preopened != '/' ? $preopened : ''); |
|
75 | + $fullpathselecteddir = $conf->ecm->dir_output.'/'.($selecteddir != '/' ? $selecteddir : ''); |
|
76 | + $fullpathpreopened = $conf->ecm->dir_output.'/'.($preopened != '/' ? $preopened : ''); |
|
77 | 77 | } |
78 | 78 | elseif ($modulepart == 'medias') |
79 | 79 | { |
80 | - $fullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($selecteddir != '/' ? $selecteddir : ''); |
|
81 | - $fullpathpreopened=$dolibarr_main_data_root.'/medias/'.($preopened != '/' ? $preopened : ''); |
|
80 | + $fullpathselecteddir = $dolibarr_main_data_root.'/medias/'.($selecteddir != '/' ? $selecteddir : ''); |
|
81 | + $fullpathpreopened = $dolibarr_main_data_root.'/medias/'.($preopened != '/' ? $preopened : ''); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | |
85 | 85 | // Security: |
86 | 86 | // On interdit les remontees de repertoire ainsi que les pipe dans les noms de fichiers. |
87 | -if (preg_match('/\.\./',$fullpathselecteddir) || preg_match('/[<>|]/',$fullpathselecteddir)) |
|
87 | +if (preg_match('/\.\./', $fullpathselecteddir) || preg_match('/[<>|]/', $fullpathselecteddir)) |
|
88 | 88 | { |
89 | 89 | dol_syslog("Refused to deliver file ".$original_file); |
90 | 90 | // Do no show plain path in shown error message |
91 | - dol_print_error(0,$langs->trans("ErrorFileNameInvalid",GETPOST("file"))); |
|
91 | + dol_print_error(0, $langs->trans("ErrorFileNameInvalid", GETPOST("file"))); |
|
92 | 92 | exit; |
93 | 93 | } |
94 | 94 | |
95 | 95 | // Check permissions |
96 | 96 | if ($modulepart == 'ecm') |
97 | 97 | { |
98 | - if (! $user->rights->ecm->read) accessforbidden(); |
|
98 | + if (!$user->rights->ecm->read) accessforbidden(); |
|
99 | 99 | } |
100 | 100 | elseif ($modulepart == 'medias') |
101 | 101 | { |
@@ -107,22 +107,22 @@ discard block |
||
107 | 107 | * View |
108 | 108 | */ |
109 | 109 | |
110 | -if (! isset($mode) || $mode != 'noajax') // if ajax mode |
|
110 | +if (!isset($mode) || $mode != 'noajax') // if ajax mode |
|
111 | 111 | { |
112 | 112 | top_httphead(); |
113 | 113 | } |
114 | 114 | |
115 | 115 | //print '<!-- selecteddir (relative dir we click on) = '.$selecteddir.', openeddir = '.$openeddir.', modulepart='.$modulepart.', preopened='.$preopened.' -->'."\n"; |
116 | -$userstatic=new User($db); |
|
117 | -$form=new Form($db); |
|
116 | +$userstatic = new User($db); |
|
117 | +$form = new Form($db); |
|
118 | 118 | $ecmdirstatic = new EcmDirectory($db); |
119 | 119 | |
120 | 120 | // 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); |
|
121 | +if (empty($sqltree)) $sqltree = $ecmdirstatic->get_full_arbo(0); |
|
122 | 122 | |
123 | 123 | // Try to find selected dir id into $sqltree and save it into $current_ecmdir_id |
124 | -$current_ecmdir_id=-1; |
|
125 | -foreach($sqltree as $keycursor => $val) |
|
124 | +$current_ecmdir_id = -1; |
|
125 | +foreach ($sqltree as $keycursor => $val) |
|
126 | 126 | { |
127 | 127 | //print $val['fullrelativename']." == ".$selecteddir; |
128 | 128 | if ($val['fullrelativename'] == $selecteddir) |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
134 | -if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) |
|
134 | +if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) |
|
135 | 135 | { |
136 | 136 | treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened); |
137 | 137 | |
@@ -159,115 +159,115 @@ discard block |
||
159 | 159 | } |
160 | 160 | |
161 | 161 | |
162 | -if (empty($conf->use_javascript_ajax) || ! empty($conf->global->MAIN_ECM_DISABLE_JS)) |
|
162 | +if (empty($conf->use_javascript_ajax) || !empty($conf->global->MAIN_ECM_DISABLE_JS)) |
|
163 | 163 | { |
164 | 164 | print '<ul class="ecmjqft">'; |
165 | 165 | |
166 | 166 | // 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 |
|
167 | + if (empty($sqltree)) $sqltree = $ecmdirstatic->get_full_arbo(0); // Slow |
|
168 | 168 | |
169 | 169 | // ----- This section will show a tree from a fulltree array ----- |
170 | 170 | // $section must also be defined |
171 | 171 | // ---------------------------------------------------------------- |
172 | 172 | |
173 | 173 | // Define fullpathselected ( _x_y_z ) of $section parameter (!! not into ajaxdirtree) |
174 | - $fullpathselected=''; |
|
175 | - foreach($sqltree as $key => $val) |
|
174 | + $fullpathselected = ''; |
|
175 | + foreach ($sqltree as $key => $val) |
|
176 | 176 | { |
177 | 177 | //print $val['id']."-".$section."<br>"; |
178 | 178 | if ($val['id'] == $section) |
179 | 179 | { |
180 | - $fullpathselected=$val['fullpath']; |
|
180 | + $fullpathselected = $val['fullpath']; |
|
181 | 181 | break; |
182 | 182 | } |
183 | 183 | } |
184 | 184 | //print "fullpathselected=".$fullpathselected."<br>"; |
185 | 185 | |
186 | 186 | // Update expandedsectionarray in session |
187 | - $expandedsectionarray=array(); |
|
188 | - if (isset($_SESSION['dol_ecmexpandedsectionarray'])) $expandedsectionarray=explode(',',$_SESSION['dol_ecmexpandedsectionarray']); |
|
187 | + $expandedsectionarray = array(); |
|
188 | + if (isset($_SESSION['dol_ecmexpandedsectionarray'])) $expandedsectionarray = explode(',', $_SESSION['dol_ecmexpandedsectionarray']); |
|
189 | 189 | |
190 | 190 | if ($section && GETPOST('sectionexpand') == 'true') |
191 | 191 | { |
192 | 192 | // We add all sections that are parent of opened section |
193 | - $pathtosection=explode('_',$fullpathselected); |
|
194 | - foreach($pathtosection as $idcursor) |
|
193 | + $pathtosection = explode('_', $fullpathselected); |
|
194 | + foreach ($pathtosection as $idcursor) |
|
195 | 195 | { |
196 | - if ($idcursor && ! in_array($idcursor,$expandedsectionarray)) // Not already in array |
|
196 | + if ($idcursor && !in_array($idcursor, $expandedsectionarray)) // Not already in array |
|
197 | 197 | { |
198 | - $expandedsectionarray[]=$idcursor; |
|
198 | + $expandedsectionarray[] = $idcursor; |
|
199 | 199 | } |
200 | 200 | } |
201 | - $_SESSION['dol_ecmexpandedsectionarray']=join(',',$expandedsectionarray); |
|
201 | + $_SESSION['dol_ecmexpandedsectionarray'] = join(',', $expandedsectionarray); |
|
202 | 202 | } |
203 | 203 | if ($section && GETPOST('sectionexpand') == 'false') |
204 | 204 | { |
205 | 205 | // We removed all expanded sections that are child of the closed section |
206 | - $oldexpandedsectionarray=$expandedsectionarray; |
|
207 | - $expandedsectionarray=array(); // Reset |
|
208 | - foreach($oldexpandedsectionarray as $sectioncursor) |
|
206 | + $oldexpandedsectionarray = $expandedsectionarray; |
|
207 | + $expandedsectionarray = array(); // Reset |
|
208 | + foreach ($oldexpandedsectionarray as $sectioncursor) |
|
209 | 209 | { |
210 | 210 | // TODO is_in_subtree(fulltree,sectionparent,sectionchild) does nox exists. Enable or remove this... |
211 | 211 | //if ($sectioncursor && ! is_in_subtree($sqltree,$section,$sectioncursor)) $expandedsectionarray[]=$sectioncursor; |
212 | 212 | } |
213 | - $_SESSION['dol_ecmexpandedsectionarray']=join(',',$expandedsectionarray); |
|
213 | + $_SESSION['dol_ecmexpandedsectionarray'] = join(',', $expandedsectionarray); |
|
214 | 214 | } |
215 | 215 | //print $_SESSION['dol_ecmexpandedsectionarray'].'<br>'; |
216 | 216 | |
217 | - $nbofentries=0; |
|
218 | - $oldvallevel=0; |
|
219 | - foreach($sqltree as $key => $val) |
|
217 | + $nbofentries = 0; |
|
218 | + $oldvallevel = 0; |
|
219 | + foreach ($sqltree as $key => $val) |
|
220 | 220 | { |
221 | 221 | |
222 | - $ecmdirstatic->id=$val['id']; |
|
223 | - $ecmdirstatic->ref=$val['label']; |
|
222 | + $ecmdirstatic->id = $val['id']; |
|
223 | + $ecmdirstatic->ref = $val['label']; |
|
224 | 224 | |
225 | 225 | // Refresh cache |
226 | - if (preg_match('/refresh/i',$action)) |
|
226 | + if (preg_match('/refresh/i', $action)) |
|
227 | 227 | { |
228 | - $result=$ecmdirstatic->fetch($val['id']); |
|
229 | - $ecmdirstatic->ref=$ecmdirstatic->label; |
|
228 | + $result = $ecmdirstatic->fetch($val['id']); |
|
229 | + $ecmdirstatic->ref = $ecmdirstatic->label; |
|
230 | 230 | |
231 | - $result=$ecmdirstatic->refreshcachenboffile(0); |
|
232 | - $val['cachenbofdoc']=$result; |
|
231 | + $result = $ecmdirstatic->refreshcachenboffile(0); |
|
232 | + $val['cachenbofdoc'] = $result; |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | //$fullpathparent=preg_replace('/(_[^_]+)$/i','',$val['fullpath']); |
236 | 236 | |
237 | 237 | // Define showline |
238 | - $showline=0; |
|
238 | + $showline = 0; |
|
239 | 239 | |
240 | 240 | // If directory is son of expanded directory, we show line |
241 | - if (in_array($val['id_mere'],$expandedsectionarray)) $showline=4; |
|
241 | + if (in_array($val['id_mere'], $expandedsectionarray)) $showline = 4; |
|
242 | 242 | // If directory is brother of selected directory, we show line |
243 | - elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) $showline=3; |
|
243 | + elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) $showline = 3; |
|
244 | 244 | // If directory is parent of selected directory or is selected directory, we show line |
245 | - elseif (preg_match('/'.$val['fullpath'].'_/i',$fullpathselected.'_')) $showline=2; |
|
245 | + elseif (preg_match('/'.$val['fullpath'].'_/i', $fullpathselected.'_')) $showline = 2; |
|
246 | 246 | // If we are level one we show line |
247 | - elseif ($val['level'] < 2) $showline=1; |
|
247 | + elseif ($val['level'] < 2) $showline = 1; |
|
248 | 248 | |
249 | 249 | if ($showline) |
250 | 250 | { |
251 | - if (in_array($val['id'],$expandedsectionarray)) $option='indexexpanded'; |
|
252 | - else $option='indexnotexpanded'; |
|
251 | + if (in_array($val['id'], $expandedsectionarray)) $option = 'indexexpanded'; |
|
252 | + else $option = 'indexnotexpanded'; |
|
253 | 253 | //print $option; |
254 | 254 | |
255 | 255 | print '<li class="directory collapsed">'; |
256 | 256 | |
257 | 257 | // Show tree graph pictos |
258 | - $cpt=1; |
|
258 | + $cpt = 1; |
|
259 | 259 | while ($cpt < $sqltree[$key]['level']) |
260 | 260 | { |
261 | 261 | print ' '; |
262 | 262 | $cpt++; |
263 | 263 | } |
264 | - $resarray=tree_showpad($sqltree,$key,1); |
|
265 | - $a=$resarray[0]; |
|
266 | - $nbofsubdir=$resarray[1]; |
|
267 | - $nboffilesinsubdir=$resarray[2]; |
|
264 | + $resarray = tree_showpad($sqltree, $key, 1); |
|
265 | + $a = $resarray[0]; |
|
266 | + $nbofsubdir = $resarray[1]; |
|
267 | + $nboffilesinsubdir = $resarray[2]; |
|
268 | 268 | |
269 | 269 | // Show link |
270 | - print $ecmdirstatic->getNomUrl(0,$option,32,'class="fmdirlia jqft ecmjqft"'); |
|
270 | + print $ecmdirstatic->getNomUrl(0, $option, 32, 'class="fmdirlia jqft ecmjqft"'); |
|
271 | 271 | |
272 | 272 | print '<div class="ecmjqft">'; |
273 | 273 | |
@@ -281,16 +281,16 @@ discard block |
||
281 | 281 | |
282 | 282 | // Info |
283 | 283 | print '<td align="center">'; |
284 | - $userstatic->id=$val['fk_user_c']; |
|
285 | - $userstatic->lastname=$val['login_c']; |
|
286 | - $htmltooltip='<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>'; |
|
287 | - $htmltooltip='<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionManual").'<br>'; |
|
288 | - $htmltooltip.='<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1, '', false, 1).'<br>'; |
|
289 | - $htmltooltip.='<b>'.$langs->trans("ECMCreationDate").'</b>: '.dol_print_date($val['date_c'],"dayhour").'<br>'; |
|
290 | - $htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>'; |
|
291 | - $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>'; |
|
284 | + $userstatic->id = $val['fk_user_c']; |
|
285 | + $userstatic->lastname = $val['login_c']; |
|
286 | + $htmltooltip = '<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>'; |
|
287 | + $htmltooltip = '<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionManual").'<br>'; |
|
288 | + $htmltooltip .= '<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1, '', false, 1).'<br>'; |
|
289 | + $htmltooltip .= '<b>'.$langs->trans("ECMCreationDate").'</b>: '.dol_print_date($val['date_c'], "dayhour").'<br>'; |
|
290 | + $htmltooltip .= '<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>'; |
|
291 | + $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>'; |
|
294 | 294 | print $form->textwithpicto('', $htmltooltip, 1, 'info'); |
295 | 295 | print "</td>"; |
296 | 296 | |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | print "</li>\n"; |
302 | 302 | } |
303 | 303 | |
304 | - $oldvallevel=$val['level']; |
|
304 | + $oldvallevel = $val['level']; |
|
305 | 305 | $nbofentries++; |
306 | 306 | } |
307 | 307 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | |
321 | 321 | |
322 | 322 | // Close db if mode is not noajax |
323 | -if ((! isset($mode) || $mode != 'noajax') && is_object($db)) $db->close(); |
|
323 | +if ((!isset($mode) || $mode != 'noajax') && is_object($db)) $db->close(); |
|
324 | 324 | |
325 | 325 | |
326 | 326 | |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | * @param int $depth Depth |
339 | 339 | * @return void |
340 | 340 | */ |
341 | -function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth=0) |
|
341 | +function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth = 0) |
|
342 | 342 | { |
343 | 343 | global $conf, $db, $langs, $form; |
344 | 344 | global $dolibarr_main_data_root; |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | { |
351 | 351 | $files = @scandir($fullpathselecteddir); |
352 | 352 | |
353 | - if (! empty($files)) |
|
353 | + if (!empty($files)) |
|
354 | 354 | { |
355 | 355 | natcasesort($files); |
356 | 356 | if (count($files) > 2) /* The 2 accounts for . and .. */ |
@@ -362,56 +362,56 @@ discard block |
||
362 | 362 | { |
363 | 363 | if ($file == 'temp') continue; |
364 | 364 | |
365 | - $nbofsubdir=0; |
|
366 | - $nboffilesinsubdir=0; |
|
365 | + $nbofsubdir = 0; |
|
366 | + $nboffilesinsubdir = 0; |
|
367 | 367 | |
368 | - $val=array(); |
|
368 | + $val = array(); |
|
369 | 369 | |
370 | 370 | // Loop on all database entries (sqltree) to find the one matching the subdir found into dir to scan |
371 | - foreach($sqltree as $key => $tmpval) |
|
371 | + foreach ($sqltree as $key => $tmpval) |
|
372 | 372 | { |
373 | 373 | //print "-- key=".$key." - ".$tmpval['fullrelativename']." vs ".(($selecteddir != '/'?$selecteddir.'/':'').$file)."<br>\n"; |
374 | - if ($tmpval['fullrelativename'] == (($selecteddir != '/'?$selecteddir.'/':'').$file)) // We found equivalent record into database |
|
374 | + if ($tmpval['fullrelativename'] == (($selecteddir != '/' ? $selecteddir.'/' : '').$file)) // We found equivalent record into database |
|
375 | 375 | { |
376 | - $val=$tmpval; |
|
377 | - $resarray=tree_showpad($sqltree,$key,1); |
|
376 | + $val = $tmpval; |
|
377 | + $resarray = tree_showpad($sqltree, $key, 1); |
|
378 | 378 | |
379 | 379 | // Refresh cache for this subdir |
380 | 380 | if (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] < 0) // Cache is not up to date, so we update it for this directory t |
381 | 381 | { |
382 | - $result=$ecmdirstatic->fetch($val['id']); |
|
383 | - $ecmdirstatic->ref=$ecmdirstatic->label; |
|
382 | + $result = $ecmdirstatic->fetch($val['id']); |
|
383 | + $ecmdirstatic->ref = $ecmdirstatic->label; |
|
384 | 384 | |
385 | - $result=$ecmdirstatic->refreshcachenboffile(0); |
|
386 | - $val['cachenbofdoc']=$result; |
|
385 | + $result = $ecmdirstatic->refreshcachenboffile(0); |
|
386 | + $val['cachenbofdoc'] = $result; |
|
387 | 387 | } |
388 | 388 | |
389 | - $a=$resarray[0]; |
|
390 | - $nbofsubdir=$resarray[1]; |
|
391 | - $nboffilesinsubdir=$resarray[2]; |
|
389 | + $a = $resarray[0]; |
|
390 | + $nbofsubdir = $resarray[1]; |
|
391 | + $nboffilesinsubdir = $resarray[2]; |
|
392 | 392 | break; |
393 | 393 | } |
394 | 394 | } |
395 | 395 | |
396 | 396 | //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 | - if ($file != '.' && $file != '..' && ((! empty($val['fullrelativename']) && $val['id'] >= 0) || dol_is_dir($fullpathselecteddir . (preg_match('/\/$/',$fullpathselecteddir)?'':'/') . $file))) |
|
397 | + if ($file != '.' && $file != '..' && ((!empty($val['fullrelativename']) && $val['id'] >= 0) || dol_is_dir($fullpathselecteddir.(preg_match('/\/$/', $fullpathselecteddir) ? '' : '/').$file))) |
|
398 | 398 | { |
399 | 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) |
400 | 400 | { |
401 | - $val['fullrelativename']=(($selecteddir && $selecteddir != '/')?$selecteddir.'/':'').$file; |
|
402 | - $val['id']=0; |
|
403 | - $val['label']=$file; |
|
404 | - $val['description']=''; |
|
405 | - $nboffilesinsubdir=$langs->trans("Unknown"); |
|
401 | + $val['fullrelativename'] = (($selecteddir && $selecteddir != '/') ? $selecteddir.'/' : '').$file; |
|
402 | + $val['id'] = 0; |
|
403 | + $val['label'] = $file; |
|
404 | + $val['description'] = ''; |
|
405 | + $nboffilesinsubdir = $langs->trans("Unknown"); |
|
406 | 406 | } |
407 | 407 | |
408 | - $collapsedorexpanded='collapsed'; |
|
409 | - if (preg_match('/^'.preg_quote($val['fullrelativename'].'/', '/').'/', $preopened)) $collapsedorexpanded='expanded'; |
|
410 | - print '<li class="directory '.$collapsedorexpanded.'">'; // collapsed is opposite if expanded |
|
408 | + $collapsedorexpanded = 'collapsed'; |
|
409 | + if (preg_match('/^'.preg_quote($val['fullrelativename'].'/', '/').'/', $preopened)) $collapsedorexpanded = 'expanded'; |
|
410 | + print '<li class="directory '.$collapsedorexpanded.'">'; // collapsed is opposite if expanded |
|
411 | 411 | |
412 | 412 | print "<a class=\"fmdirlia jqft ecmjqft\" href=\""; |
413 | 413 | print "#"; |
414 | - print "\" rel=\"" . dol_escape_htmltag($val['fullrelativename'].'/') . "\" id=\"fmdirlia_id_".$val['id']."\""; |
|
414 | + print "\" rel=\"".dol_escape_htmltag($val['fullrelativename'].'/')."\" id=\"fmdirlia_id_".$val['id']."\""; |
|
415 | 415 | print " onClick=\"loadandshowpreview('".dol_escape_js($val['fullrelativename'])."',".$val['id'].")"; |
416 | 416 | print "\">"; |
417 | 417 | print dol_escape_htmltag($file); |
@@ -427,10 +427,10 @@ discard block |
||
427 | 427 | |
428 | 428 | // Nb of docs |
429 | 429 | print '<td align="right">'; |
430 | - print (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0)?$val['cachenbofdoc']:' '; |
|
430 | + print (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0) ? $val['cachenbofdoc'] : ' '; |
|
431 | 431 | print '</td>'; |
432 | 432 | print '<td align="left">'; |
433 | - if ($nbofsubdir > 0 && $nboffilesinsubdir > 0) print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> '; |
|
433 | + if ($nbofsubdir > 0 && $nboffilesinsubdir > 0) print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> '; |
|
434 | 434 | print '</td>'; |
435 | 435 | |
436 | 436 | // Edit link |
@@ -447,17 +447,17 @@ discard block |
||
447 | 447 | if ($modulepart == 'ecm') |
448 | 448 | { |
449 | 449 | print '<td align="right" width="18">'; |
450 | - $userstatic->id=isset($val['fk_user_c'])?$val['fk_user_c']:0; |
|
451 | - $userstatic->lastname=isset($val['login_c'])?$val['login_c']:0; |
|
452 | - $htmltooltip='<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>'; |
|
453 | - $htmltooltip='<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionManual").'<br>'; |
|
454 | - $htmltooltip.='<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1, '', false, 1).'<br>'; |
|
455 | - $htmltooltip.='<b>'.$langs->trans("ECMCreationDate").'</b>: '.(isset($val['date_c'])?dol_print_date($val['date_c'],"dayhour"):$langs->trans("NeedRefresh")).'<br>'; |
|
456 | - $htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>'; |
|
457 | - $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>'; |
|
460 | - print $form->textwithpicto('',$htmltooltip,1,"info"); |
|
450 | + $userstatic->id = isset($val['fk_user_c']) ? $val['fk_user_c'] : 0; |
|
451 | + $userstatic->lastname = isset($val['login_c']) ? $val['login_c'] : 0; |
|
452 | + $htmltooltip = '<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>'; |
|
453 | + $htmltooltip = '<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionManual").'<br>'; |
|
454 | + $htmltooltip .= '<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1, '', false, 1).'<br>'; |
|
455 | + $htmltooltip .= '<b>'.$langs->trans("ECMCreationDate").'</b>: '.(isset($val['date_c']) ?dol_print_date($val['date_c'], "dayhour") : $langs->trans("NeedRefresh")).'<br>'; |
|
456 | + $htmltooltip .= '<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>'; |
|
457 | + $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>'; |
|
460 | + print $form->textwithpicto('', $htmltooltip, 1, "info"); |
|
461 | 461 | print "</td>"; |
462 | 462 | } |
463 | 463 | |
@@ -469,17 +469,17 @@ discard block |
||
469 | 469 | { |
470 | 470 | //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"; |
471 | 471 | $newselecteddir = $val['fullrelativename']; |
472 | - $newfullpathselecteddir=''; |
|
472 | + $newfullpathselecteddir = ''; |
|
473 | 473 | if ($modulepart == 'ecm') |
474 | 474 | { |
475 | - $newfullpathselecteddir=$conf->ecm->dir_output.'/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : ''); |
|
475 | + $newfullpathselecteddir = $conf->ecm->dir_output.'/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : ''); |
|
476 | 476 | } |
477 | 477 | elseif ($modulepart == 'medias') |
478 | 478 | { |
479 | - $newfullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : ''); |
|
479 | + $newfullpathselecteddir = $dolibarr_main_data_root.'/medias/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : ''); |
|
480 | 480 | } |
481 | 481 | |
482 | - if ($newfullpathselecteddir) treeOutputForAbsoluteDir($sqltree, $newselecteddir, $newfullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth+1); |
|
482 | + if ($newfullpathselecteddir) treeOutputForAbsoluteDir($sqltree, $newselecteddir, $newfullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth + 1); |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | print "</li>\n"; |
@@ -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 |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | if (! $sortorder) $sortorder="ASC"; |
57 | 57 | if (! $sortfield) $sortfield="name"; |
58 | 58 | |
59 | - $rootdirfordoc = $conf->ecm->dir_output; |
|
59 | + $rootdirfordoc = $conf->ecm->dir_output; |
|
60 | 60 | |
61 | - $upload_dir = dirname(str_replace("../", "/", $rootdirfordoc.'/'.$file)); |
|
61 | + $upload_dir = dirname(str_replace("../", "/", $rootdirfordoc.'/'.$file)); |
|
62 | 62 | |
63 | 63 | $ecmdir = new EcmDirectory($db); |
64 | 64 | $result=$ecmdir->fetch($section); |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | } |
71 | 71 | else // For no ajax call |
72 | 72 | { |
73 | - $rootdirfordoc = $conf->ecm->dir_output; |
|
73 | + $rootdirfordoc = $conf->ecm->dir_output; |
|
74 | 74 | |
75 | - $ecmdir = new EcmDirectory($db); |
|
75 | + $ecmdir = new EcmDirectory($db); |
|
76 | 76 | $relativepath=''; |
77 | 77 | if ($section > 0) |
78 | 78 | { |
@@ -85,19 +85,19 @@ discard block |
||
85 | 85 | |
86 | 86 | $relativepath=$ecmdir->getRelativePath(); // Example 'mydir/' |
87 | 87 | } |
88 | - elseif (GETPOST('section_dir')) |
|
89 | - { |
|
90 | - $relativepath=GETPOST('section_dir'); |
|
91 | - } |
|
92 | - //var_dump($section.'-'.GETPOST('section_dir').'-'.$relativepath); |
|
88 | + elseif (GETPOST('section_dir')) |
|
89 | + { |
|
90 | + $relativepath=GETPOST('section_dir'); |
|
91 | + } |
|
92 | + //var_dump($section.'-'.GETPOST('section_dir').'-'.$relativepath); |
|
93 | 93 | |
94 | - $upload_dir = $rootdirfordoc.'/'.$relativepath; |
|
94 | + $upload_dir = $rootdirfordoc.'/'.$relativepath; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | if (empty($url)) |
98 | 98 | { |
99 | - if (GETPOSTISSET('website')) $url=DOL_URL_ROOT.'/website/index.php'; |
|
100 | - else $url=DOL_URL_ROOT.'/ecm/index.php'; |
|
99 | + if (GETPOSTISSET('website')) $url=DOL_URL_ROOT.'/website/index.php'; |
|
100 | + else $url=DOL_URL_ROOT.'/ecm/index.php'; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | // Load translation files required by the page |
@@ -121,11 +121,11 @@ discard block |
||
121 | 121 | // Check permissions |
122 | 122 | if ($modulepart == 'ecm') |
123 | 123 | { |
124 | - if (! $user->rights->ecm->read) accessforbidden(); |
|
124 | + if (! $user->rights->ecm->read) accessforbidden(); |
|
125 | 125 | } |
126 | 126 | if ($modulepart == 'medias') |
127 | 127 | { |
128 | - // Always allowed |
|
128 | + // Always allowed |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | |
144 | 144 | if (! isset($mode) || $mode != 'noajax') |
145 | 145 | { |
146 | - // Ajout directives pour resoudre bug IE |
|
146 | + // Ajout directives pour resoudre bug IE |
|
147 | 147 | header('Cache-Control: Public, must-revalidate'); |
148 | 148 | header('Pragma: public'); |
149 | 149 | |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | else if ($module == 'user') $upload_dir = $conf->user->dir_output; |
211 | 211 | // Auto area for expense report |
212 | 212 | else if ($module == 'expensereport') $upload_dir = $conf->expensereport->dir_output; |
213 | - // Auto area for holiday |
|
213 | + // Auto area for holiday |
|
214 | 214 | else if ($module == 'holiday') $upload_dir = $conf->holiday->dir_output; |
215 | 215 | |
216 | 216 | // Automatic list |
@@ -233,9 +233,9 @@ discard block |
||
233 | 233 | // Manual list |
234 | 234 | else |
235 | 235 | { |
236 | - if ($module == 'medias') |
|
237 | - { |
|
238 | - /* |
|
236 | + if ($module == 'medias') |
|
237 | + { |
|
238 | + /* |
|
239 | 239 | $_POST is array like |
240 | 240 | 'token' => string '062380e11b7dcd009d07318b57b71750' (length=32) |
241 | 241 | 'action' => string 'file_manager' (length=12) |
@@ -246,66 +246,66 @@ discard block |
||
246 | 246 | 'max_file_size' => string '2097152' (length=7) |
247 | 247 | 'sendit' => string 'Envoyer fichier' (length=15) |
248 | 248 | */ |
249 | - $relativepath=GETPOST('file','alpha')?GETPOST('file','alpha'):GETPOST('section_dir','alpha'); |
|
250 | - if ($relativepath && $relativepath!= '/') $relativepath.='/'; |
|
251 | - $upload_dir = $dolibarr_main_data_root.'/'.$module.'/'.$relativepath; |
|
252 | - if (GETPOSTISSET('website') || GETPOSTISSET('file_manager')) |
|
253 | - { |
|
254 | - $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')); |
|
257 | - //if (!preg_match('/backtopage=/',$param)) $param.='&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid); |
|
258 | - } |
|
259 | - } |
|
260 | - else |
|
261 | - { |
|
262 | - $relativepath=$ecmdir->getRelativePath(); |
|
263 | - $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; |
|
264 | - } |
|
249 | + $relativepath=GETPOST('file','alpha')?GETPOST('file','alpha'):GETPOST('section_dir','alpha'); |
|
250 | + if ($relativepath && $relativepath!= '/') $relativepath.='/'; |
|
251 | + $upload_dir = $dolibarr_main_data_root.'/'.$module.'/'.$relativepath; |
|
252 | + if (GETPOSTISSET('website') || GETPOSTISSET('file_manager')) |
|
253 | + { |
|
254 | + $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')); |
|
257 | + //if (!preg_match('/backtopage=/',$param)) $param.='&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid); |
|
258 | + } |
|
259 | + } |
|
260 | + else |
|
261 | + { |
|
262 | + $relativepath=$ecmdir->getRelativePath(); |
|
263 | + $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; |
|
264 | + } |
|
265 | 265 | |
266 | 266 | // If $section defined with value 0 |
267 | - if (($section === '0' || empty($section)) && ($module != 'medias')) |
|
267 | + if (($section === '0' || empty($section)) && ($module != 'medias')) |
|
268 | 268 | { |
269 | 269 | $filearray=array(); |
270 | 270 | } |
271 | 271 | else |
272 | 272 | { |
273 | - $filearray=dol_dir_list($upload_dir,"files",0,'',array('^\.','(\.meta|_preview.*\.png)$','^temp$','^CVS$'),$sortfield, $sorting,1); |
|
273 | + $filearray=dol_dir_list($upload_dir,"files",0,'',array('^\.','(\.meta|_preview.*\.png)$','^temp$','^CVS$'),$sortfield, $sorting,1); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | if ($section) |
277 | 277 | { |
278 | 278 | $param.='§ion='.$section; |
279 | - if (isset($search_doc_ref) && $search_doc_ref != '') $param.='&search_doc_ref='.$search_doc_ref; |
|
279 | + if (isset($search_doc_ref) && $search_doc_ref != '') $param.='&search_doc_ref='.$search_doc_ref; |
|
280 | 280 | |
281 | 281 | $textifempty = $langs->trans('NoFileFound'); |
282 | 282 | } |
283 | 283 | else if ($section === '0') |
284 | 284 | { |
285 | - if ($module == 'ecm') $textifempty='<br><div align="center"><font class="warning">'.$langs->trans("DirNotSynchronizedSyncFirst").'</font></div><br>'; |
|
286 | - else $textifempty = $langs->trans('NoFileFound'); |
|
285 | + if ($module == 'ecm') $textifempty='<br><div align="center"><font class="warning">'.$langs->trans("DirNotSynchronizedSyncFirst").'</font></div><br>'; |
|
286 | + else $textifempty = $langs->trans('NoFileFound'); |
|
287 | 287 | } |
288 | 288 | else $textifempty=($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("ECMSelectASection")); |
289 | 289 | |
290 | - if ($module == 'medias') |
|
291 | - { |
|
292 | - $useinecm = 2; |
|
293 | - $modulepart='medias'; |
|
294 | - $perm=($user->rights->website->write || $user->rights->emailing->creer); |
|
295 | - $title='none'; |
|
296 | - } |
|
297 | - else |
|
298 | - { |
|
299 | - $useinecm = 1; |
|
300 | - $modulepart='ecm'; |
|
301 | - $perm=$user->rights->ecm->upload; |
|
302 | - $title=''; // Use default |
|
303 | - } |
|
304 | - |
|
305 | - // When we show list of files for ECM files, $filearray contains file list, and directory is defined with modulepart + section into $param |
|
306 | - // When we show list of files for a directory, $filearray ciontains file list, and directory is defined with modulepart + $relativepath |
|
307 | - //var_dump("title=".$title." modulepart=".$modulepart." useinecm=".$useinecm." perm=".$perm." relativepath=".$relativepath." param=".$param." url=".$url); |
|
308 | - $formfile->list_of_documents($filearray, '', $modulepart, $param, 1, $relativepath, $perm, $useinecm, $textifempty, $maxlengthname, $title, $url, 0, $perm); |
|
290 | + if ($module == 'medias') |
|
291 | + { |
|
292 | + $useinecm = 2; |
|
293 | + $modulepart='medias'; |
|
294 | + $perm=($user->rights->website->write || $user->rights->emailing->creer); |
|
295 | + $title='none'; |
|
296 | + } |
|
297 | + else |
|
298 | + { |
|
299 | + $useinecm = 1; |
|
300 | + $modulepart='ecm'; |
|
301 | + $perm=$user->rights->ecm->upload; |
|
302 | + $title=''; // Use default |
|
303 | + } |
|
304 | + |
|
305 | + // When we show list of files for ECM files, $filearray contains file list, and directory is defined with modulepart + section into $param |
|
306 | + // When we show list of files for a directory, $filearray ciontains file list, and directory is defined with modulepart + $relativepath |
|
307 | + //var_dump("title=".$title." modulepart=".$modulepart." useinecm=".$useinecm." perm=".$perm." relativepath=".$relativepath." param=".$param." url=".$url); |
|
308 | + $formfile->list_of_documents($filearray, '', $modulepart, $param, 1, $relativepath, $perm, $useinecm, $textifempty, $maxlengthname, $title, $url, 0, $perm); |
|
309 | 309 | } |
310 | 310 | } |
311 | 311 | |
@@ -321,37 +321,37 @@ discard block |
||
321 | 321 | |
322 | 322 | if ($useajax || $action == 'delete') |
323 | 323 | { |
324 | - $urlfile=''; |
|
325 | - if ($action == 'delete') $urlfile=GETPOST('urlfile','alpha'); |
|
326 | - |
|
327 | - if (empty($section_dir)) $section_dir=GETPOST("file","alpha"); |
|
328 | - $section_id=$section; |
|
329 | - |
|
330 | - require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; |
|
331 | - $useglobalvars=1; |
|
332 | - $form = new Form($db); |
|
333 | - $formquestion['urlfile']=array('type'=>'hidden','value'=>$urlfile,'name'=>'urlfile'); // We must always put field, even if empty because it is fille by javascript later |
|
334 | - $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 | - $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 | - $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'); |
|
340 | - |
|
341 | - print $form->formconfirm($url,$langs->trans("DeleteFile"),$langs->trans("ConfirmDeleteFile"),'confirm_deletefile',$formquestion,"no",($useajax?'deletefile':0)); |
|
324 | + $urlfile=''; |
|
325 | + if ($action == 'delete') $urlfile=GETPOST('urlfile','alpha'); |
|
326 | + |
|
327 | + if (empty($section_dir)) $section_dir=GETPOST("file","alpha"); |
|
328 | + $section_id=$section; |
|
329 | + |
|
330 | + require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; |
|
331 | + $useglobalvars=1; |
|
332 | + $form = new Form($db); |
|
333 | + $formquestion['urlfile']=array('type'=>'hidden','value'=>$urlfile,'name'=>'urlfile'); // We must always put field, even if empty because it is fille by javascript later |
|
334 | + $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 | + $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 | + $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'); |
|
340 | + |
|
341 | + print $form->formconfirm($url,$langs->trans("DeleteFile"),$langs->trans("ConfirmDeleteFile"),'confirm_deletefile',$formquestion,"no",($useajax?'deletefile':0)); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | if ($useajax) |
345 | 345 | { |
346 | - print '<script type="text/javascript">'; |
|
347 | - |
|
348 | - // Enable jquery handlers on new generated HTML objects (same code than into lib_footer.js.php) |
|
349 | - // Because the content is reloaded by ajax call, we must also reenable some jquery hooks |
|
350 | - // Wrapper to manage document_preview |
|
351 | - if ($conf->browser->layout != 'phone') |
|
352 | - { |
|
353 | - print "\n/* JS CODE TO ENABLE document_preview */\n"; |
|
354 | - print ' |
|
346 | + print '<script type="text/javascript">'; |
|
347 | + |
|
348 | + // Enable jquery handlers on new generated HTML objects (same code than into lib_footer.js.php) |
|
349 | + // Because the content is reloaded by ajax call, we must also reenable some jquery hooks |
|
350 | + // Wrapper to manage document_preview |
|
351 | + if ($conf->browser->layout != 'phone') |
|
352 | + { |
|
353 | + print "\n/* JS CODE TO ENABLE document_preview */\n"; |
|
354 | + print ' |
|
355 | 355 | jQuery(document).ready(function () { |
356 | 356 | jQuery(".documentpreview").click(function () { |
357 | 357 | console.log("We click on preview for element with href="+$(this).attr(\'href\')+" mime="+$(this).attr(\'mime\')); |
@@ -360,19 +360,19 @@ discard block |
||
360 | 360 | }); |
361 | 361 | }); |
362 | 362 | ' . "\n"; |
363 | - } |
|
364 | - |
|
365 | - // Enable jquery handlers button to delete files |
|
366 | - print 'jQuery(document).ready(function() {'."\n"; |
|
367 | - print ' jQuery(".deletefilelink").click(function(e) { '."\n"; |
|
368 | - print ' console.log("We click on button with class deletefilelink, param='.$param.', we set urlfile to "+jQuery(this).attr("rel"));'."\n"; |
|
369 | - print ' jQuery("#urlfile").val(jQuery(this).attr("rel"));'."\n"; |
|
370 | - //print ' jQuery("#section_dir").val(\'aaa\');'."\n"; |
|
371 | - print ' jQuery("#dialog-confirm-deletefile").dialog("open");'."\n"; |
|
372 | - print ' return false;'."\n"; |
|
373 | - print ' });'."\n"; |
|
374 | - print '});'."\n"; |
|
375 | - print '</script>'."\n"; |
|
363 | + } |
|
364 | + |
|
365 | + // Enable jquery handlers button to delete files |
|
366 | + print 'jQuery(document).ready(function() {'."\n"; |
|
367 | + print ' jQuery(".deletefilelink").click(function(e) { '."\n"; |
|
368 | + print ' console.log("We click on button with class deletefilelink, param='.$param.', we set urlfile to "+jQuery(this).attr("rel"));'."\n"; |
|
369 | + print ' jQuery("#urlfile").val(jQuery(this).attr("rel"));'."\n"; |
|
370 | + //print ' jQuery("#section_dir").val(\'aaa\');'."\n"; |
|
371 | + print ' jQuery("#dialog-confirm-deletefile").dialog("open");'."\n"; |
|
372 | + print ' return false;'."\n"; |
|
373 | + print ' });'."\n"; |
|
374 | + print '});'."\n"; |
|
375 | + print '</script>'."\n"; |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | // Close db if mode is not noajax |
@@ -27,42 +27,42 @@ 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')) 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'); |
|
34 | 34 | |
35 | -if (! isset($mode) || $mode != 'noajax') // For ajax call |
|
35 | +if (!isset($mode) || $mode != 'noajax') // For ajax call |
|
36 | 36 | { |
37 | 37 | require_once '../../main.inc.php'; |
38 | 38 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
39 | 39 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; |
40 | 40 | require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; |
41 | 41 | |
42 | - $action=GETPOST('action','aZ09'); |
|
43 | - $file=urldecode(GETPOST('file','alpha')); |
|
44 | - $section=GETPOST("section",'alpha'); |
|
45 | - $module=GETPOST("module",'alpha'); |
|
46 | - $urlsource=GETPOST("urlsource",'alpha'); |
|
47 | - $search_doc_ref=GETPOST('search_doc_ref','alpha'); |
|
42 | + $action = GETPOST('action', 'aZ09'); |
|
43 | + $file = urldecode(GETPOST('file', 'alpha')); |
|
44 | + $section = GETPOST("section", 'alpha'); |
|
45 | + $module = GETPOST("module", 'alpha'); |
|
46 | + $urlsource = GETPOST("urlsource", 'alpha'); |
|
47 | + $search_doc_ref = GETPOST('search_doc_ref', 'alpha'); |
|
48 | 48 | |
49 | - $sortfield = GETPOST("sortfield",'alpha'); |
|
50 | - $sortorder = GETPOST("sortorder",'alpha'); |
|
51 | - $page = GETPOST("page",'int'); |
|
49 | + $sortfield = GETPOST("sortfield", 'alpha'); |
|
50 | + $sortorder = GETPOST("sortorder", 'alpha'); |
|
51 | + $page = GETPOST("page", 'int'); |
|
52 | 52 | if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 |
53 | 53 | $offset = $conf->liste_limit * $page; |
54 | 54 | $pageprev = $page - 1; |
55 | 55 | $pagenext = $page + 1; |
56 | - if (! $sortorder) $sortorder="ASC"; |
|
57 | - if (! $sortfield) $sortfield="name"; |
|
56 | + if (!$sortorder) $sortorder = "ASC"; |
|
57 | + if (!$sortfield) $sortfield = "name"; |
|
58 | 58 | |
59 | 59 | $rootdirfordoc = $conf->ecm->dir_output; |
60 | 60 | |
61 | 61 | $upload_dir = dirname(str_replace("../", "/", $rootdirfordoc.'/'.$file)); |
62 | 62 | |
63 | 63 | $ecmdir = new EcmDirectory($db); |
64 | - $result=$ecmdir->fetch($section); |
|
65 | - if (! $result > 0) |
|
64 | + $result = $ecmdir->fetch($section); |
|
65 | + if (!$result > 0) |
|
66 | 66 | { |
67 | 67 | //dol_print_error($db,$ecmdir->error); |
68 | 68 | //exit; |
@@ -73,21 +73,21 @@ discard block |
||
73 | 73 | $rootdirfordoc = $conf->ecm->dir_output; |
74 | 74 | |
75 | 75 | $ecmdir = new EcmDirectory($db); |
76 | - $relativepath=''; |
|
76 | + $relativepath = ''; |
|
77 | 77 | if ($section > 0) |
78 | 78 | { |
79 | - $result=$ecmdir->fetch($section); |
|
80 | - if (! $result > 0) |
|
79 | + $result = $ecmdir->fetch($section); |
|
80 | + if (!$result > 0) |
|
81 | 81 | { |
82 | - dol_print_error($db,$ecmdir->error); |
|
82 | + dol_print_error($db, $ecmdir->error); |
|
83 | 83 | exit; |
84 | 84 | } |
85 | 85 | |
86 | - $relativepath=$ecmdir->getRelativePath(); // Example 'mydir/' |
|
86 | + $relativepath = $ecmdir->getRelativePath(); // Example 'mydir/' |
|
87 | 87 | } |
88 | 88 | elseif (GETPOST('section_dir')) |
89 | 89 | { |
90 | - $relativepath=GETPOST('section_dir'); |
|
90 | + $relativepath = GETPOST('section_dir'); |
|
91 | 91 | } |
92 | 92 | //var_dump($section.'-'.GETPOST('section_dir').'-'.$relativepath); |
93 | 93 | |
@@ -96,12 +96,12 @@ discard block |
||
96 | 96 | |
97 | 97 | if (empty($url)) |
98 | 98 | { |
99 | - if (GETPOSTISSET('website')) $url=DOL_URL_ROOT.'/website/index.php'; |
|
100 | - else $url=DOL_URL_ROOT.'/ecm/index.php'; |
|
99 | + if (GETPOSTISSET('website')) $url = DOL_URL_ROOT.'/website/index.php'; |
|
100 | + else $url = DOL_URL_ROOT.'/ecm/index.php'; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | // Load translation files required by the page |
104 | -$langs->loadLangs(array("ecm","companies","other")); |
|
104 | +$langs->loadLangs(array("ecm", "companies", "other")); |
|
105 | 105 | |
106 | 106 | // Security check |
107 | 107 | if ($user->societe_id > 0) $socid = $user->societe_id; |
@@ -110,18 +110,18 @@ discard block |
||
110 | 110 | |
111 | 111 | // Security: |
112 | 112 | // On interdit les remontees de repertoire ainsi que les pipe dans les noms de fichiers. |
113 | -if (preg_match('/\.\./',$upload_dir) || preg_match('/[<>|]/',$upload_dir)) |
|
113 | +if (preg_match('/\.\./', $upload_dir) || preg_match('/[<>|]/', $upload_dir)) |
|
114 | 114 | { |
115 | 115 | dol_syslog("Refused to deliver file ".$upload_dir); |
116 | 116 | // Do no show plain path in shown error message |
117 | - dol_print_error(0,$langs->trans("ErrorFileNameInvalid",$upload_dir)); |
|
117 | + dol_print_error(0, $langs->trans("ErrorFileNameInvalid", $upload_dir)); |
|
118 | 118 | exit; |
119 | 119 | } |
120 | 120 | |
121 | 121 | // Check permissions |
122 | 122 | if ($modulepart == 'ecm') |
123 | 123 | { |
124 | - if (! $user->rights->ecm->read) accessforbidden(); |
|
124 | + if (!$user->rights->ecm->read) accessforbidden(); |
|
125 | 125 | } |
126 | 126 | if ($modulepart == 'medias') |
127 | 127 | { |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * View |
142 | 142 | */ |
143 | 143 | |
144 | -if (! isset($mode) || $mode != 'noajax') |
|
144 | +if (!isset($mode) || $mode != 'noajax') |
|
145 | 145 | { |
146 | 146 | // Ajout directives pour resoudre bug IE |
147 | 147 | header('Cache-Control: Public, must-revalidate'); |
@@ -150,10 +150,10 @@ discard block |
||
150 | 150 | top_httphead(); |
151 | 151 | } |
152 | 152 | |
153 | -$type='directory'; |
|
153 | +$type = 'directory'; |
|
154 | 154 | |
155 | 155 | // This test if file exists should be useless. We keep it to find bug more easily |
156 | -if (! dol_is_dir($upload_dir)) |
|
156 | +if (!dol_is_dir($upload_dir)) |
|
157 | 157 | { |
158 | 158 | // dol_mkdir($upload_dir); |
159 | 159 | /* $langs->load("install"); |
@@ -164,19 +164,19 @@ discard block |
||
164 | 164 | print '<!-- ajaxdirpreview type='.$type.' -->'."\n"; |
165 | 165 | //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 | 166 | |
167 | -$param=($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:''); |
|
168 | -if (! empty($websitekey)) $param.='&website='.$websitekey; |
|
169 | -if (! empty($pageid)) $param.='&pageid='.$pageid; |
|
167 | +$param = ($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : ''); |
|
168 | +if (!empty($websitekey)) $param .= '&website='.$websitekey; |
|
169 | +if (!empty($pageid)) $param .= '&pageid='.$pageid; |
|
170 | 170 | |
171 | 171 | |
172 | 172 | // Dir scan |
173 | 173 | if ($type == 'directory') |
174 | 174 | { |
175 | - $formfile=new FormFile($db); |
|
175 | + $formfile = new FormFile($db); |
|
176 | 176 | |
177 | - $maxlengthname=40; |
|
178 | - $excludefiles = array('^SPECIMEN\.pdf$','^\.','(\.meta|_preview.*\.png)$','^temp$','^payments$','^CVS$','^thumbs$'); |
|
179 | - $sorting = (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC); |
|
177 | + $maxlengthname = 40; |
|
178 | + $excludefiles = array('^SPECIMEN\.pdf$', '^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^payments$', '^CVS$', '^thumbs$'); |
|
179 | + $sorting = (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC); |
|
180 | 180 | |
181 | 181 | // Right area. If module is defined here, we are in automatic ecm. |
182 | 182 | $automodules = array('company', 'invoice', 'invoice_supplier', 'propal', 'supplier_proposal', 'order', 'order_supplier', 'contract', 'product', 'tax', 'project', 'fichinter', 'user', 'expensereport', 'holiday'); |
@@ -216,19 +216,19 @@ discard block |
||
216 | 216 | // Automatic list |
217 | 217 | if (in_array($module, $automodules)) |
218 | 218 | { |
219 | - $param.='&module='.$module; |
|
220 | - if (isset($search_doc_ref) && $search_doc_ref != '') $param.='&search_doc_ref='.$search_doc_ref; |
|
219 | + $param .= '&module='.$module; |
|
220 | + if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.$search_doc_ref; |
|
221 | 221 | |
222 | - $textifempty=($section?$langs->trans("NoFileFound"):($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("NoFileFound"))); |
|
222 | + $textifempty = ($section ? $langs->trans("NoFileFound") : ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("NoFileFound"))); |
|
223 | 223 | |
224 | - if ($module == 'company') $excludefiles[]='^contact$'; // The subdir 'contact' contains files of contacts with no id of thirdparty. |
|
224 | + if ($module == 'company') $excludefiles[] = '^contact$'; // The subdir 'contact' contains files of contacts with no id of thirdparty. |
|
225 | 225 | |
226 | - $filter=preg_quote($search_doc_ref, '/'); |
|
227 | - $filearray=dol_dir_list($upload_dir, "files", 1, $filter, $excludefiles, $sortfield, $sorting,1); |
|
226 | + $filter = preg_quote($search_doc_ref, '/'); |
|
227 | + $filearray = dol_dir_list($upload_dir, "files", 1, $filter, $excludefiles, $sortfield, $sorting, 1); |
|
228 | 228 | |
229 | - $perm=$user->rights->ecm->upload; |
|
229 | + $perm = $user->rights->ecm->upload; |
|
230 | 230 | |
231 | - $formfile->list_of_autoecmfiles($upload_dir,$filearray,$module,$param,1,'',$perm,1,$textifempty,$maxlengthname,$url,1); |
|
231 | + $formfile->list_of_autoecmfiles($upload_dir, $filearray, $module, $param, 1, '', $perm, 1, $textifempty, $maxlengthname, $url, 1); |
|
232 | 232 | } |
233 | 233 | // Manual list |
234 | 234 | else |
@@ -246,60 +246,60 @@ discard block |
||
246 | 246 | 'max_file_size' => string '2097152' (length=7) |
247 | 247 | 'sendit' => string 'Envoyer fichier' (length=15) |
248 | 248 | */ |
249 | - $relativepath=GETPOST('file','alpha')?GETPOST('file','alpha'):GETPOST('section_dir','alpha'); |
|
250 | - if ($relativepath && $relativepath!= '/') $relativepath.='/'; |
|
249 | + $relativepath = GETPOST('file', 'alpha') ?GETPOST('file', 'alpha') : GETPOST('section_dir', 'alpha'); |
|
250 | + if ($relativepath && $relativepath != '/') $relativepath .= '/'; |
|
251 | 251 | $upload_dir = $dolibarr_main_data_root.'/'.$module.'/'.$relativepath; |
252 | 252 | if (GETPOSTISSET('website') || GETPOSTISSET('file_manager')) |
253 | 253 | { |
254 | - $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')); |
|
254 | + $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')); |
|
257 | 257 | //if (!preg_match('/backtopage=/',$param)) $param.='&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid); |
258 | 258 | } |
259 | 259 | } |
260 | 260 | else |
261 | 261 | { |
262 | - $relativepath=$ecmdir->getRelativePath(); |
|
262 | + $relativepath = $ecmdir->getRelativePath(); |
|
263 | 263 | $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; |
264 | 264 | } |
265 | 265 | |
266 | 266 | // If $section defined with value 0 |
267 | 267 | if (($section === '0' || empty($section)) && ($module != 'medias')) |
268 | 268 | { |
269 | - $filearray=array(); |
|
269 | + $filearray = array(); |
|
270 | 270 | } |
271 | 271 | else |
272 | 272 | { |
273 | - $filearray=dol_dir_list($upload_dir,"files",0,'',array('^\.','(\.meta|_preview.*\.png)$','^temp$','^CVS$'),$sortfield, $sorting,1); |
|
273 | + $filearray = dol_dir_list($upload_dir, "files", 0, '', array('^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^CVS$'), $sortfield, $sorting, 1); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | if ($section) |
277 | 277 | { |
278 | - $param.='§ion='.$section; |
|
279 | - if (isset($search_doc_ref) && $search_doc_ref != '') $param.='&search_doc_ref='.$search_doc_ref; |
|
278 | + $param .= '§ion='.$section; |
|
279 | + if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.$search_doc_ref; |
|
280 | 280 | |
281 | 281 | $textifempty = $langs->trans('NoFileFound'); |
282 | 282 | } |
283 | 283 | else if ($section === '0') |
284 | 284 | { |
285 | - if ($module == 'ecm') $textifempty='<br><div align="center"><font class="warning">'.$langs->trans("DirNotSynchronizedSyncFirst").'</font></div><br>'; |
|
285 | + if ($module == 'ecm') $textifempty = '<br><div align="center"><font class="warning">'.$langs->trans("DirNotSynchronizedSyncFirst").'</font></div><br>'; |
|
286 | 286 | else $textifempty = $langs->trans('NoFileFound'); |
287 | 287 | } |
288 | - else $textifempty=($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("ECMSelectASection")); |
|
288 | + else $textifempty = ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("ECMSelectASection")); |
|
289 | 289 | |
290 | 290 | if ($module == 'medias') |
291 | 291 | { |
292 | 292 | $useinecm = 2; |
293 | - $modulepart='medias'; |
|
294 | - $perm=($user->rights->website->write || $user->rights->emailing->creer); |
|
295 | - $title='none'; |
|
293 | + $modulepart = 'medias'; |
|
294 | + $perm = ($user->rights->website->write || $user->rights->emailing->creer); |
|
295 | + $title = 'none'; |
|
296 | 296 | } |
297 | 297 | else |
298 | 298 | { |
299 | 299 | $useinecm = 1; |
300 | - $modulepart='ecm'; |
|
301 | - $perm=$user->rights->ecm->upload; |
|
302 | - $title=''; // Use default |
|
300 | + $modulepart = 'ecm'; |
|
301 | + $perm = $user->rights->ecm->upload; |
|
302 | + $title = ''; // Use default |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | // When we show list of files for ECM files, $filearray contains file list, and directory is defined with modulepart + section into $param |
@@ -312,33 +312,33 @@ discard block |
||
312 | 312 | |
313 | 313 | |
314 | 314 | // Bottom of page |
315 | -$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; |
|
315 | +$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; |
|
319 | 319 | |
320 | 320 | //$param.=($param?'?':'').(preg_replace('/^&/','',$param)); |
321 | 321 | |
322 | 322 | if ($useajax || $action == 'delete') |
323 | 323 | { |
324 | - $urlfile=''; |
|
325 | - if ($action == 'delete') $urlfile=GETPOST('urlfile','alpha'); |
|
324 | + $urlfile = ''; |
|
325 | + if ($action == 'delete') $urlfile = GETPOST('urlfile', 'alpha'); |
|
326 | 326 | |
327 | - if (empty($section_dir)) $section_dir=GETPOST("file","alpha"); |
|
328 | - $section_id=$section; |
|
327 | + if (empty($section_dir)) $section_dir = GETPOST("file", "alpha"); |
|
328 | + $section_id = $section; |
|
329 | 329 | |
330 | 330 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; |
331 | - $useglobalvars=1; |
|
331 | + $useglobalvars = 1; |
|
332 | 332 | $form = new Form($db); |
333 | - $formquestion['urlfile']=array('type'=>'hidden','value'=>$urlfile,'name'=>'urlfile'); // We must always put field, even if empty because it is fille by javascript later |
|
334 | - $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 | - $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 | - $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'); |
|
340 | - |
|
341 | - print $form->formconfirm($url,$langs->trans("DeleteFile"),$langs->trans("ConfirmDeleteFile"),'confirm_deletefile',$formquestion,"no",($useajax?'deletefile':0)); |
|
333 | + $formquestion['urlfile'] = array('type'=>'hidden', 'value'=>$urlfile, 'name'=>'urlfile'); // We must always put field, even if empty because it is fille by javascript later |
|
334 | + $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 | + $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 | + $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'); |
|
340 | + |
|
341 | + print $form->formconfirm($url, $langs->trans("DeleteFile"), $langs->trans("ConfirmDeleteFile"), 'confirm_deletefile', $formquestion, "no", ($useajax ? 'deletefile' : 0)); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | if ($useajax) |
@@ -376,4 +376,4 @@ discard block |
||
376 | 376 | } |
377 | 377 | |
378 | 378 | // Close db if mode is not noajax |
379 | -if ((! isset($mode) || $mode != 'noajax') && is_object($db)) $db->close(); |
|
379 | +if ((!isset($mode) || $mode != 'noajax') && is_object($db)) $db->close(); |
@@ -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 | +} |
@@ -49,19 +49,19 @@ |
||
49 | 49 | // Registering the location of boxes |
50 | 50 | if (! empty($action) && ! empty($name)) |
51 | 51 | { |
52 | - $entity = GETPOST('entity','int'); |
|
53 | - $value = (GETPOST('value')?GETPOST('value'):1); |
|
52 | + $entity = GETPOST('entity','int'); |
|
53 | + $value = (GETPOST('value')?GETPOST('value'):1); |
|
54 | 54 | |
55 | - if ($user->admin) |
|
56 | - { |
|
57 | - if ($action == 'set') |
|
58 | - { |
|
59 | - dolibarr_set_const($db, $name, $value, 'chaine', 0, '', $entity); |
|
60 | - } |
|
61 | - else if ($action == 'del') |
|
62 | - { |
|
63 | - dolibarr_del_const($db, $name, $entity); |
|
64 | - } |
|
65 | - } |
|
55 | + if ($user->admin) |
|
56 | + { |
|
57 | + if ($action == 'set') |
|
58 | + { |
|
59 | + dolibarr_set_const($db, $name, $value, 'chaine', 0, '', $entity); |
|
60 | + } |
|
61 | + else if ($action == 'del') |
|
62 | + { |
|
63 | + dolibarr_del_const($db, $name, $entity); |
|
64 | + } |
|
65 | + } |
|
66 | 66 | } |
67 | 67 |
@@ -20,12 +20,25 @@ discard block |
||
20 | 20 | * \brief File to set or del an on/off constant |
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 | |
31 | 44 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
@@ -60,8 +73,7 @@ discard block |
||
60 | 73 | if ($action == 'set') |
61 | 74 | { |
62 | 75 | dolibarr_set_const($db, $name, $value, 'chaine', 0, '', $entity); |
63 | - } |
|
64 | - else if ($action == 'del') |
|
76 | + } else if ($action == 'del') |
|
65 | 77 | { |
66 | 78 | dolibarr_del_const($db, $name, $entity); |
67 | 79 | } |
@@ -20,21 +20,21 @@ discard block |
||
20 | 20 | * \brief File to set or del an on/off constant |
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')) 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'); |
|
29 | 29 | |
30 | 30 | |
31 | 31 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
32 | 32 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
33 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
33 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
34 | 34 | require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; |
35 | 35 | |
36 | -$action=GETPOST('action','alpha'); |
|
37 | -$name=GETPOST('name','alpha'); |
|
36 | +$action = GETPOST('action', 'alpha'); |
|
37 | +$name = GETPOST('name', 'alpha'); |
|
38 | 38 | |
39 | 39 | /* |
40 | 40 | * View |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | //print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n"; |
51 | 51 | |
52 | 52 | // Registering the location of boxes |
53 | -if (! empty($action) && ! empty($name)) |
|
53 | +if (!empty($action) && !empty($name)) |
|
54 | 54 | { |
55 | - $entity = GETPOST('entity','int'); |
|
56 | - $value = (GETPOST('value')?GETPOST('value'):1); |
|
55 | + $entity = GETPOST('entity', 'int'); |
|
56 | + $value = (GETPOST('value') ?GETPOST('value') : 1); |
|
57 | 57 | |
58 | 58 | if ($user->admin) |
59 | 59 | { |
@@ -53,31 +53,31 @@ discard block |
||
53 | 53 | // Generation of list of zip-town |
54 | 54 | if (! empty($_GET['zipcode']) || ! empty($_GET['town'])) |
55 | 55 | { |
56 | - $return_arr = array(); |
|
57 | - $formcompany = new FormCompany($db); |
|
58 | - |
|
59 | - // Define filter on text typed |
|
60 | - $zipcode = $_GET['zipcode']?$_GET['zipcode']:''; |
|
61 | - $town = $_GET['town']?$_GET['town']:''; |
|
62 | - |
|
63 | - if (! empty($conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) // Use zip-town table |
|
64 | - { |
|
65 | - $sql = "SELECT z.rowid, z.zip, z.town, z.fk_county, z.fk_pays as fk_country"; |
|
66 | - $sql.= ", c.rowid as fk_country, c.code as country_code, c.label as country"; |
|
67 | - $sql.= ", d.rowid as fk_county, d.code_departement as county_code, d.nom as county"; |
|
68 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_ziptown as z"; |
|
69 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX ."c_departements as d ON z.fk_county = d.rowid"; |
|
70 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r ON d.fk_region = r.code_region,"; |
|
71 | - $sql.= " ".MAIN_DB_PREFIX."c_country as c"; |
|
72 | - $sql.= " WHERE z.fk_pays = c.rowid"; |
|
73 | - $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) . "%'"; |
|
76 | - $sql.= " ORDER BY z.zip, z.town"; |
|
56 | + $return_arr = array(); |
|
57 | + $formcompany = new FormCompany($db); |
|
58 | + |
|
59 | + // Define filter on text typed |
|
60 | + $zipcode = $_GET['zipcode']?$_GET['zipcode']:''; |
|
61 | + $town = $_GET['town']?$_GET['town']:''; |
|
62 | + |
|
63 | + if (! empty($conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) // Use zip-town table |
|
64 | + { |
|
65 | + $sql = "SELECT z.rowid, z.zip, z.town, z.fk_county, z.fk_pays as fk_country"; |
|
66 | + $sql.= ", c.rowid as fk_country, c.code as country_code, c.label as country"; |
|
67 | + $sql.= ", d.rowid as fk_county, d.code_departement as county_code, d.nom as county"; |
|
68 | + $sql.= " FROM ".MAIN_DB_PREFIX."c_ziptown as z"; |
|
69 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX ."c_departements as d ON z.fk_county = d.rowid"; |
|
70 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r ON d.fk_region = r.code_region,"; |
|
71 | + $sql.= " ".MAIN_DB_PREFIX."c_country as c"; |
|
72 | + $sql.= " WHERE z.fk_pays = c.rowid"; |
|
73 | + $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) . "%'"; |
|
76 | + $sql.= " ORDER BY z.zip, z.town"; |
|
77 | 77 | $sql.= $db->plimit(100); // Avoid pb with bad criteria |
78 | - } |
|
79 | - else // Use table of third parties |
|
80 | - { |
|
78 | + } |
|
79 | + else // Use table of third parties |
|
80 | + { |
|
81 | 81 | $sql = "SELECT DISTINCT s.zip, s.town, s.fk_departement as fk_county, s.fk_pays as fk_country"; |
82 | 82 | $sql.= ", c.code as country_code, c.label as country"; |
83 | 83 | $sql.= ", d.code_departement as county_code , d.nom as county"; |
@@ -89,45 +89,45 @@ discard block |
||
89 | 89 | if ($town) $sql.= " s.town LIKE '%" . $db->escape($town) . "%'"; |
90 | 90 | $sql.= " ORDER BY s.fk_pays, s.zip, s.town"; |
91 | 91 | $sql.= $db->plimit(100); // Avoid pb with bad criteria |
92 | - } |
|
92 | + } |
|
93 | 93 | |
94 | 94 | //print $sql; |
95 | - $resql=$db->query($sql); |
|
96 | - //var_dump($db); |
|
97 | - if ($resql) |
|
98 | - { |
|
99 | - while ($row = $db->fetch_array($resql)) |
|
100 | - { |
|
101 | - $country = $row['fk_country']?($langs->transnoentitiesnoconv('Country'.$row['country_code'])!='Country'.$row['country_code']?$langs->transnoentitiesnoconv('Country'.$row['country_code']):$row['country']):''; |
|
102 | - $county = $row['fk_county']?($langs->transnoentitiesnoconv($row['county_code'])!=$row['county_code']?$langs->transnoentitiesnoconv($row['county_code']):($row['county']!='-'?$row['county']:'')):''; |
|
103 | - |
|
104 | - $row_array['label'] = $row['zip'].' '.$row['town']; |
|
105 | - $row_array['label'] .= ($county || $country)?' (':''; |
|
95 | + $resql=$db->query($sql); |
|
96 | + //var_dump($db); |
|
97 | + if ($resql) |
|
98 | + { |
|
99 | + while ($row = $db->fetch_array($resql)) |
|
100 | + { |
|
101 | + $country = $row['fk_country']?($langs->transnoentitiesnoconv('Country'.$row['country_code'])!='Country'.$row['country_code']?$langs->transnoentitiesnoconv('Country'.$row['country_code']):$row['country']):''; |
|
102 | + $county = $row['fk_county']?($langs->transnoentitiesnoconv($row['county_code'])!=$row['county_code']?$langs->transnoentitiesnoconv($row['county_code']):($row['county']!='-'?$row['county']:'')):''; |
|
103 | + |
|
104 | + $row_array['label'] = $row['zip'].' '.$row['town']; |
|
105 | + $row_array['label'] .= ($county || $country)?' (':''; |
|
106 | 106 | $row_array['label'] .= $county; |
107 | - $row_array['label'] .= ($county && $country?' - ':''); |
|
107 | + $row_array['label'] .= ($county && $country?' - ':''); |
|
108 | 108 | $row_array['label'] .= $country; |
109 | 109 | $row_array['label'] .= ($county || $country)?')':''; |
110 | 110 | if ($zipcode) |
111 | - { |
|
112 | - $row_array['value'] = $row['zip']; |
|
113 | - $row_array['town'] = $row['town']; |
|
114 | - } |
|
115 | - if ($town) |
|
116 | - { |
|
117 | - $row_array['value'] = $row['town']; |
|
118 | - $row_array['zipcode'] = $row['zip']; |
|
119 | - } |
|
120 | - $row_array['selectcountry_id'] = $row['fk_country']; |
|
121 | - $row_array['state_id'] = $row['fk_county']; |
|
122 | - |
|
123 | - // TODO Use a cache here to avoid to make select_state in each pass (this make a SQL and lot of logs) |
|
124 | - $row_array['states'] = $formcompany->select_state('',$row['fk_country'],''); |
|
125 | - |
|
126 | - array_push($return_arr,$row_array); |
|
127 | - } |
|
128 | - } |
|
129 | - |
|
130 | - echo json_encode($return_arr); |
|
111 | + { |
|
112 | + $row_array['value'] = $row['zip']; |
|
113 | + $row_array['town'] = $row['town']; |
|
114 | + } |
|
115 | + if ($town) |
|
116 | + { |
|
117 | + $row_array['value'] = $row['town']; |
|
118 | + $row_array['zipcode'] = $row['zip']; |
|
119 | + } |
|
120 | + $row_array['selectcountry_id'] = $row['fk_country']; |
|
121 | + $row_array['state_id'] = $row['fk_county']; |
|
122 | + |
|
123 | + // TODO Use a cache here to avoid to make select_state in each pass (this make a SQL and lot of logs) |
|
124 | + $row_array['states'] = $formcompany->select_state('',$row['fk_country'],''); |
|
125 | + |
|
126 | + array_push($return_arr,$row_array); |
|
127 | + } |
|
128 | + } |
|
129 | + |
|
130 | + echo json_encode($return_arr); |
|
131 | 131 | } |
132 | 132 | else |
133 | 133 | { |
@@ -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 | |
33 | 46 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
@@ -63,9 +76,11 @@ discard block |
||
63 | 76 | $zipcode = $_GET['zipcode']?$_GET['zipcode']:''; |
64 | 77 | $town = $_GET['town']?$_GET['town']:''; |
65 | 78 | |
66 | - if (! empty($conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) // Use zip-town table |
|
79 | + if (! empty($conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) { |
|
80 | + // Use zip-town table |
|
67 | 81 | { |
68 | 82 | $sql = "SELECT z.rowid, z.zip, z.town, z.fk_county, z.fk_pays as fk_country"; |
83 | + } |
|
69 | 84 | $sql.= ", c.rowid as fk_country, c.code as country_code, c.label as country"; |
70 | 85 | $sql.= ", d.rowid as fk_county, d.code_departement as county_code, d.nom as county"; |
71 | 86 | $sql.= " FROM ".MAIN_DB_PREFIX."c_ziptown as z"; |
@@ -74,12 +89,15 @@ discard block |
||
74 | 89 | $sql.= " ".MAIN_DB_PREFIX."c_country as c"; |
75 | 90 | $sql.= " WHERE z.fk_pays = c.rowid"; |
76 | 91 | $sql.= " AND z.active = 1 AND c.active = 1"; |
77 | - if ($zipcode) $sql.=" AND z.zip LIKE '" . $db->escape($zipcode) . "%'"; |
|
78 | - if ($town) $sql.=" AND z.town LIKE '%" . $db->escape($town) . "%'"; |
|
92 | + if ($zipcode) { |
|
93 | + $sql.=" AND z.zip LIKE '" . $db->escape($zipcode) . "%'"; |
|
94 | + } |
|
95 | + if ($town) { |
|
96 | + $sql.=" AND z.town LIKE '%" . $db->escape($town) . "%'"; |
|
97 | + } |
|
79 | 98 | $sql.= " ORDER BY z.zip, z.town"; |
80 | 99 | $sql.= $db->plimit(100); // Avoid pb with bad criteria |
81 | - } |
|
82 | - else // Use table of third parties |
|
100 | + } else // Use table of third parties |
|
83 | 101 | { |
84 | 102 | $sql = "SELECT DISTINCT s.zip, s.town, s.fk_departement as fk_county, s.fk_pays as fk_country"; |
85 | 103 | $sql.= ", c.code as country_code, c.label as country"; |
@@ -88,8 +106,12 @@ discard block |
||
88 | 106 | $sql.= " LEFT JOIN ".MAIN_DB_PREFIX ."c_departements as d ON s.fk_departement = d.rowid"; |
89 | 107 | $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid'; |
90 | 108 | $sql.= " WHERE"; |
91 | - if ($zipcode) $sql.= " s.zip LIKE '".$db->escape($zipcode)."%'"; |
|
92 | - if ($town) $sql.= " s.town LIKE '%" . $db->escape($town) . "%'"; |
|
109 | + if ($zipcode) { |
|
110 | + $sql.= " s.zip LIKE '".$db->escape($zipcode)."%'"; |
|
111 | + } |
|
112 | + if ($town) { |
|
113 | + $sql.= " s.town LIKE '%" . $db->escape($town) . "%'"; |
|
114 | + } |
|
93 | 115 | $sql.= " ORDER BY s.fk_pays, s.zip, s.town"; |
94 | 116 | $sql.= $db->plimit(100); // Avoid pb with bad criteria |
95 | 117 | } |
@@ -131,8 +153,7 @@ discard block |
||
131 | 153 | } |
132 | 154 | |
133 | 155 | echo json_encode($return_arr); |
134 | -} |
|
135 | -else |
|
156 | +} else |
|
136 | 157 | { |
137 | 158 | |
138 | 159 | } |
@@ -22,17 +22,17 @@ 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')) 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'); |
|
31 | 31 | |
32 | 32 | |
33 | 33 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
34 | 34 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
35 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
35 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
36 | 36 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; |
37 | 37 | |
38 | 38 | |
@@ -50,66 +50,66 @@ discard block |
||
50 | 50 | |
51 | 51 | //print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n"; |
52 | 52 | |
53 | -dol_syslog("GET is ".join(',',$_GET).', MAIN_USE_ZIPTOWN_DICTIONNARY='.(empty($conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY)?'':$conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY)); |
|
53 | +dol_syslog("GET is ".join(',', $_GET).', MAIN_USE_ZIPTOWN_DICTIONNARY='.(empty($conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY) ? '' : $conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY)); |
|
54 | 54 | //var_dump($_GET); |
55 | 55 | |
56 | 56 | // Generation of list of zip-town |
57 | -if (! empty($_GET['zipcode']) || ! empty($_GET['town'])) |
|
57 | +if (!empty($_GET['zipcode']) || !empty($_GET['town'])) |
|
58 | 58 | { |
59 | 59 | $return_arr = array(); |
60 | 60 | $formcompany = new FormCompany($db); |
61 | 61 | |
62 | 62 | // Define filter on text typed |
63 | - $zipcode = $_GET['zipcode']?$_GET['zipcode']:''; |
|
64 | - $town = $_GET['town']?$_GET['town']:''; |
|
63 | + $zipcode = $_GET['zipcode'] ? $_GET['zipcode'] : ''; |
|
64 | + $town = $_GET['town'] ? $_GET['town'] : ''; |
|
65 | 65 | |
66 | - if (! empty($conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) // Use zip-town table |
|
66 | + if (!empty($conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) // Use zip-town table |
|
67 | 67 | { |
68 | 68 | $sql = "SELECT z.rowid, z.zip, z.town, z.fk_county, z.fk_pays as fk_country"; |
69 | - $sql.= ", c.rowid as fk_country, c.code as country_code, c.label as country"; |
|
70 | - $sql.= ", d.rowid as fk_county, d.code_departement as county_code, d.nom as county"; |
|
71 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_ziptown as z"; |
|
72 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX ."c_departements as d ON z.fk_county = d.rowid"; |
|
73 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r ON d.fk_region = r.code_region,"; |
|
74 | - $sql.= " ".MAIN_DB_PREFIX."c_country as c"; |
|
75 | - $sql.= " WHERE z.fk_pays = c.rowid"; |
|
76 | - $sql.= " AND z.active = 1 AND c.active = 1"; |
|
77 | - if ($zipcode) $sql.=" AND z.zip LIKE '" . $db->escape($zipcode) . "%'"; |
|
78 | - if ($town) $sql.=" AND z.town LIKE '%" . $db->escape($town) . "%'"; |
|
79 | - $sql.= " ORDER BY z.zip, z.town"; |
|
80 | - $sql.= $db->plimit(100); // Avoid pb with bad criteria |
|
69 | + $sql .= ", c.rowid as fk_country, c.code as country_code, c.label as country"; |
|
70 | + $sql .= ", d.rowid as fk_county, d.code_departement as county_code, d.nom as county"; |
|
71 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_ziptown as z"; |
|
72 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON z.fk_county = d.rowid"; |
|
73 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r ON d.fk_region = r.code_region,"; |
|
74 | + $sql .= " ".MAIN_DB_PREFIX."c_country as c"; |
|
75 | + $sql .= " WHERE z.fk_pays = c.rowid"; |
|
76 | + $sql .= " AND z.active = 1 AND c.active = 1"; |
|
77 | + if ($zipcode) $sql .= " AND z.zip LIKE '".$db->escape($zipcode)."%'"; |
|
78 | + if ($town) $sql .= " AND z.town LIKE '%".$db->escape($town)."%'"; |
|
79 | + $sql .= " ORDER BY z.zip, z.town"; |
|
80 | + $sql .= $db->plimit(100); // Avoid pb with bad criteria |
|
81 | 81 | } |
82 | 82 | else // Use table of third parties |
83 | 83 | { |
84 | 84 | $sql = "SELECT DISTINCT s.zip, s.town, s.fk_departement as fk_county, s.fk_pays as fk_country"; |
85 | - $sql.= ", c.code as country_code, c.label as country"; |
|
86 | - $sql.= ", d.code_departement as county_code , d.nom as county"; |
|
87 | - $sql.= " FROM ".MAIN_DB_PREFIX.'societe as s'; |
|
88 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX ."c_departements as d ON s.fk_departement = d.rowid"; |
|
89 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid'; |
|
90 | - $sql.= " WHERE"; |
|
91 | - if ($zipcode) $sql.= " s.zip LIKE '".$db->escape($zipcode)."%'"; |
|
92 | - if ($town) $sql.= " s.town LIKE '%" . $db->escape($town) . "%'"; |
|
93 | - $sql.= " ORDER BY s.fk_pays, s.zip, s.town"; |
|
94 | - $sql.= $db->plimit(100); // Avoid pb with bad criteria |
|
85 | + $sql .= ", c.code as country_code, c.label as country"; |
|
86 | + $sql .= ", d.code_departement as county_code , d.nom as county"; |
|
87 | + $sql .= " FROM ".MAIN_DB_PREFIX.'societe as s'; |
|
88 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON s.fk_departement = d.rowid"; |
|
89 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid'; |
|
90 | + $sql .= " WHERE"; |
|
91 | + if ($zipcode) $sql .= " s.zip LIKE '".$db->escape($zipcode)."%'"; |
|
92 | + if ($town) $sql .= " s.town LIKE '%".$db->escape($town)."%'"; |
|
93 | + $sql .= " ORDER BY s.fk_pays, s.zip, s.town"; |
|
94 | + $sql .= $db->plimit(100); // Avoid pb with bad criteria |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | //print $sql; |
98 | - $resql=$db->query($sql); |
|
98 | + $resql = $db->query($sql); |
|
99 | 99 | //var_dump($db); |
100 | 100 | if ($resql) |
101 | 101 | { |
102 | 102 | while ($row = $db->fetch_array($resql)) |
103 | 103 | { |
104 | - $country = $row['fk_country']?($langs->transnoentitiesnoconv('Country'.$row['country_code'])!='Country'.$row['country_code']?$langs->transnoentitiesnoconv('Country'.$row['country_code']):$row['country']):''; |
|
105 | - $county = $row['fk_county']?($langs->transnoentitiesnoconv($row['county_code'])!=$row['county_code']?$langs->transnoentitiesnoconv($row['county_code']):($row['county']!='-'?$row['county']:'')):''; |
|
104 | + $country = $row['fk_country'] ? ($langs->transnoentitiesnoconv('Country'.$row['country_code']) != 'Country'.$row['country_code'] ? $langs->transnoentitiesnoconv('Country'.$row['country_code']) : $row['country']) : ''; |
|
105 | + $county = $row['fk_county'] ? ($langs->transnoentitiesnoconv($row['county_code']) != $row['county_code'] ? $langs->transnoentitiesnoconv($row['county_code']) : ($row['county'] != '-' ? $row['county'] : '')) : ''; |
|
106 | 106 | |
107 | 107 | $row_array['label'] = $row['zip'].' '.$row['town']; |
108 | - $row_array['label'] .= ($county || $country)?' (':''; |
|
108 | + $row_array['label'] .= ($county || $country) ? ' (' : ''; |
|
109 | 109 | $row_array['label'] .= $county; |
110 | - $row_array['label'] .= ($county && $country?' - ':''); |
|
110 | + $row_array['label'] .= ($county && $country ? ' - ' : ''); |
|
111 | 111 | $row_array['label'] .= $country; |
112 | - $row_array['label'] .= ($county || $country)?')':''; |
|
112 | + $row_array['label'] .= ($county || $country) ? ')' : ''; |
|
113 | 113 | if ($zipcode) |
114 | 114 | { |
115 | 115 | $row_array['value'] = $row['zip']; |
@@ -124,9 +124,9 @@ discard block |
||
124 | 124 | $row_array['state_id'] = $row['fk_county']; |
125 | 125 | |
126 | 126 | // TODO Use a cache here to avoid to make select_state in each pass (this make a SQL and lot of logs) |
127 | - $row_array['states'] = $formcompany->select_state('',$row['fk_country'],''); |
|
127 | + $row_array['states'] = $formcompany->select_state('', $row['fk_country'], ''); |
|
128 | 128 | |
129 | - array_push($return_arr,$row_array); |
|
129 | + array_push($return_arr, $row_array); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 |
@@ -43,34 +43,34 @@ |
||
43 | 43 | |
44 | 44 | // Registering the location of boxes |
45 | 45 | if ((! empty($_POST['roworder'])) && (! empty($_POST['table_element_line'])) |
46 | - && (! empty($_POST['fk_element'])) && (! empty($_POST['element_id']))) |
|
46 | + && (! empty($_POST['fk_element'])) && (! empty($_POST['element_id']))) |
|
47 | 47 | { |
48 | - $roworder=GETPOST('roworder','alpha',2); |
|
49 | - $table_element_line=GETPOST('table_element_line','alpha',2); |
|
50 | - $fk_element=GETPOST('fk_element','alpha',2); |
|
51 | - $element_id=GETPOST('element_id','int',2); |
|
48 | + $roworder=GETPOST('roworder','alpha',2); |
|
49 | + $table_element_line=GETPOST('table_element_line','alpha',2); |
|
50 | + $fk_element=GETPOST('fk_element','alpha',2); |
|
51 | + $element_id=GETPOST('element_id','int',2); |
|
52 | 52 | |
53 | - dol_syslog("AjaxRow roworder=".$roworder." table_element_line=".$table_element_line." fk_element=".$fk_element." element_id=".$element_id, LOG_DEBUG); |
|
53 | + dol_syslog("AjaxRow roworder=".$roworder." table_element_line=".$table_element_line." fk_element=".$fk_element." element_id=".$element_id, LOG_DEBUG); |
|
54 | 54 | |
55 | - $rowordertab = explode(',',$roworder); |
|
56 | - $newrowordertab = array(); |
|
57 | - foreach($rowordertab as $value) |
|
58 | - { |
|
59 | - if (! empty($value)) $newrowordertab[] = $value; |
|
60 | - } |
|
55 | + $rowordertab = explode(',',$roworder); |
|
56 | + $newrowordertab = array(); |
|
57 | + foreach($rowordertab as $value) |
|
58 | + { |
|
59 | + if (! empty($value)) $newrowordertab[] = $value; |
|
60 | + } |
|
61 | 61 | |
62 | - $row=new GenericObject($db); |
|
63 | - $row->table_element_line = $table_element_line; |
|
64 | - $row->fk_element = $fk_element; |
|
65 | - $row->id = $element_id; |
|
62 | + $row=new GenericObject($db); |
|
63 | + $row->table_element_line = $table_element_line; |
|
64 | + $row->fk_element = $fk_element; |
|
65 | + $row->id = $element_id; |
|
66 | 66 | |
67 | - $row->line_ajaxorder($newrowordertab); // This update field rank or position in table row->table_element_line |
|
67 | + $row->line_ajaxorder($newrowordertab); // This update field rank or position in table row->table_element_line |
|
68 | 68 | |
69 | - // Reorder line to have position of children lines sharing same counter than parent lines |
|
70 | - // This should be useless because there is no need to have children sharing same counter than parent, but well, it's cleaner into database. |
|
71 | - if (in_array($fk_element,array('fk_facture','fk_propal','fk_commande'))) |
|
72 | - { |
|
73 | - $result=$row->line_order(true); |
|
74 | - } |
|
69 | + // Reorder line to have position of children lines sharing same counter than parent lines |
|
70 | + // This should be useless because there is no need to have children sharing same counter than parent, but well, it's cleaner into database. |
|
71 | + if (in_array($fk_element,array('fk_facture','fk_propal','fk_commande'))) |
|
72 | + { |
|
73 | + $result=$row->line_order(true); |
|
74 | + } |
|
75 | 75 | } |
76 | 76 |
@@ -22,12 +22,25 @@ discard block |
||
22 | 22 | * This ajax page is called when doing an up or down drag and drop. |
23 | 23 | */ |
24 | 24 | |
25 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disable 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('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
|
25 | +if (! defined('NOTOKENRENEWAL')) { |
|
26 | + define('NOTOKENRENEWAL','1'); |
|
27 | +} |
|
28 | +// Disable 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('NOREQUIRETRAN')) { |
|
42 | + define('NOREQUIRETRAN','1'); |
|
43 | +} |
|
31 | 44 | |
32 | 45 | |
33 | 46 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
@@ -59,7 +72,9 @@ discard block |
||
59 | 72 | $newrowordertab = array(); |
60 | 73 | foreach($rowordertab as $value) |
61 | 74 | { |
62 | - if (! empty($value)) $newrowordertab[] = $value; |
|
75 | + if (! empty($value)) { |
|
76 | + $newrowordertab[] = $value; |
|
77 | + } |
|
63 | 78 | } |
64 | 79 | |
65 | 80 | $row=new GenericObject($db); |
@@ -22,17 +22,17 @@ discard block |
||
22 | 22 | * This ajax page is called when doing an up or down drag and drop. |
23 | 23 | */ |
24 | 24 | |
25 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disable 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('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
|
25 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disable 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('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); |
|
31 | 31 | |
32 | 32 | |
33 | 33 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
34 | 34 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
35 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
35 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
36 | 36 | require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; |
37 | 37 | |
38 | 38 | |
@@ -45,35 +45,35 @@ discard block |
||
45 | 45 | print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n"; |
46 | 46 | |
47 | 47 | // Registering the location of boxes |
48 | -if ((! empty($_POST['roworder'])) && (! empty($_POST['table_element_line'])) |
|
49 | - && (! empty($_POST['fk_element'])) && (! empty($_POST['element_id']))) |
|
48 | +if ((!empty($_POST['roworder'])) && (!empty($_POST['table_element_line'])) |
|
49 | + && (!empty($_POST['fk_element'])) && (!empty($_POST['element_id']))) |
|
50 | 50 | { |
51 | - $roworder=GETPOST('roworder','alpha',2); |
|
52 | - $table_element_line=GETPOST('table_element_line','alpha',2); |
|
53 | - $fk_element=GETPOST('fk_element','alpha',2); |
|
54 | - $element_id=GETPOST('element_id','int',2); |
|
51 | + $roworder = GETPOST('roworder', 'alpha', 2); |
|
52 | + $table_element_line = GETPOST('table_element_line', 'alpha', 2); |
|
53 | + $fk_element = GETPOST('fk_element', 'alpha', 2); |
|
54 | + $element_id = GETPOST('element_id', 'int', 2); |
|
55 | 55 | |
56 | 56 | dol_syslog("AjaxRow roworder=".$roworder." table_element_line=".$table_element_line." fk_element=".$fk_element." element_id=".$element_id, LOG_DEBUG); |
57 | 57 | |
58 | - $rowordertab = explode(',',$roworder); |
|
58 | + $rowordertab = explode(',', $roworder); |
|
59 | 59 | $newrowordertab = array(); |
60 | - foreach($rowordertab as $value) |
|
60 | + foreach ($rowordertab as $value) |
|
61 | 61 | { |
62 | - if (! empty($value)) $newrowordertab[] = $value; |
|
62 | + if (!empty($value)) $newrowordertab[] = $value; |
|
63 | 63 | } |
64 | 64 | |
65 | - $row=new GenericObject($db); |
|
65 | + $row = new GenericObject($db); |
|
66 | 66 | $row->table_element_line = $table_element_line; |
67 | 67 | $row->fk_element = $fk_element; |
68 | 68 | $row->id = $element_id; |
69 | 69 | |
70 | - $row->line_ajaxorder($newrowordertab); // This update field rank or position in table row->table_element_line |
|
70 | + $row->line_ajaxorder($newrowordertab); // This update field rank or position in table row->table_element_line |
|
71 | 71 | |
72 | 72 | // Reorder line to have position of children lines sharing same counter than parent lines |
73 | 73 | // This should be useless because there is no need to have children sharing same counter than parent, but well, it's cleaner into database. |
74 | - if (in_array($fk_element,array('fk_facture','fk_propal','fk_commande'))) |
|
74 | + if (in_array($fk_element, array('fk_facture', 'fk_propal', 'fk_commande'))) |
|
75 | 75 | { |
76 | - $result=$row->line_order(true); |
|
76 | + $result = $row->line_order(true); |
|
77 | 77 | } |
78 | 78 | } |
79 | 79 |
@@ -42,11 +42,11 @@ |
||
42 | 42 | // Registering the location of boxes |
43 | 43 | if (isset($_GET['action']) && ! empty($_GET['action'])) |
44 | 44 | { |
45 | - if ($_GET['action'] == 'getrandompassword' && $user->admin) |
|
46 | - { |
|
45 | + if ($_GET['action'] == 'getrandompassword' && $user->admin) |
|
46 | + { |
|
47 | 47 | require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; |
48 | - $generic = $_GET['generic'] ? true : false; |
|
49 | - echo getRandomPassword($generic); |
|
50 | - } |
|
48 | + $generic = $_GET['generic'] ? true : false; |
|
49 | + echo getRandomPassword($generic); |
|
50 | + } |
|
51 | 51 | } |
52 | 52 |
@@ -21,12 +21,25 @@ |
||
21 | 21 | * like key to use into URL to protect them. |
22 | 22 | */ |
23 | 23 | |
24 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal |
|
25 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); |
|
26 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); |
|
27 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
28 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
29 | -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
|
24 | +if (! defined('NOTOKENRENEWAL')) { |
|
25 | + define('NOTOKENRENEWAL','1'); |
|
26 | +} |
|
27 | +// Disables token renewal |
|
28 | +if (! defined('NOREQUIREMENU')) { |
|
29 | + define('NOREQUIREMENU','1'); |
|
30 | +} |
|
31 | +if (! defined('NOREQUIREHTML')) { |
|
32 | + define('NOREQUIREHTML','1'); |
|
33 | +} |
|
34 | +if (! defined('NOREQUIREAJAX')) { |
|
35 | + define('NOREQUIREAJAX','1'); |
|
36 | +} |
|
37 | +if (! defined('NOREQUIRESOC')) { |
|
38 | + define('NOREQUIRESOC','1'); |
|
39 | +} |
|
40 | +if (! defined('NOREQUIRETRAN')) { |
|
41 | + define('NOREQUIRETRAN','1'); |
|
42 | +} |
|
30 | 43 | |
31 | 44 | |
32 | 45 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
@@ -21,17 +21,17 @@ discard block |
||
21 | 21 | * like key to use into URL to protect them. |
22 | 22 | */ |
23 | 23 | |
24 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal |
|
25 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); |
|
26 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); |
|
27 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
28 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
29 | -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
|
24 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal |
|
25 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); |
|
26 | +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); |
|
27 | +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
28 | +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
29 | +if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); |
|
30 | 30 | |
31 | 31 | |
32 | 32 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
33 | 33 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
34 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
34 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
35 | 35 | |
36 | 36 | /* |
37 | 37 | * View |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | //print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n"; |
44 | 44 | |
45 | 45 | // Registering the location of boxes |
46 | -if (isset($_GET['action']) && ! empty($_GET['action'])) |
|
46 | +if (isset($_GET['action']) && !empty($_GET['action'])) |
|
47 | 47 | { |
48 | 48 | if ($_GET['action'] == 'getrandompassword' && $user->admin) |
49 | 49 | { |
@@ -35,11 +35,11 @@ discard block |
||
35 | 35 | $res=@include '../../main.inc.php'; |
36 | 36 | if ($res == 'ERROR_NOT_LOGGED') |
37 | 37 | { |
38 | - $langs->load("other"); |
|
39 | - $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 | - print json_encode($arrayresult); |
|
41 | - if (is_object($db)) $db->close(); |
|
42 | - exit; |
|
38 | + $langs->load("other"); |
|
39 | + $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 | + print json_encode($arrayresult); |
|
41 | + if (is_object($db)) $db->close(); |
|
42 | + exit; |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
@@ -56,85 +56,85 @@ discard block |
||
56 | 56 | |
57 | 57 | if (! empty($conf->adherent->enabled) && empty($conf->global->MAIN_SEARCHFORM_ADHERENT_DISABLED) && $user->rights->adherent->lire) |
58 | 58 | { |
59 | - $arrayresult['searchintomember']=array('position'=>8, 'shortcut'=>'M', 'img'=>'object_user', 'label'=>$langs->trans("SearchIntoMembers", $search_boxvalue), 'text'=>img_picto('','object_user').' '.$langs->trans("SearchIntoMembers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/adherents/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
59 | + $arrayresult['searchintomember']=array('position'=>8, 'shortcut'=>'M', 'img'=>'object_user', 'label'=>$langs->trans("SearchIntoMembers", $search_boxvalue), 'text'=>img_picto('','object_user').' '.$langs->trans("SearchIntoMembers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/adherents/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | if ((( ! empty($conf->societe->enabled) && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || ! empty($conf->fournisseur->enabled)) && empty($conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED) && $user->rights->societe->lire) |
63 | 63 | { |
64 | - $arrayresult['searchintothirdparty']=array('position'=>10, 'shortcut'=>'T', 'img'=>'object_company', 'label'=>$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'text'=>img_picto('','object_company').' '.$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/societe/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
64 | + $arrayresult['searchintothirdparty']=array('position'=>10, 'shortcut'=>'T', 'img'=>'object_company', 'label'=>$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'text'=>img_picto('','object_company').' '.$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/societe/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | if (! empty($conf->societe->enabled) && empty($conf->global->MAIN_SEARCHFORM_CONTACT_DISABLED) && $user->rights->societe->lire) |
68 | 68 | { |
69 | - $arrayresult['searchintocontact']=array('position'=>15, 'shortcut'=>'A', 'img'=>'object_contact', 'label'=>$langs->trans("SearchIntoContacts", $search_boxvalue), 'text'=>img_picto('','object_contact').' '.$langs->trans("SearchIntoContacts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contact/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
69 | + $arrayresult['searchintocontact']=array('position'=>15, 'shortcut'=>'A', 'img'=>'object_contact', 'label'=>$langs->trans("SearchIntoContacts", $search_boxvalue), 'text'=>img_picto('','object_contact').' '.$langs->trans("SearchIntoContacts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contact/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | if (((! empty($conf->product->enabled) && $user->rights->produit->lire) || (! empty($conf->service->enabled) && $user->rights->service->lire)) |
73 | 73 | && empty($conf->global->MAIN_SEARCHFORM_PRODUITSERVICE_DISABLED)) |
74 | 74 | { |
75 | - $arrayresult['searchintoproduct']=array('position'=>30, 'shortcut'=>'P', 'img'=>'object_product', 'label'=>$langs->trans("SearchIntoProductsOrServices", $search_boxvalue),'text'=>img_picto('','object_product').' '.$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/product/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
75 | + $arrayresult['searchintoproduct']=array('position'=>30, 'shortcut'=>'P', 'img'=>'object_product', 'label'=>$langs->trans("SearchIntoProductsOrServices", $search_boxvalue),'text'=>img_picto('','object_product').' '.$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/product/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | if (! empty($conf->projet->enabled) && empty($conf->global->MAIN_SEARCHFORM_PROJECT_DISABLED) && $user->rights->projet->lire) |
79 | 79 | { |
80 | - $arrayresult['searchintoprojects']=array('position'=>40, 'shortcut'=>'Q', 'img'=>'object_projectpub', 'label'=>$langs->trans("SearchIntoProjects", $search_boxvalue), 'text'=>img_picto('','object_projectpub').' '.$langs->trans("SearchIntoProjects", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/list.php'.($search_boxvalue?'?search_all='.urlencode($search_boxvalue):'')); |
|
80 | + $arrayresult['searchintoprojects']=array('position'=>40, 'shortcut'=>'Q', 'img'=>'object_projectpub', 'label'=>$langs->trans("SearchIntoProjects", $search_boxvalue), 'text'=>img_picto('','object_projectpub').' '.$langs->trans("SearchIntoProjects", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/list.php'.($search_boxvalue?'?search_all='.urlencode($search_boxvalue):'')); |
|
81 | 81 | } |
82 | 82 | if (! empty($conf->projet->enabled) && empty($conf->global->MAIN_SEARCHFORM_TASK_DISABLED) && $user->rights->projet->lire) |
83 | 83 | { |
84 | - $arrayresult['searchintotasks']=array('position'=>45, 'img'=>'object_task', 'label'=>$langs->trans("SearchIntoTasks", $search_boxvalue), 'text'=>img_picto('','object_task').' '.$langs->trans("SearchIntoTasks", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/tasks/list.php'.($search_boxvalue?'?search_all='.urlencode($search_boxvalue):'')); |
|
84 | + $arrayresult['searchintotasks']=array('position'=>45, 'img'=>'object_task', 'label'=>$langs->trans("SearchIntoTasks", $search_boxvalue), 'text'=>img_picto('','object_task').' '.$langs->trans("SearchIntoTasks", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/tasks/list.php'.($search_boxvalue?'?search_all='.urlencode($search_boxvalue):'')); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | if (! empty($conf->propal->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_PROPAL_DISABLED) && $user->rights->propal->lire) |
88 | 88 | { |
89 | - $arrayresult['searchintopropal']=array('position'=>60, 'img'=>'object_propal', 'label'=>$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'text'=>img_picto('','object_propal').' '.$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/comm/propal/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
89 | + $arrayresult['searchintopropal']=array('position'=>60, 'img'=>'object_propal', 'label'=>$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'text'=>img_picto('','object_propal').' '.$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/comm/propal/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
90 | 90 | } |
91 | 91 | if (! empty($conf->commande->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_ORDER_DISABLED) && $user->rights->commande->lire) |
92 | 92 | { |
93 | - $arrayresult['searchintoorder']=array('position'=>70, 'img'=>'object_order', 'label'=>$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'text'=>img_picto('','object_order').' '.$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/commande/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
93 | + $arrayresult['searchintoorder']=array('position'=>70, 'img'=>'object_order', 'label'=>$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'text'=>img_picto('','object_order').' '.$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/commande/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
94 | 94 | } |
95 | 95 | if (! empty($conf->expedition->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_SHIPMENT_DISABLED) && $user->rights->expedition->lire) |
96 | 96 | { |
97 | - $arrayresult['searchintoshipment']=array('position'=>80, 'img'=>'object_sending', 'label'=>$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'text'=>img_picto('','object_sending').' '.$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expedition/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
97 | + $arrayresult['searchintoshipment']=array('position'=>80, 'img'=>'object_sending', 'label'=>$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'text'=>img_picto('','object_sending').' '.$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expedition/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
98 | 98 | } |
99 | 99 | if (! empty($conf->facture->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_INVOICE_DISABLED) && $user->rights->facture->lire) |
100 | 100 | { |
101 | - $arrayresult['searchintoinvoice']=array('position'=>90, 'img'=>'object_bill', 'label'=>$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'text'=>img_picto('','object_bill').' '.$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/compta/facture/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
101 | + $arrayresult['searchintoinvoice']=array('position'=>90, 'img'=>'object_bill', 'label'=>$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'text'=>img_picto('','object_bill').' '.$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/compta/facture/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | if (! empty($conf->supplier_proposal->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_PROPAL_DISABLED) && $user->rights->supplier_proposal->lire) |
105 | 105 | { |
106 | - $arrayresult['searchintosupplierpropal']=array('position'=>100, 'img'=>'object_propal', 'label'=>$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'text'=>img_picto('','object_propal').' '.$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/supplier_proposal/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
106 | + $arrayresult['searchintosupplierpropal']=array('position'=>100, 'img'=>'object_propal', 'label'=>$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'text'=>img_picto('','object_propal').' '.$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/supplier_proposal/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
107 | 107 | } |
108 | 108 | if (! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_ORDER_DISABLED) && $user->rights->fournisseur->commande->lire) |
109 | 109 | { |
110 | - $arrayresult['searchintosupplierorder']=array('position'=>110, 'img'=>'object_order', 'label'=>$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'text'=>img_picto('','object_order').' '.$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/commande/list.php'.($search_boxvalue?'?search_all='.urlencode($search_boxvalue):'')); |
|
110 | + $arrayresult['searchintosupplierorder']=array('position'=>110, 'img'=>'object_order', 'label'=>$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'text'=>img_picto('','object_order').' '.$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/commande/list.php'.($search_boxvalue?'?search_all='.urlencode($search_boxvalue):'')); |
|
111 | 111 | } |
112 | 112 | if (! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED) && $user->rights->fournisseur->facture->lire) |
113 | 113 | { |
114 | - $arrayresult['searchintosupplierinvoice']=array('position'=>120, 'img'=>'object_bill', 'label'=>$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'text'=>img_picto('','object_bill').' '.$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/facture/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
114 | + $arrayresult['searchintosupplierinvoice']=array('position'=>120, 'img'=>'object_bill', 'label'=>$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'text'=>img_picto('','object_bill').' '.$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/facture/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | if (! empty($conf->contrat->enabled) && empty($conf->global->MAIN_SEARCHFORM_CONTRACT_DISABLED) && $user->rights->contrat->lire) |
118 | 118 | { |
119 | - $arrayresult['searchintocontract']=array('position'=>130, 'img'=>'object_contract', 'label'=>$langs->trans("SearchIntoContracts", $search_boxvalue), 'text'=>img_picto('','object_contract').' '.$langs->trans("SearchIntoContracts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contrat/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
119 | + $arrayresult['searchintocontract']=array('position'=>130, 'img'=>'object_contract', 'label'=>$langs->trans("SearchIntoContracts", $search_boxvalue), 'text'=>img_picto('','object_contract').' '.$langs->trans("SearchIntoContracts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contrat/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
120 | 120 | } |
121 | 121 | if (! empty($conf->ficheinter->enabled) && empty($conf->global->MAIN_SEARCHFORM_FICHINTER_DISABLED) && $user->rights->ficheinter->lire) |
122 | 122 | { |
123 | - $arrayresult['searchintointervention']=array('position'=>140, 'img'=>'object_intervention', 'label'=>$langs->trans("SearchIntoInterventions", $search_boxvalue), 'text'=>img_picto('','object_intervention').' '.$langs->trans("SearchIntoInterventions", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fichinter/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
123 | + $arrayresult['searchintointervention']=array('position'=>140, 'img'=>'object_intervention', 'label'=>$langs->trans("SearchIntoInterventions", $search_boxvalue), 'text'=>img_picto('','object_intervention').' '.$langs->trans("SearchIntoInterventions", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fichinter/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | // HR |
127 | 127 | if (! empty($conf->user->enabled) && empty($conf->global->MAIN_SEARCHFORM_USER_DISABLED) && $user->rights->user->user->lire) |
128 | 128 | { |
129 | - $arrayresult['searchintouser']=array('position'=>200, 'shortcut'=>'U', 'img'=>'object_user', 'label'=>$langs->trans("SearchIntoUsers", $search_boxvalue), 'text'=>img_picto('','object_user').' '.$langs->trans("SearchIntoUsers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/user/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
129 | + $arrayresult['searchintouser']=array('position'=>200, 'shortcut'=>'U', 'img'=>'object_user', 'label'=>$langs->trans("SearchIntoUsers", $search_boxvalue), 'text'=>img_picto('','object_user').' '.$langs->trans("SearchIntoUsers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/user/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
130 | 130 | } |
131 | 131 | if (! empty($conf->expensereport->enabled) && empty($conf->global->MAIN_SEARCHFORM_EXPENSEREPORT_DISABLED) && $user->rights->expensereport->lire) |
132 | 132 | { |
133 | - $arrayresult['searchintoexpensereport']=array('position'=>210, 'img'=>'object_trip', 'label'=>$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'text'=>img_picto('','object_trip').' '.$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm'.($search_boxvalue?'&sall='.urlencode($search_boxvalue):'')); |
|
133 | + $arrayresult['searchintoexpensereport']=array('position'=>210, 'img'=>'object_trip', 'label'=>$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'text'=>img_picto('','object_trip').' '.$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm'.($search_boxvalue?'&sall='.urlencode($search_boxvalue):'')); |
|
134 | 134 | } |
135 | 135 | if (! empty($conf->holiday->enabled) && empty($conf->global->MAIN_SEARCHFORM_HOLIDAY_DISABLED) && $user->rights->holiday->read) |
136 | 136 | { |
137 | - $arrayresult['searchintoleaves']=array('position'=>220, 'img'=>'object_holiday', 'label'=>$langs->trans("SearchIntoLeaves", $search_boxvalue), 'text'=>img_picto('','object_holiday').' '.$langs->trans("SearchIntoLeaves", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/holiday/list.php?mainmenu=hrm'.($search_boxvalue?'&sall='.urlencode($search_boxvalue):'')); |
|
137 | + $arrayresult['searchintoleaves']=array('position'=>220, 'img'=>'object_holiday', 'label'=>$langs->trans("SearchIntoLeaves", $search_boxvalue), 'text'=>img_picto('','object_holiday').' '.$langs->trans("SearchIntoLeaves", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/holiday/list.php?mainmenu=hrm'.($search_boxvalue?'&sall='.urlencode($search_boxvalue):'')); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | $reshook=$hookmanager->executeHooks('addSearchEntry',$parameters); |
152 | 152 | if (empty($reshook)) |
153 | 153 | { |
154 | - $arrayresult=array_merge($arrayresult, $hookmanager->resArray); |
|
154 | + $arrayresult=array_merge($arrayresult, $hookmanager->resArray); |
|
155 | 155 | } |
156 | 156 | else $arrayresult=$hookmanager->resArray; |
157 | 157 |
@@ -24,19 +24,19 @@ discard block |
||
24 | 24 | |
25 | 25 | // This script is called with a POST method or as an include. |
26 | 26 | |
27 | -if (! isset($usedbyinclude) || empty($usedbyinclude)) |
|
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')) 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'); |
|
34 | 34 | |
35 | - $res=@include '../../main.inc.php'; |
|
35 | + $res = @include '../../main.inc.php'; |
|
36 | 36 | if ($res == 'ERROR_NOT_LOGGED') |
37 | 37 | { |
38 | 38 | $langs->load("other"); |
39 | - $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'); |
|
39 | + $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 | 40 | print json_encode($arrayresult); |
41 | 41 | if (is_object($db)) $db->close(); |
42 | 42 | exit; |
@@ -48,93 +48,93 @@ discard block |
||
48 | 48 | //global $hookmanager; |
49 | 49 | $hookmanager->initHooks(array('searchform')); |
50 | 50 | |
51 | -$search_boxvalue=GETPOST('q', 'none'); |
|
51 | +$search_boxvalue = GETPOST('q', 'none'); |
|
52 | 52 | |
53 | -$arrayresult=array(); |
|
53 | +$arrayresult = array(); |
|
54 | 54 | |
55 | 55 | // Define $searchform |
56 | 56 | |
57 | -if (! empty($conf->adherent->enabled) && empty($conf->global->MAIN_SEARCHFORM_ADHERENT_DISABLED) && $user->rights->adherent->lire) |
|
57 | +if (!empty($conf->adherent->enabled) && empty($conf->global->MAIN_SEARCHFORM_ADHERENT_DISABLED) && $user->rights->adherent->lire) |
|
58 | 58 | { |
59 | - $arrayresult['searchintomember']=array('position'=>8, 'shortcut'=>'M', 'img'=>'object_user', 'label'=>$langs->trans("SearchIntoMembers", $search_boxvalue), 'text'=>img_picto('','object_user').' '.$langs->trans("SearchIntoMembers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/adherents/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
59 | + $arrayresult['searchintomember'] = array('position'=>8, 'shortcut'=>'M', 'img'=>'object_user', 'label'=>$langs->trans("SearchIntoMembers", $search_boxvalue), 'text'=>img_picto('', 'object_user').' '.$langs->trans("SearchIntoMembers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/adherents/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); |
|
60 | 60 | } |
61 | 61 | |
62 | -if ((( ! empty($conf->societe->enabled) && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || ! empty($conf->fournisseur->enabled)) && empty($conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED) && $user->rights->societe->lire) |
|
62 | +if (((!empty($conf->societe->enabled) && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || !empty($conf->fournisseur->enabled)) && empty($conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED) && $user->rights->societe->lire) |
|
63 | 63 | { |
64 | - $arrayresult['searchintothirdparty']=array('position'=>10, 'shortcut'=>'T', 'img'=>'object_company', 'label'=>$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'text'=>img_picto('','object_company').' '.$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/societe/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
64 | + $arrayresult['searchintothirdparty'] = array('position'=>10, 'shortcut'=>'T', 'img'=>'object_company', 'label'=>$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'text'=>img_picto('', 'object_company').' '.$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/societe/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); |
|
65 | 65 | } |
66 | 66 | |
67 | -if (! empty($conf->societe->enabled) && empty($conf->global->MAIN_SEARCHFORM_CONTACT_DISABLED) && $user->rights->societe->lire) |
|
67 | +if (!empty($conf->societe->enabled) && empty($conf->global->MAIN_SEARCHFORM_CONTACT_DISABLED) && $user->rights->societe->lire) |
|
68 | 68 | { |
69 | - $arrayresult['searchintocontact']=array('position'=>15, 'shortcut'=>'A', 'img'=>'object_contact', 'label'=>$langs->trans("SearchIntoContacts", $search_boxvalue), 'text'=>img_picto('','object_contact').' '.$langs->trans("SearchIntoContacts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contact/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
69 | + $arrayresult['searchintocontact'] = array('position'=>15, 'shortcut'=>'A', 'img'=>'object_contact', 'label'=>$langs->trans("SearchIntoContacts", $search_boxvalue), 'text'=>img_picto('', 'object_contact').' '.$langs->trans("SearchIntoContacts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contact/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); |
|
70 | 70 | } |
71 | 71 | |
72 | -if (((! empty($conf->product->enabled) && $user->rights->produit->lire) || (! empty($conf->service->enabled) && $user->rights->service->lire)) |
|
72 | +if (((!empty($conf->product->enabled) && $user->rights->produit->lire) || (!empty($conf->service->enabled) && $user->rights->service->lire)) |
|
73 | 73 | && empty($conf->global->MAIN_SEARCHFORM_PRODUITSERVICE_DISABLED)) |
74 | 74 | { |
75 | - $arrayresult['searchintoproduct']=array('position'=>30, 'shortcut'=>'P', 'img'=>'object_product', 'label'=>$langs->trans("SearchIntoProductsOrServices", $search_boxvalue),'text'=>img_picto('','object_product').' '.$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/product/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
75 | + $arrayresult['searchintoproduct'] = array('position'=>30, 'shortcut'=>'P', 'img'=>'object_product', 'label'=>$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'text'=>img_picto('', 'object_product').' '.$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/product/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); |
|
76 | 76 | } |
77 | 77 | |
78 | -if (! empty($conf->projet->enabled) && empty($conf->global->MAIN_SEARCHFORM_PROJECT_DISABLED) && $user->rights->projet->lire) |
|
78 | +if (!empty($conf->projet->enabled) && empty($conf->global->MAIN_SEARCHFORM_PROJECT_DISABLED) && $user->rights->projet->lire) |
|
79 | 79 | { |
80 | - $arrayresult['searchintoprojects']=array('position'=>40, 'shortcut'=>'Q', 'img'=>'object_projectpub', 'label'=>$langs->trans("SearchIntoProjects", $search_boxvalue), 'text'=>img_picto('','object_projectpub').' '.$langs->trans("SearchIntoProjects", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/list.php'.($search_boxvalue?'?search_all='.urlencode($search_boxvalue):'')); |
|
80 | + $arrayresult['searchintoprojects'] = array('position'=>40, 'shortcut'=>'Q', 'img'=>'object_projectpub', 'label'=>$langs->trans("SearchIntoProjects", $search_boxvalue), 'text'=>img_picto('', 'object_projectpub').' '.$langs->trans("SearchIntoProjects", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); |
|
81 | 81 | } |
82 | -if (! empty($conf->projet->enabled) && empty($conf->global->MAIN_SEARCHFORM_TASK_DISABLED) && $user->rights->projet->lire) |
|
82 | +if (!empty($conf->projet->enabled) && empty($conf->global->MAIN_SEARCHFORM_TASK_DISABLED) && $user->rights->projet->lire) |
|
83 | 83 | { |
84 | - $arrayresult['searchintotasks']=array('position'=>45, 'img'=>'object_task', 'label'=>$langs->trans("SearchIntoTasks", $search_boxvalue), 'text'=>img_picto('','object_task').' '.$langs->trans("SearchIntoTasks", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/tasks/list.php'.($search_boxvalue?'?search_all='.urlencode($search_boxvalue):'')); |
|
84 | + $arrayresult['searchintotasks'] = array('position'=>45, 'img'=>'object_task', 'label'=>$langs->trans("SearchIntoTasks", $search_boxvalue), 'text'=>img_picto('', 'object_task').' '.$langs->trans("SearchIntoTasks", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/tasks/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); |
|
85 | 85 | } |
86 | 86 | |
87 | -if (! empty($conf->propal->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_PROPAL_DISABLED) && $user->rights->propal->lire) |
|
87 | +if (!empty($conf->propal->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_PROPAL_DISABLED) && $user->rights->propal->lire) |
|
88 | 88 | { |
89 | - $arrayresult['searchintopropal']=array('position'=>60, 'img'=>'object_propal', 'label'=>$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'text'=>img_picto('','object_propal').' '.$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/comm/propal/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
89 | + $arrayresult['searchintopropal'] = array('position'=>60, 'img'=>'object_propal', 'label'=>$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'text'=>img_picto('', 'object_propal').' '.$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/comm/propal/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); |
|
90 | 90 | } |
91 | -if (! empty($conf->commande->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_ORDER_DISABLED) && $user->rights->commande->lire) |
|
91 | +if (!empty($conf->commande->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_ORDER_DISABLED) && $user->rights->commande->lire) |
|
92 | 92 | { |
93 | - $arrayresult['searchintoorder']=array('position'=>70, 'img'=>'object_order', 'label'=>$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'text'=>img_picto('','object_order').' '.$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/commande/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
93 | + $arrayresult['searchintoorder'] = array('position'=>70, 'img'=>'object_order', 'label'=>$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'text'=>img_picto('', 'object_order').' '.$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/commande/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); |
|
94 | 94 | } |
95 | -if (! empty($conf->expedition->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_SHIPMENT_DISABLED) && $user->rights->expedition->lire) |
|
95 | +if (!empty($conf->expedition->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_SHIPMENT_DISABLED) && $user->rights->expedition->lire) |
|
96 | 96 | { |
97 | - $arrayresult['searchintoshipment']=array('position'=>80, 'img'=>'object_sending', 'label'=>$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'text'=>img_picto('','object_sending').' '.$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expedition/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
97 | + $arrayresult['searchintoshipment'] = array('position'=>80, 'img'=>'object_sending', 'label'=>$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'text'=>img_picto('', 'object_sending').' '.$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expedition/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); |
|
98 | 98 | } |
99 | -if (! empty($conf->facture->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_INVOICE_DISABLED) && $user->rights->facture->lire) |
|
99 | +if (!empty($conf->facture->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_INVOICE_DISABLED) && $user->rights->facture->lire) |
|
100 | 100 | { |
101 | - $arrayresult['searchintoinvoice']=array('position'=>90, 'img'=>'object_bill', 'label'=>$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'text'=>img_picto('','object_bill').' '.$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/compta/facture/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
101 | + $arrayresult['searchintoinvoice'] = array('position'=>90, 'img'=>'object_bill', 'label'=>$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'text'=>img_picto('', 'object_bill').' '.$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/compta/facture/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); |
|
102 | 102 | } |
103 | 103 | |
104 | -if (! empty($conf->supplier_proposal->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_PROPAL_DISABLED) && $user->rights->supplier_proposal->lire) |
|
104 | +if (!empty($conf->supplier_proposal->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_PROPAL_DISABLED) && $user->rights->supplier_proposal->lire) |
|
105 | 105 | { |
106 | - $arrayresult['searchintosupplierpropal']=array('position'=>100, 'img'=>'object_propal', 'label'=>$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'text'=>img_picto('','object_propal').' '.$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/supplier_proposal/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
106 | + $arrayresult['searchintosupplierpropal'] = array('position'=>100, 'img'=>'object_propal', 'label'=>$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'text'=>img_picto('', 'object_propal').' '.$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/supplier_proposal/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); |
|
107 | 107 | } |
108 | -if (! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_ORDER_DISABLED) && $user->rights->fournisseur->commande->lire) |
|
108 | +if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_ORDER_DISABLED) && $user->rights->fournisseur->commande->lire) |
|
109 | 109 | { |
110 | - $arrayresult['searchintosupplierorder']=array('position'=>110, 'img'=>'object_order', 'label'=>$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'text'=>img_picto('','object_order').' '.$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/commande/list.php'.($search_boxvalue?'?search_all='.urlencode($search_boxvalue):'')); |
|
110 | + $arrayresult['searchintosupplierorder'] = array('position'=>110, 'img'=>'object_order', 'label'=>$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'text'=>img_picto('', 'object_order').' '.$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/commande/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); |
|
111 | 111 | } |
112 | -if (! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED) && $user->rights->fournisseur->facture->lire) |
|
112 | +if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED) && $user->rights->fournisseur->facture->lire) |
|
113 | 113 | { |
114 | - $arrayresult['searchintosupplierinvoice']=array('position'=>120, 'img'=>'object_bill', 'label'=>$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'text'=>img_picto('','object_bill').' '.$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/facture/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
114 | + $arrayresult['searchintosupplierinvoice'] = array('position'=>120, 'img'=>'object_bill', 'label'=>$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'text'=>img_picto('', 'object_bill').' '.$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/facture/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); |
|
115 | 115 | } |
116 | 116 | |
117 | -if (! empty($conf->contrat->enabled) && empty($conf->global->MAIN_SEARCHFORM_CONTRACT_DISABLED) && $user->rights->contrat->lire) |
|
117 | +if (!empty($conf->contrat->enabled) && empty($conf->global->MAIN_SEARCHFORM_CONTRACT_DISABLED) && $user->rights->contrat->lire) |
|
118 | 118 | { |
119 | - $arrayresult['searchintocontract']=array('position'=>130, 'img'=>'object_contract', 'label'=>$langs->trans("SearchIntoContracts", $search_boxvalue), 'text'=>img_picto('','object_contract').' '.$langs->trans("SearchIntoContracts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contrat/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
119 | + $arrayresult['searchintocontract'] = array('position'=>130, 'img'=>'object_contract', 'label'=>$langs->trans("SearchIntoContracts", $search_boxvalue), 'text'=>img_picto('', 'object_contract').' '.$langs->trans("SearchIntoContracts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contrat/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); |
|
120 | 120 | } |
121 | -if (! empty($conf->ficheinter->enabled) && empty($conf->global->MAIN_SEARCHFORM_FICHINTER_DISABLED) && $user->rights->ficheinter->lire) |
|
121 | +if (!empty($conf->ficheinter->enabled) && empty($conf->global->MAIN_SEARCHFORM_FICHINTER_DISABLED) && $user->rights->ficheinter->lire) |
|
122 | 122 | { |
123 | - $arrayresult['searchintointervention']=array('position'=>140, 'img'=>'object_intervention', 'label'=>$langs->trans("SearchIntoInterventions", $search_boxvalue), 'text'=>img_picto('','object_intervention').' '.$langs->trans("SearchIntoInterventions", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fichinter/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
123 | + $arrayresult['searchintointervention'] = array('position'=>140, 'img'=>'object_intervention', 'label'=>$langs->trans("SearchIntoInterventions", $search_boxvalue), 'text'=>img_picto('', 'object_intervention').' '.$langs->trans("SearchIntoInterventions", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fichinter/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | // HR |
127 | -if (! empty($conf->user->enabled) && empty($conf->global->MAIN_SEARCHFORM_USER_DISABLED) && $user->rights->user->user->lire) |
|
127 | +if (!empty($conf->user->enabled) && empty($conf->global->MAIN_SEARCHFORM_USER_DISABLED) && $user->rights->user->user->lire) |
|
128 | 128 | { |
129 | - $arrayresult['searchintouser']=array('position'=>200, 'shortcut'=>'U', 'img'=>'object_user', 'label'=>$langs->trans("SearchIntoUsers", $search_boxvalue), 'text'=>img_picto('','object_user').' '.$langs->trans("SearchIntoUsers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/user/list.php'.($search_boxvalue?'?sall='.urlencode($search_boxvalue):'')); |
|
129 | + $arrayresult['searchintouser'] = array('position'=>200, 'shortcut'=>'U', 'img'=>'object_user', 'label'=>$langs->trans("SearchIntoUsers", $search_boxvalue), 'text'=>img_picto('', 'object_user').' '.$langs->trans("SearchIntoUsers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/user/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); |
|
130 | 130 | } |
131 | -if (! empty($conf->expensereport->enabled) && empty($conf->global->MAIN_SEARCHFORM_EXPENSEREPORT_DISABLED) && $user->rights->expensereport->lire) |
|
131 | +if (!empty($conf->expensereport->enabled) && empty($conf->global->MAIN_SEARCHFORM_EXPENSEREPORT_DISABLED) && $user->rights->expensereport->lire) |
|
132 | 132 | { |
133 | - $arrayresult['searchintoexpensereport']=array('position'=>210, 'img'=>'object_trip', 'label'=>$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'text'=>img_picto('','object_trip').' '.$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm'.($search_boxvalue?'&sall='.urlencode($search_boxvalue):'')); |
|
133 | + $arrayresult['searchintoexpensereport'] = array('position'=>210, 'img'=>'object_trip', 'label'=>$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'text'=>img_picto('', 'object_trip').' '.$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : '')); |
|
134 | 134 | } |
135 | -if (! empty($conf->holiday->enabled) && empty($conf->global->MAIN_SEARCHFORM_HOLIDAY_DISABLED) && $user->rights->holiday->read) |
|
135 | +if (!empty($conf->holiday->enabled) && empty($conf->global->MAIN_SEARCHFORM_HOLIDAY_DISABLED) && $user->rights->holiday->read) |
|
136 | 136 | { |
137 | - $arrayresult['searchintoleaves']=array('position'=>220, 'img'=>'object_holiday', 'label'=>$langs->trans("SearchIntoLeaves", $search_boxvalue), 'text'=>img_picto('','object_holiday').' '.$langs->trans("SearchIntoLeaves", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/holiday/list.php?mainmenu=hrm'.($search_boxvalue?'&sall='.urlencode($search_boxvalue):'')); |
|
137 | + $arrayresult['searchintoleaves'] = array('position'=>220, 'img'=>'object_holiday', 'label'=>$langs->trans("SearchIntoLeaves", $search_boxvalue), 'text'=>img_picto('', 'object_holiday').' '.$langs->trans("SearchIntoLeaves", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/holiday/list.php?mainmenu=hrm'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : '')); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | |
@@ -147,25 +147,25 @@ discard block |
||
147 | 147 | */ |
148 | 148 | |
149 | 149 | // Execute hook addSearchEntry |
150 | -$parameters=array('search_boxvalue'=>$search_boxvalue, 'arrayresult'=>$arrayresult); |
|
151 | -$reshook=$hookmanager->executeHooks('addSearchEntry',$parameters); |
|
150 | +$parameters = array('search_boxvalue'=>$search_boxvalue, 'arrayresult'=>$arrayresult); |
|
151 | +$reshook = $hookmanager->executeHooks('addSearchEntry', $parameters); |
|
152 | 152 | if (empty($reshook)) |
153 | 153 | { |
154 | - $arrayresult=array_merge($arrayresult, $hookmanager->resArray); |
|
154 | + $arrayresult = array_merge($arrayresult, $hookmanager->resArray); |
|
155 | 155 | } |
156 | -else $arrayresult=$hookmanager->resArray; |
|
156 | +else $arrayresult = $hookmanager->resArray; |
|
157 | 157 | |
158 | 158 | // This allow to keep a search entry to the top |
159 | -if(! empty($conf->global->DEFAULT_SEARCH_INTO_MODULE)) { |
|
159 | +if (!empty($conf->global->DEFAULT_SEARCH_INTO_MODULE)) { |
|
160 | 160 | $key = 'searchinto'.$conf->global->DEFAULT_SEARCH_INTO_MODULE; |
161 | - if(array_key_exists($key, $arrayresult)) $arrayresult[$key]['position'] = -10; |
|
161 | + if (array_key_exists($key, $arrayresult)) $arrayresult[$key]['position'] = -10; |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | // Sort on position |
165 | 165 | $arrayresult = dol_sort_array($arrayresult, 'position'); |
166 | 166 | |
167 | 167 | // Print output if called by ajax or do nothing (var $arrayresult will be used) if called by an include |
168 | -if (! isset($usedbyinclude) || empty($usedbyinclude)) |
|
168 | +if (!isset($usedbyinclude) || empty($usedbyinclude)) |
|
169 | 169 | { |
170 | 170 | print json_encode($arrayresult); |
171 | 171 | if (is_object($db)) $db->close(); |
@@ -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 |
@@ -51,14 +51,14 @@ |
||
51 | 51 | header('Access-Control-Allow-Headers: X-File-Name, X-File-Type, X-File-Size'); |
52 | 52 | |
53 | 53 | switch ($_SERVER['REQUEST_METHOD']) { |
54 | - case 'OPTIONS': |
|
55 | - break; |
|
54 | + case 'OPTIONS': |
|
55 | + break; |
|
56 | 56 | case 'HEAD': |
57 | 57 | case 'GET': |
58 | 58 | $upload_handler->get(); |
59 | 59 | break; |
60 | 60 | case 'POST': |
61 | - if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE') { |
|
61 | + if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE') { |
|
62 | 62 | $upload_handler->delete(); |
63 | 63 | } else { |
64 | 64 | $upload_handler->post(); |
@@ -21,10 +21,20 @@ |
||
21 | 21 | * \brief File to return Ajax response on file upload |
22 | 22 | */ |
23 | 23 | |
24 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); |
|
25 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); |
|
26 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show |
|
27 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php |
|
24 | +if (! defined('NOCSRFCHECK')) { |
|
25 | + define('NOCSRFCHECK','1'); |
|
26 | +} |
|
27 | +if (! defined('NOTOKENRENEWAL')) { |
|
28 | + define('NOTOKENRENEWAL','1'); |
|
29 | +} |
|
30 | +if (! defined('NOREQUIREMENU')) { |
|
31 | + define('NOREQUIREMENU','1'); |
|
32 | +} |
|
33 | +// If there is no menu to show |
|
34 | +if (! defined('NOREQUIREHTML')) { |
|
35 | + define('NOREQUIREHTML','1'); |
|
36 | +} |
|
37 | +// If we don't need to load the html.form.class.php |
|
28 | 38 | |
29 | 39 | |
30 | 40 |
@@ -21,16 +21,16 @@ discard block |
||
21 | 21 | * \brief File to return Ajax response on file upload |
22 | 22 | */ |
23 | 23 | |
24 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); |
|
25 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); |
|
26 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show |
|
27 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php |
|
24 | +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); |
|
25 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); |
|
26 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no menu to show |
|
27 | +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php |
|
28 | 28 | |
29 | 29 | |
30 | 30 | |
31 | 31 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
32 | 32 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
33 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
33 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
34 | 34 | require_once DOL_DOCUMENT_ROOT.'/core/class/fileupload.class.php'; |
35 | 35 | |
36 | 36 | error_reporting(E_ALL | E_STRICT); |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | //print_r($_GET); |
40 | 40 | //print 'upload_dir='.GETPOST('upload_dir'); |
41 | 41 | |
42 | -$fk_element = GETPOST('fk_element','int'); |
|
43 | -$element = GETPOST('element','alpha'); |
|
42 | +$fk_element = GETPOST('fk_element', 'int'); |
|
43 | +$element = GETPOST('element', 'alpha'); |
|
44 | 44 | |
45 | 45 | |
46 | -$upload_handler = new FileUpload(null,$fk_element,$element); |
|
46 | +$upload_handler = new FileUpload(null, $fk_element, $element); |
|
47 | 47 | |
48 | 48 | header('Pragma: no-cache'); |
49 | 49 | header('Cache-Control: no-store, no-cache, must-revalidate'); |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | |
50 | 50 | if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'dvnext') |
51 | 51 | { |
52 | - // Increase date |
|
53 | - $al = new AccountLine($db); |
|
52 | + // Increase date |
|
53 | + $al = new AccountLine($db); |
|
54 | 54 | $al->datev_next(GETPOST('rowid','int')); |
55 | 55 | $al->fetch(GETPOST('rowid','int')); |
56 | 56 | |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | |
62 | 62 | if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'dvprev') |
63 | 63 | { |
64 | - // Decrease date |
|
65 | - $al =new AccountLine($db); |
|
64 | + // Decrease date |
|
65 | + $al =new AccountLine($db); |
|
66 | 66 | $al->datev_previous(GETPOST('rowid','int')); |
67 | 67 | $al->fetch(GETPOST('rowid','int')); |
68 | 68 | |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | |
74 | 74 | if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'donext') |
75 | 75 | { |
76 | - // Increase date |
|
77 | - $al = new AccountLine($db); |
|
76 | + // Increase date |
|
77 | + $al = new AccountLine($db); |
|
78 | 78 | $al->dateo_next(GETPOST('rowid','int')); |
79 | 79 | $al->fetch(GETPOST('rowid','int')); |
80 | 80 | |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | |
86 | 86 | if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'doprev') |
87 | 87 | { |
88 | - // Decrease date |
|
89 | - $al =new AccountLine($db); |
|
88 | + // Decrease date |
|
89 | + $al =new AccountLine($db); |
|
90 | 90 | $al->dateo_previous(GETPOST('rowid','int')); |
91 | 91 | $al->fetch(GETPOST('rowid','int')); |
92 | 92 |
@@ -20,11 +20,22 @@ |
||
20 | 20 | * \brief File to set data for bank concilation |
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 | //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Required to know date format for dol_print_date |
29 | 40 | |
30 | 41 |
@@ -20,21 +20,21 @@ discard block |
||
20 | 20 | * \brief File to set data for bank concilation |
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')) 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 | 28 | //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Required to know date format for dol_print_date |
29 | 29 | |
30 | 30 | |
31 | 31 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
32 | 32 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
33 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
33 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
34 | 34 | require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; |
35 | 35 | require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; |
36 | 36 | |
37 | -$action=GETPOST('action','aZ09'); |
|
37 | +$action = GETPOST('action', 'aZ09'); |
|
38 | 38 | |
39 | 39 | |
40 | 40 | /* |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | { |
55 | 55 | // Increase date |
56 | 56 | $al = new AccountLine($db); |
57 | - $al->datev_next(GETPOST('rowid','int')); |
|
58 | - $al->fetch(GETPOST('rowid','int')); |
|
57 | + $al->datev_next(GETPOST('rowid', 'int')); |
|
58 | + $al->fetch(GETPOST('rowid', 'int')); |
|
59 | 59 | |
60 | - print '<span>'.dol_print_date($db->jdate($al->datev),"day").'</span>'; |
|
60 | + print '<span>'.dol_print_date($db->jdate($al->datev), "day").'</span>'; |
|
61 | 61 | |
62 | 62 | exit; |
63 | 63 | } |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'dvprev') |
66 | 66 | { |
67 | 67 | // Decrease date |
68 | - $al =new AccountLine($db); |
|
69 | - $al->datev_previous(GETPOST('rowid','int')); |
|
70 | - $al->fetch(GETPOST('rowid','int')); |
|
68 | + $al = new AccountLine($db); |
|
69 | + $al->datev_previous(GETPOST('rowid', 'int')); |
|
70 | + $al->fetch(GETPOST('rowid', 'int')); |
|
71 | 71 | |
72 | - print '<span>'.dol_print_date($db->jdate($al->datev),"day").'</span>'; |
|
72 | + print '<span>'.dol_print_date($db->jdate($al->datev), "day").'</span>'; |
|
73 | 73 | |
74 | 74 | exit; |
75 | 75 | } |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | { |
79 | 79 | // Increase date |
80 | 80 | $al = new AccountLine($db); |
81 | - $al->dateo_next(GETPOST('rowid','int')); |
|
82 | - $al->fetch(GETPOST('rowid','int')); |
|
81 | + $al->dateo_next(GETPOST('rowid', 'int')); |
|
82 | + $al->fetch(GETPOST('rowid', 'int')); |
|
83 | 83 | |
84 | - print '<span>'.dol_print_date($db->jdate($al->dateo),"day").'</span>'; |
|
84 | + print '<span>'.dol_print_date($db->jdate($al->dateo), "day").'</span>'; |
|
85 | 85 | |
86 | 86 | exit; |
87 | 87 | } |
@@ -89,11 +89,11 @@ discard block |
||
89 | 89 | if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'doprev') |
90 | 90 | { |
91 | 91 | // Decrease date |
92 | - $al =new AccountLine($db); |
|
93 | - $al->dateo_previous(GETPOST('rowid','int')); |
|
94 | - $al->fetch(GETPOST('rowid','int')); |
|
92 | + $al = new AccountLine($db); |
|
93 | + $al->dateo_previous(GETPOST('rowid', 'int')); |
|
94 | + $al->fetch(GETPOST('rowid', 'int')); |
|
95 | 95 | |
96 | - print '<span>'.dol_print_date($db->jdate($al->dateo),"day").'</span>'; |
|
96 | + print '<span>'.dol_print_date($db->jdate($al->dateo), "day").'</span>'; |
|
97 | 97 | |
98 | 98 | exit; |
99 | 99 | } |