@@ -27,7 +27,7 @@ |
||
27 | 27 | $tool_name = get_lang('AddSpecificSearchField'); |
28 | 28 | |
29 | 29 | if (isset($_GET['action']) && $_GET['action'] === 'edit') { |
30 | - $tool_name = get_lang('EditSpecificSearchField'); |
|
30 | + $tool_name = get_lang('EditSpecificSearchField'); |
|
31 | 31 | } |
32 | 32 | // Create the form |
33 | 33 | $form = new FormValidator('specific_fields_add'); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @Security("has_role('ROLE_ADMIN')") |
24 | 24 | * @Route("/plugins") |
25 | 25 | * |
26 | - * @return array |
|
26 | + * @return Response |
|
27 | 27 | */ |
28 | 28 | public function pluginsAction() |
29 | 29 | { |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @Security("has_role('ROLE_ADMIN')") |
43 | 43 | * @Route("/plugins/add") |
44 | 44 | * |
45 | - * @return array |
|
45 | + * @return null|Response |
|
46 | 46 | */ |
47 | 47 | public function pluginsAddAction() |
48 | 48 | { |
@@ -54,7 +54,7 @@ |
||
54 | 54 | |
55 | 55 | if (is_file($file)) { |
56 | 56 | $pluginInfo = require $file; |
57 | - var_dump($pluginInfo);exit; |
|
57 | + var_dump($pluginInfo); exit; |
|
58 | 58 | $allPluginsList[] = $pluginInfo; |
59 | 59 | } |
60 | 60 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | * @Security("has_role('ROLE_ADMIN')") |
24 | 24 | * @Route("/settings", name="admin_settings") |
25 | 25 | * |
26 | - * @return array |
|
26 | + * @return Response |
|
27 | 27 | */ |
28 | 28 | public function indexAction() |
29 | 29 | { |
@@ -228,7 +228,7 @@ |
||
228 | 228 | get_lang('PickACourseAsATemplateForThisNewCourse'), |
229 | 229 | ], |
230 | 230 | null, |
231 | - ['url' => api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?a=search_course'] |
|
231 | + ['url' => api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=search_course'] |
|
232 | 232 | ); |
233 | 233 | } |
234 | 234 |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * @param string $prompt text prompt, should include possible options |
192 | 192 | * @param string $default default value when enter pressed |
193 | 193 | * @param array $options list of allowed options, empty means any text |
194 | - * @param bool $casesensitive true if options are case sensitive |
|
194 | + * @param bool $casesensitiveoptions true if options are case sensitive |
|
195 | 195 | * @return string entered text |
196 | 196 | */ |
197 | 197 | function cli_input($prompt, $default='', array $options=null, $casesensitiveoptions=false) { |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | /** |
289 | 289 | * Print or return section separator string |
290 | 290 | * @param bool $return false means print, true return as string |
291 | - * @return mixed void or string |
|
291 | + * @return string|null void or string |
|
292 | 292 | */ |
293 | 293 | function cli_separator($return=false) { |
294 | 294 | $separator = str_repeat('-', 79)."\n"; |
@@ -6,12 +6,12 @@ discard block |
||
6 | 6 | * @param string $location |
7 | 7 | * |
8 | 8 | */ |
9 | -function vchamilo_parse_csv_nodelist($nodelistlocation = '', $plugin = null){ |
|
9 | +function vchamilo_parse_csv_nodelist($nodelistlocation = '', $plugin = null) { |
|
10 | 10 | global $_configuration; |
11 | 11 | |
12 | 12 | $vnodes = array(); |
13 | 13 | |
14 | - if (empty($nodelistlocation)){ |
|
14 | + if (empty($nodelistlocation)) { |
|
15 | 15 | $nodelistlocation = $_configuratioh['root_sys'].'/plugin/vchamilo/nodelist.csv'; |
16 | 16 | } |
17 | 17 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | // Jump any empty or comment line |
71 | 71 | $text = fgets($fp, 1024); |
72 | 72 | $i = 0; |
73 | - while(vchamilo_is_empty_line_or_format($text, $i == 0)){ |
|
73 | + while (vchamilo_is_empty_line_or_format($text, $i == 0)) { |
|
74 | 74 | $text = fgets($fp, 1024); |
75 | 75 | $i++; |
76 | 76 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | // Check for valid field names |
81 | 81 | foreach ($headers as $h) { |
82 | 82 | $header[] = trim($h); |
83 | - $patternized = implode('|', $patterns) . "\\d+"; |
|
83 | + $patternized = implode('|', $patterns)."\\d+"; |
|
84 | 84 | $metapattern = implode('|', $metas); |
85 | 85 | if (!(isset($required[$h]) || |
86 | 86 | isset($optionalDefaults[$h]) || |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | $linenum = 2; // Since header is line 1. |
110 | 110 | |
111 | 111 | // Take some from admin profile, other fixed by hardcoded defaults. |
112 | - while (!feof ($fp)) { |
|
112 | + while (!feof($fp)) { |
|
113 | 113 | |
114 | 114 | // Make a new base record. |
115 | 115 | $vnode = new StdClass(); |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * @param bool $casesensitive true if options are case sensitive |
197 | 197 | * @return string entered text |
198 | 198 | */ |
199 | -function cli_input($prompt, $default='', array $options=null, $casesensitiveoptions=false) { |
|
199 | +function cli_input($prompt, $default = '', array $options = null, $casesensitiveoptions = false) { |
|
200 | 200 | echo $prompt; |
201 | 201 | echo "\n: "; |
202 | 202 | $input = fread(STDIN, 2048); |
@@ -222,8 +222,8 @@ discard block |
||
222 | 222 | * @param array $shortmapping array describing mapping of short to long style options ex:('h'=>'help', 'v'=>'verbose') |
223 | 223 | * @return array array of arrays, options, unrecognised as optionlongname=>value |
224 | 224 | */ |
225 | -function cli_get_params(array $longoptions, array $shortmapping=null) { |
|
226 | - $shortmapping = (array)$shortmapping; |
|
225 | +function cli_get_params(array $longoptions, array $shortmapping = null) { |
|
226 | + $shortmapping = (array) $shortmapping; |
|
227 | 227 | $options = array(); |
228 | 228 | $unrecognized = array(); |
229 | 229 | |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | * @param bool $return false means print, true return as string |
293 | 293 | * @return mixed void or string |
294 | 294 | */ |
295 | -function cli_separator($return=false) { |
|
295 | +function cli_separator($return = false) { |
|
296 | 296 | $separator = str_repeat('-', 79)."\n"; |
297 | 297 | if ($return) { |
298 | 298 | return $separator; |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | * @param bool $return false means print, true return as string |
308 | 308 | * @return mixed void or string |
309 | 309 | */ |
310 | -function cli_heading($string, $return=false) { |
|
310 | +function cli_heading($string, $return = false) { |
|
311 | 311 | $string = "== $string ==\n"; |
312 | 312 | if ($return) { |
313 | 313 | return $string; |
@@ -6,12 +6,13 @@ discard block |
||
6 | 6 | * @param string $location |
7 | 7 | * |
8 | 8 | */ |
9 | -function vchamilo_parse_csv_nodelist($nodelistlocation = '', $plugin = null){ |
|
9 | +function vchamilo_parse_csv_nodelist($nodelistlocation = '', $plugin = null) |
|
10 | +{ |
|
10 | 11 | global $_configuration; |
11 | 12 | |
12 | 13 | $vnodes = array(); |
13 | 14 | |
14 | - if (empty($nodelistlocation)){ |
|
15 | + if (empty($nodelistlocation)) { |
|
15 | 16 | $nodelistlocation = $_configuratioh['root_sys'].'/plugin/vchamilo/nodelist.csv'; |
16 | 17 | } |
17 | 18 | |
@@ -70,7 +71,7 @@ discard block |
||
70 | 71 | // Jump any empty or comment line |
71 | 72 | $text = fgets($fp, 1024); |
72 | 73 | $i = 0; |
73 | - while(vchamilo_is_empty_line_or_format($text, $i == 0)){ |
|
74 | + while(vchamilo_is_empty_line_or_format($text, $i == 0)) { |
|
74 | 75 | $text = fgets($fp, 1024); |
75 | 76 | $i++; |
76 | 77 | } |
@@ -101,7 +102,8 @@ discard block |
||
101 | 102 | |
102 | 103 | // Check for required fields. |
103 | 104 | foreach ($required as $key => $value) { |
104 | - if ($value) { // Required field missing. |
|
105 | + if ($value) { |
|
106 | +// Required field missing. |
|
105 | 107 | cli_error("fieldrequired $key"); |
106 | 108 | return; |
107 | 109 | } |
@@ -135,7 +137,9 @@ discard block |
||
135 | 137 | $key = $headers[$f]; |
136 | 138 | if (preg_match('/\|/', $key)) { |
137 | 139 | list($plugin, $variable) = explode('|', str_replace('plugin_', '', $key)); |
138 | - if (empty($variable)) die("Key error in CSV : $key "); |
|
140 | + if (empty($variable)) { |
|
141 | + die("Key error in CSV : $key "); |
|
142 | + } |
|
139 | 143 | if (!isset($vnode->$plugin)) { |
140 | 144 | $vnode->$plugin = new StdClass(); |
141 | 145 | } |
@@ -165,15 +169,21 @@ discard block |
||
165 | 169 | * Check a CSV input line format for empty or commented lines |
166 | 170 | * Ensures compatbility to UTF-8 BOM or unBOM formats |
167 | 171 | */ |
168 | -function vchamilo_is_empty_line_or_format(&$text, $resetfirst = false) { |
|
172 | +function vchamilo_is_empty_line_or_format(&$text, $resetfirst = false) |
|
173 | +{ |
|
169 | 174 | global $CFG; |
170 | 175 | |
171 | 176 | static $textlib; |
172 | 177 | static $first = true; |
173 | 178 | |
174 | 179 | // We may have a risk the BOM is present on first line |
175 | - if ($resetfirst) $first = true; |
|
176 | - if (!isset($textlib)) $textlib = new textlib(); // Singleton |
|
180 | + if ($resetfirst) { |
|
181 | + $first = true; |
|
182 | + } |
|
183 | + if (!isset($textlib)) { |
|
184 | + $textlib = new textlib(); |
|
185 | + } |
|
186 | + // Singleton |
|
177 | 187 | $text = $textlib->trim_utf8_bom($text); |
178 | 188 | $first = false; |
179 | 189 | |
@@ -196,7 +206,8 @@ discard block |
||
196 | 206 | * @param bool $casesensitive true if options are case sensitive |
197 | 207 | * @return string entered text |
198 | 208 | */ |
199 | -function cli_input($prompt, $default='', array $options=null, $casesensitiveoptions=false) { |
|
209 | +function cli_input($prompt, $default='', array $options=null, $casesensitiveoptions=false) |
|
210 | +{ |
|
200 | 211 | echo $prompt; |
201 | 212 | echo "\n: "; |
202 | 213 | $input = fread(STDIN, 2048); |
@@ -222,7 +233,8 @@ discard block |
||
222 | 233 | * @param array $shortmapping array describing mapping of short to long style options ex:('h'=>'help', 'v'=>'verbose') |
223 | 234 | * @return array array of arrays, options, unrecognised as optionlongname=>value |
224 | 235 | */ |
225 | -function cli_get_params(array $longoptions, array $shortmapping=null) { |
|
236 | +function cli_get_params(array $longoptions, array $shortmapping=null) |
|
237 | +{ |
|
226 | 238 | $shortmapping = (array)$shortmapping; |
227 | 239 | $options = array(); |
228 | 240 | $unrecognized = array(); |
@@ -292,7 +304,8 @@ discard block |
||
292 | 304 | * @param bool $return false means print, true return as string |
293 | 305 | * @return mixed void or string |
294 | 306 | */ |
295 | -function cli_separator($return=false) { |
|
307 | +function cli_separator($return=false) |
|
308 | +{ |
|
296 | 309 | $separator = str_repeat('-', 79)."\n"; |
297 | 310 | if ($return) { |
298 | 311 | return $separator; |
@@ -307,7 +320,8 @@ discard block |
||
307 | 320 | * @param bool $return false means print, true return as string |
308 | 321 | * @return mixed void or string |
309 | 322 | */ |
310 | -function cli_heading($string, $return=false) { |
|
323 | +function cli_heading($string, $return=false) |
|
324 | +{ |
|
311 | 325 | $string = "== $string ==\n"; |
312 | 326 | if ($return) { |
313 | 327 | return $string; |
@@ -321,7 +335,8 @@ discard block |
||
321 | 335 | * @param $text |
322 | 336 | * @return void |
323 | 337 | */ |
324 | -function cli_problem($text) { |
|
338 | +function cli_problem($text) |
|
339 | +{ |
|
325 | 340 | fwrite(STDERR, $text."\n"); |
326 | 341 | } |
327 | 342 | |
@@ -332,7 +347,8 @@ discard block |
||
332 | 347 | * @param int $errorcode |
333 | 348 | * @return void (does not return) |
334 | 349 | */ |
335 | -function cli_error($text, $errorcode = 1) { |
|
350 | +function cli_error($text, $errorcode = 1) |
|
351 | +{ |
|
336 | 352 | fwrite(STDERR, $text); |
337 | 353 | fwrite(STDERR, "\n"); |
338 | 354 | die($errorcode); |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | echo "Chamilo Bulk Nodes Creation v.1.0\n"; |
14 | 14 | echo "=================================\n"; |
15 | 15 | require_once('../../../main/inc/global.inc.php'); |
16 | -require_once('clilib.php'); // cli only functions |
|
16 | +require_once('clilib.php'); // cli only functions |
|
17 | 17 | // Ensure errors are well explained |
18 | 18 | ini_set('debug_display', 1); |
19 | 19 | ini_set('debug_level', E_ALL); |
@@ -68,26 +68,26 @@ discard block |
||
68 | 68 | |
69 | 69 | if (!empty($options['config'])) { |
70 | 70 | echo "Loading config : ".$options['config']; |
71 | - if (!file_exists($options['config'])){ |
|
71 | + if (!file_exists($options['config'])) { |
|
72 | 72 | cli_error('Config file mentioned but not found'); |
73 | 73 | } |
74 | 74 | |
75 | 75 | $content = file($options['config']); |
76 | - foreach($content as $l) { |
|
76 | + foreach ($content as $l) { |
|
77 | 77 | if (preg_match('/^\s+$/', $l)) continue; // Empty lines. |
78 | 78 | if (preg_match('/^[#\/!;]/', $l)) continue; // Comments (any form). |
79 | 79 | if (preg_match('/^(.*?)=(.*)$/', $l, $matches)) { |
80 | - if (in_array($matches[1], $expectedoptions)){ |
|
80 | + if (in_array($matches[1], $expectedoptions)) { |
|
81 | 81 | $options[trim($matches[1])] = trim($matches[2]); |
82 | 82 | } |
83 | 83 | } |
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
87 | -require_once($_configuration['root_sys'].'local/classes/database.class.php'); // cli only functions |
|
88 | -require_once($_configuration['root_sys'].'local/classes/textlib.class.php'); // cli only functions |
|
89 | -require_once($_configuration['root_sys'].'local/classes/mootochamlib.php'); // moodle like API |
|
90 | -require_once($_configuration['root_sys'] . '/plugin/vchamilo/lib/vchamilo_plugin.class.php'); |
|
87 | +require_once($_configuration['root_sys'].'local/classes/database.class.php'); // cli only functions |
|
88 | +require_once($_configuration['root_sys'].'local/classes/textlib.class.php'); // cli only functions |
|
89 | +require_once($_configuration['root_sys'].'local/classes/mootochamlib.php'); // moodle like API |
|
90 | +require_once($_configuration['root_sys'].'/plugin/vchamilo/lib/vchamilo_plugin.class.php'); |
|
91 | 91 | |
92 | 92 | global $DB; |
93 | 93 | if ($options['verbose']) echo "building database manager\n"; |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | // Get main admin for further replacement. |
118 | 118 | $admin = $DB->get_record('user', array('username' => 'admin')); |
119 | 119 | |
120 | -foreach($nodes as $data) { |
|
120 | +foreach ($nodes as $data) { |
|
121 | 121 | |
122 | 122 | ctrace('Making node '.$data->root_web); |
123 | 123 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $settingrec->access_url = 1; |
164 | 164 | $settingrec->selected_value = $value; |
165 | 165 | ctrace("Setting up {$settingrec->variable}|{$settingrec->subkey} to $value\n"); |
166 | - if ($oldrec = $NDB->get_record('settings_current', array('variable' => $settingrec->variable, 'subkey' => $settingrec->subkey, 'type' => $settingrec->type))){ |
|
166 | + if ($oldrec = $NDB->get_record('settings_current', array('variable' => $settingrec->variable, 'subkey' => $settingrec->subkey, 'type' => $settingrec->type))) { |
|
167 | 167 | $settingrec->id = $oldrec->id; |
168 | 168 | $NDB->update_record('settings_current', $settingrec, 'id'); |
169 | 169 | } else { |
@@ -208,9 +208,9 @@ discard block |
||
208 | 208 | |
209 | 209 | if ($interactive) { |
210 | 210 | $input = readline("Continue (y/n|r) ?\n"); |
211 | - if ($input == 'r' || $input == 'R'){ |
|
211 | + if ($input == 'r' || $input == 'R') { |
|
212 | 212 | // do nothing, just continue |
213 | - } elseif ($input == 'n' || $input == 'N'){ |
|
213 | + } elseif ($input == 'n' || $input == 'N') { |
|
214 | 214 | echo "finishing\n"; |
215 | 215 | exit; |
216 | 216 | } |
@@ -68,16 +68,22 @@ discard block |
||
68 | 68 | |
69 | 69 | if (!empty($options['config'])) { |
70 | 70 | echo "Loading config : ".$options['config']; |
71 | - if (!file_exists($options['config'])){ |
|
71 | + if (!file_exists($options['config'])) { |
|
72 | 72 | cli_error('Config file mentioned but not found'); |
73 | 73 | } |
74 | 74 | |
75 | 75 | $content = file($options['config']); |
76 | 76 | foreach($content as $l) { |
77 | - if (preg_match('/^\s+$/', $l)) continue; // Empty lines. |
|
78 | - if (preg_match('/^[#\/!;]/', $l)) continue; // Comments (any form). |
|
77 | + if (preg_match('/^\s+$/', $l)) { |
|
78 | + continue; |
|
79 | + } |
|
80 | + // Empty lines. |
|
81 | + if (preg_match('/^[#\/!;]/', $l)) { |
|
82 | + continue; |
|
83 | + } |
|
84 | + // Comments (any form). |
|
79 | 85 | if (preg_match('/^(.*?)=(.*)$/', $l, $matches)) { |
80 | - if (in_array($matches[1], $expectedoptions)){ |
|
86 | + if (in_array($matches[1], $expectedoptions)) { |
|
81 | 87 | $options[trim($matches[1])] = trim($matches[2]); |
82 | 88 | } |
83 | 89 | } |
@@ -90,16 +96,22 @@ discard block |
||
90 | 96 | require_once($_configuration['root_sys'] . '/plugin/vchamilo/lib/vchamilo_plugin.class.php'); |
91 | 97 | |
92 | 98 | global $DB; |
93 | -if ($options['verbose']) echo "building database manager\n"; |
|
99 | +if ($options['verbose']) { |
|
100 | + echo "building database manager\n"; |
|
101 | +} |
|
94 | 102 | $DB = new DatabaseManager(); |
95 | -if ($options['verbose']) echo "building plugin vchamilo\n"; |
|
103 | +if ($options['verbose']) { |
|
104 | + echo "building plugin vchamilo\n"; |
|
105 | +} |
|
96 | 106 | $plugin = VChamiloPlugin::create(); |
97 | 107 | |
98 | 108 | if (empty($options['nodes'])) { |
99 | 109 | cli_error('Missing node definition. Halt.'); |
100 | 110 | } |
101 | 111 | |
102 | -if ($options['verbose']) echo "parsing nodelist\n"; |
|
112 | +if ($options['verbose']) { |
|
113 | + echo "parsing nodelist\n"; |
|
114 | +} |
|
103 | 115 | $nodes = vchamilo_parse_csv_nodelist($options['nodes'], $plugin); |
104 | 116 | |
105 | 117 | if ($options['lint']) { |
@@ -163,7 +175,7 @@ discard block |
||
163 | 175 | $settingrec->access_url = 1; |
164 | 176 | $settingrec->selected_value = $value; |
165 | 177 | ctrace("Setting up {$settingrec->variable}|{$settingrec->subkey} to $value\n"); |
166 | - if ($oldrec = $NDB->get_record('settings_current', array('variable' => $settingrec->variable, 'subkey' => $settingrec->subkey, 'type' => $settingrec->type))){ |
|
178 | + if ($oldrec = $NDB->get_record('settings_current', array('variable' => $settingrec->variable, 'subkey' => $settingrec->subkey, 'type' => $settingrec->type))) { |
|
167 | 179 | $settingrec->id = $oldrec->id; |
168 | 180 | $NDB->update_record('settings_current', $settingrec, 'id'); |
169 | 181 | } else { |
@@ -208,9 +220,9 @@ discard block |
||
208 | 220 | |
209 | 221 | if ($interactive) { |
210 | 222 | $input = readline("Continue (y/n|r) ?\n"); |
211 | - if ($input == 'r' || $input == 'R'){ |
|
223 | + if ($input == 'r' || $input == 'R') { |
|
212 | 224 | // do nothing, just continue |
213 | - } elseif ($input == 'n' || $input == 'N'){ |
|
225 | + } elseif ($input == 'n' || $input == 'N') { |
|
214 | 226 | echo "finishing\n"; |
215 | 227 | exit; |
216 | 228 | } |
@@ -195,7 +195,7 @@ |
||
195 | 195 | } |
196 | 196 | |
197 | 197 | if ($oldrec = $NDB->get_record('settings_current', $params)) { |
198 | - ctrace("Updating {$settingrec->variable}|{$settingrec->subkey} to $configsetting->value\n"); |
|
198 | + ctrace("updating {$settingrec->variable}|{$settingrec->subkey} to $configsetting->value\n"); |
|
199 | 199 | $settingrec->id = $oldrec->id; |
200 | 200 | $NDB->update_record('settings_current', $settingrec, 'id'); |
201 | 201 | } |
@@ -46,10 +46,9 @@ discard block |
||
46 | 46 | - Universite Jean Monet (J Dubois / Michel Courbon) |
47 | 47 | - Michel Panckoucke for reporting and fixing a bug |
48 | 48 | - Patrick Cool: fixing security hole |
49 | - |
|
50 | - * @author Roan Embrechts |
|
51 | - * @version 3.0 |
|
52 | - * @package chamilo.auth.ldap |
|
49 | + * @author Roan Embrechts |
|
50 | + * @version 3.0 |
|
51 | + * @package chamilo.auth.ldap |
|
53 | 52 | * Note: |
54 | 53 | * If you are using a firewall, you might need to check port 389 is open in |
55 | 54 | * order for Chamilo to communicate with the LDAP server. |
@@ -211,8 +210,8 @@ discard block |
||
211 | 210 | $language = api_get_setting('platformLanguage'); |
212 | 211 | if (empty($language)) { $language = 'english'; } |
213 | 212 | $_userId = UserManager::create_user($prenom, $nom, $status, |
214 | - $email, $uname, $password, $official_code, |
|
215 | - $language,'', '', 'ldap'); |
|
213 | + $email, $uname, $password, $official_code, |
|
214 | + $language,'', '', 'ldap'); |
|
216 | 215 | |
217 | 216 | //echo "new user added to Chamilo, id = $_userId"; |
218 | 217 | |
@@ -271,7 +270,7 @@ discard block |
||
271 | 270 | // Open anonymous LDAP connection |
272 | 271 | $result=false; |
273 | 272 | $ldap_bind_res = ldap_handle_bind($ds,$result); |
274 | - // Executing the search with the $filter parametr |
|
273 | + // Executing the search with the $filter parametr |
|
275 | 274 | //error_log('Searching for '.$filter.' on LDAP server',0); |
276 | 275 | $sr=ldap_search($ds,$ldap_basedn,$filter); |
277 | 276 | $info = ldap_get_entries($ds, $sr); |
@@ -564,35 +563,35 @@ discard block |
||
564 | 563 | foreach ($UserList as $enreg_user) { |
565 | 564 | $enreg_user = (int) $enreg_user; |
566 | 565 | Database::query("INSERT IGNORE ". |
567 | - " INTO $tbl_session_rel_course_rel_user ". |
|
568 | - "(session_id,c_id,user_id) VALUES ". |
|
569 | - "('$id_session','$enreg_course','$enreg_user')"); |
|
566 | + " INTO $tbl_session_rel_course_rel_user ". |
|
567 | + "(session_id,c_id,user_id) VALUES ". |
|
568 | + "('$id_session','$enreg_course','$enreg_user')"); |
|
570 | 569 | } |
571 | 570 | $sql = "SELECT COUNT(user_id) as nbUsers ". |
572 | - " FROM $tbl_session_rel_course_rel_user " . |
|
573 | - " WHERE session_id='$id_session' ". |
|
574 | - " AND c_id='$enreg_course'"; |
|
571 | + " FROM $tbl_session_rel_course_rel_user " . |
|
572 | + " WHERE session_id='$id_session' ". |
|
573 | + " AND c_id='$enreg_course'"; |
|
575 | 574 | $rs = Database::query($sql); |
576 | 575 | list($nbr_users) = Database::fetch_array($rs); |
577 | 576 | Database::query("UPDATE $tbl_session_rel_course ". |
578 | - " SET nbr_users=$nbr_users " . |
|
579 | - " WHERE session_id='$id_session' ". |
|
580 | - " AND c_id='$enreg_course'"); |
|
577 | + " SET nbr_users=$nbr_users " . |
|
578 | + " WHERE session_id='$id_session' ". |
|
579 | + " AND c_id='$enreg_course'"); |
|
581 | 580 | } |
582 | 581 | foreach ($UserList as $enreg_user) { |
583 | 582 | $enreg_user = (int) $enreg_user; |
584 | 583 | Database::query("INSERT IGNORE INTO $tbl_session_rel_user ". |
585 | - " (session_id, user_id, registered_at) " . |
|
586 | - " VALUES('$id_session','$enreg_user', '" . api_get_utc_datetime() . "')"); |
|
584 | + " (session_id, user_id, registered_at) " . |
|
585 | + " VALUES('$id_session','$enreg_user', '" . api_get_utc_datetime() . "')"); |
|
587 | 586 | } |
588 | 587 | // We update the number of users in the session |
589 | 588 | $sql = "SELECT COUNT(user_id) as nbUsers FROM $tbl_session_rel_user ". |
590 | - " WHERE session_id='$id_session' ". |
|
591 | - " AND relation_type<>".SESSION_RELATION_TYPE_RRHH." "; |
|
589 | + " WHERE session_id='$id_session' ". |
|
590 | + " AND relation_type<>".SESSION_RELATION_TYPE_RRHH." "; |
|
592 | 591 | $rs = Database::query($sql); |
593 | 592 | list($nbr_users) = Database::fetch_array($rs); |
594 | 593 | Database::query("UPDATE $tbl_session SET nbr_users=$nbr_users ". |
595 | - " WHERE id='$id_session'"); |
|
594 | + " WHERE id='$id_session'"); |
|
596 | 595 | } |
597 | 596 | |
598 | 597 | function syncro_users() { |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | " AND c_id='$enreg_course'"; |
576 | 576 | $rs = Database::query($sql); |
577 | 577 | list($nbr_users) = Database::fetch_array($rs); |
578 | - Database::query("UPDATE $tbl_session_rel_course ". |
|
578 | + Database::query("update $tbl_session_rel_course ". |
|
579 | 579 | " SET nbr_users=$nbr_users " . |
580 | 580 | " WHERE session_id='$id_session' ". |
581 | 581 | " AND c_id='$enreg_course'"); |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | " AND relation_type<>".SESSION_RELATION_TYPE_RRHH." "; |
593 | 593 | $rs = Database::query($sql); |
594 | 594 | list($nbr_users) = Database::fetch_array($rs); |
595 | - Database::query("UPDATE $tbl_session SET nbr_users=$nbr_users ". |
|
595 | + Database::query("update $tbl_session SET nbr_users=$nbr_users ". |
|
596 | 596 | " WHERE id='$id_session'"); |
597 | 597 | } |
598 | 598 |
@@ -71,23 +71,32 @@ discard block |
||
71 | 71 | * @author Roan Embrechts (based on code from Universit� Jean Monet) |
72 | 72 | */ |
73 | 73 | |
74 | -function ldap_login($login, $password) { |
|
74 | +function ldap_login($login, $password) |
|
75 | +{ |
|
75 | 76 | //error_log('Entering ldap_login('.$login.','.$password.')',0); |
76 | 77 | $res = ldap_authentication_check($login, $password); |
77 | 78 | |
78 | 79 | // res=-1 -> the user does not exist in the ldap database |
79 | 80 | // res=1 -> invalid password (user does exist) |
80 | 81 | |
81 | - if ($res==1) { //WRONG PASSWORD |
|
82 | + if ($res==1) { |
|
83 | +//WRONG PASSWORD |
|
82 | 84 | //$errorMessage = "LDAP User or password incorrect, try again.<br />"; |
83 | - if (isset($log)) unset($log); if (isset($uid)) unset($uid); |
|
85 | + if (isset($log)) { |
|
86 | + unset($log); |
|
87 | + } |
|
88 | + if (isset($uid)) { |
|
89 | + unset($uid); |
|
90 | + } |
|
84 | 91 | $loginLdapSucces = false; |
85 | 92 | } |
86 | - if ($res==-1) { //WRONG USERNAME |
|
93 | + if ($res==-1) { |
|
94 | +//WRONG USERNAME |
|
87 | 95 | //$errorMessage = "LDAP User or password incorrect, try again.<br />"; |
88 | 96 | $login_ldap_success = false; |
89 | 97 | } |
90 | - if ($res==0) { //LOGIN & PASSWORD OK - SUCCES |
|
98 | + if ($res==0) { |
|
99 | +//LOGIN & PASSWORD OK - SUCCES |
|
91 | 100 | //$errorMessage = "Successful login w/ LDAP.<br>"; |
92 | 101 | $login_ldap_success = true; |
93 | 102 | } |
@@ -103,7 +112,8 @@ discard block |
||
103 | 112 | * @author Stefan De Wannemacker |
104 | 113 | * @author Roan Embrechts |
105 | 114 | */ |
106 | -function ldap_find_user_info ($login) { |
|
115 | +function ldap_find_user_info ($login) |
|
116 | +{ |
|
107 | 117 | //error_log('Entering ldap_find_user_info('.$login.')',0); |
108 | 118 | global $ldap_host, $ldap_port, $ldap_basedn, $ldap_rdn, $ldap_pass, $ldap_search_dn; |
109 | 119 | // basic sequence with LDAP is connect, bind, search, |
@@ -154,7 +164,8 @@ discard block |
||
154 | 164 | * "firstname", "name", "email", "isEmployee" |
155 | 165 | * @author Roan Embrechts |
156 | 166 | */ |
157 | -function ldap_put_user_info_locally($login, $info_array) { |
|
167 | +function ldap_put_user_info_locally($login, $info_array) |
|
168 | +{ |
|
158 | 169 | //error_log('Entering ldap_put_user_info_locally('.$login.',info_array)',0); |
159 | 170 | global $ldap_pass_placeholder; |
160 | 171 | global $submitRegistration, $submit, $uname, $email, |
@@ -242,7 +253,8 @@ discard block |
||
242 | 253 | * @param string password given by user |
243 | 254 | * @return int 0 if authentication succeeded, 1 if password was incorrect, -1 if it didn't belong to LDAP |
244 | 255 | */ |
245 | -function ldap_authentication_check ($uname, $passwd) { |
|
256 | +function ldap_authentication_check ($uname, $passwd) |
|
257 | +{ |
|
246 | 258 | //error_log('Entering ldap_authentication_check('.$uname.','.$passwd.')',0); |
247 | 259 | global $ldap_host, $ldap_port, $ldap_basedn, $ldap_host2, $ldap_port2,$ldap_rdn,$ldap_pass; |
248 | 260 | //error_log('Entering ldap_authentication_check('.$uname.','.$passwd.')',0); |
@@ -293,7 +305,8 @@ discard block |
||
293 | 305 | // return in case of wrong password connection error |
294 | 306 | if (@ldap_bind( $ds, $dn , $passwd) === false) { |
295 | 307 | return (1); // invalid password |
296 | - } else {// connection successfull |
|
308 | + } else { |
|
309 | +// connection successfull |
|
297 | 310 | return (0); |
298 | 311 | } |
299 | 312 | } // end of check |
@@ -302,7 +315,8 @@ discard block |
||
302 | 315 | * @param resource resource LDAP connexion resource, passed by reference. |
303 | 316 | * @return void |
304 | 317 | */ |
305 | -function ldap_set_version(&$resource) { |
|
318 | +function ldap_set_version(&$resource) |
|
319 | +{ |
|
306 | 320 | //error_log('Entering ldap_set_version(&$resource)',0); |
307 | 321 | global $ldap_version; |
308 | 322 | if ($ldap_version>2) { |
@@ -318,7 +332,8 @@ discard block |
||
318 | 332 | * @param boolean $ldap_bind |
319 | 333 | * @return boolean Status of the bind assignment. True for success, false for failure. |
320 | 334 | */ |
321 | -function ldap_handle_bind(&$ldap_handler,&$ldap_bind) { |
|
335 | +function ldap_handle_bind(&$ldap_handler,&$ldap_bind) |
|
336 | +{ |
|
322 | 337 | //error_log('Entering ldap_handle_bind(&$ldap_handler,&$ldap_bind)',0); |
323 | 338 | global $ldap_rdn,$ldap_pass, $extldap_config; |
324 | 339 | $ldap_rdn = $extldap_config['admin_dn']; |
@@ -347,7 +362,8 @@ discard block |
||
347 | 362 | * @see SortableTable#get_total_number_of_items() |
348 | 363 | * @author Mustapha Alouani |
349 | 364 | */ |
350 | -function ldap_get_users() { |
|
365 | +function ldap_get_users() |
|
366 | +{ |
|
351 | 367 | |
352 | 368 | global $ldap_basedn, $ldap_host, $ldap_port, $ldap_rdn, $ldap_pass, $ldap_search_dn, $extldap_user_correspondance; |
353 | 369 | |
@@ -361,7 +377,7 @@ discard block |
||
361 | 377 | if ($keyword_username != "") { |
362 | 378 | $ldap_query[] = str_replace('%username%', $keyword_username, $ldap_search_dn); |
363 | 379 | } else { |
364 | - if ($keyword_lastname!=""){ |
|
380 | + if ($keyword_lastname!="") { |
|
365 | 381 | $ldap_query[]="(".$extldap_user_correspondance['lastname']."=".$keyword_lastname."*)"; |
366 | 382 | } |
367 | 383 | if ($keyword_firstname!="") { |
@@ -372,9 +388,9 @@ discard block |
||
372 | 388 | $ldap_query[]="(employeeType=".$keyword_type.")"; |
373 | 389 | } |
374 | 390 | |
375 | - if (count($ldap_query)>1){ |
|
391 | + if (count($ldap_query)>1) { |
|
376 | 392 | $str_query ="(& "; |
377 | - foreach ($ldap_query as $query){ |
|
393 | + foreach ($ldap_query as $query) { |
|
378 | 394 | $str_query.=" $query"; |
379 | 395 | } |
380 | 396 | $str_query.=" )"; |
@@ -394,8 +410,9 @@ discard block |
||
394 | 410 | return $info; |
395 | 411 | |
396 | 412 | } else { |
397 | - if (count($ldap_query)!=0) |
|
398 | - Display :: display_error_message(get_lang('LDAPConnectionError')); |
|
413 | + if (count($ldap_query)!=0) { |
|
414 | + Display :: display_error_message(get_lang('LDAPConnectionError')); |
|
415 | + } |
|
399 | 416 | return array(); |
400 | 417 | } |
401 | 418 | } |
@@ -405,7 +422,8 @@ discard block |
||
405 | 422 | * @see SortableTable#get_total_number_of_items() |
406 | 423 | * @author Mustapha Alouani |
407 | 424 | */ |
408 | -function ldap_get_number_of_users() { |
|
425 | +function ldap_get_number_of_users() |
|
426 | +{ |
|
409 | 427 | $info = ldap_get_users(); |
410 | 428 | if (count($info)>0) { |
411 | 429 | return $info['count']; |
@@ -419,7 +437,8 @@ discard block |
||
419 | 437 | * @see SortableTable#get_table_data($from) |
420 | 438 | * @author Mustapha Alouani |
421 | 439 | */ |
422 | -function ldap_get_user_data($from, $number_of_items, $column, $direction) { |
|
440 | +function ldap_get_user_data($from, $number_of_items, $column, $direction) |
|
441 | +{ |
|
423 | 442 | |
424 | 443 | global $extldap_user_correspondance; |
425 | 444 | |
@@ -463,9 +482,10 @@ discard block |
||
463 | 482 | * @return string Some HTML-code with modify-buttons |
464 | 483 | * @author Mustapha Alouani |
465 | 484 | */ |
466 | -function modify_filter($user_id,$url_params, $row) { |
|
485 | +function modify_filter($user_id,$url_params, $row) |
|
486 | +{ |
|
467 | 487 | $query_string="id[]=".$row[0]; |
468 | - if (!empty($_GET['id_session'])){ |
|
488 | + if (!empty($_GET['id_session'])) { |
|
469 | 489 | $query_string .= '&id_session='.Security::remove_XSS($_GET['id_session']); |
470 | 490 | } |
471 | 491 | //$url_params_id="id=".$row[0]; |
@@ -478,13 +498,15 @@ discard block |
||
478 | 498 | * @param string username (and uid inside LDAP) |
479 | 499 | * @author Mustapha Alouani |
480 | 500 | */ |
481 | -function ldap_add_user($login) { |
|
501 | +function ldap_add_user($login) |
|
502 | +{ |
|
482 | 503 | if ($ldap_user = extldap_authenticate($login, 'nopass', true)) { |
483 | 504 | return extldap_add_user_by_array($ldap_user); |
484 | 505 | } |
485 | 506 | } |
486 | 507 | |
487 | -function ldap_add_user_by_array($data, $update_if_exists = true) { |
|
508 | +function ldap_add_user_by_array($data, $update_if_exists = true) |
|
509 | +{ |
|
488 | 510 | |
489 | 511 | $lastname = api_convert_encoding($data['sn'][0], api_get_system_encoding(), 'UTF-8'); |
490 | 512 | $firstname = api_convert_encoding($data['cn'][0], api_get_system_encoding(), 'UTF-8'); |
@@ -533,7 +555,8 @@ discard block |
||
533 | 555 | * @param string Course code |
534 | 556 | * @return void |
535 | 557 | */ |
536 | -function ldap_add_user_to_session($UserList, $id_session) { |
|
558 | +function ldap_add_user_to_session($UserList, $id_session) |
|
559 | +{ |
|
537 | 560 | |
538 | 561 | // Database Table Definitions |
539 | 562 | $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); |
@@ -588,7 +611,8 @@ discard block |
||
588 | 611 | " WHERE id='$id_session'"); |
589 | 612 | } |
590 | 613 | |
591 | -function syncro_users() { |
|
614 | +function syncro_users() |
|
615 | +{ |
|
592 | 616 | global $ldap_basedn, $ldap_host, $ldap_port, $ldap_rdn, $ldap_pass, $ldap_search_dn; |
593 | 617 | echo "Connecting ..."; |
594 | 618 | $ldap_connect = ldap_connect( $ldap_host, $ldap_port); |
@@ -78,16 +78,16 @@ discard block |
||
78 | 78 | // res=-1 -> the user does not exist in the ldap database |
79 | 79 | // res=1 -> invalid password (user does exist) |
80 | 80 | |
81 | - if ($res==1) { //WRONG PASSWORD |
|
81 | + if ($res == 1) { //WRONG PASSWORD |
|
82 | 82 | //$errorMessage = "LDAP User or password incorrect, try again.<br />"; |
83 | 83 | if (isset($log)) unset($log); if (isset($uid)) unset($uid); |
84 | 84 | $loginLdapSucces = false; |
85 | 85 | } |
86 | - if ($res==-1) { //WRONG USERNAME |
|
86 | + if ($res == -1) { //WRONG USERNAME |
|
87 | 87 | //$errorMessage = "LDAP User or password incorrect, try again.<br />"; |
88 | 88 | $login_ldap_success = false; |
89 | 89 | } |
90 | - if ($res==0) { //LOGIN & PASSWORD OK - SUCCES |
|
90 | + if ($res == 0) { //LOGIN & PASSWORD OK - SUCCES |
|
91 | 91 | //$errorMessage = "Successful login w/ LDAP.<br>"; |
92 | 92 | $login_ldap_success = true; |
93 | 93 | } |
@@ -103,30 +103,30 @@ discard block |
||
103 | 103 | * @author Stefan De Wannemacker |
104 | 104 | * @author Roan Embrechts |
105 | 105 | */ |
106 | -function ldap_find_user_info ($login) { |
|
106 | +function ldap_find_user_info($login) { |
|
107 | 107 | //error_log('Entering ldap_find_user_info('.$login.')',0); |
108 | 108 | global $ldap_host, $ldap_port, $ldap_basedn, $ldap_rdn, $ldap_pass, $ldap_search_dn; |
109 | 109 | // basic sequence with LDAP is connect, bind, search, |
110 | 110 | // interpret search result, close connection |
111 | 111 | |
112 | 112 | //echo "Connecting ..."; |
113 | - $ldap_connect = ldap_connect( $ldap_host, $ldap_port); |
|
113 | + $ldap_connect = ldap_connect($ldap_host, $ldap_port); |
|
114 | 114 | ldap_set_version($ldap_connect); |
115 | 115 | if ($ldap_connect) { |
116 | 116 | //echo " Connect to LDAP server successful "; |
117 | 117 | //echo "Binding ..."; |
118 | 118 | $ldap_bind = false; |
119 | - $ldap_bind_res = ldap_handle_bind($ldap_connect,$ldap_bind); |
|
119 | + $ldap_bind_res = ldap_handle_bind($ldap_connect, $ldap_bind); |
|
120 | 120 | if ($ldap_bind_res) { |
121 | 121 | //echo " LDAP bind successful... "; |
122 | 122 | //echo " Searching for uid... "; |
123 | 123 | // Search surname entry |
124 | 124 | //OLD: $sr=ldap_search($ldapconnect,"dc=rug, dc=ac, dc=be", "uid=$login"); |
125 | 125 | //echo "<p> ldapDc = '$LDAPbasedn' </p>"; |
126 | - if(!empty($ldap_search_dn)) { |
|
127 | - $sr=ldap_search($ldap_connect, $ldap_search_dn, "uid=$login"); |
|
126 | + if (!empty($ldap_search_dn)) { |
|
127 | + $sr = ldap_search($ldap_connect, $ldap_search_dn, "uid=$login"); |
|
128 | 128 | } else { |
129 | - $sr=ldap_search($ldap_connect, $ldap_basedn, "uid=$login"); |
|
129 | + $sr = ldap_search($ldap_connect, $ldap_basedn, "uid=$login"); |
|
130 | 130 | } |
131 | 131 | //echo " Search result is ".$sr; |
132 | 132 | //echo " Number of entries returned is ".ldap_count_entries($ldapconnect,$sr); |
@@ -173,25 +173,25 @@ discard block |
||
173 | 173 | $password1 = $ldap_pass_placeholder; |
174 | 174 | $official_code = ''; |
175 | 175 | |
176 | - define ("STUDENT",5); |
|
177 | - define ("COURSEMANAGER",1); |
|
176 | + define("STUDENT", 5); |
|
177 | + define("COURSEMANAGER", 1); |
|
178 | 178 | |
179 | 179 | $tutor_field = api_get_setting('ldap_filled_tutor_field'); |
180 | 180 | $tutor_value = api_get_setting('ldap_filled_tutor_field_value'); |
181 | - if(empty($tutor_field)) { |
|
181 | + if (empty($tutor_field)) { |
|
182 | 182 | $status = STUDENT; |
183 | 183 | } else { |
184 | - if(empty($tutor_value)) { |
|
184 | + if (empty($tutor_value)) { |
|
185 | 185 | //in this case, we are assuming that the admin didn't give a criteria |
186 | 186 | // so that if the field is not empty, it is a tutor |
187 | - if(!empty($info_array[$tutor_field])) { |
|
187 | + if (!empty($info_array[$tutor_field])) { |
|
188 | 188 | $status = COURSEMANAGER; |
189 | 189 | } else { |
190 | 190 | $status = STUDENT; |
191 | 191 | } |
192 | 192 | } else { |
193 | 193 | //the tutor_value is filled, so we need to check the contents of the LDAP field |
194 | - if (is_array($info_array[$tutor_field]) && in_array($tutor_value,$info_array[$tutor_field])) { |
|
194 | + if (is_array($info_array[$tutor_field]) && in_array($tutor_value, $info_array[$tutor_field])) { |
|
195 | 195 | $status = COURSEMANAGER; |
196 | 196 | } else { |
197 | 197 | $status = STUDENT; |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | if (empty($language)) { $language = 'english'; } |
209 | 209 | $_userId = UserManager::create_user($prenom, $nom, $status, |
210 | 210 | $email, $uname, $password, $official_code, |
211 | - $language,'', '', 'ldap'); |
|
211 | + $language, '', '', 'ldap'); |
|
212 | 212 | |
213 | 213 | //echo "new user added to Chamilo, id = $_userId"; |
214 | 214 | |
@@ -242,56 +242,56 @@ discard block |
||
242 | 242 | * @param string password given by user |
243 | 243 | * @return int 0 if authentication succeeded, 1 if password was incorrect, -1 if it didn't belong to LDAP |
244 | 244 | */ |
245 | -function ldap_authentication_check ($uname, $passwd) { |
|
245 | +function ldap_authentication_check($uname, $passwd) { |
|
246 | 246 | //error_log('Entering ldap_authentication_check('.$uname.','.$passwd.')',0); |
247 | - global $ldap_host, $ldap_port, $ldap_basedn, $ldap_host2, $ldap_port2,$ldap_rdn,$ldap_pass; |
|
247 | + global $ldap_host, $ldap_port, $ldap_basedn, $ldap_host2, $ldap_port2, $ldap_rdn, $ldap_pass; |
|
248 | 248 | //error_log('Entering ldap_authentication_check('.$uname.','.$passwd.')',0); |
249 | 249 | // Establish anonymous connection with LDAP server |
250 | 250 | // Etablissement de la connexion anonyme avec le serveur LDAP |
251 | - $ds=ldap_connect($ldap_host,$ldap_port); |
|
251 | + $ds = ldap_connect($ldap_host, $ldap_port); |
|
252 | 252 | ldap_set_version($ds); |
253 | 253 | |
254 | 254 | $test_bind = false; |
255 | - $test_bind_res = ldap_handle_bind($ds,$test_bind); |
|
255 | + $test_bind_res = ldap_handle_bind($ds, $test_bind); |
|
256 | 256 | //if problem, use the replica |
257 | - if ($test_bind_res===false) { |
|
258 | - $ds=ldap_connect($ldap_host2,$ldap_port2); |
|
257 | + if ($test_bind_res === false) { |
|
258 | + $ds = ldap_connect($ldap_host2, $ldap_port2); |
|
259 | 259 | ldap_set_version($ds); |
260 | 260 | } // else: error_log('Connected to server '.$ldap_host); |
261 | - if ($ds!==false) { |
|
261 | + if ($ds !== false) { |
|
262 | 262 | //Creation of filter containing values input by the user |
263 | 263 | // Here it might be necessary to use $filter="(samaccountName=$uname)"; - see http://support.chamilo.org/issues/4675 |
264 | - $filter="(uid=$uname)"; |
|
264 | + $filter = "(uid=$uname)"; |
|
265 | 265 | // Open anonymous LDAP connection |
266 | - $result=false; |
|
267 | - $ldap_bind_res = ldap_handle_bind($ds,$result); |
|
266 | + $result = false; |
|
267 | + $ldap_bind_res = ldap_handle_bind($ds, $result); |
|
268 | 268 | // Executing the search with the $filter parametr |
269 | 269 | //error_log('Searching for '.$filter.' on LDAP server',0); |
270 | - $sr=ldap_search($ds,$ldap_basedn,$filter); |
|
270 | + $sr = ldap_search($ds, $ldap_basedn, $filter); |
|
271 | 271 | $info = ldap_get_entries($ds, $sr); |
272 | - $dn=($info[0]["dn"]); |
|
272 | + $dn = ($info[0]["dn"]); |
|
273 | 273 | // debug !! echo"<br> dn = $dn<br> pass = $passwd<br>"; |
274 | 274 | // closing 1st connection |
275 | 275 | ldap_close($ds); |
276 | 276 | } |
277 | 277 | |
278 | 278 | // test the Distinguish Name from the 1st connection |
279 | - if ($dn=="") { |
|
280 | - return (-1); // doesn't belong to the addressbook |
|
279 | + if ($dn == "") { |
|
280 | + return (-1); // doesn't belong to the addressbook |
|
281 | 281 | } |
282 | 282 | //bug ldap.. if password empty, return 1! |
283 | - if ($passwd=="") { |
|
283 | + if ($passwd == "") { |
|
284 | 284 | return(1); |
285 | 285 | } |
286 | 286 | // Opening 2nd LDAP connection : Connection user for password check |
287 | - $ds=ldap_connect($ldap_host,$ldap_port); |
|
287 | + $ds = ldap_connect($ldap_host, $ldap_port); |
|
288 | 288 | ldap_set_version($ds); |
289 | 289 | if (!$test_bind) { |
290 | - $ds=ldap_connect($ldap_host2,$ldap_port2); |
|
290 | + $ds = ldap_connect($ldap_host2, $ldap_port2); |
|
291 | 291 | ldap_set_version($ds); |
292 | 292 | } |
293 | 293 | // return in case of wrong password connection error |
294 | - if (@ldap_bind( $ds, $dn , $passwd) === false) { |
|
294 | + if (@ldap_bind($ds, $dn, $passwd) === false) { |
|
295 | 295 | return (1); // invalid password |
296 | 296 | } else {// connection successfull |
297 | 297 | return (0); |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | function ldap_set_version(&$resource) { |
306 | 306 | //error_log('Entering ldap_set_version(&$resource)',0); |
307 | 307 | global $ldap_version; |
308 | - if ($ldap_version>2) { |
|
308 | + if ($ldap_version > 2) { |
|
309 | 309 | ldap_set_option($resource, LDAP_OPT_PROTOCOL_VERSION, 3); |
310 | 310 | //ok - don't do anything |
311 | 311 | //failure - should switch back to version 2 by default |
@@ -318,14 +318,14 @@ discard block |
||
318 | 318 | * @param boolean $ldap_bind |
319 | 319 | * @return boolean Status of the bind assignment. True for success, false for failure. |
320 | 320 | */ |
321 | -function ldap_handle_bind(&$ldap_handler,&$ldap_bind) { |
|
321 | +function ldap_handle_bind(&$ldap_handler, &$ldap_bind) { |
|
322 | 322 | //error_log('Entering ldap_handle_bind(&$ldap_handler,&$ldap_bind)',0); |
323 | - global $ldap_rdn,$ldap_pass, $extldap_config; |
|
323 | + global $ldap_rdn, $ldap_pass, $extldap_config; |
|
324 | 324 | $ldap_rdn = $extldap_config['admin_dn']; |
325 | 325 | $ldap_pass = $extldap_config['admin_password']; |
326 | 326 | if (!empty($ldap_rdn) and !empty($ldap_pass)) { |
327 | 327 | //error_log('Trying authenticated login :'.$ldap_rdn.'/'.$ldap_pass,0); |
328 | - $ldap_bind = ldap_bind($ldap_handler,$ldap_rdn,$ldap_pass); |
|
328 | + $ldap_bind = ldap_bind($ldap_handler, $ldap_rdn, $ldap_pass); |
|
329 | 329 | if (!$ldap_bind) { |
330 | 330 | //error_log('Authenticated login failed',0); |
331 | 331 | //try in anonymous mode, you never know... |
@@ -351,40 +351,40 @@ discard block |
||
351 | 351 | |
352 | 352 | global $ldap_basedn, $ldap_host, $ldap_port, $ldap_rdn, $ldap_pass, $ldap_search_dn, $extldap_user_correspondance; |
353 | 353 | |
354 | - $keyword_firstname = isset($_GET['keyword_firstname']) ? trim(Database::escape_string($_GET['keyword_firstname'])): ''; |
|
354 | + $keyword_firstname = isset($_GET['keyword_firstname']) ? trim(Database::escape_string($_GET['keyword_firstname'])) : ''; |
|
355 | 355 | $keyword_lastname = isset($_GET['keyword_lastname']) ? trim(Database::escape_string($_GET['keyword_lastname'])) : ''; |
356 | 356 | $keyword_username = isset($_GET['keyword_username']) ? trim(Database::escape_string($_GET['keyword_username'])) : ''; |
357 | 357 | $keyword_type = isset($_GET['keyword_type']) ? Database::escape_string($_GET['keyword_type']) : ''; |
358 | 358 | |
359 | - $ldap_query=array(); |
|
359 | + $ldap_query = array(); |
|
360 | 360 | |
361 | 361 | if ($keyword_username != "") { |
362 | 362 | $ldap_query[] = str_replace('%username%', $keyword_username, $ldap_search_dn); |
363 | 363 | } else { |
364 | - if ($keyword_lastname!=""){ |
|
365 | - $ldap_query[]="(".$extldap_user_correspondance['lastname']."=".$keyword_lastname."*)"; |
|
364 | + if ($keyword_lastname != "") { |
|
365 | + $ldap_query[] = "(".$extldap_user_correspondance['lastname']."=".$keyword_lastname."*)"; |
|
366 | 366 | } |
367 | - if ($keyword_firstname!="") { |
|
368 | - $ldap_query[]="(".$extldap_user_correspondance['firstname']."=".$keyword_firstname."*)"; |
|
367 | + if ($keyword_firstname != "") { |
|
368 | + $ldap_query[] = "(".$extldap_user_correspondance['firstname']."=".$keyword_firstname."*)"; |
|
369 | 369 | } |
370 | 370 | } |
371 | - if ($keyword_type !="" && $keyword_type !="all") { |
|
372 | - $ldap_query[]="(employeeType=".$keyword_type.")"; |
|
371 | + if ($keyword_type != "" && $keyword_type != "all") { |
|
372 | + $ldap_query[] = "(employeeType=".$keyword_type.")"; |
|
373 | 373 | } |
374 | 374 | |
375 | - if (count($ldap_query)>1){ |
|
376 | - $str_query ="(& "; |
|
377 | - foreach ($ldap_query as $query){ |
|
378 | - $str_query.=" $query"; |
|
375 | + if (count($ldap_query) > 1) { |
|
376 | + $str_query = "(& "; |
|
377 | + foreach ($ldap_query as $query) { |
|
378 | + $str_query .= " $query"; |
|
379 | 379 | } |
380 | - $str_query.=" )"; |
|
380 | + $str_query .= " )"; |
|
381 | 381 | } else { |
382 | - $str_query= count($ldap_query) > 0 ? "(".$ldap_query[0].")" : null; |
|
382 | + $str_query = count($ldap_query) > 0 ? "(".$ldap_query[0].")" : null; |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | $ds = ldap_connect($ldap_host, $ldap_port); |
386 | 386 | ldap_set_version($ds); |
387 | - if ($ds && count($ldap_query)>0) { |
|
387 | + if ($ds && count($ldap_query) > 0) { |
|
388 | 388 | $r = false; |
389 | 389 | $res = ldap_handle_bind($ds, $r); |
390 | 390 | //$sr = ldap_search($ds, "ou=test-ou,$ldap_basedn", $str_query); |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | return $info; |
395 | 395 | |
396 | 396 | } else { |
397 | - if (count($ldap_query)!=0) |
|
397 | + if (count($ldap_query) != 0) |
|
398 | 398 | Display :: display_error_message(get_lang('LDAPConnectionError')); |
399 | 399 | return array(); |
400 | 400 | } |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | */ |
408 | 408 | function ldap_get_number_of_users() { |
409 | 409 | $info = ldap_get_users(); |
410 | - if (count($info)>0) { |
|
410 | + if (count($info) > 0) { |
|
411 | 411 | return $info['count']; |
412 | 412 | } else { |
413 | 413 | return 0; |
@@ -427,9 +427,9 @@ discard block |
||
427 | 427 | $is_western_name_order = api_is_western_name_order(); |
428 | 428 | if (isset($_GET['submit'])) { |
429 | 429 | $info = ldap_get_users(); |
430 | - if ($info['count']>0) { |
|
431 | - for ($key = 0; $key < $info["count"]; $key ++) { |
|
432 | - $user=array(); |
|
430 | + if ($info['count'] > 0) { |
|
431 | + for ($key = 0; $key < $info["count"]; $key++) { |
|
432 | + $user = array(); |
|
433 | 433 | // Get uid from dn |
434 | 434 | //YW: this might be a variation between LDAP 2 and LDAP 3, but in LDAP 3, the uid is in |
435 | 435 | //the corresponding index of the array |
@@ -463,9 +463,9 @@ discard block |
||
463 | 463 | * @return string Some HTML-code with modify-buttons |
464 | 464 | * @author Mustapha Alouani |
465 | 465 | */ |
466 | -function modify_filter($user_id,$url_params, $row) { |
|
467 | - $query_string="id[]=".$row[0]; |
|
468 | - if (!empty($_GET['id_session'])){ |
|
466 | +function modify_filter($user_id, $url_params, $row) { |
|
467 | + $query_string = "id[]=".$row[0]; |
|
468 | + if (!empty($_GET['id_session'])) { |
|
469 | 469 | $query_string .= '&id_session='.Security::remove_XSS($_GET['id_session']); |
470 | 470 | } |
471 | 471 | //$url_params_id="id=".$row[0]; |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | $firstname = api_convert_encoding($data['cn'][0], api_get_system_encoding(), 'UTF-8'); |
491 | 491 | $email = $data['mail'][0]; |
492 | 492 | // Get uid from dn |
493 | - $dn_array=ldap_explode_dn($data['dn'],1); |
|
493 | + $dn_array = ldap_explode_dn($data['dn'], 1); |
|
494 | 494 | $username = $dn_array[0]; // uid is first key |
495 | 495 | $outab[] = $data['edupersonprimaryaffiliation'][0]; // Here, "student" |
496 | 496 | //$val = ldap_get_values_len($ds, $entry, "userPassword"); |
@@ -498,29 +498,29 @@ discard block |
||
498 | 498 | //$password = $val[0]; |
499 | 499 | // TODO the password, if encrypted at the source, will be encrypted twice, which makes it useless. Try to fix that. |
500 | 500 | $password = $data['userPassword'][0]; |
501 | - $structure=$data['edupersonprimaryorgunitdn'][0]; |
|
502 | - $array_structure=explode(",", $structure); |
|
503 | - $array_val=explode("=", $array_structure[0]); |
|
504 | - $etape=$array_val[1]; |
|
505 | - $array_val=explode("=", $array_structure[1]); |
|
506 | - $annee=$array_val[1]; |
|
501 | + $structure = $data['edupersonprimaryorgunitdn'][0]; |
|
502 | + $array_structure = explode(",", $structure); |
|
503 | + $array_val = explode("=", $array_structure[0]); |
|
504 | + $etape = $array_val[1]; |
|
505 | + $array_val = explode("=", $array_structure[1]); |
|
506 | + $annee = $array_val[1]; |
|
507 | 507 | // To ease management, we add the step-year (etape-annee) code |
508 | - $official_code=$etape."-".$annee; |
|
509 | - $auth_source='ldap'; |
|
508 | + $official_code = $etape."-".$annee; |
|
509 | + $auth_source = 'ldap'; |
|
510 | 510 | // No expiration date for students (recover from LDAP's shadow expiry) |
511 | - $expiration_date=''; |
|
512 | - $active=1; |
|
513 | - if(empty($status)){$status = 5;} |
|
514 | - if(empty($phone)){$phone = '';} |
|
515 | - if(empty($picture_uri)){$picture_uri = '';} |
|
511 | + $expiration_date = ''; |
|
512 | + $active = 1; |
|
513 | + if (empty($status)) {$status = 5; } |
|
514 | + if (empty($phone)) {$phone = ''; } |
|
515 | + if (empty($picture_uri)) {$picture_uri = ''; } |
|
516 | 516 | // Adding user |
517 | 517 | $user_id = 0; |
518 | 518 | if (UserManager::is_username_available($username)) { |
519 | - $user_id = UserManager::create_user($firstname,$lastname,$status,$email,$username,$password,$official_code,api_get_setting('platformLanguage'),$phone,$picture_uri,$auth_source,$expiration_date,$active); |
|
519 | + $user_id = UserManager::create_user($firstname, $lastname, $status, $email, $username, $password, $official_code, api_get_setting('platformLanguage'), $phone, $picture_uri, $auth_source, $expiration_date, $active); |
|
520 | 520 | } else { |
521 | 521 | if ($update_if_exists) { |
522 | 522 | $user = api_get_user_info($username); |
523 | - $user_id=$user['user_id']; |
|
523 | + $user_id = $user['user_id']; |
|
524 | 524 | UserManager::update_user($user_id, $firstname, $lastname, $username, null, null, $email, $status, $official_code, $phone, $picture_uri, $expiration_date, $active); |
525 | 525 | } |
526 | 526 | } |
@@ -537,21 +537,21 @@ discard block |
||
537 | 537 | |
538 | 538 | // Database Table Definitions |
539 | 539 | $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); |
540 | - $tbl_session_rel_class = Database::get_main_table(TABLE_MAIN_SESSION_CLASS); |
|
540 | + $tbl_session_rel_class = Database::get_main_table(TABLE_MAIN_SESSION_CLASS); |
|
541 | 541 | $tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); |
542 | 542 | $tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
543 | 543 | $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); |
544 | 544 | $tbl_user = Database::get_main_table(TABLE_MAIN_USER); |
545 | 545 | $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); |
546 | - $tbl_class = Database::get_main_table(TABLE_MAIN_CLASS); |
|
547 | - $tbl_class_user = Database::get_main_table(TABLE_MAIN_CLASS_USER); |
|
546 | + $tbl_class = Database::get_main_table(TABLE_MAIN_CLASS); |
|
547 | + $tbl_class_user = Database::get_main_table(TABLE_MAIN_CLASS_USER); |
|
548 | 548 | |
549 | 549 | $id_session = (int) $id_session; |
550 | 550 | // Once users are imported in the users base, we can assign them to the session |
551 | - $result=Database::query("SELECT c_id FROM $tbl_session_rel_course WHERE session_id ='$id_session'"); |
|
552 | - $CourseList=array(); |
|
553 | - while ($row=Database::fetch_array($result)) { |
|
554 | - $CourseList[]=$row['c_id']; |
|
551 | + $result = Database::query("SELECT c_id FROM $tbl_session_rel_course WHERE session_id ='$id_session'"); |
|
552 | + $CourseList = array(); |
|
553 | + while ($row = Database::fetch_array($result)) { |
|
554 | + $CourseList[] = $row['c_id']; |
|
555 | 555 | } |
556 | 556 | foreach ($CourseList as $enreg_course) { |
557 | 557 | foreach ($UserList as $enreg_user) { |
@@ -562,21 +562,21 @@ discard block |
||
562 | 562 | "('$id_session','$enreg_course','$enreg_user')"); |
563 | 563 | } |
564 | 564 | $sql = "SELECT COUNT(user_id) as nbUsers ". |
565 | - " FROM $tbl_session_rel_course_rel_user " . |
|
565 | + " FROM $tbl_session_rel_course_rel_user ". |
|
566 | 566 | " WHERE session_id='$id_session' ". |
567 | 567 | " AND c_id='$enreg_course'"; |
568 | 568 | $rs = Database::query($sql); |
569 | 569 | list($nbr_users) = Database::fetch_array($rs); |
570 | 570 | Database::query("UPDATE $tbl_session_rel_course ". |
571 | - " SET nbr_users=$nbr_users " . |
|
571 | + " SET nbr_users=$nbr_users ". |
|
572 | 572 | " WHERE session_id='$id_session' ". |
573 | 573 | " AND c_id='$enreg_course'"); |
574 | 574 | } |
575 | 575 | foreach ($UserList as $enreg_user) { |
576 | 576 | $enreg_user = (int) $enreg_user; |
577 | 577 | Database::query("INSERT IGNORE INTO $tbl_session_rel_user ". |
578 | - " (session_id, user_id, registered_at) " . |
|
579 | - " VALUES('$id_session','$enreg_user', '" . api_get_utc_datetime() . "')"); |
|
578 | + " (session_id, user_id, registered_at) ". |
|
579 | + " VALUES('$id_session','$enreg_user', '".api_get_utc_datetime()."')"); |
|
580 | 580 | } |
581 | 581 | // We update the number of users in the session |
582 | 582 | $sql = "SELECT COUNT(user_id) as nbUsers FROM $tbl_session_rel_user ". |
@@ -591,13 +591,13 @@ discard block |
||
591 | 591 | function syncro_users() { |
592 | 592 | global $ldap_basedn, $ldap_host, $ldap_port, $ldap_rdn, $ldap_pass, $ldap_search_dn; |
593 | 593 | echo "Connecting ..."; |
594 | - $ldap_connect = ldap_connect( $ldap_host, $ldap_port); |
|
594 | + $ldap_connect = ldap_connect($ldap_host, $ldap_port); |
|
595 | 595 | ldap_set_version($ldap_connect); |
596 | 596 | if ($ldap_connect) { |
597 | 597 | //echo " Connect to LDAP server successful "; |
598 | 598 | //echo "Binding ..."; |
599 | 599 | $ldap_bind = false; |
600 | - $ldap_bind_res = ldap_handle_bind($ldap_connect,$ldap_bind); |
|
600 | + $ldap_bind_res = ldap_handle_bind($ldap_connect, $ldap_bind); |
|
601 | 601 | if ($ldap_bind_res) { |
602 | 602 | //echo " LDAP bind successful... "; |
603 | 603 | //echo " Searching for uid... "; |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | //OLD: $sr=ldap_search($ldapconnect,"dc=rug, dc=ac, dc=be", "uid=$login"); |
606 | 606 | //echo "<p> ldapDc = '$LDAPbasedn' </p>"; |
607 | 607 | $all_user_query = "uid=*"; |
608 | - if(!empty($ldap_search_dn)) { |
|
608 | + if (!empty($ldap_search_dn)) { |
|
609 | 609 | $sr = ldap_search($ldap_connect, $ldap_search_dn, $all_user_query); |
610 | 610 | } else { |
611 | 611 | $sr = ldap_search($ldap_connect, $ldap_basedn, $all_user_query); |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | //echo " Number of entries returned is ".ldap_count_entries($ldapconnect,$sr); |
614 | 614 | //echo " Getting entries ..."; |
615 | 615 | $info = ldap_get_entries($ldap_connect, $sr); |
616 | - for ($key = 0; $key < $info['count']; $key ++) { |
|
616 | + for ($key = 0; $key < $info['count']; $key++) { |
|
617 | 617 | $user_id = ldap_add_user_by_array($info[$key], false); |
618 | 618 | if ($user_id) { |
619 | 619 | echo "User #$user_id created "; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @param string $rank |
95 | 95 | * |
96 | - * @return Question |
|
96 | + * @return Category |
|
97 | 97 | */ |
98 | 98 | public function setRank($rank) |
99 | 99 | { |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | /** |
202 | 202 | * Get questions |
203 | 203 | * |
204 | - * @return \Doctrine\Common\Collections\Collection |
|
204 | + * @return Question[] |
|
205 | 205 | */ |
206 | 206 | public function getQuestions() |
207 | 207 | { |
@@ -136,7 +136,7 @@ |
||
136 | 136 | ); |
137 | 137 | /** @var Category $category */ |
138 | 138 | foreach ($categories as $category) { |
139 | - $faq->addChild( |
|
139 | + $faq->addChild( |
|
140 | 140 | $category->getHeadline(), |
141 | 141 | array( |
142 | 142 | 'route' => 'faq', |