@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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 |
@@ -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 |
@@ -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 | } |
@@ -14,44 +14,44 @@ discard block |
||
14 | 14 | * Implementation of hook_help(). |
15 | 15 | */ |
16 | 16 | function i18nviews_help($path, $arg) { |
17 | - switch ($path) { |
|
17 | + switch ($path) { |
|
18 | 18 | case 'admin/modules#description' : |
19 | 19 | $output = '<p>'. t('Supports translation for views strings: title, header, footer...') .'</p>'; |
20 | - $output .= '<p>'. t('To search and translate strings, use the <a href="@translate-interface">translation interface</a> pages.', array('@translate-interface' => url('admin/build/translate'))) .'</p>'; |
|
21 | - return $output; |
|
22 | - } |
|
20 | + $output .= '<p>'. t('To search and translate strings, use the <a href="@translate-interface">translation interface</a> pages.', array('@translate-interface' => url('admin/build/translate'))) .'</p>'; |
|
21 | + return $output; |
|
22 | + } |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Implementation of hook_locale(). |
27 | 27 | */ |
28 | 28 | function i18nviews_locale($op = 'groups') { |
29 | - switch ($op) { |
|
29 | + switch ($op) { |
|
30 | 30 | case 'groups': |
31 | 31 | return array('views' => t('Views')); |
32 | 32 | case 'info': |
33 | 33 | $info['views']['refresh callback'] = 'i18nviews_locale_refresh'; |
34 | - $info['views']['format'] = TRUE; |
|
35 | - return $info; |
|
36 | - } |
|
34 | + $info['views']['format'] = TRUE; |
|
35 | + return $info; |
|
36 | + } |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Refresh views locales, 2.x version |
41 | 41 | */ |
42 | 42 | function i18nviews_locale_refresh() { |
43 | - $views = views_get_all_views(); |
|
44 | - foreach ($views as $view) { |
|
43 | + $views = views_get_all_views(); |
|
44 | + foreach ($views as $view) { |
|
45 | 45 | if (!$view->disabled) { |
46 | - $fields = _i18nviews_display_fields(); |
|
47 | - if (!empty($view->display) && is_array($view->display)) { |
|
46 | + $fields = _i18nviews_display_fields(); |
|
47 | + if (!empty($view->display) && is_array($view->display)) { |
|
48 | 48 | foreach (array_keys($view->display) as $display_id) { |
49 | - _i18nviews_localize_array($view->name, $display_id, $view->display[$display_id]->display_options, $fields, TRUE); |
|
49 | + _i18nviews_localize_array($view->name, $display_id, $view->display[$display_id]->display_options, $fields, TRUE); |
|
50 | + } |
|
50 | 51 | } |
51 | - } |
|
52 | 52 | } |
53 | - } |
|
54 | - return TRUE; // Completed successfully |
|
53 | + } |
|
54 | + return TRUE; // Completed successfully |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -60,37 +60,37 @@ discard block |
||
60 | 60 | * Remake of views_handler_field_allterms with term name translation. |
61 | 61 | */ |
62 | 62 | function i18nviews_views_handler_field_allterms($fieldinfo, $fielddata, $value, $data) { |
63 | - if ($fieldinfo['vocabulary']) { |
|
63 | + if ($fieldinfo['vocabulary']) { |
|
64 | 64 | $terms = taxonomy_node_get_terms_by_vocabulary($data->nid, $fieldinfo['vocabulary']); |
65 | - } |
|
66 | - else { |
|
65 | + } |
|
66 | + else { |
|
67 | 67 | $terms = taxonomy_node_get_terms($data->nid); |
68 | - } |
|
69 | - // Translate all these terms. |
|
70 | - _i18ntaxonomy_translate_terms($terms); |
|
68 | + } |
|
69 | + // Translate all these terms. |
|
70 | + _i18ntaxonomy_translate_terms($terms); |
|
71 | 71 | |
72 | - if ($fielddata['options'] == 'nolink') { |
|
72 | + if ($fielddata['options'] == 'nolink') { |
|
73 | 73 | foreach ($terms as $term) { |
74 | - $links[] = check_plain($term->name); |
|
74 | + $links[] = check_plain($term->name); |
|
75 | 75 | } |
76 | 76 | $links = !empty($links) ? implode(' | ', $links) : ''; |
77 | - } |
|
78 | - else { |
|
77 | + } |
|
78 | + else { |
|
79 | 79 | $node = new stdClass(); |
80 | 80 | $node->taxonomy = $terms; |
81 | 81 | $links = theme('links', taxonomy_link('taxonomy terms', $node)); |
82 | - } |
|
83 | - return $links; |
|
82 | + } |
|
83 | + return $links; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
87 | 87 | * Implementation of hook_views_api(). |
88 | 88 | */ |
89 | 89 | function i18nviews_views_api() { |
90 | - return array( |
|
90 | + return array( |
|
91 | 91 | 'api' => '2.0', |
92 | 92 | 'path' => drupal_get_path('module', 'i18nviews') . '/includes', |
93 | - ); |
|
93 | + ); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -105,38 +105,38 @@ discard block |
||
105 | 105 | * This is just for views 2.x, next version (3.x) will use a different one |
106 | 106 | */ |
107 | 107 | function i18nviews_views_pre_view(&$view, &$display_id, &$args) { |
108 | - global $language; |
|
109 | - if (views_api_version() == '2.0' && $language->language != language_default('language')) { |
|
108 | + global $language; |
|
109 | + if (views_api_version() == '2.0' && $language->language != language_default('language')) { |
|
110 | 110 | // Also checking weird values for $display_id, see 277711 |
111 | 111 | if (!empty($view->display) && is_array($view->display) && is_string($display_id)) { |
112 | - $fields = _i18nviews_display_fields(); |
|
113 | - if(!empty($view->display[$display_id])) { |
|
112 | + $fields = _i18nviews_display_fields(); |
|
113 | + if(!empty($view->display[$display_id])) { |
|
114 | 114 | $fields = _i18nviews_localize_array($view->name, $display_id, $view->display[$display_id]->handler->options, $fields); |
115 | - } |
|
116 | - if($fields && !empty($view->display['default'])) { |
|
115 | + } |
|
116 | + if($fields && !empty($view->display['default'])) { |
|
117 | 117 | _i18nviews_localize_array($view->name, 'default', $view->display['default']->handler->options, $fields); |
118 | - } |
|
118 | + } |
|
119 | 119 | } |
120 | 120 | // Translate taxonomy fields. |
121 | 121 | // @todo I don think this works at all. |
122 | 122 | if (module_exists('i18ntaxonomy') && isset($view->field) && is_array($view->field)) { |
123 | - $translate = variable_get('i18ntaxonomy_vocabularies', array()); |
|
124 | - foreach ($view->field as $index => $data) { |
|
123 | + $translate = variable_get('i18ntaxonomy_vocabularies', array()); |
|
124 | + foreach ($view->field as $index => $data) { |
|
125 | 125 | $matches = array(); |
126 | 126 | if ($data['id'] == 'term_node.name') { |
127 | - // That's a full taxonomy box. |
|
128 | - $view->field[$index]['handler'] = 'i18ntaxonomy_views_handler_field_allterms'; |
|
127 | + // That's a full taxonomy box. |
|
128 | + $view->field[$index]['handler'] = 'i18ntaxonomy_views_handler_field_allterms'; |
|
129 | 129 | } |
130 | 130 | elseif (preg_match("/term_node_(\d+)\.name/", $data['id'], $matches)) { |
131 | - $vid = $matches[1]; |
|
132 | - if ($translate[$vid]) { |
|
131 | + $vid = $matches[1]; |
|
132 | + if ($translate[$vid]) { |
|
133 | 133 | // Set new handler for this field. |
134 | 134 | $view->field[$index]['handler'] = 'i18ntaxonomy_views_handler_field_allterms'; |
135 | - } |
|
135 | + } |
|
136 | + } |
|
136 | 137 | } |
137 | - } |
|
138 | 138 | } |
139 | - } |
|
139 | + } |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * Array of field names. |
147 | 147 | */ |
148 | 148 | function _i18nviews_display_fields() { |
149 | - return array('title', 'header', 'footer', 'empty'); |
|
149 | + return array('title', 'header', 'footer', 'empty'); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -155,21 +155,21 @@ discard block |
||
155 | 155 | * We get the translated fields out of the array so they are not translated again. |
156 | 156 | */ |
157 | 157 | function _i18nviews_localize_array($name, $group, &$data, $field_names, $update = FALSE) { |
158 | - $translated = array(); |
|
159 | - foreach ($field_names as $field) { |
|
158 | + $translated = array(); |
|
159 | + foreach ($field_names as $field) { |
|
160 | 160 | if (!empty($data[$field])) { |
161 | - if ($update) { |
|
161 | + if ($update) { |
|
162 | 162 | $format = isset($data[$field . '_format']) ? $data[$field . '_format'] : NULL; |
163 | 163 | i18nstrings_update("views:$name:$group:$field", $data[$field], $format); |
164 | - } |
|
165 | - else { |
|
164 | + } |
|
165 | + else { |
|
166 | 166 | $data[$field] = i18nstrings("views:$name:$group:$field", $data[$field]); |
167 | 167 | $translated[] = $field; |
168 | - } |
|
168 | + } |
|
169 | 169 | } |
170 | - } |
|
171 | - // Return remaining field names |
|
172 | - return array_diff($field_names, $translated); |
|
170 | + } |
|
171 | + // Return remaining field names |
|
172 | + return array_diff($field_names, $translated); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
@@ -178,15 +178,15 @@ discard block |
||
178 | 178 | * We cannot play with object 2 array conversion because some are real typed objects. |
179 | 179 | */ |
180 | 180 | function _i18nviews_localize_object($name, $group, &$data, &$field_names, $trim = FALSE) { |
181 | - $translated = array(); |
|
182 | - foreach ($field_names as $field) { |
|
181 | + $translated = array(); |
|
182 | + foreach ($field_names as $field) { |
|
183 | 183 | if (!empty($data->$field)) { |
184 | - $data->$field = i18nstrings("views:$name:$group:$field", $data->$field); |
|
184 | + $data->$field = i18nstrings("views:$name:$group:$field", $data->$field); |
|
185 | + } |
|
185 | 186 | } |
186 | - } |
|
187 | - if ($trim && $translated) { |
|
187 | + if ($trim && $translated) { |
|
188 | 188 | $field_names = array_diff($field_names, $translated); |
189 | - } |
|
189 | + } |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * Add a submit handler to the submit button on views_ui_edit_display_form. |
196 | 196 | */ |
197 | 197 | function i18nviews_form_views_ui_edit_display_form_alter(&$form, $form_state) { |
198 | - $form['buttons']['submit']['#submit'][] = 'i18nviews_views_ui_edit_display_submit'; |
|
198 | + $form['buttons']['submit']['#submit'][] = 'i18nviews_views_ui_edit_display_submit'; |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -204,13 +204,13 @@ discard block |
||
204 | 204 | * Creates or updates translation source records for specified Views fields. |
205 | 205 | */ |
206 | 206 | function i18nviews_views_ui_edit_display_submit($form, &$form_state) { |
207 | - $fields = _i18nviews_display_fields(); |
|
208 | - foreach ($fields as $field) { |
|
207 | + $fields = _i18nviews_display_fields(); |
|
208 | + foreach ($fields as $field) { |
|
209 | 209 | if (isset($form_state['values'][$field])) { |
210 | - $name = $form_state['view']->name; |
|
211 | - $group = $form_state['display_id']; |
|
212 | - $format = isset($form_state['values'][$field . '_format']) ? $form_state['values'][$field . '_format'] : NULL; |
|
213 | - i18nstrings_update("views:$name:$group:$field", $form_state['values'][$field], $format); |
|
210 | + $name = $form_state['view']->name; |
|
211 | + $group = $form_state['display_id']; |
|
212 | + $format = isset($form_state['values'][$field . '_format']) ? $form_state['values'][$field . '_format'] : NULL; |
|
213 | + i18nstrings_update("views:$name:$group:$field", $form_state['values'][$field], $format); |
|
214 | + } |
|
214 | 215 | } |
215 | - } |
|
216 | 216 | } |
@@ -9,16 +9,16 @@ discard block |
||
9 | 9 | * Form builder for Wysiwyg profile form. |
10 | 10 | */ |
11 | 11 | function wysiwyg_profile_form($form_state, $profile) { |
12 | - // Merge in defaults. |
|
13 | - $profile = (array) $profile; |
|
14 | - $profile += array( |
|
12 | + // Merge in defaults. |
|
13 | + $profile = (array) $profile; |
|
14 | + $profile += array( |
|
15 | 15 | 'format' => 0, |
16 | 16 | 'editor' => '', |
17 | - ); |
|
18 | - if (empty($profile['settings'])) { |
|
17 | + ); |
|
18 | + if (empty($profile['settings'])) { |
|
19 | 19 | $profile['settings'] = array(); |
20 | - } |
|
21 | - $profile['settings'] += array( |
|
20 | + } |
|
21 | + $profile['settings'] += array( |
|
22 | 22 | 'default' => TRUE, |
23 | 23 | 'user_choose' => FALSE, |
24 | 24 | 'show_toggle' => TRUE, |
@@ -42,264 +42,264 @@ discard block |
||
42 | 42 | 'css_setting' => 'theme', |
43 | 43 | 'css_path' => NULL, |
44 | 44 | 'css_classes' => NULL, |
45 | - ); |
|
46 | - $profile = (object) $profile; |
|
45 | + ); |
|
46 | + $profile = (object) $profile; |
|
47 | 47 | |
48 | - $formats = filter_formats(); |
|
49 | - $editor = wysiwyg_get_editor($profile->editor); |
|
50 | - drupal_set_title(t('%editor profile for %format', array('%editor' => $editor['title'], '%format' => $formats[$profile->format]->name))); |
|
48 | + $formats = filter_formats(); |
|
49 | + $editor = wysiwyg_get_editor($profile->editor); |
|
50 | + drupal_set_title(t('%editor profile for %format', array('%editor' => $editor['title'], '%format' => $formats[$profile->format]->name))); |
|
51 | 51 | |
52 | - $form['format'] = array('#type' => 'value', '#value' => $profile->format); |
|
53 | - $form['input_format'] = array('#type' => 'value', '#value' => $formats[$profile->format]->name); |
|
54 | - $form['editor'] = array('#type' => 'value', '#value' => $profile->editor); |
|
52 | + $form['format'] = array('#type' => 'value', '#value' => $profile->format); |
|
53 | + $form['input_format'] = array('#type' => 'value', '#value' => $formats[$profile->format]->name); |
|
54 | + $form['editor'] = array('#type' => 'value', '#value' => $profile->editor); |
|
55 | 55 | |
56 | - $form['basic'] = array( |
|
56 | + $form['basic'] = array( |
|
57 | 57 | '#type' => 'fieldset', |
58 | 58 | '#title' => t('Basic setup'), |
59 | 59 | '#collapsible' => TRUE, |
60 | 60 | '#collapsed' => TRUE, |
61 | - ); |
|
61 | + ); |
|
62 | 62 | |
63 | - $form['basic']['default'] = array( |
|
63 | + $form['basic']['default'] = array( |
|
64 | 64 | '#type' => 'checkbox', |
65 | 65 | '#title' => t('Enabled by default'), |
66 | 66 | '#default_value' => $profile->settings['default'], |
67 | 67 | '#return_value' => 1, |
68 | 68 | '#description' => t('The default editor state for users having access to this profile. Users are able to override this state if the next option is enabled.'), |
69 | - ); |
|
69 | + ); |
|
70 | 70 | |
71 | - $form['basic']['user_choose'] = array( |
|
71 | + $form['basic']['user_choose'] = array( |
|
72 | 72 | '#type' => 'checkbox', |
73 | 73 | '#title' => t('Allow users to choose default'), |
74 | 74 | '#default_value' => $profile->settings['user_choose'], |
75 | 75 | '#return_value' => 1, |
76 | 76 | '#description' => t('If allowed, users will be able to choose their own editor default state in their user account settings.'), |
77 | - ); |
|
77 | + ); |
|
78 | 78 | |
79 | - $form['basic']['show_toggle'] = array( |
|
79 | + $form['basic']['show_toggle'] = array( |
|
80 | 80 | '#type' => 'checkbox', |
81 | 81 | '#title' => t('Show <em>enable/disable rich text</em> toggle link'), |
82 | 82 | '#default_value' => $profile->settings['show_toggle'], |
83 | 83 | '#return_value' => 1, |
84 | 84 | '#description' => t('Whether or not to show the <em>enable/disable rich text</em> toggle link below a textarea. If disabled, the user setting or global default is used (see above).'), |
85 | - ); |
|
85 | + ); |
|
86 | 86 | |
87 | - $form['basic']['theme'] = array( |
|
87 | + $form['basic']['theme'] = array( |
|
88 | 88 | '#type' => 'hidden', |
89 | 89 | '#value' => $profile->settings['theme'], |
90 | - ); |
|
90 | + ); |
|
91 | 91 | |
92 | - $form['basic']['language'] = array( |
|
92 | + $form['basic']['language'] = array( |
|
93 | 93 | '#type' => 'select', |
94 | 94 | '#title' => t('Interface language'), |
95 | 95 | '#default_value' => $profile->settings['language'], |
96 | - ); |
|
97 | - // @see _locale_prepare_predefined_list() |
|
98 | - require_once './includes/locale.inc'; |
|
99 | - $predefined = _locale_get_predefined_list(); |
|
100 | - foreach ($predefined as $key => $value) { |
|
96 | + ); |
|
97 | + // @see _locale_prepare_predefined_list() |
|
98 | + require_once './includes/locale.inc'; |
|
99 | + $predefined = _locale_get_predefined_list(); |
|
100 | + foreach ($predefined as $key => $value) { |
|
101 | 101 | // Include native name in output, if possible |
102 | 102 | if (count($value) > 1) { |
103 | - $tname = t($value[0]); |
|
104 | - $predefined[$key] = ($tname == $value[1]) ? $tname : "$tname ($value[1])"; |
|
103 | + $tname = t($value[0]); |
|
104 | + $predefined[$key] = ($tname == $value[1]) ? $tname : "$tname ($value[1])"; |
|
105 | 105 | } |
106 | 106 | else { |
107 | - $predefined[$key] = t($value[0]); |
|
107 | + $predefined[$key] = t($value[0]); |
|
108 | + } |
|
108 | 109 | } |
109 | - } |
|
110 | - asort($predefined); |
|
111 | - $form['basic']['language']['#options'] = $predefined; |
|
110 | + asort($predefined); |
|
111 | + $form['basic']['language']['#options'] = $predefined; |
|
112 | 112 | |
113 | - $form['buttons'] = array( |
|
113 | + $form['buttons'] = array( |
|
114 | 114 | '#type' => 'fieldset', |
115 | 115 | '#title' => t('Buttons and plugins'), |
116 | 116 | '#collapsible' => TRUE, |
117 | 117 | '#collapsed' => TRUE, |
118 | 118 | '#tree' => TRUE, |
119 | 119 | '#theme' => 'wysiwyg_admin_button_table', |
120 | - ); |
|
120 | + ); |
|
121 | 121 | |
122 | - $plugins = wysiwyg_get_plugins($profile->editor); |
|
123 | - // Generate the button list. |
|
124 | - foreach ($plugins as $name => $meta) { |
|
122 | + $plugins = wysiwyg_get_plugins($profile->editor); |
|
123 | + // Generate the button list. |
|
124 | + foreach ($plugins as $name => $meta) { |
|
125 | 125 | if (isset($meta['buttons']) && is_array($meta['buttons'])) { |
126 | - foreach ($meta['buttons'] as $button => $title) { |
|
126 | + foreach ($meta['buttons'] as $button => $title) { |
|
127 | 127 | $icon = ''; |
128 | 128 | if (!empty($meta['path'])) { |
129 | - // @todo Button icon locations are different in editors, editor versions, |
|
130 | - // and contrib/custom plugins (like Image Assist, f.e.). |
|
131 | - $img_src = $meta['path'] . "/images/$name.gif"; |
|
132 | - // Handle plugins that have more than one button. |
|
133 | - if (!file_exists($img_src)) { |
|
129 | + // @todo Button icon locations are different in editors, editor versions, |
|
130 | + // and contrib/custom plugins (like Image Assist, f.e.). |
|
131 | + $img_src = $meta['path'] . "/images/$name.gif"; |
|
132 | + // Handle plugins that have more than one button. |
|
133 | + if (!file_exists($img_src)) { |
|
134 | 134 | $img_src = $meta['path'] . "/images/$button.gif"; |
135 | - } |
|
136 | - $icon = file_exists($img_src) ? '<img src="' . base_path() . $img_src . '" title="' . $button . '" style="border: 1px solid grey; vertical-align: middle;" />' : ''; |
|
135 | + } |
|
136 | + $icon = file_exists($img_src) ? '<img src="' . base_path() . $img_src . '" title="' . $button . '" style="border: 1px solid grey; vertical-align: middle;" />' : ''; |
|
137 | 137 | } |
138 | 138 | $title = (isset($meta['url']) ? l($title, $meta['url'], array('target' => '_blank')) : $title); |
139 | 139 | $title = (!empty($icon) ? $icon . ' ' . $title : $title); |
140 | 140 | $form['buttons'][$name][$button] = array( |
141 | - '#type' => 'checkbox', |
|
142 | - '#title' => $title, |
|
143 | - '#default_value' => !empty($profile->settings['buttons'][$name][$button]) ? $profile->settings['buttons'][$name][$button] : FALSE, |
|
141 | + '#type' => 'checkbox', |
|
142 | + '#title' => $title, |
|
143 | + '#default_value' => !empty($profile->settings['buttons'][$name][$button]) ? $profile->settings['buttons'][$name][$button] : FALSE, |
|
144 | 144 | ); |
145 | - } |
|
145 | + } |
|
146 | 146 | } |
147 | 147 | else if (isset($meta['extensions']) && is_array($meta['extensions'])) { |
148 | - foreach ($meta['extensions'] as $extension => $title) { |
|
148 | + foreach ($meta['extensions'] as $extension => $title) { |
|
149 | 149 | $form['buttons'][$name][$extension] = array( |
150 | - '#type' => 'checkbox', |
|
151 | - '#title' => isset($meta['url']) ? l($title, $meta['url'], array('target' => '_blank')) : $title, |
|
152 | - '#default_value' => !empty($profile->settings['buttons'][$name][$extension]) ? $profile->settings['buttons'][$name][$extension] : FALSE, |
|
150 | + '#type' => 'checkbox', |
|
151 | + '#title' => isset($meta['url']) ? l($title, $meta['url'], array('target' => '_blank')) : $title, |
|
152 | + '#default_value' => !empty($profile->settings['buttons'][$name][$extension]) ? $profile->settings['buttons'][$name][$extension] : FALSE, |
|
153 | 153 | ); |
154 | - } |
|
154 | + } |
|
155 | + } |
|
155 | 156 | } |
156 | - } |
|
157 | 157 | |
158 | - $form['appearance'] = array( |
|
158 | + $form['appearance'] = array( |
|
159 | 159 | '#type' => 'fieldset', |
160 | 160 | '#title' => t('Editor appearance'), |
161 | 161 | '#collapsible' => TRUE, |
162 | 162 | '#collapsed' => TRUE, |
163 | - ); |
|
163 | + ); |
|
164 | 164 | |
165 | - $form['appearance']['toolbar_loc'] = array( |
|
165 | + $form['appearance']['toolbar_loc'] = array( |
|
166 | 166 | '#type' => 'select', |
167 | 167 | '#title' => t('Toolbar location'), |
168 | 168 | '#default_value' => $profile->settings['toolbar_loc'], |
169 | 169 | '#options' => array('bottom' => t('Bottom'), 'top' => t('Top')), |
170 | 170 | '#description' => t('This option controls whether the editor toolbar is displayed above or below the editing area.'), |
171 | - ); |
|
171 | + ); |
|
172 | 172 | |
173 | - $form['appearance']['toolbar_align'] = array( |
|
173 | + $form['appearance']['toolbar_align'] = array( |
|
174 | 174 | '#type' => 'select', |
175 | 175 | '#title' => t('Button alignment'), |
176 | 176 | '#default_value' => $profile->settings['toolbar_align'], |
177 | 177 | '#options' => array('center' => t('Center'), 'left' => t('Left'), 'right' => t('Right')), |
178 | 178 | '#description' => t('This option controls the alignment of icons in the editor toolbar.'), |
179 | - ); |
|
179 | + ); |
|
180 | 180 | |
181 | - $form['appearance']['path_loc'] = array( |
|
181 | + $form['appearance']['path_loc'] = array( |
|
182 | 182 | '#type' => 'select', |
183 | 183 | '#title' => t('Path location'), |
184 | 184 | '#default_value' => $profile->settings['path_loc'], |
185 | 185 | '#options' => array('none' => t('Hide'), 'top' => t('Top'), 'bottom' => t('Bottom')), |
186 | 186 | '#description' => t('Where to display the path to HTML elements (i.e. <code>body > table > tr > td</code>).'), |
187 | - ); |
|
187 | + ); |
|
188 | 188 | |
189 | - $form['appearance']['resizing'] = array( |
|
189 | + $form['appearance']['resizing'] = array( |
|
190 | 190 | '#type' => 'checkbox', |
191 | 191 | '#title' => t('Enable resizing button'), |
192 | 192 | '#default_value' => $profile->settings['resizing'], |
193 | 193 | '#return_value' => 1, |
194 | 194 | '#description' => t('This option gives you the ability to enable/disable the resizing button. If enabled, the Path location toolbar must be set to "Top" or "Bottom" in order to display the resize icon.'), |
195 | - ); |
|
195 | + ); |
|
196 | 196 | |
197 | - $form['output'] = array( |
|
197 | + $form['output'] = array( |
|
198 | 198 | '#type' => 'fieldset', |
199 | 199 | '#title' => t('Cleanup and output'), |
200 | 200 | '#collapsible' => TRUE, |
201 | 201 | '#collapsed' => TRUE, |
202 | - ); |
|
202 | + ); |
|
203 | 203 | |
204 | - $form['output']['verify_html'] = array( |
|
204 | + $form['output']['verify_html'] = array( |
|
205 | 205 | '#type' => 'checkbox', |
206 | 206 | '#title' => t('Verify HTML'), |
207 | 207 | '#default_value' => $profile->settings['verify_html'], |
208 | 208 | '#return_value' => 1, |
209 | 209 | '#description' => t('If enabled, potentially malicious code like <code><HEAD></code> tags will be removed from HTML contents.'), |
210 | - ); |
|
210 | + ); |
|
211 | 211 | |
212 | - $form['output']['preformatted'] = array( |
|
212 | + $form['output']['preformatted'] = array( |
|
213 | 213 | '#type' => 'checkbox', |
214 | 214 | '#title' => t('Preformatted'), |
215 | 215 | '#default_value' => $profile->settings['preformatted'], |
216 | 216 | '#return_value' => 1, |
217 | 217 | '#description' => t('If enabled, the editor will insert TAB characters on tab and preserve other whitespace characters just like a PRE element in HTML does.'), |
218 | - ); |
|
218 | + ); |
|
219 | 219 | |
220 | - $form['output']['convert_fonts_to_spans'] = array( |
|
220 | + $form['output']['convert_fonts_to_spans'] = array( |
|
221 | 221 | '#type' => 'checkbox', |
222 | 222 | '#title' => t('Convert <font> tags to styles'), |
223 | 223 | '#default_value' => $profile->settings['convert_fonts_to_spans'], |
224 | 224 | '#return_value' => 1, |
225 | 225 | '#description' => t('If enabled, HTML tags declaring the font size, font family, font color and font background color will be replaced by inline CSS styles.'), |
226 | - ); |
|
226 | + ); |
|
227 | 227 | |
228 | - $form['output']['remove_linebreaks'] = array( |
|
228 | + $form['output']['remove_linebreaks'] = array( |
|
229 | 229 | '#type' => 'checkbox', |
230 | 230 | '#title' => t('Remove linebreaks'), |
231 | 231 | '#default_value' => $profile->settings['remove_linebreaks'], |
232 | 232 | '#return_value' => 1, |
233 | 233 | '#description' => t('If enabled, the editor will remove most linebreaks from contents. Disabling this option could avoid conflicts with other input filters.'), |
234 | - ); |
|
234 | + ); |
|
235 | 235 | |
236 | - $form['output']['apply_source_formatting'] = array( |
|
236 | + $form['output']['apply_source_formatting'] = array( |
|
237 | 237 | '#type' => 'checkbox', |
238 | 238 | '#title' => t('Apply source formatting'), |
239 | 239 | '#default_value' => $profile->settings['apply_source_formatting'], |
240 | 240 | '#return_value' => 1, |
241 | 241 | '#description' => t('If enabled, the editor will re-format the HTML source code. Disabling this option could avoid conflicts with other input filters.'), |
242 | - ); |
|
242 | + ); |
|
243 | 243 | |
244 | - $form['output']['paste_auto_cleanup_on_paste'] = array( |
|
244 | + $form['output']['paste_auto_cleanup_on_paste'] = array( |
|
245 | 245 | '#type' => 'checkbox', |
246 | 246 | '#title' => t('Force cleanup on standard paste'), |
247 | 247 | '#default_value' => $profile->settings['paste_auto_cleanup_on_paste'], |
248 | 248 | '#return_value' => 1, |
249 | 249 | '#description' => t('If enabled, the default paste function (CTRL-V or SHIFT-INS) behaves like the "paste from word" plugin function.'), |
250 | - ); |
|
250 | + ); |
|
251 | 251 | |
252 | - $form['css'] = array( |
|
252 | + $form['css'] = array( |
|
253 | 253 | '#type' => 'fieldset', |
254 | 254 | '#title' => t('CSS'), |
255 | 255 | '#collapsible' => TRUE, |
256 | 256 | '#collapsed' => TRUE, |
257 | - ); |
|
257 | + ); |
|
258 | 258 | |
259 | - $form['css']['block_formats'] = array( |
|
259 | + $form['css']['block_formats'] = array( |
|
260 | 260 | '#type' => 'textfield', |
261 | 261 | '#title' => t('Block formats'), |
262 | 262 | '#default_value' => $profile->settings['block_formats'], |
263 | 263 | '#size' => 40, |
264 | 264 | '#maxlength' => 250, |
265 | 265 | '#description' => t('Comma separated list of HTML block formats. Possible values: <code>@format-list</code>.', array('@format-list' => 'p,h1,h2,h3,h4,h5,h6,div,blockquote,address,pre,code,dt,dd')), |
266 | - ); |
|
266 | + ); |
|
267 | 267 | |
268 | - $form['css']['css_setting'] = array( |
|
268 | + $form['css']['css_setting'] = array( |
|
269 | 269 | '#type' => 'select', |
270 | 270 | '#title' => t('Editor CSS'), |
271 | 271 | '#default_value' => $profile->settings['css_setting'], |
272 | 272 | '#options' => array('theme' => t('Use theme CSS'), 'self' => t('Define CSS'), 'none' => t('Editor default CSS')), |
273 | 273 | '#description' => t('Defines the CSS to be used in the editor area.<br />Use theme CSS - loads stylesheets from current site theme.<br/>Define CSS - enter path for stylesheet files below.<br />Editor default CSS - uses default stylesheets from editor.'), |
274 | - ); |
|
274 | + ); |
|
275 | 275 | |
276 | - $form['css']['css_path'] = array( |
|
276 | + $form['css']['css_path'] = array( |
|
277 | 277 | '#type' => 'textfield', |
278 | 278 | '#title' => t('CSS path'), |
279 | 279 | '#default_value' => $profile->settings['css_path'], |
280 | 280 | '#size' => 40, |
281 | 281 | '#maxlength' => 255, |
282 | 282 | '#description' => t('If "Define CSS" was selected above, enter path to a CSS file or a list of CSS files separated by a comma.') . '<br />' . t('Available tokens: <code>%b</code> (base path, eg: <code>/</code>), <code>%t</code> (path to theme, eg: <code>themes/garland</code>)') . '<br />' . t('Example:') . ' css/editor.css,/themes/garland/style.css,%b%t/style.css,http://example.com/external.css', |
283 | - ); |
|
283 | + ); |
|
284 | 284 | |
285 | - $form['css']['css_classes'] = array( |
|
285 | + $form['css']['css_classes'] = array( |
|
286 | 286 | '#type' => 'textarea', |
287 | 287 | '#title' => t('CSS classes'), |
288 | 288 | '#default_value' => $profile->settings['css_classes'], |
289 | 289 | '#description' => t('Optionally define CSS classes for the "Font style" dropdown list.<br />Enter one class on each line in the format: !format. Example: !example<br />If left blank, CSS classes are automatically imported from all loaded stylesheet(s).', array('!format' => '<code>[title]=[class]</code>', '!example' => 'My heading=header1')), |
290 | - ); |
|
290 | + ); |
|
291 | 291 | |
292 | - $form['submit'] = array( |
|
292 | + $form['submit'] = array( |
|
293 | 293 | '#type' => 'submit', |
294 | 294 | '#value' => t('Save'), |
295 | 295 | '#weight' => 100, |
296 | - ); |
|
297 | - $form['cancel'] = array( |
|
296 | + ); |
|
297 | + $form['cancel'] = array( |
|
298 | 298 | '#value' => l(t('Cancel'), 'admin/settings/wysiwyg'), |
299 | 299 | '#weight' => 110, |
300 | - ); |
|
300 | + ); |
|
301 | 301 | |
302 | - return $form; |
|
302 | + return $form; |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | /** |
@@ -308,258 +308,258 @@ discard block |
||
308 | 308 | * @see wysiwyg_profile_form() |
309 | 309 | */ |
310 | 310 | function wysiwyg_profile_form_submit($form, &$form_state) { |
311 | - $values = $form_state['values']; |
|
312 | - if (isset($values['buttons'])) { |
|
311 | + $values = $form_state['values']; |
|
312 | + if (isset($values['buttons'])) { |
|
313 | 313 | // Store only enabled buttons for each plugin. |
314 | 314 | foreach ($values['buttons'] as $plugin => $buttons) { |
315 | - $values['buttons'][$plugin] = array_filter($values['buttons'][$plugin]); |
|
315 | + $values['buttons'][$plugin] = array_filter($values['buttons'][$plugin]); |
|
316 | 316 | } |
317 | 317 | // Store only enabled plugins. |
318 | 318 | $values['buttons'] = array_filter($values['buttons']); |
319 | - } |
|
320 | - // Remove any white-space from 'block_formats' setting, since editor |
|
321 | - // implementations rely on a comma-separated list to explode(). |
|
322 | - $values['block_formats'] = preg_replace('@\s+@', '', $values['block_formats']); |
|
323 | - |
|
324 | - // Remove input format name. |
|
325 | - $format = $values['format']; |
|
326 | - $input_format = $values['input_format']; |
|
327 | - $editor = $values['editor']; |
|
328 | - unset($values['format'], $values['input_format'], $values['editor']); |
|
329 | - |
|
330 | - // Remove FAPI values. |
|
331 | - // @see system_settings_form_submit() |
|
332 | - unset($values['submit'], $values['form_id'], $values['op'], $values['form_token'], $values['form_build_id']); |
|
333 | - |
|
334 | - // Determine if this is an update. |
|
335 | - if (!db_result(db_query("SELECT 1 FROM {wysiwyg} WHERE format = %d", $format))) { |
|
319 | + } |
|
320 | + // Remove any white-space from 'block_formats' setting, since editor |
|
321 | + // implementations rely on a comma-separated list to explode(). |
|
322 | + $values['block_formats'] = preg_replace('@\s+@', '', $values['block_formats']); |
|
323 | + |
|
324 | + // Remove input format name. |
|
325 | + $format = $values['format']; |
|
326 | + $input_format = $values['input_format']; |
|
327 | + $editor = $values['editor']; |
|
328 | + unset($values['format'], $values['input_format'], $values['editor']); |
|
329 | + |
|
330 | + // Remove FAPI values. |
|
331 | + // @see system_settings_form_submit() |
|
332 | + unset($values['submit'], $values['form_id'], $values['op'], $values['form_token'], $values['form_build_id']); |
|
333 | + |
|
334 | + // Determine if this is an update. |
|
335 | + if (!db_result(db_query("SELECT 1 FROM {wysiwyg} WHERE format = %d", $format))) { |
|
336 | 336 | $update = array(); |
337 | - } |
|
338 | - else { |
|
337 | + } |
|
338 | + else { |
|
339 | 339 | $update = array('format'); |
340 | - } |
|
341 | - $wysiwyg = new stdClass(); |
|
342 | - $wysiwyg->format = $format; |
|
343 | - $wysiwyg->editor = $editor; |
|
344 | - $wysiwyg->settings = $values; |
|
340 | + } |
|
341 | + $wysiwyg = new stdClass(); |
|
342 | + $wysiwyg->format = $format; |
|
343 | + $wysiwyg->editor = $editor; |
|
344 | + $wysiwyg->settings = $values; |
|
345 | 345 | |
346 | - // Insert new profile data. |
|
347 | - drupal_write_record('wysiwyg', $wysiwyg, $update); |
|
346 | + // Insert new profile data. |
|
347 | + drupal_write_record('wysiwyg', $wysiwyg, $update); |
|
348 | 348 | |
349 | - drupal_set_message(t('Wysiwyg profile for %format has been saved.', array('%format' => $input_format))); |
|
349 | + drupal_set_message(t('Wysiwyg profile for %format has been saved.', array('%format' => $input_format))); |
|
350 | 350 | |
351 | - $form_state['redirect'] = 'admin/settings/wysiwyg'; |
|
351 | + $form_state['redirect'] = 'admin/settings/wysiwyg'; |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | /** |
355 | 355 | * Layout for the buttons in the Wysiwyg Editor profile form. |
356 | 356 | */ |
357 | 357 | function theme_wysiwyg_admin_button_table($form) { |
358 | - $buttons = array(); |
|
358 | + $buttons = array(); |
|
359 | 359 | |
360 | - // Flatten forms array. |
|
361 | - foreach (element_children($form) as $name) { |
|
360 | + // Flatten forms array. |
|
361 | + foreach (element_children($form) as $name) { |
|
362 | 362 | foreach (element_children($form[$name]) as $button) { |
363 | - $buttons[] = drupal_render($form[$name][$button]); |
|
363 | + $buttons[] = drupal_render($form[$name][$button]); |
|
364 | + } |
|
364 | 365 | } |
365 | - } |
|
366 | 366 | |
367 | - // Split checkboxes into rows with 3 columns. |
|
368 | - $total = count($buttons); |
|
369 | - $rows = array(); |
|
370 | - for ($i = 0; $i < $total; $i++) { |
|
367 | + // Split checkboxes into rows with 3 columns. |
|
368 | + $total = count($buttons); |
|
369 | + $rows = array(); |
|
370 | + for ($i = 0; $i < $total; $i++) { |
|
371 | 371 | $row = array(); |
372 | 372 | $row[] = array('data' => $buttons[$i]); |
373 | 373 | if (isset($buttons[++$i])) { |
374 | - $row[] = array('data' => $buttons[$i]); |
|
374 | + $row[] = array('data' => $buttons[$i]); |
|
375 | 375 | } |
376 | 376 | if (isset($buttons[++$i])) { |
377 | - $row[] = array('data' => $buttons[$i]); |
|
377 | + $row[] = array('data' => $buttons[$i]); |
|
378 | 378 | } |
379 | 379 | $rows[] = $row; |
380 | - } |
|
380 | + } |
|
381 | 381 | |
382 | - $output = theme('table', array(), $rows, array('width' => '100%')); |
|
382 | + $output = theme('table', array(), $rows, array('width' => '100%')); |
|
383 | 383 | |
384 | - return $output; |
|
384 | + return $output; |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | /** |
388 | 388 | * Display overview of setup Wysiwyg Editor profiles; menu callback. |
389 | 389 | */ |
390 | 390 | function wysiwyg_profile_overview() { |
391 | - include_once './includes/install.inc'; |
|
391 | + include_once './includes/install.inc'; |
|
392 | 392 | |
393 | - // Check which wysiwyg editors are installed. |
|
394 | - $editors = wysiwyg_get_all_editors(); |
|
395 | - $count = count($editors); |
|
396 | - $status = array(); |
|
397 | - $options = array('' => t('No editor')); |
|
393 | + // Check which wysiwyg editors are installed. |
|
394 | + $editors = wysiwyg_get_all_editors(); |
|
395 | + $count = count($editors); |
|
396 | + $status = array(); |
|
397 | + $options = array('' => t('No editor')); |
|
398 | 398 | |
399 | - foreach ($editors as $name => $editor) { |
|
399 | + foreach ($editors as $name => $editor) { |
|
400 | 400 | $status[$name] = array( |
401 | - 'severity' => (isset($editor['error']) ? REQUIREMENT_ERROR : ($editor['installed'] ? REQUIREMENT_OK : REQUIREMENT_INFO)), |
|
402 | - 'title' => t('<a href="!vendor-url">@editor</a> (<a href="!download-url">Download</a>)', array('!vendor-url' => $editor['vendor url'], '@editor' => $editor['title'], '!download-url' => $editor['download url'])), |
|
403 | - 'value' => (isset($editor['installed version']) ? $editor['installed version'] : t('Not installed.')), |
|
404 | - 'description' => (isset($editor['error']) ? $editor['error'] : ''), |
|
401 | + 'severity' => (isset($editor['error']) ? REQUIREMENT_ERROR : ($editor['installed'] ? REQUIREMENT_OK : REQUIREMENT_INFO)), |
|
402 | + 'title' => t('<a href="!vendor-url">@editor</a> (<a href="!download-url">Download</a>)', array('!vendor-url' => $editor['vendor url'], '@editor' => $editor['title'], '!download-url' => $editor['download url'])), |
|
403 | + 'value' => (isset($editor['installed version']) ? $editor['installed version'] : t('Not installed.')), |
|
404 | + 'description' => (isset($editor['error']) ? $editor['error'] : ''), |
|
405 | 405 | ); |
406 | 406 | if ($editor['installed']) { |
407 | - $options[$name] = $editor['title'] . (isset($editor['installed version']) ? ' ' . $editor['installed version'] : ''); |
|
407 | + $options[$name] = $editor['title'] . (isset($editor['installed version']) ? ' ' . $editor['installed version'] : ''); |
|
408 | 408 | } |
409 | 409 | else { |
410 | - // Build on-site installation instructions. |
|
411 | - // @todo Setup $library in wysiwyg_load_editor() already. |
|
412 | - $library = (isset($editor['library']) ? $editor['library'] : key($editor['libraries'])); |
|
413 | - $targs = array( |
|
410 | + // Build on-site installation instructions. |
|
411 | + // @todo Setup $library in wysiwyg_load_editor() already. |
|
412 | + $library = (isset($editor['library']) ? $editor['library'] : key($editor['libraries'])); |
|
413 | + $targs = array( |
|
414 | 414 | '@editor-path' => $editor['editor path'], |
415 | 415 | '@library-filepath' => $editor['library path'] . '/' . (isset($editor['libraries'][$library]['files'][0]) ? $editor['libraries'][$library]['files'][0] : key($editor['libraries'][$library]['files'])), |
416 | - ); |
|
417 | - $instructions = '<p>' . t('Extract the archive and copy its contents into a new folder in the following location:<br /><code>@editor-path</code>', $targs) . '</p>'; |
|
418 | - $instructions .= '<p>' . t('So the actual library can be found at:<br /><code>@library-filepath</code>', $targs) . '</p>'; |
|
416 | + ); |
|
417 | + $instructions = '<p>' . t('Extract the archive and copy its contents into a new folder in the following location:<br /><code>@editor-path</code>', $targs) . '</p>'; |
|
418 | + $instructions .= '<p>' . t('So the actual library can be found at:<br /><code>@library-filepath</code>', $targs) . '</p>'; |
|
419 | 419 | |
420 | - $status[$name]['description'] .= $instructions; |
|
421 | - $count--; |
|
420 | + $status[$name]['description'] .= $instructions; |
|
421 | + $count--; |
|
422 | 422 | } |
423 | 423 | // In case there is an error, always show installation instructions. |
424 | 424 | if (isset($editor['error'])) { |
425 | - $show_instructions = TRUE; |
|
425 | + $show_instructions = TRUE; |
|
426 | + } |
|
426 | 427 | } |
427 | - } |
|
428 | - if (!$count) { |
|
428 | + if (!$count) { |
|
429 | 429 | $show_instructions = TRUE; |
430 | - } |
|
431 | - $form['status'] = array( |
|
430 | + } |
|
431 | + $form['status'] = array( |
|
432 | 432 | '#type' => 'fieldset', |
433 | 433 | '#title' => t('Installation instructions'), |
434 | 434 | '#collapsible' => TRUE, |
435 | 435 | '#collapsed' => !isset($show_instructions), |
436 | 436 | '#description' => (!$count ? t('There are no editor libraries installed currently. The following list contains a list of currently supported editors:') : ''), |
437 | 437 | '#weight' => 10, |
438 | - ); |
|
439 | - $form['status']['report'] = array('#value' => theme('status_report', $status)); |
|
438 | + ); |
|
439 | + $form['status']['report'] = array('#value' => theme('status_report', $status)); |
|
440 | 440 | |
441 | - if (!$count) { |
|
441 | + if (!$count) { |
|
442 | 442 | return $form; |
443 | - } |
|
443 | + } |
|
444 | 444 | |
445 | - $formats = filter_formats(); |
|
446 | - // Reset Wysiwyg cache |
|
447 | - $profiles = wysiwyg_profile_load_all(TRUE); |
|
448 | - $form['formats'] = array( |
|
445 | + $formats = filter_formats(); |
|
446 | + // Reset Wysiwyg cache |
|
447 | + $profiles = wysiwyg_profile_load_all(TRUE); |
|
448 | + $form['formats'] = array( |
|
449 | 449 | '#type' => 'item', |
450 | 450 | '#description' => t('To assign a different editor to a text format, click "delete" to remove the existing first.'), |
451 | 451 | '#tree' => TRUE, |
452 | - ); |
|
452 | + ); |
|
453 | 453 | |
454 | - $enable_save = FALSE; |
|
455 | - $in_code_only = FALSE; |
|
456 | - foreach ($formats as $id => $format) { |
|
454 | + $enable_save = FALSE; |
|
455 | + $in_code_only = FALSE; |
|
456 | + foreach ($formats as $id => $format) { |
|
457 | 457 | $form['formats'][$id]['name'] = array( |
458 | - '#value' => check_plain($format->name), |
|
458 | + '#value' => check_plain($format->name), |
|
459 | 459 | ); |
460 | 460 | // Only display editor selection for associated input formats to avoid |
461 | 461 | // confusion about disabled selection. |
462 | 462 | if (isset($profiles[$id]) && !empty($profiles[$id]->editor)) { |
463 | - $in_code_only = !empty($profiles[$id]->in_code_only); |
|
464 | - $form['formats'][$id]['editor'] = array( |
|
463 | + $in_code_only = !empty($profiles[$id]->in_code_only); |
|
464 | + $form['formats'][$id]['editor'] = array( |
|
465 | 465 | '#value' => $options[$profiles[$id]->editor], |
466 | - ); |
|
467 | - if ($in_code_only) { |
|
466 | + ); |
|
467 | + if ($in_code_only) { |
|
468 | 468 | $form['formats'][$id]['name']['#value'] .= ' <em>(' . t('From: !module module', array('!module' => $profiles[$id]->export_module)) . ')</em>'; |
469 | - } |
|
469 | + } |
|
470 | 470 | } |
471 | 471 | else { |
472 | - $form['formats'][$id]['editor'] = array( |
|
472 | + $form['formats'][$id]['editor'] = array( |
|
473 | 473 | '#type' => 'select', |
474 | 474 | '#default_value' => '', |
475 | 475 | '#options' => $options, |
476 | - ); |
|
477 | - $enable_save = TRUE; |
|
476 | + ); |
|
477 | + $enable_save = TRUE; |
|
478 | 478 | } |
479 | 479 | if (isset($profiles[$id]) && !empty($profiles[$id]->editor)) { |
480 | - $edit = !empty($profiles[$id]->in_code_only)?t('Override'):t('Edit'); |
|
481 | - $form['formats'][$id]['edit'] = array( |
|
480 | + $edit = !empty($profiles[$id]->in_code_only)?t('Override'):t('Edit'); |
|
481 | + $form['formats'][$id]['edit'] = array( |
|
482 | 482 | '#value' => l($edit, "admin/settings/wysiwyg/profile/$id/edit"), |
483 | - ); |
|
484 | - // Only display delete/revert links for wysiwyg loaded from the database |
|
485 | - if (!$in_code_only) { |
|
483 | + ); |
|
484 | + // Only display delete/revert links for wysiwyg loaded from the database |
|
485 | + if (!$in_code_only) { |
|
486 | 486 | $delete = (empty($profiles[$id]->type) || $profiles[$id]->type == t('Normal'))?t('Delete'):t('Revert'); |
487 | 487 | $form['formats'][$id]['delete'] = array( |
488 | - '#value' => l($delete, "admin/settings/wysiwyg/profile/$id/delete"), |
|
488 | + '#value' => l($delete, "admin/settings/wysiwyg/profile/$id/delete"), |
|
489 | 489 | ); |
490 | - } |
|
490 | + } |
|
491 | + } |
|
491 | 492 | } |
492 | - } |
|
493 | 493 | |
494 | - // Submitting the form when no editors can be selected causes errors. |
|
495 | - if ($enable_save) { |
|
494 | + // Submitting the form when no editors can be selected causes errors. |
|
495 | + if ($enable_save) { |
|
496 | 496 | $form['submit'] = array('#type' => 'submit', '#value' => t('Save')); |
497 | - } |
|
498 | - return $form; |
|
497 | + } |
|
498 | + return $form; |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | /** |
502 | 502 | * Return HTML for the Wysiwyg profile overview form. |
503 | 503 | */ |
504 | 504 | function theme_wysiwyg_profile_overview($form) { |
505 | - if (!isset($form['formats'])) { |
|
505 | + if (!isset($form['formats'])) { |
|
506 | 506 | return; |
507 | - } |
|
508 | - $output = ''; |
|
509 | - $header = array(t('Input format'), t('Editor'), array('data' => t('Operations'), 'colspan' => 3)); |
|
510 | - $rows = array(); |
|
511 | - foreach (element_children($form['formats']) as $item) { |
|
507 | + } |
|
508 | + $output = ''; |
|
509 | + $header = array(t('Input format'), t('Editor'), array('data' => t('Operations'), 'colspan' => 3)); |
|
510 | + $rows = array(); |
|
511 | + foreach (element_children($form['formats']) as $item) { |
|
512 | 512 | $format = &$form['formats'][$item]; |
513 | 513 | $rows[] = array( |
514 | - drupal_render($format['name']), |
|
515 | - drupal_render($format['editor']), |
|
516 | - isset($format['edit']) ? drupal_render($format['edit']) : '', |
|
517 | - isset($format['export']) ? drupal_render($format['export']) : '', |
|
518 | - isset($format['delete']) ? drupal_render($format['delete']) : '', |
|
519 | - ); |
|
520 | - } |
|
521 | - $form['formats']['table']['#value'] = theme('table', $header, $rows); |
|
522 | - $output .= drupal_render($form); |
|
523 | - return $output; |
|
514 | + drupal_render($format['name']), |
|
515 | + drupal_render($format['editor']), |
|
516 | + isset($format['edit']) ? drupal_render($format['edit']) : '', |
|
517 | + isset($format['export']) ? drupal_render($format['export']) : '', |
|
518 | + isset($format['delete']) ? drupal_render($format['delete']) : '', |
|
519 | + ); |
|
520 | + } |
|
521 | + $form['formats']['table']['#value'] = theme('table', $header, $rows); |
|
522 | + $output .= drupal_render($form); |
|
523 | + return $output; |
|
524 | 524 | } |
525 | 525 | |
526 | 526 | /** |
527 | 527 | * Submit callback for Wysiwyg profile overview form. |
528 | 528 | */ |
529 | 529 | function wysiwyg_profile_overview_submit($form, &$form_state) { |
530 | - foreach ($form_state['values']['formats'] as $format => $values) { |
|
530 | + foreach ($form_state['values']['formats'] as $format => $values) { |
|
531 | 531 | db_query("UPDATE {wysiwyg} SET editor = '%s' WHERE format = %d", $values['editor'], $format); |
532 | 532 | if (!db_affected_rows()) { |
533 | - db_query("INSERT INTO {wysiwyg} (format, editor) VALUES (%d, '%s')", $format, $values['editor']); |
|
533 | + db_query("INSERT INTO {wysiwyg} (format, editor) VALUES (%d, '%s')", $format, $values['editor']); |
|
534 | + } |
|
534 | 535 | } |
535 | - } |
|
536 | 536 | } |
537 | 537 | |
538 | 538 | /** |
539 | 539 | * Delete editor profile confirmation form. |
540 | 540 | */ |
541 | 541 | function wysiwyg_profile_delete_confirm(&$form_state, $profile) { |
542 | - $formats = filter_formats(); |
|
543 | - $format = $formats[$profile->format]; |
|
544 | - $form['format'] = array('#type' => 'value', '#value' => $format); |
|
545 | - if (isset($profile->type) && $profile->type == t('Overridden')) { |
|
542 | + $formats = filter_formats(); |
|
543 | + $format = $formats[$profile->format]; |
|
544 | + $form['format'] = array('#type' => 'value', '#value' => $format); |
|
545 | + if (isset($profile->type) && $profile->type == t('Overridden')) { |
|
546 | 546 | $form['revert'] = array( |
547 | - '#type' => 'value', |
|
548 | - '#value' => TRUE, |
|
547 | + '#type' => 'value', |
|
548 | + '#value' => TRUE, |
|
549 | 549 | ); |
550 | 550 | return confirm_form( |
551 | - $form, |
|
552 | - t('Are you sure you want to revert the profile settings for %name?', array('%name' => $format->name)), |
|
553 | - 'admin/settings/wysiwyg', |
|
554 | - t('This action cannot be undone.'), t('Revert'), t('Cancel') |
|
551 | + $form, |
|
552 | + t('Are you sure you want to revert the profile settings for %name?', array('%name' => $format->name)), |
|
553 | + 'admin/settings/wysiwyg', |
|
554 | + t('This action cannot be undone.'), t('Revert'), t('Cancel') |
|
555 | 555 | ); |
556 | - } |
|
557 | - return confirm_form( |
|
556 | + } |
|
557 | + return confirm_form( |
|
558 | 558 | $form, |
559 | 559 | t('Are you sure you want to remove the profile for %name?', array('%name' => $format->name)), |
560 | 560 | 'admin/settings/wysiwyg', |
561 | 561 | t('This action cannot be undone.'), t('Remove'), t('Cancel') |
562 | - ); |
|
562 | + ); |
|
563 | 563 | } |
564 | 564 | |
565 | 565 | /** |
@@ -568,16 +568,16 @@ discard block |
||
568 | 568 | * @see wysiwyg_profile_delete_confirm() |
569 | 569 | */ |
570 | 570 | function wysiwyg_profile_delete_confirm_submit($form, &$form_state) { |
571 | - $format = $form_state['values']['format']; |
|
572 | - $wysiwyg = new stdClass(); |
|
573 | - $wysiwyg->format = $format->format; |
|
574 | - wysiwyg_profile_delete($wysiwyg); |
|
575 | - if (!empty($form_state['values']['revert'])) { |
|
571 | + $format = $form_state['values']['format']; |
|
572 | + $wysiwyg = new stdClass(); |
|
573 | + $wysiwyg->format = $format->format; |
|
574 | + wysiwyg_profile_delete($wysiwyg); |
|
575 | + if (!empty($form_state['values']['revert'])) { |
|
576 | 576 | drupal_set_message(t('Wysiwyg profile settings for %name has been reverted.', array('%name' => $format->name))); |
577 | - } |
|
578 | - else { |
|
577 | + } |
|
578 | + else { |
|
579 | 579 | drupal_set_message(t('Wysiwyg profile for %name has been deleted.', array('%name' => $format->name))); |
580 | - } |
|
581 | - $form_state['redirect'] = 'admin/settings/wysiwyg'; |
|
580 | + } |
|
581 | + $form_state['redirect'] = 'admin/settings/wysiwyg'; |
|
582 | 582 | } |
583 | 583 |