Completed
Pull Request — master (#1810)
by Christian
11:51
created
drupal/sites/default/boinc/modules/boinccore/boinccore.module 4 patches
Indentation   +656 added lines, -656 removed lines patch added patch discarded remove patch
@@ -28,22 +28,22 @@  discard block
 block discarded – undo
28 28
  * with defined URL paths
29 29
  */
30 30
 function boinccore_menu() {
31
-  $items['node_control'] = array(
31
+    $items['node_control'] = array(
32 32
     'page callback' => 'boinccore_node_control',
33 33
     'access arguments' => array('access content'),
34 34
     'type' => MENU_CALLBACK
35
-  );
36
-  $items['comment_control'] = array(
35
+    );
36
+    $items['comment_control'] = array(
37 37
     'page callback' => 'boinccore_comment_control',
38 38
     'access arguments' => array('administer comments'),
39 39
     'type' => MENU_CALLBACK
40
-  );
41
-  $items['goto'] = array(
40
+    );
41
+    $items['goto'] = array(
42 42
     'page callback' => 'boinccore_url_pagination_handler',
43 43
     'access arguments' => array('access content'),
44 44
     'type' => MENU_CALLBACK
45
-  );
46
-  $items['admin/boinc/community'] = array(
45
+    );
46
+    $items['admin/boinc/community'] = array(
47 47
     'title' => 'Community',
48 48
     'description' => 'Global settings for community interaction.',
49 49
     'page callback' => 'drupal_get_form',
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
     'access arguments' => array('administer site configuration'),
52 52
     'type' => MENU_NORMAL_ITEM,
53 53
     'file' => 'boinccore.admin.inc'
54
-  );
55
-  $items['admin/boinc/standard-content-generator'] = array(
54
+    );
55
+    $items['admin/boinc/standard-content-generator'] = array(
56 56
     'title' => 'Standard page generator',
57 57
     'description' => 'Regenerate standard site content (e.g. Help and About Us
58 58
       pages).',
@@ -61,124 +61,124 @@  discard block
 block discarded – undo
61 61
     'access arguments' => array('administer site configuration'),
62 62
     'type' => MENU_NORMAL_ITEM,
63 63
     'file' => 'boinccore.admin.inc'
64
-  );
64
+    );
65 65
   
66
-  // BOINC RPC wrappers
67
-  $items['lookup_account.php'] = array(
66
+    // BOINC RPC wrappers
67
+    $items['lookup_account.php'] = array(
68 68
     'title' => 'Look up account RPC',
69 69
     'description' => 'RPC for getting the authenticator for a user account.',
70 70
     'page callback' => 'boinccore_lookup_account',
71 71
     'access callback' => TRUE,
72 72
     'type' => MENU_CALLBACK
73
-  );
74
-  $items['am_get_info.php'] = array(
73
+    );
74
+    $items['am_get_info.php'] = array(
75 75
     'title' => 'Account manager get info RPC',
76 76
     'description' => 'RPC for getting assorted details of a user account.',
77 77
     'page callback' => 'boinccore_am_get_info',
78 78
     'access callback' => TRUE,
79 79
     'type' => MENU_CALLBACK
80
-  );
81
-  $items['am_set_info.php'] = array(
80
+    );
81
+    $items['am_set_info.php'] = array(
82 82
     'title' => 'Account manager set info RPC',
83 83
     'description' => 'RPC for updating assorted details of a user account.',
84 84
     'page callback' => 'boinccore_am_set_info',
85 85
     'access callback' => TRUE,
86 86
     'type' => MENU_CALLBACK
87
-  );
88
-  $items['am_set_host_info.php'] = array(
87
+    );
88
+    $items['am_set_host_info.php'] = array(
89 89
     'title' => 'Account manager set host info RPC',
90 90
     'description' => 'RPC for updating the venue for a given host.',
91 91
     'page callback' => 'boinccore_am_set_host_info',
92 92
     'access callback' => TRUE,
93 93
     'type' => MENU_CALLBACK
94
-  );
95
-  $items['show_user.php'] = array(
94
+    );
95
+    $items['show_user.php'] = array(
96 96
     'title' => 'Show user RPC',
97 97
     'description' => 'RPC for getting assorted details of a user account.',
98 98
     'page callback' => 'boinccore_show_user',
99 99
     'access callback' => TRUE,
100 100
     'type' => MENU_CALLBACK
101
-  );
102
-  $items['pending.php'] = array(
101
+    );
102
+    $items['pending.php'] = array(
103 103
     'title' => 'Pending credit RPC',
104 104
     'description' => 'RPC for getting pending credit for a given account.',
105 105
     'page callback' => 'boinccore_pending_credit',
106 106
     'access callback' => TRUE,
107 107
     'type' => MENU_CALLBACK
108
-  );
109
-  $items['create_team.php'] = array(
108
+    );
109
+    $items['create_team.php'] = array(
110 110
     'title' => 'Create team RPC',
111 111
     'description' => 'RPC for creating a new team.',
112 112
     'page callback' => 'boinccore_create_team',
113 113
     'access callback' => TRUE,
114 114
     'type' => MENU_CALLBACK
115
-  );
116
-  $items['team_lookup.php'] = array(
115
+    );
116
+    $items['team_lookup.php'] = array(
117 117
     'title' => 'Team lookup RPC',
118 118
     'description' => 'RPC for getting info on a team or matching teams.',
119 119
     'page callback' => 'boinccore_team_lookup',
120 120
     'access callback' => TRUE,
121 121
     'type' => MENU_CALLBACK
122
-  );
123
-  $items['team_email_list.php'] = array(
122
+    );
123
+    $items['team_email_list.php'] = array(
124 124
     'title' => 'Get team member list RPC',
125 125
     'description' => 'RPC for getting a list of members of a given team.',
126 126
     'page callback' => 'boinccore_team_email_list',
127 127
     'access callback' => TRUE,
128 128
     'type' => MENU_CALLBACK
129
-  );
130
-  $items['edit_forum_preferences_action.php'] = array(
129
+    );
130
+    $items['edit_forum_preferences_action.php'] = array(
131 131
     'title' => 'Forum preferences RPC',
132 132
     'description' => 'RPC for setting forum preferences for a given user.',
133 133
     'page callback' => 'boinccore_edit_forum_preferences',
134 134
     'access callback' => TRUE,
135 135
     'type' => MENU_CALLBACK
136
-  );
137
-  $items['forum_get_data.php'] = array(
136
+    );
137
+    $items['forum_get_data.php'] = array(
138 138
     'title' => 'Forum get data RPC',
139 139
     'description' => 'RPC for getting recent forum activity for a given user.',
140 140
     'page callback' => 'boinccore_forum_get_data',
141 141
     'access callback' => TRUE,
142 142
     'type' => MENU_CALLBACK
143
-  );
144
-  $items['apps.php'] = array(
143
+    );
144
+    $items['apps.php'] = array(
145 145
     'title' => 'Apps RPC',
146 146
     'description' => 'RPC for getting the applications in the system.',
147 147
     'page callback' => 'boinccore_apps',
148 148
     'access callback' => TRUE,
149 149
     'type' => MENU_CALLBACK
150
-  );
150
+    );
151 151
   
152
-  return $items;
152
+    return $items;
153 153
 }
154 154
 
155 155
 /**
156 156
  * Implementation of hook_menu_alter()
157 157
  */
158 158
 function boinccore_menu_alter(&$items) {
159
-  // If using Solr search and not core Drupal search, disable core search!
160
-  if (module_exists('global_search_solr') AND !module_exists('global_search')) {
159
+    // If using Solr search and not core Drupal search, disable core search!
160
+    if (module_exists('global_search_solr') AND !module_exists('global_search')) {
161 161
     // Add permission to user search.
162 162
     $check = array(
163
-      'search/node/%menu_tail',
164
-      'search/user/%menu_tail',
165
-      'user/autocomplete'
163
+        'search/node/%menu_tail',
164
+        'search/user/%menu_tail',
165
+        'user/autocomplete'
166 166
     );
167 167
     foreach ($check as $path) {
168
-      if (isset($items[$path])) {
168
+        if (isset($items[$path])) {
169 169
         $items[$path]['access callback'] = FALSE;
170
-      }
170
+        }
171
+    }
171 172
     }
172
-  }
173 173
 }
174 174
 
175 175
 /**
176 176
  * Implementation of hook_enable()
177 177
  */
178 178
 function boinccore_enable() {
179
-  // Automatically try to establish standard site content when this module is
180
-  // enabled (e.g. Help and About Us pages)
181
-  boinccore_admin_default_content_generate();
179
+    // Automatically try to establish standard site content when this module is
180
+    // enabled (e.g. Help and About Us pages)
181
+    boinccore_admin_default_content_generate();
182 182
 }
183 183
 
184 184
 /**
@@ -191,14 +191,14 @@  discard block
 block discarded – undo
191 191
  * See: https://www.drupal.org/node/339958#comment-3012662
192 192
  */
193 193
 function boinccore_boot() {
194
-  global $user, $language;
195
-  $cache = variable_get('cache', CACHE_DISABLED);
196
-  $language_negotiation = variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE);
197
-
198
-  // If we have an anonymous user, page cache is enabled, the URL has no prefix
199
-  // and browser language negotiation is set, we perform a redirect to the
200
-  // prefixed URL. 
201
-  if (empty($user->uid) && $cache != CACHE_DISABLED && $language_negotiation == LANGUAGE_NEGOTIATION_PATH) {
194
+    global $user, $language;
195
+    $cache = variable_get('cache', CACHE_DISABLED);
196
+    $language_negotiation = variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE);
197
+
198
+    // If we have an anonymous user, page cache is enabled, the URL has no prefix
199
+    // and browser language negotiation is set, we perform a redirect to the
200
+    // prefixed URL. 
201
+    if (empty($user->uid) && $cache != CACHE_DISABLED && $language_negotiation == LANGUAGE_NEGOTIATION_PATH) {
202 202
     $args = isset($_GET['q']) ? explode('/', $_GET['q']) : array();
203 203
     $prefix = array_shift($args);
204 204
 
@@ -210,24 +210,24 @@  discard block
 block discarded – undo
210 210
     // so call this backported Drupal 7 language negotation function, which
211 211
     // does both case insensitive and longest prefix matching
212 212
     if (function_exists('locale_language_from_browser')) {
213
-      $language = locale_language_from_browser();
213
+        $language = locale_language_from_browser();
214 214
     }
215 215
 
216 216
     if (!empty($language->prefix) && $prefix != $language->prefix) {
217
-      // We need full path support to perform the redirect.
218
-      drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH);
219
-
220
-      require_once './includes/common.inc';
221
-      $url = url($_GET['q'], array('query' => drupal_query_string_encode($_GET, array('q'))));
222
-      $code = variable_get('locale_redirect_http_code', 302);
223
-
224
-      // Since we are in a hook_boot() implementation cache mode is normal, so
225
-      // we can safely call hook_exit().
226
-      bootstrap_invoke_all('exit');
227
-      header("Location: $url", TRUE, $code);
228
-      exit;
217
+        // We need full path support to perform the redirect.
218
+        drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH);
219
+
220
+        require_once './includes/common.inc';
221
+        $url = url($_GET['q'], array('query' => drupal_query_string_encode($_GET, array('q'))));
222
+        $code = variable_get('locale_redirect_http_code', 302);
223
+
224
+        // Since we are in a hook_boot() implementation cache mode is normal, so
225
+        // we can safely call hook_exit().
226
+        bootstrap_invoke_all('exit');
227
+        header("Location: $url", TRUE, $code);
228
+        exit;
229
+    }
229 230
     }
230
-  }
231 231
 }
232 232
 
233 233
 
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
  *
241 241
  * Obsolete in Drupal 7...
242 242
  */
243
-  function locale_language_from_browser() {
243
+    function locale_language_from_browser() {
244 244
     if (empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
245
-      return FALSE;
245
+        return FALSE;
246 246
     }
247 247
     
248 248
     $languages = language_list('enabled');
@@ -257,14 +257,14 @@  discard block
 block discarded – undo
257 257
     // Samples: "hu, en-us;q=0.66, en;q=0.33", "hu,en-us;q=0.5"
258 258
     $browser_langcodes = array();
259 259
     if (preg_match_all('@(?<=[, ]|^)([a-zA-Z-]+|\*)(?:;q=([0-9.]+))?(?:$|\s*,\s*)@', trim($_SERVER['HTTP_ACCEPT_LANGUAGE']), $matches, PREG_SET_ORDER)) {
260
-      foreach ($matches as $match) {
260
+        foreach ($matches as $match) {
261 261
         // We can safely use strtolower() here, tags are ASCII.
262 262
         // RFC2616 mandates that the decimal part is no more than three digits,
263 263
         // so we multiply the qvalue by 1000 to avoid floating point comparisons.
264 264
         $langcode = strtolower($match[1]);
265 265
         $qvalue = isset($match[2]) ? (float) $match[2] : 1;
266 266
         $browser_langcodes[$langcode] = (int) ($qvalue * 1000);
267
-      }
267
+        }
268 268
     }
269 269
 
270 270
     // We should take pristine values from the HTTP headers, but Internet Explorer
@@ -276,10 +276,10 @@  discard block
 block discarded – undo
276 276
     // http://blogs.msdn.com/b/ie/archive/2006/10/17/accept-language-header-for-internet-explorer-7.aspx
277 277
     asort($browser_langcodes);
278 278
     foreach ($browser_langcodes as $langcode => $qvalue) {
279
-      $generic_tag = strtok($langcode, '-');
280
-      if (!isset($browser_langcodes[$generic_tag])) {
279
+        $generic_tag = strtok($langcode, '-');
280
+        if (!isset($browser_langcodes[$generic_tag])) {
281 281
         $browser_langcodes[$generic_tag] = $qvalue;
282
-      }
282
+        }
283 283
     }
284 284
 
285 285
     // Find the enabled language with the greatest qvalue, following the rules
@@ -288,148 +288,148 @@  discard block
 block discarded – undo
288 288
     $best_match_language = FALSE;
289 289
     $max_qvalue = 0;
290 290
     foreach ($languages as $langcode => $language) {
291
-      // Language tags are case insensitive (RFC2616, sec 3.10).
292
-      $langcode = strtolower($langcode);
291
+        // Language tags are case insensitive (RFC2616, sec 3.10).
292
+        $langcode = strtolower($langcode);
293 293
 
294
-      // If nothing matches below, the default qvalue is the one of the wildcard
295
-      // language, if set, or is 0 (which will never match).
296
-      $qvalue = isset($browser_langcodes['*']) ? $browser_langcodes['*'] : 0;
294
+        // If nothing matches below, the default qvalue is the one of the wildcard
295
+        // language, if set, or is 0 (which will never match).
296
+        $qvalue = isset($browser_langcodes['*']) ? $browser_langcodes['*'] : 0;
297 297
 
298
-      // Find the longest possible prefix of the browser-supplied language
299
-      // ('the language-range') that matches this site language ('the language tag').
300
-      $prefix = $langcode;
301
-      do {
298
+        // Find the longest possible prefix of the browser-supplied language
299
+        // ('the language-range') that matches this site language ('the language tag').
300
+        $prefix = $langcode;
301
+        do {
302 302
         if (isset($browser_langcodes[$prefix])) {
303
-          $qvalue = $browser_langcodes[$prefix];
304
-          break;
303
+            $qvalue = $browser_langcodes[$prefix];
304
+            break;
305 305
         }
306
-      } 
307
-       while ($prefix = substr($prefix, 0, strrpos($prefix, '-')));
306
+        } 
307
+        while ($prefix = substr($prefix, 0, strrpos($prefix, '-')));
308 308
 
309
-      // Find the best match.
310
-      if ($qvalue > $max_qvalue) {
309
+        // Find the best match.
310
+        if ($qvalue > $max_qvalue) {
311 311
         $best_match_language = $language;
312 312
         $max_qvalue = $qvalue;
313
-      }
313
+        }
314 314
     }
315 315
 
316 316
     return $best_match_language;
317
-  }
317
+    }
318 318
 }
319 319
 
320 320
 /**
321 321
  * Implementation of hook_cron()
322 322
  */
323 323
 function boinccore_cron() {
324
-  // Notify moderators if there is site content that requires moderator action
325
-  $items_in_queue = boincuser_moderation_queue_count('cron');
326
-  $last_notification = variable_get('boinccore_last_content_moderation_reminder', 0);
327
-  if ($items_in_queue AND $last_notification < time() - 24*60*60) {
324
+    // Notify moderators if there is site content that requires moderator action
325
+    $items_in_queue = boincuser_moderation_queue_count('cron');
326
+    $last_notification = variable_get('boinccore_last_content_moderation_reminder', 0);
327
+    if ($items_in_queue AND $last_notification < time() - 24*60*60) {
328 328
     global $base_url;
329 329
     global $base_path;
330 330
     $site_name = variable_get('site_name', bts('project'));
331 331
     $site_url = $base_url . $base_path;
332 332
     $settings = array(
333
-      'from' => '',
334
-      'subject' => "Content at {$site_name} is awaiting moderation",
335
-      'message' => ''
336
-      . "Please visit the moderation queue page to review content that "
337
-      . "requires moderator action: \n"
338
-      . "\n"
339
-      . "{$site_url}moderate",
333
+        'from' => '',
334
+        'subject' => "Content at {$site_name} is awaiting moderation",
335
+        'message' => ''
336
+        . "Please visit the moderation queue page to review content that "
337
+        . "requires moderator action: \n"
338
+        . "\n"
339
+        . "{$site_url}moderate",
340 340
     );
341 341
     boinccore_rules_action_mail_to_moderators($settings);
342 342
     variable_set('boinccore_last_content_moderation_reminder', time());
343
-  }
343
+    }
344 344
 }
