@@ -206,7 +206,7 @@ |
||
206 | 206 | * @return int |
207 | 207 | */ |
208 | 208 | function get_number_of_teachers() |
209 | - { |
|
209 | + { |
|
210 | 210 | return count($this->teachers); |
211 | 211 | } |
212 | 212 |
@@ -245,7 +245,7 @@ |
||
245 | 245 | * @return int |
246 | 246 | */ |
247 | 247 | function get_number_of_students() |
248 | - { |
|
248 | + { |
|
249 | 249 | return count($this->students); |
250 | 250 | } |
251 | 251 | } |
@@ -150,7 +150,8 @@ discard block |
||
150 | 150 | return $content; |
151 | 151 | } |
152 | 152 | |
153 | - public function get_students_content_html_for_drh() { |
|
153 | + public function get_students_content_html_for_drh() |
|
154 | + { |
|
154 | 155 | $attendance = new Attendance(); |
155 | 156 | $students = $this->students; |
156 | 157 | //$content = '<div style="margin:5px;">'; |
@@ -236,7 +237,7 @@ discard block |
||
236 | 237 | * @return int |
237 | 238 | */ |
238 | 239 | function get_number_of_students() |
239 | - { |
|
240 | + { |
|
240 | 241 | return count($this->students); |
241 | 242 | } |
242 | 243 | } |
@@ -108,8 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | function run() |
110 | 110 | { |
111 | - if (!$this->accept()) |
|
112 | - { |
|
111 | + if (!$this->accept()) { |
|
113 | 112 | return; |
114 | 113 | } |
115 | 114 | $this->display_header(); |
@@ -120,21 +119,15 @@ discard block |
||
120 | 119 | $action = self::get('action'); |
121 | 120 | |
122 | 121 | $has_content = !empty($search_term) || !empty($action); |
123 | - if ($has_content) |
|
124 | - { |
|
122 | + if ($has_content) { |
|
125 | 123 | echo '<div class="list">'; |
126 | - } |
|
127 | - else |
|
128 | - { |
|
124 | + } else { |
|
129 | 125 | echo '<div>'; |
130 | 126 | } |
131 | 127 | |
132 | - if (RegisterCourseWidget::factory()->run()) |
|
133 | - { |
|
128 | + if (RegisterCourseWidget::factory()->run()) { |
|
134 | 129 | $result = true; |
135 | - } |
|
136 | - else |
|
137 | - { |
|
130 | + } else { |
|
138 | 131 | $result = $this->action_display(); |
139 | 132 | } |
140 | 133 | |
@@ -148,8 +141,7 @@ discard block |
||
148 | 141 | { |
149 | 142 | $self = $_SERVER['PHP_SELF']; |
150 | 143 | $parameters = array(); |
151 | - if ($action) |
|
152 | - { |
|
144 | + if ($action) { |
|
153 | 145 | $parameters[self::PARAM_ACTION] = $action; |
154 | 146 | } |
155 | 147 | $parameters = implode('&', $parameters); |
@@ -165,8 +157,7 @@ discard block |
||
165 | 157 | global $charset; |
166 | 158 | |
167 | 159 | $search_term = self::post('search_term'); |
168 | - if ($search_term) |
|
169 | - { |
|
160 | + if ($search_term) { |
|
170 | 161 | $search_result_for_label = self::get_lang('SearchResultsFor'); |
171 | 162 | $search_term_html = htmlentities($search_term, ENT_QUOTES, $charset); |
172 | 163 | echo "<h5>$search_result_for_label $search_term_html</h5>"; |
@@ -275,8 +266,7 @@ discard block |
||
275 | 266 | |
276 | 267 | //Already subscribed |
277 | 268 | $code = $current_course['code']; |
278 | - if (isset($user_courses[$code])) |
|
279 | - { |
|
269 | + if (isset($user_courses[$code])) { |
|
280 | 270 | echo self::get_lang('AlreadySubscribed'); |
281 | 271 | return false; |
282 | 272 | } |
@@ -296,8 +286,7 @@ discard block |
||
296 | 286 | EOT; |
297 | 287 | |
298 | 288 | $search_term = $this->post('search_term'); |
299 | - if ($search_term) |
|
300 | - { |
|
289 | + if ($search_term) { |
|
301 | 290 | $search_term = Security::remove_XSS($search_term); |
302 | 291 | echo <<<EOT |
303 | 292 | <input type="hidden" name="search_course" value="1" /> |
@@ -324,19 +313,15 @@ discard block |
||
324 | 313 | */ |
325 | 314 | function retrieve_courses($search_term) |
326 | 315 | { |
327 | - if (empty($search_term)) |
|
328 | - { |
|
316 | + if (empty($search_term)) { |
|
329 | 317 | return array(); |
330 | 318 | } |
331 | 319 | $search_term = Database::escape_string($search_term); |
332 | 320 | $course_table = Database::get_main_table(TABLE_MAIN_COURSE); |
333 | 321 | |
334 | - if (api_is_anonymous()) |
|
335 | - { |
|
322 | + if (api_is_anonymous()) { |
|
336 | 323 | $course_fiter = 'visibility = ' . COURSE_VISIBILITY_OPEN_WORLD; |
337 | - } |
|
338 | - else |
|
339 | - { |
|
324 | + } else { |
|
340 | 325 | $course_fiter = 'visibility = ' . COURSE_VISIBILITY_OPEN_WORLD . ' OR '; |
341 | 326 | $course_fiter .= 'visibility = ' . COURSE_VISIBILITY_OPEN_PLATFORM . ' OR '; |
342 | 327 | $course_fiter .= '(visibility = ' . COURSE_VISIBILITY_REGISTERED . ' AND subscribe = 1)'; |
@@ -374,8 +359,7 @@ discard block |
||
374 | 359 | */ |
375 | 360 | function retrieve_user_courses($user_id = null) |
376 | 361 | { |
377 | - if (is_null($user_id)) |
|
378 | - { |
|
362 | + if (is_null($user_id)) { |
|
379 | 363 | global $_user; |
380 | 364 | $user_id = $_user['user_id']; |
381 | 365 | } |
@@ -423,8 +407,7 @@ discard block |
||
423 | 407 | */ |
424 | 408 | function filter_out_user_courses($courses) |
425 | 409 | { |
426 | - if (empty($courses)) |
|
427 | - { |
|
410 | + if (empty($courses)) { |
|
428 | 411 | return $courses; |
429 | 412 | } |
430 | 413 | |
@@ -432,8 +415,7 @@ discard block |
||
432 | 415 | $user_id = $_user['user_id']; |
433 | 416 | |
434 | 417 | $user_courses = $this->retrieve_user_courses($user_id); |
435 | - foreach ($user_courses as $key => $value) |
|
436 | - { |
|
418 | + foreach ($user_courses as $key => $value) { |
|
437 | 419 | unset($courses[$key]); |
438 | 420 | } |
439 | 421 | return $courses; |
@@ -15,7 +15,9 @@ |
||
15 | 15 | $hostName = api_get_path(WEB_PATH); |
16 | 16 | |
17 | 17 | define('DOKU_BASE', '/tmp'); |
18 | -function getSecurityToken() {}; |
|
18 | +function getSecurityToken() |
|
19 | +{ |
|
20 | +}; |
|
19 | 21 | |
20 | 22 | //close sesseion |
21 | 23 | session_write_close(); |
@@ -173,7 +173,8 @@ |
||
173 | 173 | $_configuration['vchamilo_web_root'] = "{$protocol}://".@$_SERVER['HTTP_HOST'].$contentPrefix; |
174 | 174 | |
175 | 175 | $_configuration['vchamilo_name'] = @$_SERVER['HTTP_HOST']; |
176 | - if (empty($_configuration['vchamilo_name'])) { // try again with another source if has failed |
|
176 | + if (empty($_configuration['vchamilo_name'])) { |
|
177 | +// try again with another source if has failed |
|
177 | 178 | $_configuration['vchamilo_name'] = "{$protocol}://".$_SERVER['SERVER_NAME']; |
178 | 179 | if ($_SERVER['SERVER_PORT'] != 80) { |
179 | 180 | $_configuration['vchamilo_name'] .= ':'.$_SERVER['SERVER_PORT']; |
@@ -47,7 +47,8 @@ discard block |
||
47 | 47 | * |
48 | 48 | * |
49 | 49 | */ |
50 | -function fire_vhost_cron($vhost) { |
|
50 | +function fire_vhost_cron($vhost) |
|
51 | +{ |
|
51 | 52 | global $VCRON; |
52 | 53 | |
53 | 54 | if ($VCRON->TRACE_ENABLE) { |
@@ -98,8 +99,8 @@ discard block |
||
98 | 99 | |
99 | 100 | if ($rawresponse === false) { |
100 | 101 | $error = curl_errno($ch) .':'. curl_error($ch); |
101 | - if ($VCRON->TRACE_ENABLE){ |
|
102 | - if ($CRONTRACE){ |
|
102 | + if ($VCRON->TRACE_ENABLE) { |
|
103 | + if ($CRONTRACE) { |
|
103 | 104 | fputs($CRONTRACE, "VCron start on $vhost->root_web : ".api_time_to_hms($timestamp_send)."\n" ); |
104 | 105 | fputs($CRONTRACE, "VCron Error : $error \n"); |
105 | 106 | fputs($CRONTRACE, "VCron stop on $vhost->root_web : $timestamp_receive\n#################\n\n" ); |
@@ -139,7 +140,8 @@ discard block |
||
139 | 140 | * |
140 | 141 | * |
141 | 142 | */ |
142 | -function exec_vhost_cron($vhost) { |
|
143 | +function exec_vhost_cron($vhost) |
|
144 | +{ |
|
143 | 145 | global $VCRON, $DB, $_configuration; |
144 | 146 | |
145 | 147 | if ($VCRON->TRACE_ENABLE) { |
@@ -227,7 +229,7 @@ discard block |
||
227 | 229 | |
228 | 230 | // Main execution sequence |
229 | 231 | |
230 | -if (!$vchamilos = Database::select('*', 'vchamilo', array(), 'all')){ |
|
232 | +if (!$vchamilos = Database::select('*', 'vchamilo', array(), 'all')) { |
|
231 | 233 | die("Nothing to do. No Vhosts"); |
232 | 234 | } |
233 | 235 | |
@@ -252,7 +254,7 @@ discard block |
||
252 | 254 | |
253 | 255 | die('Done.'); |
254 | 256 | } |
255 | - if ($vhost->id == api_get_setting('vchamilo_cron_lasthost', 'vchamilo')){ |
|
257 | + if ($vhost->id == api_get_setting('vchamilo_cron_lasthost', 'vchamilo')) { |
|
256 | 258 | $rr = 1; // take next one |
257 | 259 | } |
258 | 260 | } |
@@ -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 | } |
@@ -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); |