@@ -12,16 +12,16 @@ discard block |
||
12 | 12 | * @return array |
13 | 13 | */ |
14 | 14 | function jump_menu() { |
15 | - $items = array(); |
|
16 | - $items['admin/settings/jump'] = array( |
|
15 | + $items = array(); |
|
16 | + $items['admin/settings/jump'] = array( |
|
17 | 17 | 'title' => 'Jump Settings', |
18 | 18 | 'description' => 'Configure Jump module settings.', |
19 | 19 | 'page callback' => 'drupal_get_form', |
20 | 20 | 'page arguments' => array('jump_settings'), |
21 | 21 | 'access callback' => 'user_access', |
22 | 22 | 'access arguments' => array('administer menu'), |
23 | - ); |
|
24 | - return $items; |
|
23 | + ); |
|
24 | + return $items; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -30,13 +30,13 @@ discard block |
||
30 | 30 | * @return string |
31 | 31 | */ |
32 | 32 | function jump_settings() { |
33 | - $form['jump_activepageinmenu'] = array( |
|
33 | + $form['jump_activepageinmenu'] = array( |
|
34 | 34 | '#type' => 'checkbox', |
35 | 35 | '#title' => t('Show active page in menu.'), |
36 | 36 | '#default_value' => variable_get('jump_activepageinmenu', 1), |
37 | 37 | '#description' => t('This setting will force the jump menu to show the current page as the default selection in the jump menu when checked. If you have a menu option that you would always like displayed at the top of the menu, like <em>Select a menu item</em>, you will want to uncheck this. This setting controls this behavior for all jump menus sitewide. You can override this setting on a block-by-block basis.'), |
38 | - ); |
|
39 | - return system_settings_form($form); |
|
38 | + ); |
|
39 | + return system_settings_form($form); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -48,64 +48,64 @@ discard block |
||
48 | 48 | * @return array |
49 | 49 | */ |
50 | 50 | function jump_block($op = 'list', $delta = 0, $edit = array()) { |
51 | - switch ($op) { |
|
51 | + switch ($op) { |
|
52 | 52 | case 'list': |
53 | 53 | $blocks = array(); |
54 | - foreach (menu_get_menus() as $name => $title) { |
|
54 | + foreach (menu_get_menus() as $name => $title) { |
|
55 | 55 | $blocks['menu-' . $name] = array( |
56 | - 'info' => t('Jump menu: !menu', array('!menu' => $name)) |
|
56 | + 'info' => t('Jump menu: !menu', array('!menu' => $name)) |
|
57 | 57 | ); |
58 | - } |
|
58 | + } |
|
59 | 59 | |
60 | - $vocs = taxonomy_get_vocabularies(); |
|
61 | - foreach ($vocs as $vid => $vocabulary) { |
|
60 | + $vocs = taxonomy_get_vocabularies(); |
|
61 | + foreach ($vocs as $vid => $vocabulary) { |
|
62 | 62 | $blocks['taxo-' . $vid] = array( |
63 | - 'info' => t('Jump menu: !voc', array('!voc' => $vocabulary->name)) |
|
63 | + 'info' => t('Jump menu: !voc', array('!voc' => $vocabulary->name)) |
|
64 | 64 | ); |
65 | - } |
|
66 | - return $blocks; |
|
65 | + } |
|
66 | + return $blocks; |
|
67 | 67 | case 'configure': |
68 | 68 | $form = array(); |
69 | - $form['block_settings']['jump_activepageinmenu_' . $delta] = array( |
|
69 | + $form['block_settings']['jump_activepageinmenu_' . $delta] = array( |
|
70 | 70 | '#type' => 'checkbox', |
71 | 71 | '#title' => t('Show active page in jump menu.'), |
72 | 72 | '#default_value' => variable_get('jump_activepageinmenu_' . $delta, 1), |
73 | 73 | '#description' => t('This setting will force the jump menu to show the current page as the default selection in this block\'s jump menu.'), |
74 | - ); |
|
75 | - // Do the rest of the form additions in hook_form_alter() since we can't do ahah here. |
|
76 | - return $form; |
|
74 | + ); |
|
75 | + // Do the rest of the form additions in hook_form_alter() since we can't do ahah here. |
|
76 | + return $form; |
|
77 | 77 | case 'save': |
78 | 78 | variable_set('jump_activepageinmenu_' . $delta, $edit['jump_activepageinmenu_' . $delta]); |
79 | - variable_set('jump_use_js_' . $delta, $edit['jump_use_js_' . $delta]); |
|
80 | - variable_set('jump_add_select_' . $delta, $edit['jump_add_select_' . $delta]); |
|
81 | - variable_set('jump_add_select_text_' . $delta, $edit['jump_add_select_text_' . $delta]); |
|
82 | - break; |
|
79 | + variable_set('jump_use_js_' . $delta, $edit['jump_use_js_' . $delta]); |
|
80 | + variable_set('jump_add_select_' . $delta, $edit['jump_add_select_' . $delta]); |
|
81 | + variable_set('jump_add_select_text_' . $delta, $edit['jump_add_select_text_' . $delta]); |
|
82 | + break; |
|
83 | 83 | case 'view': |
84 | 84 | // The first 5 characters of $delta should be one of: |
85 | 85 | // menu- |
86 | 86 | // taxo- |
87 | 87 | $subject = ''; |
88 | - $jumpmenu_type = substr($delta, 0, 4); |
|
89 | - $jumpmenu_name = substr($delta, 5); |
|
90 | - $active = jump_get_active_setting($delta); |
|
91 | - if ($jumpmenu_type == 'menu') { |
|
88 | + $jumpmenu_type = substr($delta, 0, 4); |
|
89 | + $jumpmenu_name = substr($delta, 5); |
|
90 | + $active = jump_get_active_setting($delta); |
|
91 | + if ($jumpmenu_type == 'menu') { |
|
92 | 92 | $form = jump_quickly($jumpmenu_name, 'menu', $active); |
93 | 93 | |
94 | 94 | // Use the menu label as the default block subject |
95 | 95 | $menus = menu_get_menus(); |
96 | 96 | $subject = $menus[$jumpmenu_name]; |
97 | - } |
|
98 | - else if ($jumpmenu_type == 'taxo') { |
|
97 | + } |
|
98 | + else if ($jumpmenu_type == 'taxo') { |
|
99 | 99 | $form = jump_quickly($jumpmenu_name, 'taxo', $active); |
100 | 100 | |
101 | 101 | // Use the vocabulary name as the default block subject |
102 | 102 | $vocab = taxonomy_vocabulary_load($jumpmenu_name); |
103 | 103 | $subject = $vocab->name; |
104 | - } |
|
105 | - if (variable_get('jump_use_js_' . $delta, 0) === 1) drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js'); |
|
106 | - return array('subject' => $subject, 'content' => $form); |
|
107 | - break; |
|
108 | - } |
|
104 | + } |
|
105 | + if (variable_get('jump_use_js_' . $delta, 0) === 1) drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js'); |
|
106 | + return array('subject' => $subject, 'content' => $form); |
|
107 | + break; |
|
108 | + } |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -124,36 +124,36 @@ discard block |
||
124 | 124 | * @return array |
125 | 125 | */ |
126 | 126 | function jump_quickly($name = 'navigation', $type = 'menu', $active = -1, $override = '') { |
127 | - // Reconstruct the $delta |
|
128 | - $delta = $type . '-' . $name; |
|
129 | - if ($active === -1) { |
|
127 | + // Reconstruct the $delta |
|
128 | + $delta = $type . '-' . $name; |
|
129 | + if ($active === -1) { |
|
130 | 130 | $active = variable_get('jump_activepageinmenu', 1); |
131 | - } |
|
132 | - $menu_state = array( |
|
131 | + } |
|
132 | + $menu_state = array( |
|
133 | 133 | 'delta' => $delta, |
134 | 134 | 'active' => $active, |
135 | 135 | 'override' => $override |
136 | - ); |
|
136 | + ); |
|
137 | 137 | |
138 | - if (is_array($name)) { |
|
138 | + if (is_array($name)) { |
|
139 | 139 | $options = $name; |
140 | - } |
|
141 | - else { |
|
140 | + } |
|
141 | + else { |
|
142 | 142 | $options = array(); |
143 | 143 | if ($type == 'menu') { |
144 | - jump_menu_get_menu_options($options, $name); |
|
144 | + jump_menu_get_menu_options($options, $name); |
|
145 | 145 | } |
146 | 146 | elseif ($type == 'taxo') { |
147 | - jump_menu_get_taxo_options($options, $name); |
|
147 | + jump_menu_get_taxo_options($options, $name); |
|
148 | + } |
|
148 | 149 | } |
149 | - } |
|
150 | 150 | |
151 | - // Give each form on the page a unique id so we can handle multiple |
|
152 | - // jump forms... |
|
153 | - static $num_jump_forms = 0; |
|
154 | - $num_jump_forms++; |
|
151 | + // Give each form on the page a unique id so we can handle multiple |
|
152 | + // jump forms... |
|
153 | + static $num_jump_forms = 0; |
|
154 | + $num_jump_forms++; |
|
155 | 155 | |
156 | - return drupal_get_form('jump_quickly_form_' . $num_jump_forms, $options, $menu_state); |
|
156 | + return drupal_get_form('jump_quickly_form_' . $num_jump_forms, $options, $menu_state); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
@@ -165,43 +165,43 @@ discard block |
||
165 | 165 | * @return array |
166 | 166 | */ |
167 | 167 | function jump_quickly_form(&$form_state, $options, $menu_state) { |
168 | - $default = ''; |
|
169 | - if ($menu_state['active'] === 1) { |
|
168 | + $default = ''; |
|
169 | + if ($menu_state['active'] === 1) { |
|
170 | 170 | if (isset($options[$_GET['q']])) { |
171 | - $default = $_GET['q']; |
|
171 | + $default = $_GET['q']; |
|
172 | + } |
|
172 | 173 | } |
173 | - } |
|
174 | - if ($menu_state['override']) { |
|
174 | + if ($menu_state['override']) { |
|
175 | 175 | $default = $menu_state['override']; |
176 | - } |
|
176 | + } |
|
177 | 177 | |
178 | - $form = array(); |
|
179 | - $form['#submit'][] = 'jump_quickly_form_submit'; |
|
180 | - $form['#theme'] = 'jump_quickly_form'; |
|
181 | - $form['#attributes']['class'] = 'jump-quickly'; |
|
182 | - $form['jump_goto'] = array( |
|
178 | + $form = array(); |
|
179 | + $form['#submit'][] = 'jump_quickly_form_submit'; |
|
180 | + $form['#theme'] = 'jump_quickly_form'; |
|
181 | + $form['#attributes']['class'] = 'jump-quickly'; |
|
182 | + $form['jump_goto'] = array( |
|
183 | 183 | '#type' => 'select', |
184 | 184 | '#default_value' => $default, |
185 | 185 | '#options' => $options |
186 | - ); |
|
187 | - $form['submit'] = array( |
|
186 | + ); |
|
187 | + $form['submit'] = array( |
|
188 | 188 | '#type' => 'submit', |
189 | 189 | '#value' => t('Go') |
190 | - ); |
|
191 | - if (variable_get('jump_use_js_' . $menu_state['delta'], 0) === 1) { |
|
190 | + ); |
|
191 | + if (variable_get('jump_use_js_' . $menu_state['delta'], 0) === 1) { |
|
192 | 192 | // Give each menu a unique name. |
193 | 193 | $form['#attributes']['name'] = 'jumpquickly' . $menu_state['delta']; |
194 | 194 | $form['#attributes']['class'] .= ' js-enabled'; |
195 | 195 | // unset($form['submit']); |
196 | 196 | if (variable_get('jump_add_select_' . $menu_state['delta'], 0) === 1) { |
197 | - $form['jump_goto']['#attributes']['class'] = 'first-no-jump'; |
|
198 | - // Add the extra empty select option to the top of the array. |
|
199 | - $form['jump_goto']['#options'] = array('' => variable_get('jump_add_select_text_' . $menu_state['delta'], t('Select Option'))) + $options; |
|
200 | - $form['jump_goto']['#default_value'] = (array_key_exists($default, $options)) ? $default : ''; |
|
197 | + $form['jump_goto']['#attributes']['class'] = 'first-no-jump'; |
|
198 | + // Add the extra empty select option to the top of the array. |
|
199 | + $form['jump_goto']['#options'] = array('' => variable_get('jump_add_select_text_' . $menu_state['delta'], t('Select Option'))) + $options; |
|
200 | + $form['jump_goto']['#default_value'] = (array_key_exists($default, $options)) ? $default : ''; |
|
201 | + } |
|
201 | 202 | } |
202 | - } |
|
203 | 203 | |
204 | - return $form; |
|
204 | + return $form; |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -211,15 +211,15 @@ discard block |
||
211 | 211 | * @param array $form_state |
212 | 212 | */ |
213 | 213 | function jump_quickly_form_submit($form, &$form_state) { |
214 | - if (!empty($form_state['values']['jump_goto'])) { |
|
214 | + if (!empty($form_state['values']['jump_goto'])) { |
|
215 | 215 | $fragment = explode('#', $form_state['values']['jump_goto']); |
216 | 216 | if (isset($fragment[1])) { |
217 | - drupal_goto($fragment[0], NULL, $fragment[1]); |
|
217 | + drupal_goto($fragment[0], NULL, $fragment[1]); |
|
218 | 218 | } |
219 | 219 | else { |
220 | - drupal_goto($form_state['values']['jump_goto']); |
|
220 | + drupal_goto($form_state['values']['jump_goto']); |
|
221 | + } |
|
221 | 222 | } |
222 | - } |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
@@ -229,12 +229,12 @@ discard block |
||
229 | 229 | * @return string |
230 | 230 | */ |
231 | 231 | function theme_jump_quickly_form($form) { |
232 | - $output = '<div class="container-inline">'; |
|
233 | - $output .= drupal_render($form['jump_goto']); |
|
234 | - $output .= drupal_render($form['submit']); |
|
235 | - $output .= '</div>'; |
|
236 | - $output .= drupal_render($form); |
|
237 | - return $output; |
|
232 | + $output = '<div class="container-inline">'; |
|
233 | + $output .= drupal_render($form['jump_goto']); |
|
234 | + $output .= drupal_render($form['submit']); |
|
235 | + $output .= '</div>'; |
|
236 | + $output .= drupal_render($form); |
|
237 | + return $output; |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -244,15 +244,15 @@ discard block |
||
244 | 244 | * @param string $name |
245 | 245 | */ |
246 | 246 | function jump_menu_get_menu_options(&$options, $name) { |
247 | - $tree = menu_tree_page_data($name); |
|
248 | - $front = variable_get('site_frontpage', 'node'); |
|
249 | - foreach ($tree as $data) { |
|
247 | + $tree = menu_tree_page_data($name); |
|
248 | + $front = variable_get('site_frontpage', 'node'); |
|
249 | + foreach ($tree as $data) { |
|
250 | 250 | if (!$data['link']['hidden']) { |
251 | - $href = ($data['link']['href'] == '<front>') ? $front : $data['link']['href']; |
|
252 | - $href = (isset($data['link']['options']['fragment'])) ? $href . '#' . $data['link']['options']['fragment'] : $href; |
|
253 | - $options[$href] = $data['link']['title']; |
|
251 | + $href = ($data['link']['href'] == '<front>') ? $front : $data['link']['href']; |
|
252 | + $href = (isset($data['link']['options']['fragment'])) ? $href . '#' . $data['link']['options']['fragment'] : $href; |
|
253 | + $options[$href] = $data['link']['title']; |
|
254 | + } |
|
254 | 255 | } |
255 | - } |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -262,10 +262,10 @@ discard block |
||
262 | 262 | * @param integer $vid |
263 | 263 | */ |
264 | 264 | function jump_menu_get_taxo_options(&$options, $vid) { |
265 | - $tree = taxonomy_get_tree($vid); |
|
266 | - foreach ($tree as $term) { |
|
265 | + $tree = taxonomy_get_tree($vid); |
|
266 | + foreach ($tree as $term) { |
|
267 | 267 | $options[taxonomy_term_path($term)] = $term->name; |
268 | - } |
|
268 | + } |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | /** |
@@ -276,14 +276,14 @@ discard block |
||
276 | 276 | * @return array |
277 | 277 | */ |
278 | 278 | function jump_forms($form_id) { |
279 | - // Ensure we map a callback for our form and not something else |
|
280 | - $forms = array(); |
|
281 | - if (strpos($form_id, 'jump_quickly_form') === 0) { |
|
279 | + // Ensure we map a callback for our form and not something else |
|
280 | + $forms = array(); |
|
281 | + if (strpos($form_id, 'jump_quickly_form') === 0) { |
|
282 | 282 | // Let the forms API know where to get the form data corresponding |
283 | 283 | // to this form id. |
284 | 284 | $forms[$form_id] = array('callback' => 'jump_quickly_form'); |
285 | - } |
|
286 | - return $forms; |
|
285 | + } |
|
286 | + return $forms; |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | /** |
@@ -292,11 +292,11 @@ discard block |
||
292 | 292 | * @return array |
293 | 293 | */ |
294 | 294 | function jump_theme() { |
295 | - return array( |
|
295 | + return array( |
|
296 | 296 | 'jump_quickly_form' => array( |
297 | - 'arguments' => array('form') |
|
297 | + 'arguments' => array('form') |
|
298 | 298 | ) |
299 | - ); |
|
299 | + ); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | /** |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | * @param string $form_id |
309 | 309 | */ |
310 | 310 | function jump_form_alter(&$form, $form_state, $form_id) { |
311 | - switch ($form_id) { |
|
311 | + switch ($form_id) { |
|
312 | 312 | case 'block_admin_configure': |
313 | 313 | if ($form['module']['#value'] === 'jump' && function_exists('ahah_helper_register')) { |
314 | 314 | $delta = $form['delta']['#value']; |
@@ -317,45 +317,45 @@ discard block |
||
317 | 317 | $default_jump_add_select = (!isset($form_state['storage']['jump_add_select_' . $delta])) ? variable_get('jump_add_select_' . $delta, 0) : $form_state['storage']['jump_add_select_' . $delta]; |
318 | 318 | |
319 | 319 | $form['block_settings']['jump_wrapper'] = array( |
320 | - '#prefix' => '<div id="jump-wrapper">', |
|
321 | - '#suffix' => '</div>', |
|
322 | - '#type' => 'markup' |
|
320 | + '#prefix' => '<div id="jump-wrapper">', |
|
321 | + '#suffix' => '</div>', |
|
322 | + '#type' => 'markup' |
|
323 | 323 | ); |
324 | 324 | $form['block_settings']['jump_wrapper']['jump_use_js_' . $delta] = array( |
325 | - '#type' => 'checkbox', |
|
326 | - '#title' => t('Hide the submit button and use Javascript to automatically jump to the selected menu item'), |
|
327 | - '#default_value' => $default_jump_use_js, |
|
328 | - '#disabled' => ($default_jump_add_select === 1) ? TRUE : FALSE, |
|
329 | - '#ahah' => array( |
|
325 | + '#type' => 'checkbox', |
|
326 | + '#title' => t('Hide the submit button and use Javascript to automatically jump to the selected menu item'), |
|
327 | + '#default_value' => $default_jump_use_js, |
|
328 | + '#disabled' => ($default_jump_add_select === 1) ? TRUE : FALSE, |
|
329 | + '#ahah' => array( |
|
330 | 330 | 'event' => 'change', |
331 | 331 | 'path' => ahah_helper_path(array('block_settings', 'jump_wrapper')), |
332 | 332 | 'wrapper' => 'jump-wrapper', |
333 | - ), |
|
333 | + ), |
|
334 | 334 | ); |
335 | 335 | if ($default_jump_use_js === 1) { |
336 | - $form['block_settings']['jump_wrapper']['jump_add_select_' . $delta] = array( |
|
336 | + $form['block_settings']['jump_wrapper']['jump_add_select_' . $delta] = array( |
|
337 | 337 | '#type' => 'checkbox', |
338 | 338 | '#title' => t('Add an empty select option into the list of options'), |
339 | 339 | '#default_value' => $default_jump_add_select, |
340 | 340 | '#weight' => 1, |
341 | 341 | '#ahah' => array( |
342 | - 'event' => 'change', |
|
343 | - 'path' => ahah_helper_path(array('block_settings', 'jump_wrapper')), |
|
344 | - 'wrapper' => 'jump-wrapper', |
|
342 | + 'event' => 'change', |
|
343 | + 'path' => ahah_helper_path(array('block_settings', 'jump_wrapper')), |
|
344 | + 'wrapper' => 'jump-wrapper', |
|
345 | 345 | ), |
346 | - ); |
|
347 | - if ($default_jump_add_select === 1) { |
|
346 | + ); |
|
347 | + if ($default_jump_add_select === 1) { |
|
348 | 348 | $form['block_settings']['jump_wrapper']['jump_add_select_text_' . $delta] = array( |
349 | - '#type' => 'textfield', |
|
350 | - '#title' => t('Text to use for the empty select option'), |
|
351 | - '#default_value' => variable_get('jump_add_select_text_' . $delta, t('Select Option')), |
|
352 | - '#weight' => 2 |
|
349 | + '#type' => 'textfield', |
|
350 | + '#title' => t('Text to use for the empty select option'), |
|
351 | + '#default_value' => variable_get('jump_add_select_text_' . $delta, t('Select Option')), |
|
352 | + '#weight' => 2 |
|
353 | 353 | ); |
354 | - } |
|
354 | + } |
|
355 | 355 | } |
356 | - } |
|
357 | - break; |
|
358 | - } |
|
356 | + } |
|
357 | + break; |
|
358 | + } |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | /** |
@@ -365,16 +365,16 @@ discard block |
||
365 | 365 | * @return integer |
366 | 366 | */ |
367 | 367 | function jump_get_active_setting($delta) { |
368 | - $active_site_default = variable_get('jump_activepageinmenu', 1); |
|
369 | - $active = variable_get('jump_activepageinmenu_' . $delta, $active_site_default); |
|
370 | - return $active; |
|
368 | + $active_site_default = variable_get('jump_activepageinmenu', 1); |
|
369 | + $active = variable_get('jump_activepageinmenu_' . $delta, $active_site_default); |
|
370 | + return $active; |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | /** |
374 | 374 | * Implementation of hook_views_api(). |
375 | 375 | */ |
376 | 376 | function jump_views_api() { |
377 | - return array( |
|
377 | + return array( |
|
378 | 378 | 'api' => 2, |
379 | - ); |
|
379 | + ); |
|
380 | 380 | } |
@@ -49,62 +49,62 @@ discard block |
||
49 | 49 | */ |
50 | 50 | function jump_block($op = 'list', $delta = 0, $edit = array()) { |
51 | 51 | switch ($op) { |
52 | - case 'list': |
|
53 | - $blocks = array(); |
|
54 | - foreach (menu_get_menus() as $name => $title) { |
|
55 | - $blocks['menu-' . $name] = array( |
|
56 | - 'info' => t('Jump menu: !menu', array('!menu' => $name)) |
|
57 | - ); |
|
58 | - } |
|
52 | + case 'list': |
|
53 | + $blocks = array(); |
|
54 | + foreach (menu_get_menus() as $name => $title) { |
|
55 | + $blocks['menu-' . $name] = array( |
|
56 | + 'info' => t('Jump menu: !menu', array('!menu' => $name)) |
|
57 | + ); |
|
58 | + } |
|
59 | 59 | |
60 | - $vocs = taxonomy_get_vocabularies(); |
|
61 | - foreach ($vocs as $vid => $vocabulary) { |
|
62 | - $blocks['taxo-' . $vid] = array( |
|
63 | - 'info' => t('Jump menu: !voc', array('!voc' => $vocabulary->name)) |
|
64 | - ); |
|
65 | - } |
|
66 | - return $blocks; |
|
67 | - case 'configure': |
|
68 | - $form = array(); |
|
69 | - $form['block_settings']['jump_activepageinmenu_' . $delta] = array( |
|
70 | - '#type' => 'checkbox', |
|
71 | - '#title' => t('Show active page in jump menu.'), |
|
72 | - '#default_value' => variable_get('jump_activepageinmenu_' . $delta, 1), |
|
73 | - '#description' => t('This setting will force the jump menu to show the current page as the default selection in this block\'s jump menu.'), |
|
60 | + $vocs = taxonomy_get_vocabularies(); |
|
61 | + foreach ($vocs as $vid => $vocabulary) { |
|
62 | + $blocks['taxo-' . $vid] = array( |
|
63 | + 'info' => t('Jump menu: !voc', array('!voc' => $vocabulary->name)) |
|
74 | 64 | ); |
75 | - // Do the rest of the form additions in hook_form_alter() since we can't do ahah here. |
|
76 | - return $form; |
|
77 | - case 'save': |
|
78 | - variable_set('jump_activepageinmenu_' . $delta, $edit['jump_activepageinmenu_' . $delta]); |
|
79 | - variable_set('jump_use_js_' . $delta, $edit['jump_use_js_' . $delta]); |
|
80 | - variable_set('jump_add_select_' . $delta, $edit['jump_add_select_' . $delta]); |
|
81 | - variable_set('jump_add_select_text_' . $delta, $edit['jump_add_select_text_' . $delta]); |
|
82 | - break; |
|
83 | - case 'view': |
|
84 | - // The first 5 characters of $delta should be one of: |
|
85 | - // menu- |
|
86 | - // taxo- |
|
87 | - $subject = ''; |
|
88 | - $jumpmenu_type = substr($delta, 0, 4); |
|
89 | - $jumpmenu_name = substr($delta, 5); |
|
90 | - $active = jump_get_active_setting($delta); |
|
91 | - if ($jumpmenu_type == 'menu') { |
|
92 | - $form = jump_quickly($jumpmenu_name, 'menu', $active); |
|
65 | + } |
|
66 | + return $blocks; |
|
67 | + case 'configure': |
|
68 | + $form = array(); |
|
69 | + $form['block_settings']['jump_activepageinmenu_' . $delta] = array( |
|
70 | + '#type' => 'checkbox', |
|
71 | + '#title' => t('Show active page in jump menu.'), |
|
72 | + '#default_value' => variable_get('jump_activepageinmenu_' . $delta, 1), |
|
73 | + '#description' => t('This setting will force the jump menu to show the current page as the default selection in this block\'s jump menu.'), |
|
74 | + ); |
|
75 | + // Do the rest of the form additions in hook_form_alter() since we can't do ahah here. |
|
76 | + return $form; |
|
77 | + case 'save': |
|
78 | + variable_set('jump_activepageinmenu_' . $delta, $edit['jump_activepageinmenu_' . $delta]); |
|
79 | + variable_set('jump_use_js_' . $delta, $edit['jump_use_js_' . $delta]); |
|
80 | + variable_set('jump_add_select_' . $delta, $edit['jump_add_select_' . $delta]); |
|
81 | + variable_set('jump_add_select_text_' . $delta, $edit['jump_add_select_text_' . $delta]); |
|
82 | + break; |
|
83 | + case 'view': |
|
84 | + // The first 5 characters of $delta should be one of: |
|
85 | + // menu- |
|
86 | + // taxo- |
|
87 | + $subject = ''; |
|
88 | + $jumpmenu_type = substr($delta, 0, 4); |
|
89 | + $jumpmenu_name = substr($delta, 5); |
|
90 | + $active = jump_get_active_setting($delta); |
|
91 | + if ($jumpmenu_type == 'menu') { |
|
92 | + $form = jump_quickly($jumpmenu_name, 'menu', $active); |
|
93 | 93 | |
94 | - // Use the menu label as the default block subject |
|
95 | - $menus = menu_get_menus(); |
|
96 | - $subject = $menus[$jumpmenu_name]; |
|
97 | - } |
|
98 | - else if ($jumpmenu_type == 'taxo') { |
|
99 | - $form = jump_quickly($jumpmenu_name, 'taxo', $active); |
|
94 | + // Use the menu label as the default block subject |
|
95 | + $menus = menu_get_menus(); |
|
96 | + $subject = $menus[$jumpmenu_name]; |
|
97 | + } |
|
98 | + else if ($jumpmenu_type == 'taxo') { |
|
99 | + $form = jump_quickly($jumpmenu_name, 'taxo', $active); |
|
100 | 100 | |
101 | - // Use the vocabulary name as the default block subject |
|
102 | - $vocab = taxonomy_vocabulary_load($jumpmenu_name); |
|
103 | - $subject = $vocab->name; |
|
104 | - } |
|
105 | - if (variable_get('jump_use_js_' . $delta, 0) === 1) drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js'); |
|
106 | - return array('subject' => $subject, 'content' => $form); |
|
107 | - break; |
|
101 | + // Use the vocabulary name as the default block subject |
|
102 | + $vocab = taxonomy_vocabulary_load($jumpmenu_name); |
|
103 | + $subject = $vocab->name; |
|
104 | + } |
|
105 | + if (variable_get('jump_use_js_' . $delta, 0) === 1) drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js'); |
|
106 | + return array('subject' => $subject, 'content' => $form); |
|
107 | + break; |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | |
@@ -309,52 +309,52 @@ discard block |
||
309 | 309 | */ |
310 | 310 | function jump_form_alter(&$form, $form_state, $form_id) { |
311 | 311 | switch ($form_id) { |
312 | - case 'block_admin_configure': |
|
313 | - if ($form['module']['#value'] === 'jump' && function_exists('ahah_helper_register')) { |
|
314 | - $delta = $form['delta']['#value']; |
|
315 | - ahah_helper_register($form, $form_state); |
|
316 | - $default_jump_use_js = (!isset($form_state['storage']['jump_use_js_' . $delta])) ? variable_get('jump_use_js_' . $delta, 0) : $form_state['storage']['jump_use_js_' . $delta]; |
|
317 | - $default_jump_add_select = (!isset($form_state['storage']['jump_add_select_' . $delta])) ? variable_get('jump_add_select_' . $delta, 0) : $form_state['storage']['jump_add_select_' . $delta]; |
|
312 | + case 'block_admin_configure': |
|
313 | + if ($form['module']['#value'] === 'jump' && function_exists('ahah_helper_register')) { |
|
314 | + $delta = $form['delta']['#value']; |
|
315 | + ahah_helper_register($form, $form_state); |
|
316 | + $default_jump_use_js = (!isset($form_state['storage']['jump_use_js_' . $delta])) ? variable_get('jump_use_js_' . $delta, 0) : $form_state['storage']['jump_use_js_' . $delta]; |
|
317 | + $default_jump_add_select = (!isset($form_state['storage']['jump_add_select_' . $delta])) ? variable_get('jump_add_select_' . $delta, 0) : $form_state['storage']['jump_add_select_' . $delta]; |
|
318 | 318 | |
319 | - $form['block_settings']['jump_wrapper'] = array( |
|
320 | - '#prefix' => '<div id="jump-wrapper">', |
|
321 | - '#suffix' => '</div>', |
|
322 | - '#type' => 'markup' |
|
323 | - ); |
|
324 | - $form['block_settings']['jump_wrapper']['jump_use_js_' . $delta] = array( |
|
319 | + $form['block_settings']['jump_wrapper'] = array( |
|
320 | + '#prefix' => '<div id="jump-wrapper">', |
|
321 | + '#suffix' => '</div>', |
|
322 | + '#type' => 'markup' |
|
323 | + ); |
|
324 | + $form['block_settings']['jump_wrapper']['jump_use_js_' . $delta] = array( |
|
325 | + '#type' => 'checkbox', |
|
326 | + '#title' => t('Hide the submit button and use Javascript to automatically jump to the selected menu item'), |
|
327 | + '#default_value' => $default_jump_use_js, |
|
328 | + '#disabled' => ($default_jump_add_select === 1) ? TRUE : FALSE, |
|
329 | + '#ahah' => array( |
|
330 | + 'event' => 'change', |
|
331 | + 'path' => ahah_helper_path(array('block_settings', 'jump_wrapper')), |
|
332 | + 'wrapper' => 'jump-wrapper', |
|
333 | + ), |
|
334 | + ); |
|
335 | + if ($default_jump_use_js === 1) { |
|
336 | + $form['block_settings']['jump_wrapper']['jump_add_select_' . $delta] = array( |
|
325 | 337 | '#type' => 'checkbox', |
326 | - '#title' => t('Hide the submit button and use Javascript to automatically jump to the selected menu item'), |
|
327 | - '#default_value' => $default_jump_use_js, |
|
328 | - '#disabled' => ($default_jump_add_select === 1) ? TRUE : FALSE, |
|
338 | + '#title' => t('Add an empty select option into the list of options'), |
|
339 | + '#default_value' => $default_jump_add_select, |
|
340 | + '#weight' => 1, |
|
329 | 341 | '#ahah' => array( |
330 | 342 | 'event' => 'change', |
331 | 343 | 'path' => ahah_helper_path(array('block_settings', 'jump_wrapper')), |
332 | 344 | 'wrapper' => 'jump-wrapper', |
333 | 345 | ), |
334 | 346 | ); |
335 | - if ($default_jump_use_js === 1) { |
|
336 | - $form['block_settings']['jump_wrapper']['jump_add_select_' . $delta] = array( |
|
337 | - '#type' => 'checkbox', |
|
338 | - '#title' => t('Add an empty select option into the list of options'), |
|
339 | - '#default_value' => $default_jump_add_select, |
|
340 | - '#weight' => 1, |
|
341 | - '#ahah' => array( |
|
342 | - 'event' => 'change', |
|
343 | - 'path' => ahah_helper_path(array('block_settings', 'jump_wrapper')), |
|
344 | - 'wrapper' => 'jump-wrapper', |
|
345 | - ), |
|
347 | + if ($default_jump_add_select === 1) { |
|
348 | + $form['block_settings']['jump_wrapper']['jump_add_select_text_' . $delta] = array( |
|
349 | + '#type' => 'textfield', |
|
350 | + '#title' => t('Text to use for the empty select option'), |
|
351 | + '#default_value' => variable_get('jump_add_select_text_' . $delta, t('Select Option')), |
|
352 | + '#weight' => 2 |
|
346 | 353 | ); |
347 | - if ($default_jump_add_select === 1) { |
|
348 | - $form['block_settings']['jump_wrapper']['jump_add_select_text_' . $delta] = array( |
|
349 | - '#type' => 'textfield', |
|
350 | - '#title' => t('Text to use for the empty select option'), |
|
351 | - '#default_value' => variable_get('jump_add_select_text_' . $delta, t('Select Option')), |
|
352 | - '#weight' => 2 |
|
353 | - ); |
|
354 | - } |
|
355 | 354 | } |
356 | 355 | } |
357 | - break; |
|
356 | + } |
|
357 | + break; |
|
358 | 358 | } |
359 | 359 | } |
360 | 360 |
@@ -52,33 +52,33 @@ discard block |
||
52 | 52 | case 'list': |
53 | 53 | $blocks = array(); |
54 | 54 | foreach (menu_get_menus() as $name => $title) { |
55 | - $blocks['menu-' . $name] = array( |
|
55 | + $blocks['menu-'.$name] = array( |
|
56 | 56 | 'info' => t('Jump menu: !menu', array('!menu' => $name)) |
57 | 57 | ); |
58 | 58 | } |
59 | 59 | |
60 | 60 | $vocs = taxonomy_get_vocabularies(); |
61 | 61 | foreach ($vocs as $vid => $vocabulary) { |
62 | - $blocks['taxo-' . $vid] = array( |
|
62 | + $blocks['taxo-'.$vid] = array( |
|
63 | 63 | 'info' => t('Jump menu: !voc', array('!voc' => $vocabulary->name)) |
64 | 64 | ); |
65 | 65 | } |
66 | 66 | return $blocks; |
67 | 67 | case 'configure': |
68 | 68 | $form = array(); |
69 | - $form['block_settings']['jump_activepageinmenu_' . $delta] = array( |
|
69 | + $form['block_settings']['jump_activepageinmenu_'.$delta] = array( |
|
70 | 70 | '#type' => 'checkbox', |
71 | 71 | '#title' => t('Show active page in jump menu.'), |
72 | - '#default_value' => variable_get('jump_activepageinmenu_' . $delta, 1), |
|
72 | + '#default_value' => variable_get('jump_activepageinmenu_'.$delta, 1), |
|
73 | 73 | '#description' => t('This setting will force the jump menu to show the current page as the default selection in this block\'s jump menu.'), |
74 | 74 | ); |
75 | 75 | // Do the rest of the form additions in hook_form_alter() since we can't do ahah here. |
76 | 76 | return $form; |
77 | 77 | case 'save': |
78 | - variable_set('jump_activepageinmenu_' . $delta, $edit['jump_activepageinmenu_' . $delta]); |
|
79 | - variable_set('jump_use_js_' . $delta, $edit['jump_use_js_' . $delta]); |
|
80 | - variable_set('jump_add_select_' . $delta, $edit['jump_add_select_' . $delta]); |
|
81 | - variable_set('jump_add_select_text_' . $delta, $edit['jump_add_select_text_' . $delta]); |
|
78 | + variable_set('jump_activepageinmenu_'.$delta, $edit['jump_activepageinmenu_'.$delta]); |
|
79 | + variable_set('jump_use_js_'.$delta, $edit['jump_use_js_'.$delta]); |
|
80 | + variable_set('jump_add_select_'.$delta, $edit['jump_add_select_'.$delta]); |
|
81 | + variable_set('jump_add_select_text_'.$delta, $edit['jump_add_select_text_'.$delta]); |
|
82 | 82 | break; |
83 | 83 | case 'view': |
84 | 84 | // The first 5 characters of $delta should be one of: |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $vocab = taxonomy_vocabulary_load($jumpmenu_name); |
103 | 103 | $subject = $vocab->name; |
104 | 104 | } |
105 | - if (variable_get('jump_use_js_' . $delta, 0) === 1) drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js'); |
|
105 | + if (variable_get('jump_use_js_'.$delta, 0) === 1) drupal_add_js(drupal_get_path('module', 'jump').'/jump.js'); |
|
106 | 106 | return array('subject' => $subject, 'content' => $form); |
107 | 107 | break; |
108 | 108 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | */ |
126 | 126 | function jump_quickly($name = 'navigation', $type = 'menu', $active = -1, $override = '') { |
127 | 127 | // Reconstruct the $delta |
128 | - $delta = $type . '-' . $name; |
|
128 | + $delta = $type.'-'.$name; |
|
129 | 129 | if ($active === -1) { |
130 | 130 | $active = variable_get('jump_activepageinmenu', 1); |
131 | 131 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | static $num_jump_forms = 0; |
154 | 154 | $num_jump_forms++; |
155 | 155 | |
156 | - return drupal_get_form('jump_quickly_form_' . $num_jump_forms, $options, $menu_state); |
|
156 | + return drupal_get_form('jump_quickly_form_'.$num_jump_forms, $options, $menu_state); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
@@ -188,15 +188,15 @@ discard block |
||
188 | 188 | '#type' => 'submit', |
189 | 189 | '#value' => t('Go') |
190 | 190 | ); |
191 | - if (variable_get('jump_use_js_' . $menu_state['delta'], 0) === 1) { |
|
191 | + if (variable_get('jump_use_js_'.$menu_state['delta'], 0) === 1) { |
|
192 | 192 | // Give each menu a unique name. |
193 | - $form['#attributes']['name'] = 'jumpquickly' . $menu_state['delta']; |
|
193 | + $form['#attributes']['name'] = 'jumpquickly'.$menu_state['delta']; |
|
194 | 194 | $form['#attributes']['class'] .= ' js-enabled'; |
195 | 195 | // unset($form['submit']); |
196 | - if (variable_get('jump_add_select_' . $menu_state['delta'], 0) === 1) { |
|
196 | + if (variable_get('jump_add_select_'.$menu_state['delta'], 0) === 1) { |
|
197 | 197 | $form['jump_goto']['#attributes']['class'] = 'first-no-jump'; |
198 | 198 | // Add the extra empty select option to the top of the array. |
199 | - $form['jump_goto']['#options'] = array('' => variable_get('jump_add_select_text_' . $menu_state['delta'], t('Select Option'))) + $options; |
|
199 | + $form['jump_goto']['#options'] = array('' => variable_get('jump_add_select_text_'.$menu_state['delta'], t('Select Option'))) + $options; |
|
200 | 200 | $form['jump_goto']['#default_value'] = (array_key_exists($default, $options)) ? $default : ''; |
201 | 201 | } |
202 | 202 | } |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | foreach ($tree as $data) { |
250 | 250 | if (!$data['link']['hidden']) { |
251 | 251 | $href = ($data['link']['href'] == '<front>') ? $front : $data['link']['href']; |
252 | - $href = (isset($data['link']['options']['fragment'])) ? $href . '#' . $data['link']['options']['fragment'] : $href; |
|
252 | + $href = (isset($data['link']['options']['fragment'])) ? $href.'#'.$data['link']['options']['fragment'] : $href; |
|
253 | 253 | $options[$href] = $data['link']['title']; |
254 | 254 | } |
255 | 255 | } |
@@ -313,15 +313,15 @@ discard block |
||
313 | 313 | if ($form['module']['#value'] === 'jump' && function_exists('ahah_helper_register')) { |
314 | 314 | $delta = $form['delta']['#value']; |
315 | 315 | ahah_helper_register($form, $form_state); |
316 | - $default_jump_use_js = (!isset($form_state['storage']['jump_use_js_' . $delta])) ? variable_get('jump_use_js_' . $delta, 0) : $form_state['storage']['jump_use_js_' . $delta]; |
|
317 | - $default_jump_add_select = (!isset($form_state['storage']['jump_add_select_' . $delta])) ? variable_get('jump_add_select_' . $delta, 0) : $form_state['storage']['jump_add_select_' . $delta]; |
|
316 | + $default_jump_use_js = (!isset($form_state['storage']['jump_use_js_'.$delta])) ? variable_get('jump_use_js_'.$delta, 0) : $form_state['storage']['jump_use_js_'.$delta]; |
|
317 | + $default_jump_add_select = (!isset($form_state['storage']['jump_add_select_'.$delta])) ? variable_get('jump_add_select_'.$delta, 0) : $form_state['storage']['jump_add_select_'.$delta]; |
|
318 | 318 | |
319 | 319 | $form['block_settings']['jump_wrapper'] = array( |
320 | 320 | '#prefix' => '<div id="jump-wrapper">', |
321 | 321 | '#suffix' => '</div>', |
322 | 322 | '#type' => 'markup' |
323 | 323 | ); |
324 | - $form['block_settings']['jump_wrapper']['jump_use_js_' . $delta] = array( |
|
324 | + $form['block_settings']['jump_wrapper']['jump_use_js_'.$delta] = array( |
|
325 | 325 | '#type' => 'checkbox', |
326 | 326 | '#title' => t('Hide the submit button and use Javascript to automatically jump to the selected menu item'), |
327 | 327 | '#default_value' => $default_jump_use_js, |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | ), |
334 | 334 | ); |
335 | 335 | if ($default_jump_use_js === 1) { |
336 | - $form['block_settings']['jump_wrapper']['jump_add_select_' . $delta] = array( |
|
336 | + $form['block_settings']['jump_wrapper']['jump_add_select_'.$delta] = array( |
|
337 | 337 | '#type' => 'checkbox', |
338 | 338 | '#title' => t('Add an empty select option into the list of options'), |
339 | 339 | '#default_value' => $default_jump_add_select, |
@@ -345,10 +345,10 @@ discard block |
||
345 | 345 | ), |
346 | 346 | ); |
347 | 347 | if ($default_jump_add_select === 1) { |
348 | - $form['block_settings']['jump_wrapper']['jump_add_select_text_' . $delta] = array( |
|
348 | + $form['block_settings']['jump_wrapper']['jump_add_select_text_'.$delta] = array( |
|
349 | 349 | '#type' => 'textfield', |
350 | 350 | '#title' => t('Text to use for the empty select option'), |
351 | - '#default_value' => variable_get('jump_add_select_text_' . $delta, t('Select Option')), |
|
351 | + '#default_value' => variable_get('jump_add_select_text_'.$delta, t('Select Option')), |
|
352 | 352 | '#weight' => 2 |
353 | 353 | ); |
354 | 354 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | */ |
367 | 367 | function jump_get_active_setting($delta) { |
368 | 368 | $active_site_default = variable_get('jump_activepageinmenu', 1); |
369 | - $active = variable_get('jump_activepageinmenu_' . $delta, $active_site_default); |
|
369 | + $active = variable_get('jump_activepageinmenu_'.$delta, $active_site_default); |
|
370 | 370 | return $active; |
371 | 371 | } |
372 | 372 |
@@ -94,8 +94,7 @@ discard block |
||
94 | 94 | // Use the menu label as the default block subject |
95 | 95 | $menus = menu_get_menus(); |
96 | 96 | $subject = $menus[$jumpmenu_name]; |
97 | - } |
|
98 | - else if ($jumpmenu_type == 'taxo') { |
|
97 | + } else if ($jumpmenu_type == 'taxo') { |
|
99 | 98 | $form = jump_quickly($jumpmenu_name, 'taxo', $active); |
100 | 99 | |
101 | 100 | // Use the vocabulary name as the default block subject |
@@ -137,13 +136,11 @@ discard block |
||
137 | 136 | |
138 | 137 | if (is_array($name)) { |
139 | 138 | $options = $name; |
140 | - } |
|
141 | - else { |
|
139 | + } else { |
|
142 | 140 | $options = array(); |
143 | 141 | if ($type == 'menu') { |
144 | 142 | jump_menu_get_menu_options($options, $name); |
145 | - } |
|
146 | - elseif ($type == 'taxo') { |
|
143 | + } elseif ($type == 'taxo') { |
|
147 | 144 | jump_menu_get_taxo_options($options, $name); |
148 | 145 | } |
149 | 146 | } |
@@ -215,8 +212,7 @@ discard block |
||
215 | 212 | $fragment = explode('#', $form_state['values']['jump_goto']); |
216 | 213 | if (isset($fragment[1])) { |
217 | 214 | drupal_goto($fragment[0], NULL, $fragment[1]); |
218 | - } |
|
219 | - else { |
|
215 | + } else { |
|
220 | 216 | drupal_goto($form_state['values']['jump_goto']); |
221 | 217 | } |
222 | 218 | } |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | if (!empty($form_state['values']['jump_goto'])) { |
215 | 215 | $fragment = explode('#', $form_state['values']['jump_goto']); |
216 | 216 | if (isset($fragment[1])) { |
217 | - drupal_goto($fragment[0], NULL, $fragment[1]); |
|
217 | + drupal_goto($fragment[0], null, $fragment[1]); |
|
218 | 218 | } |
219 | 219 | else { |
220 | 220 | drupal_goto($form_state['values']['jump_goto']); |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | '#type' => 'checkbox', |
326 | 326 | '#title' => t('Hide the submit button and use Javascript to automatically jump to the selected menu item'), |
327 | 327 | '#default_value' => $default_jump_use_js, |
328 | - '#disabled' => ($default_jump_add_select === 1) ? TRUE : FALSE, |
|
328 | + '#disabled' => ($default_jump_add_select === 1) ? true : false, |
|
329 | 329 | '#ahah' => array( |
330 | 330 | 'event' => 'change', |
331 | 331 | 'path' => ahah_helper_path(array('block_settings', 'jump_wrapper')), |
@@ -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 | } |
@@ -12,33 +12,33 @@ discard block |
||
12 | 12 | * Rewrite the forum administration page with our new access rules. |
13 | 13 | */ |
14 | 14 | function _forum_access_forum_form(&$form, &$form_state, $is_container) { |
15 | - $tid = (isset($form['tid']['#value']) ? $form['tid']['#value'] : NULL); |
|
16 | - if (isset($tid) && !forum_access_access($tid, 'view', NULL, FALSE)) { |
|
15 | + $tid = (isset($form['tid']['#value']) ? $form['tid']['#value'] : NULL); |
|
16 | + if (isset($tid) && !forum_access_access($tid, 'view', NULL, FALSE)) { |
|
17 | 17 | drupal_access_denied(); // Deny access if the user doesn't have View access. |
18 | 18 | module_invoke_all('exit'); |
19 | 19 | exit; |
20 | - } |
|
20 | + } |
|
21 | 21 | |
22 | - $roles = user_roles(); |
|
23 | - if (isset($tid)) { // edit |
|
22 | + $roles = user_roles(); |
|
23 | + if (isset($tid)) { // edit |
|
24 | 24 | $template_tid = variable_get('forum_access_default_template_tid', 0); |
25 | 25 | $settings = _forum_access_get_settings($tid); |
26 | - } |
|
27 | - else { // create |
|
26 | + } |
|
27 | + else { // create |
|
28 | 28 | $template_tid = variable_get('forum_access_new_template_tid', NULL); |
29 | 29 | $settings = _forum_access_get_settings($template_tid); |
30 | - } |
|
31 | - $fa_priority = $settings['priority']; |
|
30 | + } |
|
31 | + $fa_priority = $settings['priority']; |
|
32 | 32 | |
33 | - $form['forum_access'] = array( |
|
33 | + $form['forum_access'] = array( |
|
34 | 34 | '#type' => 'fieldset', |
35 | 35 | '#title' => t('Access control'), |
36 | 36 | '#collapsible' => TRUE, |
37 | 37 | '#tree' => TRUE, |
38 | - ); |
|
38 | + ); |
|
39 | 39 | |
40 | - $tr = 't'; |
|
41 | - $variables = array( |
|
40 | + $tr = 't'; |
|
41 | + $variables = array( |
|
42 | 42 | '!access_content' => '<em>'. l($tr('access content'), 'admin/user/permissions', array('fragment' => 'module-node', 'html' => TRUE)) .'</em>', |
43 | 43 | '!access_comments' => '<em>'. l($tr('access comments'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => TRUE)) .'</em>', |
44 | 44 | '!create_forum_topics' => '<em>'. l($tr('create forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)) .'</em>', |
@@ -51,368 +51,368 @@ discard block |
||
51 | 51 | '!administer_comments' => '<em>'. l($tr('administer comments'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => TRUE)) .'</em>', |
52 | 52 | '!administer_forums' => '<em>'. l($tr('administer forums'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)) .'</em>', |
53 | 53 | '!administer_nodes' => '<em>'. l($tr('administer nodes'), 'admin/user/permissions', array('fragment' => 'module-node', 'html' => TRUE)) .'</em>', |
54 | - ); |
|
55 | - if (!$is_container) { |
|
54 | + ); |
|
55 | + if (!$is_container) { |
|
56 | 56 | $form['forum_access']['permissions'] = array( |
57 | - '#type' => 'fieldset', |
|
58 | - '#title' => $tr('Permissions information'), |
|
59 | - '#collapsible' => TRUE, |
|
60 | - '#collapsed' => TRUE, |
|
57 | + '#type' => 'fieldset', |
|
58 | + '#title' => $tr('Permissions information'), |
|
59 | + '#collapsible' => TRUE, |
|
60 | + '#collapsed' => TRUE, |
|
61 | 61 | ); |
62 | 62 | $form['forum_access']['permissions'][] = array( |
63 | - '#type' => 'markup', |
|
64 | - '#value' => '<div>'. t('Note that users need') .'<ul style="margin-top: 0"><li>'. |
|
65 | - t('the !access_content and !access_comments permissions <strong>AND <em>View</em></strong> to be able to see this forum and its content at all,', $variables) .'</li><li>'. |
|
66 | - t('the !create_forum_topics (and similar) permissions <strong>AND <em>Post</em></strong> to be able to create forum content, and', $variables) .'</li><li>'. |
|
67 | - t('the !post_comments and (probably) !post_comments_without_approval permission <!TAG>AND <em>Comment</em></!TAG> to be able to post comments/replies;', $variables + array('!TAG' => (variable_get('forum_access_D5_legacy_mode', FALSE) ? 'del title="'. t('Drupal 5 legacy mode') .'"' : 'strong'))) .'</li><li>'. |
|
68 | - t('the !edit_own_forum_topics or !edit_any_forum_topics (and similar) permissions <strong>AND (<em>Edit</em> AND <em>Comment</em></strong>) can be added if desired, <strong>plus</strong>', $variables) .'</li><li>'. |
|
69 | - t('the !delete_own_forum_topics or !delete_any_forum_topics (and similar) permissions (<strong>OR <em>Delete</em></strong>) if desired;', $variables) .'</li><li>'. |
|
70 | - t('the !administer_comments (global!) permission <strong>OR <em>Edit</em>/<em>Delete</em></strong> to be able to edit/delete comments;', $variables) .'</li><li>'. |
|
71 | - t('the !administer_forums permission <strong>AND <em>View</em></strong> to be able to administer forums (and change access!).', $variables) .'</li></ul>'. |
|
72 | - t('Furthermore note that content which is not published is treated in a different way by Drupal: it can be viewed only by its author or by users with the !administer_nodes permission. Unpublished comments and replies are accessible to users with <strong><em>Edit</em> OR <em>Delete</em></strong>, <strong>OR</strong> with the !administer_comments permission, but they are never counted on the forum page.', $variables) .'</div>', |
|
73 | - ); |
|
74 | - } |
|
75 | - |
|
76 | - // Load a template: |
|
77 | - $vid = _forum_access_get_vid(); |
|
78 | - $form['forum_access']['template'] = array( |
|
79 | - '#type' => 'fieldset', |
|
80 | - '#title' => $tr('Template'), |
|
81 | - '#collapsible' => TRUE, |
|
82 | - '#collapsed' => empty($template_tid), |
|
83 | - ); |
|
84 | - $form['forum_access']['template']['taxonomy'][$vid] = taxonomy_form($vid, array($template_tid), ''); |
|
85 | - $form['forum_access']['template']['taxonomy'][$vid]['#description'] = t("Select a forum and click !Load to retrieve that forum's settings as a starting point for this forum or container.", array('!Load' => '['. t('Load') .']')); |
|
86 | - $form['forum_access']['template']['load_button'] = array( |
|
63 | + '#type' => 'markup', |
|
64 | + '#value' => '<div>'. t('Note that users need') .'<ul style="margin-top: 0"><li>'. |
|
65 | + t('the !access_content and !access_comments permissions <strong>AND <em>View</em></strong> to be able to see this forum and its content at all,', $variables) .'</li><li>'. |
|
66 | + t('the !create_forum_topics (and similar) permissions <strong>AND <em>Post</em></strong> to be able to create forum content, and', $variables) .'</li><li>'. |
|
67 | + t('the !post_comments and (probably) !post_comments_without_approval permission <!TAG>AND <em>Comment</em></!TAG> to be able to post comments/replies;', $variables + array('!TAG' => (variable_get('forum_access_D5_legacy_mode', FALSE) ? 'del title="'. t('Drupal 5 legacy mode') .'"' : 'strong'))) .'</li><li>'. |
|
68 | + t('the !edit_own_forum_topics or !edit_any_forum_topics (and similar) permissions <strong>AND (<em>Edit</em> AND <em>Comment</em></strong>) can be added if desired, <strong>plus</strong>', $variables) .'</li><li>'. |
|
69 | + t('the !delete_own_forum_topics or !delete_any_forum_topics (and similar) permissions (<strong>OR <em>Delete</em></strong>) if desired;', $variables) .'</li><li>'. |
|
70 | + t('the !administer_comments (global!) permission <strong>OR <em>Edit</em>/<em>Delete</em></strong> to be able to edit/delete comments;', $variables) .'</li><li>'. |
|
71 | + t('the !administer_forums permission <strong>AND <em>View</em></strong> to be able to administer forums (and change access!).', $variables) .'</li></ul>'. |
|
72 | + t('Furthermore note that content which is not published is treated in a different way by Drupal: it can be viewed only by its author or by users with the !administer_nodes permission. Unpublished comments and replies are accessible to users with <strong><em>Edit</em> OR <em>Delete</em></strong>, <strong>OR</strong> with the !administer_comments permission, but they are never counted on the forum page.', $variables) .'</div>', |
|
73 | + ); |
|
74 | + } |
|
75 | + |
|
76 | + // Load a template: |
|
77 | + $vid = _forum_access_get_vid(); |
|
78 | + $form['forum_access']['template'] = array( |
|
79 | + '#type' => 'fieldset', |
|
80 | + '#title' => $tr('Template'), |
|
81 | + '#collapsible' => TRUE, |
|
82 | + '#collapsed' => empty($template_tid), |
|
83 | + ); |
|
84 | + $form['forum_access']['template']['taxonomy'][$vid] = taxonomy_form($vid, array($template_tid), ''); |
|
85 | + $form['forum_access']['template']['taxonomy'][$vid]['#description'] = t("Select a forum and click !Load to retrieve that forum's settings as a starting point for this forum or container.", array('!Load' => '['. t('Load') .']')); |
|
86 | + $form['forum_access']['template']['load_button'] = array( |
|
87 | 87 | '#type' => 'button', |
88 | 88 | '#name' => 'load_template', |
89 | 89 | '#value' => t('Load'), |
90 | 90 | '#submit' => FALSE, |
91 | - ); |
|
92 | - $form['forum_access']['template']['template_tid'] = array( |
|
91 | + ); |
|
92 | + $form['forum_access']['template']['template_tid'] = array( |
|
93 | 93 | '#type' => 'value', |
94 | 94 | '#value' => NULL, |
95 | - ); |
|
96 | - $form['forum_access']['template']['select_by_default'] = array( |
|
95 | + ); |
|
96 | + $form['forum_access']['template']['select_by_default'] = array( |
|
97 | 97 | '#type' => 'checkbox', |
98 | 98 | '#title' => t('Remember this selection.'), |
99 | 99 | '#default_value' => FALSE, |
100 | - ); |
|
101 | - $form['forum_access']['template']['load_for_new'] = array( |
|
100 | + ); |
|
101 | + $form['forum_access']['template']['load_for_new'] = array( |
|
102 | 102 | '#type' => 'checkbox', |
103 | 103 | '#title' => t("Use the selected forum's settings as defaults for new forums and containers."), |
104 | 104 | '#default_value' => FALSE, |
105 | - ); |
|
106 | - $form['forum_access']['#after_build'][] = '_forum_access_forum_form_after_build'; |
|
105 | + ); |
|
106 | + $form['forum_access']['#after_build'][] = '_forum_access_forum_form_after_build'; |
|
107 | 107 | |
108 | - // Column titles: |
|
109 | - $form['forum_access']['headers']['view'] = array( |
|
108 | + // Column titles: |
|
109 | + $form['forum_access']['headers']['view'] = array( |
|
110 | 110 | '#type' => 'item', |
111 | 111 | '#prefix' => '<div class="forum-access-div">', |
112 | 112 | '#title' => ($is_container ? t('View this container') : t('View this forum')), |
113 | 113 | '#suffix' => '</div>', |
114 | - ); |
|
115 | - $forum_vocabulary = taxonomy_vocabulary_load(_forum_access_get_vid()); |
|
116 | - $form['forum_access']['headers']['create'] = array( |
|
114 | + ); |
|
115 | + $forum_vocabulary = taxonomy_vocabulary_load(_forum_access_get_vid()); |
|
116 | + $form['forum_access']['headers']['create'] = array( |
|
117 | 117 | '#type' => 'item', |
118 | 118 | '#prefix' => '<div class="forum-access-div" id="forum-access-div-container">', |
119 | 119 | '#title' => t('See this container in the %Forums selection list', array('%Forums' => $forum_vocabulary->name)), |
120 | 120 | '#suffix' => '</div>', |
121 | - ); |
|
122 | - if (!$is_container) { |
|
121 | + ); |
|
122 | + if (!$is_container) { |
|
123 | 123 | $form['forum_access']['headers']['create'] = array( // overwrite! |
124 | - '#type' => 'item', |
|
125 | - '#prefix' => '<div class="forum-access-div">', |
|
126 | - '#title' => t('Post in this forum'), |
|
127 | - '#suffix' => '</div>', |
|
124 | + '#type' => 'item', |
|
125 | + '#prefix' => '<div class="forum-access-div">', |
|
126 | + '#title' => t('Post in this forum'), |
|
127 | + '#suffix' => '</div>', |
|
128 | 128 | ); |
129 | 129 | $form['forum_access']['headers']['comment_create'] = array( |
130 | - '#type' => 'item', |
|
131 | - '#prefix' => '<div class="forum-access-div">', |
|
132 | - '#title' => t('Comment on posts'), |
|
133 | - '#suffix' => '</div>', |
|
130 | + '#type' => 'item', |
|
131 | + '#prefix' => '<div class="forum-access-div">', |
|
132 | + '#title' => t('Comment on posts'), |
|
133 | + '#suffix' => '</div>', |
|
134 | 134 | ); |
135 | 135 | $form['forum_access']['headers']['update'] = array( |
136 | - '#type' => 'item', |
|
137 | - '#prefix' => '<div class="forum-access-div">', |
|
138 | - '#title' => t('Edit posts'), |
|
139 | - '#suffix' => '</div>', |
|
136 | + '#type' => 'item', |
|
137 | + '#prefix' => '<div class="forum-access-div">', |
|
138 | + '#title' => t('Edit posts'), |
|
139 | + '#suffix' => '</div>', |
|
140 | 140 | ); |
141 | 141 | $form['forum_access']['headers']['delete'] = array( |
142 | - '#type' => 'item', |
|
143 | - '#prefix' => '<div class="forum-access-div">', |
|
144 | - '#title' => t('Delete posts'), |
|
145 | - '#suffix' => '</div>', |
|
146 | - ); |
|
147 | - } |
|
148 | - $form['forum_access']['headers']['clearer'] = array( |
|
149 | - '#value' => '<div class="forum-access-clearer"></div>', |
|
150 | - ); |
|
142 | + '#type' => 'item', |
|
143 | + '#prefix' => '<div class="forum-access-div">', |
|
144 | + '#title' => t('Delete posts'), |
|
145 | + '#suffix' => '</div>', |
|
146 | + ); |
|
147 | + } |
|
148 | + $form['forum_access']['headers']['clearer'] = array( |
|
149 | + '#value' => '<div class="forum-access-clearer"></div>', |
|
150 | + ); |
|
151 | 151 | |
152 | - // Column content (checkboxes): |
|
153 | - $form['forum_access']['view'] = array( |
|
152 | + // Column content (checkboxes): |
|
153 | + $form['forum_access']['view'] = array( |
|
154 | 154 | '#type' => 'checkboxes', |
155 | 155 | '#prefix' => '<div class="forum-access-div">', |
156 | 156 | '#suffix' => '</div>', |
157 | 157 | '#options' => $roles, |
158 | 158 | '#default_value' => $settings['view'], |
159 | 159 | '#process' => array('expand_checkboxes', '_forum_access_forum_form_disable_checkboxes'), |
160 | - ); |
|
161 | - $form['forum_access']['create'] = array( |
|
160 | + ); |
|
161 | + $form['forum_access']['create'] = array( |
|
162 | 162 | '#type' => 'checkboxes', |
163 | 163 | '#prefix' => '<div class="forum-access-div">', |
164 | 164 | '#suffix' => '</div>', |
165 | 165 | '#options' => $roles, |
166 | 166 | '#default_value' => $settings['create'], |
167 | 167 | '#process' => array('expand_checkboxes', '_forum_access_forum_form_disable_checkboxes'), |
168 | - ); |
|
169 | - if (!$is_container) { |
|
168 | + ); |
|
169 | + if (!$is_container) { |
|
170 | 170 | $form['forum_access']['comment_create'] = array( |
171 | - '#type' => 'checkboxes', |
|
172 | - '#prefix' => '<div class="forum-access-div">', |
|
173 | - '#suffix' => '</div>', |
|
174 | - '#options' => $roles, |
|
175 | - '#default_value' => $settings['comment_create'], |
|
176 | - '#process' => array('expand_checkboxes', '_forum_access_forum_form_disable_checkboxes'), |
|
171 | + '#type' => 'checkboxes', |
|
172 | + '#prefix' => '<div class="forum-access-div">', |
|
173 | + '#suffix' => '</div>', |
|
174 | + '#options' => $roles, |
|
175 | + '#default_value' => $settings['comment_create'], |
|
176 | + '#process' => array('expand_checkboxes', '_forum_access_forum_form_disable_checkboxes'), |
|
177 | 177 | ); |
178 | 178 | $form['forum_access']['update'] = array( |
179 | - '#type' => 'checkboxes', |
|
180 | - '#prefix' => '<div class="forum-access-div">', |
|
181 | - '#suffix' => '</div>', |
|
182 | - '#options' => $roles, |
|
183 | - '#default_value' => $settings['update'], |
|
184 | - '#process' => array('expand_checkboxes', '_forum_access_forum_form_disable_checkboxes'), |
|
179 | + '#type' => 'checkboxes', |
|
180 | + '#prefix' => '<div class="forum-access-div">', |
|
181 | + '#suffix' => '</div>', |
|
182 | + '#options' => $roles, |
|
183 | + '#default_value' => $settings['update'], |
|
184 | + '#process' => array('expand_checkboxes', '_forum_access_forum_form_disable_checkboxes'), |
|
185 | 185 | ); |
186 | 186 | $form['forum_access']['delete'] = array( |
187 | - '#type' => 'checkboxes', |
|
188 | - '#prefix' => '<div class="forum-access-div">', |
|
189 | - '#suffix' => '</div>', |
|
190 | - '#options' => $roles, |
|
191 | - '#default_value' => $settings['delete'], |
|
192 | - '#process' => array('expand_checkboxes', '_forum_access_forum_form_disable_checkboxes'), |
|
193 | - ); |
|
194 | - } |
|
195 | - $form['forum_access']['clearer'] = array( |
|
187 | + '#type' => 'checkboxes', |
|
188 | + '#prefix' => '<div class="forum-access-div">', |
|
189 | + '#suffix' => '</div>', |
|
190 | + '#options' => $roles, |
|
191 | + '#default_value' => $settings['delete'], |
|
192 | + '#process' => array('expand_checkboxes', '_forum_access_forum_form_disable_checkboxes'), |
|
193 | + ); |
|
194 | + } |
|
195 | + $form['forum_access']['clearer'] = array( |
|
196 | 196 | '#type' => 'item', |
197 | 197 | '#prefix' => '<div class="forum-access-clearer">', |
198 | 198 | '#suffix' => '</div>', |
199 | 199 | '#description' => t('For explanations of special cases, hover your mouse over role names.'), |
200 | - ); |
|
201 | - if ($is_container) { |
|
200 | + ); |
|
201 | + if ($is_container) { |
|
202 | 202 | $form['forum_access']['container_note'] = array( |
203 | - '#type' => 'item', |
|
204 | - '#description' => t('Users who can see any forum or container within this one should get the <strong><em>View</em></strong> grant. <br /> Users who can post to a forum within this container should get the <strong><em>See</em></strong> grant, so that this forum appears in the proper context in the selection list.', $variables), |
|
203 | + '#type' => 'item', |
|
204 | + '#description' => t('Users who can see any forum or container within this one should get the <strong><em>View</em></strong> grant. <br /> Users who can post to a forum within this container should get the <strong><em>See</em></strong> grant, so that this forum appears in the proper context in the selection list.', $variables), |
|
205 | 205 | ); |
206 | - } |
|
206 | + } |
|
207 | 207 | |
208 | - drupal_add_css(drupal_get_path('module', 'forum_access') .'/forum_access.css'); |
|
208 | + drupal_add_css(drupal_get_path('module', 'forum_access') .'/forum_access.css'); |
|
209 | 209 | |
210 | - // Find our moderator ACL: |
|
211 | - if (isset($tid)) { // edit, not new |
|
210 | + // Find our moderator ACL: |
|
211 | + if (isset($tid)) { // edit, not new |
|
212 | 212 | $acl_id = acl_get_id_by_number('forum_access', $tid); |
213 | 213 | if (!$acl_id) { // create one |
214 | - $acl_id = acl_create_new_acl('forum_access', NULL, $tid); |
|
215 | - // update every existing node in this forum to use this acl. |
|
216 | - $result = db_query("SELECT nid FROM {term_node} WHERE tid = %d", $tid); |
|
217 | - while ($node = db_fetch_object($result)) { |
|
214 | + $acl_id = acl_create_new_acl('forum_access', NULL, $tid); |
|
215 | + // update every existing node in this forum to use this acl. |
|
216 | + $result = db_query("SELECT nid FROM {term_node} WHERE tid = %d", $tid); |
|
217 | + while ($node = db_fetch_object($result)) { |
|
218 | 218 | // all privs to this ACL. |
219 | 219 | acl_node_add_acl($node->nid, $acl_id, 1, 1, 1); |
220 | - } |
|
220 | + } |
|
221 | 221 | } |
222 | 222 | $form['forum_access']['acl'] = acl_edit_form($acl_id, t('Moderators')); |
223 | 223 | $form['forum_access']['acl'][] = array( |
224 | - '#type' => 'markup', |
|
225 | - '#value' => '<div>'. t('Moderators receive all grants above.') .'</div>', |
|
226 | - '#weight' => -1, |
|
224 | + '#type' => 'markup', |
|
225 | + '#value' => '<div>'. t('Moderators receive all grants above.') .'</div>', |
|
226 | + '#weight' => -1, |
|
227 | 227 | ); |
228 | 228 | $form['forum_access']['acl']['note'] = array( |
229 | - '#type' => 'markup', |
|
230 | - '#value' => '<div>'. t('Note: Changes to moderators are not saved until you click [!Save] below.', array('!Save' => $tr('Save'))) .'</div>', |
|
229 | + '#type' => 'markup', |
|
230 | + '#value' => '<div>'. t('Note: Changes to moderators are not saved until you click [!Save] below.', array('!Save' => $tr('Save'))) .'</div>', |
|
231 | 231 | ); |
232 | 232 | $form['forum_access']['acl']['#after_build'][] = '_forum_access_forum_form_after_build_acl0'; |
233 | 233 | $form['forum_access']['acl']['#after_build'] = array_reverse($form['forum_access']['acl']['#after_build']); |
234 | 234 | $form['forum_access']['acl']['#after_build'][] = '_forum_access_forum_form_after_build_acl2'; |
235 | - } |
|
235 | + } |
|
236 | 236 | |
237 | - foreach (module_implements('node_access_records') as $module) { |
|
237 | + foreach (module_implements('node_access_records') as $module) { |
|
238 | 238 | $na_modules[$module] = $module; |
239 | - } |
|
240 | - unset($na_modules['forum_access']); |
|
241 | - unset($na_modules['acl']); |
|
242 | - if (count($na_modules) && !$is_container) { |
|
239 | + } |
|
240 | + unset($na_modules['forum_access']); |
|
241 | + unset($na_modules['acl']); |
|
242 | + if (count($na_modules) && !$is_container) { |
|
243 | 243 | $form['forum_access']['interference'] = array( |
244 | - '#type' => 'fieldset', |
|
245 | - '#title' => t('Module interference'), |
|
246 | - '#collapsible' => TRUE, |
|
244 | + '#type' => 'fieldset', |
|
245 | + '#title' => t('Module interference'), |
|
246 | + '#collapsible' => TRUE, |
|
247 | 247 | ); |
248 | 248 | $variables = array( |
249 | - '%content_type' => node_get_types('name', 'forum'), |
|
250 | - '!Forum_Access' => 'Forum Access', |
|
251 | - '!Content_Access' => l('Content Access', 'http://drupal.org/project/content_access'), |
|
252 | - '@Content_Access' => 'Content Access', |
|
253 | - '!ACL' => 'ACL', |
|
254 | - '!module_list' => '<ul><li>'. implode($na_modules, '</li><li>') .'</li></ul>', |
|
249 | + '%content_type' => node_get_types('name', 'forum'), |
|
250 | + '!Forum_Access' => 'Forum Access', |
|
251 | + '!Content_Access' => l('Content Access', 'http://drupal.org/project/content_access'), |
|
252 | + '@Content_Access' => 'Content Access', |
|
253 | + '!ACL' => 'ACL', |
|
254 | + '!module_list' => '<ul><li>'. implode($na_modules, '</li><li>') .'</li></ul>', |
|
255 | 255 | ); |
256 | 256 | $form['forum_access']['interference'][] = array( |
257 | - '#type' => 'item', |
|
258 | - '#value' => '<p>'. t("Besides !Forum_Access (and !ACL) you have installed the following node access module(s): !module_list The grants of every module are combined for each node. Access can only be granted, not removed — if a certain module grants a permission, the other(s) cannot deny it.", $variables) .'</p>', |
|
259 | - '#description' => t('Forums can contain other content types besides %content_type; !Forum_Access will contribute the grants defined above to every node in this forum, but other node access control modules may also contribute their grants, especially to nodes of types other than %content_type.', $variables), |
|
257 | + '#type' => 'item', |
|
258 | + '#value' => '<p>'. t("Besides !Forum_Access (and !ACL) you have installed the following node access module(s): !module_list The grants of every module are combined for each node. Access can only be granted, not removed — if a certain module grants a permission, the other(s) cannot deny it.", $variables) .'</p>', |
|
259 | + '#description' => t('Forums can contain other content types besides %content_type; !Forum_Access will contribute the grants defined above to every node in this forum, but other node access control modules may also contribute their grants, especially to nodes of types other than %content_type.', $variables), |
|
260 | 260 | ); |
261 | 261 | |
262 | 262 | if (module_exists('content_access')) { |
263 | - $ca_settings = variable_get('content_access_settings', array()); |
|
264 | - foreach (array('view', 'update', 'delete', 'per_node') as $type) { |
|
263 | + $ca_settings = variable_get('content_access_settings', array()); |
|
264 | + foreach (array('view', 'update', 'delete', 'per_node') as $type) { |
|
265 | 265 | $value = content_access_get_settings($type, 'forum'); |
266 | 266 | if (!empty($value)) { |
267 | - $ca_interferes = TRUE; |
|
267 | + $ca_interferes = TRUE; |
|
268 | + } |
|
268 | 269 | } |
269 | - } |
|
270 | - $ca_priority = content_access_get_settings('priority', 'forum'); |
|
271 | - $is_conflict = $ca_priority >= $fa_priority && !empty($ca_interferes) || $ca_priority > $fa_priority; |
|
272 | - $variables += array( |
|
270 | + $ca_priority = content_access_get_settings('priority', 'forum'); |
|
271 | + $is_conflict = $ca_priority >= $fa_priority && !empty($ca_interferes) || $ca_priority > $fa_priority; |
|
272 | + $variables += array( |
|
273 | 273 | '!link' => l(t('@Content_Access configuration for the %content_type type', $variables), 'admin/content/node-type/forum/access', array('html' => TRUE)), |
274 | 274 | '%Advanced' => $tr('Advanced'), |
275 | - ); |
|
276 | - $specifically = ($ca_priority == $fa_priority ? t('Specifically, any grants given by !Content_Access cannot be taken back by !Forum_Access.', $variables) : ''); |
|
277 | - if ($is_conflict) { |
|
275 | + ); |
|
276 | + $specifically = ($ca_priority == $fa_priority ? t('Specifically, any grants given by !Content_Access cannot be taken back by !Forum_Access.', $variables) : ''); |
|
277 | + if ($is_conflict) { |
|
278 | 278 | $form['forum_access']['interference']['by_content_access'] = array( |
279 | - '#type' => 'fieldset', |
|
280 | - '#title' => 'Content Access', |
|
281 | - '#collapsible' => FALSE, |
|
282 | - '#attributes' => array('class' => 'error'), |
|
279 | + '#type' => 'fieldset', |
|
280 | + '#title' => 'Content Access', |
|
281 | + '#collapsible' => FALSE, |
|
282 | + '#attributes' => array('class' => 'error'), |
|
283 | 283 | ); |
284 | 284 | $form['forum_access']['interference']['by_content_access'][] = array( |
285 | - '#value' => '<div>'. t('You have set the !Content_Access module to control access to content of type %content_type—this can interfere with proper operation of !Forum_Access!', $variables) ." $specifically</div>", |
|
285 | + '#value' => '<div>'. t('You have set the !Content_Access module to control access to content of type %content_type—this can interfere with proper operation of !Forum_Access!', $variables) ." $specifically</div>", |
|
286 | 286 | ); |
287 | 287 | if ($ca_priority == $fa_priority) { |
288 | - $form['forum_access']['interference']['by_content_access'][] = array( |
|
288 | + $form['forum_access']['interference']['by_content_access'][] = array( |
|
289 | 289 | '#value' => '<div>'. t("Unless you really know what you're doing, we recommend that you go to the !link page and clear all checkboxes. This will instruct @Content_Access to leave the %content_type nodes alone. However, if you put nodes of other content types into forums as well, then these content types will continue to have this problem.", $variables) .'</div>', |
290 | - ); |
|
290 | + ); |
|
291 | 291 | } |
292 | 292 | else { |
293 | - $form['forum_access']['interference']['by_content_access'][] = array( |
|
293 | + $form['forum_access']['interference']['by_content_access'][] = array( |
|
294 | 294 | '#value' => '<div>'. t("The priority of @Content_Access ($ca_priority) is higher than the priority of !Forum_Access ($fa_priority), which means the latter is <strong>completely disabled</strong> for the %content_type type! Unless you really know what you're doing, we recommend that you go to the !link page, change the priority (under %Advanced) to 0, and clear all checkboxes.", $variables) .'</div>', |
295 | - ); |
|
295 | + ); |
|
296 | 296 | } |
297 | 297 | $form['forum_access']['interference']['by_content_access'][] = array( |
298 | - '#value' => '<div>'. t("Alternatively, you can give !Forum_Access priority over @Content_Access by either raising the priority of !Forum_Access in every forum above the priority of @Content_Access, or by lowering the priority of @Content_Access for the content types in question below the priority of !Forum_Access.", $variables) .'</div>', |
|
298 | + '#value' => '<div>'. t("Alternatively, you can give !Forum_Access priority over @Content_Access by either raising the priority of !Forum_Access in every forum above the priority of @Content_Access, or by lowering the priority of @Content_Access for the content types in question below the priority of !Forum_Access.", $variables) .'</div>', |
|
299 | 299 | ); |
300 | - } |
|
301 | - else { |
|
300 | + } |
|
301 | + else { |
|
302 | 302 | $form['forum_access']['interference'][] = array( |
303 | - '#value' => '<p>'. t('Note: You have installed the !Content_Access module, which has the capability to grant access to content that would otherwise be protected by !Forum_Access. Be careful when configuring @Content_Access!', $variables) .'</p>', |
|
303 | + '#value' => '<p>'. t('Note: You have installed the !Content_Access module, which has the capability to grant access to content that would otherwise be protected by !Forum_Access. Be careful when configuring @Content_Access!', $variables) .'</p>', |
|
304 | 304 | ); |
305 | - } |
|
305 | + } |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | $form['forum_access']['interference']['advanced'] = array( |
309 | - '#type' => 'fieldset', |
|
310 | - '#title' => t('Advanced'), |
|
311 | - '#collapsible' => TRUE, |
|
312 | - '#collapsed' => !($fa_priority != 0), |
|
309 | + '#type' => 'fieldset', |
|
310 | + '#title' => t('Advanced'), |
|
311 | + '#collapsible' => TRUE, |
|
312 | + '#collapsed' => !($fa_priority != 0), |
|
313 | 313 | ); |
314 | 314 | $form['forum_access']['interference']['advanced']['priority'] = array( |
315 | - '#type' => 'weight', |
|
316 | - '#title' => t('Priority of !Forum_Access node grants in this forum', $variables), |
|
317 | - '#default_value' => $fa_priority, |
|
318 | - '#description' => t("If you have no other node access control modules installed, you should leave this at the default 0. <br /> Otherwise you can raise or lower the priority of !Forum_Access' grants. Out of all the grants contributed to a node, only those with the highest priority are used, and all others are discarded.", $variables), |
|
315 | + '#type' => 'weight', |
|
316 | + '#title' => t('Priority of !Forum_Access node grants in this forum', $variables), |
|
317 | + '#default_value' => $fa_priority, |
|
318 | + '#description' => t("If you have no other node access control modules installed, you should leave this at the default 0. <br /> Otherwise you can raise or lower the priority of !Forum_Access' grants. Out of all the grants contributed to a node, only those with the highest priority are used, and all others are discarded.", $variables), |
|
319 | 319 | ); |
320 | - } |
|
320 | + } |
|
321 | 321 | |
322 | - if (!$is_container) { |
|
322 | + if (!$is_container) { |
|
323 | 323 | $variables = array( |
324 | - '!Forum_Access' => l('Forum Access', 'http://drupal.org/project/forum_access'), |
|
325 | - '!ACL' => l('ACL', 'http://drupal.org/project/acl'), |
|
326 | - '%Module_interference' => t('Module interference'), |
|
327 | - '!Forum_Access-dev' => l('Forum Access 6.x-1.x-dev', 'http://drupal.org/node/96795', array('html' => TRUE)), |
|
328 | - '!ACL-dev' => l('ACL 6.x-1.x-dev', 'http://drupal.org/node/96794', array('html' => TRUE)), |
|
329 | - '%devel_node_access' => 'devel_node_access', |
|
330 | - '!Devel' => l('Devel', 'http://drupal.org/project/devel'), |
|
331 | - '!DNA' => 'DNA', |
|
332 | - '!debug_mode' => l('debug mode', 'admin/settings/devel', array('fragment' => 'edit-devel-node-access-debug-mode')), |
|
333 | - '!dna_summary' => l('devel/node_access/summary', 'devel/node_access/summary'), |
|
334 | - '!Rebuild_permissions' => '['. $tr('Rebuild permissions') .']', |
|
335 | - '!Post_settings_link' => l('admin/content/node-settings', 'admin/content/node-settings'), |
|
336 | - '!Forum_Access_' => l('Forum Access', 'http://drupal.org/project/issues/forum_access'), |
|
337 | - '!ACL_' => l('ACL', 'http://drupal.org/project/issues/acl'), |
|
324 | + '!Forum_Access' => l('Forum Access', 'http://drupal.org/project/forum_access'), |
|
325 | + '!ACL' => l('ACL', 'http://drupal.org/project/acl'), |
|
326 | + '%Module_interference' => t('Module interference'), |
|
327 | + '!Forum_Access-dev' => l('Forum Access 6.x-1.x-dev', 'http://drupal.org/node/96795', array('html' => TRUE)), |
|
328 | + '!ACL-dev' => l('ACL 6.x-1.x-dev', 'http://drupal.org/node/96794', array('html' => TRUE)), |
|
329 | + '%devel_node_access' => 'devel_node_access', |
|
330 | + '!Devel' => l('Devel', 'http://drupal.org/project/devel'), |
|
331 | + '!DNA' => 'DNA', |
|
332 | + '!debug_mode' => l('debug mode', 'admin/settings/devel', array('fragment' => 'edit-devel-node-access-debug-mode')), |
|
333 | + '!dna_summary' => l('devel/node_access/summary', 'devel/node_access/summary'), |
|
334 | + '!Rebuild_permissions' => '['. $tr('Rebuild permissions') .']', |
|
335 | + '!Post_settings_link' => l('admin/content/node-settings', 'admin/content/node-settings'), |
|
336 | + '!Forum_Access_' => l('Forum Access', 'http://drupal.org/project/issues/forum_access'), |
|
337 | + '!ACL_' => l('ACL', 'http://drupal.org/project/issues/acl'), |
|
338 | 338 | ); |
339 | 339 | $form['forum_access']['troubleshooting'] = array( |
340 | - '#type' => 'fieldset', |
|
341 | - '#title' => t('Trouble-shooting node access'), |
|
342 | - '#collapsible' => TRUE, |
|
343 | - '#collapsed' => TRUE, |
|
340 | + '#type' => 'fieldset', |
|
341 | + '#title' => t('Trouble-shooting node access'), |
|
342 | + '#collapsible' => TRUE, |
|
343 | + '#collapsed' => TRUE, |
|
344 | 344 | ); |
345 | 345 | $form['forum_access']['troubleshooting'][] = array( |
346 | - '#type' => 'item', |
|
347 | - '#value' => '<div>'. t("In case of problems, follow these steps until you've got it worked out:") .'<ol style="margin-top: 0"><li>'. |
|
348 | - t("Update to the 'recommended' !Forum_Access and !ACL releases for your version of Drupal.", $variables) .'</li><li>'. |
|
346 | + '#type' => 'item', |
|
347 | + '#value' => '<div>'. t("In case of problems, follow these steps until you've got it worked out:") .'<ol style="margin-top: 0"><li>'. |
|
348 | + t("Update to the 'recommended' !Forum_Access and !ACL releases for your version of Drupal.", $variables) .'</li><li>'. |
|
349 | 349 | (count($na_modules) ? t("Read %Module_interference above and update your other node access modules.", $variables) .'</li><li>' : '') . |
350 | - t("Check the release notes of the development snapshots for issues that might have been fixed in !Forum_Access-dev or !ACL-dev since the latest release.", $variables) .'</li><li>'. |
|
351 | - t("Install the %devel_node_access module (!DNA, part of the !Devel module) and enable its !debug_mode: !DNA will show you all the grants that actually control your nodes in a footer block on each node's page.", $variables) .'</li><li>'. |
|
352 | - t("Additional insight can be gained from !dna_summary and by enabling the second !DNA block.", $variables) .'</li><li>'. |
|
353 | - t("Click !Rebuild_permissions on !Post_settings_link and check DNA for changes.", $variables) .'</li><li>'. |
|
354 | - t("Check the issues queues of !Forum_Access_ and !ACL_ for existing reports and possible solutions.", $variables) .'</li><li>'. |
|
355 | - t("If all of this hasn't helped, then pick ONE node that is misbehaving, look at it using an account that can see the node (and that should NOT have access if that's your problem!), create a new issue in the issues queue, describe the problem... <ul><li> what did you do? </li><li> what did you expect? </li><li> what happened instead? </li></ul> ... and <strong>attach a screenshot of all the DNA records</strong> for that one node. <br /> Be sure to indicate paths (URLs) for every page and module that you mention.") .'</li></ol></div>', |
|
350 | + t("Check the release notes of the development snapshots for issues that might have been fixed in !Forum_Access-dev or !ACL-dev since the latest release.", $variables) .'</li><li>'. |
|
351 | + t("Install the %devel_node_access module (!DNA, part of the !Devel module) and enable its !debug_mode: !DNA will show you all the grants that actually control your nodes in a footer block on each node's page.", $variables) .'</li><li>'. |
|
352 | + t("Additional insight can be gained from !dna_summary and by enabling the second !DNA block.", $variables) .'</li><li>'. |
|
353 | + t("Click !Rebuild_permissions on !Post_settings_link and check DNA for changes.", $variables) .'</li><li>'. |
|
354 | + t("Check the issues queues of !Forum_Access_ and !ACL_ for existing reports and possible solutions.", $variables) .'</li><li>'. |
|
355 | + t("If all of this hasn't helped, then pick ONE node that is misbehaving, look at it using an account that can see the node (and that should NOT have access if that's your problem!), create a new issue in the issues queue, describe the problem... <ul><li> what did you do? </li><li> what did you expect? </li><li> what happened instead? </li></ul> ... and <strong>attach a screenshot of all the DNA records</strong> for that one node. <br /> Be sure to indicate paths (URLs) for every page and module that you mention.") .'</li></ol></div>', |
|
356 | 356 | ); |
357 | 357 | $form['forum_access']['troubleshooting'][] = array( |
358 | - '#type' => 'item', |
|
359 | - '#value' => '<div>'. t("Note: You should not keep the !Devel module enabled on a production site.", $variables) .'</div>', |
|
358 | + '#type' => 'item', |
|
359 | + '#value' => '<div>'. t("Note: You should not keep the !Devel module enabled on a production site.", $variables) .'</div>', |
|
360 | 360 | ); |
361 | - } |
|
361 | + } |
|
362 | 362 | |
363 | - if (!$is_container && isset($tid) && !node_access_needs_rebuild()) { |
|
363 | + if (!$is_container && isset($tid) && !node_access_needs_rebuild()) { |
|
364 | 364 | $count = db_result(db_query("SELECT COUNT(DISTINCT n.nid) FROM {node} n INNER JOIN {term_node} tn ON tn.vid = n.vid WHERE tn.tid = %d", $tid)); |
365 | 365 | $limit = 20; // from _node_access_rebuild_batch_operation() |
366 | 366 | $threshold = variable_get('forum_access_batch_threshold', $limit); // change the variable if you want |
367 | 367 | $form['forum_access']['update_limit'] = array( |
368 | - '#type' => 'value', |
|
369 | - '#value' => $limit, |
|
368 | + '#type' => 'value', |
|
369 | + '#value' => $limit, |
|
370 | 370 | ); |
371 | 371 | $form['forum_access']['update_choice'] = array( |
372 | - '#type' => 'radios', |
|
373 | - '#title' => 'Update the permissions', |
|
374 | - '#description' => t('<em>If</em> you make any node access changes, then each node in this forum needs to be updated. Hover over the radiobuttons for details.'), |
|
375 | - '#options' => NULL, |
|
376 | - 0 => array( |
|
372 | + '#type' => 'radios', |
|
373 | + '#title' => 'Update the permissions', |
|
374 | + '#description' => t('<em>If</em> you make any node access changes, then each node in this forum needs to be updated. Hover over the radiobuttons for details.'), |
|
375 | + '#options' => NULL, |
|
376 | + 0 => array( |
|
377 | 377 | '#type' => 'radio', |
378 | 378 | '#title' => t('for all %count nodes immediately', array('%count' => $count)), |
379 | 379 | '#attributes' => array('title' => t('This option is the fastest, but with many nodes it can still take considerable time and memory. If it fails, it will leave your !node_access table in an inconsistent state.', array('!node_access' => '{node_access}'))), |
380 | 380 | '#return_value' => 0, |
381 | 381 | '#default_value' => ($count <= $threshold ? 0 : 1), |
382 | 382 | '#parents' => array('forum_access', 'update_choice'), |
383 | - ), |
|
384 | - 1 => array( |
|
383 | + ), |
|
384 | + 1 => array( |
|
385 | 385 | '#type' => 'radio', |
386 | 386 | '#title' => t('in batches of !limit now', array('!limit' => $limit)), |
387 | 387 | '#attributes' => array('title' => t('The batch option will always work reliably, but it takes longer to complete.')), |
388 | 388 | '#return_value' => 1, |
389 | 389 | '#default_value' => ($count <= $threshold ? 0 : 1), |
390 | 390 | '#parents' => array('forum_access', 'update_choice'), |
391 | - ), |
|
392 | - 2 => array( |
|
391 | + ), |
|
392 | + 2 => array( |
|
393 | 393 | '#type' => 'radio', |
394 | 394 | '#title' => t('rebuild <strong>all</strong> permissions later'), |
395 | 395 | '#attributes' => array('title' => t("This option will only set a flag to remind you to rebuild all permissions later; this is useful if you want to make multiple changes to your node access settings quickly and delay the updating until you're done.")), |
396 | 396 | '#return_value' => 2, |
397 | 397 | '#default_value' => ($count <= $threshold ? 0 : 1), |
398 | 398 | '#parents' => array('forum_access', 'update_choice'), |
399 | - ), |
|
400 | - '#attributes' => array('class' => 'forum-access-flowed'), |
|
399 | + ), |
|
400 | + '#attributes' => array('class' => 'forum-access-flowed'), |
|
401 | 401 | ); |
402 | - } |
|
403 | - if (isset($tid)) { |
|
402 | + } |
|
403 | + if (isset($tid)) { |
|
404 | 404 | $form['forum_access']['force_update'] = array( |
405 | - '#type' => 'checkbox', |
|
406 | - '#title' => t('Update even if unchanged'), |
|
405 | + '#type' => 'checkbox', |
|
406 | + '#title' => t('Update even if unchanged'), |
|
407 | 407 | ); |
408 | - } |
|
408 | + } |
|
409 | 409 | |
410 | - // Move some stuff down so our block goes in a nice place. |
|
411 | - $form['submit']['#weight'] = 10; |
|
412 | - $form['delete']['#weight'] = 10; |
|
410 | + // Move some stuff down so our block goes in a nice place. |
|
411 | + $form['submit']['#weight'] = 10; |
|
412 | + $form['delete']['#weight'] = 10; |
|
413 | 413 | |
414 | - $form['#validate'][] = '_forum_access_form_validate'; |
|
415 | - $form['#submit'][] = '_forum_access_form_submit'; |
|
414 | + $form['#validate'][] = '_forum_access_form_validate'; |
|
415 | + $form['#submit'][] = '_forum_access_form_submit'; |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | /** |
@@ -420,82 +420,82 @@ discard block |
||
420 | 420 | * are the permissions of the corresponding role. |
421 | 421 | */ |
422 | 422 | function _forum_access_get_role_permissions() { |
423 | - static $permissions; |
|
424 | - if (empty($permissions)) { |
|
423 | + static $permissions; |
|
424 | + if (empty($permissions)) { |
|
425 | 425 | $permissions[DRUPAL_AUTHENTICATED_RID] = array(); |
426 | 426 | $result = db_query('SELECT r.rid, p.perm FROM {role} r INNER JOIN {permission} p ON r.rid = p.rid ORDER BY r.rid'); |
427 | 427 | while ($role = db_fetch_object($result)) { |
428 | - $permissions[$role->rid] = ($role->rid == DRUPAL_ANONYMOUS_RID ? array() : $permissions[DRUPAL_AUTHENTICATED_RID]); |
|
429 | - $permissions[$role->rid] += array_flip(explode(', ', $role->perm)); |
|
428 | + $permissions[$role->rid] = ($role->rid == DRUPAL_ANONYMOUS_RID ? array() : $permissions[DRUPAL_AUTHENTICATED_RID]); |
|
429 | + $permissions[$role->rid] += array_flip(explode(', ', $role->perm)); |
|
430 | + } |
|
430 | 431 | } |
431 | - } |
|
432 | - return $permissions; |
|
432 | + return $permissions; |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | function _forum_access_forum_form_disable_checkboxes($element) { |
436 | - global $user; |
|
437 | - $tr = 't'; |
|
438 | - $moderator_rid = forum_access_query_moderator_rid(); |
|
436 | + global $user; |
|
437 | + $tr = 't'; |
|
438 | + $moderator_rid = forum_access_query_moderator_rid(); |
|
439 | 439 | |
440 | - $permissions = _forum_access_get_role_permissions(); |
|
441 | - $element_children = element_children($element); |
|
442 | - foreach ($element_children as $rid) { |
|
440 | + $permissions = _forum_access_get_role_permissions(); |
|
441 | + $element_children = element_children($element); |
|
442 | + foreach ($element_children as $rid) { |
|
443 | 443 | if ($rid == $moderator_rid) { |
444 | - $element[$rid]['#prefix'] = '<span title="'. t("This is the (temporary) @Forum_Moderator role; it has the '@administer_nodes' and '@administer_comments' permissions and is only used temporarily by @Forum_Access — do NOT give this role to any user!", array('@Forum_Moderator' => t('Forum Moderator'), '@administer_nodes' => $tr('administer nodes'), '@administer_comments' => $tr('administer comments'), '@Forum_Access' => 'Forum Access')) .'" class="forum-access-temporary-moderator">'; |
|
445 | - $element[$rid]['#suffix'] = "</span>"; |
|
446 | - $element[$rid]['#default_value'] = TRUE; |
|
447 | - $element[$rid]['#disabled'] = TRUE; |
|
444 | + $element[$rid]['#prefix'] = '<span title="'. t("This is the (temporary) @Forum_Moderator role; it has the '@administer_nodes' and '@administer_comments' permissions and is only used temporarily by @Forum_Access — do NOT give this role to any user!", array('@Forum_Moderator' => t('Forum Moderator'), '@administer_nodes' => $tr('administer nodes'), '@administer_comments' => $tr('administer comments'), '@Forum_Access' => 'Forum Access')) .'" class="forum-access-temporary-moderator">'; |
|
445 | + $element[$rid]['#suffix'] = "</span>"; |
|
446 | + $element[$rid]['#default_value'] = TRUE; |
|
447 | + $element[$rid]['#disabled'] = TRUE; |
|
448 | 448 | } |
449 | 449 | elseif ($element['#parents'][1] == 'create') { |
450 | - // Do nothing (Post is always mutable). |
|
450 | + // Do nothing (Post is always mutable). |
|
451 | 451 | } |
452 | 452 | elseif ($element['#parents'][1] == 'comment_create') { |
453 | 453 | } |
454 | 454 | elseif ($element['#parents'][1] == 'view' && isset($permissions[$rid]['administer forums'])) { |
455 | - $element[$rid]['#title'] = '<em>'. $element[$rid]['#title'] .'</em>'; |
|
456 | - $element[$rid]['#prefix'] = '<span title="'. t("This role has the '@administer_forums' permission, and granting '@View' enables the role holders to change the settings on this page, including @Access_control!", array('@administer_forums' => $tr('administer forums'), '@View' => t('View'), '@Access_control' => t('Access control'))) .'">'; |
|
457 | - if (isset($permissions[$rid]['administer nodes'])) { |
|
455 | + $element[$rid]['#title'] = '<em>'. $element[$rid]['#title'] .'</em>'; |
|
456 | + $element[$rid]['#prefix'] = '<span title="'. t("This role has the '@administer_forums' permission, and granting '@View' enables the role holders to change the settings on this page, including @Access_control!", array('@administer_forums' => $tr('administer forums'), '@View' => t('View'), '@Access_control' => t('Access control'))) .'">'; |
|
457 | + if (isset($permissions[$rid]['administer nodes'])) { |
|
458 | 458 | $element[$rid]['#prefix'] = str_replace('">', ' '. t("Because the role also has the '@administer_nodes' permission, it has full access to all nodes either way.", array('@administer_nodes' => $tr('administer nodes'))) .'">', $element[$rid]['#prefix']); |
459 | - } |
|
460 | - $element[$rid]['#suffix'] = "</span>"; |
|
459 | + } |
|
460 | + $element[$rid]['#suffix'] = "</span>"; |
|
461 | 461 | } |
462 | 462 | elseif (isset($permissions[$rid]['administer nodes'])) { |
463 | - $element[$rid]['#disabled'] = TRUE; |
|
464 | - $element[$rid]['#default_value'] = TRUE; |
|
465 | - $element[$rid]['#prefix'] = '<span title="'. ($rid != $moderator_rid |
|
463 | + $element[$rid]['#disabled'] = TRUE; |
|
464 | + $element[$rid]['#default_value'] = TRUE; |
|
465 | + $element[$rid]['#prefix'] = '<span title="'. ($rid != $moderator_rid |
|
466 | 466 | ? t("This role has the '@administer_nodes' permission and thus full access to all nodes.", array('@administer_nodes' => $tr('administer nodes'))) |
467 | 467 | : t("This is the @Forum_Moderator role; it has the '@administer_nodes' and '@administer_comments' permissions and thus full access to all nodes and comments.", array('@Forum_Moderator' => t('Forum Moderator'), '@administer_nodes' => $tr('administer nodes'), '@administer_comments' => $tr('administer comments')))) .'">'; |
468 | - $element[$rid]['#suffix'] = "</span>"; |
|
468 | + $element[$rid]['#suffix'] = "</span>"; |
|
469 | + } |
|
469 | 470 | } |
470 | - } |
|
471 | - return $element; |
|
471 | + return $element; |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | function _forum_access_forum_form_after_build_acl0($form, $form_state) { |
475 | - if (isset($form['#post']['forum_access']['template']['taxonomy'])) { |
|
475 | + if (isset($form['#post']['forum_access']['template']['taxonomy'])) { |
|
476 | 476 | // Get ACL's user_list for the template and replace it before ACL's after_build function gets its shot at it. |
477 | 477 | $imv = array_values($form['#post']['forum_access']['template']['taxonomy']); |
478 | 478 | $template_tid = reset($imv); |
479 | 479 | if ($acl_id = acl_get_id_by_number('forum_access', $template_tid)) { |
480 | - $f = acl_edit_form($acl_id, 'DUMMY'); |
|
481 | - $form['user_list']['#value'] = $f['user_list']['#default_value']; |
|
480 | + $f = acl_edit_form($acl_id, 'DUMMY'); |
|
481 | + $form['user_list']['#value'] = $f['user_list']['#default_value']; |
|
482 | 482 | } |
483 | - } |
|
484 | - return $form; |
|
483 | + } |
|
484 | + return $form; |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | function _forum_access_forum_form_after_build_acl2($form, $form_state) { |
488 | - if (!count(unserialize($form['user_list']['#default_value'])) && !count(unserialize($form['user_list']['#value']))) { |
|
488 | + if (!count(unserialize($form['user_list']['#default_value'])) && !count(unserialize($form['user_list']['#value']))) { |
|
489 | 489 | $form['#collapsed'] = TRUE; |
490 | - } |
|
491 | - if ($form['user_list']['#default_value'] != $form['user_list']['#value']) { |
|
490 | + } |
|
491 | + if ($form['user_list']['#default_value'] != $form['user_list']['#value']) { |
|
492 | 492 | $form['note']['#value'] = preg_replace('/<div>/', '<div class="warning">', $form['note']['#value']); |
493 | - } |
|
494 | - return $form; |
|
493 | + } |
|
494 | + return $form; |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | function _forum_access_forum_form_after_build($form, &$form_state) { |
498 | - if (isset($form_state['clicked_button']['#name']) && $form_state['clicked_button']['#name'] == $form['template']['load_button']['#name']) { |
|
498 | + if (isset($form_state['clicked_button']['#name']) && $form_state['clicked_button']['#name'] == $form['template']['load_button']['#name']) { |
|
499 | 499 | // Load a setting from a template: |
500 | 500 | $template_tid = reset(array_values($form['#post']['forum_access']['template']['taxonomy'])); |
501 | 501 | $form_state['values']['forum_access']['template']['template_tid'] = $template_tid; |
@@ -503,158 +503,158 @@ discard block |
||
503 | 503 | |
504 | 504 | $settings = _forum_access_get_settings($template_tid); |
505 | 505 | foreach (array('view', 'create', 'comment_create', 'update', 'delete') as $grant_type) { |
506 | - if (empty($form[$grant_type])) { |
|
506 | + if (empty($form[$grant_type])) { |
|
507 | 507 | continue; |
508 | - } |
|
509 | - foreach (element_children($form[$grant_type]) as $tid) { |
|
508 | + } |
|
509 | + foreach (element_children($form[$grant_type]) as $tid) { |
|
510 | 510 | $checked = array_search($tid, $settings[$grant_type]) !== FALSE; |
511 | 511 | $form[$grant_type][$tid]['#value'] = ($checked ? $tid : 0); |
512 | - } |
|
512 | + } |
|
513 | 513 | } |
514 | 514 | $form['interference']['advanced']['priority']['#value'] = $settings['priority']; |
515 | 515 | if ($settings['priority'] != 0) { |
516 | - $form['interference']['advanced']['#collapsed'] = FALSE; |
|
516 | + $form['interference']['advanced']['#collapsed'] = FALSE; |
|
517 | 517 | } |
518 | - } |
|
519 | - elseif (is_array(reset($form_state['values']['forum_access']['template']['taxonomy']))) { |
|
520 | - $imv = reset($form_state['values']['forum_access']['template']['taxonomy']); |
|
518 | + } |
|
519 | + elseif (is_array(reset($form_state['values']['forum_access']['template']['taxonomy']))) { |
|
520 | + $imv = reset($form_state['values']['forum_access']['template']['taxonomy']); |
|
521 | 521 | $template_tid = reset($imv); |
522 | - } |
|
523 | - if (isset($template_tid)) { |
|
522 | + } |
|
523 | + if (isset($template_tid)) { |
|
524 | 524 | $form['template']['select_by_default']['#value'] = ($template_tid && $template_tid == variable_get('forum_access_default_template_tid', 0)); |
525 | 525 | $form['template']['load_for_new']['#value'] = ($template_tid && $template_tid == variable_get('forum_access_new_template_tid', 0)); |
526 | - } |
|
527 | - return $form; |
|
526 | + } |
|
527 | + return $form; |
|
528 | 528 | } |
529 | 529 | |
530 | 530 | function _forum_access_form_validate($form, &$form_state) { |
531 | - global $user; |
|
531 | + global $user; |
|
532 | 532 | |
533 | - if ($user->uid == 1) { |
|
533 | + if ($user->uid == 1) { |
|
534 | 534 | return; |
535 | - } |
|
536 | - $access = $form_state['values']['forum_access']; // shortcut |
|
537 | - foreach ($access['view'] as $rid => $checked) { |
|
535 | + } |
|
536 | + $access = $form_state['values']['forum_access']; // shortcut |
|
537 | + foreach ($access['view'] as $rid => $checked) { |
|
538 | 538 | if ($checked && isset($user->roles[$rid])) { |
539 | - return; |
|
539 | + return; |
|
540 | + } |
|
540 | 541 | } |
541 | - } |
|
542 | - form_set_error('forum_access][view', t('You must assign %View access to a role that you hold.', array('%View' => 'View'))); |
|
542 | + form_set_error('forum_access][view', t('You must assign %View access to a role that you hold.', array('%View' => 'View'))); |
|
543 | 543 | } |
544 | 544 | |
545 | 545 | function _forum_access_form_submit($form, &$form_state) { |
546 | - $access = $form_state['values']['forum_access']; // shortcut |
|
546 | + $access = $form_state['values']['forum_access']; // shortcut |
|
547 | 547 | |
548 | - // Save template choice: |
|
549 | - $template_tid = reset(array_values($access['template']['taxonomy'])); |
|
550 | - if ($access['template']['select_by_default']) { |
|
548 | + // Save template choice: |
|
549 | + $template_tid = reset(array_values($access['template']['taxonomy'])); |
|
550 | + if ($access['template']['select_by_default']) { |
|
551 | 551 | variable_set('forum_access_default_template_tid', $template_tid); |
552 | - } |
|
553 | - elseif (variable_get('forum_access_default_template_tid', 0) == $template_tid) { |
|
552 | + } |
|
553 | + elseif (variable_get('forum_access_default_template_tid', 0) == $template_tid) { |
|
554 | 554 | variable_del('forum_access_default_template_tid'); |
555 | - } |
|
556 | - if ($access['template']['load_for_new']) { |
|
555 | + } |
|
556 | + if ($access['template']['load_for_new']) { |
|
557 | 557 | variable_set('forum_access_new_template_tid', $template_tid); |
558 | - } |
|
559 | - elseif (variable_get('forum_access_new_template_tid', 0) == $template_tid) { |
|
558 | + } |
|
559 | + elseif (variable_get('forum_access_new_template_tid', 0) == $template_tid) { |
|
560 | 560 | variable_del('forum_access_new_template_tid'); |
561 | - } |
|
562 | - module_load_include('node.inc', 'forum_access'); |
|
563 | - $moderator_rid = _forum_access_get_moderator_rid(TRUE); // create the moderators role if it doesn't exist |
|
564 | - |
|
565 | - // check for changes |
|
566 | - $is_changed = $is_new = strpos($_GET['q'], 'admin/content/forum/add/') === 0; |
|
567 | - $is_changed = $is_changed || !empty($access['force_update']); |
|
568 | - $form_initial_values = $form; // avoid Coder warning |
|
569 | - $form_initial_values = $form_initial_values['forum_access']; |
|
570 | - foreach (array('view', 'create', 'comment_create', 'update', 'delete') as $grant_type) { |
|
561 | + } |
|
562 | + module_load_include('node.inc', 'forum_access'); |
|
563 | + $moderator_rid = _forum_access_get_moderator_rid(TRUE); // create the moderators role if it doesn't exist |
|
564 | + |
|
565 | + // check for changes |
|
566 | + $is_changed = $is_new = strpos($_GET['q'], 'admin/content/forum/add/') === 0; |
|
567 | + $is_changed = $is_changed || !empty($access['force_update']); |
|
568 | + $form_initial_values = $form; // avoid Coder warning |
|
569 | + $form_initial_values = $form_initial_values['forum_access']; |
|
570 | + foreach (array('view', 'create', 'comment_create', 'update', 'delete') as $grant_type) { |
|
571 | 571 | if (isset($form_initial_values[$grant_type])) { |
572 | - $defaults = $form_initial_values[$grant_type]['#default_value']; |
|
573 | - $defaults = array_flip($defaults); |
|
574 | - foreach ($access[$grant_type] as $rid => $checked) { |
|
572 | + $defaults = $form_initial_values[$grant_type]['#default_value']; |
|
573 | + $defaults = array_flip($defaults); |
|
574 | + foreach ($access[$grant_type] as $rid => $checked) { |
|
575 | 575 | $is_changed = $is_changed || (empty($form_initial_values[$grant_type][$rid]['#disabled']) && !empty($checked) != isset($defaults[$rid])); |
576 | - } |
|
576 | + } |
|
577 | + } |
|
577 | 578 | } |
578 | - } |
|
579 | - if (!$is_changed && $access['acl']['user_list'] == $form_initial_values['acl']['user_list']['#default_value'] && $access['interference']['advanced']['priority'] == $form_initial_values['interference']['advanced']['priority']['#default_value']) { |
|
579 | + if (!$is_changed && $access['acl']['user_list'] == $form_initial_values['acl']['user_list']['#default_value'] && $access['interference']['advanced']['priority'] == $form_initial_values['interference']['advanced']['priority']['#default_value']) { |
|
580 | 580 | drupal_set_message(t('The content access permissions are unchanged.')); |
581 | 581 | return; |
582 | - } |
|
582 | + } |
|
583 | 583 | |
584 | - $tid = $form_state['values']['tid']; |
|
585 | - db_query("DELETE FROM {forum_access} WHERE tid = %d", $tid); |
|
584 | + $tid = $form_state['values']['tid']; |
|
585 | + db_query("DELETE FROM {forum_access} WHERE tid = %d", $tid); |
|
586 | 586 | |
587 | - $fa_priority = isset($access['interference']['advanced']['priority']) ? $access['interference']['advanced']['priority'] : 0; |
|
588 | - if (array_key_exists('acl', $access)) { |
|
587 | + $fa_priority = isset($access['interference']['advanced']['priority']) ? $access['interference']['advanced']['priority'] : 0; |
|
588 | + if (array_key_exists('acl', $access)) { |
|
589 | 589 | $moderators = unserialize($access['acl']['user_list']); |
590 | 590 | acl_save_form($access['acl'], $fa_priority); |
591 | - } |
|
592 | - $permissions = _forum_access_get_role_permissions(); |
|
593 | - foreach ($access['view'] as $rid => $checked) { |
|
591 | + } |
|
592 | + $permissions = _forum_access_get_role_permissions(); |
|
593 | + foreach ($access['view'] as $rid => $checked) { |
|
594 | 594 | if ($rid == $moderator_rid) { |
595 | - continue; |
|
595 | + continue; |
|
596 | 596 | } |
597 | 597 | if (isset($permissions[$rid]['administer nodes'])) { |
598 | - // We prefer not to save records for node administrators, because these have access anyway. |
|
599 | - if (isset($permissions[$rid]['administer forums']) && $access['view'][$rid]) { |
|
598 | + // We prefer not to save records for node administrators, because these have access anyway. |
|
599 | + if (isset($permissions[$rid]['administer forums']) && $access['view'][$rid]) { |
|
600 | 600 | // For forum administrators, View needs to be saved, ... |
601 | - } |
|
602 | - else { |
|
601 | + } |
|
602 | + else { |
|
603 | 603 | // ... otherwise forget View. |
604 | 604 | $access['view'][$rid] = FALSE; |
605 | - } |
|
606 | - if ($access['view'][$rid] || $access['create'][$rid] || $access['comment_create'][$rid]) { |
|
605 | + } |
|
606 | + if ($access['view'][$rid] || $access['create'][$rid] || $access['comment_create'][$rid]) { |
|
607 | 607 | db_query("INSERT INTO {forum_access} (tid, rid, grant_view, grant_update, grant_delete, grant_create, grant_comment_create, priority) VALUES (%d, %d, %d, %d, %d, %d, %d, %d)", |
608 | 608 | $tid, $rid, !empty($access['view'][$rid]), 0, 0, !empty($access['create'][$rid]), !empty($access['comment_create'][$rid]), $fa_priority); |
609 | - } |
|
609 | + } |
|
610 | 610 | } |
611 | 611 | else { |
612 | - db_query("INSERT INTO {forum_access} (tid, rid, grant_view, grant_update, grant_delete, grant_create, grant_comment_create, priority) VALUES (%d, %d, %d, %d, %d, %d, %d, %d)", |
|
613 | - $tid, $rid, (bool) $checked, !empty($access['update'][$rid]), !empty($access['delete'][$rid]), !empty($access['create'][$rid]), !empty($access['comment_create'][$rid]), $fa_priority); |
|
612 | + db_query("INSERT INTO {forum_access} (tid, rid, grant_view, grant_update, grant_delete, grant_create, grant_comment_create, priority) VALUES (%d, %d, %d, %d, %d, %d, %d, %d)", |
|
613 | + $tid, $rid, (bool) $checked, !empty($access['update'][$rid]), !empty($access['delete'][$rid]), !empty($access['create'][$rid]), !empty($access['comment_create'][$rid]), $fa_priority); |
|
614 | 614 | } |
615 | - } |
|
616 | - $tr = 't'; |
|
617 | - $link = l($tr('edit'), 'admin/content/forum/edit/forum/'. $tid); |
|
618 | - watchdog('access', 'Changed grants for %forum forum.', array('%forum' => $form_state['values']['name']), WATCHDOG_NOTICE, $link); |
|
615 | + } |
|
616 | + $tr = 't'; |
|
617 | + $link = l($tr('edit'), 'admin/content/forum/edit/forum/'. $tid); |
|
618 | + watchdog('access', 'Changed grants for %forum forum.', array('%forum' => $form_state['values']['name']), WATCHDOG_NOTICE, $link); |
|
619 | 619 | |
620 | - if (!$is_new && $form_state['values']['form_id'] != 'forum_form_container') { |
|
620 | + if (!$is_new && $form_state['values']['form_id'] != 'forum_form_container') { |
|
621 | 621 | if (!isset($access['update_choice']) || $access['update_choice'] == 2) { |
622 | - node_access_needs_rebuild(TRUE); |
|
622 | + node_access_needs_rebuild(TRUE); |
|
623 | 623 | } |
624 | 624 | elseif ($access['update_choice'] == 0) { |
625 | - // update immediately (but use the batch functions anyway |
|
626 | - $save_redirect = $form_state['redirect']; |
|
627 | - $form_state['redirect'] = $_GET['q']; |
|
628 | - $context = array(); |
|
629 | - $pending_error_messages = drupal_get_messages('error', FALSE); |
|
630 | - $our_error_message_index = (isset($pending_error_messages['error']) ? count($pending_error_messages['error']) : 0); |
|
631 | - _forum_access_update_batch_finished(FALSE, array(), array()); // add our error message (in case we die underway) |
|
632 | - _forum_access_update_batch_operation($tid, 999999, 1, $context); |
|
633 | - $pending_error_messages = drupal_get_messages('error', TRUE); // still alive, get and clear all 'error' messages |
|
634 | - unset($pending_error_messages['error'][$our_error_message_index]); // remove our error message |
|
635 | - foreach ($pending_error_messages['error'] as $message) { // replay any others |
|
625 | + // update immediately (but use the batch functions anyway |
|
626 | + $save_redirect = $form_state['redirect']; |
|
627 | + $form_state['redirect'] = $_GET['q']; |
|
628 | + $context = array(); |
|
629 | + $pending_error_messages = drupal_get_messages('error', FALSE); |
|
630 | + $our_error_message_index = (isset($pending_error_messages['error']) ? count($pending_error_messages['error']) : 0); |
|
631 | + _forum_access_update_batch_finished(FALSE, array(), array()); // add our error message (in case we die underway) |
|
632 | + _forum_access_update_batch_operation($tid, 999999, 1, $context); |
|
633 | + $pending_error_messages = drupal_get_messages('error', TRUE); // still alive, get and clear all 'error' messages |
|
634 | + unset($pending_error_messages['error'][$our_error_message_index]); // remove our error message |
|
635 | + foreach ($pending_error_messages['error'] as $message) { // replay any others |
|
636 | 636 | drupal_set_message($message, 'error'); |
637 | - } |
|
638 | - _forum_access_update_batch_finished(TRUE, array(), array()); |
|
639 | - $form_state['redirect'] = $save_redirect; |
|
637 | + } |
|
638 | + _forum_access_update_batch_finished(TRUE, array(), array()); |
|
639 | + $form_state['redirect'] = $save_redirect; |
|
640 | 640 | } |
641 | 641 | else { |
642 | - // mass update in batch mode, modeled after node.module |
|
643 | - $limit = $access['update_limit']; |
|
644 | - $count = db_result(db_query("SELECT COUNT(DISTINCT n.nid) FROM {node} n INNER JOIN {term_node} tn ON tn.vid = n.vid WHERE tn.tid = %d", $tid)); |
|
645 | - $batch = array( |
|
642 | + // mass update in batch mode, modeled after node.module |
|
643 | + $limit = $access['update_limit']; |
|
644 | + $count = db_result(db_query("SELECT COUNT(DISTINCT n.nid) FROM {node} n INNER JOIN {term_node} tn ON tn.vid = n.vid WHERE tn.tid = %d", $tid)); |
|
645 | + $batch = array( |
|
646 | 646 | 'title' => t('Updating content access permissions'), |
647 | 647 | 'file' => drupal_get_path('module', 'forum_access') .'/forum_access.admin.inc', |
648 | 648 | 'operations' => array( |
649 | - array('_forum_access_update_batch_operation', array($tid, $limit, $count)), |
|
649 | + array('_forum_access_update_batch_operation', array($tid, $limit, $count)), |
|
650 | 650 | ), |
651 | 651 | 'finished' => '_forum_access_update_batch_finished' |
652 | - ); |
|
653 | - batch_set($batch); |
|
652 | + ); |
|
653 | + batch_set($batch); |
|
654 | + } |
|
654 | 655 | } |
655 | - } |
|
656 | 656 | |
657 | - variable_del('forum_access_rids'); // clear cache |
|
657 | + variable_del('forum_access_rids'); // clear cache |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | /** |
@@ -665,73 +665,73 @@ discard block |
||
665 | 665 | * feedback after 1 second execution time. |
666 | 666 | */ |
667 | 667 | function _forum_access_update_batch_operation($tid, $limit, $count, &$context) { |
668 | - if (empty($context['sandbox'])) { |
|
668 | + if (empty($context['sandbox'])) { |
|
669 | 669 | // Initiate multistep processing. |
670 | 670 | $context['sandbox']['progress'] = 0; |
671 | 671 | $context['sandbox']['current_node'] = 0; |
672 | 672 | $context['sandbox']['max'] = $count; |
673 | - } |
|
673 | + } |
|
674 | 674 | |
675 | - // Process the next 20 nodes. |
|
676 | - $result = db_query_range("SELECT DISTINCT n.nid FROM {node} n INNER JOIN {term_node} tn ON tn.vid = n.vid WHERE n.nid > %d AND tn.tid = %d ORDER BY n.nid ASC", $context['sandbox']['current_node'], $tid, 0, $limit); |
|
677 | - while ($row = db_fetch_array($result)) { |
|
675 | + // Process the next 20 nodes. |
|
676 | + $result = db_query_range("SELECT DISTINCT n.nid FROM {node} n INNER JOIN {term_node} tn ON tn.vid = n.vid WHERE n.nid > %d AND tn.tid = %d ORDER BY n.nid ASC", $context['sandbox']['current_node'], $tid, 0, $limit); |
|
677 | + while ($row = db_fetch_array($result)) { |
|
678 | 678 | $loaded_node = node_load($row['nid'], NULL, TRUE); |
679 | 679 | // To preserve database integrity, only aquire grants if the node |
680 | 680 | // loads successfully. |
681 | 681 | if (!empty($loaded_node)) { |
682 | - node_access_acquire_grants($loaded_node); |
|
682 | + node_access_acquire_grants($loaded_node); |
|
683 | 683 | } |
684 | 684 | $context['sandbox']['progress']++; |
685 | 685 | $context['sandbox']['current_node'] = $loaded_node->nid; |
686 | - } |
|
686 | + } |
|
687 | 687 | |
688 | - // Multistep processing : report progress. |
|
689 | - if ($context['sandbox']['progress'] != $context['sandbox']['max']) { |
|
688 | + // Multistep processing : report progress. |
|
689 | + if ($context['sandbox']['progress'] != $context['sandbox']['max']) { |
|
690 | 690 | $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
691 | - } |
|
691 | + } |
|
692 | 692 | } |
693 | 693 | |
694 | 694 | /** |
695 | 695 | * Post-processing for forum_access_form_submit(). |
696 | 696 | */ |
697 | 697 | function _forum_access_update_batch_finished($success, $results, $operations) { |
698 | - if ($success) { |
|
698 | + if ($success) { |
|
699 | 699 | drupal_set_message(t('The content access permissions have been updated.')); |
700 | 700 | cache_clear_all(); |
701 | - } |
|
702 | - else { |
|
701 | + } |
|
702 | + else { |
|
703 | 703 | drupal_set_message(t('The content access permissions have not been properly updated.'), 'error'); |
704 | - } |
|
704 | + } |
|
705 | 705 | } |
706 | 706 | |
707 | 707 | /** |
708 | 708 | * Add our settings to the forum administration settings page. |
709 | 709 | */ |
710 | 710 | function _forum_access_forum_admin_settings_form(&$form, &$form_state) { |
711 | - $variables = array( |
|
711 | + $variables = array( |
|
712 | 712 | '!Forum_Access' => 'Forum Access', |
713 | 713 | '%View' => 'View', |
714 | 714 | '%Post' => 'Post', |
715 | 715 | '%post_comments' => 'post comments', |
716 | - ); |
|
717 | - $form['forum_access'] = array( |
|
716 | + ); |
|
717 | + $form['forum_access'] = array( |
|
718 | 718 | '#type' => 'fieldset', |
719 | 719 | '#title' => 'Forum Access', |
720 | 720 | '#attributes' => array('id' => 'edit-forum-admin-settings-forum-access'), |
721 | - ); |
|
722 | - $form['forum_access']['note'] = array( |
|
721 | + ); |
|
722 | + $form['forum_access']['note'] = array( |
|
723 | 723 | '#type' => 'item', |
724 | 724 | '#value' => t('Note: All other !Forum_Access controls are on the administration pages of the individual forums.', $variables), |
725 | - ); |
|
726 | - $form['forum_access']['forum_access_D5_legacy_mode'] = array( |
|
725 | + ); |
|
726 | + $form['forum_access']['forum_access_D5_legacy_mode'] = array( |
|
727 | 727 | '#type' => 'checkbox', |
728 | 728 | '#title' => t('Drupal 5 legacy mode', $variables), |
729 | 729 | '#default_value' => variable_get('forum_access_D5_legacy_mode', FALSE), |
730 | 730 | '#description' => t('In Drupal 5, comment posting was not restricted by !Forum_Access; users with %View access (and the %post_comments permission) were always allowed to post forum comments. Starting with Drupal 6, posting comments is now restricted to users with %Post access. Turn this option on to revert to the old behavior. The default is OFF.', $variables), |
731 | - ); |
|
732 | - $buttons = $form['buttons']; |
|
733 | - unset($form['buttons']); |
|
734 | - $form['buttons'] = $buttons; |
|
731 | + ); |
|
732 | + $buttons = $form['buttons']; |
|
733 | + unset($form['buttons']); |
|
734 | + $form['buttons'] = $buttons; |
|
735 | 735 | } |
736 | 736 | |
737 | 737 | /** |
@@ -739,63 +739,63 @@ discard block |
||
739 | 739 | */ |
740 | 740 | function _forum_access_get_settings($tid = NULL) { |
741 | 741 | $return = array('view' => array(), 'create' => array(), 'comment_create' => array(), 'update' => array(), 'delete' => array(), 'priority' => 0); |
742 | - if (!isset($tid)) { |
|
742 | + if (!isset($tid)) { |
|
743 | 743 | // Default to all users can read; all logged in users can post and comment. |
744 | 744 | $return['view'] = array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID); |
745 | 745 | $return['create'] = array(DRUPAL_AUTHENTICATED_RID); |
746 | 746 | $return['comment_create'] = array(DRUPAL_AUTHENTICATED_RID); |
747 | - } |
|
748 | - else { |
|
747 | + } |
|
748 | + else { |
|
749 | 749 | $result = db_query("SELECT * FROM {forum_access} where tid = %d", $tid); |
750 | 750 | while ($access = db_fetch_object($result)) { |
751 | - if ($access->grant_view) { |
|
751 | + if ($access->grant_view) { |
|
752 | 752 | $return['view'][] = $access->rid; |
753 | - } |
|
754 | - if ($access->grant_update) { |
|
753 | + } |
|
754 | + if ($access->grant_update) { |
|
755 | 755 | $return['update'][] = $access->rid; |
756 | - } |
|
757 | - if ($access->grant_delete) { |
|
756 | + } |
|
757 | + if ($access->grant_delete) { |
|
758 | 758 | $return['delete'][] = $access->rid; |
759 | - } |
|
760 | - if ($access->grant_create) { |
|
759 | + } |
|
760 | + if ($access->grant_create) { |
|
761 | 761 | $return['create'][] = $access->rid; |
762 | - } |
|
763 | - if ($access->grant_comment_create) { |
|
762 | + } |
|
763 | + if ($access->grant_comment_create) { |
|
764 | 764 | $return['comment_create'][] = $access->rid; |
765 | - } |
|
766 | - if ($access->rid == DRUPAL_AUTHENTICATED_RID) { // this is our reference |
|
765 | + } |
|
766 | + if ($access->rid == DRUPAL_AUTHENTICATED_RID) { // this is our reference |
|
767 | 767 | $return['priority'] = $access->priority; |
768 | - } |
|
768 | + } |
|
769 | + } |
|
769 | 770 | } |
770 | - } |
|
771 | - return $return; |
|
771 | + return $return; |
|
772 | 772 | } |
773 | 773 | |
774 | 774 | /** |
775 | 775 | * Remove unusable 'edit' links from overview form. |
776 | 776 | */ |
777 | 777 | function _forum_access_forum_overview(&$form, &$form_state) { |
778 | - global $user; |
|
779 | - if ($user->uid == 1) { |
|
778 | + global $user; |
|
779 | + if ($user->uid == 1) { |
|
780 | 780 | return; |
781 | - } |
|
782 | - foreach ($form as $key => $value) { |
|
781 | + } |
|
782 | + foreach ($form as $key => $value) { |
|
783 | 783 | if (preg_match('/^tid:(.*):0$/', $key, $matches)) { |
784 | - if (!forum_access_access($matches[1], 'view', NULL, FALSE)) { |
|
784 | + if (!forum_access_access($matches[1], 'view', NULL, FALSE)) { |
|
785 | 785 | $form[$key]['edit']['#access'] = FALSE; |
786 | 786 | if (preg_match('|<a [^>]*>([^<]*)</a>|', $form[$key]['view']['#value'], $matches)) { |
787 | - $form[$key]['view']['#value'] = $matches[1]; |
|
787 | + $form[$key]['view']['#value'] = $matches[1]; |
|
788 | + } |
|
788 | 789 | } |
789 | - } |
|
790 | 790 | } |
791 | - } |
|
791 | + } |
|
792 | 792 | } |
793 | 793 | |
794 | 794 | /** |
795 | 795 | * We must know when a role is deleted. |
796 | 796 | */ |
797 | 797 | function _forum_access_user_admin_role_form(&$form, &$form_state) { |
798 | - $form['#submit'][] = '_forum_access_user_admin_role_submit'; |
|
798 | + $form['#submit'][] = '_forum_access_user_admin_role_submit'; |
|
799 | 799 | } |
800 | 800 | |
801 | 801 | /** |
@@ -803,14 +803,14 @@ discard block |
||
803 | 803 | * Also, we complain if the Forum Moderator role is deleted. |
804 | 804 | */ |
805 | 805 | function _forum_access_user_admin_role_submit($form, &$form_state) { |
806 | - if ($form_state['values']['op'] == $form_state['values']['delete']) { |
|
806 | + if ($form_state['values']['op'] == $form_state['values']['delete']) { |
|
807 | 807 | $rid = $form_state['values']['rid']; |
808 | 808 | db_query("DELETE FROM {forum_access} WHERE rid = %d", $rid); |
809 | 809 | db_query("DELETE FROM {node_access} WHERE gid = %d AND realm = 'forum_access'", $rid); |
810 | 810 | if ($rid === forum_access_query_moderator_rid()) { |
811 | - drupal_set_message(t('The role you have just deleted is required by !Forum_Access; it will be recreated automatically.', array('!Forum_Access' => 'Forum Access')), 'error'); |
|
811 | + drupal_set_message(t('The role you have just deleted is required by !Forum_Access; it will be recreated automatically.', array('!Forum_Access' => 'Forum Access')), 'error'); |
|
812 | + } |
|
812 | 813 | } |
813 | - } |
|
814 | 814 | } |
815 | 815 | |
816 | 816 | /** |
@@ -818,27 +818,27 @@ discard block |
||
818 | 818 | * to control the same content types as we do. |
819 | 819 | */ |
820 | 820 | function _forum_access_content_access_admin_form() { |
821 | - $tr = 't'; |
|
822 | - $variables = array( |
|
821 | + $tr = 't'; |
|
822 | + $variables = array( |
|
823 | 823 | '!Content_Access' => 'Content Access', |
824 | 824 | '!Forum_Access' => 'Forum Access', |
825 | 825 | '!Forum_Access_link' => l('Forum Access', 'admin/content/forum'), |
826 | 826 | '%anonymous_user' => $tr('anonymous user'), |
827 | 827 | '%authenticated_user' => $tr('authenticated user'), |
828 | 828 | '%Advanced' => $tr('Advanced'), |
829 | - ); |
|
830 | - if (arg(3) == 'forum') { |
|
829 | + ); |
|
830 | + if (arg(3) == 'forum') { |
|
831 | 831 | drupal_set_message(t('Note: In Drupal, access can only be granted, not taken away. Whatever access you grant here will not be reflected in the !Forum_Access_link settings, but !Forum_Access can only allow <i>more</i> access, not less.', $variables) |
832 | - .'<br /><span class="error">'. t('Specifically, any rights granted to the %anonymous_user and/or the %authenticated_user will <b>override</b> the settings of !Forum_Access!', $variables) .'</span>' |
|
833 | - .'<br />'. t('To avoid conflicts with !Forum_Access settings, you may want to lower the priority of !Content_Access (under %Advanced below) below the priority of !Forum_Access for the content types that you want to be controlled by !Forum_Access.', $variables), 'warning'); |
|
834 | - } |
|
835 | - else { |
|
832 | + .'<br /><span class="error">'. t('Specifically, any rights granted to the %anonymous_user and/or the %authenticated_user will <b>override</b> the settings of !Forum_Access!', $variables) .'</span>' |
|
833 | + .'<br />'. t('To avoid conflicts with !Forum_Access settings, you may want to lower the priority of !Content_Access (under %Advanced below) below the priority of !Forum_Access for the content types that you want to be controlled by !Forum_Access.', $variables), 'warning'); |
|
834 | + } |
|
835 | + else { |
|
836 | 836 | $vid = _forum_access_get_vid(); |
837 | 837 | $vocabulary = taxonomy_vocabulary_load($vid); |
838 | 838 | if (isset($vocabulary->nodes[arg(3)])) { |
839 | - drupal_set_message(t('Note: Nodes of this content type can be put inside forums, where access to them will also be controlled by !Forum_Access.<br />In Drupal, access can only be granted, not taken away. Whatever access you grant here will not be reflected on the !Forum_Access_link settings, and vice versa, but any node access module can only allow <i>more</i> access, not less.', $variables), 'warning'); |
|
839 | + drupal_set_message(t('Note: Nodes of this content type can be put inside forums, where access to them will also be controlled by !Forum_Access.<br />In Drupal, access can only be granted, not taken away. Whatever access you grant here will not be reflected on the !Forum_Access_link settings, and vice versa, but any node access module can only allow <i>more</i> access, not less.', $variables), 'warning'); |
|
840 | + } |
|
840 | 841 | } |
841 | - } |
|
842 | 842 | } |
843 | 843 | |
844 | 844 | /** |
@@ -848,12 +848,12 @@ discard block |
||
848 | 848 | * admin/user/permissions. |
849 | 849 | */ |
850 | 850 | function _forum_access_user_admin_perm_form(&$form, &$form_state) { |
851 | - $moderator_rid = forum_access_query_moderator_rid(); |
|
852 | - if (isset($moderator_rid) && array_key_exists($moderator_rid, $form['role_names'])) { |
|
851 | + $moderator_rid = forum_access_query_moderator_rid(); |
|
852 | + if (isset($moderator_rid) && array_key_exists($moderator_rid, $form['role_names'])) { |
|
853 | 853 | drupal_set_message(t('The %role role is used internally by the @Forum_Access module and must not be changed!', array('%role' => $form['role_names'][$moderator_rid]['#value'], '@Forum_Access' => 'Forum Access')), 'warning', FALSE); |
854 | 854 | $form['checkboxes'][$moderator_rid]['#disabled'] = TRUE; |
855 | - } |
|
856 | - array_unshift($form['#submit'], '_forum_access_user_admin_perm_form_submit'); |
|
855 | + } |
|
856 | + array_unshift($form['#submit'], '_forum_access_user_admin_perm_form_submit'); |
|
857 | 857 | } |
858 | 858 | |
859 | 859 | /** |
@@ -863,10 +863,10 @@ discard block |
||
863 | 863 | * before the real handler gets them. |
864 | 864 | */ |
865 | 865 | function _forum_access_user_admin_perm_form_submit($form, &$form_state) { |
866 | - $moderator_rid = forum_access_query_moderator_rid(); |
|
867 | - if (isset($moderator_rid)) { |
|
866 | + $moderator_rid = forum_access_query_moderator_rid(); |
|
867 | + if (isset($moderator_rid)) { |
|
868 | 868 | unset($form_state['values'][$moderator_rid]); |
869 | - } |
|
869 | + } |
|
870 | 870 | } |
871 | 871 | |
872 | 872 | /** |
@@ -876,10 +876,10 @@ discard block |
||
876 | 876 | * admin/user/user. |
877 | 877 | */ |
878 | 878 | function _forum_access_user_admin_account_form(&$form, &$form_state) { |
879 | - $moderator_rid = forum_access_query_moderator_rid(); |
|
880 | - if (isset($moderator_rid)) { |
|
879 | + $moderator_rid = forum_access_query_moderator_rid(); |
|
880 | + if (isset($moderator_rid)) { |
|
881 | 881 | unset($form['options']['operation']['#options'][t('Add a role to the selected users')]["add_role-$moderator_rid"]); |
882 | - } |
|
882 | + } |
|
883 | 883 | } |
884 | 884 | |
885 | 885 | /** |
@@ -888,54 +888,54 @@ discard block |
||
888 | 888 | * Disable the Forum Moderator checkbox on user/UID/edit. |
889 | 889 | */ |
890 | 890 | function _forum_access_user_profile_form(&$form, &$form_state) { |
891 | - //dpm($form, '_forum_access_user_profile_form()'); |
|
892 | - $moderator_rid = forum_access_query_moderator_rid(); |
|
893 | - if (isset($moderator_rid) && isset($form['account']['roles']['#options'][$moderator_rid])) { |
|
891 | + //dpm($form, '_forum_access_user_profile_form()'); |
|
892 | + $moderator_rid = forum_access_query_moderator_rid(); |
|
893 | + if (isset($moderator_rid) && isset($form['account']['roles']['#options'][$moderator_rid])) { |
|
894 | 894 | $form['account']['roles'][$moderator_rid] = array( |
895 | - '#type' => 'checkbox', |
|
896 | - '#title' => $form['account']['roles']['#options'][$moderator_rid] .' ('. t('reserved for internal use by the @Forum_Access module', array('@Forum_Access' => 'Forum Access')) .')', |
|
897 | - '#default_value' => in_array($moderator_rid, $form['account']['roles']['#default_value']), |
|
898 | - '#disabled' => TRUE, |
|
895 | + '#type' => 'checkbox', |
|
896 | + '#title' => $form['account']['roles']['#options'][$moderator_rid] .' ('. t('reserved for internal use by the @Forum_Access module', array('@Forum_Access' => 'Forum Access')) .')', |
|
897 | + '#default_value' => in_array($moderator_rid, $form['account']['roles']['#default_value']), |
|
898 | + '#disabled' => TRUE, |
|
899 | 899 | ); |
900 | 900 | unset($form['account']['roles']['#options'][$moderator_rid]); |
901 | - } |
|
901 | + } |
|
902 | 902 | } |
903 | 903 | |
904 | 904 | /** |
905 | 905 | * Create the Forum Moderator role. |
906 | 906 | */ |
907 | 907 | function _forum_access_create_moderator_rid($verbose = FALSE) { |
908 | - $tr = 't'; |
|
909 | - $variables = array('!Forum_Access' => 'Forum Access', '%administer_comments' => $tr('administer comments'), '%administer_nodes' => $tr('administer nodes')); |
|
910 | - $role_name = t('Forum Moderator'); |
|
911 | - $role = new stdClass(); |
|
912 | - $role->name = $role_name; |
|
913 | - for ($i = 2; $i <= 12; ++$i) { |
|
908 | + $tr = 't'; |
|
909 | + $variables = array('!Forum_Access' => 'Forum Access', '%administer_comments' => $tr('administer comments'), '%administer_nodes' => $tr('administer nodes')); |
|
910 | + $role_name = t('Forum Moderator'); |
|
911 | + $role = new stdClass(); |
|
912 | + $role->name = $role_name; |
|
913 | + for ($i = 2; $i <= 12; ++$i) { |
|
914 | 914 | $variables['%role'] = $role->name; |
915 | 915 | if (!db_result(db_query("SELECT COUNT(rid) FROM {role} WHERE name = '%s'", $role->name)) && |
916 | 916 | drupal_write_record('role', $role)) { |
917 | - $rid = $role->rid; |
|
918 | - variable_set('forum_access_moderator_rid', $rid); |
|
919 | - $permission = new stdClass(); |
|
920 | - $permission->rid = $rid; |
|
921 | - $permission->perm = 'administer comments, administer nodes, post comments, post comments without approval'; |
|
922 | - drupal_write_record('permission', $permission); |
|
923 | - $msg = t('!Forum_Access has created a new role named %role and given it the %administer_nodes and %administer_comments permissions. This role is used internally by !Forum_Access. You can change the name of the role as you like, but you must keep it unmodified otherwise.', $variables); |
|
924 | - if ($verbose) { |
|
917 | + $rid = $role->rid; |
|
918 | + variable_set('forum_access_moderator_rid', $rid); |
|
919 | + $permission = new stdClass(); |
|
920 | + $permission->rid = $rid; |
|
921 | + $permission->perm = 'administer comments, administer nodes, post comments, post comments without approval'; |
|
922 | + drupal_write_record('permission', $permission); |
|
923 | + $msg = t('!Forum_Access has created a new role named %role and given it the %administer_nodes and %administer_comments permissions. This role is used internally by !Forum_Access. You can change the name of the role as you like, but you must keep it unmodified otherwise.', $variables); |
|
924 | + if ($verbose) { |
|
925 | 925 | drupal_set_message($msg, 'warning'); |
926 | - } |
|
927 | - watchdog('user', $msg, NULL, WATCHDOG_NOTICE); |
|
928 | - return $rid; |
|
926 | + } |
|
927 | + watchdog('user', $msg, NULL, WATCHDOG_NOTICE); |
|
928 | + return $rid; |
|
929 | 929 | } |
930 | 930 | else { |
931 | - $msg = t('!Forum_Access cannot create the %role role!', $variables); |
|
932 | - watchdog('user', $msg, NULL, WATCHDOG_WARNING); |
|
933 | - drupal_set_message($msg .' '. t('Is it already in use?'), 'error'); |
|
934 | - $role->name = $role_name .' '. $i; |
|
935 | - } |
|
936 | - } |
|
937 | - $msg = t('!Forum_Access has given up and will not work correctly! Rename one of the roles listed above, so that !Forum_Access can use its name.', $variables); |
|
938 | - drupal_set_message($msg, 'error'); |
|
939 | - watchdog('user', $msg, NULL, WATCHDOG_CRITICAL); |
|
931 | + $msg = t('!Forum_Access cannot create the %role role!', $variables); |
|
932 | + watchdog('user', $msg, NULL, WATCHDOG_WARNING); |
|
933 | + drupal_set_message($msg .' '. t('Is it already in use?'), 'error'); |
|
934 | + $role->name = $role_name .' '. $i; |
|
935 | + } |
|
936 | + } |
|
937 | + $msg = t('!Forum_Access has given up and will not work correctly! Rename one of the roles listed above, so that !Forum_Access can use its name.', $variables); |
|
938 | + drupal_set_message($msg, 'error'); |
|
939 | + watchdog('user', $msg, NULL, WATCHDOG_CRITICAL); |
|
940 | 940 | } |
941 | 941 |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | function _forum_access_forum_form(&$form, &$form_state, $is_container) { |
15 | 15 | $tid = (isset($form['tid']['#value']) ? $form['tid']['#value'] : NULL); |
16 | 16 | if (isset($tid) && !forum_access_access($tid, 'view', NULL, FALSE)) { |
17 | - drupal_access_denied(); // Deny access if the user doesn't have View access. |
|
17 | + drupal_access_denied(); // Deny access if the user doesn't have View access. |
|
18 | 18 | module_invoke_all('exit'); |
19 | 19 | exit; |
20 | 20 | } |
@@ -39,18 +39,18 @@ discard block |
||
39 | 39 | |
40 | 40 | $tr = 't'; |
41 | 41 | $variables = array( |
42 | - '!access_content' => '<em>'. l($tr('access content'), 'admin/user/permissions', array('fragment' => 'module-node', 'html' => TRUE)) .'</em>', |
|
43 | - '!access_comments' => '<em>'. l($tr('access comments'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => TRUE)) .'</em>', |
|
44 | - '!create_forum_topics' => '<em>'. l($tr('create forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)) .'</em>', |
|
45 | - '!post_comments' => '<em>'. l($tr('post comments'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => TRUE)) .'</em>', |
|
46 | - '!post_comments_without_approval' => '<em>'. l($tr('post comments without approval'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => TRUE)) .'</em>', |
|
47 | - '!edit_own_forum_topics' => '<em>'. l($tr('edit own forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)) .'</em>', |
|
48 | - '!edit_any_forum_topics' => '<em>'. l($tr('edit any forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)) .'</em>', |
|
49 | - '!delete_own_forum_topics' => '<em>'. l($tr('delete own forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)) .'</em>', |
|
50 | - '!delete_any_forum_topics' => '<em>'. l($tr('delete any forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)) .'</em>', |
|
51 | - '!administer_comments' => '<em>'. l($tr('administer comments'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => TRUE)) .'</em>', |
|
52 | - '!administer_forums' => '<em>'. l($tr('administer forums'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)) .'</em>', |
|
53 | - '!administer_nodes' => '<em>'. l($tr('administer nodes'), 'admin/user/permissions', array('fragment' => 'module-node', 'html' => TRUE)) .'</em>', |
|
42 | + '!access_content' => '<em>'.l($tr('access content'), 'admin/user/permissions', array('fragment' => 'module-node', 'html' => TRUE)).'</em>', |
|
43 | + '!access_comments' => '<em>'.l($tr('access comments'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => TRUE)).'</em>', |
|
44 | + '!create_forum_topics' => '<em>'.l($tr('create forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)).'</em>', |
|
45 | + '!post_comments' => '<em>'.l($tr('post comments'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => TRUE)).'</em>', |
|
46 | + '!post_comments_without_approval' => '<em>'.l($tr('post comments without approval'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => TRUE)).'</em>', |
|
47 | + '!edit_own_forum_topics' => '<em>'.l($tr('edit own forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)).'</em>', |
|
48 | + '!edit_any_forum_topics' => '<em>'.l($tr('edit any forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)).'</em>', |
|
49 | + '!delete_own_forum_topics' => '<em>'.l($tr('delete own forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)).'</em>', |
|
50 | + '!delete_any_forum_topics' => '<em>'.l($tr('delete any forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)).'</em>', |
|
51 | + '!administer_comments' => '<em>'.l($tr('administer comments'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => TRUE)).'</em>', |
|
52 | + '!administer_forums' => '<em>'.l($tr('administer forums'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)).'</em>', |
|
53 | + '!administer_nodes' => '<em>'.l($tr('administer nodes'), 'admin/user/permissions', array('fragment' => 'module-node', 'html' => TRUE)).'</em>', |
|
54 | 54 | ); |
55 | 55 | if (!$is_container) { |
56 | 56 | $form['forum_access']['permissions'] = array( |
@@ -61,15 +61,15 @@ discard block |
||
61 | 61 | ); |
62 | 62 | $form['forum_access']['permissions'][] = array( |
63 | 63 | '#type' => 'markup', |
64 | - '#value' => '<div>'. t('Note that users need') .'<ul style="margin-top: 0"><li>'. |
|
65 | - t('the !access_content and !access_comments permissions <strong>AND <em>View</em></strong> to be able to see this forum and its content at all,', $variables) .'</li><li>'. |
|
66 | - t('the !create_forum_topics (and similar) permissions <strong>AND <em>Post</em></strong> to be able to create forum content, and', $variables) .'</li><li>'. |
|
67 | - t('the !post_comments and (probably) !post_comments_without_approval permission <!TAG>AND <em>Comment</em></!TAG> to be able to post comments/replies;', $variables + array('!TAG' => (variable_get('forum_access_D5_legacy_mode', FALSE) ? 'del title="'. t('Drupal 5 legacy mode') .'"' : 'strong'))) .'</li><li>'. |
|
68 | - t('the !edit_own_forum_topics or !edit_any_forum_topics (and similar) permissions <strong>AND (<em>Edit</em> AND <em>Comment</em></strong>) can be added if desired, <strong>plus</strong>', $variables) .'</li><li>'. |
|
69 | - t('the !delete_own_forum_topics or !delete_any_forum_topics (and similar) permissions (<strong>OR <em>Delete</em></strong>) if desired;', $variables) .'</li><li>'. |
|
70 | - t('the !administer_comments (global!) permission <strong>OR <em>Edit</em>/<em>Delete</em></strong> to be able to edit/delete comments;', $variables) .'</li><li>'. |
|
71 | - t('the !administer_forums permission <strong>AND <em>View</em></strong> to be able to administer forums (and change access!).', $variables) .'</li></ul>'. |
|
72 | - t('Furthermore note that content which is not published is treated in a different way by Drupal: it can be viewed only by its author or by users with the !administer_nodes permission. Unpublished comments and replies are accessible to users with <strong><em>Edit</em> OR <em>Delete</em></strong>, <strong>OR</strong> with the !administer_comments permission, but they are never counted on the forum page.', $variables) .'</div>', |
|
64 | + '#value' => '<div>'.t('Note that users need').'<ul style="margin-top: 0"><li>'. |
|
65 | + t('the !access_content and !access_comments permissions <strong>AND <em>View</em></strong> to be able to see this forum and its content at all,', $variables).'</li><li>'. |
|
66 | + t('the !create_forum_topics (and similar) permissions <strong>AND <em>Post</em></strong> to be able to create forum content, and', $variables).'</li><li>'. |
|
67 | + t('the !post_comments and (probably) !post_comments_without_approval permission <!TAG>AND <em>Comment</em></!TAG> to be able to post comments/replies;', $variables + array('!TAG' => (variable_get('forum_access_D5_legacy_mode', FALSE) ? 'del title="'.t('Drupal 5 legacy mode').'"' : 'strong'))).'</li><li>'. |
|
68 | + t('the !edit_own_forum_topics or !edit_any_forum_topics (and similar) permissions <strong>AND (<em>Edit</em> AND <em>Comment</em></strong>) can be added if desired, <strong>plus</strong>', $variables).'</li><li>'. |
|
69 | + t('the !delete_own_forum_topics or !delete_any_forum_topics (and similar) permissions (<strong>OR <em>Delete</em></strong>) if desired;', $variables).'</li><li>'. |
|
70 | + t('the !administer_comments (global!) permission <strong>OR <em>Edit</em>/<em>Delete</em></strong> to be able to edit/delete comments;', $variables).'</li><li>'. |
|
71 | + t('the !administer_forums permission <strong>AND <em>View</em></strong> to be able to administer forums (and change access!).', $variables).'</li></ul>'. |
|
72 | + t('Furthermore note that content which is not published is treated in a different way by Drupal: it can be viewed only by its author or by users with the !administer_nodes permission. Unpublished comments and replies are accessible to users with <strong><em>Edit</em> OR <em>Delete</em></strong>, <strong>OR</strong> with the !administer_comments permission, but they are never counted on the forum page.', $variables).'</div>', |
|
73 | 73 | ); |
74 | 74 | } |
75 | 75 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | '#collapsed' => empty($template_tid), |
83 | 83 | ); |
84 | 84 | $form['forum_access']['template']['taxonomy'][$vid] = taxonomy_form($vid, array($template_tid), ''); |
85 | - $form['forum_access']['template']['taxonomy'][$vid]['#description'] = t("Select a forum and click !Load to retrieve that forum's settings as a starting point for this forum or container.", array('!Load' => '['. t('Load') .']')); |
|
85 | + $form['forum_access']['template']['taxonomy'][$vid]['#description'] = t("Select a forum and click !Load to retrieve that forum's settings as a starting point for this forum or container.", array('!Load' => '['.t('Load').']')); |
|
86 | 86 | $form['forum_access']['template']['load_button'] = array( |
87 | 87 | '#type' => 'button', |
88 | 88 | '#name' => 'load_template', |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | ); |
206 | 206 | } |
207 | 207 | |
208 | - drupal_add_css(drupal_get_path('module', 'forum_access') .'/forum_access.css'); |
|
208 | + drupal_add_css(drupal_get_path('module', 'forum_access').'/forum_access.css'); |
|
209 | 209 | |
210 | 210 | // Find our moderator ACL: |
211 | 211 | if (isset($tid)) { // edit, not new |
@@ -222,12 +222,12 @@ discard block |
||
222 | 222 | $form['forum_access']['acl'] = acl_edit_form($acl_id, t('Moderators')); |
223 | 223 | $form['forum_access']['acl'][] = array( |
224 | 224 | '#type' => 'markup', |
225 | - '#value' => '<div>'. t('Moderators receive all grants above.') .'</div>', |
|
225 | + '#value' => '<div>'.t('Moderators receive all grants above.').'</div>', |
|
226 | 226 | '#weight' => -1, |
227 | 227 | ); |
228 | 228 | $form['forum_access']['acl']['note'] = array( |
229 | 229 | '#type' => 'markup', |
230 | - '#value' => '<div>'. t('Note: Changes to moderators are not saved until you click [!Save] below.', array('!Save' => $tr('Save'))) .'</div>', |
|
230 | + '#value' => '<div>'.t('Note: Changes to moderators are not saved until you click [!Save] below.', array('!Save' => $tr('Save'))).'</div>', |
|
231 | 231 | ); |
232 | 232 | $form['forum_access']['acl']['#after_build'][] = '_forum_access_forum_form_after_build_acl0'; |
233 | 233 | $form['forum_access']['acl']['#after_build'] = array_reverse($form['forum_access']['acl']['#after_build']); |
@@ -251,11 +251,11 @@ discard block |
||
251 | 251 | '!Content_Access' => l('Content Access', 'http://drupal.org/project/content_access'), |
252 | 252 | '@Content_Access' => 'Content Access', |
253 | 253 | '!ACL' => 'ACL', |
254 | - '!module_list' => '<ul><li>'. implode($na_modules, '</li><li>') .'</li></ul>', |
|
254 | + '!module_list' => '<ul><li>'.implode($na_modules, '</li><li>').'</li></ul>', |
|
255 | 255 | ); |
256 | 256 | $form['forum_access']['interference'][] = array( |
257 | 257 | '#type' => 'item', |
258 | - '#value' => '<p>'. t("Besides !Forum_Access (and !ACL) you have installed the following node access module(s): !module_list The grants of every module are combined for each node. Access can only be granted, not removed — if a certain module grants a permission, the other(s) cannot deny it.", $variables) .'</p>', |
|
258 | + '#value' => '<p>'.t("Besides !Forum_Access (and !ACL) you have installed the following node access module(s): !module_list The grants of every module are combined for each node. Access can only be granted, not removed — if a certain module grants a permission, the other(s) cannot deny it.", $variables).'</p>', |
|
259 | 259 | '#description' => t('Forums can contain other content types besides %content_type; !Forum_Access will contribute the grants defined above to every node in this forum, but other node access control modules may also contribute their grants, especially to nodes of types other than %content_type.', $variables), |
260 | 260 | ); |
261 | 261 | |
@@ -282,25 +282,25 @@ discard block |
||
282 | 282 | '#attributes' => array('class' => 'error'), |
283 | 283 | ); |
284 | 284 | $form['forum_access']['interference']['by_content_access'][] = array( |
285 | - '#value' => '<div>'. t('You have set the !Content_Access module to control access to content of type %content_type—this can interfere with proper operation of !Forum_Access!', $variables) ." $specifically</div>", |
|
285 | + '#value' => '<div>'.t('You have set the !Content_Access module to control access to content of type %content_type—this can interfere with proper operation of !Forum_Access!', $variables)." $specifically</div>", |
|
286 | 286 | ); |
287 | 287 | if ($ca_priority == $fa_priority) { |
288 | 288 | $form['forum_access']['interference']['by_content_access'][] = array( |
289 | - '#value' => '<div>'. t("Unless you really know what you're doing, we recommend that you go to the !link page and clear all checkboxes. This will instruct @Content_Access to leave the %content_type nodes alone. However, if you put nodes of other content types into forums as well, then these content types will continue to have this problem.", $variables) .'</div>', |
|
289 | + '#value' => '<div>'.t("Unless you really know what you're doing, we recommend that you go to the !link page and clear all checkboxes. This will instruct @Content_Access to leave the %content_type nodes alone. However, if you put nodes of other content types into forums as well, then these content types will continue to have this problem.", $variables).'</div>', |
|
290 | 290 | ); |
291 | 291 | } |
292 | 292 | else { |
293 | 293 | $form['forum_access']['interference']['by_content_access'][] = array( |
294 | - '#value' => '<div>'. t("The priority of @Content_Access ($ca_priority) is higher than the priority of !Forum_Access ($fa_priority), which means the latter is <strong>completely disabled</strong> for the %content_type type! Unless you really know what you're doing, we recommend that you go to the !link page, change the priority (under %Advanced) to 0, and clear all checkboxes.", $variables) .'</div>', |
|
294 | + '#value' => '<div>'.t("The priority of @Content_Access ($ca_priority) is higher than the priority of !Forum_Access ($fa_priority), which means the latter is <strong>completely disabled</strong> for the %content_type type! Unless you really know what you're doing, we recommend that you go to the !link page, change the priority (under %Advanced) to 0, and clear all checkboxes.", $variables).'</div>', |
|
295 | 295 | ); |
296 | 296 | } |
297 | 297 | $form['forum_access']['interference']['by_content_access'][] = array( |
298 | - '#value' => '<div>'. t("Alternatively, you can give !Forum_Access priority over @Content_Access by either raising the priority of !Forum_Access in every forum above the priority of @Content_Access, or by lowering the priority of @Content_Access for the content types in question below the priority of !Forum_Access.", $variables) .'</div>', |
|
298 | + '#value' => '<div>'.t("Alternatively, you can give !Forum_Access priority over @Content_Access by either raising the priority of !Forum_Access in every forum above the priority of @Content_Access, or by lowering the priority of @Content_Access for the content types in question below the priority of !Forum_Access.", $variables).'</div>', |
|
299 | 299 | ); |
300 | 300 | } |
301 | 301 | else { |
302 | 302 | $form['forum_access']['interference'][] = array( |
303 | - '#value' => '<p>'. t('Note: You have installed the !Content_Access module, which has the capability to grant access to content that would otherwise be protected by !Forum_Access. Be careful when configuring @Content_Access!', $variables) .'</p>', |
|
303 | + '#value' => '<p>'.t('Note: You have installed the !Content_Access module, which has the capability to grant access to content that would otherwise be protected by !Forum_Access. Be careful when configuring @Content_Access!', $variables).'</p>', |
|
304 | 304 | ); |
305 | 305 | } |
306 | 306 | } |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | '!DNA' => 'DNA', |
332 | 332 | '!debug_mode' => l('debug mode', 'admin/settings/devel', array('fragment' => 'edit-devel-node-access-debug-mode')), |
333 | 333 | '!dna_summary' => l('devel/node_access/summary', 'devel/node_access/summary'), |
334 | - '!Rebuild_permissions' => '['. $tr('Rebuild permissions') .']', |
|
334 | + '!Rebuild_permissions' => '['.$tr('Rebuild permissions').']', |
|
335 | 335 | '!Post_settings_link' => l('admin/content/node-settings', 'admin/content/node-settings'), |
336 | 336 | '!Forum_Access_' => l('Forum Access', 'http://drupal.org/project/issues/forum_access'), |
337 | 337 | '!ACL_' => l('ACL', 'http://drupal.org/project/issues/acl'), |
@@ -344,26 +344,26 @@ discard block |
||
344 | 344 | ); |
345 | 345 | $form['forum_access']['troubleshooting'][] = array( |
346 | 346 | '#type' => 'item', |
347 | - '#value' => '<div>'. t("In case of problems, follow these steps until you've got it worked out:") .'<ol style="margin-top: 0"><li>'. |
|
348 | - t("Update to the 'recommended' !Forum_Access and !ACL releases for your version of Drupal.", $variables) .'</li><li>'. |
|
349 | - (count($na_modules) ? t("Read %Module_interference above and update your other node access modules.", $variables) .'</li><li>' : '') . |
|
350 | - t("Check the release notes of the development snapshots for issues that might have been fixed in !Forum_Access-dev or !ACL-dev since the latest release.", $variables) .'</li><li>'. |
|
351 | - t("Install the %devel_node_access module (!DNA, part of the !Devel module) and enable its !debug_mode: !DNA will show you all the grants that actually control your nodes in a footer block on each node's page.", $variables) .'</li><li>'. |
|
352 | - t("Additional insight can be gained from !dna_summary and by enabling the second !DNA block.", $variables) .'</li><li>'. |
|
353 | - t("Click !Rebuild_permissions on !Post_settings_link and check DNA for changes.", $variables) .'</li><li>'. |
|
354 | - t("Check the issues queues of !Forum_Access_ and !ACL_ for existing reports and possible solutions.", $variables) .'</li><li>'. |
|
355 | - t("If all of this hasn't helped, then pick ONE node that is misbehaving, look at it using an account that can see the node (and that should NOT have access if that's your problem!), create a new issue in the issues queue, describe the problem... <ul><li> what did you do? </li><li> what did you expect? </li><li> what happened instead? </li></ul> ... and <strong>attach a screenshot of all the DNA records</strong> for that one node. <br /> Be sure to indicate paths (URLs) for every page and module that you mention.") .'</li></ol></div>', |
|
347 | + '#value' => '<div>'.t("In case of problems, follow these steps until you've got it worked out:").'<ol style="margin-top: 0"><li>'. |
|
348 | + t("Update to the 'recommended' !Forum_Access and !ACL releases for your version of Drupal.", $variables).'</li><li>'. |
|
349 | + (count($na_modules) ? t("Read %Module_interference above and update your other node access modules.", $variables).'</li><li>' : ''). |
|
350 | + t("Check the release notes of the development snapshots for issues that might have been fixed in !Forum_Access-dev or !ACL-dev since the latest release.", $variables).'</li><li>'. |
|
351 | + t("Install the %devel_node_access module (!DNA, part of the !Devel module) and enable its !debug_mode: !DNA will show you all the grants that actually control your nodes in a footer block on each node's page.", $variables).'</li><li>'. |
|
352 | + t("Additional insight can be gained from !dna_summary and by enabling the second !DNA block.", $variables).'</li><li>'. |
|
353 | + t("Click !Rebuild_permissions on !Post_settings_link and check DNA for changes.", $variables).'</li><li>'. |
|
354 | + t("Check the issues queues of !Forum_Access_ and !ACL_ for existing reports and possible solutions.", $variables).'</li><li>'. |
|
355 | + t("If all of this hasn't helped, then pick ONE node that is misbehaving, look at it using an account that can see the node (and that should NOT have access if that's your problem!), create a new issue in the issues queue, describe the problem... <ul><li> what did you do? </li><li> what did you expect? </li><li> what happened instead? </li></ul> ... and <strong>attach a screenshot of all the DNA records</strong> for that one node. <br /> Be sure to indicate paths (URLs) for every page and module that you mention.").'</li></ol></div>', |
|
356 | 356 | ); |
357 | 357 | $form['forum_access']['troubleshooting'][] = array( |
358 | 358 | '#type' => 'item', |
359 | - '#value' => '<div>'. t("Note: You should not keep the !Devel module enabled on a production site.", $variables) .'</div>', |
|
359 | + '#value' => '<div>'.t("Note: You should not keep the !Devel module enabled on a production site.", $variables).'</div>', |
|
360 | 360 | ); |
361 | 361 | } |
362 | 362 | |
363 | 363 | if (!$is_container && isset($tid) && !node_access_needs_rebuild()) { |
364 | 364 | $count = db_result(db_query("SELECT COUNT(DISTINCT n.nid) FROM {node} n INNER JOIN {term_node} tn ON tn.vid = n.vid WHERE tn.tid = %d", $tid)); |
365 | - $limit = 20; // from _node_access_rebuild_batch_operation() |
|
366 | - $threshold = variable_get('forum_access_batch_threshold', $limit); // change the variable if you want |
|
365 | + $limit = 20; // from _node_access_rebuild_batch_operation() |
|
366 | + $threshold = variable_get('forum_access_batch_threshold', $limit); // change the variable if you want |
|
367 | 367 | $form['forum_access']['update_limit'] = array( |
368 | 368 | '#type' => 'value', |
369 | 369 | '#value' => $limit, |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | $element_children = element_children($element); |
442 | 442 | foreach ($element_children as $rid) { |
443 | 443 | if ($rid == $moderator_rid) { |
444 | - $element[$rid]['#prefix'] = '<span title="'. t("This is the (temporary) @Forum_Moderator role; it has the '@administer_nodes' and '@administer_comments' permissions and is only used temporarily by @Forum_Access — do NOT give this role to any user!", array('@Forum_Moderator' => t('Forum Moderator'), '@administer_nodes' => $tr('administer nodes'), '@administer_comments' => $tr('administer comments'), '@Forum_Access' => 'Forum Access')) .'" class="forum-access-temporary-moderator">'; |
|
444 | + $element[$rid]['#prefix'] = '<span title="'.t("This is the (temporary) @Forum_Moderator role; it has the '@administer_nodes' and '@administer_comments' permissions and is only used temporarily by @Forum_Access — do NOT give this role to any user!", array('@Forum_Moderator' => t('Forum Moderator'), '@administer_nodes' => $tr('administer nodes'), '@administer_comments' => $tr('administer comments'), '@Forum_Access' => 'Forum Access')).'" class="forum-access-temporary-moderator">'; |
|
445 | 445 | $element[$rid]['#suffix'] = "</span>"; |
446 | 446 | $element[$rid]['#default_value'] = TRUE; |
447 | 447 | $element[$rid]['#disabled'] = TRUE; |
@@ -452,19 +452,19 @@ discard block |
||
452 | 452 | elseif ($element['#parents'][1] == 'comment_create') { |
453 | 453 | } |
454 | 454 | elseif ($element['#parents'][1] == 'view' && isset($permissions[$rid]['administer forums'])) { |
455 | - $element[$rid]['#title'] = '<em>'. $element[$rid]['#title'] .'</em>'; |
|
456 | - $element[$rid]['#prefix'] = '<span title="'. t("This role has the '@administer_forums' permission, and granting '@View' enables the role holders to change the settings on this page, including @Access_control!", array('@administer_forums' => $tr('administer forums'), '@View' => t('View'), '@Access_control' => t('Access control'))) .'">'; |
|
455 | + $element[$rid]['#title'] = '<em>'.$element[$rid]['#title'].'</em>'; |
|
456 | + $element[$rid]['#prefix'] = '<span title="'.t("This role has the '@administer_forums' permission, and granting '@View' enables the role holders to change the settings on this page, including @Access_control!", array('@administer_forums' => $tr('administer forums'), '@View' => t('View'), '@Access_control' => t('Access control'))).'">'; |
|
457 | 457 | if (isset($permissions[$rid]['administer nodes'])) { |
458 | - $element[$rid]['#prefix'] = str_replace('">', ' '. t("Because the role also has the '@administer_nodes' permission, it has full access to all nodes either way.", array('@administer_nodes' => $tr('administer nodes'))) .'">', $element[$rid]['#prefix']); |
|
458 | + $element[$rid]['#prefix'] = str_replace('">', ' '.t("Because the role also has the '@administer_nodes' permission, it has full access to all nodes either way.", array('@administer_nodes' => $tr('administer nodes'))).'">', $element[$rid]['#prefix']); |
|
459 | 459 | } |
460 | 460 | $element[$rid]['#suffix'] = "</span>"; |
461 | 461 | } |
462 | 462 | elseif (isset($permissions[$rid]['administer nodes'])) { |
463 | 463 | $element[$rid]['#disabled'] = TRUE; |
464 | 464 | $element[$rid]['#default_value'] = TRUE; |
465 | - $element[$rid]['#prefix'] = '<span title="'. ($rid != $moderator_rid |
|
465 | + $element[$rid]['#prefix'] = '<span title="'.($rid != $moderator_rid |
|
466 | 466 | ? t("This role has the '@administer_nodes' permission and thus full access to all nodes.", array('@administer_nodes' => $tr('administer nodes'))) |
467 | - : t("This is the @Forum_Moderator role; it has the '@administer_nodes' and '@administer_comments' permissions and thus full access to all nodes and comments.", array('@Forum_Moderator' => t('Forum Moderator'), '@administer_nodes' => $tr('administer nodes'), '@administer_comments' => $tr('administer comments')))) .'">'; |
|
467 | + : t("This is the @Forum_Moderator role; it has the '@administer_nodes' and '@administer_comments' permissions and thus full access to all nodes and comments.", array('@Forum_Moderator' => t('Forum Moderator'), '@administer_nodes' => $tr('administer nodes'), '@administer_comments' => $tr('administer comments')))).'">'; |
|
468 | 468 | $element[$rid]['#suffix'] = "</span>"; |
469 | 469 | } |
470 | 470 | } |
@@ -560,12 +560,12 @@ discard block |
||
560 | 560 | variable_del('forum_access_new_template_tid'); |
561 | 561 | } |
562 | 562 | module_load_include('node.inc', 'forum_access'); |
563 | - $moderator_rid = _forum_access_get_moderator_rid(TRUE); // create the moderators role if it doesn't exist |
|
563 | + $moderator_rid = _forum_access_get_moderator_rid(TRUE); // create the moderators role if it doesn't exist |
|
564 | 564 | |
565 | 565 | // check for changes |
566 | 566 | $is_changed = $is_new = strpos($_GET['q'], 'admin/content/forum/add/') === 0; |
567 | 567 | $is_changed = $is_changed || !empty($access['force_update']); |
568 | - $form_initial_values = $form; // avoid Coder warning |
|
568 | + $form_initial_values = $form; // avoid Coder warning |
|
569 | 569 | $form_initial_values = $form_initial_values['forum_access']; |
570 | 570 | foreach (array('view', 'create', 'comment_create', 'update', 'delete') as $grant_type) { |
571 | 571 | if (isset($form_initial_values[$grant_type])) { |
@@ -610,11 +610,11 @@ discard block |
||
610 | 610 | } |
611 | 611 | else { |
612 | 612 | db_query("INSERT INTO {forum_access} (tid, rid, grant_view, grant_update, grant_delete, grant_create, grant_comment_create, priority) VALUES (%d, %d, %d, %d, %d, %d, %d, %d)", |
613 | - $tid, $rid, (bool) $checked, !empty($access['update'][$rid]), !empty($access['delete'][$rid]), !empty($access['create'][$rid]), !empty($access['comment_create'][$rid]), $fa_priority); |
|
613 | + $tid, $rid, (bool)$checked, !empty($access['update'][$rid]), !empty($access['delete'][$rid]), !empty($access['create'][$rid]), !empty($access['comment_create'][$rid]), $fa_priority); |
|
614 | 614 | } |
615 | 615 | } |
616 | 616 | $tr = 't'; |
617 | - $link = l($tr('edit'), 'admin/content/forum/edit/forum/'. $tid); |
|
617 | + $link = l($tr('edit'), 'admin/content/forum/edit/forum/'.$tid); |
|
618 | 618 | watchdog('access', 'Changed grants for %forum forum.', array('%forum' => $form_state['values']['name']), WATCHDOG_NOTICE, $link); |
619 | 619 | |
620 | 620 | if (!$is_new && $form_state['values']['form_id'] != 'forum_form_container') { |
@@ -628,10 +628,10 @@ discard block |
||
628 | 628 | $context = array(); |
629 | 629 | $pending_error_messages = drupal_get_messages('error', FALSE); |
630 | 630 | $our_error_message_index = (isset($pending_error_messages['error']) ? count($pending_error_messages['error']) : 0); |
631 | - _forum_access_update_batch_finished(FALSE, array(), array()); // add our error message (in case we die underway) |
|
631 | + _forum_access_update_batch_finished(FALSE, array(), array()); // add our error message (in case we die underway) |
|
632 | 632 | _forum_access_update_batch_operation($tid, 999999, 1, $context); |
633 | - $pending_error_messages = drupal_get_messages('error', TRUE); // still alive, get and clear all 'error' messages |
|
634 | - unset($pending_error_messages['error'][$our_error_message_index]); // remove our error message |
|
633 | + $pending_error_messages = drupal_get_messages('error', TRUE); // still alive, get and clear all 'error' messages |
|
634 | + unset($pending_error_messages['error'][$our_error_message_index]); // remove our error message |
|
635 | 635 | foreach ($pending_error_messages['error'] as $message) { // replay any others |
636 | 636 | drupal_set_message($message, 'error'); |
637 | 637 | } |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | $count = db_result(db_query("SELECT COUNT(DISTINCT n.nid) FROM {node} n INNER JOIN {term_node} tn ON tn.vid = n.vid WHERE tn.tid = %d", $tid)); |
645 | 645 | $batch = array( |
646 | 646 | 'title' => t('Updating content access permissions'), |
647 | - 'file' => drupal_get_path('module', 'forum_access') .'/forum_access.admin.inc', |
|
647 | + 'file' => drupal_get_path('module', 'forum_access').'/forum_access.admin.inc', |
|
648 | 648 | 'operations' => array( |
649 | 649 | array('_forum_access_update_batch_operation', array($tid, $limit, $count)), |
650 | 650 | ), |
@@ -654,7 +654,7 @@ discard block |
||
654 | 654 | } |
655 | 655 | } |
656 | 656 | |
657 | - variable_del('forum_access_rids'); // clear cache |
|
657 | + variable_del('forum_access_rids'); // clear cache |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | /** |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | |
688 | 688 | // Multistep processing : report progress. |
689 | 689 | if ($context['sandbox']['progress'] != $context['sandbox']['max']) { |
690 | - $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
|
690 | + $context['finished'] = $context['sandbox']['progress']/$context['sandbox']['max']; |
|
691 | 691 | } |
692 | 692 | } |
693 | 693 | |
@@ -829,8 +829,8 @@ discard block |
||
829 | 829 | ); |
830 | 830 | if (arg(3) == 'forum') { |
831 | 831 | drupal_set_message(t('Note: In Drupal, access can only be granted, not taken away. Whatever access you grant here will not be reflected in the !Forum_Access_link settings, but !Forum_Access can only allow <i>more</i> access, not less.', $variables) |
832 | - .'<br /><span class="error">'. t('Specifically, any rights granted to the %anonymous_user and/or the %authenticated_user will <b>override</b> the settings of !Forum_Access!', $variables) .'</span>' |
|
833 | - .'<br />'. t('To avoid conflicts with !Forum_Access settings, you may want to lower the priority of !Content_Access (under %Advanced below) below the priority of !Forum_Access for the content types that you want to be controlled by !Forum_Access.', $variables), 'warning'); |
|
832 | + .'<br /><span class="error">'.t('Specifically, any rights granted to the %anonymous_user and/or the %authenticated_user will <b>override</b> the settings of !Forum_Access!', $variables).'</span>' |
|
833 | + .'<br />'.t('To avoid conflicts with !Forum_Access settings, you may want to lower the priority of !Content_Access (under %Advanced below) below the priority of !Forum_Access for the content types that you want to be controlled by !Forum_Access.', $variables), 'warning'); |
|
834 | 834 | } |
835 | 835 | else { |
836 | 836 | $vid = _forum_access_get_vid(); |
@@ -893,7 +893,7 @@ discard block |
||
893 | 893 | if (isset($moderator_rid) && isset($form['account']['roles']['#options'][$moderator_rid])) { |
894 | 894 | $form['account']['roles'][$moderator_rid] = array( |
895 | 895 | '#type' => 'checkbox', |
896 | - '#title' => $form['account']['roles']['#options'][$moderator_rid] .' ('. t('reserved for internal use by the @Forum_Access module', array('@Forum_Access' => 'Forum Access')) .')', |
|
896 | + '#title' => $form['account']['roles']['#options'][$moderator_rid].' ('.t('reserved for internal use by the @Forum_Access module', array('@Forum_Access' => 'Forum Access')).')', |
|
897 | 897 | '#default_value' => in_array($moderator_rid, $form['account']['roles']['#default_value']), |
898 | 898 | '#disabled' => TRUE, |
899 | 899 | ); |
@@ -930,8 +930,8 @@ discard block |
||
930 | 930 | else { |
931 | 931 | $msg = t('!Forum_Access cannot create the %role role!', $variables); |
932 | 932 | watchdog('user', $msg, NULL, WATCHDOG_WARNING); |
933 | - drupal_set_message($msg .' '. t('Is it already in use?'), 'error'); |
|
934 | - $role->name = $role_name .' '. $i; |
|
933 | + drupal_set_message($msg.' '.t('Is it already in use?'), 'error'); |
|
934 | + $role->name = $role_name.' '.$i; |
|
935 | 935 | } |
936 | 936 | } |
937 | 937 | $msg = t('!Forum_Access has given up and will not work correctly! Rename one of the roles listed above, so that !Forum_Access can use its name.', $variables); |
@@ -20,11 +20,12 @@ discard block |
||
20 | 20 | } |
21 | 21 | |
22 | 22 | $roles = user_roles(); |
23 | - if (isset($tid)) { // edit |
|
23 | + if (isset($tid)) { |
|
24 | +// edit |
|
24 | 25 | $template_tid = variable_get('forum_access_default_template_tid', 0); |
25 | 26 | $settings = _forum_access_get_settings($tid); |
26 | - } |
|
27 | - else { // create |
|
27 | + } else { |
|
28 | +// create |
|
28 | 29 | $template_tid = variable_get('forum_access_new_template_tid', NULL); |
29 | 30 | $settings = _forum_access_get_settings($template_tid); |
30 | 31 | } |
@@ -208,9 +209,11 @@ discard block |
||
208 | 209 | drupal_add_css(drupal_get_path('module', 'forum_access') .'/forum_access.css'); |
209 | 210 | |
210 | 211 | // Find our moderator ACL: |
211 | - if (isset($tid)) { // edit, not new |
|
212 | + if (isset($tid)) { |
|
213 | +// edit, not new |
|
212 | 214 | $acl_id = acl_get_id_by_number('forum_access', $tid); |
213 | - if (!$acl_id) { // create one |
|
215 | + if (!$acl_id) { |
|
216 | +// create one |
|
214 | 217 | $acl_id = acl_create_new_acl('forum_access', NULL, $tid); |
215 | 218 | // update every existing node in this forum to use this acl. |
216 | 219 | $result = db_query("SELECT nid FROM {term_node} WHERE tid = %d", $tid); |
@@ -288,8 +291,7 @@ discard block |
||
288 | 291 | $form['forum_access']['interference']['by_content_access'][] = array( |
289 | 292 | '#value' => '<div>'. t("Unless you really know what you're doing, we recommend that you go to the !link page and clear all checkboxes. This will instruct @Content_Access to leave the %content_type nodes alone. However, if you put nodes of other content types into forums as well, then these content types will continue to have this problem.", $variables) .'</div>', |
290 | 293 | ); |
291 | - } |
|
292 | - else { |
|
294 | + } else { |
|
293 | 295 | $form['forum_access']['interference']['by_content_access'][] = array( |
294 | 296 | '#value' => '<div>'. t("The priority of @Content_Access ($ca_priority) is higher than the priority of !Forum_Access ($fa_priority), which means the latter is <strong>completely disabled</strong> for the %content_type type! Unless you really know what you're doing, we recommend that you go to the !link page, change the priority (under %Advanced) to 0, and clear all checkboxes.", $variables) .'</div>', |
295 | 297 | ); |
@@ -297,8 +299,7 @@ discard block |
||
297 | 299 | $form['forum_access']['interference']['by_content_access'][] = array( |
298 | 300 | '#value' => '<div>'. t("Alternatively, you can give !Forum_Access priority over @Content_Access by either raising the priority of !Forum_Access in every forum above the priority of @Content_Access, or by lowering the priority of @Content_Access for the content types in question below the priority of !Forum_Access.", $variables) .'</div>', |
299 | 301 | ); |
300 | - } |
|
301 | - else { |
|
302 | + } else { |
|
302 | 303 | $form['forum_access']['interference'][] = array( |
303 | 304 | '#value' => '<p>'. t('Note: You have installed the !Content_Access module, which has the capability to grant access to content that would otherwise be protected by !Forum_Access. Be careful when configuring @Content_Access!', $variables) .'</p>', |
304 | 305 | ); |
@@ -445,21 +446,17 @@ discard block |
||
445 | 446 | $element[$rid]['#suffix'] = "</span>"; |
446 | 447 | $element[$rid]['#default_value'] = TRUE; |
447 | 448 | $element[$rid]['#disabled'] = TRUE; |
448 | - } |
|
449 | - elseif ($element['#parents'][1] == 'create') { |
|
449 | + } elseif ($element['#parents'][1] == 'create') { |
|
450 | 450 | // Do nothing (Post is always mutable). |
451 | - } |
|
452 | - elseif ($element['#parents'][1] == 'comment_create') { |
|
453 | - } |
|
454 | - elseif ($element['#parents'][1] == 'view' && isset($permissions[$rid]['administer forums'])) { |
|
451 | + } elseif ($element['#parents'][1] == 'comment_create') { |
|
452 | + } elseif ($element['#parents'][1] == 'view' && isset($permissions[$rid]['administer forums'])) { |
|
455 | 453 | $element[$rid]['#title'] = '<em>'. $element[$rid]['#title'] .'</em>'; |
456 | 454 | $element[$rid]['#prefix'] = '<span title="'. t("This role has the '@administer_forums' permission, and granting '@View' enables the role holders to change the settings on this page, including @Access_control!", array('@administer_forums' => $tr('administer forums'), '@View' => t('View'), '@Access_control' => t('Access control'))) .'">'; |
457 | 455 | if (isset($permissions[$rid]['administer nodes'])) { |
458 | 456 | $element[$rid]['#prefix'] = str_replace('">', ' '. t("Because the role also has the '@administer_nodes' permission, it has full access to all nodes either way.", array('@administer_nodes' => $tr('administer nodes'))) .'">', $element[$rid]['#prefix']); |
459 | 457 | } |
460 | 458 | $element[$rid]['#suffix'] = "</span>"; |
461 | - } |
|
462 | - elseif (isset($permissions[$rid]['administer nodes'])) { |
|
459 | + } elseif (isset($permissions[$rid]['administer nodes'])) { |
|
463 | 460 | $element[$rid]['#disabled'] = TRUE; |
464 | 461 | $element[$rid]['#default_value'] = TRUE; |
465 | 462 | $element[$rid]['#prefix'] = '<span title="'. ($rid != $moderator_rid |
@@ -515,8 +512,7 @@ discard block |
||
515 | 512 | if ($settings['priority'] != 0) { |
516 | 513 | $form['interference']['advanced']['#collapsed'] = FALSE; |
517 | 514 | } |
518 | - } |
|
519 | - elseif (is_array(reset($form_state['values']['forum_access']['template']['taxonomy']))) { |
|
515 | + } elseif (is_array(reset($form_state['values']['forum_access']['template']['taxonomy']))) { |
|
520 | 516 | $imv = reset($form_state['values']['forum_access']['template']['taxonomy']); |
521 | 517 | $template_tid = reset($imv); |
522 | 518 | } |
@@ -549,14 +545,12 @@ discard block |
||
549 | 545 | $template_tid = reset(array_values($access['template']['taxonomy'])); |
550 | 546 | if ($access['template']['select_by_default']) { |
551 | 547 | variable_set('forum_access_default_template_tid', $template_tid); |
552 | - } |
|
553 | - elseif (variable_get('forum_access_default_template_tid', 0) == $template_tid) { |
|
548 | + } elseif (variable_get('forum_access_default_template_tid', 0) == $template_tid) { |
|
554 | 549 | variable_del('forum_access_default_template_tid'); |
555 | 550 | } |
556 | 551 | if ($access['template']['load_for_new']) { |
557 | 552 | variable_set('forum_access_new_template_tid', $template_tid); |
558 | - } |
|
559 | - elseif (variable_get('forum_access_new_template_tid', 0) == $template_tid) { |
|
553 | + } elseif (variable_get('forum_access_new_template_tid', 0) == $template_tid) { |
|
560 | 554 | variable_del('forum_access_new_template_tid'); |
561 | 555 | } |
562 | 556 | module_load_include('node.inc', 'forum_access'); |
@@ -598,8 +592,7 @@ discard block |
||
598 | 592 | // We prefer not to save records for node administrators, because these have access anyway. |
599 | 593 | if (isset($permissions[$rid]['administer forums']) && $access['view'][$rid]) { |
600 | 594 | // For forum administrators, View needs to be saved, ... |
601 | - } |
|
602 | - else { |
|
595 | + } else { |
|
603 | 596 | // ... otherwise forget View. |
604 | 597 | $access['view'][$rid] = FALSE; |
605 | 598 | } |
@@ -607,8 +600,7 @@ discard block |
||
607 | 600 | db_query("INSERT INTO {forum_access} (tid, rid, grant_view, grant_update, grant_delete, grant_create, grant_comment_create, priority) VALUES (%d, %d, %d, %d, %d, %d, %d, %d)", |
608 | 601 | $tid, $rid, !empty($access['view'][$rid]), 0, 0, !empty($access['create'][$rid]), !empty($access['comment_create'][$rid]), $fa_priority); |
609 | 602 | } |
610 | - } |
|
611 | - else { |
|
603 | + } else { |
|
612 | 604 | db_query("INSERT INTO {forum_access} (tid, rid, grant_view, grant_update, grant_delete, grant_create, grant_comment_create, priority) VALUES (%d, %d, %d, %d, %d, %d, %d, %d)", |
613 | 605 | $tid, $rid, (bool) $checked, !empty($access['update'][$rid]), !empty($access['delete'][$rid]), !empty($access['create'][$rid]), !empty($access['comment_create'][$rid]), $fa_priority); |
614 | 606 | } |
@@ -620,8 +612,7 @@ discard block |
||
620 | 612 | if (!$is_new && $form_state['values']['form_id'] != 'forum_form_container') { |
621 | 613 | if (!isset($access['update_choice']) || $access['update_choice'] == 2) { |
622 | 614 | node_access_needs_rebuild(TRUE); |
623 | - } |
|
624 | - elseif ($access['update_choice'] == 0) { |
|
615 | + } elseif ($access['update_choice'] == 0) { |
|
625 | 616 | // update immediately (but use the batch functions anyway |
626 | 617 | $save_redirect = $form_state['redirect']; |
627 | 618 | $form_state['redirect'] = $_GET['q']; |
@@ -632,13 +623,13 @@ discard block |
||
632 | 623 | _forum_access_update_batch_operation($tid, 999999, 1, $context); |
633 | 624 | $pending_error_messages = drupal_get_messages('error', TRUE); // still alive, get and clear all 'error' messages |
634 | 625 | unset($pending_error_messages['error'][$our_error_message_index]); // remove our error message |
635 | - foreach ($pending_error_messages['error'] as $message) { // replay any others |
|
626 | + foreach ($pending_error_messages['error'] as $message) { |
|
627 | +// replay any others |
|
636 | 628 | drupal_set_message($message, 'error'); |
637 | 629 | } |
638 | 630 | _forum_access_update_batch_finished(TRUE, array(), array()); |
639 | 631 | $form_state['redirect'] = $save_redirect; |
640 | - } |
|
641 | - else { |
|
632 | + } else { |
|
642 | 633 | // mass update in batch mode, modeled after node.module |
643 | 634 | $limit = $access['update_limit']; |
644 | 635 | $count = db_result(db_query("SELECT COUNT(DISTINCT n.nid) FROM {node} n INNER JOIN {term_node} tn ON tn.vid = n.vid WHERE tn.tid = %d", $tid)); |
@@ -698,8 +689,7 @@ discard block |
||
698 | 689 | if ($success) { |
699 | 690 | drupal_set_message(t('The content access permissions have been updated.')); |
700 | 691 | cache_clear_all(); |
701 | - } |
|
702 | - else { |
|
692 | + } else { |
|
703 | 693 | drupal_set_message(t('The content access permissions have not been properly updated.'), 'error'); |
704 | 694 | } |
705 | 695 | } |
@@ -744,8 +734,7 @@ discard block |
||
744 | 734 | $return['view'] = array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID); |
745 | 735 | $return['create'] = array(DRUPAL_AUTHENTICATED_RID); |
746 | 736 | $return['comment_create'] = array(DRUPAL_AUTHENTICATED_RID); |
747 | - } |
|
748 | - else { |
|
737 | + } else { |
|
749 | 738 | $result = db_query("SELECT * FROM {forum_access} where tid = %d", $tid); |
750 | 739 | while ($access = db_fetch_object($result)) { |
751 | 740 | if ($access->grant_view) { |
@@ -763,7 +752,8 @@ discard block |
||
763 | 752 | if ($access->grant_comment_create) { |
764 | 753 | $return['comment_create'][] = $access->rid; |
765 | 754 | } |
766 | - if ($access->rid == DRUPAL_AUTHENTICATED_RID) { // this is our reference |
|
755 | + if ($access->rid == DRUPAL_AUTHENTICATED_RID) { |
|
756 | +// this is our reference |
|
767 | 757 | $return['priority'] = $access->priority; |
768 | 758 | } |
769 | 759 | } |
@@ -831,8 +821,7 @@ discard block |
||
831 | 821 | drupal_set_message(t('Note: In Drupal, access can only be granted, not taken away. Whatever access you grant here will not be reflected in the !Forum_Access_link settings, but !Forum_Access can only allow <i>more</i> access, not less.', $variables) |
832 | 822 | .'<br /><span class="error">'. t('Specifically, any rights granted to the %anonymous_user and/or the %authenticated_user will <b>override</b> the settings of !Forum_Access!', $variables) .'</span>' |
833 | 823 | .'<br />'. t('To avoid conflicts with !Forum_Access settings, you may want to lower the priority of !Content_Access (under %Advanced below) below the priority of !Forum_Access for the content types that you want to be controlled by !Forum_Access.', $variables), 'warning'); |
834 | - } |
|
835 | - else { |
|
824 | + } else { |
|
836 | 825 | $vid = _forum_access_get_vid(); |
837 | 826 | $vocabulary = taxonomy_vocabulary_load($vid); |
838 | 827 | if (isset($vocabulary->nodes[arg(3)])) { |
@@ -926,8 +915,7 @@ discard block |
||
926 | 915 | } |
927 | 916 | watchdog('user', $msg, NULL, WATCHDOG_NOTICE); |
928 | 917 | return $rid; |
929 | - } |
|
930 | - else { |
|
918 | + } else { |
|
931 | 919 | $msg = t('!Forum_Access cannot create the %role role!', $variables); |
932 | 920 | watchdog('user', $msg, NULL, WATCHDOG_WARNING); |
933 | 921 | drupal_set_message($msg .' '. t('Is it already in use?'), 'error'); |
@@ -12,8 +12,8 @@ discard block |
||
12 | 12 | * Rewrite the forum administration page with our new access rules. |
13 | 13 | */ |
14 | 14 | function _forum_access_forum_form(&$form, &$form_state, $is_container) { |
15 | - $tid = (isset($form['tid']['#value']) ? $form['tid']['#value'] : NULL); |
|
16 | - if (isset($tid) && !forum_access_access($tid, 'view', NULL, FALSE)) { |
|
15 | + $tid = (isset($form['tid']['#value']) ? $form['tid']['#value'] : null); |
|
16 | + if (isset($tid) && !forum_access_access($tid, 'view', null, false)) { |
|
17 | 17 | drupal_access_denied(); // Deny access if the user doesn't have View access. |
18 | 18 | module_invoke_all('exit'); |
19 | 19 | exit; |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | $settings = _forum_access_get_settings($tid); |
26 | 26 | } |
27 | 27 | else { // create |
28 | - $template_tid = variable_get('forum_access_new_template_tid', NULL); |
|
28 | + $template_tid = variable_get('forum_access_new_template_tid', null); |
|
29 | 29 | $settings = _forum_access_get_settings($template_tid); |
30 | 30 | } |
31 | 31 | $fa_priority = $settings['priority']; |
@@ -33,38 +33,38 @@ discard block |
||
33 | 33 | $form['forum_access'] = array( |
34 | 34 | '#type' => 'fieldset', |
35 | 35 | '#title' => t('Access control'), |
36 | - '#collapsible' => TRUE, |
|
37 | - '#tree' => TRUE, |
|
36 | + '#collapsible' => true, |
|
37 | + '#tree' => true, |
|
38 | 38 | ); |
39 | 39 | |
40 | 40 | $tr = 't'; |
41 | 41 | $variables = array( |
42 | - '!access_content' => '<em>'. l($tr('access content'), 'admin/user/permissions', array('fragment' => 'module-node', 'html' => TRUE)) .'</em>', |
|
43 | - '!access_comments' => '<em>'. l($tr('access comments'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => TRUE)) .'</em>', |
|
44 | - '!create_forum_topics' => '<em>'. l($tr('create forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)) .'</em>', |
|
45 | - '!post_comments' => '<em>'. l($tr('post comments'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => TRUE)) .'</em>', |
|
46 | - '!post_comments_without_approval' => '<em>'. l($tr('post comments without approval'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => TRUE)) .'</em>', |
|
47 | - '!edit_own_forum_topics' => '<em>'. l($tr('edit own forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)) .'</em>', |
|
48 | - '!edit_any_forum_topics' => '<em>'. l($tr('edit any forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)) .'</em>', |
|
49 | - '!delete_own_forum_topics' => '<em>'. l($tr('delete own forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)) .'</em>', |
|
50 | - '!delete_any_forum_topics' => '<em>'. l($tr('delete any forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)) .'</em>', |
|
51 | - '!administer_comments' => '<em>'. l($tr('administer comments'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => TRUE)) .'</em>', |
|
52 | - '!administer_forums' => '<em>'. l($tr('administer forums'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)) .'</em>', |
|
53 | - '!administer_nodes' => '<em>'. l($tr('administer nodes'), 'admin/user/permissions', array('fragment' => 'module-node', 'html' => TRUE)) .'</em>', |
|
42 | + '!access_content' => '<em>'. l($tr('access content'), 'admin/user/permissions', array('fragment' => 'module-node', 'html' => true)) .'</em>', |
|
43 | + '!access_comments' => '<em>'. l($tr('access comments'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => true)) .'</em>', |
|
44 | + '!create_forum_topics' => '<em>'. l($tr('create forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => true)) .'</em>', |
|
45 | + '!post_comments' => '<em>'. l($tr('post comments'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => true)) .'</em>', |
|
46 | + '!post_comments_without_approval' => '<em>'. l($tr('post comments without approval'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => true)) .'</em>', |
|
47 | + '!edit_own_forum_topics' => '<em>'. l($tr('edit own forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => true)) .'</em>', |
|
48 | + '!edit_any_forum_topics' => '<em>'. l($tr('edit any forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => true)) .'</em>', |
|
49 | + '!delete_own_forum_topics' => '<em>'. l($tr('delete own forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => true)) .'</em>', |
|
50 | + '!delete_any_forum_topics' => '<em>'. l($tr('delete any forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => true)) .'</em>', |
|
51 | + '!administer_comments' => '<em>'. l($tr('administer comments'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => true)) .'</em>', |
|
52 | + '!administer_forums' => '<em>'. l($tr('administer forums'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => true)) .'</em>', |
|
53 | + '!administer_nodes' => '<em>'. l($tr('administer nodes'), 'admin/user/permissions', array('fragment' => 'module-node', 'html' => true)) .'</em>', |
|
54 | 54 | ); |
55 | 55 | if (!$is_container) { |
56 | 56 | $form['forum_access']['permissions'] = array( |
57 | 57 | '#type' => 'fieldset', |
58 | 58 | '#title' => $tr('Permissions information'), |
59 | - '#collapsible' => TRUE, |
|
60 | - '#collapsed' => TRUE, |
|
59 | + '#collapsible' => true, |
|
60 | + '#collapsed' => true, |
|
61 | 61 | ); |
62 | 62 | $form['forum_access']['permissions'][] = array( |
63 | 63 | '#type' => 'markup', |
64 | 64 | '#value' => '<div>'. t('Note that users need') .'<ul style="margin-top: 0"><li>'. |
65 | 65 | t('the !access_content and !access_comments permissions <strong>AND <em>View</em></strong> to be able to see this forum and its content at all,', $variables) .'</li><li>'. |
66 | 66 | t('the !create_forum_topics (and similar) permissions <strong>AND <em>Post</em></strong> to be able to create forum content, and', $variables) .'</li><li>'. |
67 | - t('the !post_comments and (probably) !post_comments_without_approval permission <!TAG>AND <em>Comment</em></!TAG> to be able to post comments/replies;', $variables + array('!TAG' => (variable_get('forum_access_D5_legacy_mode', FALSE) ? 'del title="'. t('Drupal 5 legacy mode') .'"' : 'strong'))) .'</li><li>'. |
|
67 | + t('the !post_comments and (probably) !post_comments_without_approval permission <!TAG>AND <em>Comment</em></!TAG> to be able to post comments/replies;', $variables + array('!TAG' => (variable_get('forum_access_D5_legacy_mode', false) ? 'del title="'. t('Drupal 5 legacy mode') .'"' : 'strong'))) .'</li><li>'. |
|
68 | 68 | t('the !edit_own_forum_topics or !edit_any_forum_topics (and similar) permissions <strong>AND (<em>Edit</em> AND <em>Comment</em></strong>) can be added if desired, <strong>plus</strong>', $variables) .'</li><li>'. |
69 | 69 | t('the !delete_own_forum_topics or !delete_any_forum_topics (and similar) permissions (<strong>OR <em>Delete</em></strong>) if desired;', $variables) .'</li><li>'. |
70 | 70 | t('the !administer_comments (global!) permission <strong>OR <em>Edit</em>/<em>Delete</em></strong> to be able to edit/delete comments;', $variables) .'</li><li>'. |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | $form['forum_access']['template'] = array( |
79 | 79 | '#type' => 'fieldset', |
80 | 80 | '#title' => $tr('Template'), |
81 | - '#collapsible' => TRUE, |
|
81 | + '#collapsible' => true, |
|
82 | 82 | '#collapsed' => empty($template_tid), |
83 | 83 | ); |
84 | 84 | $form['forum_access']['template']['taxonomy'][$vid] = taxonomy_form($vid, array($template_tid), ''); |
@@ -87,21 +87,21 @@ discard block |
||
87 | 87 | '#type' => 'button', |
88 | 88 | '#name' => 'load_template', |
89 | 89 | '#value' => t('Load'), |
90 | - '#submit' => FALSE, |
|
90 | + '#submit' => false, |
|
91 | 91 | ); |
92 | 92 | $form['forum_access']['template']['template_tid'] = array( |
93 | 93 | '#type' => 'value', |
94 | - '#value' => NULL, |
|
94 | + '#value' => null, |
|
95 | 95 | ); |
96 | 96 | $form['forum_access']['template']['select_by_default'] = array( |
97 | 97 | '#type' => 'checkbox', |
98 | 98 | '#title' => t('Remember this selection.'), |
99 | - '#default_value' => FALSE, |
|
99 | + '#default_value' => false, |
|
100 | 100 | ); |
101 | 101 | $form['forum_access']['template']['load_for_new'] = array( |
102 | 102 | '#type' => 'checkbox', |
103 | 103 | '#title' => t("Use the selected forum's settings as defaults for new forums and containers."), |
104 | - '#default_value' => FALSE, |
|
104 | + '#default_value' => false, |
|
105 | 105 | ); |
106 | 106 | $form['forum_access']['#after_build'][] = '_forum_access_forum_form_after_build'; |
107 | 107 | |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | if (isset($tid)) { // edit, not new |
212 | 212 | $acl_id = acl_get_id_by_number('forum_access', $tid); |
213 | 213 | if (!$acl_id) { // create one |
214 | - $acl_id = acl_create_new_acl('forum_access', NULL, $tid); |
|
214 | + $acl_id = acl_create_new_acl('forum_access', null, $tid); |
|
215 | 215 | // update every existing node in this forum to use this acl. |
216 | 216 | $result = db_query("SELECT nid FROM {term_node} WHERE tid = %d", $tid); |
217 | 217 | while ($node = db_fetch_object($result)) { |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | $form['forum_access']['interference'] = array( |
244 | 244 | '#type' => 'fieldset', |
245 | 245 | '#title' => t('Module interference'), |
246 | - '#collapsible' => TRUE, |
|
246 | + '#collapsible' => true, |
|
247 | 247 | ); |
248 | 248 | $variables = array( |
249 | 249 | '%content_type' => node_get_types('name', 'forum'), |
@@ -264,13 +264,13 @@ discard block |
||
264 | 264 | foreach (array('view', 'update', 'delete', 'per_node') as $type) { |
265 | 265 | $value = content_access_get_settings($type, 'forum'); |
266 | 266 | if (!empty($value)) { |
267 | - $ca_interferes = TRUE; |
|
267 | + $ca_interferes = true; |
|
268 | 268 | } |
269 | 269 | } |
270 | 270 | $ca_priority = content_access_get_settings('priority', 'forum'); |
271 | 271 | $is_conflict = $ca_priority >= $fa_priority && !empty($ca_interferes) || $ca_priority > $fa_priority; |
272 | 272 | $variables += array( |
273 | - '!link' => l(t('@Content_Access configuration for the %content_type type', $variables), 'admin/content/node-type/forum/access', array('html' => TRUE)), |
|
273 | + '!link' => l(t('@Content_Access configuration for the %content_type type', $variables), 'admin/content/node-type/forum/access', array('html' => true)), |
|
274 | 274 | '%Advanced' => $tr('Advanced'), |
275 | 275 | ); |
276 | 276 | $specifically = ($ca_priority == $fa_priority ? t('Specifically, any grants given by !Content_Access cannot be taken back by !Forum_Access.', $variables) : ''); |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | $form['forum_access']['interference']['by_content_access'] = array( |
279 | 279 | '#type' => 'fieldset', |
280 | 280 | '#title' => 'Content Access', |
281 | - '#collapsible' => FALSE, |
|
281 | + '#collapsible' => false, |
|
282 | 282 | '#attributes' => array('class' => 'error'), |
283 | 283 | ); |
284 | 284 | $form['forum_access']['interference']['by_content_access'][] = array( |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | $form['forum_access']['interference']['advanced'] = array( |
309 | 309 | '#type' => 'fieldset', |
310 | 310 | '#title' => t('Advanced'), |
311 | - '#collapsible' => TRUE, |
|
311 | + '#collapsible' => true, |
|
312 | 312 | '#collapsed' => !($fa_priority != 0), |
313 | 313 | ); |
314 | 314 | $form['forum_access']['interference']['advanced']['priority'] = array( |
@@ -324,8 +324,8 @@ discard block |
||
324 | 324 | '!Forum_Access' => l('Forum Access', 'http://drupal.org/project/forum_access'), |
325 | 325 | '!ACL' => l('ACL', 'http://drupal.org/project/acl'), |
326 | 326 | '%Module_interference' => t('Module interference'), |
327 | - '!Forum_Access-dev' => l('Forum Access 6.x-1.x-dev', 'http://drupal.org/node/96795', array('html' => TRUE)), |
|
328 | - '!ACL-dev' => l('ACL 6.x-1.x-dev', 'http://drupal.org/node/96794', array('html' => TRUE)), |
|
327 | + '!Forum_Access-dev' => l('Forum Access 6.x-1.x-dev', 'http://drupal.org/node/96795', array('html' => true)), |
|
328 | + '!ACL-dev' => l('ACL 6.x-1.x-dev', 'http://drupal.org/node/96794', array('html' => true)), |
|
329 | 329 | '%devel_node_access' => 'devel_node_access', |
330 | 330 | '!Devel' => l('Devel', 'http://drupal.org/project/devel'), |
331 | 331 | '!DNA' => 'DNA', |
@@ -339,8 +339,8 @@ discard block |
||
339 | 339 | $form['forum_access']['troubleshooting'] = array( |
340 | 340 | '#type' => 'fieldset', |
341 | 341 | '#title' => t('Trouble-shooting node access'), |
342 | - '#collapsible' => TRUE, |
|
343 | - '#collapsed' => TRUE, |
|
342 | + '#collapsible' => true, |
|
343 | + '#collapsed' => true, |
|
344 | 344 | ); |
345 | 345 | $form['forum_access']['troubleshooting'][] = array( |
346 | 346 | '#type' => 'item', |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | '#type' => 'radios', |
373 | 373 | '#title' => 'Update the permissions', |
374 | 374 | '#description' => t('<em>If</em> you make any node access changes, then each node in this forum needs to be updated. Hover over the radiobuttons for details.'), |
375 | - '#options' => NULL, |
|
375 | + '#options' => null, |
|
376 | 376 | 0 => array( |
377 | 377 | '#type' => 'radio', |
378 | 378 | '#title' => t('for all %count nodes immediately', array('%count' => $count)), |
@@ -443,8 +443,8 @@ discard block |
||
443 | 443 | if ($rid == $moderator_rid) { |
444 | 444 | $element[$rid]['#prefix'] = '<span title="'. t("This is the (temporary) @Forum_Moderator role; it has the '@administer_nodes' and '@administer_comments' permissions and is only used temporarily by @Forum_Access — do NOT give this role to any user!", array('@Forum_Moderator' => t('Forum Moderator'), '@administer_nodes' => $tr('administer nodes'), '@administer_comments' => $tr('administer comments'), '@Forum_Access' => 'Forum Access')) .'" class="forum-access-temporary-moderator">'; |
445 | 445 | $element[$rid]['#suffix'] = "</span>"; |
446 | - $element[$rid]['#default_value'] = TRUE; |
|
447 | - $element[$rid]['#disabled'] = TRUE; |
|
446 | + $element[$rid]['#default_value'] = true; |
|
447 | + $element[$rid]['#disabled'] = true; |
|
448 | 448 | } |
449 | 449 | elseif ($element['#parents'][1] == 'create') { |
450 | 450 | // Do nothing (Post is always mutable). |
@@ -460,8 +460,8 @@ discard block |
||
460 | 460 | $element[$rid]['#suffix'] = "</span>"; |
461 | 461 | } |
462 | 462 | elseif (isset($permissions[$rid]['administer nodes'])) { |
463 | - $element[$rid]['#disabled'] = TRUE; |
|
464 | - $element[$rid]['#default_value'] = TRUE; |
|
463 | + $element[$rid]['#disabled'] = true; |
|
464 | + $element[$rid]['#default_value'] = true; |
|
465 | 465 | $element[$rid]['#prefix'] = '<span title="'. ($rid != $moderator_rid |
466 | 466 | ? t("This role has the '@administer_nodes' permission and thus full access to all nodes.", array('@administer_nodes' => $tr('administer nodes'))) |
467 | 467 | : t("This is the @Forum_Moderator role; it has the '@administer_nodes' and '@administer_comments' permissions and thus full access to all nodes and comments.", array('@Forum_Moderator' => t('Forum Moderator'), '@administer_nodes' => $tr('administer nodes'), '@administer_comments' => $tr('administer comments')))) .'">'; |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | |
487 | 487 | function _forum_access_forum_form_after_build_acl2($form, $form_state) { |
488 | 488 | if (!count(unserialize($form['user_list']['#default_value'])) && !count(unserialize($form['user_list']['#value']))) { |
489 | - $form['#collapsed'] = TRUE; |
|
489 | + $form['#collapsed'] = true; |
|
490 | 490 | } |
491 | 491 | if ($form['user_list']['#default_value'] != $form['user_list']['#value']) { |
492 | 492 | $form['note']['#value'] = preg_replace('/<div>/', '<div class="warning">', $form['note']['#value']); |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | // Load a setting from a template: |
500 | 500 | $template_tid = reset(array_values($form['#post']['forum_access']['template']['taxonomy'])); |
501 | 501 | $form_state['values']['forum_access']['template']['template_tid'] = $template_tid; |
502 | - $form['template']['#collapsed'] = FALSE; |
|
502 | + $form['template']['#collapsed'] = false; |
|
503 | 503 | |
504 | 504 | $settings = _forum_access_get_settings($template_tid); |
505 | 505 | foreach (array('view', 'create', 'comment_create', 'update', 'delete') as $grant_type) { |
@@ -507,13 +507,13 @@ discard block |
||
507 | 507 | continue; |
508 | 508 | } |
509 | 509 | foreach (element_children($form[$grant_type]) as $tid) { |
510 | - $checked = array_search($tid, $settings[$grant_type]) !== FALSE; |
|
510 | + $checked = array_search($tid, $settings[$grant_type]) !== false; |
|
511 | 511 | $form[$grant_type][$tid]['#value'] = ($checked ? $tid : 0); |
512 | 512 | } |
513 | 513 | } |
514 | 514 | $form['interference']['advanced']['priority']['#value'] = $settings['priority']; |
515 | 515 | if ($settings['priority'] != 0) { |
516 | - $form['interference']['advanced']['#collapsed'] = FALSE; |
|
516 | + $form['interference']['advanced']['#collapsed'] = false; |
|
517 | 517 | } |
518 | 518 | } |
519 | 519 | elseif (is_array(reset($form_state['values']['forum_access']['template']['taxonomy']))) { |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | variable_del('forum_access_new_template_tid'); |
561 | 561 | } |
562 | 562 | module_load_include('node.inc', 'forum_access'); |
563 | - $moderator_rid = _forum_access_get_moderator_rid(TRUE); // create the moderators role if it doesn't exist |
|
563 | + $moderator_rid = _forum_access_get_moderator_rid(true); // create the moderators role if it doesn't exist |
|
564 | 564 | |
565 | 565 | // check for changes |
566 | 566 | $is_changed = $is_new = strpos($_GET['q'], 'admin/content/forum/add/') === 0; |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | } |
602 | 602 | else { |
603 | 603 | // ... otherwise forget View. |
604 | - $access['view'][$rid] = FALSE; |
|
604 | + $access['view'][$rid] = false; |
|
605 | 605 | } |
606 | 606 | if ($access['view'][$rid] || $access['create'][$rid] || $access['comment_create'][$rid]) { |
607 | 607 | db_query("INSERT INTO {forum_access} (tid, rid, grant_view, grant_update, grant_delete, grant_create, grant_comment_create, priority) VALUES (%d, %d, %d, %d, %d, %d, %d, %d)", |
@@ -619,23 +619,23 @@ discard block |
||
619 | 619 | |
620 | 620 | if (!$is_new && $form_state['values']['form_id'] != 'forum_form_container') { |
621 | 621 | if (!isset($access['update_choice']) || $access['update_choice'] == 2) { |
622 | - node_access_needs_rebuild(TRUE); |
|
622 | + node_access_needs_rebuild(true); |
|
623 | 623 | } |
624 | 624 | elseif ($access['update_choice'] == 0) { |
625 | 625 | // update immediately (but use the batch functions anyway |
626 | 626 | $save_redirect = $form_state['redirect']; |
627 | 627 | $form_state['redirect'] = $_GET['q']; |
628 | 628 | $context = array(); |
629 | - $pending_error_messages = drupal_get_messages('error', FALSE); |
|
629 | + $pending_error_messages = drupal_get_messages('error', false); |
|
630 | 630 | $our_error_message_index = (isset($pending_error_messages['error']) ? count($pending_error_messages['error']) : 0); |
631 | - _forum_access_update_batch_finished(FALSE, array(), array()); // add our error message (in case we die underway) |
|
631 | + _forum_access_update_batch_finished(false, array(), array()); // add our error message (in case we die underway) |
|
632 | 632 | _forum_access_update_batch_operation($tid, 999999, 1, $context); |
633 | - $pending_error_messages = drupal_get_messages('error', TRUE); // still alive, get and clear all 'error' messages |
|
633 | + $pending_error_messages = drupal_get_messages('error', true); // still alive, get and clear all 'error' messages |
|
634 | 634 | unset($pending_error_messages['error'][$our_error_message_index]); // remove our error message |
635 | 635 | foreach ($pending_error_messages['error'] as $message) { // replay any others |
636 | 636 | drupal_set_message($message, 'error'); |
637 | 637 | } |
638 | - _forum_access_update_batch_finished(TRUE, array(), array()); |
|
638 | + _forum_access_update_batch_finished(true, array(), array()); |
|
639 | 639 | $form_state['redirect'] = $save_redirect; |
640 | 640 | } |
641 | 641 | else { |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | // Process the next 20 nodes. |
676 | 676 | $result = db_query_range("SELECT DISTINCT n.nid FROM {node} n INNER JOIN {term_node} tn ON tn.vid = n.vid WHERE n.nid > %d AND tn.tid = %d ORDER BY n.nid ASC", $context['sandbox']['current_node'], $tid, 0, $limit); |
677 | 677 | while ($row = db_fetch_array($result)) { |
678 | - $loaded_node = node_load($row['nid'], NULL, TRUE); |
|
678 | + $loaded_node = node_load($row['nid'], null, true); |
|
679 | 679 | // To preserve database integrity, only aquire grants if the node |
680 | 680 | // loads successfully. |
681 | 681 | if (!empty($loaded_node)) { |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | $form['forum_access']['forum_access_D5_legacy_mode'] = array( |
727 | 727 | '#type' => 'checkbox', |
728 | 728 | '#title' => t('Drupal 5 legacy mode', $variables), |
729 | - '#default_value' => variable_get('forum_access_D5_legacy_mode', FALSE), |
|
729 | + '#default_value' => variable_get('forum_access_D5_legacy_mode', false), |
|
730 | 730 | '#description' => t('In Drupal 5, comment posting was not restricted by !Forum_Access; users with %View access (and the %post_comments permission) were always allowed to post forum comments. Starting with Drupal 6, posting comments is now restricted to users with %Post access. Turn this option on to revert to the old behavior. The default is OFF.', $variables), |
731 | 731 | ); |
732 | 732 | $buttons = $form['buttons']; |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | /** |
738 | 738 | * Helper function to retrieve the settings for a forum. |
739 | 739 | */ |
740 | -function _forum_access_get_settings($tid = NULL) { |
|
740 | +function _forum_access_get_settings($tid = null) { |
|
741 | 741 | $return = array('view' => array(), 'create' => array(), 'comment_create' => array(), 'update' => array(), 'delete' => array(), 'priority' => 0); |
742 | 742 | if (!isset($tid)) { |
743 | 743 | // Default to all users can read; all logged in users can post and comment. |
@@ -781,8 +781,8 @@ discard block |
||
781 | 781 | } |
782 | 782 | foreach ($form as $key => $value) { |
783 | 783 | if (preg_match('/^tid:(.*):0$/', $key, $matches)) { |
784 | - if (!forum_access_access($matches[1], 'view', NULL, FALSE)) { |
|
785 | - $form[$key]['edit']['#access'] = FALSE; |
|
784 | + if (!forum_access_access($matches[1], 'view', null, false)) { |
|
785 | + $form[$key]['edit']['#access'] = false; |
|
786 | 786 | if (preg_match('|<a [^>]*>([^<]*)</a>|', $form[$key]['view']['#value'], $matches)) { |
787 | 787 | $form[$key]['view']['#value'] = $matches[1]; |
788 | 788 | } |
@@ -850,8 +850,8 @@ discard block |
||
850 | 850 | function _forum_access_user_admin_perm_form(&$form, &$form_state) { |
851 | 851 | $moderator_rid = forum_access_query_moderator_rid(); |
852 | 852 | if (isset($moderator_rid) && array_key_exists($moderator_rid, $form['role_names'])) { |
853 | - drupal_set_message(t('The %role role is used internally by the @Forum_Access module and must not be changed!', array('%role' => $form['role_names'][$moderator_rid]['#value'], '@Forum_Access' => 'Forum Access')), 'warning', FALSE); |
|
854 | - $form['checkboxes'][$moderator_rid]['#disabled'] = TRUE; |
|
853 | + drupal_set_message(t('The %role role is used internally by the @Forum_Access module and must not be changed!', array('%role' => $form['role_names'][$moderator_rid]['#value'], '@Forum_Access' => 'Forum Access')), 'warning', false); |
|
854 | + $form['checkboxes'][$moderator_rid]['#disabled'] = true; |
|
855 | 855 | } |
856 | 856 | array_unshift($form['#submit'], '_forum_access_user_admin_perm_form_submit'); |
857 | 857 | } |
@@ -895,7 +895,7 @@ discard block |
||
895 | 895 | '#type' => 'checkbox', |
896 | 896 | '#title' => $form['account']['roles']['#options'][$moderator_rid] .' ('. t('reserved for internal use by the @Forum_Access module', array('@Forum_Access' => 'Forum Access')) .')', |
897 | 897 | '#default_value' => in_array($moderator_rid, $form['account']['roles']['#default_value']), |
898 | - '#disabled' => TRUE, |
|
898 | + '#disabled' => true, |
|
899 | 899 | ); |
900 | 900 | unset($form['account']['roles']['#options'][$moderator_rid]); |
901 | 901 | } |
@@ -904,7 +904,7 @@ discard block |
||
904 | 904 | /** |
905 | 905 | * Create the Forum Moderator role. |
906 | 906 | */ |
907 | -function _forum_access_create_moderator_rid($verbose = FALSE) { |
|
907 | +function _forum_access_create_moderator_rid($verbose = false) { |
|
908 | 908 | $tr = 't'; |
909 | 909 | $variables = array('!Forum_Access' => 'Forum Access', '%administer_comments' => $tr('administer comments'), '%administer_nodes' => $tr('administer nodes')); |
910 | 910 | $role_name = t('Forum Moderator'); |
@@ -924,18 +924,18 @@ discard block |
||
924 | 924 | if ($verbose) { |
925 | 925 | drupal_set_message($msg, 'warning'); |
926 | 926 | } |
927 | - watchdog('user', $msg, NULL, WATCHDOG_NOTICE); |
|
927 | + watchdog('user', $msg, null, WATCHDOG_NOTICE); |
|
928 | 928 | return $rid; |
929 | 929 | } |
930 | 930 | else { |
931 | 931 | $msg = t('!Forum_Access cannot create the %role role!', $variables); |
932 | - watchdog('user', $msg, NULL, WATCHDOG_WARNING); |
|
932 | + watchdog('user', $msg, null, WATCHDOG_WARNING); |
|
933 | 933 | drupal_set_message($msg .' '. t('Is it already in use?'), 'error'); |
934 | 934 | $role->name = $role_name .' '. $i; |
935 | 935 | } |
936 | 936 | } |
937 | 937 | $msg = t('!Forum_Access has given up and will not work correctly! Rename one of the roles listed above, so that !Forum_Access can use its name.', $variables); |
938 | 938 | drupal_set_message($msg, 'error'); |
939 | - watchdog('user', $msg, NULL, WATCHDOG_CRITICAL); |
|
939 | + watchdog('user', $msg, null, WATCHDOG_CRITICAL); |
|
940 | 940 | } |
941 | 941 |
@@ -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); |
@@ -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') and !(forum_access_access($tid, 'create') and ($node->uid==$user->uid)) ) { |
|
121 | + if (!forum_access_access($tid, 'comment_create') and !(forum_access_access($tid, 'create') and ($node->uid==$user->uid)) ) { |
|
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') and !(forum_access_access($tid, 'create') and ($node->uid==$user->uid)) ) { |
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 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 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') and !(forum_access_access($tid, 'create') and ($node->uid==$user->uid)) ) { |
|
121 | + if (!forum_access_access($tid, 'comment_create') and !(forum_access_access($tid, 'create') and ($node->uid == $user->uid))) { |
|
122 | 122 | switch (arg(0)) { |
123 | 123 | case 'node': |
124 | 124 | // Remove the in-line comment form, replace with text message to user. |
@@ -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 | } |
@@ -86,75 +86,75 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | switch (arg(0)) { |
89 | - case 'comment': |
|
90 | - if (variable_get('forum_access_D5_legacy_mode', FALSE)) { |
|
91 | - return; // disable comment access control |
|
92 | - } |
|
93 | - if ((arg(1) == 'edit' || arg(1) == 'delete') && !user_access('administer comments')) { |
|
94 | - if (is_numeric($cid = arg(2))) { // comment/edit/%, comment/delete/% |
|
95 | - $access[] = (arg(1) == 'edit' ? 'update' : 'delete'); |
|
96 | - $comment = _comment_load($cid); |
|
97 | - $nid = $comment->nid; |
|
98 | - // If the node turns out to be in a forum where we have update/delete |
|
99 | - // access, then we need Moderator permissions now, so we can moderate |
|
100 | - // this comment. |
|
101 | - // We won't provide full Administrator access, though: we'll remove |
|
102 | - // author and timestamp, for example. |
|
103 | - $grant_normal_access = TRUE; |
|
104 | - } |
|
89 | + case 'comment': |
|
90 | + if (variable_get('forum_access_D5_legacy_mode', FALSE)) { |
|
91 | + return; // disable comment access control |
|
92 | + } |
|
93 | + if ((arg(1) == 'edit' || arg(1) == 'delete') && !user_access('administer comments')) { |
|
94 | + if (is_numeric($cid = arg(2))) { // comment/edit/%, comment/delete/% |
|
95 | + $access[] = (arg(1) == 'edit' ? 'update' : 'delete'); |
|
96 | + $comment = _comment_load($cid); |
|
97 | + $nid = $comment->nid; |
|
98 | + // If the node turns out to be in a forum where we have update/delete |
|
99 | + // access, then we need Moderator permissions now, so we can moderate |
|
100 | + // this comment. |
|
101 | + // We won't provide full Administrator access, though: we'll remove |
|
102 | + // author and timestamp, for example. |
|
103 | + $grant_normal_access = TRUE; |
|
105 | 104 | } |
106 | - break; |
|
105 | + } |
|
106 | + break; |
|
107 | 107 | |
108 | - case 'node': |
|
109 | - if (is_numeric(arg(1))) { |
|
110 | - if (arg(2) == 'edit' && !user_access('administer nodes')) { // node/%/edit |
|
111 | - $access[] = 'update'; |
|
112 | - $nid = arg(1); |
|
113 | - // If the node turns out to be in a forum where we have update/delete |
|
114 | - // access, then we already get limited edit capabilities from NA, but |
|
115 | - // we need some more, e.g. publish/unpublish and comment status. |
|
116 | - // In order to get these controls on the form, we need Moderator |
|
117 | - // permissions now. |
|
118 | - // We won't provide full Administrator access, though: we'll remove |
|
119 | - // author and timestamp, for example. |
|
120 | - } |
|
121 | - if (arg(2) == 'delete' && !user_access('administer nodes')) { // node/%/delete |
|
122 | - $access = array(); |
|
123 | - $nid = arg(1); |
|
124 | - // This is the delete confirmation page. We don't need any |
|
125 | - // additional permissions, but we'll assert 'view' access below. |
|
126 | - } |
|
127 | - if (arg(2) == NULL && !user_access('administer comments')) { // node/% |
|
128 | - $access[] = 'update'; |
|
129 | - $nid = arg(1); |
|
130 | - // If the node turns out to be in a forum where we have update/delete |
|
131 | - // access, then we'll get the 'Edit' link automatically from NA, but |
|
132 | - // we'll need Moderator permissions, so that we can add the edit/delete |
|
133 | - // comment links (*after* we've identified the other comment links). |
|
134 | - } |
|
108 | + case 'node': |
|
109 | + if (is_numeric(arg(1))) { |
|
110 | + if (arg(2) == 'edit' && !user_access('administer nodes')) { // node/%/edit |
|
111 | + $access[] = 'update'; |
|
112 | + $nid = arg(1); |
|
113 | + // If the node turns out to be in a forum where we have update/delete |
|
114 | + // access, then we already get limited edit capabilities from NA, but |
|
115 | + // we need some more, e.g. publish/unpublish and comment status. |
|
116 | + // In order to get these controls on the form, we need Moderator |
|
117 | + // permissions now. |
|
118 | + // We won't provide full Administrator access, though: we'll remove |
|
119 | + // author and timestamp, for example. |
|
135 | 120 | } |
136 | - break; |
|
137 | - |
|
138 | - case 'community': |
|
139 | - if (arg(1)=='forum') { |
|
140 | - if (is_numeric(arg(2))) { |
|
141 | - $tid=arg(2); |
|
142 | - // Obtain the tid from a URL path containing |
|
143 | - // community/forum/%tid, this will prevent users from |
|
144 | - // loading forums they are not allowed to access. |
|
145 | - // However, only tid>1 are terms we care about. (This |
|
146 | - // allows forum_tweaks mark-read functionality to |
|
147 | - // work.) |
|
148 | - if (isset($tid) and ($tid>1)) { |
|
149 | - if (!forum_access_access($tid, 'view')) { |
|
150 | - drupal_access_denied(); |
|
151 | - module_invoke_all('exit'); |
|
152 | - exit; |
|
153 | - } |
|
154 | - }// isset($tid) |
|
155 | - }// is_numeric(arg(2)) |
|
156 | - }// arg(1)==forum |
|
121 | + if (arg(2) == 'delete' && !user_access('administer nodes')) { // node/%/delete |
|
122 | + $access = array(); |
|
123 | + $nid = arg(1); |
|
124 | + // This is the delete confirmation page. We don't need any |
|
125 | + // additional permissions, but we'll assert 'view' access below. |
|
126 | + } |
|
127 | + if (arg(2) == NULL && !user_access('administer comments')) { // node/% |
|
128 | + $access[] = 'update'; |
|
129 | + $nid = arg(1); |
|
130 | + // If the node turns out to be in a forum where we have update/delete |
|
131 | + // access, then we'll get the 'Edit' link automatically from NA, but |
|
132 | + // we'll need Moderator permissions, so that we can add the edit/delete |
|
133 | + // comment links (*after* we've identified the other comment links). |
|
134 | + } |
|
135 | + } |
|
157 | 136 | break; |
137 | + |
|
138 | + case 'community': |
|
139 | + if (arg(1)=='forum') { |
|
140 | + if (is_numeric(arg(2))) { |
|
141 | + $tid=arg(2); |
|
142 | + // Obtain the tid from a URL path containing |
|
143 | + // community/forum/%tid, this will prevent users from |
|
144 | + // loading forums they are not allowed to access. |
|
145 | + // However, only tid>1 are terms we care about. (This |
|
146 | + // allows forum_tweaks mark-read functionality to |
|
147 | + // work.) |
|
148 | + if (isset($tid) and ($tid>1)) { |
|
149 | + if (!forum_access_access($tid, 'view')) { |
|
150 | + drupal_access_denied(); |
|
151 | + module_invoke_all('exit'); |
|
152 | + exit; |
|
153 | + } |
|
154 | + }// isset($tid) |
|
155 | + }// is_numeric(arg(2)) |
|
156 | + }// arg(1)==forum |
|
157 | + break; |
|
158 | 158 | }// switch |
159 | 159 | if (isset($nid)) { |
160 | 160 | $node = node_load($nid); |
@@ -244,36 +244,36 @@ discard block |
||
244 | 244 | global $user; |
245 | 245 | $sql = NULL; |
246 | 246 | switch ($primary_field) { |
247 | - case 'tid': |
|
248 | - if ($user->uid == 1 |
|
249 | - || user_access('administer nodes') && strpos($_GET['q'], 'node/add/forum') === FALSE |
|
250 | - || user_access('administer forums') && $_GET['q'] == 'admin/content/forum') { |
|
251 | - break; |
|
252 | - } |
|
253 | - if (strpos($_GET['q'], 'node/add/forum') !== FALSE) { |
|
254 | - $required_access = 'create'; |
|
255 | - } |
|
256 | - else { |
|
257 | - $required_access = 'view'; |
|
258 | - } |
|
259 | - $roles = implode(', ', array_keys($user->roles)); |
|
260 | - $sql['join'] = "LEFT JOIN {forum_access} fa ON $primary_table.tid = fa.tid |
|
247 | + case 'tid': |
|
248 | + if ($user->uid == 1 |
|
249 | + || user_access('administer nodes') && strpos($_GET['q'], 'node/add/forum') === FALSE |
|
250 | + || user_access('administer forums') && $_GET['q'] == 'admin/content/forum') { |
|
251 | + break; |
|
252 | + } |
|
253 | + if (strpos($_GET['q'], 'node/add/forum') !== FALSE) { |
|
254 | + $required_access = 'create'; |
|
255 | + } |
|
256 | + else { |
|
257 | + $required_access = 'view'; |
|
258 | + } |
|
259 | + $roles = implode(', ', array_keys($user->roles)); |
|
260 | + $sql['join'] = "LEFT JOIN {forum_access} fa ON $primary_table.tid = fa.tid |
|
261 | 261 | LEFT JOIN {acl} acl_fa ON acl_fa.number = $primary_table.tid AND acl_fa.module = 'forum_access' |
262 | 262 | LEFT JOIN {acl_user} aclu_fa ON aclu_fa.acl_id = acl_fa.acl_id AND aclu_fa.uid = $user->uid"; |
263 | - $sql['where'] = "(fa.grant_$required_access >= 1 AND fa.rid IN ($roles)) OR fa.tid IS NULL OR aclu_fa.uid = $user->uid"; |
|
264 | - $sql['distinct'] = 1; |
|
265 | - break; |
|
263 | + $sql['where'] = "(fa.grant_$required_access >= 1 AND fa.rid IN ($roles)) OR fa.tid IS NULL OR aclu_fa.uid = $user->uid"; |
|
264 | + $sql['distinct'] = 1; |
|
265 | + break; |
|
266 | 266 | |
267 | - case 'rid': |
|
268 | - if (strpos($query, 'FROM {role}') === FALSE |
|
269 | - || strpos($_GET['q'] .'/', 'admin/content/forum/') === 0) { |
|
270 | - break; |
|
271 | - } |
|
272 | - $moderator_rid = forum_access_query_moderator_rid(); |
|
273 | - if (!empty($moderator_rid)) { |
|
274 | - $sql['where'] = "$primary_table.rid <> $moderator_rid"; |
|
275 | - } |
|
267 | + case 'rid': |
|
268 | + if (strpos($query, 'FROM {role}') === FALSE |
|
269 | + || strpos($_GET['q'] .'/', 'admin/content/forum/') === 0) { |
|
276 | 270 | break; |
271 | + } |
|
272 | + $moderator_rid = forum_access_query_moderator_rid(); |
|
273 | + if (!empty($moderator_rid)) { |
|
274 | + $sql['where'] = "$primary_table.rid <> $moderator_rid"; |
|
275 | + } |
|
276 | + break; |
|
277 | 277 | } |
278 | 278 | return $sql; |
279 | 279 | } |
@@ -301,42 +301,42 @@ discard block |
||
301 | 301 | } |
302 | 302 | |
303 | 303 | switch ($op) { |
304 | - case 'presave': |
|
305 | - $old_tid = db_result(db_query('SELECT tid FROM {forum} WHERE nid = %d', $node->nid)); |
|
306 | - break; |
|
304 | + case 'presave': |
|
305 | + $old_tid = db_result(db_query('SELECT tid FROM {forum} WHERE nid = %d', $node->nid)); |
|
306 | + break; |
|
307 | 307 | |
308 | - case 'update': |
|
309 | - if (!empty($old_tid)) { |
|
310 | - if (!empty($node->tid) && $node->tid == $old_tid) { |
|
311 | - return; |
|
312 | - } |
|
313 | - acl_node_clear_acls($node->nid, 'forum_access'); |
|
308 | + case 'update': |
|
309 | + if (!empty($old_tid)) { |
|
310 | + if (!empty($node->tid) && $node->tid == $old_tid) { |
|
311 | + return; |
|
312 | + } |
|
313 | + acl_node_clear_acls($node->nid, 'forum_access'); |
|
314 | 314 | |
315 | - if (module_exists('nodecomment')) { |
|
316 | - _forum_access_changed_tid($node->tid); |
|
317 | - $result = db_query('SELECT cid FROM {node_comments} WHERE nid = %d', $node->nid); |
|
318 | - while ($row = db_fetch_object($result)) { |
|
319 | - acl_node_clear_acls($row->cid, 'forum_access'); |
|
320 | - } |
|
315 | + if (module_exists('nodecomment')) { |
|
316 | + _forum_access_changed_tid($node->tid); |
|
317 | + $result = db_query('SELECT cid FROM {node_comments} WHERE nid = %d', $node->nid); |
|
318 | + while ($row = db_fetch_object($result)) { |
|
319 | + acl_node_clear_acls($row->cid, 'forum_access'); |
|
321 | 320 | } |
322 | 321 | } |
323 | - // Deliberate no break -- for changed and for previously unassigned terms we need an insert. |
|
324 | - |
|
325 | - case 'insert': |
|
326 | - if (!empty($node->tid)) { |
|
327 | - $acl_id = acl_get_id_by_number('forum_access', $node->tid); |
|
328 | - acl_node_add_acl($node->nid, $acl_id, 1, 1, 1); |
|
329 | - |
|
330 | - if (isset($old_tid) && module_exists('nodecomment')) { |
|
331 | - $result = db_query('SELECT cid FROM {node_comments} WHERE nid = %d', $node->nid); |
|
332 | - while ($row = db_fetch_object($result)) { |
|
333 | - acl_node_add_acl($row->cid, $acl_id, 1, 1, 1); |
|
334 | - node_access_acquire_grants(node_load($row->cid)); |
|
335 | - } |
|
322 | + } |
|
323 | + // Deliberate no break -- for changed and for previously unassigned terms we need an insert. |
|
324 | + |
|
325 | + case 'insert': |
|
326 | + if (!empty($node->tid)) { |
|
327 | + $acl_id = acl_get_id_by_number('forum_access', $node->tid); |
|
328 | + acl_node_add_acl($node->nid, $acl_id, 1, 1, 1); |
|
329 | + |
|
330 | + if (isset($old_tid) && module_exists('nodecomment')) { |
|
331 | + $result = db_query('SELECT cid FROM {node_comments} WHERE nid = %d', $node->nid); |
|
332 | + while ($row = db_fetch_object($result)) { |
|
333 | + acl_node_add_acl($row->cid, $acl_id, 1, 1, 1); |
|
334 | + node_access_acquire_grants(node_load($row->cid)); |
|
336 | 335 | } |
337 | 336 | } |
338 | - $old_tid = NULL; |
|
339 | - break; |
|
337 | + } |
|
338 | + $old_tid = NULL; |
|
339 | + break; |
|
340 | 340 | } |
341 | 341 | } |
342 | 342 | |
@@ -587,20 +587,20 @@ discard block |
||
587 | 587 | */ |
588 | 588 | function forum_access_user($op, &$edit, &$account, $category = NULL) { |
589 | 589 | switch ($op) { |
590 | - case 'validate': |
|
591 | - $rid = forum_access_query_moderator_rid(); |
|
592 | - if (!empty($rid)) { |
|
593 | - if (isset($edit['roles'][$rid]) && $edit['roles'][$rid]) { |
|
594 | - $roles = user_roles(); |
|
595 | - $variables = array( |
|
596 | - '@Forum_Access' => 'Forum Access', |
|
597 | - '%Role' => $roles[$rid], |
|
598 | - ); |
|
599 | - drupal_set_message(t('The %Role role is reserved for internal use by the @Forum_Access module! It was not assigned.', $variables), 'warning'); |
|
600 | - unset($edit['roles'][$rid]); |
|
601 | - } |
|
590 | + case 'validate': |
|
591 | + $rid = forum_access_query_moderator_rid(); |
|
592 | + if (!empty($rid)) { |
|
593 | + if (isset($edit['roles'][$rid]) && $edit['roles'][$rid]) { |
|
594 | + $roles = user_roles(); |
|
595 | + $variables = array( |
|
596 | + '@Forum_Access' => 'Forum Access', |
|
597 | + '%Role' => $roles[$rid], |
|
598 | + ); |
|
599 | + drupal_set_message(t('The %Role role is reserved for internal use by the @Forum_Access module! It was not assigned.', $variables), 'warning'); |
|
600 | + unset($edit['roles'][$rid]); |
|
602 | 601 | } |
603 | - break; |
|
602 | + } |
|
603 | + break; |
|
604 | 604 | } |
605 | 605 | } |
606 | 606 |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | if ($tid) { |
49 | 49 | if (!isset($grants[$tid])) { |
50 | 50 | if (!isset($node_admins)) { |
51 | - $node_admins = user_roles(FALSE, 'administer nodes'); |
|
51 | + $node_admins = user_roles(false, 'administer nodes'); |
|
52 | 52 | } |
53 | 53 | $result = db_query('SELECT * FROM {forum_access} WHERE tid = %d', $tid); |
54 | 54 | while ($grant = db_fetch_object($result)) { |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | |
88 | 88 | switch (arg(0)) { |
89 | 89 | case 'comment': |
90 | - if (variable_get('forum_access_D5_legacy_mode', FALSE)) { |
|
90 | + if (variable_get('forum_access_D5_legacy_mode', false)) { |
|
91 | 91 | return; // disable comment access control |
92 | 92 | } |
93 | 93 | if ((arg(1) == 'edit' || arg(1) == 'delete') && !user_access('administer comments')) { |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | // this comment. |
101 | 101 | // We won't provide full Administrator access, though: we'll remove |
102 | 102 | // author and timestamp, for example. |
103 | - $grant_normal_access = TRUE; |
|
103 | + $grant_normal_access = true; |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | break; |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | // This is the delete confirmation page. We don't need any |
125 | 125 | // additional permissions, but we'll assert 'view' access below. |
126 | 126 | } |
127 | - if (arg(2) == NULL && !user_access('administer comments')) { // node/% |
|
127 | + if (arg(2) == null && !user_access('administer comments')) { // node/% |
|
128 | 128 | $access[] = 'update'; |
129 | 129 | $nid = arg(1); |
130 | 130 | // If the node turns out to be in a forum where we have update/delete |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | module_load_include('node.inc', 'forum_access'); |
192 | 192 | _forum_access_node_form($form, $form_state); |
193 | 193 | } |
194 | - elseif ($form_id == 'comment_form' && !variable_get('forum_access_D5_legacy_mode', FALSE)) { |
|
194 | + elseif ($form_id == 'comment_form' && !variable_get('forum_access_D5_legacy_mode', false)) { |
|
195 | 195 | module_load_include('node.inc', 'forum_access'); |
196 | 196 | _forum_access_comment_form($form, $form_state); |
197 | 197 | } |
@@ -201,11 +201,11 @@ discard block |
||
201 | 201 | } |
202 | 202 | elseif ($form_id == 'forum_form_container') { |
203 | 203 | module_load_include('admin.inc', 'forum_access'); |
204 | - _forum_access_forum_form($form, $form_state, TRUE); |
|
204 | + _forum_access_forum_form($form, $form_state, true); |
|
205 | 205 | } |
206 | 206 | elseif ($form_id == 'forum_form_forum') { |
207 | 207 | module_load_include('admin.inc', 'forum_access'); |
208 | - _forum_access_forum_form($form, $form_state, FALSE); |
|
208 | + _forum_access_forum_form($form, $form_state, false); |
|
209 | 209 | } |
210 | 210 | elseif ($form_id == 'forum_admin_settings') { |
211 | 211 | module_load_include('admin.inc', 'forum_access'); |
@@ -242,15 +242,15 @@ discard block |
||
242 | 242 | */ |
243 | 243 | function forum_access_db_rewrite_sql($query, $primary_table, $primary_field, $args) { |
244 | 244 | global $user; |
245 | - $sql = NULL; |
|
245 | + $sql = null; |
|
246 | 246 | switch ($primary_field) { |
247 | 247 | case 'tid': |
248 | 248 | if ($user->uid == 1 |
249 | - || user_access('administer nodes') && strpos($_GET['q'], 'node/add/forum') === FALSE |
|
249 | + || user_access('administer nodes') && strpos($_GET['q'], 'node/add/forum') === false |
|
250 | 250 | || user_access('administer forums') && $_GET['q'] == 'admin/content/forum') { |
251 | 251 | break; |
252 | 252 | } |
253 | - if (strpos($_GET['q'], 'node/add/forum') !== FALSE) { |
|
253 | + if (strpos($_GET['q'], 'node/add/forum') !== false) { |
|
254 | 254 | $required_access = 'create'; |
255 | 255 | } |
256 | 256 | else { |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | break; |
266 | 266 | |
267 | 267 | case 'rid': |
268 | - if (strpos($query, 'FROM {role}') === FALSE |
|
268 | + if (strpos($query, 'FROM {role}') === false |
|
269 | 269 | || strpos($_GET['q'] .'/', 'admin/content/forum/') === 0) { |
270 | 270 | break; |
271 | 271 | } |
@@ -283,8 +283,8 @@ discard block |
||
283 | 283 | * |
284 | 284 | * Add ACL data to fresh forum posts. |
285 | 285 | */ |
286 | -function forum_access_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) { |
|
287 | - static $old_tid = NULL; |
|
286 | +function forum_access_nodeapi(&$node, $op, $teaser = null, $page = null) { |
|
287 | + static $old_tid = null; |
|
288 | 288 | // This is modeled after forum_nodeapi(): |
289 | 289 | $vid = _forum_access_get_vid(); |
290 | 290 | $vocabulary = taxonomy_vocabulary_load($vid); |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | } |
336 | 336 | } |
337 | 337 | } |
338 | - $old_tid = NULL; |
|
338 | + $old_tid = null; |
|
339 | 339 | break; |
340 | 340 | } |
341 | 341 | } |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | * and thus it is disabled by default. Set the variable to TRUE to enable. |
362 | 362 | */ |
363 | 363 | function forum_access_preprocess_forum_list(&$variables) { |
364 | - if (variable_get('forum_access_provide_moderators_template_variable', FALSE)) { |
|
364 | + if (variable_get('forum_access_provide_moderators_template_variable', false)) { |
|
365 | 365 | static $users; |
366 | 366 | foreach ($variables['forums'] as $tid => $forum) { |
367 | 367 | $moderators = array(); |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | $moderators[$uid] = $users[$uid]; |
374 | 374 | } |
375 | 375 | } |
376 | - $forum->forum_access_moderators = (empty($moderators) ? NULL : $moderators); |
|
376 | + $forum->forum_access_moderators = (empty($moderators) ? null : $moderators); |
|
377 | 377 | } |
378 | 378 | } |
379 | 379 | } |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | } |
395 | 395 | } |
396 | 396 | |
397 | -if (!variable_get('forum_access_D5_legacy_mode', FALSE)) { |
|
397 | +if (!variable_get('forum_access_D5_legacy_mode', false)) { |
|
398 | 398 | // LEGACY-MODE disables these methods |
399 | 399 | |
400 | 400 | /** |
@@ -403,9 +403,9 @@ discard block |
||
403 | 403 | * For nodes, remove the 'Add new comment' link, if the user does not have the |
404 | 404 | * 'comment_create' permission; for comments, add any missing links (D6.17+). |
405 | 405 | */ |
406 | -function forum_access_link_alter(&$links, $node, $comment = NULL) { |
|
406 | +function forum_access_link_alter(&$links, $node, $comment = null) { |
|
407 | 407 | global $user; |
408 | - static $user1, $recursing = FALSE, $stored_links; |
|
408 | + static $user1, $recursing = false, $stored_links; |
|
409 | 409 | |
410 | 410 | // If we are being called recursively, store the $links and return. |
411 | 411 | if ($recursing) { |
@@ -438,12 +438,12 @@ discard block |
||
438 | 438 | unset($required_keys[$access]); |
439 | 439 | } |
440 | 440 | elseif (!array_key_exists($key, $links)) { |
441 | - $link_is_missing = TRUE; |
|
441 | + $link_is_missing = true; |
|
442 | 442 | } |
443 | 443 | } |
444 | 444 | |
445 | 445 | // Hack to manually remove quote link if comment_reply link is no longer set |
446 | - if ( (!(isset($links['comment_reply']))) AND isset($links['quote']) ) { |
|
446 | + if ( (!(isset($links['comment_reply']))) and isset($links['quote']) ) { |
|
447 | 447 | unset($links['quote']); |
448 | 448 | } |
449 | 449 | |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | $user1 = user_load(1); |
459 | 459 | } |
460 | 460 | $saved_user = $user; |
461 | - session_save_session(FALSE); |
|
461 | + session_save_session(false); |
|
462 | 462 | $user = $user1; |
463 | 463 | |
464 | 464 | // With UID 1 we call hook_link(). This should give us the full set of |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | $admin_links = module_invoke_all('link', 'comment', $comment, array_key_exists('comment_parent', $links)); |
467 | 467 | |
468 | 468 | $user = $saved_user; |
469 | - session_save_session(TRUE); |
|
469 | + session_save_session(true); |
|
470 | 470 | |
471 | 471 | // Remove the links from $admin_links that are not in the reduced |
472 | 472 | // set of $required_links AND not available to the current user anyway. |
@@ -483,9 +483,9 @@ discard block |
||
483 | 483 | // called it will store a copy of the links at their current state. Then |
484 | 484 | // we pull those links which have not been link_alter'ed by any modules |
485 | 485 | // that come after forum_access. |
486 | - $recursing = TRUE; |
|
486 | + $recursing = true; |
|
487 | 487 | drupal_alter('link', $admin_links, $node, $comment); |
488 | - $recursing = FALSE; |
|
488 | + $recursing = false; |
|
489 | 489 | // Now return the stored links. |
490 | 490 | $links = $stored_links; |
491 | 491 | } |
@@ -523,9 +523,9 @@ discard block |
||
523 | 523 | /** |
524 | 524 | * This is also required by ACL module. |
525 | 525 | */ |
526 | -function forum_access_enabled($set = NULL) { |
|
527 | - static $enabled = TRUE; |
|
528 | - if ($set !== NULL) { |
|
526 | +function forum_access_enabled($set = null) { |
|
527 | + static $enabled = true; |
|
528 | + if ($set !== null) { |
|
529 | 529 | $enabled = $set; |
530 | 530 | } |
531 | 531 | return $enabled; |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | * 1 - access granted |
545 | 545 | * 2 - access granted for forum moderator |
546 | 546 | */ |
547 | -function forum_access_access($tid, $type, $account = NULL, $administer_nodes_sees_everything = TRUE) { |
|
547 | +function forum_access_access($tid, $type, $account = null, $administer_nodes_sees_everything = true) { |
|
548 | 548 | static $cache = array(); |
549 | 549 | if (!$account) { |
550 | 550 | global $user; |
@@ -552,13 +552,13 @@ discard block |
||
552 | 552 | } |
553 | 553 | |
554 | 554 | if ($account->uid == 1 || |
555 | - $administer_nodes_sees_everything && user_access('administer nodes', $account) && array_search($type, array('view', 'update', 'delete')) !== FALSE) { |
|
555 | + $administer_nodes_sees_everything && user_access('administer nodes', $account) && array_search($type, array('view', 'update', 'delete')) !== false) { |
|
556 | 556 | return 1; |
557 | 557 | } |
558 | 558 | |
559 | 559 | if (!isset($cache[$account->uid][$tid][$type])) { |
560 | 560 | if (!user_access('access content', $account)) { |
561 | - return $cache[$account->uid][$tid][$type] = FALSE; |
|
561 | + return $cache[$account->uid][$tid][$type] = false; |
|
562 | 562 | } |
563 | 563 | |
564 | 564 | $roles = array_keys($account->roles); |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | $cache[$account->uid][$tid][$type] = 2; |
576 | 576 | } |
577 | 577 | else { |
578 | - $cache[$account->uid][$tid][$type] = FALSE; |
|
578 | + $cache[$account->uid][$tid][$type] = false; |
|
579 | 579 | } |
580 | 580 | } |
581 | 581 | } |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | /** |
586 | 586 | * Implementation of hook_user(). |
587 | 587 | */ |
588 | -function forum_access_user($op, &$edit, &$account, $category = NULL) { |
|
588 | +function forum_access_user($op, &$edit, &$account, $category = null) { |
|
589 | 589 | switch ($op) { |
590 | 590 | case 'validate': |
591 | 591 | $rid = forum_access_query_moderator_rid(); |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | * no forum or container is specified will return TRUE if the user has at least |
629 | 629 | * one role that can access at least one forum. |
630 | 630 | */ |
631 | -function _forum_access_forum_access_callback($tid = NULL) { |
|
631 | +function _forum_access_forum_access_callback($tid = null) { |
|
632 | 632 | return (!$tid && _forum_access_access_any_forum()) || forum_access_access($tid, 'view'); |
633 | 633 | } |
634 | 634 | |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | * Returns TRUE if the user has at least one role that can access |
639 | 639 | * at least one forum. |
640 | 640 | */ |
641 | -function _forum_access_access_any_forum($account = NULL) { |
|
641 | +function _forum_access_access_any_forum($account = null) { |
|
642 | 642 | global $user; |
643 | 643 | static $return = array(); |
644 | 644 | |
@@ -648,12 +648,12 @@ discard block |
||
648 | 648 | |
649 | 649 | if (!isset($return[$account->uid])) { |
650 | 650 | if ($account->uid == 1) { |
651 | - return $return[$account->uid] = TRUE; |
|
651 | + return $return[$account->uid] = true; |
|
652 | 652 | } |
653 | 653 | if (!user_access('access content', $account)) { |
654 | - return $return[$account->uid] = FALSE; |
|
654 | + return $return[$account->uid] = false; |
|
655 | 655 | } |
656 | - $rids = variable_get('forum_access_rids', NULL); |
|
656 | + $rids = variable_get('forum_access_rids', null); |
|
657 | 657 | if (!isset($rids)) { |
658 | 658 | $rids = array(); |
659 | 659 | $result = db_query("SELECT fa.rid FROM {forum_access} fa WHERE fa.grant_view > 0 GROUP BY fa.rid"); |
@@ -664,10 +664,10 @@ discard block |
||
664 | 664 | } |
665 | 665 | foreach ($rids as $rid) { |
666 | 666 | if (isset($account->roles[$rid])) { |
667 | - return $return[$account->uid] = TRUE; |
|
667 | + return $return[$account->uid] = true; |
|
668 | 668 | } |
669 | 669 | } |
670 | - $return[$account->uid] = FALSE; |
|
670 | + $return[$account->uid] = false; |
|
671 | 671 | } |
672 | 672 | return $return[$account->uid]; |
673 | 673 | } |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | * |
678 | 678 | * Delete {forum_access} records when forums are deleted. |
679 | 679 | */ |
680 | -function forum_access_taxonomy($op, $type, $array = NULL) { |
|
680 | +function forum_access_taxonomy($op, $type, $array = null) { |
|
681 | 681 | //dpm($array, "hook_taxonomy($op, $type)"); |
682 | 682 | if ($type = 'term' && $op == 'delete' && $array['vid'] == _forum_access_get_vid()) { |
683 | 683 | db_query("DELETE FROM {forum_access} WHERE tid = %d", $array['tid']); |
@@ -697,21 +697,21 @@ discard block |
||
697 | 697 | * exist. |
698 | 698 | */ |
699 | 699 | function forum_access_query_moderator_rid() { |
700 | - return variable_get('forum_access_moderator_rid', NULL); |
|
700 | + return variable_get('forum_access_moderator_rid', null); |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | /** |
704 | 704 | * Return the forum tid or FALSE. |
705 | 705 | */ |
706 | 706 | function _forum_access_get_tid($node) { |
707 | - return (isset($node->forum_tid) ? $node->forum_tid : (isset($node->tid) ? $node->tid : FALSE)); |
|
707 | + return (isset($node->forum_tid) ? $node->forum_tid : (isset($node->tid) ? $node->tid : false)); |
|
708 | 708 | } |
709 | 709 | |
710 | 710 | /** |
711 | 711 | * Save and return the $tid. |
712 | 712 | */ |
713 | -function _forum_access_changed_tid($tid = NULL) { |
|
714 | - static $saved_tid = NULL; |
|
713 | +function _forum_access_changed_tid($tid = null) { |
|
714 | + static $saved_tid = null; |
|
715 | 715 | if (!empty($tid)) { |
716 | 716 | $saved_tid = $tid; |
717 | 717 | } |
@@ -722,7 +722,7 @@ discard block |
||
722 | 722 | * Implementation of hook_node_access_explain(). |
723 | 723 | */ |
724 | 724 | function forum_access_node_access_explain($row) { |
725 | - static $roles = NULL; |
|
725 | + static $roles = null; |
|
726 | 726 | if ($row->realm == 'forum_access') { |
727 | 727 | if (!isset($roles)) { |
728 | 728 | module_load_include('node.inc', 'forum_access'); |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | /** |
739 | 739 | * Implementation of hook_acl_explain(). |
740 | 740 | */ |
741 | -function forum_access_acl_explain($acl_id, $name, $number, $users = NULL) { |
|
741 | +function forum_access_acl_explain($acl_id, $name, $number, $users = null) { |
|
742 | 742 | if (empty($users)) { |
743 | 743 | return "ACL (id=$acl_id) would grant access to nodes in forum/$number."; |
744 | 744 | } |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | * roles as ACLs, so rids translate directly to gids. |
16 | 16 | */ |
17 | 17 | function forum_access_node_grants($user, $op) { |
18 | - $grants['forum_access'] = array_keys($user->roles); |
|
19 | - return $grants; |
|
18 | + $grants['forum_access'] = array_keys($user->roles); |
|
19 | + return $grants; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -26,51 +26,51 @@ discard block |
||
26 | 26 | * Checks to see if maybe we're being disabled. |
27 | 27 | */ |
28 | 28 | function forum_access_node_access_records($node) { |
29 | - if (!forum_access_enabled()) { |
|
29 | + if (!forum_access_enabled()) { |
|
30 | 30 | return; |
31 | - } |
|
31 | + } |
|
32 | 32 | |
33 | - static $grants = array(); |
|
34 | - static $node_admins; |
|
35 | - $tid = _forum_access_get_tid($node); |
|
33 | + static $grants = array(); |
|
34 | + static $node_admins; |
|
35 | + $tid = _forum_access_get_tid($node); |
|
36 | 36 | |
37 | - // Set proper grants for nodecomment comment nodes. |
|
38 | - if (isset($node->comment_target_nid)) { |
|
37 | + // Set proper grants for nodecomment comment nodes. |
|
38 | + if (isset($node->comment_target_nid)) { |
|
39 | 39 | if ($changed_tid = _forum_access_changed_tid()) { |
40 | - $tid = $changed_tid; // the topic node hasn't been saved yet! |
|
40 | + $tid = $changed_tid; // the topic node hasn't been saved yet! |
|
41 | 41 | } |
42 | 42 | else { |
43 | - $node = node_load($node->comment_target_nid); |
|
44 | - $tid = _forum_access_get_tid($node); |
|
43 | + $node = node_load($node->comment_target_nid); |
|
44 | + $tid = _forum_access_get_tid($node); |
|
45 | + } |
|
45 | 46 | } |
46 | - } |
|
47 | 47 | |
48 | - if ($tid) { |
|
48 | + if ($tid) { |
|
49 | 49 | if (!isset($grants[$tid])) { |
50 | - if (!isset($node_admins)) { |
|
50 | + if (!isset($node_admins)) { |
|
51 | 51 | $node_admins = user_roles(FALSE, 'administer nodes'); |
52 | - } |
|
53 | - $result = db_query('SELECT * FROM {forum_access} WHERE tid = %d', $tid); |
|
54 | - while ($grant = db_fetch_object($result)) { |
|
52 | + } |
|
53 | + $result = db_query('SELECT * FROM {forum_access} WHERE tid = %d', $tid); |
|
54 | + while ($grant = db_fetch_object($result)) { |
|
55 | 55 | if (isset($node_admins[$grant->rid])) { |
56 | - continue; // Don't provide any useless grants! |
|
56 | + continue; // Don't provide any useless grants! |
|
57 | 57 | } |
58 | 58 | $grants[$tid][] = array( |
59 | - 'realm' => 'forum_access', |
|
60 | - 'gid' => $grant->rid, |
|
61 | - 'grant_view' => $grant->grant_view, |
|
62 | - 'grant_update' => $grant->grant_update, |
|
63 | - 'grant_delete' => $grant->grant_delete, |
|
64 | - 'grant_comment_create' => $grant->grant_comment_create, |
|
65 | - 'priority' => $grant->priority, |
|
59 | + 'realm' => 'forum_access', |
|
60 | + 'gid' => $grant->rid, |
|
61 | + 'grant_view' => $grant->grant_view, |
|
62 | + 'grant_update' => $grant->grant_update, |
|
63 | + 'grant_delete' => $grant->grant_delete, |
|
64 | + 'grant_comment_create' => $grant->grant_comment_create, |
|
65 | + 'priority' => $grant->priority, |
|
66 | 66 | ); |
67 | - } |
|
68 | - //drupal_set_message("forum_access_node_access_records($node->nid) (tid=$tid) returns ". var_export($grants[$tid], TRUE), 'status'); |
|
67 | + } |
|
68 | + //drupal_set_message("forum_access_node_access_records($node->nid) (tid=$tid) returns ". var_export($grants[$tid], TRUE), 'status'); |
|
69 | 69 | } |
70 | 70 | if (isset($grants[$tid])) { |
71 | - return $grants[$tid]; |
|
71 | + return $grants[$tid]; |
|
72 | + } |
|
72 | 73 | } |
73 | - } |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -80,60 +80,60 @@ discard block |
||
80 | 80 | * and comment/delete/% where needed. |
81 | 81 | */ |
82 | 82 | function forum_access_init() { |
83 | - global $user; |
|
84 | - if ($user->uid == 1) { |
|
83 | + global $user; |
|
84 | + if ($user->uid == 1) { |
|
85 | 85 | return; |
86 | - } |
|
86 | + } |
|
87 | 87 | |
88 | - switch (arg(0)) { |
|
88 | + switch (arg(0)) { |
|
89 | 89 | case 'comment': |
90 | 90 | if (variable_get('forum_access_D5_legacy_mode', FALSE)) { |
91 | 91 | return; // disable comment access control |
92 | - } |
|
93 | - if ((arg(1) == 'edit' || arg(1) == 'delete') && !user_access('administer comments')) { |
|
92 | + } |
|
93 | + if ((arg(1) == 'edit' || arg(1) == 'delete') && !user_access('administer comments')) { |
|
94 | 94 | if (is_numeric($cid = arg(2))) { // comment/edit/%, comment/delete/% |
95 | - $access[] = (arg(1) == 'edit' ? 'update' : 'delete'); |
|
96 | - $comment = _comment_load($cid); |
|
97 | - $nid = $comment->nid; |
|
98 | - // If the node turns out to be in a forum where we have update/delete |
|
99 | - // access, then we need Moderator permissions now, so we can moderate |
|
100 | - // this comment. |
|
101 | - // We won't provide full Administrator access, though: we'll remove |
|
102 | - // author and timestamp, for example. |
|
103 | - $grant_normal_access = TRUE; |
|
104 | - } |
|
105 | - } |
|
106 | - break; |
|
95 | + $access[] = (arg(1) == 'edit' ? 'update' : 'delete'); |
|
96 | + $comment = _comment_load($cid); |
|
97 | + $nid = $comment->nid; |
|
98 | + // If the node turns out to be in a forum where we have update/delete |
|
99 | + // access, then we need Moderator permissions now, so we can moderate |
|
100 | + // this comment. |
|
101 | + // We won't provide full Administrator access, though: we'll remove |
|
102 | + // author and timestamp, for example. |
|
103 | + $grant_normal_access = TRUE; |
|
104 | + } |
|
105 | + } |
|
106 | + break; |
|
107 | 107 | |
108 | 108 | case 'node': |
109 | 109 | if (is_numeric(arg(1))) { |
110 | 110 | if (arg(2) == 'edit' && !user_access('administer nodes')) { // node/%/edit |
111 | - $access[] = 'update'; |
|
112 | - $nid = arg(1); |
|
113 | - // If the node turns out to be in a forum where we have update/delete |
|
114 | - // access, then we already get limited edit capabilities from NA, but |
|
115 | - // we need some more, e.g. publish/unpublish and comment status. |
|
116 | - // In order to get these controls on the form, we need Moderator |
|
117 | - // permissions now. |
|
118 | - // We won't provide full Administrator access, though: we'll remove |
|
119 | - // author and timestamp, for example. |
|
111 | + $access[] = 'update'; |
|
112 | + $nid = arg(1); |
|
113 | + // If the node turns out to be in a forum where we have update/delete |
|
114 | + // access, then we already get limited edit capabilities from NA, but |
|
115 | + // we need some more, e.g. publish/unpublish and comment status. |
|
116 | + // In order to get these controls on the form, we need Moderator |
|
117 | + // permissions now. |
|
118 | + // We won't provide full Administrator access, though: we'll remove |
|
119 | + // author and timestamp, for example. |
|
120 | 120 | } |
121 | 121 | if (arg(2) == 'delete' && !user_access('administer nodes')) { // node/%/delete |
122 | - $access = array(); |
|
123 | - $nid = arg(1); |
|
124 | - // This is the delete confirmation page. We don't need any |
|
125 | - // additional permissions, but we'll assert 'view' access below. |
|
122 | + $access = array(); |
|
123 | + $nid = arg(1); |
|
124 | + // This is the delete confirmation page. We don't need any |
|
125 | + // additional permissions, but we'll assert 'view' access below. |
|
126 | 126 | } |
127 | 127 | if (arg(2) == NULL && !user_access('administer comments')) { // node/% |
128 | - $access[] = 'update'; |
|
129 | - $nid = arg(1); |
|
130 | - // If the node turns out to be in a forum where we have update/delete |
|
131 | - // access, then we'll get the 'Edit' link automatically from NA, but |
|
132 | - // we'll need Moderator permissions, so that we can add the edit/delete |
|
133 | - // comment links (*after* we've identified the other comment links). |
|
128 | + $access[] = 'update'; |
|
129 | + $nid = arg(1); |
|
130 | + // If the node turns out to be in a forum where we have update/delete |
|
131 | + // access, then we'll get the 'Edit' link automatically from NA, but |
|
132 | + // we'll need Moderator permissions, so that we can add the edit/delete |
|
133 | + // comment links (*after* we've identified the other comment links). |
|
134 | 134 | } |
135 | - } |
|
136 | - break; |
|
135 | + } |
|
136 | + break; |
|
137 | 137 | |
138 | 138 | case 'community': |
139 | 139 | if (arg(1)=='forum') { |
@@ -155,30 +155,30 @@ discard block |
||
155 | 155 | }// is_numeric(arg(2)) |
156 | 156 | }// arg(1)==forum |
157 | 157 | break; |
158 | - }// switch |
|
159 | - if (isset($nid)) { |
|
158 | + }// switch |
|
159 | + if (isset($nid)) { |
|
160 | 160 | $node = node_load($nid); |
161 | 161 | if ($tid = _forum_access_get_tid($node)) { |
162 | - if (!forum_access_access($tid, 'view')) { |
|
162 | + if (!forum_access_access($tid, 'view')) { |
|
163 | 163 | drupal_access_denied(); |
164 | 164 | module_invoke_all('exit'); |
165 | 165 | exit; |
166 | - } |
|
167 | - foreach ($access as $a) { |
|
166 | + } |
|
167 | + foreach ($access as $a) { |
|
168 | 168 | $faa = forum_access_access($tid, $a); |
169 | 169 | $grant_moderator_access = $faa > 1; |
170 | 170 | $grant_normal_access = !empty($grant_normal_access) && $faa > 0; |
171 | 171 | if ($grant_normal_access || $grant_moderator_access) { |
172 | - $user->_forum_access_moderator = $grant_moderator_access; |
|
173 | - if (arg(0) == 'comment' || arg(0) == 'node' && arg(2) == 'edit') { |
|
172 | + $user->_forum_access_moderator = $grant_moderator_access; |
|
173 | + if (arg(0) == 'comment' || arg(0) == 'node' && arg(2) == 'edit') { |
|
174 | 174 | module_load_include('node.inc', 'forum_access'); |
175 | 175 | _forum_access_enable_moderator(); |
176 | 176 | break; |
177 | - } |
|
177 | + } |
|
178 | 178 | } |
179 | - } |
|
179 | + } |
|
180 | + } |
|
180 | 181 | } |
181 | - } |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -187,50 +187,50 @@ discard block |
||
187 | 187 | * Alter the node/comment create/edit forms and various admin forms. |
188 | 188 | */ |
189 | 189 | function forum_access_form_alter(&$form, &$form_state, $form_id) { |
190 | - if (isset($form['type']['#value']) && $form['type']['#value'] .'_node_form' == $form_id) { |
|
190 | + if (isset($form['type']['#value']) && $form['type']['#value'] .'_node_form' == $form_id) { |
|
191 | 191 | module_load_include('node.inc', 'forum_access'); |
192 | 192 | _forum_access_node_form($form, $form_state); |
193 | - } |
|
194 | - elseif ($form_id == 'comment_form' && !variable_get('forum_access_D5_legacy_mode', FALSE)) { |
|
193 | + } |
|
194 | + elseif ($form_id == 'comment_form' && !variable_get('forum_access_D5_legacy_mode', FALSE)) { |
|
195 | 195 | module_load_include('node.inc', 'forum_access'); |
196 | 196 | _forum_access_comment_form($form, $form_state); |
197 | - } |
|
198 | - elseif ($form_id == 'forum_overview') { |
|
197 | + } |
|
198 | + elseif ($form_id == 'forum_overview') { |
|
199 | 199 | module_load_include('admin.inc', 'forum_access'); |
200 | 200 | _forum_access_forum_overview($form, $form_state); |
201 | - } |
|
202 | - elseif ($form_id == 'forum_form_container') { |
|
201 | + } |
|
202 | + elseif ($form_id == 'forum_form_container') { |
|
203 | 203 | module_load_include('admin.inc', 'forum_access'); |
204 | 204 | _forum_access_forum_form($form, $form_state, TRUE); |
205 | - } |
|
206 | - elseif ($form_id == 'forum_form_forum') { |
|
205 | + } |
|
206 | + elseif ($form_id == 'forum_form_forum') { |
|
207 | 207 | module_load_include('admin.inc', 'forum_access'); |
208 | 208 | _forum_access_forum_form($form, $form_state, FALSE); |
209 | - } |
|
210 | - elseif ($form_id == 'forum_admin_settings') { |
|
209 | + } |
|
210 | + elseif ($form_id == 'forum_admin_settings') { |
|
211 | 211 | module_load_include('admin.inc', 'forum_access'); |
212 | 212 | _forum_access_forum_admin_settings_form($form, $form_state); |
213 | - } |
|
214 | - elseif ($form_id == 'user_admin_role') { |
|
213 | + } |
|
214 | + elseif ($form_id == 'user_admin_role') { |
|
215 | 215 | module_load_include('admin.inc', 'forum_access'); |
216 | 216 | _forum_access_user_admin_role_form($form, $form_state); |
217 | - } |
|
218 | - elseif ($form_id == 'content_access_admin_settings' && empty($_POST)) { |
|
217 | + } |
|
218 | + elseif ($form_id == 'content_access_admin_settings' && empty($_POST)) { |
|
219 | 219 | module_load_include('admin.inc', 'forum_access'); |
220 | 220 | _forum_access_content_access_admin_form(); |
221 | - } |
|
222 | - elseif ($form_id == 'user_admin_perm') { |
|
221 | + } |
|
222 | + elseif ($form_id == 'user_admin_perm') { |
|
223 | 223 | module_load_include('admin.inc', 'forum_access'); |
224 | 224 | _forum_access_user_admin_perm_form($form, $form_state); |
225 | - } |
|
226 | - elseif ($form_id == 'user_admin_account') { |
|
225 | + } |
|
226 | + elseif ($form_id == 'user_admin_account') { |
|
227 | 227 | module_load_include('admin.inc', 'forum_access'); |
228 | 228 | _forum_access_user_admin_account_form($form, $form_state); |
229 | - } |
|
230 | - elseif ($form_id == 'user_profile_form') { |
|
229 | + } |
|
230 | + elseif ($form_id == 'user_profile_form') { |
|
231 | 231 | module_load_include('admin.inc', 'forum_access'); |
232 | 232 | _forum_access_user_profile_form($form, $form_state); |
233 | - } |
|
233 | + } |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | /** |
@@ -241,41 +241,41 @@ discard block |
||
241 | 241 | * taxonomy. There should be. |
242 | 242 | */ |
243 | 243 | function forum_access_db_rewrite_sql($query, $primary_table, $primary_field, $args) { |
244 | - global $user; |
|
245 | - $sql = NULL; |
|
246 | - switch ($primary_field) { |
|
244 | + global $user; |
|
245 | + $sql = NULL; |
|
246 | + switch ($primary_field) { |
|
247 | 247 | case 'tid': |
248 | 248 | if ($user->uid == 1 |
249 | 249 | || user_access('administer nodes') && strpos($_GET['q'], 'node/add/forum') === FALSE |
250 | 250 | || user_access('administer forums') && $_GET['q'] == 'admin/content/forum') { |
251 | 251 | break; |
252 | - } |
|
253 | - if (strpos($_GET['q'], 'node/add/forum') !== FALSE) { |
|
252 | + } |
|
253 | + if (strpos($_GET['q'], 'node/add/forum') !== FALSE) { |
|
254 | 254 | $required_access = 'create'; |
255 | - } |
|
256 | - else { |
|
255 | + } |
|
256 | + else { |
|
257 | 257 | $required_access = 'view'; |
258 | - } |
|
259 | - $roles = implode(', ', array_keys($user->roles)); |
|
260 | - $sql['join'] = "LEFT JOIN {forum_access} fa ON $primary_table.tid = fa.tid |
|
258 | + } |
|
259 | + $roles = implode(', ', array_keys($user->roles)); |
|
260 | + $sql['join'] = "LEFT JOIN {forum_access} fa ON $primary_table.tid = fa.tid |
|
261 | 261 | LEFT JOIN {acl} acl_fa ON acl_fa.number = $primary_table.tid AND acl_fa.module = 'forum_access' |
262 | 262 | LEFT JOIN {acl_user} aclu_fa ON aclu_fa.acl_id = acl_fa.acl_id AND aclu_fa.uid = $user->uid"; |
263 | - $sql['where'] = "(fa.grant_$required_access >= 1 AND fa.rid IN ($roles)) OR fa.tid IS NULL OR aclu_fa.uid = $user->uid"; |
|
264 | - $sql['distinct'] = 1; |
|
265 | - break; |
|
263 | + $sql['where'] = "(fa.grant_$required_access >= 1 AND fa.rid IN ($roles)) OR fa.tid IS NULL OR aclu_fa.uid = $user->uid"; |
|
264 | + $sql['distinct'] = 1; |
|
265 | + break; |
|
266 | 266 | |
267 | 267 | case 'rid': |
268 | 268 | if (strpos($query, 'FROM {role}') === FALSE |
269 | 269 | || strpos($_GET['q'] .'/', 'admin/content/forum/') === 0) { |
270 | 270 | break; |
271 | - } |
|
272 | - $moderator_rid = forum_access_query_moderator_rid(); |
|
273 | - if (!empty($moderator_rid)) { |
|
271 | + } |
|
272 | + $moderator_rid = forum_access_query_moderator_rid(); |
|
273 | + if (!empty($moderator_rid)) { |
|
274 | 274 | $sql['where'] = "$primary_table.rid <> $moderator_rid"; |
275 | - } |
|
276 | - break; |
|
277 | - } |
|
278 | - return $sql; |
|
275 | + } |
|
276 | + break; |
|
277 | + } |
|
278 | + return $sql; |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -284,43 +284,43 @@ discard block |
||
284 | 284 | * Add ACL data to fresh forum posts. |
285 | 285 | */ |
286 | 286 | function forum_access_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) { |
287 | - static $old_tid = NULL; |
|
288 | - // This is modeled after forum_nodeapi(): |
|
289 | - $vid = _forum_access_get_vid(); |
|
290 | - $vocabulary = taxonomy_vocabulary_load($vid); |
|
291 | - if (empty($vocabulary) || !in_array($node->type, $vocabulary->nodes)) { |
|
287 | + static $old_tid = NULL; |
|
288 | + // This is modeled after forum_nodeapi(): |
|
289 | + $vid = _forum_access_get_vid(); |
|
290 | + $vocabulary = taxonomy_vocabulary_load($vid); |
|
291 | + if (empty($vocabulary) || !in_array($node->type, $vocabulary->nodes)) { |
|
292 | 292 | if ($op == 'insert' && isset($node->comment_target_nid)) { |
293 | - // Set moderator on nodecomment. |
|
294 | - $topic_node = node_load($node->comment_target_nid); |
|
295 | - if ($topic_tid = _forum_access_get_tid($topic_node)) { |
|
293 | + // Set moderator on nodecomment. |
|
294 | + $topic_node = node_load($node->comment_target_nid); |
|
295 | + if ($topic_tid = _forum_access_get_tid($topic_node)) { |
|
296 | 296 | $acl_id = acl_get_id_by_number('forum_access', $topic_tid); |
297 | 297 | acl_node_add_acl($node->nid, $acl_id, 1, 1, 1); |
298 | - } |
|
298 | + } |
|
299 | 299 | } |
300 | 300 | return; |
301 | - } |
|
301 | + } |
|
302 | 302 | |
303 | - switch ($op) { |
|
303 | + switch ($op) { |
|
304 | 304 | case 'presave': |
305 | 305 | $old_tid = db_result(db_query('SELECT tid FROM {forum} WHERE nid = %d', $node->nid)); |
306 | - break; |
|
306 | + break; |
|
307 | 307 | |
308 | 308 | case 'update': |
309 | 309 | if (!empty($old_tid)) { |
310 | 310 | if (!empty($node->tid) && $node->tid == $old_tid) { |
311 | - return; |
|
311 | + return; |
|
312 | 312 | } |
313 | 313 | acl_node_clear_acls($node->nid, 'forum_access'); |
314 | 314 | |
315 | 315 | if (module_exists('nodecomment')) { |
316 | - _forum_access_changed_tid($node->tid); |
|
317 | - $result = db_query('SELECT cid FROM {node_comments} WHERE nid = %d', $node->nid); |
|
318 | - while ($row = db_fetch_object($result)) { |
|
316 | + _forum_access_changed_tid($node->tid); |
|
317 | + $result = db_query('SELECT cid FROM {node_comments} WHERE nid = %d', $node->nid); |
|
318 | + while ($row = db_fetch_object($result)) { |
|
319 | 319 | acl_node_clear_acls($row->cid, 'forum_access'); |
320 | - } |
|
320 | + } |
|
321 | + } |
|
321 | 322 | } |
322 | - } |
|
323 | - // Deliberate no break -- for changed and for previously unassigned terms we need an insert. |
|
323 | + // Deliberate no break -- for changed and for previously unassigned terms we need an insert. |
|
324 | 324 | |
325 | 325 | case 'insert': |
326 | 326 | if (!empty($node->tid)) { |
@@ -328,27 +328,27 @@ discard block |
||
328 | 328 | acl_node_add_acl($node->nid, $acl_id, 1, 1, 1); |
329 | 329 | |
330 | 330 | if (isset($old_tid) && module_exists('nodecomment')) { |
331 | - $result = db_query('SELECT cid FROM {node_comments} WHERE nid = %d', $node->nid); |
|
332 | - while ($row = db_fetch_object($result)) { |
|
331 | + $result = db_query('SELECT cid FROM {node_comments} WHERE nid = %d', $node->nid); |
|
332 | + while ($row = db_fetch_object($result)) { |
|
333 | 333 | acl_node_add_acl($row->cid, $acl_id, 1, 1, 1); |
334 | 334 | node_access_acquire_grants(node_load($row->cid)); |
335 | - } |
|
335 | + } |
|
336 | 336 | } |
337 | - } |
|
338 | - $old_tid = NULL; |
|
339 | - break; |
|
340 | - } |
|
337 | + } |
|
338 | + $old_tid = NULL; |
|
339 | + break; |
|
340 | + } |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | /** |
344 | 344 | * Get an array of moderator UIDs or NULL. |
345 | 345 | */ |
346 | 346 | function forum_access_get_moderator_uids($tid) { |
347 | - if ($acl_id = acl_get_id_by_number('forum_access', $tid)) { |
|
347 | + if ($acl_id = acl_get_id_by_number('forum_access', $tid)) { |
|
348 | 348 | if ($uids = acl_get_uids($acl_id)) { |
349 | - return $uids; |
|
349 | + return $uids; |
|
350 | + } |
|
350 | 351 | } |
351 | - } |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | /** |
@@ -361,21 +361,21 @@ discard block |
||
361 | 361 | * and thus it is disabled by default. Set the variable to TRUE to enable. |
362 | 362 | */ |
363 | 363 | function forum_access_preprocess_forum_list(&$variables) { |
364 | - if (variable_get('forum_access_provide_moderators_template_variable', FALSE)) { |
|
364 | + if (variable_get('forum_access_provide_moderators_template_variable', FALSE)) { |
|
365 | 365 | static $users; |
366 | 366 | foreach ($variables['forums'] as $tid => $forum) { |
367 | - $moderators = array(); |
|
368 | - if ($uids = forum_access_get_moderator_uids($tid)) { |
|
367 | + $moderators = array(); |
|
368 | + if ($uids = forum_access_get_moderator_uids($tid)) { |
|
369 | 369 | foreach ($uids as $uid) { |
370 | - if (!isset($users[$uid])) { |
|
370 | + if (!isset($users[$uid])) { |
|
371 | 371 | $users[$uid] = user_load(array('uid' => $uid)); |
372 | - } |
|
373 | - $moderators[$uid] = $users[$uid]; |
|
372 | + } |
|
373 | + $moderators[$uid] = $users[$uid]; |
|
374 | + } |
|
374 | 375 | } |
375 | - } |
|
376 | - $forum->forum_access_moderators = (empty($moderators) ? NULL : $moderators); |
|
376 | + $forum->forum_access_moderators = (empty($moderators) ? NULL : $moderators); |
|
377 | + } |
|
377 | 378 | } |
378 | - } |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | /** |
@@ -385,17 +385,17 @@ discard block |
||
385 | 385 | * 'create' permission. |
386 | 386 | */ |
387 | 387 | function forum_access_preprocess_forums(&$variables) { |
388 | - if (!forum_access_access($variables['tid'], 'create') && !empty($variables['links'])) { |
|
388 | + if (!forum_access_access($variables['tid'], 'create') && !empty($variables['links'])) { |
|
389 | 389 | foreach ($variables['links'] as $key => $link) { |
390 | - if (isset($link['href']) && substr($link['href'], 0, 9) == 'node/add/') { |
|
390 | + if (isset($link['href']) && substr($link['href'], 0, 9) == 'node/add/') { |
|
391 | 391 | unset($variables['links'][$key]); |
392 | - } |
|
392 | + } |
|
393 | + } |
|
393 | 394 | } |
394 | - } |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | if (!variable_get('forum_access_D5_legacy_mode', FALSE)) { |
398 | - // LEGACY-MODE disables these methods |
|
398 | + // LEGACY-MODE disables these methods |
|
399 | 399 | |
400 | 400 | /** |
401 | 401 | * Implementation of hook_link_alter(). |
@@ -404,42 +404,42 @@ discard block |
||
404 | 404 | * 'comment_create' permission; for comments, add any missing links (D6.17+). |
405 | 405 | */ |
406 | 406 | function forum_access_link_alter(&$links, $node, $comment = NULL) { |
407 | - global $user; |
|
408 | - static $user1, $recursing = FALSE, $stored_links; |
|
407 | + global $user; |
|
408 | + static $user1, $recursing = FALSE, $stored_links; |
|
409 | 409 | |
410 | - // If we are being called recursively, store the $links and return. |
|
411 | - if ($recursing) { |
|
410 | + // If we are being called recursively, store the $links and return. |
|
411 | + if ($recursing) { |
|
412 | 412 | $stored_links = $links; |
413 | 413 | return; |
414 | - } |
|
415 | - if ($user->uid == 1 || !($tid = _forum_access_get_tid($node))) { |
|
414 | + } |
|
415 | + if ($user->uid == 1 || !($tid = _forum_access_get_tid($node))) { |
|
416 | 416 | return; |
417 | - } |
|
418 | - if (empty($comment)) { |
|
417 | + } |
|
418 | + if (empty($comment)) { |
|
419 | 419 | // Check links for the node. |
420 | 420 | if ($tid && isset($links['comment_add']) && !forum_access_access($tid, 'comment_create') && !(forum_access_access($tid, 'create') and ($node->uid==$user->uid)) ) { |
421 | - unset($links['comment_add']); |
|
422 | - // Hack to manually remove quote link |
|
423 | - if ( isset($links['quote']) ) { |
|
424 | - unset($links['quote']); |
|
425 | - } |
|
426 | - } |
|
427 | - } |
|
428 | - else { |
|
421 | + unset($links['comment_add']); |
|
422 | + // Hack to manually remove quote link |
|
423 | + if ( isset($links['quote']) ) { |
|
424 | + unset($links['quote']); |
|
425 | + } |
|
426 | + } |
|
427 | + } |
|
428 | + else { |
|
429 | 429 | // Check links for the comment. |
430 | 430 | $required_keys = array( |
431 | - 'comment_create' => 'comment_reply', |
|
432 | - 'update' => 'comment_edit', |
|
433 | - 'delete' => 'comment_delete', |
|
431 | + 'comment_create' => 'comment_reply', |
|
432 | + 'update' => 'comment_edit', |
|
433 | + 'delete' => 'comment_delete', |
|
434 | 434 | ); |
435 | 435 | foreach ($required_keys as $access => $key) { |
436 | - if (!forum_access_access($tid, $access) && !($access == 'update' && comment_access('edit', $comment)) && !($access == 'comment_create' && forum_access_access($tid, 'create') && ($node->uid==$user->uid)) ) { |
|
436 | + if (!forum_access_access($tid, $access) && !($access == 'update' && comment_access('edit', $comment)) && !($access == 'comment_create' && forum_access_access($tid, 'create') && ($node->uid==$user->uid)) ) { |
|
437 | 437 | unset($links[$required_keys[$access]]); |
438 | 438 | unset($required_keys[$access]); |
439 | - } |
|
440 | - elseif (!array_key_exists($key, $links)) { |
|
439 | + } |
|
440 | + elseif (!array_key_exists($key, $links)) { |
|
441 | 441 | $link_is_missing = TRUE; |
442 | - } |
|
442 | + } |
|
443 | 443 | } |
444 | 444 | |
445 | 445 | // Hack to manually remove quote link if comment_reply link is no longer set |
@@ -448,48 +448,48 @@ discard block |
||
448 | 448 | } |
449 | 449 | |
450 | 450 | if (isset($required_keys['comment_create']) && !user_access('post comments')) { |
451 | - unset($required_keys['comment_create']); |
|
451 | + unset($required_keys['comment_create']); |
|
452 | 452 | } |
453 | 453 | if (!empty($link_is_missing)) { |
454 | - // One of the $required_links should be present, because the current |
|
455 | - // user has the corresponding permission, but it isn't. |
|
456 | - // We temporarily switch to UID 1 to 'harvest' all comment links. |
|
457 | - if (!isset($user1)) { |
|
454 | + // One of the $required_links should be present, because the current |
|
455 | + // user has the corresponding permission, but it isn't. |
|
456 | + // We temporarily switch to UID 1 to 'harvest' all comment links. |
|
457 | + if (!isset($user1)) { |
|
458 | 458 | $user1 = user_load(1); |
459 | - } |
|
460 | - $saved_user = $user; |
|
461 | - session_save_session(FALSE); |
|
462 | - $user = $user1; |
|
463 | - |
|
464 | - // With UID 1 we call hook_link(). This should give us the full set of |
|
465 | - // links that the site admin sees. |
|
466 | - $admin_links = module_invoke_all('link', 'comment', $comment, array_key_exists('comment_parent', $links)); |
|
467 | - |
|
468 | - $user = $saved_user; |
|
469 | - session_save_session(TRUE); |
|
470 | - |
|
471 | - // Remove the links from $admin_links that are not in the reduced |
|
472 | - // set of $required_links AND not available to the current user anyway. |
|
473 | - // Afterwards, $admin_links should have the same content as $links, plus |
|
474 | - // one or more additional links from the original set in $required_links. |
|
475 | - foreach ($admin_links as $key => $target) { |
|
459 | + } |
|
460 | + $saved_user = $user; |
|
461 | + session_save_session(FALSE); |
|
462 | + $user = $user1; |
|
463 | + |
|
464 | + // With UID 1 we call hook_link(). This should give us the full set of |
|
465 | + // links that the site admin sees. |
|
466 | + $admin_links = module_invoke_all('link', 'comment', $comment, array_key_exists('comment_parent', $links)); |
|
467 | + |
|
468 | + $user = $saved_user; |
|
469 | + session_save_session(TRUE); |
|
470 | + |
|
471 | + // Remove the links from $admin_links that are not in the reduced |
|
472 | + // set of $required_links AND not available to the current user anyway. |
|
473 | + // Afterwards, $admin_links should have the same content as $links, plus |
|
474 | + // one or more additional links from the original set in $required_links. |
|
475 | + foreach ($admin_links as $key => $target) { |
|
476 | 476 | if (!in_array($key, $required_keys) && !array_key_exists($key, $links)) { |
477 | - unset($admin_links[$key]); |
|
478 | - } |
|
479 | - } |
|
480 | - |
|
481 | - // As the real current user, call hook_link_alter on the admin links. |
|
482 | - // First we set a static variable so that the next time this function is |
|
483 | - // called it will store a copy of the links at their current state. Then |
|
484 | - // we pull those links which have not been link_alter'ed by any modules |
|
485 | - // that come after forum_access. |
|
486 | - $recursing = TRUE; |
|
487 | - drupal_alter('link', $admin_links, $node, $comment); |
|
488 | - $recursing = FALSE; |
|
489 | - // Now return the stored links. |
|
490 | - $links = $stored_links; |
|
491 | - } |
|
492 | - }// if empty($comment) |
|
477 | + unset($admin_links[$key]); |
|
478 | + } |
|
479 | + } |
|
480 | + |
|
481 | + // As the real current user, call hook_link_alter on the admin links. |
|
482 | + // First we set a static variable so that the next time this function is |
|
483 | + // called it will store a copy of the links at their current state. Then |
|
484 | + // we pull those links which have not been link_alter'ed by any modules |
|
485 | + // that come after forum_access. |
|
486 | + $recursing = TRUE; |
|
487 | + drupal_alter('link', $admin_links, $node, $comment); |
|
488 | + $recursing = FALSE; |
|
489 | + // Now return the stored links. |
|
490 | + $links = $stored_links; |
|
491 | + } |
|
492 | + }// if empty($comment) |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | /** |
@@ -499,10 +499,10 @@ discard block |
||
499 | 499 | * (after _forum_access_comment_form()). |
500 | 500 | */ |
501 | 501 | function forum_access_preprocess_box(&$variables) { |
502 | - $tr = 't'; |
|
503 | - if (empty($variables['content']) && ($variables['title'] == $tr('Post new comment') || $variables['title'] == $tr('Reply'))) { |
|
502 | + $tr = 't'; |
|
503 | + if (empty($variables['content']) && ($variables['title'] == $tr('Post new comment') || $variables['title'] == $tr('Reply'))) { |
|
504 | 504 | $variables['title'] = ''; |
505 | - } |
|
505 | + } |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | /** |
@@ -512,10 +512,10 @@ discard block |
||
512 | 512 | * remove those that aren't accessible to the user. |
513 | 513 | */ |
514 | 514 | function forum_access_preprocess_comment(&$variables) { |
515 | - if (version_compare(VERSION, '6.17', '<') && isset($variables['node']->tid)) { |
|
515 | + if (version_compare(VERSION, '6.17', '<') && isset($variables['node']->tid)) { |
|
516 | 516 | module_load_include('node.inc', 'forum_access'); |
517 | 517 | _forum_access_preprocess_comment($variables); |
518 | - } |
|
518 | + } |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | } // End of !LEGACY-MODE |
@@ -524,11 +524,11 @@ discard block |
||
524 | 524 | * This is also required by ACL module. |
525 | 525 | */ |
526 | 526 | function forum_access_enabled($set = NULL) { |
527 | - static $enabled = TRUE; |
|
528 | - if ($set !== NULL) { |
|
527 | + static $enabled = TRUE; |
|
528 | + if ($set !== NULL) { |
|
529 | 529 | $enabled = $set; |
530 | - } |
|
531 | - return $enabled; |
|
530 | + } |
|
531 | + return $enabled; |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | /** |
@@ -545,63 +545,63 @@ discard block |
||
545 | 545 | * 2 - access granted for forum moderator |
546 | 546 | */ |
547 | 547 | function forum_access_access($tid, $type, $account = NULL, $administer_nodes_sees_everything = TRUE) { |
548 | - static $cache = array(); |
|
549 | - if (!$account) { |
|
548 | + static $cache = array(); |
|
549 | + if (!$account) { |
|
550 | 550 | global $user; |
551 | 551 | $account = $user; |
552 | - } |
|
552 | + } |
|
553 | 553 | |
554 | - if ($account->uid == 1 || |
|
554 | + if ($account->uid == 1 || |
|
555 | 555 | $administer_nodes_sees_everything && user_access('administer nodes', $account) && array_search($type, array('view', 'update', 'delete')) !== FALSE) { |
556 | 556 | return 1; |
557 | - } |
|
557 | + } |
|
558 | 558 | |
559 | - if (!isset($cache[$account->uid][$tid][$type])) { |
|
559 | + if (!isset($cache[$account->uid][$tid][$type])) { |
|
560 | 560 | if (!user_access('access content', $account)) { |
561 | - return $cache[$account->uid][$tid][$type] = FALSE; |
|
561 | + return $cache[$account->uid][$tid][$type] = FALSE; |
|
562 | 562 | } |
563 | 563 | |
564 | 564 | $roles = array_keys($account->roles); |
565 | 565 | $result = db_result(db_query("SELECT tid FROM {forum_access} WHERE rid IN (". db_placeholders($roles) .") AND grant_". $type ." = 1 AND tid = %d", array_merge($roles, array($tid)))); |
566 | 566 | |
567 | 567 | if ($result) { |
568 | - $cache[$account->uid][$tid][$type] = 1; |
|
568 | + $cache[$account->uid][$tid][$type] = 1; |
|
569 | 569 | } |
570 | 570 | else { |
571 | - // check our moderators too |
|
572 | - $acl_id = acl_get_id_by_number('forum_access', $tid); |
|
573 | - $result = db_result(db_query("SELECT uid FROM {acl_user} WHERE acl_id = %d AND uid = %d", $acl_id, $account->uid)); |
|
574 | - if ($result) { |
|
571 | + // check our moderators too |
|
572 | + $acl_id = acl_get_id_by_number('forum_access', $tid); |
|
573 | + $result = db_result(db_query("SELECT uid FROM {acl_user} WHERE acl_id = %d AND uid = %d", $acl_id, $account->uid)); |
|
574 | + if ($result) { |
|
575 | 575 | $cache[$account->uid][$tid][$type] = 2; |
576 | - } |
|
577 | - else { |
|
576 | + } |
|
577 | + else { |
|
578 | 578 | $cache[$account->uid][$tid][$type] = FALSE; |
579 | - } |
|
579 | + } |
|
580 | 580 | } |
581 | - } |
|
582 | - return $cache[$account->uid][$tid][$type]; |
|
581 | + } |
|
582 | + return $cache[$account->uid][$tid][$type]; |
|
583 | 583 | } |
584 | 584 | |
585 | 585 | /** |
586 | 586 | * Implementation of hook_user(). |
587 | 587 | */ |
588 | 588 | function forum_access_user($op, &$edit, &$account, $category = NULL) { |
589 | - switch ($op) { |
|
589 | + switch ($op) { |
|
590 | 590 | case 'validate': |
591 | 591 | $rid = forum_access_query_moderator_rid(); |
592 | - if (!empty($rid)) { |
|
592 | + if (!empty($rid)) { |
|
593 | 593 | if (isset($edit['roles'][$rid]) && $edit['roles'][$rid]) { |
594 | - $roles = user_roles(); |
|
595 | - $variables = array( |
|
594 | + $roles = user_roles(); |
|
595 | + $variables = array( |
|
596 | 596 | '@Forum_Access' => 'Forum Access', |
597 | 597 | '%Role' => $roles[$rid], |
598 | - ); |
|
599 | - drupal_set_message(t('The %Role role is reserved for internal use by the @Forum_Access module! It was not assigned.', $variables), 'warning'); |
|
600 | - unset($edit['roles'][$rid]); |
|
598 | + ); |
|
599 | + drupal_set_message(t('The %Role role is reserved for internal use by the @Forum_Access module! It was not assigned.', $variables), 'warning'); |
|
600 | + unset($edit['roles'][$rid]); |
|
601 | + } |
|
601 | 602 | } |
602 | - } |
|
603 | - break; |
|
604 | - } |
|
603 | + break; |
|
604 | + } |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | /** |
@@ -610,15 +610,15 @@ discard block |
||
610 | 610 | * Remove the 'Forum' menu item if no forums are visible. |
611 | 611 | */ |
612 | 612 | function forum_access_menu_alter(&$items) { |
613 | - if (!empty($items['forum'])) { |
|
613 | + if (!empty($items['forum'])) { |
|
614 | 614 | //dpm($items['forum'], 'hook_menu_alter($items[\'forum\'])'); |
615 | 615 | if (!empty($items['forum']['access callback']) || $items['forum']['access arguments'][0] != 'access content') { |
616 | - drupal_set_message(t('Unexpected access specification for the %forum menu path; @Forum_Access cannot control its access.', array('%forum' => 'forum', '@Forum_Access' => 'Forum Access')), 'error'); |
|
617 | - return; |
|
616 | + drupal_set_message(t('Unexpected access specification for the %forum menu path; @Forum_Access cannot control its access.', array('%forum' => 'forum', '@Forum_Access' => 'Forum Access')), 'error'); |
|
617 | + return; |
|
618 | 618 | } |
619 | 619 | $items['forum']['access callback'] = '_forum_access_forum_access_callback'; |
620 | 620 | $items['forum']['access arguments'] = array(1); |
621 | - } |
|
621 | + } |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | /** |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | * one role that can access at least one forum. |
630 | 630 | */ |
631 | 631 | function _forum_access_forum_access_callback($tid = NULL) { |
632 | - return (!$tid && _forum_access_access_any_forum()) || forum_access_access($tid, 'view'); |
|
632 | + return (!$tid && _forum_access_access_any_forum()) || forum_access_access($tid, 'view'); |
|
633 | 633 | } |
634 | 634 | |
635 | 635 | /** |
@@ -639,37 +639,37 @@ discard block |
||
639 | 639 | * at least one forum. |
640 | 640 | */ |
641 | 641 | function _forum_access_access_any_forum($account = NULL) { |
642 | - global $user; |
|
643 | - static $return = array(); |
|
642 | + global $user; |
|
643 | + static $return = array(); |
|
644 | 644 | |
645 | - if (!isset($account)) { |
|
645 | + if (!isset($account)) { |
|
646 | 646 | $account = $user; |
647 | - } |
|
647 | + } |
|
648 | 648 | |
649 | - if (!isset($return[$account->uid])) { |
|
649 | + if (!isset($return[$account->uid])) { |
|
650 | 650 | if ($account->uid == 1) { |
651 | - return $return[$account->uid] = TRUE; |
|
651 | + return $return[$account->uid] = TRUE; |
|
652 | 652 | } |
653 | 653 | if (!user_access('access content', $account)) { |
654 | - return $return[$account->uid] = FALSE; |
|
654 | + return $return[$account->uid] = FALSE; |
|
655 | 655 | } |
656 | 656 | $rids = variable_get('forum_access_rids', NULL); |
657 | 657 | if (!isset($rids)) { |
658 | - $rids = array(); |
|
659 | - $result = db_query("SELECT fa.rid FROM {forum_access} fa WHERE fa.grant_view > 0 GROUP BY fa.rid"); |
|
660 | - while ($role = db_fetch_object($result)) { |
|
658 | + $rids = array(); |
|
659 | + $result = db_query("SELECT fa.rid FROM {forum_access} fa WHERE fa.grant_view > 0 GROUP BY fa.rid"); |
|
660 | + while ($role = db_fetch_object($result)) { |
|
661 | 661 | $rids[] = $role->rid; |
662 | - } |
|
663 | - variable_set('forum_access_rids', $rids); |
|
662 | + } |
|
663 | + variable_set('forum_access_rids', $rids); |
|
664 | 664 | } |
665 | 665 | foreach ($rids as $rid) { |
666 | - if (isset($account->roles[$rid])) { |
|
666 | + if (isset($account->roles[$rid])) { |
|
667 | 667 | return $return[$account->uid] = TRUE; |
668 | - } |
|
668 | + } |
|
669 | 669 | } |
670 | 670 | $return[$account->uid] = FALSE; |
671 | - } |
|
672 | - return $return[$account->uid]; |
|
671 | + } |
|
672 | + return $return[$account->uid]; |
|
673 | 673 | } |
674 | 674 | |
675 | 675 | /** |
@@ -678,18 +678,18 @@ discard block |
||
678 | 678 | * Delete {forum_access} records when forums are deleted. |
679 | 679 | */ |
680 | 680 | function forum_access_taxonomy($op, $type, $array = NULL) { |
681 | - //dpm($array, "hook_taxonomy($op, $type)"); |
|
682 | - if ($type = 'term' && $op == 'delete' && $array['vid'] == _forum_access_get_vid()) { |
|
681 | + //dpm($array, "hook_taxonomy($op, $type)"); |
|
682 | + if ($type = 'term' && $op == 'delete' && $array['vid'] == _forum_access_get_vid()) { |
|
683 | 683 | db_query("DELETE FROM {forum_access} WHERE tid = %d", $array['tid']); |
684 | 684 | variable_del('forum_access_rids'); // clear cache |
685 | - } |
|
685 | + } |
|
686 | 686 | } |
687 | 687 | |
688 | 688 | /** |
689 | 689 | * Return forum.module's forum vocabulary ID. |
690 | 690 | */ |
691 | 691 | function _forum_access_get_vid() { |
692 | - return variable_get('forum_nav_vocabulary', ''); |
|
692 | + return variable_get('forum_nav_vocabulary', ''); |
|
693 | 693 | } |
694 | 694 | |
695 | 695 | /** |
@@ -697,51 +697,51 @@ discard block |
||
697 | 697 | * exist. |
698 | 698 | */ |
699 | 699 | function forum_access_query_moderator_rid() { |
700 | - return variable_get('forum_access_moderator_rid', NULL); |
|
700 | + return variable_get('forum_access_moderator_rid', NULL); |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | /** |
704 | 704 | * Return the forum tid or FALSE. |
705 | 705 | */ |
706 | 706 | function _forum_access_get_tid($node) { |
707 | - return (isset($node->forum_tid) ? $node->forum_tid : (isset($node->tid) ? $node->tid : FALSE)); |
|
707 | + return (isset($node->forum_tid) ? $node->forum_tid : (isset($node->tid) ? $node->tid : FALSE)); |
|
708 | 708 | } |
709 | 709 | |
710 | 710 | /** |
711 | 711 | * Save and return the $tid. |
712 | 712 | */ |
713 | 713 | function _forum_access_changed_tid($tid = NULL) { |
714 | - static $saved_tid = NULL; |
|
715 | - if (!empty($tid)) { |
|
714 | + static $saved_tid = NULL; |
|
715 | + if (!empty($tid)) { |
|
716 | 716 | $saved_tid = $tid; |
717 | - } |
|
718 | - return $saved_tid; |
|
717 | + } |
|
718 | + return $saved_tid; |
|
719 | 719 | } |
720 | 720 | |
721 | 721 | /** |
722 | 722 | * Implementation of hook_node_access_explain(). |
723 | 723 | */ |
724 | 724 | function forum_access_node_access_explain($row) { |
725 | - static $roles = NULL; |
|
726 | - if ($row->realm == 'forum_access') { |
|
725 | + static $roles = NULL; |
|
726 | + if ($row->realm == 'forum_access') { |
|
727 | 727 | if (!isset($roles)) { |
728 | - module_load_include('node.inc', 'forum_access'); |
|
729 | - $roles = _forum_access_get_all_roles(); |
|
728 | + module_load_include('node.inc', 'forum_access'); |
|
729 | + $roles = _forum_access_get_all_roles(); |
|
730 | 730 | } |
731 | 731 | if (isset($roles[$row->gid])) { |
732 | - return array($roles[$row->gid]); |
|
732 | + return array($roles[$row->gid]); |
|
733 | 733 | } |
734 | 734 | return array('(unknown gid)'); |
735 | - } |
|
735 | + } |
|
736 | 736 | } |
737 | 737 | |
738 | 738 | /** |
739 | 739 | * Implementation of hook_acl_explain(). |
740 | 740 | */ |
741 | 741 | function forum_access_acl_explain($acl_id, $name, $number, $users = NULL) { |
742 | - if (empty($users)) { |
|
742 | + if (empty($users)) { |
|
743 | 743 | return "ACL (id=$acl_id) would grant access to nodes in forum/$number."; |
744 | - } |
|
745 | - return "ACL (id=$acl_id) grants access to nodes in forum/$number to the listed user(s)."; |
|
744 | + } |
|
745 | + return "ACL (id=$acl_id) grants access to nodes in forum/$number to the listed user(s)."; |
|
746 | 746 | } |
747 | 747 |
@@ -136,16 +136,16 @@ discard block |
||
136 | 136 | break; |
137 | 137 | |
138 | 138 | case 'community': |
139 | - if (arg(1)=='forum') { |
|
139 | + if (arg(1) == 'forum') { |
|
140 | 140 | if (is_numeric(arg(2))) { |
141 | - $tid=arg(2); |
|
141 | + $tid = arg(2); |
|
142 | 142 | // Obtain the tid from a URL path containing |
143 | 143 | // community/forum/%tid, this will prevent users from |
144 | 144 | // loading forums they are not allowed to access. |
145 | 145 | // However, only tid>1 are terms we care about. (This |
146 | 146 | // allows forum_tweaks mark-read functionality to |
147 | 147 | // work.) |
148 | - if (isset($tid) and ($tid>1)) { |
|
148 | + if (isset($tid) and ($tid > 1)) { |
|
149 | 149 | if (!forum_access_access($tid, 'view')) { |
150 | 150 | drupal_access_denied(); |
151 | 151 | module_invoke_all('exit'); |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * Alter the node/comment create/edit forms and various admin forms. |
188 | 188 | */ |
189 | 189 | function forum_access_form_alter(&$form, &$form_state, $form_id) { |
190 | - if (isset($form['type']['#value']) && $form['type']['#value'] .'_node_form' == $form_id) { |
|
190 | + if (isset($form['type']['#value']) && $form['type']['#value'].'_node_form' == $form_id) { |
|
191 | 191 | module_load_include('node.inc', 'forum_access'); |
192 | 192 | _forum_access_node_form($form, $form_state); |
193 | 193 | } |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | |
267 | 267 | case 'rid': |
268 | 268 | if (strpos($query, 'FROM {role}') === FALSE |
269 | - || strpos($_GET['q'] .'/', 'admin/content/forum/') === 0) { |
|
269 | + || strpos($_GET['q'].'/', 'admin/content/forum/') === 0) { |
|
270 | 270 | break; |
271 | 271 | } |
272 | 272 | $moderator_rid = forum_access_query_moderator_rid(); |
@@ -417,10 +417,10 @@ discard block |
||
417 | 417 | } |
418 | 418 | if (empty($comment)) { |
419 | 419 | // Check links for the node. |
420 | - if ($tid && isset($links['comment_add']) && !forum_access_access($tid, 'comment_create') && !(forum_access_access($tid, 'create') and ($node->uid==$user->uid)) ) { |
|
420 | + if ($tid && isset($links['comment_add']) && !forum_access_access($tid, 'comment_create') && !(forum_access_access($tid, 'create') and ($node->uid == $user->uid))) { |
|
421 | 421 | unset($links['comment_add']); |
422 | 422 | // Hack to manually remove quote link |
423 | - if ( isset($links['quote']) ) { |
|
423 | + if (isset($links['quote'])) { |
|
424 | 424 | unset($links['quote']); |
425 | 425 | } |
426 | 426 | } |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | 'delete' => 'comment_delete', |
434 | 434 | ); |
435 | 435 | foreach ($required_keys as $access => $key) { |
436 | - if (!forum_access_access($tid, $access) && !($access == 'update' && comment_access('edit', $comment)) && !($access == 'comment_create' && forum_access_access($tid, 'create') && ($node->uid==$user->uid)) ) { |
|
436 | + if (!forum_access_access($tid, $access) && !($access == 'update' && comment_access('edit', $comment)) && !($access == 'comment_create' && forum_access_access($tid, 'create') && ($node->uid == $user->uid))) { |
|
437 | 437 | unset($links[$required_keys[$access]]); |
438 | 438 | unset($required_keys[$access]); |
439 | 439 | } |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | } |
444 | 444 | |
445 | 445 | // Hack to manually remove quote link if comment_reply link is no longer set |
446 | - if ( (!(isset($links['comment_reply']))) AND isset($links['quote']) ) { |
|
446 | + if ((!(isset($links['comment_reply']))) AND isset($links['quote'])) { |
|
447 | 447 | unset($links['quote']); |
448 | 448 | } |
449 | 449 | |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | } |
563 | 563 | |
564 | 564 | $roles = array_keys($account->roles); |
565 | - $result = db_result(db_query("SELECT tid FROM {forum_access} WHERE rid IN (". db_placeholders($roles) .") AND grant_". $type ." = 1 AND tid = %d", array_merge($roles, array($tid)))); |
|
565 | + $result = db_result(db_query("SELECT tid FROM {forum_access} WHERE rid IN (".db_placeholders($roles).") AND grant_".$type." = 1 AND tid = %d", array_merge($roles, array($tid)))); |
|
566 | 566 | |
567 | 567 | if ($result) { |
568 | 568 | $cache[$account->uid][$tid][$type] = 1; |
@@ -38,8 +38,7 @@ discard block |
||
38 | 38 | if (isset($node->comment_target_nid)) { |
39 | 39 | if ($changed_tid = _forum_access_changed_tid()) { |
40 | 40 | $tid = $changed_tid; // the topic node hasn't been saved yet! |
41 | - } |
|
42 | - else { |
|
41 | + } else { |
|
43 | 42 | $node = node_load($node->comment_target_nid); |
44 | 43 | $tid = _forum_access_get_tid($node); |
45 | 44 | } |
@@ -91,7 +90,8 @@ discard block |
||
91 | 90 | return; // disable comment access control |
92 | 91 | } |
93 | 92 | if ((arg(1) == 'edit' || arg(1) == 'delete') && !user_access('administer comments')) { |
94 | - if (is_numeric($cid = arg(2))) { // comment/edit/%, comment/delete/% |
|
93 | + if (is_numeric($cid = arg(2))) { |
|
94 | +// comment/edit/%, comment/delete/% |
|
95 | 95 | $access[] = (arg(1) == 'edit' ? 'update' : 'delete'); |
96 | 96 | $comment = _comment_load($cid); |
97 | 97 | $nid = $comment->nid; |
@@ -107,7 +107,8 @@ discard block |
||
107 | 107 | |
108 | 108 | case 'node': |
109 | 109 | if (is_numeric(arg(1))) { |
110 | - if (arg(2) == 'edit' && !user_access('administer nodes')) { // node/%/edit |
|
110 | + if (arg(2) == 'edit' && !user_access('administer nodes')) { |
|
111 | +// node/%/edit |
|
111 | 112 | $access[] = 'update'; |
112 | 113 | $nid = arg(1); |
113 | 114 | // If the node turns out to be in a forum where we have update/delete |
@@ -118,13 +119,15 @@ discard block |
||
118 | 119 | // We won't provide full Administrator access, though: we'll remove |
119 | 120 | // author and timestamp, for example. |
120 | 121 | } |
121 | - if (arg(2) == 'delete' && !user_access('administer nodes')) { // node/%/delete |
|
122 | + if (arg(2) == 'delete' && !user_access('administer nodes')) { |
|
123 | +// node/%/delete |
|
122 | 124 | $access = array(); |
123 | 125 | $nid = arg(1); |
124 | 126 | // This is the delete confirmation page. We don't need any |
125 | 127 | // additional permissions, but we'll assert 'view' access below. |
126 | 128 | } |
127 | - if (arg(2) == NULL && !user_access('administer comments')) { // node/% |
|
129 | + if (arg(2) == NULL && !user_access('administer comments')) { |
|
130 | +// node/% |
|
128 | 131 | $access[] = 'update'; |
129 | 132 | $nid = arg(1); |
130 | 133 | // If the node turns out to be in a forum where we have update/delete |
@@ -190,44 +193,34 @@ discard block |
||
190 | 193 | if (isset($form['type']['#value']) && $form['type']['#value'] .'_node_form' == $form_id) { |
191 | 194 | module_load_include('node.inc', 'forum_access'); |
192 | 195 | _forum_access_node_form($form, $form_state); |
193 | - } |
|
194 | - elseif ($form_id == 'comment_form' && !variable_get('forum_access_D5_legacy_mode', FALSE)) { |
|
196 | + } elseif ($form_id == 'comment_form' && !variable_get('forum_access_D5_legacy_mode', FALSE)) { |
|
195 | 197 | module_load_include('node.inc', 'forum_access'); |
196 | 198 | _forum_access_comment_form($form, $form_state); |
197 | - } |
|
198 | - elseif ($form_id == 'forum_overview') { |
|
199 | + } elseif ($form_id == 'forum_overview') { |
|
199 | 200 | module_load_include('admin.inc', 'forum_access'); |
200 | 201 | _forum_access_forum_overview($form, $form_state); |
201 | - } |
|
202 | - elseif ($form_id == 'forum_form_container') { |
|
202 | + } elseif ($form_id == 'forum_form_container') { |
|
203 | 203 | module_load_include('admin.inc', 'forum_access'); |
204 | 204 | _forum_access_forum_form($form, $form_state, TRUE); |
205 | - } |
|
206 | - elseif ($form_id == 'forum_form_forum') { |
|
205 | + } elseif ($form_id == 'forum_form_forum') { |
|
207 | 206 | module_load_include('admin.inc', 'forum_access'); |
208 | 207 | _forum_access_forum_form($form, $form_state, FALSE); |
209 | - } |
|
210 | - elseif ($form_id == 'forum_admin_settings') { |
|
208 | + } elseif ($form_id == 'forum_admin_settings') { |
|
211 | 209 | module_load_include('admin.inc', 'forum_access'); |
212 | 210 | _forum_access_forum_admin_settings_form($form, $form_state); |
213 | - } |
|
214 | - elseif ($form_id == 'user_admin_role') { |
|
211 | + } elseif ($form_id == 'user_admin_role') { |
|
215 | 212 | module_load_include('admin.inc', 'forum_access'); |
216 | 213 | _forum_access_user_admin_role_form($form, $form_state); |
217 | - } |
|
218 | - elseif ($form_id == 'content_access_admin_settings' && empty($_POST)) { |
|
214 | + } elseif ($form_id == 'content_access_admin_settings' && empty($_POST)) { |
|
219 | 215 | module_load_include('admin.inc', 'forum_access'); |
220 | 216 | _forum_access_content_access_admin_form(); |
221 | - } |
|
222 | - elseif ($form_id == 'user_admin_perm') { |
|
217 | + } elseif ($form_id == 'user_admin_perm') { |
|
223 | 218 | module_load_include('admin.inc', 'forum_access'); |
224 | 219 | _forum_access_user_admin_perm_form($form, $form_state); |
225 | - } |
|
226 | - elseif ($form_id == 'user_admin_account') { |
|
220 | + } elseif ($form_id == 'user_admin_account') { |
|
227 | 221 | module_load_include('admin.inc', 'forum_access'); |
228 | 222 | _forum_access_user_admin_account_form($form, $form_state); |
229 | - } |
|
230 | - elseif ($form_id == 'user_profile_form') { |
|
223 | + } elseif ($form_id == 'user_profile_form') { |
|
231 | 224 | module_load_include('admin.inc', 'forum_access'); |
232 | 225 | _forum_access_user_profile_form($form, $form_state); |
233 | 226 | } |
@@ -252,8 +245,7 @@ discard block |
||
252 | 245 | } |
253 | 246 | if (strpos($_GET['q'], 'node/add/forum') !== FALSE) { |
254 | 247 | $required_access = 'create'; |
255 | - } |
|
256 | - else { |
|
248 | + } else { |
|
257 | 249 | $required_access = 'view'; |
258 | 250 | } |
259 | 251 | $roles = implode(', ', array_keys($user->roles)); |
@@ -424,8 +416,7 @@ discard block |
||
424 | 416 | unset($links['quote']); |
425 | 417 | } |
426 | 418 | } |
427 | - } |
|
428 | - else { |
|
419 | + } else { |
|
429 | 420 | // Check links for the comment. |
430 | 421 | $required_keys = array( |
431 | 422 | 'comment_create' => 'comment_reply', |
@@ -436,8 +427,7 @@ discard block |
||
436 | 427 | if (!forum_access_access($tid, $access) && !($access == 'update' && comment_access('edit', $comment)) && !($access == 'comment_create' && forum_access_access($tid, 'create') && ($node->uid==$user->uid)) ) { |
437 | 428 | unset($links[$required_keys[$access]]); |
438 | 429 | unset($required_keys[$access]); |
439 | - } |
|
440 | - elseif (!array_key_exists($key, $links)) { |
|
430 | + } elseif (!array_key_exists($key, $links)) { |
|
441 | 431 | $link_is_missing = TRUE; |
442 | 432 | } |
443 | 433 | } |
@@ -566,15 +556,13 @@ discard block |
||
566 | 556 | |
567 | 557 | if ($result) { |
568 | 558 | $cache[$account->uid][$tid][$type] = 1; |
569 | - } |
|
570 | - else { |
|
559 | + } else { |
|
571 | 560 | // check our moderators too |
572 | 561 | $acl_id = acl_get_id_by_number('forum_access', $tid); |
573 | 562 | $result = db_result(db_query("SELECT uid FROM {acl_user} WHERE acl_id = %d AND uid = %d", $acl_id, $account->uid)); |
574 | 563 | if ($result) { |
575 | 564 | $cache[$account->uid][$tid][$type] = 2; |
576 | - } |
|
577 | - else { |
|
565 | + } else { |
|
578 | 566 | $cache[$account->uid][$tid][$type] = FALSE; |
579 | 567 | } |
580 | 568 | } |
@@ -1,47 +1,47 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | function i18nviews_views_data() { |
4 | - $data['node']['content_negotiation'] = array( |
|
4 | + $data['node']['content_negotiation'] = array( |
|
5 | 5 | 'group' => t('Node translation'), |
6 | 6 | 'title' => t('Content negotiation'), |
7 | 7 | 'help' => t('Removes the nodes that are not valid according to the content selection mode.'), |
8 | 8 | 'filter' => array( |
9 | - 'handler' => 'content_negotiation_filter_handler', |
|
9 | + 'handler' => 'content_negotiation_filter_handler', |
|
10 | 10 | ), |
11 | - ); |
|
12 | - return $data; |
|
11 | + ); |
|
12 | + return $data; |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | /** |
16 | 16 | * Implementation of hook_views_handlers |
17 | 17 | */ |
18 | 18 | function i18nviews_views_handlers() { |
19 | - return array( |
|
19 | + return array( |
|
20 | 20 | 'info' => array( |
21 | - 'path' => drupal_get_path('module', 'i18nviews') . '/includes', |
|
21 | + 'path' => drupal_get_path('module', 'i18nviews') . '/includes', |
|
22 | 22 | ), |
23 | 23 | 'handlers' => array( |
24 | - 'content_negotiation_filter_handler' => array( |
|
24 | + 'content_negotiation_filter_handler' => array( |
|
25 | 25 | 'parent' => 'views_handler_filter', |
26 | - ), |
|
26 | + ), |
|
27 | 27 | ), |
28 | - ); |
|
28 | + ); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Implementation of hook_views_plugins(). |
33 | 33 | */ |
34 | 34 | function i18nviews_views_plugins() { |
35 | - $path = drupal_get_path('module', 'i18nviews') . '/includes'; |
|
36 | - return array( |
|
35 | + $path = drupal_get_path('module', 'i18nviews') . '/includes'; |
|
36 | + return array( |
|
37 | 37 | 'module' => 'i18nviews', |
38 | 38 | 'localization' => array( |
39 | - 'i18nstrings' => array( |
|
39 | + 'i18nstrings' => array( |
|
40 | 40 | 'title' => t('Views translation module'), |
41 | 41 | 'help' => t("Use the locale system as implemented by the Views translation module."), |
42 | 42 | 'handler' => 'views_plugin_localization_i18nstrings', |
43 | 43 | 'path' => $path, |
44 | - ), |
|
44 | + ), |
|
45 | 45 | ), |
46 | - ); |
|
46 | + ); |
|
47 | 47 | } |
48 | 48 | \ No newline at end of file |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | function i18nviews_views_handlers() { |
19 | 19 | return array( |
20 | 20 | 'info' => array( |
21 | - 'path' => drupal_get_path('module', 'i18nviews') . '/includes', |
|
21 | + 'path' => drupal_get_path('module', 'i18nviews').'/includes', |
|
22 | 22 | ), |
23 | 23 | 'handlers' => array( |
24 | 24 | 'content_negotiation_filter_handler' => array( |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * Implementation of hook_views_plugins(). |
33 | 33 | */ |
34 | 34 | function i18nviews_views_plugins() { |
35 | - $path = drupal_get_path('module', 'i18nviews') . '/includes'; |
|
35 | + $path = drupal_get_path('module', 'i18nviews').'/includes'; |
|
36 | 36 | return array( |
37 | 37 | 'module' => 'i18nviews', |
38 | 38 | 'localization' => array( |
@@ -1,18 +1,18 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | class content_negotiation_filter_handler extends views_handler_filter { |
4 | - function query() { |
|
4 | + function query() { |
|
5 | 5 | $this->ensure_my_table(); |
6 | 6 | $where = i18n_db_rewrite_where($this->table_alias, 'node'); |
7 | 7 | if (!empty($where)) { |
8 | - $this->query->add_where($this->options['group'], $where); |
|
8 | + $this->query->add_where($this->options['group'], $where); |
|
9 | + } |
|
9 | 10 | } |
10 | - } |
|
11 | 11 | |
12 | - function option_definition() { |
|
12 | + function option_definition() { |
|
13 | 13 | $options = parent::option_definition(); |
14 | 14 | $options['operator']['default'] = ''; |
15 | 15 | $options['value']['default'] = ''; |
16 | 16 | return $options; |
17 | - } |
|
17 | + } |
|
18 | 18 | } |