345 345
 
346 346
 /**
347 347
  * Implementation of hook_rules_action_info().
348 348
  */
349 349
 function boinccore_rules_action_info() {
350
-  return array(
350
+    return array(
351 351
     'boinccore_rules_action_mail_to_moderators' => array(
352
-      'label' => t('Notify moderators via email'),
353
-      'module' => 'BOINC core',
354
-      'eval input' => array('subject', 'message', 'from'),
352
+        'label' => t('Notify moderators via email'),
353
+        'module' => 'BOINC core',
354
+        'eval input' => array('subject', 'message', 'from'),
355 355
     ),
356 356
     'boinccore_rules_action_mark_content_for_moderation' => array(
357
-      'label' => t('Mark content for moderation'),
358
-      'arguments' => array(
357
+        'label' => t('Mark content for moderation'),
358
+        'arguments' => array(
359 359
         'node' => array('type' => 'node', 'label' => t('Content')),
360
-      ),
361
-      'module' => 'BOINC core',
360
+        ),
361
+        'module' => 'BOINC core',
362 362
     ),
363
-  );
363
+    );
364 364
 }
365 365
 
366 366
 /**
367 367
  * Implementation of hook_form_alter()
368 368
  */
369 369
 function boinccore_form_alter(&$form, $form_state, $form_id) {
370
-  global $user;
371
-  $account = user_load($user->uid);
372
-  switch ($form_id) {
373
-  // Comment form
374
-  case 'comment_form':
370
+    global $user;
371
+    $account = user_load($user->uid);
372
+    switch ($form_id) {
373
+    // Comment form
374
+    case 'comment_form':
375 375
     $user_image = boincuser_get_user_profile_image($user->uid);
376 376
     $user_info = '<div class="user">';
377 377
     if ($user_image) {
378
-      $user_info .= '  <div class="picture">';
379
-      if (is_array($user_image) AND $user_image['image']['filepath']) {
378
+        $user_info .= '  <div class="picture">';
379
+        if (is_array($user_image) AND $user_image['image']['filepath']) {
380 380
         $user_info .= theme('imagefield_image', $user_image['image'], $user_image['alt'], $user_image['alt'], array(), false);
381
-      }
382
-      elseif (is_string($user_image)) {
381
+        }
382
+        elseif (is_string($user_image)) {
383 383
         $user_info .= '<img src="' . $user_image . '"/>';
384
-      }
385
-      $user_info .= '  </div>';
384
+        }
385
+        $user_info .= '  </div>';
386 386
     }
387 387
     $user_info .= '  <div class="name">' . theme('username', $account) . '</div>';
388 388
     if ($account->uid) {
389
-      //$user_info .= '  <div class="join-date">Joined: ' . date('j M y', $account->created) . '</div>';
390
-      //$user_info .= '  <div class="post-count">Posts: ' . $account->post_count . '</div>';
391
-      //$user_info .= '  <div class="credit">Credit: ' . $account->boincuser_total_credit . '</div>';
392
-      //$user_info .= '  <div class="rac">RAC: ' . $account->boincuser_expavg_credit . '</div>';
389
+        //$user_info .= '  <div class="join-date">Joined: ' . date('j M y', $account->created) . '</div>';
390
+        //$user_info .= '  <div class="post-count">Posts: ' . $account->post_count . '</div>';
391
+        //$user_info .= '  <div class="credit">Credit: ' . $account->boincuser_total_credit . '</div>';
392
+        //$user_info .= '  <div class="rac">RAC: ' . $account->boincuser_expavg_credit . '</div>';
393 393
     }
394 394
     $user_info .= '</div>';
395 395
     array_unshift($form, array(
396
-      'user_info' => array(
396
+        'user_info' => array(
397 397
         '#value' => $user_info,
398
-      ),
399
-      'comment_form_prefix' => array(
398
+        ),
399
+        'comment_form_prefix' => array(
400 400
         '#value' => '<div class="form-body">',
401
-      ),
401
+        ),
402 402
     ));
403 403
     $form['comment_form_suffix'] = array(
404
-      '#value' => '</div>',
404
+        '#value' => '</div>',
405 405
     );
406 406
     
407 407
     module_load_include('inc', 'bbcode', 'bbcode-help');
408 408
     $form['bbcode_help'] = array(
409
-      '#title' => bts('BBcode help'),
410
-      '#type' => 'fieldset',
411
-      '#attributes' => array(
409
+        '#title' => bts('BBcode help'),
410
+        '#type' => 'fieldset',
411
+        '#attributes' => array(
412 412
         'class' => 'bbcode_help',
413
-      ),
414
-      '#collapsible' => TRUE,
415
-      '#collapsed' => TRUE,
416
-      'content' => array(
413
+        ),
414
+        '#collapsible' => TRUE,
415
+        '#collapsed' => TRUE,
416
+        'content' => array(
417 417
         '#value' => _bbcode_filter_tip(),
418
-      ),
418
+        ),
419 419
     );
420 420
     
421 421
     // If a specific comment is being referenced, go back to it on cancel
422 422
     if ($comment_ref = $form['pid']['#value']) {
423
-      $cancel_url = "goto/comment/{$comment_ref}";
423
+        $cancel_url = "goto/comment/{$comment_ref}";
424 424
     }
425 425
     else {
426
-      $cancel_url = "node/{$form['nid']['#value']}";
426
+        $cancel_url = "node/{$form['nid']['#value']}";
427 427
     }
428 428
     
429 429
     // Wrap action buttons for styling consistency
430 430
     $form['buttons']['form control tabs prefix'] = array(
431
-      '#value' => '<ul class="form-control tab-list">',
432
-      '#weight' => 1001,
431
+        '#value' => '<ul class="form-control tab-list">',
432
+        '#weight' => 1001,
433 433
     );
434 434
     $form['buttons']['submit'] = $form['submit'];
435 435
     unset($form['submit']);
@@ -448,12 +448,12 @@  discard block
 block discarded – undo
448 448
     $form['buttons']['preview']['#suffix'] = '</li>';
449 449
     $form['buttons']['preview']['#weight'] = 1003;
450 450
     $form['buttons']['cancel'] = array(
451
-      '#value' => '<li class="tab">' . l(bts('Cancel'), $cancel_url) . '</li>',
452
-      '#weight' => 1004,
451
+        '#value' => '<li class="tab">' . l(bts('Cancel'), $cancel_url) . '</li>',
452
+        '#weight' => 1004,
453 453
     );
454 454
     $form['buttons']['form control tabs suffix'] = array(
455
-      '#value' => '</ul>',
456
-      '#weight' => 1010,
455
+        '#value' => '</ul>',
456
+        '#weight' => 1010,
457 457
     );
458 458
     
459 459
     // Remove redundant name field
@@ -461,19 +461,19 @@  discard block
 block discarded – undo
461 461
     
462 462
     break;
463 463
     
464
-  // Forum node form
465
-  case 'forum_node_form':
464
+    // Forum node form
465
+    case 'forum_node_form':
466 466
   case 'team_forum_node_form':
467 467
     $forum_id = key($form['#node']->taxonomy);
468 468
     $form['buttons']['separator_bottom'] = array(
469
-      '#value' => '<div class="separator buttons"></div>',
470
-      '#weight' => 999,
469
+        '#value' => '<div class="separator buttons"></div>',
470
+        '#weight' => 999,
471 471
     );
472 472
     
473 473
     // Wrap action buttons for styling consistency
474 474
     $form['buttons']['form control tabs prefix'] = array(
475
-      '#value' => '<ul class="form-control tab-list">',
476
-      '#weight' => 1001,
475
+        '#value' => '<ul class="form-control tab-list">',
476
+        '#weight' => 1001,
477 477
     );
478 478
     $form['buttons']['submit']['#prefix'] = '<li class="first tab">';
479 479
     $form['buttons']['submit']['#value'] = bts('Post topic');
@@ -486,16 +486,16 @@  discard block
 block discarded – undo
486 486
     $form['buttons']['preview_changes']['#suffix'] = '</li>';
487 487
     $form['buttons']['preview_changes']['#weight'] = 1004;
488 488
     $form['buttons']['cancel'] = array(
489
-      '#value' => '<li class="tab">' . l(bts('Cancel'), "community/forum/{$forum_id}") . '</li>',
490
-      '#weight' => 1005,
489
+        '#value' => '<li class="tab">' . l(bts('Cancel'), "community/forum/{$forum_id}") . '</li>',
490
+        '#weight' => 1005,
491 491
     );
492 492
     $form['buttons']['form control tabs suffix'] = array(
493
-      '#value' => '</ul>',
494
-      '#weight' => 1010,
493
+        '#value' => '</ul>',
494
+        '#weight' => 1010,
495 495
     );
496 496
 
497 497
     break;
498
-  default:
498
+    default:
499 499
   }
500 500
 }
501 501
 
@@ -503,61 +503,61 @@  discard block
 block discarded – undo
503 503
  * Implementation of hook_link_alter()
504 504
  */
505 505
 function boinccore_link_alter(&$links, $node, $comment = NULL) {
506
-  //echo '<pre>' . print_r($links, true) . '</pre>';
507
-  foreach ($links as $module => $link) {
506
+    //echo '<pre>' . print_r($links, true) . '</pre>';
507
+    foreach ($links as $module => $link) {
508 508
     // Remove the ignore user link
509 509
     if (strstr($module, 'ignore_user')) {
510
-      unset($links[$module]);
510
+        unset($links[$module]);
511 511
     }
512
-  }
513
-  // Node first, then comment: to be consistent with boinccore_link() function
514
-  if (!($comment)) {
512
+    }
513
+    // Node first, then comment: to be consistent with boinccore_link() function
514
+    if (!($comment)) {
515 515
     // modify the comment_add link
516 516
     if (isset($links['comment_add'])) {
517
-      $links['comment_add']['title'] = bts('reply');
518
-      $links['comment_add']['attributes'] = array(
519
-          'title' => bts('Reply to this comment')
520
-      );
517
+        $links['comment_add']['title'] = bts('reply');
518
+        $links['comment_add']['attributes'] = array(
519
+            'title' => bts('Reply to this comment')
520
+        );
521 521
     }
522 522
     // modify quote link
523 523
     if (isset($links['quote'])) {
524
-      $links['quote']['attributes'] = array(
525
-          'title' => bts('Reply to this topic with a quote')
526
-      );
524
+        $links['quote']['attributes'] = array(
525
+            'title' => bts('Reply to this topic with a quote')
526
+        );
527 527
     }
528
-  }
529
-  else {
528
+    }
529
+    else {
530 530
     // Standard EDIT, DELETE, and REPLY links are created by Drupal, but we want to alter them
531 531
     if (isset($links['comment_delete'])) {
532
-      $links['comment_delete']['attributes'] = array(
533
-          'title' => bts('Delete this comment')
534
-      );
532
+        $links['comment_delete']['attributes'] = array(
533
+            'title' => bts('Delete this comment')
534
+        );
535 535
     }
536 536
     if (isset($links['comment_edit'])) {
537
-      $links['comment_edit']['attributes'] = array(
538
-          'title' => bts('Edit this comment')
539
-      );
537
+        $links['comment_edit']['attributes'] = array(
538
+            'title' => bts('Edit this comment')
539
+        );
540 540
     }
541 541
     if (isset($links['comment_reply'])) {
542
-      $links['comment_reply']['attributes'] = array(
543
-          'title' => bts('Reply to this comment')
544
-      );
542
+        $links['comment_reply']['attributes'] = array(
543
+            'title' => bts('Reply to this comment')
544
+        );
545 545
     }
546
-  }// if !$comment
546
+    }// if !$comment
547 547
 }
548 548
 
549 549
 /**
550 550
  * Implementation of hook_locale().
551 551
  */
552 552
 function boinccore_locale($op = 'groups', $group = NULL) {
553
-  switch ($op) {
553
+    switch ($op) {
554 554
     case 'groups':
555 555
       return array('boinc' => bts('BOINC'));
556 556
     case 'info':
557 557
       //$info['boinc']['refresh callback'] = 'boinccore_locale_refresh';
558 558
       $info['boinc']['format'] = FALSE;
559
-      return $info;
560
-  }
559
+        return $info;
560
+    }
561 561
 }
562 562
 
563 563
 
@@ -565,71 +565,71 @@  discard block
 block discarded – undo
565 565
  * Implementation of hook_link()
566 566
  */
567 567
 function boinccore_link($type, $object, $teaser = FALSE) {
568
-  // Add custom links with this hook
568
+    // Add custom links with this hook
569 569
 
570
-  if ($type=='node') {
570
+    if ($type=='node') {
571 571
     if ( ($object->type=='forum') OR ($object->type=='team_forum') ) {
572
-      // Add topic moderator controls
573
-      if (user_access('edit any forum topic')) {
572
+        // Add topic moderator controls
573
+        if (user_access('edit any forum topic')) {
574 574
         $node_control = "node_control/{$object->nid}";
575 575
         if ($object->sticky) {
576
-          $links['make_unsticky'] = array(
577
-              'title' => bts('Make unsticky'),
578
-              'href' => "{$node_control}/unsticky",
579
-              'attributes' => array(
580
-                  'title' => bts('Remove sticky status from this topic')
581
-              )
582
-          );
576
+            $links['make_unsticky'] = array(
577
+                'title' => bts('Make unsticky'),
578
+                'href' => "{$node_control}/unsticky",
579
+                'attributes' => array(
580
+                    'title' => bts('Remove sticky status from this topic')
581
+                )
582
+            );
583 583
         }
584 584
         else {
585
-          $links['make_sticky'] = array(
586
-              'title' => bts('Make sticky'),
587
-              'href' => "{$node_control}/sticky",
588
-              'attributes' => array(
589
-                  'title' => bts('Make this topic sticky')
590
-              )
591
-          );
585
+            $links['make_sticky'] = array(
586
+                'title' => bts('Make sticky'),
587
+                'href' => "{$node_control}/sticky",
588
+                'attributes' => array(
589
+                    'title' => bts('Make this topic sticky')
590
+                )
591
+            );
592 592
         }
593 593
         if ($object->comment == COMMENT_NODE_READ_WRITE) {
594
-          $links['lock'] = array(
595
-              'title' => bts('Lock'),
596
-              'href' => "{$node_control}/lock",
597
-              'attributes' => array(
598
-                  'title' => bts('Lock this thread for comments')
599
-              )
600
-          );
594
+            $links['lock'] = array(
595
+                'title' => bts('Lock'),
596
+                'href' => "{$node_control}/lock",
597
+                'attributes' => array(
598
+                    'title' => bts('Lock this thread for comments')
599
+                )
600
+            );
601 601
         }
602 602
         else {
603
-          $links['unlock'] = array(
604
-              'title' => bts('Unlock'),
605
-              'href' => "{$node_control}/unlock",
606
-              'attributes' => array(
607
-                  'title' => bts('Unlock this thread for comments')
608
-              )
609
-          );
603
+            $links['unlock'] = array(
604
+                'title' => bts('Unlock'),
605
+                'href' => "{$node_control}/unlock",
606
+                'attributes' => array(
607
+                    'title' => bts('Unlock this thread for comments')
608
+                )
609
+            );
610 610
         }
611 611
         if ($object->status) {
612
-          $links['hide'] = array(
613
-              'title' => bts('Hide'),
614
-              'href' => "{$node_control}/hide",
615
-              'attributes' => array(
616
-                  'title' => bts('Hide this topic')
617
-              )
618
-          );
612
+            $links['hide'] = array(
613
+                'title' => bts('Hide'),
614
+                'href' => "{$node_control}/hide",
615
+                'attributes' => array(
616
+                    'title' => bts('Hide this topic')
617
+                )
618
+            );
619 619
         }
620 620
         else {
621
-          $links['unhide'] = array(
622
-              'title' => bts('Unhide'),
623
-              'href' => "{$node_control}/unhide",
624
-              'attributes' => array(
625
-                  'title' => bts('Unhide this topic')
626
-              )
627
-          );
621
+            $links['unhide'] = array(
622
+                'title' => bts('Unhide'),
623
+                'href' => "{$node_control}/unhide",
624
+                'attributes' => array(
625
+                    'title' => bts('Unhide this topic')
626
+                )
627
+            );
628 628
         }
629
-      }// if user_access('edit any forum topic')
629
+        }// if user_access('edit any forum topic')
630 630
     }
631
-  }
632
-  else if ($type=='comment') {
631
+    }
632
+    else if ($type=='comment') {
633 633
     $node = node_load($object->nid);
634 634
     $nid = $object->nid;
635 635
     $cid = $object->cid;
@@ -649,10 +649,10 @@  discard block
 block discarded – undo
649 649
     // HIDE and COVERT comment
650 650
     // The following are moderator only links
651 651
     if (user_access('administer comments')) {
652
-      $comment_control = "comment_control/{$cid}";
653
-      // Add link to convert comment into a new topic
654
-      $reply_count = db_result(db_query(' SELECT COUNT(*) FROM comments WHERE pid = %d', $cid ));
655
-      if ($reply_count == 0) {
652
+        $comment_control = "comment_control/{$cid}";
653
+        // Add link to convert comment into a new topic
654
+        $reply_count = db_result(db_query(' SELECT COUNT(*) FROM comments WHERE pid = %d', $cid ));
655
+        if ($reply_count == 0) {
656 656
         $links['convert'] = array(
657 657
             'title' => bts('Convert'),
658 658
             'href' => "{$comment_control}/convert",
@@ -660,9 +660,9 @@  discard block
 block discarded – undo
660 660
                 'title' => bts('Convert this comment to a new topic')
661 661
             )
662 662
         );
663
-      }
664
-      // Add hide link
665
-      if ($object->status == 0) {
663
+        }
664
+        // Add hide link
665
+        if ($object->status == 0) {
666 666
         $links['hide'] = array(
667 667
             'title' => bts('Hide'),
668 668
             'href' => "{$comment_control}/hide",
@@ -670,8 +670,8 @@  discard block
 block discarded – undo
670 670
                 'title' => bts('Hide this comment')
671 671
             )
672 672
         );
673
-      }
674
-      else {
673
+        }
674
+        else {
675 675
         $links['unhide'] = array(
676 676
             'title' => bts('Unhide'),
677 677
             'href' => "{$comment_control}/unhide",
@@ -679,11 +679,11 @@  discard block
 block discarded – undo
679 679
                 'title' => bts('Unhide this comment')
680 680
             )
681 681
         );
682
-      }
682
+        }
683 683
     }// if user_access('administer comments')
684
-  }//if $type
684
+    }//if $type
685 685
 
