@@ -27,32 +27,32 @@ discard block |
||
27 | 27 | //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language |
28 | 28 | //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
29 | 29 | //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations |
30 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK',1); |
|
31 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); |
|
30 | +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); |
|
31 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); |
|
32 | 32 | //if (! defined('NOLOGIN')) define('NOLOGIN',1); // Not disabled cause need to load personalized language |
33 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); |
|
33 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); |
|
34 | 34 | //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1); |
35 | 35 | |
36 | 36 | require_once '../main.inc.php'; |
37 | 37 | |
38 | -if (GETPOST('lang', 'aZ09')) $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php |
|
38 | +if (GETPOST('lang', 'aZ09')) $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php |
|
39 | 39 | |
40 | 40 | $langs->load("main"); |
41 | 41 | |
42 | -$right=($langs->trans("DIRECTION")=='rtl'?'left':'right'); |
|
43 | -$left=($langs->trans("DIRECTION")=='rtl'?'right':'left'); |
|
42 | +$right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right'); |
|
43 | +$left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left'); |
|
44 | 44 | |
45 | 45 | |
46 | 46 | /* |
47 | 47 | * View |
48 | 48 | */ |
49 | 49 | |
50 | -$title=$langs->trans("Search"); |
|
50 | +$title = $langs->trans("Search"); |
|
51 | 51 | |
52 | 52 | // URL http://mydolibarr/core/search_page?dol_use_jmobile=1 can be used for tests |
53 | -$head='<!-- Quick access -->'."\n"; |
|
54 | -$arrayofjs=array(); |
|
55 | -$arrayofcss=array(); |
|
53 | +$head = '<!-- Quick access -->'."\n"; |
|
54 | +$arrayofjs = array(); |
|
55 | +$arrayofcss = array(); |
|
56 | 56 | top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss); |
57 | 57 | |
58 | 58 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | print '<div>'; |
62 | 62 | //print '<br>'; |
63 | 63 | |
64 | -$nbofsearch=0; |
|
64 | +$nbofsearch = 0; |
|
65 | 65 | |
66 | 66 | // Instantiate hooks of thirdparty module |
67 | 67 | $hookmanager->initHooks(array('searchform')); |
@@ -71,41 +71,41 @@ discard block |
||
71 | 71 | |
72 | 72 | if ($conf->use_javascript_ajax && 1 == 2) // select2 is ko with jmobile |
73 | 73 | { |
74 | - if (! is_object($form)) $form=new Form($db); |
|
75 | - $selected=-1; |
|
76 | - $searchform.='<br><br>'.$form->selectArrayAjax('searchselectcombo', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, '', '', 0, 1, 'minwidth300', 1, $langs->trans("Search"), 0); |
|
74 | + if (!is_object($form)) $form = new Form($db); |
|
75 | + $selected = -1; |
|
76 | + $searchform .= '<br><br>'.$form->selectArrayAjax('searchselectcombo', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, '', '', 0, 1, 'minwidth300', 1, $langs->trans("Search"), 0); |
|
77 | 77 | } |
78 | 78 | else |
79 | 79 | { |
80 | 80 | $usedbyinclude = 1; // Used into next include |
81 | - $showtitlebefore = GETPOST('showtitlebefore','int'); |
|
81 | + $showtitlebefore = GETPOST('showtitlebefore', 'int'); |
|
82 | 82 | include DOL_DOCUMENT_ROOT.'/core/ajax/selectsearchbox.php'; |
83 | 83 | |
84 | - $accesskeyalreadyassigned=array(); |
|
85 | - foreach($arrayresult as $key => $val) |
|
84 | + $accesskeyalreadyassigned = array(); |
|
85 | + foreach ($arrayresult as $key => $val) |
|
86 | 86 | { |
87 | - $tmp=explode('?', $val['url']); |
|
88 | - $urlaction=$tmp[0]; |
|
89 | - $keysearch='search_all'; |
|
87 | + $tmp = explode('?', $val['url']); |
|
88 | + $urlaction = $tmp[0]; |
|
89 | + $keysearch = 'search_all'; |
|
90 | 90 | |
91 | - $accesskey=''; |
|
92 | - if (! $accesskeyalreadyassigned[$val['label'][0]]) |
|
91 | + $accesskey = ''; |
|
92 | + if (!$accesskeyalreadyassigned[$val['label'][0]]) |
|
93 | 93 | { |
94 | - $accesskey=$val['label'][0]; |
|
95 | - $accesskeyalreadyassigned[$accesskey]=$accesskey; |
|
94 | + $accesskey = $val['label'][0]; |
|
95 | + $accesskeyalreadyassigned[$accesskey] = $accesskey; |
|
96 | 96 | } |
97 | - $searchform.=printSearchForm($urlaction, $urlaction, $val['label'], 'minwidth200', $keysearch, $accesskey, $key, img_picto('',$val['img'],'', 0, 1), $showtitlebefore); |
|
97 | + $searchform .= printSearchForm($urlaction, $urlaction, $val['label'], 'minwidth200', $keysearch, $accesskey, $key, img_picto('', $val['img'], '', 0, 1), $showtitlebefore); |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | 101 | // Execute hook printSearchForm |
102 | -$parameters=array('searchform'=>$searchform); |
|
103 | -$reshook=$hookmanager->executeHooks('printSearchForm',$parameters); // Note that $action and $object may have been modified by some hooks |
|
102 | +$parameters = array('searchform'=>$searchform); |
|
103 | +$reshook = $hookmanager->executeHooks('printSearchForm', $parameters); // Note that $action and $object may have been modified by some hooks |
|
104 | 104 | if (empty($reshook)) |
105 | 105 | { |
106 | - $searchform.=$hookmanager->resPrint; |
|
106 | + $searchform .= $hookmanager->resPrint; |
|
107 | 107 | } |
108 | -else $searchform=$hookmanager->resPrint; |
|
108 | +else $searchform = $hookmanager->resPrint; |
|
109 | 109 | |
110 | 110 | |
111 | 111 | print "\n"; |
@@ -23,18 +23,18 @@ discard block |
||
23 | 23 | * \brief Code for actions on extrafields admin pages |
24 | 24 | */ |
25 | 25 | |
26 | -$maxsizestring=255; |
|
27 | -$maxsizeint=10; |
|
28 | -$mesg=array(); |
|
26 | +$maxsizestring = 255; |
|
27 | +$maxsizeint = 10; |
|
28 | +$mesg = array(); |
|
29 | 29 | |
30 | -$extrasize=GETPOST('size','int'); |
|
31 | -$type=GETPOST('type','alpha'); |
|
32 | -$param=GETPOST('param','alpha'); |
|
30 | +$extrasize = GETPOST('size', 'int'); |
|
31 | +$type = GETPOST('type', 'alpha'); |
|
32 | +$param = GETPOST('param', 'alpha'); |
|
33 | 33 | |
34 | -if ($type=='double' && strpos($extrasize,',')===false) $extrasize='24,8'; |
|
35 | -if ($type=='date') $extrasize=''; |
|
36 | -if ($type=='datetime') $extrasize=''; |
|
37 | -if ($type=='select') $extrasize=''; |
|
34 | +if ($type == 'double' && strpos($extrasize, ',') === false) $extrasize = '24,8'; |
|
35 | +if ($type == 'date') $extrasize = ''; |
|
36 | +if ($type == 'datetime') $extrasize = ''; |
|
37 | +if ($type == 'select') $extrasize = ''; |
|
38 | 38 | |
39 | 39 | |
40 | 40 | // Add attribute |
@@ -43,83 +43,83 @@ discard block |
||
43 | 43 | if ($_POST["button"] != $langs->trans("Cancel")) |
44 | 44 | { |
45 | 45 | // Check values |
46 | - if (! $type) |
|
46 | + if (!$type) |
|
47 | 47 | { |
48 | 48 | $error++; |
49 | 49 | $langs->load("errors"); |
50 | - $mesg[]=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")); |
|
50 | + $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); |
|
51 | 51 | $action = 'create'; |
52 | 52 | } |
53 | - if ($type=='varchar' && $extrasize <= 0) |
|
53 | + if ($type == 'varchar' && $extrasize <= 0) |
|
54 | 54 | { |
55 | 55 | $error++; |
56 | 56 | $langs->load("errors"); |
57 | - $mesg[]=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Size")); |
|
57 | + $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); |
|
58 | 58 | $action = 'edit'; |
59 | 59 | } |
60 | - if ($type=='varchar' && $extrasize > $maxsizestring) |
|
60 | + if ($type == 'varchar' && $extrasize > $maxsizestring) |
|
61 | 61 | { |
62 | 62 | $error++; |
63 | 63 | $langs->load("errors"); |
64 | - $mesg[]=$langs->trans("ErrorSizeTooLongForVarcharType",$maxsizestring); |
|
64 | + $mesg[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); |
|
65 | 65 | $action = 'create'; |
66 | 66 | } |
67 | - if ($type=='int' && $extrasize > $maxsizeint) |
|
67 | + if ($type == 'int' && $extrasize > $maxsizeint) |
|
68 | 68 | { |
69 | 69 | $error++; |
70 | 70 | $langs->load("errors"); |
71 | - $mesg[]=$langs->trans("ErrorSizeTooLongForIntType",$maxsizeint); |
|
71 | + $mesg[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); |
|
72 | 72 | $action = 'create'; |
73 | 73 | } |
74 | - if ($type=='select' && !$param) |
|
74 | + if ($type == 'select' && !$param) |
|
75 | 75 | { |
76 | 76 | $error++; |
77 | 77 | $langs->load("errors"); |
78 | - $mesg[]=$langs->trans("ErrorNoValueForSelectType"); |
|
78 | + $mesg[] = $langs->trans("ErrorNoValueForSelectType"); |
|
79 | 79 | $action = 'create'; |
80 | 80 | } |
81 | - if ($type=='sellist' && !$param) |
|
81 | + if ($type == 'sellist' && !$param) |
|
82 | 82 | { |
83 | 83 | $error++; |
84 | 84 | $langs->load("errors"); |
85 | - $mesg[]=$langs->trans("ErrorNoValueForSelectListType"); |
|
85 | + $mesg[] = $langs->trans("ErrorNoValueForSelectListType"); |
|
86 | 86 | $action = 'create'; |
87 | 87 | } |
88 | - if ($type=='checkbox' && !$param) |
|
88 | + if ($type == 'checkbox' && !$param) |
|
89 | 89 | { |
90 | 90 | $error++; |
91 | 91 | $langs->load("errors"); |
92 | - $mesg[]=$langs->trans("ErrorNoValueForCheckBoxType"); |
|
92 | + $mesg[] = $langs->trans("ErrorNoValueForCheckBoxType"); |
|
93 | 93 | $action = 'create'; |
94 | 94 | } |
95 | - if ($type=='link' && !$param) |
|
95 | + if ($type == 'link' && !$param) |
|
96 | 96 | { |
97 | 97 | $error++; |
98 | 98 | $langs->load("errors"); |
99 | - $mesg[]=$langs->trans("ErrorNoValueForLinkType"); |
|
99 | + $mesg[] = $langs->trans("ErrorNoValueForLinkType"); |
|
100 | 100 | $action = 'create'; |
101 | 101 | } |
102 | - if ($type=='radio' && !$param) |
|
102 | + if ($type == 'radio' && !$param) |
|
103 | 103 | { |
104 | 104 | $error++; |
105 | 105 | $langs->load("errors"); |
106 | - $mesg[]=$langs->trans("ErrorNoValueForRadioType"); |
|
106 | + $mesg[] = $langs->trans("ErrorNoValueForRadioType"); |
|
107 | 107 | $action = 'create'; |
108 | 108 | } |
109 | - if ((($type=='radio') || ($type=='checkbox')) && $param) |
|
109 | + if ((($type == 'radio') || ($type == 'checkbox')) && $param) |
|
110 | 110 | { |
111 | 111 | // Construct array for parameter (value of select list) |
112 | 112 | $parameters = $param; |
113 | - $parameters_array = explode("\r\n",$parameters); |
|
114 | - foreach($parameters_array as $param_ligne) |
|
113 | + $parameters_array = explode("\r\n", $parameters); |
|
114 | + foreach ($parameters_array as $param_ligne) |
|
115 | 115 | { |
116 | 116 | if (!empty($param_ligne)) { |
117 | - if (preg_match_all('/,/',$param_ligne,$matches)) |
|
117 | + if (preg_match_all('/,/', $param_ligne, $matches)) |
|
118 | 118 | { |
119 | - if (count($matches[0])>1) { |
|
119 | + if (count($matches[0]) > 1) { |
|
120 | 120 | $error++; |
121 | 121 | $langs->load("errors"); |
122 | - $mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne); |
|
122 | + $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); |
|
123 | 123 | $action = 'create'; |
124 | 124 | } |
125 | 125 | } |
@@ -127,25 +127,25 @@ discard block |
||
127 | 127 | { |
128 | 128 | $error++; |
129 | 129 | $langs->load("errors"); |
130 | - $mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne); |
|
130 | + $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); |
|
131 | 131 | $action = 'create'; |
132 | 132 | } |
133 | 133 | } |
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | - if (! $error) |
|
137 | + if (!$error) |
|
138 | 138 | { |
139 | 139 | // attrname must be alphabetical and lower case only |
140 | - if (isset($_POST["attrname"]) && preg_match("/^[a-z0-9-_]+$/",$_POST['attrname']) && !is_numeric($_POST["attrname"])) |
|
140 | + if (isset($_POST["attrname"]) && preg_match("/^[a-z0-9-_]+$/", $_POST['attrname']) && !is_numeric($_POST["attrname"])) |
|
141 | 141 | { |
142 | 142 | // Construct array for parameter (value of select list) |
143 | - $default_value = GETPOST('default_value','alpha'); |
|
143 | + $default_value = GETPOST('default_value', 'alpha'); |
|
144 | 144 | $parameters = $param; |
145 | - $parameters_array = explode("\r\n",$parameters); |
|
145 | + $parameters_array = explode("\r\n", $parameters); |
|
146 | 146 | //In sellist we have only one line and it can have come to do SQL expression |
147 | - if ($type=='sellist') { |
|
148 | - foreach($parameters_array as $param_ligne) |
|
147 | + if ($type == 'sellist') { |
|
148 | + foreach ($parameters_array as $param_ligne) |
|
149 | 149 | { |
150 | 150 | $params['options'] = array($parameters=>null); |
151 | 151 | } |
@@ -153,37 +153,37 @@ discard block |
||
153 | 153 | else |
154 | 154 | { |
155 | 155 | //Esle it's separated key/value and coma list |
156 | - foreach($parameters_array as $param_ligne) |
|
156 | + foreach ($parameters_array as $param_ligne) |
|
157 | 157 | { |
158 | - list($key,$value) = explode(',',$param_ligne); |
|
158 | + list($key, $value) = explode(',', $param_ligne); |
|
159 | 159 | $params['options'][$key] = $value; |
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
163 | 163 | // Visibility: -1=not visible by default in list, 1=visible, 0=hidden |
164 | 164 | $visibility = GETPOST('list', 'alpha'); |
165 | - if ($type == 'separate') $visibility=3; |
|
165 | + if ($type == 'separate') $visibility = 3; |
|
166 | 166 | |
167 | - $result=$extrafields->addExtraField( |
|
167 | + $result = $extrafields->addExtraField( |
|
168 | 168 | GETPOST('attrname', 'alpha'), |
169 | 169 | GETPOST('label', 'alpha'), |
170 | 170 | $type, |
171 | 171 | GETPOST('pos', 'int'), |
172 | 172 | $extrasize, |
173 | 173 | $elementtype, |
174 | - (GETPOST('unique', 'alpha')?1:0), |
|
175 | - (GETPOST('required', 'alpha')?1:0), |
|
174 | + (GETPOST('unique', 'alpha') ? 1 : 0), |
|
175 | + (GETPOST('required', 'alpha') ? 1 : 0), |
|
176 | 176 | $default_value, |
177 | 177 | $params, |
178 | - (GETPOST('alwayseditable', 'alpha')?1:0), |
|
179 | - (GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''), |
|
178 | + (GETPOST('alwayseditable', 'alpha') ? 1 : 0), |
|
179 | + (GETPOST('perms', 'alpha') ?GETPOST('perms', 'alpha') : ''), |
|
180 | 180 | $visibility, |
181 | - GETPOST('help','alpha'), |
|
182 | - GETPOST('computed_value','alpha'), |
|
183 | - (GETPOST('entitycurrentorall', 'alpha')?0:''), |
|
181 | + GETPOST('help', 'alpha'), |
|
182 | + GETPOST('computed_value', 'alpha'), |
|
183 | + (GETPOST('entitycurrentorall', 'alpha') ? 0 : ''), |
|
184 | 184 | GETPOST('langfile', 'alpha'), |
185 | 185 | 1, |
186 | - (GETPOST('totalizable', 'alpha')?1:0) |
|
186 | + (GETPOST('totalizable', 'alpha') ? 1 : 0) |
|
187 | 187 | ); |
188 | 188 | if ($result > 0) |
189 | 189 | { |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | else |
195 | 195 | { |
196 | 196 | $error++; |
197 | - $mesg=$extrafields->error; |
|
197 | + $mesg = $extrafields->error; |
|
198 | 198 | setEventMessages($mesg, null, 'errors'); |
199 | 199 | } |
200 | 200 | } |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | { |
203 | 203 | $error++; |
204 | 204 | $langs->load("errors"); |
205 | - $mesg=$langs->trans("ErrorFieldCanNotContainSpecialNorUpperCharacters",$langs->transnoentities("AttributeCode")); |
|
205 | + $mesg = $langs->trans("ErrorFieldCanNotContainSpecialNorUpperCharacters", $langs->transnoentities("AttributeCode")); |
|
206 | 206 | setEventMessages($mesg, null, 'errors'); |
207 | 207 | $action = 'create'; |
208 | 208 | } |
@@ -220,76 +220,76 @@ discard block |
||
220 | 220 | if ($_POST["button"] != $langs->trans("Cancel")) |
221 | 221 | { |
222 | 222 | // Check values |
223 | - if (! $type) |
|
223 | + if (!$type) |
|
224 | 224 | { |
225 | 225 | $error++; |
226 | 226 | $langs->load("errors"); |
227 | - $mesg[]=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")); |
|
227 | + $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); |
|
228 | 228 | $action = 'edit'; |
229 | 229 | } |
230 | - if ($type=='varchar' && $extrasize <= 0) |
|
230 | + if ($type == 'varchar' && $extrasize <= 0) |
|
231 | 231 | { |
232 | 232 | $error++; |
233 | 233 | $langs->load("errors"); |
234 | - $mesg[]=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Size")); |
|
234 | + $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); |
|
235 | 235 | $action = 'edit'; |
236 | 236 | } |
237 | - if ($type=='varchar' && $extrasize > $maxsizestring) |
|
237 | + if ($type == 'varchar' && $extrasize > $maxsizestring) |
|
238 | 238 | { |
239 | 239 | $error++; |
240 | 240 | $langs->load("errors"); |
241 | - $mesg[]=$langs->trans("ErrorSizeTooLongForVarcharType",$maxsizestring); |
|
241 | + $mesg[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); |
|
242 | 242 | $action = 'edit'; |
243 | 243 | } |
244 | - if ($type=='int' && $extrasize > $maxsizeint) |
|
244 | + if ($type == 'int' && $extrasize > $maxsizeint) |
|
245 | 245 | { |
246 | 246 | $error++; |
247 | 247 | $langs->load("errors"); |
248 | - $mesg[]=$langs->trans("ErrorSizeTooLongForIntType",$maxsizeint); |
|
248 | + $mesg[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); |
|
249 | 249 | $action = 'edit'; |
250 | 250 | } |
251 | - if ($type=='select' && !$param) |
|
251 | + if ($type == 'select' && !$param) |
|
252 | 252 | { |
253 | 253 | $error++; |
254 | 254 | $langs->load("errors"); |
255 | - $mesg[]=$langs->trans("ErrorNoValueForSelectType"); |
|
255 | + $mesg[] = $langs->trans("ErrorNoValueForSelectType"); |
|
256 | 256 | $action = 'edit'; |
257 | 257 | } |
258 | - if ($type=='sellist' && !$param) |
|
258 | + if ($type == 'sellist' && !$param) |
|
259 | 259 | { |
260 | 260 | $error++; |
261 | 261 | $langs->load("errors"); |
262 | - $mesg[]=$langs->trans("ErrorNoValueForSelectListType"); |
|
262 | + $mesg[] = $langs->trans("ErrorNoValueForSelectListType"); |
|
263 | 263 | $action = 'edit'; |
264 | 264 | } |
265 | - if ($type=='checkbox' && !$param) |
|
265 | + if ($type == 'checkbox' && !$param) |
|
266 | 266 | { |
267 | 267 | $error++; |
268 | 268 | $langs->load("errors"); |
269 | - $mesg[]=$langs->trans("ErrorNoValueForCheckBoxType"); |
|
269 | + $mesg[] = $langs->trans("ErrorNoValueForCheckBoxType"); |
|
270 | 270 | $action = 'edit'; |
271 | 271 | } |
272 | - if ($type=='radio' && !$param) |
|
272 | + if ($type == 'radio' && !$param) |
|
273 | 273 | { |
274 | 274 | $error++; |
275 | 275 | $langs->load("errors"); |
276 | - $mesg[]=$langs->trans("ErrorNoValueForRadioType"); |
|
276 | + $mesg[] = $langs->trans("ErrorNoValueForRadioType"); |
|
277 | 277 | $action = 'edit'; |
278 | 278 | } |
279 | - if ((($type=='radio') || ($type=='checkbox')) && $param) |
|
279 | + if ((($type == 'radio') || ($type == 'checkbox')) && $param) |
|
280 | 280 | { |
281 | 281 | // Construct array for parameter (value of select list) |
282 | 282 | $parameters = $param; |
283 | - $parameters_array = explode("\r\n",$parameters); |
|
284 | - foreach($parameters_array as $param_ligne) |
|
283 | + $parameters_array = explode("\r\n", $parameters); |
|
284 | + foreach ($parameters_array as $param_ligne) |
|
285 | 285 | { |
286 | 286 | if (!empty($param_ligne)) { |
287 | - if (preg_match_all('/,/',$param_ligne,$matches)) |
|
287 | + if (preg_match_all('/,/', $param_ligne, $matches)) |
|
288 | 288 | { |
289 | - if (count($matches[0])>1) { |
|
289 | + if (count($matches[0]) > 1) { |
|
290 | 290 | $error++; |
291 | 291 | $langs->load("errors"); |
292 | - $mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne); |
|
292 | + $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); |
|
293 | 293 | $action = 'edit'; |
294 | 294 | } |
295 | 295 | } |
@@ -297,24 +297,24 @@ discard block |
||
297 | 297 | { |
298 | 298 | $error++; |
299 | 299 | $langs->load("errors"); |
300 | - $mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne); |
|
300 | + $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); |
|
301 | 301 | $action = 'edit'; |
302 | 302 | } |
303 | 303 | } |
304 | 304 | } |
305 | 305 | } |
306 | 306 | |
307 | - if (! $error) |
|
307 | + if (!$error) |
|
308 | 308 | { |
309 | - if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$_POST['attrname'])) |
|
309 | + if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $_POST['attrname'])) |
|
310 | 310 | { |
311 | - $pos = GETPOST('pos','int'); |
|
311 | + $pos = GETPOST('pos', 'int'); |
|
312 | 312 | // Construct array for parameter (value of select list) |
313 | 313 | $parameters = $param; |
314 | - $parameters_array = explode("\r\n",$parameters); |
|
314 | + $parameters_array = explode("\r\n", $parameters); |
|
315 | 315 | //In sellist we have only one line and it can have come to do SQL expression |
316 | - if ($type=='sellist') { |
|
317 | - foreach($parameters_array as $param_ligne) |
|
316 | + if ($type == 'sellist') { |
|
317 | + foreach ($parameters_array as $param_ligne) |
|
318 | 318 | { |
319 | 319 | $params['options'] = array($parameters=>null); |
320 | 320 | } |
@@ -322,37 +322,37 @@ discard block |
||
322 | 322 | else |
323 | 323 | { |
324 | 324 | //Esle it's separated key/value and coma list |
325 | - foreach($parameters_array as $param_ligne) |
|
325 | + foreach ($parameters_array as $param_ligne) |
|
326 | 326 | { |
327 | - list($key,$value) = explode(',',$param_ligne); |
|
327 | + list($key, $value) = explode(',', $param_ligne); |
|
328 | 328 | $params['options'][$key] = $value; |
329 | 329 | } |
330 | 330 | } |
331 | 331 | |
332 | 332 | // Visibility: -1=not visible by default in list, 1=visible, 0=hidden |
333 | 333 | $visibility = GETPOST('list', 'alpha'); |
334 | - if ($type == 'separate') $visibility=3; |
|
334 | + if ($type == 'separate') $visibility = 3; |
|
335 | 335 | |
336 | - $result=$extrafields->update( |
|
336 | + $result = $extrafields->update( |
|
337 | 337 | GETPOST('attrname', 'alpha'), |
338 | 338 | GETPOST('label', 'alpha'), |
339 | 339 | $type, |
340 | 340 | $extrasize, |
341 | 341 | $elementtype, |
342 | - (GETPOST('unique', 'alpha')?1:0), |
|
343 | - (GETPOST('required', 'alpha')?1:0), |
|
342 | + (GETPOST('unique', 'alpha') ? 1 : 0), |
|
343 | + (GETPOST('required', 'alpha') ? 1 : 0), |
|
344 | 344 | $pos, |
345 | 345 | $params, |
346 | - (GETPOST('alwayseditable', 'alpha')?1:0), |
|
347 | - (GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''), |
|
346 | + (GETPOST('alwayseditable', 'alpha') ? 1 : 0), |
|
347 | + (GETPOST('perms', 'alpha') ?GETPOST('perms', 'alpha') : ''), |
|
348 | 348 | $visibility, |
349 | - GETPOST('help','alpha'), |
|
350 | - GETPOST('default_value','alpha'), |
|
351 | - GETPOST('computed_value','alpha'), |
|
352 | - (GETPOST('entitycurrentorall', 'alpha')?0:''), |
|
349 | + GETPOST('help', 'alpha'), |
|
350 | + GETPOST('default_value', 'alpha'), |
|
351 | + GETPOST('computed_value', 'alpha'), |
|
352 | + (GETPOST('entitycurrentorall', 'alpha') ? 0 : ''), |
|
353 | 353 | GETPOST('langfile'), |
354 | 354 | 1, |
355 | - (GETPOST('totalizable', 'alpha')?1:0) |
|
355 | + (GETPOST('totalizable', 'alpha') ? 1 : 0) |
|
356 | 356 | ); |
357 | 357 | if ($result > 0) |
358 | 358 | { |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | else |
364 | 364 | { |
365 | 365 | $error++; |
366 | - $mesg=$extrafields->error; |
|
366 | + $mesg = $extrafields->error; |
|
367 | 367 | setEventMessages($mesg, null, 'errors'); |
368 | 368 | } |
369 | 369 | } |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | { |
372 | 372 | $error++; |
373 | 373 | $langs->load("errors"); |
374 | - $mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode")); |
|
374 | + $mesg = $langs->trans("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("AttributeCode")); |
|
375 | 375 | setEventMessages($mesg, null, 'errors'); |
376 | 376 | } |
377 | 377 | } |
@@ -385,21 +385,21 @@ discard block |
||
385 | 385 | // Delete attribute |
386 | 386 | if ($action == 'delete') |
387 | 387 | { |
388 | - if(isset($_GET["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$_GET["attrname"])) |
|
388 | + if (isset($_GET["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $_GET["attrname"])) |
|
389 | 389 | { |
390 | - $result=$extrafields->delete($_GET["attrname"],$elementtype); |
|
390 | + $result = $extrafields->delete($_GET["attrname"], $elementtype); |
|
391 | 391 | if ($result >= 0) |
392 | 392 | { |
393 | 393 | header("Location: ".$_SERVER["PHP_SELF"]); |
394 | 394 | exit; |
395 | 395 | } |
396 | - else $mesg=$extrafields->error; |
|
396 | + else $mesg = $extrafields->error; |
|
397 | 397 | } |
398 | 398 | else |
399 | 399 | { |
400 | 400 | $error++; |
401 | 401 | $langs->load("errors"); |
402 | - $mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode")); |
|
402 | + $mesg = $langs->trans("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("AttributeCode")); |
|
403 | 403 | } |
404 | 404 | } |
405 | 405 |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | * @param int $entitytotest Number of instance (always 1 if module multicompany not enabled) |
35 | 35 | * @return string Login if OK, '' if KO |
36 | 36 | */ |
37 | -function check_user_password_openid($usertotest,$passwordtotest,$entitytotest) |
|
37 | +function check_user_password_openid($usertotest, $passwordtotest, $entitytotest) |
|
38 | 38 | { |
39 | - global $_POST,$db,$conf,$langs; |
|
39 | + global $_POST, $db, $conf, $langs; |
|
40 | 40 | |
41 | 41 | dol_syslog("functions_openid::check_user_password_openid usertotest=".$usertotest); |
42 | 42 | |
43 | - $login=''; |
|
43 | + $login = ''; |
|
44 | 44 | |
45 | 45 | // Get identity from user and redirect browser to OpenID Server |
46 | 46 | if (isset($_POST['username'])) |
@@ -48,14 +48,14 @@ discard block |
||
48 | 48 | $openid = new SimpleOpenID(); |
49 | 49 | $openid->SetIdentity($_POST['username']); |
50 | 50 | $protocol = ($conf->file->main_force_https ? 'https://' : 'http://'); |
51 | - $openid->SetTrustRoot($protocol . $_SERVER["HTTP_HOST"]); |
|
52 | - $openid->SetRequiredFields(array('email','fullname')); |
|
51 | + $openid->SetTrustRoot($protocol.$_SERVER["HTTP_HOST"]); |
|
52 | + $openid->SetRequiredFields(array('email', 'fullname')); |
|
53 | 53 | $_SESSION['dol_entity'] = $_POST["entity"]; |
54 | 54 | //$openid->SetOptionalFields(array('dob','gender','postcode','country','language','timezone')); |
55 | 55 | if ($openid->sendDiscoveryRequestToGetXRDS()) |
56 | 56 | { |
57 | - $openid->SetApprovedURL($protocol . $_SERVER["HTTP_HOST"] . $_SERVER["SCRIPT_NAME"]); // Send Response from OpenID server to this script |
|
58 | - $openid->Redirect(); // This will redirect user to OpenID Server |
|
57 | + $openid->SetApprovedURL($protocol.$_SERVER["HTTP_HOST"].$_SERVER["SCRIPT_NAME"]); // Send Response from OpenID server to this script |
|
58 | + $openid->Redirect(); // This will redirect user to OpenID Server |
|
59 | 59 | } |
60 | 60 | else |
61 | 61 | { |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | return false; |
66 | 66 | } |
67 | 67 | // Perform HTTP Request to OpenID server to validate key |
68 | - elseif($_GET['openid_mode'] == 'id_res') |
|
68 | + elseif ($_GET['openid_mode'] == 'id_res') |
|
69 | 69 | { |
70 | 70 | $openid = new SimpleOpenID(); |
71 | 71 | $openid->SetIdentity($_GET['openid_identity']); |
@@ -74,23 +74,23 @@ discard block |
||
74 | 74 | { |
75 | 75 | // OK HERE KEY IS VALID |
76 | 76 | |
77 | - $sql ="SELECT login"; |
|
78 | - $sql.=" FROM ".MAIN_DB_PREFIX."user"; |
|
79 | - $sql.=" WHERE openid = '".$db->escape($_GET['openid_identity'])."'"; |
|
80 | - $sql.=" AND entity IN (0," . ($_SESSION["dol_entity"] ? $_SESSION["dol_entity"] : 1) . ")"; |
|
77 | + $sql = "SELECT login"; |
|
78 | + $sql .= " FROM ".MAIN_DB_PREFIX."user"; |
|
79 | + $sql .= " WHERE openid = '".$db->escape($_GET['openid_identity'])."'"; |
|
80 | + $sql .= " AND entity IN (0,".($_SESSION["dol_entity"] ? $_SESSION["dol_entity"] : 1).")"; |
|
81 | 81 | |
82 | 82 | dol_syslog("functions_openid::check_user_password_openid", LOG_DEBUG); |
83 | - $resql=$db->query($sql); |
|
83 | + $resql = $db->query($sql); |
|
84 | 84 | if ($resql) |
85 | 85 | { |
86 | - $obj=$db->fetch_object($resql); |
|
86 | + $obj = $db->fetch_object($resql); |
|
87 | 87 | if ($obj) |
88 | 88 | { |
89 | - $login=$obj->login; |
|
89 | + $login = $obj->login; |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | } |
93 | - else if($openid->IsError() === true) |
|
93 | + else if ($openid->IsError() === true) |
|
94 | 94 | { |
95 | 95 | // ON THE WAY, WE GOT SOME ERROR |
96 | 96 | $error = $openid->GetError(); |
@@ -32,17 +32,17 @@ |
||
32 | 32 | * @param int $entitytotest Number of instance (always 1 if module multicompany not enabled) |
33 | 33 | * @return string Login if OK, '' if KO |
34 | 34 | */ |
35 | -function check_user_password_forceuser($usertotest,$passwordtotest,$entitytotest) |
|
35 | +function check_user_password_forceuser($usertotest, $passwordtotest, $entitytotest) |
|
36 | 36 | { |
37 | 37 | // Variable dolibarr_auto_user must be defined in conf.php file |
38 | 38 | global $dolibarr_auto_user; |
39 | 39 | |
40 | 40 | dol_syslog("functions_forceuser::check_user_password_forceuser"); |
41 | 41 | |
42 | - $login=$dolibarr_auto_user; |
|
43 | - if (empty($login)) $login='auto'; |
|
42 | + $login = $dolibarr_auto_user; |
|
43 | + if (empty($login)) $login = 'auto'; |
|
44 | 44 | |
45 | - if ($_SESSION["dol_loginmesg"]) $login=''; |
|
45 | + if ($_SESSION["dol_loginmesg"]) $login = ''; |
|
46 | 46 | |
47 | 47 | dol_syslog("functions_forceuser::check_user_password_forceuser ok. forced user = ".$login); |
48 | 48 | return $login; |
@@ -33,19 +33,19 @@ discard block |
||
33 | 33 | * @param int $entitytotest Number of instance (always 1 if module multicompany not enabled) |
34 | 34 | * @return string Login if OK, '' if KO |
35 | 35 | */ |
36 | -function check_user_password_dolibarr($usertotest,$passwordtotest,$entitytotest=1) |
|
36 | +function check_user_password_dolibarr($usertotest, $passwordtotest, $entitytotest = 1) |
|
37 | 37 | { |
38 | - global $db,$conf,$langs; |
|
38 | + global $db, $conf, $langs; |
|
39 | 39 | |
40 | 40 | // Force master entity in transversal mode |
41 | - $entity=$entitytotest; |
|
42 | - if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $entity=1; |
|
41 | + $entity = $entitytotest; |
|
42 | + if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $entity = 1; |
|
43 | 43 | |
44 | - $login=''; |
|
44 | + $login = ''; |
|
45 | 45 | |
46 | - if (! empty($usertotest)) |
|
46 | + if (!empty($usertotest)) |
|
47 | 47 | { |
48 | - dol_syslog("functions_dolibarr::check_user_password_dolibarr usertotest=".$usertotest." passwordtotest=".preg_replace('/./','*',$passwordtotest)." entitytotest=".$entitytotest); |
|
48 | + dol_syslog("functions_dolibarr::check_user_password_dolibarr usertotest=".$usertotest." passwordtotest=".preg_replace('/./', '*', $passwordtotest)." entitytotest=".$entitytotest); |
|
49 | 49 | |
50 | 50 | // If test username/password asked, we define $test=false if ko and $login var to login if ok, set also $_SESSION["dol_loginmesg"] if ko |
51 | 51 | $table = MAIN_DB_PREFIX."user"; |
@@ -53,51 +53,51 @@ discard block |
||
53 | 53 | $usernamecol2 = 'email'; |
54 | 54 | $entitycol = 'entity'; |
55 | 55 | |
56 | - $sql ='SELECT rowid, login, entity, pass, pass_crypted'; |
|
57 | - $sql.=' FROM '.$table; |
|
58 | - $sql.=' WHERE ('.$usernamecol1." = '".$db->escape($usertotest)."'"; |
|
59 | - if (preg_match('/@/',$usertotest)) $sql.=' OR '.$usernamecol2." = '".$db->escape($usertotest)."'"; |
|
60 | - $sql.=') AND '.$entitycol." IN (0," . ($entity ? $entity : 1) . ")"; |
|
61 | - $sql.=' AND statut = 1'; |
|
56 | + $sql = 'SELECT rowid, login, entity, pass, pass_crypted'; |
|
57 | + $sql .= ' FROM '.$table; |
|
58 | + $sql .= ' WHERE ('.$usernamecol1." = '".$db->escape($usertotest)."'"; |
|
59 | + if (preg_match('/@/', $usertotest)) $sql .= ' OR '.$usernamecol2." = '".$db->escape($usertotest)."'"; |
|
60 | + $sql .= ') AND '.$entitycol." IN (0,".($entity ? $entity : 1).")"; |
|
61 | + $sql .= ' AND statut = 1'; |
|
62 | 62 | // Required to first found the user into entity, then the superadmin. |
63 | 63 | // For the case (TODO and that we must avoid) a user has renamed its login with same value than a user in entity 0. |
64 | - $sql.=' ORDER BY entity DESC'; |
|
64 | + $sql .= ' ORDER BY entity DESC'; |
|
65 | 65 | |
66 | - $resql=$db->query($sql); |
|
66 | + $resql = $db->query($sql); |
|
67 | 67 | if ($resql) |
68 | 68 | { |
69 | - $obj=$db->fetch_object($resql); |
|
69 | + $obj = $db->fetch_object($resql); |
|
70 | 70 | if ($obj) |
71 | 71 | { |
72 | - $passclear=$obj->pass; |
|
73 | - $passcrypted=$obj->pass_crypted; |
|
74 | - $passtyped=$passwordtotest; |
|
72 | + $passclear = $obj->pass; |
|
73 | + $passcrypted = $obj->pass_crypted; |
|
74 | + $passtyped = $passwordtotest; |
|
75 | 75 | |
76 | - $passok=false; |
|
76 | + $passok = false; |
|
77 | 77 | |
78 | 78 | // Check crypted password |
79 | - $cryptType=''; |
|
80 | - if (! empty($conf->global->DATABASE_PWD_ENCRYPTED)) $cryptType=$conf->global->DATABASE_PWD_ENCRYPTED; |
|
79 | + $cryptType = ''; |
|
80 | + if (!empty($conf->global->DATABASE_PWD_ENCRYPTED)) $cryptType = $conf->global->DATABASE_PWD_ENCRYPTED; |
|
81 | 81 | |
82 | 82 | // By default, we used MD5 |
83 | - if (! in_array($cryptType,array('md5'))) $cryptType='md5'; |
|
83 | + if (!in_array($cryptType, array('md5'))) $cryptType = 'md5'; |
|
84 | 84 | // Check crypted password according to crypt algorithm |
85 | 85 | if ($cryptType == 'md5') |
86 | 86 | { |
87 | 87 | if (dol_verifyHash($passtyped, $passcrypted)) |
88 | 88 | { |
89 | - $passok=true; |
|
89 | + $passok = true; |
|
90 | 90 | dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ok - ".$cryptType." of pass is ok"); |
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
94 | 94 | // For compatibility with old versions |
95 | - if (! $passok) |
|
95 | + if (!$passok) |
|
96 | 96 | { |
97 | - if ((! $passcrypted || $passtyped) |
|
97 | + if ((!$passcrypted || $passtyped) |
|
98 | 98 | && ($passclear && ($passtyped == $passclear))) |
99 | 99 | { |
100 | - $passok=true; |
|
100 | + $passok = true; |
|
101 | 101 | dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ok - found pass in database"); |
102 | 102 | } |
103 | 103 | } |
@@ -105,31 +105,31 @@ discard block |
||
105 | 105 | // Password ok ? |
106 | 106 | if ($passok) |
107 | 107 | { |
108 | - $login=$obj->login; |
|
108 | + $login = $obj->login; |
|
109 | 109 | } |
110 | 110 | else |
111 | 111 | { |
112 | 112 | dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko bad password for '".$usertotest."'"); |
113 | - sleep(2); // Anti brut force protection |
|
113 | + sleep(2); // Anti brut force protection |
|
114 | 114 | |
115 | 115 | // Load translation files required by the page |
116 | 116 | $langs->loadLangs(array('main', 'errors')); |
117 | 117 | |
118 | - $_SESSION["dol_loginmesg"]=$langs->trans("ErrorBadLoginPassword"); |
|
118 | + $_SESSION["dol_loginmesg"] = $langs->trans("ErrorBadLoginPassword"); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | // We must check entity |
122 | - if ($passok && ! empty($conf->multicompany->enabled)) // We must check entity |
|
122 | + if ($passok && !empty($conf->multicompany->enabled)) // We must check entity |
|
123 | 123 | { |
124 | 124 | global $mc; |
125 | 125 | |
126 | - if (! isset($mc)) $conf->multicompany->enabled = false; // Global not available, disable $conf->multicompany->enabled for safety |
|
126 | + if (!isset($mc)) $conf->multicompany->enabled = false; // Global not available, disable $conf->multicompany->enabled for safety |
|
127 | 127 | else |
128 | 128 | { |
129 | 129 | $ret = $mc->checkRight($obj->rowid, $entitytotest); |
130 | 130 | if ($ret < 0) |
131 | 131 | { |
132 | - dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko entity '" . $entitytotest . "' not allowed for user '" . $obj->rowid . "'"); |
|
132 | + dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko entity '".$entitytotest."' not allowed for user '".$obj->rowid."'"); |
|
133 | 133 | $login = ''; // force authentication failure |
134 | 134 | } |
135 | 135 | } |
@@ -143,14 +143,14 @@ discard block |
||
143 | 143 | // Load translation files required by the page |
144 | 144 | $langs->loadLangs(array('main', 'errors')); |
145 | 145 | |
146 | - $_SESSION["dol_loginmesg"]=$langs->trans("ErrorBadLoginPassword"); |
|
146 | + $_SESSION["dol_loginmesg"] = $langs->trans("ErrorBadLoginPassword"); |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | else |
150 | 150 | { |
151 | 151 | dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko db error for '".$usertotest."' error=".$db->lasterror()); |
152 | 152 | sleep(1); |
153 | - $_SESSION["dol_loginmesg"]=$db->lasterror(); |
|
153 | + $_SESSION["dol_loginmesg"] = $db->lasterror(); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 |
@@ -31,14 +31,14 @@ |
||
31 | 31 | * @param int $entitytotest Number of instance (always 1 if module multicompany not enabled) |
32 | 32 | * @return string Login if OK, '' if KO |
33 | 33 | */ |
34 | -function check_user_password_http($usertotest,$passwordtotest,$entitytotest) |
|
34 | +function check_user_password_http($usertotest, $passwordtotest, $entitytotest) |
|
35 | 35 | { |
36 | - dol_syslog("functions_http::check_user_password_http _SERVER[REMOTE_USER]=".(empty($_SERVER["REMOTE_USER"])?'':$_SERVER["REMOTE_USER"])); |
|
36 | + dol_syslog("functions_http::check_user_password_http _SERVER[REMOTE_USER]=".(empty($_SERVER["REMOTE_USER"]) ? '' : $_SERVER["REMOTE_USER"])); |
|
37 | 37 | |
38 | - $login=''; |
|
39 | - if (! empty($_SERVER["REMOTE_USER"])) |
|
38 | + $login = ''; |
|
39 | + if (!empty($_SERVER["REMOTE_USER"])) |
|
40 | 40 | { |
41 | - $login=$_SERVER["REMOTE_USER"]; |
|
41 | + $login = $_SERVER["REMOTE_USER"]; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | return $login; |
@@ -32,25 +32,25 @@ discard block |
||
32 | 32 | * @param int $entitytotest Number of instance (always 1 if module multicompany not enabled) |
33 | 33 | * @return string Login if OK, '' if KO |
34 | 34 | */ |
35 | -function check_user_password_ldap($usertotest,$passwordtotest,$entitytotest) |
|
35 | +function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest) |
|
36 | 36 | { |
37 | - global $db,$conf,$langs; |
|
37 | + global $db, $conf, $langs; |
|
38 | 38 | global $_POST; |
39 | - global $dolibarr_main_auth_ldap_host,$dolibarr_main_auth_ldap_port; |
|
40 | - global $dolibarr_main_auth_ldap_version,$dolibarr_main_auth_ldap_servertype; |
|
41 | - global $dolibarr_main_auth_ldap_login_attribute,$dolibarr_main_auth_ldap_dn; |
|
42 | - global $dolibarr_main_auth_ldap_admin_login,$dolibarr_main_auth_ldap_admin_pass; |
|
39 | + global $dolibarr_main_auth_ldap_host, $dolibarr_main_auth_ldap_port; |
|
40 | + global $dolibarr_main_auth_ldap_version, $dolibarr_main_auth_ldap_servertype; |
|
41 | + global $dolibarr_main_auth_ldap_login_attribute, $dolibarr_main_auth_ldap_dn; |
|
42 | + global $dolibarr_main_auth_ldap_admin_login, $dolibarr_main_auth_ldap_admin_pass; |
|
43 | 43 | global $dolibarr_main_auth_ldap_filter; |
44 | 44 | global $dolibarr_main_auth_ldap_debug; |
45 | 45 | |
46 | 46 | // Force master entity in transversal mode |
47 | - $entity=$entitytotest; |
|
48 | - if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $entity=1; |
|
47 | + $entity = $entitytotest; |
|
48 | + if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $entity = 1; |
|
49 | 49 | |
50 | - $login=''; |
|
51 | - $resultFetchUser=''; |
|
50 | + $login = ''; |
|
51 | + $resultFetchUser = ''; |
|
52 | 52 | |
53 | - if (! function_exists("ldap_connect")) |
|
53 | + if (!function_exists("ldap_connect")) |
|
54 | 54 | { |
55 | 55 | dol_syslog("functions_ldap::check_user_password_ldap Authentification ko failed to connect to LDAP. LDAP functions are disabled on this PHP"); |
56 | 56 | sleep(1); |
@@ -58,51 +58,51 @@ discard block |
||
58 | 58 | // Load translation files required by the page |
59 | 59 | $langs->loadLangs(array('main', 'other')); |
60 | 60 | |
61 | - $_SESSION["dol_loginmesg"]=$langs->trans("ErrorLDAPFunctionsAreDisabledOnThisPHP").' '.$langs->trans("TryAnotherConnectionMode"); |
|
61 | + $_SESSION["dol_loginmesg"] = $langs->trans("ErrorLDAPFunctionsAreDisabledOnThisPHP").' '.$langs->trans("TryAnotherConnectionMode"); |
|
62 | 62 | return; |
63 | 63 | } |
64 | 64 | |
65 | 65 | if ($usertotest) |
66 | 66 | { |
67 | - dol_syslog("functions_ldap::check_user_password_ldap usertotest=".$usertotest." passwordtotest=".preg_replace('/./','*',$passwordtotest)." entitytotest=".$entitytotest); |
|
67 | + dol_syslog("functions_ldap::check_user_password_ldap usertotest=".$usertotest." passwordtotest=".preg_replace('/./', '*', $passwordtotest)." entitytotest=".$entitytotest); |
|
68 | 68 | |
69 | 69 | // If test username/password asked, we define $test=false and $login var if ok, set $_SESSION["dol_loginmesg"] if ko |
70 | - $ldaphost=$dolibarr_main_auth_ldap_host; |
|
71 | - $ldapport=$dolibarr_main_auth_ldap_port; |
|
72 | - $ldapversion=$dolibarr_main_auth_ldap_version; |
|
73 | - $ldapservertype=(empty($dolibarr_main_auth_ldap_servertype) ? 'openldap' : $dolibarr_main_auth_ldap_servertype); |
|
70 | + $ldaphost = $dolibarr_main_auth_ldap_host; |
|
71 | + $ldapport = $dolibarr_main_auth_ldap_port; |
|
72 | + $ldapversion = $dolibarr_main_auth_ldap_version; |
|
73 | + $ldapservertype = (empty($dolibarr_main_auth_ldap_servertype) ? 'openldap' : $dolibarr_main_auth_ldap_servertype); |
|
74 | 74 | |
75 | - $ldapuserattr=$dolibarr_main_auth_ldap_login_attribute; |
|
76 | - $ldapdn=$dolibarr_main_auth_ldap_dn; |
|
77 | - $ldapadminlogin=$dolibarr_main_auth_ldap_admin_login; |
|
78 | - $ldapadminpass=$dolibarr_main_auth_ldap_admin_pass; |
|
79 | - $ldapdebug=(empty($dolibarr_main_auth_ldap_debug) || $dolibarr_main_auth_ldap_debug=="false" ? false : true); |
|
75 | + $ldapuserattr = $dolibarr_main_auth_ldap_login_attribute; |
|
76 | + $ldapdn = $dolibarr_main_auth_ldap_dn; |
|
77 | + $ldapadminlogin = $dolibarr_main_auth_ldap_admin_login; |
|
78 | + $ldapadminpass = $dolibarr_main_auth_ldap_admin_pass; |
|
79 | + $ldapdebug = (empty($dolibarr_main_auth_ldap_debug) || $dolibarr_main_auth_ldap_debug == "false" ? false : true); |
|
80 | 80 | |
81 | 81 | if ($ldapdebug) print "DEBUG: Logging LDAP steps<br>\n"; |
82 | 82 | |
83 | 83 | require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php'; |
84 | - $ldap=new Ldap(); |
|
85 | - $ldap->server=explode(',',$ldaphost); |
|
86 | - $ldap->serverPort=$ldapport; |
|
87 | - $ldap->ldapProtocolVersion=$ldapversion; |
|
88 | - $ldap->serverType=$ldapservertype; |
|
89 | - $ldap->searchUser=$ldapadminlogin; |
|
90 | - $ldap->searchPassword=$ldapadminpass; |
|
84 | + $ldap = new Ldap(); |
|
85 | + $ldap->server = explode(',', $ldaphost); |
|
86 | + $ldap->serverPort = $ldapport; |
|
87 | + $ldap->ldapProtocolVersion = $ldapversion; |
|
88 | + $ldap->serverType = $ldapservertype; |
|
89 | + $ldap->searchUser = $ldapadminlogin; |
|
90 | + $ldap->searchPassword = $ldapadminpass; |
|
91 | 91 | |
92 | 92 | if ($ldapdebug) |
93 | 93 | { |
94 | - dol_syslog("functions_ldap::check_user_password_ldap Server:".join(',',$ldap->server).", Port:".$ldap->serverPort.", Protocol:".$ldap->ldapProtocolVersion.", Type:".$ldap->serverType); |
|
94 | + dol_syslog("functions_ldap::check_user_password_ldap Server:".join(',', $ldap->server).", Port:".$ldap->serverPort.", Protocol:".$ldap->ldapProtocolVersion.", Type:".$ldap->serverType); |
|
95 | 95 | dol_syslog("functions_ldap::check_user_password_ldap uid/samacountname=".$ldapuserattr.", dn=".$ldapdn.", Admin:".$ldap->searchUser.", Pass:".$ldap->searchPassword); |
96 | - print "DEBUG: Server:".join(',',$ldap->server).", Port:".$ldap->serverPort.", Protocol:".$ldap->ldapProtocolVersion.", Type:".$ldap->serverType."<br>\n"; |
|
96 | + print "DEBUG: Server:".join(',', $ldap->server).", Port:".$ldap->serverPort.", Protocol:".$ldap->ldapProtocolVersion.", Type:".$ldap->serverType."<br>\n"; |
|
97 | 97 | print "DEBUG: uid/samacountname=".$ldapuserattr.", dn=".$ldapdn.", Admin:".$ldap->searchUser.", Pass:".$ldap->searchPassword."<br>\n"; |
98 | 98 | } |
99 | 99 | |
100 | - $resultFetchLdapUser=0; |
|
100 | + $resultFetchLdapUser = 0; |
|
101 | 101 | |
102 | 102 | // Define $userSearchFilter |
103 | 103 | $userSearchFilter = ""; |
104 | 104 | if (empty($dolibarr_main_auth_ldap_filter)) { |
105 | - $userSearchFilter = "(" . $ldapuserattr . "=" . $usertotest . ")"; |
|
105 | + $userSearchFilter = "(".$ldapuserattr."=".$usertotest.")"; |
|
106 | 106 | } else { |
107 | 107 | $userSearchFilter = str_replace('%1%', $usertotest, $dolibarr_main_auth_ldap_filter); |
108 | 108 | } |
@@ -111,10 +111,10 @@ discard block |
||
111 | 111 | // Code to get user in LDAP from an admin connection (may differ from user connection, done later) |
112 | 112 | if ($ldapadminlogin) |
113 | 113 | { |
114 | - $result=$ldap->connect_bind(); |
|
114 | + $result = $ldap->connect_bind(); |
|
115 | 115 | if ($result > 0) |
116 | 116 | { |
117 | - $resultFetchLdapUser = $ldap->fetch($usertotest,$userSearchFilter); |
|
117 | + $resultFetchLdapUser = $ldap->fetch($usertotest, $userSearchFilter); |
|
118 | 118 | //dol_syslog('functions_ldap::check_user_password_ldap resultFetchLdapUser='.$resultFetchLdapUser); |
119 | 119 | if ($resultFetchLdapUser > 0 && $ldap->pwdlastset == 0) // If ok but password need to be reset |
120 | 120 | { |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | $ldap->close(); |
124 | 124 | sleep(1); |
125 | 125 | $langs->load('ldap'); |
126 | - $_SESSION["dol_loginmesg"]=$langs->trans("YouMustChangePassNextLogon",$usertotest,$ldap->domainFQDN); |
|
126 | + $_SESSION["dol_loginmesg"] = $langs->trans("YouMustChangePassNextLogon", $usertotest, $ldap->domainFQDN); |
|
127 | 127 | return ''; |
128 | 128 | } |
129 | 129 | } |
@@ -137,41 +137,41 @@ discard block |
||
137 | 137 | // Forge LDAP user and password to test with them |
138 | 138 | // If LDAP need a dn with login like "uid=jbloggs,ou=People,dc=foo,dc=com", default dn may work even if previous code with |
139 | 139 | // admin login no exectued. |
140 | - $ldap->searchUser=$ldapuserattr."=".$usertotest.",".$ldapdn; // Default dn (will work if LDAP accept a dn with login value inside) |
|
140 | + $ldap->searchUser = $ldapuserattr."=".$usertotest.",".$ldapdn; // Default dn (will work if LDAP accept a dn with login value inside) |
|
141 | 141 | // But if LDAP need a dn with name like "cn=Jhon Bloggs,ou=People,dc=foo,dc=com", previous part must have been executed to have |
142 | 142 | // dn detected into ldapUserDN. |
143 | 143 | if ($resultFetchLdapUser && !empty($ldap->ldapUserDN)) $ldap->searchUser = $ldap->ldapUserDN; |
144 | - $ldap->searchPassword=$passwordtotest; |
|
144 | + $ldap->searchPassword = $passwordtotest; |
|
145 | 145 | |
146 | 146 | // Test with this->seachUser and this->searchPassword |
147 | 147 | //print $resultFetchLdapUser."-".$ldap->ldapUserDN."-".$ldap->searchUser.'-'.$ldap->searchPassword;exit; |
148 | - $result=$ldap->connect_bind(); |
|
148 | + $result = $ldap->connect_bind(); |
|
149 | 149 | if ($result > 0) |
150 | 150 | { |
151 | 151 | if ($result == 2) // Connection is ok for user/pass into LDAP |
152 | 152 | { |
153 | 153 | dol_syslog("functions_ldap::check_user_password_ldap Authentification ok"); |
154 | - $login=$usertotest; |
|
154 | + $login = $usertotest; |
|
155 | 155 | |
156 | 156 | // ldap2dolibarr synchronisation |
157 | - if ($login && ! empty($conf->ldap->enabled) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') // ldap2dolibarr synchronisation |
|
157 | + if ($login && !empty($conf->ldap->enabled) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') // ldap2dolibarr synchronisation |
|
158 | 158 | { |
159 | 159 | dol_syslog("functions_ldap::check_user_password_ldap Sync ldap2dolibarr"); |
160 | 160 | |
161 | 161 | // On charge les attributs du user ldap |
162 | 162 | if ($ldapdebug) print "DEBUG: login ldap = ".$login."<br>\n"; |
163 | - $resultFetchLdapUser = $ldap->fetch($login,$userSearchFilter); |
|
163 | + $resultFetchLdapUser = $ldap->fetch($login, $userSearchFilter); |
|
164 | 164 | |
165 | - if ($ldapdebug) print "DEBUG: UACF = ".join(',',$ldap->uacf)."<br>\n"; |
|
166 | - if ($ldapdebug) print "DEBUG: pwdLastSet = ".dol_print_date($ldap->pwdlastset,'day')."<br>\n"; |
|
167 | - if ($ldapdebug) print "DEBUG: badPasswordTime = ".dol_print_date($ldap->badpwdtime,'day')."<br>\n"; |
|
165 | + if ($ldapdebug) print "DEBUG: UACF = ".join(',', $ldap->uacf)."<br>\n"; |
|
166 | + if ($ldapdebug) print "DEBUG: pwdLastSet = ".dol_print_date($ldap->pwdlastset, 'day')."<br>\n"; |
|
167 | + if ($ldapdebug) print "DEBUG: badPasswordTime = ".dol_print_date($ldap->badpwdtime, 'day')."<br>\n"; |
|
168 | 168 | |
169 | 169 | // On recherche le user dolibarr en fonction de son SID ldap |
170 | 170 | $sid = $ldap->getObjectSid($login); |
171 | 171 | if ($ldapdebug) print "DEBUG: sid = ".$sid."<br>\n"; |
172 | 172 | |
173 | - $usertmp=new User($db); |
|
174 | - $resultFetchUser=$usertmp->fetch('',$login,$sid); |
|
173 | + $usertmp = new User($db); |
|
174 | + $resultFetchUser = $usertmp->fetch('', $login, $sid); |
|
175 | 175 | if ($resultFetchUser > 0) |
176 | 176 | { |
177 | 177 | dol_syslog("functions_ldap::check_user_password_ldap Sync user found user id=".$usertmp->id); |
@@ -189,17 +189,17 @@ discard block |
||
189 | 189 | unset($usertmp); |
190 | 190 | } |
191 | 191 | |
192 | - if (! empty($conf->multicompany->enabled)) // We must check entity (even if sync is not active) |
|
192 | + if (!empty($conf->multicompany->enabled)) // We must check entity (even if sync is not active) |
|
193 | 193 | { |
194 | 194 | global $mc; |
195 | 195 | |
196 | - $usertmp=new User($db); |
|
197 | - $usertmp->fetch('',$login); |
|
198 | - $ret=$mc->checkRight($usertmp->id, $entitytotest); |
|
196 | + $usertmp = new User($db); |
|
197 | + $usertmp->fetch('', $login); |
|
198 | + $ret = $mc->checkRight($usertmp->id, $entitytotest); |
|
199 | 199 | if ($ret < 0) |
200 | 200 | { |
201 | 201 | dol_syslog("functions_ldap::check_user_password_ldap Authentification ko entity '".$entitytotest."' not allowed for user '".$usertmp->id."'"); |
202 | - $login=''; // force authentication failure |
|
202 | + $login = ''; // force authentication failure |
|
203 | 203 | } |
204 | 204 | unset($usertmp); |
205 | 205 | } |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | // Load translation files required by the page |
213 | 213 | $langs->loadLangs(array('main', 'other')); |
214 | 214 | |
215 | - $_SESSION["dol_loginmesg"]=$langs->trans("ErrorBadLoginPassword"); |
|
215 | + $_SESSION["dol_loginmesg"] = $langs->trans("ErrorBadLoginPassword"); |
|
216 | 216 | } |
217 | 217 | } |
218 | 218 | else |
@@ -232,12 +232,12 @@ discard block |
||
232 | 232 | $ldap->ldapErrorText = ldap_error($ldap->connection); |
233 | 233 | dol_syslog("functions_ldap::check_user_password_ldap ".$ldap->ldapErrorCode." ".$ldap->ldapErrorText); |
234 | 234 | } |
235 | - sleep(2); // Anti brut force protection |
|
235 | + sleep(2); // Anti brut force protection |
|
236 | 236 | |
237 | 237 | // Load translation files required by the page |
238 | 238 | $langs->loadLangs(array('main', 'other', 'errors')); |
239 | 239 | ; |
240 | - $_SESSION["dol_loginmesg"]=($ldap->error?$ldap->error:$langs->trans("ErrorBadLoginPassword")); |
|
240 | + $_SESSION["dol_loginmesg"] = ($ldap->error ? $ldap->error : $langs->trans("ErrorBadLoginPassword")); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | $ldap->close(); |
@@ -31,14 +31,14 @@ |
||
31 | 31 | * @param int $entitytotest Number of instance (always 1 if module multicompany not enabled) |
32 | 32 | * @return string Login if OK, '' if KO |
33 | 33 | */ |
34 | -function check_user_password_empty($usertotest,$passwordtotest,$entitytotest) |
|
34 | +function check_user_password_empty($usertotest, $passwordtotest, $entitytotest) |
|
35 | 35 | { |
36 | 36 | global $langs; |
37 | 37 | |
38 | 38 | dol_syslog("functions_empty::check_user_password_empty usertotest=".$usertotest); |
39 | 39 | |
40 | - $login=''; |
|
41 | - $_SESSION["dol_loginmesg"]=$langs->trans("FailedToLogin"); |
|
40 | + $login = ''; |
|
41 | + $_SESSION["dol_loginmesg"] = $langs->trans("FailedToLogin"); |
|
42 | 42 | |
43 | 43 | return $login; |
44 | 44 | } |
@@ -30,16 +30,16 @@ |
||
30 | 30 | // Save selection |
31 | 31 | if (GETPOST('formfilteraction') == 'listafterchangingselectedfields') |
32 | 32 | { |
33 | - $tabparam=array(); |
|
33 | + $tabparam = array(); |
|
34 | 34 | |
35 | - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; |
|
35 | + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; |
|
36 | 36 | |
37 | - if (GETPOST("selectedfields")) $tabparam["MAIN_SELECTEDFIELDS_".$varpage]=GETPOST("selectedfields"); |
|
38 | - else $tabparam["MAIN_SELECTEDFIELDS_".$varpage]=''; |
|
37 | + if (GETPOST("selectedfields")) $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = GETPOST("selectedfields"); |
|
38 | + else $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = ''; |
|
39 | 39 | |
40 | 40 | include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
41 | 41 | |
42 | - $result=dol_set_user_param($db, $conf, $user, $tabparam); |
|
42 | + $result = dol_set_user_param($db, $conf, $user, $tabparam); |
|
43 | 43 | |
44 | 44 | //$action='list'; |
45 | 45 | //var_dump($tabparam);exit; |