Completed
Push — master ( 39c101...9585a5 )
by Christian
09:45
created
sites/default/boinc/modules/contrib/content_profile/content_profile.module 6 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -99,6 +99,7 @@  discard block
 block discarded – undo
99 99
 
100 100
 /**
101 101
  * Presents a node editing or adding form for the given content profile.
102
+ * @param string $type
102 103
  */
103 104
 function content_profile_page_edit($type, $account) {
104 105
   drupal_set_title(check_plain($account->name));
@@ -211,7 +212,7 @@  discard block
 block discarded – undo
211 212
  * @param $op
212 213
  *   When set to 'types', content profile content types are returned
213 214
  *   as type objects. When set to 'names', only their type names are returned.
214
- * @param $setting
215
+ * @param string $setting
215 216
  *   If set, only content types that have this setting activated are returned.
216 217
  *   Leave it NULL to get all content profile types.
217 218
  * @param $value
Please login to merge, or discard this patch.
Indentation   +230 added lines, -230 removed lines patch added patch discarded remove patch
@@ -11,56 +11,56 @@  discard block
 block discarded – undo
11 11
  * Implementation of hook_init().
12 12
  */
13 13
 function content_profile_init() {
14
-  module_load_include('inc', 'content_profile', 'content_profile.theme_vars');
14
+    module_load_include('inc', 'content_profile', 'content_profile.theme_vars');
15 15
 }
16 16
 
17 17
 /**
18 18
  * Implementation of hook_ctools_plugin_directory().
19 19
  */
20 20
 function content_profile_ctools_plugin_directory($module, $plugin) {
21
-  if ($module == 'ctools' && $plugin == 'relationships') {
21
+    if ($module == 'ctools' && $plugin == 'relationships') {
22 22
     return 'panels/' . $plugin;
23
-  }
23
+    }
24 24
 }
25 25
 
26 26
 /**
27 27
  * Implementation of hook_menu().
28 28
  */
29 29
 function content_profile_menu() {
30
-  $items = array();
30
+    $items = array();
31 31
 
32
-  //Register a path for each content profile type
33
-  foreach (content_profile_get_types('names') as $type => $typename) {
32
+    //Register a path for each content profile type
33
+    foreach (content_profile_get_types('names') as $type => $typename) {
34 34
     $items['admin/content/node-type/'. str_replace('_', '-', $type) .'/edit'] = array(
35
-      'title' => 'Edit',
36
-      'type' => MENU_DEFAULT_LOCAL_TASK,
35
+        'title' => 'Edit',
36
+        'type' => MENU_DEFAULT_LOCAL_TASK,
37 37
     );
38 38
     $items['admin/content/node-type/'. str_replace('_', '-', $type) .'/profile'] = array(
39
-      'title' => 'Content profile',
40
-      'description' => 'Configure the display and management of this content profile.',
41
-      'page callback' => 'drupal_get_form',
42
-      'page arguments' => array('content_profile_admin_settings', $type),
43
-      'access callback' => 'user_access',
44
-      'access arguments' => array('administer nodes'),
45
-      'type' => MENU_LOCAL_TASK,
46
-      'weight' => 1,
39
+        'title' => 'Content profile',
40
+        'description' => 'Configure the display and management of this content profile.',
41
+        'page callback' => 'drupal_get_form',
42
+        'page arguments' => array('content_profile_admin_settings', $type),
43
+        'access callback' => 'user_access',
44
+        'access arguments' => array('administer nodes'),
45
+        'type' => MENU_LOCAL_TASK,
46
+        'weight' => 1,
47 47
     );
48
-  }
49
-  foreach (content_profile_get_types('names') as $type => $type_name) {
48
+    }
49
+    foreach (content_profile_get_types('names') as $type => $type_name) {
50 50
     $items['user/%user/profile/'. $type] = array(
51
-      'title callback' => 'check_plain',
52
-      'title' => drupal_ucfirst($type_name),
53
-      'page callback' => 'content_profile_page_edit',
54
-      'page arguments' => array($type, 1),
55
-      'access callback' => 'content_profile_page_access',
56
-      'access arguments' => array($type, 1),
57
-      'weight' => content_profile_get_settings($type, 'weight'),
58
-      'file' => 'node.pages.inc',
59
-      'file path' => drupal_get_path('module', 'node'),
60
-      'type' => content_profile_get_settings($type, 'edit_tab') == 'top' ? MENU_LOCAL_TASK : MENU_CALLBACK,
51
+        'title callback' => 'check_plain',
52
+        'title' => drupal_ucfirst($type_name),
53
+        'page callback' => 'content_profile_page_edit',
54
+        'page arguments' => array($type, 1),
55
+        'access callback' => 'content_profile_page_access',
56
+        'access arguments' => array($type, 1),
57
+        'weight' => content_profile_get_settings($type, 'weight'),
58
+        'file' => 'node.pages.inc',
59
+        'file path' => drupal_get_path('module', 'node'),
60
+        'type' => content_profile_get_settings($type, 'edit_tab') == 'top' ? MENU_LOCAL_TASK : MENU_CALLBACK,
61 61
     );
62
-  }
63
-  return $items;
62
+    }
63
+    return $items;
64 64
 }
65 65
 
66 66
 /**
@@ -68,45 +68,45 @@  discard block
 block discarded – undo
68 68
  * Take over menu items generated by the user module for our categories.
69 69
  */
70 70
 function content_profile_menu_alter(&$items) {
71
-  foreach (content_profile_get_types('names', 'edit_tab', 'sub') as $type => $type_name) {
71
+    foreach (content_profile_get_types('names', 'edit_tab', 'sub') as $type => $type_name) {
72 72
     if (!empty($items['user/%user_category/edit/'. $type])) {
73
-      $item = &$items['user/%user_category/edit/'. $type];
74
-      $item = array(
73
+        $item = &$items['user/%user_category/edit/'. $type];
74
+        $item = array(
75 75
         'page callback' => 'content_profile_page_edit',
76 76
         'page arguments' => array($type, 1),
77 77
         'access callback' => 'content_profile_page_access',
78 78
         'access arguments' => array($type, 1),
79 79
         'file' => 'node.pages.inc',
80 80
         'file path' => drupal_get_path('module', 'node'),
81
-      ) + $item;
81
+        ) + $item;
82
+    }
82 83
     }
83
-  }
84 84
 }
85 85
 
86 86
 
87 87
 function content_profile_page_access($type, $account) {
88
-  if ($node = content_profile_load($type, $account->uid)) {
88
+    if ($node = content_profile_load($type, $account->uid)) {
89 89
     return node_access('update', $node);
90
-  }
91
-  // Else user may view the page when they are going to create their own profile
92
-  // or have permission to create it for others.
93
-  global $user;
94
-  if ($user->uid == $account->uid || user_access('administer nodes') ){
90
+    }
91
+    // Else user may view the page when they are going to create their own profile
92
+    // or have permission to create it for others.
93
+    global $user;
94
+    if ($user->uid == $account->uid || user_access('administer nodes') ){
95 95
     return node_access('create', $type);
96
-  }
97
-  return FALSE;
96
+    }
97
+    return FALSE;
98 98
 }
99 99
 
100 100
 /**
101 101
  * Presents a node editing or adding form for the given content profile.
102 102
  */
103 103
 function content_profile_page_edit($type, $account) {
104
-  drupal_set_title(check_plain($account->name));
105
-  $node = content_profile_load($type, $account->uid);
106
-  if (!$node) {
104
+    drupal_set_title(check_plain($account->name));
105
+    $node = content_profile_load($type, $account->uid);
106
+    if (!$node) {
107 107
     $node = array('uid' => $account->uid, 'name' => (isset($account->name) ? $account->name : ''), 'type' => $type, 'language' => '');
108
-  }
109
-  return drupal_get_form($type .'_node_form', $node);
108
+    }
109
+    return drupal_get_form($type .'_node_form', $node);
110 110
 }
111 111
 
112 112
 
@@ -114,10 +114,10 @@  discard block
 block discarded – undo
114 114
  * Implementation of hook_views_api().
115 115
  */
116 116
 function content_profile_views_api() {
117
-  return array(
117
+    return array(
118 118
     'api' => 2,
119 119
     'path' => drupal_get_path('module', 'content_profile') .'/views',
120
-  );
120
+    );
121 121
 }
122 122
 
123 123
 
@@ -125,71 +125,71 @@  discard block
 block discarded – undo
125 125
  * Menu callback; content profile settings.
126 126
  */
127 127
 function content_profile_admin_settings(&$form_state, $type) {
128
-  $form_state['type'] = $type;
128
+    $form_state['type'] = $type;
129 129
 
130
-  $form['weight'] = array(
130
+    $form['weight'] = array(
131 131
     '#type' => 'weight',
132 132
     '#title' => t("Weight"),
133 133
     '#default_value' => content_profile_get_settings($type, 'weight'),
134 134
     '#description' => t('The weight of content of this content type where ever they appear - this applies to the input form integration as well to the display integration.'),
135 135
     '#weight' => 5,
136
-  );
137
-  $form['display'] = array(
136
+    );
137
+    $form['display'] = array(
138 138
     '#type' => 'fieldset',
139 139
     '#title' => t('Display settings'),
140 140
     '#description' => t('Customize the display of this content profile.'),
141 141
     '#collapsible' => TRUE,
142
-  );
143
-  $form['display']['user_display'] = array(
142
+    );
143
+    $form['display']['user_display'] = array(
144 144
     '#type' => 'radios',
145 145
     '#title' => t("User page display style"),
146 146
     '#default_value' => content_profile_get_settings($type, 'user_display'),
147 147
     '#options' => array(
148
-      0 => t("Don't display this content profile on the user account page"),
149
-      'link' => t('Display it as link to the profile content'),
150
-      'full' => t('Display the full content'),
151
-      'teaser' => t("Display the content's teaser"),
148
+        0 => t("Don't display this content profile on the user account page"),
149
+        'link' => t('Display it as link to the profile content'),
150
+        'full' => t('Display the full content'),
151
+        'teaser' => t("Display the content's teaser"),
152 152
     ),
153
-  );
154
-  $form['display']['edit_link'] = array(
153
+    );
154
+    $form['display']['edit_link'] = array(
155 155
     '#type' => 'checkbox',
156 156
     '#title' => t("Include an edit link to the display"),
157 157
     '#default_value' => content_profile_get_settings($type, 'edit_link'),
158
-  );
159
-  $form['display']['add_link'] = array(
158
+    );
159
+    $form['display']['add_link'] = array(
160 160
     '#type' => 'checkbox',
161 161
     '#title' => t("Show a link to the content profile creation page, if there is no profile."),
162 162
     '#default_value' => content_profile_get_settings($type, 'add_link'),
163 163
     '#description' => t("If selected and the user has no profile of this type yet, a link to add one is shown on the user page."),
164
-  );
165
-  $form['display']['edit_tab'] = array(
164
+    );
165
+    $form['display']['edit_tab'] = array(
166 166
     '#type' => 'radios',
167 167
     '#title' => t("Profile edit tab"),
168 168
     '#default_value' => content_profile_get_settings($type, 'edit_tab'),
169 169
     '#options' => array(
170
-      0 => t('None'),
171
-      'top' => t("Show a tab at the user's page"),
172
-      'sub' => t("Show a secondary tab below the user's edit tab"),
170
+        0 => t('None'),
171
+        'top' => t("Show a tab at the user's page"),
172
+        'sub' => t("Show a secondary tab below the user's edit tab"),
173 173
     ),
174
-  );
175
-  $form['submit'] = array(
174
+    );
175
+    $form['submit'] = array(
176 176
     '#type' => 'submit',
177 177
     '#value' => t('Submit'),
178 178
     '#weight' => 10,
179
-  );
180
-  return $form;
179
+    );
180
+    return $form;
181 181
 }
182 182
 
183 183
 function content_profile_admin_settings_submit($form, &$form_state) {
184
-  $settings = content_profile_get_settings($form_state['type']);
185
-  foreach (content_profile_settings_info() as $setting => $default) {
184
+    $settings = content_profile_get_settings($form_state['type']);
185
+    foreach (content_profile_settings_info() as $setting => $default) {
186 186
     if (isset($form_state['values'][$setting])) {
187
-      $settings[$setting] = $form_state['values'][$setting];
187
+        $settings[$setting] = $form_state['values'][$setting];
188
+    }
188 189
     }
189
-  }
190
-  content_profile_set_settings($form_state['type'], $settings);
191
-  drupal_set_message('Your changes have been saved.');
192
-  menu_rebuild();
190
+    content_profile_set_settings($form_state['type'], $settings);
191
+    drupal_set_message('Your changes have been saved.');
192
+    menu_rebuild();
193 193
 }
194 194
 
195 195
 /**
@@ -198,10 +198,10 @@  discard block
 block discarded – undo
198 198
  *   The node object or the node's type
199 199
  */
200 200
 function is_content_profile($type) {
201
-  if (is_object($type)) {
201
+    if (is_object($type)) {
202 202
     $type = $type->type;
203
-  }
204
-  return variable_get('content_profile_use_'. $type, FALSE);
203
+    }
204
+    return variable_get('content_profile_use_'. $type, FALSE);
205 205
 }
206 206
 
207 207
 /**
@@ -218,14 +218,14 @@  discard block
 block discarded – undo
218 218
  *   The value to compare the given setting too.
219 219
  */
220 220
 function content_profile_get_types($op = 'types', $setting = NULL , $value = TRUE) {
221
-  $types = array();
221
+    $types = array();
222 222
 
223
-  foreach (node_get_types($op) as $type => $info) {
223
+    foreach (node_get_types($op) as $type => $info) {
224 224
     if (is_content_profile($type) && (!isset($setting) || content_profile_get_settings($type, $setting) == $value)) {
225
-      $types[$type] = $info;
225
+        $types[$type] = $info;
226 226
     }
227
-  }
228
-  return $types;
227
+    }
228
+    return $types;
229 229
 }
230 230
 
231 231
 /**
@@ -233,79 +233,79 @@  discard block
 block discarded – undo
233 233
  * Rename or delete the settings variable if a type changes.
234 234
  */
235 235
 function content_profile_node_type($op, $info) {
236
-  switch ($op) {
236
+    switch ($op) {
237 237
     case 'delete':
238 238
       variable_del('content_profile_use_'. $info->type);
239
-      variable_del('content_profile_'. $info->type);
240
-      break;
239
+        variable_del('content_profile_'. $info->type);
240
+        break;
241 241
     case 'update':
242 242
       if (!empty($info->old_type) && $info->old_type != $info->type) {
243 243
         if (is_content_profile($info->old_type)) {
244
-          $settings = variable_get('content_profile_'. $info->old_type, array());
245
-          variable_del('content_profile_use_'. $info->old_type);
246
-          variable_del('content_profile_'. $info->old_type);
247
-          variable_set('content_profile_use_'. $info->type, 1);
248
-          variable_set('content_profile_'. $info->type, $settings);
244
+            $settings = variable_get('content_profile_'. $info->old_type, array());
245
+            variable_del('content_profile_use_'. $info->old_type);
246
+            variable_del('content_profile_'. $info->old_type);
247
+            variable_set('content_profile_use_'. $info->type, 1);
248
+            variable_set('content_profile_'. $info->type, $settings);
249
+        }
249 250
         }
250
-      }
251
-      break;
252
-  }
251
+        break;
252
+    }
253 253
 }
254 254
 
255 255
 /**
256 256
  * Implementation of hook_form_alter().
257 257
  */
258 258
 function content_profile_form_alter(&$form, $form_state, $form_id) {
259
-  if ($form_id == 'node_type_form') {
259
+    if ($form_id == 'node_type_form') {
260 260
     $form['content_profile'] = array(
261
-      '#type' => 'fieldset',
262
-      '#title' => t('Content Profile'),
263
-      '#group' => 'additional_settings',
264
-      '#collapsible' => TRUE,
265
-      '#collapsed' => TRUE,
266
-      '#weight' => 32,
261
+        '#type' => 'fieldset',
262
+        '#title' => t('Content Profile'),
263
+        '#group' => 'additional_settings',
264
+        '#collapsible' => TRUE,
265
+        '#collapsed' => TRUE,
266
+        '#weight' => 32,
267 267
     );
268 268
     $form['content_profile']['content_profile_use'] = array(
269
-      '#type' => 'checkbox',
270
-      '#title' => t('Use this content type as a content profile for users'),
271
-      '#default_value' => variable_get('content_profile_use_'. $form['#node_type']->type, FALSE),
269
+        '#type' => 'checkbox',
270
+        '#title' => t('Use this content type as a content profile for users'),
271
+        '#default_value' => variable_get('content_profile_use_'. $form['#node_type']->type, FALSE),
272 272
     );
273
-  }
274
-  elseif (isset($form['#node']) && $form['#node']->type .'_node_form' == $form_id && is_content_profile($form['#node'])) {
273
+    }
274
+    elseif (isset($form['#node']) && $form['#node']->type .'_node_form' == $form_id && is_content_profile($form['#node'])) {
275 275
     // Customize the redirect target and buttons of our own node forms.
276 276
     if (arg(0) == 'user' && is_numeric(arg(1)) && arg(2) == 'edit' || arg(2) == 'profile') {
277
-      $form['buttons']['preview']['#access'] = FALSE;
278
-      $form['buttons']['delete']['#access'] = FALSE;
279
-      $form['#redirect'] = arg(2) == 'profile' ? 'user/'. $form['#node']->uid : $_GET['q'];
277
+        $form['buttons']['preview']['#access'] = FALSE;
278
+        $form['buttons']['delete']['#access'] = FALSE;
279
+        $form['#redirect'] = arg(2) == 'profile' ? 'user/'. $form['#node']->uid : $_GET['q'];
280 280
     }
281 281
     // Set the author value - note that this works only for admins.
282 282
     if (!empty($_GET['uid']) && ($uid = intval($_GET['uid'])) && ($user = user_load($uid))) {
283
-      $form['author']['name']['#default_value'] = $user->name;
283
+        $form['author']['name']['#default_value'] = $user->name;
284
+    }
284 285
     }
285
-  }
286 286
 }
287 287
 
288 288
 /**
289 289
  * Implementation of hook_user().
290 290
  */
291 291
 function content_profile_user($op, &$edit, &$account, $category = NULL) {
292
-  global $user;
292
+    global $user;
293 293
 
294
-  switch ($op) {
294
+    switch ($op) {
295 295
     case 'categories':
296 296
       $data = array();
297
-      foreach (content_profile_get_types('names', 'edit_tab', 'sub') as $type => $type_name) {
297
+        foreach (content_profile_get_types('names', 'edit_tab', 'sub') as $type => $type_name) {
298 298
         $data[] = array(
299
-          'name' => $type,
300
-          'title' => drupal_ucfirst($type_name),
301
-          'weight' => content_profile_get_settings($type, 'weight') + 1,
299
+            'name' => $type,
300
+            'title' => drupal_ucfirst($type_name),
301
+            'weight' => content_profile_get_settings($type, 'weight') + 1,
302 302
         );
303
-      }
304
-      return $data;
303
+        }
304
+        return $data;
305 305
 
306 306
     case 'view':
307 307
       $account->content['content_profile'] = content_profile_show_profiles($account->uid);
308
-      break;
308
+        break;
309 309
 
310 310
     case 'delete':
311 311
       // Retrieve all profile nodes (in any language) for this user by issueing an SQL query.
@@ -315,11 +315,11 @@  discard block
 block discarded – undo
315 315
 
316 316
         $result = db_query("SELECT * FROM {node} WHERE (". implode(' OR ', $condition) .") AND uid = %d", $arguments);
317 317
         while ($node = db_fetch_object($result)) {
318
-          _content_profile_node_delete($node);
318
+            _content_profile_node_delete($node);
319
+        }
319 320
         }
320
-      }
321
-      break;
322
-  }
321
+        break;
322
+    }
323 323
 }
324 324
 
325 325
 /**
@@ -333,42 +333,42 @@  discard block
 block discarded – undo
333 333
  * "SELECT * FROM {node}" query) instead of just the $nid.
334 334
  */
335 335
 function _content_profile_node_delete($node) {
336
-  // Copied over from node_load(), so that node_invoke('delete') gets
337
-  // the fully extended node object, like modules would expect:
336
+    // Copied over from node_load(), so that node_invoke('delete') gets
337
+    // the fully extended node object, like modules would expect:
338 338
 
339
-  if ($node->nid) {
339
+    if ($node->nid) {
340 340
     // Call the node specific callback (if any) and piggy-back the
341 341
     // results to the node or overwrite some values.
342 342
     if ($extra = node_invoke($node, 'load')) {
343
-      foreach ($extra as $key => $value) {
343
+        foreach ($extra as $key => $value) {
344 344
         $node->$key = $value;
345
-      }
345
+        }
346 346
     }
347 347
     if ($extra = node_invoke_nodeapi($node, 'load')) {
348
-      foreach ($extra as $key => $value) {
348
+        foreach ($extra as $key => $value) {
349 349
         $node->$key = $value;
350
-      }
350
+        }
351
+    }
351 352
     }
352
-  }
353 353
 
354
-  // Copied over from node_delete():
354
+    // Copied over from node_delete():
355 355
 
356
-  db_query('DELETE FROM {node} WHERE nid = %d', $node->nid);
357
-  db_query('DELETE FROM {node_revisions} WHERE nid = %d', $node->nid);
356
+    db_query('DELETE FROM {node} WHERE nid = %d', $node->nid);
357
+    db_query('DELETE FROM {node_revisions} WHERE nid = %d', $node->nid);
358 358
 
359
-  // Call the node-specific callback (if any):
360
-  node_invoke($node, 'delete');
361
-  node_invoke_nodeapi($node, 'delete');
359
+    // Call the node-specific callback (if any):
360
+    node_invoke($node, 'delete');
361
+    node_invoke_nodeapi($node, 'delete');
362 362
 
363
-  // Clear the cache so an anonymous poster can see the node being deleted.
364
-  cache_clear_all();
363
+    // Clear the cache so an anonymous poster can see the node being deleted.
364
+    cache_clear_all();
365 365
 
366
-  // Remove this node from the search index if needed.
367
-  if (function_exists('search_wipe')) {
366
+    // Remove this node from the search index if needed.
367
+    if (function_exists('search_wipe')) {
368 368
     search_wipe($node->nid, 'node');
369
-  }
370
-  watchdog('content', '@type: deleted %title.', array('@type' => $node->type, '%title' => $node->title));
371
-  drupal_set_message(t('@type %title has been deleted.', array('@type' => node_get_types('name', $node), '%title' => $node->title)));
369
+    }
370
+    watchdog('content', '@type: deleted %title.', array('@type' => $node->type, '%title' => $node->title));
371
+    drupal_set_message(t('@type %title has been deleted.', array('@type' => node_get_types('name', $node), '%title' => $node->title)));
372 372
 }
373 373
 
374 374
 /**
@@ -376,30 +376,30 @@  discard block
 block discarded – undo
376 376
  */
377 377
 function content_profile_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
378 378
 
379
-  if ($op == 'prepare' && is_content_profile($node) && !isset($node->nid) && $node->uid && !user_access('administer nodes') && arg(0) != 'admin') {
379
+    if ($op == 'prepare' && is_content_profile($node) && !isset($node->nid) && $node->uid && !user_access('administer nodes') && arg(0) != 'admin') {
380 380
     // Check if this nodetype already exists
381 381
     if ($nid = content_profile_profile_exists($node, $node->uid)) {
382
-      // This node already exists, redirect to edit page
383
-      drupal_goto('node/'. $nid .'/edit', 'destination=user/'. $node->uid);
382
+        // This node already exists, redirect to edit page
383
+        drupal_goto('node/'. $nid .'/edit', 'destination=user/'. $node->uid);
384 384
     }
385
-  }
386
-  elseif ($op == 'validate' && is_content_profile($node) && user_access('administer nodes')) {
385
+    }
386
+    elseif ($op == 'validate' && is_content_profile($node) && user_access('administer nodes')) {
387 387
     $form = $a3;
388 388
     // Only validate if the user-name changed or we add a new node
389 389
     if (!empty($node->nid) && $form['author']['name']['#default_value'] == $node->name) {
390
-      return;
390
+        return;
391 391
     }
392 392
     //check whether the selected user has already a profile
393 393
     $uid = db_result(db_query("SELECT uid FROM {users} WHERE name = '%s'", $node->name));
394 394
     if ($uid && content_profile_profile_exists($node, $uid)) {
395
-      form_set_error('name', t('This user already has a content profile of this type. You can only create one profile per user.'));
395
+        form_set_error('name', t('This user already has a content profile of this type. You can only create one profile per user.'));
396
+    }
396 397
     }
397
-  }
398
-  elseif ($op == 'prepare translation' && is_content_profile($node->translation_source)) {
398
+    elseif ($op == 'prepare translation' && is_content_profile($node->translation_source)) {
399 399
     // Make sure the translated profile belongs to the same user.
400 400
     $node->uid = $node->translation_source->uid;
401 401
     $node->name = $node->translation_source->name;
402
-  }
402
+    }
403 403
 }
404 404
 
405 405
 /**
@@ -412,11 +412,11 @@  discard block
 block discarded – undo
412 412
  * @return If a node exists, the node id, FALSE else.
413 413
  */
414 414
 function content_profile_profile_exists($node, $uid) {
415
-  $query = "SELECT n.nid AS nid FROM {node} n WHERE n.type = '%s' AND n.uid = %d ";
416
-  if (module_exists('translation') && translation_supported_type($node->type)) {
415
+    $query = "SELECT n.nid AS nid FROM {node} n WHERE n.type = '%s' AND n.uid = %d ";
416
+    if (module_exists('translation') && translation_supported_type($node->type)) {
417 417
     $query .= "AND n.language = '%s'";
418
-  }
419
-  return db_result(db_query($query, $node->type, $uid, $node->language));
418
+    }
419
+    return db_result(db_query($query, $node->type, $uid, $node->language));
420 420
 }
421 421
 
422 422
 /**
@@ -428,19 +428,19 @@  discard block
 block discarded – undo
428 428
  *   e.g. user_edit, register or weight.
429 429
  */
430 430
 function content_profile_get_settings($type, $return = 'all') {
431
-  $settings = variable_get('content_profile_'. $type, array());
432
-  $settings += content_profile_settings_info();
433
-  if ($return == 'all') {
431
+    $settings = variable_get('content_profile_'. $type, array());
432
+    $settings += content_profile_settings_info();
433
+    if ($return == 'all') {
434 434
     return $settings;
435
-  }
436
-  return $settings[$return];
435
+    }
436
+    return $settings[$return];
437 437
 }
438 438
 
439 439
 /**
440 440
  * Saves the content_profile settings of a content type.
441 441
  */
442 442
 function content_profile_set_settings($type, $settings) {
443
-  variable_set('content_profile_'. $type, $settings);
443
+    variable_set('content_profile_'. $type, $settings);
444 444
 }
445 445
 
446 446
 /**
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
  * and their default value.
449 449
  */
450 450
 function content_profile_settings_info() {
451
-  return module_invoke_all('content_profile_settings');
451
+    return module_invoke_all('content_profile_settings');
452 452
 }
453 453
 
454 454
 /**
@@ -457,13 +457,13 @@  discard block
 block discarded – undo
457 457
  * Defines content profile settings and their default value.
458 458
  */
459 459
 function content_profile_content_profile_settings() {
460
-  return array(
460
+    return array(
461 461
     'weight' => 0,
462 462
     'user_display' => 'full',
463 463
     'edit_link' => 0,
464 464
     'edit_tab' => 'sub',
465 465
     'add_link' => 1,
466
-  );
466
+    );
467 467
 }
468 468
 
469 469
 /**
@@ -479,17 +479,17 @@  discard block
 block discarded – undo
479 479
  *   Optional. If set, the cache is reset.
480 480
  */
481 481
 function content_profile_load($type, $uid, $lang = '', $reset = NULL) {
482
-  static $cache = array();
482
+    static $cache = array();
483 483
 
484
-  if (!isset($cache[$type][$uid][$lang]) || $reset) {
484
+    if (!isset($cache[$type][$uid][$lang]) || $reset) {
485 485
     $cache[$type][$uid][$lang] = FALSE;
486 486
     $params = array('type' => $type, 'uid' => $uid);
487 487
     if ($node = node_load($lang ? $params + array('language' => $lang) : $params, NULL, $reset)) {
488
-      $cache[$type][$uid][$lang] = $node->nid;
488
+        $cache[$type][$uid][$lang] = $node->nid;
489 489
     }
490 490
     return $node;
491
-  }
492
-  return !empty($cache[$type][$uid][$lang]) ? node_load($cache[$type][$uid][$lang]) : FALSE;
491
+    }
492
+    return !empty($cache[$type][$uid][$lang]) ? node_load($cache[$type][$uid][$lang]) : FALSE;
493 493
 }
494 494
 
495 495
 /**
@@ -498,19 +498,19 @@  discard block
 block discarded – undo
498 498
  * Show node submission guidelines for content profile node forms.
499 499
  */
500 500
 function content_profile_help($path, $arg) {
501
-  if (preg_match('/user\/\%\/(profile|edit)\/(.*)/', $path, $matches)) {
501
+    if (preg_match('/user\/\%\/(profile|edit)\/(.*)/', $path, $matches)) {
502 502
     foreach (content_profile_get_types('names') as $type => $typename) {
503
-      if ($type == $matches[2]) {
503
+        if ($type == $matches[2]) {
504 504
         $node = content_profile_load($type, $arg[1]);
505 505
         if ($node) {
506
-          return node_help('node/%/edit', array(1 => $node->nid));
506
+            return node_help('node/%/edit', array(1 => $node->nid));
507 507
         }
508 508
         else {
509
-          return node_help('node/add/'. $type, array('node', 'add', $type));
509
+            return node_help('node/add/'. $type, array('node', 'add', $type));
510 510
         }
511
-      }
511
+        }
512
+    }
512 513
     }
513
-  }
514 514
 }
515 515
 
516 516
 /**
@@ -518,14 +518,14 @@  discard block
 block discarded – undo
518 518
  * that shows all content_profiles as configured by the admin.
519 519
  */
520 520
 function content_profile_show_profiles($uid) {
521
-  global $user;
521
+    global $user;
522 522
 
523
-  $content = array();
524
-  foreach (content_profile_get_types('names') as $type => $type_name) {
523
+    $content = array();
524
+    foreach (content_profile_get_types('names') as $type => $type_name) {
525 525
     $node = content_profile_load($type, $uid);
526 526
 
527 527
     if (($style = content_profile_get_settings($type, 'user_display')) && $node && node_access('view', $node)) {
528
-      $content['content_profile_'. $type] = array(
528
+        $content['content_profile_'. $type] = array(
529 529
         '#theme' => ($style == 'link') ? 'content_profile_display_link' : 'content_profile_display_view',
530 530
         '#edit_link' => content_profile_get_settings($type, 'edit_link'),
531 531
         '#uid' => $uid,
@@ -533,59 +533,59 @@  discard block
 block discarded – undo
533 533
         '#content_type' => $type,
534 534
         '#weight' => content_profile_get_settings($type, 'weight'),
535 535
         '#suffix' => '<br />',
536
-      );
536
+        );
537 537
 
538
-      // Working around the bug described at http://drupal.org/node/302873
539
-      module_load_include('inc', 'content_profile', 'content_profile.theme');
538
+        // Working around the bug described at http://drupal.org/node/302873
539
+        module_load_include('inc', 'content_profile', 'content_profile.theme');
540 540
     }
541 541
     elseif (user_access('create '. $type .' content') && content_profile_get_settings($type, 'add_link') && !$node && ($uid == $user->uid || user_access('administer nodes'))) {
542
-      $content['content_profile_'. $type] = array(
542
+        $content['content_profile_'. $type] = array(
543 543
         '#admin' => $uid != $user->uid,
544 544
         '#theme' => 'content_profile_display_add_link',
545 545
         '#uid' => $uid,
546 546
         '#content_type' => $type,
547 547
         '#weight' => content_profile_get_settings($type, 'weight'),
548 548
         '#suffix' => '<br />',
549
-      );
549
+        );
550
+    }
550 551
     }
551
-  }
552
-  if ($content) {
552
+    if ($content) {
553 553
     $content['#prefix'] = '<p id="content-profile-view">';
554 554
     $content['#suffix'] = '</p>';
555
-  }
556
-  return $content;
555
+    }
556
+    return $content;
557 557
 }
558 558
 
559 559
 /**
560 560
  * Implementation of hook_theme().
561 561
  */
562 562
 function content_profile_theme() {
563
-  $return = array(
563
+    $return = array(
564 564
     'content_profile_display_view' => array(
565
-      'template'  => 'content_profile-display-view',
566
-      'arguments' => array('element' => NULL),
567
-      'file' => 'content_profile.theme.inc',
565
+        'template'  => 'content_profile-display-view',
566
+        'arguments' => array('element' => NULL),
567
+        'file' => 'content_profile.theme.inc',
568 568
     ),
569 569
     'content_profile_display_add_link' => array(
570
-      'file' => 'content_profile.theme.inc',
570
+        'file' => 'content_profile.theme.inc',
571 571
     ),
572 572
     'content_profile_display_link' => array(
573
-      'file' => 'content_profile.theme.inc',
573
+        'file' => 'content_profile.theme.inc',
574 574
     ),
575 575
     'content_profile_display_tab_view' => array(
576
-      'file' => 'content_profile.theme.inc',
576
+        'file' => 'content_profile.theme.inc',
577 577
     ),
578 578
     'content_profile_display_tab_edit' => array(
579
-      'file' => 'content_profile.theme.inc',
579
+        'file' => 'content_profile.theme.inc',
580 580
     ),
581
-  );
582
-  if (module_exists('pageroute')) {
581
+    );
582
+    if (module_exists('pageroute')) {
583 583
     $return['content_profile_pageroute_empty']  = array(
584
-      'arguments' => array('type_name' => NULL),
585
-    	'file' => 'content_profile.pageroute.inc',
584
+        'arguments' => array('type_name' => NULL),
585
+        'file' => 'content_profile.pageroute.inc',
586 586
     );
587
-  }
588
-  return $return;
587
+    }
588
+    return $return;
589 589
 }
590 590
 
591 591
 /**
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
  * $conf['content_profile_extra_templates'] in settings.php.
595 595
  */
596 596
 function content_profile_theme_registry_alter(&$items) {
597
-  $templates = array_merge(array(
597
+    $templates = array_merge(array(
598 598
     'author_pane',
599 599
     'comment',
600 600
     'node',
@@ -603,47 +603,47 @@  discard block
 block discarded – undo
603 603
     'username',
604 604
     'user_profile',
605 605
     'user_signature',
606
-  ), variable_get('content_profile_extra_templates', array()));
606
+    ), variable_get('content_profile_extra_templates', array()));
607 607
 
608
-  foreach ($templates as $key) {
608
+    foreach ($templates as $key) {
609 609
     if (isset($items[$key])) {
610
-      $items[$key] += array('preprocess functions' => array());
611
-      $items[$key]['preprocess functions'][] = 'content_profile_template_preprocess';
610
+        $items[$key] += array('preprocess functions' => array());
611
+        $items[$key]['preprocess functions'][] = 'content_profile_template_preprocess';
612
+    }
612 613
     }
613
-  }
614 614
 }
615 615
 
616 616
 /**
617 617
  * Adds $content_profile variable if we can find a $uid.
618 618
  */
619 619
 function content_profile_template_preprocess(&$variables, $hook) {
620
-  // Search the uid
621
-  foreach (array('account_id', 'uid', 'account', 'node', 'comment', 'user') as $name) {
620
+    // Search the uid
621
+    foreach (array('account_id', 'uid', 'account', 'node', 'comment', 'user') as $name) {
622 622
     if (isset($variables[$name])) {
623
-      $uid = is_object($variables[$name]) ? $variables[$name]->uid : $variables[$name];
624
-      $variables['content_profile'] = new content_profile_theme_variables($uid);
625
-      break;
623
+        $uid = is_object($variables[$name]) ? $variables[$name]->uid : $variables[$name];
624
+        $variables['content_profile'] = new content_profile_theme_variables($uid);
625
+        break;
626
+    }
626 627
     }
627
-  }
628 628
 }
629 629
 
630 630
 /**
631 631
  * Implementation of hook_simpletest().
632 632
  */
633 633
 function content_profile_simpletest() {
634
-  // Scan through content_profile/tests directory for any .test files to tell SimpleTest module.
635
-  $tests = file_scan_directory(drupal_get_path('module', 'content_profile') .'/tests', '\.test');
636
-  return array_keys($tests);
634
+    // Scan through content_profile/tests directory for any .test files to tell SimpleTest module.
635
+    $tests = file_scan_directory(drupal_get_path('module', 'content_profile') .'/tests', '\.test');
636
+    return array_keys($tests);
637 637
 }
638 638
 
639 639
 /**
640 640
  * Implementation of hook_pageroute_info() for Pageroute integration.
641 641
  */
642 642
 function content_profile_pageroute_info() {
643
-  return array(
643
+    return array(
644 644
     'content_profile' => array(
645
-      'viewprofile' => 'content_profile.pageroute',
646
-      'editprofile' => 'content_profile.pageroute',
645
+        'viewprofile' => 'content_profile.pageroute',
646
+        'editprofile' => 'content_profile.pageroute',
647 647
     )
648
-  );
648
+    );
649 649
 }
Please login to merge, or discard this patch.
Switch Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -234,21 +234,21 @@  discard block
 block discarded – undo
234 234
  */
235 235
 function content_profile_node_type($op, $info) {
236 236
   switch ($op) {
237
-    case 'delete':
238
-      variable_del('content_profile_use_'. $info->type);
239
-      variable_del('content_profile_'. $info->type);
240
-      break;
241
-    case 'update':
242
-      if (!empty($info->old_type) && $info->old_type != $info->type) {
243
-        if (is_content_profile($info->old_type)) {
244
-          $settings = variable_get('content_profile_'. $info->old_type, array());
245
-          variable_del('content_profile_use_'. $info->old_type);
246
-          variable_del('content_profile_'. $info->old_type);
247
-          variable_set('content_profile_use_'. $info->type, 1);
248
-          variable_set('content_profile_'. $info->type, $settings);
249
-        }
237
+  case 'delete':
238
+    variable_del('content_profile_use_'. $info->type);
239
+    variable_del('content_profile_'. $info->type);
240
+    break;
241
+  case 'update':
242
+    if (!empty($info->old_type) && $info->old_type != $info->type) {
243
+      if (is_content_profile($info->old_type)) {
244
+        $settings = variable_get('content_profile_'. $info->old_type, array());
245
+        variable_del('content_profile_use_'. $info->old_type);
246
+        variable_del('content_profile_'. $info->old_type);
247
+        variable_set('content_profile_use_'. $info->type, 1);
248
+        variable_set('content_profile_'. $info->type, $settings);
250 249
       }
251
-      break;
250
+    }
251
+    break;
252 252
   }
253 253
 }
254 254
 
@@ -292,33 +292,33 @@  discard block
 block discarded – undo
292 292
   global $user;
293 293
 
294 294
   switch ($op) {
295
-    case 'categories':
296
-      $data = array();
297
-      foreach (content_profile_get_types('names', 'edit_tab', 'sub') as $type => $type_name) {
298
-        $data[] = array(
299
-          'name' => $type,
300
-          'title' => drupal_ucfirst($type_name),
301
-          'weight' => content_profile_get_settings($type, 'weight') + 1,
302
-        );
303
-      }
304
-      return $data;
295
+  case 'categories':
296
+    $data = array();
297
+    foreach (content_profile_get_types('names', 'edit_tab', 'sub') as $type => $type_name) {
298
+      $data[] = array(
299
+        'name' => $type,
300
+        'title' => drupal_ucfirst($type_name),
301
+        'weight' => content_profile_get_settings($type, 'weight') + 1,
302
+      );
303
+    }
304
+    return $data;
305 305
 
306
-    case 'view':
307
-      $account->content['content_profile'] = content_profile_show_profiles($account->uid);
308
-      break;
306
+  case 'view':
307
+    $account->content['content_profile'] = content_profile_show_profiles($account->uid);
308
+    break;
309 309
 
310
-    case 'delete':
311
-      // Retrieve all profile nodes (in any language) for this user by issueing an SQL query.
312
-      if ($types = content_profile_get_types()) {
313
-        $condition = array_fill(0, count($types), "type = '%s'");
314
-        $arguments = array_merge(array_keys($types), array($account->uid));
310
+  case 'delete':
311
+    // Retrieve all profile nodes (in any language) for this user by issueing an SQL query.
312
+    if ($types = content_profile_get_types()) {
313
+      $condition = array_fill(0, count($types), "type = '%s'");
314
+      $arguments = array_merge(array_keys($types), array($account->uid));
315 315
 
316
-        $result = db_query("SELECT * FROM {node} WHERE (". implode(' OR ', $condition) .") AND uid = %d", $arguments);
317
-        while ($node = db_fetch_object($result)) {
318
-          _content_profile_node_delete($node);
319
-        }
316
+      $result = db_query("SELECT * FROM {node} WHERE (". implode(' OR ', $condition) .") AND uid = %d", $arguments);
317
+      while ($node = db_fetch_object($result)) {
318
+        _content_profile_node_delete($node);
320 319
       }
321
-      break;
320
+    }
321
+    break;
322 322
   }
323 323
 }
324 324
 
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  */
20 20
 function content_profile_ctools_plugin_directory($module, $plugin) {
21 21
   if ($module == 'ctools' && $plugin == 'relationships') {
22
-    return 'panels/' . $plugin;
22
+    return 'panels/'.$plugin;
23 23
   }
24 24
 }
25 25
 
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
 
32 32
   //Register a path for each content profile type
33 33
   foreach (content_profile_get_types('names') as $type => $typename) {
34
-    $items['admin/content/node-type/'. str_replace('_', '-', $type) .'/edit'] = array(
34
+    $items['admin/content/node-type/'.str_replace('_', '-', $type).'/edit'] = array(
35 35
       'title' => 'Edit',
36 36
       'type' => MENU_DEFAULT_LOCAL_TASK,
37 37
     );
38
-    $items['admin/content/node-type/'. str_replace('_', '-', $type) .'/profile'] = array(
38
+    $items['admin/content/node-type/'.str_replace('_', '-', $type).'/profile'] = array(
39 39
       'title' => 'Content profile',
40 40
       'description' => 'Configure the display and management of this content profile.',
41 41
       'page callback' => 'drupal_get_form',
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     );
48 48
   }
49 49
   foreach (content_profile_get_types('names') as $type => $type_name) {
50
-    $items['user/%user/profile/'. $type] = array(
50
+    $items['user/%user/profile/'.$type] = array(
51 51
       'title callback' => 'check_plain',
52 52
       'title' => drupal_ucfirst($type_name),
53 53
       'page callback' => 'content_profile_page_edit',
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
  */
70 70
 function content_profile_menu_alter(&$items) {
71 71
   foreach (content_profile_get_types('names', 'edit_tab', 'sub') as $type => $type_name) {
72
-    if (!empty($items['user/%user_category/edit/'. $type])) {
73
-      $item = &$items['user/%user_category/edit/'. $type];
72
+    if (!empty($items['user/%user_category/edit/'.$type])) {
73
+      $item = &$items['user/%user_category/edit/'.$type];
74 74
       $item = array(
75 75
         'page callback' => 'content_profile_page_edit',
76 76
         'page arguments' => array($type, 1),
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
   // Else user may view the page when they are going to create their own profile
92 92
   // or have permission to create it for others.
93 93
   global $user;
94
-  if ($user->uid == $account->uid || user_access('administer nodes') ){
94
+  if ($user->uid == $account->uid || user_access('administer nodes')) {
95 95
     return node_access('create', $type);
96 96
   }
97 97
   return FALSE;
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
   if (!$node) {
107 107
     $node = array('uid' => $account->uid, 'name' => (isset($account->name) ? $account->name : ''), 'type' => $type, 'language' => '');
108 108
   }
109
-  return drupal_get_form($type .'_node_form', $node);
109
+  return drupal_get_form($type.'_node_form', $node);
110 110
 }
111 111
 
112 112
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 function content_profile_views_api() {
117 117
   return array(
118 118
     'api' => 2,
119
-    'path' => drupal_get_path('module', 'content_profile') .'/views',
119
+    'path' => drupal_get_path('module', 'content_profile').'/views',
120 120
   );
121 121
 }
122 122
 
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
   if (is_object($type)) {
202 202
     $type = $type->type;
203 203
   }
204
-  return variable_get('content_profile_use_'. $type, FALSE);
204
+  return variable_get('content_profile_use_'.$type, FALSE);
205 205
 }
206 206
 
207 207
 /**
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
  * @param $value
218 218
  *   The value to compare the given setting too.
219 219
  */
220
-function content_profile_get_types($op = 'types', $setting = NULL , $value = TRUE) {
220
+function content_profile_get_types($op = 'types', $setting = NULL, $value = TRUE) {
221 221
   $types = array();
222 222
 
223 223
   foreach (node_get_types($op) as $type => $info) {
@@ -235,17 +235,17 @@  discard block
 block discarded – undo
235 235
 function content_profile_node_type($op, $info) {
236 236
   switch ($op) {
237 237
     case 'delete':
238
-      variable_del('content_profile_use_'. $info->type);
239
-      variable_del('content_profile_'. $info->type);
238
+      variable_del('content_profile_use_'.$info->type);
239
+      variable_del('content_profile_'.$info->type);
240 240
       break;
241 241
     case 'update':
242 242
       if (!empty($info->old_type) && $info->old_type != $info->type) {
243 243
         if (is_content_profile($info->old_type)) {
244
-          $settings = variable_get('content_profile_'. $info->old_type, array());
245
-          variable_del('content_profile_use_'. $info->old_type);
246
-          variable_del('content_profile_'. $info->old_type);
247
-          variable_set('content_profile_use_'. $info->type, 1);
248
-          variable_set('content_profile_'. $info->type, $settings);
244
+          $settings = variable_get('content_profile_'.$info->old_type, array());
245
+          variable_del('content_profile_use_'.$info->old_type);
246
+          variable_del('content_profile_'.$info->old_type);
247
+          variable_set('content_profile_use_'.$info->type, 1);
248
+          variable_set('content_profile_'.$info->type, $settings);
249 249
         }
250 250
       }
251 251
       break;
@@ -268,15 +268,15 @@  discard block
 block discarded – undo
268 268
     $form['content_profile']['content_profile_use'] = array(
269 269
       '#type' => 'checkbox',
270 270
       '#title' => t('Use this content type as a content profile for users'),
271
-      '#default_value' => variable_get('content_profile_use_'. $form['#node_type']->type, FALSE),
271
+      '#default_value' => variable_get('content_profile_use_'.$form['#node_type']->type, FALSE),
272 272
     );
273 273
   }
274
-  elseif (isset($form['#node']) && $form['#node']->type .'_node_form' == $form_id && is_content_profile($form['#node'])) {
274
+  elseif (isset($form['#node']) && $form['#node']->type.'_node_form' == $form_id && is_content_profile($form['#node'])) {
275 275
     // Customize the redirect target and buttons of our own node forms.
276 276
     if (arg(0) == 'user' && is_numeric(arg(1)) && arg(2) == 'edit' || arg(2) == 'profile') {
277 277
       $form['buttons']['preview']['#access'] = FALSE;
278 278
       $form['buttons']['delete']['#access'] = FALSE;
279
-      $form['#redirect'] = arg(2) == 'profile' ? 'user/'. $form['#node']->uid : $_GET['q'];
279
+      $form['#redirect'] = arg(2) == 'profile' ? 'user/'.$form['#node']->uid : $_GET['q'];
280 280
     }
281 281
     // Set the author value - note that this works only for admins.
282 282
     if (!empty($_GET['uid']) && ($uid = intval($_GET['uid'])) && ($user = user_load($uid))) {
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
         $condition = array_fill(0, count($types), "type = '%s'");
314 314
         $arguments = array_merge(array_keys($types), array($account->uid));
315 315
 
316
-        $result = db_query("SELECT * FROM {node} WHERE (". implode(' OR ', $condition) .") AND uid = %d", $arguments);
316
+        $result = db_query("SELECT * FROM {node} WHERE (".implode(' OR ', $condition).") AND uid = %d", $arguments);
317 317
         while ($node = db_fetch_object($result)) {
318 318
           _content_profile_node_delete($node);
319 319
         }
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
     // Check if this nodetype already exists
381 381
     if ($nid = content_profile_profile_exists($node, $node->uid)) {
382 382
       // This node already exists, redirect to edit page
383
-      drupal_goto('node/'. $nid .'/edit', 'destination=user/'. $node->uid);
383
+      drupal_goto('node/'.$nid.'/edit', 'destination=user/'.$node->uid);
384 384
     }
385 385
   }
386 386
   elseif ($op == 'validate' && is_content_profile($node) && user_access('administer nodes')) {
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
  *   e.g. user_edit, register or weight.
429 429
  */
430 430
 function content_profile_get_settings($type, $return = 'all') {
431
-  $settings = variable_get('content_profile_'. $type, array());
431
+  $settings = variable_get('content_profile_'.$type, array());
432 432
   $settings += content_profile_settings_info();
433 433
   if ($return == 'all') {
434 434
     return $settings;
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
  * Saves the content_profile settings of a content type.
441 441
  */
442 442
 function content_profile_set_settings($type, $settings) {
443
-  variable_set('content_profile_'. $type, $settings);
443
+  variable_set('content_profile_'.$type, $settings);
444 444
 }
445 445
 
446 446
 /**
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
           return node_help('node/%/edit', array(1 => $node->nid));
507 507
         }
508 508
         else {
509
-          return node_help('node/add/'. $type, array('node', 'add', $type));
509
+          return node_help('node/add/'.$type, array('node', 'add', $type));
510 510
         }
511 511
       }
512 512
     }
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
     $node = content_profile_load($type, $uid);
526 526
 
527 527
     if (($style = content_profile_get_settings($type, 'user_display')) && $node && node_access('view', $node)) {
528
-      $content['content_profile_'. $type] = array(
528
+      $content['content_profile_'.$type] = array(
529 529
         '#theme' => ($style == 'link') ? 'content_profile_display_link' : 'content_profile_display_view',
530 530
         '#edit_link' => content_profile_get_settings($type, 'edit_link'),
531 531
         '#uid' => $uid,
@@ -538,8 +538,8 @@  discard block
 block discarded – undo
538 538
       // Working around the bug described at http://drupal.org/node/302873
539 539
       module_load_include('inc', 'content_profile', 'content_profile.theme');
540 540
     }
541
-    elseif (user_access('create '. $type .' content') && content_profile_get_settings($type, 'add_link') && !$node && ($uid == $user->uid || user_access('administer nodes'))) {
542
-      $content['content_profile_'. $type] = array(
541
+    elseif (user_access('create '.$type.' content') && content_profile_get_settings($type, 'add_link') && !$node && ($uid == $user->uid || user_access('administer nodes'))) {
542
+      $content['content_profile_'.$type] = array(
543 543
         '#admin' => $uid != $user->uid,
544 544
         '#theme' => 'content_profile_display_add_link',
545 545
         '#uid' => $uid,
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
     ),
581 581
   );
582 582
   if (module_exists('pageroute')) {
583
-    $return['content_profile_pageroute_empty']  = array(
583
+    $return['content_profile_pageroute_empty'] = array(
584 584
       'arguments' => array('type_name' => NULL),
585 585
     	'file' => 'content_profile.pageroute.inc',
586 586
     );
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
  */
633 633
 function content_profile_simpletest() {
634 634
   // Scan through content_profile/tests directory for any .test files to tell SimpleTest module.
635
-  $tests = file_scan_directory(drupal_get_path('module', 'content_profile') .'/tests', '\.test');
635
+  $tests = file_scan_directory(drupal_get_path('module', 'content_profile').'/tests', '\.test');
636 636
   return array_keys($tests);
637 637
 }
638 638
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -11 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
   // Else user may view the page when they are going to create their own profile
92 92
   // or have permission to create it for others.
93 93
   global $user;
94
-  if ($user->uid == $account->uid || user_access('administer nodes') ){
94
+  if ($user->uid == $account->uid || user_access('administer nodes') ) {
95 95
     return node_access('create', $type);
96 96
   }
97 97
   return FALSE;
@@ -270,8 +270,7 @@  discard block
 block discarded – undo
270 270
       '#title' => t('Use this content type as a content profile for users'),
271 271
       '#default_value' => variable_get('content_profile_use_'. $form['#node_type']->type, FALSE),
272 272
     );
273
-  }
274
-  elseif (isset($form['#node']) && $form['#node']->type .'_node_form' == $form_id && is_content_profile($form['#node'])) {
273
+  } elseif (isset($form['#node']) && $form['#node']->type .'_node_form' == $form_id && is_content_profile($form['#node'])) {
275 274
     // Customize the redirect target and buttons of our own node forms.
276 275
     if (arg(0) == 'user' && is_numeric(arg(1)) && arg(2) == 'edit' || arg(2) == 'profile') {
277 276
       $form['buttons']['preview']['#access'] = FALSE;
@@ -382,8 +381,7 @@  discard block
 block discarded – undo
382 381
       // This node already exists, redirect to edit page
383 382
       drupal_goto('node/'. $nid .'/edit', 'destination=user/'. $node->uid);
384 383
     }
385
-  }
386
-  elseif ($op == 'validate' && is_content_profile($node) && user_access('administer nodes')) {
384
+  } elseif ($op == 'validate' && is_content_profile($node) && user_access('administer nodes')) {
387 385
     $form = $a3;
388 386
     // Only validate if the user-name changed or we add a new node
389 387
     if (!empty($node->nid) && $form['author']['name']['#default_value'] == $node->name) {
@@ -394,8 +392,7 @@  discard block
 block discarded – undo
394 392
     if ($uid && content_profile_profile_exists($node, $uid)) {
395 393
       form_set_error('name', t('This user already has a content profile of this type. You can only create one profile per user.'));
396 394
     }
397
-  }
398
-  elseif ($op == 'prepare translation' && is_content_profile($node->translation_source)) {
395
+  } elseif ($op == 'prepare translation' && is_content_profile($node->translation_source)) {
399 396
     // Make sure the translated profile belongs to the same user.
400 397
     $node->uid = $node->translation_source->uid;
401 398
     $node->name = $node->translation_source->name;
@@ -504,8 +501,7 @@  discard block
 block discarded – undo
504 501
         $node = content_profile_load($type, $arg[1]);
505 502
         if ($node) {
506 503
           return node_help('node/%/edit', array(1 => $node->nid));
507
-        }
508
-        else {
504
+        } else {
509 505
           return node_help('node/add/'. $type, array('node', 'add', $type));
510 506
         }
511 507
       }
@@ -537,8 +533,7 @@  discard block
 block discarded – undo
537 533
 
538 534
       // Working around the bug described at http://drupal.org/node/302873
539 535
       module_load_include('inc', 'content_profile', 'content_profile.theme');
540
-    }
541
-    elseif (user_access('create '. $type .' content') && content_profile_get_settings($type, 'add_link') && !$node && ($uid == $user->uid || user_access('administer nodes'))) {
536
+    } elseif (user_access('create '. $type .' content') && content_profile_get_settings($type, 'add_link') && !$node && ($uid == $user->uid || user_access('administer nodes'))) {
542 537
       $content['content_profile_'. $type] = array(
543 538
         '#admin' => $uid != $user->uid,
544 539
         '#theme' => 'content_profile_display_add_link',
Please login to merge, or discard this patch.
Upper-Lower-Casing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
   if ($user->uid == $account->uid || user_access('administer nodes') ){
95 95
     return node_access('create', $type);
96 96
   }
97
-  return FALSE;
97
+  return false;
98 98
 }
99 99
 
100 100
 /**
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
     '#type' => 'fieldset',
139 139
     '#title' => t('Display settings'),
140 140
     '#description' => t('Customize the display of this content profile.'),
141
-    '#collapsible' => TRUE,
141
+    '#collapsible' => true,
142 142
   );
143 143
   $form['display']['user_display'] = array(
144 144
     '#type' => 'radios',
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
   if (is_object($type)) {
202 202
     $type = $type->type;
203 203
   }
204
-  return variable_get('content_profile_use_'. $type, FALSE);
204
+  return variable_get('content_profile_use_'. $type, false);
205 205
 }
206 206
 
207 207
 /**
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
  * @param $value
218 218
  *   The value to compare the given setting too.
219 219
  */
220
-function content_profile_get_types($op = 'types', $setting = NULL , $value = TRUE) {
220
+function content_profile_get_types($op = 'types', $setting = null , $value = true) {
221 221
   $types = array();
222 222
 
223 223
   foreach (node_get_types($op) as $type => $info) {
@@ -261,21 +261,21 @@  discard block
 block discarded – undo
261 261
       '#type' => 'fieldset',
262 262
       '#title' => t('Content Profile'),
263 263
       '#group' => 'additional_settings',
264
-      '#collapsible' => TRUE,
265
-      '#collapsed' => TRUE,
264
+      '#collapsible' => true,
265
+      '#collapsed' => true,
266 266
       '#weight' => 32,
267 267
     );
268 268
     $form['content_profile']['content_profile_use'] = array(
269 269
       '#type' => 'checkbox',
270 270
       '#title' => t('Use this content type as a content profile for users'),
271
-      '#default_value' => variable_get('content_profile_use_'. $form['#node_type']->type, FALSE),
271
+      '#default_value' => variable_get('content_profile_use_'. $form['#node_type']->type, false),
272 272
     );
273 273
   }
274 274
   elseif (isset($form['#node']) && $form['#node']->type .'_node_form' == $form_id && is_content_profile($form['#node'])) {
275 275
     // Customize the redirect target and buttons of our own node forms.
276 276
     if (arg(0) == 'user' && is_numeric(arg(1)) && arg(2) == 'edit' || arg(2) == 'profile') {
277
-      $form['buttons']['preview']['#access'] = FALSE;
278
-      $form['buttons']['delete']['#access'] = FALSE;
277
+      $form['buttons']['preview']['#access'] = false;
278
+      $form['buttons']['delete']['#access'] = false;
279 279
       $form['#redirect'] = arg(2) == 'profile' ? 'user/'. $form['#node']->uid : $_GET['q'];
280 280
     }
281 281
     // Set the author value - note that this works only for admins.
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 /**
289 289
  * Implementation of hook_user().
290 290
  */
291
-function content_profile_user($op, &$edit, &$account, $category = NULL) {
291
+function content_profile_user($op, &$edit, &$account, $category = null) {
292 292
   global $user;
293 293
 
294 294
   switch ($op) {
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 /**
375 375
  * Implementation of hook_nodeapi().
376 376
  */
377
-function content_profile_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
377
+function content_profile_nodeapi(&$node, $op, $a3 = null, $a4 = null) {
378 378
 
379 379
   if ($op == 'prepare' && is_content_profile($node) && !isset($node->nid) && $node->uid && !user_access('administer nodes') && arg(0) != 'admin') {
380 380
     // Check if this nodetype already exists
@@ -478,18 +478,18 @@  discard block
 block discarded – undo
478 478
  * @param $reset
479 479
  *   Optional. If set, the cache is reset.
480 480
  */
481
-function content_profile_load($type, $uid, $lang = '', $reset = NULL) {
481
+function content_profile_load($type, $uid, $lang = '', $reset = null) {
482 482
   static $cache = array();
483 483
 
484 484
   if (!isset($cache[$type][$uid][$lang]) || $reset) {
485
-    $cache[$type][$uid][$lang] = FALSE;
485
+    $cache[$type][$uid][$lang] = false;
486 486
     $params = array('type' => $type, 'uid' => $uid);
487
-    if ($node = node_load($lang ? $params + array('language' => $lang) : $params, NULL, $reset)) {
487
+    if ($node = node_load($lang ? $params + array('language' => $lang) : $params, null, $reset)) {
488 488
       $cache[$type][$uid][$lang] = $node->nid;
489 489
     }
490 490
     return $node;
491 491
   }
492
-  return !empty($cache[$type][$uid][$lang]) ? node_load($cache[$type][$uid][$lang]) : FALSE;
492
+  return !empty($cache[$type][$uid][$lang]) ? node_load($cache[$type][$uid][$lang]) : false;
493 493
 }
494 494
 
495 495
 /**
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
   $return = array(
564 564
     'content_profile_display_view' => array(
565 565
       'template'  => 'content_profile-display-view',
566
-      'arguments' => array('element' => NULL),
566
+      'arguments' => array('element' => null),
567 567
       'file' => 'content_profile.theme.inc',
568 568
     ),
569 569
     'content_profile_display_add_link' => array(
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
   );
582 582
   if (module_exists('pageroute')) {
583 583
     $return['content_profile_pageroute_empty']  = array(
584
-      'arguments' => array('type_name' => NULL),
584
+      'arguments' => array('type_name' => null),
585 585
     	'file' => 'content_profile.pageroute.inc',
586 586
     );
587 587
   }
Please login to merge, or discard this patch.
sites/default/boinc/modules/contrib/forum_access/forum_access.admin.inc 5 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -10,6 +10,7 @@  discard block
 block discarded – undo
10 10
 
11 11
 /**
12 12
  * Rewrite the forum administration page with our new access rules.
13
+ * @param boolean $is_container
13 14
  */
14 15
 function _forum_access_forum_form(&$form, &$form_state, $is_container) {
15 16
   $tid = (isset($form['tid']['#value']) ? $form['tid']['#value'] : NULL);
@@ -663,6 +664,8 @@  discard block
 block discarded – undo
663 664
  * This is a multistep operation : we go through all nodes by packs of 20.
664 665
  * The batch processing engine interrupts processing and sends progress
665 666
  * feedback after 1 second execution time.
667
+ * @param integer $limit
668
+ * @param integer $count
666 669
  */
667 670
 function _forum_access_update_batch_operation($tid, $limit, $count, &$context) {
668 671
   if (empty($context['sandbox'])) {
@@ -693,6 +696,7 @@  discard block
 block discarded – undo
693 696
 
694 697
 /**
695 698
  * Post-processing for forum_access_form_submit().
699
+ * @param boolean $success
696 700
  */
697 701
 function _forum_access_update_batch_finished($success, $results, $operations) {
698 702
   if ($success) {
Please login to merge, or discard this patch.
Indentation   +470 added lines, -470 removed lines patch added patch discarded remove patch
@@ -12,33 +12,33 @@  discard block
 block discarded – undo
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
 block discarded – undo
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 &mdash; 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 &mdash; 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&mdash;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&mdash;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&nbsp;Access&nbsp;6.x-1.x-dev', 'http://drupal.org/node/96795', array('html' => TRUE)),
328
-      '!ACL-dev'             => l('ACL&nbsp;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&nbsp;Access&nbsp;6.x-1.x-dev', 'http://drupal.org/node/96795', array('html' => TRUE)),
328
+        '!ACL-dev'             => l('ACL&nbsp;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
 block discarded – undo
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 &mdash; 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 &mdash; 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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 function _forum_access_forum_form(&$form, &$form_state, $is_container) {
15 15
   $tid = (isset($form['tid']['#value']) ? $form['tid']['#value'] : NULL);
16 16
   if (isset($tid) && !forum_access_access($tid, 'view', NULL, FALSE)) {
17
-    drupal_access_denied();  // Deny access if the user doesn't have View access.
17
+    drupal_access_denied(); // Deny access if the user doesn't have View access.
18 18
     module_invoke_all('exit');
19 19
     exit;
20 20
   }
@@ -39,18 +39,18 @@  discard block
 block discarded – undo
39 39
 
40 40
   $tr = 't';
41 41
   $variables = array(
42
-    '!access_content'                 => '<em>'. l($tr('access content'), 'admin/user/permissions', array('fragment' => 'module-node', 'html' => TRUE)) .'</em>',
43
-    '!access_comments'                => '<em>'. l($tr('access comments'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => TRUE)) .'</em>',
44
-    '!create_forum_topics'            => '<em>'. l($tr('create forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)) .'</em>',
45
-    '!post_comments'                  => '<em>'. l($tr('post comments'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => TRUE)) .'</em>',
46
-    '!post_comments_without_approval' => '<em>'. l($tr('post comments without approval'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => TRUE)) .'</em>',
47
-    '!edit_own_forum_topics'          => '<em>'. l($tr('edit own forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)) .'</em>',
48
-    '!edit_any_forum_topics'          => '<em>'. l($tr('edit any forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)) .'</em>',
49
-    '!delete_own_forum_topics'        => '<em>'. l($tr('delete own forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)) .'</em>',
50
-    '!delete_any_forum_topics'        => '<em>'. l($tr('delete any forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)) .'</em>',
51
-    '!administer_comments'            => '<em>'. l($tr('administer comments'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => TRUE)) .'</em>',
52
-    '!administer_forums'              => '<em>'. l($tr('administer forums'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)) .'</em>',
53
-    '!administer_nodes'               => '<em>'. l($tr('administer nodes'), 'admin/user/permissions', array('fragment' => 'module-node', 'html' => TRUE)) .'</em>',
42
+    '!access_content'                 => '<em>'.l($tr('access content'), 'admin/user/permissions', array('fragment' => 'module-node', 'html' => TRUE)).'</em>',
43
+    '!access_comments'                => '<em>'.l($tr('access comments'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => TRUE)).'</em>',
44
+    '!create_forum_topics'            => '<em>'.l($tr('create forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)).'</em>',
45
+    '!post_comments'                  => '<em>'.l($tr('post comments'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => TRUE)).'</em>',
46
+    '!post_comments_without_approval' => '<em>'.l($tr('post comments without approval'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => TRUE)).'</em>',
47
+    '!edit_own_forum_topics'          => '<em>'.l($tr('edit own forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)).'</em>',
48
+    '!edit_any_forum_topics'          => '<em>'.l($tr('edit any forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)).'</em>',
49
+    '!delete_own_forum_topics'        => '<em>'.l($tr('delete own forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)).'</em>',
50
+    '!delete_any_forum_topics'        => '<em>'.l($tr('delete any forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)).'</em>',
51
+    '!administer_comments'            => '<em>'.l($tr('administer comments'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => TRUE)).'</em>',
52
+    '!administer_forums'              => '<em>'.l($tr('administer forums'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)).'</em>',
53
+    '!administer_nodes'               => '<em>'.l($tr('administer nodes'), 'admin/user/permissions', array('fragment' => 'module-node', 'html' => TRUE)).'</em>',
54 54
   );
55 55
   if (!$is_container) {
56 56
     $form['forum_access']['permissions'] = array(
@@ -61,15 +61,15 @@  discard block
 block discarded – undo
61 61
     );
62 62
     $form['forum_access']['permissions'][] = array(
63 63
       '#type' => 'markup',
64
-      '#value' => '<div>'. t('Note that users need') .'<ul style="margin-top: 0"><li>'.
65
-                           t('the !access_content and !access_comments permissions <strong>AND <em>View</em></strong> to be able to see this forum and its content at all,', $variables) .'</li><li>'.
66
-                           t('the !create_forum_topics (and similar) permissions <strong>AND <em>Post</em></strong> to be able to create forum content, and', $variables) .'</li><li>'.
67
-                           t('the !post_comments and (probably) !post_comments_without_approval permission <!TAG>AND <em>Comment</em></!TAG> to be able to post comments/replies;', $variables + array('!TAG' => (variable_get('forum_access_D5_legacy_mode', FALSE) ? 'del title="'. t('Drupal 5 legacy mode') .'"' : 'strong'))) .'</li><li>'.
68
-                           t('the !edit_own_forum_topics or !edit_any_forum_topics (and similar) permissions <strong>AND (<em>Edit</em> AND <em>Comment</em></strong>) can be added if desired, <strong>plus</strong>', $variables) .'</li><li>'.
69
-                           t('the !delete_own_forum_topics or !delete_any_forum_topics (and similar) permissions (<strong>OR <em>Delete</em></strong>) if desired;', $variables) .'</li><li>'.
70
-                           t('the !administer_comments (global!) permission <strong>OR <em>Edit</em>/<em>Delete</em></strong> to be able to edit/delete comments;', $variables) .'</li><li>'.
71
-                           t('the !administer_forums permission <strong>AND <em>View</em></strong> to be able to administer forums (and change access!).', $variables) .'</li></ul>'.
72
-                           t('Furthermore note that content which is not published is treated in a different way by Drupal: it can be viewed only by its author or by users with the !administer_nodes permission. Unpublished comments and replies are accessible to users with <strong><em>Edit</em> OR <em>Delete</em></strong>, <strong>OR</strong> with the !administer_comments permission, but they are never counted on the forum page.', $variables) .'</div>',
64
+      '#value' => '<div>'.t('Note that users need').'<ul style="margin-top: 0"><li>'.
65
+                           t('the !access_content and !access_comments permissions <strong>AND <em>View</em></strong> to be able to see this forum and its content at all,', $variables).'</li><li>'.
66
+                           t('the !create_forum_topics (and similar) permissions <strong>AND <em>Post</em></strong> to be able to create forum content, and', $variables).'</li><li>'.
67
+                           t('the !post_comments and (probably) !post_comments_without_approval permission <!TAG>AND <em>Comment</em></!TAG> to be able to post comments/replies;', $variables + array('!TAG' => (variable_get('forum_access_D5_legacy_mode', FALSE) ? 'del title="'.t('Drupal 5 legacy mode').'"' : 'strong'))).'</li><li>'.
68
+                           t('the !edit_own_forum_topics or !edit_any_forum_topics (and similar) permissions <strong>AND (<em>Edit</em> AND <em>Comment</em></strong>) can be added if desired, <strong>plus</strong>', $variables).'</li><li>'.
69
+                           t('the !delete_own_forum_topics or !delete_any_forum_topics (and similar) permissions (<strong>OR <em>Delete</em></strong>) if desired;', $variables).'</li><li>'.
70
+                           t('the !administer_comments (global!) permission <strong>OR <em>Edit</em>/<em>Delete</em></strong> to be able to edit/delete comments;', $variables).'</li><li>'.
71
+                           t('the !administer_forums permission <strong>AND <em>View</em></strong> to be able to administer forums (and change access!).', $variables).'</li></ul>'.
72
+                           t('Furthermore note that content which is not published is treated in a different way by Drupal: it can be viewed only by its author or by users with the !administer_nodes permission. Unpublished comments and replies are accessible to users with <strong><em>Edit</em> OR <em>Delete</em></strong>, <strong>OR</strong> with the !administer_comments permission, but they are never counted on the forum page.', $variables).'</div>',
73 73
     );
74 74
   }
75 75
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
       '#collapsed' => empty($template_tid),
83 83
   );
84 84
   $form['forum_access']['template']['taxonomy'][$vid] = taxonomy_form($vid, array($template_tid), '');
85
-  $form['forum_access']['template']['taxonomy'][$vid]['#description'] = t("Select a forum and click !Load to retrieve that forum's settings as a starting point for this forum or container.", array('!Load' => '['. t('Load') .']'));
85
+  $form['forum_access']['template']['taxonomy'][$vid]['#description'] = t("Select a forum and click !Load to retrieve that forum's settings as a starting point for this forum or container.", array('!Load' => '['.t('Load').']'));
86 86
   $form['forum_access']['template']['load_button'] = array(
87 87
     '#type' => 'button',
88 88
     '#name' => 'load_template',
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
     );
206 206
   }
207 207
 
208
-  drupal_add_css(drupal_get_path('module', 'forum_access') .'/forum_access.css');
208
+  drupal_add_css(drupal_get_path('module', 'forum_access').'/forum_access.css');
209 209
 
210 210
   // Find our moderator ACL:
211 211
   if (isset($tid)) {  // edit, not new
@@ -222,12 +222,12 @@  discard block
 block discarded – undo
222 222
     $form['forum_access']['acl'] = acl_edit_form($acl_id, t('Moderators'));
223 223
     $form['forum_access']['acl'][] = array(
224 224
       '#type' => 'markup',
225
-      '#value' => '<div>'. t('Moderators receive all grants above.') .'</div>',
225
+      '#value' => '<div>'.t('Moderators receive all grants above.').'</div>',
226 226
       '#weight' => -1,
227 227
     );
228 228
     $form['forum_access']['acl']['note'] = array(
229 229
       '#type' => 'markup',
230
-      '#value' => '<div>'. t('Note: Changes to moderators are not saved until you click [!Save] below.', array('!Save' => $tr('Save'))) .'</div>',
230
+      '#value' => '<div>'.t('Note: Changes to moderators are not saved until you click [!Save] below.', array('!Save' => $tr('Save'))).'</div>',
231 231
     );
232 232
     $form['forum_access']['acl']['#after_build'][] = '_forum_access_forum_form_after_build_acl0';
233 233
     $form['forum_access']['acl']['#after_build'] = array_reverse($form['forum_access']['acl']['#after_build']);
@@ -251,11 +251,11 @@  discard block
 block discarded – undo
251 251
       '!Content_Access' => l('Content Access', 'http://drupal.org/project/content_access'),
252 252
       '@Content_Access' => 'Content Access',
253 253
       '!ACL' => 'ACL',
254
-      '!module_list' => '<ul><li>'. implode($na_modules, '</li><li>') .'</li></ul>',
254
+      '!module_list' => '<ul><li>'.implode($na_modules, '</li><li>').'</li></ul>',
255 255
     );
256 256
     $form['forum_access']['interference'][] = array(
257 257
       '#type' => 'item',
258
-      '#value' => '<p>'. t("Besides !Forum_Access (and !ACL) you have installed the following node access module(s): !module_list   The grants of every module are combined for each node. Access can only be granted, not removed &mdash; if a certain module grants a permission, the other(s) cannot deny it.", $variables) .'</p>',
258
+      '#value' => '<p>'.t("Besides !Forum_Access (and !ACL) you have installed the following node access module(s): !module_list   The grants of every module are combined for each node. Access can only be granted, not removed &mdash; if a certain module grants a permission, the other(s) cannot deny it.", $variables).'</p>',
259 259
       '#description' => t('Forums can contain other content types besides %content_type; !Forum_Access will contribute the grants defined above to every node in this forum, but other node access control modules may also contribute their grants, especially to nodes of types other than %content_type.', $variables),
260 260
     );
261 261
 
@@ -282,25 +282,25 @@  discard block
 block discarded – undo
282 282
           '#attributes' => array('class' => 'error'),
283 283
         );
284 284
         $form['forum_access']['interference']['by_content_access'][] = array(
285
-          '#value' => '<div>'. t('You have set the !Content_Access module to control access to content of type %content_type&mdash;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&mdash;this can interfere with proper operation of !Forum_Access!', $variables)." $specifically</div>",
286 286
         );
287 287
         if ($ca_priority == $fa_priority) {
288 288
           $form['forum_access']['interference']['by_content_access'][] = array(
289
-            '#value' => '<div>'. t("Unless you really know what you're doing, we recommend that you go to the !link page and clear all checkboxes. This will instruct @Content_Access to leave the %content_type nodes alone. However, if you put nodes of other content types into forums as well, then these content types will continue to have this problem.", $variables) .'</div>',
289
+            '#value' => '<div>'.t("Unless you really know what you're doing, we recommend that you go to the !link page and clear all checkboxes. This will instruct @Content_Access to leave the %content_type nodes alone. However, if you put nodes of other content types into forums as well, then these content types will continue to have this problem.", $variables).'</div>',
290 290
           );
291 291
         }
292 292
         else {
293 293
           $form['forum_access']['interference']['by_content_access'][] = array(
294
-            '#value' => '<div>'. t("The priority of @Content_Access ($ca_priority) is higher than the priority of !Forum_Access ($fa_priority), which means the latter is <strong>completely disabled</strong> for the %content_type type! Unless you really know what you're doing, we recommend that you go to the !link page, change the priority (under %Advanced) to 0, and clear all checkboxes.", $variables) .'</div>',
294
+            '#value' => '<div>'.t("The priority of @Content_Access ($ca_priority) is higher than the priority of !Forum_Access ($fa_priority), which means the latter is <strong>completely disabled</strong> for the %content_type type! Unless you really know what you're doing, we recommend that you go to the !link page, change the priority (under %Advanced) to 0, and clear all checkboxes.", $variables).'</div>',
295 295
           );
296 296
         }
297 297
         $form['forum_access']['interference']['by_content_access'][] = array(
298
-          '#value' => '<div>'. t("Alternatively, you can give !Forum_Access priority over @Content_Access by either raising the priority of !Forum_Access in every forum above the priority of @Content_Access, or by lowering the priority of @Content_Access for the content types in question below the priority of !Forum_Access.", $variables) .'</div>',
298
+          '#value' => '<div>'.t("Alternatively, you can give !Forum_Access priority over @Content_Access by either raising the priority of !Forum_Access in every forum above the priority of @Content_Access, or by lowering the priority of @Content_Access for the content types in question below the priority of !Forum_Access.", $variables).'</div>',
299 299
         );
300 300
       }
301 301
       else {
302 302
         $form['forum_access']['interference'][] = array(
303
-          '#value' => '<p>'. t('Note: You have installed the !Content_Access module, which has the capability to grant access to content that would otherwise be protected by !Forum_Access. Be careful when configuring @Content_Access!', $variables) .'</p>',
303
+          '#value' => '<p>'.t('Note: You have installed the !Content_Access module, which has the capability to grant access to content that would otherwise be protected by !Forum_Access. Be careful when configuring @Content_Access!', $variables).'</p>',
304 304
         );
305 305
       }
306 306
     }
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
       '!DNA'                 => 'DNA',
332 332
       '!debug_mode'          => l('debug mode', 'admin/settings/devel', array('fragment' => 'edit-devel-node-access-debug-mode')),
333 333
       '!dna_summary'         => l('devel/node_access/summary', 'devel/node_access/summary'),
334
-      '!Rebuild_permissions' => '['. $tr('Rebuild permissions') .']',
334
+      '!Rebuild_permissions' => '['.$tr('Rebuild permissions').']',
335 335
       '!Post_settings_link'  => l('admin/content/node-settings', 'admin/content/node-settings'),
336 336
       '!Forum_Access_'       => l('Forum Access', 'http://drupal.org/project/issues/forum_access'),
337 337
       '!ACL_'                => l('ACL', 'http://drupal.org/project/issues/acl'),
@@ -344,26 +344,26 @@  discard block
 block discarded – undo
344 344
     );
345 345
     $form['forum_access']['troubleshooting'][] = array(
346 346
       '#type' => 'item',
347
-      '#value' => '<div>'.    t("In case of problems, follow these steps until you've got it worked out:") .'<ol style="margin-top: 0"><li>'.
348
-                              t("Update to the 'recommended' !Forum_Access and !ACL releases for your version of Drupal.", $variables) .'</li><li>'.
349
-        (count($na_modules) ? t("Read %Module_interference above and update your other node access modules.", $variables) .'</li><li>' : '') .
350
-                              t("Check the release notes of the development snapshots for issues that might have been fixed in !Forum_Access-dev or !ACL-dev since the latest release.", $variables) .'</li><li>'.
351
-                              t("Install the %devel_node_access module (!DNA, part of the !Devel module) and enable its !debug_mode: !DNA will show you all the grants that actually control your nodes in a footer block on each node's page.", $variables) .'</li><li>'.
352
-                              t("Additional insight can be gained from !dna_summary and by enabling the second !DNA block.", $variables) .'</li><li>'.
353
-                              t("Click !Rebuild_permissions on !Post_settings_link and check DNA for changes.", $variables) .'</li><li>'.
354
-                              t("Check the issues queues of !Forum_Access_ and !ACL_ for existing reports and possible solutions.", $variables) .'</li><li>'.
355
-                              t("If all of this hasn't helped, then pick ONE node that is misbehaving, look at it using an account that can see the node (and that should NOT have access if that's your problem!), create a new issue in the issues queue, describe the problem... <ul><li> what did you do? </li><li> what did you expect? </li><li> what happened instead? </li></ul> ... and <strong>attach a screenshot of all the DNA records</strong> for that one node. <br /> Be sure to indicate paths (URLs) for every page and module that you mention.") .'</li></ol></div>',
347
+      '#value' => '<div>'.t("In case of problems, follow these steps until you've got it worked out:").'<ol style="margin-top: 0"><li>'.
348
+                              t("Update to the 'recommended' !Forum_Access and !ACL releases for your version of Drupal.", $variables).'</li><li>'.
349
+        (count($na_modules) ? t("Read %Module_interference above and update your other node access modules.", $variables).'</li><li>' : '').
350
+                              t("Check the release notes of the development snapshots for issues that might have been fixed in !Forum_Access-dev or !ACL-dev since the latest release.", $variables).'</li><li>'.
351
+                              t("Install the %devel_node_access module (!DNA, part of the !Devel module) and enable its !debug_mode: !DNA will show you all the grants that actually control your nodes in a footer block on each node's page.", $variables).'</li><li>'.
352
+                              t("Additional insight can be gained from !dna_summary and by enabling the second !DNA block.", $variables).'</li><li>'.
353
+                              t("Click !Rebuild_permissions on !Post_settings_link and check DNA for changes.", $variables).'</li><li>'.
354
+                              t("Check the issues queues of !Forum_Access_ and !ACL_ for existing reports and possible solutions.", $variables).'</li><li>'.
355
+                              t("If all of this hasn't helped, then pick ONE node that is misbehaving, look at it using an account that can see the node (and that should NOT have access if that's your problem!), create a new issue in the issues queue, describe the problem... <ul><li> what did you do? </li><li> what did you expect? </li><li> what happened instead? </li></ul> ... and <strong>attach a screenshot of all the DNA records</strong> for that one node. <br /> Be sure to indicate paths (URLs) for every page and module that you mention.").'</li></ol></div>',
356 356
     );
357 357
     $form['forum_access']['troubleshooting'][] = array(
358 358
       '#type' => 'item',
359
-      '#value' => '<div>'. t("Note: You should not keep the !Devel module enabled on a production site.", $variables) .'</div>',
359
+      '#value' => '<div>'.t("Note: You should not keep the !Devel module enabled on a production site.", $variables).'</div>',
360 360
     );
361 361
   }
362 362
 
363 363
   if (!$is_container && isset($tid) && !node_access_needs_rebuild()) {
364 364
     $count = db_result(db_query("SELECT COUNT(DISTINCT n.nid) FROM {node} n INNER JOIN {term_node} tn ON tn.vid = n.vid WHERE tn.tid = %d", $tid));
365
-    $limit = 20;   // from _node_access_rebuild_batch_operation()
366
-    $threshold = variable_get('forum_access_batch_threshold', $limit);  // change the variable if you want
365
+    $limit = 20; // from _node_access_rebuild_batch_operation()
366
+    $threshold = variable_get('forum_access_batch_threshold', $limit); // change the variable if you want
367 367
     $form['forum_access']['update_limit'] = array(
368 368
       '#type' => 'value',
369 369
       '#value' => $limit,
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
   $element_children = element_children($element);
442 442
   foreach ($element_children as $rid) {
443 443
     if ($rid == $moderator_rid) {
444
-      $element[$rid]['#prefix'] = '<span title="'. t("This is the (temporary) @Forum_Moderator role; it has the '@administer_nodes' and '@administer_comments' permissions and is only used temporarily by @Forum_Access &mdash; do NOT give this role to any user!", array('@Forum_Moderator' => t('Forum Moderator'), '@administer_nodes' => $tr('administer nodes'), '@administer_comments' => $tr('administer comments'), '@Forum_Access' => 'Forum Access')) .'" class="forum-access-temporary-moderator">';
444
+      $element[$rid]['#prefix'] = '<span title="'.t("This is the (temporary) @Forum_Moderator role; it has the '@administer_nodes' and '@administer_comments' permissions and is only used temporarily by @Forum_Access &mdash; do NOT give this role to any user!", array('@Forum_Moderator' => t('Forum Moderator'), '@administer_nodes' => $tr('administer nodes'), '@administer_comments' => $tr('administer comments'), '@Forum_Access' => 'Forum Access')).'" class="forum-access-temporary-moderator">';
445 445
       $element[$rid]['#suffix'] = "</span>";
446 446
       $element[$rid]['#default_value'] = TRUE;
447 447
       $element[$rid]['#disabled'] = TRUE;
@@ -452,19 +452,19 @@  discard block
 block discarded – undo
452 452
     elseif ($element['#parents'][1] == 'comment_create') {
453 453
     }
454 454
     elseif ($element['#parents'][1] == 'view' && isset($permissions[$rid]['administer forums'])) {
455
-      $element[$rid]['#title'] = '<em>'. $element[$rid]['#title'] .'</em>';
456
-      $element[$rid]['#prefix'] = '<span title="'. t("This role has the '@administer_forums' permission, and granting '@View' enables the role holders to change the settings on this page, including @Access_control!", array('@administer_forums' => $tr('administer forums'), '@View' => t('View'), '@Access_control' => t('Access control'))) .'">';
455
+      $element[$rid]['#title'] = '<em>'.$element[$rid]['#title'].'</em>';
456
+      $element[$rid]['#prefix'] = '<span title="'.t("This role has the '@administer_forums' permission, and granting '@View' enables the role holders to change the settings on this page, including @Access_control!", array('@administer_forums' => $tr('administer forums'), '@View' => t('View'), '@Access_control' => t('Access control'))).'">';
457 457
       if (isset($permissions[$rid]['administer nodes'])) {
458
-        $element[$rid]['#prefix'] = str_replace('">', ' '. t("Because the role also has the '@administer_nodes' permission, it has full access to all nodes either way.", array('@administer_nodes' => $tr('administer nodes'))) .'">', $element[$rid]['#prefix']);
458
+        $element[$rid]['#prefix'] = str_replace('">', ' '.t("Because the role also has the '@administer_nodes' permission, it has full access to all nodes either way.", array('@administer_nodes' => $tr('administer nodes'))).'">', $element[$rid]['#prefix']);
459 459
       }
460 460
       $element[$rid]['#suffix'] = "</span>";
461 461
     }
462 462
     elseif (isset($permissions[$rid]['administer nodes'])) {
463 463
       $element[$rid]['#disabled'] = TRUE;
464 464
       $element[$rid]['#default_value'] = TRUE;
465
-      $element[$rid]['#prefix'] = '<span title="'. ($rid != $moderator_rid
465
+      $element[$rid]['#prefix'] = '<span title="'.($rid != $moderator_rid
466 466
                                                     ? t("This role has the '@administer_nodes' permission and thus full access to all nodes.", array('@administer_nodes' => $tr('administer nodes')))
467
-                                                    : t("This is the @Forum_Moderator role; it has the '@administer_nodes' and '@administer_comments' permissions and thus full access to all nodes and comments.", array('@Forum_Moderator' => t('Forum Moderator'), '@administer_nodes' => $tr('administer nodes'), '@administer_comments' => $tr('administer comments')))) .'">';
467
+                                                    : t("This is the @Forum_Moderator role; it has the '@administer_nodes' and '@administer_comments' permissions and thus full access to all nodes and comments.", array('@Forum_Moderator' => t('Forum Moderator'), '@administer_nodes' => $tr('administer nodes'), '@administer_comments' => $tr('administer comments')))).'">';
468 468
       $element[$rid]['#suffix'] = "</span>";
469 469
     }
470 470
   }
@@ -560,12 +560,12 @@  discard block
 block discarded – undo
560 560
     variable_del('forum_access_new_template_tid');
561 561
   }
562 562
   module_load_include('node.inc', 'forum_access');
563
-  $moderator_rid = _forum_access_get_moderator_rid(TRUE);  // create the moderators role if it doesn't exist
563
+  $moderator_rid = _forum_access_get_moderator_rid(TRUE); // create the moderators role if it doesn't exist
564 564
 
565 565
   // check for changes
566 566
   $is_changed = $is_new = strpos($_GET['q'], 'admin/content/forum/add/') === 0;
567 567
   $is_changed = $is_changed || !empty($access['force_update']);
568
-  $form_initial_values = $form;  // avoid Coder warning
568
+  $form_initial_values = $form; // avoid Coder warning
569 569
   $form_initial_values = $form_initial_values['forum_access'];
570 570
   foreach (array('view', 'create', 'comment_create', 'update', 'delete') as $grant_type) {
571 571
     if (isset($form_initial_values[$grant_type])) {
@@ -610,11 +610,11 @@  discard block
 block discarded – undo
610 610
     }
611 611
     else {
612 612
       db_query("INSERT INTO {forum_access} (tid, rid, grant_view, grant_update, grant_delete, grant_create, grant_comment_create, priority) VALUES (%d, %d, %d, %d, %d, %d, %d, %d)",
613
-      $tid, $rid, (bool) $checked, !empty($access['update'][$rid]), !empty($access['delete'][$rid]), !empty($access['create'][$rid]), !empty($access['comment_create'][$rid]), $fa_priority);
613
+      $tid, $rid, (bool)$checked, !empty($access['update'][$rid]), !empty($access['delete'][$rid]), !empty($access['create'][$rid]), !empty($access['comment_create'][$rid]), $fa_priority);
614 614
     }
615 615
   }
616 616
   $tr = 't';
617
-  $link = l($tr('edit'), 'admin/content/forum/edit/forum/'. $tid);
617
+  $link = l($tr('edit'), 'admin/content/forum/edit/forum/'.$tid);
618 618
   watchdog('access', 'Changed grants for %forum forum.', array('%forum' => $form_state['values']['name']), WATCHDOG_NOTICE, $link);
619 619
 
620 620
   if (!$is_new && $form_state['values']['form_id'] != 'forum_form_container') {
@@ -628,10 +628,10 @@  discard block
 block discarded – undo
628 628
       $context = array();
629 629
       $pending_error_messages = drupal_get_messages('error', FALSE);
630 630
       $our_error_message_index = (isset($pending_error_messages['error']) ? count($pending_error_messages['error']) : 0);
631
-      _forum_access_update_batch_finished(FALSE, array(), array());       // add our error message (in case we die underway)
631
+      _forum_access_update_batch_finished(FALSE, array(), array()); // add our error message (in case we die underway)
632 632
       _forum_access_update_batch_operation($tid, 999999, 1, $context);
633
-      $pending_error_messages = drupal_get_messages('error', TRUE);       // still alive, get and clear all 'error' messages
634
-      unset($pending_error_messages['error'][$our_error_message_index]);  // remove our error message
633
+      $pending_error_messages = drupal_get_messages('error', TRUE); // still alive, get and clear all 'error' messages
634
+      unset($pending_error_messages['error'][$our_error_message_index]); // remove our error message
635 635
       foreach ($pending_error_messages['error'] as $message) {            // replay any others
636 636
         drupal_set_message($message, 'error');
637 637
       }
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
       $count = db_result(db_query("SELECT COUNT(DISTINCT n.nid) FROM {node} n INNER JOIN {term_node} tn ON tn.vid = n.vid WHERE tn.tid = %d", $tid));
645 645
       $batch = array(
646 646
         'title' => t('Updating content access permissions'),
647
-        'file' => drupal_get_path('module', 'forum_access') .'/forum_access.admin.inc',
647
+        'file' => drupal_get_path('module', 'forum_access').'/forum_access.admin.inc',
648 648
         'operations' => array(
649 649
           array('_forum_access_update_batch_operation', array($tid, $limit, $count)),
650 650
         ),
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
     }
655 655
   }
656 656
 
657
-  variable_del('forum_access_rids');  // clear cache
657
+  variable_del('forum_access_rids'); // clear cache
658 658
 }
659 659
 
660 660
 /**
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
 
688 688
   // Multistep processing : report progress.
689 689
   if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
690
-    $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
690
+    $context['finished'] = $context['sandbox']['progress']/$context['sandbox']['max'];
691 691
   }
692 692
 }
693 693
 
@@ -829,8 +829,8 @@  discard block
 block discarded – undo
829 829
   );
830 830
   if (arg(3) == 'forum') {
831 831
     drupal_set_message(t('Note: In Drupal, access can only be granted, not taken away. Whatever access you grant here will not be reflected in the !Forum_Access_link settings, but !Forum_Access can only allow <i>more</i> access, not less.', $variables)
832
-      .'<br /><span class="error">'. t('Specifically, any rights granted to the %anonymous_user and/or the %authenticated_user will <b>override</b> the settings of !Forum_Access!', $variables) .'</span>'
833
-      .'<br />'. t('To avoid conflicts with !Forum_Access settings, you may want to lower the priority of !Content_Access (under %Advanced below) below the priority of !Forum_Access for the content types that you want to be controlled by !Forum_Access.', $variables), 'warning');
832
+      .'<br /><span class="error">'.t('Specifically, any rights granted to the %anonymous_user and/or the %authenticated_user will <b>override</b> the settings of !Forum_Access!', $variables).'</span>'
833
+      .'<br />'.t('To avoid conflicts with !Forum_Access settings, you may want to lower the priority of !Content_Access (under %Advanced below) below the priority of !Forum_Access for the content types that you want to be controlled by !Forum_Access.', $variables), 'warning');
834 834
   }
835 835
   else {
836 836
     $vid = _forum_access_get_vid();
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
   if (isset($moderator_rid) && isset($form['account']['roles']['#options'][$moderator_rid])) {
894 894
     $form['account']['roles'][$moderator_rid] = array(
895 895
       '#type' => 'checkbox',
896
-      '#title' => $form['account']['roles']['#options'][$moderator_rid] .' ('. t('reserved for internal use by the @Forum_Access module', array('@Forum_Access' => 'Forum Access')) .')',
896
+      '#title' => $form['account']['roles']['#options'][$moderator_rid].' ('.t('reserved for internal use by the @Forum_Access module', array('@Forum_Access' => 'Forum Access')).')',
897 897
       '#default_value' => in_array($moderator_rid, $form['account']['roles']['#default_value']),
898 898
       '#disabled' => TRUE,
899 899
     );
@@ -930,8 +930,8 @@  discard block
 block discarded – undo
930 930
     else {
931 931
       $msg = t('!Forum_Access cannot create the %role role!', $variables);
932 932
       watchdog('user', $msg, NULL, WATCHDOG_WARNING);
933
-      drupal_set_message($msg .' '. t('Is it already in use?'), 'error');
934
-      $role->name = $role_name .' '. $i;
933
+      drupal_set_message($msg.' '.t('Is it already in use?'), 'error');
934
+      $role->name = $role_name.' '.$i;
935 935
     }
936 936
   }
937 937
   $msg = t('!Forum_Access has given up and will not work correctly! Rename one of the roles listed above, so that !Forum_Access can use its name.', $variables);
Please login to merge, or discard this patch.
Braces   +29 added lines, -41 removed lines patch added patch discarded remove patch
@@ -20,11 +20,12 @@  discard block
 block discarded – undo
20 20
   }
21 21
 
22 22
   $roles = user_roles();
23
-  if (isset($tid)) {  // edit
23
+  if (isset($tid)) {
24
+// edit
24 25
     $template_tid = variable_get('forum_access_default_template_tid', 0);
25 26
     $settings = _forum_access_get_settings($tid);
26
-  }
27
-  else {  // create
27
+  } else {
28
+// create
28 29
     $template_tid = variable_get('forum_access_new_template_tid', NULL);
29 30
     $settings = _forum_access_get_settings($template_tid);
30 31
   }
@@ -208,9 +209,11 @@  discard block
 block discarded – undo
208 209
   drupal_add_css(drupal_get_path('module', 'forum_access') .'/forum_access.css');
209 210
 
210 211
   // Find our moderator ACL:
211
-  if (isset($tid)) {  // edit, not new
212
+  if (isset($tid)) {
213
+// edit, not new
212 214
     $acl_id = acl_get_id_by_number('forum_access', $tid);
213
-    if (!$acl_id) { // create one
215
+    if (!$acl_id) {
216
+// create one
214 217
       $acl_id = acl_create_new_acl('forum_access', NULL, $tid);
215 218
       // update every existing node in this forum to use this acl.
216 219
       $result = db_query("SELECT nid FROM {term_node} WHERE tid = %d", $tid);
@@ -288,8 +291,7 @@  discard block
 block discarded – undo
288 291
           $form['forum_access']['interference']['by_content_access'][] = array(
289 292
             '#value' => '<div>'. t("Unless you really know what you're doing, we recommend that you go to the !link page and clear all checkboxes. This will instruct @Content_Access to leave the %content_type nodes alone. However, if you put nodes of other content types into forums as well, then these content types will continue to have this problem.", $variables) .'</div>',
290 293
           );
291
-        }
292
-        else {
294
+        } else {
293 295
           $form['forum_access']['interference']['by_content_access'][] = array(
294 296
             '#value' => '<div>'. t("The priority of @Content_Access ($ca_priority) is higher than the priority of !Forum_Access ($fa_priority), which means the latter is <strong>completely disabled</strong> for the %content_type type! Unless you really know what you're doing, we recommend that you go to the !link page, change the priority (under %Advanced) to 0, and clear all checkboxes.", $variables) .'</div>',
295 297
           );
@@ -297,8 +299,7 @@  discard block
 block discarded – undo
297 299
         $form['forum_access']['interference']['by_content_access'][] = array(
298 300
           '#value' => '<div>'. t("Alternatively, you can give !Forum_Access priority over @Content_Access by either raising the priority of !Forum_Access in every forum above the priority of @Content_Access, or by lowering the priority of @Content_Access for the content types in question below the priority of !Forum_Access.", $variables) .'</div>',
299 301
         );
300
-      }
301
-      else {
302
+      } else {
302 303
         $form['forum_access']['interference'][] = array(
303 304
           '#value' => '<p>'. t('Note: You have installed the !Content_Access module, which has the capability to grant access to content that would otherwise be protected by !Forum_Access. Be careful when configuring @Content_Access!', $variables) .'</p>',
304 305
         );
@@ -445,21 +446,17 @@  discard block
 block discarded – undo
445 446
       $element[$rid]['#suffix'] = "</span>";
446 447
       $element[$rid]['#default_value'] = TRUE;
447 448
       $element[$rid]['#disabled'] = TRUE;
448
-    }
449
-    elseif ($element['#parents'][1] == 'create') {
449
+    } elseif ($element['#parents'][1] == 'create') {
450 450
       // Do nothing (Post is always mutable).
451
-    }
452
-    elseif ($element['#parents'][1] == 'comment_create') {
453
-    }
454
-    elseif ($element['#parents'][1] == 'view' && isset($permissions[$rid]['administer forums'])) {
451
+    } elseif ($element['#parents'][1] == 'comment_create') {
452
+    } elseif ($element['#parents'][1] == 'view' && isset($permissions[$rid]['administer forums'])) {
455 453
       $element[$rid]['#title'] = '<em>'. $element[$rid]['#title'] .'</em>';
456 454
       $element[$rid]['#prefix'] = '<span title="'. t("This role has the '@administer_forums' permission, and granting '@View' enables the role holders to change the settings on this page, including @Access_control!", array('@administer_forums' => $tr('administer forums'), '@View' => t('View'), '@Access_control' => t('Access control'))) .'">';
457 455
       if (isset($permissions[$rid]['administer nodes'])) {
458 456
         $element[$rid]['#prefix'] = str_replace('">', ' '. t("Because the role also has the '@administer_nodes' permission, it has full access to all nodes either way.", array('@administer_nodes' => $tr('administer nodes'))) .'">', $element[$rid]['#prefix']);
459 457
       }
460 458
       $element[$rid]['#suffix'] = "</span>";
461
-    }
462
-    elseif (isset($permissions[$rid]['administer nodes'])) {
459
+    } elseif (isset($permissions[$rid]['administer nodes'])) {
463 460
       $element[$rid]['#disabled'] = TRUE;
464 461
       $element[$rid]['#default_value'] = TRUE;
465 462
       $element[$rid]['#prefix'] = '<span title="'. ($rid != $moderator_rid
@@ -515,8 +512,7 @@  discard block
 block discarded – undo
515 512
     if ($settings['priority'] != 0) {
516 513
       $form['interference']['advanced']['#collapsed'] = FALSE;
517 514
     }
518
-  }
519
-  elseif (is_array(reset($form_state['values']['forum_access']['template']['taxonomy']))) {
515
+  } elseif (is_array(reset($form_state['values']['forum_access']['template']['taxonomy']))) {
520 516
       $imv = reset($form_state['values']['forum_access']['template']['taxonomy']);
521 517
     $template_tid = reset($imv);
522 518
   }
@@ -549,14 +545,12 @@  discard block
 block discarded – undo
549 545
   $template_tid = reset(array_values($access['template']['taxonomy']));
550 546
   if ($access['template']['select_by_default']) {
551 547
     variable_set('forum_access_default_template_tid', $template_tid);
552
-  }
553
-  elseif (variable_get('forum_access_default_template_tid', 0) == $template_tid) {
548
+  } elseif (variable_get('forum_access_default_template_tid', 0) == $template_tid) {
554 549
     variable_del('forum_access_default_template_tid');
555 550
   }
556 551
   if ($access['template']['load_for_new']) {
557 552
     variable_set('forum_access_new_template_tid', $template_tid);
558
-  }
559
-  elseif (variable_get('forum_access_new_template_tid', 0) == $template_tid) {
553
+  } elseif (variable_get('forum_access_new_template_tid', 0) == $template_tid) {
560 554
     variable_del('forum_access_new_template_tid');
561 555
   }
562 556
   module_load_include('node.inc', 'forum_access');
@@ -598,8 +592,7 @@  discard block
 block discarded – undo
598 592
       // We prefer not to save records for node administrators, because these have access anyway.
599 593
       if (isset($permissions[$rid]['administer forums']) && $access['view'][$rid]) {
600 594
         // For forum administrators, View needs to be saved, ...
601
-      }
602
-      else {
595
+      } else {
603 596
         // ... otherwise forget View.
604 597
         $access['view'][$rid] = FALSE;
605 598
       }
@@ -607,8 +600,7 @@  discard block
 block discarded – undo
607 600
         db_query("INSERT INTO {forum_access} (tid, rid, grant_view, grant_update, grant_delete, grant_create, grant_comment_create, priority) VALUES (%d, %d, %d, %d, %d, %d, %d, %d)",
608 601
         $tid, $rid, !empty($access['view'][$rid]), 0, 0, !empty($access['create'][$rid]), !empty($access['comment_create'][$rid]), $fa_priority);
609 602
       }
610
-    }
611
-    else {
603
+    } else {
612 604
       db_query("INSERT INTO {forum_access} (tid, rid, grant_view, grant_update, grant_delete, grant_create, grant_comment_create, priority) VALUES (%d, %d, %d, %d, %d, %d, %d, %d)",
613 605
       $tid, $rid, (bool) $checked, !empty($access['update'][$rid]), !empty($access['delete'][$rid]), !empty($access['create'][$rid]), !empty($access['comment_create'][$rid]), $fa_priority);
614 606
     }
@@ -620,8 +612,7 @@  discard block
 block discarded – undo
620 612
   if (!$is_new && $form_state['values']['form_id'] != 'forum_form_container') {
621 613
     if (!isset($access['update_choice']) || $access['update_choice'] == 2) {
622 614
       node_access_needs_rebuild(TRUE);
623
-    }
624
-    elseif ($access['update_choice'] == 0) {
615
+    } elseif ($access['update_choice'] == 0) {
625 616
       // update immediately (but use the batch functions anyway
626 617
       $save_redirect = $form_state['redirect'];
627 618
       $form_state['redirect'] = $_GET['q'];
@@ -632,13 +623,13 @@  discard block
 block discarded – undo
632 623
       _forum_access_update_batch_operation($tid, 999999, 1, $context);
633 624
       $pending_error_messages = drupal_get_messages('error', TRUE);       // still alive, get and clear all 'error' messages
634 625
       unset($pending_error_messages['error'][$our_error_message_index]);  // remove our error message
635
-      foreach ($pending_error_messages['error'] as $message) {            // replay any others
626
+      foreach ($pending_error_messages['error'] as $message) {
627
+// replay any others
636 628
         drupal_set_message($message, 'error');
637 629
       }
638 630
       _forum_access_update_batch_finished(TRUE, array(), array());
639 631
       $form_state['redirect'] = $save_redirect;
640
-    }
641
-    else {
632
+    } else {
642 633
       // mass update in batch mode, modeled after node.module
643 634
       $limit = $access['update_limit'];
644 635
       $count = db_result(db_query("SELECT COUNT(DISTINCT n.nid) FROM {node} n INNER JOIN {term_node} tn ON tn.vid = n.vid WHERE tn.tid = %d", $tid));
@@ -698,8 +689,7 @@  discard block
 block discarded – undo
698 689
   if ($success) {
699 690
     drupal_set_message(t('The content access permissions have been updated.'));
700 691
     cache_clear_all();
701
-  }
702
-  else {
692
+  } else {
703 693
     drupal_set_message(t('The content access permissions have not been properly updated.'), 'error');
704 694
   }
705 695
 }
@@ -744,8 +734,7 @@  discard block
 block discarded – undo
744 734
     $return['view'] = array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID);
745 735
     $return['create'] = array(DRUPAL_AUTHENTICATED_RID);
746 736
     $return['comment_create'] = array(DRUPAL_AUTHENTICATED_RID);
747
-  }
748
-  else {
737
+  } else {
749 738
     $result = db_query("SELECT * FROM {forum_access} where tid = %d", $tid);
750 739
     while ($access = db_fetch_object($result)) {
751 740
       if ($access->grant_view) {
@@ -763,7 +752,8 @@  discard block
 block discarded – undo
763 752
       if ($access->grant_comment_create) {
764 753
         $return['comment_create'][] = $access->rid;
765 754
       }
766
-      if ($access->rid == DRUPAL_AUTHENTICATED_RID) {  // this is our reference
755
+      if ($access->rid == DRUPAL_AUTHENTICATED_RID) {
756
+// this is our reference
767 757
         $return['priority'] = $access->priority;
768 758
       }
769 759
     }
@@ -831,8 +821,7 @@  discard block
 block discarded – undo
831 821
     drupal_set_message(t('Note: In Drupal, access can only be granted, not taken away. Whatever access you grant here will not be reflected in the !Forum_Access_link settings, but !Forum_Access can only allow <i>more</i> access, not less.', $variables)
832 822
       .'<br /><span class="error">'. t('Specifically, any rights granted to the %anonymous_user and/or the %authenticated_user will <b>override</b> the settings of !Forum_Access!', $variables) .'</span>'
833 823
       .'<br />'. t('To avoid conflicts with !Forum_Access settings, you may want to lower the priority of !Content_Access (under %Advanced below) below the priority of !Forum_Access for the content types that you want to be controlled by !Forum_Access.', $variables), 'warning');
834
-  }
835
-  else {
824
+  } else {
836 825
     $vid = _forum_access_get_vid();
837 826
     $vocabulary = taxonomy_vocabulary_load($vid);
838 827
     if (isset($vocabulary->nodes[arg(3)])) {
@@ -926,8 +915,7 @@  discard block
 block discarded – undo
926 915
       }
927 916
       watchdog('user', $msg, NULL, WATCHDOG_NOTICE);
928 917
       return $rid;
929
-    }
930
-    else {
918
+    } else {
931 919
       $msg = t('!Forum_Access cannot create the %role role!', $variables);
932 920
       watchdog('user', $msg, NULL, WATCHDOG_WARNING);
933 921
       drupal_set_message($msg .' '. t('Is it already in use?'), 'error');
Please login to merge, or discard this patch.
Upper-Lower-Casing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@  discard block
 block discarded – undo
12 12
  * Rewrite the forum administration page with our new access rules.
13 13
  */
14 14
 function _forum_access_forum_form(&$form, &$form_state, $is_container) {
15
-  $tid = (isset($form['tid']['#value']) ? $form['tid']['#value'] : NULL);
16
-  if (isset($tid) && !forum_access_access($tid, 'view', NULL, FALSE)) {
15
+  $tid = (isset($form['tid']['#value']) ? $form['tid']['#value'] : null);
16
+  if (isset($tid) && !forum_access_access($tid, 'view', null, false)) {
17 17
     drupal_access_denied();  // Deny access if the user doesn't have View access.
18 18
     module_invoke_all('exit');
19 19
     exit;
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
     $settings = _forum_access_get_settings($tid);
26 26
   }
27 27
   else {  // create
28
-    $template_tid = variable_get('forum_access_new_template_tid', NULL);
28
+    $template_tid = variable_get('forum_access_new_template_tid', null);
29 29
     $settings = _forum_access_get_settings($template_tid);
30 30
   }
31 31
   $fa_priority = $settings['priority'];
@@ -33,38 +33,38 @@  discard block
 block discarded – undo
33 33
   $form['forum_access'] = array(
34 34
     '#type' => 'fieldset',
35 35
     '#title' => t('Access control'),
36
-    '#collapsible' => TRUE,
37
-    '#tree' => TRUE,
36
+    '#collapsible' => true,
37
+    '#tree' => true,
38 38
   );
39 39
 
40 40
   $tr = 't';
41 41
   $variables = array(
42
-    '!access_content'                 => '<em>'. l($tr('access content'), 'admin/user/permissions', array('fragment' => 'module-node', 'html' => TRUE)) .'</em>',
43
-    '!access_comments'                => '<em>'. l($tr('access comments'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => TRUE)) .'</em>',
44
-    '!create_forum_topics'            => '<em>'. l($tr('create forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)) .'</em>',
45
-    '!post_comments'                  => '<em>'. l($tr('post comments'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => TRUE)) .'</em>',
46
-    '!post_comments_without_approval' => '<em>'. l($tr('post comments without approval'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => TRUE)) .'</em>',
47
-    '!edit_own_forum_topics'          => '<em>'. l($tr('edit own forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)) .'</em>',
48
-    '!edit_any_forum_topics'          => '<em>'. l($tr('edit any forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)) .'</em>',
49
-    '!delete_own_forum_topics'        => '<em>'. l($tr('delete own forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)) .'</em>',
50
-    '!delete_any_forum_topics'        => '<em>'. l($tr('delete any forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)) .'</em>',
51
-    '!administer_comments'            => '<em>'. l($tr('administer comments'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => TRUE)) .'</em>',
52
-    '!administer_forums'              => '<em>'. l($tr('administer forums'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => TRUE)) .'</em>',
53
-    '!administer_nodes'               => '<em>'. l($tr('administer nodes'), 'admin/user/permissions', array('fragment' => 'module-node', 'html' => TRUE)) .'</em>',
42
+    '!access_content'                 => '<em>'. l($tr('access content'), 'admin/user/permissions', array('fragment' => 'module-node', 'html' => true)) .'</em>',
43
+    '!access_comments'                => '<em>'. l($tr('access comments'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => true)) .'</em>',
44
+    '!create_forum_topics'            => '<em>'. l($tr('create forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => true)) .'</em>',
45
+    '!post_comments'                  => '<em>'. l($tr('post comments'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => true)) .'</em>',
46
+    '!post_comments_without_approval' => '<em>'. l($tr('post comments without approval'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => true)) .'</em>',
47
+    '!edit_own_forum_topics'          => '<em>'. l($tr('edit own forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => true)) .'</em>',
48
+    '!edit_any_forum_topics'          => '<em>'. l($tr('edit any forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => true)) .'</em>',
49
+    '!delete_own_forum_topics'        => '<em>'. l($tr('delete own forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => true)) .'</em>',
50
+    '!delete_any_forum_topics'        => '<em>'. l($tr('delete any forum topics'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => true)) .'</em>',
51
+    '!administer_comments'            => '<em>'. l($tr('administer comments'), 'admin/user/permissions', array('fragment' => 'module-comment', 'html' => true)) .'</em>',
52
+    '!administer_forums'              => '<em>'. l($tr('administer forums'), 'admin/user/permissions', array('fragment' => 'module-forum', 'html' => true)) .'</em>',
53
+    '!administer_nodes'               => '<em>'. l($tr('administer nodes'), 'admin/user/permissions', array('fragment' => 'module-node', 'html' => true)) .'</em>',
54 54
   );
55 55
   if (!$is_container) {
56 56
     $form['forum_access']['permissions'] = array(
57 57
       '#type' => 'fieldset',
58 58
       '#title' => $tr('Permissions information'),
59
-      '#collapsible' => TRUE,
60
-      '#collapsed' => TRUE,
59
+      '#collapsible' => true,
60
+      '#collapsed' => true,
61 61
     );
62 62
     $form['forum_access']['permissions'][] = array(
63 63
       '#type' => 'markup',
64 64
       '#value' => '<div>'. t('Note that users need') .'<ul style="margin-top: 0"><li>'.
65 65
                            t('the !access_content and !access_comments permissions <strong>AND <em>View</em></strong> to be able to see this forum and its content at all,', $variables) .'</li><li>'.
66 66
                            t('the !create_forum_topics (and similar) permissions <strong>AND <em>Post</em></strong> to be able to create forum content, and', $variables) .'</li><li>'.
67
-                           t('the !post_comments and (probably) !post_comments_without_approval permission <!TAG>AND <em>Comment</em></!TAG> to be able to post comments/replies;', $variables + array('!TAG' => (variable_get('forum_access_D5_legacy_mode', FALSE) ? 'del title="'. t('Drupal 5 legacy mode') .'"' : 'strong'))) .'</li><li>'.
67
+                           t('the !post_comments and (probably) !post_comments_without_approval permission <!TAG>AND <em>Comment</em></!TAG> to be able to post comments/replies;', $variables + array('!TAG' => (variable_get('forum_access_D5_legacy_mode', false) ? 'del title="'. t('Drupal 5 legacy mode') .'"' : 'strong'))) .'</li><li>'.
68 68
                            t('the !edit_own_forum_topics or !edit_any_forum_topics (and similar) permissions <strong>AND (<em>Edit</em> AND <em>Comment</em></strong>) can be added if desired, <strong>plus</strong>', $variables) .'</li><li>'.
69 69
                            t('the !delete_own_forum_topics or !delete_any_forum_topics (and similar) permissions (<strong>OR <em>Delete</em></strong>) if desired;', $variables) .'</li><li>'.
70 70
                            t('the !administer_comments (global!) permission <strong>OR <em>Edit</em>/<em>Delete</em></strong> to be able to edit/delete comments;', $variables) .'</li><li>'.
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
   $form['forum_access']['template'] = array(
79 79
       '#type' => 'fieldset',
80 80
       '#title' => $tr('Template'),
81
-      '#collapsible' => TRUE,
81
+      '#collapsible' => true,
82 82
       '#collapsed' => empty($template_tid),
83 83
   );
84 84
   $form['forum_access']['template']['taxonomy'][$vid] = taxonomy_form($vid, array($template_tid), '');
@@ -87,21 +87,21 @@  discard block
 block discarded – undo
87 87
     '#type' => 'button',
88 88
     '#name' => 'load_template',
89 89
     '#value' => t('Load'),
90
-    '#submit' => FALSE,
90
+    '#submit' => false,
91 91
   );
92 92
   $form['forum_access']['template']['template_tid'] = array(
93 93
     '#type' => 'value',
94
-    '#value' => NULL,
94
+    '#value' => null,
95 95
   );
96 96
   $form['forum_access']['template']['select_by_default'] = array(
97 97
     '#type' => 'checkbox',
98 98
     '#title' => t('Remember this selection.'),
99
-    '#default_value' => FALSE,
99
+    '#default_value' => false,
100 100
   );
101 101
   $form['forum_access']['template']['load_for_new'] = array(
102 102
     '#type' => 'checkbox',
103 103
     '#title' => t("Use the selected forum's settings as defaults for new forums and containers."),
104
-    '#default_value' => FALSE,
104
+    '#default_value' => false,
105 105
   );
106 106
   $form['forum_access']['#after_build'][] = '_forum_access_forum_form_after_build';
107 107
 
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
   if (isset($tid)) {  // edit, not new
212 212
     $acl_id = acl_get_id_by_number('forum_access', $tid);
213 213
     if (!$acl_id) { // create one
214
-      $acl_id = acl_create_new_acl('forum_access', NULL, $tid);
214
+      $acl_id = acl_create_new_acl('forum_access', null, $tid);
215 215
       // update every existing node in this forum to use this acl.
216 216
       $result = db_query("SELECT nid FROM {term_node} WHERE tid = %d", $tid);
217 217
       while ($node = db_fetch_object($result)) {
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     $form['forum_access']['interference'] = array(
244 244
       '#type' => 'fieldset',
245 245
       '#title' => t('Module interference'),
246
-      '#collapsible' => TRUE,
246
+      '#collapsible' => true,
247 247
     );
248 248
     $variables = array(
249 249
       '%content_type' => node_get_types('name', 'forum'),
@@ -264,13 +264,13 @@  discard block
 block discarded – undo
264 264
       foreach (array('view', 'update', 'delete', 'per_node') as $type) {
265 265
         $value = content_access_get_settings($type, 'forum');
266 266
         if (!empty($value)) {
267
-          $ca_interferes = TRUE;
267
+          $ca_interferes = true;
268 268
         }
269 269
       }
270 270
       $ca_priority = content_access_get_settings('priority', 'forum');
271 271
       $is_conflict = $ca_priority >= $fa_priority && !empty($ca_interferes) || $ca_priority > $fa_priority;
272 272
       $variables += array(
273
-        '!link' => l(t('@Content_Access configuration for the %content_type type', $variables), 'admin/content/node-type/forum/access', array('html' => TRUE)),
273
+        '!link' => l(t('@Content_Access configuration for the %content_type type', $variables), 'admin/content/node-type/forum/access', array('html' => true)),
274 274
         '%Advanced' => $tr('Advanced'),
275 275
       );
276 276
       $specifically = ($ca_priority == $fa_priority ? t('Specifically, any grants given by !Content_Access cannot be taken back by !Forum_Access.', $variables) : '');
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
         $form['forum_access']['interference']['by_content_access'] = array(
279 279
           '#type' => 'fieldset',
280 280
           '#title' => 'Content Access',
281
-          '#collapsible' => FALSE,
281
+          '#collapsible' => false,
282 282
           '#attributes' => array('class' => 'error'),
283 283
         );
284 284
         $form['forum_access']['interference']['by_content_access'][] = array(
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
     $form['forum_access']['interference']['advanced'] = array(
309 309
       '#type' => 'fieldset',
310 310
       '#title' => t('Advanced'),
311
-      '#collapsible' => TRUE,
311
+      '#collapsible' => true,
312 312
       '#collapsed' => !($fa_priority != 0),
313 313
     );
314 314
     $form['forum_access']['interference']['advanced']['priority'] = array(
@@ -324,8 +324,8 @@  discard block
 block discarded – undo
324 324
       '!Forum_Access'        => l('Forum Access', 'http://drupal.org/project/forum_access'),
325 325
       '!ACL'                 => l('ACL', 'http://drupal.org/project/acl'),
326 326
       '%Module_interference' => t('Module interference'),
327
-      '!Forum_Access-dev'    => l('Forum&nbsp;Access&nbsp;6.x-1.x-dev', 'http://drupal.org/node/96795', array('html' => TRUE)),
328
-      '!ACL-dev'             => l('ACL&nbsp;6.x-1.x-dev', 'http://drupal.org/node/96794', array('html' => TRUE)),
327
+      '!Forum_Access-dev'    => l('Forum&nbsp;Access&nbsp;6.x-1.x-dev', 'http://drupal.org/node/96795', array('html' => true)),
328
+      '!ACL-dev'             => l('ACL&nbsp;6.x-1.x-dev', 'http://drupal.org/node/96794', array('html' => true)),
329 329
       '%devel_node_access'   => 'devel_node_access',
330 330
       '!Devel'               => l('Devel', 'http://drupal.org/project/devel'),
331 331
       '!DNA'                 => 'DNA',
@@ -339,8 +339,8 @@  discard block
 block discarded – undo
339 339
     $form['forum_access']['troubleshooting'] = array(
340 340
       '#type' => 'fieldset',
341 341
       '#title' => t('Trouble-shooting node access'),
342
-      '#collapsible' => TRUE,
343
-      '#collapsed' => TRUE,
342
+      '#collapsible' => true,
343
+      '#collapsed' => true,
344 344
     );
345 345
     $form['forum_access']['troubleshooting'][] = array(
346 346
       '#type' => 'item',
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
       '#type' => 'radios',
373 373
       '#title' => 'Update the permissions',
374 374
       '#description' => t('<em>If</em> you make any node access changes, then each node in this forum needs to be updated. Hover over the radiobuttons for details.'),
375
-      '#options' => NULL,
375
+      '#options' => null,
376 376
       0 => array(
377 377
         '#type' => 'radio',
378 378
         '#title' => t('for all %count nodes immediately', array('%count' => $count)),
@@ -443,8 +443,8 @@  discard block
 block discarded – undo
443 443
     if ($rid == $moderator_rid) {
444 444
       $element[$rid]['#prefix'] = '<span title="'. t("This is the (temporary) @Forum_Moderator role; it has the '@administer_nodes' and '@administer_comments' permissions and is only used temporarily by @Forum_Access &mdash; do NOT give this role to any user!", array('@Forum_Moderator' => t('Forum Moderator'), '@administer_nodes' => $tr('administer nodes'), '@administer_comments' => $tr('administer comments'), '@Forum_Access' => 'Forum Access')) .'" class="forum-access-temporary-moderator">';
445 445
       $element[$rid]['#suffix'] = "</span>";
446
-      $element[$rid]['#default_value'] = TRUE;
447
-      $element[$rid]['#disabled'] = TRUE;
446
+      $element[$rid]['#default_value'] = true;
447
+      $element[$rid]['#disabled'] = true;
448 448
     }
449 449
     elseif ($element['#parents'][1] == 'create') {
450 450
       // Do nothing (Post is always mutable).
@@ -460,8 +460,8 @@  discard block
 block discarded – undo
460 460
       $element[$rid]['#suffix'] = "</span>";
461 461
     }
462 462
     elseif (isset($permissions[$rid]['administer nodes'])) {
463
-      $element[$rid]['#disabled'] = TRUE;
464
-      $element[$rid]['#default_value'] = TRUE;
463
+      $element[$rid]['#disabled'] = true;
464
+      $element[$rid]['#default_value'] = true;
465 465
       $element[$rid]['#prefix'] = '<span title="'. ($rid != $moderator_rid
466 466
                                                     ? t("This role has the '@administer_nodes' permission and thus full access to all nodes.", array('@administer_nodes' => $tr('administer nodes')))
467 467
                                                     : t("This is the @Forum_Moderator role; it has the '@administer_nodes' and '@administer_comments' permissions and thus full access to all nodes and comments.", array('@Forum_Moderator' => t('Forum Moderator'), '@administer_nodes' => $tr('administer nodes'), '@administer_comments' => $tr('administer comments')))) .'">';
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
 
487 487
 function _forum_access_forum_form_after_build_acl2($form, $form_state) {
488 488
   if (!count(unserialize($form['user_list']['#default_value'])) && !count(unserialize($form['user_list']['#value']))) {
489
-    $form['#collapsed'] = TRUE;
489
+    $form['#collapsed'] = true;
490 490
   }
491 491
   if ($form['user_list']['#default_value'] != $form['user_list']['#value']) {
492 492
     $form['note']['#value'] = preg_replace('/<div>/', '<div class="warning">', $form['note']['#value']);
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
     // Load a setting from a template:
500 500
     $template_tid = reset(array_values($form['#post']['forum_access']['template']['taxonomy']));
501 501
     $form_state['values']['forum_access']['template']['template_tid'] = $template_tid;
502
-    $form['template']['#collapsed'] = FALSE;
502
+    $form['template']['#collapsed'] = false;
503 503
 
504 504
     $settings = _forum_access_get_settings($template_tid);
505 505
     foreach (array('view', 'create', 'comment_create', 'update', 'delete') as $grant_type) {
@@ -507,13 +507,13 @@  discard block
 block discarded – undo
507 507
         continue;
508 508
       }
509 509
       foreach (element_children($form[$grant_type]) as $tid) {
510
-        $checked = array_search($tid, $settings[$grant_type]) !== FALSE;
510
+        $checked = array_search($tid, $settings[$grant_type]) !== false;
511 511
         $form[$grant_type][$tid]['#value'] = ($checked ? $tid : 0);
512 512
       }
513 513
     }
514 514
     $form['interference']['advanced']['priority']['#value'] = $settings['priority'];
515 515
     if ($settings['priority'] != 0) {
516
-      $form['interference']['advanced']['#collapsed'] = FALSE;
516
+      $form['interference']['advanced']['#collapsed'] = false;
517 517
     }
518 518
   }
519 519
   elseif (is_array(reset($form_state['values']['forum_access']['template']['taxonomy']))) {
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
     variable_del('forum_access_new_template_tid');
561 561
   }
562 562
   module_load_include('node.inc', 'forum_access');
563
-  $moderator_rid = _forum_access_get_moderator_rid(TRUE);  // create the moderators role if it doesn't exist
563
+  $moderator_rid = _forum_access_get_moderator_rid(true);  // create the moderators role if it doesn't exist
564 564
 
565 565
   // check for changes
566 566
   $is_changed = $is_new = strpos($_GET['q'], 'admin/content/forum/add/') === 0;
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
       }
602 602
       else {
603 603
         // ... otherwise forget View.
604
-        $access['view'][$rid] = FALSE;
604
+        $access['view'][$rid] = false;
605 605
       }
606 606
       if ($access['view'][$rid] || $access['create'][$rid] || $access['comment_create'][$rid]) {
607 607
         db_query("INSERT INTO {forum_access} (tid, rid, grant_view, grant_update, grant_delete, grant_create, grant_comment_create, priority) VALUES (%d, %d, %d, %d, %d, %d, %d, %d)",
@@ -619,23 +619,23 @@  discard block
 block discarded – undo
619 619
 
620 620
   if (!$is_new && $form_state['values']['form_id'] != 'forum_form_container') {
621 621
     if (!isset($access['update_choice']) || $access['update_choice'] == 2) {
622
-      node_access_needs_rebuild(TRUE);
622
+      node_access_needs_rebuild(true);
623 623
     }
624 624
     elseif ($access['update_choice'] == 0) {
625 625
       // update immediately (but use the batch functions anyway
626 626
       $save_redirect = $form_state['redirect'];
627 627
       $form_state['redirect'] = $_GET['q'];
628 628
       $context = array();
629
-      $pending_error_messages = drupal_get_messages('error', FALSE);
629
+      $pending_error_messages = drupal_get_messages('error', false);
630 630
       $our_error_message_index = (isset($pending_error_messages['error']) ? count($pending_error_messages['error']) : 0);
631
-      _forum_access_update_batch_finished(FALSE, array(), array());       // add our error message (in case we die underway)
631
+      _forum_access_update_batch_finished(false, array(), array());       // add our error message (in case we die underway)
632 632
       _forum_access_update_batch_operation($tid, 999999, 1, $context);
633
-      $pending_error_messages = drupal_get_messages('error', TRUE);       // still alive, get and clear all 'error' messages
633
+      $pending_error_messages = drupal_get_messages('error', true);       // still alive, get and clear all 'error' messages
634 634
       unset($pending_error_messages['error'][$our_error_message_index]);  // remove our error message
635 635
       foreach ($pending_error_messages['error'] as $message) {            // replay any others
636 636
         drupal_set_message($message, 'error');
637 637
       }
638
-      _forum_access_update_batch_finished(TRUE, array(), array());
638
+      _forum_access_update_batch_finished(true, array(), array());
639 639
       $form_state['redirect'] = $save_redirect;
640 640
     }
641 641
     else {
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
   // Process the next 20 nodes.
676 676
   $result = db_query_range("SELECT DISTINCT n.nid FROM {node} n INNER JOIN {term_node} tn ON tn.vid = n.vid WHERE n.nid > %d AND tn.tid = %d ORDER BY n.nid ASC", $context['sandbox']['current_node'], $tid, 0, $limit);
677 677
   while ($row = db_fetch_array($result)) {
678
-    $loaded_node = node_load($row['nid'], NULL, TRUE);
678
+    $loaded_node = node_load($row['nid'], null, true);
679 679
     // To preserve database integrity, only aquire grants if the node
680 680
     // loads successfully.
681 681
     if (!empty($loaded_node)) {
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
   $form['forum_access']['forum_access_D5_legacy_mode'] = array(
727 727
     '#type'          => 'checkbox',
728 728
     '#title'         => t('Drupal 5 legacy mode', $variables),
729
-    '#default_value' => variable_get('forum_access_D5_legacy_mode', FALSE),
729
+    '#default_value' => variable_get('forum_access_D5_legacy_mode', false),
730 730
     '#description'   => t('In Drupal 5, comment posting was not restricted by !Forum_Access; users with %View access (and the %post_comments permission) were always allowed to post forum comments. Starting with Drupal 6, posting comments is now restricted to users with %Post access. Turn this option on to revert to the old behavior. The default is OFF.', $variables),
731 731
   );
732 732
   $buttons = $form['buttons'];
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
 /**
738 738
  * Helper function to retrieve the settings for a forum.
739 739
  */
740
-function _forum_access_get_settings($tid = NULL) {
740
+function _forum_access_get_settings($tid = null) {
741 741
     $return = array('view' => array(), 'create' => array(), 'comment_create' => array(), 'update' => array(), 'delete' => array(), 'priority' => 0);
742 742
   if (!isset($tid)) {
743 743
     // Default to all users can read; all logged in users can post and comment.
@@ -781,8 +781,8 @@  discard block
 block discarded – undo
781 781
   }
782 782
   foreach ($form as $key => $value) {
783 783
     if (preg_match('/^tid:(.*):0$/', $key, $matches)) {
784
-      if (!forum_access_access($matches[1], 'view', NULL, FALSE)) {
785
-        $form[$key]['edit']['#access'] = FALSE;
784
+      if (!forum_access_access($matches[1], 'view', null, false)) {
785
+        $form[$key]['edit']['#access'] = false;
786 786
         if (preg_match('|<a [^>]*>([^<]*)</a>|', $form[$key]['view']['#value'], $matches)) {
787 787
           $form[$key]['view']['#value'] = $matches[1];
788 788
         }
@@ -850,8 +850,8 @@  discard block
 block discarded – undo
850 850
 function _forum_access_user_admin_perm_form(&$form, &$form_state) {
851 851
   $moderator_rid = forum_access_query_moderator_rid();
852 852
   if (isset($moderator_rid) && array_key_exists($moderator_rid, $form['role_names'])) {
853
-    drupal_set_message(t('The %role role is used internally by the @Forum_Access module and must not be changed!', array('%role' => $form['role_names'][$moderator_rid]['#value'], '@Forum_Access' => 'Forum Access')), 'warning', FALSE);
854
-    $form['checkboxes'][$moderator_rid]['#disabled'] = TRUE;
853
+    drupal_set_message(t('The %role role is used internally by the @Forum_Access module and must not be changed!', array('%role' => $form['role_names'][$moderator_rid]['#value'], '@Forum_Access' => 'Forum Access')), 'warning', false);
854
+    $form['checkboxes'][$moderator_rid]['#disabled'] = true;
855 855
   }
856 856
   array_unshift($form['#submit'], '_forum_access_user_admin_perm_form_submit');
857 857
 }
@@ -895,7 +895,7 @@  discard block
 block discarded – undo
895 895
       '#type' => 'checkbox',
896 896
       '#title' => $form['account']['roles']['#options'][$moderator_rid] .' ('. t('reserved for internal use by the @Forum_Access module', array('@Forum_Access' => 'Forum Access')) .')',
897 897
       '#default_value' => in_array($moderator_rid, $form['account']['roles']['#default_value']),
898
-      '#disabled' => TRUE,
898
+      '#disabled' => true,
899 899
     );
900 900
     unset($form['account']['roles']['#options'][$moderator_rid]);
901 901
   }
@@ -904,7 +904,7 @@  discard block
 block discarded – undo
904 904
 /**
905 905
  * Create the Forum Moderator role.
906 906
  */
907
-function _forum_access_create_moderator_rid($verbose = FALSE) {
907
+function _forum_access_create_moderator_rid($verbose = false) {
908 908
   $tr = 't';
909 909
   $variables = array('!Forum_Access' => 'Forum Access', '%administer_comments' => $tr('administer comments'), '%administer_nodes' => $tr('administer nodes'));
910 910
   $role_name = t('Forum Moderator');
@@ -924,18 +924,18 @@  discard block
 block discarded – undo
924 924
       if ($verbose) {
925 925
         drupal_set_message($msg, 'warning');
926 926
       }
927
-      watchdog('user', $msg, NULL, WATCHDOG_NOTICE);
927
+      watchdog('user', $msg, null, WATCHDOG_NOTICE);
928 928
       return $rid;
929 929
     }
930 930
     else {
931 931
       $msg = t('!Forum_Access cannot create the %role role!', $variables);
932
-      watchdog('user', $msg, NULL, WATCHDOG_WARNING);
932
+      watchdog('user', $msg, null, WATCHDOG_WARNING);
933 933
       drupal_set_message($msg .' '. t('Is it already in use?'), 'error');
934 934
       $role->name = $role_name .' '. $i;
935 935
     }
936 936
   }
937 937
   $msg = t('!Forum_Access has given up and will not work correctly! Rename one of the roles listed above, so that !Forum_Access can use its name.', $variables);
938 938
   drupal_set_message($msg, 'error');
939
-  watchdog('user', $msg, NULL, WATCHDOG_CRITICAL);
939
+  watchdog('user', $msg, null, WATCHDOG_CRITICAL);
940 940
 }
941 941
 
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/contrib/i18nviews/i18nviews.module 6 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -143,7 +143,7 @@
 block discarded – undo
143 143
  * Return the Views fields that should be translated.
144 144
  *
145 145
  * @return
146
- *   Array of field names.
146
+ string[]   Array of field names.
147 147
  */
148 148
 function _i18nviews_display_fields() {
149 149
   return array('title', 'header', 'footer', 'empty');
Please login to merge, or discard this patch.
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -14,44 +14,44 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Switch Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -15,10 +15,10 @@  discard block
 block discarded – undo
15 15
  */
16 16
 function i18nviews_help($path, $arg) {
17 17
   switch ($path) {
18
-    case 'admin/modules#description' :
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;
18
+  case 'admin/modules#description' :
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 22
   }
23 23
 }
24 24
 
@@ -27,12 +27,12 @@  discard block
 block discarded – undo
27 27
  */
28 28
 function i18nviews_locale($op = 'groups') {
29 29
   switch ($op) {
30
-    case 'groups':
31
-      return array('views' => t('Views'));
32
-    case 'info':
33
-      $info['views']['refresh callback'] = 'i18nviews_locale_refresh';
34
-      $info['views']['format'] = TRUE;
35
-      return $info;
30
+  case 'groups':
31
+    return array('views' => t('Views'));
32
+  case 'info':
33
+    $info['views']['refresh callback'] = 'i18nviews_locale_refresh';
34
+    $info['views']['format'] = TRUE;
35
+    return $info;
36 36
   }
37 37
 }
38 38
 
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 function i18nviews_help($path, $arg) {
17 17
   switch ($path) {
18 18
     case 'admin/modules#description' :
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>';
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 21
       return $output;
22 22
   }
23 23
 }
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 function i18nviews_views_api() {
90 90
   return array(
91 91
     'api' => '2.0',
92
-    'path' => drupal_get_path('module', 'i18nviews') . '/includes',
92
+    'path' => drupal_get_path('module', 'i18nviews').'/includes',
93 93
   );
94 94
 }
95 95
 
@@ -110,10 +110,10 @@  discard block
 block discarded – undo
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 112
       $fields = _i18nviews_display_fields();
113
-      if(!empty($view->display[$display_id])) {
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 115
       }
116
-      if($fields && !empty($view->display['default'])) {
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
     }
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
   foreach ($field_names as $field) {
160 160
     if (!empty($data[$field])) {
161 161
       if ($update) {
162
-        $format = isset($data[$field . '_format']) ? $data[$field . '_format'] : NULL;
162
+        $format = isset($data[$field.'_format']) ? $data[$field.'_format'] : NULL;
163 163
         i18nstrings_update("views:$name:$group:$field", $data[$field], $format);
164 164
       }
165 165
       else {
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
     if (isset($form_state['values'][$field])) {
210 210
       $name = $form_state['view']->name;
211 211
       $group = $form_state['display_id'];
212
-      $format = isset($form_state['values'][$field . '_format']) ? $form_state['values'][$field . '_format'] : NULL;
212
+      $format = isset($form_state['values'][$field.'_format']) ? $form_state['values'][$field.'_format'] : NULL;
213 213
       i18nstrings_update("views:$name:$group:$field", $form_state['values'][$field], $format);
214 214
     }
215 215
   }
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -62,8 +62,7 @@  discard block
 block discarded – undo
62 62
 function i18nviews_views_handler_field_allterms($fieldinfo, $fielddata, $value, $data) {
63 63
   if ($fieldinfo['vocabulary']) {
64 64
     $terms = taxonomy_node_get_terms_by_vocabulary($data->nid, $fieldinfo['vocabulary']);
65
-  }
66
-  else {
65
+  } else {
67 66
     $terms = taxonomy_node_get_terms($data->nid);
68 67
   }
69 68
   // Translate all these terms.
@@ -74,8 +73,7 @@  discard block
 block discarded – undo
74 73
       $links[] = check_plain($term->name);
75 74
     }
76 75
     $links = !empty($links) ? implode(' | ', $links) : '';
77
-  }
78
-  else {
76
+  } else {
79 77
     $node = new stdClass();
80 78
     $node->taxonomy = $terms;
81 79
     $links = theme('links', taxonomy_link('taxonomy terms', $node));
@@ -126,8 +124,7 @@  discard block
 block discarded – undo
126 124
         if ($data['id'] == 'term_node.name') {
127 125
           // That's a full taxonomy box.
128 126
           $view->field[$index]['handler'] = 'i18ntaxonomy_views_handler_field_allterms';
129
-        }
130
-        elseif (preg_match("/term_node_(\d+)\.name/", $data['id'], $matches)) {
127
+        } elseif (preg_match("/term_node_(\d+)\.name/", $data['id'], $matches)) {
131 128
           $vid = $matches[1];
132 129
           if ($translate[$vid]) {
133 130
             // Set new handler for this field.
@@ -161,8 +158,7 @@  discard block
 block discarded – undo
161 158
       if ($update) {
162 159
         $format = isset($data[$field . '_format']) ? $data[$field . '_format'] : NULL;
163 160
         i18nstrings_update("views:$name:$group:$field", $data[$field], $format);
164
-      }
165
-      else {
161
+      } else {
166 162
         $data[$field] = i18nstrings("views:$name:$group:$field", $data[$field]);
167 163
         $translated[] = $field;
168 164
       }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
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;
34
+      $info['views']['format'] = true;
35 35
       return $info;
36 36
   }
37 37
 }
@@ -46,12 +46,12 @@  discard block
 block discarded – undo
46 46
       $fields = _i18nviews_display_fields();
47 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 53
   }
54
-  return TRUE; // Completed successfully
54
+  return true; // Completed successfully
55 55
 }
56 56
 
57 57
 /**
@@ -154,12 +154,12 @@  discard block
 block discarded – undo
154 154
  *
155 155
  * We get the translated fields out of the array so they are not translated again.
156 156
  */
157
-function _i18nviews_localize_array($name, $group, &$data, $field_names, $update = FALSE) {
157
+function _i18nviews_localize_array($name, $group, &$data, $field_names, $update = false) {
158 158
   $translated = array();
159 159
   foreach ($field_names as $field) {
160 160
     if (!empty($data[$field])) {
161 161
       if ($update) {
162
-        $format = isset($data[$field . '_format']) ? $data[$field . '_format'] : NULL;
162
+        $format = isset($data[$field . '_format']) ? $data[$field . '_format'] : null;
163 163
         i18nstrings_update("views:$name:$group:$field", $data[$field], $format);
164 164
       }
165 165
       else {
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
  *
178 178
  * We cannot play with object 2 array conversion because some are real typed objects.
179 179
  */
180
-function _i18nviews_localize_object($name, $group, &$data, &$field_names, $trim = FALSE) {
180
+function _i18nviews_localize_object($name, $group, &$data, &$field_names, $trim = false) {
181 181
   $translated = array();
182 182
   foreach ($field_names as $field) {
183 183
     if (!empty($data->$field)) {
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
     if (isset($form_state['values'][$field])) {
210 210
       $name = $form_state['view']->name;
211 211
       $group = $form_state['display_id'];
212
-      $format = isset($form_state['values'][$field . '_format']) ? $form_state['values'][$field . '_format'] : NULL;
212
+      $format = isset($form_state['values'][$field . '_format']) ? $form_state['values'][$field . '_format'] : null;
213 213
       i18nstrings_update("views:$name:$group:$field", $form_state['values'][$field], $format);
214 214
     }
215 215
   }
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/contrib/jump/jump.module 6 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -161,7 +161,6 @@
 block discarded – undo
161 161
  *
162 162
  * @param array $form_state
163 163
  * @param array $options
164
- * @param integer $active
165 164
  * @return array
166 165
  */
167 166
 function jump_quickly_form(&$form_state, $options, $menu_state) {
Please login to merge, or discard this patch.
Indentation   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -12,16 +12,16 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Switch Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -49,62 +49,62 @@  discard block
 block discarded – undo
49 49
  */
50 50
 function jump_block($op = 'list', $delta = 0, $edit = array()) {
51 51
   switch ($op) {
52
-    case 'list':
53
-      $blocks = array();
54
-      foreach (menu_get_menus() as $name => $title) {
55
-        $blocks['menu-' . $name] = array(
56
-          'info' => t('Jump menu: !menu', array('!menu' => $name))
57
-        );
58
-      }
52
+  case 'list':
53
+    $blocks = array();
54
+    foreach (menu_get_menus() as $name => $title) {
55
+      $blocks['menu-' . $name] = array(
56
+        'info' => t('Jump menu: !menu', array('!menu' => $name))
57
+      );
58
+    }
59 59
 
60
-      $vocs = taxonomy_get_vocabularies();
61
-      foreach ($vocs as $vid => $vocabulary) {
62
-        $blocks['taxo-' . $vid] = array(
63
-          'info' => t('Jump menu: !voc', array('!voc' => $vocabulary->name))
64
-        );
65
-      }
66
-      return $blocks;
67
-    case 'configure':
68
-      $form = array();
69
-      $form['block_settings']['jump_activepageinmenu_' . $delta] = array(
70
-        '#type' => 'checkbox',
71
-        '#title' => t('Show active page in jump menu.'),
72
-        '#default_value' => variable_get('jump_activepageinmenu_' . $delta, 1),
73
-        '#description' => t('This setting will force the jump menu to show the current page as the default selection in this block\'s jump menu.'),
60
+    $vocs = taxonomy_get_vocabularies();
61
+    foreach ($vocs as $vid => $vocabulary) {
62
+      $blocks['taxo-' . $vid] = array(
63
+        'info' => t('Jump menu: !voc', array('!voc' => $vocabulary->name))
74 64
       );
75
-      // Do the rest of the form additions in hook_form_alter() since we can't do ahah here.
76
-      return $form;
77
-    case 'save':
78
-      variable_set('jump_activepageinmenu_' . $delta, $edit['jump_activepageinmenu_' . $delta]);
79
-      variable_set('jump_use_js_' . $delta, $edit['jump_use_js_' . $delta]);
80
-      variable_set('jump_add_select_' . $delta, $edit['jump_add_select_' . $delta]);
81
-      variable_set('jump_add_select_text_' . $delta, $edit['jump_add_select_text_' . $delta]);
82
-      break;
83
-    case 'view':
84
-      // The first 5 characters of $delta should be one of:
85
-      //    menu-
86
-      //    taxo-
87
-      $subject = '';
88
-      $jumpmenu_type = substr($delta, 0, 4);
89
-      $jumpmenu_name = substr($delta, 5);
90
-      $active = jump_get_active_setting($delta);
91
-      if ($jumpmenu_type == 'menu') {
92
-        $form = jump_quickly($jumpmenu_name, 'menu', $active);
65
+    }
66
+    return $blocks;
67
+  case 'configure':
68
+    $form = array();
69
+    $form['block_settings']['jump_activepageinmenu_' . $delta] = array(
70
+      '#type' => 'checkbox',
71
+      '#title' => t('Show active page in jump menu.'),
72
+      '#default_value' => variable_get('jump_activepageinmenu_' . $delta, 1),
73
+      '#description' => t('This setting will force the jump menu to show the current page as the default selection in this block\'s jump menu.'),
74
+    );
75
+    // Do the rest of the form additions in hook_form_alter() since we can't do ahah here.
76
+    return $form;
77
+  case 'save':
78
+    variable_set('jump_activepageinmenu_' . $delta, $edit['jump_activepageinmenu_' . $delta]);
79
+    variable_set('jump_use_js_' . $delta, $edit['jump_use_js_' . $delta]);
80
+    variable_set('jump_add_select_' . $delta, $edit['jump_add_select_' . $delta]);
81
+    variable_set('jump_add_select_text_' . $delta, $edit['jump_add_select_text_' . $delta]);
82
+    break;
83
+  case 'view':
84
+    // The first 5 characters of $delta should be one of:
85
+    //    menu-
86
+    //    taxo-
87
+    $subject = '';
88
+    $jumpmenu_type = substr($delta, 0, 4);
89
+    $jumpmenu_name = substr($delta, 5);
90
+    $active = jump_get_active_setting($delta);
91
+    if ($jumpmenu_type == 'menu') {
92
+      $form = jump_quickly($jumpmenu_name, 'menu', $active);
93 93
 
94
-        // Use the menu label as the default block subject
95
-        $menus = menu_get_menus();
96
-        $subject = $menus[$jumpmenu_name];
97
-      }
98
-      else if ($jumpmenu_type == 'taxo') {
99
-        $form = jump_quickly($jumpmenu_name, 'taxo', $active);
94
+      // Use the menu label as the default block subject
95
+      $menus = menu_get_menus();
96
+      $subject = $menus[$jumpmenu_name];
97
+    }
98
+    else if ($jumpmenu_type == 'taxo') {
99
+      $form = jump_quickly($jumpmenu_name, 'taxo', $active);
100 100
 
101
-        // Use the vocabulary name as the default block subject
102
-        $vocab = taxonomy_vocabulary_load($jumpmenu_name);
103
-        $subject = $vocab->name;
104
-      }
105
-      if (variable_get('jump_use_js_' . $delta, 0) === 1) drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js');
106
-      return array('subject' => $subject, 'content' => $form);
107
-      break;
101
+      // Use the vocabulary name as the default block subject
102
+      $vocab = taxonomy_vocabulary_load($jumpmenu_name);
103
+      $subject = $vocab->name;
104
+    }
105
+    if (variable_get('jump_use_js_' . $delta, 0) === 1) drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js');
106
+    return array('subject' => $subject, 'content' => $form);
107
+    break;
108 108
   }
109 109
 }
110 110
 
@@ -309,52 +309,52 @@  discard block
 block discarded – undo
309 309
  */
310 310
 function jump_form_alter(&$form, $form_state, $form_id) {
311 311
   switch ($form_id) {
312
-    case 'block_admin_configure':
313
-      if ($form['module']['#value'] === 'jump' && function_exists('ahah_helper_register')) {
314
-        $delta = $form['delta']['#value'];
315
-        ahah_helper_register($form, $form_state);
316
-        $default_jump_use_js = (!isset($form_state['storage']['jump_use_js_' . $delta])) ? variable_get('jump_use_js_' . $delta, 0) : $form_state['storage']['jump_use_js_' . $delta];
317
-        $default_jump_add_select = (!isset($form_state['storage']['jump_add_select_' . $delta])) ? variable_get('jump_add_select_' . $delta, 0) : $form_state['storage']['jump_add_select_' . $delta];
312
+  case 'block_admin_configure':
313
+    if ($form['module']['#value'] === 'jump' && function_exists('ahah_helper_register')) {
314
+      $delta = $form['delta']['#value'];
315
+      ahah_helper_register($form, $form_state);
316
+      $default_jump_use_js = (!isset($form_state['storage']['jump_use_js_' . $delta])) ? variable_get('jump_use_js_' . $delta, 0) : $form_state['storage']['jump_use_js_' . $delta];
317
+      $default_jump_add_select = (!isset($form_state['storage']['jump_add_select_' . $delta])) ? variable_get('jump_add_select_' . $delta, 0) : $form_state['storage']['jump_add_select_' . $delta];
318 318
 
319
-        $form['block_settings']['jump_wrapper'] = array(
320
-          '#prefix' => '<div id="jump-wrapper">',
321
-          '#suffix' => '</div>',
322
-          '#type' => 'markup'
323
-        );
324
-        $form['block_settings']['jump_wrapper']['jump_use_js_' . $delta] = array(
319
+      $form['block_settings']['jump_wrapper'] = array(
320
+        '#prefix' => '<div id="jump-wrapper">',
321
+        '#suffix' => '</div>',
322
+        '#type' => 'markup'
323
+      );
324
+      $form['block_settings']['jump_wrapper']['jump_use_js_' . $delta] = array(
325
+        '#type' => 'checkbox',
326
+        '#title' => t('Hide the submit button and use Javascript to automatically jump to the selected menu item'),
327
+        '#default_value' => $default_jump_use_js,
328
+        '#disabled' => ($default_jump_add_select === 1) ? TRUE : FALSE,
329
+        '#ahah' => array(
330
+          'event' => 'change',
331
+          'path' => ahah_helper_path(array('block_settings', 'jump_wrapper')),
332
+          'wrapper' => 'jump-wrapper',
333
+        ),
334
+      );
335
+      if ($default_jump_use_js === 1) {
336
+        $form['block_settings']['jump_wrapper']['jump_add_select_' . $delta] = array(
325 337
           '#type' => 'checkbox',
326
-          '#title' => t('Hide the submit button and use Javascript to automatically jump to the selected menu item'),
327
-          '#default_value' => $default_jump_use_js,
328
-          '#disabled' => ($default_jump_add_select === 1) ? TRUE : FALSE,
338
+          '#title' => t('Add an empty select option into the list of options'),
339
+          '#default_value' => $default_jump_add_select,
340
+          '#weight' => 1,
329 341
           '#ahah' => array(
330 342
             'event' => 'change',
331 343
             'path' => ahah_helper_path(array('block_settings', 'jump_wrapper')),
332 344
             'wrapper' => 'jump-wrapper',
333 345
           ),
334 346
         );
335
-        if ($default_jump_use_js === 1) {
336
-          $form['block_settings']['jump_wrapper']['jump_add_select_' . $delta] = array(
337
-            '#type' => 'checkbox',
338
-            '#title' => t('Add an empty select option into the list of options'),
339
-            '#default_value' => $default_jump_add_select,
340
-            '#weight' => 1,
341
-            '#ahah' => array(
342
-              'event' => 'change',
343
-              'path' => ahah_helper_path(array('block_settings', 'jump_wrapper')),
344
-              'wrapper' => 'jump-wrapper',
345
-            ),
347
+        if ($default_jump_add_select === 1) {
348
+          $form['block_settings']['jump_wrapper']['jump_add_select_text_' . $delta] = array(
349
+            '#type' => 'textfield',
350
+            '#title' => t('Text to use for the empty select option'),
351
+            '#default_value' => variable_get('jump_add_select_text_' . $delta, t('Select Option')),
352
+            '#weight' => 2
346 353
           );
347
-          if ($default_jump_add_select === 1) {
348
-            $form['block_settings']['jump_wrapper']['jump_add_select_text_' . $delta] = array(
349
-              '#type' => 'textfield',
350
-              '#title' => t('Text to use for the empty select option'),
351
-              '#default_value' => variable_get('jump_add_select_text_' . $delta, t('Select Option')),
352
-              '#weight' => 2
353
-            );
354
-          }
355 354
         }
356 355
       }
357
-      break;
356
+    }
357
+    break;
358 358
   }
359 359
 }
360 360
 
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -52,33 +52,33 @@  discard block
 block discarded – undo
52 52
     case 'list':
53 53
       $blocks = array();
54 54
       foreach (menu_get_menus() as $name => $title) {
55
-        $blocks['menu-' . $name] = array(
55
+        $blocks['menu-'.$name] = array(
56 56
           'info' => t('Jump menu: !menu', array('!menu' => $name))
57 57
         );
58 58
       }
59 59
 
60 60
       $vocs = taxonomy_get_vocabularies();
61 61
       foreach ($vocs as $vid => $vocabulary) {
62
-        $blocks['taxo-' . $vid] = array(
62
+        $blocks['taxo-'.$vid] = array(
63 63
           'info' => t('Jump menu: !voc', array('!voc' => $vocabulary->name))
64 64
         );
65 65
       }
66 66
       return $blocks;
67 67
     case 'configure':
68 68
       $form = array();
69
-      $form['block_settings']['jump_activepageinmenu_' . $delta] = array(
69
+      $form['block_settings']['jump_activepageinmenu_'.$delta] = array(
70 70
         '#type' => 'checkbox',
71 71
         '#title' => t('Show active page in jump menu.'),
72
-        '#default_value' => variable_get('jump_activepageinmenu_' . $delta, 1),
72
+        '#default_value' => variable_get('jump_activepageinmenu_'.$delta, 1),
73 73
         '#description' => t('This setting will force the jump menu to show the current page as the default selection in this block\'s jump menu.'),
74 74
       );
75 75
       // Do the rest of the form additions in hook_form_alter() since we can't do ahah here.
76 76
       return $form;
77 77
     case 'save':
78
-      variable_set('jump_activepageinmenu_' . $delta, $edit['jump_activepageinmenu_' . $delta]);
79
-      variable_set('jump_use_js_' . $delta, $edit['jump_use_js_' . $delta]);
80
-      variable_set('jump_add_select_' . $delta, $edit['jump_add_select_' . $delta]);
81
-      variable_set('jump_add_select_text_' . $delta, $edit['jump_add_select_text_' . $delta]);
78
+      variable_set('jump_activepageinmenu_'.$delta, $edit['jump_activepageinmenu_'.$delta]);
79
+      variable_set('jump_use_js_'.$delta, $edit['jump_use_js_'.$delta]);
80
+      variable_set('jump_add_select_'.$delta, $edit['jump_add_select_'.$delta]);
81
+      variable_set('jump_add_select_text_'.$delta, $edit['jump_add_select_text_'.$delta]);
82 82
       break;
83 83
     case 'view':
84 84
       // The first 5 characters of $delta should be one of:
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
         $vocab = taxonomy_vocabulary_load($jumpmenu_name);
103 103
         $subject = $vocab->name;
104 104
       }
105
-      if (variable_get('jump_use_js_' . $delta, 0) === 1) drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js');
105
+      if (variable_get('jump_use_js_'.$delta, 0) === 1) drupal_add_js(drupal_get_path('module', 'jump').'/jump.js');
106 106
       return array('subject' => $subject, 'content' => $form);
107 107
       break;
108 108
   }
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
  */
126 126
 function jump_quickly($name = 'navigation', $type = 'menu', $active = -1, $override = '') {
127 127
   // Reconstruct the $delta
128
-  $delta = $type . '-' . $name;
128
+  $delta = $type.'-'.$name;
129 129
   if ($active === -1) {
130 130
     $active = variable_get('jump_activepageinmenu', 1);
131 131
   }
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
   static $num_jump_forms = 0;
154 154
   $num_jump_forms++;
155 155
 
156
-  return drupal_get_form('jump_quickly_form_' . $num_jump_forms, $options, $menu_state);
156
+  return drupal_get_form('jump_quickly_form_'.$num_jump_forms, $options, $menu_state);
157 157
 }
158 158
 
159 159
 /**
@@ -188,15 +188,15 @@  discard block
 block discarded – undo
188 188
     '#type' => 'submit',
189 189
     '#value' => t('Go')
190 190
   );
191
-  if (variable_get('jump_use_js_' . $menu_state['delta'], 0) === 1) {
191
+  if (variable_get('jump_use_js_'.$menu_state['delta'], 0) === 1) {
192 192
     // Give each menu a unique name.
193
-    $form['#attributes']['name'] = 'jumpquickly' . $menu_state['delta'];
193
+    $form['#attributes']['name'] = 'jumpquickly'.$menu_state['delta'];
194 194
     $form['#attributes']['class'] .= ' js-enabled';
195 195
 //    unset($form['submit']);
196
-    if (variable_get('jump_add_select_' . $menu_state['delta'], 0) === 1) {
196
+    if (variable_get('jump_add_select_'.$menu_state['delta'], 0) === 1) {
197 197
       $form['jump_goto']['#attributes']['class'] = 'first-no-jump';
198 198
       // Add the extra empty select option to the top of the array.
199
-      $form['jump_goto']['#options'] = array('' => variable_get('jump_add_select_text_' . $menu_state['delta'], t('Select Option'))) + $options;
199
+      $form['jump_goto']['#options'] = array('' => variable_get('jump_add_select_text_'.$menu_state['delta'], t('Select Option'))) + $options;
200 200
       $form['jump_goto']['#default_value'] = (array_key_exists($default, $options)) ? $default : '';
201 201
     }
202 202
   }
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
   foreach ($tree as $data) {
250 250
     if (!$data['link']['hidden']) {
251 251
       $href = ($data['link']['href'] == '<front>') ? $front : $data['link']['href'];
252
-      $href = (isset($data['link']['options']['fragment'])) ? $href . '#' . $data['link']['options']['fragment'] : $href;
252
+      $href = (isset($data['link']['options']['fragment'])) ? $href.'#'.$data['link']['options']['fragment'] : $href;
253 253
       $options[$href] = $data['link']['title'];
254 254
     }
255 255
   }
@@ -313,15 +313,15 @@  discard block
 block discarded – undo
313 313
       if ($form['module']['#value'] === 'jump' && function_exists('ahah_helper_register')) {
314 314
         $delta = $form['delta']['#value'];
315 315
         ahah_helper_register($form, $form_state);
316
-        $default_jump_use_js = (!isset($form_state['storage']['jump_use_js_' . $delta])) ? variable_get('jump_use_js_' . $delta, 0) : $form_state['storage']['jump_use_js_' . $delta];
317
-        $default_jump_add_select = (!isset($form_state['storage']['jump_add_select_' . $delta])) ? variable_get('jump_add_select_' . $delta, 0) : $form_state['storage']['jump_add_select_' . $delta];
316
+        $default_jump_use_js = (!isset($form_state['storage']['jump_use_js_'.$delta])) ? variable_get('jump_use_js_'.$delta, 0) : $form_state['storage']['jump_use_js_'.$delta];
317
+        $default_jump_add_select = (!isset($form_state['storage']['jump_add_select_'.$delta])) ? variable_get('jump_add_select_'.$delta, 0) : $form_state['storage']['jump_add_select_'.$delta];
318 318
 
319 319
         $form['block_settings']['jump_wrapper'] = array(
320 320
           '#prefix' => '<div id="jump-wrapper">',
321 321
           '#suffix' => '</div>',
322 322
           '#type' => 'markup'
323 323
         );
324
-        $form['block_settings']['jump_wrapper']['jump_use_js_' . $delta] = array(
324
+        $form['block_settings']['jump_wrapper']['jump_use_js_'.$delta] = array(
325 325
           '#type' => 'checkbox',
326 326
           '#title' => t('Hide the submit button and use Javascript to automatically jump to the selected menu item'),
327 327
           '#default_value' => $default_jump_use_js,
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
           ),
334 334
         );
335 335
         if ($default_jump_use_js === 1) {
336
-          $form['block_settings']['jump_wrapper']['jump_add_select_' . $delta] = array(
336
+          $form['block_settings']['jump_wrapper']['jump_add_select_'.$delta] = array(
337 337
             '#type' => 'checkbox',
338 338
             '#title' => t('Add an empty select option into the list of options'),
339 339
             '#default_value' => $default_jump_add_select,
@@ -345,10 +345,10 @@  discard block
 block discarded – undo
345 345
             ),
346 346
           );
347 347
           if ($default_jump_add_select === 1) {
348
-            $form['block_settings']['jump_wrapper']['jump_add_select_text_' . $delta] = array(
348
+            $form['block_settings']['jump_wrapper']['jump_add_select_text_'.$delta] = array(
349 349
               '#type' => 'textfield',
350 350
               '#title' => t('Text to use for the empty select option'),
351
-              '#default_value' => variable_get('jump_add_select_text_' . $delta, t('Select Option')),
351
+              '#default_value' => variable_get('jump_add_select_text_'.$delta, t('Select Option')),
352 352
               '#weight' => 2
353 353
             );
354 354
           }
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
  */
367 367
 function jump_get_active_setting($delta) {
368 368
   $active_site_default = variable_get('jump_activepageinmenu', 1);
369
-  $active = variable_get('jump_activepageinmenu_' . $delta, $active_site_default);
369
+  $active = variable_get('jump_activepageinmenu_'.$delta, $active_site_default);
370 370
   return $active;
371 371
 }
372 372
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -94,8 +94,7 @@  discard block
 block discarded – undo
94 94
         // Use the menu label as the default block subject
95 95
         $menus = menu_get_menus();
96 96
         $subject = $menus[$jumpmenu_name];
97
-      }
98
-      else if ($jumpmenu_type == 'taxo') {
97
+      } else if ($jumpmenu_type == 'taxo') {
99 98
         $form = jump_quickly($jumpmenu_name, 'taxo', $active);
100 99
 
101 100
         // Use the vocabulary name as the default block subject
@@ -137,13 +136,11 @@  discard block
 block discarded – undo
137 136
 
138 137
   if (is_array($name)) {
139 138
     $options = $name;
140
-  }
141
-  else {
139
+  } else {
142 140
     $options = array();
143 141
     if ($type == 'menu') {
144 142
       jump_menu_get_menu_options($options, $name);
145
-    }
146
-    elseif ($type == 'taxo') {
143
+    } elseif ($type == 'taxo') {
147 144
       jump_menu_get_taxo_options($options, $name);
148 145
     }
149 146
   }
@@ -215,8 +212,7 @@  discard block
 block discarded – undo
215 212
     $fragment = explode('#', $form_state['values']['jump_goto']);
216 213
     if (isset($fragment[1])) {
217 214
       drupal_goto($fragment[0], NULL, $fragment[1]);
218
-    }
219
-    else {
215
+    } else {
220 216
       drupal_goto($form_state['values']['jump_goto']);
221 217
     }
222 218
   }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
   if (!empty($form_state['values']['jump_goto'])) {
215 215
     $fragment = explode('#', $form_state['values']['jump_goto']);
216 216
     if (isset($fragment[1])) {
217
-      drupal_goto($fragment[0], NULL, $fragment[1]);
217
+      drupal_goto($fragment[0], null, $fragment[1]);
218 218
     }
219 219
     else {
220 220
       drupal_goto($form_state['values']['jump_goto']);
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
           '#type' => 'checkbox',
326 326
           '#title' => t('Hide the submit button and use Javascript to automatically jump to the selected menu item'),
327 327
           '#default_value' => $default_jump_use_js,
328
-          '#disabled' => ($default_jump_add_select === 1) ? TRUE : FALSE,
328
+          '#disabled' => ($default_jump_add_select === 1) ? true : false,
329 329
           '#ahah' => array(
330 330
             'event' => 'change',
331 331
             'path' => ahah_helper_path(array('block_settings', 'jump_wrapper')),
Please login to merge, or discard this patch.
default/boinc/modules/contrib/privatemsg/pm_block_user/pm_block_user.module 6 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
  *   messages from.
375 375
  *
376 376
  * @return
377
- *   TRUE if the user is allowed to block $account, or FALSE if not.
377
+ boolean   TRUE if the user is allowed to block $account, or FALSE if not.
378 378
  */
379 379
 function _pm_block_user_access($account) {
380 380
   global $user;
@@ -399,11 +399,11 @@  discard block
 block discarded – undo
399 399
  *   Author user object to check.
400 400
  * @param $recipient
401 401
  *   Receiver user object to check.
402
- * @param $action
402
+ * @param integer $action
403 403
  *   The action to be taken, defaults to PM_BLOCK_USER_DISALLOW_BLOCKING.
404 404
  *
405 405
  * @return
406
- *   TRUE if a rule exists for the combination of author recipient and action.
406
+ boolean   TRUE if a rule exists for the combination of author recipient and action.
407 407
  */
408 408
 function _pm_block_user_rule_exists($author, $recipient, $action = PM_BLOCK_USER_DISALLOW_BLOCKING) {
409 409
   $block_actions = variable_get('pm_block_user_actions', array());
Please login to merge, or discard this patch.
Indentation   +222 added lines, -222 removed lines patch added patch discarded remove patch
@@ -19,17 +19,17 @@  discard block
 block discarded – undo
19 19
  * Implements hook_help().
20 20
  */
21 21
 function pm_block_user_help($path) {
22
-  switch ($path) {
22
+    switch ($path) {
23 23
     case 'admin/settings/messages/block':
24 24
       return '<p>' . t('This area is used to define user blocking rules for the Privatemsg module. Rules allow control of who may block messages from whom. By default all users are allowed to block messages from anyone else. However, a site may have groups of users that need to contact or get information to others, for example: the site may have administrative staff or be a forum with moderators. Groups of users are defined by roles, which can be managed on the <a href="@roles">roles configuration page</a>.', array('@roles' => url('admin/user/roles'))) . '</p>';
25
-  }
25
+    }
26 26
 }
27 27
 
28 28
 /**
29 29
  * Implements hook_menu().
30 30
  */
31 31
 function pm_block_user_menu() {
32
-  $items['messages/block/%user'] = array(
32
+    $items['messages/block/%user'] = array(
33 33
     'title'            => 'Block user messages',
34 34
     'page callback'    => 'drupal_get_form',
35 35
     'page arguments'   => array('pm_block_user_form', 2),
@@ -37,61 +37,61 @@  discard block
 block discarded – undo
37 37
     'access arguments' => array(2),
38 38
     'type'             => MENU_CALLBACK,
39 39
     'weight'           => -10,
40
-  );
40
+    );
41 41
 
42
-  $items['admin/settings/messages/block'] = array(
42
+    $items['admin/settings/messages/block'] = array(
43 43
     'title'            => 'User blocking rules',
44 44
     'description'      => 'Configure rules for which users may block each other.',
45 45
     'page callback'    => 'drupal_get_form',
46 46
     'page arguments'   => array('pm_block_user_settings'),
47 47
     'access arguments' => array('administer privatemsg settings'),
48 48
     'type'             => MENU_LOCAL_TASK,
49
-  );
49
+    );
50 50
 
51
-  $items['messages/block/js'] = array(
51
+    $items['messages/block/js'] = array(
52 52
     'title' => 'Javascript block actions form',
53 53
     'page callback' => 'pm_block_user_js',
54 54
     'access arguments' => array('administer privatemsg settings'),
55 55
     'type' => MENU_CALLBACK,
56
-  );
56
+    );
57 57
 
58
-  return $items;
58
+    return $items;
59 59
 }
60 60
 
61 61
 /**
62 62
  * Menu callback for blocked user settings.
63 63
  */
64 64
 function pm_block_user_settings(&$form_state) {
65
-  drupal_add_css(drupal_get_path('module', 'pm_block_user') .'/pm_block_user.css');
66
-  // Need to cache form for AHAH, so it can be rebuilt from cache later.
67
-  $form = array(
65
+    drupal_add_css(drupal_get_path('module', 'pm_block_user') .'/pm_block_user.css');
66
+    // Need to cache form for AHAH, so it can be rebuilt from cache later.
67
+    $form = array(
68 68
     '#cache' => TRUE,
69
-  );
69
+    );
70 70
 
71
-  // Container for just the actions, used for AHAH.
72
-  $form['block_actions'] = array(
71
+    // Container for just the actions, used for AHAH.
72
+    $form['block_actions'] = array(
73 73
     '#tree' => TRUE,
74 74
     '#prefix' => '<div id="block-actions">',
75 75
     '#suffix' => '</div>',
76 76
     '#theme' => 'pm_block_user_actions',
77
-  );
77
+    );
78 78
 
79
-  // Should we populate the form with data from $form_state or the database?
80
-  if (!isset($form_state['pm_block_user']['block_actions'])) {
79
+    // Should we populate the form with data from $form_state or the database?
80
+    if (!isset($form_state['pm_block_user']['block_actions'])) {
81 81
     $block_actions = variable_get('pm_block_user_actions', array());
82
-  }
83
-  else {
82
+    }
83
+    else {
84 84
     $block_actions = $form_state['pm_block_user']['block_actions'];
85
-  }
86
-  // Work through each rule, adding it as a new element in
87
-  // $form['block_actions'] ready to be themed later.
88
-  foreach ($block_actions as $delta => $details) {
85
+    }
86
+    // Work through each rule, adding it as a new element in
87
+    // $form['block_actions'] ready to be themed later.
88
+    foreach ($block_actions as $delta => $details) {
89 89
     $details['delta'] = $delta;
90 90
     $form['block_actions'][$delta] = _pm_block_user_actions_form($details);
91
-  }
91
+    }
92 92
 
93
-  // The magic AHAH callback button that adds more rows.
94
-  $form['pm_block_actions_more'] = array(
93
+    // The magic AHAH callback button that adds more rows.
94
+    $form['pm_block_actions_more'] = array(
95 95
     '#type' => 'submit',
96 96
     '#value' => t('More'),
97 97
     '#weight' => 1,
@@ -99,20 +99,20 @@  discard block
 block discarded – undo
99 99
     '#suffix' => '<label for="edit-pm-block-actions-more">' . t('Add new rule') . '</label></div>',
100 100
     '#submit' => array('pm_block_user_more_submit'),
101 101
     '#ahah' => array(
102
-      'path' => 'messages/block/js',
103
-      'wrapper' => 'block-actions',
104
-      'method' => 'replace',
105
-      'effect' => 'fade',
102
+        'path' => 'messages/block/js',
103
+        'wrapper' => 'block-actions',
104
+        'method' => 'replace',
105
+        'effect' => 'fade',
106 106
     ),
107
-  );
107
+    );
108 108
 
109
-  $form['submit_form'] = array(
109
+    $form['submit_form'] = array(
110 110
     '#type' => 'submit',
111 111
     '#weight' => 10,
112 112
     '#value' => t('Save configuration'),
113
-  );
113
+    );
114 114
 
115
-  return $form;
115
+    return $form;
116 116
 }
117 117
 
118 118
 /**
@@ -132,50 +132,50 @@  discard block
 block discarded – undo
132 132
  *   Part of a form with controls for sending, receiving and actions.
133 133
  */
134 134
 function _pm_block_user_actions_form($details, $blacklist = TRUE) {
135
-  $form = array(
135
+    $form = array(
136 136
     '#tree' => TRUE,
137
-  );
138
-  $delta = $details['delta'];
139
-  // FALSE by default, or if the user has checked the 'Enabled' check box for
140
-  // this row.
141
-  $row_disabled = (isset($details['enabled']) ? !$details['enabled'] : FALSE);
137
+    );
138
+    $delta = $details['delta'];
139
+    // FALSE by default, or if the user has checked the 'Enabled' check box for
140
+    // this row.
141
+    $row_disabled = (isset($details['enabled']) ? !$details['enabled'] : FALSE);
142 142
 
143
-  $form['author'] = array(
143
+    $form['author'] = array(
144 144
     '#type' => 'select',
145 145
     '#options' => user_roles(TRUE),
146 146
     '#default_value' => (isset($details['author']) ? $details['author'] : DRUPAL_AUTHENTICATED_RID),
147 147
     '#disabled' => $row_disabled,
148
-  );
149
-  $form['recipient'] = array(
148
+    );
149
+    $form['recipient'] = array(
150 150
     '#type' => 'select',
151 151
     '#options' => user_roles(TRUE),
152 152
     '#default_value' => (isset($details['recipient']) ? $details['recipient'] : DRUPAL_AUTHENTICATED_RID),
153 153
     '#disabled' => $row_disabled,
154
-  );
154
+    );
155 155
 
156
-  // Provide different action radios if we're using a whitelist or a blacklist.
157
-  if ($blacklist) {
156
+    // Provide different action radios if we're using a whitelist or a blacklist.
157
+    if ($blacklist) {
158 158
     $options = array(
159
-      PM_BLOCK_USER_DISALLOW_BLOCKING => t('Disallow blocking author'),
160
-      PM_BLOCK_USER_DISALLOW_SENDING => t('Disallow sending message'),
159
+        PM_BLOCK_USER_DISALLOW_BLOCKING => t('Disallow blocking author'),
160
+        PM_BLOCK_USER_DISALLOW_SENDING => t('Disallow sending message'),
161 161
     );
162 162
     $default_value = (isset($details['action']) ? $details['action'] : PM_BLOCK_USER_DISALLOW_BLOCKING);
163
-  }
164
-  else {
163
+    }
164
+    else {
165 165
     // @todo: add whitelist options/default_value here.
166
-  }
167
-  $form['action']  = array(
166
+    }
167
+    $form['action']  = array(
168 168
     '#type' => 'radios',
169 169
     '#options' => $options,
170 170
     '#disabled' => $row_disabled,
171 171
     '#default_value' => $default_value,
172
-  );
172
+    );
173 173
 
174
-  $form['enabled'] = array(
174
+    $form['enabled'] = array(
175 175
     '#type' => 'checkbox',
176 176
     '#default_value' => (isset($details['enabled']) ? $details['enabled'] : TRUE),
177
-  );
178
-  $form['remove'] = array(
177
+    );
178
+    $form['remove'] = array(
179 179
     '#type' => 'submit',
180 180
     '#submit' => array('pm_block_user_remove_submit'),
181 181
     '#value' => t('Remove'),
@@ -183,14 +183,14 @@  discard block
 block discarded – undo
183 183
     '#prefix' => '<div id="remove-rule-button">',
184 184
     '#suffix' => '<label for="edit-remove">' . t('Remove rule') . '</label></div>',
185 185
     '#ahah' => array(
186
-      'path' => 'messages/block/js',
187
-      'wrapper' => 'block-actions',
188
-      'method' => 'replace',
189
-      'effect' => 'fade',
186
+        'path' => 'messages/block/js',
187
+        'wrapper' => 'block-actions',
188
+        'method' => 'replace',
189
+        'effect' => 'fade',
190 190
     ),
191
-  );
191
+    );
192 192
 
193
-  return $form;
193
+    return $form;
194 194
 }
195 195
 
196 196
 /**
@@ -199,17 +199,17 @@  discard block
 block discarded – undo
199 199
  * @see pm_block_user_remove_submit()
200 200
  */
201 201
 function pm_block_user_more_submit($form, &$form_state) {
202
-  unset($form_state['submit_handlers']);
203
-  form_execute_handlers('submit', $form, $form_state);
204
-  // Get the submitted actions, then put them into a special area of
205
-  // the $form_state.
206
-  $submitted_values = $form_state['values'];
207
-  // Add an empty action.
208
-  $submitted_values['block_actions'][] = array();
209
-  $form_state['pm_block_user'] = $submitted_values;
210
-  // Rebuild the form by passing our $form_state through the
211
-  // pm_block_user_settings() builder function.
212
-  $form_state['rebuild'] = TRUE;
202
+    unset($form_state['submit_handlers']);
203
+    form_execute_handlers('submit', $form, $form_state);
204
+    // Get the submitted actions, then put them into a special area of
205
+    // the $form_state.
206
+    $submitted_values = $form_state['values'];
207
+    // Add an empty action.
208
+    $submitted_values['block_actions'][] = array();
209
+    $form_state['pm_block_user'] = $submitted_values;
210
+    // Rebuild the form by passing our $form_state through the
211
+    // pm_block_user_settings() builder function.
212
+    $form_state['rebuild'] = TRUE;
213 213
 }
214 214
 
215 215
 /**
@@ -218,33 +218,33 @@  discard block
 block discarded – undo
218 218
  * @see pm_block_user_more_submit()
219 219
  */
220 220
 function pm_block_user_remove_submit($form, &$form_state) {
221
-  unset($form_state['submit_handlers']);
222
-  form_execute_handlers('submit', $form, $form_state);
223
-  $submitted_values = $form_state['values'];
224
-  // Remove the requested action.
225
-  $delta = $form_state['clicked_button']['#parents'][1];
226
-  unset($submitted_values['block_actions'][$delta]);
227
-  $form_state['pm_block_user'] = $submitted_values;
228
-  $form_state['rebuild'] = TRUE;
221
+    unset($form_state['submit_handlers']);
222
+    form_execute_handlers('submit', $form, $form_state);
223
+    $submitted_values = $form_state['values'];
224
+    // Remove the requested action.
225
+    $delta = $form_state['clicked_button']['#parents'][1];
226
+    unset($submitted_values['block_actions'][$delta]);
227
+    $form_state['pm_block_user'] = $submitted_values;
228
+    $form_state['rebuild'] = TRUE;
229 229
 }
230 230
 
231 231
 /**
232 232
  * Submit handler for admin form.
233 233
  */
234 234
 function pm_block_user_settings_submit($form, &$form_state) {
235
-  // We don't want it to submit when we're adding/removing actions.
236
-  if ($form_state['clicked_button']['#id'] == 'edit-submit-form') {
235
+    // We don't want it to submit when we're adding/removing actions.
236
+    if ($form_state['clicked_button']['#id'] == 'edit-submit-form') {
237 237
     // If the form's 'block_actions' aren't set, the user has deleted all the
238 238
     // rows in the table, so we save an empty array to stop errors in the form
239 239
     // builder.
240 240
     if (isset($form_state['values']['block_actions'])) {
241
-      variable_set('pm_block_user_actions', _pm_block_user_settings_filter($form_state['values']['block_actions']));
241
+        variable_set('pm_block_user_actions', _pm_block_user_settings_filter($form_state['values']['block_actions']));
242 242
     }
243 243
     else {
244
-      variable_set('pm_block_user_actions', array());
244
+        variable_set('pm_block_user_actions', array());
245 245
     }
246 246
     drupal_set_message(t('The configuration options have been saved.'));
247
-  }
247
+    }
248 248
 }
249 249
 
250 250
 /**
@@ -259,60 +259,60 @@  discard block
 block discarded – undo
259 259
  * @see pm_block_user_settings_submit()
260 260
  */
261 261
 function _pm_block_user_settings_filter($settings) {
262
-  // Add-in the names of any settings to be saved into the array below.
263
-  $save_keys = array('author', 'recipient', 'action', 'enabled');
264
-  $matching = array();
265
-  // Run through each of the keys we want to save, creating a new array.
266
-  // It's not possible to simply check for unwanted values and unset() them as
267
-  // the array is multi-dimensional.
268
-  foreach ($save_keys as $save_key) {
262
+    // Add-in the names of any settings to be saved into the array below.
263
+    $save_keys = array('author', 'recipient', 'action', 'enabled');
264
+    $matching = array();
265
+    // Run through each of the keys we want to save, creating a new array.
266
+    // It's not possible to simply check for unwanted values and unset() them as
267
+    // the array is multi-dimensional.
268
+    foreach ($save_keys as $save_key) {
269 269
     if (isset($settings[$save_key])) {
270
-      $matching[$save_key] = $settings[$save_key];
270
+        $matching[$save_key] = $settings[$save_key];
271
+    }
271 272
     }
272
-  }
273
-  if (count($matching) > 0) {
273
+    if (count($matching) > 0) {
274 274
     return $matching;
275
-  }
276
-  else {
275
+    }
276
+    else {
277 277
     return array_map('_pm_block_user_settings_filter', $settings);
278
-  }
278
+    }
279 279
 }
280 280
 
281 281
 /**
282 282
  * Menu callback for AHAH handling.
283 283
  */
284 284
 function pm_block_user_js() {
285
-  // See: http://drupal.org/node/331941 for the philosophy of Drupal AHAH.
286
-  $form_state = array('storage' => NULL, 'submitted' => FALSE);
287
-  $form_build_id = $_POST['form_build_id'];
288
-  $form = form_get_cache($form_build_id, $form_state);
289
-  $args = $form['#parameters'];
290
-  $form_id = array_shift($args);
291
-  $form['#post'] = $_POST;
292
-  $form['#redirect'] = FALSE;
293
-  $form['#programmed'] = FALSE;
294
-  $form_state['post'] = $_POST;
295
-  drupal_process_form($form_id, $form, $form_state);
296
-  $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id);
297
-  $output_form = $form['block_actions'];
298
-  unset($output_form['#prefix'], $output_form['#suffix']); // Prevent duplicate wrappers.
299
-  $output = theme('status_messages') . drupal_render($output_form);
300
-
301
-  // Hack to make behaviours attach to new HTML controls (delete buttons in
302
-  // this case).
303
-  $javascript = drupal_add_js(NULL, NULL, 'header');
304
-  drupal_json(array('status' => TRUE, 'data' => $output));
285
+    // See: http://drupal.org/node/331941 for the philosophy of Drupal AHAH.
286
+    $form_state = array('storage' => NULL, 'submitted' => FALSE);
287
+    $form_build_id = $_POST['form_build_id'];
288
+    $form = form_get_cache($form_build_id, $form_state);
289
+    $args = $form['#parameters'];
290
+    $form_id = array_shift($args);
291
+    $form['#post'] = $_POST;
292
+    $form['#redirect'] = FALSE;
293
+    $form['#programmed'] = FALSE;
294
+    $form_state['post'] = $_POST;
295
+    drupal_process_form($form_id, $form, $form_state);
296
+    $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id);
297
+    $output_form = $form['block_actions'];
298
+    unset($output_form['#prefix'], $output_form['#suffix']); // Prevent duplicate wrappers.
299
+    $output = theme('status_messages') . drupal_render($output_form);
300
+
301
+    // Hack to make behaviours attach to new HTML controls (delete buttons in
302
+    // this case).
303
+    $javascript = drupal_add_js(NULL, NULL, 'header');
304
+    drupal_json(array('status' => TRUE, 'data' => $output));
305 305
 }
306 306
 
307 307
 /**
308 308
  * Implements hook_theme().
309 309
  */
310 310
 function pm_block_user_theme() {
311
-  return array(
311
+    return array(
312 312
     'pm_block_user_actions' => array(
313
-      'arguments' => array('form' => NULL),
313
+        'arguments' => array('form' => NULL),
314 314
     ),
315
-  );
315
+    );
316 316
 }
317 317
 
318 318
 /**
@@ -321,49 +321,49 @@  discard block
 block discarded – undo
321 321
  * @ingroup themeable
322 322
  */
323 323
 function theme_pm_block_user_actions($form) {
324
-  $rows = array();
325
-  $headers = array(
324
+    $rows = array();
325
+    $headers = array(
326 326
     t('If the author has the role'),
327 327
     t('And the recipient has the role'),
328 328
     t('Action'),
329 329
     t('Enabled'),
330 330
     '',
331
-  );
332
-  $form_data = element_children($form);
331
+    );
332
+    $form_data = element_children($form);
333 333
 
334
-  foreach ($form_data as $key) {
334
+    foreach ($form_data as $key) {
335 335
     // Build the table row.
336 336
     $row = array(
337
-      'data' => array(
337
+        'data' => array(
338 338
         array('data' => drupal_render($form[$key]['author'])),
339 339
         array('data' => drupal_render($form[$key]['recipient'])),
340 340
         array('data' => drupal_render($form[$key]['action'])),
341 341
         array('data' => drupal_render($form[$key]['enabled'])),
342 342
         array('data' => drupal_render($form[$key]['remove'])),
343
-      ),
343
+        ),
344 344
     );
345 345
 
346 346
     // Add additional attributes to the row, such as a class for this row.
347 347
     if (isset($form[$key]['#attributes'])) {
348
-      $row = array_merge($row, $form[$key]['#attributes']);
348
+        $row = array_merge($row, $form[$key]['#attributes']);
349 349
     }
350 350
     $rows[] = $row;
351
-  }
351
+    }
352 352
 
353
-  // If there are no rows, output some instructions for the user.
354
-  if (empty($form_data)) {
353
+    // If there are no rows, output some instructions for the user.
354
+    if (empty($form_data)) {
355 355
     $rows[] = array(
356
-      array(
356
+        array(
357 357
         'data' => t("No rules have been added. All users may block private messages from each other. To limit which users may be blocked, click 'Add new rule'."),
358 358
         'colspan' => '5',
359
-      ),
359
+        ),
360 360
     );
361
-  }
361
+    }
362 362
 
363
-  $output = theme('table', $headers, $rows);
364
-  $output .= drupal_render($form);
363
+    $output = theme('table', $headers, $rows);
364
+    $output .= drupal_render($form);
365 365
 
366
-  return $output;
366
+    return $output;
367 367
 }
368 368
 
369 369
 /**
@@ -377,14 +377,14 @@  discard block
 block discarded – undo
377 377
  *   TRUE if the user is allowed to block $account, or FALSE if not.
378 378
  */
379 379
 function _pm_block_user_access($account) {
380
-  global $user;
381
-  if (!privatemsg_user_access('read privatemsg', $user)) {
380
+    global $user;
381
+    if (!privatemsg_user_access('read privatemsg', $user)) {
382 382
     return FALSE;
383
-  }
384
-  if (_pm_block_user_rule_exists($account, $user, PM_BLOCK_USER_DISALLOW_BLOCKING)) {
383
+    }
384
+    if (_pm_block_user_rule_exists($account, $user, PM_BLOCK_USER_DISALLOW_BLOCKING)) {
385 385
     return FALSE;
386
-  }
387
-  return TRUE;
386
+    }
387
+    return TRUE;
388 388
 }
389 389
 
390 390
 /**
@@ -406,179 +406,179 @@  discard block
 block discarded – undo
406 406
  *   TRUE if a rule exists for the combination of author recipient and action.
407 407
  */
408 408
 function _pm_block_user_rule_exists($author, $recipient, $action = PM_BLOCK_USER_DISALLOW_BLOCKING) {
409
-  $block_actions = variable_get('pm_block_user_actions', array());
410
-  foreach ($block_actions as $delta => $details) {
409
+    $block_actions = variable_get('pm_block_user_actions', array());
410
+    foreach ($block_actions as $delta => $details) {
411 411
     // If this rule doesn't relate to $action, or it's disabled
412 412
     // ignore it and go to next loop iteration.
413 413
     if ($details['action'] != $action || !$details['enabled']) {
414
-      continue;
414
+        continue;
415 415
     }
416 416
     // There are no rules governing user one, but user one may have roles that
417 417
     // affect other users, so these exceptions are narrow in scope.
418 418
     // Disallow sending affects private message authors.
419 419
     if ($author->uid == 1 && $action == PM_BLOCK_USER_DISALLOW_SENDING) {
420
-      continue;
420
+        continue;
421 421
     }
422 422
     // Disallow blocking affects private message recipients.
423 423
     if ($recipient->uid == 1 && $action == PM_BLOCK_USER_DISALLOW_BLOCKING) {
424
-      continue;
424
+        continue;
425 425
     }
426 426
     // The author has a role matching the rule and so does the recipient.
427 427
     if (isset($author->roles[$details['author']]) && isset($recipient->roles[$details['recipient']])) {
428
-      return TRUE;
428
+        return TRUE;
429
+    }
429 430
     }
430
-  }
431
-  return FALSE;
431
+    return FALSE;
432 432
 }
433 433
 
434 434
 function pm_block_user_form($form_state, $author) {
435
-  global $user;
435
+    global $user;
436 436
 
437
-  $form['author'] = array(
437
+    $form['author'] = array(
438 438
     '#type' => 'value',
439 439
     '#value' => $author->uid,
440
-  );
440
+    );
441 441
     $form['recipient'] = array(
442 442
     '#type' => 'value',
443 443
     '#value' => $user->uid,
444
-  );
445
-  $form['author_name'] = array(
444
+    );
445
+    $form['author_name'] = array(
446 446
     '#type' => 'value',
447 447
     '#value' => $author->name,
448
-  );
449
-  $form['destination'] = array(
448
+    );
449
+    $form['destination'] = array(
450 450
     '#type' => 'value',
451 451
     '#value' => isset($_GET['destination']) ? $_GET['destination'] : 'messages/',
452
-  );
452
+    );
453 453
 
454
-  if (db_result(db_query('SELECT COUNT(recipient) FROM {pm_block_user} WHERE author = %d AND recipient = %d', $author->uid, $user->uid))) {
454
+    if (db_result(db_query('SELECT COUNT(recipient) FROM {pm_block_user} WHERE author = %d AND recipient = %d', $author->uid, $user->uid))) {
455 455
     $form['block_action'] = array(
456
-      '#type' => 'value',
457
-      '#value' => 'unblock_user',
456
+        '#type' => 'value',
457
+        '#value' => 'unblock_user',
458 458
     );
459 459
     return confirm_form($form,
460
-      t('You have previously blocked "@author" from sending you any more messages. Are you sure you want to unblock this user?', array('@author' => $author->name)),
461
-      isset($_GET['destination']) ? $_GET['destination'] : 'messages/',
462
-      t('This action cannot be undone.'),
463
-      t('Unblock @author', array('@author' => $author->name)),
464
-      t('Cancel')
460
+        t('You have previously blocked "@author" from sending you any more messages. Are you sure you want to unblock this user?', array('@author' => $author->name)),
461
+        isset($_GET['destination']) ? $_GET['destination'] : 'messages/',
462
+        t('This action cannot be undone.'),
463
+        t('Unblock @author', array('@author' => $author->name)),
464
+        t('Cancel')
465 465
     );
466
-  }
467
-  else {
466
+    }
467
+    else {
468 468
     $form['block_action'] = array(
469
-      '#type' => 'value',
470
-      '#value' => 'block_user',
469
+        '#type' => 'value',
470
+        '#value' => 'block_user',
471 471
     );
472 472
     return confirm_form($form,
473
-      t('Are you sure you want to block "@author" from sending you any more messages?', array('@author' => $author->name)),
474
-      isset($_GET['destination']) ? $_GET['destination'] : 'messages/',
475
-      '',
476
-      t('Block @author', array('@author' => $author->name)),
477
-      t('Cancel')
473
+        t('Are you sure you want to block "@author" from sending you any more messages?', array('@author' => $author->name)),
474
+        isset($_GET['destination']) ? $_GET['destination'] : 'messages/',
475
+        '',
476
+        t('Block @author', array('@author' => $author->name)),
477
+        t('Cancel')
478 478
     );
479
-  }
479
+    }
480 480
 }
481 481
 
482 482
 /**
483 483
  * Implements hook_form_submit().
484 484
  */
485 485
 function pm_block_user_form_submit($form, &$form_state) {
486
-  if ($form_state['values']['confirm']) {
486
+    if ($form_state['values']['confirm']) {
487 487
     switch ($form_state['values']['block_action']) {
488
-      case 'block_user':
488
+        case 'block_user':
489 489
         db_query('INSERT INTO {pm_block_user} (author, recipient) VALUES (%d, %d)', $form_state['values']['author'], $form_state['values']['recipient']);
490 490
         drupal_set_message(t('@author has been blocked from sending you any further messages.', array('@author' => $form_state['values']['author_name'])));
491
-      break;
492
-      case 'unblock_user':
491
+        break;
492
+        case 'unblock_user':
493 493
         db_query('DELETE FROM {pm_block_user} WHERE author = %d AND recipient = %d', $form_state['values']['author'], $form_state['values']['recipient']);
494 494
         drupal_set_message(t('@author is now allowed to send you new messages.', array('@author' => $form_state['values']['author_name'])));
495
-      break;
495
+        break;
496
+    }
496 497
     }
497
-  }
498
-  $form_state['redirect'] = $form_state['values']['destination'];
498
+    $form_state['redirect'] = $form_state['values']['destination'];
499 499
 }
500 500
 
501 501
 /**
502 502
  * Implements hook_privatemsg_block_message().
503 503
  */
504 504
 function pm_block_user_privatemsg_block_message($author, $recipients) {
505
-  $blocked = array();
506
-  // Loop through each recipient and ensure there is no rule blocking this
507
-  // author from sending them private messages. Use a reference, so when
508
-  // user_load() is needed here the array is updated, negating the need for
509
-  // further calls to user_load() later in the code.
510
-  foreach (array_keys($recipients) as $uid) {
505
+    $blocked = array();
506
+    // Loop through each recipient and ensure there is no rule blocking this
507
+    // author from sending them private messages. Use a reference, so when
508
+    // user_load() is needed here the array is updated, negating the need for
509
+    // further calls to user_load() later in the code.
510
+    foreach (array_keys($recipients) as $uid) {
511 511
 
512 512
     // Ensure we have a recipient user object which includes roles.
513 513
     if (!isset($recipients[$uid]->roles)) {
514
-      $recipients[$uid] = user_load($uid);
514
+        $recipients[$uid] = user_load($uid);
515 515
     }
516 516
     // Note: this is checks whether the author may send the message (see third
517 517
     // parameter). Further below is a check whether the recipient may block it.
518 518
     if (_pm_block_user_rule_exists($author, $recipients[$uid], PM_BLOCK_USER_DISALLOW_SENDING)) {
519
-      $blocked[] = array(
519
+        $blocked[] = array(
520 520
         'uid' => $uid,
521 521
         'message' => t('Sorry, private messaging rules forbid sending messages to !name.', array('!name' => $recipients[$uid]->name)),
522
-      );
522
+        );
523
+    }
523 524
     }
524
-  }
525 525
 
526
-  $args = array_merge(array($author->uid), array_keys($recipients));
527
-  $result = db_query('SELECT recipient FROM {pm_block_user} WHERE author = %d AND recipient IN ('. db_placeholders($recipients) .') GROUP BY recipient', $args);
528
-  while ($row = db_fetch_array($result)) {
526
+    $args = array_merge(array($author->uid), array_keys($recipients));
527
+    $result = db_query('SELECT recipient FROM {pm_block_user} WHERE author = %d AND recipient IN ('. db_placeholders($recipients) .') GROUP BY recipient', $args);
528
+    while ($row = db_fetch_array($result)) {
529 529
     $recipient = $recipients[$row['recipient']];
530 530
     // If there's a rule disallowing blocking of this message, send it anyway.
531 531
     if (_pm_block_user_rule_exists($author, $recipient, PM_BLOCK_USER_DISALLOW_BLOCKING)) {
532
-      continue;
532
+        continue;
533 533
     }
534 534
     $blocked[] = array(
535
-      'uid' => $row['recipient'],
536
-      'message' => t('%name has chosen to not recieve any more messages from you.', array('%name' => $recipients[$row['recipient']]->name))
535
+        'uid' => $row['recipient'],
536
+        'message' => t('%name has chosen to not recieve any more messages from you.', array('%name' => $recipients[$row['recipient']]->name))
537 537
     );
538
-  }
539
-  return $blocked;
538
+    }
539
+    return $blocked;
540 540
 }
541 541
 
542 542
 function pm_block_user_privatemsg_sql_load_alter(&$fragments, $pmid, $uid) {
543
-  $fragments['select'][] = 'pmbu.recipient AS is_blocked';
543
+    $fragments['select'][] = 'pmbu.recipient AS is_blocked';
544 544
 
545
-  $fragments['inner_join'][] = 'LEFT JOIN {pm_block_user} pmbu ON (pm.author = pmbu.author AND pmi.uid = pmbu.recipient)';
545
+    $fragments['inner_join'][] = 'LEFT JOIN {pm_block_user} pmbu ON (pm.author = pmbu.author AND pmi.uid = pmbu.recipient)';
546 546
 }
547 547
 
548 548
 /**
549 549
  * Implements hook_privatemsg_message_view_alter().
550 550
  */
551 551
 function pm_block_user_privatemsg_message_view_alter(&$vars) {
552
-  global $user;
552
+    global $user;
553 553
 
554
-  $author = $vars['message']['author'];
555
-  if (_pm_block_user_rule_exists($author, $user, PM_BLOCK_USER_DISALLOW_BLOCKING)) {
554
+    $author = $vars['message']['author'];
555
+    if (_pm_block_user_rule_exists($author, $user, PM_BLOCK_USER_DISALLOW_BLOCKING)) {
556 556
     return;
557
-  }
558
-  if (!isset($vars['message']['thread_id'])) {
557
+    }
558
+    if (!isset($vars['message']['thread_id'])) {
559 559
     // No thread id, this is probably only a preview
560 560
     return;
561
-  }
562
-  $thread_id = $vars['message']['thread_id'];
561
+    }
562
+    $thread_id = $vars['message']['thread_id'];
563 563
 
564
-  if ($user->uid <> $author->uid) {
564
+    if ($user->uid <> $author->uid) {
565 565
     if ($vars['message']['is_blocked']) {
566
-      $vars['message_actions']['unblock_author'] = array('title' => t('Unblock author'), 'href' => 'messages/block/'. $author->uid, 'query' => 'destination=messages/view/' . $thread_id);
566
+        $vars['message_actions']['unblock_author'] = array('title' => t('Unblock author'), 'href' => 'messages/block/'. $author->uid, 'query' => 'destination=messages/view/' . $thread_id);
567 567
     }
568 568
     else {
569
-      $vars['message_actions']['block_author'] = array('title' => t('Block author'), 'href' => 'messages/block/'. $author->uid, 'query' => 'destination=messages/view/' . $thread_id);
569
+        $vars['message_actions']['block_author'] = array('title' => t('Block author'), 'href' => 'messages/block/'. $author->uid, 'query' => 'destination=messages/view/' . $thread_id);
570
+    }
570 571
     }
571
-  }
572 572
 }
573 573
 
574 574
 /**
575 575
  * Implement hook_user().
576 576
  */
577 577
 function pm_block_user_user($op, &$edit, &$account, $category = NULL) {
578
-  switch ($op) {
579
-      case 'delete':
578
+    switch ($op) {
579
+        case 'delete':
580 580
       // Delete blocking rules which involve this user.
581 581
       db_query("DELETE FROM {pm_block_user} WHERE author = %d OR recipient = %d", $account->uid, $account->uid);
582
-      break;
583
-  }
582
+        break;
583
+    }
584 584
 }
Please login to merge, or discard this patch.
Switch Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
  */
21 21
 function pm_block_user_help($path) {
22 22
   switch ($path) {
23
-    case 'admin/settings/messages/block':
24
-      return '<p>' . t('This area is used to define user blocking rules for the Privatemsg module. Rules allow control of who may block messages from whom. By default all users are allowed to block messages from anyone else. However, a site may have groups of users that need to contact or get information to others, for example: the site may have administrative staff or be a forum with moderators. Groups of users are defined by roles, which can be managed on the <a href="@roles">roles configuration page</a>.', array('@roles' => url('admin/user/roles'))) . '</p>';
23
+  case 'admin/settings/messages/block':
24
+    return '<p>' . t('This area is used to define user blocking rules for the Privatemsg module. Rules allow control of who may block messages from whom. By default all users are allowed to block messages from anyone else. However, a site may have groups of users that need to contact or get information to others, for example: the site may have administrative staff or be a forum with moderators. Groups of users are defined by roles, which can be managed on the <a href="@roles">roles configuration page</a>.', array('@roles' => url('admin/user/roles'))) . '</p>';
25 25
   }
26 26
 }
27 27
 
@@ -485,14 +485,14 @@  discard block
 block discarded – undo
485 485
 function pm_block_user_form_submit($form, &$form_state) {
486 486
   if ($form_state['values']['confirm']) {
487 487
     switch ($form_state['values']['block_action']) {
488
-      case 'block_user':
489
-        db_query('INSERT INTO {pm_block_user} (author, recipient) VALUES (%d, %d)', $form_state['values']['author'], $form_state['values']['recipient']);
490
-        drupal_set_message(t('@author has been blocked from sending you any further messages.', array('@author' => $form_state['values']['author_name'])));
491
-      break;
492
-      case 'unblock_user':
493
-        db_query('DELETE FROM {pm_block_user} WHERE author = %d AND recipient = %d', $form_state['values']['author'], $form_state['values']['recipient']);
494
-        drupal_set_message(t('@author is now allowed to send you new messages.', array('@author' => $form_state['values']['author_name'])));
495
-      break;
488
+    case 'block_user':
489
+      db_query('INSERT INTO {pm_block_user} (author, recipient) VALUES (%d, %d)', $form_state['values']['author'], $form_state['values']['recipient']);
490
+      drupal_set_message(t('@author has been blocked from sending you any further messages.', array('@author' => $form_state['values']['author_name'])));
491
+    break;
492
+    case 'unblock_user':
493
+      db_query('DELETE FROM {pm_block_user} WHERE author = %d AND recipient = %d', $form_state['values']['author'], $form_state['values']['recipient']);
494
+      drupal_set_message(t('@author is now allowed to send you new messages.', array('@author' => $form_state['values']['author_name'])));
495
+    break;
496 496
     }
497 497
   }
498 498
   $form_state['redirect'] = $form_state['values']['destination'];
@@ -576,9 +576,9 @@  discard block
 block discarded – undo
576 576
  */
577 577
 function pm_block_user_user($op, &$edit, &$account, $category = NULL) {
578 578
   switch ($op) {
579
-      case 'delete':
580
-      // Delete blocking rules which involve this user.
581
-      db_query("DELETE FROM {pm_block_user} WHERE author = %d OR recipient = %d", $account->uid, $account->uid);
582
-      break;
579
+  case 'delete':
580
+  // Delete blocking rules which involve this user.
581
+  db_query("DELETE FROM {pm_block_user} WHERE author = %d OR recipient = %d", $account->uid, $account->uid);
582
+  break;
583 583
   }
584 584
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 function pm_block_user_help($path) {
22 22
   switch ($path) {
23 23
     case 'admin/settings/messages/block':
24
-      return '<p>' . t('This area is used to define user blocking rules for the Privatemsg module. Rules allow control of who may block messages from whom. By default all users are allowed to block messages from anyone else. However, a site may have groups of users that need to contact or get information to others, for example: the site may have administrative staff or be a forum with moderators. Groups of users are defined by roles, which can be managed on the <a href="@roles">roles configuration page</a>.', array('@roles' => url('admin/user/roles'))) . '</p>';
24
+      return '<p>'.t('This area is used to define user blocking rules for the Privatemsg module. Rules allow control of who may block messages from whom. By default all users are allowed to block messages from anyone else. However, a site may have groups of users that need to contact or get information to others, for example: the site may have administrative staff or be a forum with moderators. Groups of users are defined by roles, which can be managed on the <a href="@roles">roles configuration page</a>.', array('@roles' => url('admin/user/roles'))).'</p>';
25 25
   }
26 26
 }
27 27
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
  * Menu callback for blocked user settings.
63 63
  */
64 64
 function pm_block_user_settings(&$form_state) {
65
-  drupal_add_css(drupal_get_path('module', 'pm_block_user') .'/pm_block_user.css');
65
+  drupal_add_css(drupal_get_path('module', 'pm_block_user').'/pm_block_user.css');
66 66
   // Need to cache form for AHAH, so it can be rebuilt from cache later.
67 67
   $form = array(
68 68
     '#cache' => TRUE,
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
     '#value' => t('More'),
97 97
     '#weight' => 1,
98 98
     '#prefix' => '<div id="add-rule-button">',
99
-    '#suffix' => '<label for="edit-pm-block-actions-more">' . t('Add new rule') . '</label></div>',
99
+    '#suffix' => '<label for="edit-pm-block-actions-more">'.t('Add new rule').'</label></div>',
100 100
     '#submit' => array('pm_block_user_more_submit'),
101 101
     '#ahah' => array(
102 102
       'path' => 'messages/block/js',
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
   else {
165 165
     // @todo: add whitelist options/default_value here.
166 166
   }
167
-  $form['action']  = array(
167
+  $form['action'] = array(
168 168
     '#type' => 'radios',
169 169
     '#options' => $options,
170 170
     '#disabled' => $row_disabled,
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
     '#value' => t('Remove'),
182 182
     '#attributes' => array('class' => 'remove-action'),
183 183
     '#prefix' => '<div id="remove-rule-button">',
184
-    '#suffix' => '<label for="edit-remove">' . t('Remove rule') . '</label></div>',
184
+    '#suffix' => '<label for="edit-remove">'.t('Remove rule').'</label></div>',
185 185
     '#ahah' => array(
186 186
       'path' => 'messages/block/js',
187 187
       'wrapper' => 'block-actions',
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
   $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id);
297 297
   $output_form = $form['block_actions'];
298 298
   unset($output_form['#prefix'], $output_form['#suffix']); // Prevent duplicate wrappers.
299
-  $output = theme('status_messages') . drupal_render($output_form);
299
+  $output = theme('status_messages').drupal_render($output_form);
300 300
 
301 301
   // Hack to make behaviours attach to new HTML controls (delete buttons in
302 302
   // this case).
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
   }
525 525
 
526 526
   $args = array_merge(array($author->uid), array_keys($recipients));
527
-  $result = db_query('SELECT recipient FROM {pm_block_user} WHERE author = %d AND recipient IN ('. db_placeholders($recipients) .') GROUP BY recipient', $args);
527
+  $result = db_query('SELECT recipient FROM {pm_block_user} WHERE author = %d AND recipient IN ('.db_placeholders($recipients).') GROUP BY recipient', $args);
528 528
   while ($row = db_fetch_array($result)) {
529 529
     $recipient = $recipients[$row['recipient']];
530 530
     // If there's a rule disallowing blocking of this message, send it anyway.
@@ -563,10 +563,10 @@  discard block
 block discarded – undo
563 563
 
564 564
   if ($user->uid <> $author->uid) {
565 565
     if ($vars['message']['is_blocked']) {
566
-      $vars['message_actions']['unblock_author'] = array('title' => t('Unblock author'), 'href' => 'messages/block/'. $author->uid, 'query' => 'destination=messages/view/' . $thread_id);
566
+      $vars['message_actions']['unblock_author'] = array('title' => t('Unblock author'), 'href' => 'messages/block/'.$author->uid, 'query' => 'destination=messages/view/'.$thread_id);
567 567
     }
568 568
     else {
569
-      $vars['message_actions']['block_author'] = array('title' => t('Block author'), 'href' => 'messages/block/'. $author->uid, 'query' => 'destination=messages/view/' . $thread_id);
569
+      $vars['message_actions']['block_author'] = array('title' => t('Block author'), 'href' => 'messages/block/'.$author->uid, 'query' => 'destination=messages/view/'.$thread_id);
570 570
     }
571 571
   }
572 572
 }
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -79,8 +79,7 @@  discard block
 block discarded – undo
79 79
   // Should we populate the form with data from $form_state or the database?
80 80
   if (!isset($form_state['pm_block_user']['block_actions'])) {
81 81
     $block_actions = variable_get('pm_block_user_actions', array());
82
-  }
83
-  else {
82
+  } else {
84 83
     $block_actions = $form_state['pm_block_user']['block_actions'];
85 84
   }
86 85
   // Work through each rule, adding it as a new element in
@@ -160,8 +159,7 @@  discard block
 block discarded – undo
160 159
       PM_BLOCK_USER_DISALLOW_SENDING => t('Disallow sending message'),
161 160
     );
162 161
     $default_value = (isset($details['action']) ? $details['action'] : PM_BLOCK_USER_DISALLOW_BLOCKING);
163
-  }
164
-  else {
162
+  } else {
165 163
     // @todo: add whitelist options/default_value here.
166 164
   }
167 165
   $form['action']  = array(
@@ -239,8 +237,7 @@  discard block
 block discarded – undo
239 237
     // builder.
240 238
     if (isset($form_state['values']['block_actions'])) {
241 239
       variable_set('pm_block_user_actions', _pm_block_user_settings_filter($form_state['values']['block_actions']));
242
-    }
243
-    else {
240
+    } else {
244 241
       variable_set('pm_block_user_actions', array());
245 242
     }
246 243
     drupal_set_message(t('The configuration options have been saved.'));
@@ -272,8 +269,7 @@  discard block
 block discarded – undo
272 269
   }
273 270
   if (count($matching) > 0) {
274 271
     return $matching;
275
-  }
276
-  else {
272
+  } else {
277 273
     return array_map('_pm_block_user_settings_filter', $settings);
278 274
   }
279 275
 }
@@ -463,8 +459,7 @@  discard block
 block discarded – undo
463 459
       t('Unblock @author', array('@author' => $author->name)),
464 460
       t('Cancel')
465 461
     );
466
-  }
467
-  else {
462
+  } else {
468 463
     $form['block_action'] = array(
469 464
       '#type' => 'value',
470 465
       '#value' => 'block_user',
@@ -564,8 +559,7 @@  discard block
 block discarded – undo
564 559
   if ($user->uid <> $author->uid) {
565 560
     if ($vars['message']['is_blocked']) {
566 561
       $vars['message_actions']['unblock_author'] = array('title' => t('Unblock author'), 'href' => 'messages/block/'. $author->uid, 'query' => 'destination=messages/view/' . $thread_id);
567
-    }
568
-    else {
562
+    } else {
569 563
       $vars['message_actions']['block_author'] = array('title' => t('Block author'), 'href' => 'messages/block/'. $author->uid, 'query' => 'destination=messages/view/' . $thread_id);
570 564
     }
571 565
   }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -65,12 +65,12 @@  discard block
 block discarded – undo
65 65
   drupal_add_css(drupal_get_path('module', 'pm_block_user') .'/pm_block_user.css');
66 66
   // Need to cache form for AHAH, so it can be rebuilt from cache later.
67 67
   $form = array(
68
-    '#cache' => TRUE,
68
+    '#cache' => true,
69 69
   );
70 70
 
71 71
   // Container for just the actions, used for AHAH.
72 72
   $form['block_actions'] = array(
73
-    '#tree' => TRUE,
73
+    '#tree' => true,
74 74
     '#prefix' => '<div id="block-actions">',
75 75
     '#suffix' => '</div>',
76 76
     '#theme' => 'pm_block_user_actions',
@@ -131,24 +131,24 @@  discard block
 block discarded – undo
131 131
  * @return
132 132
  *   Part of a form with controls for sending, receiving and actions.
133 133
  */
134
-function _pm_block_user_actions_form($details, $blacklist = TRUE) {
134
+function _pm_block_user_actions_form($details, $blacklist = true) {
135 135
   $form = array(
136
-    '#tree' => TRUE,
136
+    '#tree' => true,
137 137
   );
138 138
   $delta = $details['delta'];
139 139
   // FALSE by default, or if the user has checked the 'Enabled' check box for
140 140
   // this row.
141
-  $row_disabled = (isset($details['enabled']) ? !$details['enabled'] : FALSE);
141
+  $row_disabled = (isset($details['enabled']) ? !$details['enabled'] : false);
142 142
 
143 143
   $form['author'] = array(
144 144
     '#type' => 'select',
145
-    '#options' => user_roles(TRUE),
145
+    '#options' => user_roles(true),
146 146
     '#default_value' => (isset($details['author']) ? $details['author'] : DRUPAL_AUTHENTICATED_RID),
147 147
     '#disabled' => $row_disabled,
148 148
   );
149 149
   $form['recipient'] = array(
150 150
     '#type' => 'select',
151
-    '#options' => user_roles(TRUE),
151
+    '#options' => user_roles(true),
152 152
     '#default_value' => (isset($details['recipient']) ? $details['recipient'] : DRUPAL_AUTHENTICATED_RID),
153 153
     '#disabled' => $row_disabled,
154 154
   );
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 
174 174
   $form['enabled'] = array(
175 175
     '#type' => 'checkbox',
176
-    '#default_value' => (isset($details['enabled']) ? $details['enabled'] : TRUE),
176
+    '#default_value' => (isset($details['enabled']) ? $details['enabled'] : true),
177 177
   );
178 178
   $form['remove'] = array(
179 179
     '#type' => 'submit',
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
   $form_state['pm_block_user'] = $submitted_values;
210 210
   // Rebuild the form by passing our $form_state through the
211 211
   // pm_block_user_settings() builder function.
212
-  $form_state['rebuild'] = TRUE;
212
+  $form_state['rebuild'] = true;
213 213
 }
214 214
 
215 215
 /**
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
   $delta = $form_state['clicked_button']['#parents'][1];
226 226
   unset($submitted_values['block_actions'][$delta]);
227 227
   $form_state['pm_block_user'] = $submitted_values;
228
-  $form_state['rebuild'] = TRUE;
228
+  $form_state['rebuild'] = true;
229 229
 }
230 230
 
231 231
 /**
@@ -283,14 +283,14 @@  discard block
 block discarded – undo
283 283
  */
284 284
 function pm_block_user_js() {
285 285
   // See: http://drupal.org/node/331941 for the philosophy of Drupal AHAH.
286
-  $form_state = array('storage' => NULL, 'submitted' => FALSE);
286
+  $form_state = array('storage' => null, 'submitted' => false);
287 287
   $form_build_id = $_POST['form_build_id'];
288 288
   $form = form_get_cache($form_build_id, $form_state);
289 289
   $args = $form['#parameters'];
290 290
   $form_id = array_shift($args);
291 291
   $form['#post'] = $_POST;
292
-  $form['#redirect'] = FALSE;
293
-  $form['#programmed'] = FALSE;
292
+  $form['#redirect'] = false;
293
+  $form['#programmed'] = false;
294 294
   $form_state['post'] = $_POST;
295 295
   drupal_process_form($form_id, $form, $form_state);
296 296
   $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id);
@@ -300,8 +300,8 @@  discard block
 block discarded – undo
300 300
 
301 301
   // Hack to make behaviours attach to new HTML controls (delete buttons in
302 302
   // this case).
303
-  $javascript = drupal_add_js(NULL, NULL, 'header');
304
-  drupal_json(array('status' => TRUE, 'data' => $output));
303
+  $javascript = drupal_add_js(null, null, 'header');
304
+  drupal_json(array('status' => true, 'data' => $output));
305 305
 }
306 306
 
307 307
 /**
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 function pm_block_user_theme() {
311 311
   return array(
312 312
     'pm_block_user_actions' => array(
313
-      'arguments' => array('form' => NULL),
313
+      'arguments' => array('form' => null),
314 314
     ),
315 315
   );
316 316
 }
@@ -379,12 +379,12 @@  discard block
 block discarded – undo
379 379
 function _pm_block_user_access($account) {
380 380
   global $user;
381 381
   if (!privatemsg_user_access('read privatemsg', $user)) {
382
-    return FALSE;
382
+    return false;
383 383
   }
384 384
   if (_pm_block_user_rule_exists($account, $user, PM_BLOCK_USER_DISALLOW_BLOCKING)) {
385
-    return FALSE;
385
+    return false;
386 386
   }
387
-  return TRUE;
387
+  return true;
388 388
 }
389 389
 
390 390
 /**
@@ -425,10 +425,10 @@  discard block
 block discarded – undo
425 425
     }
426 426
     // The author has a role matching the rule and so does the recipient.
427 427
     if (isset($author->roles[$details['author']]) && isset($recipient->roles[$details['recipient']])) {
428
-      return TRUE;
428
+      return true;
429 429
     }
430 430
   }
431
-  return FALSE;
431
+  return false;
432 432
 }
433 433
 
434 434
 function pm_block_user_form($form_state, $author) {
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 /**
575 575
  * Implement hook_user().
576 576
  */
577
-function pm_block_user_user($op, &$edit, &$account, $category = NULL) {
577
+function pm_block_user_user($op, &$edit, &$account, $category = null) {
578 578
   switch ($op) {
579 579
       case 'delete':
580 580
       // Delete blocking rules which involve this user.
Please login to merge, or discard this patch.
boinc/modules/contrib/privatemsg/pm_email_notify/pm_email_notify.module 6 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -148,6 +148,8 @@
 block discarded – undo
148 148
  * Implements hook_user().
149 149
  *
150 150
  * Display settings form and store its information.
151
+ * @param string $op
152
+ * @param string $category
151 153
  */
152 154
 function pm_email_notify_user($op, &$edit, &$account, $category = NULL) {
153 155
   switch ($op) {
Please login to merge, or discard this patch.
Switch Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -106,10 +106,10 @@  discard block
 block discarded – undo
106 106
   $variables = user_mail_tokens($params['recipient'], $language);
107 107
   $variables = array_merge($variables, _pm_email_notify_token($params['recipient'], $params['message'], $language));
108 108
   switch ($key) {
109
-    case 'notice':
110
-      $message['subject'] = t(variable_get('pm_email_notify_subject', 'New private message at !site.'), $variables, $language->language);
111
-      $message['body'] = t(variable_get('pm_email_notify_body', _pm_email_notify_default_body()), $variables, $language->language);
112
-      break;
109
+  case 'notice':
110
+    $message['subject'] = t(variable_get('pm_email_notify_subject', 'New private message at !site.'), $variables, $language->language);
111
+    $message['body'] = t(variable_get('pm_email_notify_body', _pm_email_notify_default_body()), $variables, $language->language);
112
+    break;
113 113
   }
114 114
 }
115 115
 
@@ -151,42 +151,42 @@  discard block
 block discarded – undo
151 151
  */
152 152
 function pm_email_notify_user($op, &$edit, &$account, $category = NULL) {
153 153
   switch ($op) {
154
-    case 'form':
155
-      if ($category == 'account' && privatemsg_user_access('read privatemsg', $account)) {
156
-        $form['enable_pm_mail'] = array(
157
-          '#type' => 'fieldset',
158
-          '#title' => t('Privatemsg e-mail notification'),
159
-          '#collapsible' => TRUE,
160
-          '#collapsed' => FALSE,
161
-          '#weight' => 10,
162
-        );
163
-        $form['enable_pm_mail']['pm_send_notifications'] = array(
164
-          '#type' => 'checkbox',
165
-          '#title' => t('Receive email notification for incoming private messages'),
166
-          '#default_value' => _pm_email_notify_is_enabled($account->uid),
167
-        );
168
-      }
169
-      return $form;
154
+  case 'form':
155
+    if ($category == 'account' && privatemsg_user_access('read privatemsg', $account)) {
156
+      $form['enable_pm_mail'] = array(
157
+        '#type' => 'fieldset',
158
+        '#title' => t('Privatemsg e-mail notification'),
159
+        '#collapsible' => TRUE,
160
+        '#collapsed' => FALSE,
161
+        '#weight' => 10,
162
+      );
163
+      $form['enable_pm_mail']['pm_send_notifications'] = array(
164
+        '#type' => 'checkbox',
165
+        '#title' => t('Receive email notification for incoming private messages'),
166
+        '#default_value' => _pm_email_notify_is_enabled($account->uid),
167
+      );
168
+    }
169
+    return $form;
170 170
 
171
-     case 'submit':
172
-      if (isset($edit['pm_send_notifications']) && privatemsg_user_access('read privatemsg', $account)) {
173
-        $pm_email_enabled = $edit['pm_send_notifications'];
174
-        unset($edit['pm_send_notifications']);
175
-        // Update database entry with user preference.
176
-        $exists = db_result(db_query("SELECT 1 FROM {pm_email_notify} WHERE user_id = %d", $account->uid));
177
-        if ($exists) {
178
-          // If there is an existing entry, update.
179
-          db_query("UPDATE {pm_email_notify} SET email_notify_is_enabled = %d WHERE user_id = %d", $pm_email_enabled, $account->uid);
180
-        }
181
-        else {
182
-          // If not, create a new one.
183
-          db_query("INSERT INTO {pm_email_notify} (email_notify_is_enabled, user_id) VALUES (%d, %d)", $pm_email_enabled, $account->uid);
184
-        }
185
-      }
186
-      break;
171
+  case 'submit':
172
+   if (isset($edit['pm_send_notifications']) && privatemsg_user_access('read privatemsg', $account)) {
173
+     $pm_email_enabled = $edit['pm_send_notifications'];
174
+     unset($edit['pm_send_notifications']);
175
+     // Update database entry with user preference.
176
+     $exists = db_result(db_query("SELECT 1 FROM {pm_email_notify} WHERE user_id = %d", $account->uid));
177
+     if ($exists) {
178
+       // If there is an existing entry, update.
179
+       db_query("UPDATE {pm_email_notify} SET email_notify_is_enabled = %d WHERE user_id = %d", $pm_email_enabled, $account->uid);
180
+     }
181
+     else {
182
+       // If not, create a new one.
183
+       db_query("INSERT INTO {pm_email_notify} (email_notify_is_enabled, user_id) VALUES (%d, %d)", $pm_email_enabled, $account->uid);
184
+     }
185
+   }
186
+   break;
187 187
 
188
-     case 'delete':
189
-      db_query("DELETE FROM {pm_email_notify} WHERE user_id = %d", $account->uid);
190
-      break;
188
+  case 'delete':
189
+   db_query("DELETE FROM {pm_email_notify} WHERE user_id = %d", $account->uid);
190
+   break;
191 191
   }
192 192
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -177,8 +177,7 @@
 block discarded – undo
177 177
         if ($exists) {
178 178
           // If there is an existing entry, update.
179 179
           db_query("UPDATE {pm_email_notify} SET email_notify_is_enabled = %d WHERE user_id = %d", $pm_email_enabled, $account->uid);
180
-        }
181
-        else {
180
+        } else {
182 181
           // If not, create a new one.
183 182
           db_query("INSERT INTO {pm_email_notify} (email_notify_is_enabled, user_id) VALUES (%d, %d)", $pm_email_enabled, $account->uid);
184 183
         }
Please login to merge, or discard this patch.
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  * Implements hook_menu().
10 10
  */
11 11
 function pm_email_notify_menu() {
12
-  $items['admin/settings/messages/notify'] = array(
12
+    $items['admin/settings/messages/notify'] = array(
13 13
     'title'            => 'E-mail notify',
14 14
     'description'      => 'E-mail notification settings',
15 15
     'page callback'    => 'drupal_get_form',
@@ -17,47 +17,47 @@  discard block
 block discarded – undo
17 17
     'access arguments' => array('administer privatemsg settings'),
18 18
     'type'             => MENU_LOCAL_TASK,
19 19
     'weight'           => 10,
20
-  );
21
-  return $items;
20
+    );
21
+    return $items;
22 22
 }
23 23
 
24 24
 /**
25 25
  * Menu callback for administration settings.
26 26
  */
27 27
 function pm_email_notify_admin_settings_form() {
28
-  $form['pm_email'] = array(
28
+    $form['pm_email'] = array(
29 29
     '#type' => 'fieldset',
30 30
     '#title' => t('Privatemsg e-mail notification'),
31 31
     '#collapsible' => FALSE,
32 32
     '#collapsed' => FALSE,
33
-  );
34
-  $form['pm_email']['pm_email_notify_default'] = array(
33
+    );
34
+    $form['pm_email']['pm_email_notify_default'] = array(
35 35
     '#type' => 'checkbox',
36 36
     '#title' => t('Notify users of new private messages by default'),
37 37
     '#default_value' => variable_get('pm_email_notify_default', TRUE),
38 38
     '#weight' => 0,
39
-  );
39
+    );
40 40
 
41
-  $form['pm_email']['pm_email_notify_desc'] = array(
41
+    $form['pm_email']['pm_email_notify_desc'] = array(
42 42
     '#type' => 'item',
43 43
     '#value' => t('Customize the email messages sent to users upon receipt of a new private message. <br />Available variables are: !author, !author_uid, !pm_subject, !pm_body, !thread, !site, !login_url, !uri, !uri_brief, !message (URL), !settings (URL), !boincuser_name, and !author_boincuser_name.'),
44 44
     '#weight' => 1,
45
-  );
45
+    );
46 46
 
47
-  $form['pm_email']['pm_email_notify_subject'] = array(
47
+    $form['pm_email']['pm_email_notify_subject'] = array(
48 48
     '#type' => 'textfield',
49 49
     '#title' => t('Subject of notification messages'),
50 50
     '#default_value' => variable_get('pm_email_notify_subject', 'New private message at !site.'),
51 51
     '#weight' => 2,
52
-  );
52
+    );
53 53
 
54
-  $form['pm_email']['pm_email_notify_body'] = array(
54
+    $form['pm_email']['pm_email_notify_body'] = array(
55 55
     '#type' => 'textarea',
56 56
     '#title' => t('Body of notification messages'),
57 57
     '#default_value' => variable_get('pm_email_notify_body', _pm_email_notify_default_body()),
58 58
     '#weight' => 3,
59
-  );
60
-  return system_settings_form($form);
59
+    );
60
+    return system_settings_form($form);
61 61
 }
62 62
 
63 63
 /**
@@ -70,47 +70,47 @@  discard block
 block discarded – undo
70 70
  *   User uid
71 71
  */
72 72
 function _pm_email_notify_is_enabled($uid) {
73
-  static $notifications = array();
74
-  // Cache the result set in case this method is executed in batched operation which will perform many unnecessary repeated selects for the same user
75
-  if ( !isset($notifications[$uid]) ) {
73
+    static $notifications = array();
74
+    // Cache the result set in case this method is executed in batched operation which will perform many unnecessary repeated selects for the same user
75
+    if ( !isset($notifications[$uid]) ) {
76 76
     $mail_notification = db_result(db_query('SELECT email_notify_is_enabled FROM {pm_email_notify} WHERE user_id = %d', $uid));
77 77
     if ($mail_notification === FALSE) {
78
-      // db_result() returns FALSE if result was not found.
79
-      $mail_notification = variable_get('pm_email_notify_default', TRUE);
78
+        // db_result() returns FALSE if result was not found.
79
+        $mail_notification = variable_get('pm_email_notify_default', TRUE);
80 80
     }
81 81
     $notifications[$uid] = $mail_notification;
82
-  }
83
-  return $notifications[$uid];
82
+    }
83
+    return $notifications[$uid];
84 84
 }
85 85
 
86 86
 /**
87 87
  * Implements hook_privatemsg_message_insert().
88 88
  */
89 89
 function pm_email_notify_privatemsg_message_insert($message) {
90
-  foreach ($message['recipients'] as $recipient) {
90
+    foreach ($message['recipients'] as $recipient) {
91 91
     // check if recipient enabled email notifications
92 92
     if (_pm_email_notify_is_enabled($recipient->uid)) {
93
-      // send them a new pm notification email if they did
94
-      $params['recipient'] = $recipient;
95
-      $params['message'] = $message;
96
-      drupal_mail('pm_email_notify', 'notice', $recipient->mail, user_preferred_language($recipient), $params);
93
+        // send them a new pm notification email if they did
94
+        $params['recipient'] = $recipient;
95
+        $params['message'] = $message;
96
+        drupal_mail('pm_email_notify', 'notice', $recipient->mail, user_preferred_language($recipient), $params);
97
+    }
97 98
     }
98
-  }
99 99
 }
100 100
 
101 101
 /**
102 102
  * Implements hook_mail().
103 103
  */
104 104
 function pm_email_notify_mail($key, &$message, $params) {
105
-  $language = $message['language'];
106
-  $variables = user_mail_tokens($params['recipient'], $language);
107
-  $variables = array_merge($variables, _pm_email_notify_token($params['recipient'], $params['message'], $language));
108
-  switch ($key) {
105
+    $language = $message['language'];
106
+    $variables = user_mail_tokens($params['recipient'], $language);
107
+    $variables = array_merge($variables, _pm_email_notify_token($params['recipient'], $params['message'], $language));
108
+    switch ($key) {
109 109
     case 'notice':
110 110
       $message['subject'] = t(variable_get('pm_email_notify_subject', 'New private message at !site.'), $variables, $language->language);
111
-      $message['body'] = t(variable_get('pm_email_notify_body', _pm_email_notify_default_body()), $variables, $language->language);
112
-      break;
113
-  }
111
+        $message['body'] = t(variable_get('pm_email_notify_body', _pm_email_notify_default_body()), $variables, $language->language);
112
+        break;
113
+    }
114 114
 }
115 115
 
116 116
 /**
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
  *   Array of mappings from token names to values (for use with strtr()).
124 124
  */
125 125
 function _pm_email_notify_token($recipient, $message, $language) {
126
-  $tokens = array(
126
+    $tokens = array(
127 127
     '!author_uid' => $message['author']->uid,
128 128
     '!author' => $message['author']->name,
129 129
     '!pm_subject' => trim(drupal_html_to_text(check_plain($message['subject']))),
@@ -134,16 +134,16 @@  discard block
 block discarded – undo
134 134
     '!settings' => url('user/' . $recipient->uid . '/edit', array('absolute' => TRUE, 'language' => $language)),
135 135
     '!boincuser_name' => $recipient->boincuser_name,
136 136
     '!author_boincuser_name' => user_load($message['author']->uid)->boincuser_name,
137
-  );
137
+    );
138 138
 
139
-  return $tokens;
139
+    return $tokens;
140 140
 }
141 141
 
142 142
 /**
143 143
  * Returns default email notification body.
144 144
  */
145 145
 function _pm_email_notify_default_body() {
146
-  return "Hi !username,\n\nThis is an automatic reminder from the site !site. You have received a new private message from !author.\n\nTo read your message, follow this link:\n!message\n\nIf you don't want to receive these emails again, change your preferences here:\n!settings";
146
+    return "Hi !username,\n\nThis is an automatic reminder from the site !site. You have received a new private message from !author.\n\nTo read your message, follow this link:\n!message\n\nIf you don't want to receive these emails again, change your preferences here:\n!settings";
147 147
 }
148 148
 
149 149
 /**
@@ -152,43 +152,43 @@  discard block
 block discarded – undo
152 152
  * Display settings form and store its information.
153 153
  */
154 154
 function pm_email_notify_user($op, &$edit, &$account, $category = NULL) {
155
-  switch ($op) {
155
+    switch ($op) {
156 156
     case 'form':
157 157
       if ($category == 'account' && privatemsg_user_access('read privatemsg', $account)) {
158 158
         $form['enable_pm_mail'] = array(
159
-          '#type' => 'fieldset',
160
-          '#title' => t('Privatemsg e-mail notification'),
161
-          '#collapsible' => TRUE,
162
-          '#collapsed' => FALSE,
163
-          '#weight' => 10,
159
+            '#type' => 'fieldset',
160
+            '#title' => t('Privatemsg e-mail notification'),
161
+            '#collapsible' => TRUE,
162
+            '#collapsed' => FALSE,
163
+            '#weight' => 10,
164 164
         );
165 165
         $form['enable_pm_mail']['pm_send_notifications'] = array(
166
-          '#type' => 'checkbox',
167
-          '#title' => t('Receive email notification for incoming private messages'),
168
-          '#default_value' => _pm_email_notify_is_enabled($account->uid),
166
+            '#type' => 'checkbox',
167
+            '#title' => t('Receive email notification for incoming private messages'),
168
+            '#default_value' => _pm_email_notify_is_enabled($account->uid),
169 169
         );
170
-      }
171
-      return $form;
170
+        }
171
+        return $form;
172 172
 
173
-     case 'submit':
173
+        case 'submit':
174 174
       if (isset($edit['pm_send_notifications']) && privatemsg_user_access('read privatemsg', $account)) {
175 175
         $pm_email_enabled = $edit['pm_send_notifications'];
176 176
         unset($edit['pm_send_notifications']);
177 177
         // Update database entry with user preference.
178 178
         $exists = db_result(db_query("SELECT 1 FROM {pm_email_notify} WHERE user_id = %d", $account->uid));
179 179
         if ($exists) {
180
-          // If there is an existing entry, update.
181
-          db_query("UPDATE {pm_email_notify} SET email_notify_is_enabled = %d WHERE user_id = %d", $pm_email_enabled, $account->uid);
180
+            // If there is an existing entry, update.
181
+            db_query("UPDATE {pm_email_notify} SET email_notify_is_enabled = %d WHERE user_id = %d", $pm_email_enabled, $account->uid);
182 182
         }
183 183
         else {
184
-          // If not, create a new one.
185
-          db_query("INSERT INTO {pm_email_notify} (email_notify_is_enabled, user_id) VALUES (%d, %d)", $pm_email_enabled, $account->uid);
184
+            // If not, create a new one.
185
+            db_query("INSERT INTO {pm_email_notify} (email_notify_is_enabled, user_id) VALUES (%d, %d)", $pm_email_enabled, $account->uid);
186
+        }
186 187
         }
187
-      }
188
-      break;
188
+        break;
189 189
 
190
-     case 'delete':
190
+        case 'delete':
191 191
       db_query("DELETE FROM {pm_email_notify} WHERE user_id = %d", $account->uid);
192
-      break;
193
-  }
192
+        break;
193
+    }
194 194
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 function _pm_email_notify_is_enabled($uid) {
73 73
   static $notifications = array();
74 74
   // Cache the result set in case this method is executed in batched operation which will perform many unnecessary repeated selects for the same user
75
-  if ( !isset($notifications[$uid]) ) {
75
+  if (!isset($notifications[$uid])) {
76 76
     $mail_notification = db_result(db_query('SELECT email_notify_is_enabled FROM {pm_email_notify} WHERE user_id = %d', $uid));
77 77
     if ($mail_notification === FALSE) {
78 78
       // db_result() returns FALSE if result was not found.
@@ -130,8 +130,8 @@  discard block
 block discarded – undo
130 130
     '!pm_body' => trim(drupal_html_to_text(check_markup($message['body'], $message['format'], FALSE))),
131 131
     '!thread' => $message['thread_id'],
132 132
     '!user_uid' => $recipient->uid,
133
-    '!message' => url('messages/view/' . $message['thread_id'], array('absolute' => TRUE, 'language' => $language)),
134
-    '!settings' => url('user/' . $recipient->uid . '/edit', array('absolute' => TRUE, 'language' => $language)),
133
+    '!message' => url('messages/view/'.$message['thread_id'], array('absolute' => TRUE, 'language' => $language)),
134
+    '!settings' => url('user/'.$recipient->uid.'/edit', array('absolute' => TRUE, 'language' => $language)),
135 135
     '!boincuser_name' => $recipient->boincuser_name,
136 136
     '!author_boincuser_name' => user_load($message['author']->uid)->boincuser_name,
137 137
   );
Please login to merge, or discard this patch.
Upper-Lower-Casing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -28,13 +28,13 @@  discard block
 block discarded – undo
28 28
   $form['pm_email'] = array(
29 29
     '#type' => 'fieldset',
30 30
     '#title' => t('Privatemsg e-mail notification'),
31
-    '#collapsible' => FALSE,
32
-    '#collapsed' => FALSE,
31
+    '#collapsible' => false,
32
+    '#collapsed' => false,
33 33
   );
34 34
   $form['pm_email']['pm_email_notify_default'] = array(
35 35
     '#type' => 'checkbox',
36 36
     '#title' => t('Notify users of new private messages by default'),
37
-    '#default_value' => variable_get('pm_email_notify_default', TRUE),
37
+    '#default_value' => variable_get('pm_email_notify_default', true),
38 38
     '#weight' => 0,
39 39
   );
40 40
 
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
   // Cache the result set in case this method is executed in batched operation which will perform many unnecessary repeated selects for the same user
75 75
   if ( !isset($notifications[$uid]) ) {
76 76
     $mail_notification = db_result(db_query('SELECT email_notify_is_enabled FROM {pm_email_notify} WHERE user_id = %d', $uid));
77
-    if ($mail_notification === FALSE) {
77
+    if ($mail_notification === false) {
78 78
       // db_result() returns FALSE if result was not found.
79
-      $mail_notification = variable_get('pm_email_notify_default', TRUE);
79
+      $mail_notification = variable_get('pm_email_notify_default', true);
80 80
     }
81 81
     $notifications[$uid] = $mail_notification;
82 82
   }
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
     '!author_uid' => $message['author']->uid,
128 128
     '!author' => $message['author']->name,
129 129
     '!pm_subject' => trim(drupal_html_to_text(check_plain($message['subject']))),
130
-    '!pm_body' => trim(drupal_html_to_text(check_markup($message['body'], $message['format'], FALSE))),
130
+    '!pm_body' => trim(drupal_html_to_text(check_markup($message['body'], $message['format'], false))),
131 131
     '!thread' => $message['thread_id'],
132 132
     '!user_uid' => $recipient->uid,
133
-    '!message' => url('messages/view/' . $message['thread_id'], array('absolute' => TRUE, 'language' => $language)),
134
-    '!settings' => url('user/' . $recipient->uid . '/edit', array('absolute' => TRUE, 'language' => $language)),
133
+    '!message' => url('messages/view/' . $message['thread_id'], array('absolute' => true, 'language' => $language)),
134
+    '!settings' => url('user/' . $recipient->uid . '/edit', array('absolute' => true, 'language' => $language)),
135 135
     '!boincuser_name' => $recipient->boincuser_name,
136 136
     '!author_boincuser_name' => user_load($message['author']->uid)->boincuser_name,
137 137
   );
@@ -151,15 +151,15 @@  discard block
 block discarded – undo
151 151
  *
152 152
  * Display settings form and store its information.
153 153
  */
154
-function pm_email_notify_user($op, &$edit, &$account, $category = NULL) {
154
+function pm_email_notify_user($op, &$edit, &$account, $category = null) {
155 155
   switch ($op) {
156 156
     case 'form':
157 157
       if ($category == 'account' && privatemsg_user_access('read privatemsg', $account)) {
158 158
         $form['enable_pm_mail'] = array(
159 159
           '#type' => 'fieldset',
160 160
           '#title' => t('Privatemsg e-mail notification'),
161
-          '#collapsible' => TRUE,
162
-          '#collapsed' => FALSE,
161
+          '#collapsible' => true,
162
+          '#collapsed' => false,
163 163
           '#weight' => 10,
164 164
         );
165 165
         $form['enable_pm_mail']['pm_send_notifications'] = array(
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/contrib/privatemsg/privatemsg.module 6 patches
Doc Comments   +7 added lines, -5 removed lines patch added patch discarded remove patch
@@ -37,6 +37,7 @@  discard block
 block discarded – undo
37 37
  *
38 38
  * @param $userstring
39 39
  *   A string with user id, for example 1,2,4. Returned by the list query
40
+ * @param integer $slice
40 41
  *
41 42
  * @return
42 43
  *   Array with user objects.
@@ -72,7 +73,7 @@  discard block
 block discarded – undo
72 73
  *   Array with user objects, for example the one returnd by
73 74
  *   _privatemsg_generate_user_array.
74 75
  *
75
- * @param $limit
76
+ * @param integer $limit
76 77
  *   Limit the number of user objects which should be displayed.
77 78
  * @param $no_text
78 79
  *   When TRUE, don't display the Participants/From text.
@@ -215,7 +216,7 @@  discard block
 block discarded – undo
215 216
  *   Permission string, defaults to read privatemsg
216 217
  *
217 218
  * @return
218
- *   TRUE if user has access, FALSE if not
219
+ boolean   TRUE if user has access, FALSE if not
219 220
  *
220 221
  * @ingroup api
221 222
  */
@@ -730,7 +731,7 @@  discard block
 block discarded – undo
730 731
  *
731 732
  * @param $pmid
732 733
  *   Message id
733
- * @param $status
734
+ * @param integer $status
734 735
  *   Either PRIVATEMSG_READ or PRIVATEMSG_UNREAD
735 736
  * @param $account
736 737
  *   User object, defaults to the current user
@@ -1949,9 +1950,10 @@  discard block
 block discarded – undo
1949 1950
  *   Recipient of the message
1950 1951
  * @param $account
1951 1952
  *   Sender of the message, defaults to the current user
1953
+ * @param string $subject
1952 1954
  *
1953 1955
  * @return
1954
- *   Either FALSE or a URL string
1956
+ false|string   Either FALSE or a URL string
1955 1957
  *
1956 1958
  * @ingroup api
1957 1959
  */
@@ -2273,7 +2275,7 @@  discard block
 block discarded – undo
2273 2275
  *
2274 2276
  * Uses @link theming theme patterns @endlink to theme single headers.
2275 2277
  *
2276
- * @param $has_posts
2278
+ * @param boolean $has_posts
2277 2279
  *   TRUE when there is at least one row. Decides if the select all checkbox
2278 2280
  *   should be displayed.
2279 2281
  * @param $keys
Please login to merge, or discard this patch.
Switch Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -1437,43 +1437,43 @@  discard block
 block discarded – undo
1437 1437
   global $user;
1438 1438
 
1439 1439
   switch ($op) {
1440
-    case 'view':
1441
-      if ($url = privatemsg_get_link(array($account))) {
1442
-        $account->content['privatemsg_send_new_message'] = array(
1443
-          '#type'   => 'markup',
1444
-          '#value'  => l(t('Send this user a message'), $url, array('query' => drupal_get_destination())),
1445
-          '#weight' => 10,
1446
-        );
1447
-      }
1448
-      break;
1449
-    case 'login':
1450
-      if (variable_get('privatemsg_display_loginmessage', TRUE) && privatemsg_user_access()) {
1451
-        $count = privatemsg_unread_count();
1452
-        if ($count) {
1453
-          drupal_set_message(format_plural($count, 'You have <a href="@messages">1 unread message</a>.', 'You have <a href="@messages">@count unread messages</a>', array('@messages' => url('messages'))));
1454
-        }
1440
+  case 'view':
1441
+    if ($url = privatemsg_get_link(array($account))) {
1442
+      $account->content['privatemsg_send_new_message'] = array(
1443
+        '#type'   => 'markup',
1444
+        '#value'  => l(t('Send this user a message'), $url, array('query' => drupal_get_destination())),
1445
+        '#weight' => 10,
1446
+      );
1447
+    }
1448
+    break;
1449
+  case 'login':
1450
+    if (variable_get('privatemsg_display_loginmessage', TRUE) && privatemsg_user_access()) {
1451
+      $count = privatemsg_unread_count();
1452
+      if ($count) {
1453
+        drupal_set_message(format_plural($count, 'You have <a href="@messages">1 unread message</a>.', 'You have <a href="@messages">@count unread messages</a>', array('@messages' => url('messages'))));
1455 1454
       }
1456
-      break;
1457
-    case 'delete':
1455
+    }
1456
+    break;
1457
+  case 'delete':
1458 1458
 
1459
-      // Load all mids of the messages the user wrote.
1460
-      $result = db_query("SELECT mid FROM {pm_message} WHERE author = %d", $account->uid);
1461
-      $mids = array();
1462
-      while ($row = db_fetch_array($result)) {
1463
-        $mids[] = $row['mid'];
1464
-      }
1459
+    // Load all mids of the messages the user wrote.
1460
+    $result = db_query("SELECT mid FROM {pm_message} WHERE author = %d", $account->uid);
1461
+    $mids = array();
1462
+    while ($row = db_fetch_array($result)) {
1463
+      $mids[] = $row['mid'];
1464
+    }
1465 1465
 
1466
-      // Delete messages the user wrote.
1467
-      db_query('DELETE FROM {pm_message} WHERE author = %d', $account->uid);
1466
+    // Delete messages the user wrote.
1467
+    db_query('DELETE FROM {pm_message} WHERE author = %d', $account->uid);
1468 1468
 
1469
-      if (!empty($mids)) {
1470
-        // Delete recipient entries in {pm_index} of the messages the user wrote.
1471
-        db_query('DELETE FROM {pm_index} WHERE mid IN (' . db_placeholders($mids) . ')', $mids);
1472
-      }
1469
+    if (!empty($mids)) {
1470
+      // Delete recipient entries in {pm_index} of the messages the user wrote.
1471
+      db_query('DELETE FROM {pm_index} WHERE mid IN (' . db_placeholders($mids) . ')', $mids);
1472
+    }
1473 1473
 
1474
-      // Delete recipient entries of that user.
1475
-      db_query('DELETE FROM {pm_index} WHERE uid = %d', $account->uid);
1476
-      break;
1474
+    // Delete recipient entries of that user.
1475
+    db_query('DELETE FROM {pm_index} WHERE uid = %d', $account->uid);
1476
+    break;
1477 1477
   }
1478 1478
 }
1479 1479
 
@@ -1494,12 +1494,12 @@  discard block
 block discarded – undo
1494 1494
   elseif ('view' == $op) {
1495 1495
     $block = array();
1496 1496
     switch ($delta) {
1497
-      case 'privatemsg-menu':
1498
-        $block = _privatemsg_block_menu();
1499
-        break;
1500
-      case 'privatemsg-new':
1501
-        $block = _privatemsg_block_new();
1502
-        break;
1497
+    case 'privatemsg-menu':
1498
+      $block = _privatemsg_block_menu();
1499
+      break;
1500
+    case 'privatemsg-new':
1501
+      $block = _privatemsg_block_new();
1502
+      break;
1503 1503
     }
1504 1504
     return $block;
1505 1505
   }
Please login to merge, or discard this patch.
Indentation   +1082 added lines, -1083 removed lines patch added patch discarded remove patch
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
  * Implements hook_perm().
23 23
  */
24 24
 function privatemsg_perm() {
25
-  return array(
25
+    return array(
26 26
     'read privatemsg',
27 27
     'read all private messages',
28 28
     'administer privatemsg settings',
29 29
     'write privatemsg',
30 30
     'delete privatemsg',
31
-  );
31
+    );
32 32
 }
33 33
 
34 34
 /**
@@ -42,27 +42,27 @@  discard block
 block discarded – undo
42 42
  *   Array with user objects.
43 43
  */
44 44
 function _privatemsg_generate_user_array($userstring, $slice = NULL) {
45
-  static $user_cache = array();
46
-
47
-  // Convert user uid list (uid1,uid2,uid3) into an array. If $slice is not NULL
48
-  // pass that as argument to array_slice(). For example, -4 will only load the
49
-  // last four users.
50
-  // This is done to avoid loading user objects that are not displayed, for
51
-  // obvious performance reasons.
52
-  $users = explode(',', $userstring);
53
-  if (!is_null($slice)) {
45
+    static $user_cache = array();
46
+
47
+    // Convert user uid list (uid1,uid2,uid3) into an array. If $slice is not NULL
48
+    // pass that as argument to array_slice(). For example, -4 will only load the
49
+    // last four users.
50
+    // This is done to avoid loading user objects that are not displayed, for
51
+    // obvious performance reasons.
52
+    $users = explode(',', $userstring);
53
+    if (!is_null($slice)) {
54 54
     $users = array_slice($users, $slice);
55
-  }
56
-  $participants = array();
57
-  foreach ($users as $uid) {
55
+    }
56
+    $participants = array();
57
+    foreach ($users as $uid) {
58 58
     if (!array_key_exists($uid, $user_cache)) {
59
-      $user_cache[$uid] = user_load($uid);
59
+        $user_cache[$uid] = user_load($uid);
60 60
     }
61 61
     if (is_object($user_cache[$uid])) {
62
-      $participants[$uid] = $user_cache[$uid];
62
+        $participants[$uid] = $user_cache[$uid];
63
+    }
63 64
     }
64
-  }
65
-  return $participants;
65
+    return $participants;
66 66
 }
67 67
 
68 68
 /**
@@ -80,60 +80,60 @@  discard block
 block discarded – undo
80 80
  *   String with formated user objects, like user1, user2.
81 81
  */
82 82
 function _privatemsg_format_participants($part_array, $limit = NULL, $no_text = FALSE) {
83
-  if (count($part_array) > 0) {
83
+    if (count($part_array) > 0) {
84 84
     $to = array();
85 85
     $limited = FALSE;
86 86
     foreach ($part_array as $account) {
87
-      if (is_int($limit) && count($to) >= $limit) {
87
+        if (is_int($limit) && count($to) >= $limit) {
88 88
         $limited = TRUE;
89 89
         break;
90
-      }
91
-      $to[] = theme('username', $account);
90
+        }
91
+        $to[] = theme('username', $account);
92 92
     }
93 93
 
94 94
     $limit_string = '';
95 95
     if ($limited) {
96
-      $limit_string = t(' and others');
96
+        $limit_string = t(' and others');
97 97
     }
98 98
 
99 99
 
100 100
     if ($no_text) {
101
-      return implode(', ', $to) . $limit_string;
101
+        return implode(', ', $to) . $limit_string;
102 102
     }
103 103
 
104 104
     $last = array_pop($to);
105 105
     if (count($to) == 0) { // Only one participant
106
-      return t("From !last", array('!last' => $last));
106
+        return t("From !last", array('!last' => $last));
107 107
     }
108 108
     else { // Multipe participants..
109
-      $participants = implode(', ', $to);
110
-      return t('Participants: !participants and !last', array('!participants' => $participants, '!last' => $last));
109
+        $participants = implode(', ', $to);
110
+        return t('Participants: !participants and !last', array('!participants' => $participants, '!last' => $last));
111
+    }
111 112
     }
112
-  }
113
-  return '';
113
+    return '';
114 114
 }
115 115
 
116 116
 /**
117 117
  * Implements hook_menu().
118 118
  */
119 119
 function privatemsg_menu() {
120
-  $items['messages'] = array(
120
+    $items['messages'] = array(
121 121
     'title'            => 'Messages',
122 122
     'title callback'  => 'privatemsg_title_callback',
123 123
     'page callback'    => 'drupal_get_form',
124 124
     'page arguments'   => array('privatemsg_list', 'list'),
125 125
     'access callback'  => 'privatemsg_user_access',
126 126
     'type'             => MENU_NORMAL_ITEM,
127
-  );
128
-  $items['messages/list'] = array(
127
+    );
128
+    $items['messages/list'] = array(
129 129
     'title'            => 'Messages',
130 130
     'page callback'    => 'drupal_get_form',
131 131
     'page arguments'   => array('privatemsg_list', 'list'),
132 132
     'access callback'  => 'privatemsg_user_access',
133 133
     'type'             => MENU_DEFAULT_LOCAL_TASK,
134 134
     'weight'           => -10,
135
-  );
136
-  $items['messages/view/%privatemsg_thread'] = array(
135
+    );
136
+    $items['messages/view/%privatemsg_thread'] = array(
137 137
     'title'            => 'Read message',
138 138
     // Set the third argument to TRUE so that we can show access denied instead
139 139
     // of not found.
@@ -144,16 +144,16 @@  discard block
 block discarded – undo
144 144
     'access arguments' => array(2),
145 145
     'type'             => MENU_LOCAL_TASK,
146 146
     'weight'           => -5,
147
-  );
148
-  $items['messages/delete/%privatemsg_thread/%privatemsg_message'] = array(
147
+    );
148
+    $items['messages/delete/%privatemsg_thread/%privatemsg_message'] = array(
149 149
     'title'            => 'Delete message',
150 150
     'page callback'    => 'drupal_get_form',
151 151
     'page arguments'   => array('privatemsg_delete', 2, 3),
152 152
     'access callback'  => 'privatemsg_user_access',
153 153
     'access arguments' => array('delete privatemsg'),
154 154
     'type'             => MENU_CALLBACK,
155
-  );
156
-  $items['messages/new'] = array(
155
+    );
156
+    $items['messages/new'] = array(
157 157
     'title'            => 'Write new message',
158 158
     'page callback'    => 'drupal_get_form',
159 159
     'page arguments'   => array('privatemsg_new', 2, 3, NULL),
@@ -161,24 +161,24 @@  discard block
 block discarded – undo
161 161
     'access arguments' => array('write privatemsg'),
162 162
     'type'             => MENU_LOCAL_TASK,
163 163
     'weight'           => -3,
164
-  );
165
-  // Auto-completes available user names & removes duplicates.
166
-  $items['messages/user-name-autocomplete'] = array(
164
+    );
165
+    // Auto-completes available user names & removes duplicates.
166
+    $items['messages/user-name-autocomplete'] = array(
167 167
     'page callback'    => 'privatemsg_user_name_autocomplete',
168 168
     'access callback'  => 'privatemsg_user_access',
169 169
     'access arguments' => array('write privatemsg'),
170 170
     'type'             => MENU_CALLBACK,
171 171
     'weight'           => -10,
172
-  );
173
-  $items['admin/settings/messages'] = array(
172
+    );
173
+    $items['admin/settings/messages'] = array(
174 174
     'title'            => 'Private messages',
175 175
     'description'      => 'Configure private messaging settings.',
176 176
     'page callback'    => 'drupal_get_form',
177 177
     'page arguments'   => array('private_message_settings'),
178 178
     'access arguments' => array('administer privatemsg settings'),
179 179
     'type'             => MENU_NORMAL_ITEM,
180
-  );
181
-  $items['admin/settings/messages/default'] = array(
180
+    );
181
+    $items['admin/settings/messages/default'] = array(
182 182
     'title'            => 'Private messages',
183 183
     'description'      => 'Configure private messaging settings.',
184 184
     'page callback'    => 'drupal_get_form',
@@ -186,24 +186,24 @@  discard block
 block discarded – undo
186 186
     'access arguments' => array('administer privatemsg settings'),
187 187
     'type'             => MENU_DEFAULT_LOCAL_TASK,
188 188
     'weight'           => -10,
189
-  );
190
-  $items['messages/undo/action'] = array(
189
+    );
190
+    $items['messages/undo/action'] = array(
191 191
     'title'            => 'Private messages',
192 192
     'description'      => 'Undo last thread action',
193 193
     'page callback'    => 'privatemsg_undo_action',
194 194
     'access arguments' => array('read privatemsg'),
195 195
     'type'             => MENU_CALLBACK,
196
-  );
197
-  $items['user/%/messages'] = array(
196
+    );
197
+    $items['user/%/messages'] = array(
198 198
     'title' => 'Messages',
199 199
     'page callback'    => 'drupal_get_form',
200 200
     'page arguments'   => array('privatemsg_list', 'list', 1),
201 201
     'access callback'  => 'privatemsg_user_access',
202 202
     'access arguments' => array('read all private messages'),
203 203
     'type' => MENU_LOCAL_TASK,
204
-  );
204
+    );
205 205
 
206
-  return $items;
206
+    return $items;
207 207
 }
208 208
 
209 209
 /**
@@ -220,17 +220,17 @@  discard block
 block discarded – undo
220 220
  * @ingroup api
221 221
  */
222 222
 function privatemsg_user_access($permission = 'read privatemsg', $account = NULL) {
223
-  if ( $account === NULL ) {
223
+    if ( $account === NULL ) {
224 224
     global $user;
225 225
     $account = $user;
226
-  }
227
-  if (!$account->uid) { // Disallow anonymous access, regardless of permissions
226
+    }
227
+    if (!$account->uid) { // Disallow anonymous access, regardless of permissions
228 228
     return FALSE;
229
-  }
230
-  if (!user_access($permission, $account)) {
229
+    }
230
+    if (!user_access($permission, $account)) {
231 231
     return FALSE;
232
-  }
233
-  return TRUE;
232
+    }
233
+    return TRUE;
234 234
 }
235 235
 
236 236
 /**
@@ -247,15 +247,15 @@  discard block
 block discarded – undo
247 247
  * @ingroup api
248 248
  */
249 249
 function privatemsg_view_access($thread = array()) {
250
-  // Do not allow access to threads without messages.
251
-  if (empty($thread['messages'])) {
250
+    // Do not allow access to threads without messages.
251
+    if (empty($thread['messages'])) {
252 252
     // Count all messages, if there
253 253
     return FALSE;
254
-  }
255
-  if (privatemsg_user_access('read privatemsg') && arg(1) == 'view') {
254
+    }
255
+    if (privatemsg_user_access('read privatemsg') && arg(1) == 'view') {
256 256
     return TRUE;
257
-  }
258
-  return FALSE;
257
+    }
258
+    return FALSE;
259 259
 }
260 260
 
261 261
 /**
@@ -284,142 +284,141 @@  discard block
 block discarded – undo
284 284
  *
285 285
  *   If no messages are found, or the thread_id is invalid, the function returns
286 286
  *   FALSE.
287
-
288 287
  * @ingroup api
289 288
  */
290 289
 function privatemsg_thread_load($thread_id, $account = NULL, $start = NULL, $useAccessDenied = FALSE) {
291
-  static $threads = array();
292
-  if ((int)$thread_id > 0) {
290
+    static $threads = array();
291
+    if ((int)$thread_id > 0) {
293 292
     $thread = array('thread_id' => $thread_id);
294 293
 
295 294
     if (is_null($account)) {
296
-      global $user;
297
-      $account = drupal_clone($user);
295
+        global $user;
296
+        $account = drupal_clone($user);
298 297
     }
299 298
 
300 299
     if (!isset($threads[$account->uid])) {
301
-      $threads[$account->uid] = array();
300
+        $threads[$account->uid] = array();
302 301
     }
303 302
 
304 303
     if (!array_key_exists($thread_id, $threads[$account->uid])) {
305
-      // Load the list of participants.
306
-      $query = _privatemsg_assemble_query('participants', $thread_id);
307
-      $participants = db_query($query['query']);
308
-      $thread['participants'] = array();
309
-      while ($participant = db_fetch_object($participants)) {
304
+        // Load the list of participants.
305
+        $query = _privatemsg_assemble_query('participants', $thread_id);
306
+        $participants = db_query($query['query']);
307
+        $thread['participants'] = array();
308
+        while ($participant = db_fetch_object($participants)) {
310 309
         $thread['participants'][$participant->uid] = $participant;
311
-      }
312
-      $thread['read_all'] = FALSE;
313
-      if (!array_key_exists($account->uid, $thread['participants']) && privatemsg_user_access('read all private messages', $account)) {
310
+        }
311
+        $thread['read_all'] = FALSE;
312
+        if (!array_key_exists($account->uid, $thread['participants']) && privatemsg_user_access('read all private messages', $account)) {
314 313
         $thread['read_all'] = TRUE;
315
-      }
314
+        }
316 315
 
317
-      // Load messages returned by the messages query with privatemsg_message_load_multiple().
318
-      $query = _privatemsg_assemble_query('messages', array($thread_id), $thread['read_all'] ? NULL : $account);
319
-      $thread['message_count'] = $thread['to'] = db_result(db_query($query['count']));
320
-      $thread['from'] = 1;
321
-      // Check if we need to limit the messages.
322
-      $max_amount = variable_get('privatemsg_view_max_amount', 20);
316
+        // Load messages returned by the messages query with privatemsg_message_load_multiple().
317
+        $query = _privatemsg_assemble_query('messages', array($thread_id), $thread['read_all'] ? NULL : $account);
318
+        $thread['message_count'] = $thread['to'] = db_result(db_query($query['count']));
319
+        $thread['from'] = 1;
320
+        // Check if we need to limit the messages.
321
+        $max_amount = variable_get('privatemsg_view_max_amount', 20);
323 322
 
324
-      // If there is no start value, select based on get params.
325
-      if (is_null($start)) {
323
+        // If there is no start value, select based on get params.
324
+        if (is_null($start)) {
326 325
         if (isset($_GET['start']) && $_GET['start'] < $thread['message_count']) {
327
-          $start = $_GET['start'];
326
+            $start = $_GET['start'];
328 327
         }
329 328
         elseif (!variable_get('privatemsg_view_use_max_as_default', FALSE) && $max_amount == PRIVATEMSG_UNLIMITED) {
330
-          $start = PRIVATEMSG_UNLIMITED;
329
+            $start = PRIVATEMSG_UNLIMITED;
331 330
         }
332 331
         else {
333
-          $start = $thread['message_count'] - (variable_get('privatemsg_view_use_max_as_default', FALSE) ? variable_get('privatemsg_view_default_amount', 10) : $max_amount);
332
+            $start = $thread['message_count'] - (variable_get('privatemsg_view_use_max_as_default', FALSE) ? variable_get('privatemsg_view_default_amount', 10) : $max_amount);
333
+        }
334 334
         }
335
-      }
336 335
 
337
-      if ($start != PRIVATEMSG_UNLIMITED) {
336
+        if ($start != PRIVATEMSG_UNLIMITED) {
338 337
         if ($max_amount == PRIVATEMSG_UNLIMITED) {
339
-          $last_page = 0;
340
-          $max_amount = $thread['message_count'];
338
+            $last_page = 0;
339
+            $max_amount = $thread['message_count'];
341 340
         }
342 341
         else {
343
-          // Calculate the number of messages on the "last" page to avoid
344
-          // message overlap.
345
-          // Note - the last page lists the earliest messages, not the latest.
346
-          $paging_count = variable_get('privatemsg_view_use_max_as_default', FALSE) ? $thread['message_count'] - variable_get('privatemsg_view_default_amount', 10) : $thread['message_count'];
347
-          $last_page = $paging_count % $max_amount;
342
+            // Calculate the number of messages on the "last" page to avoid
343
+            // message overlap.
344
+            // Note - the last page lists the earliest messages, not the latest.
345
+            $paging_count = variable_get('privatemsg_view_use_max_as_default', FALSE) ? $thread['message_count'] - variable_get('privatemsg_view_default_amount', 10) : $thread['message_count'];
346
+            $last_page = $paging_count % $max_amount;
348 347
         }
349 348
 
350 349
         // Sanity check - we cannot start from a negative number.
351 350
         if ($start < 0) {
352
-          $start = 0;
351
+            $start = 0;
353 352
         }
354 353
         $thread['start'] = $start;
355 354
 
356 355
         //If there are newer messages on the page, show pager link allowing to go to the newer messages.
357 356
         if (($start + $max_amount + 1) < $thread['message_count']) {
358
-          $thread['to'] = $start + $max_amount;
359
-          $thread['newer_start'] = $start + $max_amount;
357
+            $thread['to'] = $start + $max_amount;
358
+            $thread['newer_start'] = $start + $max_amount;
360 359
         }
361 360
         if ($start - $max_amount >= 0) {
362
-          $thread['older_start'] = $start - $max_amount;
361
+            $thread['older_start'] = $start - $max_amount;
363 362
         }
364 363
         elseif ($start > 0) {
365
-          $thread['older_start'] = 0;
364
+            $thread['older_start'] = 0;
366 365
         }
367 366
 
368 367
         // Do not show messages on the last page that would show on the page
369 368
         // before. This will only work when using the visual pager.
370 369
         if ($start < $last_page && $max_amount != PRIVATEMSG_UNLIMITED && $max_amount < $thread['message_count']) {
371
-          unset($thread['older_start']);
372
-          $thread['to'] = $thread['newer_start'] = $max_amount = $last_page;
373
-          // Start from the first message - this is a specific hack to make sure
374
-          // the message display has sane paging on the last page.
375
-          $start = 0;
370
+            unset($thread['older_start']);
371
+            $thread['to'] = $thread['newer_start'] = $max_amount = $last_page;
372
+            // Start from the first message - this is a specific hack to make sure
373
+            // the message display has sane paging on the last page.
374
+            $start = 0;
376 375
         }
377 376
         // Visual counts start from 1 instead of zero, so plus one.
378 377
         $thread['from'] = $start + 1;
379 378
         $conversation = db_query_range($query['query'], $start, $max_amount);
380
-      }
381
-      else {
379
+        }
380
+        else {
382 381
         $conversation = db_query($query['query']);
383
-      }
384
-      $mids = array();
385
-      while ($result = db_fetch_array($conversation)) {
382
+        }
383
+        $mids = array();
384
+        while ($result = db_fetch_array($conversation)) {
386 385
         $mids[] = $result['mid'];
387
-      }
388
-      // Load messages returned by the messages query.
389
-      $thread['messages'] = privatemsg_message_load_multiple($mids, $thread['read_all'] ? NULL : $account);
386
+        }
387
+        // Load messages returned by the messages query.
388
+        $thread['messages'] = privatemsg_message_load_multiple($mids, $thread['read_all'] ? NULL : $account);
390 389
 
391
-      // If there are no messages, don't allow access to the thread.
392
-      if (empty($thread['messages'])) {
390
+        // If there are no messages, don't allow access to the thread.
391
+        if (empty($thread['messages'])) {
393 392
         if ($useAccessDenied) {
394
-          // Generate new query with read all to see if the thread does exist.
395
-          $query = _privatemsg_assemble_query('messages', array($thread_id), NULL);
396
-          $exists = db_result(db_query($query['count']));
397
-          if (!$exists) {
393
+            // Generate new query with read all to see if the thread does exist.
394
+            $query = _privatemsg_assemble_query('messages', array($thread_id), NULL);
395
+            $exists = db_result(db_query($query['count']));
396
+            if (!$exists) {
398 397
             // Thread does not exist, display 404.
399 398
             $thread = FALSE;
400
-          }
399
+            }
401 400
         }
402 401
         else {
403
-          $thread = FALSE;
402
+            $thread = FALSE;
403
+        }
404 404
         }
405
-      }
406
-      else {
405
+        else {
407 406
         // General data, assume subject is the same for all messages of that thread.
408 407
         $thread['user'] = $account;
409 408
         $message = current($thread['messages']);
410 409
         $thread['subject'] = $message['subject'];
411
-      }
412
-      $threads[$account->uid][$thread_id] = $thread;
410
+        }
411
+        $threads[$account->uid][$thread_id] = $thread;
413 412
     }
414 413
 
415 414
     return $threads[$account->uid][$thread_id];
416
-  }
417
-  return FALSE;
415
+    }
416
+    return FALSE;
418 417
 }
419 418
 
420 419
 function private_message_view_options() {
421
-  $options = module_invoke_all('privatemsg_view_template');
422
-  return $options;
420
+    $options = module_invoke_all('privatemsg_view_template');
421
+    return $options;
423 422
 }
424 423
 
425 424
 /**
@@ -435,108 +434,108 @@  discard block
 block discarded – undo
435 434
  * };
436 435
  */
437 436
 function privatemsg_privatemsg_view_template() {
438
-  return array(
437
+    return array(
439 438
     'privatemsg-view' => 'Default view',
440
-  );
439
+    );
441 440
 }
442 441
 
443 442
 function private_message_settings() {
444
-  $form = array();
443
+    $form = array();
445 444
 
446
-  $form['theming_settings'] = array(
445
+    $form['theming_settings'] = array(
447 446
     '#type'        => 'fieldset',
448 447
     '#collapsible' => TRUE,
449 448
     '#collapsed'   => TRUE,
450 449
     '#title'       => t('Theming settings'),
451
-  );
452
-  $form['theming_settings']['private_message_view_template'] = array(
450
+    );
451
+    $form['theming_settings']['private_message_view_template'] = array(
453 452
     '#type'          => 'radios',
454 453
     '#title'         => t('Private message display template'),
455 454
     '#default_value' => variable_get('private_message_view_template', 'privatemsg-view'),
456 455
     '#options'       => private_message_view_options(),
457
-  );
458
-  $form['privatemsg_display_loginmessage'] = array(
456
+    );
457
+    $form['privatemsg_display_loginmessage'] = array(
459 458
     '#type' => 'checkbox',
460 459
     '#title' => t('Inform the user about new messages on login'),
461 460
     '#default_value' => variable_get('privatemsg_display_loginmessage', TRUE),
462 461
     '#description' => t('This option can safely be disabled if the "New message indication" block is used instead.'),
463
-  );
462
+    );
464 463
 
465
-  $form['flush_deleted'] = array(
464
+    $form['flush_deleted'] = array(
466 465
     '#type'        => 'fieldset',
467 466
     '#collapsible' => TRUE,
468 467
     '#collapsed'   => TRUE,
469 468
     '#title'       => t('Flush deleted messages'),
470 469
     '#description' => t('By default, deleted messages are only hidden from the user but still stored in the database. These settings control if and when messages should be removed.'),
471
-  );
470
+    );
472 471
 
473
-  $form['flush_deleted']['privatemsg_flush_enabled'] = array(
472
+    $form['flush_deleted']['privatemsg_flush_enabled'] = array(
474 473
     '#type'          => 'checkbox',
475 474
     '#title'         => t('Flush deleted messages'),
476 475
     '#default_value' => variable_get('privatemsg_flush_enabled', FALSE),
477 476
     '#description'   => t('Enable the flushing of deleted messages. Requires that cron is enabled'),
478
-  );
477
+    );
479 478
 
480
-  $form['flush_deleted']['privatemsg_flush_days'] = array(
479
+    $form['flush_deleted']['privatemsg_flush_days'] = array(
481 480
     '#type' => 'select',
482 481
     '#title' => t('Flush messages after they have been deleted for more days than'),
483 482
     '#default_value' => variable_get('privatemsg_flush_days', 30),
484 483
     '#options' => drupal_map_assoc(array(0, 1, 2, 5, 10, 30, 100)),
485
-  );
484
+    );
486 485
 
487
-  $form['flush_deleted']['privatemsg_flush_max'] = array(
486
+    $form['flush_deleted']['privatemsg_flush_max'] = array(
488 487
     '#type' => 'select',
489 488
     '#title' => t('Maximum number of messages to flush per cron run'),
490 489
     '#default_value' => variable_get('privatemsg_flush_max', 200),
491 490
     '#options' => drupal_map_assoc(array(50, 100, 200, 500, 1000)),
492
-  );
491
+    );
493 492
 
494
-  $form['privatemsg_listing'] = array(
493
+    $form['privatemsg_listing'] = array(
495 494
     '#type' => 'fieldset',
496 495
     '#title' => t('Configure listings'),
497 496
     '#collapsible' => TRUE,
498 497
     '#collapsed' => FALSE,
499
-  );
498
+    );
500 499
 
501
-  $form['privatemsg_listing']['privatemsg_per_page'] = array(
500
+    $form['privatemsg_listing']['privatemsg_per_page'] = array(
502 501
     '#type' => 'select',
503 502
     '#title' => t('Threads per page'),
504 503
     '#default_value' => variable_get('privatemsg_per_page', 25),
505 504
     '#options' => drupal_map_assoc(array(10, 25, 50, 75, 100)),
506 505
     '#description' => t('Choose the number of conversations that should be listed per page.'),
507
-  );
506
+    );
508 507
 
509
-  $form['privatemsg_listing']['privatemsg_display_fields'] = array(
508
+    $form['privatemsg_listing']['privatemsg_display_fields'] = array(
510 509
     '#type' => 'checkboxes',
511 510
     '#title' => t('Configure fields'),
512 511
     '#description' => t('Select which columns/fields should be displayed in the message listings. Subject and Last updated cannot be disabled.'),
513 512
     '#options' => array(
514
-      'participants'    => t('Participants'),
515
-      'thread_started'  => t('Started'),
516
-      'count'           => t('Messages'),
513
+        'participants'    => t('Participants'),
514
+        'thread_started'  => t('Started'),
515
+        'count'           => t('Messages'),
517 516
     ),
518 517
     '#default_value' => variable_get('privatemsg_display_fields', array('participants')),
519
-  );
518
+    );
520 519
 
521
-  $amounts = drupal_map_assoc(array(5, 10, 20, 30, 50, 70, 90, 150, 200, 250, 300));
522
-  $form['privatemsg_listing']['privatemsg_view_max_amount'] = array(
520
+    $amounts = drupal_map_assoc(array(5, 10, 20, 30, 50, 70, 90, 150, 200, 250, 300));
521
+    $form['privatemsg_listing']['privatemsg_view_max_amount'] = array(
523 522
     '#type'          => 'select',
524 523
     '#title'         => t('Number of messages on thread pages'),
525 524
     '#options'       => $amounts + array(PRIVATEMSG_UNLIMITED => t('Unlimited')),
526 525
     '#default_value' => variable_get('privatemsg_view_max_amount', 20),
527 526
     '#description'   => t('Threads will not show more than this number of messages on a single page.'),
528 527
     '#weight'        => 10,
529
-  );
528
+    );
530 529
 
531
-  $form['privatemsg_listing']['privatemsg_view_use_max_as_default'] = array(
530
+    $form['privatemsg_listing']['privatemsg_view_use_max_as_default'] = array(
532 531
     '#type'          => 'checkbox',
533 532
     '#title'         => t('Display different amount of messages on first thread page'),
534 533
     '#default_value' => variable_get('privatemsg_view_use_max_as_default', FALSE),
535 534
     '#description'   => t('By default, the first thread page shows the maximally allowed amount of messages. Enable this checkbox to set a different value.'),
536 535
     '#weight'        => 15,
537
-  );
536
+    );
538 537
 
539
-  $form['privatemsg_listing']['privatemsg_view_default_amount'] = array(
538
+    $form['privatemsg_listing']['privatemsg_view_default_amount'] = array(
540 539
     '#prefix'        => '<div id="privatemsg-view-default-button">',
541 540
     '#suffix'        => '</div>',
542 541
     '#type'          => 'select',
@@ -545,15 +544,15 @@  discard block
 block discarded – undo
545 544
     '#description'   => t('The number of messages to be displayed on first thread page. Displays the newest messages.'),
546 545
     '#options'       => $amounts,
547 546
     '#weight'        => 20,
548
-  );
549
-  drupal_add_js(drupal_get_path('module', 'privatemsg') .'/privatemsg-admin.js');
547
+    );
548
+    drupal_add_js(drupal_get_path('module', 'privatemsg') .'/privatemsg-admin.js');
550 549
 
551
-  $form['#submit'][] = 'private_message_settings_submit';
552
-  return system_settings_form($form);
550
+    $form['#submit'][] = 'private_message_settings_submit';
551
+    return system_settings_form($form);
553 552
 }
554 553
 
555 554
 function private_message_settings_submit() {
556
-  drupal_rebuild_theme_registry();
555
+    drupal_rebuild_theme_registry();
557 556
 }
558 557
 
559 558
 /**
@@ -563,107 +562,107 @@  discard block
 block discarded – undo
563 562
  * old enough are flushed.
564 563
  */
565 564
 function privatemsg_cron() {
566
-  if (variable_get('privatemsg_flush_enabled', FALSE)) {
565
+    if (variable_get('privatemsg_flush_enabled', FALSE)) {
567 566
     $query = _privatemsg_assemble_query('deleted', variable_get('privatemsg_flush_days', 30));
568 567
     $result = db_query($query['query']);
569 568
 
570 569
     $flushed = 0;
571 570
     while (($row = db_fetch_array($result)) && ($flushed < variable_get('privatemsg_flush_max', 200))) {
572
-      $message = privatemsg_message_load($row['mid']);
573
-      module_invoke_all('privatemsg_message_flush', $message);
571
+        $message = privatemsg_message_load($row['mid']);
572
+        module_invoke_all('privatemsg_message_flush', $message);
574 573
 
575
-      // Delete recipients of the message.
576
-      db_query('DELETE FROM {pm_index} WHERE mid = %d', $row['mid']);
577
-      // Delete message itself.
578
-      db_query('DELETE FROM {pm_message} WHERE mid = %d', $row['mid']);
579
-      $flushed++;
574
+        // Delete recipients of the message.
575
+        db_query('DELETE FROM {pm_index} WHERE mid = %d', $row['mid']);
576
+        // Delete message itself.
577
+        db_query('DELETE FROM {pm_message} WHERE mid = %d', $row['mid']);
578
+        $flushed++;
579
+    }
580 580
     }
581
-  }
582 581
 }
583 582
 
584 583
 function privatemsg_theme() {
585
-  return array(
584
+    return array(
586 585
     'privatemsg_view'    => array(
587
-      'arguments'        => array('message' => NULL),
588
-      'template'         => variable_get('private_message_view_template', 'privatemsg-view'), // 'privatemsg',
586
+        'arguments'        => array('message' => NULL),
587
+        'template'         => variable_get('private_message_view_template', 'privatemsg-view'), // 'privatemsg',
589 588
     ),
590 589
     'privatemsg_from'    => array(
591
-      'arguments'        => array('author' => NULL),
592
-      'template'         => 'privatemsg-from',
590
+        'arguments'        => array('author' => NULL),
591
+        'template'         => 'privatemsg-from',
593 592
     ),
594 593
     'privatemsg_recipients' => array(
595
-      'arguments'        => array('message' => NULL),
596
-      'template'         => 'privatemsg-recipients',
594
+        'arguments'        => array('message' => NULL),
595
+        'template'         => 'privatemsg-recipients',
597 596
     ),
598 597
     'privatemsg_between' => array(
599
-      'arguments'        => array('recipients' => NULL),
600
-      'template'         => 'privatemsg-between',
598
+        'arguments'        => array('recipients' => NULL),
599
+        'template'         => 'privatemsg-between',
601 600
     ),
602 601
     'privatemsg_list'    => array(
603
-      'file'                  => 'privatemsg.theme.inc',
604
-      'path'                  => drupal_get_path('module', 'privatemsg'),
605
-      'arguments'        => array('form'),
602
+        'file'                  => 'privatemsg.theme.inc',
603
+        'path'                  => drupal_get_path('module', 'privatemsg'),
604
+        'arguments'        => array('form'),
606 605
     ),
607 606
     // Define pattern for header/field templates. The theme system will register all
608 607
     // theme functions that start with the defined pattern.
609 608
     'privatemsg_list_header'  => array(
610
-      'file'                  => 'privatemsg.theme.inc',
611
-      'path'                  => drupal_get_path('module', 'privatemsg'),
612
-      'pattern'               => 'privatemsg_list_header__',
613
-      'arguments'             => array(),
609
+        'file'                  => 'privatemsg.theme.inc',
610
+        'path'                  => drupal_get_path('module', 'privatemsg'),
611
+        'pattern'               => 'privatemsg_list_header__',
612
+        'arguments'             => array(),
614 613
     ),
615 614
     'privatemsg_list_field'   => array(
616
-      'file'                  => 'privatemsg.theme.inc',
617
-      'path'                  => drupal_get_path('module', 'privatemsg'),
618
-      'pattern'               => 'privatemsg_list_field__',
619
-      'arguments'             => array('thread'),
615
+        'file'                  => 'privatemsg.theme.inc',
616
+        'path'                  => drupal_get_path('module', 'privatemsg'),
617
+        'pattern'               => 'privatemsg_list_field__',
618
+        'arguments'             => array('thread'),
620 619
     ),
621 620
     'privatemsg_new_block'  => array(
622
-      'file'                  => 'privatemsg.theme.inc',
623
-      'path'                  => drupal_get_path('module', 'privatemsg'),
624
-      'arguments'             => array('count'),
621
+        'file'                  => 'privatemsg.theme.inc',
622
+        'path'                  => drupal_get_path('module', 'privatemsg'),
623
+        'arguments'             => array('count'),
625 624
     ),
626
-  );
625
+    );
627 626
 }
628 627
 
629 628
 function template_preprocess_privatemsg_view(&$vars) {
630 629
 //  drupal_set_message('<pre>'. print_r($vars,1 ) . '</pre>');
631 630
 
632
-  $message = $vars['message'];
633
-  $vars['mid'] = isset($message['mid']) ? $message['mid'] : NULL;
634
-  $vars['thread_id'] = isset($message['thread_id']) ? $message['thread_id'] : NULL;
635
-  $vars['author_picture'] = theme('user_picture', $message['author']);
636
-  $vars['author_name_link'] = theme('username', $message['author']);
637
-  /**
638
-   * @todo perhaps make this timestamp configurable via admin UI?
639
-   */
640
-  $vars['message_timestamp'] = format_date($message['timestamp'], 'small');
641
-  $vars['message_body'] = check_markup($message['body'], $message['format'], FALSE);
642
-  if (isset($vars['mid']) && isset($vars['thread_id']) && privatemsg_user_access('delete privatemsg')) {
631
+    $message = $vars['message'];
632
+    $vars['mid'] = isset($message['mid']) ? $message['mid'] : NULL;
633
+    $vars['thread_id'] = isset($message['thread_id']) ? $message['thread_id'] : NULL;
634
+    $vars['author_picture'] = theme('user_picture', $message['author']);
635
+    $vars['author_name_link'] = theme('username', $message['author']);
636
+    /**
637
+     * @todo perhaps make this timestamp configurable via admin UI?
638
+     */
639
+    $vars['message_timestamp'] = format_date($message['timestamp'], 'small');
640
+    $vars['message_body'] = check_markup($message['body'], $message['format'], FALSE);
641
+    if (isset($vars['mid']) && isset($vars['thread_id']) && privatemsg_user_access('delete privatemsg')) {
643 642
     $vars['message_actions'][] = array('title' => t('Delete message'), 'href' => 'messages/delete/' . $vars['thread_id'] . '/' . $vars['mid']);
644
-  }
645
-  $vars['message_anchors'][] = 'privatemsg-mid-' . $vars['mid'];
646
-  if (!empty($message['is_new'])) {
643
+    }
644
+    $vars['message_anchors'][] = 'privatemsg-mid-' . $vars['mid'];
645
+    if (!empty($message['is_new'])) {
647 646
     $vars['message_anchors'][] = 'new';
648 647
     $vars['new'] = drupal_ucfirst(t('new'));
649
-  }
648
+    }
650 649
 
651
-  // call hook_privatemsg_message_view_alter
652
-  drupal_alter('privatemsg_message_view', $vars);
650
+    // call hook_privatemsg_message_view_alter
651
+    drupal_alter('privatemsg_message_view', $vars);
653 652
 
654
-  $vars['message_actions'] = !empty($vars['message_actions']) ? theme('links', $vars['message_actions'], array('class' => 'message-actions')) : '';
653
+    $vars['message_actions'] = !empty($vars['message_actions']) ? theme('links', $vars['message_actions'], array('class' => 'message-actions')) : '';
655 654
 
656
-  $vars['anchors'] = '';
657
-  foreach ($vars['message_anchors'] as $anchor) {
655
+    $vars['anchors'] = '';
656
+    foreach ($vars['message_anchors'] as $anchor) {
658 657
     $vars['anchors'] .= '<a name="' . $anchor . '"></a>';
659
-  }
658
+    }
660 659
 }
661 660
 
662 661
 function template_preprocess_privatemsg_recipients(&$vars) {
663
-  $vars['participants'] = ''; // assign a default empty value
664
-  if (isset($vars['message']['participants'])) {
662
+    $vars['participants'] = ''; // assign a default empty value
663
+    if (isset($vars['message']['participants'])) {
665 664
     $vars['participants'] = _privatemsg_format_participants($vars['message']['participants']);
666
-  }
665
+    }
667 666
 }
668 667
 
669 668
 /**
@@ -680,49 +679,49 @@  discard block
 block discarded – undo
680 679
  *   Form array
681 680
  */
682 681
 function privatemsg_list(&$form_state, $argument = 'list', $uid = NULL) {
683
-  global $user;
682
+    global $user;
684 683
 
685
-  // Setting default behavior...
686
-  $account = $user;
687
-  // Because uid is submitted by the menu system, it's a string not a integer.
688
-  if ((int)$uid > 0 && $uid != $user->uid) {
684
+    // Setting default behavior...
685
+    $account = $user;
686
+    // Because uid is submitted by the menu system, it's a string not a integer.
687
+    if ((int)$uid > 0 && $uid != $user->uid) {
689 688
     // Trying to view someone else's messages...
690 689
     if (!privatemsg_user_access('read all private messages')) {
691
-      drupal_set_message(t("You do not have sufficient rights to view someone else's messages"), 'warning');
690
+        drupal_set_message(t("You do not have sufficient rights to view someone else's messages"), 'warning');
692 691
     }
693 692
     elseif ($account_check = user_load(array('uid' => $uid))) {
694
-      // Has rights and user_load return an array so user does exist
695
-      $account = $account_check;
693
+        // Has rights and user_load return an array so user does exist
694
+        $account = $account_check;
695
+    }
696 696
     }
697
-  }
698
-  // By this point we have figured out for which user we are listing messages and now it is safe to use $account->uid in the listing query.
697
+    // By this point we have figured out for which user we are listing messages and now it is safe to use $account->uid in the listing query.
699 698
 
700
-  $query = _privatemsg_assemble_query('list', $account, $argument);
701
-  $result = pager_query($query['query'], variable_get('privatemsg_per_page', 25), 0, $query['count']);
699
+    $query = _privatemsg_assemble_query('list', $account, $argument);
700
+    $result = pager_query($query['query'], variable_get('privatemsg_per_page', 25), 0, $query['count']);
702 701
 
703
-  $threads = array();
704
-  $form['#data'] = array();
705
-  while ($row = db_fetch_array($result)) {
702
+    $threads = array();
703
+    $form['#data'] = array();
704
+    while ($row = db_fetch_array($result)) {
706 705
     // Store the raw row data.
707 706
     $form['#data'][$row['thread_id']] = $row;
708 707
     // store thread id for the checkboxes array
709 708
     $threads[$row['thread_id']] = '';
710
-  }
711
-  if (!empty($form['#data'])) {
709
+    }
710
+    if (!empty($form['#data'])) {
712 711
     $form['actions'] = _privatemsg_action_form();
713
-  }
712
+    }
714 713
 
715
-  // Save the currently active account, used for actions.
716
-  $form['account'] = array('#type' => 'value', '#value' => $account);
714
+    // Save the currently active account, used for actions.
715
+    $form['account'] = array('#type' => 'value', '#value' => $account);
717 716
 
718
-  // Define checkboxes, pager and theme
719
-  $form['threads'] = array('#type' => 'checkboxes', '#options' => $threads);
720
-  $form['pager'] = array('#value' => theme('pager'), '#weight' => 20);
721
-  $form['#theme'] = 'privatemsg_list';
717
+    // Define checkboxes, pager and theme
718
+    $form['threads'] = array('#type' => 'checkboxes', '#options' => $threads);
719
+    $form['pager'] = array('#value' => theme('pager'), '#weight' => 20);
720
+    $form['#theme'] = 'privatemsg_list';
722 721
 
723
-  // Store the account for which the threads are displayed.
724
-  $form['#account'] = $account;
725
-  return $form;
722
+    // Store the account for which the threads are displayed.
723
+    $form['#account'] = $account;
724
+    return $form;
726 725
 }
727 726
 
728 727
 /**
@@ -736,12 +735,12 @@  discard block
 block discarded – undo
736 735
  *   User object, defaults to the current user
737 736
  */
738 737
 function privatemsg_message_change_status($pmid, $status, $account = NULL) {
739
-  if (!$account) {
738
+    if (!$account) {
740 739
     global $user;
741 740
     $account = $user;
742
-  }
743
-  $query = "UPDATE {pm_index} SET is_new = %d WHERE mid = %d AND uid = %d";
744
-  db_query($query, $status, $pmid, $account->uid);
741
+    }
742
+    $query = "UPDATE {pm_index} SET is_new = %d WHERE mid = %d AND uid = %d";
743
+    db_query($query, $status, $pmid, $account->uid);
745 744
 }
746 745
 
747 746
 /**
@@ -753,16 +752,16 @@  discard block
 block discarded – undo
753 752
  * @ingroup api
754 753
  */
755 754
 function privatemsg_unread_count($account = NULL) {
756
-  static $counts = array();
757
-  if (!$account || $account->uid == 0) {
755
+    static $counts = array();
756
+    if (!$account || $account->uid == 0) {
758 757
     global $user;
759 758
     $account = $user;
760
-  }
761
-  if ( !isset($counts[$account->uid])) {
759
+    }
760
+    if ( !isset($counts[$account->uid])) {
762 761
     $query = _privatemsg_assemble_query('unread_count', $account);
763 762
     $counts[$account->uid] = db_result(db_query($query['query']));
764
-  }
765
-  return $counts[$account->uid];
763
+    }
764
+    return $counts[$account->uid];
766 765
 }
767 766
 
768 767
 /**
@@ -776,285 +775,285 @@  discard block
 block discarded – undo
776 775
  * @see privatemsg_thread_load()
777 776
  */
778 777
 function privatemsg_view($thread) {
779
-  drupal_set_title(check_plain($thread['subject']));
778
+    drupal_set_title(check_plain($thread['subject']));
780 779
 
781
-  // Generate paging links.
782
-  $older = '';
783
-  if (isset($thread['older_start'])) {
780
+    // Generate paging links.
781
+    $older = '';
782
+    if (isset($thread['older_start'])) {
784 783
     $options = array(
785
-      'query' => array('start' => $thread['older_start']),
786
-      'title' => t('Display older messages'),
784
+        'query' => array('start' => $thread['older_start']),
785
+        'title' => t('Display older messages'),
787 786
     );
788
-     $older = l(t('<<'), 'messages/view/' . $thread['thread_id'], $options);
789
-  }
790
-  $newer = '';
791
-  if (isset($thread['newer_start'])) {
787
+        $older = l(t('<<'), 'messages/view/' . $thread['thread_id'], $options);
788
+    }
789
+    $newer = '';
790
+    if (isset($thread['newer_start'])) {
792 791
     $options = array(
793
-      'query' => array('start' => $thread['newer_start']),
794
-      'title' => t('Display newer messages'),
792
+        'query' => array('start' => $thread['newer_start']),
793
+        'title' => t('Display newer messages'),
795 794
     );
796 795
     $newer = l(t('>>'), 'messages/view/' . $thread['thread_id'], $options);
797
-  }
798
-  $substitutions = array('@from' => $thread['from'], '@to' => $thread['to'], '@total' => $thread['message_count'], '!previous_link' => $older, '!newer_link' => $newer);
799
-  $title = t('!previous_link Displaying messages @from - @to of @total !newer_link', $substitutions);
800
-  $content['pager_top'] = array(
796
+    }
797
+    $substitutions = array('@from' => $thread['from'], '@to' => $thread['to'], '@total' => $thread['message_count'], '!previous_link' => $older, '!newer_link' => $newer);
798
+    $title = t('!previous_link Displaying messages @from - @to of @total !newer_link', $substitutions);
799
+    $content['pager_top'] = array(
801 800
     '#value'  => trim($title),
802 801
     '#prefix' => '<div class="privatemsg-view-pager">',
803 802
     '#suffix' => '</div>',
804 803
     '#weight' => -10,
805
-  );
804
+    );
806 805
 
807
-  // Display a copy at the end.
808
-  $content['pager_bottom'] = $content['pager_top'];
809
-  $content['pager_bottom']['#weight'] = 3;
806
+    // Display a copy at the end.
807
+    $content['pager_bottom'] = $content['pager_top'];
808
+    $content['pager_bottom']['#weight'] = 3;
810 809
 
811
-  // Render the participants.
812
-  $content['participants']['#value'] = theme('privatemsg_recipients', $thread);
813
-  $content['participants']['#weight'] = -5;
810
+    // Render the participants.
811
+    $content['participants']['#value'] = theme('privatemsg_recipients', $thread);
812
+    $content['participants']['#weight'] = -5;
814 813
 
815
-  // Render the messages.
816
-  $output = '';
817
-  foreach ($thread['messages'] as $pmid => $message) {
814
+    // Render the messages.
815
+    $output = '';
816
+    foreach ($thread['messages'] as $pmid => $message) {
818 817
     // Set message as read and theme it.
819 818
     if (!empty($message['is_new'])) {
820
-      privatemsg_message_change_status($pmid, PRIVATEMSG_READ, $thread['user']);
819
+        privatemsg_message_change_status($pmid, PRIVATEMSG_READ, $thread['user']);
821 820
     }
822 821
     $output .= theme('privatemsg_view', $message);
823
-  }
824
-  $content['messages']['#value'] = $output;
825
-  $content['messages']['#weight'] = 0;
822
+    }
823
+    $content['messages']['#value'] = $output;
824
+    $content['messages']['#weight'] = 0;
826 825
 
827
-  // Display the reply form if user is allowed to use it.
828
-  if (privatemsg_user_access('write privatemsg')) {
826
+    // Display the reply form if user is allowed to use it.
827
+    if (privatemsg_user_access('write privatemsg')) {
829 828
     $content['reply']['#value'] = drupal_get_form('privatemsg_new', $thread['participants'], $thread['subject'], $thread['thread_id'], $thread['read_all']);
830 829
     $content['reply']['#weight'] = 5;
831
-  }
830
+    }
832 831
 
833
-  // Check after calling the privatemsg_new form so that this message is only
834
-  // displayed when we are not sending a message.
835
-  if ($thread['read_all']) {
832
+    // Check after calling the privatemsg_new form so that this message is only
833
+    // displayed when we are not sending a message.
834
+    if ($thread['read_all']) {
836 835
     // User has permission to read all messages AND is not a participant of the current thread.
837 836
     drupal_set_message(t('This conversation is being viewed with escalated priviledges and may not be the same as shown to normal users.'), 'warning');
838
-  }
837
+    }
839 838
 
840
-  // Allow other modules to hook into the $content array and alter it.
841
-  drupal_alter('privatemsg_view_messages', $content, $thread);
842
-  return drupal_render($content);
839
+    // Allow other modules to hook into the $content array and alter it.
840
+    drupal_alter('privatemsg_view_messages', $content, $thread);
841
+    return drupal_render($content);
843 842
 }
844 843
 
845 844
 
846 845
 function privatemsg_new(&$form_state, $recipients = array(), $subject = '', $thread_id = NULL, $read_all = FALSE) {
847
-  global $user;
846
+    global $user;
848 847
 
849
-  $recipients_string = '';
850
-  $body      = '';
848
+    $recipients_string = '';
849
+    $body      = '';
851 850
 
852
-  // convert recipients to array of user objects
853
-  if (!empty($recipients) && is_string($recipients) || is_int($recipients)) {
851
+    // convert recipients to array of user objects
852
+    if (!empty($recipients) && is_string($recipients) || is_int($recipients)) {
854 853
     $recipients = _privatemsg_generate_user_array($recipients);
855
-  }
856
-  elseif (is_object($recipients)) {
854
+    }
855
+    elseif (is_object($recipients)) {
857 856
     $recipients = array($recipients);
858
-  }
859
-  elseif (empty($recipients) && is_string($recipients)) {
857
+    }
858
+    elseif (empty($recipients) && is_string($recipients)) {
860 859
     $recipients = array();
861
-  }
860
+    }
862 861
 
863
-  $usercount = 0;
864
-  $to = array();
865
-  $to_themed = array();
866
-  $blocked = FALSE;
867
-  foreach ($recipients as $recipient) {
862
+    $usercount = 0;
863
+    $to = array();
864
+    $to_themed = array();
865
+    $blocked = FALSE;
866
+    foreach ($recipients as $recipient) {
868 867
     if (in_array($recipient->name, $to)) {
869
-      // We already added the recipient to the list, skip him.
870
-      continue;
868
+        // We already added the recipient to the list, skip him.
869
+        continue;
871 870
     }
872 871
     // Check if another module is blocking the sending of messages to the recipient by current user.
873 872
     $user_blocked = module_invoke_all('privatemsg_block_message', $user, array($recipient->uid => $recipient));
874 873
     if (!count($user_blocked) <> 0 && $recipient->uid) {
875
-      if ($recipient->uid == $user->uid) {
874
+        if ($recipient->uid == $user->uid) {
876 875
         $usercount++;
877 876
         // Skip putting author in the recipients list for now.
878 877
         continue;
879
-      }
880
-      $myuser = user_load(array('uid' => $recipient->uid));
881
-      $myname = preg_replace("/ /", "\xc2\xa0", $myuser->boincuser_name);
882
-      $to[] = $myname . "_" . $myuser->boincuser_id;
883
-      $to_themed[$recipient->uid] = $myname;
878
+        }
879
+        $myuser = user_load(array('uid' => $recipient->uid));
880
+        $myname = preg_replace("/ /", "\xc2\xa0", $myuser->boincuser_name);
881
+        $to[] = $myname . "_" . $myuser->boincuser_id;
882
+        $to_themed[$recipient->uid] = $myname;
884 883
     }
885 884
     else {
886
-      // Recipient list contains blocked users.
887
-      $blocked = TRUE;
885
+        // Recipient list contains blocked users.
886
+        $blocked = TRUE;
887
+    }
888 888
     }
889
-  }
890 889
 
891
-  if (empty($to) && $usercount >= 1 && !$blocked) {
890
+    if (empty($to) && $usercount >= 1 && !$blocked) {
892 891
     // Assume the user sent message to own account as if the usercount is one or less, then the user sent a message but not to self.
893 892
     $myuser = user_load(array('uid' => $user->uid));
894 893
     $myname = preg_replace("/ /", "\xc2\xa0", $myuser->boincuser_name);
895 894
     $to[] = $myname . "_" . $myuser->boincuser_id;
896 895
     $to_themed[$user->uid] = $myname;
897
-  }
898
-  if (!empty($to)) {
896
+    }
897
+    if (!empty($to)) {
899 898
     $recipients_string = implode(' ', $to);
900 899
     $recipients_string .= ' ';
901
-  }
902
-  if (isset($form_state['values'])) {
900
+    }
901
+    if (isset($form_state['values'])) {
903 902
     if (isset($form_state['values']['recipient'])) {
904
-      $recipients_string = $form_state['values']['recipient'];
903
+        $recipients_string = $form_state['values']['recipient'];
905 904
 
906 905
     }
907 906
     $subject   = $form_state['values']['subject'];
908 907
     $body      = $form_state['values']['body'];
909
-  }
910
-  if (!$thread_id && !empty($recipients_string)) {
908
+    }
909
+    if (!$thread_id && !empty($recipients_string)) {
911 910
     drupal_set_title(t('Write new message to %recipient', array('%recipient' => $recipients_string)));
912
-  }
913
-  elseif (!$thread_id) {
911
+    }
912
+    elseif (!$thread_id) {
914 913
     drupal_set_title(t('Write new message'));
915
-  }
914
+    }
916 915
 
917
-  $form = array();
918
-  if (isset($form_state['privatemsg_preview'])) {
916
+    $form = array();
917
+    if (isset($form_state['privatemsg_preview'])) {
919 918
     $form['message_header'] = array(
920
-      '#type' => 'fieldset',
921
-      '#attributes' => array('class' => 'preview'),
919
+        '#type' => 'fieldset',
920
+        '#attributes' => array('class' => 'preview'),
922 921
     );
923 922
     $form['message_header']['message_preview'] = array(
924
-      '#value'  => $form_state['privatemsg_preview'],
923
+        '#value'  => $form_state['privatemsg_preview'],
925 924
     );
926
-  }
927
-  $form['privatemsg'] = array(
925
+    }
926
+    $form['privatemsg'] = array(
928 927
     '#type'               => 'fieldset',
929 928
     '#access'             => privatemsg_user_access('write privatemsg'),
930
-  );
931
-  $form['privatemsg']['author'] = array(
929
+    );
930
+    $form['privatemsg']['author'] = array(
932 931
     '#type' => 'value',
933 932
     '#value' => $user,
934
-  );
935
-  if (is_null($thread_id)) {
933
+    );
934
+    if (is_null($thread_id)) {
936 935
     $form['privatemsg']['recipient'] = array(
937
-      '#type'               => 'textfield',
938
-      '#title'              => t('To'),
939
-      '#description'        => t('Separate multiple names with a space. The number appearing in the suffix is the BOINC id. You can find a user\'s BOINC id on their user profile page.'),
940
-      '#default_value'      => $recipients_string,
941
-      '#required'           => TRUE,
942
-      '#weight'             => -10,
943
-      '#size'               => 50,
944
-      '#autocomplete_path'  => 'messages/user-name-autocomplete',
945
-      // Do not hardcode #maxlength, make it configurable by number of recipients, not their name length.
936
+        '#type'               => 'textfield',
937
+        '#title'              => t('To'),
938
+        '#description'        => t('Separate multiple names with a space. The number appearing in the suffix is the BOINC id. You can find a user\'s BOINC id on their user profile page.'),
939
+        '#default_value'      => $recipients_string,
940
+        '#required'           => TRUE,
941
+        '#weight'             => -10,
942
+        '#size'               => 50,
943
+        '#autocomplete_path'  => 'messages/user-name-autocomplete',
944
+        // Do not hardcode #maxlength, make it configurable by number of recipients, not their name length.
946 945
     );
947
-  }
948
-  $form['privatemsg']['subject'] = array(
946
+    }
947
+    $form['privatemsg']['subject'] = array(
949 948
     '#type'               => 'textfield',
950 949
     '#title'              => t('Subject'),
951 950
     '#size'               => 50,
952 951
     '#maxlength'          => 255,
953 952
     '#default_value'      => $subject,
954 953
     '#weight'             => -5,
955
-  );
956
-  $form['privatemsg']['body'] = array(
954
+    );
955
+    $form['privatemsg']['body'] = array(
957 956
     '#type'               => 'textarea',
958 957
     '#title'              => t('Message'),
959 958
     '#rows'               => 6,
960 959
     '#weight'             => 0,
961 960
     '#default_value'      => $body,
962 961
     '#resizable'          => TRUE,
963
-  );
964
-  $format = FILTER_FORMAT_DEFAULT;
965
-  // The input filter widget looses the format during preview, specify it
966
-  // explicitly.
967
-  if (isset($form_state['values']) && array_key_exists('format', $form_state['values'])) {
962
+    );
963
+    $format = FILTER_FORMAT_DEFAULT;
964
+    // The input filter widget looses the format during preview, specify it
965
+    // explicitly.
966
+    if (isset($form_state['values']) && array_key_exists('format', $form_state['values'])) {
968 967
     $format = $form_state['values']['format'];
969
-  }
970
-  $form['privatemsg']['format'] = filter_form($format);
971
-  $form['privatemsg']['preview'] = array(
968
+    }
969
+    $form['privatemsg']['format'] = filter_form($format);
970
+    $form['privatemsg']['preview'] = array(
972 971
     '#type'               => 'submit',
973 972
     '#value'              => t('Preview message'),
974 973
     '#submit'             => array('pm_preview'),
975 974
     '#validate'           => array('pm_send_validate'),
976 975
     '#weight'             => 10,
977
-  );
978
-  $form['privatemsg']['submit'] = array(
976
+    );
977
+    $form['privatemsg']['submit'] = array(
979 978
     '#type'               => 'submit',
980 979
     '#value'              => t('Send message'),
981 980
     '#submit'             => array('pm_send'),
982 981
     '#validate'           => array('pm_send_validate'),
983 982
     '#weight'             => 15,
984
-  );
985
-  $url = 'messages';
986
-  $title = t('Cancel');
987
-  if (isset($_REQUEST['destination'])) {
983
+    );
984
+    $url = 'messages';
985
+    $title = t('Cancel');
986
+    if (isset($_REQUEST['destination'])) {
988 987
     $url = $_REQUEST['destination'];
989
-  }
990
-  elseif (!is_null($thread_id)) {
988
+    }
989
+    elseif (!is_null($thread_id)) {
991 990
     $url = $_GET['q'];
992 991
     $title = t('Clear');
993
-  }
992
+    }
994 993
 
995
-  $form['privatemsg']['cancel'] = array(
994
+    $form['privatemsg']['cancel'] = array(
996 995
     '#value'              => l($title, $url, array('attributes' => array('id' => 'edit-cancel'))),
997 996
     '#weight'             => 20,
998
-  );
997
+    );
999 998
 
1000
-  if (!is_null($thread_id)) {
999
+    if (!is_null($thread_id)) {
1001 1000
     $form['privatemsg']['thread_id'] = array(
1002
-      '#type' => 'value',
1003
-      '#value' => $thread_id,
1001
+        '#type' => 'value',
1002
+        '#value' => $thread_id,
1004 1003
     );
1005 1004
     $form['privatemsg']['subject'] = array(
1006
-          '#type' => 'value',
1007
-          '#default_value' => $subject,
1005
+            '#type' => 'value',
1006
+            '#default_value' => $subject,
1008 1007
     );
1009 1008
     $recipients_string_themed = implode(', ', $to_themed);
1010 1009
     $form['privatemsg']['recipient_display'] = array(
1011
-      '#value' =>  '<p>'. t('<strong>Reply to thread</strong>:<br /> Recipients: !to', array('!to' => $recipients_string_themed)) .'</p>',
1012
-      '#weight' => -10,
1010
+        '#value' =>  '<p>'. t('<strong>Reply to thread</strong>:<br /> Recipients: !to', array('!to' => $recipients_string_themed)) .'</p>',
1011
+        '#weight' => -10,
1013 1012
     );
1014 1013
     if (empty($recipients_string)) {
1015
-      // If there are no valid recipients, unset the message reply form.
1016
-      $form['privatemsg']['#access'] = FALSE;
1014
+        // If there are no valid recipients, unset the message reply form.
1015
+        $form['privatemsg']['#access'] = FALSE;
1016
+    }
1017 1017
     }
1018
-  }
1019
-  $form['privatemsg']['read_all'] = array(
1018
+    $form['privatemsg']['read_all'] = array(
1020 1019
     '#type'  => 'value',
1021 1020
     '#value' => $read_all,
1022
-  );
1023
-  return $form;
1021
+    );
1022
+    return $form;
1024 1023
 }
1025 1024
 
1026 1025
 function pm_send_validate($form, &$form_state) {
1027
-  // The actual message that is being sent, we create this during validation and pass to submit to send out.
1028
-  $message = $form_state['values'];
1029
-  $message['timestamp'] = time();
1030
-  // Avoid subjects which only consist of a space as these can not be clicked.
1031
-  $message['subject'] = trim($message['subject']);
1026
+    // The actual message that is being sent, we create this during validation and pass to submit to send out.
1027
+    $message = $form_state['values'];
1028
+    $message['timestamp'] = time();
1029
+    // Avoid subjects which only consist of a space as these can not be clicked.
1030
+    $message['subject'] = trim($message['subject']);
1032 1031
 
1033 1032
 
1034
-  $trimed_body = trim(truncate_utf8(strip_tags($message['body']), 50, TRUE, TRUE));
1035
-  if (empty($message['subject']) && !empty($trimed_body)) {
1033
+    $trimed_body = trim(truncate_utf8(strip_tags($message['body']), 50, TRUE, TRUE));
1034
+    if (empty($message['subject']) && !empty($trimed_body)) {
1036 1035
     $message['subject'] = $trimed_body;
1037
-  }
1038
-  // Only parse the user string for a new thread.
1039
-  if (!isset($message['thread_id'])) {
1036
+    }
1037
+    // Only parse the user string for a new thread.
1038
+    if (!isset($message['thread_id'])) {
1040 1039
     list($message['recipients'], $invalid) = _privatemsg_parse_userstring($message['recipient']);
1041
-  }
1042
-  else {
1040
+    }
1041
+    else {
1043 1042
     // Load participants.
1044 1043
     $message['recipients'] = _privatemsg_load_thread_participants($message['thread_id']);
1045 1044
     // Remove author.
1046 1045
     if (isset($message['recipients'][$message['author']->uid]) && count($message['recipients']) > 1) {
1047
-      unset($message['recipients'][$message['author']->uid]);
1046
+        unset($message['recipients'][$message['author']->uid]);
1048 1047
     }
1049
-  }
1050
-  $validated = _privatemsg_validate_message($message, TRUE);
1051
-  foreach ($validated['messages'] as $type => $text) {
1048
+    }
1049
+    $validated = _privatemsg_validate_message($message, TRUE);
1050
+    foreach ($validated['messages'] as $type => $text) {
1052 1051
     drupal_set_message($text, $type);
1053
-  }
1054
-  $form_state['validate_built_message'] = $message;
1055
-  if (!empty($invalid)) {
1052
+    }
1053
+    $form_state['validate_built_message'] = $message;
1054
+    if (!empty($invalid)) {
1056 1055
     drupal_set_message(t('The following users will not receive this private message: @invalid', array('@invalid' => implode(", ", $invalid))), 'error');
1057
-  }
1056
+    }
1058 1057
 }
1059 1058
 
1060 1059
 /**
@@ -1064,15 +1063,15 @@  discard block
 block discarded – undo
1064 1063
  *   Thread ID for wich the participants should be loaded.
1065 1064
  */
1066 1065
 function _privatemsg_load_thread_participants($thread_id) {
1067
-  $query = _privatemsg_assemble_query('participants', $thread_id);
1068
-  $result = db_query($query['query']);
1069
-  $participants = array();
1070
-  while ($uid = db_fetch_object($result)) {
1066
+    $query = _privatemsg_assemble_query('participants', $thread_id);
1067
+    $result = db_query($query['query']);
1068
+    $participants = array();
1069
+    while ($uid = db_fetch_object($result)) {
1071 1070
     if (($recipient = user_load($uid->uid))) {
1072
-      $participants[$recipient->uid] = $recipient;
1071
+        $participants[$recipient->uid] = $recipient;
1072
+    }
1073 1073
     }
1074
-  }
1075
-  return $participants;
1074
+    return $participants;
1076 1075
 }
1077 1076
 
1078 1077
 /**
@@ -1088,67 +1087,67 @@  discard block
 block discarded – undo
1088 1087
  *   with invalid names.
1089 1088
  */
1090 1089
 function _privatemsg_parse_userstring($input) {
1091
-  if (is_string($input)) {
1090
+    if (is_string($input)) {
1092 1091
     $input = explode(' ', $input);
1093
-  }
1092
+    }
1094 1093
 
1095
-  // Start working through the input array.
1096
-  $invalid = array();
1097
-  $recipients = array();
1098
-  foreach ($input as $string) {
1094
+    // Start working through the input array.
1095
+    $invalid = array();
1096
+    $recipients = array();
1097
+    foreach ($input as $string) {
1099 1098
     $string = trim($string);
1100 1099
     if (!empty($string)) { // We don't care about white space names.
1101 1100
 
1102
-      // First, check if another module is able to resolve the string into an
1103
-      // user object.
1104
-      foreach (module_implements('privatemsg_name_lookup') as $module) {
1101
+        // First, check if another module is able to resolve the string into an
1102
+        // user object.
1103
+        foreach (module_implements('privatemsg_name_lookup') as $module) {
1105 1104
         $function = $module . '_privatemsg_name_lookup';
1106 1105
         if (($recipient = $function($string)) && is_object($recipient)) {
1107
-          // If there is a match, continue with the next input string.
1108
-          $recipients[$recipient->uid] = $recipient;
1109
-          continue 2;
1106
+            // If there is a match, continue with the next input string.
1107
+            $recipients[$recipient->uid] = $recipient;
1108
+            continue 2;
1110 1109
         }
1111
-      }
1112
-      // Fall back to the default username lookup.
1113
-      if (!$error = module_invoke('user', 'validate_name', $string)) {
1110
+        }
1111
+        // Fall back to the default username lookup.
1112
+        if (!$error = module_invoke('user', 'validate_name', $string)) {
1114 1113
         // String is a valid username, look it up.
1115 1114
         if ($recipient = user_load(array('name' => $string))) {
1116
-          $recipients[$recipient->uid] = $recipient;
1117
-          continue;
1115
+            $recipients[$recipient->uid] = $recipient;
1116
+            continue;
1117
+        }
1118 1118
         }
1119
-      }
1120
-      $invalid[$string] = $string;
1119
+        $invalid[$string] = $string;
1121 1120
     }
1122
-  }
1123
-  return array($recipients, $invalid);
1121
+    }
1122
+    return array($recipients, $invalid);
1124 1123
 }
1125 1124
 
1126 1125
 /**
1127 1126
  * Submit callback for the privatemsg_new form.
1128 1127
  */
1129 1128
 function pm_send($form, &$form_state) {
1130
-  $status = _privatemsg_send($form_state['validate_built_message']);
1131
-  // Load usernames to which the message was sent to.
1132
-  $recipient_names = array();
1133
-  foreach ($form_state['validate_built_message']['recipients'] as $recipient) {
1129
+    $status = _privatemsg_send($form_state['validate_built_message']);
1130
+    // Load usernames to which the message was sent to.
1131
+    $recipient_names = array();
1132
+    foreach ($form_state['validate_built_message']['recipients'] as $recipient) {
1134 1133
     $recipient_names[] = theme('username', $recipient);
1135
-  }
1136
-  if ($status !== FALSE )  {
1134
+    }
1135
+    if ($status !== FALSE )  {
1137 1136
     drupal_set_message(t('A message has been sent to !recipients.', array('!recipients' => implode(', ', $recipient_names))));
1138
-  }
1139
-  else {
1137
+    }
1138
+    else {
1140 1139
     drupal_set_message(t('An attempt to send a message <em>may have failed</em> when sending to !recipients.', array('!recipients' => implode(', ', $recipient_names))), 'error');
1141
-  }
1140
+    }
1142 1141
 }
1143 1142
 
1144 1143
 function pm_preview($form, &$form_state) {
1145 1144
 
1146 1145
     drupal_validate_form($form['form_id']['#value'], $form, $form_state);
1147 1146
     if (!form_get_errors()) {
1148
-      $form_state['privatemsg_preview'] = theme('privatemsg_view', $form_state['validate_built_message']);
1147
+        $form_state['privatemsg_preview'] = theme('privatemsg_view', $form_state['validate_built_message']);
1149 1148
     }
1150 1149
 
1151
-  $form_state['rebuild'] = TRUE; // this forces our form to be rebuilt instead of being submitted.
1150
+    $form_state['rebuild'] = TRUE; // this forces our form to be rebuilt instead of being submitted.
1152 1151
 }
1153 1152
 
1154 1153
 /**
@@ -1169,65 +1168,65 @@  discard block
 block discarded – undo
1169 1168
  */
1170 1169
 
1171 1170
 function privatemsg_sql_list(&$fragments, $account, $argument = 'list') {
1172
-  $fragments['primary_table'] = '{pm_message} pm';
1173
-
1174
-  // Load enabled columns.
1175
-  $fields = array_filter(variable_get('privatemsg_display_fields', array('participants')));
1176
-
1177
-  // Required columns.
1178
-  $fragments['select'][]      = 'pmi.thread_id';
1179
-  // We have to use MIN as the subject might not be the same in some threads.
1180
-  // MIN() does not have a useful meaning except that it helps to correctly
1181
-  // aggregate the thread on PostgreSQL.
1182
-  $fragments['select'][]      = 'MIN(pm.subject) as subject';
1183
-  $fragments['select'][]      = 'MAX(pm.timestamp) as last_updated';
1184
-  // We use SUM so that we can count the number of unread messages.
1185
-  $fragments['select'][]      = 'SUM(pmi.is_new) as is_new';
1186
-
1187
-  // Select number of messages in the thread if the count is
1188
-  // set to be displayed.
1189
-  if (in_array('count', $fields)) {
1171
+    $fragments['primary_table'] = '{pm_message} pm';
1172
+
1173
+    // Load enabled columns.
1174
+    $fields = array_filter(variable_get('privatemsg_display_fields', array('participants')));
1175
+
1176
+    // Required columns.
1177
+    $fragments['select'][]      = 'pmi.thread_id';
1178
+    // We have to use MIN as the subject might not be the same in some threads.
1179
+    // MIN() does not have a useful meaning except that it helps to correctly
1180
+    // aggregate the thread on PostgreSQL.
1181
+    $fragments['select'][]      = 'MIN(pm.subject) as subject';
1182
+    $fragments['select'][]      = 'MAX(pm.timestamp) as last_updated';
1183
+    // We use SUM so that we can count the number of unread messages.
1184
+    $fragments['select'][]      = 'SUM(pmi.is_new) as is_new';
1185
+
1186
+    // Select number of messages in the thread if the count is
1187
+    // set to be displayed.
1188
+    if (in_array('count', $fields)) {
1190 1189
     $fragments['select'][]      = 'COUNT(distinct pmi.mid) as count';
1191
-  }
1192
-  if (in_array('participants', $fields)) {
1190
+    }
1191
+    if (in_array('participants', $fields)) {
1193 1192
     // Query for a string with uid's, for example "1,6,7".
1194 1193
     // @todo: Replace this with a single query similiar to the tag list.
1195 1194
     if ($GLOBALS['db_type'] == 'pgsql') {
1196
-      // PostgreSQL does not know GROUP_CONCAT, so a subquery is required.
1197
-      $fragments['select'][]      = "array_to_string(array(SELECT DISTINCT textin(int4out(pmia.uid))
1195
+        // PostgreSQL does not know GROUP_CONCAT, so a subquery is required.
1196
+        $fragments['select'][]      = "array_to_string(array(SELECT DISTINCT textin(int4out(pmia.uid))
1198 1197
                                                             FROM {pm_index} pmia
1199 1198
                                                             WHERE pmia.thread_id = pmi.thread_id), ',') AS participants";
1200 1199
     }
1201 1200
     else {
1202
-      $fragments['select'][]      = '(SELECT GROUP_CONCAT(DISTINCT pmia.uid SEPARATOR ",")
1201
+        $fragments['select'][]      = '(SELECT GROUP_CONCAT(DISTINCT pmia.uid SEPARATOR ",")
1203 1202
                                                             FROM {pm_index} pmia
1204 1203
                                                             WHERE pmia.thread_id = pmi.thread_id) AS participants';
1205 1204
     }
1206
-  }
1207
-  if (in_array('thread_started', $fields)) {
1205
+    }
1206
+    if (in_array('thread_started', $fields)) {
1208 1207
     $fragments['select'][]      = 'MIN(pm.timestamp) as thread_started';
1209
-  }
1208
+    }
1210 1209
 
1211
-  $fragments['inner_join'][]  = 'INNER JOIN {pm_index} pmi ON pm.mid = pmi.mid';
1210
+    $fragments['inner_join'][]  = 'INNER JOIN {pm_index} pmi ON pm.mid = pmi.mid';
1212 1211
 
1213
-  // Only load undeleted messages of the current user and group by thread.
1214
-  $fragments['where'][]       = 'pmi.uid = %d';
1215
-  $fragments['query_args']['where'][]  = $account->uid;
1216
-  $fragments['where'][]       = 'pmi.deleted = 0';
1217
-  $fragments['group_by'][]    = 'pmi.thread_id';
1212
+    // Only load undeleted messages of the current user and group by thread.
1213
+    $fragments['where'][]       = 'pmi.uid = %d';
1214
+    $fragments['query_args']['where'][]  = $account->uid;
1215
+    $fragments['where'][]       = 'pmi.deleted = 0';
1216
+    $fragments['group_by'][]    = 'pmi.thread_id';
1218 1217
 
1219
-  $order_by_first = 'MAX(pmi.is_new) DESC, ';
1220
-  // MySQL 4.1 does not allow to order by aggregate functions. MAX() is used
1221
-  // to avoid a ordering bug with multiple new messages.
1222
-  if ($GLOBALS['db_type'] != 'pgsql' && version_compare(db_version(), '5.0.0') < 0) {
1218
+    $order_by_first = 'MAX(pmi.is_new) DESC, ';
1219
+    // MySQL 4.1 does not allow to order by aggregate functions. MAX() is used
1220
+    // to avoid a ordering bug with multiple new messages.
1221
+    if ($GLOBALS['db_type'] != 'pgsql' && version_compare(db_version(), '5.0.0') < 0) {
1223 1222
     $order_by_first = 'is_new DESC, ';
1224
-  }
1223
+    }
1225 1224
 
1226
-  // tablesort_sql() generates a ORDER BY string. However, the "ORDER BY " part 
1227
-  // is not needed and added by the query builder. Discard the first 9
1228
-  // characters of the string.
1229
-  $order_by = drupal_substr(tablesort_sql(_privatemsg_list_headers( FALSE, array_merge(array('subject', 'last_updated'), $fields)), $order_by_first), 9);
1230
-  $fragments['order_by'][]  = $order_by;
1225
+    // tablesort_sql() generates a ORDER BY string. However, the "ORDER BY " part 
1226
+    // is not needed and added by the query builder. Discard the first 9
1227
+    // characters of the string.
1228
+    $order_by = drupal_substr(tablesort_sql(_privatemsg_list_headers( FALSE, array_merge(array('subject', 'last_updated'), $fields)), $order_by_first), 9);
1229
+    $fragments['order_by'][]  = $order_by;
1231 1230
 }
1232 1231
 
1233 1232
 /**
@@ -1241,27 +1240,27 @@  discard block
 block discarded – undo
1241 1240
  *   Account for which the messages should be loaded.
1242 1241
  */
1243 1242
 function privatemsg_sql_load(&$fragments, $pmids, $account = NULL) {
1244
-  $fragments['primary_table'] = '{pm_message} pm';
1245
-
1246
-  $fragments['select'][]      = "pm.mid";
1247
-  $fragments['select'][]      = "pm.author";
1248
-  $fragments['select'][]      = "pm.subject";
1249
-  $fragments['select'][]      = "pm.body";
1250
-  $fragments['select'][]      = "pm.timestamp";
1251
-  $fragments['select'][]      = "pm.format";
1252
-  $fragments['select'][]      = "pmi.is_new";
1253
-  $fragments['select'][]      = "pmi.thread_id";
1254
-
1255
-  $fragments['inner_join'][]  = 'INNER JOIN {pm_index} pmi ON pm.mid = pmi.mid';
1256
-  // Use IN() to load multiple messages at the same time.
1257
-  $fragments['where'][]       = 'pmi.mid IN (' . db_placeholders($pmids) . ')';
1258
-  $fragments['query_args']['where']  += $pmids;
1259
-  if ($account) {
1243
+    $fragments['primary_table'] = '{pm_message} pm';
1244
+
1245
+    $fragments['select'][]      = "pm.mid";
1246
+    $fragments['select'][]      = "pm.author";
1247
+    $fragments['select'][]      = "pm.subject";
1248
+    $fragments['select'][]      = "pm.body";
1249
+    $fragments['select'][]      = "pm.timestamp";
1250
+    $fragments['select'][]      = "pm.format";
1251
+    $fragments['select'][]      = "pmi.is_new";
1252
+    $fragments['select'][]      = "pmi.thread_id";
1253
+
1254
+    $fragments['inner_join'][]  = 'INNER JOIN {pm_index} pmi ON pm.mid = pmi.mid';
1255
+    // Use IN() to load multiple messages at the same time.
1256
+    $fragments['where'][]       = 'pmi.mid IN (' . db_placeholders($pmids) . ')';
1257
+    $fragments['query_args']['where']  += $pmids;
1258
+    if ($account) {
1260 1259
     $fragments['where'][]       = 'pmi.uid = %d';
1261 1260
     $fragments['query_args']['where'][]  = $account->uid;
1262
-  }
1263
-  $fragments['order_by'][] = 'pm.timestamp ASC';
1264
-  $fragments['order_by'][] = 'pm.mid ASC';
1261
+    }
1262
+    $fragments['order_by'][] = 'pm.timestamp ASC';
1263
+    $fragments['order_by'][] = 'pm.mid ASC';
1265 1264
 }
1266 1265
 
1267 1266
 /**
@@ -1277,30 +1276,30 @@  discard block
 block discarded – undo
1277 1276
  *   Deleted messages are only loaded if this is set to TRUE.
1278 1277
  */
1279 1278
 function privatemsg_sql_messages(&$fragments, $threads, $account = NULL, $load_all = FALSE) {
1280
-  $fragments['primary_table'] = '{pm_index} pmi';
1279
+    $fragments['primary_table'] = '{pm_index} pmi';
1281 1280
 
1282
-  $fragments['select'][]      = 'pmi.mid';
1283
-  $fragments['where'][]       = 'pmi.thread_id IN ('. db_placeholders($threads) .')';
1284
-  $fragments['query_args']['where']   += $threads;
1285
-  $fragments['inner_join'][]  = 'INNER JOIN {pm_message} pm ON (pm.mid = pmi.mid)';
1286
-  if ($account) {
1281
+    $fragments['select'][]      = 'pmi.mid';
1282
+    $fragments['where'][]       = 'pmi.thread_id IN ('. db_placeholders($threads) .')';
1283
+    $fragments['query_args']['where']   += $threads;
1284
+    $fragments['inner_join'][]  = 'INNER JOIN {pm_message} pm ON (pm.mid = pmi.mid)';
1285
+    if ($account) {
1287 1286
     // Only load the user's messages.
1288 1287
     $fragments['where'][]     = 'pmi.uid = %d';
1289 1288
     $fragments['query_args']['where'][]  = $account->uid;
1290
-  }
1291
-  if (!$load_all) {
1289
+    }
1290
+    if (!$load_all) {
1292 1291
     // Also load deleted messages when requested.
1293 1292
     $fragments['where'][]     = 'pmi.deleted = 0';
1294
-  }
1295
-  // Only load each mid once.
1296
-  $fragments['group_by'][]    = 'pmi.mid';
1297
-  $fragments['group_by'][]    = 'pm.timestamp';
1293
+    }
1294
+    // Only load each mid once.
1295
+    $fragments['group_by'][]    = 'pmi.mid';
1296
+    $fragments['group_by'][]    = 'pm.timestamp';
1298 1297
 
1299
-  // Order by timestamp first.
1300
-  $fragments['order_by'][]    = 'pm.timestamp ASC';
1301
-  // If there are multiple inserts during the same second (tests, for example)
1302
-  // sort by mid second to have them in the same order as they were saved.
1303
-  $fragments['order_by'][]    = 'pmi.mid ASC';
1298
+    // Order by timestamp first.
1299
+    $fragments['order_by'][]    = 'pm.timestamp ASC';
1300
+    // If there are multiple inserts during the same second (tests, for example)
1301
+    // sort by mid second to have them in the same order as they were saved.
1302
+    $fragments['order_by'][]    = 'pmi.mid ASC';
1304 1303
 
1305 1304
 }
1306 1305
 
@@ -1313,16 +1312,16 @@  discard block
 block discarded – undo
1313 1312
  *   Thread id from which the participants should be loaded.
1314 1313
  */
1315 1314
 function privatemsg_sql_participants(&$fragments, $thread_id) {
1316
-  $fragments['primary_table'] = '{pm_index} pmi';
1315
+    $fragments['primary_table'] = '{pm_index} pmi';
1317 1316
 
1318
-  // Only load each participant once since they are listed as recipient for
1319
-  // every message of that thread.
1320
-  $fragments['select'][]      = 'DISTINCT(pmi.uid) AS uid';
1321
-  $fragments['select'][]      = 'u.name AS name';
1317
+    // Only load each participant once since they are listed as recipient for
1318
+    // every message of that thread.
1319
+    $fragments['select'][]      = 'DISTINCT(pmi.uid) AS uid';
1320
+    $fragments['select'][]      = 'u.name AS name';
1322 1321
 
1323
-  $fragments['inner_join'][]  = 'INNER JOIN {users} u ON (u.uid = pmi.uid)';
1324
-  $fragments['where'][]       = 'pmi.thread_id = %d';
1325
-  $fragments['query_args']['where'][]  = $thread_id;
1322
+    $fragments['inner_join'][]  = 'INNER JOIN {users} u ON (u.uid = pmi.uid)';
1323
+    $fragments['where'][]       = 'pmi.thread_id = %d';
1324
+    $fragments['query_args']['where'][]  = $thread_id;
1326 1325
 }
1327 1326
 
1328 1327
 /**
@@ -1334,15 +1333,15 @@  discard block
 block discarded – undo
1334 1333
  *   User object for which the messages are being counted.
1335 1334
  */
1336 1335
 function privatemsg_sql_unread_count(&$fragments, $account) {
1337
-  $fragments['primary_table'] = '{pm_index} pmi';
1336
+    $fragments['primary_table'] = '{pm_index} pmi';
1338 1337
 
1339
-  $fragments['select'][]      = 'COUNT(DISTINCT thread_id) as unread_count';
1338
+    $fragments['select'][]      = 'COUNT(DISTINCT thread_id) as unread_count';
1340 1339
 
1341
-  // Only count new messages that have not been deleted.
1342
-  $fragments['where'][]       = 'pmi.deleted = 0';
1343
-  $fragments['where'][]       = 'pmi.is_new = 1';
1344
-  $fragments['where'][]       = 'pmi.uid = %d';
1345
-  $fragments['query_args']['where'][]  = $account->uid;
1340
+    // Only count new messages that have not been deleted.
1341
+    $fragments['where'][]       = 'pmi.deleted = 0';
1342
+    $fragments['where'][]       = 'pmi.is_new = 1';
1343
+    $fragments['where'][]       = 'pmi.uid = %d';
1344
+    $fragments['query_args']['where'][]  = $account->uid;
1346 1345
 }
1347 1346
 
1348 1347
 /**
@@ -1356,27 +1355,27 @@  discard block
 block discarded – undo
1356 1355
  *   Array of names not to be used as suggestions.
1357 1356
  */
1358 1357
 function privatemsg_sql_autocomplete(&$fragments, $search, $names) {
1359
-  // Select users from BOINC user table by name and id. The id is
1360
-  // unique.
1361
-  $fragments['primary_table'] = '{user} u';
1362
-  $fragments['select'][] = 'u.name,u.id';
1363
-  // Escape the % to get it through the placeholder replacement.
1364
-  $fragments['where'][] = "u.name LIKE '%s'";
1365
-  $fragments['query_args']['where'][] = $search .'%%';
1366
-  if (!empty($names)) {
1358
+    // Select users from BOINC user table by name and id. The id is
1359
+    // unique.
1360
+    $fragments['primary_table'] = '{user} u';
1361
+    $fragments['select'][] = 'u.name,u.id';
1362
+    // Escape the % to get it through the placeholder replacement.
1363
+    $fragments['where'][] = "u.name LIKE '%s'";
1364
+    $fragments['query_args']['where'][] = $search .'%%';
1365
+    if (!empty($names)) {
1367 1366
     // If there are already names selected, exclude them from the
1368 1367
     // suggestions. Extract the BOINC ids from the names array, and
1369 1368
     // use to remove query results.
1370 1369
     $ids = array();
1371 1370
     foreach ($names as $name) {
1372
-      $boincid = substr($name, strrpos($name, '_') + 1);
1373
-      $ids[$boincid] = $boincid;
1371
+        $boincid = substr($name, strrpos($name, '_') + 1);
1372
+        $ids[$boincid] = $boincid;
1374 1373
     }
1375 1374
     $fragments['where'][] = "u.id NOT IN (". db_placeholders($ids, 'int') .")";
1376 1375
     $fragments['query_args']['where'] += $ids;
1377
-  }
1378
-  // Only load active users and sort them by name.
1379
-  $fragments['order_by'][] = 'u.name ASC';
1376
+    }
1377
+    // Only load active users and sort them by name.
1378
+    $fragments['order_by'][] = 'u.name ASC';
1380 1379
 }
1381 1380
 
1382 1381
 /**
@@ -1388,24 +1387,24 @@  discard block
 block discarded – undo
1388 1387
  *   Select messages older than x days.
1389 1388
  */
1390 1389
 function privatemsg_sql_deleted(&$fragments, $days) {
1391
-  $fragments['primary_table'] = '{pm_message} pm';
1390
+    $fragments['primary_table'] = '{pm_message} pm';
1392 1391
 
1393
-  $fragments['select'][] = 'pm.mid';
1394
-  // The lowest value is higher than 0 if all recipients have deleted a message.
1395
-  $fragments['select'][] = 'MIN(pmi.deleted) as is_deleted';
1396
-  // The time the most recent deletion happened.
1397
-  $fragments['select'][] = 'MAX(pmi.deleted) as last_deleted';
1392
+    $fragments['select'][] = 'pm.mid';
1393
+    // The lowest value is higher than 0 if all recipients have deleted a message.
1394
+    $fragments['select'][] = 'MIN(pmi.deleted) as is_deleted';
1395
+    // The time the most recent deletion happened.
1396
+    $fragments['select'][] = 'MAX(pmi.deleted) as last_deleted';
1398 1397
 
1399
-  $fragments['inner_join'][] = 'INNER JOIN {pm_index} pmi ON (pmi.mid = pm.mid)';
1398
+    $fragments['inner_join'][] = 'INNER JOIN {pm_index} pmi ON (pmi.mid = pm.mid)';
1400 1399
 
1401
-  $fragments['group_by'][] = 'pm.mid';
1400
+    $fragments['group_by'][] = 'pm.mid';
1402 1401
 
1403
-  // Ignore messages that have not been deleted by all users.
1404
-  $fragments['having'][] = 'MIN(pmi.deleted) > 0';
1402
+    // Ignore messages that have not been deleted by all users.
1403
+    $fragments['having'][] = 'MIN(pmi.deleted) > 0';
1405 1404
 
1406
-  // Only select messages that have been deleted more than n days ago.
1407
-  $fragments['having'][] = 'MAX(pmi.deleted) < %d';
1408
-  $fragments['query_args']['having'][] = time() - $days * 86400;
1405
+    // Only select messages that have been deleted more than n days ago.
1406
+    $fragments['having'][] = 'MAX(pmi.deleted) < %d';
1407
+    $fragments['query_args']['having'][] = time() - $days * 86400;
1409 1408
 }
1410 1409
 
1411 1410
 /**
@@ -1418,19 +1417,19 @@  discard block
 block discarded – undo
1418 1417
  * Prevents usernames from being used and/or suggested twice.
1419 1418
  */
1420 1419
 function privatemsg_user_name_autocomplete($string) {
1421
-  $names = array();
1422
-  // 1: Parse $string and build list of valid user names.
1423
-  $fragments = explode(' ', $string);
1424
-  foreach ($fragments as $index => $name) {
1420
+    $names = array();
1421
+    // 1: Parse $string and build list of valid user names.
1422
+    $fragments = explode(' ', $string);
1423
+    foreach ($fragments as $index => $name) {
1425 1424
     if ($name = trim($name)) {
1426
-      $names[$name] = $name;
1427
-    }
1428
-  }
1429
-  // By using user_validate_user we can ensure that names included in $names are at least logisticaly possible.
1430
-  // 2: Find the next user name suggestion.
1431
-  $fragment = array_pop($names);
1432
-  $matches = array();
1433
-  if (!empty($fragment)) {
1425
+        $names[$name] = $name;
1426
+    }
1427
+    }
1428
+    // By using user_validate_user we can ensure that names included in $names are at least logisticaly possible.
1429
+    // 2: Find the next user name suggestion.
1430
+    $fragment = array_pop($names);
1431
+    $matches = array();
1432
+    if (!empty($fragment)) {
1434 1433
     $query = _privatemsg_assemble_query('autocomplete', $fragment, $names);
1435 1434
     db_set_active('boinc');
1436 1435
     $result = db_query_range($query['query'], $fragment, 0, 10);
@@ -1438,175 +1437,175 @@  discard block
 block discarded – undo
1438 1437
     $prefix = count($names) ? implode(' ', $names) . ' ' : '';
1439 1438
     // 3: Build proper suggestions and print.
1440 1439
     while ($user = db_fetch_object($result)) {
1441
-      $myname = preg_replace("/ /", "\xc2\xa0", $user->name);
1442
-      $matches[$prefix . $myname . "_" . $user->id . ' '] = htmlentities($myname) . '(' . $user->id . ')';
1440
+        $myname = preg_replace("/ /", "\xc2\xa0", $user->name);
1441
+        $matches[$prefix . $myname . "_" . $user->id . ' '] = htmlentities($myname) . '(' . $user->id . ')';
1443 1442
     }
1444
-  }
1445
-  // convert to object to prevent drupal bug, see http://drupal.org/node/175361
1446
-  drupal_json((object)$matches);
1443
+    }
1444
+    // convert to object to prevent drupal bug, see http://drupal.org/node/175361
1445
+    drupal_json((object)$matches);
1447 1446
 }
1448 1447
 
1449 1448
 function privatemsg_user($op, &$edit, &$account, $category = NULL) {
1450
-  global $user;
1449
+    global $user;
1451 1450
 
1452
-  switch ($op) {
1451
+    switch ($op) {
1453 1452
     case 'view':
1454 1453
       if ($url = privatemsg_get_link(array($account))) {
1455 1454
         $account->content['privatemsg_send_new_message'] = array(
1456
-          '#type'   => 'markup',
1457
-          '#value'  => l(t('Send this user a message'), $url, array('query' => drupal_get_destination())),
1458
-          '#weight' => 10,
1455
+            '#type'   => 'markup',
1456
+            '#value'  => l(t('Send this user a message'), $url, array('query' => drupal_get_destination())),
1457
+            '#weight' => 10,
1459 1458
         );
1460
-      }
1461
-      break;
1459
+        }
1460
+        break;
1462 1461
     case 'login':
1463 1462
       if (variable_get('privatemsg_display_loginmessage', TRUE) && privatemsg_user_access()) {
1464 1463
         $count = privatemsg_unread_count();
1465 1464
         if ($count) {
1466
-          drupal_set_message(format_plural($count, 'You have <a href="@messages">1 unread message</a>.', 'You have <a href="@messages">@count unread messages</a>', array('@messages' => url('messages'))));
1465
+            drupal_set_message(format_plural($count, 'You have <a href="@messages">1 unread message</a>.', 'You have <a href="@messages">@count unread messages</a>', array('@messages' => url('messages'))));
1467 1466
         }
1468
-      }
1469
-      break;
1467
+        }
1468
+        break;
1470 1469
     case 'delete':
1471 1470
 
1472 1471
       // Load all mids of the messages the user wrote.
1473 1472
       $result = db_query("SELECT mid FROM {pm_message} WHERE author = %d", $account->uid);
1474
-      $mids = array();
1475
-      while ($row = db_fetch_array($result)) {
1473
+        $mids = array();
1474
+        while ($row = db_fetch_array($result)) {
1476 1475
         $mids[] = $row['mid'];
1477
-      }
1476
+        }
1478 1477
 
1479
-      // Delete messages the user wrote.
1480
-      db_query('DELETE FROM {pm_message} WHERE author = %d', $account->uid);
1478
+        // Delete messages the user wrote.
1479
+        db_query('DELETE FROM {pm_message} WHERE author = %d', $account->uid);
1481 1480
 
1482
-      if (!empty($mids)) {
1481
+        if (!empty($mids)) {
1483 1482
         // Delete recipient entries in {pm_index} of the messages the user wrote.
1484 1483
         db_query('DELETE FROM {pm_index} WHERE mid IN (' . db_placeholders($mids) . ')', $mids);
1485
-      }
1484
+        }
1486 1485
 
1487
-      // Delete recipient entries of that user.
1488
-      db_query('DELETE FROM {pm_index} WHERE uid = %d', $account->uid);
1489
-      break;
1490
-  }
1486
+        // Delete recipient entries of that user.
1487
+        db_query('DELETE FROM {pm_index} WHERE uid = %d', $account->uid);
1488
+        break;
1489
+    }
1491 1490
 }
1492 1491
 
1493 1492
 function privatemsg_block($op = 'list', $delta = 0, $edit = array()) {
1494
-  if ('list' == $op) {
1493
+    if ('list' == $op) {
1495 1494
     $blocks = array();
1496 1495
     $blocks['privatemsg-menu'] = array(
1497
-      'info' => t('Privatemsg links'),
1498
-      'cache' => BLOCK_NO_CACHE,
1496
+        'info' => t('Privatemsg links'),
1497
+        'cache' => BLOCK_NO_CACHE,
1499 1498
     );
1500 1499
     $blocks['privatemsg-new'] = array(
1501
-      'info' => t('New message indication'),
1502
-      'cache' => BLOCK_NO_CACHE,
1500
+        'info' => t('New message indication'),
1501
+        'cache' => BLOCK_NO_CACHE,
1503 1502
     );
1504 1503
 
1505 1504
     return $blocks;
1506
-  }
1507
-  elseif ('view' == $op) {
1505
+    }
1506
+    elseif ('view' == $op) {
1508 1507
     $block = array();
1509 1508
     switch ($delta) {
1510
-      case 'privatemsg-menu':
1509
+        case 'privatemsg-menu':
1511 1510
         $block = _privatemsg_block_menu();
1512 1511
         break;
1513
-      case 'privatemsg-new':
1512
+        case 'privatemsg-new':
1514 1513
         $block = _privatemsg_block_new();
1515 1514
         break;
1516 1515
     }
1517 1516
     return $block;
1518
-  }
1517
+    }
1519 1518
 }
1520 1519
 
1521 1520
 function privatemsg_title_callback($title = NULL) {
1522
-  $count = privatemsg_unread_count();
1521
+    $count = privatemsg_unread_count();
1523 1522
 
1524
-  if ($count > 0) {
1523
+    if ($count > 0) {
1525 1524
     return format_plural($count, 'Messages (1 new)', 'Messages (@count new)');
1526
-  }
1527
-  return t('Messages');
1525
+    }
1526
+    return t('Messages');
1528 1527
 }
1529 1528
 
1530 1529
 
1531 1530
 function _privatemsg_block_new() {
1532
-  $block = array();
1531
+    $block = array();
1533 1532
 
1534
-  if (!privatemsg_user_access()) {
1533
+    if (!privatemsg_user_access()) {
1535 1534
     return $block;
1536
-  }
1535
+    }
1537 1536
 
1538
-  $count = privatemsg_unread_count();
1539
-  if ($count) {
1537
+    $count = privatemsg_unread_count();
1538
+    if ($count) {
1540 1539
     $block = array(
1541
-      'subject' => format_plural($count, 'New message', 'New messages'),
1542
-      'content' => theme('privatemsg_new_block', $count),
1540
+        'subject' => format_plural($count, 'New message', 'New messages'),
1541
+        'content' => theme('privatemsg_new_block', $count),
1543 1542
     );
1544 1543
     return $block;
1545
-  }
1546
-  return array();
1544
+    }
1545
+    return array();
1547 1546
 }
1548 1547
 
1549 1548
 function _privatemsg_block_menu() {
1550
-  $block = array();
1549
+    $block = array();
1551 1550
 
1552
-  $links = array();
1553
-  if (privatemsg_user_access('write privatemsg')) {
1551
+    $links = array();
1552
+    if (privatemsg_user_access('write privatemsg')) {
1554 1553
     $links[] = l(t('Write new message'), 'messages/new');
1555
-  }
1556
-  if (privatemsg_user_access('read privatemsg') || privatemsg_user_access('read all private messages') ) {
1554
+    }
1555
+    if (privatemsg_user_access('read privatemsg') || privatemsg_user_access('read all private messages') ) {
1557 1556
     $links[] = l(privatemsg_title_callback(), 'messages');
1558
-  }
1559
-  if ( count( $links ) ) {
1557
+    }
1558
+    if ( count( $links ) ) {
1560 1559
     $block = array(
1561
-      'subject' => t('Private messages'),
1562
-      'content' => theme('item_list', $links),
1560
+        'subject' => t('Private messages'),
1561
+        'content' => theme('item_list', $links),
1563 1562
     );
1564
-  }
1565
-  return $block;
1563
+    }
1564
+    return $block;
1566 1565
 }
1567 1566
 
1568 1567
 function privatemsg_delete($form_state, $thread, $message) {
1569
-  $form['pmid'] = array(
1568
+    $form['pmid'] = array(
1570 1569
     '#type' => 'value',
1571 1570
     '#value' => $message['mid'],
1572
-  );
1573
-  $form['delete_destination'] = array(
1571
+    );
1572
+    $form['delete_destination'] = array(
1574 1573
     '#type' => 'value',
1575 1574
     '#value' => count($thread['messages']) > 1 ? 'messages/view/' . $message['thread_id'] : 'messages',
1576
-  );
1575
+    );
1577 1576
 
1578
-  if (privatemsg_user_access('read all private messages')) {
1577
+    if (privatemsg_user_access('read all private messages')) {
1579 1578
     $form['delete_options'] = array(
1580
-      '#type' => 'checkbox',
1581
-      '#title' => t('Delete this message for all users?'),
1582
-      '#description' => t('Tick the box to delete the message for all users.'),
1583
-      '#default_value' => FALSE,
1579
+        '#type' => 'checkbox',
1580
+        '#title' => t('Delete this message for all users?'),
1581
+        '#description' => t('Tick the box to delete the message for all users.'),
1582
+        '#default_value' => FALSE,
1584 1583
     );
1585
-  }
1586
-  return confirm_form($form,
1584
+    }
1585
+    return confirm_form($form,
1587 1586
     t('Are you sure you want to delete this message?'),
1588 1587
     isset($_GET['destination']) ? $_GET['destination'] : 'messages/view/'. $message['thread_id'],
1589 1588
     t('This action cannot be undone.'),
1590 1589
     t('Delete'),
1591 1590
     t('Cancel')
1592
-  );
1591
+    );
1593 1592
 }
1594 1593
 
1595 1594
 function privatemsg_delete_submit($form, &$form_state) {
1596
-  global $user;
1597
-  $account = drupal_clone($user);
1595
+    global $user;
1596
+    $account = drupal_clone($user);
1598 1597
 
1599
-  if ($form_state['values']['confirm']) {
1598
+    if ($form_state['values']['confirm']) {
1600 1599
     if (isset($form_state['values']['delete_options']) && $form_state['values']['delete_options']) {
1601
-      privatemsg_message_change_delete($form_state['values']['pmid'], 1);
1602
-      drupal_set_message(t('Message has been deleted for all users.'));
1600
+        privatemsg_message_change_delete($form_state['values']['pmid'], 1);
1601
+        drupal_set_message(t('Message has been deleted for all users.'));
1603 1602
     }
1604 1603
     else {
1605
-      privatemsg_message_change_delete($form_state['values']['pmid'], 1, $account);
1606
-      drupal_set_message(t('Message has been deleted.'));
1604
+        privatemsg_message_change_delete($form_state['values']['pmid'], 1, $account);
1605
+        drupal_set_message(t('Message has been deleted.'));
1607 1606
     }
1608
-  }
1609
-  $form_state['redirect'] = $form_state['values']['delete_destination'];
1607
+    }
1608
+    $form_state['redirect'] = $form_state['values']['delete_destination'];
1610 1609
 }
1611 1610
 
1612 1611
 /**
@@ -1623,18 +1622,18 @@  discard block
 block discarded – undo
1623 1622
  * @ingroup api
1624 1623
  */
1625 1624
 function privatemsg_message_change_delete($pmid, $delete, $account = NULL) {
1626
-  $delete_value = 0;
1627
-  if ($delete == TRUE) {
1625
+    $delete_value = 0;
1626
+    if ($delete == TRUE) {
1628 1627
     $delete_value = time();
1629
-  }
1628
+    }
1630 1629
 
1631
-  if ($account) {
1630
+    if ($account) {
1632 1631
     db_query('UPDATE {pm_index} SET deleted = %d WHERE mid = %d AND uid = %d', $delete_value, $pmid, $account->uid);
1633
-  }
1634
-  else {
1632
+    }
1633
+    else {
1635 1634
     // Mark deleted for all users.
1636 1635
     db_query('UPDATE {pm_index} SET deleted = %d WHERE mid = %d', $delete_value, $pmid);
1637
-  }
1636
+    }
1638 1637
 }
1639 1638
 
1640 1639
 /**
@@ -1677,35 +1676,35 @@  discard block
 block discarded – undo
1677 1676
  * @ingroup api
1678 1677
  */
1679 1678
 function privatemsg_new_thread($recipients, $subject, $body = NULL, $options = array()) {
1680
-  global $user;
1681
-  $author = drupal_clone($user);
1682
-
1683
-  $message = array();
1684
-  $message['subject'] = $subject;
1685
-  $message['body'] = $body;
1686
-  // Make sure that recipients are keyed by user id and are not added
1687
-  // multiple times.
1688
-  foreach ($recipients as $recipient) {
1679
+    global $user;
1680
+    $author = drupal_clone($user);
1681
+
1682
+    $message = array();
1683
+    $message['subject'] = $subject;
1684
+    $message['body'] = $body;
1685
+    // Make sure that recipients are keyed by user id and are not added
1686
+    // multiple times.
1687
+    foreach ($recipients as $recipient) {
1689 1688
     $message['recipients'][$recipient->uid] = $recipient;
1690
-  }
1689
+    }
1691 1690
 
1692
-  // Set custom options, if any.
1693
-  if (!empty($options)) {
1691
+    // Set custom options, if any.
1692
+    if (!empty($options)) {
1694 1693
     $message += $options;
1695
-  }
1696
-  // Apply defaults - this will not overwrite existing keys.
1697
-  $message += array(
1694
+    }
1695
+    // Apply defaults - this will not overwrite existing keys.
1696
+    $message += array(
1698 1697
     'author' => $author,
1699 1698
     'timestamp' => time(),
1700 1699
     'format' => filter_resolve_format(FILTER_FORMAT_DEFAULT),
1701
-  );
1700
+    );
1702 1701
 
1703
-  $validated = _privatemsg_validate_message($message);
1704
-  if ($validated['success']) {
1702
+    $validated = _privatemsg_validate_message($message);
1703
+    if ($validated['success']) {
1705 1704
     $validated['message'] = _privatemsg_send($message);
1706
-  }
1705
+    }
1707 1706
 
1708
-  return $validated;
1707
+    return $validated;
1709 1708
 }
1710 1709
 
1711 1710
 /**
@@ -1742,144 +1741,144 @@  discard block
 block discarded – undo
1742 1741
  * @ingroup api
1743 1742
  */
1744 1743
 function privatemsg_reply($thread_id, $body, $options = array()) {
1745
-  global $user;
1746
-  $author = drupal_clone($user);
1744
+    global $user;
1745
+    $author = drupal_clone($user);
1747 1746
 
1748
-  $message = array();
1749
-  $message['body'] = $body;
1747
+    $message = array();
1748
+    $message['body'] = $body;
1750 1749
 
1751
-  // set custom options, if any
1752
-  if (!empty($options)) {
1750
+    // set custom options, if any
1751
+    if (!empty($options)) {
1753 1752
     $message += $options;
1754
-  }
1755
-  // apply defaults
1756
-  $message += array(
1753
+    }
1754
+    // apply defaults
1755
+    $message += array(
1757 1756
     'author' => $author,
1758 1757
     'timestamp' => time(),
1759 1758
     'format' => filter_resolve_format(FILTER_FORMAT_DEFAULT),
1760
-  );
1759
+    );
1761 1760
 
1762
-  // We don't know the subject and the recipients, so we need to load them..
1763
-  // thread_id == mid on the first message of the thread
1764
-  $first_message = privatemsg_message_load($thread_id, $message['author']);
1765
-  if (!$first_message) {
1761
+    // We don't know the subject and the recipients, so we need to load them..
1762
+    // thread_id == mid on the first message of the thread
1763
+    $first_message = privatemsg_message_load($thread_id, $message['author']);
1764
+    if (!$first_message) {
1766 1765
     return array(t('Thread %thread_id not found, unable to answer', array('%thread_id' => $thread_id)));
1767
-  }
1766
+    }
1768 1767
 
1769
-  $message['thread_id'] = $thread_id;
1770
-  // Load participants.
1771
-  $message['recipients'] = _privatemsg_load_thread_participants($thread_id);
1772
-  // Remove author.
1773
-  if (isset($message['recipients'][$message['author']->uid]) && count($message['recipients']) > 1) {
1768
+    $message['thread_id'] = $thread_id;
1769
+    // Load participants.
1770
+    $message['recipients'] = _privatemsg_load_thread_participants($thread_id);
1771
+    // Remove author.
1772
+    if (isset($message['recipients'][$message['author']->uid]) && count($message['recipients']) > 1) {
1774 1773
     unset($message['recipients'][$message['author']->uid]);
1775
-  }
1776
-  $message['subject'] = $first_message['subject'];
1774
+    }
1775
+    $message['subject'] = $first_message['subject'];
1777 1776
 
1778
-  $validated = _privatemsg_validate_message($message);
1779
-  if ($validated['success']) {
1777
+    $validated = _privatemsg_validate_message($message);
1778
+    if ($validated['success']) {
1780 1779
     $validated['message'] = _privatemsg_send($message);
1781
-  }
1782
-  return $validated;
1780
+    }
1781
+    return $validated;
1783 1782
 }
1784 1783
 
1785 1784
 function _privatemsg_validate_message(&$message, $form = FALSE) {
1786
-  $messages = array('error' => array(), 'warning' => array());
1787
-  if (!privatemsg_user_access('write privatemsg', $message['author'])) {
1785
+    $messages = array('error' => array(), 'warning' => array());
1786
+    if (!privatemsg_user_access('write privatemsg', $message['author'])) {
1788 1787
     // no need to do further checks in this case...
1789 1788
     if ($form) {
1790
-      form_set_error('author', t('User @user is not allowed to write messages', array('@user' => $message['author']->name)));
1791
-      return array(
1789
+        form_set_error('author', t('User @user is not allowed to write messages', array('@user' => $message['author']->name)));
1790
+        return array(
1792 1791
         'success'  => FALSE,
1793 1792
         'messages'   => $messages,
1794
-      );
1793
+        );
1795 1794
     }
1796 1795
     else {
1797
-      $messages['error'][] = t('User @user is not allowed to write messages', array('@user' => $message['author']->name));
1798
-      return array(
1799
-         'success'  => FALSE,
1800
-         'messages'   => $messages,
1801
-      );
1796
+        $messages['error'][] = t('User @user is not allowed to write messages', array('@user' => $message['author']->name));
1797
+        return array(
1798
+            'success'  => FALSE,
1799
+            'messages'   => $messages,
1800
+        );
1801
+    }
1802 1802
     }
1803
-  }
1804 1803
 
1805
-  // Prevent subjects which only consist of a space as these can not be clicked.
1806
-  $message['subject'] = trim($message['subject']);
1807
-  if (empty($message['subject'])) {
1804
+    // Prevent subjects which only consist of a space as these can not be clicked.
1805
+    $message['subject'] = trim($message['subject']);
1806
+    if (empty($message['subject'])) {
1808 1807
     if ($form) {
1809
-      form_set_error('subject', t('Disallowed to send a message without subject'));
1808
+        form_set_error('subject', t('Disallowed to send a message without subject'));
1810 1809
     }
1811 1810
     else {
1812
-      $messages['error'][] = t('Disallowed to send a message without subject');
1811
+        $messages['error'][] = t('Disallowed to send a message without subject');
1812
+    }
1813 1813
     }
1814
-  }
1815 1814
 
1816
-  // Don't allow replies without a body.
1817
-  if (!empty($message['thread_id']) && ($message['body'] === NULL || $message['body'] === '') ) {
1815
+    // Don't allow replies without a body.
1816
+    if (!empty($message['thread_id']) && ($message['body'] === NULL || $message['body'] === '') ) {
1818 1817
     if ($form) {
1819
-      form_set_error('body', t('Disallowed to send reply without a message.'));
1818
+        form_set_error('body', t('Disallowed to send reply without a message.'));
1820 1819
     }
1821 1820
     else {
1822
-      $messages['error'][] = t('Disallowed to send reply without a message.');
1821
+        $messages['error'][] = t('Disallowed to send reply without a message.');
1822
+    }
1823 1823
     }
1824
-  }
1825
-  // Check if an allowed format is used. global $user needs to be changed since
1826
-  // it is not possible to do the check for a specific user.
1827
-  global $user;
1828
-  $original_user = drupal_clone($user);
1829
-  session_save_session(FALSE);
1830
-  $user = $message['author'];
1824
+    // Check if an allowed format is used. global $user needs to be changed since
1825
+    // it is not possible to do the check for a specific user.
1826
+    global $user;
1827
+    $original_user = drupal_clone($user);
1828
+    session_save_session(FALSE);
1829
+    $user = $message['author'];
1831 1830
 
1832
-  if (!filter_access($message['format'])) {
1831
+    if (!filter_access($message['format'])) {
1833 1832
     if ($form) {
1834
-      form_set_error('format', t('You are not allowed to use the specified input format.'));
1833
+        form_set_error('format', t('You are not allowed to use the specified input format.'));
1835 1834
     }
1836 1835
     else {
1837
-      $messages['error'][] = t('User @user is not allowed to use the specified input format.', array('@user' => $message['author']->name));
1836
+        $messages['error'][] = t('User @user is not allowed to use the specified input format.', array('@user' => $message['author']->name));
1837
+    }
1838 1838
     }
1839
-  }
1840 1839
 
1841
-  $user = $original_user;
1842
-  session_save_session(TRUE);
1840
+    $user = $original_user;
1841
+    session_save_session(TRUE);
1843 1842
 
1844
-  if (empty($message['recipients']) || !is_array($message['recipients'])) {
1843
+    if (empty($message['recipients']) || !is_array($message['recipients'])) {
1845 1844
     if ($form) {
1846
-      form_set_error('to', t('Disallowed to send a message without at least one valid recipient'));
1845
+        form_set_error('to', t('Disallowed to send a message without at least one valid recipient'));
1847 1846
     }
1848 1847
     else {
1849
-      $messages['error'][] = t('Disallowed to send a message without at least one valid recipient');
1848
+        $messages['error'][] = t('Disallowed to send a message without at least one valid recipient');
1849
+    }
1850 1850
     }
1851
-  }
1852 1851
 
1853
-  if (!empty($message['recipients']) && is_array($message['recipients'])) {
1852
+    if (!empty($message['recipients']) && is_array($message['recipients'])) {
1854 1853
     foreach (module_invoke_all('privatemsg_block_message', $message['author'], $message['recipients']) as $blocked) {
1855
-      unset($message['recipients'][$blocked['uid']]);
1856
-      if ($form) {
1854
+        unset($message['recipients'][$blocked['uid']]);
1855
+        if ($form) {
1857 1856
         drupal_set_message($blocked['message'], 'warning');
1858
-      }
1859
-      else {
1857
+        }
1858
+        else {
1860 1859
         $messages['warning'][] = $blocked['message'];
1861
-      }
1860
+        }
1861
+    }
1862 1862
     }
1863
-  }
1864 1863
 
1865
-  // Check again, give another error message if all recipients are blocked
1866
-  if (empty($message['recipients'])) {
1864
+    // Check again, give another error message if all recipients are blocked
1865
+    if (empty($message['recipients'])) {
1867 1866
     if ($form) {
1868
-      form_set_error('to', t('Disallowed to send message because all recipients are blocked'));
1867
+        form_set_error('to', t('Disallowed to send message because all recipients are blocked'));
1869 1868
     }
1870 1869
     else {
1871
-      $messages['error'][] = t('Disallowed to send message because all recipients are blocked');
1870
+        $messages['error'][] = t('Disallowed to send message because all recipients are blocked');
1871
+    }
1872 1872
     }
1873
-  }
1874 1873
 
1875
-  $messages = array_merge_recursive(module_invoke_all('privatemsg_message_validate', $message, $form), $messages);
1874
+    $messages = array_merge_recursive(module_invoke_all('privatemsg_message_validate', $message, $form), $messages);
1876 1875
 
1877
-  // Check if there are errors in $messages or if $form is TRUE, there are form errors.
1878
-  $success = empty($messages['error']) || ($form && count((array)form_get_errors()) > 0);
1879
-  return array(
1876
+    // Check if there are errors in $messages or if $form is TRUE, there are form errors.
1877
+    $success = empty($messages['error']) || ($form && count((array)form_get_errors()) > 0);
1878
+    return array(
1880 1879
     'success'  => $success,
1881 1880
     'messages'   => $messages,
1882
-  );
1881
+    );
1883 1882
 }
1884 1883
 
1885 1884
 /**
@@ -1895,61 +1894,61 @@  discard block
 block discarded – undo
1895 1894
  */
1896 1895
 function _privatemsg_send($message) {
1897 1896
 
1898
-  drupal_alter('privatemsg_message_presave', $message);
1897
+    drupal_alter('privatemsg_message_presave', $message);
1899 1898
 
1900
-  $index_sql = "INSERT INTO {pm_index} (mid, thread_id, uid, is_new, deleted) VALUES (%d, %d, %d, %d, 0)";
1901
-  if (isset($message['read_all']) && $message['read_all']) {
1899
+    $index_sql = "INSERT INTO {pm_index} (mid, thread_id, uid, is_new, deleted) VALUES (%d, %d, %d, %d, 0)";
1900
+    if (isset($message['read_all']) && $message['read_all']) {
1902 1901
     // The message was sent in read all mode, add the author as recipient to all
1903 1902
     // existing messages.
1904 1903
     $query_messages = _privatemsg_assemble_query('messages', array($message['thread_id']), NULL);
1905 1904
     $conversation = db_query($query_messages['query']);
1906 1905
     while ($result = db_fetch_array($conversation)) {
1907
-      if (!db_query($index_sql, $result['mid'], $message['thread_id'], $message['author']->uid, 0)) {
1906
+        if (!db_query($index_sql, $result['mid'], $message['thread_id'], $message['author']->uid, 0)) {
1908 1907
         return FALSE;
1909
-      }
1910
-    }
1911
-  }
1912
-
1913
-  // 1) Save the message body first.
1914
-  $args = array();
1915
-  $args[] = $message['subject'];
1916
-  $args[] = $message['author']->uid;
1917
-  $args[] = $message['body'];
1918
-  $args[] = $message['format'];
1919
-  $args[] = $message['timestamp'];
1920
-  $message_sql = "INSERT INTO {pm_message} (subject, author, body, format, timestamp) VALUES ('%s', %d, '%s', %d, %d)";
1921
-  db_query($message_sql, $args);
1922
-  $mid = db_last_insert_id('pm_message', 'mid');
1923
-  $message['mid'] = $mid;
1924
-
1925
-  // Thread ID is the same as the mid if it's the first message in the thread.
1926
-  if (!isset($message['thread_id'])) {
1908
+        }
1909
+    }
1910
+    }
1911
+
1912
+    // 1) Save the message body first.
1913
+    $args = array();
1914
+    $args[] = $message['subject'];
1915
+    $args[] = $message['author']->uid;
1916
+    $args[] = $message['body'];
1917
+    $args[] = $message['format'];
1918
+    $args[] = $message['timestamp'];
1919
+    $message_sql = "INSERT INTO {pm_message} (subject, author, body, format, timestamp) VALUES ('%s', %d, '%s', %d, %d)";
1920
+    db_query($message_sql, $args);
1921
+    $mid = db_last_insert_id('pm_message', 'mid');
1922
+    $message['mid'] = $mid;
1923
+
1924
+    // Thread ID is the same as the mid if it's the first message in the thread.
1925
+    if (!isset($message['thread_id'])) {
1927 1926
     $message['thread_id'] = $mid;
1928
-  }
1927
+    }
1929 1928
 
1930
-  // 2) Save message to recipients.
1931
-  // Each recipient gets a record in the pm_index table.
1932
-  foreach ($message['recipients'] as $recipient) {
1929
+    // 2) Save message to recipients.
1930
+    // Each recipient gets a record in the pm_index table.
1931
+    foreach ($message['recipients'] as $recipient) {
1933 1932
     if (!db_query($index_sql, $mid, $message['thread_id'], $recipient->uid, 1) ) {
1934
-      // We assume if one insert failed then the rest may fail too against the
1935
-      // same table.
1936
-      return FALSE;
1933
+        // We assume if one insert failed then the rest may fail too against the
1934
+        // same table.
1935
+        return FALSE;
1936
+    }
1937 1937
     }
1938
-  }
1939 1938
 
1940
-  // When author is also the recipient, we want to set message to UNREAD.
1941
-  // All other times the message is set to READ.
1942
-  $is_new = isset($message['recipients'][$message['author']->uid]) ? 1 : 0;
1939
+    // When author is also the recipient, we want to set message to UNREAD.
1940
+    // All other times the message is set to READ.
1941
+    $is_new = isset($message['recipients'][$message['author']->uid]) ? 1 : 0;
1943 1942
 
1944
-  // Also add a record for the author to the pm_index table.
1945
-  if (!db_query($index_sql, $mid, $message['thread_id'], $message['author']->uid, $is_new)) {
1943
+    // Also add a record for the author to the pm_index table.
1944
+    if (!db_query($index_sql, $mid, $message['thread_id'], $message['author']->uid, $is_new)) {
1946 1945
     return FALSE;
1947
-  }
1946
+    }
1948 1947
 
1949
-  module_invoke_all('privatemsg_message_insert', $message);
1948
+    module_invoke_all('privatemsg_message_insert', $message);
1950 1949
 
1951
-  // If we reached here that means we were successful at writing all messages to db.
1952
-  return $message;
1950
+    // If we reached here that means we were successful at writing all messages to db.
1951
+    return $message;
1953 1952
 }
1954 1953
 
1955 1954
 /**
@@ -1969,37 +1968,37 @@  discard block
 block discarded – undo
1969 1968
  * @ingroup api
1970 1969
  */
1971 1970
 function privatemsg_get_link($recipients, $account = array(), $subject = NULL) {
1972
-  if ($account == NULL) {
1971
+    if ($account == NULL) {
1973 1972
     global $user;
1974 1973
     $account = $user;
1975
-  }
1974
+    }
1976 1975
 
1977
-  if (!is_array($recipients)) {
1976
+    if (!is_array($recipients)) {
1978 1977
     $recipients = array($recipients);
1979
-  }
1978
+    }
1980 1979
 
1981
-  if (!privatemsg_user_access('write privatemsg', $account) || $account->uid == 0) {
1980
+    if (!privatemsg_user_access('write privatemsg', $account) || $account->uid == 0) {
1982 1981
     return FALSE;
1983
-  }
1982
+    }
1984 1983
 
1985
-  $validated = array();
1986
-  foreach ($recipients as $recipient) {
1984
+    $validated = array();
1985
+    foreach ($recipients as $recipient) {
1987 1986
     if (!privatemsg_user_access('read privatemsg', $recipient)) {
1988
-      continue;
1987
+        continue;
1989 1988
     }
1990 1989
     if (count(module_invoke_all('privatemsg_block_message', $account, array($recipient->uid => $recipient))) > 0) {
1991
-      continue;
1990
+        continue;
1992 1991
     }
1993 1992
     $validated[] = $recipient->uid;
1994
-  }
1995
-  if (empty($validated)) {
1993
+    }
1994
+    if (empty($validated)) {
1996 1995
     return FALSE;
1997
-  }
1998
-  $url = 'messages/new/'. implode(',', $validated);
1999
-  if (!is_null($subject)) {
1996
+    }
1997
+    $url = 'messages/new/'. implode(',', $validated);
1998
+    if (!is_null($subject)) {
2000 1999
     $url .= '/'. $subject;
2001
-  }
2002
-  return $url;
2000
+    }
2001
+    return $url;
2003 2002
 }
2004 2003
 
2005 2004
 /**
@@ -2014,8 +2013,8 @@  discard block
 block discarded – undo
2014 2013
  * @ingroup api
2015 2014
  */
2016 2015
 function privatemsg_message_load($pmid, $account = NULL) {
2017
-  $messages = privatemsg_message_load_multiple(array($pmid), $account);
2018
-  return current($messages);
2016
+    $messages = privatemsg_message_load_multiple(array($pmid), $account);
2017
+    return current($messages);
2019 2018
 }
2020 2019
 
2021 2020
 /**
@@ -2030,27 +2029,27 @@  discard block
 block discarded – undo
2030 2029
  * @ingroup api
2031 2030
  */
2032 2031
 function privatemsg_message_load_multiple($pmids, $account = NULL) {
2033
-  // Avoid SQL error that would happen with an empty pm.mid IN () clause.
2034
-  if (empty($pmids)) {
2032
+    // Avoid SQL error that would happen with an empty pm.mid IN () clause.
2033
+    if (empty($pmids)) {
2035 2034
     return array();
2036
-  }
2035
+    }
2037 2036
 
2038
-  $query = _privatemsg_assemble_query('load', $pmids, $account);
2039
-  $result = db_query($query['query']);
2040
-  $messages = array();
2041
-  while ($message = db_fetch_array($result)) {
2037
+    $query = _privatemsg_assemble_query('load', $pmids, $account);
2038
+    $result = db_query($query['query']);
2039
+    $messages = array();
2040
+    while ($message = db_fetch_array($result)) {
2042 2041
     // Load author of message.
2043 2042
     if (!($message['author'] = user_load($message['author']))) {
2044
-      // If user does not exist, load anonymous user.
2045
-      $message['author'] = user_load(array('uid' => 0));
2043
+        // If user does not exist, load anonymous user.
2044
+        $message['author'] = user_load(array('uid' => 0));
2046 2045
     }
2047 2046
     $returned = module_invoke_all('privatemsg_message_load', $message);
2048 2047
     if (!empty($returned)) {
2049
-      $message = array_merge_recursive($returned, $message);
2048
+        $message = array_merge_recursive($returned, $message);
2050 2049
     }
2051 2050
     $messages[$message['mid']] = $message;
2052
-  }
2053
-  return $messages;
2051
+    }
2052
+    return $messages;
2054 2053
 }
2055 2054
 
2056 2055
 /**
@@ -2069,26 +2068,26 @@  discard block
 block discarded – undo
2069 2068
  */
2070 2069
 function _privatemsg_assemble_query($query) {
2071 2070
 
2072
-  // Modules will be allowed to choose the prefix for the querybuilder, but if there is not one supplied, 'privatemsg' will be taken by default.
2073
-  if (is_array($query)) {
2071
+    // Modules will be allowed to choose the prefix for the querybuilder, but if there is not one supplied, 'privatemsg' will be taken by default.
2072
+    if (is_array($query)) {
2074 2073
     $query_id = $query[0];
2075 2074
     $query_group = $query[1];
2076
-  }
2077
-  else {
2075
+    }
2076
+    else {
2078 2077
     $query_id = $query;
2079 2078
     $query_group = 'privatemsg';
2080
-  }
2081
-
2082
-  $SELECT = array();
2083
-  $INNER_JOIN = array();
2084
-  $WHERE = array();
2085
-  $GROUP_BY = array();
2086
-  $HAVING   = array();
2087
-  $ORDER_BY = array();
2088
-  $QUERY_ARGS = array('select' => array(), 'where' => array(), 'join' => array(), 'having' => array());
2089
-  $primary_table = '';
2090
-
2091
-  $fragments = array(
2079
+    }
2080
+
2081
+    $SELECT = array();
2082
+    $INNER_JOIN = array();
2083
+    $WHERE = array();
2084
+    $GROUP_BY = array();
2085
+    $HAVING   = array();
2086
+    $ORDER_BY = array();
2087
+    $QUERY_ARGS = array('select' => array(), 'where' => array(), 'join' => array(), 'having' => array());
2088
+    $primary_table = '';
2089
+
2090
+    $fragments = array(
2092 2091
     'select'      => $SELECT,
2093 2092
     'inner_join'  => $INNER_JOIN,
2094 2093
     'where'       => $WHERE,
@@ -2097,52 +2096,52 @@  discard block
 block discarded – undo
2097 2096
     'order_by'    => $ORDER_BY,
2098 2097
     'query_args'  => $QUERY_ARGS,
2099 2098
     'primary_table'  => $primary_table,
2100
-  );
2101
-
2102
-  /**
2103
-   * Begin: dynamic arguments
2104
-   */
2105
-  $args = func_get_args();
2106
-  unset($args[0]);
2107
-  // we do the merge because we call call_user_func_array and not drupal_alter
2108
-  // this is necessary because otherwise we would not be able to use $args correctly (otherwise it doesnt unfold)
2109
-  $alterargs = array(&$fragments);
2110
-  $query_function = $query_group .'_sql_'. $query_id;
2111
-  if (!empty($args)) {
2099
+    );
2100
+
2101
+    /**
2102
+     * Begin: dynamic arguments
2103
+     */
2104
+    $args = func_get_args();
2105
+    unset($args[0]);
2106
+    // we do the merge because we call call_user_func_array and not drupal_alter
2107
+    // this is necessary because otherwise we would not be able to use $args correctly (otherwise it doesnt unfold)
2108
+    $alterargs = array(&$fragments);
2109
+    $query_function = $query_group .'_sql_'. $query_id;
2110
+    if (!empty($args)) {
2112 2111
     $alterargs = array_merge($alterargs, $args);
2113
-  }
2114
-  /**
2115
-   * END: Dynamic arguments
2116
-   */
2117
-  if (!function_exists($query_function)) {
2112
+    }
2113
+    /**
2114
+     * END: Dynamic arguments
2115
+     */
2116
+    if (!function_exists($query_function)) {
2118 2117
     drupal_set_message(t('Query function %function does not exist', array('%function' => $query_function)), 'error');
2119 2118
     return FALSE;
2120
-  }
2121
-  call_user_func_array($query_function, $alterargs);
2122
-
2123
-  array_unshift($alterargs, $query_function);
2124
-  call_user_func_array('drupal_alter', $alterargs);
2125
-
2126
-  $SELECT = $fragments['select'];
2127
-  $INNER_JOIN = $fragments['inner_join'];
2128
-  $WHERE = $fragments['where'];
2129
-  $GROUP_BY = $fragments['group_by'];
2130
-  $HAVING   = $fragments['having'];
2131
-  $ORDER_BY = $fragments['order_by'];
2132
-  $QUERY_ARGS = $fragments['query_args'];
2133
-  $primary_table = $fragments['primary_table'];
2134
-
2135
-  // pgsql has a case sensitive LIKE - replace it with ILIKE. see http://drupal.org/node/462982
2136
-  if ($GLOBALS['db_type'] == 'pgsql') {
2119
+    }
2120
+    call_user_func_array($query_function, $alterargs);
2121
+
2122
+    array_unshift($alterargs, $query_function);
2123
+    call_user_func_array('drupal_alter', $alterargs);
2124
+
2125
+    $SELECT = $fragments['select'];
2126
+    $INNER_JOIN = $fragments['inner_join'];
2127
+    $WHERE = $fragments['where'];
2128
+    $GROUP_BY = $fragments['group_by'];
2129
+    $HAVING   = $fragments['having'];
2130
+    $ORDER_BY = $fragments['order_by'];
2131
+    $QUERY_ARGS = $fragments['query_args'];
2132
+    $primary_table = $fragments['primary_table'];
2133
+
2134
+    // pgsql has a case sensitive LIKE - replace it with ILIKE. see http://drupal.org/node/462982
2135
+    if ($GLOBALS['db_type'] == 'pgsql') {
2137 2136
     $WHERE = str_replace('LIKE', 'ILIKE', $WHERE);
2138
-  }
2137
+    }
2139 2138
 
2140
-  if (empty($primary_table)) {
2139
+    if (empty($primary_table)) {
2141 2140
     $primary_table = '{privatemsg} pm';
2142
-  }
2141
+    }
2143 2142
 
2144
-  // Perform the whole query assembly only if we have something to select.
2145
-  if (!empty($SELECT)) {
2143
+    // Perform the whole query assembly only if we have something to select.
2144
+    if (!empty($SELECT)) {
2146 2145
     $str_select = implode(", ", $SELECT);
2147 2146
     $query = "SELECT {$str_select} FROM ". $primary_table;
2148 2147
 
@@ -2150,51 +2149,51 @@  discard block
 block discarded – undo
2150 2149
     // In most cases,  "COUNT(*)" is enough to get the count query, but in queries involving a GROUP BY, we want a count of the number of groups we have, not the count of elements inside each group.
2151 2150
     // So we test if there is GROUP BY and if there is, count the number of distinct groups. If not, we go the normal wal and do a plain COUNT(*).
2152 2151
     if (!empty($GROUP_BY)) {
2153
-      // PostgreSQL does not support COUNT(sometextfield, someintfield), so I'm only using the first one
2154
-      // Works fine for thread_id/list but may generate an error when a more complex GROUP BY is used.
2155
-      $str_group_by_count = current($GROUP_BY);
2156
-      $count = "SELECT COUNT(DISTINCT {$str_group_by_count}) FROM ". $primary_table;
2152
+        // PostgreSQL does not support COUNT(sometextfield, someintfield), so I'm only using the first one
2153
+        // Works fine for thread_id/list but may generate an error when a more complex GROUP BY is used.
2154
+        $str_group_by_count = current($GROUP_BY);
2155
+        $count = "SELECT COUNT(DISTINCT {$str_group_by_count}) FROM ". $primary_table;
2157 2156
     }
2158 2157
     else {
2159
-      $count = "SELECT COUNT(*) FROM ". $primary_table;
2158
+        $count = "SELECT COUNT(*) FROM ". $primary_table;
2160 2159
     }
2161 2160
 
2162 2161
     if (!empty($INNER_JOIN)) {
2163
-      $str_inner_join = implode(' ', $INNER_JOIN);
2164
-      $query .= " {$str_inner_join}";
2165
-      $count .= " {$str_inner_join}";
2162
+        $str_inner_join = implode(' ', $INNER_JOIN);
2163
+        $query .= " {$str_inner_join}";
2164
+        $count .= " {$str_inner_join}";
2166 2165
     }
2167 2166
     if (!empty($WHERE)) {
2168
-      $str_where = '('. implode(') AND (', $WHERE) .')';
2169
-      $query .= " WHERE {$str_where}";
2170
-      $count .= " WHERE {$str_where}";
2167
+        $str_where = '('. implode(') AND (', $WHERE) .')';
2168
+        $query .= " WHERE {$str_where}";
2169
+        $count .= " WHERE {$str_where}";
2171 2170
     }
2172 2171
     if (!empty($GROUP_BY)) {
2173
-      $str_group_by = ' GROUP BY '. implode(", ", $GROUP_BY) ;
2174
-      $query .= " {$str_group_by}";
2172
+        $str_group_by = ' GROUP BY '. implode(", ", $GROUP_BY) ;
2173
+        $query .= " {$str_group_by}";
2175 2174
     }
2176 2175
     if (!empty($HAVING)) {
2177
-      $str_having = '('. implode(') AND (', $HAVING) .')';
2178
-      $query .= " HAVING {$str_having}";
2179
-      // queries containing a HAVING break the count query on pgsql.
2180
-      // In this case, use the subquery method as outlined in http://drupal.org/node/303087#comment-1370752 .
2181
-      // The subquery method will work for all COUNT queries, but it is thought to be much slower, so we are only using it where other cross database approaches fail.
2182
-      $count = 'SELECT COUNT(*) FROM ('. $query .') as count';
2176
+        $str_having = '('. implode(') AND (', $HAVING) .')';
2177
+        $query .= " HAVING {$str_having}";
2178
+        // queries containing a HAVING break the count query on pgsql.
2179
+        // In this case, use the subquery method as outlined in http://drupal.org/node/303087#comment-1370752 .
2180
+        // The subquery method will work for all COUNT queries, but it is thought to be much slower, so we are only using it where other cross database approaches fail.
2181
+        $count = 'SELECT COUNT(*) FROM ('. $query .') as count';
2183 2182
     }
2184 2183
     if (!empty($ORDER_BY)) {
2185
-      $str_order_by = ' ORDER BY '. implode(", ", $ORDER_BY) ;
2186
-      $query .= " {$str_order_by}";
2184
+        $str_order_by = ' ORDER BY '. implode(", ", $ORDER_BY) ;
2185
+        $query .= " {$str_order_by}";
2187 2186
     }
2188 2187
     $QUERY_ARGS = array_merge($QUERY_ARGS['select'], $QUERY_ARGS['join'], $QUERY_ARGS['where'], $QUERY_ARGS['having']);
2189 2188
     if (!empty($QUERY_ARGS)) {
2190
-      _db_query_callback($QUERY_ARGS, TRUE);
2191
-      $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query);
2192
-      _db_query_callback($QUERY_ARGS, TRUE);
2193
-      $count = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $count);
2189
+        _db_query_callback($QUERY_ARGS, TRUE);
2190
+        $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query);
2191
+        _db_query_callback($QUERY_ARGS, TRUE);
2192
+        $count = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $count);
2194 2193
     }
2195 2194
     return array('query' => $query, 'count' => $count);
2196
-  }
2197
-  return FALSE;
2195
+    }
2196
+    return FALSE;
2198 2197
 }
2199 2198
 
2200 2199
 /**
@@ -2211,44 +2210,44 @@  discard block
 block discarded – undo
2211 2210
  *   The FAPI definitions for the thread action form.
2212 2211
  */
2213 2212
 function _privatemsg_action_form() {
2214
-  $form = array(
2215
-      '#type'        => 'fieldset',
2216
-      '#title'       => t('Actions'),
2217
-      '#prefix'      => '<div class="container-inline">',
2218
-      '#suffix'      => '</div>',
2219
-      '#collapsible' => TRUE,
2220
-      '#collapsed'   => FALSE,
2221
-      '#weight'      => 15,
2222
-  );
2223
-  if (privatemsg_user_access('delete privatemsg')) {
2213
+    $form = array(
2214
+        '#type'        => 'fieldset',
2215
+        '#title'       => t('Actions'),
2216
+        '#prefix'      => '<div class="container-inline">',
2217
+        '#suffix'      => '</div>',
2218
+        '#collapsible' => TRUE,
2219
+        '#collapsed'   => FALSE,
2220
+        '#weight'      => 15,
2221
+    );
2222
+    if (privatemsg_user_access('delete privatemsg')) {
2224 2223
     $form['delete'] = array(
2225 2224
         '#type'   => 'submit',
2226 2225
         '#value'  => t('Delete'),
2227 2226
     );
2228
-  }
2229
-  // Display all operations which have a label.
2230
-  $options = array(0 => t('More actions...'));
2231
-  foreach (module_invoke_all('privatemsg_thread_operations') as $operation => $array) {
2227
+    }
2228
+    // Display all operations which have a label.
2229
+    $options = array(0 => t('More actions...'));
2230
+    foreach (module_invoke_all('privatemsg_thread_operations') as $operation => $array) {
2232 2231
     if (isset($array['label'])) {
2233
-      $options[$operation] = $array['label'];
2234
-    }
2235
-  }
2236
-  $form['operation'] = array(
2237
-      '#type'          => 'select',
2238
-      '#options'       => $options,
2239
-      '#default_value' => 0,
2240
-  );
2241
-  $form['submit'] = array(
2242
-      '#prefix'     => '<div class="privatemsg-op-button">',
2243
-      '#suffix'    => '</div>',
2244
-      '#type'       => 'submit',
2245
-      '#value'      => t('Execute'),
2246
-      '#submit'     => array('privatemsg_list_submit'),
2247
-      '#attributes' => array('class' => 'privatemsg-action-button'),
2248
-  );
2249
-  // JS for hiding the execute button.
2250
-  drupal_add_js(drupal_get_path('module', 'privatemsg') .'/privatemsg-list.js');
2251
-  return $form;
2232
+        $options[$operation] = $array['label'];
2233
+    }
2234
+    }
2235
+    $form['operation'] = array(
2236
+        '#type'          => 'select',
2237
+        '#options'       => $options,
2238
+        '#default_value' => 0,
2239
+    );
2240
+    $form['submit'] = array(
2241
+        '#prefix'     => '<div class="privatemsg-op-button">',
2242
+        '#suffix'    => '</div>',
2243
+        '#type'       => 'submit',
2244
+        '#value'      => t('Execute'),
2245
+        '#submit'     => array('privatemsg_list_submit'),
2246
+        '#attributes' => array('class' => 'privatemsg-action-button'),
2247
+    );
2248
+    // JS for hiding the execute button.
2249
+    drupal_add_js(drupal_get_path('module', 'privatemsg') .'/privatemsg-list.js');
2250
+    return $form;
2252 2251
 }
2253 2252
 
2254 2253
 /**
@@ -2263,23 +2262,23 @@  discard block
 block discarded – undo
2263 2262
  *   current user.
2264 2263
  */
2265 2264
 function privatemsg_thread_change_status($threads, $status, $account = NULL) {
2266
-  if (!is_array($threads)) {
2265
+    if (!is_array($threads)) {
2267 2266
     $threads = array($threads);
2268
-  }
2269
-  if (empty($account)) {
2267
+    }
2268
+    if (empty($account)) {
2270 2269
     global $user;
2271 2270
     $account = drupal_clone($user);
2272
-  }
2273
-  // Merge status and uid with the threads list. array_merge() will not overwrite/ignore thread_id 1.
2274
-  $params = array_merge(array($status, $account->uid), $threads);
2275
-  db_query('UPDATE {pm_index} SET is_new = %d WHERE uid = %d AND thread_id IN ('. db_placeholders($threads) .')', $params);
2271
+    }
2272
+    // Merge status and uid with the threads list. array_merge() will not overwrite/ignore thread_id 1.
2273
+    $params = array_merge(array($status, $account->uid), $threads);
2274
+    db_query('UPDATE {pm_index} SET is_new = %d WHERE uid = %d AND thread_id IN ('. db_placeholders($threads) .')', $params);
2276 2275
 
2277
-  if ($status == PRIVATEMSG_UNREAD) {
2276
+    if ($status == PRIVATEMSG_UNREAD) {
2278 2277
     drupal_set_message(format_plural(count($threads), 'Marked 1 thread as unread.', 'Marked @count threads as unread.'));
2279
-  }
2280
-  else {
2278
+    }
2279
+    else {
2281 2280
     drupal_set_message(format_plural(count($threads), 'Marked 1 thread as read.', 'Marked @count threads as read.'));
2282
-  }
2281
+    }
2283 2282
 }
2284 2283
 /**
2285 2284
  * Returns a table header definition based on the submitted keys.
@@ -2295,25 +2294,25 @@  discard block
 block discarded – undo
2295 2294
  *   Array with header defintions for tablesort_sql and theme('table').
2296 2295
  */
2297 2296
 function _privatemsg_list_headers($has_posts, $keys) {
2298
-  $select_header = $has_posts ? theme('table_select_header_cell') : '';
2299
-  $select_header['#weight'] = -50;
2297
+    $select_header = $has_posts ? theme('table_select_header_cell') : '';
2298
+    $select_header['#weight'] = -50;
2300 2299
 
2301
-  // theme() doesn't include the theme file for patterns, we need to do it manually.
2302
-  include_once drupal_get_path('module', 'privatemsg') .'/privatemsg.theme.inc';
2300
+    // theme() doesn't include the theme file for patterns, we need to do it manually.
2301
+    include_once drupal_get_path('module', 'privatemsg') .'/privatemsg.theme.inc';
2303 2302
 
2304
-  $header = array($select_header);
2305
-  foreach ($keys as $key) {
2303
+    $header = array($select_header);
2304
+    foreach ($keys as $key) {
2306 2305
     // First, try to load a specific theme for that header, if not present, use the default.
2307 2306
     if ($return = theme(array('privatemsg_list_header__'. $key, 'privatemsg_list_header'))) {
2308
-      // The default theme returns nothing, only store the value if we have something.
2309
-      $header[$key] = $return;
2307
+        // The default theme returns nothing, only store the value if we have something.
2308
+        $header[$key] = $return;
2309
+    }
2310 2310
     }
2311
-  }
2312
-  if (count($header) == 1) {
2311
+    if (count($header) == 1) {
2313 2312
     // No header definition returned, fallback to the default.
2314 2313
     $header += _privatemsg_list_headers_fallback($keys);
2315
-  }
2316
-  return $header;
2314
+    }
2315
+    return $header;
2317 2316
 }
2318 2317
 
2319 2318
 /**
@@ -2323,15 +2322,15 @@  discard block
 block discarded – undo
2323 2322
  *   Array with the correct headers.
2324 2323
  */
2325 2324
 function _privatemsg_list_headers_fallback($keys) {
2326
-  $header = array();
2327
-  foreach ($keys as $key) {
2325
+    $header = array();
2326
+    foreach ($keys as $key) {
2328 2327
     $theme_function = 'phptemplate_privatemsg_list_header__' . $key;
2329 2328
     if (function_exists($theme_function)) {
2330
-      $header[$key] = $theme_function();
2329
+        $header[$key] = $theme_function();
2330
+    }
2331 2331
     }
2332
-  }
2333 2332
 
2334
-  return $header;
2333
+    return $header;
2335 2334
 }
2336 2335
 
2337 2336
 /**
@@ -2345,23 +2344,23 @@  discard block
 block discarded – undo
2345 2344
  *   Row definition for use with theme('table')
2346 2345
  */
2347 2346
 function _privatemsg_list_thread($thread) {
2348
-  $row = array('data' => array());
2347
+    $row = array('data' => array());
2349 2348
 
2350
-  if (!empty($thread['is_new'])) {
2349
+    if (!empty($thread['is_new'])) {
2351 2350
     // Set the css class in the tr tag.
2352 2351
     $row['class'] = 'privatemsg-unread';
2353
-  }
2354
-  foreach ($thread as $key => $data) {
2352
+    }
2353
+    foreach ($thread as $key => $data) {
2355 2354
     // First, try to load a specific theme for that field, if not present, use the default.
2356 2355
     if ($return = theme(array('privatemsg_list_field__'. $key, 'privatemsg_list_field'), $thread)) {
2357
-      // The default theme returns nothing, only store the value if we have something.
2358
-      $row['data'][$key] = $return;
2356
+        // The default theme returns nothing, only store the value if we have something.
2357
+        $row['data'][$key] = $return;
2358
+    }
2359 2359
     }
2360
-  }
2361
-  if (empty($row['data'])) {
2360
+    if (empty($row['data'])) {
2362 2361
     $row['data'] = _privatemsg_list_thread_fallback($thread);
2363
-  }
2364
-  return $row;
2362
+    }
2363
+    return $row;
2365 2364
 }
2366 2365
 
2367 2366
 /**
@@ -2371,15 +2370,15 @@  discard block
 block discarded – undo
2371 2370
  *   Array with row data.
2372 2371
  */
2373 2372
 function _privatemsg_list_thread_fallback($thread) {
2374
-  $row_data = array();
2375
-  foreach ($thread as $key => $data) {
2373
+    $row_data = array();
2374
+    foreach ($thread as $key => $data) {
2376 2375
     $theme_function = 'phptemplate_privatemsg_list_field__' . $key;
2377 2376
     if (function_exists($theme_function)) {
2378
-      $row_data[$key] = $theme_function($thread);
2377
+        $row_data[$key] = $theme_function($thread);
2378
+    }
2379 2379
     }
2380
-  }
2381 2380
 
2382
-  return $row_data;
2381
+    return $row_data;
2383 2382
 }
2384 2383
 
2385 2384
 /**
@@ -2389,20 +2388,20 @@  discard block
 block discarded – undo
2389 2388
  * execute it.
2390 2389
  */
2391 2390
 function privatemsg_undo_action() {
2392
-  // Check if a undo callback for that user exists.
2393
-  if (isset($_SESSION['privatemsg']['undo callback']) && is_array($_SESSION['privatemsg']['undo callback'])) {
2391
+    // Check if a undo callback for that user exists.
2392
+    if (isset($_SESSION['privatemsg']['undo callback']) && is_array($_SESSION['privatemsg']['undo callback'])) {
2394 2393
     $undo = $_SESSION['privatemsg']['undo callback'];
2395 2394
     // If the defined undo callback exists, execute it
2396 2395
     if (isset($undo['function']) && isset($undo['args'])) {
2397
-      // Load the user object.
2398
-      if (isset($undo['args']['account']) && $undo['args']['account'] > 0) {
2396
+        // Load the user object.
2397
+        if (isset($undo['args']['account']) && $undo['args']['account'] > 0) {
2399 2398
         $undo['args']['account'] = user_load((int)$undo['args']['account']);
2400
-      }
2401
-      call_user_func_array($undo['function'], $undo['args']);
2399
+        }
2400
+        call_user_func_array($undo['function'], $undo['args']);
2402 2401
     }
2403 2402
     // Return back to the site defined by the destination GET param.
2404 2403
     drupal_goto();
2405
-  }
2404
+    }
2406 2405
 }
2407 2406
 
2408 2407
 /**
@@ -2412,29 +2411,29 @@  discard block
 block discarded – undo
2412 2411
  * based on node_admin_nodes_submit().
2413 2412
  */
2414 2413
 function privatemsg_list_submit($form, &$form_state) {
2415
-  // Load all available operation definitions.
2416
-  $operations = module_invoke_all('privatemsg_thread_operations');
2414
+    // Load all available operation definitions.
2415
+    $operations = module_invoke_all('privatemsg_thread_operations');
2417 2416
 
2418
-  // Default "default" operation, which won't do anything.
2419
-  $operation = array('callback' => 0);
2417
+    // Default "default" operation, which won't do anything.
2418
+    $operation = array('callback' => 0);
2420 2419
 
2421
-  // Check if a valid operation has been submitted.
2422
-  if (isset($form_state['values']['operation']) && isset($operations[$form_state['values']['operation']])) {
2420
+    // Check if a valid operation has been submitted.
2421
+    if (isset($form_state['values']['operation']) && isset($operations[$form_state['values']['operation']])) {
2423 2422
     $operation = $operations[$form_state['values']['operation']];
2424
-  }
2423
+    }
2425 2424
 
2426
-  // Load all keys where the value is the current op.
2427
-  $keys = array_keys($form_state['values'], $form_state['values']['op']);
2425
+    // Load all keys where the value is the current op.
2426
+    $keys = array_keys($form_state['values'], $form_state['values']['op']);
2428 2427
 
2429
-  // The first one is op itself, we need to use the second.
2430
-  if (isset($keys[1]) && isset($operations[$keys[1]])) {
2428
+    // The first one is op itself, we need to use the second.
2429
+    if (isset($keys[1]) && isset($operations[$keys[1]])) {
2431 2430
     $operation = $operations[$keys[1]];
2432
-  }
2431
+    }
2433 2432
 
2434
-  // Only execute something if we have a valid callback and at least one checked thread.
2435
-  if (!empty($operation['callback'])) {
2433
+    // Only execute something if we have a valid callback and at least one checked thread.
2434
+    if (!empty($operation['callback'])) {
2436 2435
     privatemsg_operation_execute($operation, $form_state['values']['threads'], $form_state['values']['account']);
2437
-  }
2436
+    }
2438 2437
 }
2439 2438
 
2440 2439
 /**
@@ -2448,42 +2447,42 @@  discard block
 block discarded – undo
2448 2447
  *   array can be directly passed to it.
2449 2448
  */
2450 2449
 function privatemsg_operation_execute($operation, $threads, $account = null) {
2451
-  // Filter out unchecked threads, this gives us an array of "checked" threads.
2452
-  $threads = array_filter($threads);
2450
+    // Filter out unchecked threads, this gives us an array of "checked" threads.
2451
+    $threads = array_filter($threads);
2453 2452
 
2454
-  if (empty($threads)) {
2453
+    if (empty($threads)) {
2455 2454
     // Do not execute anything if there are no checked threads.
2456 2455
     return;
2457
-  }
2458
-  // Add in callback arguments if present.
2459
-  if (isset($operation['callback arguments'])) {
2456
+    }
2457
+    // Add in callback arguments if present.
2458
+    if (isset($operation['callback arguments'])) {
2460 2459
     $args = array_merge(array($threads), $operation['callback arguments']);
2461
-  }
2462
-  else {
2460
+    }
2461
+    else {
2463 2462
     $args = array($threads);
2464
-  }
2463
+    }
2465 2464
 
2466
-  // Add the user object to the arguments.
2467
-  if ($account) {
2465
+    // Add the user object to the arguments.
2466
+    if ($account) {
2468 2467
     $args[] = $account;
2469
-  }
2468
+    }
2470 2469
 
2471
-  // Execute the chosen action and pass the defined arguments.
2472
-  call_user_func_array($operation['callback'], $args);
2470
+    // Execute the chosen action and pass the defined arguments.
2471
+    call_user_func_array($operation['callback'], $args);
2473 2472
 
2474
-  // Check if that operation has defined an undo callback.
2475
-  if (isset($operation['undo callback']) && $undo_function = $operation['undo callback']) {
2473
+    // Check if that operation has defined an undo callback.
2474
+    if (isset($operation['undo callback']) && $undo_function = $operation['undo callback']) {
2476 2475
     // Add in callback arguments if present.
2477 2476
     if (isset($operation['undo callback arguments'])) {
2478
-      $undo_args = array_merge(array($threads), $operation['undo callback arguments']);
2477
+        $undo_args = array_merge(array($threads), $operation['undo callback arguments']);
2479 2478
     }
2480 2479
     else {
2481
-      $undo_args = array($threads);
2480
+        $undo_args = array($threads);
2482 2481
     }
2483 2482
 
2484 2483
     // Avoid saving the complete user object in the session.
2485 2484
     if ($account) {
2486
-      $undo_args['account'] = $account->uid;
2485
+        $undo_args['account'] = $account->uid;
2487 2486
     }
2488 2487
     // Store the undo callback in the session and display a "Undo" link.
2489 2488
     // @todo: Provide a more flexible solution for such an undo action, operation defined string for example.
@@ -2491,7 +2490,7 @@  discard block
 block discarded – undo
2491 2490
     $undo = url('messages/undo/action', array('query' => drupal_get_destination()));
2492 2491
 
2493 2492
     drupal_set_message(t('The previous action can be <a href="!undo">undone</a>.', array('!undo' => $undo)));
2494
-  }
2493
+    }
2495 2494
 }
2496 2495
 
2497 2496
 /**
@@ -2507,71 +2506,71 @@  discard block
 block discarded – undo
2507 2506
  *   defaults to the current user.
2508 2507
  */
2509 2508
 function privatemsg_thread_change_delete($threads, $delete, $account = NULL) {
2510
-  if (!is_array($threads)) {
2509
+    if (!is_array($threads)) {
2511 2510
     $threads = array($threads);
2512
-  }
2513
-  if (empty($account)) {
2511
+    }
2512
+    if (empty($account)) {
2514 2513
     global $user;
2515 2514
     $account = drupal_clone($user);
2516
-  }
2515
+    }
2517 2516
 
2518
-  // Merge status and uid with the threads list. array_merge() will not overwrite/ignore thread_id 1.
2519
-  $params = array_merge(array($delete, $account->uid), $threads);
2517
+    // Merge status and uid with the threads list. array_merge() will not overwrite/ignore thread_id 1.
2518
+    $params = array_merge(array($delete, $account->uid), $threads);
2520 2519
 
2521
-  // Load all messages of those threads including the deleted.
2522
-  $query = _privatemsg_assemble_query('messages', $threads, $account, TRUE);
2523
-  $result = db_query($query['query']);
2520
+    // Load all messages of those threads including the deleted.
2521
+    $query = _privatemsg_assemble_query('messages', $threads, $account, TRUE);
2522
+    $result = db_query($query['query']);
2524 2523
 
2525
-  // Delete each message. We need to do that to trigger the delete hook.
2526
-  while ($row = db_fetch_array($result)) {
2524
+    // Delete each message. We need to do that to trigger the delete hook.
2525
+    while ($row = db_fetch_array($result)) {
2527 2526
     privatemsg_message_change_delete($row['mid'], $delete, $account);
2528
-  }
2527
+    }
2529 2528
 
2530
-  if ($delete) {
2529
+    if ($delete) {
2531 2530
     drupal_set_message(format_plural(count($threads), 'Deleted 1 thread.', 'Deleted @count threads.'));
2532
-  }
2533
-  else {
2531
+    }
2532
+    else {
2534 2533
     drupal_set_message(format_plural(count($threads), 'Restored 1 thread.', 'Restored @count threads.'));
2535
-  }
2534
+    }
2536 2535
 }
2537 2536
 
2538 2537
 /**
2539 2538
  * Implements hook_privatemsg_thread_operations().
2540 2539
  */
2541 2540
 function privatemsg_privatemsg_thread_operations() {
2542
-  $operations = array(
2541
+    $operations = array(
2543 2542
     'mark as read' => array(
2544
-      'label' => t('Mark as read'),
2545
-      'callback' => 'privatemsg_thread_change_status',
2546
-      'callback arguments' => array('status' => PRIVATEMSG_READ),
2547
-      'undo callback' => 'privatemsg_thread_change_status',
2548
-      'undo callback arguments' => array('status' => PRIVATEMSG_UNREAD),
2543
+        'label' => t('Mark as read'),
2544
+        'callback' => 'privatemsg_thread_change_status',
2545
+        'callback arguments' => array('status' => PRIVATEMSG_READ),
2546
+        'undo callback' => 'privatemsg_thread_change_status',
2547
+        'undo callback arguments' => array('status' => PRIVATEMSG_UNREAD),
2549 2548
     ),
2550 2549
     'mark as unread' => array(
2551
-      'label' => t('Mark as unread'),
2552
-      'callback' => 'privatemsg_thread_change_status',
2553
-      'callback arguments' => array('status' => PRIVATEMSG_UNREAD),
2554
-      'undo callback' => 'privatemsg_thread_change_status',
2555
-      'undo callback arguments' => array('status' => PRIVATEMSG_READ),
2550
+        'label' => t('Mark as unread'),
2551
+        'callback' => 'privatemsg_thread_change_status',
2552
+        'callback arguments' => array('status' => PRIVATEMSG_UNREAD),
2553
+        'undo callback' => 'privatemsg_thread_change_status',
2554
+        'undo callback arguments' => array('status' => PRIVATEMSG_READ),
2556 2555
     ),
2557
-  );
2558
-  if (privatemsg_user_access('delete privatemsg')) {
2556
+    );
2557
+    if (privatemsg_user_access('delete privatemsg')) {
2559 2558
     $operations['delete'] = array(
2560
-      'callback' => 'privatemsg_thread_change_delete',
2561
-      'callback arguments' => array('delete' => 1),
2562
-      'undo callback' => 'privatemsg_thread_change_delete',
2563
-      'undo callback arguments' => array('delete' => 0),
2559
+        'callback' => 'privatemsg_thread_change_delete',
2560
+        'callback arguments' => array('delete' => 1),
2561
+        'undo callback' => 'privatemsg_thread_change_delete',
2562
+        'undo callback arguments' => array('delete' => 0),
2564 2563
     );
2565
-  }
2566
-  return $operations;
2564
+    }
2565
+    return $operations;
2567 2566
 }
2568 2567
 
2569 2568
 /**
2570 2569
  * Implementation of hook_views_api().
2571 2570
  */
2572 2571
 function privatemsg_views_api() {
2573
-  return array(
2572
+    return array(
2574 2573
     'api' => 2,
2575 2574
     'path' => drupal_get_path('module', 'privatemsg') . '/views',
2576
-  );
2575
+    );
2577 2576
 }
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 
99 99
 
100 100
     if ($no_text) {
101
-      return implode(', ', $to) . $limit_string;
101
+      return implode(', ', $to).$limit_string;
102 102
     }
103 103
 
104 104
     $last = array_pop($to);
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
  * @ingroup api
221 221
  */
222 222
 function privatemsg_user_access($permission = 'read privatemsg', $account = NULL) {
223
-  if ( $account === NULL ) {
223
+  if ($account === NULL) {
224 224
     global $user;
225 225
     $account = $user;
226 226
   }
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
           // message overlap.
345 345
           // Note - the last page lists the earliest messages, not the latest.
346 346
           $paging_count = variable_get('privatemsg_view_use_max_as_default', FALSE) ? $thread['message_count'] - variable_get('privatemsg_view_default_amount', 10) : $thread['message_count'];
347
-          $last_page = $paging_count % $max_amount;
347
+          $last_page = $paging_count%$max_amount;
348 348
         }
349 349
 
350 350
         // Sanity check - we cannot start from a negative number.
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
     '#options'       => $amounts,
547 547
     '#weight'        => 20,
548 548
   );
549
-  drupal_add_js(drupal_get_path('module', 'privatemsg') .'/privatemsg-admin.js');
549
+  drupal_add_js(drupal_get_path('module', 'privatemsg').'/privatemsg-admin.js');
550 550
 
551 551
   $form['#submit'][] = 'private_message_settings_submit';
552 552
   return system_settings_form($form);
@@ -640,9 +640,9 @@  discard block
 block discarded – undo
640 640
   $vars['message_timestamp'] = format_date($message['timestamp'], 'small');
641 641
   $vars['message_body'] = check_markup($message['body'], $message['format'], FALSE);
642 642
   if (isset($vars['mid']) && isset($vars['thread_id']) && privatemsg_user_access('delete privatemsg')) {
643
-    $vars['message_actions'][] = array('title' => t('Delete message'), 'href' => 'messages/delete/' . $vars['thread_id'] . '/' . $vars['mid']);
643
+    $vars['message_actions'][] = array('title' => t('Delete message'), 'href' => 'messages/delete/'.$vars['thread_id'].'/'.$vars['mid']);
644 644
   }
645
-  $vars['message_anchors'][] = 'privatemsg-mid-' . $vars['mid'];
645
+  $vars['message_anchors'][] = 'privatemsg-mid-'.$vars['mid'];
646 646
   if (!empty($message['is_new'])) {
647 647
     $vars['message_anchors'][] = 'new';
648 648
     $vars['new'] = drupal_ucfirst(t('new'));
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
 
656 656
   $vars['anchors'] = '';
657 657
   foreach ($vars['message_anchors'] as $anchor) {
658
-    $vars['anchors'] .= '<a name="' . $anchor . '"></a>';
658
+    $vars['anchors'] .= '<a name="'.$anchor.'"></a>';
659 659
   }
660 660
 }
661 661
 
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
     global $user;
759 759
     $account = $user;
760 760
   }
761
-  if ( !isset($counts[$account->uid])) {
761
+  if (!isset($counts[$account->uid])) {
762 762
     $query = _privatemsg_assemble_query('unread_count', $account);
763 763
     $counts[$account->uid] = db_result(db_query($query['query']));
764 764
   }
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
       'query' => array('start' => $thread['older_start']),
786 786
       'title' => t('Display older messages'),
787 787
     );
788
-     $older = l(t('<<'), 'messages/view/' . $thread['thread_id'], $options);
788
+     $older = l(t('<<'), 'messages/view/'.$thread['thread_id'], $options);
789 789
   }
790 790
   $newer = '';
791 791
   if (isset($thread['newer_start'])) {
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
       'query' => array('start' => $thread['newer_start']),
794 794
       'title' => t('Display newer messages'),
795 795
     );
796
-    $newer = l(t('>>'), 'messages/view/' . $thread['thread_id'], $options);
796
+    $newer = l(t('>>'), 'messages/view/'.$thread['thread_id'], $options);
797 797
   }
798 798
   $substitutions = array('@from' => $thread['from'], '@to' => $thread['to'], '@total' => $thread['message_count'], '!previous_link' => $older, '!newer_link' => $newer);
799 799
   $title = t('!previous_link Displaying messages @from - @to of @total !newer_link', $substitutions);
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
   global $user;
848 848
 
849 849
   $recipients_string = '';
850
-  $body      = '';
850
+  $body = '';
851 851
 
852 852
   // convert recipients to array of user objects
853 853
   if (!empty($recipients) && is_string($recipients) || is_int($recipients)) {
@@ -879,7 +879,7 @@  discard block
 block discarded – undo
879 879
       }
880 880
       $myuser = user_load(array('uid' => $recipient->uid));
881 881
       $myname = preg_replace("/ /", "\xc2\xa0", $myuser->boincuser_name);
882
-      $to[] = $myname . "_" . $myuser->boincuser_id;
882
+      $to[] = $myname."_".$myuser->boincuser_id;
883 883
       $to_themed[$recipient->uid] = $myname;
884 884
     }
885 885
     else {
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
     // Assume the user sent message to own account as if the usercount is one or less, then the user sent a message but not to self.
893 893
     $myuser = user_load(array('uid' => $user->uid));
894 894
     $myname = preg_replace("/ /", "\xc2\xa0", $myuser->boincuser_name);
895
-    $to[] = $myname . "_" . $myuser->boincuser_id;
895
+    $to[] = $myname."_".$myuser->boincuser_id;
896 896
     $to_themed[$user->uid] = $myname;
897 897
   }
898 898
   if (!empty($to)) {
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
     );
1009 1009
     $recipients_string_themed = implode(', ', $to_themed);
1010 1010
     $form['privatemsg']['recipient_display'] = array(
1011
-      '#value' =>  '<p>'. t('<strong>Reply to thread</strong>:<br /> Recipients: !to', array('!to' => $recipients_string_themed)) .'</p>',
1011
+      '#value' =>  '<p>'.t('<strong>Reply to thread</strong>:<br /> Recipients: !to', array('!to' => $recipients_string_themed)).'</p>',
1012 1012
       '#weight' => -10,
1013 1013
     );
1014 1014
     if (empty($recipients_string)) {
@@ -1102,7 +1102,7 @@  discard block
 block discarded – undo
1102 1102
       // First, check if another module is able to resolve the string into an
1103 1103
       // user object.
1104 1104
       foreach (module_implements('privatemsg_name_lookup') as $module) {
1105
-        $function = $module . '_privatemsg_name_lookup';
1105
+        $function = $module.'_privatemsg_name_lookup';
1106 1106
         if (($recipient = $function($string)) && is_object($recipient)) {
1107 1107
           // If there is a match, continue with the next input string.
1108 1108
           $recipients[$recipient->uid] = $recipient;
@@ -1133,7 +1133,7 @@  discard block
 block discarded – undo
1133 1133
   foreach ($form_state['validate_built_message']['recipients'] as $recipient) {
1134 1134
     $recipient_names[] = theme('username', $recipient);
1135 1135
   }
1136
-  if ($status !== FALSE )  {
1136
+  if ($status !== FALSE) {
1137 1137
     drupal_set_message(t('A message has been sent to !recipients.', array('!recipients' => implode(', ', $recipient_names))));
1138 1138
   }
1139 1139
   else {
@@ -1175,7 +1175,7 @@  discard block
 block discarded – undo
1175 1175
   $fields = array_filter(variable_get('privatemsg_display_fields', array('participants')));
1176 1176
 
1177 1177
   // Required columns.
1178
-  $fragments['select'][]      = 'pmi.thread_id';
1178
+  $fragments['select'][] = 'pmi.thread_id';
1179 1179
   // We have to use MIN as the subject might not be the same in some threads.
1180 1180
   // MIN() does not have a useful meaning except that it helps to correctly
1181 1181
   // aggregate the thread on PostgreSQL.
@@ -1187,32 +1187,32 @@  discard block
 block discarded – undo
1187 1187
   // Select number of messages in the thread if the count is
1188 1188
   // set to be displayed.
1189 1189
   if (in_array('count', $fields)) {
1190
-    $fragments['select'][]      = 'COUNT(distinct pmi.mid) as count';
1190
+    $fragments['select'][] = 'COUNT(distinct pmi.mid) as count';
1191 1191
   }
1192 1192
   if (in_array('participants', $fields)) {
1193 1193
     // Query for a string with uid's, for example "1,6,7".
1194 1194
     // @todo: Replace this with a single query similiar to the tag list.
1195 1195
     if ($GLOBALS['db_type'] == 'pgsql') {
1196 1196
       // PostgreSQL does not know GROUP_CONCAT, so a subquery is required.
1197
-      $fragments['select'][]      = "array_to_string(array(SELECT DISTINCT textin(int4out(pmia.uid))
1197
+      $fragments['select'][] = "array_to_string(array(SELECT DISTINCT textin(int4out(pmia.uid))
1198 1198
                                                             FROM {pm_index} pmia
1199 1199
                                                             WHERE pmia.thread_id = pmi.thread_id), ',') AS participants";
1200 1200
     }
1201 1201
     else {
1202
-      $fragments['select'][]      = '(SELECT GROUP_CONCAT(DISTINCT pmia.uid SEPARATOR ",")
1202
+      $fragments['select'][] = '(SELECT GROUP_CONCAT(DISTINCT pmia.uid SEPARATOR ",")
1203 1203
                                                             FROM {pm_index} pmia
1204 1204
                                                             WHERE pmia.thread_id = pmi.thread_id) AS participants';
1205 1205
     }
1206 1206
   }
1207 1207
   if (in_array('thread_started', $fields)) {
1208
-    $fragments['select'][]      = 'MIN(pm.timestamp) as thread_started';
1208
+    $fragments['select'][] = 'MIN(pm.timestamp) as thread_started';
1209 1209
   }
1210 1210
 
1211 1211
   $fragments['inner_join'][]  = 'INNER JOIN {pm_index} pmi ON pm.mid = pmi.mid';
1212 1212
 
1213 1213
   // Only load undeleted messages of the current user and group by thread.
1214 1214
   $fragments['where'][]       = 'pmi.uid = %d';
1215
-  $fragments['query_args']['where'][]  = $account->uid;
1215
+  $fragments['query_args']['where'][] = $account->uid;
1216 1216
   $fragments['where'][]       = 'pmi.deleted = 0';
1217 1217
   $fragments['group_by'][]    = 'pmi.thread_id';
1218 1218
 
@@ -1226,8 +1226,8 @@  discard block
 block discarded – undo
1226 1226
   // tablesort_sql() generates a ORDER BY string. However, the "ORDER BY " part 
1227 1227
   // is not needed and added by the query builder. Discard the first 9
1228 1228
   // characters of the string.
1229
-  $order_by = drupal_substr(tablesort_sql(_privatemsg_list_headers( FALSE, array_merge(array('subject', 'last_updated'), $fields)), $order_by_first), 9);
1230
-  $fragments['order_by'][]  = $order_by;
1229
+  $order_by = drupal_substr(tablesort_sql(_privatemsg_list_headers(FALSE, array_merge(array('subject', 'last_updated'), $fields)), $order_by_first), 9);
1230
+  $fragments['order_by'][] = $order_by;
1231 1231
 }
1232 1232
 
1233 1233
 /**
@@ -1254,11 +1254,11 @@  discard block
 block discarded – undo
1254 1254
 
1255 1255
   $fragments['inner_join'][]  = 'INNER JOIN {pm_index} pmi ON pm.mid = pmi.mid';
1256 1256
   // Use IN() to load multiple messages at the same time.
1257
-  $fragments['where'][]       = 'pmi.mid IN (' . db_placeholders($pmids) . ')';
1258
-  $fragments['query_args']['where']  += $pmids;
1257
+  $fragments['where'][]       = 'pmi.mid IN ('.db_placeholders($pmids).')';
1258
+  $fragments['query_args']['where'] += $pmids;
1259 1259
   if ($account) {
1260
-    $fragments['where'][]       = 'pmi.uid = %d';
1261
-    $fragments['query_args']['where'][]  = $account->uid;
1260
+    $fragments['where'][] = 'pmi.uid = %d';
1261
+    $fragments['query_args']['where'][] = $account->uid;
1262 1262
   }
1263 1263
   $fragments['order_by'][] = 'pm.timestamp ASC';
1264 1264
   $fragments['order_by'][] = 'pm.mid ASC';
@@ -1280,13 +1280,13 @@  discard block
 block discarded – undo
1280 1280
   $fragments['primary_table'] = '{pm_index} pmi';
1281 1281
 
1282 1282
   $fragments['select'][]      = 'pmi.mid';
1283
-  $fragments['where'][]       = 'pmi.thread_id IN ('. db_placeholders($threads) .')';
1284
-  $fragments['query_args']['where']   += $threads;
1283
+  $fragments['where'][]       = 'pmi.thread_id IN ('.db_placeholders($threads).')';
1284
+  $fragments['query_args']['where'] += $threads;
1285 1285
   $fragments['inner_join'][]  = 'INNER JOIN {pm_message} pm ON (pm.mid = pmi.mid)';
1286 1286
   if ($account) {
1287 1287
     // Only load the user's messages.
1288 1288
     $fragments['where'][]     = 'pmi.uid = %d';
1289
-    $fragments['query_args']['where'][]  = $account->uid;
1289
+    $fragments['query_args']['where'][] = $account->uid;
1290 1290
   }
1291 1291
   if (!$load_all) {
1292 1292
     // Also load deleted messages when requested.
@@ -1322,7 +1322,7 @@  discard block
 block discarded – undo
1322 1322
 
1323 1323
   $fragments['inner_join'][]  = 'INNER JOIN {users} u ON (u.uid = pmi.uid)';
1324 1324
   $fragments['where'][]       = 'pmi.thread_id = %d';
1325
-  $fragments['query_args']['where'][]  = $thread_id;
1325
+  $fragments['query_args']['where'][] = $thread_id;
1326 1326
 }
1327 1327
 
1328 1328
 /**
@@ -1342,7 +1342,7 @@  discard block
 block discarded – undo
1342 1342
   $fragments['where'][]       = 'pmi.deleted = 0';
1343 1343
   $fragments['where'][]       = 'pmi.is_new = 1';
1344 1344
   $fragments['where'][]       = 'pmi.uid = %d';
1345
-  $fragments['query_args']['where'][]  = $account->uid;
1345
+  $fragments['query_args']['where'][] = $account->uid;
1346 1346
 }
1347 1347
 
1348 1348
 /**
@@ -1362,7 +1362,7 @@  discard block
 block discarded – undo
1362 1362
   $fragments['select'][] = 'u.name,u.id';
1363 1363
   // Escape the % to get it through the placeholder replacement.
1364 1364
   $fragments['where'][] = "u.name LIKE '%s'";
1365
-  $fragments['query_args']['where'][] = $search .'%%';
1365
+  $fragments['query_args']['where'][] = $search.'%%';
1366 1366
   if (!empty($names)) {
1367 1367
     // If there are already names selected, exclude them from the
1368 1368
     // suggestions. Extract the BOINC ids from the names array, and
@@ -1372,7 +1372,7 @@  discard block
 block discarded – undo
1372 1372
       $boincid = substr($name, strrpos($name, '_') + 1);
1373 1373
       $ids[$boincid] = $boincid;
1374 1374
     }
1375
-    $fragments['where'][] = "u.id NOT IN (". db_placeholders($ids, 'int') .")";
1375
+    $fragments['where'][] = "u.id NOT IN (".db_placeholders($ids, 'int').")";
1376 1376
     $fragments['query_args']['where'] += $ids;
1377 1377
   }
1378 1378
   // Only load active users and sort them by name.
@@ -1405,7 +1405,7 @@  discard block
 block discarded – undo
1405 1405
 
1406 1406
   // Only select messages that have been deleted more than n days ago.
1407 1407
   $fragments['having'][] = 'MAX(pmi.deleted) < %d';
1408
-  $fragments['query_args']['having'][] = time() - $days * 86400;
1408
+  $fragments['query_args']['having'][] = time() - $days*86400;
1409 1409
 }
1410 1410
 
1411 1411
 /**
@@ -1435,11 +1435,11 @@  discard block
 block discarded – undo
1435 1435
     db_set_active('boinc');
1436 1436
     $result = db_query_range($query['query'], $fragment, 0, 10);
1437 1437
     db_set_active('default');
1438
-    $prefix = count($names) ? implode(' ', $names) . ' ' : '';
1438
+    $prefix = count($names) ? implode(' ', $names).' ' : '';
1439 1439
     // 3: Build proper suggestions and print.
1440 1440
     while ($user = db_fetch_object($result)) {
1441 1441
       $myname = preg_replace("/ /", "\xc2\xa0", $user->name);
1442
-      $matches[$prefix . $myname . "_" . $user->id . ' '] = htmlentities($myname) . '(' . $user->id . ')';
1442
+      $matches[$prefix.$myname."_".$user->id.' '] = htmlentities($myname).'('.$user->id.')';
1443 1443
     }
1444 1444
   }
1445 1445
   // convert to object to prevent drupal bug, see http://drupal.org/node/175361
@@ -1481,7 +1481,7 @@  discard block
 block discarded – undo
1481 1481
 
1482 1482
       if (!empty($mids)) {
1483 1483
         // Delete recipient entries in {pm_index} of the messages the user wrote.
1484
-        db_query('DELETE FROM {pm_index} WHERE mid IN (' . db_placeholders($mids) . ')', $mids);
1484
+        db_query('DELETE FROM {pm_index} WHERE mid IN ('.db_placeholders($mids).')', $mids);
1485 1485
       }
1486 1486
 
1487 1487
       // Delete recipient entries of that user.
@@ -1553,10 +1553,10 @@  discard block
 block discarded – undo
1553 1553
   if (privatemsg_user_access('write privatemsg')) {
1554 1554
     $links[] = l(t('Write new message'), 'messages/new');
1555 1555
   }
1556
-  if (privatemsg_user_access('read privatemsg') || privatemsg_user_access('read all private messages') ) {
1556
+  if (privatemsg_user_access('read privatemsg') || privatemsg_user_access('read all private messages')) {
1557 1557
     $links[] = l(privatemsg_title_callback(), 'messages');
1558 1558
   }
1559
-  if ( count( $links ) ) {
1559
+  if (count($links)) {
1560 1560
     $block = array(
1561 1561
       'subject' => t('Private messages'),
1562 1562
       'content' => theme('item_list', $links),
@@ -1572,7 +1572,7 @@  discard block
 block discarded – undo
1572 1572
   );
1573 1573
   $form['delete_destination'] = array(
1574 1574
     '#type' => 'value',
1575
-    '#value' => count($thread['messages']) > 1 ? 'messages/view/' . $message['thread_id'] : 'messages',
1575
+    '#value' => count($thread['messages']) > 1 ? 'messages/view/'.$message['thread_id'] : 'messages',
1576 1576
   );
1577 1577
 
1578 1578
   if (privatemsg_user_access('read all private messages')) {
@@ -1585,7 +1585,7 @@  discard block
 block discarded – undo
1585 1585
   }
1586 1586
   return confirm_form($form,
1587 1587
     t('Are you sure you want to delete this message?'),
1588
-    isset($_GET['destination']) ? $_GET['destination'] : 'messages/view/'. $message['thread_id'],
1588
+    isset($_GET['destination']) ? $_GET['destination'] : 'messages/view/'.$message['thread_id'],
1589 1589
     t('This action cannot be undone.'),
1590 1590
     t('Delete'),
1591 1591
     t('Cancel')
@@ -1814,7 +1814,7 @@  discard block
 block discarded – undo
1814 1814
   }
1815 1815
 
1816 1816
   // Don't allow replies without a body.
1817
-  if (!empty($message['thread_id']) && ($message['body'] === NULL || $message['body'] === '') ) {
1817
+  if (!empty($message['thread_id']) && ($message['body'] === NULL || $message['body'] === '')) {
1818 1818
     if ($form) {
1819 1819
       form_set_error('body', t('Disallowed to send reply without a message.'));
1820 1820
     }
@@ -1930,7 +1930,7 @@  discard block
 block discarded – undo
1930 1930
   // 2) Save message to recipients.
1931 1931
   // Each recipient gets a record in the pm_index table.
1932 1932
   foreach ($message['recipients'] as $recipient) {
1933
-    if (!db_query($index_sql, $mid, $message['thread_id'], $recipient->uid, 1) ) {
1933
+    if (!db_query($index_sql, $mid, $message['thread_id'], $recipient->uid, 1)) {
1934 1934
       // We assume if one insert failed then the rest may fail too against the
1935 1935
       // same table.
1936 1936
       return FALSE;
@@ -1995,9 +1995,9 @@  discard block
 block discarded – undo
1995 1995
   if (empty($validated)) {
1996 1996
     return FALSE;
1997 1997
   }
1998
-  $url = 'messages/new/'. implode(',', $validated);
1998
+  $url = 'messages/new/'.implode(',', $validated);
1999 1999
   if (!is_null($subject)) {
2000
-    $url .= '/'. $subject;
2000
+    $url .= '/'.$subject;
2001 2001
   }
2002 2002
   return $url;
2003 2003
 }
@@ -2107,7 +2107,7 @@  discard block
 block discarded – undo
2107 2107
   // we do the merge because we call call_user_func_array and not drupal_alter
2108 2108
   // this is necessary because otherwise we would not be able to use $args correctly (otherwise it doesnt unfold)
2109 2109
   $alterargs = array(&$fragments);
2110
-  $query_function = $query_group .'_sql_'. $query_id;
2110
+  $query_function = $query_group.'_sql_'.$query_id;
2111 2111
   if (!empty($args)) {
2112 2112
     $alterargs = array_merge($alterargs, $args);
2113 2113
   }
@@ -2144,7 +2144,7 @@  discard block
 block discarded – undo
2144 2144
   // Perform the whole query assembly only if we have something to select.
2145 2145
   if (!empty($SELECT)) {
2146 2146
     $str_select = implode(", ", $SELECT);
2147
-    $query = "SELECT {$str_select} FROM ". $primary_table;
2147
+    $query = "SELECT {$str_select} FROM ".$primary_table;
2148 2148
 
2149 2149
     // Also build a count query which can be passed to pager_query to get a "page count" as that does not play well with queries including "GROUP BY".
2150 2150
     // In most cases,  "COUNT(*)" is enough to get the count query, but in queries involving a GROUP BY, we want a count of the number of groups we have, not the count of elements inside each group.
@@ -2153,10 +2153,10 @@  discard block
 block discarded – undo
2153 2153
       // PostgreSQL does not support COUNT(sometextfield, someintfield), so I'm only using the first one
2154 2154
       // Works fine for thread_id/list but may generate an error when a more complex GROUP BY is used.
2155 2155
       $str_group_by_count = current($GROUP_BY);
2156
-      $count = "SELECT COUNT(DISTINCT {$str_group_by_count}) FROM ". $primary_table;
2156
+      $count = "SELECT COUNT(DISTINCT {$str_group_by_count}) FROM ".$primary_table;
2157 2157
     }
2158 2158
     else {
2159
-      $count = "SELECT COUNT(*) FROM ". $primary_table;
2159
+      $count = "SELECT COUNT(*) FROM ".$primary_table;
2160 2160
     }
2161 2161
 
2162 2162
     if (!empty($INNER_JOIN)) {
@@ -2165,24 +2165,24 @@  discard block
 block discarded – undo
2165 2165
       $count .= " {$str_inner_join}";
2166 2166
     }
2167 2167
     if (!empty($WHERE)) {
2168
-      $str_where = '('. implode(') AND (', $WHERE) .')';
2168
+      $str_where = '('.implode(') AND (', $WHERE).')';
2169 2169
       $query .= " WHERE {$str_where}";
2170 2170
       $count .= " WHERE {$str_where}";
2171 2171
     }
2172 2172
     if (!empty($GROUP_BY)) {
2173
-      $str_group_by = ' GROUP BY '. implode(", ", $GROUP_BY) ;
2173
+      $str_group_by = ' GROUP BY '.implode(", ", $GROUP_BY);
2174 2174
       $query .= " {$str_group_by}";
2175 2175
     }
2176 2176
     if (!empty($HAVING)) {
2177
-      $str_having = '('. implode(') AND (', $HAVING) .')';
2177
+      $str_having = '('.implode(') AND (', $HAVING).')';
2178 2178
       $query .= " HAVING {$str_having}";
2179 2179
       // queries containing a HAVING break the count query on pgsql.
2180 2180
       // In this case, use the subquery method as outlined in http://drupal.org/node/303087#comment-1370752 .
2181 2181
       // The subquery method will work for all COUNT queries, but it is thought to be much slower, so we are only using it where other cross database approaches fail.
2182
-      $count = 'SELECT COUNT(*) FROM ('. $query .') as count';
2182
+      $count = 'SELECT COUNT(*) FROM ('.$query.') as count';
2183 2183
     }
2184 2184
     if (!empty($ORDER_BY)) {
2185
-      $str_order_by = ' ORDER BY '. implode(", ", $ORDER_BY) ;
2185
+      $str_order_by = ' ORDER BY '.implode(", ", $ORDER_BY);
2186 2186
       $query .= " {$str_order_by}";
2187 2187
     }
2188 2188
     $QUERY_ARGS = array_merge($QUERY_ARGS['select'], $QUERY_ARGS['join'], $QUERY_ARGS['where'], $QUERY_ARGS['having']);
@@ -2247,7 +2247,7 @@  discard block
 block discarded – undo
2247 2247
       '#attributes' => array('class' => 'privatemsg-action-button'),
2248 2248
   );
2249 2249
   // JS for hiding the execute button.
2250
-  drupal_add_js(drupal_get_path('module', 'privatemsg') .'/privatemsg-list.js');
2250
+  drupal_add_js(drupal_get_path('module', 'privatemsg').'/privatemsg-list.js');
2251 2251
   return $form;
2252 2252
 }
2253 2253
 
@@ -2272,7 +2272,7 @@  discard block
 block discarded – undo
2272 2272
   }
2273 2273
   // Merge status and uid with the threads list. array_merge() will not overwrite/ignore thread_id 1.
2274 2274
   $params = array_merge(array($status, $account->uid), $threads);
2275
-  db_query('UPDATE {pm_index} SET is_new = %d WHERE uid = %d AND thread_id IN ('. db_placeholders($threads) .')', $params);
2275
+  db_query('UPDATE {pm_index} SET is_new = %d WHERE uid = %d AND thread_id IN ('.db_placeholders($threads).')', $params);
2276 2276
 
2277 2277
   if ($status == PRIVATEMSG_UNREAD) {
2278 2278
     drupal_set_message(format_plural(count($threads), 'Marked 1 thread as unread.', 'Marked @count threads as unread.'));
@@ -2299,12 +2299,12 @@  discard block
 block discarded – undo
2299 2299
   $select_header['#weight'] = -50;
2300 2300
 
2301 2301
   // theme() doesn't include the theme file for patterns, we need to do it manually.
2302
-  include_once drupal_get_path('module', 'privatemsg') .'/privatemsg.theme.inc';
2302
+  include_once drupal_get_path('module', 'privatemsg').'/privatemsg.theme.inc';
2303 2303
 
2304 2304
   $header = array($select_header);
2305 2305
   foreach ($keys as $key) {
2306 2306
     // First, try to load a specific theme for that header, if not present, use the default.
2307
-    if ($return = theme(array('privatemsg_list_header__'. $key, 'privatemsg_list_header'))) {
2307
+    if ($return = theme(array('privatemsg_list_header__'.$key, 'privatemsg_list_header'))) {
2308 2308
       // The default theme returns nothing, only store the value if we have something.
2309 2309
       $header[$key] = $return;
2310 2310
     }
@@ -2325,7 +2325,7 @@  discard block
 block discarded – undo
2325 2325
 function _privatemsg_list_headers_fallback($keys) {
2326 2326
   $header = array();
2327 2327
   foreach ($keys as $key) {
2328
-    $theme_function = 'phptemplate_privatemsg_list_header__' . $key;
2328
+    $theme_function = 'phptemplate_privatemsg_list_header__'.$key;
2329 2329
     if (function_exists($theme_function)) {
2330 2330
       $header[$key] = $theme_function();
2331 2331
     }
@@ -2353,7 +2353,7 @@  discard block
 block discarded – undo
2353 2353
   }
2354 2354
   foreach ($thread as $key => $data) {
2355 2355
     // First, try to load a specific theme for that field, if not present, use the default.
2356
-    if ($return = theme(array('privatemsg_list_field__'. $key, 'privatemsg_list_field'), $thread)) {
2356
+    if ($return = theme(array('privatemsg_list_field__'.$key, 'privatemsg_list_field'), $thread)) {
2357 2357
       // The default theme returns nothing, only store the value if we have something.
2358 2358
       $row['data'][$key] = $return;
2359 2359
     }
@@ -2373,7 +2373,7 @@  discard block
 block discarded – undo
2373 2373
 function _privatemsg_list_thread_fallback($thread) {
2374 2374
   $row_data = array();
2375 2375
   foreach ($thread as $key => $data) {
2376
-    $theme_function = 'phptemplate_privatemsg_list_field__' . $key;
2376
+    $theme_function = 'phptemplate_privatemsg_list_field__'.$key;
2377 2377
     if (function_exists($theme_function)) {
2378 2378
       $row_data[$key] = $theme_function($thread);
2379 2379
     }
@@ -2572,6 +2572,6 @@  discard block
 block discarded – undo
2572 2572
 function privatemsg_views_api() {
2573 2573
   return array(
2574 2574
     'api' => 2,
2575
-    'path' => drupal_get_path('module', 'privatemsg') . '/views',
2575
+    'path' => drupal_get_path('module', 'privatemsg').'/views',
2576 2576
   );
2577 2577
 }
Please login to merge, or discard this patch.
Braces   +41 added lines, -70 removed lines patch added patch discarded remove patch
@@ -102,10 +102,11 @@  discard block
 block discarded – undo
102 102
     }
103 103
 
104 104
     $last = array_pop($to);
105
-    if (count($to) == 0) { // Only one participant
105
+    if (count($to) == 0) {
106
+// Only one participant
106 107
       return t("From !last", array('!last' => $last));
107
-    }
108
-    else { // Multipe participants..
108
+    } else {
109
+// Multipe participants..
109 110
       $participants = implode(', ', $to);
110 111
       return t('Participants: !participants and !last', array('!participants' => $participants, '!last' => $last));
111 112
     }
@@ -224,7 +225,8 @@  discard block
 block discarded – undo
224 225
     global $user;
225 226
     $account = $user;
226 227
   }
227
-  if (!$account->uid) { // Disallow anonymous access, regardless of permissions
228
+  if (!$account->uid) {
229
+// Disallow anonymous access, regardless of permissions
228 230
     return FALSE;
229 231
   }
230 232
   if (!user_access($permission, $account)) {
@@ -325,11 +327,9 @@  discard block
 block discarded – undo
325 327
       if (is_null($start)) {
326 328
         if (isset($_GET['start']) && $_GET['start'] < $thread['message_count']) {
327 329
           $start = $_GET['start'];
328
-        }
329
-        elseif (!variable_get('privatemsg_view_use_max_as_default', FALSE) && $max_amount == PRIVATEMSG_UNLIMITED) {
330
+        } elseif (!variable_get('privatemsg_view_use_max_as_default', FALSE) && $max_amount == PRIVATEMSG_UNLIMITED) {
330 331
           $start = PRIVATEMSG_UNLIMITED;
331
-        }
332
-        else {
332
+        } else {
333 333
           $start = $thread['message_count'] - (variable_get('privatemsg_view_use_max_as_default', FALSE) ? variable_get('privatemsg_view_default_amount', 10) : $max_amount);
334 334
         }
335 335
       }
@@ -338,8 +338,7 @@  discard block
 block discarded – undo
338 338
         if ($max_amount == PRIVATEMSG_UNLIMITED) {
339 339
           $last_page = 0;
340 340
           $max_amount = $thread['message_count'];
341
-        }
342
-        else {
341
+        } else {
343 342
           // Calculate the number of messages on the "last" page to avoid
344 343
           // message overlap.
345 344
           // Note - the last page lists the earliest messages, not the latest.
@@ -360,8 +359,7 @@  discard block
 block discarded – undo
360 359
         }
361 360
         if ($start - $max_amount >= 0) {
362 361
           $thread['older_start'] = $start - $max_amount;
363
-        }
364
-        elseif ($start > 0) {
362
+        } elseif ($start > 0) {
365 363
           $thread['older_start'] = 0;
366 364
         }
367 365
 
@@ -377,8 +375,7 @@  discard block
 block discarded – undo
377 375
         // Visual counts start from 1 instead of zero, so plus one.
378 376
         $thread['from'] = $start + 1;
379 377
         $conversation = db_query_range($query['query'], $start, $max_amount);
380
-      }
381
-      else {
378
+      } else {
382 379
         $conversation = db_query($query['query']);
383 380
       }
384 381
       $mids = array();
@@ -398,12 +395,10 @@  discard block
 block discarded – undo
398 395
             // Thread does not exist, display 404.
399 396
             $thread = FALSE;
400 397
           }
401
-        }
402
-        else {
398
+        } else {
403 399
           $thread = FALSE;
404 400
         }
405
-      }
406
-      else {
401
+      } else {
407 402
         // General data, assume subject is the same for all messages of that thread.
408 403
         $thread['user'] = $account;
409 404
         $message = current($thread['messages']);
@@ -689,8 +684,7 @@  discard block
 block discarded – undo
689 684
     // Trying to view someone else's messages...
690 685
     if (!privatemsg_user_access('read all private messages')) {
691 686
       drupal_set_message(t("You do not have sufficient rights to view someone else's messages"), 'warning');
692
-    }
693
-    elseif ($account_check = user_load(array('uid' => $uid))) {
687
+    } elseif ($account_check = user_load(array('uid' => $uid))) {
694 688
       // Has rights and user_load return an array so user does exist
695 689
       $account = $account_check;
696 690
     }
@@ -852,11 +846,9 @@  discard block
 block discarded – undo
852 846
   // convert recipients to array of user objects
853 847
   if (!empty($recipients) && is_string($recipients) || is_int($recipients)) {
854 848
     $recipients = _privatemsg_generate_user_array($recipients);
855
-  }
856
-  elseif (is_object($recipients)) {
849
+  } elseif (is_object($recipients)) {
857 850
     $recipients = array($recipients);
858
-  }
859
-  elseif (empty($recipients) && is_string($recipients)) {
851
+  } elseif (empty($recipients) && is_string($recipients)) {
860 852
     $recipients = array();
861 853
   }
862 854
 
@@ -881,8 +873,7 @@  discard block
 block discarded – undo
881 873
       $myname = preg_replace("/ /", "\xc2\xa0", $myuser->boincuser_name);
882 874
       $to[] = $myname . "_" . $myuser->boincuser_id;
883 875
       $to_themed[$recipient->uid] = $myname;
884
-    }
885
-    else {
876
+    } else {
886 877
       // Recipient list contains blocked users.
887 878
       $blocked = TRUE;
888 879
     }
@@ -909,8 +900,7 @@  discard block
 block discarded – undo
909 900
   }
910 901
   if (!$thread_id && !empty($recipients_string)) {
911 902
     drupal_set_title(t('Write new message to %recipient', array('%recipient' => $recipients_string)));
912
-  }
913
-  elseif (!$thread_id) {
903
+  } elseif (!$thread_id) {
914 904
     drupal_set_title(t('Write new message'));
915 905
   }
916 906
 
@@ -986,8 +976,7 @@  discard block
 block discarded – undo
986 976
   $title = t('Cancel');
987 977
   if (isset($_REQUEST['destination'])) {
988 978
     $url = $_REQUEST['destination'];
989
-  }
990
-  elseif (!is_null($thread_id)) {
979
+  } elseif (!is_null($thread_id)) {
991 980
     $url = $_GET['q'];
992 981
     $title = t('Clear');
993 982
   }
@@ -1038,8 +1027,7 @@  discard block
 block discarded – undo
1038 1027
   // Only parse the user string for a new thread.
1039 1028
   if (!isset($message['thread_id'])) {
1040 1029
     list($message['recipients'], $invalid) = _privatemsg_parse_userstring($message['recipient']);
1041
-  }
1042
-  else {
1030
+  } else {
1043 1031
     // Load participants.
1044 1032
     $message['recipients'] = _privatemsg_load_thread_participants($message['thread_id']);
1045 1033
     // Remove author.
@@ -1097,7 +1085,8 @@  discard block
 block discarded – undo
1097 1085
   $recipients = array();
1098 1086
   foreach ($input as $string) {
1099 1087
     $string = trim($string);
1100
-    if (!empty($string)) { // We don't care about white space names.
1088
+    if (!empty($string)) {
1089
+// We don't care about white space names.
1101 1090
 
1102 1091
       // First, check if another module is able to resolve the string into an
1103 1092
       // user object.
@@ -1133,10 +1122,9 @@  discard block
 block discarded – undo
1133 1122
   foreach ($form_state['validate_built_message']['recipients'] as $recipient) {
1134 1123
     $recipient_names[] = theme('username', $recipient);
1135 1124
   }
1136
-  if ($status !== FALSE )  {
1125
+  if ($status !== FALSE ) {
1137 1126
     drupal_set_message(t('A message has been sent to !recipients.', array('!recipients' => implode(', ', $recipient_names))));
1138
-  }
1139
-  else {
1127
+  } else {
1140 1128
     drupal_set_message(t('An attempt to send a message <em>may have failed</em> when sending to !recipients.', array('!recipients' => implode(', ', $recipient_names))), 'error');
1141 1129
   }
1142 1130
 }
@@ -1197,8 +1185,7 @@  discard block
 block discarded – undo
1197 1185
       $fragments['select'][]      = "array_to_string(array(SELECT DISTINCT textin(int4out(pmia.uid))
1198 1186
                                                             FROM {pm_index} pmia
1199 1187
                                                             WHERE pmia.thread_id = pmi.thread_id), ',') AS participants";
1200
-    }
1201
-    else {
1188
+    } else {
1202 1189
       $fragments['select'][]      = '(SELECT GROUP_CONCAT(DISTINCT pmia.uid SEPARATOR ",")
1203 1190
                                                             FROM {pm_index} pmia
1204 1191
                                                             WHERE pmia.thread_id = pmi.thread_id) AS participants';
@@ -1503,8 +1490,7 @@  discard block
 block discarded – undo
1503 1490
     );
1504 1491
 
1505 1492
     return $blocks;
1506
-  }
1507
-  elseif ('view' == $op) {
1493
+  } elseif ('view' == $op) {
1508 1494
     $block = array();
1509 1495
     switch ($delta) {
1510 1496
       case 'privatemsg-menu':
@@ -1600,8 +1586,7 @@  discard block
 block discarded – undo
1600 1586
     if (isset($form_state['values']['delete_options']) && $form_state['values']['delete_options']) {
1601 1587
       privatemsg_message_change_delete($form_state['values']['pmid'], 1);
1602 1588
       drupal_set_message(t('Message has been deleted for all users.'));
1603
-    }
1604
-    else {
1589
+    } else {
1605 1590
       privatemsg_message_change_delete($form_state['values']['pmid'], 1, $account);
1606 1591
       drupal_set_message(t('Message has been deleted.'));
1607 1592
     }
@@ -1630,8 +1615,7 @@  discard block
 block discarded – undo
1630 1615
 
1631 1616
   if ($account) {
1632 1617
     db_query('UPDATE {pm_index} SET deleted = %d WHERE mid = %d AND uid = %d', $delete_value, $pmid, $account->uid);
1633
-  }
1634
-  else {
1618
+  } else {
1635 1619
     // Mark deleted for all users.
1636 1620
     db_query('UPDATE {pm_index} SET deleted = %d WHERE mid = %d', $delete_value, $pmid);
1637 1621
   }
@@ -1792,8 +1776,7 @@  discard block
 block discarded – undo
1792 1776
         'success'  => FALSE,
1793 1777
         'messages'   => $messages,
1794 1778
       );
1795
-    }
1796
-    else {
1779
+    } else {
1797 1780
       $messages['error'][] = t('User @user is not allowed to write messages', array('@user' => $message['author']->name));
1798 1781
       return array(
1799 1782
          'success'  => FALSE,
@@ -1807,8 +1790,7 @@  discard block
 block discarded – undo
1807 1790
   if (empty($message['subject'])) {
1808 1791
     if ($form) {
1809 1792
       form_set_error('subject', t('Disallowed to send a message without subject'));
1810
-    }
1811
-    else {
1793
+    } else {
1812 1794
       $messages['error'][] = t('Disallowed to send a message without subject');
1813 1795
     }
1814 1796
   }
@@ -1817,8 +1799,7 @@  discard block
 block discarded – undo
1817 1799
   if (!empty($message['thread_id']) && ($message['body'] === NULL || $message['body'] === '') ) {
1818 1800
     if ($form) {
1819 1801
       form_set_error('body', t('Disallowed to send reply without a message.'));
1820
-    }
1821
-    else {
1802
+    } else {
1822 1803
       $messages['error'][] = t('Disallowed to send reply without a message.');
1823 1804
     }
1824 1805
   }
@@ -1832,8 +1813,7 @@  discard block
 block discarded – undo
1832 1813
   if (!filter_access($message['format'])) {
1833 1814
     if ($form) {
1834 1815
       form_set_error('format', t('You are not allowed to use the specified input format.'));
1835
-    }
1836
-    else {
1816
+    } else {
1837 1817
       $messages['error'][] = t('User @user is not allowed to use the specified input format.', array('@user' => $message['author']->name));
1838 1818
     }
1839 1819
   }
@@ -1844,8 +1824,7 @@  discard block
 block discarded – undo
1844 1824
   if (empty($message['recipients']) || !is_array($message['recipients'])) {
1845 1825
     if ($form) {
1846 1826
       form_set_error('to', t('Disallowed to send a message without at least one valid recipient'));
1847
-    }
1848
-    else {
1827
+    } else {
1849 1828
       $messages['error'][] = t('Disallowed to send a message without at least one valid recipient');
1850 1829
     }
1851 1830
   }
@@ -1855,8 +1834,7 @@  discard block
 block discarded – undo
1855 1834
       unset($message['recipients'][$blocked['uid']]);
1856 1835
       if ($form) {
1857 1836
         drupal_set_message($blocked['message'], 'warning');
1858
-      }
1859
-      else {
1837
+      } else {
1860 1838
         $messages['warning'][] = $blocked['message'];
1861 1839
       }
1862 1840
     }
@@ -1866,8 +1844,7 @@  discard block
 block discarded – undo
1866 1844
   if (empty($message['recipients'])) {
1867 1845
     if ($form) {
1868 1846
       form_set_error('to', t('Disallowed to send message because all recipients are blocked'));
1869
-    }
1870
-    else {
1847
+    } else {
1871 1848
       $messages['error'][] = t('Disallowed to send message because all recipients are blocked');
1872 1849
     }
1873 1850
   }
@@ -2073,8 +2050,7 @@  discard block
 block discarded – undo
2073 2050
   if (is_array($query)) {
2074 2051
     $query_id = $query[0];
2075 2052
     $query_group = $query[1];
2076
-  }
2077
-  else {
2053
+  } else {
2078 2054
     $query_id = $query;
2079 2055
     $query_group = 'privatemsg';
2080 2056
   }
@@ -2154,8 +2130,7 @@  discard block
 block discarded – undo
2154 2130
       // Works fine for thread_id/list but may generate an error when a more complex GROUP BY is used.
2155 2131
       $str_group_by_count = current($GROUP_BY);
2156 2132
       $count = "SELECT COUNT(DISTINCT {$str_group_by_count}) FROM ". $primary_table;
2157
-    }
2158
-    else {
2133
+    } else {
2159 2134
       $count = "SELECT COUNT(*) FROM ". $primary_table;
2160 2135
     }
2161 2136
 
@@ -2276,8 +2251,7 @@  discard block
 block discarded – undo
2276 2251
 
2277 2252
   if ($status == PRIVATEMSG_UNREAD) {
2278 2253
     drupal_set_message(format_plural(count($threads), 'Marked 1 thread as unread.', 'Marked @count threads as unread.'));
2279
-  }
2280
-  else {
2254
+  } else {
2281 2255
     drupal_set_message(format_plural(count($threads), 'Marked 1 thread as read.', 'Marked @count threads as read.'));
2282 2256
   }
2283 2257
 }
@@ -2458,8 +2432,7 @@  discard block
 block discarded – undo
2458 2432
   // Add in callback arguments if present.
2459 2433
   if (isset($operation['callback arguments'])) {
2460 2434
     $args = array_merge(array($threads), $operation['callback arguments']);
2461
-  }
2462
-  else {
2435
+  } else {
2463 2436
     $args = array($threads);
2464 2437
   }
2465 2438
 
@@ -2476,8 +2449,7 @@  discard block
 block discarded – undo
2476 2449
     // Add in callback arguments if present.
2477 2450
     if (isset($operation['undo callback arguments'])) {
2478 2451
       $undo_args = array_merge(array($threads), $operation['undo callback arguments']);
2479
-    }
2480
-    else {
2452
+    } else {
2481 2453
       $undo_args = array($threads);
2482 2454
     }
2483 2455
 
@@ -2529,8 +2501,7 @@  discard block
 block discarded – undo
2529 2501
 
2530 2502
   if ($delete) {
2531 2503
     drupal_set_message(format_plural(count($threads), 'Deleted 1 thread.', 'Deleted @count threads.'));
2532
-  }
2533
-  else {
2504
+  } else {
2534 2505
     drupal_set_message(format_plural(count($threads), 'Restored 1 thread.', 'Restored @count threads.'));
2535 2506
   }
2536 2507
 }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
  * @return
42 42
  *   Array with user objects.
43 43
  */
44
-function _privatemsg_generate_user_array($userstring, $slice = NULL) {
44
+function _privatemsg_generate_user_array($userstring, $slice = null) {
45 45
   static $user_cache = array();
46 46
 
47 47
   // Convert user uid list (uid1,uid2,uid3) into an array. If $slice is not NULL
@@ -79,13 +79,13 @@  discard block
 block discarded – undo
79 79
  * @return
80 80
  *   String with formated user objects, like user1, user2.
81 81
  */
82
-function _privatemsg_format_participants($part_array, $limit = NULL, $no_text = FALSE) {
82
+function _privatemsg_format_participants($part_array, $limit = null, $no_text = false) {
83 83
   if (count($part_array) > 0) {
84 84
     $to = array();
85
-    $limited = FALSE;
85
+    $limited = false;
86 86
     foreach ($part_array as $account) {
87 87
       if (is_int($limit) && count($to) >= $limit) {
88
-        $limited = TRUE;
88
+        $limited = true;
89 89
         break;
90 90
       }
91 91
       $to[] = theme('username', $account);
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
     'title'            => 'Read message',
138 138
     // Set the third argument to TRUE so that we can show access denied instead
139 139
     // of not found.
140
-    'load arguments'   => array(NULL, NULL, TRUE),
140
+    'load arguments'   => array(null, null, true),
141 141
     'page callback'    => 'privatemsg_view',
142 142
     'page arguments'   => array(2),
143 143
     'access callback'  => 'privatemsg_view_access',
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
   $items['messages/new'] = array(
157 157
     'title'            => 'Write new message',
158 158
     'page callback'    => 'drupal_get_form',
159
-    'page arguments'   => array('privatemsg_new', 2, 3, NULL),
159
+    'page arguments'   => array('privatemsg_new', 2, 3, null),
160 160
     'access callback'  => 'privatemsg_user_access',
161 161
     'access arguments' => array('write privatemsg'),
162 162
     'type'             => MENU_LOCAL_TASK,
@@ -219,18 +219,18 @@  discard block
 block discarded – undo
219 219
  *
220 220
  * @ingroup api
221 221
  */
222
-function privatemsg_user_access($permission = 'read privatemsg', $account = NULL) {
223
-  if ( $account === NULL ) {
222
+function privatemsg_user_access($permission = 'read privatemsg', $account = null) {
223
+  if ( $account === null ) {
224 224
     global $user;
225 225
     $account = $user;
226 226
   }
227 227
   if (!$account->uid) { // Disallow anonymous access, regardless of permissions
228
-    return FALSE;
228
+    return false;
229 229
   }
230 230
   if (!user_access($permission, $account)) {
231
-    return FALSE;
231
+    return false;
232 232
   }
233
-  return TRUE;
233
+  return true;
234 234
 }
235 235
 
236 236
 /**
@@ -250,12 +250,12 @@  discard block
 block discarded – undo
250 250
   // Do not allow access to threads without messages.
251 251
   if (empty($thread['messages'])) {
252 252
     // Count all messages, if there
253
-    return FALSE;
253
+    return false;
254 254
   }
255 255
   if (privatemsg_user_access('read privatemsg') && arg(1) == 'view') {
256
-    return TRUE;
256
+    return true;
257 257
   }
258
-  return FALSE;
258
+  return false;
259 259
 }
260 260
 
261 261
 /**
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 
288 288
  * @ingroup api
289 289
  */
290
-function privatemsg_thread_load($thread_id, $account = NULL, $start = NULL, $useAccessDenied = FALSE) {
290
+function privatemsg_thread_load($thread_id, $account = null, $start = null, $useAccessDenied = false) {
291 291
   static $threads = array();
292 292
   if ((int)$thread_id > 0) {
293 293
     $thread = array('thread_id' => $thread_id);
@@ -309,13 +309,13 @@  discard block
 block discarded – undo
309 309
       while ($participant = db_fetch_object($participants)) {
310 310
         $thread['participants'][$participant->uid] = $participant;
311 311
       }
312
-      $thread['read_all'] = FALSE;
312
+      $thread['read_all'] = false;
313 313
       if (!array_key_exists($account->uid, $thread['participants']) && privatemsg_user_access('read all private messages', $account)) {
314
-        $thread['read_all'] = TRUE;
314
+        $thread['read_all'] = true;
315 315
       }
316 316
 
317 317
       // Load messages returned by the messages query with privatemsg_message_load_multiple().
318
-      $query = _privatemsg_assemble_query('messages', array($thread_id), $thread['read_all'] ? NULL : $account);
318
+      $query = _privatemsg_assemble_query('messages', array($thread_id), $thread['read_all'] ? null : $account);
319 319
       $thread['message_count'] = $thread['to'] = db_result(db_query($query['count']));
320 320
       $thread['from'] = 1;
321 321
       // Check if we need to limit the messages.
@@ -326,11 +326,11 @@  discard block
 block discarded – undo
326 326
         if (isset($_GET['start']) && $_GET['start'] < $thread['message_count']) {
327 327
           $start = $_GET['start'];
328 328
         }
329
-        elseif (!variable_get('privatemsg_view_use_max_as_default', FALSE) && $max_amount == PRIVATEMSG_UNLIMITED) {
329
+        elseif (!variable_get('privatemsg_view_use_max_as_default', false) && $max_amount == PRIVATEMSG_UNLIMITED) {
330 330
           $start = PRIVATEMSG_UNLIMITED;
331 331
         }
332 332
         else {
333
-          $start = $thread['message_count'] - (variable_get('privatemsg_view_use_max_as_default', FALSE) ? variable_get('privatemsg_view_default_amount', 10) : $max_amount);
333
+          $start = $thread['message_count'] - (variable_get('privatemsg_view_use_max_as_default', false) ? variable_get('privatemsg_view_default_amount', 10) : $max_amount);
334 334
         }
335 335
       }
336 336
 
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
           // Calculate the number of messages on the "last" page to avoid
344 344
           // message overlap.
345 345
           // Note - the last page lists the earliest messages, not the latest.
346
-          $paging_count = variable_get('privatemsg_view_use_max_as_default', FALSE) ? $thread['message_count'] - variable_get('privatemsg_view_default_amount', 10) : $thread['message_count'];
346
+          $paging_count = variable_get('privatemsg_view_use_max_as_default', false) ? $thread['message_count'] - variable_get('privatemsg_view_default_amount', 10) : $thread['message_count'];
347 347
           $last_page = $paging_count % $max_amount;
348 348
         }
349 349
 
@@ -386,21 +386,21 @@  discard block
 block discarded – undo
386 386
         $mids[] = $result['mid'];
387 387
       }
388 388
       // Load messages returned by the messages query.
389
-      $thread['messages'] = privatemsg_message_load_multiple($mids, $thread['read_all'] ? NULL : $account);
389
+      $thread['messages'] = privatemsg_message_load_multiple($mids, $thread['read_all'] ? null : $account);
390 390
 
391 391
       // If there are no messages, don't allow access to the thread.
392 392
       if (empty($thread['messages'])) {
393 393
         if ($useAccessDenied) {
394 394
           // Generate new query with read all to see if the thread does exist.
395
-          $query = _privatemsg_assemble_query('messages', array($thread_id), NULL);
395
+          $query = _privatemsg_assemble_query('messages', array($thread_id), null);
396 396
           $exists = db_result(db_query($query['count']));
397 397
           if (!$exists) {
398 398
             // Thread does not exist, display 404.
399
-            $thread = FALSE;
399
+            $thread = false;
400 400
           }
401 401
         }
402 402
         else {
403
-          $thread = FALSE;
403
+          $thread = false;
404 404
         }
405 405
       }
406 406
       else {
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 
415 415
     return $threads[$account->uid][$thread_id];
416 416
   }
417
-  return FALSE;
417
+  return false;
418 418
 }
419 419
 
420 420
 function private_message_view_options() {
@@ -445,8 +445,8 @@  discard block
 block discarded – undo
445 445
 
446 446
   $form['theming_settings'] = array(
447 447
     '#type'        => 'fieldset',
448
-    '#collapsible' => TRUE,
449
-    '#collapsed'   => TRUE,
448
+    '#collapsible' => true,
449
+    '#collapsed'   => true,
450 450
     '#title'       => t('Theming settings'),
451 451
   );
452 452
   $form['theming_settings']['private_message_view_template'] = array(
@@ -458,14 +458,14 @@  discard block
 block discarded – undo
458 458
   $form['privatemsg_display_loginmessage'] = array(
459 459
     '#type' => 'checkbox',
460 460
     '#title' => t('Inform the user about new messages on login'),
461
-    '#default_value' => variable_get('privatemsg_display_loginmessage', TRUE),
461
+    '#default_value' => variable_get('privatemsg_display_loginmessage', true),
462 462
     '#description' => t('This option can safely be disabled if the "New message indication" block is used instead.'),
463 463
   );
464 464
 
465 465
   $form['flush_deleted'] = array(
466 466
     '#type'        => 'fieldset',
467
-    '#collapsible' => TRUE,
468
-    '#collapsed'   => TRUE,
467
+    '#collapsible' => true,
468
+    '#collapsed'   => true,
469 469
     '#title'       => t('Flush deleted messages'),
470 470
     '#description' => t('By default, deleted messages are only hidden from the user but still stored in the database. These settings control if and when messages should be removed.'),
471 471
   );
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
   $form['flush_deleted']['privatemsg_flush_enabled'] = array(
474 474
     '#type'          => 'checkbox',
475 475
     '#title'         => t('Flush deleted messages'),
476
-    '#default_value' => variable_get('privatemsg_flush_enabled', FALSE),
476
+    '#default_value' => variable_get('privatemsg_flush_enabled', false),
477 477
     '#description'   => t('Enable the flushing of deleted messages. Requires that cron is enabled'),
478 478
   );
479 479
 
@@ -494,8 +494,8 @@  discard block
 block discarded – undo
494 494
   $form['privatemsg_listing'] = array(
495 495
     '#type' => 'fieldset',
496 496
     '#title' => t('Configure listings'),
497
-    '#collapsible' => TRUE,
498
-    '#collapsed' => FALSE,
497
+    '#collapsible' => true,
498
+    '#collapsed' => false,
499 499
   );
500 500
 
501 501
   $form['privatemsg_listing']['privatemsg_per_page'] = array(
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
   $form['privatemsg_listing']['privatemsg_view_use_max_as_default'] = array(
532 532
     '#type'          => 'checkbox',
533 533
     '#title'         => t('Display different amount of messages on first thread page'),
534
-    '#default_value' => variable_get('privatemsg_view_use_max_as_default', FALSE),
534
+    '#default_value' => variable_get('privatemsg_view_use_max_as_default', false),
535 535
     '#description'   => t('By default, the first thread page shows the maximally allowed amount of messages. Enable this checkbox to set a different value.'),
536 536
     '#weight'        => 15,
537 537
   );
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
  * old enough are flushed.
564 564
  */
565 565
 function privatemsg_cron() {
566
-  if (variable_get('privatemsg_flush_enabled', FALSE)) {
566
+  if (variable_get('privatemsg_flush_enabled', false)) {
567 567
     $query = _privatemsg_assemble_query('deleted', variable_get('privatemsg_flush_days', 30));
568 568
     $result = db_query($query['query']);
569 569
 
@@ -584,19 +584,19 @@  discard block
 block discarded – undo
584 584
 function privatemsg_theme() {
585 585
   return array(
586 586
     'privatemsg_view'    => array(
587
-      'arguments'        => array('message' => NULL),
587
+      'arguments'        => array('message' => null),
588 588
       'template'         => variable_get('private_message_view_template', 'privatemsg-view'), // 'privatemsg',
589 589
     ),
590 590
     'privatemsg_from'    => array(
591
-      'arguments'        => array('author' => NULL),
591
+      'arguments'        => array('author' => null),
592 592
       'template'         => 'privatemsg-from',
593 593
     ),
594 594
     'privatemsg_recipients' => array(
595
-      'arguments'        => array('message' => NULL),
595
+      'arguments'        => array('message' => null),
596 596
       'template'         => 'privatemsg-recipients',
597 597
     ),
598 598
     'privatemsg_between' => array(
599
-      'arguments'        => array('recipients' => NULL),
599
+      'arguments'        => array('recipients' => null),
600 600
       'template'         => 'privatemsg-between',
601 601
     ),
602 602
     'privatemsg_list'    => array(
@@ -630,15 +630,15 @@  discard block
 block discarded – undo
630 630
 //  drupal_set_message('<pre>'. print_r($vars,1 ) . '</pre>');
631 631
 
632 632
   $message = $vars['message'];
633
-  $vars['mid'] = isset($message['mid']) ? $message['mid'] : NULL;
634
-  $vars['thread_id'] = isset($message['thread_id']) ? $message['thread_id'] : NULL;
633
+  $vars['mid'] = isset($message['mid']) ? $message['mid'] : null;
634
+  $vars['thread_id'] = isset($message['thread_id']) ? $message['thread_id'] : null;
635 635
   $vars['author_picture'] = theme('user_picture', $message['author']);
636 636
   $vars['author_name_link'] = theme('username', $message['author']);
637 637
   /**
638 638
    * @todo perhaps make this timestamp configurable via admin UI?
639 639
    */
640 640
   $vars['message_timestamp'] = format_date($message['timestamp'], 'small');
641
-  $vars['message_body'] = check_markup($message['body'], $message['format'], FALSE);
641
+  $vars['message_body'] = check_markup($message['body'], $message['format'], false);
642 642
   if (isset($vars['mid']) && isset($vars['thread_id']) && privatemsg_user_access('delete privatemsg')) {
643 643
     $vars['message_actions'][] = array('title' => t('Delete message'), 'href' => 'messages/delete/' . $vars['thread_id'] . '/' . $vars['mid']);
644 644
   }
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
  * @return
680 680
  *   Form array
681 681
  */
682
-function privatemsg_list(&$form_state, $argument = 'list', $uid = NULL) {
682
+function privatemsg_list(&$form_state, $argument = 'list', $uid = null) {
683 683
   global $user;
684 684
 
685 685
   // Setting default behavior...
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
  * @param $account
736 736
  *   User object, defaults to the current user
737 737
  */
738
-function privatemsg_message_change_status($pmid, $status, $account = NULL) {
738
+function privatemsg_message_change_status($pmid, $status, $account = null) {
739 739
   if (!$account) {
740 740
     global $user;
741 741
     $account = $user;
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
  *
753 753
  * @ingroup api
754 754
  */
755
-function privatemsg_unread_count($account = NULL) {
755
+function privatemsg_unread_count($account = null) {
756 756
   static $counts = array();
757 757
   if (!$account || $account->uid == 0) {
758 758
     global $user;
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
 }
844 844
 
845 845
 
846
-function privatemsg_new(&$form_state, $recipients = array(), $subject = '', $thread_id = NULL, $read_all = FALSE) {
846
+function privatemsg_new(&$form_state, $recipients = array(), $subject = '', $thread_id = null, $read_all = false) {
847 847
   global $user;
848 848
 
849 849
   $recipients_string = '';
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
   $usercount = 0;
864 864
   $to = array();
865 865
   $to_themed = array();
866
-  $blocked = FALSE;
866
+  $blocked = false;
867 867
   foreach ($recipients as $recipient) {
868 868
     if (in_array($recipient->name, $to)) {
869 869
       // We already added the recipient to the list, skip him.
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
     }
885 885
     else {
886 886
       // Recipient list contains blocked users.
887
-      $blocked = TRUE;
887
+      $blocked = true;
888 888
     }
889 889
   }
890 890
 
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
       '#title'              => t('To'),
939 939
       '#description'        => t('Separate multiple names with a space. The number appearing in the suffix is the BOINC id. You can find a user\'s BOINC id on their user profile page.'),
940 940
       '#default_value'      => $recipients_string,
941
-      '#required'           => TRUE,
941
+      '#required'           => true,
942 942
       '#weight'             => -10,
943 943
       '#size'               => 50,
944 944
       '#autocomplete_path'  => 'messages/user-name-autocomplete',
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
     '#rows'               => 6,
960 960
     '#weight'             => 0,
961 961
     '#default_value'      => $body,
962
-    '#resizable'          => TRUE,
962
+    '#resizable'          => true,
963 963
   );
964 964
   $format = FILTER_FORMAT_DEFAULT;
965 965
   // The input filter widget looses the format during preview, specify it
@@ -1013,7 +1013,7 @@  discard block
 block discarded – undo
1013 1013
     );
1014 1014
     if (empty($recipients_string)) {
1015 1015
       // If there are no valid recipients, unset the message reply form.
1016
-      $form['privatemsg']['#access'] = FALSE;
1016
+      $form['privatemsg']['#access'] = false;
1017 1017
     }
1018 1018
   }
1019 1019
   $form['privatemsg']['read_all'] = array(
@@ -1031,7 +1031,7 @@  discard block
 block discarded – undo
1031 1031
   $message['subject'] = trim($message['subject']);
1032 1032
 
1033 1033
 
1034
-  $trimed_body = trim(truncate_utf8(strip_tags($message['body']), 50, TRUE, TRUE));
1034
+  $trimed_body = trim(truncate_utf8(strip_tags($message['body']), 50, true, true));
1035 1035
   if (empty($message['subject']) && !empty($trimed_body)) {
1036 1036
     $message['subject'] = $trimed_body;
1037 1037
   }
@@ -1047,7 +1047,7 @@  discard block
 block discarded – undo
1047 1047
       unset($message['recipients'][$message['author']->uid]);
1048 1048
     }
1049 1049
   }
1050
-  $validated = _privatemsg_validate_message($message, TRUE);
1050
+  $validated = _privatemsg_validate_message($message, true);
1051 1051
   foreach ($validated['messages'] as $type => $text) {
1052 1052
     drupal_set_message($text, $type);
1053 1053
   }
@@ -1133,7 +1133,7 @@  discard block
 block discarded – undo
1133 1133
   foreach ($form_state['validate_built_message']['recipients'] as $recipient) {
1134 1134
     $recipient_names[] = theme('username', $recipient);
1135 1135
   }
1136
-  if ($status !== FALSE )  {
1136
+  if ($status !== false )  {
1137 1137
     drupal_set_message(t('A message has been sent to !recipients.', array('!recipients' => implode(', ', $recipient_names))));
1138 1138
   }
1139 1139
   else {
@@ -1148,7 +1148,7 @@  discard block
 block discarded – undo
1148 1148
       $form_state['privatemsg_preview'] = theme('privatemsg_view', $form_state['validate_built_message']);
1149 1149
     }
1150 1150
 
1151
-  $form_state['rebuild'] = TRUE; // this forces our form to be rebuilt instead of being submitted.
1151
+  $form_state['rebuild'] = true; // this forces our form to be rebuilt instead of being submitted.
1152 1152
 }
1153 1153
 
1154 1154
 /**
@@ -1226,7 +1226,7 @@  discard block
 block discarded – undo
1226 1226
   // tablesort_sql() generates a ORDER BY string. However, the "ORDER BY " part 
1227 1227
   // is not needed and added by the query builder. Discard the first 9
1228 1228
   // characters of the string.
1229
-  $order_by = drupal_substr(tablesort_sql(_privatemsg_list_headers( FALSE, array_merge(array('subject', 'last_updated'), $fields)), $order_by_first), 9);
1229
+  $order_by = drupal_substr(tablesort_sql(_privatemsg_list_headers( false, array_merge(array('subject', 'last_updated'), $fields)), $order_by_first), 9);
1230 1230
   $fragments['order_by'][]  = $order_by;
1231 1231
 }
1232 1232
 
@@ -1240,7 +1240,7 @@  discard block
 block discarded – undo
1240 1240
  * @param $account
1241 1241
  *   Account for which the messages should be loaded.
1242 1242
  */
1243
-function privatemsg_sql_load(&$fragments, $pmids, $account = NULL) {
1243
+function privatemsg_sql_load(&$fragments, $pmids, $account = null) {
1244 1244
   $fragments['primary_table'] = '{pm_message} pm';
1245 1245
 
1246 1246
   $fragments['select'][]      = "pm.mid";
@@ -1276,7 +1276,7 @@  discard block
 block discarded – undo
1276 1276
  * @param $load_all
1277 1277
  *   Deleted messages are only loaded if this is set to TRUE.
1278 1278
  */
1279
-function privatemsg_sql_messages(&$fragments, $threads, $account = NULL, $load_all = FALSE) {
1279
+function privatemsg_sql_messages(&$fragments, $threads, $account = null, $load_all = false) {
1280 1280
   $fragments['primary_table'] = '{pm_index} pmi';
1281 1281
 
1282 1282
   $fragments['select'][]      = 'pmi.mid';
@@ -1446,7 +1446,7 @@  discard block
 block discarded – undo
1446 1446
   drupal_json((object)$matches);
1447 1447
 }
1448 1448
 
1449
-function privatemsg_user($op, &$edit, &$account, $category = NULL) {
1449
+function privatemsg_user($op, &$edit, &$account, $category = null) {
1450 1450
   global $user;
1451 1451
 
1452 1452
   switch ($op) {
@@ -1460,7 +1460,7 @@  discard block
 block discarded – undo
1460 1460
       }
1461 1461
       break;
1462 1462
     case 'login':
1463
-      if (variable_get('privatemsg_display_loginmessage', TRUE) && privatemsg_user_access()) {
1463
+      if (variable_get('privatemsg_display_loginmessage', true) && privatemsg_user_access()) {
1464 1464
         $count = privatemsg_unread_count();
1465 1465
         if ($count) {
1466 1466
           drupal_set_message(format_plural($count, 'You have <a href="@messages">1 unread message</a>.', 'You have <a href="@messages">@count unread messages</a>', array('@messages' => url('messages'))));
@@ -1518,7 +1518,7 @@  discard block
 block discarded – undo
1518 1518
   }
1519 1519
 }
1520 1520
 
1521
-function privatemsg_title_callback($title = NULL) {
1521
+function privatemsg_title_callback($title = null) {
1522 1522
   $count = privatemsg_unread_count();
1523 1523
 
1524 1524
   if ($count > 0) {
@@ -1580,7 +1580,7 @@  discard block
 block discarded – undo
1580 1580
       '#type' => 'checkbox',
1581 1581
       '#title' => t('Delete this message for all users?'),
1582 1582
       '#description' => t('Tick the box to delete the message for all users.'),
1583
-      '#default_value' => FALSE,
1583
+      '#default_value' => false,
1584 1584
     );
1585 1585
   }
1586 1586
   return confirm_form($form,
@@ -1622,9 +1622,9 @@  discard block
 block discarded – undo
1622 1622
  *
1623 1623
  * @ingroup api
1624 1624
  */
1625
-function privatemsg_message_change_delete($pmid, $delete, $account = NULL) {
1625
+function privatemsg_message_change_delete($pmid, $delete, $account = null) {
1626 1626
   $delete_value = 0;
1627
-  if ($delete == TRUE) {
1627
+  if ($delete == true) {
1628 1628
     $delete_value = time();
1629 1629
   }
1630 1630
 
@@ -1676,7 +1676,7 @@  discard block
 block discarded – undo
1676 1676
  *
1677 1677
  * @ingroup api
1678 1678
  */
1679
-function privatemsg_new_thread($recipients, $subject, $body = NULL, $options = array()) {
1679
+function privatemsg_new_thread($recipients, $subject, $body = null, $options = array()) {
1680 1680
   global $user;
1681 1681
   $author = drupal_clone($user);
1682 1682
 
@@ -1782,21 +1782,21 @@  discard block
 block discarded – undo
1782 1782
   return $validated;
1783 1783
 }
1784 1784
 
1785
-function _privatemsg_validate_message(&$message, $form = FALSE) {
1785
+function _privatemsg_validate_message(&$message, $form = false) {
1786 1786
   $messages = array('error' => array(), 'warning' => array());
1787 1787
   if (!privatemsg_user_access('write privatemsg', $message['author'])) {
1788 1788
     // no need to do further checks in this case...
1789 1789
     if ($form) {
1790 1790
       form_set_error('author', t('User @user is not allowed to write messages', array('@user' => $message['author']->name)));
1791 1791
       return array(
1792
-        'success'  => FALSE,
1792
+        'success'  => false,
1793 1793
         'messages'   => $messages,
1794 1794
       );
1795 1795
     }
1796 1796
     else {
1797 1797
       $messages['error'][] = t('User @user is not allowed to write messages', array('@user' => $message['author']->name));
1798 1798
       return array(
1799
-         'success'  => FALSE,
1799
+         'success'  => false,
1800 1800
          'messages'   => $messages,
1801 1801
       );
1802 1802
     }
@@ -1814,7 +1814,7 @@  discard block
 block discarded – undo
1814 1814
   }
1815 1815
 
1816 1816
   // Don't allow replies without a body.
1817
-  if (!empty($message['thread_id']) && ($message['body'] === NULL || $message['body'] === '') ) {
1817
+  if (!empty($message['thread_id']) && ($message['body'] === null || $message['body'] === '') ) {
1818 1818
     if ($form) {
1819 1819
       form_set_error('body', t('Disallowed to send reply without a message.'));
1820 1820
     }
@@ -1826,7 +1826,7 @@  discard block
 block discarded – undo
1826 1826
   // it is not possible to do the check for a specific user.
1827 1827
   global $user;
1828 1828
   $original_user = drupal_clone($user);
1829
-  session_save_session(FALSE);
1829
+  session_save_session(false);
1830 1830
   $user = $message['author'];
1831 1831
 
1832 1832
   if (!filter_access($message['format'])) {
@@ -1839,7 +1839,7 @@  discard block
 block discarded – undo
1839 1839
   }
1840 1840
 
1841 1841
   $user = $original_user;
1842
-  session_save_session(TRUE);
1842
+  session_save_session(true);
1843 1843
 
1844 1844
   if (empty($message['recipients']) || !is_array($message['recipients'])) {
1845 1845
     if ($form) {
@@ -1901,11 +1901,11 @@  discard block
 block discarded – undo
1901 1901
   if (isset($message['read_all']) && $message['read_all']) {
1902 1902
     // The message was sent in read all mode, add the author as recipient to all
1903 1903
     // existing messages.
1904
-    $query_messages = _privatemsg_assemble_query('messages', array($message['thread_id']), NULL);
1904
+    $query_messages = _privatemsg_assemble_query('messages', array($message['thread_id']), null);
1905 1905
     $conversation = db_query($query_messages['query']);
1906 1906
     while ($result = db_fetch_array($conversation)) {
1907 1907
       if (!db_query($index_sql, $result['mid'], $message['thread_id'], $message['author']->uid, 0)) {
1908
-        return FALSE;
1908
+        return false;
1909 1909
       }
1910 1910
     }
1911 1911
   }
@@ -1933,7 +1933,7 @@  discard block
 block discarded – undo
1933 1933
     if (!db_query($index_sql, $mid, $message['thread_id'], $recipient->uid, 1) ) {
1934 1934
       // We assume if one insert failed then the rest may fail too against the
1935 1935
       // same table.
1936
-      return FALSE;
1936
+      return false;
1937 1937
     }
1938 1938
   }
1939 1939
 
@@ -1943,7 +1943,7 @@  discard block
 block discarded – undo
1943 1943
 
1944 1944
   // Also add a record for the author to the pm_index table.
1945 1945
   if (!db_query($index_sql, $mid, $message['thread_id'], $message['author']->uid, $is_new)) {
1946
-    return FALSE;
1946
+    return false;
1947 1947
   }
1948 1948
 
1949 1949
   module_invoke_all('privatemsg_message_insert', $message);
@@ -1968,8 +1968,8 @@  discard block
 block discarded – undo
1968 1968
  *
1969 1969
  * @ingroup api
1970 1970
  */
1971
-function privatemsg_get_link($recipients, $account = array(), $subject = NULL) {
1972
-  if ($account == NULL) {
1971
+function privatemsg_get_link($recipients, $account = array(), $subject = null) {
1972
+  if ($account == null) {
1973 1973
     global $user;
1974 1974
     $account = $user;
1975 1975
   }
@@ -1979,7 +1979,7 @@  discard block
 block discarded – undo
1979 1979
   }
1980 1980
 
1981 1981
   if (!privatemsg_user_access('write privatemsg', $account) || $account->uid == 0) {
1982
-    return FALSE;
1982
+    return false;
1983 1983
   }
1984 1984
 
1985 1985
   $validated = array();
@@ -1993,7 +1993,7 @@  discard block
 block discarded – undo
1993 1993
     $validated[] = $recipient->uid;
1994 1994
   }
1995 1995
   if (empty($validated)) {
1996
-    return FALSE;
1996
+    return false;
1997 1997
   }
1998 1998
   $url = 'messages/new/'. implode(',', $validated);
1999 1999
   if (!is_null($subject)) {
@@ -2013,7 +2013,7 @@  discard block
 block discarded – undo
2013 2013
  *
2014 2014
  * @ingroup api
2015 2015
  */
2016
-function privatemsg_message_load($pmid, $account = NULL) {
2016
+function privatemsg_message_load($pmid, $account = null) {
2017 2017
   $messages = privatemsg_message_load_multiple(array($pmid), $account);
2018 2018
   return current($messages);
2019 2019
 }
@@ -2029,7 +2029,7 @@  discard block
 block discarded – undo
2029 2029
  *
2030 2030
  * @ingroup api
2031 2031
  */
2032
-function privatemsg_message_load_multiple($pmids, $account = NULL) {
2032
+function privatemsg_message_load_multiple($pmids, $account = null) {
2033 2033
   // Avoid SQL error that would happen with an empty pm.mid IN () clause.
2034 2034
   if (empty($pmids)) {
2035 2035
     return array();
@@ -2116,7 +2116,7 @@  discard block
 block discarded – undo
2116 2116
    */
2117 2117
   if (!function_exists($query_function)) {
2118 2118
     drupal_set_message(t('Query function %function does not exist', array('%function' => $query_function)), 'error');
2119
-    return FALSE;
2119
+    return false;
2120 2120
   }
2121 2121
   call_user_func_array($query_function, $alterargs);
2122 2122
 
@@ -2144,7 +2144,7 @@  discard block
 block discarded – undo
2144 2144
   // Perform the whole query assembly only if we have something to select.
2145 2145
   if (!empty($SELECT)) {
2146 2146
     $str_select = implode(", ", $SELECT);
2147
-    $query = "SELECT {$str_select} FROM ". $primary_table;
2147
+    $query = "select {$str_select} FROM ". $primary_table;
2148 2148
 
2149 2149
     // Also build a count query which can be passed to pager_query to get a "page count" as that does not play well with queries including "GROUP BY".
2150 2150
     // In most cases,  "COUNT(*)" is enough to get the count query, but in queries involving a GROUP BY, we want a count of the number of groups we have, not the count of elements inside each group.
@@ -2187,14 +2187,14 @@  discard block
 block discarded – undo
2187 2187
     }
2188 2188
     $QUERY_ARGS = array_merge($QUERY_ARGS['select'], $QUERY_ARGS['join'], $QUERY_ARGS['where'], $QUERY_ARGS['having']);
2189 2189
     if (!empty($QUERY_ARGS)) {
2190
-      _db_query_callback($QUERY_ARGS, TRUE);
2190
+      _db_query_callback($QUERY_ARGS, true);
2191 2191
       $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query);
2192
-      _db_query_callback($QUERY_ARGS, TRUE);
2192
+      _db_query_callback($QUERY_ARGS, true);
2193 2193
       $count = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $count);
2194 2194
     }
2195 2195
     return array('query' => $query, 'count' => $count);
2196 2196
   }
2197
-  return FALSE;
2197
+  return false;
2198 2198
 }
2199 2199
 
2200 2200
 /**
@@ -2216,8 +2216,8 @@  discard block
 block discarded – undo
2216 2216
       '#title'       => t('Actions'),
2217 2217
       '#prefix'      => '<div class="container-inline">',
2218 2218
       '#suffix'      => '</div>',
2219
-      '#collapsible' => TRUE,
2220
-      '#collapsed'   => FALSE,
2219
+      '#collapsible' => true,
2220
+      '#collapsed'   => false,
2221 2221
       '#weight'      => 15,
2222 2222
   );
2223 2223
   if (privatemsg_user_access('delete privatemsg')) {
@@ -2262,7 +2262,7 @@  discard block
 block discarded – undo
2262 2262
  *   User object for which the threads should be deleted, defaults to the
2263 2263
  *   current user.
2264 2264
  */
2265
-function privatemsg_thread_change_status($threads, $status, $account = NULL) {
2265
+function privatemsg_thread_change_status($threads, $status, $account = null) {
2266 2266
   if (!is_array($threads)) {
2267 2267
     $threads = array($threads);
2268 2268
   }
@@ -2506,7 +2506,7 @@  discard block
 block discarded – undo
2506 2506
  *   User object for which the threads should be deleted,
2507 2507
  *   defaults to the current user.
2508 2508
  */
2509
-function privatemsg_thread_change_delete($threads, $delete, $account = NULL) {
2509
+function privatemsg_thread_change_delete($threads, $delete, $account = null) {
2510 2510
   if (!is_array($threads)) {
2511 2511
     $threads = array($threads);
2512 2512
   }
@@ -2519,7 +2519,7 @@  discard block
 block discarded – undo
2519 2519
   $params = array_merge(array($delete, $account->uid), $threads);
2520 2520
 
2521 2521
   // Load all messages of those threads including the deleted.
2522
-  $query = _privatemsg_assemble_query('messages', $threads, $account, TRUE);
2522
+  $query = _privatemsg_assemble_query('messages', $threads, $account, true);
2523 2523
   $result = db_query($query['query']);
2524 2524
 
2525 2525
   // Delete each message. We need to do that to trigger the delete hook.
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/contrib/wysiwyg/editors/ckeditor.inc 5 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
  *   An array containing editor properties as returned from hook_editor().
56 56
  *
57 57
  * @return
58
- *   The installed editor version.
58
+ null|string   The installed editor version.
59 59
  */
60 60
 function wysiwyg_ckeditor_version($editor) {
61 61
   $library = $editor['library path'] . '/ckeditor.js';
Please login to merge, or discard this patch.
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -9,23 +9,23 @@  discard block
 block discarded – undo
9 9
  * Plugin implementation of hook_editor().
10 10
  */
11 11
 function wysiwyg_ckeditor_editor() {
12
-  $editor['ckeditor'] = array(
12
+    $editor['ckeditor'] = array(
13 13
     'title' => 'CKEditor',
14 14
     'vendor url' => 'http://ckeditor.com',
15 15
     'download url' => 'http://ckeditor.com/download',
16 16
     'libraries' => array(
17
-      '' => array(
17
+        '' => array(
18 18
         'title' => 'Default',
19 19
         'files' => array(
20
-          'ckeditor.js' => array('preprocess' => FALSE),
20
+            'ckeditor.js' => array('preprocess' => FALSE),
21 21
         ),
22
-      ),
23
-      'src' => array(
22
+        ),
23
+        'src' => array(
24 24
         'title' => 'Source',
25 25
         'files' => array(
26
-          'ckeditor_source.js' => array('preprocess' => FALSE),
26
+            'ckeditor_source.js' => array('preprocess' => FALSE),
27
+        ),
27 28
         ),
28
-      ),
29 29
     ),
30 30
     'version callback' => 'wysiwyg_ckeditor_version',
31 31
     'themes callback' => 'wysiwyg_ckeditor_themes',
@@ -33,19 +33,19 @@  discard block
 block discarded – undo
33 33
     'plugin callback' => 'wysiwyg_ckeditor_plugins',
34 34
     'plugin settings callback' => 'wysiwyg_ckeditor_plugin_settings',
35 35
     'proxy plugin' => array(
36
-      'drupal' => array(
36
+        'drupal' => array(
37 37
         'load' => TRUE,
38 38
         'proxy' => TRUE,
39
-      ),
39
+        ),
40 40
     ),
41 41
     'proxy plugin settings callback' => 'wysiwyg_ckeditor_proxy_plugin_settings',
42 42
     'versions' => array(
43
-      '3.0.0.3665' => array(
43
+        '3.0.0.3665' => array(
44 44
         'js files' => array('ckeditor-3.0.js'),
45
-      ),
45
+        ),
46 46
     ),
47
-  );
48
-  return $editor;
47
+    );
48
+    return $editor;
49 49
 }
50 50
 
51 51
 /**
@@ -58,25 +58,25 @@  discard block
 block discarded – undo
58 58
  *   The installed editor version.
59 59
  */
60 60
 function wysiwyg_ckeditor_version($editor) {
61
-  $library = $editor['library path'] . '/ckeditor.js';
62
-  if (!file_exists($library)) {
61
+    $library = $editor['library path'] . '/ckeditor.js';
62
+    if (!file_exists($library)) {
63 63
     return;
64
-  }
65
-  $library = fopen($library, 'r');
66
-  $max_lines = 8;
67
-  while ($max_lines && $line = fgets($library, 500)) {
64
+    }
65
+    $library = fopen($library, 'r');
66
+    $max_lines = 8;
67
+    while ($max_lines && $line = fgets($library, 500)) {
68 68
     // version:'CKEditor 3.0 SVN',revision:'3665'
69 69
     // version:'3.0 RC',revision:'3753'
70 70
     // version:'3.0.1',revision:'4391'
71 71
     if (preg_match('@version:\'(?:CKEditor )?([\d\.]+)(?:.+revision:\'([\d]+))?@', $line, $version)) {
72
-      fclose($library);
73
-      // Version numbers need to have three parts since 3.0.1.
74
-      $version[1] = preg_replace('/^(\d+)\.(\d+)$/', '${1}.${2}.0', $version[1]);
75
-      return $version[1] . '.' . $version[2];
72
+        fclose($library);
73
+        // Version numbers need to have three parts since 3.0.1.
74
+        $version[1] = preg_replace('/^(\d+)\.(\d+)$/', '${1}.${2}.0', $version[1]);
75
+        return $version[1] . '.' . $version[2];
76 76
     }
77 77
     $max_lines--;
78
-  }
79
-  fclose($library);
78
+    }
79
+    fclose($library);
80 80
 }
81 81
 
82 82
 /**
@@ -92,23 +92,23 @@  discard block
 block discarded – undo
92 92
  *   theme name.
93 93
  */
94 94
 function wysiwyg_ckeditor_themes($editor, $profile) {
95
-  // @todo Skins are not themes but this will do for now.
96
-  $path = $editor['library path'] . '/skins/';
97
-  if (file_exists($path) && ($dir_handle = opendir($path))) {
95
+    // @todo Skins are not themes but this will do for now.
96
+    $path = $editor['library path'] . '/skins/';
97
+    if (file_exists($path) && ($dir_handle = opendir($path))) {
98 98
     $themes = array();
99 99
     while ($file = readdir($dir_handle)) {
100
-      if (is_dir($path . $file) && substr($file, 0, 1) != '.' && $file != 'CVS') {
100
+        if (is_dir($path . $file) && substr($file, 0, 1) != '.' && $file != 'CVS') {
101 101
         $themes[] = $file;
102
-      }
102
+        }
103 103
     }
104 104
     closedir($dir_handle);
105 105
     natcasesort($themes);
106 106
     $themes = array_values($themes);
107 107
     return !empty($themes) ? $themes : array('default');
108
-  }
109
-  else {
108
+    }
109
+    else {
110 110
     return array('default');
111
-  }
111
+    }
112 112
 }
113 113
 
114 114
 /**
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
  *   Drupal.settings.wysiwyg.configs.{editor}
127 127
  */
128 128
 function wysiwyg_ckeditor_settings($editor, $config, $theme) {
129
-  $settings = array(
129
+    $settings = array(
130 130
     'baseHref' => $GLOBALS['base_url'] . '/',
131 131
     'width' => '100%',
132 132
     // For better compatibility with smaller textareas.
@@ -142,155 +142,155 @@  discard block
 block discarded – undo
142 142
     // @todo Check whether completely disabling ProcessHTMLEntities is an option.
143 143
     'entities_latin' => FALSE,
144 144
     'entities_greek' => FALSE,
145
-  );
145
+    );
146 146
 
147
-  // Add HTML block format settings; common block formats are already predefined
148
-  // by CKEditor.
149
-  if (isset($config['block_formats'])) {
147
+    // Add HTML block format settings; common block formats are already predefined
148
+    // by CKEditor.
149
+    if (isset($config['block_formats'])) {
150 150
     $block_formats = explode(',', drupal_strtolower($config['block_formats']));
151 151
     $predefined_formats = array('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'pre', 'address', 'div');
152 152
     foreach (array_diff($block_formats, $predefined_formats) as $tag) {
153
-      $tag = trim($tag);
154
-      $settings["format_$tag"] = array('element' => $tag);
153
+        $tag = trim($tag);
154
+        $settings["format_$tag"] = array('element' => $tag);
155 155
     }
156 156
     $settings['format_tags'] = implode(';', $block_formats);
157
-  }
157
+    }
158 158
 
159
-  if (isset($config['apply_source_formatting'])) {
159
+    if (isset($config['apply_source_formatting'])) {
160 160
     $settings['apply_source_formatting'] = $config['apply_source_formatting'];
161
-  }
161
+    }
162 162
 
163
-  if (isset($config['css_setting'])) {
163
+    if (isset($config['css_setting'])) {
164 164
     // Versions below 3.0.1 could only handle one stylesheet.
165 165
     if (version_compare($editor['installed version'], '3.0.1.4391', '<')) {
166
-      if ($config['css_setting'] == 'theme') {
166
+        if ($config['css_setting'] == 'theme') {
167 167
         $settings['contentsCss'] = reset(wysiwyg_get_css());
168
-      }
169
-      elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) {
168
+        }
169
+        elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) {
170 170
         $settings['contentsCss'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme()));
171
-      }
171
+        }
172 172
     }
173 173
     else {
174
-      if ($config['css_setting'] == 'theme') {
174
+        if ($config['css_setting'] == 'theme') {
175 175
         $settings['contentsCss'] = wysiwyg_get_css();
176
-      }
177
-      elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) {
176
+        }
177
+        elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) {
178 178
         $settings['contentsCss'] = explode(',', strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme())));
179
-      }
179
+        }
180
+    }
180 181
     }
181
-  }
182 182
 
183
-  if (isset($config['language'])) {
183
+    if (isset($config['language'])) {
184 184
     $settings['language'] = $config['language'];
185
-  }
186
-  if (isset($config['resizing'])) {
185
+    }
186
+    if (isset($config['resizing'])) {
187 187
     // CKEditor tests "!== false", so ensure it is a Boolean.
188 188
     $settings['resize_enabled'] = (bool) $config['resizing'];
189
-  }
190
-  if (isset($config['toolbar_loc'])) {
189
+    }
190
+    if (isset($config['toolbar_loc'])) {
191 191
     $settings['toolbarLocation'] = $config['toolbar_loc'];
192
-  }
192
+    }
193 193
 
194
-  $settings['toolbar'] = array();
195
-  if (!empty($config['buttons'])) {
194
+    $settings['toolbar'] = array();
195
+    if (!empty($config['buttons'])) {
196 196
     $extra_plugins = array();
197 197
     $plugins = wysiwyg_get_plugins($editor['name']);
198 198
     foreach ($config['buttons'] as $plugin => $buttons) {
199
-      foreach ($buttons as $button => $enabled) {
199
+        foreach ($buttons as $button => $enabled) {
200 200
         // Iterate separately over buttons and extensions properties.
201 201
         foreach (array('buttons', 'extensions') as $type) {
202
-          // Skip unavailable plugins.
203
-          if (!isset($plugins[$plugin][$type][$button])) {
202
+            // Skip unavailable plugins.
203
+            if (!isset($plugins[$plugin][$type][$button])) {
204 204
             continue;
205
-          }
206
-          // Add buttons.
207
-          if ($type == 'buttons') {
205
+            }
206
+            // Add buttons.
207
+            if ($type == 'buttons') {
208 208
             $settings['toolbar'][] = $button;
209
-          }
210
-          // Add external Drupal plugins to the list of extensions.
211
-          if ($type == 'buttons' && !empty($plugins[$plugin]['proxy'])) {
209
+            }
210
+            // Add external Drupal plugins to the list of extensions.
211
+            if ($type == 'buttons' && !empty($plugins[$plugin]['proxy'])) {
212 212
             $extra_plugins[] = $button;
213
-          }
214
-          // Add external plugins to the list of extensions.
215
-          elseif ($type == 'buttons' && empty($plugins[$plugin]['internal'])) {
213
+            }
214
+            // Add external plugins to the list of extensions.
215
+            elseif ($type == 'buttons' && empty($plugins[$plugin]['internal'])) {
216 216
             $extra_plugins[] = $plugin;
217
-          }
218
-          // Add internal buttons that also need to be loaded as extension.
219
-          elseif ($type == 'buttons' && !empty($plugins[$plugin]['load'])) {
217
+            }
218
+            // Add internal buttons that also need to be loaded as extension.
219
+            elseif ($type == 'buttons' && !empty($plugins[$plugin]['load'])) {
220 220
             $extra_plugins[] = $plugin;
221
-          }
222
-          // Add plain extensions.
223
-          elseif ($type == 'extensions' && !empty($plugins[$plugin]['load'])) {
221
+            }
222
+            // Add plain extensions.
223
+            elseif ($type == 'extensions' && !empty($plugins[$plugin]['load'])) {
224 224
             $extra_plugins[] = $plugin;
225
-          }
226
-          // Allow plugins to add or override global configuration settings.
227
-          if (!empty($plugins[$plugin]['options'])) {
225
+            }
226
+            // Allow plugins to add or override global configuration settings.
227
+            if (!empty($plugins[$plugin]['options'])) {
228 228
             $settings = array_merge($settings, $plugins[$plugin]['options']);
229
-          }
229
+            }
230
+        }
230 231
         }
231
-      }
232 232
     }
233 233
     if (!empty($extra_plugins)) {
234
-      $settings['extraPlugins'] = implode(',', $extra_plugins);
234
+        $settings['extraPlugins'] = implode(',', $extra_plugins);
235 235
     }
236
-  }
237
-  // For now, all buttons are placed into one row.
238
-  $settings['toolbar'] = array($settings['toolbar']);
236
+    }
237
+    // For now, all buttons are placed into one row.
238
+    $settings['toolbar'] = array($settings['toolbar']);
239 239
 
240
-  return $settings;
240
+    return $settings;
241 241
 }
242 242
 
243 243
 /**
244 244
  * Build a JS settings array of native external plugins that need to be loaded separately.
245 245
  */
246 246
 function wysiwyg_ckeditor_plugin_settings($editor, $profile, $plugins) {
247
-  $settings = array();
248
-  foreach ($plugins as $name => $plugin) {
247
+    $settings = array();
248
+    foreach ($plugins as $name => $plugin) {
249 249
     // Register all plugins that need to be loaded.
250 250
     if (!empty($plugin['load'])) {
251
-      $settings[$name] = array();
252
-      // Add path for native external plugins.
253
-      if (empty($plugin['internal']) && isset($plugin['path'])) {
251
+        $settings[$name] = array();
252
+        // Add path for native external plugins.
253
+        if (empty($plugin['internal']) && isset($plugin['path'])) {
254 254
         $settings[$name]['path'] = base_path() . $plugin['path'] . '/';
255
-      }
256
-      // Force native internal plugins to use the standard path.
257
-      else {
255
+        }
256
+        // Force native internal plugins to use the standard path.
257
+        else {
258 258
         $settings[$name]['path'] = base_path() . $editor['library path'] . '/plugins/' . $name . '/';
259
-      }
260
-      // CKEditor defaults to 'plugin.js' on its own when filename is not set.
261
-      if (!empty($plugin['filename'])) {
259
+        }
260
+        // CKEditor defaults to 'plugin.js' on its own when filename is not set.
261
+        if (!empty($plugin['filename'])) {
262 262
         $settings[$name]['fileName'] = $plugin['filename'];
263
-      }
263
+        }
264 264
     }
265
-  }
266
-  return $settings;
265
+    }
266
+    return $settings;
267 267
 }
268 268
 
269 269
 /**
270 270
  * Build a JS settings array for Drupal plugins loaded via the proxy plugin.
271 271
  */
272 272
 function wysiwyg_ckeditor_proxy_plugin_settings($editor, $profile, $plugins) {
273
-  $settings = array();
274
-  foreach ($plugins as $name => $plugin) {
273
+    $settings = array();
274
+    foreach ($plugins as $name => $plugin) {
275 275
     // Populate required plugin settings.
276 276
     $settings[$name] = $plugin['dialog settings'] + array(
277
-      'title' => $plugin['title'],
278
-      'icon' => base_path() . $plugin['icon path'] . '/' . $plugin['icon file'],
279
-      'iconTitle' => $plugin['icon title'],
280
-      // @todo These should only be set if the plugin defined them.
281
-      'css' => base_path() . $plugin['css path'] . '/' . $plugin['css file'],
277
+        'title' => $plugin['title'],
278
+        'icon' => base_path() . $plugin['icon path'] . '/' . $plugin['icon file'],
279
+        'iconTitle' => $plugin['icon title'],
280
+        // @todo These should only be set if the plugin defined them.
281
+        'css' => base_path() . $plugin['css path'] . '/' . $plugin['css file'],
282 282
     );
283
-  }
284
-  return $settings;
283
+    }
284
+    return $settings;
285 285
 }
286 286
 
287 287
 /**
288 288
  * Return internal plugins for this editor; semi-implementation of hook_wysiwyg_plugin().
289 289
  */
290 290
 function wysiwyg_ckeditor_plugins($editor) {
291
-  $plugins = array(
291
+    $plugins = array(
292 292
     'default' => array(
293
-      'buttons' => array(
293
+        'buttons' => array(
294 294
         'Bold' => t('Bold'), 'Italic' => t('Italic'), 'Underline' => t('Underline'),
295 295
         'Strike' => t('Strike-through'),
296 296
         'JustifyLeft' => t('Align left'), 'JustifyCenter' => t('Align center'), 'JustifyRight' => t('Align right'), 'JustifyBlock' => t('Justify'),
@@ -317,17 +317,17 @@  discard block
 block discarded – undo
317 317
         'Maximize' => t('Maximize'),
318 318
         'SpellChecker' => t('Check spelling'), 'Scayt' => t('Check spelling as you type'),
319 319
         'About' => t('About'),
320
-      ),
321
-      'internal' => TRUE,
320
+        ),
321
+        'internal' => TRUE,
322 322
     ),
323
-  );
323
+    );
324 324
 
325
-  if (version_compare($editor['installed version'], '3.1.0.4885', '<')) {
325
+    if (version_compare($editor['installed version'], '3.1.0.4885', '<')) {
326 326
     unset($plugins['default']['buttons']['CreateDiv']);
327
-  }
328
-  if (version_compare($editor['installed version'], '3.5.0.6260', '<')) {
327
+    }
328
+    if (version_compare($editor['installed version'], '3.5.0.6260', '<')) {
329 329
     unset($plugins['default']['buttons']['Iframe']);
330
-  }
331
-  return $plugins;
330
+    }
331
+    return $plugins;
332 332
 }
333 333
 
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
  *   The installed editor version.
59 59
  */
60 60
 function wysiwyg_ckeditor_version($editor) {
61
-  $library = $editor['library path'] . '/ckeditor.js';
61
+  $library = $editor['library path'].'/ckeditor.js';
62 62
   if (!file_exists($library)) {
63 63
     return;
64 64
   }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
       fclose($library);
73 73
       // Version numbers need to have three parts since 3.0.1.
74 74
       $version[1] = preg_replace('/^(\d+)\.(\d+)$/', '${1}.${2}.0', $version[1]);
75
-      return $version[1] . '.' . $version[2];
75
+      return $version[1].'.'.$version[2];
76 76
     }
77 77
     $max_lines--;
78 78
   }
@@ -93,11 +93,11 @@  discard block
 block discarded – undo
93 93
  */
94 94
 function wysiwyg_ckeditor_themes($editor, $profile) {
95 95
   // @todo Skins are not themes but this will do for now.
96
-  $path = $editor['library path'] . '/skins/';
96
+  $path = $editor['library path'].'/skins/';
97 97
   if (file_exists($path) && ($dir_handle = opendir($path))) {
98 98
     $themes = array();
99 99
     while ($file = readdir($dir_handle)) {
100
-      if (is_dir($path . $file) && substr($file, 0, 1) != '.' && $file != 'CVS') {
100
+      if (is_dir($path.$file) && substr($file, 0, 1) != '.' && $file != 'CVS') {
101 101
         $themes[] = $file;
102 102
       }
103 103
     }
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
  */
128 128
 function wysiwyg_ckeditor_settings($editor, $config, $theme) {
129 129
   $settings = array(
130
-    'baseHref' => $GLOBALS['base_url'] . '/',
130
+    'baseHref' => $GLOBALS['base_url'].'/',
131 131
     'width' => '100%',
132 132
     // For better compatibility with smaller textareas.
133 133
     'resize_minWidth' => 450,
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
   }
186 186
   if (isset($config['resizing'])) {
187 187
     // CKEditor tests "!== false", so ensure it is a Boolean.
188
-    $settings['resize_enabled'] = (bool) $config['resizing'];
188
+    $settings['resize_enabled'] = (bool)$config['resizing'];
189 189
   }
190 190
   if (isset($config['toolbar_loc'])) {
191 191
     $settings['toolbarLocation'] = $config['toolbar_loc'];
@@ -251,11 +251,11 @@  discard block
 block discarded – undo
251 251
       $settings[$name] = array();
252 252
       // Add path for native external plugins.
253 253
       if (empty($plugin['internal']) && isset($plugin['path'])) {
254
-        $settings[$name]['path'] = base_path() . $plugin['path'] . '/';
254
+        $settings[$name]['path'] = base_path().$plugin['path'].'/';
255 255
       }
256 256
       // Force native internal plugins to use the standard path.
257 257
       else {
258
-        $settings[$name]['path'] = base_path() . $editor['library path'] . '/plugins/' . $name . '/';
258
+        $settings[$name]['path'] = base_path().$editor['library path'].'/plugins/'.$name.'/';
259 259
       }
260 260
       // CKEditor defaults to 'plugin.js' on its own when filename is not set.
261 261
       if (!empty($plugin['filename'])) {
@@ -275,10 +275,10 @@  discard block
 block discarded – undo
275 275
     // Populate required plugin settings.
276 276
     $settings[$name] = $plugin['dialog settings'] + array(
277 277
       'title' => $plugin['title'],
278
-      'icon' => base_path() . $plugin['icon path'] . '/' . $plugin['icon file'],
278
+      'icon' => base_path().$plugin['icon path'].'/'.$plugin['icon file'],
279 279
       'iconTitle' => $plugin['icon title'],
280 280
       // @todo These should only be set if the plugin defined them.
281
-      'css' => base_path() . $plugin['css path'] . '/' . $plugin['css file'],
281
+      'css' => base_path().$plugin['css path'].'/'.$plugin['css file'],
282 282
     );
283 283
   }
284 284
   return $settings;
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -105,8 +105,7 @@  discard block
 block discarded – undo
105 105
     natcasesort($themes);
106 106
     $themes = array_values($themes);
107 107
     return !empty($themes) ? $themes : array('default');
108
-  }
109
-  else {
108
+  } else {
110 109
     return array('default');
111 110
   }
112 111
 }
@@ -165,16 +164,13 @@  discard block
 block discarded – undo
165 164
     if (version_compare($editor['installed version'], '3.0.1.4391', '<')) {
166 165
       if ($config['css_setting'] == 'theme') {
167 166
         $settings['contentsCss'] = reset(wysiwyg_get_css());
168
-      }
169
-      elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) {
167
+      } elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) {
170 168
         $settings['contentsCss'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme()));
171 169
       }
172
-    }
173
-    else {
170
+    } else {
174 171
       if ($config['css_setting'] == 'theme') {
175 172
         $settings['contentsCss'] = wysiwyg_get_css();
176
-      }
177
-      elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) {
173
+      } elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) {
178 174
         $settings['contentsCss'] = explode(',', strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme())));
179 175
       }
180 176
     }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -17,13 +17,13 @@  discard block
 block discarded – undo
17 17
       '' => array(
18 18
         'title' => 'Default',
19 19
         'files' => array(
20
-          'ckeditor.js' => array('preprocess' => FALSE),
20
+          'ckeditor.js' => array('preprocess' => false),
21 21
         ),
22 22
       ),
23 23
       'src' => array(
24 24
         'title' => 'Source',
25 25
         'files' => array(
26
-          'ckeditor_source.js' => array('preprocess' => FALSE),
26
+          'ckeditor_source.js' => array('preprocess' => false),
27 27
         ),
28 28
       ),
29 29
     ),
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
     'plugin settings callback' => 'wysiwyg_ckeditor_plugin_settings',
35 35
     'proxy plugin' => array(
36 36
       'drupal' => array(
37
-        'load' => TRUE,
38
-        'proxy' => TRUE,
37
+        'load' => true,
38
+        'proxy' => true,
39 39
       ),
40 40
     ),
41 41
     'proxy plugin settings callback' => 'wysiwyg_ckeditor_proxy_plugin_settings',
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
     // disable at least the additional character sets. CKEditor always converts
141 141
     // XML default characters '&', '<', '>'.
142 142
     // @todo Check whether completely disabling ProcessHTMLEntities is an option.
143
-    'entities_latin' => FALSE,
144
-    'entities_greek' => FALSE,
143
+    'entities_latin' => false,
144
+    'entities_greek' => false,
145 145
   );
146 146
 
147 147
   // Add HTML block format settings; common block formats are already predefined
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
         'SpellChecker' => t('Check spelling'), 'Scayt' => t('Check spelling as you type'),
319 319
         'About' => t('About'),
320 320
       ),
321
-      'internal' => TRUE,
321
+      'internal' => true,
322 322
     ),
323 323
   );
324 324
 
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/contrib/wysiwyg/editors/fckeditor.inc 5 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
  *   An array containing editor properties as returned from hook_editor().
48 48
  *
49 49
  * @return
50
- *   The installed editor version.
50
+ null|string   The installed editor version.
51 51
  */
52 52
 function wysiwyg_fckeditor_version($editor) {
53 53
   $library = $editor['library path'] . '/fckeditor.js';
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
  *   A wysiwyg editor profile.
76 76
  *
77 77
  * @return
78
- *   An array of theme names. The first returned name should be the default
78
+ string[]   An array of theme names. The first returned name should be the default
79 79
  *   theme name.
80 80
  */
81 81
 function wysiwyg_fckeditor_themes($editor, $profile) {
Please login to merge, or discard this patch.
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -9,15 +9,15 @@  discard block
 block discarded – undo
9 9
  * Plugin implementation of hook_editor().
10 10
  */
11 11
 function wysiwyg_fckeditor_editor() {
12
-  $editor['fckeditor'] = array(
12
+    $editor['fckeditor'] = array(
13 13
     'title' => 'FCKeditor',
14 14
     'vendor url' => 'http://www.fckeditor.net',
15 15
     'download url' => 'http://www.fckeditor.net/download',
16 16
     'libraries' => array(
17
-      '' => array(
17
+        '' => array(
18 18
         'title' => 'Default',
19 19
         'files' => array('fckeditor.js'),
20
-      ),
20
+        ),
21 21
     ),
22 22
     'version callback' => 'wysiwyg_fckeditor_version',
23 23
     'themes callback' => 'wysiwyg_fckeditor_themes',
@@ -25,19 +25,19 @@  discard block
 block discarded – undo
25 25
     'plugin callback' => 'wysiwyg_fckeditor_plugins',
26 26
     'plugin settings callback' => 'wysiwyg_fckeditor_plugin_settings',
27 27
     'proxy plugin' => array(
28
-      'drupal' => array(
28
+        'drupal' => array(
29 29
         'load' => TRUE,
30 30
         'proxy' => TRUE,
31
-      ),
31
+        ),
32 32
     ),
33 33
     'proxy plugin settings callback' => 'wysiwyg_fckeditor_proxy_plugin_settings',
34 34
     'versions' => array(
35
-      '2.6' => array(
35
+        '2.6' => array(
36 36
         'js files' => array('fckeditor-2.6.js'),
37
-      ),
37
+        ),
38 38
     ),
39
-  );
40
-  return $editor;
39
+    );
40
+    return $editor;
41 41
 }
42 42
 
43 43
 /**
@@ -50,20 +50,20 @@  discard block
 block discarded – undo
50 50
  *   The installed editor version.
51 51
  */
52 52
 function wysiwyg_fckeditor_version($editor) {
53
-  $library = $editor['library path'] . '/fckeditor.js';
54
-  if (!file_exists($library)) {
53
+    $library = $editor['library path'] . '/fckeditor.js';
54
+    if (!file_exists($library)) {
55 55
     return;
56
-  }
57
-  $library = fopen($library, 'r');
58
-  $max_lines = 100;
59
-  while ($max_lines && $line = fgets($library, 60)) {
56
+    }
57
+    $library = fopen($library, 'r');
58
+    $max_lines = 100;
59
+    while ($max_lines && $line = fgets($library, 60)) {
60 60
     if (preg_match('@^FCKeditor.prototype.Version\s*= \'([\d\.]+)@', $line, $version)) {
61
-      fclose($library);
62
-      return $version[1];
61
+        fclose($library);
62
+        return $version[1];
63 63
     }
64 64
     $max_lines--;
65
-  }
66
-  fclose($library);
65
+    }
66
+    fclose($library);
67 67
 }
68 68
 
69 69
 /**
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
  *   theme name.
80 80
  */
81 81
 function wysiwyg_fckeditor_themes($editor, $profile) {
82
-  return array('default', 'office2003', 'silver');
82
+    return array('default', 'office2003', 'silver');
83 83
 }
84 84
 
85 85
 /**
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
  *   Drupal.settings.wysiwyg.configs.{editor}
98 98
  */
99 99
 function wysiwyg_fckeditor_settings($editor, $config, $theme) {
100
-  $settings = array(
100
+    $settings = array(
101 101
     'EditorPath' => base_path() . $editor['library path'] . '/',
102 102
     'SkinPath' => base_path() . $editor['library path'] . '/editor/skins/' . $theme . '/',
103 103
     'CustomConfigurationsPath' => base_path() . drupal_get_path('module', 'wysiwyg') . '/editors/js/fckeditor.config.js',
@@ -116,105 +116,105 @@  discard block
 block discarded – undo
116 116
     // @todo Check whether completely disabling ProcessHTMLEntities is an option.
117 117
     'IncludeLatinEntities' => FALSE,
118 118
     'IncludeGreekEntities' => FALSE,
119
-  );
120
-  if (isset($config['block_formats'])) {
119
+    );
120
+    if (isset($config['block_formats'])) {
121 121
     $settings['FontFormats'] = strtr($config['block_formats'], array(',' => ';'));
122
-  }
123
-  if (isset($config['apply_source_formatting'])) {
122
+    }
123
+    if (isset($config['apply_source_formatting'])) {
124 124
     $settings['FormatOutput'] = $settings['FormatSource'] = $config['apply_source_formatting'];
125
-  }
126
-  if (isset($config['paste_auto_cleanup_on_paste'])) {
125
+    }
126
+    if (isset($config['paste_auto_cleanup_on_paste'])) {
127 127
     $settings['AutoDetectPasteFromWord'] = $config['paste_auto_cleanup_on_paste'];
128
-  }
128
+    }
129 129
 
130
-  if (isset($config['css_setting'])) {
130
+    if (isset($config['css_setting'])) {
131 131
     if ($config['css_setting'] == 'theme') {
132
-      $settings['EditorAreaCSS'] = implode(',', wysiwyg_get_css());
132
+        $settings['EditorAreaCSS'] = implode(',', wysiwyg_get_css());
133 133
     }
134 134
     else if ($config['css_setting'] == 'self' && isset($config['css_path'])) {
135
-      $settings['EditorAreaCSS'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme()));
135
+        $settings['EditorAreaCSS'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme()));
136
+    }
136 137
     }
137
-  }
138 138
 
139
-  // Use our custom toolbar set.
140
-  $settings['ToolbarSet'] = 'Wysiwyg';
141
-  // Populate our custom toolbar set for fckeditor.config.js.
142
-  $settings['buttons'] = array();
143
-  if (!empty($config['buttons'])) {
139
+    // Use our custom toolbar set.
140
+    $settings['ToolbarSet'] = 'Wysiwyg';
141
+    // Populate our custom toolbar set for fckeditor.config.js.
142
+    $settings['buttons'] = array();
143
+    if (!empty($config['buttons'])) {
144 144
     $plugins = wysiwyg_get_plugins($editor['name']);
145 145
     foreach ($config['buttons'] as $plugin => $buttons) {
146
-      foreach ($buttons as $button => $enabled) {
146
+        foreach ($buttons as $button => $enabled) {
147 147
         // Iterate separately over buttons and extensions properties.
148 148
         foreach (array('buttons', 'extensions') as $type) {
149
-          // Skip unavailable plugins.
150
-          if (!isset($plugins[$plugin][$type][$button])) {
149
+            // Skip unavailable plugins.
150
+            if (!isset($plugins[$plugin][$type][$button])) {
151 151
             continue;
152
-          }
153
-          // Add buttons.
154
-          if ($type == 'buttons') {
152
+            }
153
+            // Add buttons.
154
+            if ($type == 'buttons') {
155 155
             $settings['buttons'][] = $button;
156
-          }
157
-          // Allow plugins to add or override global configuration settings.
158
-          if (!empty($plugins[$plugin]['options'])) {
156
+            }
157
+            // Allow plugins to add or override global configuration settings.
158
+            if (!empty($plugins[$plugin]['options'])) {
159 159
             $settings = array_merge($settings, $plugins[$plugin]['options']);
160
-          }
160
+            }
161 161
         }
162
-      }
162
+        }
163
+    }
163 164
     }
164
-  }
165
-  // For now, all buttons are placed into one row.
166
-  $settings['buttons'] = array($settings['buttons']);
165
+    // For now, all buttons are placed into one row.
166
+    $settings['buttons'] = array($settings['buttons']);
167 167
 
168
-  return $settings;
168
+    return $settings;
169 169
 }
170 170
 
171 171
 /**
172 172
  * Build a JS settings array of native external plugins that need to be loaded separately.
173 173
  */
174 174
 function wysiwyg_fckeditor_plugin_settings($editor, $profile, $plugins) {
175
-  $settings = array();
176
-  foreach ($plugins as $name => $plugin) {
175
+    $settings = array();
176
+    foreach ($plugins as $name => $plugin) {
177 177
     // Register all plugins that need to be loaded.
178 178
     if (!empty($plugin['load'])) {
179
-      $settings[$name] = array();
180
-      // Add path for native external plugins; internal ones do not need a path.
181
-      if (empty($plugin['internal']) && isset($plugin['path'])) {
179
+        $settings[$name] = array();
180
+        // Add path for native external plugins; internal ones do not need a path.
181
+        if (empty($plugin['internal']) && isset($plugin['path'])) {
182 182
         // All native FCKeditor plugins use the filename fckplugin.js.
183 183
         $settings[$name]['path'] = base_path() . $plugin['path'] . '/';
184
-      }
185
-      if (!empty($plugin['languages'])) {
184
+        }
185
+        if (!empty($plugin['languages'])) {
186 186
         $settings[$name]['languages'] = $plugin['languages'];
187
-      }
187
+        }
188
+    }
188 189
     }
189
-  }
190
-  return $settings;
190
+    return $settings;
191 191
 }
192 192
 
193 193
 /**
194 194
  * Build a JS settings array for Drupal plugins loaded via the proxy plugin.
195 195
  */
196 196
 function wysiwyg_fckeditor_proxy_plugin_settings($editor, $profile, $plugins) {
197
-  $settings = array();
198
-  foreach ($plugins as $name => $plugin) {
197
+    $settings = array();
198
+    foreach ($plugins as $name => $plugin) {
199 199
     // Populate required plugin settings.
200 200
     $settings[$name] = $plugin['dialog settings'] + array(
201
-      'title' => $plugin['title'],
202
-      'icon' => base_path() . $plugin['icon path'] . '/' . $plugin['icon file'],
203
-      'iconTitle' => $plugin['icon title'],
204
-      // @todo These should only be set if the plugin defined them.
205
-      'css' => base_path() . $plugin['css path'] . '/' . $plugin['css file'],
201
+        'title' => $plugin['title'],
202
+        'icon' => base_path() . $plugin['icon path'] . '/' . $plugin['icon file'],
203
+        'iconTitle' => $plugin['icon title'],
204
+        // @todo These should only be set if the plugin defined them.
205
+        'css' => base_path() . $plugin['css path'] . '/' . $plugin['css file'],
206 206
     );
207
-  }
208
-  return $settings;
207
+    }
208
+    return $settings;
209 209
 }
210 210
 
211 211
 /**
212 212
  * Return internal plugins for this editor; semi-implementation of hook_wysiwyg_plugin().
213 213
  */
214 214
 function wysiwyg_fckeditor_plugins($editor) {
215
-  $plugins = array(
215
+    $plugins = array(
216 216
     'default' => array(
217
-      'buttons' => array(
217
+        'buttons' => array(
218 218
         'Bold' => t('Bold'), 'Italic' => t('Italic'), 'Underline' => t('Underline'),
219 219
         'StrikeThrough' => t('Strike-through'),
220 220
         'JustifyLeft' => t('Align left'), 'JustifyCenter' => t('Align center'), 'JustifyRight' => t('Align right'), 'JustifyFull' => t('Justify'),
@@ -240,39 +240,39 @@  discard block
 block discarded – undo
240 240
         'Flash' => t('Flash'), 'Smiley' => t('Smiley'),
241 241
         'FitWindow' => t('FitWindow'),
242 242
         'SpellCheck' => t('Check spelling'),
243
-      ),
244
-      'internal' => TRUE,
243
+        ),
244
+        'internal' => TRUE,
245 245
     ),
246 246
     'autogrow' => array(
247
-      'path' => $editor['library path'] . '/editor/plugins',
248
-      'extensions' => array(
247
+        'path' => $editor['library path'] . '/editor/plugins',
248
+        'extensions' => array(
249 249
         'autogrow' => t('Autogrow'),
250
-      ),
251
-      'options' => array(
250
+        ),
251
+        'options' => array(
252 252
         'AutoGrowMax' => 800,
253
-      ),
254
-      'internal' => TRUE,
255
-      'load' => TRUE,
253
+        ),
254
+        'internal' => TRUE,
255
+        'load' => TRUE,
256 256
     ),
257 257
     'bbcode' => array(
258
-      'path' => $editor['library path'] . '/editor/plugins',
259
-      'extensions' => array(
258
+        'path' => $editor['library path'] . '/editor/plugins',
259
+        'extensions' => array(
260 260
         'bbcode' => t('BBCode'),
261
-      ),
262
-      'internal' => TRUE,
263
-      'load' => TRUE,
261
+        ),
262
+        'internal' => TRUE,
263
+        'load' => TRUE,
264 264
     ),
265 265
     'dragresizetable' => array(
266
-      'path' => $editor['library path'] . '/editor/plugins',
267
-      'extensions' => array(
266
+        'path' => $editor['library path'] . '/editor/plugins',
267
+        'extensions' => array(
268 268
         'dragresizetable' => t('Table drag/resize'),
269
-      ),
270
-      'internal' => TRUE,
271
-      'load' => TRUE,
269
+        ),
270
+        'internal' => TRUE,
271
+        'load' => TRUE,
272 272
     ),
273 273
     'tablecommands' => array(
274
-      'path' => $editor['library path'] . '/editor/plugins',
275
-      'buttons' => array(
274
+        'path' => $editor['library path'] . '/editor/plugins',
275
+        'buttons' => array(
276 276
         'TableCellProp' => t('Table: Cell properties'),
277 277
         'TableInsertRowAfter' => t('Table: Insert row after'),
278 278
         'TableInsertColumnAfter' => t('Table: Insert column after'),
@@ -282,11 +282,11 @@  discard block
 block discarded – undo
282 282
         'TableDeleteCells' => t('Table: Delete cells'),
283 283
         'TableMergeCells' => t('Table: Merge cells'),
284 284
         'TableHorizontalSplitCell' => t('Table: Horizontal split cell'),
285
-      ),
286
-      'internal' => TRUE,
287
-      'load' => TRUE,
285
+        ),
286
+        'internal' => TRUE,
287
+        'load' => TRUE,
288 288
     ),
289
-  );
290
-  return $plugins;
289
+    );
290
+    return $plugins;
291 291
 }
292 292
 
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
  *   The installed editor version.
51 51
  */
52 52
 function wysiwyg_fckeditor_version($editor) {
53
-  $library = $editor['library path'] . '/fckeditor.js';
53
+  $library = $editor['library path'].'/fckeditor.js';
54 54
   if (!file_exists($library)) {
55 55
     return;
56 56
   }
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
  */
99 99
 function wysiwyg_fckeditor_settings($editor, $config, $theme) {
100 100
   $settings = array(
101
-    'EditorPath' => base_path() . $editor['library path'] . '/',
102
-    'SkinPath' => base_path() . $editor['library path'] . '/editor/skins/' . $theme . '/',
103
-    'CustomConfigurationsPath' => base_path() . drupal_get_path('module', 'wysiwyg') . '/editors/js/fckeditor.config.js',
101
+    'EditorPath' => base_path().$editor['library path'].'/',
102
+    'SkinPath' => base_path().$editor['library path'].'/editor/skins/'.$theme.'/',
103
+    'CustomConfigurationsPath' => base_path().drupal_get_path('module', 'wysiwyg').'/editors/js/fckeditor.config.js',
104 104
     'Width' => '100%',
105 105
     'Height' => 420,
106 106
     'LinkBrowser' => FALSE,
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
       // Add path for native external plugins; internal ones do not need a path.
181 181
       if (empty($plugin['internal']) && isset($plugin['path'])) {
182 182
         // All native FCKeditor plugins use the filename fckplugin.js.
183
-        $settings[$name]['path'] = base_path() . $plugin['path'] . '/';
183
+        $settings[$name]['path'] = base_path().$plugin['path'].'/';
184 184
       }
185 185
       if (!empty($plugin['languages'])) {
186 186
         $settings[$name]['languages'] = $plugin['languages'];
@@ -199,10 +199,10 @@  discard block
 block discarded – undo
199 199
     // Populate required plugin settings.
200 200
     $settings[$name] = $plugin['dialog settings'] + array(
201 201
       'title' => $plugin['title'],
202
-      'icon' => base_path() . $plugin['icon path'] . '/' . $plugin['icon file'],
202
+      'icon' => base_path().$plugin['icon path'].'/'.$plugin['icon file'],
203 203
       'iconTitle' => $plugin['icon title'],
204 204
       // @todo These should only be set if the plugin defined them.
205
-      'css' => base_path() . $plugin['css path'] . '/' . $plugin['css file'],
205
+      'css' => base_path().$plugin['css path'].'/'.$plugin['css file'],
206 206
     );
207 207
   }
208 208
   return $settings;
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
       'internal' => TRUE,
245 245
     ),
246 246
     'autogrow' => array(
247
-      'path' => $editor['library path'] . '/editor/plugins',
247
+      'path' => $editor['library path'].'/editor/plugins',
248 248
       'extensions' => array(
249 249
         'autogrow' => t('Autogrow'),
250 250
       ),
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
       'load' => TRUE,
256 256
     ),
257 257
     'bbcode' => array(
258
-      'path' => $editor['library path'] . '/editor/plugins',
258
+      'path' => $editor['library path'].'/editor/plugins',
259 259
       'extensions' => array(
260 260
         'bbcode' => t('BBCode'),
261 261
       ),
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
       'load' => TRUE,
264 264
     ),
265 265
     'dragresizetable' => array(
266
-      'path' => $editor['library path'] . '/editor/plugins',
266
+      'path' => $editor['library path'].'/editor/plugins',
267 267
       'extensions' => array(
268 268
         'dragresizetable' => t('Table drag/resize'),
269 269
       ),
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
       'load' => TRUE,
272 272
     ),
273 273
     'tablecommands' => array(
274
-      'path' => $editor['library path'] . '/editor/plugins',
274
+      'path' => $editor['library path'].'/editor/plugins',
275 275
       'buttons' => array(
276 276
         'TableCellProp' => t('Table: Cell properties'),
277 277
         'TableInsertRowAfter' => t('Table: Insert row after'),
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -130,8 +130,7 @@
 block discarded – undo
130 130
   if (isset($config['css_setting'])) {
131 131
     if ($config['css_setting'] == 'theme') {
132 132
       $settings['EditorAreaCSS'] = implode(',', wysiwyg_get_css());
133
-    }
134
-    else if ($config['css_setting'] == 'self' && isset($config['css_path'])) {
133
+    } else if ($config['css_setting'] == 'self' && isset($config['css_path'])) {
135 134
       $settings['EditorAreaCSS'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme()));
136 135
     }
137 136
   }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
     'plugin settings callback' => 'wysiwyg_fckeditor_plugin_settings',
27 27
     'proxy plugin' => array(
28 28
       'drupal' => array(
29
-        'load' => TRUE,
30
-        'proxy' => TRUE,
29
+        'load' => true,
30
+        'proxy' => true,
31 31
       ),
32 32
     ),
33 33
     'proxy plugin settings callback' => 'wysiwyg_fckeditor_proxy_plugin_settings',
@@ -103,19 +103,19 @@  discard block
 block discarded – undo
103 103
     'CustomConfigurationsPath' => base_path() . drupal_get_path('module', 'wysiwyg') . '/editors/js/fckeditor.config.js',
104 104
     'Width' => '100%',
105 105
     'Height' => 420,
106
-    'LinkBrowser' => FALSE,
107
-    'LinkUpload' => FALSE,
108
-    'ImageBrowser' => FALSE,
109
-    'ImageUpload' => FALSE,
110
-    'FlashBrowser' => FALSE,
111
-    'FlashUpload' => FALSE,
106
+    'LinkBrowser' => false,
107
+    'LinkUpload' => false,
108
+    'ImageBrowser' => false,
109
+    'ImageUpload' => false,
110
+    'FlashBrowser' => false,
111
+    'FlashUpload' => false,
112 112
     // By default, FCKeditor converts most characters into HTML entities. Since
113 113
     // it does not support a custom definition, but Drupal supports Unicode, we
114 114
     // disable at least the additional character sets. FCKeditor always converts
115 115
     // XML default characters '&', '<', '>'.
116 116
     // @todo Check whether completely disabling ProcessHTMLEntities is an option.
117
-    'IncludeLatinEntities' => FALSE,
118
-    'IncludeGreekEntities' => FALSE,
117
+    'IncludeLatinEntities' => false,
118
+    'IncludeGreekEntities' => false,
119 119
   );
120 120
   if (isset($config['block_formats'])) {
121 121
     $settings['FontFormats'] = strtr($config['block_formats'], array(',' => ';'));
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
         'FitWindow' => t('FitWindow'),
242 242
         'SpellCheck' => t('Check spelling'),
243 243
       ),
244
-      'internal' => TRUE,
244
+      'internal' => true,
245 245
     ),
246 246
     'autogrow' => array(
247 247
       'path' => $editor['library path'] . '/editor/plugins',
@@ -251,24 +251,24 @@  discard block
 block discarded – undo
251 251
       'options' => array(
252 252
         'AutoGrowMax' => 800,
253 253
       ),
254
-      'internal' => TRUE,
255
-      'load' => TRUE,
254
+      'internal' => true,
255
+      'load' => true,
256 256
     ),
257 257
     'bbcode' => array(
258 258
       'path' => $editor['library path'] . '/editor/plugins',
259 259
       'extensions' => array(
260 260
         'bbcode' => t('BBCode'),
261 261
       ),
262
-      'internal' => TRUE,
263
-      'load' => TRUE,
262
+      'internal' => true,
263
+      'load' => true,
264 264
     ),
265 265
     'dragresizetable' => array(
266 266
       'path' => $editor['library path'] . '/editor/plugins',
267 267
       'extensions' => array(
268 268
         'dragresizetable' => t('Table drag/resize'),
269 269
       ),
270
-      'internal' => TRUE,
271
-      'load' => TRUE,
270
+      'internal' => true,
271
+      'load' => true,
272 272
     ),
273 273
     'tablecommands' => array(
274 274
       'path' => $editor['library path'] . '/editor/plugins',
@@ -283,8 +283,8 @@  discard block
 block discarded – undo
283 283
         'TableMergeCells' => t('Table: Merge cells'),
284 284
         'TableHorizontalSplitCell' => t('Table: Horizontal split cell'),
285 285
       ),
286
-      'internal' => TRUE,
287
-      'load' => TRUE,
286
+      'internal' => true,
287
+      'load' => true,
288 288
     ),
289 289
   );
290 290
   return $plugins;
Please login to merge, or discard this patch.