686
-  return $links;
686
+    return $links;
687 687
 }
688 688
 
689 689
 
@@ -697,39 +697,39 @@  discard block
 block discarded – undo
697 697
  * link rather than through the node form.
698 698
  */
699 699
 function boinccore_node_control($nid = NULL, $action = NULL) {
700
-  if ((!$nid OR !$node = node_load($nid)) OR
700
+    if ((!$nid OR !$node = node_load($nid)) OR
701 701
       ($node->type == 'forum' AND !user_access('edit any forum topic')) OR
702 702
       ($node->type != 'forum' AND !user_access('administer nodes'))) {
703 703
     // What are you even doing here...
704 704
     return FALSE;
705
-  }
706
-  switch ($action) {
707
-  case 'unhide':
705
+    }
706
+    switch ($action) {
707
+    case 'unhide':
708 708
     node_publish_action($node);
709 709
     break;
710
-  case 'hide':
710
+    case 'hide':
711 711
     node_unpublish_action($node);
712 712
     break;
713
-  case 'sticky':
713
+    case 'sticky':
714 714
     node_make_sticky_action($node);
715 715
     break;
716
-  case 'unsticky':
716
+    case 'unsticky':
717 717
     node_make_unsticky_action($node);
718 718
     break;
719
-  case 'lock':
719
+    case 'lock':
720 720
     $node->comment = 1;
721 721
     watchdog('action', 'Locked comments on @type %title.', array(
722
-      '@type' => node_get_types('name', $node), '%title' => $node->title));
722
+        '@type' => node_get_types('name', $node), '%title' => $node->title));
723 723
     break;
724
-  case 'unlock':
724
+    case 'unlock':
725 725
     $node->comment = 2;
726 726
     watchdog('action', 'Unlocked comments on @type %title.', array(
727
-      '@type' => node_get_types('name', $node), '%title' => $node->title));
727
+        '@type' => node_get_types('name', $node), '%title' => $node->title));
728 728
     break;
729
-  default:
729
+    default:
730 730
   }
731
-  node_save($node);
732
-  drupal_goto("node/{$nid}");
731
+    node_save($node);
732
+    drupal_goto("node/{$nid}");
733 733
 }
734 734
 
735 735
 /**
@@ -738,26 +738,26 @@  discard block
 block discarded – undo
738 738
  * through the comment edit form.
739 739
  */
