@@ -88,17 +88,26 @@ discard block |
||
88 | 88 | "; |
89 | 89 | } |
90 | 90 | |
91 | +/** |
|
92 | + * @param string $name |
|
93 | + */ |
|
91 | 94 | function item_xml($name, $val) { |
92 | 95 | if (!$val) $val = 0; |
93 | 96 | echo " <$name>$val</$name>\n"; |
94 | 97 | } |
95 | 98 | |
99 | +/** |
|
100 | + * @param string $name |
|
101 | + */ |
|
96 | 102 | function item_html($name, $val) { |
97 | 103 | $name = tra($name); |
98 | 104 | echo "<tr><td>$name</td><td>$val</td></tr>\n"; |
99 | 105 | //echo "<tr><td align=right>$name</td><td align=right>$val</td></tr>\n"; |
100 | 106 | } |
101 | 107 | |
108 | +/** |
|
109 | + * @param stdClass $x |
|
110 | + */ |
|
102 | 111 | function show_status_html($x) { |
103 | 112 | page_head(tra("Project status")); |
104 | 113 | $j = $x->jobs; |
@@ -190,6 +199,9 @@ discard block |
||
190 | 199 | page_tail(); |
191 | 200 | } |
192 | 201 | |
202 | +/** |
|
203 | + * @param stdClass $x |
|
204 | + */ |
|
193 | 205 | function show_status_xml($x) { |
194 | 206 | xml_header(); |
195 | 207 | echo "<server_status>\n<daemon_status>\n"; |
@@ -239,6 +251,11 @@ discard block |
||
239 | 251 | "; |
240 | 252 | } |
241 | 253 | |
254 | +/** |
|
255 | + * @param string $cmd |
|
256 | + * @param string $pidname |
|
257 | + * @param string $host |
|
258 | + */ |
|
242 | 259 | function local_daemon_running($cmd, $pidname, $host) { |
243 | 260 | if (!$pidname) { |
244 | 261 | $cmd = trim($cmd); |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | $avg = round($app->info->avg, 2); |
172 | 172 | $min = round($app->info->min, 2); |
173 | 173 | $max = round($app->info->max, 2); |
174 | - $x = $max?"$avg ($min - $max)":"---"; |
|
174 | + $x = $max ? "$avg ($min - $max)" : "---"; |
|
175 | 175 | $u = $app->info->users; |
176 | 176 | echo "<tr> |
177 | 177 | <td>$app->user_friendly_name</td> |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | $cmd = trim($cmd); |
245 | 245 | $x = explode(" ", $cmd); |
246 | 246 | $prog = $x[0]; |
247 | - $pidname = $prog . '.pid'; |
|
247 | + $pidname = $prog.'.pid'; |
|
248 | 248 | } |
249 | 249 | $path = "../../pid_$host/$pidname"; |
250 | 250 | if (is_file($path)) { |
@@ -285,12 +285,12 @@ discard block |
||
285 | 285 | } |
286 | 286 | $master_host = $u["host"]; |
287 | 287 | if ($config->www_host) { |
288 | - $web_host = trim((string) $config->www_host); |
|
288 | + $web_host = trim((string)$config->www_host); |
|
289 | 289 | } else { |
290 | 290 | $web_host = $main_host; |
291 | 291 | } |
292 | 292 | if ($config->sched_host) { |
293 | - $sched_host = trim((string) $config->sched_host); |
|
293 | + $sched_host = trim((string)$config->sched_host); |
|
294 | 294 | } else { |
295 | 295 | $sched_host = $main_host; |
296 | 296 | } |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | |
301 | 301 | // the upload and download servers are sort of daemons too |
302 | 302 | // |
303 | - $url = trim((string) $config->download_url); |
|
303 | + $url = trim((string)$config->download_url); |
|
304 | 304 | $u = parse_url($url); |
305 | 305 | $h = $u["host"]; |
306 | 306 | if ($h == $master_host) { |
@@ -312,14 +312,14 @@ discard block |
||
312 | 312 | } else { |
313 | 313 | $have_remote = true; |
314 | 314 | } |
315 | - $url = trim((string) $config->upload_url); |
|
315 | + $url = trim((string)$config->upload_url); |
|
316 | 316 | $u = parse_url($url); |
317 | 317 | $h = $u["host"]; |
318 | 318 | if ($h == $master_host) { |
319 | 319 | $y = new StdClass; |
320 | 320 | $y->cmd = "Upload server"; |
321 | 321 | $y->host = $h; |
322 | - $y->status = !file_exists("../../stop_upload");; |
|
322 | + $y->status = !file_exists("../../stop_upload"); ; |
|
323 | 323 | $local_daemons[] = $y; |
324 | 324 | } else { |
325 | 325 | $have_remote = true; |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | $y = new StdClass; |
332 | 332 | $y->cmd = "Scheduler"; |
333 | 333 | $y->host = $sched_host; |
334 | - $y->status = !file_exists("../../stop_sched");; |
|
334 | + $y->status = !file_exists("../../stop_sched"); ; |
|
335 | 335 | $local_daemons[] = $y; |
336 | 336 | } else { |
337 | 337 | $have_remote = true; |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | $disabled_daemons[] = $x; |
348 | 348 | continue; |
349 | 349 | } |
350 | - $host = $d->host?(string)$d->host:$main_host; |
|
350 | + $host = $d->host ? (string)$d->host : $main_host; |
|
351 | 351 | if ($host != $web_host) { |
352 | 352 | $have_remote = true; |
353 | 353 | continue; |
@@ -251,7 +251,7 @@ |
||
251 | 251 | $pid = file_get_contents($path); |
252 | 252 | if ($pid) { |
253 | 253 | $pid = trim($pid); |
254 | - $out = Array(); |
|
254 | + $out = array(); |
|
255 | 255 | exec("ps -ww $pid", $out); |
256 | 256 | foreach ($out as $y) { |
257 | 257 | if (strstr($y, (string)$pid)) return 1; |
@@ -25,6 +25,9 @@ |
||
25 | 25 | |
26 | 26 | check_get_args(array("mode")); |
27 | 27 | |
28 | +/** |
|
29 | + * @param string $mode |
|
30 | + */ |
|
28 | 31 | function filename($mode) { |
29 | 32 | switch ($mode) { |
30 | 33 | case 'host': return "cuda_hosts.dat"; |
@@ -92,7 +92,7 @@ |
||
92 | 92 | echo $x; |
93 | 93 | break; |
94 | 94 | } |
95 | - echo "</td><td align=right>".format_credit_large($y->credit),"</td><td align=right>$y->nresults</td></tr>\n"; |
|
95 | + echo "</td><td align=right>".format_credit_large($y->credit), "</td><td align=right>$y->nresults</td></tr>\n"; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | $mode = get_str('mode', true); |
@@ -37,6 +37,9 @@ discard block |
||
37 | 37 | return $n; |
38 | 38 | } |
39 | 39 | |
40 | +/** |
|
41 | + * @param integer $state |
|
42 | + */ |
|
40 | 43 | function show_all_link($batches, $state, $limit, $user, $app) { |
41 | 44 | $n = state_count($batches, $state); |
42 | 45 | if ($n > $limit) { |
@@ -269,6 +272,9 @@ discard block |
||
269 | 272 | page_tail(); |
270 | 273 | } |
271 | 274 | |
275 | +/** |
|
276 | + * @param null|integer $app_id |
|
277 | + */ |
|
272 | 278 | function check_admin_access($user, $app_id) { |
273 | 279 | $user_submit = BoincUserSubmit::lookup_userid($user->id); |
274 | 280 | if (!$user_submit) error_page("no access"); |
@@ -523,6 +529,9 @@ discard block |
||
523 | 529 | page_tail(); |
524 | 530 | } |
525 | 531 | |
532 | +/** |
|
533 | + * @param null|integer $state |
|
534 | + */ |
|
526 | 535 | function show_batches_in_state($batches, $state) { |
527 | 536 | switch ($state) { |
528 | 537 | case BATCH_STATE_IN_PROGRESS: |
@@ -369,7 +369,7 @@ |
||
369 | 369 | $text = "---"; |
370 | 370 | if ($batch->state == BATCH_STATE_COMPLETE) { |
371 | 371 | $y = '<font color="red">failed</font>'; |
372 | - } else { |
|
372 | + } else { |
|
373 | 373 | $y = "in progress"; |
374 | 374 | } |
375 | 375 | } |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | $wus = BoincWorkunit::enum("batch = $batch->id"); |
309 | 309 | $batch = get_batch_params($batch, $wus); |
310 | 310 | |
311 | - page_head("Batch $batch_id"); |
|
311 | + page_head("batch $batch_id"); |
|
312 | 312 | start_table(); |
313 | 313 | row2("name", $batch->name); |
314 | 314 | row2("application", $app->name); |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | $wu = BoincWorkunit::lookup_id($wuid); |
394 | 394 | if (!$wu) error_page("no such job"); |
395 | 395 | |
396 | - page_head("Job $wuid"); |
|
396 | + page_head("job $wuid"); |
|
397 | 397 | |
398 | 398 | echo " |
399 | 399 | <a href=workunit.php?wuid=$wuid>Workunit details</a> · |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | } |
324 | 324 | row2("GFLOP/hours, estimated", number_format(credit_to_gflop_hours($batch->credit_estimate), 2)); |
325 | 325 | row2("GFLOP/hours, actual", number_format(credit_to_gflop_hours($batch->credit_canonical), 2)); |
326 | - row2("Output File Size (MB)", number_format(batch_output_file_size($batch->id)/1e6,2)); |
|
326 | + row2("Output File Size (MB)", number_format(batch_output_file_size($batch->id)/1e6, 2)); |
|
327 | 327 | end_table(); |
328 | 328 | if (batch_output_file_size($batch->id) <= 1e8) { |
329 | 329 | $url = boinc_get_output_files_url($user, $batch_id); |
@@ -357,9 +357,9 @@ discard block |
||
357 | 357 | "Canonical instance<br><small>click to see result page on BOINC server</smallp>", |
358 | 358 | "Download Results" |
359 | 359 | ); |
360 | - foreach($wus as $wu) { |
|
360 | + foreach ($wus as $wu) { |
|
361 | 361 | $resultid = $wu->canonical_resultid; |
362 | - $durl = boinc_get_wu_output_files_url($user,$wu->id); |
|
362 | + $durl = boinc_get_wu_output_files_url($user, $wu->id); |
|
363 | 363 | if ($resultid) { |
364 | 364 | $x = "<a href=result.php?resultid=$resultid>$resultid</a>"; |
365 | 365 | $y = '<font color="green">completed</font>'; |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | $text = "---"; |
370 | 370 | if ($batch->state == BATCH_STATE_COMPLETE) { |
371 | 371 | $y = '<font color="red">failed</font>'; |
372 | - } else { |
|
372 | + } else { |
|
373 | 373 | $y = "in progress"; |
374 | 374 | } |
375 | 375 | } |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | $results = BoincResult::enum("workunitid=$wuid"); |
435 | 435 | $upload_dir = parse_config(get_config(), "<upload_dir>"); |
436 | 436 | $fanout = parse_config(get_config(), "<uldl_dir_fanout>"); |
437 | - foreach($results as $result) { |
|
437 | + foreach ($results as $result) { |
|
438 | 438 | echo "<tr> |
439 | 439 | <td><a href=result.php?resultid=$result->id>$result->id · $result->name </a></td> |
440 | 440 | <td>".state_string($result)."</td> |
@@ -57,6 +57,9 @@ |
||
57 | 57 | edit_form($user, $team, $forum, true); |
58 | 58 | } |
59 | 59 | |
60 | +/** |
|
61 | + * @param boolean $first |
|
62 | + */ |
|
60 | 63 | function edit_form($user, $team, $forum, $first) { |
61 | 64 | page_head(tra("Team Message Board")); |
62 | 65 | echo " |
@@ -30,6 +30,9 @@ |
||
30 | 30 | // list entries are of the form id => team, |
31 | 31 | // where team includes a field "refcnt". |
32 | 32 | // |
33 | +/** |
|
34 | + * @param integer $weight |
|
35 | + */ |
|
33 | 36 | function merge_lists($list1, &$list2, $weight) { |
34 | 37 | foreach($list1 as $team) { |
35 | 38 | $id = $team->id; |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | // where team includes a field "refcnt". |
32 | 32 | // |
33 | 33 | function merge_lists($list1, &$list2, $weight) { |
34 | - foreach($list1 as $team) { |
|
34 | + foreach ($list1 as $team) { |
|
35 | 35 | $id = $team->id; |
36 | 36 | if (array_key_exists($id, $list2)) { |
37 | 37 | $list2[$id]->refcnt += $weight; |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | if (defined("SHOW_NONVALIDATED_TEAMS")) { |
98 | 98 | $user = BoincUser::lookup_id($team->userid); |
99 | 99 | echo "<td>"; |
100 | - echo $user->email_validated?"Yes":"No"; |
|
100 | + echo $user->email_validated ? "Yes" : "No"; |
|
101 | 101 | echo "</td>\n"; |
102 | 102 | } |
103 | 103 | echo " |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | xml_header(); |
138 | 138 | echo "<teams>\n"; |
139 | 139 | sort_list($list); |
140 | - foreach($list as $team) { |
|
140 | + foreach ($list as $team) { |
|
141 | 141 | show_team_xml($team); |
142 | 142 | } |
143 | 143 | echo "</teams>\n"; |
@@ -164,14 +164,14 @@ discard block |
||
164 | 164 | merge_lists($list2, $list, 3); |
165 | 165 | $tried = true; |
166 | 166 | } |
167 | - if (strlen($params->country) && $params->country!='None') { |
|
167 | + if (strlen($params->country) && $params->country != 'None') { |
|
168 | 168 | $country = BoincDb::escape_string($params->country); |
169 | 169 | $list2 = get_teams("country = '$country'", $params->active); |
170 | 170 | //echo "<br>country matches: ",sizeof($list2); |
171 | 171 | merge_lists($list2, $list, 1); |
172 | 172 | $tried = true; |
173 | 173 | } |
174 | - if ($params->type and $params->type>1) { |
|
174 | + if ($params->type and $params->type > 1) { |
|
175 | 175 | $list2 = get_teams("type=$params->type", $params->active); |
176 | 176 | //echo "<br>type matches: ",sizeof($list2); |
177 | 177 | merge_lists($list2, $list, 2); |
@@ -9,9 +9,9 @@ discard block |
||
9 | 9 | * Implementation of hook_views_plugins(). |
10 | 10 | */ |
11 | 11 | function jump_views_plugins() { |
12 | - return array( |
|
12 | + return array( |
|
13 | 13 | 'style' => array( |
14 | - 'jump_views' => array( |
|
14 | + 'jump_views' => array( |
|
15 | 15 | 'title' => t('Jump menu'), |
16 | 16 | 'theme' => 'jump_views_plugin_style', |
17 | 17 | 'help' => t('Displays items as a select list jump menu.'), |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | 'uses fields' => TRUE, |
21 | 21 | 'uses options' => TRUE, |
22 | 22 | 'type' => 'normal', |
23 | - ), |
|
23 | + ), |
|
24 | 24 | ), |
25 | - ); |
|
25 | + ); |
|
26 | 26 | } |
@@ -16,9 +16,9 @@ |
||
16 | 16 | 'theme' => 'jump_views_plugin_style', |
17 | 17 | 'help' => t('Displays items as a select list jump menu.'), |
18 | 18 | 'handler' => 'jump_views_plugin_style', |
19 | - 'uses row plugin' => TRUE, |
|
20 | - 'uses fields' => TRUE, |
|
21 | - 'uses options' => TRUE, |
|
19 | + 'uses row plugin' => true, |
|
20 | + 'uses fields' => true, |
|
21 | + 'uses options' => true, |
|
22 | 22 | 'type' => 'normal', |
23 | 23 | ), |
24 | 24 | ), |
@@ -9,20 +9,20 @@ discard block |
||
9 | 9 | * Implementation of hook_views_default_views(). |
10 | 10 | */ |
11 | 11 | function jump_views_default_views() { |
12 | - $view = new view; |
|
13 | - $view->name = 'recent_nodes_jump_menu'; |
|
14 | - $view->description = 'Recent nodes in a jump menu.'; |
|
15 | - $view->tag = ''; |
|
16 | - $view->view_php = ''; |
|
17 | - $view->base_table = 'node'; |
|
18 | - $view->is_cacheable = FALSE; |
|
19 | - $view->api_version = 2; |
|
20 | - $view->disabled = TRUE; |
|
21 | - $handler = $view->new_display('default', 'Defaults', 'default'); |
|
22 | - $handler->override_option('fields', array( |
|
12 | + $view = new view; |
|
13 | + $view->name = 'recent_nodes_jump_menu'; |
|
14 | + $view->description = 'Recent nodes in a jump menu.'; |
|
15 | + $view->tag = ''; |
|
16 | + $view->view_php = ''; |
|
17 | + $view->base_table = 'node'; |
|
18 | + $view->is_cacheable = FALSE; |
|
19 | + $view->api_version = 2; |
|
20 | + $view->disabled = TRUE; |
|
21 | + $handler = $view->new_display('default', 'Defaults', 'default'); |
|
22 | + $handler->override_option('fields', array( |
|
23 | 23 | 'nid' => array( |
24 | - 'label' => 'Nid', |
|
25 | - 'alter' => array( |
|
24 | + 'label' => 'Nid', |
|
25 | + 'alter' => array( |
|
26 | 26 | 'alter_text' => 1, |
27 | 27 | 'text' => 'node/[nid]', |
28 | 28 | 'make_link' => 0, |
@@ -38,17 +38,17 @@ discard block |
||
38 | 38 | 'ellipsis' => 1, |
39 | 39 | 'strip_tags' => 0, |
40 | 40 | 'html' => 0, |
41 | - ), |
|
42 | - 'link_to_node' => 0, |
|
43 | - 'exclude' => 1, |
|
44 | - 'id' => 'nid', |
|
45 | - 'table' => 'node', |
|
46 | - 'field' => 'nid', |
|
47 | - 'relationship' => 'none', |
|
41 | + ), |
|
42 | + 'link_to_node' => 0, |
|
43 | + 'exclude' => 1, |
|
44 | + 'id' => 'nid', |
|
45 | + 'table' => 'node', |
|
46 | + 'field' => 'nid', |
|
47 | + 'relationship' => 'none', |
|
48 | 48 | ), |
49 | 49 | 'title' => array( |
50 | - 'label' => '', |
|
51 | - 'alter' => array( |
|
50 | + 'label' => '', |
|
51 | + 'alter' => array( |
|
52 | 52 | 'alter_text' => 0, |
53 | 53 | 'text' => '', |
54 | 54 | 'make_link' => 0, |
@@ -64,60 +64,60 @@ discard block |
||
64 | 64 | 'ellipsis' => 1, |
65 | 65 | 'strip_tags' => 0, |
66 | 66 | 'html' => 0, |
67 | - ), |
|
68 | - 'link_to_node' => 0, |
|
69 | - 'exclude' => 0, |
|
70 | - 'id' => 'title', |
|
71 | - 'table' => 'node', |
|
72 | - 'field' => 'title', |
|
73 | - 'relationship' => 'none', |
|
67 | + ), |
|
68 | + 'link_to_node' => 0, |
|
69 | + 'exclude' => 0, |
|
70 | + 'id' => 'title', |
|
71 | + 'table' => 'node', |
|
72 | + 'field' => 'title', |
|
73 | + 'relationship' => 'none', |
|
74 | 74 | ), |
75 | - )); |
|
76 | - $handler->override_option('sorts', array( |
|
75 | + )); |
|
76 | + $handler->override_option('sorts', array( |
|
77 | 77 | 'changed' => array( |
78 | - 'order' => 'DESC', |
|
79 | - 'granularity' => 'second', |
|
80 | - 'id' => 'changed', |
|
81 | - 'table' => 'node', |
|
82 | - 'field' => 'changed', |
|
83 | - 'relationship' => 'none', |
|
78 | + 'order' => 'DESC', |
|
79 | + 'granularity' => 'second', |
|
80 | + 'id' => 'changed', |
|
81 | + 'table' => 'node', |
|
82 | + 'field' => 'changed', |
|
83 | + 'relationship' => 'none', |
|
84 | 84 | ), |
85 | - )); |
|
86 | - $handler->override_option('filters', array( |
|
85 | + )); |
|
86 | + $handler->override_option('filters', array( |
|
87 | 87 | 'status_extra' => array( |
88 | - 'operator' => '=', |
|
89 | - 'value' => '', |
|
90 | - 'group' => '0', |
|
91 | - 'exposed' => FALSE, |
|
92 | - 'expose' => array( |
|
88 | + 'operator' => '=', |
|
89 | + 'value' => '', |
|
90 | + 'group' => '0', |
|
91 | + 'exposed' => FALSE, |
|
92 | + 'expose' => array( |
|
93 | 93 | 'operator' => FALSE, |
94 | 94 | 'label' => '', |
95 | - ), |
|
96 | - 'id' => 'status_extra', |
|
97 | - 'table' => 'node', |
|
98 | - 'field' => 'status_extra', |
|
99 | - 'relationship' => 'none', |
|
95 | + ), |
|
96 | + 'id' => 'status_extra', |
|
97 | + 'table' => 'node', |
|
98 | + 'field' => 'status_extra', |
|
99 | + 'relationship' => 'none', |
|
100 | 100 | ), |
101 | - )); |
|
102 | - $handler->override_option('access', array( |
|
101 | + )); |
|
102 | + $handler->override_option('access', array( |
|
103 | 103 | 'type' => 'none', |
104 | - )); |
|
105 | - $handler->override_option('cache', array( |
|
104 | + )); |
|
105 | + $handler->override_option('cache', array( |
|
106 | 106 | 'type' => 'none', |
107 | - )); |
|
108 | - $handler->override_option('style_plugin', 'jump_views'); |
|
109 | - $handler->override_option('style_options', array( |
|
107 | + )); |
|
108 | + $handler->override_option('style_plugin', 'jump_views'); |
|
109 | + $handler->override_option('style_options', array( |
|
110 | 110 | 'grouping' => '', |
111 | 111 | 'keys' => array( |
112 | - 'nid' => 'nid', |
|
113 | - 'title' => 0, |
|
112 | + 'nid' => 'nid', |
|
113 | + 'title' => 0, |
|
114 | 114 | ), |
115 | 115 | 'first_item' => 'Recent nodes', |
116 | - )); |
|
117 | - $handler = $view->new_display('block', 'Block', 'block_1'); |
|
118 | - $handler->override_option('block_description', ''); |
|
119 | - $handler->override_option('block_caching', -1); |
|
116 | + )); |
|
117 | + $handler = $view->new_display('block', 'Block', 'block_1'); |
|
118 | + $handler->override_option('block_description', ''); |
|
119 | + $handler->override_option('block_caching', -1); |
|
120 | 120 | |
121 | - $views[$view->name] = $view; |
|
122 | - return $views; |
|
121 | + $views[$view->name] = $view; |
|
122 | + return $views; |
|
123 | 123 | } |
@@ -15,9 +15,9 @@ discard block |
||
15 | 15 | $view->tag = ''; |
16 | 16 | $view->view_php = ''; |
17 | 17 | $view->base_table = 'node'; |
18 | - $view->is_cacheable = FALSE; |
|
18 | + $view->is_cacheable = false; |
|
19 | 19 | $view->api_version = 2; |
20 | - $view->disabled = TRUE; |
|
20 | + $view->disabled = true; |
|
21 | 21 | $handler = $view->new_display('default', 'Defaults', 'default'); |
22 | 22 | $handler->override_option('fields', array( |
23 | 23 | 'nid' => array( |
@@ -88,9 +88,9 @@ discard block |
||
88 | 88 | 'operator' => '=', |
89 | 89 | 'value' => '', |
90 | 90 | 'group' => '0', |
91 | - 'exposed' => FALSE, |
|
91 | + 'exposed' => false, |
|
92 | 92 | 'expose' => array( |
93 | - 'operator' => FALSE, |
|
93 | + 'operator' => false, |
|
94 | 94 | 'label' => '', |
95 | 95 | ), |
96 | 96 | 'id' => 'status_extra', |
@@ -7,11 +7,11 @@ discard block |
||
7 | 7 | |
8 | 8 | class jump_views_plugin_style extends views_plugin_style { |
9 | 9 | |
10 | - function render() { |
|
10 | + function render() { |
|
11 | 11 | // Build an array of field / field_alias pairs. |
12 | 12 | $this->field_map = array(); |
13 | 13 | foreach ($this->view->field as $field_name => $object) { |
14 | - $this-> field_map[$object->field_alias] = $field_name; |
|
14 | + $this-> field_map[$object->field_alias] = $field_name; |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | // $keys contains the fields used to build up the path. |
@@ -21,116 +21,116 @@ discard block |
||
21 | 21 | // callback. |
22 | 22 | $select = array(); |
23 | 23 | if (!empty($this->options['first_item'])) { |
24 | - $select[0] = $this->options['first_item']; |
|
24 | + $select[0] = $this->options['first_item']; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | foreach ($this->view->result as $row) { |
28 | - $select_key = array(); |
|
29 | - // For each field in the row, we first check if it's to be used |
|
30 | - // as part of the select key, then run views token replacement |
|
31 | - // on it. This allows for paths like node/n/revisions/6 to be built |
|
32 | - // easily. |
|
33 | - foreach ($row as $field => $value) { |
|
28 | + $select_key = array(); |
|
29 | + // For each field in the row, we first check if it's to be used |
|
30 | + // as part of the select key, then run views token replacement |
|
31 | + // on it. This allows for paths like node/n/revisions/6 to be built |
|
32 | + // easily. |
|
33 | + foreach ($row as $field => $value) { |
|
34 | 34 | if (in_array($this->field_map[$field], $keys)) { |
35 | - $field_object = $this->view->field[$this->field_map[$field]]; |
|
36 | - // Re-implementing some of the code from views_handler_field.inc |
|
37 | - // since we need to operate on $result, and to avoid using |
|
38 | - // a row style or templates. |
|
39 | - if (!empty($field_object->options['alter']['alter_text']) && !empty($field_object->options['alter']['text'])) { |
|
35 | + $field_object = $this->view->field[$this->field_map[$field]]; |
|
36 | + // Re-implementing some of the code from views_handler_field.inc |
|
37 | + // since we need to operate on $result, and to avoid using |
|
38 | + // a row style or templates. |
|
39 | + if (!empty($field_object->options['alter']['alter_text']) && !empty($field_object->options['alter']['text'])) { |
|
40 | 40 | $tokens = $this->get_render_tokens($this->field_map[$field], $row); |
41 | 41 | $value = $field_object->render_altered($tokens); |
42 | - } |
|
43 | - $select_key[] = $value; |
|
42 | + } |
|
43 | + $select_key[] = $value; |
|
44 | 44 | } |
45 | - } |
|
46 | - // For the value of the select, just use the output of the row, but strip |
|
47 | - // all markup first. |
|
48 | - $select_key = implode('/', $select_key); |
|
49 | - $raw_select_value = $this->row_plugin->render($row); |
|
50 | - $select_value = trim(html_entity_decode(strip_tags($raw_select_value), ENT_QUOTES)); |
|
51 | - $select[$select_key] = $select_value; |
|
45 | + } |
|
46 | + // For the value of the select, just use the output of the row, but strip |
|
47 | + // all markup first. |
|
48 | + $select_key = implode('/', $select_key); |
|
49 | + $raw_select_value = $this->row_plugin->render($row); |
|
50 | + $select_value = trim(html_entity_decode(strip_tags($raw_select_value), ENT_QUOTES)); |
|
51 | + $select[$select_key] = $select_value; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | return jump_quickly($select); |
55 | - } |
|
55 | + } |
|
56 | 56 | |
57 | - function option_definition() { |
|
57 | + function option_definition() { |
|
58 | 58 | $options = parent::option_definition(); |
59 | 59 | $options['keys'] = array('default' => array()); |
60 | 60 | $options['first_item'] = array('default' => ''); |
61 | 61 | return $options; |
62 | - } |
|
62 | + } |
|
63 | 63 | |
64 | - function options_form(&$form, $form_state) { |
|
64 | + function options_form(&$form, $form_state) { |
|
65 | 65 | parent::options_form($form, $form_state); |
66 | 66 | $handlers = $this->display->handler->get_handlers('field'); |
67 | 67 | if (empty($handlers)) { |
68 | - $form['error_markup'] = array( |
|
68 | + $form['error_markup'] = array( |
|
69 | 69 | '#value' => t('You need at least one field before you can configure your jump menu settings'), |
70 | 70 | '#prefix' => '<div class="error form-item description">', |
71 | 71 | '#suffix' => '</div>', |
72 | - ); |
|
73 | - return; |
|
72 | + ); |
|
73 | + return; |
|
74 | 74 | } |
75 | 75 | // Create an array of fields from the data we know. |
76 | 76 | foreach ($handlers as $field => $handler) { |
77 | - if ($label = $handler->label()) { |
|
77 | + if ($label = $handler->label()) { |
|
78 | 78 | $field_names[$field] = $label; |
79 | - } |
|
80 | - else { |
|
79 | + } |
|
80 | + else { |
|
81 | 81 | $field_names[$field] = $handler->ui_name(); |
82 | - } |
|
82 | + } |
|
83 | 83 | } |
84 | 84 | $form['keys'] = array( |
85 | - '#type' => 'checkboxes', |
|
86 | - '#title' => t('Select keys'), |
|
87 | - '#default_value' => $this->options['keys'], |
|
88 | - '#description' => t("These fields will be used to build the path for each row, used as the 'key' in the select options, and will be automatically separated by '/'"), |
|
89 | - '#options' => $field_names, |
|
85 | + '#type' => 'checkboxes', |
|
86 | + '#title' => t('Select keys'), |
|
87 | + '#default_value' => $this->options['keys'], |
|
88 | + '#description' => t("These fields will be used to build the path for each row, used as the 'key' in the select options, and will be automatically separated by '/'"), |
|
89 | + '#options' => $field_names, |
|
90 | 90 | ); |
91 | 91 | $form['first_item'] = array( |
92 | - '#type' => 'textfield', |
|
93 | - '#title' => 'First item', |
|
94 | - '#default_value' => $this->options['first_item'], |
|
95 | - '#description' => t('This will be used as the first item in your select list, for example <em>Choose one</em>'), |
|
92 | + '#type' => 'textfield', |
|
93 | + '#title' => 'First item', |
|
94 | + '#default_value' => $this->options['first_item'], |
|
95 | + '#description' => t('This will be used as the first item in your select list, for example <em>Choose one</em>'), |
|
96 | 96 | ); |
97 | - } |
|
97 | + } |
|
98 | 98 | |
99 | - /** |
|
100 | - * Get the 'render' tokens to use for advanced rendering. |
|
101 | - * |
|
102 | - * This runs through all of the fields and arguments that |
|
103 | - * are available and gets their values. This will then be |
|
104 | - * used in one giant str_replace(). |
|
105 | - * Slightly modified from views_handler_field.inc |
|
106 | - */ |
|
107 | - function get_render_tokens($field_name, $row) { |
|
99 | + /** |
|
100 | + * Get the 'render' tokens to use for advanced rendering. |
|
101 | + * |
|
102 | + * This runs through all of the fields and arguments that |
|
103 | + * are available and gets their values. This will then be |
|
104 | + * used in one giant str_replace(). |
|
105 | + * Slightly modified from views_handler_field.inc |
|
106 | + */ |
|
107 | + function get_render_tokens($field_name, $row) { |
|
108 | 108 | $tokens = array(); |
109 | 109 | if (!empty($this->view->build_info['substitutions'])) { |
110 | - $tokens = $this->view->build_info['substitutions']; |
|
110 | + $tokens = $this->view->build_info['substitutions']; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | $count = 0; |
114 | 114 | foreach ($this->view->display_handler->get_handlers('argument') as $arg => $handler) { |
115 | - $token = '%'. ++$count; |
|
116 | - if (!isset($tokens[$token])) { |
|
115 | + $token = '%'. ++$count; |
|
116 | + if (!isset($tokens[$token])) { |
|
117 | 117 | $tokens[$token] = ''; |
118 | - } |
|
118 | + } |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | // Now add replacements for our fields. |
122 | 122 | $options = array(); |
123 | 123 | $map = array_flip($this->field_map); |
124 | 124 | foreach ($this->view->display_handler->get_handlers('field') as $field => $handler) { |
125 | - $map = array_flip($this->field_map); |
|
126 | - if (isset($row->$map[$field])) { |
|
125 | + $map = array_flip($this->field_map); |
|
126 | + if (isset($row->$map[$field])) { |
|
127 | 127 | $tokens["[$field]"] = $row->$map[$field]; |
128 | - } |
|
129 | - else { |
|
128 | + } |
|
129 | + else { |
|
130 | 130 | $tokens["[$field]"] = ''; |
131 | - } |
|
131 | + } |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | return $tokens; |
135 | - } |
|
135 | + } |
|
136 | 136 | } |
@@ -112,7 +112,7 @@ |
||
112 | 112 | |
113 | 113 | $count = 0; |
114 | 114 | foreach ($this->view->display_handler->get_handlers('argument') as $arg => $handler) { |
115 | - $token = '%'. ++$count; |
|
115 | + $token = '%'.++$count; |
|
116 | 116 | if (!isset($tokens[$token])) { |
117 | 117 | $tokens[$token] = ''; |
118 | 118 | } |
@@ -76,8 +76,7 @@ discard block |
||
76 | 76 | foreach ($handlers as $field => $handler) { |
77 | 77 | if ($label = $handler->label()) { |
78 | 78 | $field_names[$field] = $label; |
79 | - } |
|
80 | - else { |
|
79 | + } else { |
|
81 | 80 | $field_names[$field] = $handler->ui_name(); |
82 | 81 | } |
83 | 82 | } |
@@ -125,8 +124,7 @@ discard block |
||
125 | 124 | $map = array_flip($this->field_map); |
126 | 125 | if (isset($row->$map[$field])) { |
127 | 126 | $tokens["[$field]"] = $row->$map[$field]; |
128 | - } |
|
129 | - else { |
|
127 | + } else { |
|
130 | 128 | $tokens["[$field]"] = ''; |
131 | 129 | } |
132 | 130 | } |
@@ -13,64 +13,64 @@ discard block |
||
13 | 13 | * Rewrite the taxonomy item on the node form. |
14 | 14 | */ |
15 | 15 | function _forum_access_node_form(&$form, &$form_state) { |
16 | - global $user; |
|
17 | - $vid = _forum_access_get_vid(); |
|
16 | + global $user; |
|
17 | + $vid = _forum_access_get_vid(); |
|
18 | 18 | |
19 | - if (!isset($form['taxonomy'][$vid]['#options'])) { |
|
19 | + if (!isset($form['taxonomy'][$vid]['#options'])) { |
|
20 | 20 | return; |
21 | - } |
|
21 | + } |
|
22 | 22 | |
23 | - // True node administrators are all powerful and do NOT get their forms rewritten here. |
|
24 | - if (user_access('administer nodes') && empty($user->_forum_access_moderator)) { |
|
23 | + // True node administrators are all powerful and do NOT get their forms rewritten here. |
|
24 | + if (user_access('administer nodes') && empty($user->_forum_access_moderator)) { |
|
25 | 25 | return; |
26 | - } |
|
26 | + } |
|
27 | 27 | |
28 | - $roles = array_keys($user->roles); |
|
29 | - $result = db_query("SELECT tid FROM {forum_access} WHERE rid IN (". db_placeholders($roles) .") AND grant_create = 1", $roles); |
|
30 | - while ($obj = db_fetch_object($result)) { |
|
28 | + $roles = array_keys($user->roles); |
|
29 | + $result = db_query("SELECT tid FROM {forum_access} WHERE rid IN (". db_placeholders($roles) .") AND grant_create = 1", $roles); |
|
30 | + while ($obj = db_fetch_object($result)) { |
|
31 | 31 | $tids[$obj->tid] = $obj->tid; |
32 | - } |
|
32 | + } |
|
33 | 33 | |
34 | - // Also get all forums they happen to be able to moderate. |
|
35 | - $result = db_query("SELECT a.number AS tid FROM {acl} a INNER JOIN {acl_user} u ON a.acl_id = u.acl_id WHERE a.module = 'forum_access' AND u.uid = %d", $user->uid); |
|
36 | - while ($obj = db_fetch_object($result)) { |
|
34 | + // Also get all forums they happen to be able to moderate. |
|
35 | + $result = db_query("SELECT a.number AS tid FROM {acl} a INNER JOIN {acl_user} u ON a.acl_id = u.acl_id WHERE a.module = 'forum_access' AND u.uid = %d", $user->uid); |
|
36 | + while ($obj = db_fetch_object($result)) { |
|
37 | 37 | $tids[$obj->tid] = $obj->tid; |
38 | - } |
|
38 | + } |
|
39 | 39 | |
40 | - // Ensure the forum they're trying to post to directly is allowed, otherwise |
|
41 | - // there will be much confusion. |
|
42 | - $forum_tid = arg(3); |
|
43 | - if (isset($forum_tid) && is_numeric($forum_tid) && !isset($tids[$forum_tid])) { |
|
40 | + // Ensure the forum they're trying to post to directly is allowed, otherwise |
|
41 | + // there will be much confusion. |
|
42 | + $forum_tid = arg(3); |
|
43 | + if (isset($forum_tid) && is_numeric($forum_tid) && !isset($tids[$forum_tid])) { |
|
44 | 44 | drupal_access_denied(); |
45 | 45 | module_invoke_all('exit'); |
46 | 46 | exit; |
47 | - } |
|
47 | + } |
|
48 | 48 | |
49 | - foreach ($form['taxonomy'][$vid]['#options'] as $tid => $name) { |
|
49 | + foreach ($form['taxonomy'][$vid]['#options'] as $tid => $name) { |
|
50 | 50 | if (!is_numeric($tid)) { |
51 | - $options[$tid] = $name; |
|
51 | + $options[$tid] = $name; |
|
52 | 52 | } |
53 | 53 | elseif (is_object($name)) { |
54 | - foreach ($name->option as $sub_tid => $sub_name) { |
|
54 | + foreach ($name->option as $sub_tid => $sub_name) { |
|
55 | 55 | if (!empty($tids[$sub_tid])) { |
56 | - $options[$tid]->option[$sub_tid] = $sub_name; |
|
56 | + $options[$tid]->option[$sub_tid] = $sub_name; |
|
57 | + } |
|
57 | 58 | } |
58 | - } |
|
59 | 59 | } |
60 | 60 | elseif ($tids[$tid]) { |
61 | - $options[$tid] = $name; |
|
61 | + $options[$tid] = $name; |
|
62 | + } |
|
62 | 63 | } |
63 | - } |
|
64 | 64 | |
65 | - if ($options) { |
|
65 | + if ($options) { |
|
66 | 66 | $form['taxonomy'][$vid]['#options'] = $options; |
67 | - } |
|
68 | - else { |
|
67 | + } |
|
68 | + else { |
|
69 | 69 | unset($form['taxonomy'][$vid]); |
70 | - } |
|
70 | + } |
|
71 | 71 | |
72 | - // Apply modifications for Moderators (by role or uid). |
|
73 | - if (!empty($user->_forum_access_moderator)) { |
|
72 | + // Apply modifications for Moderators (by role or uid). |
|
73 | + if (!empty($user->_forum_access_moderator)) { |
|
74 | 74 | // We gave this user the 'administer nodes' permission, which he doesn't |
75 | 75 | // normally have. Remove controls that should be reserved to true node |
76 | 76 | // administrators. |
@@ -78,31 +78,31 @@ discard block |
||
78 | 78 | $allowed_elements = variable_get('forum_access_allowed_node_edit_elements', array('nid', 'vid', 'uid', 'created', 'type', 'changed', 'title', 'shadow', 'body_field', 'revision_information', 'form_build_id', 'form_token', 'form_id', 'comment_settings', 'taxonomy', 'attachments')); |
79 | 79 | $allowed_options = variable_get('forum_access_allowed_node_edit_options', array('status', 'sticky', 'subscriptions_notify')); |
80 | 80 | foreach (element_children($form) as $key) { |
81 | - switch ($key) { |
|
81 | + switch ($key) { |
|
82 | 82 | case 'options': |
83 | 83 | foreach (element_children($form[$key]) as $key2) { |
84 | 84 | if (array_search($key2, $allowed_options) === FALSE) { |
85 | - $form[$key][$key2]['#access'] = FALSE; |
|
85 | + $form[$key][$key2]['#access'] = FALSE; |
|
86 | + } |
|
86 | 87 | } |
87 | - } |
|
88 | - break; |
|
88 | + break; |
|
89 | 89 | case 'buttons': |
90 | 90 | $tid = $form['taxonomy'][$vid]['#default_value'][0]; |
91 | - if (!forum_access_access($tid, 'update')) { |
|
91 | + if (!forum_access_access($tid, 'update')) { |
|
92 | 92 | $form['buttons']['submit']['#access'] = FALSE; |
93 | 93 | $form['buttons']['preview']['#access'] = FALSE; |
94 | - } |
|
95 | - if (!forum_access_access($tid, 'delete')) { |
|
94 | + } |
|
95 | + if (!forum_access_access($tid, 'delete')) { |
|
96 | 96 | $form['buttons']['delete']['#access'] = FALSE; |
97 | - } |
|
98 | - break; |
|
97 | + } |
|
98 | + break; |
|
99 | 99 | default: |
100 | 100 | if (array_search($key, $allowed_elements) === FALSE) { |
101 | 101 | $form[$key]['#access'] = FALSE; |
102 | - } |
|
103 | - } |
|
102 | + } |
|
103 | + } |
|
104 | + } |
|
104 | 105 | } |
105 | - } |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -114,18 +114,18 @@ discard block |
||
114 | 114 | * and sanitize the Administration options for users with Edit grants. |
115 | 115 | */ |
116 | 116 | function _forum_access_comment_form(&$form, &$form_state) { |
117 | - global $user; |
|
118 | - if ($user->uid != 1 && isset($form['nid']['#value'])) { |
|
117 | + global $user; |
|
118 | + if ($user->uid != 1 && isset($form['nid']['#value'])) { |
|
119 | 119 | $node = node_load($form['nid']['#value']); |
120 | 120 | if ($tid = _forum_access_get_tid($node)) { |
121 | - if (!forum_access_access($tid, 'comment_create')) { |
|
121 | + if (!forum_access_access($tid, 'comment_create')) { |
|
122 | 122 | switch (arg(0)) { |
123 | - case 'node': |
|
123 | + case 'node': |
|
124 | 124 | // Remove the in-line comment form, replace with text message to user. |
125 | 125 | $form = NULL; |
126 | - $form['from'] = array( |
|
127 | - '#type' => 'item', |
|
128 | - '#value' => 'You do not have permission to post comments in this forum.',); |
|
126 | + $form['from'] = array( |
|
127 | + '#type' => 'item', |
|
128 | + '#value' => 'You do not have permission to post comments in this forum.',); |
|
129 | 129 | break; |
130 | 130 | case 'comment': |
131 | 131 | if (arg(1)=='reply') { |
@@ -135,38 +135,38 @@ discard block |
||
135 | 135 | } |
136 | 136 | break; |
137 | 137 | }//switch arg(0) |
138 | - } |
|
139 | - else { |
|
138 | + } |
|
139 | + else { |
|
140 | 140 | if (isset($form['admin']) && !empty($user->_forum_access_moderator)) { |
141 | - foreach (element_children($form['admin']) as $key) { |
|
141 | + foreach (element_children($form['admin']) as $key) { |
|
142 | 142 | if ($key != 'status') { |
143 | - $form['admin'][$key]['#access'] = FALSE; |
|
143 | + $form['admin'][$key]['#access'] = FALSE; |
|
144 | 144 | } |
145 | - } |
|
145 | + } |
|
146 | + } |
|
146 | 147 | } |
147 | - } |
|
148 | 148 | } |
149 | - } |
|
149 | + } |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /* |
153 | 153 | * Give the user the 'administer nodes' and 'administer comments' permissions for this request. |
154 | 154 | */ |
155 | 155 | function _forum_access_enable_moderator() { |
156 | - global $user; |
|
157 | - $rid = _forum_access_get_moderator_rid(); |
|
158 | - $user->roles[$rid] = '(forum_access temporary)'; |
|
159 | - user_access('', NULL, TRUE); // clear the permissions cache to activate the new role |
|
156 | + global $user; |
|
157 | + $rid = _forum_access_get_moderator_rid(); |
|
158 | + $user->roles[$rid] = '(forum_access temporary)'; |
|
159 | + user_access('', NULL, TRUE); // clear the permissions cache to activate the new role |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /* |
163 | 163 | * Remove the moderator permissions. |
164 | 164 | */ |
165 | 165 | function _forum_access_disable_moderator() { |
166 | - global $user; |
|
167 | - $rid = _forum_access_get_moderator_rid(); |
|
168 | - unset($user->roles[$rid]); |
|
169 | - user_access('', NULL, TRUE); // clear the permissions cache to revert to normal |
|
166 | + global $user; |
|
167 | + $rid = _forum_access_get_moderator_rid(); |
|
168 | + unset($user->roles[$rid]); |
|
169 | + user_access('', NULL, TRUE); // clear the permissions cache to revert to normal |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /* |
@@ -174,26 +174,26 @@ discard block |
||
174 | 174 | * then create it. |
175 | 175 | */ |
176 | 176 | function _forum_access_get_moderator_rid($verbose = FALSE) { |
177 | - $rid = forum_access_query_moderator_rid(); |
|
178 | - if ($rid !== NULL) { |
|
177 | + $rid = forum_access_query_moderator_rid(); |
|
178 | + if ($rid !== NULL) { |
|
179 | 179 | if (db_result(db_query("SELECT COUNT(rid) FROM {role} WHERE rid = %d", $rid)) == 1) { |
180 | - return $rid; |
|
180 | + return $rid; |
|
181 | + } |
|
181 | 182 | } |
182 | - } |
|
183 | - module_load_include('admin.inc', 'forum_access'); |
|
184 | - return _forum_access_create_moderator_rid($verbose); |
|
183 | + module_load_include('admin.inc', 'forum_access'); |
|
184 | + return _forum_access_create_moderator_rid($verbose); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | /* |
188 | 188 | * Return the roles for forum_access_node_access_explain(). |
189 | 189 | */ |
190 | 190 | function _forum_access_get_all_roles() { |
191 | - $roles = user_roles(); |
|
192 | - $moderator_rid = forum_access_query_moderator_rid(); |
|
193 | - if (isset($roles[$moderator_rid])) { |
|
191 | + $roles = user_roles(); |
|
192 | + $moderator_rid = forum_access_query_moderator_rid(); |
|
193 | + if (isset($roles[$moderator_rid])) { |
|
194 | 194 | $roles[$moderator_rid] .= ' '. t('(!Forum_Access temporary role, does not need any grants.)', array('!Forum_Access' => 'Forum Access')); |
195 | - } |
|
196 | - return $roles; |
|
195 | + } |
|
196 | + return $roles; |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -201,42 +201,42 @@ discard block |
||
201 | 201 | * remove those that aren't accessible to the user (pre-D6.17). |
202 | 202 | */ |
203 | 203 | function _forum_access_preprocess_comment(&$variables) { |
204 | - global $user; |
|
205 | - if (!empty($user->_forum_access_moderator)) { |
|
204 | + global $user; |
|
205 | + if (!empty($user->_forum_access_moderator)) { |
|
206 | 206 | _forum_access_enable_moderator(); // this allows us to retrieve the comment links (without setting precedent!) |
207 | - } |
|
207 | + } |
|
208 | 208 | |
209 | - $tid = $variables['node']->tid; |
|
210 | - $links = module_invoke_all('link', 'comment', $variables['comment'], 0); |
|
211 | - if (!empty($user->_forum_access_moderator) && arg(0) == 'node' && arg(2) == NULL) { |
|
209 | + $tid = $variables['node']->tid; |
|
210 | + $links = module_invoke_all('link', 'comment', $variables['comment'], 0); |
|
211 | + if (!empty($user->_forum_access_moderator) && arg(0) == 'node' && arg(2) == NULL) { |
|
212 | 212 | _forum_access_disable_moderator(); |
213 | - } |
|
213 | + } |
|
214 | 214 | |
215 | - if (isset($links['comment_reply']) && (!preg_match('#<li class="[^"]*comment_reply[^"]*".*</li>#U', $variables['links']) || !user_access('post comments') || !forum_access_access($tid, 'comment_create', NULL, FALSE))) { |
|
215 | + if (isset($links['comment_reply']) && (!preg_match('#<li class="[^"]*comment_reply[^"]*".*</li>#U', $variables['links']) || !user_access('post comments') || !forum_access_access($tid, 'comment_create', NULL, FALSE))) { |
|
216 | 216 | unset($links['comment_reply']); |
217 | - } |
|
218 | - if (isset($links['comment_edit']) && !forum_access_access($tid, 'update', NULL, FALSE) && !comment_access('edit', $variables['comment'])) { |
|
217 | + } |
|
218 | + if (isset($links['comment_edit']) && !forum_access_access($tid, 'update', NULL, FALSE) && !comment_access('edit', $variables['comment'])) { |
|
219 | 219 | unset($links['comment_edit']); |
220 | - } |
|
221 | - if (isset($links['comment_delete']) && !forum_access_access($tid, 'delete', NULL, FALSE) && !user_access('administer comments')) { |
|
220 | + } |
|
221 | + if (isset($links['comment_delete']) && !forum_access_access($tid, 'delete', NULL, FALSE) && !user_access('administer comments')) { |
|
222 | 222 | unset($links['comment_delete']); |
223 | - } |
|
224 | - foreach (array_keys($links) as $link) { |
|
223 | + } |
|
224 | + foreach (array_keys($links) as $link) { |
|
225 | 225 | if (!in_array($link, array('comment_reply', 'comment_edit', 'comment_delete'))) { |
226 | - $link_preg_quote = preg_quote($link, '#'); |
|
227 | - if (!preg_match('#<li class="[^"]*'. $link_preg_quote .'[^"]*"(.|\n)*</li>#U', $variables['links'])) { |
|
226 | + $link_preg_quote = preg_quote($link, '#'); |
|
227 | + if (!preg_match('#<li class="[^"]*'. $link_preg_quote .'[^"]*"(.|\n)*</li>#U', $variables['links'])) { |
|
228 | 228 | unset($links[$link]); // eliminate possible additional unknown links that came in for 'administer_comments' |
229 | - } |
|
229 | + } |
|
230 | + } |
|
230 | 231 | } |
231 | - } |
|
232 | 232 | |
233 | - drupal_alter('link', $links, $variables['node'], $variables['comment']); |
|
233 | + drupal_alter('link', $links, $variables['node'], $variables['comment']); |
|
234 | 234 | |
235 | - if (empty($links)) { |
|
235 | + if (empty($links)) { |
|
236 | 236 | $links['comment_forbidden'] = array( |
237 | - 'title' => theme('comment_post_forbidden', $variables['node']), |
|
238 | - 'html' => TRUE, |
|
237 | + 'title' => theme('comment_post_forbidden', $variables['node']), |
|
238 | + 'html' => TRUE, |
|
239 | 239 | ); |
240 | - } |
|
241 | - $variables['links'] = theme('links', $links); |
|
240 | + } |
|
241 | + $variables['links'] = theme('links', $links); |
|
242 | 242 | } |
@@ -79,27 +79,27 @@ discard block |
||
79 | 79 | $allowed_options = variable_get('forum_access_allowed_node_edit_options', array('status', 'sticky', 'subscriptions_notify')); |
80 | 80 | foreach (element_children($form) as $key) { |
81 | 81 | switch ($key) { |
82 | - case 'options': |
|
83 | - foreach (element_children($form[$key]) as $key2) { |
|
84 | - if (array_search($key2, $allowed_options) === FALSE) { |
|
85 | - $form[$key][$key2]['#access'] = FALSE; |
|
86 | - } |
|
87 | - } |
|
88 | - break; |
|
89 | - case 'buttons': |
|
90 | - $tid = $form['taxonomy'][$vid]['#default_value'][0]; |
|
91 | - if (!forum_access_access($tid, 'update')) { |
|
92 | - $form['buttons']['submit']['#access'] = FALSE; |
|
93 | - $form['buttons']['preview']['#access'] = FALSE; |
|
94 | - } |
|
95 | - if (!forum_access_access($tid, 'delete')) { |
|
96 | - $form['buttons']['delete']['#access'] = FALSE; |
|
97 | - } |
|
98 | - break; |
|
99 | - default: |
|
100 | - if (array_search($key, $allowed_elements) === FALSE) { |
|
101 | - $form[$key]['#access'] = FALSE; |
|
82 | + case 'options': |
|
83 | + foreach (element_children($form[$key]) as $key2) { |
|
84 | + if (array_search($key2, $allowed_options) === FALSE) { |
|
85 | + $form[$key][$key2]['#access'] = FALSE; |
|
102 | 86 | } |
87 | + } |
|
88 | + break; |
|
89 | + case 'buttons': |
|
90 | + $tid = $form['taxonomy'][$vid]['#default_value'][0]; |
|
91 | + if (!forum_access_access($tid, 'update')) { |
|
92 | + $form['buttons']['submit']['#access'] = FALSE; |
|
93 | + $form['buttons']['preview']['#access'] = FALSE; |
|
94 | + } |
|
95 | + if (!forum_access_access($tid, 'delete')) { |
|
96 | + $form['buttons']['delete']['#access'] = FALSE; |
|
97 | + } |
|
98 | + break; |
|
99 | + default: |
|
100 | + if (array_search($key, $allowed_elements) === FALSE) { |
|
101 | + $form[$key]['#access'] = FALSE; |
|
102 | + } |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | } |
@@ -120,20 +120,20 @@ discard block |
||
120 | 120 | if ($tid = _forum_access_get_tid($node)) { |
121 | 121 | if (!forum_access_access($tid, 'comment_create')) { |
122 | 122 | switch (arg(0)) { |
123 | - case 'node': |
|
124 | - // Remove the in-line comment form, replace with text message to user. |
|
125 | - $form = NULL; |
|
126 | - $form['from'] = array( |
|
127 | - '#type' => 'item', |
|
128 | - '#value' => 'You do not have permission to post comments in this forum.',); |
|
129 | - break; |
|
130 | - case 'comment': |
|
131 | - if (arg(1)=='reply') { |
|
132 | - drupal_set_message(t("ERROR: You do not have permission to post comments in this forum."), 'error'); |
|
133 | - drupal_goto("node/$node->nid"); |
|
134 | - exit; |
|
135 | - } |
|
136 | - break; |
|
123 | + case 'node': |
|
124 | + // Remove the in-line comment form, replace with text message to user. |
|
125 | + $form = NULL; |
|
126 | + $form['from'] = array( |
|
127 | + '#type' => 'item', |
|
128 | + '#value' => 'You do not have permission to post comments in this forum.',); |
|
129 | + break; |
|
130 | + case 'comment': |
|
131 | + if (arg(1)=='reply') { |
|
132 | + drupal_set_message(t("ERROR: You do not have permission to post comments in this forum."), 'error'); |
|
133 | + drupal_goto("node/$node->nid"); |
|
134 | + exit; |
|
135 | + } |
|
136 | + break; |
|
137 | 137 | }//switch arg(0) |
138 | 138 | } |
139 | 139 | else { |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | } |
27 | 27 | |
28 | 28 | $roles = array_keys($user->roles); |
29 | - $result = db_query("SELECT tid FROM {forum_access} WHERE rid IN (". db_placeholders($roles) .") AND grant_create = 1", $roles); |
|
29 | + $result = db_query("SELECT tid FROM {forum_access} WHERE rid IN (".db_placeholders($roles).") AND grant_create = 1", $roles); |
|
30 | 30 | while ($obj = db_fetch_object($result)) { |
31 | 31 | $tids[$obj->tid] = $obj->tid; |
32 | 32 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | '#value' => 'You do not have permission to post comments in this forum.',); |
129 | 129 | break; |
130 | 130 | case 'comment': |
131 | - if (arg(1)=='reply') { |
|
131 | + if (arg(1) == 'reply') { |
|
132 | 132 | drupal_set_message(t("ERROR: You do not have permission to post comments in this forum."), 'error'); |
133 | 133 | drupal_goto("node/$node->nid"); |
134 | 134 | exit; |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | $roles = user_roles(); |
192 | 192 | $moderator_rid = forum_access_query_moderator_rid(); |
193 | 193 | if (isset($roles[$moderator_rid])) { |
194 | - $roles[$moderator_rid] .= ' '. t('(!Forum_Access temporary role, does not need any grants.)', array('!Forum_Access' => 'Forum Access')); |
|
194 | + $roles[$moderator_rid] .= ' '.t('(!Forum_Access temporary role, does not need any grants.)', array('!Forum_Access' => 'Forum Access')); |
|
195 | 195 | } |
196 | 196 | return $roles; |
197 | 197 | } |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | foreach (array_keys($links) as $link) { |
225 | 225 | if (!in_array($link, array('comment_reply', 'comment_edit', 'comment_delete'))) { |
226 | 226 | $link_preg_quote = preg_quote($link, '#'); |
227 | - if (!preg_match('#<li class="[^"]*'. $link_preg_quote .'[^"]*"(.|\n)*</li>#U', $variables['links'])) { |
|
227 | + if (!preg_match('#<li class="[^"]*'.$link_preg_quote.'[^"]*"(.|\n)*</li>#U', $variables['links'])) { |
|
228 | 228 | unset($links[$link]); // eliminate possible additional unknown links that came in for 'administer_comments' |
229 | 229 | } |
230 | 230 | } |
@@ -49,23 +49,20 @@ discard block |
||
49 | 49 | foreach ($form['taxonomy'][$vid]['#options'] as $tid => $name) { |
50 | 50 | if (!is_numeric($tid)) { |
51 | 51 | $options[$tid] = $name; |
52 | - } |
|
53 | - elseif (is_object($name)) { |
|
52 | + } elseif (is_object($name)) { |
|
54 | 53 | foreach ($name->option as $sub_tid => $sub_name) { |
55 | 54 | if (!empty($tids[$sub_tid])) { |
56 | 55 | $options[$tid]->option[$sub_tid] = $sub_name; |
57 | 56 | } |
58 | 57 | } |
59 | - } |
|
60 | - elseif ($tids[$tid]) { |
|
58 | + } elseif ($tids[$tid]) { |
|
61 | 59 | $options[$tid] = $name; |
62 | 60 | } |
63 | 61 | } |
64 | 62 | |
65 | 63 | if ($options) { |
66 | 64 | $form['taxonomy'][$vid]['#options'] = $options; |
67 | - } |
|
68 | - else { |
|
65 | + } else { |
|
69 | 66 | unset($form['taxonomy'][$vid]); |
70 | 67 | } |
71 | 68 | |
@@ -135,8 +132,7 @@ discard block |
||
135 | 132 | } |
136 | 133 | break; |
137 | 134 | }//switch arg(0) |
138 | - } |
|
139 | - else { |
|
135 | + } else { |
|
140 | 136 | if (isset($form['admin']) && !empty($user->_forum_access_moderator)) { |
141 | 137 | foreach (element_children($form['admin']) as $key) { |
142 | 138 | if ($key != 'status') { |
@@ -81,24 +81,24 @@ discard block |
||
81 | 81 | switch ($key) { |
82 | 82 | case 'options': |
83 | 83 | foreach (element_children($form[$key]) as $key2) { |
84 | - if (array_search($key2, $allowed_options) === FALSE) { |
|
85 | - $form[$key][$key2]['#access'] = FALSE; |
|
84 | + if (array_search($key2, $allowed_options) === false) { |
|
85 | + $form[$key][$key2]['#access'] = false; |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | break; |
89 | 89 | case 'buttons': |
90 | 90 | $tid = $form['taxonomy'][$vid]['#default_value'][0]; |
91 | 91 | if (!forum_access_access($tid, 'update')) { |
92 | - $form['buttons']['submit']['#access'] = FALSE; |
|
93 | - $form['buttons']['preview']['#access'] = FALSE; |
|
92 | + $form['buttons']['submit']['#access'] = false; |
|
93 | + $form['buttons']['preview']['#access'] = false; |
|
94 | 94 | } |
95 | 95 | if (!forum_access_access($tid, 'delete')) { |
96 | - $form['buttons']['delete']['#access'] = FALSE; |
|
96 | + $form['buttons']['delete']['#access'] = false; |
|
97 | 97 | } |
98 | 98 | break; |
99 | 99 | default: |
100 | - if (array_search($key, $allowed_elements) === FALSE) { |
|
101 | - $form[$key]['#access'] = FALSE; |
|
100 | + if (array_search($key, $allowed_elements) === false) { |
|
101 | + $form[$key]['#access'] = false; |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | switch (arg(0)) { |
123 | 123 | case 'node': |
124 | 124 | // Remove the in-line comment form, replace with text message to user. |
125 | - $form = NULL; |
|
125 | + $form = null; |
|
126 | 126 | $form['from'] = array( |
127 | 127 | '#type' => 'item', |
128 | 128 | '#value' => 'You do not have permission to post comments in this forum.',); |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | if (isset($form['admin']) && !empty($user->_forum_access_moderator)) { |
141 | 141 | foreach (element_children($form['admin']) as $key) { |
142 | 142 | if ($key != 'status') { |
143 | - $form['admin'][$key]['#access'] = FALSE; |
|
143 | + $form['admin'][$key]['#access'] = false; |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | } |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | global $user; |
157 | 157 | $rid = _forum_access_get_moderator_rid(); |
158 | 158 | $user->roles[$rid] = '(forum_access temporary)'; |
159 | - user_access('', NULL, TRUE); // clear the permissions cache to activate the new role |
|
159 | + user_access('', null, true); // clear the permissions cache to activate the new role |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /* |
@@ -166,16 +166,16 @@ discard block |
||
166 | 166 | global $user; |
167 | 167 | $rid = _forum_access_get_moderator_rid(); |
168 | 168 | unset($user->roles[$rid]); |
169 | - user_access('', NULL, TRUE); // clear the permissions cache to revert to normal |
|
169 | + user_access('', null, true); // clear the permissions cache to revert to normal |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /* |
173 | 173 | * Retrieve the rid of the Forum Moderator role; if the role does not exist, |
174 | 174 | * then create it. |
175 | 175 | */ |
176 | -function _forum_access_get_moderator_rid($verbose = FALSE) { |
|
176 | +function _forum_access_get_moderator_rid($verbose = false) { |
|
177 | 177 | $rid = forum_access_query_moderator_rid(); |
178 | - if ($rid !== NULL) { |
|
178 | + if ($rid !== null) { |
|
179 | 179 | if (db_result(db_query("SELECT COUNT(rid) FROM {role} WHERE rid = %d", $rid)) == 1) { |
180 | 180 | return $rid; |
181 | 181 | } |
@@ -208,17 +208,17 @@ discard block |
||
208 | 208 | |
209 | 209 | $tid = $variables['node']->tid; |
210 | 210 | $links = module_invoke_all('link', 'comment', $variables['comment'], 0); |
211 | - if (!empty($user->_forum_access_moderator) && arg(0) == 'node' && arg(2) == NULL) { |
|
211 | + if (!empty($user->_forum_access_moderator) && arg(0) == 'node' && arg(2) == null) { |
|
212 | 212 | _forum_access_disable_moderator(); |
213 | 213 | } |
214 | 214 | |
215 | - if (isset($links['comment_reply']) && (!preg_match('#<li class="[^"]*comment_reply[^"]*".*</li>#U', $variables['links']) || !user_access('post comments') || !forum_access_access($tid, 'comment_create', NULL, FALSE))) { |
|
215 | + if (isset($links['comment_reply']) && (!preg_match('#<li class="[^"]*comment_reply[^"]*".*</li>#U', $variables['links']) || !user_access('post comments') || !forum_access_access($tid, 'comment_create', null, false))) { |
|
216 | 216 | unset($links['comment_reply']); |
217 | 217 | } |
218 | - if (isset($links['comment_edit']) && !forum_access_access($tid, 'update', NULL, FALSE) && !comment_access('edit', $variables['comment'])) { |
|
218 | + if (isset($links['comment_edit']) && !forum_access_access($tid, 'update', null, false) && !comment_access('edit', $variables['comment'])) { |
|
219 | 219 | unset($links['comment_edit']); |
220 | 220 | } |
221 | - if (isset($links['comment_delete']) && !forum_access_access($tid, 'delete', NULL, FALSE) && !user_access('administer comments')) { |
|
221 | + if (isset($links['comment_delete']) && !forum_access_access($tid, 'delete', null, false) && !user_access('administer comments')) { |
|
222 | 222 | unset($links['comment_delete']); |
223 | 223 | } |
224 | 224 | foreach (array_keys($links) as $link) { |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | if (empty($links)) { |
236 | 236 | $links['comment_forbidden'] = array( |
237 | 237 | 'title' => theme('comment_post_forbidden', $variables['node']), |
238 | - 'html' => TRUE, |
|
238 | + 'html' => true, |
|
239 | 239 | ); |
240 | 240 | } |
241 | 241 | $variables['links'] = theme('links', $links); |