740 740
 function boinccore_comment_control($cid = NULL, $action = NULL) {
741
-  if (!$cid OR !$comment = _comment_load($cid)) {
741
+    if (!$cid OR !$comment = _comment_load($cid)) {
742 742
     // What are you even doing here...
743 743
     return FALSE;
744
-  }
745
-  $return_path = "node/{$comment->nid}";
746
-  $return_anchor = "comment-{$cid}";
747
-  switch ($action) {
748
-  case 'unhide':
744
+    }
745
+    $return_path = "node/{$comment->nid}";
746
+    $return_anchor = "comment-{$cid}";
747
+    switch ($action) {
748
+    case 'unhide':
749 749
     comment_publish_action($comment);
750 750
     if (module_exists("boinc_solr_comments")) {
751
-      boinc_solr_comments_publish($comment);
751
+        boinc_solr_comments_publish($comment);
752 752
     }
753 753
     break;
754
-  case 'hide':
754
+    case 'hide':
755 755
     comment_unpublish_action($comment);
756 756
     if (module_exists("boinc_solr_comments")) {
757
-      boinc_solr_comments_unpublish($comment);
757
+        boinc_solr_comments_unpublish($comment);
758 758
     }
759 759
     break;
760
-  case 'convert':
760
+    case 'convert':
761 761
     $node = new stdClass();
762 762
     $node->name = $comment->subject;
763 763
     $node->title = $node->name;
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
     $node->tid = $parent_node->tid;
778 778
  
779 779
     if (filter_access($comment->format)) {
780
-      $node->format = $comment->format;
780
+        $node->format = $comment->format;
781 781
     }
782 782
     
783 783
     // Save the new node
@@ -791,9 +791,9 @@  discard block
 block discarded – undo
791 791
     $return_path = "node/{$node->nid}";
792 792
     $return_anchor = NULL;
793 793
     break;
794
-  default:
794
+    default:
795 795
   }
796
-  drupal_goto($return_path, NULL, $return_anchor);
796
+    drupal_goto($return_path, NULL, $return_anchor);
797 797
 }
798 798
 
799 799
 /**
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
  * Get the authenticator for a given account
802 802
  */
803 803
 function boinccore_lookup_account() {
804
-  include_boinc('user/lookup_account.php');
804
+    include_boinc('user/lookup_account.php');
805 805
 }
806 806
 
807 807
 /**
@@ -809,29 +809,29 @@  discard block
 block discarded – undo
809 809
  * Get assorted details for a given account
810 810
  */
811 811
 function boinccore_am_get_info() {
812
-  // Remove q from the GET request or BOINC will panic
813
-  unset($_GET['q']);
814
-  // Capture the XML output of the RPC so we can override things
815
-  ob_start();
816
-  include_boinc('user/am_get_info.php');
817
-  $xml = ob_get_clean();
818
-  $xml = load_configuration($xml);
819
-  // See if the account has an approved profile in Drupal
820
-  $uid = !empty($xml['am_get_info_reply']['id']) ? boincuser_lookup_uid($xml['am_get_info_reply']['id']) : 0;
821
-  if ($uid) {
812
+    // Remove q from the GET request or BOINC will panic
813
+    unset($_GET['q']);
814
+    // Capture the XML output of the RPC so we can override things
815
+    ob_start();
816
+    include_boinc('user/am_get_info.php');
817
+    $xml = ob_get_clean();
818
+    $xml = load_configuration($xml);
819
+    // See if the account has an approved profile in Drupal
820
+    $uid = !empty($xml['am_get_info_reply']['id']) ? boincuser_lookup_uid($xml['am_get_info_reply']['id']) : 0;
821
+    if ($uid) {
822 822
     $content_profile = content_profile_load('profile', $uid);
823 823
     $profile_is_approved = ($content_profile->status AND !$content_profile->moderate);
824 824
     $country = check_plain($content_profile->field_country[0]['value']);
825 825
     $website = '';
826 826
     if ($profile_is_approved) {
827
-      $website = check_plain($content_profile->field_url[0]['value']);
827
+        $website = check_plain($content_profile->field_url[0]['value']);
828 828
     }
829 829
     // Override BOINC values with Drupal values as needed
830 830
     $xml['am_get_info_reply']['has_profile']['@value'] = ($profile_is_approved) ? 1 : 0;
831 831
     $xml['am_get_info_reply']['country']['@value'] = $country;
832 832
     $xml['am_get_info_reply']['url']['@value'] = $website;
833
-  }
834
-  print save_configuration($xml);
833
+    }
834
+    print save_configuration($xml);
835 835
 }
836 836
 
837 837
 /**
@@ -839,75 +839,75 @@  discard block
 block discarded – undo
839 839
  * Update assorted details for a given account
840 840
  */
841 841
 function boinccore_am_set_info() {
842
-  // Remove q from the GET request or BOINC will panic
843
-  unset($_GET['q']);
844
-  // Validate the XML prefs (in case BOINC does not)
845
-  $global_prefs = !empty($_POST['global_prefs']) ? $_POST['global_prefs'] : (!empty($_GET['global_prefs']) ? $_GET['global_prefs'] : NULL);
846
-  $project_prefs = !empty($_POST['project_prefs']) ? $_POST['project_prefs'] : (!empty($_GET['project_prefs']) ? $_GET['project_prefs'] : NULL);
847
-  libxml_use_internal_errors(true);
848
-  $xml = new DomDocument();
849
-  if ($global_prefs) {
842
+    // Remove q from the GET request or BOINC will panic
843
+    unset($_GET['q']);
844
+    // Validate the XML prefs (in case BOINC does not)
845
+    $global_prefs = !empty($_POST['global_prefs']) ? $_POST['global_prefs'] : (!empty($_GET['global_prefs']) ? $_GET['global_prefs'] : NULL);
846
+    $project_prefs = !empty($_POST['project_prefs']) ? $_POST['project_prefs'] : (!empty($_GET['project_prefs']) ? $_GET['project_prefs'] : NULL);
847
+    libxml_use_internal_errors(true);
848
+    $xml = new DomDocument();
849
+    if ($global_prefs) {
850 850
     $xml->loadXML($global_prefs, LIBXML_NOBLANKS);
851 851
     if ($errors = libxml_get_errors($xml)) {
852
-      $lines = explode("\r", $global_prefs);
853
-      watchdog('am_set_info', "XML validation error in global_prefs: {$errors[0]->message} at line {$errors[0]->line}" .
852
+        $lines = explode("\r", $global_prefs);
853
+        watchdog('am_set_info', "XML validation error in global_prefs: {$errors[0]->message} at line {$errors[0]->line}" .
854 854
         ': <br/>' . htmlentities($lines[$errors[0]->line - 1]), array(), WATCHDOG_ERROR);
855 855
     }
856
-  }
857
-  elseif ($project_prefs) {
856
+    }
857
+    elseif ($project_prefs) {
858 858
     $xml->loadXML($project_prefs, LIBXML_NOBLANKS);
859 859
     if ($errors = libxml_get_errors($xml)) {
860
-      $lines = explode("\r", $project_prefs);
861
-      watchdog('am_set_info', "XML validation error in project_prefs: {$errors[0]->message} at line {$errors[0]->line}" .
860
+        $lines = explode("\r", $project_prefs);
861
+        watchdog('am_set_info', "XML validation error in project_prefs: {$errors[0]->message} at line {$errors[0]->line}" .
862 862
         ': <br/>' . htmlentities($lines[$errors[0]->line - 1]), array(), WATCHDOG_ERROR);
863 863
     }
864
-  }
865
-  if (!$errors) {
864
+    }
865
+    if (!$errors) {
866 866
     // Capture the XML output of the RPC so we can override things
867 867
     ob_start();
868 868
     include_boinc('user/am_set_info.php');
869 869
     $xml = ob_get_clean();
870 870
     $xml = load_configuration($xml);
871 871
     if (isset($xml['am_set_info_reply']['success'])) {
872
-      // Find the account in Drupal
873
-      $boinc_auth = !empty($_POST['account_key']) ? $_POST['account_key'] : $_GET['account_key'];
874
-      db_set_active('boinc');
875
-      $boinc_id = db_result(db_query("
872
+        // Find the account in Drupal
873
+        $boinc_auth = !empty($_POST['account_key']) ? $_POST['account_key'] : $_GET['account_key'];
874
+        db_set_active('boinc');
875
+        $boinc_id = db_result(db_query("
876 876
         SELECT id
877 877
         FROM {user}
878 878
         WHERE authenticator = '%s'",
879 879
         $boinc_auth
880
-      ));
881
-      db_set_active('default');
882
-      $uid = boincuser_lookup_uid($boinc_id);
880
+        ));
881
+        db_set_active('default');
882
+        $uid = boincuser_lookup_uid($boinc_id);
883 883
       
884
-      // Apply any relevant updates to the Drupal account, also
885
-      $country = !empty($_POST['country']) ? $_POST['country'] : (!empty($_GET['country']) ? $_GET['country'] : NULL);
886
-      $url = !empty($_POST['url']) ? $_POST['url'] : (!empty($_GET['url']) ? $_GET['url'] : NULL);
887
-      $email_addr = !empty($_POST['email_addr']) ? $_POST['email_addr'] : (!empty($_GET['email_addr']) ? $_GET['email_addr'] : NULL);
884
+        // Apply any relevant updates to the Drupal account, also
885
+        $country = !empty($_POST['country']) ? $_POST['country'] : (!empty($_GET['country']) ? $_GET['country'] : NULL);
886
+        $url = !empty($_POST['url']) ? $_POST['url'] : (!empty($_GET['url']) ? $_GET['url'] : NULL);
887
+        $email_addr = !empty($_POST['email_addr']) ? $_POST['email_addr'] : (!empty($_GET['email_addr']) ? $_GET['email_addr'] : NULL);
888 888
       
889
-      if ($email_addr) {
889
+        if ($email_addr) {
890 890
         $account = user_load($uid);
891 891
         user_save($account, array('mail' => $email_addr));
892
-      }
893
-      if ($country OR $url) {
892
+        }
893
+        if ($country OR $url) {
894 894
         $content_profile = content_profile_load('profile', $uid);
895 895
         if ($country) $content_profile->field_country[0]['value'] = $country;
896 896
         if ($url) $content_profile->field_url[0]['value'] = $url;
897 897
         node_save($content_profile);
898
-      }
898
+        }
899 899
     }
900
-  }
901
-  else {
900
+    }
901
+    else {
902 902
     $xml = array(
903
-      'error' => array(
903
+        'error' => array(
904 904
         'error_num' => -112,
905 905
         'error_msg' => "{$errors[0]->message} at line {$errors[0]->line}" .
906 906
         ': <br/>' . htmlentities($lines[$errors[0]->line - 1])
907
-      ),
907
+        ),
908 908
     );
909
-  }
910
-  print save_configuration($xml);
909
+    }
910
+    print save_configuration($xml);
911 911
 }
912 912
 
913 913
 /**
@@ -915,17 +915,17 @@  discard block
 block discarded – undo
915 915
  * Update the venue for the given host
916 916
  */
917 917
 function boinccore_am_set_host_info() {
918
-  // Remove q from the GET request or BOINC will panic
919
-  unset($_GET['q']);
920
-  // Capture the XML output of the RPC so we can override things
921
-  ob_start();
922
-  include_boinc('user/am_set_host_info.php');
923
-  $xml = ob_get_clean();
924
-  $xml = load_configuration($xml);
925
-  if (isset($xml['am_set_host_info_reply']['success'])) {
918
+    // Remove q from the GET request or BOINC will panic
919
+    unset($_GET['q']);
920
+    // Capture the XML output of the RPC so we can override things
921
+    ob_start();
922
+    include_boinc('user/am_set_host_info.php');
923
+    $xml = ob_get_clean();
924
+    $xml = load_configuration($xml);
925
+    if (isset($xml['am_set_host_info_reply']['success'])) {
926 926
     // Override anything that needs overriding
927
-  }
928
-  print save_configuration($xml);
927
+    }
928
+    print save_configuration($xml);
929 929
 }
930 930
 
931 931
 /**
@@ -933,29 +933,29 @@  discard block
 block discarded – undo
933 933
  * Get assorted details for a given account
934 934
  */
935 935
 function boinccore_show_user() {
936
-  // Remove q from the GET request or BOINC will panic
937
-  unset($_GET['q']);
938
-  // Capture the XML output of the RPC so we can override things
939
-  ob_start();
940
-  include_boinc('user/show_user.php');
941
-  $xml = ob_get_clean();
942
-  $xml = load_configuration($xml);
943
-  // See if the account has an approved profile in Drupal
944
-  $uid = !empty($xml['user']['id']) ? boincuser_lookup_uid($xml['user']['id']) : 0;
945
-  if ($uid) {
936
+    // Remove q from the GET request or BOINC will panic
937
+    unset($_GET['q']);
938
+    // Capture the XML output of the RPC so we can override things
939
+    ob_start();
940
+    include_boinc('user/show_user.php');
941
+    $xml = ob_get_clean();
942
+    $xml = load_configuration($xml);
943
+    // See if the account has an approved profile in Drupal
944
+    $uid = !empty($xml['user']['id']) ? boincuser_lookup_uid($xml['user']['id']) : 0;
945
+    if ($uid) {
946 946
     $content_profile = content_profile_load('profile', $uid);
947 947
     $profile_is_approved = ($content_profile->status AND !$content_profile->moderate);
948 948
     $country = check_plain($content_profile->field_country[0]['value']);
949 949
     $website = '';
950 950
     if ($profile_is_approved) {
951
-      $website = check_plain($content_profile->field_url[0]['value']);
951
+        $website = check_plain($content_profile->field_url[0]['value']);
952 952
     }
953 953
     // Override BOINC values with Drupal values as needed
954 954
     $xml['user']['has_profile']['@value'] = ($profile_is_approved) ? 1 : 0;
955 955
     $xml['user']['country']['@value'] = $country;
956 956
     $xml['user']['url']['@value'] = $website;
957
-  }
958
-  print save_configuration($xml);
957
+    }
958
+    print save_configuration($xml);
959 959
 }
960 960
 
961 961
 /**
@@ -963,9 +963,9 @@  discard block
 block discarded – undo
963 963
  * Get pending credit information for a given account
964 964
  */
965 965
 function boinccore_pending_credit() {
966
-  // Remove q from the GET request or BOINC will panic
967
-  unset($_GET['q']);
968
-  include_boinc('user/pending.php');
966
+    // Remove q from the GET request or BOINC will panic
967
+    unset($_GET['q']);
968
+    include_boinc('user/pending.php');
969 969
 }
970 970
 
971 971
 /**
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
  */
975 975
 function boinccore_create_team() {
976 976
   
977
-  if (module_exists('boincteam')) {
977
+    if (module_exists('boincteam')) {
978 978
     module_load_include('module', 'boincteam', 'boincteam');
979 979
   
980 980
     $input_format = !empty($values['format']) ? $values['format'] : 4;
@@ -987,9 +987,9 @@  discard block
 block discarded – undo
987 987
     $xml = load_configuration($xml);
988 988
     
989 989
     if (isset($xml['create_team_reply']['success'])) {
990
-      $boincteam_id = isset($xml['create_team_reply']['team_id']['@value']) ? $xml['create_team_reply']['team_id']['@value'] : 0;
990
+        $boincteam_id = isset($xml['create_team_reply']['team_id']['@value']) ? $xml['create_team_reply']['team_id']['@value'] : 0;
991 991
       
992
-      if ($boincteam_id) {
992
+        if ($boincteam_id) {
993 993
         
994 994
         $boincteam = boincteam_load($boincteam_id);
995 995
         $team_owner_uid = boincuser_lookup_uid($boincteam->userid);
@@ -997,92 +997,92 @@  discard block
 block discarded – undo
997 997
         // Create the team node in Drupal
998 998
         
999 999
         $values = array(
1000
-          'name' => isset($_GET['name']) ? $_GET['name'] : '',
1001
-          'description' => isset($_GET['description']) ? $_GET['description'] : '',
1002
-          'type' => isset($_GET['type']) ? $_GET['type'] : '',
1000
+            'name' => isset($_GET['name']) ? $_GET['name'] : '',
1001
+            'description' => isset($_GET['description']) ? $_GET['description'] : '',
1002
+            'type' => isset($_GET['type']) ? $_GET['type'] : '',
1003 1003
         );
1004 1004
         $teaser = node_teaser($values['description']);
1005 1005
         $created_time = time();
1006 1006
         
1007 1007
         $node = array(
1008
-          'type' => 'team',
1009
-          'title' => $values['name'],
1010
-          'body' => $values['description'],
1011
-          'teaser' => $teaser,
1012
-          'uid' => $team_owner_uid,
1013
-          'path' => null,
1014
-          'status' => 1,  // published or not - always publish
1015
-          'promote' => 0,
1016
-          'created' => $created_time,
1017
-          'comment' => 0,  // comments disabled
1018
-          'moderate' => 0,
1019
-          'sticky' => 0,
1020
-          'format' => $input_format
1008
+            'type' => 'team',
1009
+            'title' => $values['name'],
1010
+            'body' => $values['description'],
1011
+            'teaser' => $teaser,
1012
+            'uid' => $team_owner_uid,
1013
+            'path' => null,
1014
+            'status' => 1,  // published or not - always publish
1015
+            'promote' => 0,
1016
+            'created' => $created_time,
1017
+            'comment' => 0,  // comments disabled
1018
+            'moderate' => 0,
1019
+            'sticky' => 0,
1020
+            'format' => $input_format
1021 1021
         );
1022 1022
         
1023 1023
         // Use pathauto function, if available, to clean up the path
1024 1024
         if (module_exists('pathauto')) {
1025
-          module_load_include('inc', 'pathauto', 'pathauto');
1026
-          $node['path'] = pathauto_cleanstring($values['name']);
1025
+            module_load_include('inc', 'pathauto', 'pathauto');
1026
+            $node['path'] = pathauto_cleanstring($values['name']);
1027 1027
         
1028
-          $node = (object) $node; // node_save requires an object form
1029
-          $team_categories = taxonomy_get_term_by_name($values['type']);
1030
-          $node->taxonomy[] = $team_categories[0];
1028
+            $node = (object) $node; // node_save requires an object form
1029
+            $team_categories = taxonomy_get_term_by_name($values['type']);
1030
+            $node->taxonomy[] = $team_categories[0];
1031 1031
           
1032
-          // Save the team node
1033
-          node_save($node);
1034
-          // Save the team IDs to a BOINC <--> Drupal reference table.
1035
-          db_query('INSERT INTO {boincteam} (team_id, nid) VALUES (%d, %d)', $boincteam_id, $node->nid);
1032
+            // Save the team node
1033
+            node_save($node);
1034
+            // Save the team IDs to a BOINC <--> Drupal reference table.
1035
+            db_query('INSERT INTO {boincteam} (team_id, nid) VALUES (%d, %d)', $boincteam_id, $node->nid);
1036 1036
         }
1037 1037
         else {
1038
-          $xml['create_team_reply']['warning'] = t(
1038
+            $xml['create_team_reply']['warning'] = t(
1039 1039
             'There was a problem integrating this team into Drupal. Please
1040 1040
             contact @project administrators!', array('@project' => PROJECT)
1041
-          );
1042
-          watchdog(
1041
+            );
1042
+            watchdog(
1043 1043
             'BOINC team',
1044 1044
             'BOINC teams require the Pathauto module. Team cannot be created in
1045 1045
               Drupal via create_team.php RPC.',
1046 1046
             array(),
1047 1047
             WATCHDOG_ERROR
1048
-          );
1049
-          // Delete from the BOINC DB if we can't sync with Drupal
1050
-          $boincteam::delete();
1048
+            );
1049
+            // Delete from the BOINC DB if we can't sync with Drupal
1050
+            $boincteam::delete();
1051 1051
         }
1052
-      }
1053
-      else {
1052
+        }
1053
+        else {
1054 1054
         $xml['create_team_reply']['warning'] = t(
1055
-          'There was a problem integrating this team into Drupal. Please
1055
+            'There was a problem integrating this team into Drupal. Please
1056 1056
           contact @project administrators!', array('@project' => PROJECT)
1057 1057
         );
1058 1058
         watchdog(
1059
-          'BOINC team',
1060
-          'Team cannot be created in Drupal via create_team.php RPC because no
1059
+            'BOINC team',
1060
+            'Team cannot be created in Drupal via create_team.php RPC because no
1061 1061
             BOINC team ID was returned in the XML.',
1062
-          array(),
1063
-          WATCHDOG_ERROR
1062
+            array(),
1063
+            WATCHDOG_ERROR
1064 1064
         );
1065
-      }
1065
+        }
1066 1066
     }
1067
-  }
1068
-  else {
1067
+    }
1068
+    else {
1069 1069
     $xml = array(
1070
-      'error' => array(
1070
+        'error' => array(
1071 1071
         'error_num' => -1,
1072 1072
         'error_msg' => t(
1073
-          'Teams are not enabled for this project'
1073
+            'Teams are not enabled for this project'
1074
+        ),
1074 1075
         ),
1075
-      ),
1076 1076
     );
1077 1077
     watchdog(
1078
-      'BOINC team',
1079
-      'Team cannot be created in Drupal via create_team.php RPC because the
1078
+        'BOINC team',
1079
+        'Team cannot be created in Drupal via create_team.php RPC because the
1080 1080
         BOINC team module is not enabled.',
1081
-      array(),
1082
-      WATCHDOG_ERROR
1081
+        array(),
1082
+        WATCHDOG_ERROR
1083 1083
     );
1084
-  }
1085
-  print save_configuration($xml);
1084
+    }
1085
+    print save_configuration($xml);
1086 1086
 }
1087 1087
 
1088 1088
 /**
@@ -1090,9 +1090,9 @@  discard block
 block discarded – undo
1090 1090
  * Get info on a team by ID or a list of teams that match a given name
1091 1091
  */
1092 1092
 function boinccore_team_lookup() {
1093
-  // Remove q from the GET request or BOINC will panic
1094
-  unset($_GET['q']);
1095
-  include_boinc('user/team_lookup.php');
1093
+    // Remove q from the GET request or BOINC will panic
1094
+    unset($_GET['q']);
1095
+    include_boinc('user/team_lookup.php');
1096 1096
 }
1097 1097
 
1098 1098
 /**
@@ -1100,107 +1100,107 @@  discard block
 block discarded – undo
1100 1100
  * Get members of a given team
1101 1101
  */
1102 1102
 function boinccore_team_email_list() {
1103
-  // See if the account has an approved profile in Drupal
1104
-  $boincteam_id = !empty($_POST['teamid']) ? $_POST['teamid'] : $_GET['teamid'];
1105
-  $account_key = !empty($_POST['account_key']) ? $_POST['account_key'] : $_GET['account_key'];
1106
-  $credit_only = !empty($_POST['creditonly']) ? $_POST['creditonly'] : $_GET['creditonly'];
1107
-  $show_xml = !empty($_POST['xml']) ? $_POST['xml'] : $_GET['xml'];
1108
-  if (!$show_xml) {
1109
-      // creditonly does not affect non xml output in BOINC
1110
-      $credit_only = FALSE;
1111
-  }
1112
-  $admin_request = FALSE;
1113
-  if ($boincteam_id && is_numeric($boincteam_id)) {
1103
+    // See if the account has an approved profile in Drupal
1104
+    $boincteam_id = !empty($_POST['teamid']) ? $_POST['teamid'] : $_GET['teamid'];
1105
+    $account_key = !empty($_POST['account_key']) ? $_POST['account_key'] : $_GET['account_key'];
1106
+    $credit_only = !empty($_POST['creditonly']) ? $_POST['creditonly'] : $_GET['creditonly'];
1107
+    $show_xml = !empty($_POST['xml']) ? $_POST['xml'] : $_GET['xml'];
1108
+    if (!$show_xml) {
1109
+        // creditonly does not affect non xml output in BOINC
1110
+        $credit_only = FALSE;
1111
+    }
1112
+    $admin_request = FALSE;
1113
+    if ($boincteam_id && is_numeric($boincteam_id)) {
1114 1114
     if ($account_key) {
1115
-      // See if this is a team admin
1116
-      db_set_active('boinc');
1117
-      $boincuser_id = db_result(db_query("
1115
+        // See if this is a team admin
1116
+        db_set_active('boinc');
1117
+        $boincuser_id = db_result(db_query("
1118 1118
         SELECT 
1119 1119
           u.id
1120 1120
         FROM {user} u
1121 1121
         WHERE u.authenticator = '%s'
1122 1122
         LIMIT 1",
1123 1123
         $account_key
1124
-      ));
1125
-      db_set_active('default');
1126
-      require_boinc('team');
1127
-      $boincuser = boincuser_load(boincuser_lookup_uid($boincuser_id), TRUE);
1128
-      $boincteam = boincteam_load($boincteam_id);
1129
-      $admin_request = is_team_admin($boincuser, $boincteam) OR is_team_founder($boincuser, $boincteam);
1124
+        ));
1125
+        db_set_active('default');
1126
+        require_boinc('team');
1127
+        $boincuser = boincuser_load(boincuser_lookup_uid($boincuser_id), TRUE);
1128
+        $boincteam = boincteam_load($boincteam_id);
1129
+        $admin_request = is_team_admin($boincuser, $boincteam) OR is_team_founder($boincuser, $boincteam);
1130 1130
     }
1131 1131
 
1132 1132
     if ($credit_only) {
1133
-      db_set_active('boinc');
1134
-      $result = db_query("
1133
+        db_set_active('boinc');
1134
+        $result = db_query("
1135 1135
         SELECT
1136 1136
           u.id, u.name, u.cross_project_id, u.email_addr, u.total_credit, u.expavg_credit, u.expavg_time
1137 1137
         FROM {user} u
1138 1138
         WHERE u.teamid = %d and u.total_credit > 0",
1139 1139
         $boincteam_id
1140
-      );
1141
-      db_set_active('default');
1140
+        );
1141
+        db_set_active('default');
1142 1142
 
1143
-      $xml = array('users' => array());
1144
-      while ($member = db_fetch_object($result)) {
1143
+        $xml = array('users' => array());
1144
+        while ($member = db_fetch_object($result)) {
1145 1145
         $team_member = array(
1146
-          'id' => $member->id,
1147
-          'cpid' => md5($member->cross_project_id.$member->email_addr),
1148
-          'name' => htmlspecialchars($member->name),
1149
-          'total_credit' => round($member->total_credit),
1150
-          'expavg_credit' => round($member->expavg_credit),
1151
-          'expavg_time' => round($member->expavg_time),
1146
+            'id' => $member->id,
1147
+            'cpid' => md5($member->cross_project_id.$member->email_addr),
1148
+            'name' => htmlspecialchars($member->name),
1149
+            'total_credit' => round($member->total_credit),
1150
+            'expavg_credit' => round($member->expavg_credit),
1151
+            'expavg_time' => round($member->expavg_time),
1152 1152
         );
1153 1153
         $xml['users']['user'][] = $team_member;
1154
-      }
1154
+        }
1155 1155
     }
1156 1156
     else {
1157
-      $members = array();
1158
-      db_set_active('boinc');
1159
-      $result = db_query("
1157
+        $members = array();
1158
+        db_set_active('boinc');
1159
+        $result = db_query("
1160 1160
         SELECT
1161 1161
           u.name, u.email_addr
1162 1162
         FROM {user} u
1163 1163
         WHERE u.teamid = %d
1164 1164
         ORDER BY u.email_addr ASC",
1165 1165
         $boincteam_id
1166
-      );
1167
-      db_set_active('default');
1166
+        );
1167
+        db_set_active('default');
1168 1168
 
1169
-      while ($member = db_fetch_object($result)) {
1169
+        while ($member = db_fetch_object($result)) {
1170 1170
         $members[] = user_load(array('mail' => $member->email_addr));
1171
-      }
1171
+        }
1172 1172
 
1173
-      $xml = array('users' => array());
1174
-      foreach ($members as $member) {
1173
+        $xml = array('users' => array());
1174
+        foreach ($members as $member) {
1175 1175
         $content_profile = content_profile_load('profile', $member->uid);
1176 1176
         $team_member = array(
1177
-          'id' => $member->boincuser_id,
1178
-          'cpid' => $member->boincuser_cpid,
1179
-          'create_time' => $member->created,
1180
-          'name' => $member->boincuser_name,
1181
-          'country' => $content_profile->field_country[0]['value'],
1182
-          'total_credit' => $member->boincuser_total_credit,
1183
-          'expavg_credit' => $member->boincuser_expavg_credit,
1184
-          'expavg_time' => $member->boincuser_expavg_time,
1185
-          'url' => $content_profile->field_url[0]['value'],
1186
-          'has_profile' => ($content_profile->status AND !$content_profile->moderate) ? 1 : 0,
1177
+            'id' => $member->boincuser_id,
1178
+            'cpid' => $member->boincuser_cpid,
1179
+            'create_time' => $member->created,
1180
+            'name' => $member->boincuser_name,
1181
+            'country' => $content_profile->field_country[0]['value'],
1182
+            'total_credit' => $member->boincuser_total_credit,
1183
+            'expavg_credit' => $member->boincuser_expavg_credit,
1184
+            'expavg_time' => $member->boincuser_expavg_time,
1185
+            'url' => $content_profile->field_url[0]['value'],
1186
+            'has_profile' => ($content_profile->status AND !$content_profile->moderate) ? 1 : 0,
1187 1187
         );
1188 1188
         if ($admin_request) {
1189
-          $team_member['email_addr'] = $member->mail;
1189
+            $team_member['email_addr'] = $member->mail;
1190 1190
         }
1191 1191
         $xml['users']['user'][] = $team_member;
1192
-      }
1192
+        }
1193 1193
     }
1194
-  }
1195
-  else {
1194
+    }
1195
+    else {
1196 1196
     $xml = array(
1197
-      'error' => array(
1197
+        'error' => array(
1198 1198
         'error_num' => -136,
1199 1199
         'error_msg' => 'Not found',
1200
-      ),
1200
+        ),
1201 1201
     );
1202
-  }
1203
-  print xml_to_text(array_to_xml($xml), TRUE, TRUE);
1202
+    }
1203
+    print xml_to_text(array_to_xml($xml), TRUE, TRUE);
1204 1204
 }
1205 1205
 
1206 1206
 /**
@@ -1208,114 +1208,114 @@  discard block
 block discarded – undo
1208 1208
  * Edit the forum preferences for a given user
1209 1209
  */
1210 1210
 function boinccore_edit_forum_preferences() {
1211
-  // Do not pass through to BOINC in this case as BOINC forums are no longer
1212
-  // relevant -- use Drupal data only
1211
+    // Do not pass through to BOINC in this case as BOINC forums are no longer
1212
+    // relevant -- use Drupal data only
1213 1213
   
1214
-  $account_key = !empty($_POST['account_key']) ? $_POST['account_key'] : (!empty($_GET['account_key']) ? $_GET['account_key'] : NULL);
1214
+    $account_key = !empty($_POST['account_key']) ? $_POST['account_key'] : (!empty($_GET['account_key']) ? $_GET['account_key'] : NULL);
1215 1215
   
1216
-  require_boinc('boinc_db');
1217
-  $boincuser = BoincUser::lookup_auth($account_key);
1218
-  if ($boincuser) {
1216
+    require_boinc('boinc_db');
1217
+    $boincuser = BoincUser::lookup_auth($account_key);
1218
+    if ($boincuser) {
1219 1219
     $uid = boincuser_lookup_uid($boincuser->id);
1220 1220
     if ($uid AND $account = user_load($uid)) {
1221
-      // Currently supported preferences
1222
-      $avatar_url = isset($_POST['avatar_url']) ? $_POST['avatar_url'] : (isset($_GET['avatar_url']) ? $_GET['avatar_url'] : NULL);
1223
-      $hide_signatures = isset($_POST['forum_hide_signatures']) ? $_POST['forum_hide_signatures'] : (isset($_GET['forum_hide_signatures']) ? $_GET['forum_hide_signatures'] : NULL);
1224
-      $signature = isset($_POST['signature']) ? $_POST['signature'] : (isset($_GET['signature']) ? $_GET['signature'] : NULL);
1225
-      $post_order = isset($_POST['thread_sort']) ? $_POST['thread_sort'] : (isset($_GET['thread_sort']) ? $_GET['thread_sort'] : NULL);
1226
-      // Update preferences as needed
1227
-      if ($avatar_url) {
1221
+        // Currently supported preferences
1222
+        $avatar_url = isset($_POST['avatar_url']) ? $_POST['avatar_url'] : (isset($_GET['avatar_url']) ? $_GET['avatar_url'] : NULL);
1223
+        $hide_signatures = isset($_POST['forum_hide_signatures']) ? $_POST['forum_hide_signatures'] : (isset($_GET['forum_hide_signatures']) ? $_GET['forum_hide_signatures'] : NULL);
1224
+        $signature = isset($_POST['signature']) ? $_POST['signature'] : (isset($_GET['signature']) ? $_GET['signature'] : NULL);
1225
+        $post_order = isset($_POST['thread_sort']) ? $_POST['thread_sort'] : (isset($_GET['thread_sort']) ? $_GET['thread_sort'] : NULL);
1226
+        // Update preferences as needed
1227
+        if ($avatar_url) {
1228 1228
         $avatar_image = file_get_contents($avatar_url);
1229 1229
         if ($avatar_image) {
1230
-          $image_dir = 'profiles';
1231
-          $image_path = "{$image_dir}/{$boincuser->id}_avatar.jpg";
1232
-          $file = file_save_data($avatar_image, $image_path, FILE_EXISTS_REPLACE);
1233
-          if ($file) {
1230
+            $image_dir = 'profiles';
1231
+            $image_path = "{$image_dir}/{$boincuser->id}_avatar.jpg";
1232
+            $file = file_save_data($avatar_image, $image_path, FILE_EXISTS_REPLACE);
1233
+            if ($file) {
1234 1234
             $profile = new stdClass();
1235 1235
             $profile->type = 'profile';
1236 1236
             $profile->language = NULL;
1237 1237
             if ($profile_nid = content_profile_profile_exists($profile, $account->uid)) {
1238
-              $profile_node = node_load($profile_nid);
1239
-              if ($profile_node) {
1238
+                $profile_node = node_load($profile_nid);
1239
+                if ($profile_node) {
1240 1240
                 $avatar_image = get_cck_image_object(file_directory_path() . '/' . $image_path, 'field_image', 'profile', TRUE);
1241 1241
                 if ($avatar_image) {
1242
-                  $profile_node->field_image[0] = $avatar_image;
1243
-                  node_save($profile_node);
1242
+                    $profile_node->field_image[0] = $avatar_image;
1243
+                    node_save($profile_node);
1244 1244
                 }
1245 1245
                 else {
1246
-                  $error = 'Error saving avatar to profile';
1246
+                    $error = 'Error saving avatar to profile';
1247 1247
                 }
1248
-              }
1249
-              else {
1248
+                }
1249
+                else {
1250 1250
                 $error = 'Unable to load user profile';
1251
-              }
1251
+                }
1252 1252
             }
1253 1253
             else {
1254
-              $error = 'User has no profile, so avatar could not be added';
1254
+                $error = 'User has no profile, so avatar could not be added';
1255
+            }
1255 1256
             }
1256
-          }
1257
-          else {
1257
+            else {
1258 1258
             $error = 'Unable to save remote image';
1259
-          }
1259
+            }
1260 1260
         }
1261 1261
         else {
1262
-          $error = 'Could not find avatar image at URL';
1262
+            $error = 'Could not find avatar image at URL';
1263 1263
         }
1264
-      }
1265
-      if ($hide_signatures !== NULL) {
1264
+        }
1265
+        if ($hide_signatures !== NULL) {
1266 1266
         user_save($account, array('hide_signatures' => ($hide_signatures ? 1 : 0)));
1267
-      }
1268
-      if ($signature !== NULL) {
1267
+        }
1268
+        if ($signature !== NULL) {
1269 1269
         $signature = check_markup($signature);
1270 1270
         user_save($account, array('signature' => $signature));
1271
-      }
1272
-      if ($post_order) {
1271
+        }
1272
+        if ($post_order) {
1273 1273
         require_boinc('forum');
1274 1274
         $post_order_map = array(
1275
-          CREATE_TIME_OLD => 2,
1276
-          CREATE_TIME_NEW => 1,
1275
+            CREATE_TIME_OLD => 2,
1276
+            CREATE_TIME_NEW => 1,
1277 1277
         );
1278 1278
         $drupal_post_order = isset($post_order_map[$post_order]) ? $post_order_map[$post_order] : 2;
1279 1279
         user_save($account, array('sort' => $drupal_post_order));
1280
-      }
1281
-      if (!$error) {
1280
+        }
1281
+        if (!$error) {
1282 1282
         // Success
1283 1283
         $xml = array(
1284
-          'edit_forum_preferences' => array(
1284
+            'edit_forum_preferences' => array(
1285 1285
             'success' => NULL,
1286
-          ),
1286
+            ),
1287 1287
         );
1288
-      }
1289
-      else {
1288
+        }
1289
+        else {
1290 1290
         // Failure
1291 1291
         $xml = array(
1292
-          'error' => array(
1292
+            'error' => array(
1293 1293
             'error_num' => -1,
1294 1294
             'error_msg' => $error,
1295
-          ),
1295
+            ),
1296 1296
         );
1297
-      }
1297
+        }
1298 1298
     }
1299 1299
     else {
1300
-      // Drupal user not found
1301
-      $xml = array(
1300
+        // Drupal user not found
1301
+        $xml = array(
1302 1302
         'error' => array(
1303
-          'error_num' => -1,
1304
-          'error_msg' => 'Unknown error',
1303
+            'error_num' => -1,
1304
+            'error_msg' => 'Unknown error',
1305 1305
         ),
1306
-      );
1306
+        );
1307 1307
     }
1308
-  }
1309
-  else {
1308
+    }
1309
+    else {
1310 1310
     // BOINC user not found
1311 1311
     $xml = array(
1312
-      'error' => array(
1312
+        'error' => array(
1313 1313
         'error_num' => -136,
1314 1314
         'error_msg' => 'Not found',
1315
-      ),
1315
+        ),
1316 1316
     );
1317
-  }
1318
-  print xml_to_text(array_to_xml($xml), TRUE, TRUE);
1317
+    }
1318
+    print xml_to_text(array_to_xml($xml), TRUE, TRUE);
1319 1319
 }
1320 1320
 
1321 1321
 /**
@@ -1323,14 +1323,14 @@  discard block
 block discarded – undo
1323 1323
  * Get the last comments OR threads made by a given user
1324 1324
  */
1325 1325
 function boinccore_forum_get_data() {
1326
-  // Do not pass through to BOINC in this case as BOINC forums are no longer
1327
-  // relevant -- use Drupal data only
1326
+    // Do not pass through to BOINC in this case as BOINC forums are no longer
1327
+    // relevant -- use Drupal data only
1328 1328
   
1329
-  $xml = array();
1330
-  $boinc_id = !empty($_POST['userid']) ? $_POST['userid'] : (!empty($_GET['userid']) ? $_GET['userid'] : NULL);
1331
-  $uid = boincuser_lookup_uid($boinc_id);
1329
+    $xml = array();
1330
+    $boinc_id = !empty($_POST['userid']) ? $_POST['userid'] : (!empty($_GET['userid']) ? $_GET['userid'] : NULL);
1331
+    $uid = boincuser_lookup_uid($boinc_id);
1332 1332
   
1333
-  if ($uid) {
1333
+    if ($uid) {
1334 1334
     $method = !empty($_POST['method']) ? $_POST['method'] : (!empty($_GET['method']) ? $_GET['method'] : NULL);
1335 1335
     $count = !empty($_POST['count']) ? $_POST['count'] : (!empty($_GET['count']) ? $_GET['count'] : NULL);
1336 1336
     if (!$count) $count = 10;
@@ -1338,7 +1338,7 @@  discard block
 block discarded – undo
1338 1338
     switch ($method) {
1339 1339
     case 'user_posts':
1340 1340
       $content_length = !empty($_POST['content_length']) ? $_POST['content_length'] : (!empty($_GET['content_length']) ? $_GET['content_length'] : NULL);
1341
-      $posts = db_query("
1341
+        $posts = db_query("
1342 1342
         SELECT
1343 1343
           c.cid,
1344 1344
           n.nid,
@@ -1352,26 +1352,26 @@  discard block
 block discarded – undo
1352 1352
         ORDER BY timestamp DESC
1353 1353
         LIMIT %d",
1354 1354
         $uid, (int) $count
1355
-      );
1356
-      $xml = array(
1355
+        );
1356
+        $xml = array(
1357 1357
         'rpc_response' => array(
1358
-          'count' => 0,
1359
-          'posts' => array(),
1358
+            'count' => 0,
1359
+            'posts' => array(),
1360 1360
         ),
1361
-      );
1362
-      $post_count = 0;
1363
-      while ($post = db_fetch_object($posts)) {
1361
+        );
1362
+        $post_count = 0;
1363
+        while ($post = db_fetch_object($posts)) {
1364 1364
         $xml['rpc_response']['posts']['post'][] = array(
1365
-          'id' => $post->cid,
1366
-          'threadid' => $post->nid,
1367
-          'threadtitle' => $post->title,
1368
-          'timestamp' => $post->timestamp,
1369
-          'content' => ($content_length ? substr($post->comment, 0, $content_length) : $post->comment),
1365
+            'id' => $post->cid,
1366
+            'threadid' => $post->nid,
1367
+            'threadtitle' => $post->title,
1368
+            'timestamp' => $post->timestamp,
1369
+            'content' => ($content_length ? substr($post->comment, 0, $content_length) : $post->comment),
1370 1370
         );
1371 1371
         $post_count++;
1372
-      }
1373
-      $xml['rpc_response']['count'] = $post_count;
1374
-      break;
1372
+        }
1373
+        $xml['rpc_response']['count'] = $post_count;
1374
+        break;
1375 1375
       
1376 1376
     case 'user_threads':
1377 1377
       $threads = db_query("
@@ -1395,45 +1395,45 @@  discard block
 block discarded – undo
1395 1395
         ORDER BY changed DESC
1396 1396
         LIMIT %d",
1397 1397
         $uid, (int) $count
1398
-      );
1399
-      $xml = array(
1398
+        );
1399
+        $xml = array(
1400 1400
         'rpc_response' => array(
1401
-          'count' => 0,
1402
-          'threads' => array(),
1401
+            'count' => 0,
1402
+            'threads' => array(),
1403 1403
         ),
1404
-      );
1405
-      $thread_count = 0;
1406
-      while ($thread = db_fetch_object($threads)) {
1404
+        );
1405
+        $thread_count = 0;
1406
+        while ($thread = db_fetch_object($threads)) {
1407 1407
         $xml['rpc_response']['threads']['thread'][] = array(
1408
-          'id' => $thread->nid,
1409
-          'forumid' => $thread->tid,
1410
-          'replies' => $thread->replies,
1411
-          'views' => $thread->views,
1412
-          'timestamp' => $thread->changed,
1413
-          'title' => $thread->title,
1408
+            'id' => $thread->nid,
1409
+            'forumid' => $thread->tid,
1410
+            'replies' => $thread->replies,
1411
+            'views' => $thread->views,
1412
+            'timestamp' => $thread->changed,
1413
+            'title' => $thread->title,
1414 1414
         );
1415 1415
         $thread_count++;
1416
-      }
1417
-      $xml['rpc_response']['count'] = $thread_count;
1418
-      break;
1416
+        }
1417
+        $xml['rpc_response']['count'] = $thread_count;
1418
+        break;
1419 1419
     default:
1420 1420
       $xml = array(
1421 1421
         'error' => array(
1422
-          'error_num' => -1,
1423
-          'error_msg' => 'Unknown error',
1422
+            'error_num' => -1,
1423
+            'error_msg' => 'Unknown error',
1424 1424
         ),
1425
-      );
1425
+        );
1426 1426
     }
1427
-  }
1428
-  else {
1427
+    }
1428
+    else {
1429 1429
     $xml = array(
1430
-      'error' => array(
1430
+        'error' => array(
1431 1431
         'error_num' => -136,
1432 1432
         'error_msg' => 'Not found',
1433
-      ),
1433
+        ),
1434 1434
     );
1435
-  }
1436
-  print xml_to_text(array_to_xml($xml), TRUE, TRUE);
1435
+    }
1436
+    print xml_to_text(array_to_xml($xml), TRUE, TRUE);
1437 1437
 }
1438 1438
 
1439 1439
 /**
@@ -1441,9 +1441,9 @@  discard block
 block discarded – undo
1441 1441
  * Get information on applications in the system
1442 1442
  */
1443 1443
 function boinccore_apps() {
1444
-  // Remove q from the GET request or BOINC will panic
1445
-  unset($_GET['q']);
1446
-  include_boinc('user/apps.php');
1444
+    // Remove q from the GET request or BOINC will panic
1445
+    unset($_GET['q']);
1446
+    include_boinc('user/apps.php');
1447 1447
 }
1448 1448
 
1449 1449
 /**
@@ -1453,141 +1453,141 @@  discard block
 block discarded – undo
1453 1453
  * controller function, which can compute the page based on the user's settings
1454 1454
  */
1455 1455
 function boinccore_url_pagination_handler($type, $object_id = NULL) {
1456
-  global $user;
1457
-  $path = NULL;
1458
-  $params = array();
1459
-  switch ($type) {
1460
-  case 'boinc-forum':
1456
+    global $user;
1457
+    $path = NULL;
1458
+    $params = array();
1459
+    switch ($type) {
1460
+    case 'boinc-forum':
1461 1461
     // Redirect requests to a BOINC forum to the Drupal forum
1462 1462
     $forum_id = db_result(db_query('
1463 1463
       SELECT tid
1464 1464
       FROM {boincimport_temp_forum}
1465 1465
       WHERE forum_id = %d',
1466
-      $object_id
1466
+        $object_id
1467 1467
     ));
1468 1468
     if ($forum_id) {
1469
-      drupal_goto("community/forum/{$forum_id}");
1469
+        drupal_goto("community/forum/{$forum_id}");
1470 1470
     }
1471 1471
     break;
1472
-  case 'boinc-forum-index':
1472
+    case 'boinc-forum-index':
1473 1473
     // Redirect requests to the top level BOINC forum to Drupal forums
1474 1474
     drupal_goto("community/forum");
1475 1475
     break;
1476
-  case 'boinc-forum-post':
1476
+    case 'boinc-forum-post':
1477 1477
     // Redirect requests to a BOINC forum post to the Drupal comment
1478 1478
     $cid = db_result(db_query('
1479 1479
       SELECT cid
1480 1480
       FROM {boincimport_temp_post}
1481 1481
       WHERE post_id = %d',
1482
-      $object_id
1482
+        $object_id
1483 1483
     ));
1484 1484
     if ($cid) {
1485
-      drupal_goto("goto/comment/{$cid}");
1485
+        drupal_goto("goto/comment/{$cid}");
1486 1486
     }
1487 1487
     break;
1488
-  case 'boinc-forum-topic':
1488
+    case 'boinc-forum-topic':
1489 1489
     // Redirect requests to a BOINC forum topic to the Drupal node
1490 1490
     $nid = db_result(db_query('
1491 1491
       SELECT nid
1492 1492
       FROM {boincimport_temp_topic}
1493 1493
       WHERE topic_id = %d',
1494
-      $object_id
1494
+        $object_id
1495 1495
     ));
1496 1496
     if ($nid) {
1497
-      drupal_goto("node/{$nid}");
1497
+        drupal_goto("node/{$nid}");
1498 1498
     }
1499 1499
     break;
1500
-  case 'boinc-host':
1500
+    case 'boinc-host':
1501 1501
     // Redirect requests to BOINC host details to the host page in Drupal
1502 1502
     drupal_goto("host/{$object_id}");
1503 1503
     break;
1504
-  case 'boinc-hosts-user':
1504
+    case 'boinc-hosts-user':
1505 1505
     // Redirect requests to a BOINC user host list to the host list in Drupal
1506 1506
     $uid = boincuser_lookup_uid($object_id);
1507 1507
     if ($uid) {
1508
-      drupal_goto("account/{$uid}/computers");
1508
+        drupal_goto("account/{$uid}/computers");
1509 1509
     }
1510 1510
     break;
1511
-  case 'boinc-result':
1511
+    case 'boinc-result':
1512 1512
     // Redirect requests to BOINC task details to the task page in Drupal
1513 1513
     drupal_goto("task/{$object_id}");
1514
-  case 'boinc-results-host':
1514
+    case 'boinc-results-host':
1515 1515
     // Redirect requests to BOINC tasks by host to the host task page in Drupal
1516 1516
     drupal_goto("host/{$object_id}/tasks");
1517 1517
     break;
1518
-  case 'boinc-results-user':
1518
+    case 'boinc-results-user':
1519 1519
     // Redirect requests to a BOINC user's tasks to the Drupal account tasks
1520 1520
     drupal_goto("account/tasks");
1521 1521
     break;
1522
-  case 'boinc-user':
1522
+    case 'boinc-user':
1523 1523
     // Redirect requests to a BOINC user ID to the Drupal profile
1524 1524
     $uid = boincuser_lookup_uid($object_id);
1525 1525
     if ($uid) {
1526
-      drupal_goto("account/{$uid}");
1526
+        drupal_goto("account/{$uid}");
1527 1527
     }
1528 1528
     break;
1529
-  case 'boinc-workunit':
1529
+    case 'boinc-workunit':
1530 1530
     // Redirect requests to BOINC workunits to the workunit page in Drupal
1531 1531
     drupal_goto("workunit/{$object_id}");
1532 1532
     break;
1533
-  case 'comment':
1533
+    case 'comment':
1534 1534
     $object = _comment_load($object_id);
1535 1535
     if ($object) {
1536
-      $path = "node/{$object->nid}";
1537
-      // Get the sort order
1538
-      $gt_lt = '<';
1539
-      $comment_order = (isset($user->sort)) ? $user->sort : variable_get('comment_default_order_forum', 2);
1540
-      if ($comment_order == COMMENT_ORDER_NEWEST_FIRST) {
1536
+        $path = "node/{$object->nid}";
1537
+        // Get the sort order
1538
+        $gt_lt = '<';
1539
+        $comment_order = (isset($user->sort)) ? $user->sort : variable_get('comment_default_order_forum', 2);
1540
+        if ($comment_order == COMMENT_ORDER_NEWEST_FIRST) {
1541 1541
         $gt_lt = '>';
1542
-      }
1543
-      // See how many comments there are before (or after) this comment...
1544
-      $comment_offset = db_result(db_query('
1542
+        }
1543
+        // See how many comments there are before (or after) this comment...
1544
+        $comment_offset = db_result(db_query('
1545 1545
         SELECT COUNT(*) FROM {comments}
1546 1546
         WHERE nid = %d AND status = 0 AND timestamp %s %d',
1547 1547
         $object->nid, $gt_lt, $object->timestamp));
1548
-      if ($comment_offset) {
1548
+        if ($comment_offset) {
1549 1549
         // Get the number of comments per page
1550 1550
         if ($user->comments_per_page) {
1551
-          $comments_per_page = $user->comments_per_page;
1551
+            $comments_per_page = $user->comments_per_page;
1552 1552
         }
1553 1553
         else {
1554
-          $node = node_load($object->nid);
1555
-          $comments_per_page = variable_get(
1554
+            $node = node_load($object->nid);
1555
+            $comments_per_page = variable_get(
1556 1556
             "comment_default_per_page_{$node->type}", 50
1557
-          );
1557
+            );
1558 1558
         }
1559 1559
         // Determine which page to display in order to show the given comment
1560 1560
         $page = floor($comment_offset / $comments_per_page);
1561 1561
         if ($page) {
1562
-          $params = array('page' => $page);
1562
+            $params = array('page' => $page);
1563
+        }
1563 1564
         }
1564
-      }
1565 1565
     }
1566 1566
     if ($path) {
1567
-      drupal_goto($path, $params, "comment-{$object->cid}");
1567
+        drupal_goto($path, $params, "comment-{$object->cid}");
1568 1568
     }
1569 1569
     break;
1570
-  case 'friend-requests':
1570
+    case 'friend-requests':
1571 1571
     // Check for a login, then redirect to the user's friend requests page
1572 1572
     if ($user->uid) {
1573
-      drupal_goto("account/{$user->uid}/friends/pending");
1573
+        drupal_goto("account/{$user->uid}/friends/pending");
1574 1574
     }
1575 1575
     else {
1576
-      drupal_goto('user/login', array(
1576
+        drupal_goto('user/login', array(
1577 1577
         'destination' => 'goto/friend-requests'
1578
-      ));
1578
+        ));
1579 1579
     }
1580 1580
     break;
1581
-  default:
1581
+    default:
1582 1582
   }
1583
-  drupal_not_found();
1583
+    drupal_not_found();
1584 1584
 }
1585 1585
 
1586 1586
 /*
1587 1587
  * Fetch an array of all countries 
1588 1588
  */
1589 1589
 function boinccore_get_country_list() {
1590
-  return array(
1590
+    return array(
1591 1591
     'None' => 'None',
1592 1592
     'International' => 'International',
1593 1593
     'Afghanistan' => 'Afghanistan',
@@ -1821,7 +1821,7 @@  discard block
 block discarded – undo
1821 1821
     'Yemen' => 'Yemen',
1822 1822
     'Zambia' => 'Zambia',
1823 1823
     'Zimbabwe' => 'Zimbabwe',
1824
-  );
1824
+    );
1825 1825
 }
1826 1826
 
1827 1827
 
@@ -1829,79 +1829,79 @@  discard block
 block discarded – undo
1829 1829
  * Action: Mark node for moderation
1830 1830
  */
1831 1831
 function boinccore_rules_action_mark_content_for_moderation($node) {
1832
-  $node->moderate = 1;
1833
-  return array('node' => $node);
1832
+    $node->moderate = 1;
1833
+    return array('node' => $node);
1834 1834
 }
1835 1835
 
1836 1836
 /**
1837 1837
  * Action: Send mail to moderators.
1838 1838
  */
1839 1839
 function boinccore_rules_action_mail_to_moderators($settings) {
1840
-  module_load_include('inc', 'rules', 'modules/system.rules');
1841
-  $mailing_list = variable_get('boinc_moderator_mailing_list', '');
1842
-  $force_individual_notifications = variable_get('boinc_moderator_force_individual_notifications', 0);
1840
+    module_load_include('inc', 'rules', 'modules/system.rules');
1841
+    $mailing_list = variable_get('boinc_moderator_mailing_list', '');
1842
+    $force_individual_notifications = variable_get('boinc_moderator_force_individual_notifications', 0);
1843 1843
   
1844
-  if (!$mailing_list OR $force_individual_notifications) {
1844
+    if (!$mailing_list OR $force_individual_notifications) {
1845 1845
     // Send individual emails to all moderators
1846 1846
     $roles = user_roles();
1847 1847
     $moderator_rid = array_search('moderator', $roles);
1848 1848
     if ($moderator_rid !== FALSE) {
1849
-      $settings['recipients'] = array($moderator_rid);
1850
-      rules_action_mail_to_users_of_role($settings);
1849
+        $settings['recipients'] = array($moderator_rid);
1850
+        rules_action_mail_to_users_of_role($settings);
1851 1851
     }
1852 1852
     else {
1853
-      watchdog(
1853
+        watchdog(
1854 1854
         'boinccore',
1855 1855
         'Unable to identify members of the moderator role to send moderator notifications!',
1856 1856
         array(),
1857 1857
         WATCHDOG_ERROR
1858
-      );
1858
+        );
1859 1859
     }
1860
-  }
1861
-  if ($mailing_list) {
1860
+    }
1861
+    if ($mailing_list) {
1862 1862
     $settings['to'] = $mailing_list;
1863 1863
     rules_action_mail($settings);
1864
-  }
1864
+    }
1865 1865
 }
1866 1866
 /**
1867 1867
  * Action "Send mail to moderators" configuration form
1868 1868
  */
1869 1869
 function boinccore_rules_action_mail_to_moderators_form($settings = array(), &$form) {
1870
-  // Select only non-anonymous user roles because anonymous users won't have emails.
1871
-  rules_action_mail_to_user_form($settings, $form);
1870
+    // Select only non-anonymous user roles because anonymous users won't have emails.
1871
+    rules_action_mail_to_user_form($settings, $form);
1872 1872
 }
1873 1873
 
1874 1874
 /*
1875 1875
  * BOINC wrapper for string translation
1876 1876
  */
1877 1877
 function bts($string, $args = array(), $langcode = NULL, $context = 'boinc: ', $update = TRUE) {
1878
-  if (function_exists('i18nstrings_ts')) {
1878
+    if (function_exists('i18nstrings_ts')) {
1879 1879
     $string = i18nstrings_ts($context, $string, $langcode, $update);
1880
-  }
1881
-  if (empty($args)) {
1880
+    }
1881
+    if (empty($args)) {
1882 1882
     return $string;
1883
-  }
1884
-  else {
1883
+    }
1884
+    else {
1885 1885
     // Transform arguments before inserting them.
1886 1886
     foreach ($args as $key => $value) {
1887
-      switch ($key [0]) {
1887
+        switch ($key [0]) {
1888 1888
         case '@':
1889 1889
           // Escaped only.
1890 1890
           $args [$key] = check_plain($value);
1891
-          break;
1891
+            break;
1892 1892
 
1893 1893
         case '%':
1894 1894
         default:
1895 1895
           // Escaped and placeholder.
1896 1896
           $args [$key] = theme('placeholder', $value);
1897
-          break;
1897
+            break;
1898 1898
 
1899 1899
         case '!':
1900 1900
           // Pass-through.
1901 1901
       }
1902 1902
     }
1903 1903
     return strtr($string, $args);
1904
-  }
1904
+    }
1905 1905
 }
1906 1906
 
1907 1907
 
@@ -1913,9 +1913,9 @@  discard block
 block discarded – undo
1913 1913
  * Overview of moderation queues
1914 1914
  */               
1915 1915
 function boinccore_moderation_overview_panel() {
1916
-  $output = '<h2 class="pane-title">' . bts('Moderation') . '</h2>';
1917
-  $output .= '<ul class="tab-list action-list">';
1918
-  if (module_exists('user_profiles')) {
1916
+    $output = '<h2 class="pane-title">' . bts('Moderation') . '</h2>';
1917
+    $output .= '<ul class="tab-list action-list">';
1918
+    if (module_exists('user_profiles')) {
1919 1919
     $profile_count = db_result(db_query("
1920 1920
       SELECT COUNT(DISTINCT(n.nid))
1921 1921
       FROM {node} n
@@ -1927,7 +1927,7 @@  discard block
 block discarded – undo
1927 1927
     $output .= '<span class="item-count">' . $profile_count . '</span>';
1928 1928
     $output .= '</div>';
1929 1929
     $output .= '</li>';
1930
-  }
1931
-  $output .= '</ul>';
1932
-  return $output;
1930
+    }
1931
+    $output .= '</ul>';
1932
+    return $output;
1933 1933
 }
Please login to merge, or discard this patch.
Switch Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -551,12 +551,12 @@  discard block
 block discarded – undo
551 551
  */
552 552
 function boinccore_locale($op = 'groups', $group = NULL) {
553 553
   switch ($op) {
554
-    case 'groups':
555
-      return array('boinc' => bts('BOINC'));
556
-    case 'info':
557
-      //$info['boinc']['refresh callback'] = 'boinccore_locale_refresh';
558
-      $info['boinc']['format'] = FALSE;
559
-      return $info;
554
+  case 'groups':
555
+    return array('boinc' => bts('BOINC'));
556
+  case 'info':
557
+    //$info['boinc']['refresh callback'] = 'boinccore_locale_refresh';
558
+    $info['boinc']['format'] = FALSE;
559
+    return $info;
560 560
   }
561 561
 }
562 562
 
@@ -1885,19 +1885,19 @@  discard block
 block discarded – undo
1885 1885
     // Transform arguments before inserting them.
1886 1886
     foreach ($args as $key => $value) {
1887 1887
       switch ($key [0]) {
1888
-        case '@':
1889
-          // Escaped only.
1890
-          $args [$key] = check_plain($value);
1891
-          break;
1892
-
1893
-        case '%':
1894
-        default:
1895
-          // Escaped and placeholder.
1896
-          $args [$key] = theme('placeholder', $value);
1897
-          break;
1898
-
1899
-        case '!':
1900
-          // Pass-through.
1888
+      case '@':
1889
+        // Escaped only.
1890
+        $args [$key] = check_plain($value);
1891
+        break;
1892
+
1893
+      case '%':
1894
+      default:
1895
+        // Escaped and placeholder.
1896
+        $args [$key] = theme('placeholder', $value);
1897
+        break;
1898
+
1899
+      case '!':
1900
+        // Pass-through.
1901 1901
       }
1902 1902
     }
1903 1903
     return strtr($string, $args);
Please login to merge, or discard this patch.
Braces   +28 added lines, -56 removed lines patch added patch discarded remove patch
@@ -378,8 +378,7 @@  discard block
 block discarded – undo
378 378
       $user_info .= '  <div class="picture">';
379 379
       if (is_array($user_image) AND $user_image['image']['filepath']) {
380 380
         $user_info .= theme('imagefield_image', $user_image['image'], $user_image['alt'], $user_image['alt'], array(), false);
381
-      }
382
-      elseif (is_string($user_image)) {
381
+      } elseif (is_string($user_image)) {
383 382
         $user_info .= '<img src="' . $user_image . '"/>';
384 383
       }
385 384
       $user_info .= '  </div>';
@@ -421,8 +420,7 @@  discard block
 block discarded – undo
421 420
     // If a specific comment is being referenced, go back to it on cancel
422 421
     if ($comment_ref = $form['pid']['#value']) {
423 422
       $cancel_url = "goto/comment/{$comment_ref}";
424
-    }
425
-    else {
423
+    } else {
426 424
       $cancel_url = "node/{$form['nid']['#value']}";
427 425
     }
428 426
     
@@ -525,8 +523,7 @@  discard block
 block discarded – undo
525 523
           'title' => bts('Reply to this topic with a quote')
526 524
       );
527 525
     }
528
-  }
529
-  else {
526
+  } else {
530 527
     // Standard EDIT, DELETE, and REPLY links are created by Drupal, but we want to alter them
531 528
     if (isset($links['comment_delete'])) {
532 529
       $links['comment_delete']['attributes'] = array(
@@ -580,8 +577,7 @@  discard block
 block discarded – undo
580 577
                   'title' => bts('Remove sticky status from this topic')
581 578
               )
582 579
           );
583
-        }
584
-        else {
580
+        } else {
585 581
           $links['make_sticky'] = array(
586 582
               'title' => bts('Make sticky'),
587 583
               'href' => "{$node_control}/sticky",
@@ -598,8 +594,7 @@  discard block
 block discarded – undo
598 594
                   'title' => bts('Lock this thread for comments')
599 595
               )
600 596
           );
601
-        }
602
-        else {
597
+        } else {
603 598
           $links['unlock'] = array(
604 599
               'title' => bts('Unlock'),
605 600
               'href' => "{$node_control}/unlock",
@@ -616,8 +611,7 @@  discard block
 block discarded – undo
616 611
                   'title' => bts('Hide this topic')
617 612
               )
618 613
           );
619
-        }
620
-        else {
614
+        } else {
621 615
           $links['unhide'] = array(
622 616
               'title' => bts('Unhide'),
623 617
               'href' => "{$node_control}/unhide",
@@ -628,8 +622,7 @@  discard block
 block discarded – undo
628 622
         }
629 623
       }// if user_access('edit any forum topic')
630 624
     }
631
-  }
632
-  else if ($type=='comment') {
625
+  } else if ($type=='comment') {
633 626
     $node = node_load($object->nid);
634 627
     $nid = $object->nid;
635 628
     $cid = $object->cid;
@@ -670,8 +663,7 @@  discard block
 block discarded – undo
670 663
                 'title' => bts('Hide this comment')
671 664
             )
672 665
         );
673
-      }
674
-      else {
666
+      } else {
675 667
         $links['unhide'] = array(
676 668
             'title' => bts('Unhide'),
677 669
             'href' => "{$comment_control}/unhide",
@@ -853,8 +845,7 @@  discard block
 block discarded – undo
853 845
       watchdog('am_set_info', "XML validation error in global_prefs: {$errors[0]->message} at line {$errors[0]->line}" .
854 846
         ': <br/>' . htmlentities($lines[$errors[0]->line - 1]), array(), WATCHDOG_ERROR);
855 847
     }
856
-  }
857
-  elseif ($project_prefs) {
848
+  } elseif ($project_prefs) {
858 849
     $xml->loadXML($project_prefs, LIBXML_NOBLANKS);
859 850
     if ($errors = libxml_get_errors($xml)) {
860 851
       $lines = explode("\r", $project_prefs);
@@ -897,8 +888,7 @@  discard block
 block discarded – undo
897 888
         node_save($content_profile);
898 889
       }
899 890
     }
900
-  }
901
-  else {
891
+  } else {
902 892
     $xml = array(
903 893
       'error' => array(
904 894
         'error_num' => -112,
@@ -1033,8 +1023,7 @@  discard block
 block discarded – undo
1033 1023
           node_save($node);
1034 1024
           // Save the team IDs to a BOINC <--> Drupal reference table.
1035 1025
           db_query('INSERT INTO {boincteam} (team_id, nid) VALUES (%d, %d)', $boincteam_id, $node->nid);
1036
-        }
1037
-        else {
1026
+        } else {
1038 1027
           $xml['create_team_reply']['warning'] = t(
1039 1028
             'There was a problem integrating this team into Drupal. Please
1040 1029
             contact @project administrators!', array('@project' => PROJECT)
@@ -1049,8 +1038,7 @@  discard block
 block discarded – undo
1049 1038
           // Delete from the BOINC DB if we can't sync with Drupal
1050 1039
           $boincteam::delete();
1051 1040
         }
1052
-      }
1053
-      else {
1041
+      } else {
1054 1042
         $xml['create_team_reply']['warning'] = t(
1055 1043
           'There was a problem integrating this team into Drupal. Please
1056 1044
           contact @project administrators!', array('@project' => PROJECT)
@@ -1064,8 +1052,7 @@  discard block
 block discarded – undo
1064 1052
         );
1065 1053
       }
1066 1054
     }
1067
-  }
1068
-  else {
1055
+  } else {
1069 1056
     $xml = array(
1070 1057
       'error' => array(
1071 1058
         'error_num' => -1,
@@ -1152,8 +1139,7 @@  discard block
 block discarded – undo
1152 1139
         );
1153 1140
         $xml['users']['user'][] = $team_member;
1154 1141
       }
1155
-    }
1156
-    else {
1142
+    } else {
1157 1143
       $members = array();
1158 1144
       db_set_active('boinc');
1159 1145
       $result = db_query("
@@ -1191,8 +1177,7 @@  discard block
 block discarded – undo
1191 1177
         $xml['users']['user'][] = $team_member;
1192 1178
       }
1193 1179
     }
1194
-  }
1195
-  else {
1180
+  } else {
1196 1181
     $xml = array(
1197 1182
       'error' => array(
1198 1183
         'error_num' => -136,
@@ -1241,24 +1226,19 @@  discard block
 block discarded – undo
1241 1226
                 if ($avatar_image) {
1242 1227
                   $profile_node->field_image[0] = $avatar_image;
1243 1228
                   node_save($profile_node);
1244
-                }
1245
-                else {
1229
+                } else {
1246 1230
                   $error = 'Error saving avatar to profile';
1247 1231
                 }
1248
-              }
1249
-              else {
1232
+              } else {
1250 1233
                 $error = 'Unable to load user profile';
1251 1234
               }
1252
-            }
1253
-            else {
1235
+            } else {
1254 1236
               $error = 'User has no profile, so avatar could not be added';
1255 1237
             }
1256
-          }
1257
-          else {
1238
+          } else {
1258 1239
             $error = 'Unable to save remote image';
1259 1240
           }
1260
-        }
1261
-        else {
1241
+        } else {
1262 1242
           $error = 'Could not find avatar image at URL';
1263 1243
         }
1264 1244
       }
@@ -1285,8 +1265,7 @@  discard block
 block discarded – undo
1285 1265
             'success' => NULL,
1286 1266
           ),
1287 1267
         );
1288
-      }
1289
-      else {
1268
+      } else {
1290 1269
         // Failure
1291 1270
         $xml = array(
1292 1271
           'error' => array(
@@ -1295,8 +1274,7 @@  discard block
 block discarded – undo
1295 1274
           ),
1296 1275
         );
1297 1276
       }
1298
-    }
1299
-    else {
1277
+    } else {
1300 1278
       // Drupal user not found
1301 1279
       $xml = array(
1302 1280
         'error' => array(
@@ -1305,8 +1283,7 @@  discard block
 block discarded – undo
1305 1283
         ),
1306 1284
       );
1307 1285
     }
1308
-  }
1309
-  else {
1286
+  } else {
1310 1287
     // BOINC user not found
1311 1288
     $xml = array(
1312 1289
       'error' => array(
@@ -1424,8 +1401,7 @@  discard block
 block discarded – undo
1424 1401
         ),
1425 1402
       );
1426 1403
     }
1427
-  }
1428
-  else {
1404
+  } else {
1429 1405
     $xml = array(
1430 1406
       'error' => array(
1431 1407
         'error_num' => -136,
@@ -1549,8 +1525,7 @@  discard block
 block discarded – undo
1549 1525
         // Get the number of comments per page
1550 1526
         if ($user->comments_per_page) {
1551 1527
           $comments_per_page = $user->comments_per_page;
1552
-        }
1553
-        else {
1528
+        } else {
1554 1529
           $node = node_load($object->nid);
1555 1530
           $comments_per_page = variable_get(
1556 1531
             "comment_default_per_page_{$node->type}", 50
@@ -1571,8 +1546,7 @@  discard block
 block discarded – undo
1571 1546
     // Check for a login, then redirect to the user's friend requests page
1572 1547
     if ($user->uid) {
1573 1548
       drupal_goto("account/{$user->uid}/friends/pending");
1574
-    }
1575
-    else {
1549
+    } else {
1576 1550
       drupal_goto('user/login', array(
1577 1551
         'destination' => 'goto/friend-requests'
1578 1552
       ));
@@ -1848,8 +1822,7 @@  discard block
 block discarded – undo
1848 1822
     if ($moderator_rid !== FALSE) {
1849 1823
       $settings['recipients'] = array($moderator_rid);
1850 1824
       rules_action_mail_to_users_of_role($settings);
1851
-    }
1852
-    else {
1825
+    } else {
1853 1826
       watchdog(
1854 1827
         'boinccore',
1855 1828
         'Unable to identify members of the moderator role to send moderator notifications!',
@@ -1880,8 +1853,7 @@  discard block
 block discarded – undo
1880 1853
   }
1881 1854
   if (empty($args)) {
1882 1855
     return $string;
1883
-  }
1884
-  else {
1856
+  } else {
1885 1857
     // Transform arguments before inserting them.
1886 1858
     foreach ($args as $key => $value) {
1887 1859
       switch ($key [0]) {
Please login to merge, or discard this patch.
Upper-Lower-Casing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -68,84 +68,84 @@  discard block
 block discarded – undo
68 68
     'title' => 'Look up account RPC',
69 69
     'description' => 'RPC for getting the authenticator for a user account.',
70 70
     'page callback' => 'boinccore_lookup_account',
71
-    'access callback' => TRUE,
71
+    'access callback' => true,
72 72
     'type' => MENU_CALLBACK
73 73
   );
74 74
   $items['am_get_info.php'] = array(
75 75
     'title' => 'Account manager get info RPC',
76 76
     'description' => 'RPC for getting assorted details of a user account.',
77 77
     'page callback' => 'boinccore_am_get_info',
78
-    'access callback' => TRUE,
78
+    'access callback' => true,
79 79
     'type' => MENU_CALLBACK
80 80
   );
81 81
   $items['am_set_info.php'] = array(
82 82
     'title' => 'Account manager set info RPC',
83 83
     'description' => 'RPC for updating assorted details of a user account.',
84 84
     'page callback' => 'boinccore_am_set_info',
85
-    'access callback' => TRUE,
85
+    'access callback' => true,
86 86
     'type' => MENU_CALLBACK
87 87
   );
88 88
   $items['am_set_host_info.php'] = array(
89 89
     'title' => 'Account manager set host info RPC',
90 90
     'description' => 'RPC for updating the venue for a given host.',
91 91
     'page callback' => 'boinccore_am_set_host_info',
92
-    'access callback' => TRUE,
92
+    'access callback' => true,
93 93
     'type' => MENU_CALLBACK
94 94
   );
95 95
   $items['show_user.php'] = array(
96 96
     'title' => 'Show user RPC',
97 97
     'description' => 'RPC for getting assorted details of a user account.',
98 98
     'page callback' => 'boinccore_show_user',
99
-    'access callback' => TRUE,
99
+    'access callback' => true,
100 100
     'type' => MENU_CALLBACK
101 101
   );
102 102
   $items['pending.php'] = array(
103 103
     'title' => 'Pending credit RPC',
104 104
     'description' => 'RPC for getting pending credit for a given account.',
105 105
     'page callback' => 'boinccore_pending_credit',
106
-    'access callback' => TRUE,
106
+    'access callback' => true,
107 107
     'type' => MENU_CALLBACK
108 108
   );
109 109
   $items['create_team.php'] = array(
110 110
     'title' => 'Create team RPC',
111 111
     'description' => 'RPC for creating a new team.',
112 112
     'page callback' => 'boinccore_create_team',
113
-    'access callback' => TRUE,
113
+    'access callback' => true,
114 114
     'type' => MENU_CALLBACK
115 115
   );
116 116
   $items['team_lookup.php'] = array(
117 117
     'title' => 'Team lookup RPC',
118 118
     'description' => 'RPC for getting info on a team or matching teams.',
119 119
     'page callback' => 'boinccore_team_lookup',
120
-    'access callback' => TRUE,
120
+    'access callback' => true,
121 121
     'type' => MENU_CALLBACK
122 122
   );
123 123
   $items['team_email_list.php'] = array(
124 124
     'title' => 'Get team member list RPC',
125 125
     'description' => 'RPC for getting a list of members of a given team.',
126 126
     'page callback' => 'boinccore_team_email_list',
127
-    'access callback' => TRUE,
127
+    'access callback' => true,
128 128
     'type' => MENU_CALLBACK
129 129
   );
130 130
   $items['edit_forum_preferences_action.php'] = array(
131 131
     'title' => 'Forum preferences RPC',
132 132
     'description' => 'RPC for setting forum preferences for a given user.',
133 133
     'page callback' => 'boinccore_edit_forum_preferences',
134
-    'access callback' => TRUE,
134
+    'access callback' => true,
135 135
     'type' => MENU_CALLBACK
136 136
   );
137 137
   $items['forum_get_data.php'] = array(
138 138
     'title' => 'Forum get data RPC',
139 139
     'description' => 'RPC for getting recent forum activity for a given user.',
140 140
     'page callback' => 'boinccore_forum_get_data',
141
-    'access callback' => TRUE,
141
+    'access callback' => true,
142 142
     'type' => MENU_CALLBACK
143 143
   );
144 144
   $items['apps.php'] = array(
145 145
     'title' => 'Apps RPC',
146 146
     'description' => 'RPC for getting the applications in the system.',
147 147
     'page callback' => 'boinccore_apps',
148
-    'access callback' => TRUE,
148
+    'access callback' => true,
149 149
     'type' => MENU_CALLBACK
150 150
   );
151 151
   
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
  */
158 158
 function boinccore_menu_alter(&$items) {
159 159
   // If using Solr search and not core Drupal search, disable core search!
160
-  if (module_exists('global_search_solr') AND !module_exists('global_search')) {
160
+  if (module_exists('global_search_solr') and !module_exists('global_search')) {
161 161
     // Add permission to user search.
162 162
     $check = array(
163 163
       'search/node/%menu_tail',
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
     );
167 167
     foreach ($check as $path) {
168 168
       if (isset($items[$path])) {
169
-        $items[$path]['access callback'] = FALSE;
169
+        $items[$path]['access callback'] = false;
170 170
       }
171 171
     }
172 172
   }
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
       // Since we are in a hook_boot() implementation cache mode is normal, so
225 225
       // we can safely call hook_exit().
226 226
       bootstrap_invoke_all('exit');
227
-      header("Location: $url", TRUE, $code);
227
+      header("Location: $url", true, $code);
228 228
       exit;
229 229
     }
230 230
   }
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
  */
243 243
   function locale_language_from_browser() {
244 244
     if (empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
245
-      return FALSE;
245
+      return false;
246 246
     }
247 247
     
248 248
     $languages = language_list('enabled');
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
     // Find the enabled language with the greatest qvalue, following the rules
286 286
     // of RFC 2616 (section 14.4). If several languages have the same qvalue,
287 287
     // prefer the one with the greatest weight.
288
-    $best_match_language = FALSE;
288
+    $best_match_language = false;
289 289
     $max_qvalue = 0;
290 290
     foreach ($languages as $langcode => $language) {
291 291
       // Language tags are case insensitive (RFC2616, sec 3.10).
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
   // Notify moderators if there is site content that requires moderator action
325 325
   $items_in_queue = boincuser_moderation_queue_count('cron');
326 326
   $last_notification = variable_get('boinccore_last_content_moderation_reminder', 0);
327
-  if ($items_in_queue AND $last_notification < time() - 24*60*60) {
327
+  if ($items_in_queue and $last_notification < time() - 24*60*60) {
328 328
     global $base_url;
329 329
     global $base_path;
330 330
     $site_name = variable_get('site_name', bts('project'));
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
     $user_info = '<div class="user">';
377 377
     if ($user_image) {
378 378
       $user_info .= '  <div class="picture">';
379
-      if (is_array($user_image) AND $user_image['image']['filepath']) {
379
+      if (is_array($user_image) and $user_image['image']['filepath']) {
380 380
         $user_info .= theme('imagefield_image', $user_image['image'], $user_image['alt'], $user_image['alt'], array(), false);
381 381
       }
382 382
       elseif (is_string($user_image)) {
@@ -411,8 +411,8 @@  discard block
 block discarded – undo
411 411
       '#attributes' => array(
412 412
         'class' => 'bbcode_help',
413 413
       ),
414
-      '#collapsible' => TRUE,
415
-      '#collapsed' => TRUE,
414
+      '#collapsible' => true,
415
+      '#collapsed' => true,
416 416
       'content' => array(
417 417
         '#value' => _bbcode_filter_tip(),
418 418
       ),
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
 /**
503 503
  * Implementation of hook_link_alter()
504 504
  */
505
-function boinccore_link_alter(&$links, $node, $comment = NULL) {
505
+function boinccore_link_alter(&$links, $node, $comment = null) {
506 506
   //echo '<pre>' . print_r($links, true) . '</pre>';
507 507
   foreach ($links as $module => $link) {
508 508
     // Remove the ignore user link
@@ -549,13 +549,13 @@  discard block
 block discarded – undo
549 549
 /**
550 550
  * Implementation of hook_locale().
551 551
  */
552
-function boinccore_locale($op = 'groups', $group = NULL) {
552
+function boinccore_locale($op = 'groups', $group = null) {
553 553
   switch ($op) {
554 554
     case 'groups':
555 555
       return array('boinc' => bts('BOINC'));
556 556
     case 'info':
557 557
       //$info['boinc']['refresh callback'] = 'boinccore_locale_refresh';
558
-      $info['boinc']['format'] = FALSE;
558
+      $info['boinc']['format'] = false;
559 559
       return $info;
560 560
   }
561 561
 }
@@ -564,11 +564,11 @@  discard block
 block discarded – undo
564 564
 /**
565 565
  * Implementation of hook_link()
566 566
  */
567
-function boinccore_link($type, $object, $teaser = FALSE) {
567
+function boinccore_link($type, $object, $teaser = false) {
568 568
   // Add custom links with this hook
569 569
 
570 570
   if ($type=='node') {
571
-    if ( ($object->type=='forum') OR ($object->type=='team_forum') ) {
571
+    if ( ($object->type=='forum') or ($object->type=='team_forum') ) {
572 572
       // Add topic moderator controls
573 573
       if (user_access('edit any forum topic')) {
574 574
         $node_control = "node_control/{$object->nid}";
@@ -696,12 +696,12 @@  discard block
 block discarded – undo
696 696
  * Allow published, sticky, and comment status to be set on nodes by direct
697 697
  * link rather than through the node form.
698 698
  */
699
-function boinccore_node_control($nid = NULL, $action = NULL) {
700
-  if ((!$nid OR !$node = node_load($nid)) OR
701
-      ($node->type == 'forum' AND !user_access('edit any forum topic')) OR
702
-      ($node->type != 'forum' AND !user_access('administer nodes'))) {
699
+function boinccore_node_control($nid = null, $action = null) {
700
+  if ((!$nid or !$node = node_load($nid)) or
701
+      ($node->type == 'forum' and !user_access('edit any forum topic')) or
702
+      ($node->type != 'forum' and !user_access('administer nodes'))) {
703 703
     // What are you even doing here...
704
-    return FALSE;
704
+    return false;
705 705
   }
706 706
   switch ($action) {
707 707
   case 'unhide':
@@ -737,10 +737,10 @@  discard block
 block discarded – undo
737 737
  * Allow published status to be set on comments by direct link rather than
738 738
  * through the comment edit form.
739 739
  */
740
-function boinccore_comment_control($cid = NULL, $action = NULL) {
741
-  if (!$cid OR !$comment = _comment_load($cid)) {
740
+function boinccore_comment_control($cid = null, $action = null) {
741
+  if (!$cid or !$comment = _comment_load($cid)) {
742 742
     // What are you even doing here...
743
-    return FALSE;
743
+    return false;
744 744
   }
745 745
   $return_path = "node/{$comment->nid}";
746 746
   $return_anchor = "comment-{$cid}";
@@ -789,11 +789,11 @@  discard block
 block discarded – undo
789 789
     _comment_delete_thread($comment);
790 790
     
791 791
     $return_path = "node/{$node->nid}";
792
-    $return_anchor = NULL;
792
+    $return_anchor = null;
793 793
     break;
794 794
   default:
795 795
   }
796
-  drupal_goto($return_path, NULL, $return_anchor);
796
+  drupal_goto($return_path, null, $return_anchor);
797 797
 }
798 798
 
799 799
 /**
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
   $uid = !empty($xml['am_get_info_reply']['id']) ? boincuser_lookup_uid($xml['am_get_info_reply']['id']) : 0;
821 821
   if ($uid) {
822 822
     $content_profile = content_profile_load('profile', $uid);
823
-    $profile_is_approved = ($content_profile->status AND !$content_profile->moderate);
823
+    $profile_is_approved = ($content_profile->status and !$content_profile->moderate);
824 824
     $country = check_plain($content_profile->field_country[0]['value']);
825 825
     $website = '';
826 826
     if ($profile_is_approved) {
@@ -842,8 +842,8 @@  discard block
 block discarded – undo
842 842
   // Remove q from the GET request or BOINC will panic
843 843
   unset($_GET['q']);
844 844
   // Validate the XML prefs (in case BOINC does not)
845
-  $global_prefs = !empty($_POST['global_prefs']) ? $_POST['global_prefs'] : (!empty($_GET['global_prefs']) ? $_GET['global_prefs'] : NULL);
846
-  $project_prefs = !empty($_POST['project_prefs']) ? $_POST['project_prefs'] : (!empty($_GET['project_prefs']) ? $_GET['project_prefs'] : NULL);
845
+  $global_prefs = !empty($_POST['global_prefs']) ? $_POST['global_prefs'] : (!empty($_GET['global_prefs']) ? $_GET['global_prefs'] : null);
846
+  $project_prefs = !empty($_POST['project_prefs']) ? $_POST['project_prefs'] : (!empty($_GET['project_prefs']) ? $_GET['project_prefs'] : null);
847 847
   libxml_use_internal_errors(true);
848 848
   $xml = new DomDocument();
849 849
   if ($global_prefs) {
@@ -882,15 +882,15 @@  discard block
 block discarded – undo
882 882
       $uid = boincuser_lookup_uid($boinc_id);
883 883
       
884 884
       // Apply any relevant updates to the Drupal account, also
885
-      $country = !empty($_POST['country']) ? $_POST['country'] : (!empty($_GET['country']) ? $_GET['country'] : NULL);
886
-      $url = !empty($_POST['url']) ? $_POST['url'] : (!empty($_GET['url']) ? $_GET['url'] : NULL);
887
-      $email_addr = !empty($_POST['email_addr']) ? $_POST['email_addr'] : (!empty($_GET['email_addr']) ? $_GET['email_addr'] : NULL);
885
+      $country = !empty($_POST['country']) ? $_POST['country'] : (!empty($_GET['country']) ? $_GET['country'] : null);
886
+      $url = !empty($_POST['url']) ? $_POST['url'] : (!empty($_GET['url']) ? $_GET['url'] : null);
887
+      $email_addr = !empty($_POST['email_addr']) ? $_POST['email_addr'] : (!empty($_GET['email_addr']) ? $_GET['email_addr'] : null);
888 888
       
889 889
       if ($email_addr) {
890 890
         $account = user_load($uid);
891 891
         user_save($account, array('mail' => $email_addr));
892 892
       }
893
-      if ($country OR $url) {
893
+      if ($country or $url) {
894 894
         $content_profile = content_profile_load('profile', $uid);
895 895
         if ($country) $content_profile->field_country[0]['value'] = $country;
896 896
         if ($url) $content_profile->field_url[0]['value'] = $url;
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
   $uid = !empty($xml['user']['id']) ? boincuser_lookup_uid($xml['user']['id']) : 0;
945 945
   if ($uid) {
946 946
     $content_profile = content_profile_load('profile', $uid);
947
-    $profile_is_approved = ($content_profile->status AND !$content_profile->moderate);
947
+    $profile_is_approved = ($content_profile->status and !$content_profile->moderate);
948 948
     $country = check_plain($content_profile->field_country[0]['value']);
949 949
     $website = '';
950 950
     if ($profile_is_approved) {
@@ -1107,9 +1107,9 @@  discard block
 block discarded – undo
1107 1107
   $show_xml = !empty($_POST['xml']) ? $_POST['xml'] : $_GET['xml'];
1108 1108
   if (!$show_xml) {
1109 1109
       // creditonly does not affect non xml output in BOINC
1110
-      $credit_only = FALSE;
1110
+      $credit_only = false;
1111 1111
   }
1112
-  $admin_request = FALSE;
1112
+  $admin_request = false;
1113 1113
   if ($boincteam_id && is_numeric($boincteam_id)) {
1114 1114
     if ($account_key) {
1115 1115
       // See if this is a team admin
@@ -1124,9 +1124,9 @@  discard block
 block discarded – undo
1124 1124
       ));
1125 1125
       db_set_active('default');
1126 1126
       require_boinc('team');
1127
-      $boincuser = boincuser_load(boincuser_lookup_uid($boincuser_id), TRUE);
1127
+      $boincuser = boincuser_load(boincuser_lookup_uid($boincuser_id), true);
1128 1128
       $boincteam = boincteam_load($boincteam_id);
1129
-      $admin_request = is_team_admin($boincuser, $boincteam) OR is_team_founder($boincuser, $boincteam);
1129
+      $admin_request = is_team_admin($boincuser, $boincteam) or is_team_founder($boincuser, $boincteam);
1130 1130
     }
1131 1131
 
1132 1132
     if ($credit_only) {
@@ -1183,7 +1183,7 @@  discard block
 block discarded – undo
1183 1183
           'expavg_credit' => $member->boincuser_expavg_credit,
1184 1184
           'expavg_time' => $member->boincuser_expavg_time,
1185 1185
           'url' => $content_profile->field_url[0]['value'],
1186
-          'has_profile' => ($content_profile->status AND !$content_profile->moderate) ? 1 : 0,
1186
+          'has_profile' => ($content_profile->status and !$content_profile->moderate) ? 1 : 0,
1187 1187
         );
1188 1188
         if ($admin_request) {
1189 1189
           $team_member['email_addr'] = $member->mail;
@@ -1200,7 +1200,7 @@  discard block
 block discarded – undo
1200 1200
       ),
1201 1201
     );
1202 1202
   }
1203
-  print xml_to_text(array_to_xml($xml), TRUE, TRUE);
1203
+  print xml_to_text(array_to_xml($xml), true, true);
1204 1204
 }
1205 1205
 
1206 1206
 /**
@@ -1211,18 +1211,18 @@  discard block
 block discarded – undo
1211 1211
   // Do not pass through to BOINC in this case as BOINC forums are no longer
1212 1212
   // relevant -- use Drupal data only
1213 1213
   
1214
-  $account_key = !empty($_POST['account_key']) ? $_POST['account_key'] : (!empty($_GET['account_key']) ? $_GET['account_key'] : NULL);
1214
+  $account_key = !empty($_POST['account_key']) ? $_POST['account_key'] : (!empty($_GET['account_key']) ? $_GET['account_key'] : null);
1215 1215
   
1216 1216
   require_boinc('boinc_db');
1217 1217
   $boincuser = BoincUser::lookup_auth($account_key);
1218 1218
   if ($boincuser) {
1219 1219
     $uid = boincuser_lookup_uid($boincuser->id);
1220
-    if ($uid AND $account = user_load($uid)) {
1220
+    if ($uid and $account = user_load($uid)) {
1221 1221
       // Currently supported preferences
1222
-      $avatar_url = isset($_POST['avatar_url']) ? $_POST['avatar_url'] : (isset($_GET['avatar_url']) ? $_GET['avatar_url'] : NULL);
1223
-      $hide_signatures = isset($_POST['forum_hide_signatures']) ? $_POST['forum_hide_signatures'] : (isset($_GET['forum_hide_signatures']) ? $_GET['forum_hide_signatures'] : NULL);
1224
-      $signature = isset($_POST['signature']) ? $_POST['signature'] : (isset($_GET['signature']) ? $_GET['signature'] : NULL);
1225
-      $post_order = isset($_POST['thread_sort']) ? $_POST['thread_sort'] : (isset($_GET['thread_sort']) ? $_GET['thread_sort'] : NULL);
1222
+      $avatar_url = isset($_POST['avatar_url']) ? $_POST['avatar_url'] : (isset($_GET['avatar_url']) ? $_GET['avatar_url'] : null);
1223
+      $hide_signatures = isset($_POST['forum_hide_signatures']) ? $_POST['forum_hide_signatures'] : (isset($_GET['forum_hide_signatures']) ? $_GET['forum_hide_signatures'] : null);
1224
+      $signature = isset($_POST['signature']) ? $_POST['signature'] : (isset($_GET['signature']) ? $_GET['signature'] : null);
1225
+      $post_order = isset($_POST['thread_sort']) ? $_POST['thread_sort'] : (isset($_GET['thread_sort']) ? $_GET['thread_sort'] : null);
1226 1226
       // Update preferences as needed
1227 1227
       if ($avatar_url) {
1228 1228
         $avatar_image = file_get_contents($avatar_url);
@@ -1233,11 +1233,11 @@  discard block
 block discarded – undo
1233 1233
           if ($file) {
1234 1234
             $profile = new stdClass();
1235 1235
             $profile->type = 'profile';
1236
-            $profile->language = NULL;
1236
+            $profile->language = null;
1237 1237
             if ($profile_nid = content_profile_profile_exists($profile, $account->uid)) {
1238 1238
               $profile_node = node_load($profile_nid);
1239 1239
               if ($profile_node) {
1240
-                $avatar_image = get_cck_image_object(file_directory_path() . '/' . $image_path, 'field_image', 'profile', TRUE);
1240
+                $avatar_image = get_cck_image_object(file_directory_path() . '/' . $image_path, 'field_image', 'profile', true);
1241 1241
                 if ($avatar_image) {
1242 1242
                   $profile_node->field_image[0] = $avatar_image;
1243 1243
                   node_save($profile_node);
@@ -1262,10 +1262,10 @@  discard block
 block discarded – undo
1262 1262
           $error = 'Could not find avatar image at URL';
1263 1263
         }
1264 1264
       }
1265
-      if ($hide_signatures !== NULL) {
1265
+      if ($hide_signatures !== null) {
1266 1266
         user_save($account, array('hide_signatures' => ($hide_signatures ? 1 : 0)));
1267 1267
       }
1268
-      if ($signature !== NULL) {
1268
+      if ($signature !== null) {
1269 1269
         $signature = check_markup($signature);
1270 1270
         user_save($account, array('signature' => $signature));
1271 1271
       }
@@ -1282,7 +1282,7 @@  discard block
 block discarded – undo
1282 1282
         // Success
1283 1283
         $xml = array(
1284 1284
           'edit_forum_preferences' => array(
1285
-            'success' => NULL,
1285
+            'success' => null,
1286 1286
           ),
1287 1287
         );
1288 1288
       }
@@ -1315,7 +1315,7 @@  discard block
 block discarded – undo
1315 1315
       ),
1316 1316
     );
1317 1317
   }
1318
-  print xml_to_text(array_to_xml($xml), TRUE, TRUE);
1318
+  print xml_to_text(array_to_xml($xml), true, true);
1319 1319
 }
1320 1320
 
1321 1321
 /**
@@ -1327,17 +1327,17 @@  discard block
 block discarded – undo
1327 1327
   // relevant -- use Drupal data only
1328 1328
   
1329 1329
   $xml = array();
1330
-  $boinc_id = !empty($_POST['userid']) ? $_POST['userid'] : (!empty($_GET['userid']) ? $_GET['userid'] : NULL);
1330
+  $boinc_id = !empty($_POST['userid']) ? $_POST['userid'] : (!empty($_GET['userid']) ? $_GET['userid'] : null);
1331 1331
   $uid = boincuser_lookup_uid($boinc_id);
1332 1332
   
1333 1333
   if ($uid) {
1334
-    $method = !empty($_POST['method']) ? $_POST['method'] : (!empty($_GET['method']) ? $_GET['method'] : NULL);
1335
-    $count = !empty($_POST['count']) ? $_POST['count'] : (!empty($_GET['count']) ? $_GET['count'] : NULL);
1334
+    $method = !empty($_POST['method']) ? $_POST['method'] : (!empty($_GET['method']) ? $_GET['method'] : null);
1335
+    $count = !empty($_POST['count']) ? $_POST['count'] : (!empty($_GET['count']) ? $_GET['count'] : null);
1336 1336
     if (!$count) $count = 10;
1337 1337
     
1338 1338
     switch ($method) {
1339 1339
     case 'user_posts':
1340
-      $content_length = !empty($_POST['content_length']) ? $_POST['content_length'] : (!empty($_GET['content_length']) ? $_GET['content_length'] : NULL);
1340
+      $content_length = !empty($_POST['content_length']) ? $_POST['content_length'] : (!empty($_GET['content_length']) ? $_GET['content_length'] : null);
1341 1341
       $posts = db_query("
1342 1342
         SELECT
1343 1343
           c.cid,
@@ -1433,7 +1433,7 @@  discard block
 block discarded – undo
1433 1433
       ),
1434 1434
     );
1435 1435
   }
1436
-  print xml_to_text(array_to_xml($xml), TRUE, TRUE);
1436
+  print xml_to_text(array_to_xml($xml), true, true);
1437 1437
 }
1438 1438
 
1439 1439
 /**
@@ -1452,9 +1452,9 @@  discard block
 block discarded – undo
1452 1452
  * in advance on which page a given comment will appear. Link instead to this
1453 1453
  * controller function, which can compute the page based on the user's settings
1454 1454
  */
1455
-function boinccore_url_pagination_handler($type, $object_id = NULL) {
1455
+function boinccore_url_pagination_handler($type, $object_id = null) {
1456 1456
   global $user;
1457
-  $path = NULL;
1457
+  $path = null;
1458 1458
   $params = array();
1459 1459
   switch ($type) {
1460 1460
   case 'boinc-forum':
@@ -1841,11 +1841,11 @@  discard block
 block discarded – undo
1841 1841
   $mailing_list = variable_get('boinc_moderator_mailing_list', '');
1842 1842
   $force_individual_notifications = variable_get('boinc_moderator_force_individual_notifications', 0);
1843 1843
   
1844
-  if (!$mailing_list OR $force_individual_notifications) {
1844
+  if (!$mailing_list or $force_individual_notifications) {
1845 1845
     // Send individual emails to all moderators
1846 1846
     $roles = user_roles();
1847 1847
     $moderator_rid = array_search('moderator', $roles);
1848
-    if ($moderator_rid !== FALSE) {
1848
+    if ($moderator_rid !== false) {
1849 1849
       $settings['recipients'] = array($moderator_rid);
1850 1850
       rules_action_mail_to_users_of_role($settings);
1851 1851
     }
@@ -1874,7 +1874,7 @@  discard block
 block discarded – undo
1874 1874
 /*
1875 1875
  * BOINC wrapper for string translation
1876 1876
  */
1877
-function bts($string, $args = array(), $langcode = NULL, $context = 'boinc: ', $update = TRUE) {
1877
+function bts($string, $args = array(), $langcode = null, $context = 'boinc: ', $update = true) {
1878 1878
   if (function_exists('i18nstrings_ts')) {
1879 1879
     $string = i18nstrings_ts($context, $string, $langcode, $update);
1880 1880
   }
Please login to merge, or discard this patch.