Passed
Push — master ( 90102b...16e7c5 )
by Christian
07:15
created
drupal/sites/default/boinc/modules/boinccore/boinccore.module 1 patch
Indentation   +705 added lines, -705 removed lines patch added patch discarded remove patch
@@ -29,22 +29,22 @@  discard block
 block discarded – undo
29 29
  * with defined URL paths
30 30
  */
31 31
 function boinccore_menu() {
32
-  $items['node_control'] = array(
32
+    $items['node_control'] = array(
33 33
     'page callback' => 'boinccore_node_control',
34 34
     'access arguments' => array('access content'),
35 35
     'type' => MENU_CALLBACK
36
-  );
37
-  $items['comment_control'] = array(
36
+    );
37
+    $items['comment_control'] = array(
38 38
     'page callback' => 'boinccore_comment_control',
39 39
     'access arguments' => array('administer comments'),
40 40
     'type' => MENU_CALLBACK
41
-  );
42
-  $items['goto'] = array(
41
+    );
42
+    $items['goto'] = array(
43 43
     'page callback' => 'boinccore_url_pagination_handler',
44 44
     'access arguments' => array('access content'),
45 45
     'type' => MENU_CALLBACK
46
-  );
47
-  $items['admin/boinc/community'] = array(
46
+    );
47
+    $items['admin/boinc/community'] = array(
48 48
     'title' => 'Community',
49 49
     'description' => 'Global settings for community interaction.',
50 50
     'page callback' => 'drupal_get_form',
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
     'access arguments' => array('administer site configuration'),
53 53
     'type' => MENU_NORMAL_ITEM,
54 54
     'file' => 'boinccore.admin.inc'
55
-  );
56
-  $items['admin/boinc/standard-content-generator'] = array(
55
+    );
56
+    $items['admin/boinc/standard-content-generator'] = array(
57 57
     'title' => 'Standard page generator',
58 58
     'description' => 'Regenerate standard site content (e.g. Help and About Us
59 59
       pages).',
@@ -62,172 +62,172 @@  discard block
 block discarded – undo
62 62
     'access arguments' => array('administer site configuration'),
63 63
     'type' => MENU_NORMAL_ITEM,
64 64
     'file' => 'boinccore.admin.inc'
65
-  );
65
+    );
66 66
   
67
-  // BOINC RPC wrappers
68
-  $items['lookup_account.php'] = array(
67
+    // BOINC RPC wrappers
68
+    $items['lookup_account.php'] = array(
69 69
     'title' => 'Look up account RPC',
70 70
     'description' => 'RPC for getting the authenticator for a user account.',
71 71
     'page callback' => 'boinccore_lookup_account',
72 72
     'access callback' => TRUE,
73 73
     'type' => MENU_CALLBACK
74
-  );
75
-  $items['am_get_info.php'] = array(
74
+    );
75
+    $items['am_get_info.php'] = array(
76 76
     'title' => 'Account manager get info RPC',
77 77
     'description' => 'RPC for getting assorted details of a user account.',
78 78
     'page callback' => 'boinccore_am_get_info',
79 79
     'access callback' => TRUE,
80 80
     'type' => MENU_CALLBACK
81
-  );
82
-  $items['am_set_info.php'] = array(
81
+    );
82
+    $items['am_set_info.php'] = array(
83 83
     'title' => 'Account manager set info RPC',
84 84
     'description' => 'RPC for updating assorted details of a user account.',
85 85
     'page callback' => 'boinccore_am_set_info',
86 86
     'access callback' => TRUE,
87 87
     'type' => MENU_CALLBACK
88
-  );
89
-  $items['am_set_host_info.php'] = array(
88
+    );
89
+    $items['am_set_host_info.php'] = array(
90 90
     'title' => 'Account manager set host info RPC',
91 91
     'description' => 'RPC for updating the venue for a given host.',
92 92
     'page callback' => 'boinccore_am_set_host_info',
93 93
     'access callback' => TRUE,
94 94
     'type' => MENU_CALLBACK
95
-  );
96
-  $items['show_user.php'] = array(
95
+    );
96
+    $items['show_user.php'] = array(
97 97
     'title' => 'Show user RPC',
98 98
     'description' => 'RPC for getting assorted details of a user account.',
99 99
     'page callback' => 'boinccore_show_user',
100 100
     'access callback' => TRUE,
101 101
     'type' => MENU_CALLBACK
102
-  );
103
-  $items['pending.php'] = array(
102
+    );
103
+    $items['pending.php'] = array(
104 104
     'title' => 'Pending credit RPC',
105 105
     'description' => 'RPC for getting pending credit for a given account.',
106 106
     'page callback' => 'boinccore_pending_credit',
107 107
     'access callback' => TRUE,
108 108
     'type' => MENU_CALLBACK
109
-  );
110
-  $items['create_team.php'] = array(
109
+    );
110
+    $items['create_team.php'] = array(
111 111
     'title' => 'Create team RPC',
112 112
     'description' => 'RPC for creating a new team.',
113 113
     'page callback' => 'boinccore_create_team',
114 114
     'access callback' => TRUE,
115 115
     'type' => MENU_CALLBACK
116
-  );
117
-  $items['team_lookup.php'] = array(
116
+    );
117
+    $items['team_lookup.php'] = array(
118 118
     'title' => 'Team lookup RPC',
119 119
     'description' => 'RPC for getting info on a team or matching teams.',
120 120
     'page callback' => 'boinccore_team_lookup',
121 121
     'access callback' => TRUE,
122 122
     'type' => MENU_CALLBACK
123
-  );
124
-  $items['team_email_list.php'] = array(
123
+    );
124
+    $items['team_email_list.php'] = array(
125 125
     'title' => 'Get team member list RPC',
126 126
     'description' => 'RPC for getting a list of members of a given team.',
127 127
     'page callback' => 'boinccore_team_email_list',
128 128
     'access callback' => TRUE,
129 129
     'type' => MENU_CALLBACK
130
-  );
131
-  $items['edit_forum_preferences_action.php'] = array(
130
+    );
131
+    $items['edit_forum_preferences_action.php'] = array(
132 132
     'title' => 'Forum preferences RPC',
133 133
     'description' => 'RPC for setting forum preferences for a given user.',
134 134
     'page callback' => 'boinccore_edit_forum_preferences',
135 135
     'access callback' => TRUE,
136 136
     'type' => MENU_CALLBACK
137
-  );
138
-  $items['forum_get_data.php'] = array(
137
+    );
138
+    $items['forum_get_data.php'] = array(
139 139
     'title' => 'Forum get data RPC',
140 140
     'description' => 'RPC for getting recent forum activity for a given user.',
141 141
     'page callback' => 'boinccore_forum_get_data',
142 142
     'access callback' => TRUE,
143 143
     'type' => MENU_CALLBACK
144
-  );
145
-  $items['apps.php'] = array(
144
+    );
145
+    $items['apps.php'] = array(
146 146
     'title' => 'Apps RPC',
147 147
     'description' => 'RPC for getting the applications in the system.',
148 148
     'page callback' => 'boinccore_apps',
149 149
     'access callback' => TRUE,
150 150
     'type' => MENU_CALLBACK
151
-  );
151
+    );
152 152
   
153
-  return $items;
153
+    return $items;
154 154
 }
155 155
 
156 156
 /**
157 157
  * Implementation of hook_menu_alter()
158 158
  */
159 159
 function boinccore_menu_alter(&$items) {
160
-  // If using Solr search and not core Drupal search, disable core search!
161
-  if (module_exists('global_search_solr') AND !module_exists('global_search')) {
160
+    // If using Solr search and not core Drupal search, disable core search!
161
+    if (module_exists('global_search_solr') AND !module_exists('global_search')) {
162 162
     // Add permission to user search.
163 163
     $check = array(
164
-      'search/node/%menu_tail',
165
-      'search/user/%menu_tail',
166
-      'user/autocomplete'
164
+        'search/node/%menu_tail',
165
+        'search/user/%menu_tail',
166
+        'user/autocomplete'
167 167
     );
168 168
     foreach ($check as $path) {
169
-      if (isset($items[$path])) {
169
+        if (isset($items[$path])) {
170 170
         $items[$path]['access callback'] = FALSE;
171
-      }
171
+        }
172 172
     }
173
-  }
174
-  // If using content profile module (for user profiles) setup special
175
-  // delete page.
176
-  if (module_exists('content_profile')) {
173
+    }
174
+    // If using content profile module (for user profiles) setup special
175
+    // delete page.
176
+    if (module_exists('content_profile')) {
177 177
     $items['node/%node/delete'] = array(
178
-      'title' => 'Delete',
179
-      'page callback' => 'drupal_get_form',
180
-      'page arguments' => array('boinccore_delete_confirm', 1),
181
-      'access callback' => 'node_access',
182
-      'access arguments' => array('delete', 1),
183
-      'module' => 'boinccore',
184
-      'file' => 'includes/boinccore.forms.inc',
185
-      'weight' => 1,
186
-      'type' => MENU_CALLBACK,
178
+        'title' => 'Delete',
179
+        'page callback' => 'drupal_get_form',
180
+        'page arguments' => array('boinccore_delete_confirm', 1),
181
+        'access callback' => 'node_access',
182
+        'access arguments' => array('delete', 1),
183
+        'module' => 'boinccore',
184
+        'file' => 'includes/boinccore.forms.inc',
185
+        'weight' => 1,
186
+        'type' => MENU_CALLBACK,
187 187
     );
188
-  }
188
+    }
189 189
 
190
-  // 'Remove' menu paths for ignore_user and privatemsg
191
-  // (pm_block_user) module which we have 'overridden' with
192
-  // boincwork's own functions.
193
-  if (module_exists('ignore_user')) {
190
+    // 'Remove' menu paths for ignore_user and privatemsg
191
+    // (pm_block_user) module which we have 'overridden' with
192
+    // boincwork's own functions.
193
+    if (module_exists('ignore_user')) {
194 194
     $check = array(
195
-      'ignore_user/add',
196
-      'ignore_user/remove',
195
+        'ignore_user/add',
196
+        'ignore_user/remove',
197 197
     );
198 198
     foreach ($check as $path) {
199
-      if (isset($items[$path])) {
199
+        if (isset($items[$path])) {
200 200
         $items[$path]['access callback'] = FALSE;
201
-      }
201
+        }
202 202
     }
203 203
 
204 204
     // Redirect user to privacy prefs page.
205 205
     $path1 = 'ignore_user/list';
206 206
     if (isset($items[$path1])) {
207
-      $items[$path1]['page callback'] = 'drupal_goto';
208
-      $items[$path1]['page arguments'] = array('account/prefs/privacy');
207
+        $items[$path1]['page callback'] = 'drupal_goto';
208
+        $items[$path1]['page arguments'] = array('account/prefs/privacy');
209
+    }
209 210
     }
210
-  }
211 211
 
212
-  if (module_exists('pm_block_user')) {
212
+    if (module_exists('pm_block_user')) {
213 213
     $check = array(
214
-      'messages/block/%user',
214
+        'messages/block/%user',
215 215
     );
216 216
     foreach ($check as $path) {
217
-      if (isset($items[$path])) {
217
+        if (isset($items[$path])) {
218 218
         $items[$path]['access callback'] = FALSE;
219
-      }
219
+        }
220
+    }
220 221
     }
221
-  }
222 222
 }
223 223
 
224 224
 /**
225 225
  * Implementation of hook_enable()
226 226
  */
227 227
 function boinccore_enable() {
228
-  // Automatically try to establish standard site content when this module is
229
-  // enabled (e.g. Help and About Us pages)
230
-  boinccore_admin_default_content_generate();
228
+    // Automatically try to establish standard site content when this module is
229
+    // enabled (e.g. Help and About Us pages)
230
+    boinccore_admin_default_content_generate();
231 231
 }
232 232
 
233 233
 /**
@@ -240,14 +240,14 @@  discard block
 block discarded – undo
240 240
  * See: https://www.drupal.org/node/339958#comment-3012662
241 241
  */
242 242
 function boinccore_boot() {
243
-  global $user, $language;
244
-  $cache = variable_get('cache', CACHE_DISABLED);
245
-  $language_negotiation = variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE);
246
-
247
-  // If we have an anonymous user, page cache is enabled, the URL has no prefix
248
-  // and browser language negotiation is set, we perform a redirect to the
249
-  // prefixed URL. 
250
-  if (empty($user->uid) && $cache != CACHE_DISABLED && $language_negotiation == LANGUAGE_NEGOTIATION_PATH) {
243
+    global $user, $language;
244
+    $cache = variable_get('cache', CACHE_DISABLED);
245
+    $language_negotiation = variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE);
246
+
247
+    // If we have an anonymous user, page cache is enabled, the URL has no prefix
248
+    // and browser language negotiation is set, we perform a redirect to the
249
+    // prefixed URL. 
250
+    if (empty($user->uid) && $cache != CACHE_DISABLED && $language_negotiation == LANGUAGE_NEGOTIATION_PATH) {
251 251
     $args = isset($_GET['q']) ? explode('/', $_GET['q']) : array();
252 252
     $prefix = array_shift($args);
253 253
 
@@ -259,24 +259,24 @@  discard block
 block discarded – undo
259 259
     // so call this backported Drupal 7 language negotation function, which
260 260
     // does both case insensitive and longest prefix matching
261 261
     if (function_exists('locale_language_from_browser')) {
262
-      $language = locale_language_from_browser();
262
+        $language = locale_language_from_browser();
263 263
     }
264 264
 
265 265
     if (!empty($language->prefix) && $prefix != $language->prefix) {
266
-      // We need full path support to perform the redirect.
267
-      drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH);
268
-
269
-      require_once './includes/common.inc';
270
-      $url = url($_GET['q'], array('query' => drupal_query_string_encode($_GET, array('q'))));
271
-      $code = variable_get('locale_redirect_http_code', 302);
272
-
273
-      // Since we are in a hook_boot() implementation cache mode is normal, so
274
-      // we can safely call hook_exit().
275
-      bootstrap_invoke_all('exit');
276
-      header("Location: $url", TRUE, $code);
277
-      exit;
266
+        // We need full path support to perform the redirect.
267
+        drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH);
268
+
269
+        require_once './includes/common.inc';
270
+        $url = url($_GET['q'], array('query' => drupal_query_string_encode($_GET, array('q'))));
271
+        $code = variable_get('locale_redirect_http_code', 302);
272
+
273
+        // Since we are in a hook_boot() implementation cache mode is normal, so
274
+        // we can safely call hook_exit().
275
+        bootstrap_invoke_all('exit');
276
+        header("Location: $url", TRUE, $code);
277
+        exit;
278
+    }
278 279
     }
279
-  }
280 280
 }
281 281
 
282 282
 
@@ -289,9 +289,9 @@  discard block
 block discarded – undo
289 289
  *
290 290
  * Obsolete in Drupal 7...
291 291
  */
292
-  function locale_language_from_browser() {
292
+    function locale_language_from_browser() {
293 293
     if (empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
294
-      return FALSE;
294
+        return FALSE;
295 295
     }
296 296
     
297 297
     $languages = language_list('enabled');
@@ -306,14 +306,14 @@  discard block
 block discarded – undo
306 306
     // Samples: "hu, en-us;q=0.66, en;q=0.33", "hu,en-us;q=0.5"
307 307
     $browser_langcodes = array();
308 308
     if (preg_match_all('@(?<=[, ]|^)([a-zA-Z-]+|\*)(?:;q=([0-9.]+))?(?:$|\s*,\s*)@', trim($_SERVER['HTTP_ACCEPT_LANGUAGE']), $matches, PREG_SET_ORDER)) {
309
-      foreach ($matches as $match) {
309
+        foreach ($matches as $match) {
310 310
         // We can safely use strtolower() here, tags are ASCII.
311 311
         // RFC2616 mandates that the decimal part is no more than three digits,
312 312
         // so we multiply the qvalue by 1000 to avoid floating point comparisons.
313 313
         $langcode = strtolower($match[1]);
314 314
         $qvalue = isset($match[2]) ? (float) $match[2] : 1;
315 315
         $browser_langcodes[$langcode] = (int) ($qvalue * 1000);
316
-      }
316
+        }
317 317
     }
318 318
 
319 319
     // We should take pristine values from the HTTP headers, but Internet Explorer
@@ -325,10 +325,10 @@  discard block
 block discarded – undo
325 325
     // http://blogs.msdn.com/b/ie/archive/2006/10/17/accept-language-header-for-internet-explorer-7.aspx
326 326
     asort($browser_langcodes);
327 327
     foreach ($browser_langcodes as $langcode => $qvalue) {
328
-      $generic_tag = strtok($langcode, '-');
329
-      if (!isset($browser_langcodes[$generic_tag])) {
328
+        $generic_tag = strtok($langcode, '-');
329
+        if (!isset($browser_langcodes[$generic_tag])) {
330 330
         $browser_langcodes[$generic_tag] = $qvalue;
331
-      }
331
+        }
332 332
     }
333 333
 
334 334
     // Find the enabled language with the greatest qvalue, following the rules
@@ -337,151 +337,151 @@  discard block
 block discarded – undo
337 337
     $best_match_language = FALSE;
338 338
     $max_qvalue = 0;
339 339
     foreach ($languages as $langcode => $language) {
340
-      // Language tags are case insensitive (RFC2616, sec 3.10).
341
-      $langcode = strtolower($langcode);
340
+        // Language tags are case insensitive (RFC2616, sec 3.10).
341
+        $langcode = strtolower($langcode);
342 342
 
343
-      // If nothing matches below, the default qvalue is the one of the wildcard
344
-      // language, if set, or is 0 (which will never match).
345
-      $qvalue = isset($browser_langcodes['*']) ? $browser_langcodes['*'] : 0;
343
+        // If nothing matches below, the default qvalue is the one of the wildcard
344
+        // language, if set, or is 0 (which will never match).
345
+        $qvalue = isset($browser_langcodes['*']) ? $browser_langcodes['*'] : 0;
346 346
 
347
-      // Find the longest possible prefix of the browser-supplied language
348
-      // ('the language-range') that matches this site language ('the language tag').
349
-      $prefix = $langcode;
350
-      do {
347
+        // Find the longest possible prefix of the browser-supplied language
348
+        // ('the language-range') that matches this site language ('the language tag').
349
+        $prefix = $langcode;
350
+        do {
351 351
         if (isset($browser_langcodes[$prefix])) {
352
-          $qvalue = $browser_langcodes[$prefix];
353
-          break;
352
+            $qvalue = $browser_langcodes[$prefix];
353
+            break;
354 354
         }
355
-      } 
356
-       while ($prefix = substr($prefix, 0, strrpos($prefix, '-')));
355
+        } 
356
+        while ($prefix = substr($prefix, 0, strrpos($prefix, '-')));
357 357
 
358
-      // Find the best match.
359
-      if ($qvalue > $max_qvalue) {
358
+        // Find the best match.
359
+        if ($qvalue > $max_qvalue) {
360 360
         $best_match_language = $language;
361 361
         $max_qvalue = $qvalue;
362
-      }
362
+        }
363 363
     }
364 364
 
365 365
     return $best_match_language;
366
-  }
366
+    }
367 367
 }
368 368
 
369 369
 /**
370 370
  * Implementation of hook_cron()
371 371
  */
372 372
 function boinccore_cron() {
373
-  // Notify moderators if there is site content that requires moderator action
374
-  $items_in_queue = boincuser_moderation_queue_count('cron');
375
-  $last_notification = variable_get('boinccore_last_content_moderation_reminder', 0);
376
-  if ($items_in_queue AND $last_notification < time() - 24*60*60) {
373
+    // Notify moderators if there is site content that requires moderator action
374
+    $items_in_queue = boincuser_moderation_queue_count('cron');
375
+    $last_notification = variable_get('boinccore_last_content_moderation_reminder', 0);
376
+    if ($items_in_queue AND $last_notification < time() - 24*60*60) {
377 377
     global $base_url;
378 378
     global $base_path;
379 379
     $site_name = variable_get('site_name', 'Drupal-BOINC');
380 380
     $site_url = $base_url . $base_path;
381 381
     $settings = array(
382
-      'from' => '',
383
-      'subject' => "Content at {$site_name} is awaiting moderation",
384
-      'message' => ''
385
-      . "Please visit the moderation queue page to review content that "
386
-      . "requires moderator action: \n"
387
-      . "\n"
388
-      . "{$site_url}moderate",
382
+        'from' => '',
383
+        'subject' => "Content at {$site_name} is awaiting moderation",
384
+        'message' => ''
385
+        . "Please visit the moderation queue page to review content that "
386
+        . "requires moderator action: \n"
387
+        . "\n"
388
+        . "{$site_url}moderate",
389 389
     );
390 390
     boinccore_rules_action_mail_to_moderators($settings);
391 391
     variable_set('boinccore_last_content_moderation_reminder', time());
392
-  }
392
+    }
393 393
 
394
-  // Delete expired tokens in BOINC DB
395
-  _boinccore_delete_expired_tokens();
394
+    // Delete expired tokens in BOINC DB
395
+    _boinccore_delete_expired_tokens();
396 396
 }
397 397
 
398 398
 /**
399 399
  * Implementation of hook_rules_action_info().
400 400
  */
401 401
 function boinccore_rules_action_info() {
402
-  return array(
402
+    return array(
403 403
     'boinccore_rules_action_mail_to_moderators' => array(
404
-      'label' => t('Notify moderators via email'),
405
-      'module' => 'BOINC core',
406
-      'eval input' => array('subject', 'message', 'from'),
404
+        'label' => t('Notify moderators via email'),
405
+        'module' => 'BOINC core',
406
+        'eval input' => array('subject', 'message', 'from'),
407 407
     ),
408 408
     'boinccore_rules_action_mark_content_for_moderation' => array(
409
-      'label' => t('Mark content for moderation'),
410
-      'arguments' => array(
409
+        'label' => t('Mark content for moderation'),
410
+        'arguments' => array(
411 411
         'node' => array('type' => 'node', 'label' => t('Content')),
412
-      ),
413
-      'module' => 'BOINC core',
412
+        ),
413
+        'module' => 'BOINC core',
414 414
     ),
415
-  );
415
+    );
416 416
 }
417 417
 
418 418
 /**
419 419
  * Implementation of hook_form_alter()
420 420
  */
421 421
 function boinccore_form_alter(&$form, $form_state, $form_id) {
422
-  global $user;
423
-  $account = user_load($user->uid);
424
-  switch ($form_id) {
425
-  // Comment form
426
-  case 'comment_form':
422
+    global $user;
423
+    $account = user_load($user->uid);
424
+    switch ($form_id) {
425
+    // Comment form
426
+    case 'comment_form':
427 427
     $user_image = boincuser_get_user_profile_image($user->uid);
428 428
     $user_info = '<div class="user">';
429 429
     if ($user_image) {
430
-      $user_info .= '  <div class="picture">';
431
-      if (is_array($user_image) AND $user_image['image']['filepath']) {
430
+        $user_info .= '  <div class="picture">';
431
+        if (is_array($user_image) AND $user_image['image']['filepath']) {
432 432
         $user_info .= theme('imagefield_image', $user_image['image'], $user_image['alt'], $user_image['alt'], array(), false);
433
-      }
434
-      elseif (is_string($user_image)) {
433
+        }
434
+        elseif (is_string($user_image)) {
435 435
         $user_info .= '<img src="' . $user_image . '"/>';
436
-      }
437
-      $user_info .= '  </div>';
436
+        }
437
+        $user_info .= '  </div>';
438 438
     }
439 439
     $user_info .= '  <div class="name">' . theme('username', $account) . '</div>';
440 440
     if ($account->uid) {
441
-      //$user_info .= '  <div class="join-date">Joined: ' . date('j M y', $account->created) . '</div>';
442
-      //$user_info .= '  <div class="post-count">Posts: ' . $account->post_count . '</div>';
443
-      //$user_info .= '  <div class="credit">Credit: ' . $account->boincuser_total_credit . '</div>';
444
-      //$user_info .= '  <div class="rac">RAC: ' . $account->boincuser_expavg_credit . '</div>';
441
+        //$user_info .= '  <div class="join-date">Joined: ' . date('j M y', $account->created) . '</div>';
442
+        //$user_info .= '  <div class="post-count">Posts: ' . $account->post_count . '</div>';
443
+        //$user_info .= '  <div class="credit">Credit: ' . $account->boincuser_total_credit . '</div>';
444
+        //$user_info .= '  <div class="rac">RAC: ' . $account->boincuser_expavg_credit . '</div>';
445 445
     }
446 446
     $user_info .= '</div>';
447 447
     array_unshift($form, array(
448
-      'user_info' => array(
448
+        'user_info' => array(
449 449
         '#value' => $user_info,
450
-      ),
451
-      'comment_form_prefix' => array(
450
+        ),
451
+        'comment_form_prefix' => array(
452 452
         '#value' => '<div class="form-body">',
453
-      ),
453
+        ),
454 454
     ));
455 455
     $form['comment_form_suffix'] = array(
456
-      '#value' => '</div>',
456
+        '#value' => '</div>',
457 457
     );
458 458
     
459 459
     module_load_include('inc', 'bbcode', 'bbcode-help');
460 460
     $form['bbcode_help'] = array(
461
-      '#title' => bts('BBcode help', array(), NULL, 'boinc:help-with-user-input-with-BBCode'),
462
-      '#type' => 'fieldset',
463
-      '#attributes' => array(
461
+        '#title' => bts('BBcode help', array(), NULL, 'boinc:help-with-user-input-with-BBCode'),
462
+        '#type' => 'fieldset',
463
+        '#attributes' => array(
464 464
         'class' => 'bbcode_help',
465
-      ),
466
-      '#collapsible' => TRUE,
467
-      '#collapsed' => TRUE,
468
-      'content' => array(
465
+        ),
466
+        '#collapsible' => TRUE,
467
+        '#collapsed' => TRUE,
468
+        'content' => array(
469 469
         '#value' => _bbcode_filter_tip(),
470
-      ),
470
+        ),
471 471
     );
472 472
     
473 473
     // If a specific comment is being referenced, go back to it on cancel
474 474
     if ($comment_ref = $form['pid']['#value']) {
475
-      $cancel_url = "goto/comment/{$comment_ref}";
475
+        $cancel_url = "goto/comment/{$comment_ref}";
476 476
     }
477 477
     else {
478
-      $cancel_url = "node/{$form['nid']['#value']}";
478
+        $cancel_url = "node/{$form['nid']['#value']}";
479 479
     }
480 480
     
481 481
     // Wrap action buttons for styling consistency
482 482
     $form['buttons']['form control tabs prefix'] = array(
483
-      '#value' => '<ul class="form-control tab-list">',
484
-      '#weight' => 1001,
483
+        '#value' => '<ul class="form-control tab-list">',
484
+        '#weight' => 1001,
485 485
     );
486 486
     $form['buttons']['submit'] = $form['submit'];
487 487
     unset($form['submit']);
@@ -500,12 +500,12 @@  discard block
 block discarded – undo
500 500
     $form['buttons']['preview']['#suffix'] = '</li>';
501 501
     $form['buttons']['preview']['#weight'] = 1003;
502 502
     $form['buttons']['cancel'] = array(
503
-      '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $cancel_url) . '</li>',
504
-      '#weight' => 1004,
503
+        '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $cancel_url) . '</li>',
504
+        '#weight' => 1004,
505 505
     );
506 506
     $form['buttons']['form control tabs suffix'] = array(
507
-      '#value' => '</ul>',
508
-      '#weight' => 1010,
507
+        '#value' => '</ul>',
508
+        '#weight' => 1010,
509 509
     );
510 510
     
511 511
     // Remove redundant name field
@@ -521,38 +521,38 @@  discard block
 block discarded – undo
521 521
     $community_role = array_search('community member', user_roles(true));
522 522
     $unrestricted_role = array_search('verified contributor', user_roles(true));
523 523
     if ( (isset($account->roles[$community_role])) and (!isset($account->roles[$unrestricted_role])) ) {
524
-      if ($node->type == 'forum') {
524
+        if ($node->type == 'forum') {
525 525
         if (module_exists('captcha')) {
526
-          $form['comment_captcha'] = array(
526
+            $form['comment_captcha'] = array(
527 527
             '#type' => 'captcha',
528 528
             '#weight' => 1000,
529
-          );
529
+            );
530 530
         }
531
-      }
532
-      else {
531
+        }
532
+        else {
533 533
         $form = NULL;
534 534
         $form['from'] = array(
535
-          '#type'  => 'item',
536
-          '#value' => 'You do not have permission to post comments in this forum.',
535
+            '#type'  => 'item',
536
+            '#value' => 'You do not have permission to post comments in this forum.',
537 537
         );
538
-      }
538
+        }
539 539
     }
540 540
     
541 541
     break;
542 542
     
543
-  // Forum node form
544
-  case 'forum_node_form':
543
+    // Forum node form
544
+    case 'forum_node_form':
545 545
   case 'team_forum_node_form':
546 546
     $forum_id = key($form['#node']->taxonomy);
547 547
     $form['buttons']['separator_bottom'] = array(
548
-      '#value' => '<div class="separator buttons"></div>',
549
-      '#weight' => 999,
548
+        '#value' => '<div class="separator buttons"></div>',
549
+        '#weight' => 999,
550 550
     );
551 551
     
552 552
     // Wrap action buttons for styling consistency
553 553
     $form['buttons']['form control tabs prefix'] = array(
554
-      '#value' => '<ul class="form-control tab-list">',
555
-      '#weight' => 1001,
554
+        '#value' => '<ul class="form-control tab-list">',
555
+        '#weight' => 1001,
556 556
     );
557 557
     $form['buttons']['submit']['#prefix'] = '<li class="first tab">';
558 558
     $form['buttons']['submit']['#value'] = bts('Post topic', array(), NULL, 'boinc:post-forum-comment');
@@ -565,28 +565,28 @@  discard block
 block discarded – undo
565 565
     $form['buttons']['preview_changes']['#suffix'] = '</li>';
566 566
     $form['buttons']['preview_changes']['#weight'] = 1004;
567 567
     $form['buttons']['cancel'] = array(
568
-      '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "community/forum/{$forum_id}") . '</li>',
569
-      '#weight' => 1005,
568
+        '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "community/forum/{$forum_id}") . '</li>',
569
+        '#weight' => 1005,
570 570
     );
571 571
     $form['buttons']['form control tabs suffix'] = array(
572
-      '#value' => '</ul>',
573
-      '#weight' => 1010,
572
+        '#value' => '</ul>',
573
+        '#weight' => 1010,
574 574
     );
575 575
 
576 576
     // Add captcha for role='community member'
577 577
     $community_role = array_search('community member', user_roles(true));
578 578
     $unrestricted_role = array_search('verified contributor', user_roles(true));
579 579
     if ( (isset($account->roles[$community_role])) and (!isset($account->roles[$unrestricted_role])) ) {
580
-      if (module_exists('captcha')) {
580
+        if (module_exists('captcha')) {
581 581
         $form['comment_captcha'] = array(
582
-          '#type' => 'captcha',
583
-          '#weight' => 1000,
582
+            '#type' => 'captcha',
583
+            '#weight' => 1000,
584 584
         );
585
-      }
585
+        }
586 586
     }
587 587
 
588 588
     break;
589
-  case 'boinccore_delete_confirm':
589
+    case 'boinccore_delete_confirm':
590 590
     // Wrap action buttons for styling consistency
591 591
     $form['actions']['#prefix'] = '<ul class="form-control tab-list">';
592 592
     $form['actions']['#suffix'] = '</ul>';
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
     $form['actions']['cancel']['#prefix'] = '<li class="tab">';
597 597
     $form['actions']['cancel']['#suffix'] = '</li>';
598 598
     break;
599
-  default:
599
+    default:
600 600
   }
601 601
 }
602 602
 
@@ -604,61 +604,61 @@  discard block
 block discarded – undo
604 604
  * Implementation of hook_link_alter()
605 605
  */
606 606
 function boinccore_link_alter(&$links, $node, $comment = NULL) {
607
-  //echo '<pre>' . print_r($links, true) . '</pre>';
608
-  foreach ($links as $module => $link) {
607
+    //echo '<pre>' . print_r($links, true) . '</pre>';
608
+    foreach ($links as $module => $link) {
609 609
     // Remove the ignore user link
610 610
     if (strstr($module, 'ignore_user')) {
611
-      unset($links[$module]);
611
+        unset($links[$module]);
612 612
     }
613
-  }
614
-  // Node first, then comment: to be consistent with boinccore_link() function
615
-  if (!($comment)) {
613
+    }
614
+    // Node first, then comment: to be consistent with boinccore_link() function
615
+    if (!($comment)) {
616 616
     // modify the comment_add link
617 617
     if (isset($links['comment_add'])) {
618
-      $links['comment_add']['title'] = bts('reply', array(), NULL, 'boinc:forum-reply-to-comment');
619
-      $links['comment_add']['attributes'] = array(
620
-          'title' => bts('Reply to this comment', array(), NULL, 'boinc:forum-reply-to-comment')
621
-      );
618
+        $links['comment_add']['title'] = bts('reply', array(), NULL, 'boinc:forum-reply-to-comment');
619
+        $links['comment_add']['attributes'] = array(
620
+            'title' => bts('Reply to this comment', array(), NULL, 'boinc:forum-reply-to-comment')
621
+        );
622 622
     }
623 623
     // modify quote link
624 624
     if (isset($links['quote'])) {
625
-      $links['quote']['attributes'] = array(
626
-          'title' => bts('Reply to this topic with a quote', array(), NULL, 'boinc:forum-reply-to-comment')
627
-      );
625
+        $links['quote']['attributes'] = array(
626
+            'title' => bts('Reply to this topic with a quote', array(), NULL, 'boinc:forum-reply-to-comment')
627
+        );
628 628
     }
629
-  }
630
-  else {
629
+    }
630
+    else {
631 631
     // Standard EDIT, DELETE, and REPLY links are created by Drupal, but we want to alter them
632 632
     if (isset($links['comment_delete'])) {
633
-      $links['comment_delete']['attributes'] = array(
634
-          'title' => bts('Delete this comment', array(), NULL, 'boinc:forum-delete-comment')
635
-      );
633
+        $links['comment_delete']['attributes'] = array(
634
+            'title' => bts('Delete this comment', array(), NULL, 'boinc:forum-delete-comment')
635
+        );
636 636
     }
637 637
     if (isset($links['comment_edit'])) {
638
-      $links['comment_edit']['attributes'] = array(
639
-          'title' => bts('Edit this comment', array(), NULL, 'boinc:forum-edit-comment')
640
-      );
638
+        $links['comment_edit']['attributes'] = array(
639
+            'title' => bts('Edit this comment', array(), NULL, 'boinc:forum-edit-comment')
640
+        );
641 641
     }
642 642
     if (isset($links['comment_reply'])) {
643
-      $links['comment_reply']['attributes'] = array(
644
-          'title' => bts('Reply to this comment', array(), NULL, 'boinc:forum-reply-to-comment')
645
-      );
643
+        $links['comment_reply']['attributes'] = array(
644
+            'title' => bts('Reply to this comment', array(), NULL, 'boinc:forum-reply-to-comment')
645
+        );
646 646
     }
647
-  }// if !$comment
647
+    }// if !$comment
648 648
 }
649 649
 
650 650
 /**
651 651
  * Implementation of hook_locale().
652 652
  */
653 653
 function boinccore_locale($op = 'groups', $group = NULL) {
654
-  switch ($op) {
654
+    switch ($op) {
655 655
     case 'groups':
656 656
         return array('boinc' => 'BOINC');
657 657
     case 'info':
658 658
       //$info['boinc']['refresh callback'] = 'boinccore_locale_refresh';
659 659
       $info['boinc']['format'] = FALSE;
660
-      return $info;
661
-  }
660
+        return $info;
661
+    }
662 662
 }
663 663
 
664 664
 
@@ -666,71 +666,71 @@  discard block
 block discarded – undo
666 666
  * Implementation of hook_link()
667 667
  */
668 668
 function boinccore_link($type, $object, $teaser = FALSE) {
669
-  // Add custom links with this hook
669
+    // Add custom links with this hook
670 670
 
671
-  if ($type=='node') {
671
+    if ($type=='node') {
672 672
     if ( ($object->type=='forum') OR ($object->type=='team_forum') ) {
673
-      // Add topic moderator controls
674
-      if (user_access('edit any forum topic')) {
673
+        // Add topic moderator controls
674
+        if (user_access('edit any forum topic')) {
675 675
         $node_control = "node_control/{$object->nid}";
676 676
         if ($object->sticky) {
677
-          $links['make_unsticky'] = array(
678
-              'title' => bts('Make unsticky', array(), NULL, 'boinc:forum-unsticky-comment'),
679
-              'href' => "{$node_control}/unsticky",
680
-              'attributes' => array(
681
-                  'title' => bts('Remove sticky status from this topic', array(), NULL, 'boinc:forum-unsticky-comment')
682
-              )
683
-          );
677
+            $links['make_unsticky'] = array(
678
+                'title' => bts('Make unsticky', array(), NULL, 'boinc:forum-unsticky-comment'),
679
+                'href' => "{$node_control}/unsticky",
680
+                'attributes' => array(
681
+                    'title' => bts('Remove sticky status from this topic', array(), NULL, 'boinc:forum-unsticky-comment')
682
+                )
683
+            );
684 684
         }
685 685
         else {
686
-          $links['make_sticky'] = array(
687
-              'title' => bts('Make sticky', array(), NULL, 'boinc:forum-sticky-comment'),
688
-              'href' => "{$node_control}/sticky",
689
-              'attributes' => array(
690
-                  'title' => bts('Make this topic sticky', array(), NULL, 'boinc:forum-sticky-comment')
691
-              )
692
-          );
686
+            $links['make_sticky'] = array(
687
+                'title' => bts('Make sticky', array(), NULL, 'boinc:forum-sticky-comment'),
688
+                'href' => "{$node_control}/sticky",
689
+                'attributes' => array(
690
+                    'title' => bts('Make this topic sticky', array(), NULL, 'boinc:forum-sticky-comment')
691
+                )
692
+            );
693 693
         }
694 694
         if ($object->comment == COMMENT_NODE_READ_WRITE) {
695
-          $links['lock'] = array(
696
-              'title' => bts('Lock', array(), NULL, 'boinc:forum-lock-comment'),
697
-              'href' => "{$node_control}/lock",
698
-              'attributes' => array(
699
-                  'title' => bts('Lock this thread for comments', array(), NULL, 'boinc:forum-lock-comment')
700
-              )
701
-          );
695
+            $links['lock'] = array(
696
+                'title' => bts('Lock', array(), NULL, 'boinc:forum-lock-comment'),
697
+                'href' => "{$node_control}/lock",
698
+                'attributes' => array(
699
+                    'title' => bts('Lock this thread for comments', array(), NULL, 'boinc:forum-lock-comment')
700
+                )
701
+            );
702 702
         }
703 703
         else {
704
-          $links['unlock'] = array(
705
-              'title' => bts('Unlock', array(), NULL, 'boinc:forum-unlock-comment'),
706
-              'href' => "{$node_control}/unlock",
707
-              'attributes' => array(
708
-                  'title' => bts('Unlock this thread for comments', array(), NULL, 'boinc:forum-unlock-comment')
709
-              )
710
-          );
704
+            $links['unlock'] = array(
705
+                'title' => bts('Unlock', array(), NULL, 'boinc:forum-unlock-comment'),
706
+                'href' => "{$node_control}/unlock",
707
+                'attributes' => array(
708
+                    'title' => bts('Unlock this thread for comments', array(), NULL, 'boinc:forum-unlock-comment')
709
+                )
710
+            );
711 711
         }
712 712
         if ($object->status) {
713
-          $links['hide'] = array(
714
-              'title' => bts('Hide', array(), NULL, 'boinc:forum-hide-comment'),
715
-              'href' => "{$node_control}/hide",
716
-              'attributes' => array(
717
-                  'title' => bts('Hide this topic', array(), NULL, 'boinc:forum-hide-comment')
718
-              )
719
-          );
713
+            $links['hide'] = array(
714
+                'title' => bts('Hide', array(), NULL, 'boinc:forum-hide-comment'),
715
+                'href' => "{$node_control}/hide",
716
+                'attributes' => array(
717
+                    'title' => bts('Hide this topic', array(), NULL, 'boinc:forum-hide-comment')
718
+                )
719
+            );
720 720
         }
721 721
         else {
722
-          $links['unhide'] = array(
723
-              'title' => bts('Unhide', array(), NULL, 'boinc:forum-unhide-comment'),
724
-              'href' => "{$node_control}/unhide",
725
-              'attributes' => array(
726
-                  'title' => bts('Unhide this topic', array(), NULL, 'boinc:forum-unhide-comment')
727
-              )
728
-          );
722
+            $links['unhide'] = array(
723
+                'title' => bts('Unhide', array(), NULL, 'boinc:forum-unhide-comment'),
724
+                'href' => "{$node_control}/unhide",
725
+                'attributes' => array(
726
+                    'title' => bts('Unhide this topic', array(), NULL, 'boinc:forum-unhide-comment')
727
+                )
728
+            );
729 729
         }
730
-      }// if user_access('edit any forum topic')
730
+        }// if user_access('edit any forum topic')
731 731
     }
732
-  }
733
-  else if ($type=='comment') {
732
+    }
733
+    else if ($type=='comment') {
734 734
     $node = node_load($object->nid);
735 735
     $nid = $object->nid;
736 736
     $cid = $object->cid;
@@ -750,10 +750,10 @@  discard block
 block discarded – undo
750 750
     // HIDE and COVERT comment
751 751
     // The following are moderator only links
752 752
     if (user_access('administer comments')) {
753
-      $comment_control = "comment_control/{$cid}";
754
-      // Add link to convert comment into a new topic
755
-      $reply_count = db_result(db_query(' SELECT COUNT(*) FROM comments WHERE pid = %d', $cid ));
756
-      if ($reply_count == 0) {
753
+        $comment_control = "comment_control/{$cid}";
754
+        // Add link to convert comment into a new topic
755
+        $reply_count = db_result(db_query(' SELECT COUNT(*) FROM comments WHERE pid = %d', $cid ));
756
+        if ($reply_count == 0) {
757 757
         $links['convert'] = array(
758 758
             'title' => bts('Convert', array(), NULL, 'boinc:forum-convert-comment-to-topic'),
759 759
             'href' => "{$comment_control}/convert",
@@ -761,9 +761,9 @@  discard block
 block discarded – undo
761 761
                 'title' => bts('Convert this comment to a new topic', array(), NULL, 'boinc:forum-convert-comment-to-topic')
762 762
             )
763 763
         );
764
-      }
765
-      // Add hide link
766
-      if ($object->status == 0) {
764
+        }
765
+        // Add hide link
766
+        if ($object->status == 0) {
767 767
         $links['hide'] = array(
768 768
             'title' => bts('Hide', array(), NULL, 'boinc:forum-hide-comment'),
769 769
             'href' => "{$comment_control}/hide",
@@ -771,8 +771,8 @@  discard block
 block discarded – undo
771 771
                 'title' => bts('Hide this comment', array(), NULL, 'boinc:forum-hide-comment')
772 772
             )
773 773
         );
774
-      }
775
-      else {
774
+        }
775
+        else {
776 776
         $links['unhide'] = array(
777 777
             'title' => bts('Unhide', array(), NULL, 'boinc:forum-unhide-comment'),
778 778
             'href' => "{$comment_control}/unhide",
@@ -780,11 +780,11 @@  discard block
 block discarded – undo
780 780
                 'title' => bts('Unhide this comment', array(), NULL, 'boinc:forum-unhide-comment')
781 781
             )
782 782
         );
783
-      }
783
+        }
784 784
     }// if user_access('administer comments')
785
-  }//if $type
785
+    }//if $type
786 786
 
787
-  return $links;
787
+    return $links;
788 788
 }
789 789
 
790 790
 
@@ -798,45 +798,45 @@  discard block
 block discarded – undo
798 798
  * link rather than through the node form.
799 799
  */
800 800
 function boinccore_node_control($nid = NULL, $action = NULL) {
801
-  if ((!$nid OR !$node = node_load($nid)) OR
801
+    if ((!$nid OR !$node = node_load($nid)) OR
802 802
       ($node->type == 'forum' AND !user_access('edit any forum topic')) OR
803 803
       ($node->type != 'forum' AND !user_access('administer nodes'))) {
804 804
     // What are you even doing here...
805 805
     return FALSE;
806
-  }
807
-  switch ($action) {
808
-  case 'unhide':
806
+    }
807
+    switch ($action) {
808
+    case 'unhide':
809 809
     node_publish_action($node);
810 810
     break;
811
-  case 'hide':
811
+    case 'hide':
812 812
     node_unpublish_action($node);
813 813
     break;
814
-  case 'sticky':
814
+    case 'sticky':
815 815
     node_make_sticky_action($node);
816 816
     break;
817
-  case 'unsticky':
817
+    case 'unsticky':
818 818
     node_make_unsticky_action($node);
819 819
     break;
820
-  case 'lock':
820
+    case 'lock':
821 821
     $node->comment = 1;
822 822
     watchdog('action', 'Locked comments on @type %title.', array(
823
-      '@type' => node_get_types('name', $node), '%title' => $node->title));
823
+        '@type' => node_get_types('name', $node), '%title' => $node->title));
824 824
     break;
825
-  case 'unlock':
825
+    case 'unlock':
826 826
     $node->comment = 2;
827 827
     watchdog('action', 'Unlocked comments on @type %title.', array(
828
-      '@type' => node_get_types('name', $node), '%title' => $node->title));
828
+        '@type' => node_get_types('name', $node), '%title' => $node->title));
829 829
     break;
830
-  default:
830
+    default:
831 831
   }
832
-  node_save($node);
833
-  // If hiding a forum topic (node) and not an administrator, go to
834
-  // the forum page. Otherwise the user will reach an access-denied
835
-  // page.
836
-  if (($action=="hide") and (!user_access('administer forums'))) {
832
+    node_save($node);
833
+    // If hiding a forum topic (node) and not an administrator, go to
834
+    // the forum page. Otherwise the user will reach an access-denied
835
+    // page.
836
+    if (($action=="hide") and (!user_access('administer forums'))) {
837 837
     drupal_goto("community/forum/{$node->tid}");
838
-  }
839
-  drupal_goto("node/{$nid}");
838
+    }
839
+    drupal_goto("node/{$nid}");
840 840
 }
841 841
 
842 842
 /**
@@ -845,28 +845,28 @@  discard block
 block discarded – undo
845 845
  * through the comment edit form.
846 846
  */
847 847
 function boinccore_comment_control($cid = NULL, $action = NULL) {
848
-  if (!$cid OR !$comment = _comment_load($cid)) {
848
+    if (!$cid OR !$comment = _comment_load($cid)) {
849 849
     // What are you even doing here...
850 850
     return FALSE;
851
-  }
852
-  $return_path = "node/{$comment->nid}";
853
-  $return_anchor = "comment-{$cid}";
854
-  switch ($action) {
855
-  case 'unhide':
851
+    }
852
+    $return_path = "node/{$comment->nid}";
853
+    $return_anchor = "comment-{$cid}";
854
+    switch ($action) {
855
+    case 'unhide':
856 856
     comment_publish_action($comment);
857 857
     rules_invoke_event('boinccore_comment_unhidden', $comment);
858 858
     if (module_exists("boinc_solr_comments")) {
859
-      boinc_solr_comments_publish($comment);
859
+        boinc_solr_comments_publish($comment);
860 860
     }
861 861
     break;
862
-  case 'hide':
862
+    case 'hide':
863 863
     comment_unpublish_action($comment);
864 864
     rules_invoke_event('comment_unpublish', $comment);
865 865
     if (module_exists("boinc_solr_comments")) {
866
-      boinc_solr_comments_unpublish($comment);
866
+        boinc_solr_comments_unpublish($comment);
867 867
     }
868 868
     break;
869
-  case 'convert':
869
+    case 'convert':
870 870
     $node = new stdClass();
871 871
     $node->name = $comment->subject;
872 872
     $node->title = $node->name;
@@ -886,7 +886,7 @@  discard block
 block discarded – undo
886 886
     $node->tid = $parent_node->tid;
887 887
  
888 888
     if (filter_access($comment->format)) {
889
-      $node->format = $comment->format;
889
+        $node->format = $comment->format;
890 890
     }
891 891
     
892 892
     // Save the new node
@@ -902,9 +902,9 @@  discard block
 block discarded – undo
902 902
     $return_path = "node/{$node->nid}";
903 903
     $return_anchor = NULL;
904 904
     break;
905
-  default:
905
+    default:
906 906
   }
907
-  drupal_goto($return_path, NULL, $return_anchor);
907
+    drupal_goto($return_path, NULL, $return_anchor);
908 908
 }
909 909
 
910 910
 /**
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
  * Get the authenticator for a given account
913 913
  */
914 914
 function boinccore_lookup_account() {
915
-  include_boinc('user/lookup_account.php');
915
+    include_boinc('user/lookup_account.php');
916 916
 }
917 917
 
918 918
 /**
@@ -920,29 +920,29 @@  discard block
 block discarded – undo
920 920
  * Get assorted details for a given account
921 921
  */
922 922
 function boinccore_am_get_info() {
923
-  // Remove q from the GET request or BOINC will panic
924
-  unset($_GET['q']);
925
-  // Capture the XML output of the RPC so we can override things
926
-  ob_start();
927
-  include_boinc('user/am_get_info.php');
928
-  $xml = ob_get_clean();
929
-  $xml = load_configuration($xml);
930
-  // See if the account has an approved profile in Drupal
931
-  $uid = !empty($xml['am_get_info_reply']['id']) ? boincuser_lookup_uid($xml['am_get_info_reply']['id']) : 0;
932
-  if ($uid) {
923
+    // Remove q from the GET request or BOINC will panic
924
+    unset($_GET['q']);
925
+    // Capture the XML output of the RPC so we can override things
926
+    ob_start();
927
+    include_boinc('user/am_get_info.php');
928
+    $xml = ob_get_clean();
929
+    $xml = load_configuration($xml);
930
+    // See if the account has an approved profile in Drupal
931
+    $uid = !empty($xml['am_get_info_reply']['id']) ? boincuser_lookup_uid($xml['am_get_info_reply']['id']) : 0;
932
+    if ($uid) {
933 933
     $content_profile = content_profile_load('profile', $uid);
934 934
     $profile_is_approved = ($content_profile->status AND !$content_profile->moderate);
935 935
     $country = check_plain($content_profile->field_country[0]['value']);
936 936
     $website = '';
937 937
     if ($profile_is_approved) {
938
-      $website = check_plain($content_profile->field_url[0]['value']);
938
+        $website = check_plain($content_profile->field_url[0]['value']);
939 939
     }
940 940
     // Override BOINC values with Drupal values as needed
941 941
     $xml['am_get_info_reply']['has_profile']['@value'] = ($profile_is_approved) ? 1 : 0;
942 942
     $xml['am_get_info_reply']['country']['@value'] = $country;
943 943
     $xml['am_get_info_reply']['url']['@value'] = $website;
944
-  }
945
-  print save_configuration($xml);
944
+    }
945
+    print save_configuration($xml);
946 946
 }
947 947
 
948 948
 /**
@@ -950,75 +950,75 @@  discard block
 block discarded – undo
950 950
  * Update assorted details for a given account
951 951
  */
952 952
 function boinccore_am_set_info() {
953
-  // Remove q from the GET request or BOINC will panic
954
-  unset($_GET['q']);
955
-  // Validate the XML prefs (in case BOINC does not)
956
-  $global_prefs = !empty($_POST['global_prefs']) ? $_POST['global_prefs'] : (!empty($_GET['global_prefs']) ? $_GET['global_prefs'] : NULL);
957
-  $project_prefs = !empty($_POST['project_prefs']) ? $_POST['project_prefs'] : (!empty($_GET['project_prefs']) ? $_GET['project_prefs'] : NULL);
958
-  libxml_use_internal_errors(true);
959
-  $xml = new DomDocument();
960
-  if ($global_prefs) {
953
+    // Remove q from the GET request or BOINC will panic
954
+    unset($_GET['q']);
955
+    // Validate the XML prefs (in case BOINC does not)
956
+    $global_prefs = !empty($_POST['global_prefs']) ? $_POST['global_prefs'] : (!empty($_GET['global_prefs']) ? $_GET['global_prefs'] : NULL);
957
+    $project_prefs = !empty($_POST['project_prefs']) ? $_POST['project_prefs'] : (!empty($_GET['project_prefs']) ? $_GET['project_prefs'] : NULL);
958
+    libxml_use_internal_errors(true);
959
+    $xml = new DomDocument();
960
+    if ($global_prefs) {
961 961
     $xml->loadXML($global_prefs, LIBXML_NOBLANKS);
962 962
     if ($errors = libxml_get_errors($xml)) {
963
-      $lines = explode("\r", $global_prefs);
964
-      watchdog('am_set_info', "XML validation error in global_prefs: {$errors[0]->message} at line {$errors[0]->line}" .
963
+        $lines = explode("\r", $global_prefs);
964
+        watchdog('am_set_info', "XML validation error in global_prefs: {$errors[0]->message} at line {$errors[0]->line}" .
965 965
         ': <br/>' . htmlentities($lines[$errors[0]->line - 1]), array(), WATCHDOG_ERROR);
966 966
     }
967
-  }
968
-  elseif ($project_prefs) {
967
+    }
968
+    elseif ($project_prefs) {
969 969
     $xml->loadXML($project_prefs, LIBXML_NOBLANKS);
970 970
     if ($errors = libxml_get_errors($xml)) {
971
-      $lines = explode("\r", $project_prefs);
972
-      watchdog('am_set_info', "XML validation error in project_prefs: {$errors[0]->message} at line {$errors[0]->line}" .
971
+        $lines = explode("\r", $project_prefs);
972
+        watchdog('am_set_info', "XML validation error in project_prefs: {$errors[0]->message} at line {$errors[0]->line}" .
973 973
         ': <br/>' . htmlentities($lines[$errors[0]->line - 1]), array(), WATCHDOG_ERROR);
974 974
     }
975
-  }
976
-  if (!$errors) {
975
+    }
976
+    if (!$errors) {
977 977
     // Capture the XML output of the RPC so we can override things
978 978
     ob_start();
979 979
     include_boinc('user/am_set_info.php');
980 980
     $xml = ob_get_clean();
981 981
     $xml = load_configuration($xml);
982 982
     if (isset($xml['am_set_info_reply']['success'])) {
983
-      // Find the account in Drupal
984
-      $boinc_auth = !empty($_POST['account_key']) ? $_POST['account_key'] : $_GET['account_key'];
985
-      db_set_active('boinc_rw');
986
-      $boinc_id = db_result(db_query("
983
+        // Find the account in Drupal
984
+        $boinc_auth = !empty($_POST['account_key']) ? $_POST['account_key'] : $_GET['account_key'];
985
+        db_set_active('boinc_rw');
986
+        $boinc_id = db_result(db_query("
987 987
         SELECT id
988 988
         FROM {user}
989 989
         WHERE authenticator = '%s'",
990 990
         $boinc_auth
991
-      ));
992
-      db_set_active('default');
993
-      $uid = boincuser_lookup_uid($boinc_id);
991
+        ));
992
+        db_set_active('default');
993
+        $uid = boincuser_lookup_uid($boinc_id);
994 994
       
995
-      // Apply any relevant updates to the Drupal account, also
996
-      $country = !empty($_POST['country']) ? $_POST['country'] : (!empty($_GET['country']) ? $_GET['country'] : NULL);
997
-      $url = !empty($_POST['url']) ? $_POST['url'] : (!empty($_GET['url']) ? $_GET['url'] : NULL);
998
-      $email_addr = !empty($_POST['email_addr']) ? $_POST['email_addr'] : (!empty($_GET['email_addr']) ? $_GET['email_addr'] : NULL);
995
+        // Apply any relevant updates to the Drupal account, also
996
+        $country = !empty($_POST['country']) ? $_POST['country'] : (!empty($_GET['country']) ? $_GET['country'] : NULL);
997
+        $url = !empty($_POST['url']) ? $_POST['url'] : (!empty($_GET['url']) ? $_GET['url'] : NULL);
998
+        $email_addr = !empty($_POST['email_addr']) ? $_POST['email_addr'] : (!empty($_GET['email_addr']) ? $_GET['email_addr'] : NULL);
999 999
       
1000
-      if ($email_addr) {
1000
+        if ($email_addr) {
1001 1001
         $account = user_load($uid);
1002 1002
         user_save($account, array('mail' => $email_addr));
1003
-      }
1004
-      if ($country OR $url) {
1003
+        }
1004
+        if ($country OR $url) {
1005 1005
         $content_profile = content_profile_load('profile', $uid);
1006 1006
         if ($country) $content_profile->field_country[0]['value'] = $country;
1007 1007
         if ($url) $content_profile->field_url[0]['value'] = $url;
1008 1008
         node_save($content_profile);
1009
-      }
1009
+        }
1010 1010
     }
1011
-  }
1012
-  else {
1011
+    }
1012
+    else {
1013 1013
     $xml = array(
1014
-      'error' => array(
1014
+        'error' => array(
1015 1015
         'error_num' => -112,
1016 1016
         'error_msg' => "{$errors[0]->message} at line {$errors[0]->line}" .
1017 1017
         ': <br/>' . htmlentities($lines[$errors[0]->line - 1])
1018
-      ),
1018
+        ),
1019 1019
     );
1020
-  }
1021
-  print save_configuration($xml);
1020
+    }
1021
+    print save_configuration($xml);
1022 1022
 }
1023 1023
 
1024 1024
 /**
@@ -1026,17 +1026,17 @@  discard block
 block discarded – undo
1026 1026
  * Update the venue for the given host
1027 1027
  */
1028 1028
 function boinccore_am_set_host_info() {
1029
-  // Remove q from the GET request or BOINC will panic
1030
-  unset($_GET['q']);
1031
-  // Capture the XML output of the RPC so we can override things
1032
-  ob_start();
1033
-  include_boinc('user/am_set_host_info.php');
1034
-  $xml = ob_get_clean();
1035
-  $xml = load_configuration($xml);
1036
-  if (isset($xml['am_set_host_info_reply']['success'])) {
1029
+    // Remove q from the GET request or BOINC will panic
1030
+    unset($_GET['q']);
1031
+    // Capture the XML output of the RPC so we can override things
1032
+    ob_start();
1033
+    include_boinc('user/am_set_host_info.php');
1034
+    $xml = ob_get_clean();
1035
+    $xml = load_configuration($xml);
1036
+    if (isset($xml['am_set_host_info_reply']['success'])) {
1037 1037
     // Override anything that needs overriding
1038
-  }
1039
-  print save_configuration($xml);
1038
+    }
1039
+    print save_configuration($xml);
1040 1040
 }
1041 1041
 
1042 1042
 /**
@@ -1044,29 +1044,29 @@  discard block
 block discarded – undo
1044 1044
  * Get assorted details for a given account
1045 1045
  */
1046 1046
 function boinccore_show_user() {
1047
-  // Remove q from the GET request or BOINC will panic
1048
-  unset($_GET['q']);
1049
-  // Capture the XML output of the RPC so we can override things
1050
-  ob_start();
1051
-  include_boinc('user/show_user.php');
1052
-  $xml = ob_get_clean();
1053
-  $xml = load_configuration($xml);
1054
-  // See if the account has an approved profile in Drupal
1055
-  $uid = !empty($xml['user']['id']) ? boincuser_lookup_uid($xml['user']['id']) : 0;
1056
-  if ($uid) {
1047
+    // Remove q from the GET request or BOINC will panic
1048
+    unset($_GET['q']);
1049
+    // Capture the XML output of the RPC so we can override things
1050
+    ob_start();
1051
+    include_boinc('user/show_user.php');
1052
+    $xml = ob_get_clean();
1053
+    $xml = load_configuration($xml);
1054
+    // See if the account has an approved profile in Drupal
1055
+    $uid = !empty($xml['user']['id']) ? boincuser_lookup_uid($xml['user']['id']) : 0;
1056
+    if ($uid) {
1057 1057
     $content_profile = content_profile_load('profile', $uid);
1058 1058
     $profile_is_approved = ($content_profile->status AND !$content_profile->moderate);
1059 1059
     $country = check_plain($content_profile->field_country[0]['value']);
1060 1060
     $website = '';
1061 1061
     if ($profile_is_approved) {
1062
-      $website = check_plain($content_profile->field_url[0]['value']);
1062
+        $website = check_plain($content_profile->field_url[0]['value']);
1063 1063
     }
1064 1064
     // Override BOINC values with Drupal values as needed
1065 1065
     $xml['user']['has_profile']['@value'] = ($profile_is_approved) ? 1 : 0;
1066 1066
     $xml['user']['country']['@value'] = $country;
1067 1067
     $xml['user']['url']['@value'] = $website;
1068
-  }
1069
-  print save_configuration($xml);
1068
+    }
1069
+    print save_configuration($xml);
1070 1070
 }
1071 1071
 
1072 1072
 /**
@@ -1074,9 +1074,9 @@  discard block
 block discarded – undo
1074 1074
  * Get pending credit information for a given account
1075 1075
  */
1076 1076
 function boinccore_pending_credit() {
1077
-  // Remove q from the GET request or BOINC will panic
1078
-  unset($_GET['q']);
1079
-  include_boinc('user/pending.php');
1077
+    // Remove q from the GET request or BOINC will panic
1078
+    unset($_GET['q']);
1079
+    include_boinc('user/pending.php');
1080 1080
 }
1081 1081
 
1082 1082
 /**
@@ -1085,7 +1085,7 @@  discard block
 block discarded – undo
1085 1085
  */
1086 1086
 function boinccore_create_team() {
1087 1087
   
1088
-  if (module_exists('boincteam')) {
1088
+    if (module_exists('boincteam')) {
1089 1089
     module_load_include('module', 'boincteam', 'boincteam');
1090 1090
   
1091 1091
     $input_format = !empty($values['format']) ? $values['format'] : 4;
@@ -1098,9 +1098,9 @@  discard block
 block discarded – undo
1098 1098
     $xml = load_configuration($xml);
1099 1099
     
1100 1100
     if (isset($xml['create_team_reply']['success'])) {
1101
-      $boincteam_id = isset($xml['create_team_reply']['team_id']['@value']) ? $xml['create_team_reply']['team_id']['@value'] : 0;
1101
+        $boincteam_id = isset($xml['create_team_reply']['team_id']['@value']) ? $xml['create_team_reply']['team_id']['@value'] : 0;
1102 1102
       
1103
-      if ($boincteam_id) {
1103
+        if ($boincteam_id) {
1104 1104
         
1105 1105
         $boincteam = boincteam_load($boincteam_id);
1106 1106
         $team_owner_uid = boincuser_lookup_uid($boincteam->userid);
@@ -1108,92 +1108,92 @@  discard block
 block discarded – undo
1108 1108
         // Create the team node in Drupal
1109 1109
         
1110 1110
         $values = array(
1111
-          'name' => isset($_GET['name']) ? $_GET['name'] : '',
1112
-          'description' => isset($_GET['description']) ? $_GET['description'] : '',
1113
-          'type' => isset($_GET['type']) ? $_GET['type'] : '',
1111
+            'name' => isset($_GET['name']) ? $_GET['name'] : '',
1112
+            'description' => isset($_GET['description']) ? $_GET['description'] : '',
1113
+            'type' => isset($_GET['type']) ? $_GET['type'] : '',
1114 1114
         );
1115 1115
         $teaser = node_teaser($values['description']);
1116 1116
         $created_time = time();
1117 1117
         
1118 1118
         $node = array(
1119
-          'type' => 'team',
1120
-          'title' => $values['name'],
1121
-          'body' => $values['description'],
1122
-          'teaser' => $teaser,
1123
-          'uid' => $team_owner_uid,
1124
-          'path' => null,
1125
-          'status' => 1,  // published or not - always publish
1126
-          'promote' => 0,
1127
-          'created' => $created_time,
1128
-          'comment' => 0,  // comments disabled
1129
-          'moderate' => 0,
1130
-          'sticky' => 0,
1131
-          'format' => $input_format
1119
+            'type' => 'team',
1120
+            'title' => $values['name'],
1121
+            'body' => $values['description'],
1122
+            'teaser' => $teaser,
1123
+            'uid' => $team_owner_uid,
1124
+            'path' => null,
1125
+            'status' => 1,  // published or not - always publish
1126
+            'promote' => 0,
1127
+            'created' => $created_time,
1128
+            'comment' => 0,  // comments disabled
1129
+            'moderate' => 0,
1130
+            'sticky' => 0,
1131
+            'format' => $input_format
1132 1132
         );
1133 1133
         
1134 1134
         // Use pathauto function, if available, to clean up the path
1135 1135
         if (module_exists('pathauto')) {
1136
-          module_load_include('inc', 'pathauto', 'pathauto');
1137
-          $node['path'] = pathauto_cleanstring($values['name']);
1136
+            module_load_include('inc', 'pathauto', 'pathauto');
1137
+            $node['path'] = pathauto_cleanstring($values['name']);
1138 1138
         
1139
-          $node = (object) $node; // node_save requires an object form
1140
-          $team_categories = taxonomy_get_term_by_name($values['type']);
1141
-          $node->taxonomy[] = $team_categories[0];
1139
+            $node = (object) $node; // node_save requires an object form
1140
+            $team_categories = taxonomy_get_term_by_name($values['type']);
1141
+            $node->taxonomy[] = $team_categories[0];
1142 1142
           
1143
-          // Save the team node
1144
-          node_save($node);
1145
-          // Save the team IDs to a BOINC <--> Drupal reference table.
1146
-          db_query('INSERT INTO {boincteam} (team_id, nid) VALUES (%d, %d)', $boincteam_id, $node->nid);
1143
+            // Save the team node
1144
+            node_save($node);
1145
+            // Save the team IDs to a BOINC <--> Drupal reference table.
1146
+            db_query('INSERT INTO {boincteam} (team_id, nid) VALUES (%d, %d)', $boincteam_id, $node->nid);
1147 1147
         }
1148 1148
         else {
1149
-          $xml['create_team_reply']['warning'] = t(
1149
+            $xml['create_team_reply']['warning'] = t(
1150 1150
             'There was a problem integrating this team into Drupal. Please
1151 1151
             contact @project administrators!', array('@project' => PROJECT)
1152
-          );
1153
-          watchdog(
1152
+            );
1153
+            watchdog(
1154 1154
             'BOINC team',
1155 1155
             'BOINC teams require the Pathauto module. Team cannot be created in
1156 1156
               Drupal via create_team.php RPC.',
1157 1157
             array(),
1158 1158
             WATCHDOG_ERROR
1159
-          );
1160
-          // Delete from the BOINC DB if we can't sync with Drupal
1161
-          $boincteam::delete();
1159
+            );
1160
+            // Delete from the BOINC DB if we can't sync with Drupal
1161
+            $boincteam::delete();
1162 1162
         }
1163
-      }
1164
-      else {
1163
+        }
1164
+        else {
1165 1165
         $xml['create_team_reply']['warning'] = t(
1166
-          'There was a problem integrating this team into Drupal. Please
1166
+            'There was a problem integrating this team into Drupal. Please
1167 1167
           contact @project administrators!', array('@project' => PROJECT)
1168 1168
         );
1169 1169
         watchdog(
1170
-          'BOINC team',
1171
-          'Team cannot be created in Drupal via create_team.php RPC because no
1170
+            'BOINC team',
1171
+            'Team cannot be created in Drupal via create_team.php RPC because no
1172 1172
             BOINC team ID was returned in the XML.',
1173
-          array(),
1174
-          WATCHDOG_ERROR
1173
+            array(),
1174
+            WATCHDOG_ERROR
1175 1175
         );
1176
-      }
1176
+        }
1177 1177
     }
1178
-  }
1179
-  else {
1178
+    }
1179
+    else {
1180 1180
     $xml = array(
1181
-      'error' => array(
1181
+        'error' => array(
1182 1182
         'error_num' => -1,
1183 1183
         'error_msg' => t(
1184
-          'Teams are not enabled for this project'
1184
+            'Teams are not enabled for this project'
1185
+        ),
1185 1186
         ),
1186
-      ),
1187 1187
     );
1188 1188
     watchdog(
1189
-      'BOINC team',
1190
-      'Team cannot be created in Drupal via create_team.php RPC because the
1189
+        'BOINC team',
1190
+        'Team cannot be created in Drupal via create_team.php RPC because the
1191 1191
         BOINC team module is not enabled.',
1192
-      array(),
1193
-      WATCHDOG_ERROR
1192
+        array(),
1193
+        WATCHDOG_ERROR
1194 1194
     );
1195
-  }
1196
-  print save_configuration($xml);
1195
+    }
1196
+    print save_configuration($xml);
1197 1197
 }
1198 1198
 
1199 1199
 /**
@@ -1201,9 +1201,9 @@  discard block
 block discarded – undo
1201 1201
  * Get info on a team by ID or a list of teams that match a given name
1202 1202
  */
1203 1203
 function boinccore_team_lookup() {
1204
-  // Remove q from the GET request or BOINC will panic
1205
-  unset($_GET['q']);
1206
-  include_boinc('user/team_lookup.php');
1204
+    // Remove q from the GET request or BOINC will panic
1205
+    unset($_GET['q']);
1206
+    include_boinc('user/team_lookup.php');
1207 1207
 }
1208 1208
 
1209 1209
 /**
@@ -1211,72 +1211,72 @@  discard block
 block discarded – undo
1211 1211
  * Get members of a given team
1212 1212
  */
1213 1213
 function boinccore_team_email_list() {
1214
-  // See if the account has an approved profile in Drupal
1215
-  $boincteam_id = !empty($_POST['teamid']) ? $_POST['teamid'] : $_GET['teamid'];
1216
-  $credit_only = !empty($_POST['creditonly']) ? $_POST['creditonly'] : $_GET['creditonly'];
1217
-  $show_xml = !empty($_POST['xml']) ? $_POST['xml'] : $_GET['xml'];
1218
-  if (!$show_xml) {
1219
-      // creditonly does not affect non xml output in BOINC
1220
-      $credit_only = FALSE;
1221
-  }
1222
-  $xml = array();
1214
+    // See if the account has an approved profile in Drupal
1215
+    $boincteam_id = !empty($_POST['teamid']) ? $_POST['teamid'] : $_GET['teamid'];
1216
+    $credit_only = !empty($_POST['creditonly']) ? $_POST['creditonly'] : $_GET['creditonly'];
1217
+    $show_xml = !empty($_POST['xml']) ? $_POST['xml'] : $_GET['xml'];
1218
+    if (!$show_xml) {
1219
+        // creditonly does not affect non xml output in BOINC
1220
+        $credit_only = FALSE;
1221
+    }
1222
+    $xml = array();
1223 1223
 
1224
-  if ($boincteam_id && is_numeric($boincteam_id)) {
1224
+    if ($boincteam_id && is_numeric($boincteam_id)) {
1225 1225
     if ($credit_only) {
1226
-      db_set_active('boinc_rw');
1227
-      $result = db_query("
1226
+        db_set_active('boinc_rw');
1227
+        $result = db_query("
1228 1228
         SELECT
1229 1229
           u.id, u.name, u.cross_project_id, u.email_addr, u.total_credit, u.expavg_credit, u.expavg_time
1230 1230
         FROM {user} u
1231 1231
         WHERE u.teamid = %d and u.total_credit > 0",
1232 1232
         $boincteam_id
1233
-      );
1234
-      db_set_active('default');
1233
+        );
1234
+        db_set_active('default');
1235 1235
 
1236
-      $xml = array('users' => array());
1237
-      while ($member = db_fetch_object($result)) {
1236
+        $xml = array('users' => array());
1237
+        while ($member = db_fetch_object($result)) {
1238 1238
         $team_member = array(
1239
-          'id' => $member->id,
1240
-          'cpid' => md5($member->cross_project_id.$member->email_addr),
1241
-          'name' => htmlspecialchars($member->name),
1242
-          'total_credit' => round($member->total_credit),
1243
-          'expavg_credit' => round($member->expavg_credit),
1244
-          'expavg_time' => round($member->expavg_time),
1239
+            'id' => $member->id,
1240
+            'cpid' => md5($member->cross_project_id.$member->email_addr),
1241
+            'name' => htmlspecialchars($member->name),
1242
+            'total_credit' => round($member->total_credit),
1243
+            'expavg_credit' => round($member->expavg_credit),
1244
+            'expavg_time' => round($member->expavg_time),
1245 1245
         );
1246 1246
         $xml['users']['user'][] = $team_member;
1247
-      }
1247
+        }
1248 1248
     }
1249 1249
     else {
1250
-      // Query BOINC database user table
1251
-      db_set_active('boinc_rw');
1252
-      $result = db_query("
1250
+        // Query BOINC database user table
1251
+        db_set_active('boinc_rw');
1252
+        $result = db_query("
1253 1253
         SELECT
1254 1254
           u.id, u.name, u.cross_project_id, u.create_time, u.email_addr, u.total_credit, u.expavg_credit, u.expavg_time
1255 1255
         FROM {user} u
1256 1256
         WHERE u.teamid = %d ORDER BY u.email_addr ASC",
1257 1257
         $boincteam_id
1258
-      );
1259
-      db_set_active('default');
1258
+        );
1259
+        db_set_active('default');
1260 1260
 
1261
-      // Extract information from BOINC database for team members.
1262
-      $team_members = array();
1263
-      while ($member = db_fetch_object($result)) {
1261
+        // Extract information from BOINC database for team members.
1262
+        $team_members = array();
1263
+        while ($member = db_fetch_object($result)) {
1264 1264
         $team_members[$member->id] = array(
1265
-          'id' => $member->id,
1266
-          'cpid' => md5($member->cross_project_id.$member->email_addr),
1267
-          'create_time' => $member->create_time,
1268
-          'name' => htmlspecialchars($member->name),
1269
-          'country' => NULL,
1270
-          'total_credit' => round($member->total_credit),
1271
-          'expavg_credit' => round($member->expavg_credit),
1272
-          'expavg_time' => round($member->expavg_time),
1273
-          'url' => NULL,
1274
-          'has_profile' => 0,
1265
+            'id' => $member->id,
1266
+            'cpid' => md5($member->cross_project_id.$member->email_addr),
1267
+            'create_time' => $member->create_time,
1268
+            'name' => htmlspecialchars($member->name),
1269
+            'country' => NULL,
1270
+            'total_credit' => round($member->total_credit),
1271
+            'expavg_credit' => round($member->expavg_credit),
1272
+            'expavg_time' => round($member->expavg_time),
1273
+            'url' => NULL,
1274
+            'has_profile' => 0,
1275 1275
         );
1276
-      }
1276
+        }
1277 1277
 
1278
-      // Query Drupal database, multiple tables
1279
-      $sql1 = "
1278
+        // Query Drupal database, multiple tables
1279
+        $sql1 = "
1280 1280
          SELECT
1281 1281
            bu.boinc_id, du.uid, du.name, n.nid, n.type, n.field_country_value, n.field_url_value
1282 1282
          FROM {boincuser} AS bu
@@ -1287,28 +1287,28 @@  discard block
 block discarded – undo
1287 1287
            INNER JOIN {content_type_profile} AS p ON node.nid=p.nid
1288 1288
            WHERE node.type='profile' ) n ON du.uid=n.uid
1289 1289
          WHERE bu.boinc_id IN (%s)";
1290
-      $member_id_list = implode(',', array_keys($team_members));
1291
-      if (!$member_id_list) {
1290
+        $member_id_list = implode(',', array_keys($team_members));
1291
+        if (!$member_id_list) {
1292 1292
         $member_id_list = '-1';
1293
-      }
1294
-      $result = db_query($sql1, $member_id_list);
1295
-      while ($member = db_fetch_object($result)) {
1293
+        }
1294
+        $result = db_query($sql1, $member_id_list);
1295
+        while ($member = db_fetch_object($result)) {
1296 1296
         $team_members[$member->boinc_id]['country'] = $member->field_country_value;
1297 1297
         $team_members[$member->boinc_id]['url'] = $member->field_url_value;
1298 1298
         $team_members[$member->boinc_id]['has_profile'] = isset($member->nid) ? 1:  0;
1299 1299
         $xml['users']['user'][] = $team_members[$member->boinc_id];
1300
-      }
1300
+        }
1301 1301
     } // end if credit_only
1302
-  }
1303
-  else {
1302
+    }
1303
+    else {
1304 1304
     $xml = array(
1305
-      'error' => array(
1305
+        'error' => array(
1306 1306
         'error_num' => -136,
1307 1307
         'error_msg' => 'Not found',
1308
-      ),
1308
+        ),
1309 1309
     );
1310
-  } // end if boincteam_id
1311
-  print xml_to_text(array_to_xml($xml), TRUE, TRUE);
1310
+    } // end if boincteam_id
1311
+    print xml_to_text(array_to_xml($xml), TRUE, TRUE);
1312 1312
 }
1313 1313
 
1314 1314
 /**
@@ -1316,114 +1316,114 @@  discard block
 block discarded – undo
1316 1316
  * Edit the forum preferences for a given user
1317 1317
  */
1318 1318
 function boinccore_edit_forum_preferences() {
1319
-  // Do not pass through to BOINC in this case as BOINC forums are no longer
1320
-  // relevant -- use Drupal data only
1319
+    // Do not pass through to BOINC in this case as BOINC forums are no longer
1320
+    // relevant -- use Drupal data only
1321 1321
   
1322
-  $account_key = !empty($_POST['account_key']) ? $_POST['account_key'] : (!empty($_GET['account_key']) ? $_GET['account_key'] : NULL);
1322
+    $account_key = !empty($_POST['account_key']) ? $_POST['account_key'] : (!empty($_GET['account_key']) ? $_GET['account_key'] : NULL);
1323 1323
   
1324
-  require_boinc('boinc_db');
1325
-  $boincuser = BoincUser::lookup_auth($account_key);
1326
-  if ($boincuser) {
1324
+    require_boinc('boinc_db');
1325
+    $boincuser = BoincUser::lookup_auth($account_key);
1326
+    if ($boincuser) {
1327 1327
     $uid = boincuser_lookup_uid($boincuser->id);
1328 1328
     if ($uid AND $account = user_load($uid)) {
1329
-      // Currently supported preferences
1330
-      $avatar_url = isset($_POST['avatar_url']) ? $_POST['avatar_url'] : (isset($_GET['avatar_url']) ? $_GET['avatar_url'] : NULL);
1331
-      $hide_signatures = isset($_POST['forum_hide_signatures']) ? $_POST['forum_hide_signatures'] : (isset($_GET['forum_hide_signatures']) ? $_GET['forum_hide_signatures'] : NULL);
1332
-      $signature = isset($_POST['signature']) ? $_POST['signature'] : (isset($_GET['signature']) ? $_GET['signature'] : NULL);
1333
-      $post_order = isset($_POST['thread_sort']) ? $_POST['thread_sort'] : (isset($_GET['thread_sort']) ? $_GET['thread_sort'] : NULL);
1334
-      // Update preferences as needed
1335
-      if ($avatar_url) {
1329
+        // Currently supported preferences
1330
+        $avatar_url = isset($_POST['avatar_url']) ? $_POST['avatar_url'] : (isset($_GET['avatar_url']) ? $_GET['avatar_url'] : NULL);
1331
+        $hide_signatures = isset($_POST['forum_hide_signatures']) ? $_POST['forum_hide_signatures'] : (isset($_GET['forum_hide_signatures']) ? $_GET['forum_hide_signatures'] : NULL);
1332
+        $signature = isset($_POST['signature']) ? $_POST['signature'] : (isset($_GET['signature']) ? $_GET['signature'] : NULL);
1333
+        $post_order = isset($_POST['thread_sort']) ? $_POST['thread_sort'] : (isset($_GET['thread_sort']) ? $_GET['thread_sort'] : NULL);
1334
+        // Update preferences as needed
1335
+        if ($avatar_url) {
1336 1336
         $avatar_image = file_get_contents($avatar_url);
1337 1337
         if ($avatar_image) {
1338
-          $image_dir = 'profiles';
1339
-          $image_path = "{$image_dir}/{$boincuser->id}_avatar.jpg";
1340
-          $file = file_save_data($avatar_image, $image_path, FILE_EXISTS_REPLACE);
1341
-          if ($file) {
1338
+            $image_dir = 'profiles';
1339
+            $image_path = "{$image_dir}/{$boincuser->id}_avatar.jpg";
1340
+            $file = file_save_data($avatar_image, $image_path, FILE_EXISTS_REPLACE);
1341
+            if ($file) {
1342 1342
             $profile = new stdClass();
1343 1343
             $profile->type = 'profile';
1344 1344
             $profile->language = NULL;
1345 1345
             if ($profile_nid = content_profile_profile_exists($profile, $account->uid)) {
1346
-              $profile_node = node_load($profile_nid);
1347
-              if ($profile_node) {
1346
+                $profile_node = node_load($profile_nid);
1347
+                if ($profile_node) {
1348 1348
                 $avatar_image = get_cck_image_object(file_directory_path() . '/' . $image_path, 'field_image', 'profile', TRUE);
1349 1349
                 if ($avatar_image) {
1350
-                  $profile_node->field_image[0] = $avatar_image;
1351
-                  node_save($profile_node);
1350
+                    $profile_node->field_image[0] = $avatar_image;
1351
+                    node_save($profile_node);
1352 1352
                 }
1353 1353
                 else {
1354
-                  $error = 'Error saving avatar to profile';
1354
+                    $error = 'Error saving avatar to profile';
1355
+                }
1355 1356
                 }
1356
-              }
1357
-              else {
1357
+                else {
1358 1358
                 $error = 'Unable to load user profile';
1359
-              }
1359
+                }
1360 1360
             }
1361 1361
             else {
1362
-              $error = 'User has no profile, so avatar could not be added';
1362
+                $error = 'User has no profile, so avatar could not be added';
1363
+            }
1363 1364
             }
1364
-          }
1365
-          else {
1365
+            else {
1366 1366
             $error = 'Unable to save remote image';
1367
-          }
1367
+            }
1368 1368
         }
1369 1369
         else {
1370
-          $error = 'Could not find avatar image at URL';
1370
+            $error = 'Could not find avatar image at URL';
1371 1371
         }
1372
-      }
1373
-      if ($hide_signatures !== NULL) {
1372
+        }
1373
+        if ($hide_signatures !== NULL) {
1374 1374
         user_save($account, array('hide_signatures' => ($hide_signatures ? 1 : 0)));
1375
-      }
1376
-      if ($signature !== NULL) {
1375
+        }
1376
+        if ($signature !== NULL) {
1377 1377
         $signature = check_markup($signature);
1378 1378
         user_save($account, array('signature' => $signature));
1379
-      }
1380
-      if ($post_order) {
1379
+        }
1380
+        if ($post_order) {
1381 1381
         require_boinc('forum');
1382 1382
         $post_order_map = array(
1383
-          CREATE_TIME_OLD => 2,
1384
-          CREATE_TIME_NEW => 1,
1383
+            CREATE_TIME_OLD => 2,
1384
+            CREATE_TIME_NEW => 1,
1385 1385
         );
1386 1386
         $drupal_post_order = isset($post_order_map[$post_order]) ? $post_order_map[$post_order] : 2;
1387 1387
         user_save($account, array('sort' => $drupal_post_order));
1388
-      }
1389
-      if (!$error) {
1388
+        }
1389
+        if (!$error) {
1390 1390
         // Success
1391 1391
         $xml = array(
1392
-          'edit_forum_preferences' => array(
1392
+            'edit_forum_preferences' => array(
1393 1393
             'success' => NULL,
1394
-          ),
1394
+            ),
1395 1395
         );
1396
-      }
1397
-      else {
1396
+        }
1397
+        else {
1398 1398
         // Failure
1399 1399
         $xml = array(
1400
-          'error' => array(
1400
+            'error' => array(
1401 1401
             'error_num' => -1,
1402 1402
             'error_msg' => $error,
1403
-          ),
1403
+            ),
1404 1404
         );
1405
-      }
1405
+        }
1406 1406
     }
1407 1407
     else {
1408
-      // Drupal user not found
1409
-      $xml = array(
1408
+        // Drupal user not found
1409
+        $xml = array(
1410 1410
         'error' => array(
1411
-          'error_num' => -1,
1412
-          'error_msg' => 'Unknown error',
1411
+            'error_num' => -1,
1412
+            'error_msg' => 'Unknown error',
1413 1413
         ),
1414
-      );
1414
+        );
1415 1415
     }
1416
-  }
1417
-  else {
1416
+    }
1417
+    else {
1418 1418
     // BOINC user not found
1419 1419
     $xml = array(
1420
-      'error' => array(
1420
+        'error' => array(
1421 1421
         'error_num' => -136,
1422 1422
         'error_msg' => 'Not found',
1423
-      ),
1423
+        ),
1424 1424
     );
1425
-  }
1426
-  print xml_to_text(array_to_xml($xml), TRUE, TRUE);
1425
+    }
1426
+    print xml_to_text(array_to_xml($xml), TRUE, TRUE);
1427 1427
 }
1428 1428
 
1429 1429
 /**
@@ -1431,14 +1431,14 @@  discard block
 block discarded – undo
1431 1431
  * Get the last comments OR threads made by a given user
1432 1432
  */
1433 1433
 function boinccore_forum_get_data() {
1434
-  // Do not pass through to BOINC in this case as BOINC forums are no longer
1435
-  // relevant -- use Drupal data only
1434
+    // Do not pass through to BOINC in this case as BOINC forums are no longer
1435
+    // relevant -- use Drupal data only
1436 1436
   
1437
-  $xml = array();
1438
-  $boinc_id = !empty($_POST['userid']) ? $_POST['userid'] : (!empty($_GET['userid']) ? $_GET['userid'] : NULL);
1439
-  $uid = boincuser_lookup_uid($boinc_id);
1437
+    $xml = array();
1438
+    $boinc_id = !empty($_POST['userid']) ? $_POST['userid'] : (!empty($_GET['userid']) ? $_GET['userid'] : NULL);
1439
+    $uid = boincuser_lookup_uid($boinc_id);
1440 1440
   
1441
-  if ($uid) {
1441
+    if ($uid) {
1442 1442
     $method = !empty($_POST['method']) ? $_POST['method'] : (!empty($_GET['method']) ? $_GET['method'] : NULL);
1443 1443
     $count = !empty($_POST['count']) ? $_POST['count'] : (!empty($_GET['count']) ? $_GET['count'] : NULL);
1444 1444
     if (!$count) $count = 10;
@@ -1446,7 +1446,7 @@  discard block
 block discarded – undo
1446 1446
     switch ($method) {
1447 1447
     case 'user_posts':
1448 1448
       $content_length = !empty($_POST['content_length']) ? $_POST['content_length'] : (!empty($_GET['content_length']) ? $_GET['content_length'] : NULL);
1449
-      $posts = db_query("
1449
+        $posts = db_query("
1450 1450
         SELECT
1451 1451
           c.cid,
1452 1452
           n.nid,
@@ -1460,26 +1460,26 @@  discard block
 block discarded – undo
1460 1460
         ORDER BY timestamp DESC
1461 1461
         LIMIT %d",
1462 1462
         $uid, (int) $count
1463
-      );
1464
-      $xml = array(
1463
+        );
1464
+        $xml = array(
1465 1465
         'rpc_response' => array(
1466
-          'count' => 0,
1467
-          'posts' => array(),
1466
+            'count' => 0,
1467
+            'posts' => array(),
1468 1468
         ),
1469
-      );
1470
-      $post_count = 0;
1471
-      while ($post = db_fetch_object($posts)) {
1469
+        );
1470
+        $post_count = 0;
1471
+        while ($post = db_fetch_object($posts)) {
1472 1472
         $xml['rpc_response']['posts']['post'][] = array(
1473
-          'id' => $post->cid,
1474
-          'threadid' => $post->nid,
1475
-          'threadtitle' => $post->title,
1476
-          'timestamp' => $post->timestamp,
1477
-          'content' => ($content_length ? substr($post->comment, 0, $content_length) : $post->comment),
1473
+            'id' => $post->cid,
1474
+            'threadid' => $post->nid,
1475
+            'threadtitle' => $post->title,
1476
+            'timestamp' => $post->timestamp,
1477
+            'content' => ($content_length ? substr($post->comment, 0, $content_length) : $post->comment),
1478 1478
         );
1479 1479
         $post_count++;
1480
-      }
1481
-      $xml['rpc_response']['count'] = $post_count;
1482
-      break;
1480
+        }
1481
+        $xml['rpc_response']['count'] = $post_count;
1482
+        break;
1483 1483
       
1484 1484
     case 'user_threads':
1485 1485
       $threads = db_query("
@@ -1503,45 +1503,45 @@  discard block
 block discarded – undo
1503 1503
         ORDER BY changed DESC
1504 1504
         LIMIT %d",
1505 1505
         $uid, (int) $count
1506
-      );
1507
-      $xml = array(
1506
+        );
1507
+        $xml = array(
1508 1508
         'rpc_response' => array(
1509
-          'count' => 0,
1510
-          'threads' => array(),
1509
+            'count' => 0,
1510
+            'threads' => array(),
1511 1511
         ),
1512
-      );
1513
-      $thread_count = 0;
1514
-      while ($thread = db_fetch_object($threads)) {
1512
+        );
1513
+        $thread_count = 0;
1514
+        while ($thread = db_fetch_object($threads)) {
1515 1515
         $xml['rpc_response']['threads']['thread'][] = array(
1516
-          'id' => $thread->nid,
1517
-          'forumid' => $thread->tid,
1518
-          'replies' => $thread->replies,
1519
-          'views' => $thread->views,
1520
-          'timestamp' => $thread->changed,
1521
-          'title' => $thread->title,
1516
+            'id' => $thread->nid,
1517
+            'forumid' => $thread->tid,
1518
+            'replies' => $thread->replies,
1519
+            'views' => $thread->views,
1520
+            'timestamp' => $thread->changed,
1521
+            'title' => $thread->title,
1522 1522
         );
1523 1523
         $thread_count++;
1524
-      }
1525
-      $xml['rpc_response']['count'] = $thread_count;
1526
-      break;
1524
+        }
1525
+        $xml['rpc_response']['count'] = $thread_count;
1526
+        break;
1527 1527
     default:
1528 1528
       $xml = array(
1529 1529
         'error' => array(
1530
-          'error_num' => -1,
1531
-          'error_msg' => 'Unknown error',
1530
+            'error_num' => -1,
1531
+            'error_msg' => 'Unknown error',
1532 1532
         ),
1533
-      );
1533
+        );
1534 1534
     }
1535
-  }
1536
-  else {
1535
+    }
1536
+    else {
1537 1537
     $xml = array(
1538
-      'error' => array(
1538
+        'error' => array(
1539 1539
         'error_num' => -136,
1540 1540
         'error_msg' => 'Not found',
1541
-      ),
1541
+        ),
1542 1542
     );
1543
-  }
1544
-  print xml_to_text(array_to_xml($xml), TRUE, TRUE);
1543
+    }
1544
+    print xml_to_text(array_to_xml($xml), TRUE, TRUE);
1545 1545
 }
1546 1546
 
1547 1547
 /**
@@ -1549,9 +1549,9 @@  discard block
 block discarded – undo
1549 1549
  * Get information on applications in the system
1550 1550
  */
1551 1551
 function boinccore_apps() {
1552
-  // Remove q from the GET request or BOINC will panic
1553
-  unset($_GET['q']);
1554
-  include_boinc('user/apps.php');
1552
+    // Remove q from the GET request or BOINC will panic
1553
+    unset($_GET['q']);
1554
+    include_boinc('user/apps.php');
1555 1555
 }
1556 1556
 
1557 1557
 /**
@@ -1561,141 +1561,141 @@  discard block
 block discarded – undo
1561 1561
  * controller function, which can compute the page based on the user's settings
1562 1562
  */
1563 1563
 function boinccore_url_pagination_handler($type, $object_id = NULL) {
1564
-  global $user;
1565
-  $path = NULL;
1566
-  $params = array();
1567
-  switch ($type) {
1568
-  case 'boinc-forum':
1564
+    global $user;
1565
+    $path = NULL;
1566
+    $params = array();
1567
+    switch ($type) {
1568
+    case 'boinc-forum':
1569 1569
     // Redirect requests to a BOINC forum to the Drupal forum
1570 1570
     $forum_id = db_result(db_query('
1571 1571
       SELECT tid
1572 1572
       FROM {boincimport_temp_forum}
1573 1573
       WHERE forum_id = %d',
1574
-      $object_id
1574
+        $object_id
1575 1575
     ));
1576 1576
     if ($forum_id) {
1577
-      drupal_goto("community/forum/{$forum_id}");
1577
+        drupal_goto("community/forum/{$forum_id}");
1578 1578
     }
1579 1579
     break;
1580
-  case 'boinc-forum-index':
1580
+    case 'boinc-forum-index':
1581 1581
     // Redirect requests to the top level BOINC forum to Drupal forums
1582 1582
     drupal_goto("community/forum");
1583 1583
     break;
1584
-  case 'boinc-forum-post':
1584
+    case 'boinc-forum-post':
1585 1585
     // Redirect requests to a BOINC forum post to the Drupal comment
1586 1586
     $cid = db_result(db_query('
1587 1587
       SELECT cid
1588 1588
       FROM {boincimport_temp_post}
1589 1589
       WHERE post_id = %d',
1590
-      $object_id
1590
+        $object_id
1591 1591
     ));
1592 1592
     if ($cid) {
1593
-      drupal_goto("goto/comment/{$cid}");
1593
+        drupal_goto("goto/comment/{$cid}");
1594 1594
     }
1595 1595
     break;
1596
-  case 'boinc-forum-topic':
1596
+    case 'boinc-forum-topic':
1597 1597
     // Redirect requests to a BOINC forum topic to the Drupal node
1598 1598
     $nid = db_result(db_query('
1599 1599
       SELECT nid
1600 1600
       FROM {boincimport_temp_topic}
1601 1601
       WHERE topic_id = %d',
1602
-      $object_id
1602
+        $object_id
1603 1603
     ));
1604 1604
     if ($nid) {
1605
-      drupal_goto("node/{$nid}");
1605
+        drupal_goto("node/{$nid}");
1606 1606
     }
1607 1607
     break;
1608
-  case 'boinc-host':
1608
+    case 'boinc-host':
1609 1609
     // Redirect requests to BOINC host details to the host page in Drupal
1610 1610
     drupal_goto("host/{$object_id}");
1611 1611
     break;
1612
-  case 'boinc-hosts-user':
1612
+    case 'boinc-hosts-user':
1613 1613
     // Redirect requests to a BOINC user host list to the host list in Drupal
1614 1614
     $uid = boincuser_lookup_uid($object_id);
1615 1615
     if ($uid) {
1616
-      drupal_goto("account/{$uid}/computers");
1616
+        drupal_goto("account/{$uid}/computers");
1617 1617
     }
1618 1618
     break;
1619
-  case 'boinc-result':
1619
+    case 'boinc-result':
1620 1620
     // Redirect requests to BOINC task details to the task page in Drupal
1621 1621
     drupal_goto("task/{$object_id}");
1622
-  case 'boinc-results-host':
1622
+    case 'boinc-results-host':
1623 1623
     // Redirect requests to BOINC tasks by host to the host task page in Drupal
1624 1624
     drupal_goto("host/{$object_id}/tasks");
1625 1625
     break;
1626
-  case 'boinc-results-user':
1626
+    case 'boinc-results-user':
1627 1627
     // Redirect requests to a BOINC user's tasks to the Drupal account tasks
1628 1628
     drupal_goto("account/tasks");
1629 1629
     break;
1630
-  case 'boinc-user':
1630
+    case 'boinc-user':
1631 1631
     // Redirect requests to a BOINC user ID to the Drupal profile
1632 1632
     $uid = boincuser_lookup_uid($object_id);
1633 1633
     if ($uid) {
1634
-      drupal_goto("account/{$uid}");
1634
+        drupal_goto("account/{$uid}");
1635 1635
     }
1636 1636
     break;
1637
-  case 'boinc-workunit':
1637
+    case 'boinc-workunit':
1638 1638
     // Redirect requests to BOINC workunits to the workunit page in Drupal
1639 1639
     drupal_goto("workunit/{$object_id}");
1640 1640
     break;
1641
-  case 'comment':
1641
+    case 'comment':
1642 1642
     $object = _comment_load($object_id);
1643 1643
     if ($object) {
1644
-      $path = "node/{$object->nid}";
1645
-      // Get the sort order
1646
-      $gt_lt = '<';
1647
-      $comment_order = (isset($user->sort)) ? $user->sort : variable_get('comment_default_order_forum', 2);
1648
-      if ($comment_order == COMMENT_ORDER_NEWEST_FIRST) {
1644
+        $path = "node/{$object->nid}";
1645
+        // Get the sort order
1646
+        $gt_lt = '<';
1647
+        $comment_order = (isset($user->sort)) ? $user->sort : variable_get('comment_default_order_forum', 2);
1648
+        if ($comment_order == COMMENT_ORDER_NEWEST_FIRST) {
1649 1649
         $gt_lt = '>';
1650
-      }
1651
-      // See how many comments there are before (or after) this comment...
1652
-      $comment_offset = db_result(db_query('
1650
+        }
1651
+        // See how many comments there are before (or after) this comment...
1652
+        $comment_offset = db_result(db_query('
1653 1653
         SELECT COUNT(*) FROM {comments}
1654 1654
         WHERE nid = %d AND status = 0 AND timestamp %s %d',
1655 1655
         $object->nid, $gt_lt, $object->timestamp));
1656
-      if ($comment_offset) {
1656
+        if ($comment_offset) {
1657 1657
         // Get the number of comments per page
1658 1658
         if ($user->comments_per_page) {
1659
-          $comments_per_page = $user->comments_per_page;
1659
+            $comments_per_page = $user->comments_per_page;
1660 1660
         }
1661 1661
         else {
1662
-          $node = node_load($object->nid);
1663
-          $comments_per_page = variable_get(
1662
+            $node = node_load($object->nid);
1663
+            $comments_per_page = variable_get(
1664 1664
             "comment_default_per_page_{$node->type}", 50
1665
-          );
1665
+            );
1666 1666
         }
1667 1667
         // Determine which page to display in order to show the given comment
1668 1668
         $page = floor($comment_offset / $comments_per_page);
1669 1669
         if ($page) {
1670
-          $params = array('page' => $page);
1670
+            $params = array('page' => $page);
1671
+        }
1671 1672
         }
1672
-      }
1673 1673
     }
1674 1674
     if ($path) {
1675
-      drupal_goto($path, $params, "comment-{$object->cid}");
1675
+        drupal_goto($path, $params, "comment-{$object->cid}");
1676 1676
     }
1677 1677
     break;
1678
-  case 'friend-requests':
1678
+    case 'friend-requests':
1679 1679
     // Check for a login, then redirect to the user's friend requests page
1680 1680
     if ($user->uid) {
1681
-      drupal_goto("account/{$user->uid}/friends/pending");
1681
+        drupal_goto("account/{$user->uid}/friends/pending");
1682 1682
     }
1683 1683
     else {
1684
-      drupal_goto('user/login', array(
1684
+        drupal_goto('user/login', array(
1685 1685
         'destination' => 'goto/friend-requests'
1686
-      ));
1686
+        ));
1687 1687
     }
1688 1688
     break;
1689
-  default:
1689
+    default:
1690 1690
   }
1691
-  drupal_not_found();
1691
+    drupal_not_found();
1692 1692
 }
1693 1693
 
1694 1694
 /*
1695 1695
  * Fetch an array of all countries 
1696 1696
  */
1697 1697
 function boinccore_get_country_list() {
1698
-  return array(
1698
+    return array(
1699 1699
     'None' => 'None',
1700 1700
     'International' => 'International',
1701 1701
     'Afghanistan' => 'Afghanistan',
@@ -1929,7 +1929,7 @@  discard block
 block discarded – undo
1929 1929
     'Yemen' => 'Yemen',
1930 1930
     'Zambia' => 'Zambia',
1931 1931
     'Zimbabwe' => 'Zimbabwe',
1932
-  );
1932
+    );
1933 1933
 }
1934 1934
 
1935 1935
 
@@ -1937,79 +1937,79 @@  discard block
 block discarded – undo
1937 1937
  * Action: Mark node for moderation
1938 1938
  */
1939 1939
 function boinccore_rules_action_mark_content_for_moderation($node) {
1940
-  $node->moderate = 1;
1941
-  return array('node' => $node);
1940
+    $node->moderate = 1;
1941
+    return array('node' => $node);
1942 1942
 }
1943 1943
 
1944 1944
 /**
1945 1945
  * Action: Send mail to moderators.
1946 1946
  */
1947 1947
 function boinccore_rules_action_mail_to_moderators($settings) {
1948
-  module_load_include('inc', 'rules', 'modules/system.rules');
1949
-  $mailing_list = variable_get('boinc_moderator_mailing_list', '');
1950
-  $force_individual_notifications = variable_get('boinc_moderator_force_individual_notifications', 0);
1948
+    module_load_include('inc', 'rules', 'modules/system.rules');
1949
+    $mailing_list = variable_get('boinc_moderator_mailing_list', '');
1950
+    $force_individual_notifications = variable_get('boinc_moderator_force_individual_notifications', 0);
1951 1951
   
1952
-  if (!$mailing_list OR $force_individual_notifications) {
1952
+    if (!$mailing_list OR $force_individual_notifications) {
1953 1953
     // Send individual emails to all moderators
1954 1954
     $roles = user_roles();
1955 1955
     $moderator_rid = array_search('moderator', $roles);
1956 1956
     if ($moderator_rid !== FALSE) {
1957
-      $settings['recipients'] = array($moderator_rid);
1958
-      rules_action_mail_to_users_of_role($settings);
1957
+        $settings['recipients'] = array($moderator_rid);
1958
+        rules_action_mail_to_users_of_role($settings);
1959 1959
     }
1960 1960
     else {
1961
-      watchdog(
1961
+        watchdog(
1962 1962
         'boinccore',
1963 1963
         'Unable to identify members of the moderator role to send moderator notifications!',
1964 1964
         array(),
1965 1965
         WATCHDOG_ERROR
1966
-      );
1966
+        );
1967 1967
     }
1968
-  }
1969
-  if ($mailing_list) {
1968
+    }
1969
+    if ($mailing_list) {
1970 1970
     $settings['to'] = $mailing_list;
1971 1971
     rules_action_mail($settings);
1972
-  }
1972
+    }
1973 1973
 }
1974 1974
 /**
1975 1975
  * Action "Send mail to moderators" configuration form
1976 1976
  */
1977 1977
 function boinccore_rules_action_mail_to_moderators_form($settings = array(), &$form) {
1978
-  // Select only non-anonymous user roles because anonymous users won't have emails.
1979
-  rules_action_mail_to_user_form($settings, $form);
1978
+    // Select only non-anonymous user roles because anonymous users won't have emails.
1979
+    rules_action_mail_to_user_form($settings, $form);
1980 1980
 }
1981 1981
 
1982 1982
 /*
1983 1983
  * BOINC wrapper for string translation
1984 1984
  */
1985 1985
 function bts($string, $args = array(), $langcode = NULL, $context = 'boinc: ', $update = TRUE) {
1986
-  if (function_exists('i18nstrings_ts')) {
1986
+    if (function_exists('i18nstrings_ts')) {
1987 1987
     $string = i18nstrings_ts($context, $string, $langcode, $update);
1988
-  }
1989
-  if (empty($args)) {
1988
+    }
1989
+    if (empty($args)) {
1990 1990
     return $string;
1991
-  }
1992
-  else {
1991
+    }
1992
+    else {
1993 1993
     // Transform arguments before inserting them.
1994 1994
     foreach ($args as $key => $value) {
1995
-      switch ($key [0]) {
1995
+        switch ($key [0]) {
1996 1996
         case '@':
1997 1997
           // Escaped only.
1998 1998
           $args [$key] = check_plain($value);
1999
-          break;
1999
+            break;
2000 2000
 
2001 2001
         case '%':
2002 2002
         default:
2003 2003
           // Escaped and placeholder.
2004 2004
           $args [$key] = theme('placeholder', $value);
2005
-          break;
2005
+            break;
2006 2006
 
2007 2007
         case '!':
2008 2008
           // Pass-through.
2009 2009
       }
2010 2010
     }
2011 2011
     return strtr($string, $args);
2012
-  }
2012
+    }
2013 2013
 }
2014 2014
 
2015 2015
 
@@ -2021,9 +2021,9 @@  discard block
 block discarded – undo
2021 2021
  * Overview of moderation queues
2022 2022
  */               
2023 2023
 function boinccore_moderation_overview_panel() {
2024
-  $output = '<h2 class="pane-title">' . bts('Moderation', array(), NULL, 'boinc:moderate-profiles') . '</h2>';
2025
-  $output .= '<ul class="tab-list action-list">';
2026
-  if (module_exists('user_profiles')) {
2024
+    $output = '<h2 class="pane-title">' . bts('Moderation', array(), NULL, 'boinc:moderate-profiles') . '</h2>';
2025
+    $output .= '<ul class="tab-list action-list">';
2026
+    if (module_exists('user_profiles')) {
2027 2027
     $profile_count = db_result(db_query("
2028 2028
       SELECT COUNT(DISTINCT(n.nid))
2029 2029
       FROM {node} n
@@ -2035,9 +2035,9 @@  discard block
 block discarded – undo
2035 2035
     $output .= '<span class="item-count">' . $profile_count . '</span>';
2036 2036
     $output .= '</div>';
2037 2037
     $output .= '</li>';
2038
-  }
2039
-  $output .= '</ul>';
2040
-  return $output;
2038
+    }
2039
+    $output .= '</ul>';
2040
+    return $output;
2041 2041
 }
2042 2042
 
2043 2043
 
@@ -2047,10 +2047,10 @@  discard block
 block discarded – undo
2047 2047
  *
2048 2048
  */
2049 2049
 function  _boinccore_delete_expired_tokens() {
2050
-  require_boinc('boinc_db');
2050
+    require_boinc('boinc_db');
2051 2051
 
2052
-  $num_deleted = BoincToken::delete_expired();
2053
-  if ($num_deleted>0) {
2052
+    $num_deleted = BoincToken::delete_expired();
2053
+    if ($num_deleted>0) {
2054 2054
     watchdog('boinccore', "Deleted ${num_deleted} tokens from table token", WATCHDOG_NOTICE);
2055
-  }
2055
+    }
2056 2056
 }
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boincuser/boincuser.admin.inc 1 patch
Indentation   +179 added lines, -179 removed lines patch added patch discarded remove patch
@@ -28,13 +28,13 @@  discard block
 block discarded – undo
28 28
 }*/
29 29
 
30 30
 /**
31
-  * The BOINC environment form allows paths to be set to connect Drupal to an
32
-  * existing BOINC web interface.
33
-  */
31
+ * The BOINC environment form allows paths to be set to connect Drupal to an
32
+ * existing BOINC web interface.
33
+ */
34 34
 function boincuser_admin_environment(&$form_state) {
35
-  global $base_url;
36
-  $form = array();
37
-  $default = array(
35
+    global $base_url;
36
+    $form = array();
37
+    $default = array(
38 38
     'boinc_root_dir' => variable_get('boinc_root_dir', ''),
39 39
     'boinc_config_xml_dir' => variable_get('boinc_config_xml_dir', ''),
40 40
     'boinc_html_inc_dir' => variable_get('boinc_html_inc_dir', ''),
@@ -45,291 +45,291 @@  discard block
 block discarded – undo
45 45
     'boinc_app_list_url' => variable_get('boinc_app_list_url', ''),
46 46
     'boinc_debug_mode' => variable_get('boinc_debug_mode', 0),
47 47
     'boinc_project_config_keywords' => variable_get('boinc_project_config_keywords', ''),
48
-  );
49
-  //drupal_set_message(print_r($default, true));
50
-  //drupal_set_message(print_r($form_state, true));
51
-  // Show overrides if the root dir is set and others have not been detected
52
-  $show_overrides = FALSE;
53
-  if ($default['boinc_root_dir']) {
48
+    );
49
+    //drupal_set_message(print_r($default, true));
50
+    //drupal_set_message(print_r($form_state, true));
51
+    // Show overrides if the root dir is set and others have not been detected
52
+    $show_overrides = FALSE;
53
+    if ($default['boinc_root_dir']) {
54 54
     foreach ($default as $key => $dir) {
55
-      switch ($key) {
56
-      case 'boinc_config_xml_dir':
55
+        switch ($key) {
56
+        case 'boinc_config_xml_dir':
57 57
       case 'boinc_html_inc_dir':
58 58
       case 'boinc_project_config_dir':
59 59
       case 'boinc_user_image_dir':
60 60
         // If any of these values are not set, show the overrides section
61 61
         if (!$dir) {
62
-          $default[$key] = $form_state['values'][$key];
63
-          $show_overrides = TRUE;
64
-          break;
62
+            $default[$key] = $form_state['values'][$key];
63
+            $show_overrides = TRUE;
64
+            break;
65 65
         }
66 66
         break;
67
-      default:
67
+        default:
68 68
       }
69
-      if ($show_overrides) {
69
+        if ($show_overrides) {
70 70
         break;
71
-      }
71
+        }
72
+    }
72 73
     }
73
-  }
74
-  // Define the form
75
-  $form['boinc_root_dir'] = array(
74
+    // Define the form
75
+    $form['boinc_root_dir'] = array(
76 76
     '#type' => 'textfield',
77 77
     '#title' => t('BOINC project root directory'),
78 78
     '#default_value' => $default['boinc_root_dir'], 
79 79
     '#description' => t('The filesystem path to the BOINC project root. This
80 80
       directory should contain config.xml as well as the html subdirectory,
81 81
       which itself contains inc/, project/, and user_profile/.'),
82
-  );
83
-  $form['overrides'] = array(
82
+    );
83
+    $form['overrides'] = array(
84 84
     '#title' => t('Overrides'),
85 85
     '#type' => 'fieldset',
86 86
     '#description' => '',
87 87
     '#collapsible' => TRUE,
88 88
     '#collapsed' => !$show_overrides,
89 89
     '#attributes' => array('class' => 'advanced-settings')
90
-  );
91
-  $form['overrides']['boinc_config_xml_dir'] = array(
90
+    );
91
+    $form['overrides']['boinc_config_xml_dir'] = array(
92 92
     '#type' => 'textfield',
93 93
     '#title' => t('BOINC config.xml directory'),
94 94
     '#default_value' => $default['boinc_config_xml_dir'],
95 95
     '#description' => t('The filesystem path that contains config.xml'),
96
-  );
97
-  $form['overrides']['boinc_html_inc_dir'] = array(
96
+    );
97
+    $form['overrides']['boinc_html_inc_dir'] = array(
98 98
     '#type' => 'textfield',
99 99
     '#title' => t('BOINC web includes directory'),
100 100
     '#default_value' => $default['boinc_html_inc_dir'],
101 101
     '#description' => t('The filesystem path to the html/inc/ directory that
102 102
       contains util.inc'),
103
-  );
104
-  $form['overrides']['boinc_project_config_dir'] = array(
103
+    );
104
+    $form['overrides']['boinc_project_config_dir'] = array(
105 105
     '#type' => 'textfield',
106 106
     '#title' => t('BOINC project config directory'),
107 107
     '#default_value' => $default['boinc_project_config_dir'],
108 108
     '#description' => t('The filesystem path to the project/ directory that
109 109
       contains project.inc'),
110
-  );
111
-  $form['overrides']['boinc_user_image_dir'] = array(
110
+    );
111
+    $form['overrides']['boinc_user_image_dir'] = array(
112 112
     '#type' => 'textfield',
113 113
     '#title' => t('BOINC user profile image directory'),
114 114
     '#default_value' => $default['boinc_user_image_dir'],
115 115
     '#description' => t('The filesystem directory that contains user images'),
116
-  );
117
-  $form['boinc_server_status_url'] = array(
116
+    );
117
+    $form['boinc_server_status_url'] = array(
118 118
     '#type' => 'textfield',
119 119
     '#title' => t('BOINC server status page URL (optional)'),
120 120
     '#default_value' => $default['boinc_server_status_url'],
121 121
     '#description' => t('An absolute URL or path relative to the site base to the server status page (e.g. %full_url or just %relative_url).',
122
-      array(
122
+        array(
123 123
         '%full_url' => $base_url . '/server_status.php',
124 124
         '%relative_url' => 'server_status.php',
125
-      )
125
+        )
126 126
     ),
127
-  );
128
-  $form['boinc_app_list_url'] = array(
127
+    );
128
+    $form['boinc_app_list_url'] = array(
129 129
     '#type' => 'textfield',
130 130
     '#title' => t('BOINC applications page URL (optional)'),
131 131
     '#default_value' => $default['boinc_app_list_url'],
132 132
     '#description' => t('An absolute URL or path relative to the site base to the applications page (e.g. %full_url or just %relative_url).',
133
-      array(
133
+        array(
134 134
         '%full_url' => $base_url . '/apps.php',
135 135
         '%relative_url' => 'apps.php',
136
-      )
136
+        )
137 137
     ),
138
-  );
139
-  $form['boinc_host_sched_logs_dir'] = array(
138
+    );
139
+    $form['boinc_host_sched_logs_dir'] = array(
140 140
     '#type' => 'textfield',
141 141
     '#title' => t('BOINC host scheduler log directory (optional)'),
142 142
     '#default_value' => $default['boinc_host_sched_logs_dir'],
143 143
     '#description' => t('The filesystem directory that contains host scheduler logs'),
144
-  );
145
-  $form['boinc_debug_mode'] = array(
144
+    );
145
+    $form['boinc_debug_mode'] = array(
146 146
     '#type' => 'checkbox',
147 147
     '#title' => t('Show debug messages in system log'),
148 148
     '#default_value' => $default['boinc_debug_mode']
149
-  );
150
-  $form['boinc_project_config_keywords'] = array(
149
+    );
150
+    $form['boinc_project_config_keywords'] = array(
151 151
     '#type' => 'textarea',
152 152
     '#title' => t('Project/Job Keywords for get_project_config RPC'),
153 153
     '#default_value' => $default['boinc_project_config_keywords'],
154 154
     '#description' => t('XML from this text box will be appended to the XML output from the get_project_config RPC. There is no check for XML validity! See !link for more details. It is okay to leave this blank.',
155 155
     array(
156
-      '!link' => l('BOINC wiki page', 'https://boinc.berkeley.edu/trac/wiki/JobKeywords')
156
+        '!link' => l('BOINC wiki page', 'https://boinc.berkeley.edu/trac/wiki/JobKeywords')
157 157
     )),
158
-  );
159
-  return system_settings_form($form);
158
+    );
159
+    return system_settings_form($form);
160 160
 }
161 161
 
162 162
 /**
163
-  * Validate the BOINC environment form.
164
-  */
163
+ * Validate the BOINC environment form.
164
+ */
165 165
 function boincuser_admin_environment_validate($form, &$form_state) {
166
-  $values = $form_state['values'];
167
-  if (!$values['boinc_root_dir']) {
166
+    $values = $form_state['values'];
167
+    if (!$values['boinc_root_dir']) {
168 168
     form_set_error('boinc_root_dir', t('BOINC project root directory must be
169 169
       defined!'));
170
-  }
171
-  elseif (!is_dir($values['boinc_root_dir'])) {
170
+    }
171
+    elseif (!is_dir($values['boinc_root_dir'])) {
172 172
     form_set_error('boinc_root_dir', t('BOINC project root not found at %directory',
173
-      array('%directory' => $values['boinc_root_dir'])
173
+        array('%directory' => $values['boinc_root_dir'])
174 174
     ));
175
-  }
176
-  else {
175
+    }
176
+    else {
177 177
     // By default, try to automatically set specific directories from the root
178 178
     if (!$values['boinc_config_xml_dir']) {
179
-      $values['boinc_config_xml_dir'] = $values['boinc_root_dir'];
180
-      form_set_value($form['overrides']['boinc_config_xml_dir'], $values['boinc_config_xml_dir'], $form_state);
179
+        $values['boinc_config_xml_dir'] = $values['boinc_root_dir'];
180
+        form_set_value($form['overrides']['boinc_config_xml_dir'], $values['boinc_config_xml_dir'], $form_state);
181 181
     }
182 182
     if (!$values['boinc_html_inc_dir']) {
183
-      $values['boinc_html_inc_dir'] = "{$values['boinc_root_dir']}/html/inc";
184
-      form_set_value($form['overrides']['boinc_html_inc_dir'], $values['boinc_html_inc_dir'], $form_state);
183
+        $values['boinc_html_inc_dir'] = "{$values['boinc_root_dir']}/html/inc";
184
+        form_set_value($form['overrides']['boinc_html_inc_dir'], $values['boinc_html_inc_dir'], $form_state);
185 185
     }
186 186
     if (!$values['boinc_project_config_dir']) {
187
-      $values['boinc_project_config_dir'] = "{$values['boinc_root_dir']}/html/project";
188
-      form_set_value($form['overrides']['boinc_project_config_dir'], $values['boinc_project_config_dir'], $form_state);
187
+        $values['boinc_project_config_dir'] = "{$values['boinc_root_dir']}/html/project";
188
+        form_set_value($form['overrides']['boinc_project_config_dir'], $values['boinc_project_config_dir'], $form_state);
189 189
     }
190 190
     if (!$values['boinc_user_image_dir']) {
191
-      $values['boinc_user_image_dir'] = "{$values['boinc_root_dir']}/html/user_profile/images";
192
-      form_set_value($form['overrides']['boinc_user_image_dir'], $values['boinc_user_image_dir'], $form_state);
191
+        $values['boinc_user_image_dir'] = "{$values['boinc_root_dir']}/html/user_profile/images";
192
+        form_set_value($form['overrides']['boinc_user_image_dir'], $values['boinc_user_image_dir'], $form_state);
193 193
     }
194 194
     // Validate that required BOINC content is found
195 195
     if (!is_readable("{$values['boinc_config_xml_dir']}/config.xml")) {
196
-      form_set_error('boinc_config_xml_dir', t('@file not found in %directory',
196
+        form_set_error('boinc_config_xml_dir', t('@file not found in %directory',
197 197
         array(
198
-          '@file' => 'config.xml',
199
-          '%directory' => "{$values['boinc_config_xml_dir']}/"
198
+            '@file' => 'config.xml',
199
+            '%directory' => "{$values['boinc_config_xml_dir']}/"
200 200
         )
201
-      ));
201
+        ));
202 202
     }
203 203
     if (!is_readable("{$values['boinc_html_inc_dir']}/util.inc")) {
204
-      form_set_error('boinc_html_inc_dir', t('@file not found in %directory',
204
+        form_set_error('boinc_html_inc_dir', t('@file not found in %directory',
205 205
         array(
206
-          '@file' => 'util.inc',
207
-          '%directory' => "{$values['boinc_html_inc_dir']}/"
206
+            '@file' => 'util.inc',
207
+            '%directory' => "{$values['boinc_html_inc_dir']}/"
208 208
         )
209
-      ));
209
+        ));
210 210
     }
211 211
     if (!is_readable("{$values['boinc_project_config_dir']}/project.inc")) {
212
-      form_set_error('boinc_project_config_dir', t('@file not found in %directory',
212
+        form_set_error('boinc_project_config_dir', t('@file not found in %directory',
213 213
         array(
214
-          '@file' => 'project.inc',
215
-          '%directory' => "{$values['boinc_project_config_dir']}/"
214
+            '@file' => 'project.inc',
215
+            '%directory' => "{$values['boinc_project_config_dir']}/"
216 216
         )
217
-      ));
217
+        ));
218 218
     }
219 219
     if (!is_dir($values['boinc_user_image_dir'])) {
220
-      form_set_error('boinc_user_image_dir', t('Profile image directory not found
220
+        form_set_error('boinc_user_image_dir', t('Profile image directory not found
221 221
         at %directory', array('%directory' => $values['boinc_user_image_dir'])
222
-      ));
222
+        ));
223 223
     }
224 224
     if ($values['boinc_host_sched_logs_dir']
225 225
         AND !is_dir($values['boinc_host_sched_logs_dir'])
226
-      ) {
227
-      form_set_error('boinc_host_sched_logs_dir', t('Host scheduler log
226
+        ) {
227
+        form_set_error('boinc_host_sched_logs_dir', t('Host scheduler log
228 228
         directory not found at %directory',
229 229
         array('%directory' => $values['boinc_host_sched_logs_dir'])
230
-      ));
230
+        ));
231
+    }
231 232
     }
232
-  }
233 233
 }
234 234
 
235 235
 /**
236
-  * Handle post-validation submission of BOINC environment form.
237
-  */
236
+ * Handle post-validation submission of BOINC environment form.
237
+ */
238 238
 function boincuser_admin_environment_submit($form, &$form_state) {
239
-  unset($_SESSION['boinc_env']);
240
-  drupal_set_message(t('BOINC environment settings have been updated.'));
239
+    unset($_SESSION['boinc_env']);
240
+    drupal_set_message(t('BOINC environment settings have been updated.'));
241 241
 }
242 242
 
243 243
 /**
244
-  * The BOINC scheduler form provides options for how scheduler tags are
245
-  * inserted into the front page
246
-  */
244
+ * The BOINC scheduler form provides options for how scheduler tags are
245
+ * inserted into the front page
246
+ */
247 247
 function boincuser_admin_scheduler(&$form_state) {
248
-  $form = array();
249
-  $config_cgi_url = '';
250
-  if ($config_xml_dir = variable_get('boinc_config_xml_dir', '')) {
248
+    $form = array();
249
+    $config_cgi_url = '';
250
+    if ($config_xml_dir = variable_get('boinc_config_xml_dir', '')) {
251 251
     // Get the cgi_url option from the config file as the default scheduler URL
252 252
     $xml = new DOMDocument();
253 253
     if ($xml->load("{$config_xml_dir}/config.xml")) {
254
-      $config = xml_to_array($xml);
255
-      if (isset($config['boinc']['config']['cgi_url']['@value'])) {
254
+        $config = xml_to_array($xml);
255
+        if (isset($config['boinc']['config']['cgi_url']['@value'])) {
256 256
         $config_cgi_url = rtrim(trim($config['boinc']['config']['cgi_url']['@value']), '/');
257 257
         $config_cgi_url .= '/cgi';
258
-      }
258
+        }
259
+    }
259 260
     }
260
-  }
261
-  $default = array(
261
+    $default = array(
262 262
     'boinc_scheduler_urls' => variable_get('boinc_scheduler_urls', $config_cgi_url),
263 263
     'boinc_scheduler_tag_format_old' => variable_get('boinc_scheduler_tag_format_old', 1),
264 264
     'boinc_scheduler_tag_format_new' => variable_get('boinc_scheduler_tag_format_new', 1)
265
-  );
265
+    );
266 266
   
267
-  // Define the form
268
-  $form['boinc_scheduler_urls'] = array(
267
+    // Define the form
268
+    $form['boinc_scheduler_urls'] = array(
269 269
     '#type' => 'textarea',
270 270
     '#title' => t('Scheduling server URLs'),
271 271
     '#default_value' => $default['boinc_scheduler_urls'],
272 272
     '#cols' => 60,
273 273
     '#rows' => 5,
274 274
     '#description' => t('If there are multiple URLs, please enter one per line.'),
275
-  );
276
-  $form['boinc_scheduler_tag_format_old'] = array(
275
+    );
276
+    $form['boinc_scheduler_tag_format_old'] = array(
277 277
     '#type' => 'checkbox',
278 278
     '#title' => t('Old format (@scheduler tag)', array('@scheduler' => '<scheduler>')),
279 279
     '#default_value' => $default['boinc_scheduler_tag_format_old']
280
-  );
281
-  $form['boinc_scheduler_tag_format_new'] = array(
280
+    );
281
+    $form['boinc_scheduler_tag_format_new'] = array(
282 282
     '#type' => 'checkbox',
283 283
     '#title' => t('New format (@link tag)', array('@link' => '<link>')),
284 284
     '#default_value' => $default['boinc_scheduler_tag_format_new']
285
-  );
285
+    );
286 286
   
287
-  return system_settings_form($form);
287
+    return system_settings_form($form);
288 288
 }
289 289
 
290 290
 /**
291
-  * Validate the BOINC scheduler form.
292
-  */
291
+ * Validate the BOINC scheduler form.
292
+ */
293 293
 function boincuser_admin_scheduler_validate($form, &$form_state) {
294
-  $values = $form_state['values'];
295
-  if (!$values['boinc_scheduler_urls']) {
294
+    $values = $form_state['values'];
295
+    if (!$values['boinc_scheduler_urls']) {
296 296
     form_set_error('boinc_scheduler_urls', t('At least one scheduling server
297 297
       URL must be specified.'));
298
-  }
299
-  else {
298
+    }
299
+    else {
300 300
     $urls = explode("\r\n", $values['boinc_scheduler_urls']);
301 301
     foreach ($urls as $key => $url) {
302
-      if (!$url) {
302
+        if (!$url) {
303 303
         unset($urls[$key]);
304 304
         continue;
305
-      }
306
-      if (!filter_var($url, FILTER_VALIDATE_URL)) {
305
+        }
306
+        if (!filter_var($url, FILTER_VALIDATE_URL)) {
307 307
         form_set_error('boinc_scheduler_urls', t('@url is not a valid URL
308 308
           format.', array('@url' => $url)));
309 309
         break;
310
-      }
310
+        }
311 311
     }
312 312
     $form_state['values']['boinc_scheduler_urls'] = implode("\r\n", $urls);
313
-  }
313
+    }
314 314
 }
315 315
 
316 316
 /**
317
-  * Handle post-validation submission of BOINC scheduler form.
318
-  */
317
+ * Handle post-validation submission of BOINC scheduler form.
318
+ */
319 319
 function boincuser_admin_scheduler_submit($form, &$form_state) {
320
-  drupal_set_message(t('BOINC scheduling server settings have been updated.'));
320
+    drupal_set_message(t('BOINC scheduling server settings have been updated.'));
321 321
 }
322 322
 
323 323
 
324 324
 /**
325
-  * Drupal-BOINC Web site related options.
326
-  */
325
+ * Drupal-BOINC Web site related options.
326
+ */
327 327
 function boincuser_admin_weboptions(&$form_state) {
328
-  global $base_url;
329
-  $form = array();
328
+    global $base_url;
329
+    $form = array();
330 330
 
331
-  //form defaults
332
-  $default = array(
331
+    //form defaults
332
+    $default = array(
333 333
     'boinc_weboptions_enableaccountcreateRPC' => variable_get('boinc_weboptions_enableaccountcreateRPC', TRUE),
334 334
     'boinc_weboptions_registrationtitle' => variable_get('boinc_weboptions_registrationtitle', 'Please read and acknowledge our terms of use'),
335 335
     'boinc_weboptions_termsofuse' => variable_get('boinc_weboptions_termsofuse', ''),
@@ -343,65 +343,65 @@  discard block
 block discarded – undo
343 343
     'boinc_weboptions_rulespolicies' => variable_get('boinc_weboptions_rulespolicies', ''),
344 344
     'boinc_other_frontpage' => variable_get('boinc_other_frontpage', ''),
345 345
     'boinc_weboptions_blacklisted_usernames' => variable_get('boinc_weboptions_blacklisted_usernames', "admin\nadministrator\nmoderator"),
346
-  );
346
+    );
347 347
 
348
-  // Define the form
349
-  $form['registrationtitle'] = array(
348
+    // Define the form
349
+    $form['registrationtitle'] = array(
350 350
     '#value' => '<h3>BOINC Registration</h3>',
351
-  );
351
+    );
352 352
 
353
-  $form['boinc_weboptions_enableaccountcreateRPC'] = array(
353
+    $form['boinc_weboptions_enableaccountcreateRPC'] = array(
354 354
     '#type' => 'checkbox',
355 355
     '#title' => t('Enable create_account.php RPC'),
356 356
     '#default_value' => $default['boinc_weboptions_enableaccountcreateRPC'],
357 357
     '#description' => t('If checked, users will be able to create an account remotely using the create_account.php RPC. This option is independent of the user regsitration option found in ') . l(t('User management -> User settings'), '/admin/user/settings') . '. If enabled, user <b>may not be able to see and agree to the terms-of-use</b> to your site\'s privacy and data retention policies!',
358
-  );
358
+    );
359 359
 
360
-  $form['boinc_weboptions_registrationtitle'] = array(
360
+    $form['boinc_weboptions_registrationtitle'] = array(
361 361
     '#type' => 'textfield',
362 362
     '#title' => t('Title of regsistration page'),
363 363
     '#description' => t('Title text presented above the terms of use text.'),
364 364
     '#default_value' => $default['boinc_weboptions_registrationtitle'],
365
-  );
365
+    );
366 366
 
367
-  $form['boinc_weboptions_termsofuse'] = array(
367
+    $form['boinc_weboptions_termsofuse'] = array(
368 368
     '#type' => 'textarea',
369 369
     '#title' => t('Terms of Use Message for User Registration Page'),
370 370
     '#default_value' => $default['boinc_weboptions_termsofuse'],
371 371
     '#cols' => 60,
372 372
     '#rows' => 8,
373 373
     '#description' => t('Text to be displayed on site\'s user registration page. Privacy policy and other data retention information goes here. If empty, there will be no terms of use message, and the title above and checkbox below will not be shown.'),
374
-  );
374
+    );
375 375
 
376
-  $form['boinc_weboptions_overrideboinctou'] = array(
376
+    $form['boinc_weboptions_overrideboinctou'] = array(
377 377
     '#type' => 'checkbox',
378 378
     '#title' => t('Override BOINC terms of use.'),
379 379
     '#default_value' => $default['boinc_weboptions_overrideboinctou'],
380 380
     '#description' => t('Override the BOINC terms_of_use.txt file for get_profject_config.php RPC. If TRUE, the get_project_config.php RPC will use the above terms of use text entered above. Otherwise, the original terms_of_use.txt text file in the project directory is used. And you will need to be responsible for keeping both the text file and the above terms of use text up-to-date and in sync with each other.'),
381
-  );
381
+    );
382 382
 
383
-  $form['boinc_weboptions_agreequestion'] = array(
383
+    $form['boinc_weboptions_agreequestion'] = array(
384 384
     '#type' => 'textfield',
385 385
     '#title' => t('Terms of use agreement question'),
386 386
     '#description' => t('This text is presented to the user as the question next to the \'I agree\' checkbox.'),
387 387
     '#default_value' => $default['boinc_weboptions_agreequestion'],
388
-  );
388
+    );
389 389
 
390
-  $form['boinc_weboptions_registrationtitle2'] = array(
390
+    $form['boinc_weboptions_registrationtitle2'] = array(
391 391
     '#type' => 'textfield',
392 392
     '#title' => t('Instructions for username/email/password questions'),
393 393
     '#description' => t('Title text presented below terms of use and above username/email/password textfields.'),
394 394
     '#default_value' => $default['boinc_weboptions_registrationtitle2'],
395
-  );
395
+    );
396 396
 
397
-  $form['boinc_weboptions_existinguser_tou'] = array(
397
+    $form['boinc_weboptions_existinguser_tou'] = array(
398 398
     '#type' => 'checkbox',
399 399
     '#title' => t('Are existing users forced to agree to the Terms of Use?'),
400 400
     '#default_value' => $default['boinc_weboptions_existinguser_tou'],
401 401
     '#description' => t('If TRUE, existing users are forced to agree to a terms of use (if present) when the login and the system has detected they have not agreed. Otherwise they may login as normal. This option has no affect on whether or not new users must agree to the terms of use.'),
402
-  );
402
+    );
403 403
 
404
-  $form['boinc_weboptions_pathstoignore'] = array(
404
+    $form['boinc_weboptions_pathstoignore'] = array(
405 405
     '#type' => 'textarea',
406 406
     '#title' => t('Paths to ignore the Terms of Use page'),
407 407
     '#default_value' => $default['boinc_weboptions_pathstoignore'],
@@ -410,80 +410,80 @@  discard block
 block discarded – undo
410 410
     '#description' => t('A list of Drupal URLs/paths to ignore for Terms of Use (ToU). If the option above \'Are existing users forced to agree to the Terms of Use?\' is activated, then some paths need to be ignored when checking if a user has agreed to the ToU. A good example is the logout path, "logout", or else users will not be able to logout!
411 411
 <p>There is a default list of paths that must be ignored or else the site will not function. They are not included in this box. Here you may provide additional paths to be ignored, for example the privacy policy page may be accessible so that users may read it before agreeing to the site\'s ToU.
412 412
 <p>Paths should be entered one per line. All paths should be <em>lower-case</em> and  should not include a leading \'/\'. Example: account/info/edit will allow the user to visit ' . $base_url . '/account/info/edit without first agreeing to the ToU. Regexp are allowed. Example: account/* will allow the user to visit any path starting with ' . $base_url . '/account/.'),
413
-  );
413
+    );
414 414
 
415
-  $form['pathtitle'] = array(
415
+    $form['pathtitle'] = array(
416 416
     '#value' => '<h3>Path Options</h3>',
417
-  );
417
+    );
418 418
 
419
-  $form['boinc_weboptions_accountfinish'] = array (
419
+    $form['boinc_weboptions_accountfinish'] = array (
420 420
     '#type' => 'textfield',
421 421
     '#title' => t('Path to a custom account_finish.php page, should be a path to a node'),
422 422
     '#description' => t('Provide a path to a node which will serve as your site\'s landing page for users create an account using the BOINC client manager. They will be directed to this page after the account is created. If blank, a default account_finish page will be used.<br>Examples: account_finish, content/welcome, node/123'),
423 423
     '#default_value' => $default['boinc_weboptions_accountfinish'],
424
-  );
425
-  $form['boinc_weboptions_moderationpage'] = array (
424
+    );
425
+    $form['boinc_weboptions_moderationpage'] = array (
426 426
     '#type' => 'textfield',
427 427
     '#title' => t('Path to the site\'s content moderation info page, should be a path to a node'),
428 428
     '#description' => t('Provide a path to a node which will serve as your site\'s page for account/content moderation information. This will be used on the default account_finish page. If blank, no link to a moderation page will be provided. If a path is provided to the custom account_finish.php page (above), this field will be ignored.<br>Examples: moderation, content/moderation, node/456'),
429 429
     '#default_value' => $default['boinc_weboptions_moderationpage'],
430
-  );
431
-  $form['boinc_weboptions_rulespolicies'] = array (
430
+    );
431
+    $form['boinc_weboptions_rulespolicies'] = array (
432 432
     '#type' => 'textfield',
433 433
     '#title' => t('Path to the site\'s rule and policies page, should be a path to a node'),
434 434
     '#description' => t('Provide a path to a node which will serve as your site\'s rules and policies page. This will be used on the Join page shown to new users. If blank, no link to a rules and policies page will be provided.<br>Examples: rules-and-policies, node/789'),
435 435
     '#default_value' => $default['boinc_weboptions_rulespolicies'],
436
-  );
437
-  $form['boinc_other_frontpage'] = array (
436
+    );
437
+    $form['boinc_other_frontpage'] = array (
438 438
     '#type' => 'textarea',
439 439
     '#title' => bts('Message for site\'s Home Page', array(), NULL, 'boinc:admin-boinc-other-options'),
440 440
     '#default_value' => $default['boinc_other_frontpage'],
441 441
     '#cols' => 60,
442 442
     '#rows' => 8,
443 443
     '#description' => bts('Text to be displayed on the site\'s Home landing page.', array(), NULL, 'boinc:admin-boinc-other-options'),
444
-  );
444
+    );
445 445
 
446
-  $form['Othertitle'] = array(
446
+    $form['Othertitle'] = array(
447 447
     '#value' => '<h3>Other Options</h3>',
448
-  );
448
+    );
449 449
 
450
-  $form['boinc_weboptions_blacklisted_usernames'] = array (
450
+    $form['boinc_weboptions_blacklisted_usernames'] = array (
451 451
     '#type' => 'textarea',
452 452
     '#title' => t('BOINC username blacklist'),
453 453
     '#default_value' => $default['boinc_weboptions_blacklisted_usernames'],
454 454
     '#cols' => 60,
455 455
     '#rows' => 7,
456 456
     '#description' => t('Username blacklist: List of names that users will not be able to choose as their BOINC username. This will only affect Web registration and when a user changes their name using the Web site. Names should be entered one per line.<p>All names should be <em>lower-case</em>. The comparison made is case-insensitive.<p>If you wish to <em>disable</em> this feature, remove all names from this textbox; the blacklist will be empty.'),
457
-  );
457
+    );
458 458
 
459
-  return system_settings_form($form);
459
+    return system_settings_form($form);
460 460
 }
461 461
 
462 462
 /**
463
-  * Validate BOINC other form
464
-  */
463
+ * Validate BOINC other form
464
+ */
465 465
 function boincuser_admin_weboptions_validate($form, &$form_state) {
466
-  $values = $form_state['values'];
466
+    $values = $form_state['values'];
467 467
 
468
-  $accountfinish = $values['boinc_weboptions_accountfinish'];
469
-  if ( ($accountfinish) AND (!drupal_lookup_path('source', $accountfinish)) ) {
468
+    $accountfinish = $values['boinc_weboptions_accountfinish'];
469
+    if ( ($accountfinish) AND (!drupal_lookup_path('source', $accountfinish)) ) {
470 470
     form_set_error('boinc weboptions_accountfinish', t('Path to custom account finish page not found. Please provide a valid path, or leave blank to unset.'));
471
-  }
471
+    }
472 472
 
473
-  $moderationpage = $values['boinc_weboptions_moderationpage'];
474
-  if ( ($moderationpage) AND (!drupal_lookup_path('source', $moderationpage)) ) {
473
+    $moderationpage = $values['boinc_weboptions_moderationpage'];
474
+    if ( ($moderationpage) AND (!drupal_lookup_path('source', $moderationpage)) ) {
475 475
     form_set_error('boinc weboptions_moderationpage', t('Path to moderation page not found. Please provide a valid path, or leave blank to unset.'));
476
-  }
476
+    }
477 477
 
478
-  $rulespolicies = $values['boinc_weboptions_rulespolicies'];
479
-  if ( ($rulespolicies) AND (!drupal_lookup_path('source', $rulespolicies)) ) {
478
+    $rulespolicies = $values['boinc_weboptions_rulespolicies'];
479
+    if ( ($rulespolicies) AND (!drupal_lookup_path('source', $rulespolicies)) ) {
480 480
     form_set_error('boinc weboptions_rulespolicies', t('Path to rules and policies page not found. Please provide a valid path, or leave blank to unset.'));
481
-  }
481
+    }
482 482
 }
483 483
 
484 484
 /**
485
-  * Submit BOINC other form
486
-  */
485
+ * Submit BOINC other form
486
+ */
487 487
 function boincuser_admin_weboptions_submit($form, &$form_state) {
488
-  drupal_set_message( bts("Status: Drupa-BOINC Web site options have been updated", array(), NULL, 'boinc:admin-boinc-website-options') );
488
+    drupal_set_message( bts("Status: Drupa-BOINC Web site options have been updated", array(), NULL, 'boinc:admin-boinc-website-options') );
489 489
 }
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boincuser/boincuser.module 1 patch
Indentation   +834 added lines, -834 removed lines patch added patch discarded remove patch
@@ -27,44 +27,44 @@  discard block
 block discarded – undo
27 27
  * with defined URL paths
28 28
  */
29 29
 function boincuser_menu() {
30
-  $items['account/posts'] = array(
30
+    $items['account/posts'] = array(
31 31
     'title' => 'Recent posts',
32 32
     'description' => '',
33 33
     'page callback' => 'boincuser_goto_recent_posts',
34 34
     'access callback' => 'user_is_logged_in',
35 35
     'type' => MENU_CALLBACK,
36
-  );
37
-  $items['account/profile'] = array(
36
+    );
37
+    $items['account/profile'] = array(
38 38
     'title' => '',
39 39
     'description' => '',
40 40
     'page callback' => 'boincuser_view_profile',
41 41
     'access callback' => 'user_is_logged_in',
42 42
     'type' => MENU_NORMAL_ITEM
43
-  );
44
-  $items['account/profile/view'] = array(
43
+    );
44
+    $items['account/profile/view'] = array(
45 45
     'title' => 'View',
46 46
     'description' => 'Show a user profile',
47 47
     'page callback' => 'boincuser_view_profile',
48 48
     'access callback' => 'user_is_logged_in',
49 49
     'type' => MENU_DEFAULT_LOCAL_TASK,
50 50
     'weight' => 0
51
-  );
52
-  $items['account/profile/edit'] = array(
51
+    );
52
+    $items['account/profile/edit'] = array(
53 53
     'title' => 'Edit',
54 54
     'description' => 'Edit a user profile',
55 55
     'page callback' => 'boincuser_edit_profile',
56 56
     'access arguments' => array('edit own profile content'),
57 57
     'type' => MENU_LOCAL_TASK,
58 58
     'weight' => 5
59
-  );
60
-  $items['account/team'] = array(
59
+    );
60
+    $items['account/team'] = array(
61 61
     'title' => 'User team',
62 62
     'description' => '',
63 63
     'page callback' => 'boincuser_goto_team',
64 64
     'access callback' => 'user_is_logged_in',
65 65
     'type' => MENU_CALLBACK,
66
-  );
67
-  $items['moderate/profile/%user/approve'] = array(
66
+    );
67
+    $items['moderate/profile/%user/approve'] = array(
68 68
     'title' => 'Profile approval',
69 69
     'description' => 'Approve profile content',
70 70
     'page callback' => 'boincuser_moderate_profile_approve',
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
     'access arguments' => array('edit any profile content'),
73 73
     'type' => MENU_CALLBACK,
74 74
     'weight' => 5
75
-  );
76
-  $items['moderate/profile/%user/edit'] = array(
75
+    );
76
+    $items['moderate/profile/%user/edit'] = array(
77 77
     'title' => 'Profile editor',
78 78
     'description' => 'Edit a user profile',
79 79
     'page callback' => 'boincuser_edit_profile',
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
     'access arguments' => array('edit any profile content'),
82 82
     'type' => MENU_CALLBACK,
83 83
     'weight' => 5
84
-  );
85
-  $items['moderate/profile/%/reject'] = array(
84
+    );
85
+    $items['moderate/profile/%/reject'] = array(
86 86
     'title' => bts('Reject profile', array(), NULL, 'boinc:moderate-user'),
87 87
     'description' => 'Reject profile content',
88 88
     'page callback' => 'drupal_get_form',
@@ -90,60 +90,60 @@  discard block
 block discarded – undo
90 90
     'access arguments' => array('edit any profile content'),
91 91
     'type' => MENU_CALLBACK,
92 92
     'weight' => 5
93
-  );
94
-  $items['moderate/user/%/ban'] = array(
93
+    );
94
+    $items['moderate/user/%/ban'] = array(
95 95
     'title' => bts('Ban user', array(), NULL, 'boinc:moderate-ban-user'),
96 96
     'description' => 'Ban a user from using community features',
97 97
     'page callback' => 'drupal_get_form',
98 98
     'page arguments' => array('boincuser_moderate_user_ban_form', 2),
99 99
     'access callback' => 'boincuser_moderate_community_access',
100 100
     'type' => MENU_CALLBACK,
101
-  );
102
-  $items['join'] = array(
101
+    );
102
+    $items['join'] = array(
103 103
     'title' => '',
104 104
     'description' => '',
105 105
     'page callback' => 'join_page',
106 106
     'access arguments' => array('access content'),
107 107
     'type' => MENU_NORMAL_ITEM
108
-  );
109
-  $items['join/new'] = array(
108
+    );
109
+    $items['join/new'] = array(
110 110
     'title' => bts("I'm new"),
111 111
     'page callback' => 'join_page',
112 112
     'page arguments' => array(1),
113 113
     'access arguments' => array('access content'),
114 114
     'type' => MENU_DEFAULT_LOCAL_TASK,
115 115
     'weight' => 0
116
-  );
117
-  $items['join/boinc'] = array(
116
+    );
117
+    $items['join/boinc'] = array(
118 118
     'title' => bts("I'm a BOINC user"),
119 119
     'page callback' => 'join_page',
120 120
     'page arguments' => array(1),
121 121
     'access arguments' => array('access content'),
122 122
     'type' => MENU_LOCAL_TASK,
123 123
     'weight' => 5
124
-  );
125
-  $items['user/login/auth'] = array(
124
+    );
125
+    $items['user/login/auth'] = array(
126 126
     'title' => bts('Authenticator login', array(), NULL, 'boinc:authenticator-login-page'),
127 127
     'description' => 'Log in using a user authenticator',
128 128
     'page callback' => 'drupal_get_form',
129 129
     'page arguments' => array('boincuser_authloginform'),
130 130
     'access arguments' => array('access content'),
131 131
     'type' => MENU_CALLBACK,
132
-  );
133
-  $items['user/termsofuse'] = array(
132
+    );
133
+    $items['user/termsofuse'] = array(
134 134
     'title' => bts('Terms of Use', array(), NULL, 'boinc:termsofuse-form'),
135 135
     'description' => 'A site\'s term of use.',
136 136
     'page callback' => 'drupal_get_form',
137 137
     'page arguments' => array('boincuser_termsofuse_form'),
138 138
     'access callback' => 'user_is_logged_in',
139 139
     'type' => MENU_CALLBACK,
140
-  );
141
-  $items['user_control'] = array(
140
+    );
141
+    $items['user_control'] = array(
142 142
     'page callback' => 'boincuser_control',
143 143
     'access arguments' => array('access user profiles'),
144 144
     'type' => MENU_CALLBACK
145
-  );
146
-  $items['admin/boinc'] = array(
145
+    );
146
+    $items['admin/boinc'] = array(
147 147
     'title' => 'BOINC configuration',
148 148
     'position' => 'right',
149 149
     'weight' => -8,
@@ -151,8 +151,8 @@  discard block
 block discarded – undo
151 151
     'access arguments' => array('administer site configuration'),
152 152
     'file' => 'system.admin.inc',
153 153
     'file path' => drupal_get_path('module', 'system'),
154
-  );
155
-  $items['admin/boinc/environment'] = array(
154
+    );
155
+    $items['admin/boinc/environment'] = array(
156 156
     'title' => 'Environment: General',
157 157
     'description' => 'Set paths to BOINC functions and any other necessary
158 158
       variables that establish a BOINC environment.',
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
     'access arguments' => array('administer site configuration'),
162 162
     'type' => MENU_NORMAL_ITEM,
163 163
     'file' => 'boincuser.admin.inc'
164
-  );
165
-  $items['admin/boinc/scheduler'] = array(
164
+    );
165
+    $items['admin/boinc/scheduler'] = array(
166 166
     'title' => 'Environment: Scheduling server URLs',
167 167
     'description' => 'Set BOINC scheduler options.',
168 168
     'page callback' => 'drupal_get_form',
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
     'access arguments' => array('administer site configuration'),
171 171
     'type' => MENU_NORMAL_ITEM,
172 172
     'file' => 'boincuser.admin.inc'
173
-  );
174
-  $items['admin/boinc/weboptions'] = array(
173
+    );
174
+    $items['admin/boinc/weboptions'] = array(
175 175
     'title' => 'Environment: Website Options',
176 176
     'description' => 'Set options configuring this Drupal-BOINC Web site.',
177 177
     'page callback' => 'drupal_get_form',
@@ -179,117 +179,117 @@  discard block
 block discarded – undo
179 179
     'access arguments' => array('administer site configuration'),
180 180
     'type' => MENU_NORMAL_ITEM,
181 181
     'file' => 'boincuser.admin.inc'
182
-  );
182
+    );
183 183
   
184
-  $items['create_account.php'] = array(
184
+    $items['create_account.php'] = array(
185 185
     'title' => 'Create Account RPC',
186 186
     'description' => 'RPC for creating user accounts.',
187 187
     'page callback' => 'boincuser_create_account',
188 188
     'access callback' => TRUE,
189 189
     'type' => MENU_CALLBACK
190
-  );
191
-  $items['account_finish.php'] = array(
190
+    );
191
+    $items['account_finish.php'] = array(
192 192
     'title' => 'Welcome to ' . variable_get('site_name', 'Drupal-BOINC'),
193 193
     'description' => 'RPC for after a user has created an account.',
194 194
     'page callback' => 'boincuser_account_finish',
195 195
     'access callback' => TRUE,
196 196
     'type' => MENU_CALLBACK,
197
-  );
198
-  $items['boincuser/autocomplete'] = array(
197
+    );
198
+    $items['boincuser/autocomplete'] = array(
199 199
     'page callback' => '_boincuser_user_name_autocomplete',
200 200
     'access callback' => TRUE,
201 201
     'type' => MENU_CALLBACK,
202
-  );
203
-  $items['user/%user/recoveremail/%'] = array(
202
+    );
203
+    $items['user/%user/recoveremail/%'] = array(
204 204
     'title' => t('Recover previous email'),
205 205
     'description' => t('Form to revert email to previous address.'),
206 206
     'page callback' => 'drupal_get_form',
207 207
     'page arguments' => array('boincuser_revertemail', 3),
208 208
     'access callback' => 'user_is_logged_in',
209 209
     'type' => MENU_CALLBACK,
210
-  );
211
-  $items['recover_email.php'] = array(
210
+    );
211
+    $items['recover_email.php'] = array(
212 212
     'title' => t('Recover previous email'),
213 213
     'description' => t('redirect'),
214 214
     'page callback' => '_boincuser_redirect_recover_email',
215 215
     'access callback' => TRUE,
216 216
     'type' => MENU_CALLBACK,
217
-  );
218
-  return $items;
217
+    );
218
+    return $items;
219 219
 }
220 220
 
221 221
 /**
222 222
  * Implementation of hook_init()
223 223
  */
224 224
 function boincuser_init() {
225
-  global $user;
226
-  // Skip this check for charts, which are loaded separately
227
-  // (may get duplicate or unexpected messages otherwise)
228
-  if (substr($_GET['q'], 0, 7) == 'charts/') {
225
+    global $user;
226
+    // Skip this check for charts, which are loaded separately
227
+    // (may get duplicate or unexpected messages otherwise)
228
+    if (substr($_GET['q'], 0, 7) == 'charts/') {
229 229
     return;
230
-  }
230
+    }
231 231
 
232
-  // If admin user, do some basic site functionality checks
233
-  if (user_access('administer site configuration')) {
232
+    // If admin user, do some basic site functionality checks
233
+    if (user_access('administer site configuration')) {
234 234
     // Ensure we have a configured BOINC environment
235 235
     boinc_get_path();
236 236
     boinc_get_scheduler_tags();
237
-  }
237
+    }
238 238
   
239
-  // Check credits for the verified contributor role
240
-  boincuser_check_credit_requirements();
239
+    // Check credits for the verified contributor role
240
+    boincuser_check_credit_requirements();
241 241
   
242
-  if (module_exists('boincteam')) {
242
+    if (module_exists('boincteam')) {
243 243
     // Display any persistent team messages
244 244
     boincteam_show_messages();
245
-  }
245
+    }
246 246
 
247
-  // Check if user has agreed to the terms of use. If not, send the
248
-  // user to the terms-of-use form. This is only makes sense if the
249
-  // termsofuse is enabled, by having text in the termsofuse variable.
250
-  $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE);
251
-  $termsofuse = variable_get('boinc_weboptions_termsofuse', '');
252
-  if ( (!empty($termsofuse)) and ($user->uid) ) {
247
+    // Check if user has agreed to the terms of use. If not, send the
248
+    // user to the terms-of-use form. This is only makes sense if the
249
+    // termsofuse is enabled, by having text in the termsofuse variable.
250
+    $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE);
251
+    $termsofuse = variable_get('boinc_weboptions_termsofuse', '');
252
+    if ( (!empty($termsofuse)) and ($user->uid) ) {
253 253
     if ( !boincuser_check_termsofuse($user) and ($existinguser_tou) ) {
254 254
 
255
-      // Admins are exempt, otherwise the admin may not be able to
256
-      // access the site!
257
-      $administrator_role = array_search('administrator', user_roles(true));
258
-      if (!isset($user->roles[$administrator_role])) {
255
+        // Admins are exempt, otherwise the admin may not be able to
256
+        // access the site!
257
+        $administrator_role = array_search('administrator', user_roles(true));
258
+        if (!isset($user->roles[$administrator_role])) {
259 259
         $path = drupal_get_path_alias($_GET['q']);
260 260
 
261 261
         // Any paths that should NOT be redirected go here.
262 262
         // The site will not function correctly if these are not exempt!
263 263
         $paths0 = array(
264
-          'user/termsofuse',
265
-          'logout',
266
-          'account/info/edit',
267
-          'user/' . $user->uid . '/edit',
268
-          'user/' . $user->uid . '/recoveremail/*',
269
-          'recover_email.php',
264
+            'user/termsofuse',
265
+            'logout',
266
+            'account/info/edit',
267
+            'user/' . $user->uid . '/edit',
268
+            'user/' . $user->uid . '/recoveremail/*',
269
+            'recover_email.php',
270 270
         );
271 271
         if (module_exists('boincuser_delete')) {
272
-          $paths0[] = 'user/' . $user->uid . '/delete';
273
-          $paths0[] = 'user/' . $user->uid . '/deleteconfirm/*';
274
-          $paths0[] = 'user/' . $user->uid . '/odeleteconfirm/*';
272
+            $paths0[] = 'user/' . $user->uid . '/delete';
273
+            $paths0[] = 'user/' . $user->uid . '/deleteconfirm/*';
274
+            $paths0[] = 'user/' . $user->uid . '/odeleteconfirm/*';
275 275
         }
276 276
 
277 277
         // Paths added by the admin
278 278
         $paths1 = preg_split('/\r\n|\r|\n/', variable_get('boinc_weboptions_pathstoignore', "moderation\ncontent/moderation\nprivacy"));
279 279
         $paths2 = array();
280 280
         if (is_array($paths1)) {
281
-          $paths2 = array_map('strtolower', $paths1);
281
+            $paths2 = array_map('strtolower', $paths1);
282 282
         }
283 283
 
284 284
         // paths to ignore
285 285
         $paths_to_ignore = array_unique( array_merge($paths0, $paths2) );
286 286
 
287 287
         if (!_boincuser_ignore_paths($path, $paths_to_ignore)) {
288
-          drupal_goto('user/termsofuse');
288
+            drupal_goto('user/termsofuse');
289
+        }
289 290
         }
290
-      }
291 291
     }
292
-  }
292
+    }
293 293
 }
294 294
 
295 295
 /**
@@ -297,13 +297,13 @@  discard block
 block discarded – undo
297 297
  * Drupal user operations
298 298
  */
299 299
 function boincuser_user($op, &$edit, &$account, $category = NULL) {
300
-  require_boinc('boinc_db');
301
-  require_boinc('user');
302
-  require_boinc('xml');
300
+    require_boinc('boinc_db');
301
+    require_boinc('user');
302
+    require_boinc('xml');
303 303
 
304
-  require_boinc('password_compat/password');
305
-  // Handle BOINC integration for users with UID > 1 (skip anonymous and admin)
306
-  if ($account->uid > 1) {
304
+    require_boinc('password_compat/password');
305
+    // Handle BOINC integration for users with UID > 1 (skip anonymous and admin)
306
+    if ($account->uid > 1) {
307 307
     switch($op) {
308 308
     case 'load':
309 309
       // User loading; insert BOINC data into the user object
@@ -311,11 +311,11 @@  discard block
 block discarded – undo
311 311
         SELECT boinc_id, penalty_expiration
312 312
         FROM {boincuser} WHERE uid = %d",
313 313
         $account->uid
314
-      ));
315
-      $account->boincuser_id = $drupal_user->boinc_id;
316
-      $account->boincuser_penalty_expiration = $drupal_user->penalty_expiration;
317
-      db_set_active('boinc_rw');
318
-      $boinc_user = db_fetch_object(db_query("
314
+        ));
315
+        $account->boincuser_id = $drupal_user->boinc_id;
316
+        $account->boincuser_penalty_expiration = $drupal_user->penalty_expiration;
317
+        db_set_active('boinc_rw');
318
+        $boinc_user = db_fetch_object(db_query("
319 319
         SELECT
320 320
           name,
321 321
           authenticator,
@@ -331,29 +331,29 @@  discard block
 block discarded – undo
331 331
         FROM {user}
332 332
         WHERE id = %d",
333 333
         $account->boincuser_id
334
-      ));
335
-      $account->boincuser_name = $boinc_user->name;
336
-      $account->boincuser_account_key = $boinc_user->authenticator;
337
-      $account->boincuser_weak_auth = md5($boinc_user->authenticator . $boinc_user->passwd_hash);
338
-      $account->boincuser_total_credit = round($boinc_user->total_credit);
339
-      $account->boincuser_expavg_credit = round($boinc_user->expavg_credit);
340
-      $account->boincuser_expavg_time = round($boinc_user->expavg_time);
341
-      $account->boincuser_cpid = md5($boinc_user->cross_project_id . $account->mail);
342
-      $account->boincuser_default_pref_set = $boinc_user->venue;
343
-      $account->boincteam_id = $boinc_user->teamid;
344
-      $account->boincuser_previous_email_addr = $boinc_user->previous_email_addr;
345
-      $account->boincuser_email_addr_change_time = $boinc_user->email_addr_change_time;
346
-      db_set_active('default');
347
-      // Set Drupal team ID
348
-      $account->team = NULL;
349
-      if ($account->boincteam_id) {
334
+        ));
335
+        $account->boincuser_name = $boinc_user->name;
336
+        $account->boincuser_account_key = $boinc_user->authenticator;
337
+        $account->boincuser_weak_auth = md5($boinc_user->authenticator . $boinc_user->passwd_hash);
338
+        $account->boincuser_total_credit = round($boinc_user->total_credit);
339
+        $account->boincuser_expavg_credit = round($boinc_user->expavg_credit);
340
+        $account->boincuser_expavg_time = round($boinc_user->expavg_time);
341
+        $account->boincuser_cpid = md5($boinc_user->cross_project_id . $account->mail);
342
+        $account->boincuser_default_pref_set = $boinc_user->venue;
343
+        $account->boincteam_id = $boinc_user->teamid;
344
+        $account->boincuser_previous_email_addr = $boinc_user->previous_email_addr;
345
+        $account->boincuser_email_addr_change_time = $boinc_user->email_addr_change_time;
346
+        db_set_active('default');
347
+        // Set Drupal team ID
348
+        $account->team = NULL;
349
+        if ($account->boincteam_id) {
350 350
         $account->team = db_result(db_query("
351 351
           SELECT nid FROM {boincteam} WHERE team_id = %d",
352
-          $account->boincteam_id
352
+            $account->boincteam_id
353 353
         ));
354
-      }
355
-      // Set post count
356
-      $account->post_count = db_result(db_query("
354
+        }
355
+        // Set post count
356
+        $account->post_count = db_result(db_query("
357 357
         SELECT COUNT(*) +
358 358
         (
359 359
           SELECT COUNT(*) FROM {node}
@@ -366,8 +366,8 @@  discard block
 block discarded – undo
366 366
         WHERE comments.uid = '%d'
367 367
         AND node.status = 1",
368 368
         $account->uid, $account->uid
369
-      ));
370
-      break;
369
+        ));
370
+        break;
371 371
       
372 372
     case 'view':
373 373
       // SAMPLE: Add BOINC data to the user profile
@@ -393,74 +393,74 @@  discard block
 block discarded – undo
393 393
         case 'user_account':
394 394
           // Validate data before updating user account info
395 395
           boincuser_account_validate($edit, $account);
396
-          break;
396
+            break;
397 397
         
398 398
         default:
399 399
           
400 400
         }
401 401
         // We don't want to save validation source, so remove it
402 402
         $edit['validation_source'] = null;
403
-      }
404
-      break;
403
+        }
404
+        break;
405 405
       
406 406
     case 'insert':
407 407
       // New user being added to the system
408 408
       $imported = $_SESSION['importedUser'];
409
-      unset($_SESSION['importedUser']);
409
+        unset($_SESSION['importedUser']);
410 410
       
411
-      watchdog(
411
+        watchdog(
412 412
         'boincuser',
413 413
         'Creating user account for %email_addr',
414 414
         array('%email_addr' => $edit['mail']),
415 415
         WATCHDOG_NOTICE
416
-      );
416
+        );
417 417
       
418
-      // The create_acount RPC will call this block of code when
419
-      // user_save() is used. If user is registering using the Web
420
-      // registration form, create a BOINC user and relationships.
421
-      // Create a BOINC account unless importing from BOINC.
422
-      if (!$imported) {
418
+        // The create_acount RPC will call this block of code when
419
+        // user_save() is used. If user is registering using the Web
420
+        // registration form, create a BOINC user and relationships.
421
+        // Create a BOINC account unless importing from BOINC.
422
+        if (!$imported) {
423 423
 
424 424
         // set email address lower-case
425 425
         $lower_email_addr = strtolower($edit['mail']);
426 426
 
427 427
         if ($edit['boincuser_name']) {
428
-          $myname = $edit['boincuser_name'];
428
+            $myname = $edit['boincuser_name'];
429 429
         }
430 430
         else if ($edit['name']) {
431
-          $myname = $edit['name'];
431
+            $myname = $edit['name'];
432 432
         }
433 433
         else {
434
-          $myname = 'noname';
434
+            $myname = 'noname';
435 435
         }
436 436
 
437 437
         $user_params = array(
438
-          'email_addr' => $lower_email_addr,
439
-          'name' => $myname,
438
+            'email_addr' => $lower_email_addr,
439
+            'name' => $myname,
440 440
         );
441 441
 
442 442
         // If the 'pass' variable is already a hash, then don't hash it again.
443 443
         if ($edit['boinchash_flag']) {
444
-          $user_params['passwd_hash'] = $edit['pass'];
444
+            $user_params['passwd_hash'] = $edit['pass'];
445 445
         }
446 446
         else {
447
-          // The passwd_hash here is only the md5() hash. This is
448
-          // because BOINC make_user(), called later, will run
449
-          // password_hash() on this md5 hash.
450
-          $user_params['passwd_hash'] = md5($edit['pass'].$lower_email_addr);
447
+            // The passwd_hash here is only the md5() hash. This is
448
+            // because BOINC make_user(), called later, will run
449
+            // password_hash() on this md5 hash.
450
+            $user_params['passwd_hash'] = md5($edit['pass'].$lower_email_addr);
451 451
         }
452 452
 
453 453
         $boinc_user = boincuser_register_make_user($user_params);
454 454
         if (!$boinc_user) {
455
-          // Account exists with this email addr
456
-          form_set_error('email', bts('Error creating BOINC account.', array(), NULL, 'boinc:add-new-user'));
457
-          return;
455
+            // Account exists with this email addr
456
+            form_set_error('email', bts('Error creating BOINC account.', array(), NULL, 'boinc:add-new-user'));
457
+            return;
458 458
         }
459 459
 
460 460
         // Add user to community role by default (not banned)
461 461
         $unrestricted_role = array_search('community member', user_roles(true)); 
462 462
         $edit['roles'] = array(
463
-          $unrestricted_role => ''
463
+            $unrestricted_role => ''
464 464
         );
465 465
 
466 466
         // Disable show_hosts flag, set to TRUE by default
@@ -471,14 +471,14 @@  discard block
 block discarded – undo
471 471
         // Cross reference Drupal account with BOINC
472 472
         $reference = db_query("INSERT INTO {boincuser} SET uid='%d', boinc_id='%d'", $account->uid, $boinc_user->id);
473 473
         if (!$reference) {
474
-          drupal_set_message(t('Error connecting BOINC account.'), 'error');
475
-          return;
474
+            drupal_set_message(t('Error connecting BOINC account.'), 'error');
475
+            return;
476 476
         }
477 477
 
478 478
         // if terms of use exist, the user must agree.
479 479
         $termsofuse = variable_get('boinc_weboptions_termsofuse', '');
480 480
         if (!empty($termsofuse)) {
481
-          $reference2 = boincuser_consentto_termsofuse($account);
481
+            $reference2 = boincuser_consentto_termsofuse($account);
482 482
         }
483 483
 
484 484
         // Don't save custom fields to the Drupal user object
@@ -486,10 +486,10 @@  discard block
 block discarded – undo
486 486
         $edit['boinchash_flag'] = null;
487 487
         // Set email address to lower case in Drupal users table
488 488
         if ($account) {
489
-          user_save($account, array('mail' => $lower_email_addr));
489
+            user_save($account, array('mail' => $lower_email_addr));
490 490
         }
491
-      }
492
-      break;
491
+        }
492
+        break;
493 493
       
494 494
     case 'update':
495 495
       if (isset($edit['update_source'])) {
@@ -500,8 +500,8 @@  discard block
 block discarded – undo
500 500
           // Ensure that BOINC data is altered
501 501
 
502 502
           $changing_email = ($edit['mail'] AND $edit['mail'] != $boinc_user->email_addr) ? true : false;
503
-          $changing_pass = ($edit['pass']) ? true : false;
504
-          if ($changing_email OR $changing_pass) {
503
+            $changing_pass = ($edit['pass']) ? true : false;
504
+            if ($changing_email OR $changing_pass) {
505 505
             // set email address to lower-case
506 506
             $lower_email_addr = strtolower($edit['mail']);
507 507
 
@@ -510,70 +510,70 @@  discard block
 block discarded – undo
510 510
             $passwd_hash = password_hash( md5($passwd.$lower_email_addr), PASSWORD_DEFAULT );
511 511
             // Algorithm for changing email and/or password
512 512
             if ($changing_email) {
513
-              // locally store current email to set as previous email
514
-              $prev_email = $account->mail;
515
-              $mytime = (user_access('administer users')) ? $boinc_user->email_addr_change_time : time();
516
-              $querypart = "email_addr='{$lower_email_addr}', passwd_hash='{$passwd_hash}', previous_email_addr = '{$prev_email}', email_addr_change_time = $mytime";
513
+                // locally store current email to set as previous email
514
+                $prev_email = $account->mail;
515
+                $mytime = (user_access('administer users')) ? $boinc_user->email_addr_change_time : time();
516
+                $querypart = "email_addr='{$lower_email_addr}', passwd_hash='{$passwd_hash}', previous_email_addr = '{$prev_email}', email_addr_change_time = $mytime";
517 517
             }
518 518
             else {
519
-              $querypart = "email_addr='{$lower_email_addr}', passwd_hash='{$passwd_hash}'";
519
+                $querypart = "email_addr='{$lower_email_addr}', passwd_hash='{$passwd_hash}'";
520 520
             }
521 521
 
522 522
             // Update user account information
523 523
             $result = $boinc_user->update($querypart);
524 524
 
525 525
             if ($changing_email) {
526
-              // reload account
527
-              $account = user_load($account->uid);
528
-              _boincuser_send_emailchange($account, $lower_email_addr, $prev_email, user_access('administer users'));
526
+                // reload account
527
+                $account = user_load($account->uid);
528
+                _boincuser_send_emailchange($account, $lower_email_addr, $prev_email, user_access('administer users'));
529 529
             }
530 530
 
531 531
             // Change email to edit to lower-case version, this sets
532 532
             // email in Drupal database to the lower-case email
533 533
             // address.
534 534
             $edit['mail'] = strtolower($lower_email_addr);
535
-          }
535
+            }
536 536
 
537
-          // Change boinc username
538
-          if ($edit['boincuser_name'] and ($edit['boincuser_name'] != $boinc_user->name)) {
537
+            // Change boinc username
538
+            if ($edit['boincuser_name'] and ($edit['boincuser_name'] != $boinc_user->name)) {
539 539
             $boincuser_name = $edit['boincuser_name'];
540 540
             $result = $boinc_user->update(
541 541
                 "name='{$boincuser_name}'"
542 542
             );
543
-          }
543
+            }
544 544
 
545
-          break;
545
+            break;
546 546
         case 'user_profile':
547 547
           if ($edit['boincuser_name'] != $boinc_user->name) {
548 548
             $boincuser_name = $edit['boincuser_name'];
549 549
             $result = $boinc_user->update(
550 550
                 "name='{$boincuser_name}'"
551 551
             );
552
-          }
553
-          break;
552
+            }
553
+            break;
554 554
         default:
555 555
         }
556 556
         // We don't want to save update source or duplicate custom fields, so
557 557
         // remove them before continuing to core Drupal routines
558 558
         $edit['update_source'] = null;
559 559
         $edit['boincuser_name'] = null;
560
-      }
561
-      break;
560
+        }
561
+        break;
562 562
 
563 563
     case 'login':
564 564
       // Function is forward compatible to Drupal 7
565 565
       boincuser_user_login($edit, $account);
566
-      break;
566
+        break;
567 567
 
568 568
     case 'delete':
569 569
       // Function is forward compatible to Drupal 7
570 570
       boincuser_user_delete($account);
571
-      break;
571
+        break;
572 572
 
573 573
     default:
574 574
       
575 575
     }
576
-  }
576
+    }
577 577
 }
578 578
 
579 579
 /**
@@ -582,39 +582,39 @@  discard block
 block discarded – undo
582 582
  *(forward compatible to Drupal 7).
583 583
  */
584 584
 function boincuser_user_login(&$edit, $account) {
585
-  $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE);
586
-  $termsofuse = variable_get('boinc_weboptions_termsofuse', '');
587
-
588
-  // Use the same code as boincuser_form_alter(), for case
589
-  // 'user_profile_form', if the refering page is the user password
590
-  // reset form, then do not check for terms of use.
591
-  $reset_pass = (strpos($_SERVER['HTTP_REFERER'], "/user/reset/$account->uid") === FALSE) ? 0 : 1;
592
-  if ($reset_pass) {
585
+    $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE);
586
+    $termsofuse = variable_get('boinc_weboptions_termsofuse', '');
587
+
588
+    // Use the same code as boincuser_form_alter(), for case
589
+    // 'user_profile_form', if the refering page is the user password
590
+    // reset form, then do not check for terms of use.
591
+    $reset_pass = (strpos($_SERVER['HTTP_REFERER'], "/user/reset/$account->uid") === FALSE) ? 0 : 1;
592
+    if ($reset_pass) {
593 593
     return;
594
-  }
594
+    }
595 595
 
596
-  // Check if user has agreed to terms of use.
597
-  if ( (!empty($termsofuse)) and ($account->uid) and 
596
+    // Check if user has agreed to terms of use.
597
+    if ( (!empty($termsofuse)) and ($account->uid) and 
598 598
        (!boincuser_check_termsofuse($account)) and ($existinguser_tou) ) {
599 599
 
600 600
     // Admins are exempted.
601 601
     $administrator_role = array_search('administrator', user_roles(true));
602 602
     if (!isset($account->roles[$administrator_role])) {
603 603
 
604
-      // Find and save the current destination and use as an parameter
605
-      // to send the user back to here he/she came from.
606
-      $np = ltrim('user/termsofuse', '/');
607
-      $path_for_destination = rawurlencode($np);
604
+        // Find and save the current destination and use as an parameter
605
+        // to send the user back to here he/she came from.
606
+        $np = ltrim('user/termsofuse', '/');
607
+        $path_for_destination = rawurlencode($np);
608 608
 
609
-      $query_for_destination = '';
610
-      $prevdest = $_REQUEST['destination'];
611
-      if ($prevdest) {
609
+        $query_for_destination = '';
610
+        $prevdest = $_REQUEST['destination'];
611
+        if ($prevdest) {
612 612
         $query_for_destination = '?destination=' . $prevdest;
613
-      }
614
-      $_REQUEST['destination'] = $path_for_destination . $query_for_destination;
613
+        }
614
+        $_REQUEST['destination'] = $path_for_destination . $query_for_destination;
615 615
 
616 616
     }
617
-  }
617
+    }
618 618
 }
619 619
 
620 620
 /**
@@ -623,16 +623,16 @@  discard block
 block discarded – undo
623 623
  */
624 624
 function boincuser_user_delete($account) {
625 625
 
626
-  $boincid = $account->boincuser_id;
627
-  // bug in comment module, remove user name from comments. Find all
628
-  // comments with uid=0 and clear the field 'name'.
629
-  $qrc1 = db_query("UPDATE {comments} SET comments.name='' WHERE comments.uid=0");
626
+    $boincid = $account->boincuser_id;
627
+    // bug in comment module, remove user name from comments. Find all
628
+    // comments with uid=0 and clear the field 'name'.
629
+    $qrc1 = db_query("UPDATE {comments} SET comments.name='' WHERE comments.uid=0");
630 630
 
631
-  // Delete entry in drupal boincuser table.
632
-  $qrc2 = db_query("DELETE FROM {boincuser} WHERE uid=%d", $account->uid);
633
-  if (!$qrc2) {
631
+    // Delete entry in drupal boincuser table.
632
+    $qrc2 = db_query("DELETE FROM {boincuser} WHERE uid=%d", $account->uid);
633
+    if (!$qrc2) {
634 634
     watchdog('user', 'Error deleting user account, boincuser table UID: %uid.', array('%uid' => $account->uid), WATCHDOG_ERROR);
635
-  }
635
+    }
636 636
 }
637 637
 
638 638
 
@@ -641,13 +641,13 @@  discard block
 block discarded – undo
641 641
  * Obsolete in Drupal 7...
642 642
  */
643 643
 function boincuser_nodeapi(&$node, $op, $a3 = null, $a4 = null) {
644
-  // In Drupal 7, these operation cases will all exist as their own hooks,
645
-  // so let's approximate that here so that this function can simply be removed
646
-  // upon migration to 7
647
-  switch($op) {
648
-  case 'update':
644
+    // In Drupal 7, these operation cases will all exist as their own hooks,
645
+    // so let's approximate that here so that this function can simply be removed
646
+    // upon migration to 7
647
+    switch($op) {
648
+    case 'update':
649 649
     boincuser_node_update($node);
650
-  }
650
+    }
651 651
 }
652 652
 
653 653
 /**
@@ -655,8 +655,8 @@  discard block
 block discarded – undo
655 655
  * is updated (forward compatible to Drupal 7)
656 656
  */
657 657
 function boincuser_node_update($node) {
658
-  switch($node->type) {
659
-  case 'profile':
658
+    switch($node->type) {
659
+    case 'profile':
660 660
     // Update the BOINC database directly
661 661
     $account = user_load($node->uid);
662 662
     // Save user account data
@@ -668,11 +668,11 @@  discard block
 block discarded – undo
668 668
       UPDATE user
669 669
       SET country = '%s', postal_code = '%s', url = '%s', has_profile = 1
670 670
       WHERE id = %d",
671
-      $country, $postal_code, $url, $account->boincuser_id
671
+        $country, $postal_code, $url, $account->boincuser_id
672 672
     );
673 673
     db_set_active('default');
674 674
     if (!$account_updated) {
675
-      drupal_set_message(t('Error saving BOINC account info.'), 'error');
675
+        drupal_set_message(t('Error saving BOINC account info.'), 'error');
676 676
     }
677 677
     // Save profile data
678 678
     $response1 = $node->field_background[0]['value'];
@@ -683,16 +683,16 @@  discard block
 block discarded – undo
683 683
       SET userid = %d, response1 = '%s', response2 = '%s'
684 684
       ON DUPLICATE KEY UPDATE
685 685
         response1 = '%s', response2 = '%s'",
686
-      $account->boincuser_id, $response1, $response2,
687
-      $response1, $response2
686
+        $account->boincuser_id, $response1, $response2,
687
+        $response1, $response2
688 688
     );
689 689
     db_set_active('default');
690 690
     if (!$profile_updated) {
691
-      drupal_set_message(t('Error saving BOINC profile.'), 'error');
691
+        drupal_set_message(t('Error saving BOINC profile.'), 'error');
692 692
     }
693 693
     break;
694 694
     
695
-  default:
695
+    default:
696 696
     
697 697
   }
698 698
 }
@@ -701,21 +701,21 @@  discard block
 block discarded – undo
701 701
 * Implementation of hook_views_api()
702 702
 */
703 703
 function boincuser_views_api() {
704
-  return array(
704
+    return array(
705 705
     'api' => 2.0,
706 706
     'path' => drupal_get_path('module', 'boincuser')
707
-  );
707
+    );
708 708
 }
709 709
 
710 710
 /**
711 711
 * Implementation of hook_form_alter()
712 712
 */
713 713
 function boincuser_form_alter(&$form, $form_state, $form_id) {
714
-  require_boinc('token');
714
+    require_boinc('token');
715 715
 
716
-  global $user;
717
-  switch ($form_id) {
718
-  case 'flag_confirm':
716
+    global $user;
717
+    switch ($form_id) {
718
+    case 'flag_confirm':
719 719
     // The URL seems to be the only way to put any kind of context to this
720 720
     // request!
721 721
     $action = arg(2);
@@ -724,25 +724,25 @@  discard block
 block discarded – undo
724 724
     
725 725
     // Wrap action buttons for styling consistency
726 726
     $form['form control tabs prefix'] = array(
727
-      '#value' => '<ul class="form-control tab-list">',
728
-      '#weight' => 1001,
727
+        '#value' => '<ul class="form-control tab-list">',
728
+        '#weight' => 1001,
729 729
     );
730 730
     
731 731
     switch ($flag_type) {
732 732
     case 'friend':
733 733
       $friend_id = $form['content_id']['#value'];
734
-      $flag = flag_get_flag('friend');
735
-      $friend_status = flag_friend_determine_friend_status($flag, $friend_id, $user->uid);
734
+        $flag = flag_get_flag('friend');
735
+        $friend_status = flag_friend_determine_friend_status($flag, $friend_id, $user->uid);
736 736
       
737
-      // General friend form overrides
738
-      $form['flag_friend_submit']['#prefix'] = '<li class="first tab">';
739
-      $form['flag_friend_submit']['#value'] = bts('Send request', array(), NULL, 'boinc:friends-page');
740
-      $form['flag_friend_submit']['#type'] = 'submit';
741
-      $form['flag_friend_submit']['#suffix'] = '</li>';
742
-      $form['flag_friend_submit']['#weight'] = 1002;
737
+        // General friend form overrides
738
+        $form['flag_friend_submit']['#prefix'] = '<li class="first tab">';
739
+        $form['flag_friend_submit']['#value'] = bts('Send request', array(), NULL, 'boinc:friends-page');
740
+        $form['flag_friend_submit']['#type'] = 'submit';
741
+        $form['flag_friend_submit']['#suffix'] = '</li>';
742
+        $form['flag_friend_submit']['#weight'] = 1002;
743 743
       
744
-      switch ($friend_status) {
745
-      case FLAG_FRIEND_BOTH:
744
+        switch ($friend_status) {
745
+        case FLAG_FRIEND_BOTH:
746 746
       case FLAG_FRIEND_FLAGGED:
747 747
         unset($form['actions']);
748 748
         $form['flag_friend_submit']['#value'] = bts('Remove friend', array(), NULL, 'boinc:friends-remove');
@@ -751,53 +751,53 @@  discard block
 block discarded – undo
751 751
         $form['#submit'][] = 'boincuser_fix_unfriend_form_submit';
752 752
         $form['#submit'][] = $final_handler;
753 753
         break;
754
-      case FLAG_FRIEND_PENDING:
754
+        case FLAG_FRIEND_PENDING:
755 755
         unset($form['actions']);
756 756
         $form['flag_friend_submit']['#value'] = bts('Remove request', array(), NULL, 'boinc:friends-page');
757 757
         break;
758
-      case FLAG_FRIEND_APPROVAL:
758
+        case FLAG_FRIEND_APPROVAL:
759 759
         if ($action == 'flag') {
760
-          $form['flag_friend_submit']['#value'] = bts('Approve request', array(), NULL, 'boinc:friends-page');
760
+            $form['flag_friend_submit']['#value'] = bts('Approve request', array(), NULL, 'boinc:friends-page');
761 761
         }
762 762
         elseif ($action == 'unflag') {
763
-          unset($form['actions']);
764
-          $form['flag_friend_submit']['#value'] = bts('Deny request', array(), NULL, 'boinc:friends-page');
763
+            unset($form['actions']);
764
+            $form['flag_friend_submit']['#value'] = bts('Deny request', array(), NULL, 'boinc:friends-page');
765 765
         }
766 766
         break;
767
-      case FLAG_FRIEND_UNFLAGGED:
767
+        case FLAG_FRIEND_UNFLAGGED:
768 768
       default:
769 769
         $user_links[] = array(
770
-          'title' => bts('Add as friend', array(), NULL, 'boinc:friends-add'),
771
-          'href' => "flag/confirm/flag/friend/{$account->uid}"
770
+            'title' => bts('Add as friend', array(), NULL, 'boinc:friends-add'),
771
+            'href' => "flag/confirm/flag/friend/{$account->uid}"
772 772
         );
773
-      }
774
-      break;
773
+        }
774
+        break;
775 775
       
776 776
     default:
777 777
     }
778 778
     
779 779
     $form['cancel'] = array(
780
-      '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $cancel_dest) . '</li>',
781
-      '#weight' => 1004,
780
+        '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $cancel_dest) . '</li>',
781
+        '#weight' => 1004,
782 782
     );
783 783
     $form['form control tabs suffix'] = array(
784
-      '#value' => '</ul>',
785
-      '#weight' => 1010,
784
+        '#value' => '</ul>',
785
+        '#weight' => 1010,
786 786
     );
787 787
     
788 788
     break;
789 789
     
790
-  // General node edit form
791
-  case 'news_node_form':
790
+    // General node edit form
791
+    case 'news_node_form':
792 792
     $form['separator_bottom'] = array(
793
-      '#value' => '<div class="separator buttons"></div>',
794
-      '#weight' => 999,
793
+        '#value' => '<div class="separator buttons"></div>',
794
+        '#weight' => 999,
795 795
     );
796 796
     
797 797
     // Wrap action buttons for styling consistency
798 798
     $form['buttons']['form control tabs prefix'] = array(
799
-      '#value' => '<ul class="form-control tab-list">',
800
-      '#weight' => 1001,
799
+        '#value' => '<ul class="form-control tab-list">',
800
+        '#weight' => 1001,
801 801
     );
802 802
     $form['buttons']['submit']['#prefix'] = '<li class="first tab">';
803 803
     $form['buttons']['submit']['#value'] = bts('Save changes', array(), NULL, 'boinc:form-save');
@@ -810,15 +810,15 @@  discard block
 block discarded – undo
810 810
     $form['buttons']['preview_changes']['#suffix'] = '</li>';
811 811
     $form['buttons']['preview_changes']['#weight'] = 1004;
812 812
     $form['buttons']['cancel'] = array(
813
-      '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "node/{$form['nid']['#value']}") . '</li>',
814
-      '#weight' => 1005,
813
+        '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "node/{$form['nid']['#value']}") . '</li>',
814
+        '#weight' => 1005,
815 815
     );
816 816
     $form['buttons']['delete']['#prefix'] = '<li class="tab">';
817 817
     $form['buttons']['delete']['#suffix'] = '</li>';
818 818
     $form['buttons']['delete']['#weight'] = 1006;
819 819
     $form['buttons']['form control tabs suffix'] = array(
820
-      '#value' => '</ul>',
821
-      '#weight' => 1010,
820
+        '#value' => '</ul>',
821
+        '#weight' => 1010,
822 822
     );
823 823
     
824 824
     // Preview is ugly, unset until it works
@@ -826,16 +826,16 @@  discard block
 block discarded – undo
826 826
 
827 827
     break;
828 828
   
829
-  case 'node_delete_confirm':
829
+    case 'node_delete_confirm':
830 830
     $form['separator_bottom'] = array(
831
-      '#value' => '<div class="separator buttons"></div>',
832
-      '#weight' => 999,
831
+        '#value' => '<div class="separator buttons"></div>',
832
+        '#weight' => 999,
833 833
     );
834 834
     
835 835
     // Wrap action buttons for styling consistency
836 836
     $form['actions']['form control tabs prefix'] = array(
837
-      '#value' => '<ul class="form-control tab-list">',
838
-      '#weight' => 1001,
837
+        '#value' => '<ul class="form-control tab-list">',
838
+        '#weight' => 1001,
839 839
     );
840 840
     $form['actions']['submit']['#prefix'] = '<li class="first tab">';
841 841
     $form['actions']['submit']['#value'] = bts('Delete', array(), NULL, 'boinc:form-delete');
@@ -843,23 +843,23 @@  discard block
 block discarded – undo
843 843
     $form['actions']['submit']['#weight'] = 1002;
844 844
     $form['actions']['cancel'] = array(
845 845
         '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "node/{$form['nid']['#value']}") . '</li>',
846
-      '#weight' => 1005,
846
+        '#weight' => 1005,
847 847
     );
848 848
     $form['actions']['form control tabs suffix'] = array(
849
-      '#value' => '</ul>',
850
-      '#weight' => 1010,
849
+        '#value' => '</ul>',
850
+        '#weight' => 1010,
851 851
     );
852 852
     $form['#redirect'] = 'account/profile';
853 853
     break;
854 854
     
855
-  case 'privatemsg_new':
855
+    case 'privatemsg_new':
856 856
     
857 857
     $form['privatemsg']['body']['#title'] = '';
858 858
     
859 859
     // Wrap action buttons for styling consistency
860 860
     $form['privatemsg']['form control tabs prefix'] = array(
861
-      '#value' => '<ul class="form-control tab-list">',
862
-      '#weight' => 1001,
861
+        '#value' => '<ul class="form-control tab-list">',
862
+        '#weight' => 1001,
863 863
     );
864 864
     $form['privatemsg']['submit']['#prefix'] = '<li class="first tab">';
865 865
     $form['privatemsg']['submit']['#value'] = bts('Send message', array(), NULL, 'boinc:private-message');
@@ -869,26 +869,26 @@  discard block
 block discarded – undo
869 869
     $form['privatemsg']['preview']['#suffix'] = '</li>';
870 870
     $form['privatemsg']['preview']['#weight'] = 1003;
871 871
     $form['privatemsg']['cancel'] = array(
872
-      '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>',
873
-      '#weight' => 1004,
872
+        '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>',
873
+        '#weight' => 1004,
874 874
     );
875 875
     $form['privatemsg']['form control tabs suffix'] = array(
876
-      '#value' => '</ul>',
877
-      '#weight' => 1010,
876
+        '#value' => '</ul>',
877
+        '#weight' => 1010,
878 878
     );
879 879
     
880 880
     unset($form['privatemsg']['recipient_display']);
881 881
     
882 882
     break;
883 883
     
884
-  // Login form
885
-  case 'user_login':
884
+    // Login form
885
+    case 'user_login':
886 886
   case 'user_login_block':
887 887
       drupal_set_title(bts('Login', array(), NULL, 'boinc:menu-link'));
888 888
     // Replace name with email in login form
889 889
     unset($form['name']);
890 890
     array_unshift($form, array(
891
-      'email' => array(
891
+        'email' => array(
892 892
         '#type' => 'textfield',
893 893
         '#title' => bts('Email address', array(), NULL, 'boinc:email-address-to-login'),
894 894
         '#size' => ($form_id == 'user_login_block') ? 15 : 60,
@@ -896,18 +896,18 @@  discard block
 block discarded – undo
896 896
         '#required' => TRUE,
897 897
         '#attributes' => array('tabindex' => '1'),
898 898
         '#description' => bts('Enter your @s email address.', array('@s' => variable_get('site_name', 'Drupal-BOINC')), NULL, 'boinc:standard-login-page')
899
-      ),
900
-      'validation_source' => array(
899
+        ),
900
+        'validation_source' => array(
901 901
         '#type' => 'hidden',
902 902
         '#value' => 'user_login'
903
-      )
903
+        )
904 904
     ));
905 905
     $form['#redirect'] = 'home';
906 906
     
907 907
     // Wrap action buttons for styling consistency
908 908
     $form['buttons']['form control tabs prefix'] = array(
909
-      '#value' => '<ul class="form-control tab-list">',
910
-      '#weight' => 1001,
909
+        '#value' => '<ul class="form-control tab-list">',
910
+        '#weight' => 1001,
911 911
     );
912 912
     $form['buttons']['submit'] = $form['submit'];
913 913
     $form['buttons']['submit']['#prefix'] = '<li class="first tab">';
@@ -915,8 +915,8 @@  discard block
 block discarded – undo
915 915
     $form['buttons']['submit']['#suffix'] = '</li>';
916 916
     $form['buttons']['submit']['#weight'] = 1002;
917 917
     $form['buttons']['form control tabs suffix'] = array(
918
-      '#value' => '</ul>',
919
-      '#weight' => 1010,
918
+        '#value' => '</ul>',
919
+        '#weight' => 1010,
920 920
     );
921 921
     unset($form['submit']);
922 922
     
@@ -925,23 +925,23 @@  discard block
 block discarded – undo
925 925
     isset($form['buttons']['submit']['#attributes']) ? array_push($form['buttons']['submit']['#attributes'], array('tabindex' => '3')) : $form['buttons']['submit']['#attributes'] = array('tabindex' => '3');
926 926
     // If the user login form is being submitted, use BOINC validation handler.
927 927
     if (isset($form_state['post']['email']) and isset($form_state['post']['pass'])) {
928
-      // Find the local validation function's entry so we can replace it.
929
-      $array_key = array_search('user_login_authenticate_validate', $form['#validate']);
930
-      if ($array_key === FALSE) {
928
+        // Find the local validation function's entry so we can replace it.
929
+        $array_key = array_search('user_login_authenticate_validate', $form['#validate']);
930
+        if ($array_key === FALSE) {
931 931
         // Could not find it. Some other module must have run form_alter().
932 932
         // We will simply add our validation just before the final validator.
933 933
         $final_validator = array_pop($form['#validate']);
934 934
         $form['#validate'][] = 'boincuser_login_validate';
935 935
         $form['#validate'][] = $final_validator;
936
-      } else {
936
+        } else {
937 937
         // Replace the local validation function with BOINC validation
938 938
         $form['#validate'][$array_key] = 'boincuser_login_validate';
939
-      }
939
+        }
940 940
     }
941 941
     break;
942 942
     
943
-  // User credentials form
944
-  case 'user_profile_form':
943
+    // User credentials form
944
+    case 'user_profile_form':
945 945
 
946 946
     // Use the displaly name as the title, not the username
947 947
     $account = user_load($form['#uid']);
@@ -949,28 +949,28 @@  discard block
 block discarded – undo
949 949
     
950 950
     // Message for admins
951 951
     if (user_access('administer users')) {
952
-      drupal_set_message(
952
+        drupal_set_message(
953 953
         bts('WARNING: You are editing the information for user. Please note: you may change a user\'s password by itself. But to change the user\'s email address you must change both the email address and the password simultaneously.')
954
-      , 'warning');
954
+        , 'warning');
955 955
     }
956 956
 
957 957
     // Set special message if user has not agreed to TOU
958 958
     $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE);
959 959
     $termsofuse = variable_get('boinc_weboptions_termsofuse', '');
960 960
     if ( (!boincuser_check_termsofuse($account)) and ($existinguser_tou) and (!empty($termsofuse)) and (!user_access('administer users')) ) {
961
-      drupal_set_message(
961
+        drupal_set_message(
962 962
         bts('INFO: You have not agreed to the terms of use for @project. You may use this form to change your email address and/or password. Please note: you may not delete your account within seven (7) days of changing your email address.',
963 963
         array(
964
-          '@project' => variable_get('site_name','Drupal-BOINC'),
964
+            '@project' => variable_get('site_name','Drupal-BOINC'),
965 965
         ), NULL, 'boinc:account-credentials-change')
966
-      , 'info');
966
+        , 'info');
967 967
     }
968 968
 
969 969
     // A bit hackish... but don't require the user to enter his password if
970 970
     // coming from the password reset function
971 971
     $reset_pass = (strpos($_SERVER['HTTP_REFERER'], "/user/reset/{$form['#uid']}") === FALSE) ? 0 : 1;
972 972
     if ($reset_pass) {
973
-      $_SESSION['reset_pass'] = 1;
973
+        $_SESSION['reset_pass'] = 1;
974 974
     }
975 975
 
976 976
     // Adjust form elements already present
@@ -982,8 +982,8 @@  discard block
 block discarded – undo
982 982
     $form['account']['pass']['#size'] = 17;
983 983
 
984 984
     if (user_access('administer users')) {
985
-      // Add BOINC username (aka displayname)
986
-      $form['account']['boincuser_name'] = array(
985
+        // Add BOINC username (aka displayname)
986
+        $form['account']['boincuser_name'] = array(
987 987
         '#type' => 'textfield',
988 988
         '#title' => bts('BOINC Username', array(), NULL, 'boinc:user-or-team-name'),
989 989
         '#default_value' => $account->boincuser_name,
@@ -991,68 +991,68 @@  discard block
 block discarded – undo
991 991
         '#required' => TRUE,
992 992
         '#description' => bts('This is the BOINC (external) username. This is the same setting as found in Account -> Preferences -> Community.', array(), NULL, 'boinc:username-change'),
993 993
         '#size' => 40,
994
-      );
994
+        );
995 995
     }
996 996
 
997 997
     // If email address was changed less than 7 days (7 * 86400 s)
998 998
     // ago, it cannot be changed again.
999 999
     $duration = TOKEN_DURATION_ONE_WEEK;
1000 1000
     if (($account->boincuser_email_addr_change_time + $duration) > time() and (!user_access('administer users'))) {
1001
-      $form['account']['mail']['#required'] = FALSE;
1002
-      $form['account']['mailhelp'] = array(
1001
+        $form['account']['mail']['#required'] = FALSE;
1002
+        $form['account']['mailhelp'] = array(
1003 1003
         '#value' => bts("You email address was changed within the past seven (7) days. Please look for an email to !prev_email if you need to revert this change. You may change your email address on !time.",
1004
-          array(
1004
+            array(
1005 1005
             '!prev_email' => $account->boincuser_previous_email_addr,
1006 1006
             '!time' => date('F j, Y \a\t G:i T', $account->boincuser_email_addr_change_time + $duration),
1007
-          ), NULL, 'boinc:account-credentials-change'),
1008
-      );
1007
+            ), NULL, 'boinc:account-credentials-change'),
1008
+        );
1009 1009
     }
1010 1010
 
1011 1011
     if (!$reset_pass AND ($user->uid == $account->uid OR !user_access('administer users'))) {
1012
-      // Add a password authenticator, required to change email or pw
1013
-      $form['account']['current_pass'] = array(
1012
+        // Add a password authenticator, required to change email or pw
1013
+        $form['account']['current_pass'] = array(
1014 1014
         '#type' => 'password',
1015 1015
         '#title' => bts('Enter your password to save changes', array(), NULL, 'boinc:account-credentials-change'),
1016 1016
         '#description' => bts('Enter your current password if changing your email
1017 1017
           address or password.', array(), NULL, 'boinc:account-credentials-change'),
1018 1018
         '#size' => 17,
1019 1019
         '#attributes' => array(
1020
-          'autocomplete' => 'off',
1020
+            'autocomplete' => 'off',
1021 1021
         ),
1022
-      );
1022
+        );
1023 1023
     }
1024 1024
     
1025 1025
     // Add account keys, CPID, etc
1026 1026
     $form['account']['boincuser_id'] = array(
1027
-      '#value' => '
1027
+        '#value' => '
1028 1028
         <div class="form-item">
1029 1029
           <label>' . bts('BOINC user ID', array(), NULL, 'boinc:account-credentials-change') . '</label>
1030 1030
           <span>' . $account->boincuser_id . '</span>
1031 1031
         </div>',
1032 1032
     );
1033 1033
     $form['account']['user_id'] = array(
1034
-      '#value' => '
1034
+        '#value' => '
1035 1035
         <div class="form-item">
1036 1036
           <label>' . bts('Drupal user ID', array(), NULL, 'boinc:account-credentials-change') . '</label>
1037 1037
           <span>' . $account->uid . '</span>
1038 1038
         </div>',
1039 1039
     );
1040 1040
     $form['account']['account_key'] = array(
1041
-      '#value' => '
1041
+        '#value' => '
1042 1042
         <div class="form-item">
1043 1043
           <label>' . bts('Account key', array(), NULL, 'boinc:account-credentials-change') . '</label>
1044 1044
           <span>' . $account->boincuser_account_key . '</span>
1045 1045
         </div>',
1046 1046
     );
1047 1047
     $form['account']['weak_account_key'] = array(
1048
-      '#value' => '
1048
+        '#value' => '
1049 1049
         <div class="form-item">
1050 1050
           <label>' . bts('Weak account key', array(), NULL, 'boinc:account-credentials-change') . '</label>
1051 1051
           <span>' . "{$account->boincuser_id}_{$account->boincuser_weak_auth}" . '</span>
1052 1052
         </div>',
1053 1053
     );
1054 1054
     $form['account']['cpid'] = array(
1055
-      '#value' => '
1055
+        '#value' => '
1056 1056
         <div class="form-item">
1057 1057
           <label>' . bts('Cross-project ID', array(), NULL, 'boinc:account-credentials-change') . '</label>
1058 1058
           <span>' . $account->boincuser_cpid . '</span>
@@ -1060,30 +1060,30 @@  discard block
 block discarded – undo
1060 1060
     );
1061 1061
     
1062 1062
     $form['account']['separator_bottom'] = array(
1063
-      '#value' => '<div class="separator buttons"></div>'
1063
+        '#value' => '<div class="separator buttons"></div>'
1064 1064
     );
1065 1065
     
1066 1066
     // Wrap action buttons for styling consistency
1067 1067
     $form['form control tabs prefix'] = array(
1068
-      '#value' => '<ul class="form-control tab-list">',
1069
-      '#weight' => 1001,
1068
+        '#value' => '<ul class="form-control tab-list">',
1069
+        '#weight' => 1001,
1070 1070
     );
1071 1071
     $form['submit']['#prefix'] = '<li class="first tab">';
1072 1072
     $form['submit']['#value'] = bts('Save changes', array(), NULL, 'boinc:form-save');
1073 1073
     $form['submit']['#suffix'] = '</li>';
1074 1074
     $form['submit']['#weight'] = 1002;
1075 1075
     $form['cancel'] = array(
1076
-      '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>',
1077
-      '#weight' => 1003,
1076
+        '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>',
1077
+        '#weight' => 1003,
1078 1078
     );
1079 1079
     if (isset($form['delete']) AND is_array($form['delete'])) {
1080
-      $form['delete']['#prefix'] = '<li class="first alt tab">';
1081
-      $form['delete']['#suffix'] = '</li>';
1082
-      $form['delete']['#weight'] = 1004;
1080
+        $form['delete']['#prefix'] = '<li class="first alt tab">';
1081
+        $form['delete']['#suffix'] = '</li>';
1082
+        $form['delete']['#weight'] = 1004;
1083 1083
     }
1084 1084
     $form['form control tabs suffix'] = array(
1085
-      '#value' => '</ul>',
1086
-      '#weight' => 1010,
1085
+        '#value' => '</ul>',
1086
+        '#weight' => 1010,
1087 1087
     );
1088 1088
     
1089 1089
     // Rearrange form elements
@@ -1103,7 +1103,7 @@  discard block
 block discarded – undo
1103 1103
     // Remove redundant / unnecessary form elements
1104 1104
     unset($form['theme_select']);
1105 1105
     if (!module_exists('boincuser_delete')) {
1106
-      unset($form['delete']);
1106
+        unset($form['delete']);
1107 1107
     }
1108 1108
     
1109 1109
     // These are on the Community preferences form (boincwork module)
@@ -1119,18 +1119,18 @@  discard block
 block discarded – undo
1119 1119
     
1120 1120
     // Internal fields to indicate where these user changes are taking place
1121 1121
     array_unshift($form, array(
1122
-      'validation_source' => array(
1122
+        'validation_source' => array(
1123 1123
         '#type' => 'hidden',
1124 1124
         '#value' => 'user_account'
1125
-      ),
1126
-      'update_source' => array(
1125
+        ),
1126
+        'update_source' => array(
1127 1127
         '#type' => 'hidden',
1128 1128
         '#value' => 'user_account'
1129
-      )
1129
+        )
1130 1130
     ));
1131 1131
     break;
1132 1132
     
1133
-  case 'profile_node_form':
1133
+    case 'profile_node_form':
1134 1134
     
1135 1135
     // Use the display name as the title, not the username
1136 1136
     $account = user_load($form['uid']['#value']);
@@ -1141,22 +1141,22 @@  discard block
 block discarded – undo
1141 1141
     $form['title']['#access'] = FALSE;
1142 1142
 
1143 1143
     $form['separator_bottom'] = array(
1144
-      '#value' => '<div class="separator buttons"></div>',
1145
-      '#weight' => 999,
1144
+        '#value' => '<div class="separator buttons"></div>',
1145
+        '#weight' => 999,
1146 1146
     );
1147 1147
     
1148 1148
     if (module_exists('captcha')) {
1149
-      // Add an optional captcha
1150
-      $form['profile_captcha'] = array(
1149
+        // Add an optional captcha
1150
+        $form['profile_captcha'] = array(
1151 1151
         '#type' => 'captcha',
1152 1152
         '#weight' => 1000,
1153
-      );
1153
+        );
1154 1154
     }
1155 1155
     
1156 1156
     // Wrap action buttons for styling consistency
1157 1157
     $form['buttons']['form control tabs prefix'] = array(
1158
-      '#value' => '<ul class="form-control tab-list">',
1159
-      '#weight' => 1001,
1158
+        '#value' => '<ul class="form-control tab-list">',
1159
+        '#weight' => 1001,
1160 1160
     );
1161 1161
     $form['buttons']['submit']['#prefix'] = '<li class="first tab">';
1162 1162
     $form['buttons']['submit']['#value'] = bts('Save changes', array(), NULL, 'boinc:form-save');
@@ -1169,8 +1169,8 @@  discard block
 block discarded – undo
1169 1169
     $form['buttons']['preview_changes']['#suffix'] = '</li>';
1170 1170
     $form['buttons']['preview_changes']['#weight'] = 1004;
1171 1171
     $form['buttons']['cancel'] = array(
1172
-      '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>',
1173
-      '#weight' => 1005,
1172
+        '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>',
1173
+        '#weight' => 1005,
1174 1174
     );
1175 1175
     $form['buttons']['delete']['#prefix'] = '<li class="tab">';
1176 1176
     $form['buttons']['delete']['#suffix'] = '</li>';
@@ -1178,8 +1178,8 @@  discard block
 block discarded – undo
1178 1178
     $form['buttons']['delete']['#weight'] = 1006;
1179 1179
     $form['buttons']['delete']['#submit'] = array('_boincuser_node_profile_delete_submit');
1180 1180
     $form['buttons']['form control tabs suffix'] = array(
1181
-      '#value' => '</ul>',
1182
-      '#weight' => 1010,
1181
+        '#value' => '</ul>',
1182
+        '#weight' => 1010,
1183 1183
     );
1184 1184
     
1185 1185
     $form['#after_build'][] = 'boincuser_profile_node_form_after_build';
@@ -1192,74 +1192,74 @@  discard block
 block discarded – undo
1192 1192
     
1193 1193
     // Internal fields to indicate where these user changes are taking place
1194 1194
     array_unshift($form, array(
1195
-      'validation_source' => array(
1195
+        'validation_source' => array(
1196 1196
         '#type' => 'hidden',
1197 1197
         '#value' => 'user_profile'
1198
-      ),
1199
-      'update_source' => array(
1198
+        ),
1199
+        'update_source' => array(
1200 1200
         '#type' => 'hidden',
1201 1201
         '#value' => 'user_profile'
1202
-      )
1202
+        )
1203 1203
     ));
1204 1204
     break;
1205 1205
   
1206
-  // Registration form
1207
-  case 'user_register':
1206
+    // Registration form
1207
+    case 'user_register':
1208 1208
     array_unshift($form, array(
1209
-      'boincuser_name' => array(
1209
+        'boincuser_name' => array(
1210 1210
         '#type' => 'textfield', 
1211 1211
         '#title' => bts('Name', array(), NULL, 'boinc:user-or-team-name'), 
1212 1212
         '#default_value' => $edit['boincuser_name'], 
1213 1213
         '#maxlength' => USERNAME_MAX_LENGTH, 
1214 1214
         '#description' => bts('Spaces are allowed; punctuation is not allowed except for periods, hyphens, and underscores.', array(), NULL, 'boinc:user-register'), 
1215 1215
         '#required' => TRUE
1216
-      ),
1216
+        ),
1217 1217
     ));
1218 1218
     // Set name temporarily to dummy value to beat validation
1219 1219
     $form['name'] = array(
1220
-      '#type' => 'hidden',
1221
-      '#value' => rand() . '.' . time()
1220
+        '#type' => 'hidden',
1221
+        '#value' => rand() . '.' . time()
1222 1222
     );
1223 1223
     
1224 1224
     // Terms of use section
1225 1225
     $termsofuse = variable_get('boinc_weboptions_termsofuse', '');
1226 1226
     if (!empty($termsofuse)) {
1227
-      $form['title1'] = array(
1227
+        $form['title1'] = array(
1228 1228
         '#weight' => -12,
1229 1229
         '#value' => '<h2>' . bts(variable_get('boinc_weboptions_registrationtitle', 'Please read and acknowledge our terms of use'), array(), NULL, 'project:user-register' ) . '</h2>',
1230 1230
         '#prefix' => '<div id="register-title1">',
1231 1231
         '#suffix' => '</div>',
1232
-      );
1232
+        );
1233 1233
 
1234
-      $form['termsofuse'] = array(
1234
+        $form['termsofuse'] = array(
1235 1235
         '#weight' => -10,
1236 1236
         '#value' => bts($termsofuse, array(), NULL, 'project:user-register'),
1237 1237
         '#prefix' => '<div id="register-termsofuse">',
1238 1238
         '#suffix' => '</div>',
1239
-      );
1239
+        );
1240 1240
 
1241
-      $form['agreeTOU'] = array(
1241
+        $form['agreeTOU'] = array(
1242 1242
         '#type' => 'checkbox',
1243 1243
         '#title' => bts(variable_get('boinc_weboptions_agreequestion', 'Do you agree with the above terms of use?'), array(), NULL, 'project:user-register'),
1244 1244
         '#weight' => -8,
1245 1245
         '#prefix' => '<div id="register-checkbox">',
1246 1246
         '#suffix' => '</div>',
1247
-      );
1247
+        );
1248 1248
     }
1249 1249
 
1250 1250
     $form['title2'] = array(
1251
-      '#weight' => -6,
1252
-      '#value' => '<h2>' . bts(variable_get('boinc_weboptions_registrationtitle2', 'Fill in your name, email, and choose a secure passphrase.'), array(), NULL, 'project:user-register') . '</h2>',
1253
-      '#prefix' => '<div id="register-title2">',
1254
-      '#suffix' => '</div>',
1251
+        '#weight' => -6,
1252
+        '#value' => '<h2>' . bts(variable_get('boinc_weboptions_registrationtitle2', 'Fill in your name, email, and choose a secure passphrase.'), array(), NULL, 'project:user-register') . '</h2>',
1253
+        '#prefix' => '<div id="register-title2">',
1254
+        '#suffix' => '</div>',
1255 1255
     );
1256 1256
 
1257 1257
     if (module_exists('captcha')) {
1258
-      // Add an optional captcha
1259
-      $form['register_captcha'] = array(
1258
+        // Add an optional captcha
1259
+        $form['register_captcha'] = array(
1260 1260
         '#type' => 'captcha',
1261 1261
         '#weight' => 1000,
1262
-      );
1262
+        );
1263 1263
     }
1264 1264
     
1265 1265
     $form['#validate'][] = 'boincuser_register_validate';
@@ -1267,35 +1267,35 @@  discard block
 block discarded – undo
1267 1267
     $form['submit']['#weight'] = 1001;
1268 1268
     break;
1269 1269
     
1270
-  // Request new password form
1271
-  case 'user_pass':
1270
+    // Request new password form
1271
+    case 'user_pass':
1272 1272
     drupal_set_title(bts('Forgot password', array(), NULL, 'boinc:forgot-password'));
1273 1273
     // Replace name/email text box with email only; retain "name" label
1274 1274
     // for compatibility with standard Drupal submit function
1275 1275
     unset($form['name']);
1276 1276
     array_unshift($form, array(
1277
-      'name' => array(
1277
+        'name' => array(
1278 1278
         '#type' => 'textfield',
1279 1279
         '#title' => bts('Email address', array(), NULL, 'boinc:email-address-to-login'),
1280 1280
         '#size' => 60,
1281 1281
         '#maxlength' => EMAIL_MAX_LENGTH,
1282 1282
         '#required' => TRUE,
1283 1283
         '#description' => bts(
1284
-          'Enter your email address to receive instructions for resetting your password (or use the !authenticator_login).',
1285
-          array(
1284
+            'Enter your email address to receive instructions for resetting your password (or use the !authenticator_login).',
1285
+            array(
1286 1286
             '!authenticator_login' => l(
1287
-              bts('authenticator-based login', array(), NULL, 'boinc:forgot-password'),
1288
-              'user/login/auth'
1287
+                bts('authenticator-based login', array(), NULL, 'boinc:forgot-password'),
1288
+                'user/login/auth'
1289
+            )
1289 1290
             )
1290
-          )
1291 1291
         , NULL, 'boinc:forgot-password'),
1292
-      ),
1292
+        ),
1293 1293
     ));
1294 1294
     
1295 1295
     // Wrap action buttons for styling consistency
1296 1296
     $form['buttons']['form control tabs prefix'] = array(
1297
-      '#value' => '<ul class="form-control tab-list">',
1298
-      '#weight' => 1001,
1297
+        '#value' => '<ul class="form-control tab-list">',
1298
+        '#weight' => 1001,
1299 1299
     );
1300 1300
     $form['buttons']['submit'] = $form['submit'];
1301 1301
     $form['buttons']['submit']['#prefix'] = '<li class="first tab">';
@@ -1303,26 +1303,26 @@  discard block
 block discarded – undo
1303 1303
     $form['buttons']['submit']['#suffix'] = '</li>';
1304 1304
     $form['buttons']['submit']['#weight'] = 1002;
1305 1305
     $form['buttons']['cancel'] = array(
1306
-      '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'user/login') . '</li>',
1307
-      '#weight' => 1005,
1306
+        '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'user/login') . '</li>',
1307
+        '#weight' => 1005,
1308 1308
     );
1309 1309
     $form['buttons']['form control tabs suffix'] = array(
1310
-      '#value' => '</ul>',
1311
-      '#weight' => 1010,
1310
+        '#value' => '</ul>',
1311
+        '#weight' => 1010,
1312 1312
     );
1313 1313
     unset($form['submit']);
1314 1314
     
1315 1315
     // If the form is being submitted, use BOINC validation handler.
1316 1316
     if (isset($form_state['post']['name'])) {
1317
-      // Prepend the BOINC validation function to local validation
1318
-      array_unshift($form['#validate'], 'boincuser_request_pass_validate');
1317
+        // Prepend the BOINC validation function to local validation
1318
+        array_unshift($form['#validate'], 'boincuser_request_pass_validate');
1319 1319
     }
1320 1320
     break;
1321 1321
     
1322
-  case 'views_exposed_form':
1322
+    case 'views_exposed_form':
1323 1323
       $form['submit']['#value'] = bts('Search', array(), NULL, 'boinc:search-user');
1324 1324
     break;
1325
-  }
1325
+    }
1326 1326
 }
1327 1327
 
1328 1328
 /**
@@ -1330,10 +1330,10 @@  discard block
 block discarded – undo
1330 1330
  * built; this is called from boincuser_form_alter()
1331 1331
  */
1332 1332
 function boincuser_profile_node_form_after_build($form, &$form_state) {
1333
-  // Move to community prefs form
1334
-  $form_state['storage']['avatar'] = $form['field_image'];
1335
-  unset($form['field_image']);
1336
-  return $form;
1333
+    // Move to community prefs form
1334
+    $form_state['storage']['avatar'] = $form['field_image'];
1335
+    unset($form['field_image']);
1336
+    return $form;
1337 1337
 }
1338 1338
 
1339 1339
 /**
@@ -1341,8 +1341,8 @@  discard block
 block discarded – undo
1341 1341
  * @see http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hook_elements/6
1342 1342
  */
1343 1343
 function boincuser_elements() {
1344
-  $type['password_confirm']['#process'][] = 'boincuser_process_password_confirm';
1345
-  return $type;
1344
+    $type['password_confirm']['#process'][] = 'boincuser_process_password_confirm';
1345
+    return $type;
1346 1346
 }
1347 1347
 
1348 1348
 /**
@@ -1350,11 +1350,11 @@  discard block
 block discarded – undo
1350 1350
  * profile form
1351 1351
  */
1352 1352
 function boincuser_process_password_confirm($element) {
1353
-  // Check if parent element is "account".
1354
-  if ($element['#array_parents'][0] == 'account') {
1353
+    // Check if parent element is "account".
1354
+    if ($element['#array_parents'][0] == 'account') {
1355 1355
     $element['pass1']['#title'] = bts('Change password', array(), NULL, 'boinc:forgot-password');
1356
-  }
1357
-  return $element;
1356
+    }
1357
+    return $element;
1358 1358
 }
1359 1359
 
1360 1360
 /**
@@ -1362,40 +1362,40 @@  discard block
 block discarded – undo
1362 1362
  * Register theme functions for use in this module.
1363 1363
  */
1364 1364
 function boincuser_theme($existing, $type, $theme, $path) {
1365
-  return array(
1365
+    return array(
1366 1366
     'boincuser_user_pass' => array(
1367
-      'arguments' => array()
1367
+        'arguments' => array()
1368 1368
     )
1369
-  );
1369
+    );
1370 1370
 }
1371 1371
 
1372 1372
 /**
1373 1373
  * Implementation of hook_token_values
1374 1374
  */
1375 1375
 function boincuser_token_values($type, $object = NULL, $options = array()) {
1376
-  if ($type == 'user') {
1376
+    if ($type == 'user') {
1377 1377
     $account = user_load($object->uid);
1378 1378
     $tokens['display-name'] = $account->boincuser_name;
1379 1379
     return $tokens;
1380
-  }
1380
+    }
1381 1381
 }
1382 1382
 
1383 1383
 /**
1384 1384
  * Implementation of hook_token_list
1385 1385
  */
1386 1386
 function boincuser_token_list($type = 'all') {
1387
-  if ($type == 'user' || $type == 'all') {
1387
+    if ($type == 'user' || $type == 'all') {
1388 1388
     $tokens['user']['display-name']      = t("The user's name that should be displayed");
1389 1389
     return $tokens;
1390
-  }
1390
+    }
1391 1391
 }
1392 1392
 
1393 1393
 /**
1394 1394
  * Implementation of hook_views_pre_execute()
1395 1395
  */
1396 1396
 function boincuser_views_pre_execute(&$view) {
1397
-  $account_id = $view->args[0];
1398
-  if ($view->name=="user_activity") {
1397
+    $account_id = $view->args[0];
1398
+    if ($view->name=="user_activity") {
1399 1399
     // Run the following custom query for the user_activity view
1400 1400
     $view->build_info['query']= "
1401 1401
       SELECT node_revisions.vid AS vid,
@@ -1427,25 +1427,25 @@  discard block
 block discarded – undo
1427 1427
     
1428 1428
     // count_query determines the pager.  Do this so the right item count is returned.
1429 1429
     $view->build_info['count_query'] = $view->build_info['query'];
1430
-  }
1430
+    }
1431 1431
 }
1432 1432
 
1433 1433
 /**
1434 1434
  * Implementation of hook_cron()
1435 1435
  */
1436 1436
 function boincuser_cron() {
1437
-  // Delete expired users in the BOINC database, user_delete table.
1438
-  require_boinc('boinc_db');
1439
-  $num_deleted = BoincUserDeleted::delete_expired();
1440
-  if ($num_deleted>0) {
1437
+    // Delete expired users in the BOINC database, user_delete table.
1438
+    require_boinc('boinc_db');
1439
+    $num_deleted = BoincUserDeleted::delete_expired();
1440
+    if ($num_deleted>0) {
1441 1441
     watchdog('boincuser', "Deleted ${num_deleted} users from user_deleted table", WATCHDOG_NOTICE);
1442
-  }
1442
+    }
1443 1443
 
1444
-  // Delete expired tokens from token table
1445
-  $tokens_deleted = BoincToken::delete_expired();
1446
-  if ($tokens_deleted>0) {
1444
+    // Delete expired tokens from token table
1445
+    $tokens_deleted = BoincToken::delete_expired();
1446
+    if ($tokens_deleted>0) {
1447 1447
     watchdog('boincuser', "Deleted ${tokens_deleted} tokens from token table", WATCHDOG_NOTICE);
1448
-  }
1448
+    }
1449 1449
 }
1450 1450
 
1451 1451
 /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
@@ -1456,17 +1456,17 @@  discard block
 block discarded – undo
1456 1456
  * Page callback shortcut to recent posts for the logged in user
1457 1457
  */
1458 1458
 function boincuser_goto_recent_posts() {
1459
-  global $user;
1460
-  drupal_goto("account/{$user->uid}/posts");
1459
+    global $user;
1460
+    drupal_goto("account/{$user->uid}/posts");
1461 1461
 }
1462 1462
 
1463 1463
 /**
1464 1464
  * Page callback shortcut to the team of the logged in user
1465 1465
  */
1466 1466
 function boincuser_goto_team() {
1467
-  global $user;
1468
-  $account = user_load($user->uid);
1469
-  drupal_goto("community/teams/{$account->team}");
1467
+    global $user;
1468
+    $account = user_load($user->uid);
1469
+    drupal_goto("community/teams/{$account->team}");
1470 1470
 }
1471 1471
 
1472 1472
 /**
@@ -1475,93 +1475,93 @@  discard block
 block discarded – undo
1475 1475
  * user profile pages, so use a wrapper for display
1476 1476
  */
1477 1477
 function boincuser_view_profile($account = null) {
1478
-  // Create the user profile page
1479
-  if (!$account) {
1478
+    // Create the user profile page
1479
+    if (!$account) {
1480 1480
     global $user;
1481 1481
     $account = $user;
1482
-  }
1482
+    }
1483 1483
 
1484
-  $min_credit_to_post = variable_get('boinc_comment_min_credit', 0);
1485
-  $verified_contributor = array_search('verified contributor', user_roles(true));
1486
-  if (!isset($account->roles[$verified_contributor])) {
1484
+    $min_credit_to_post = variable_get('boinc_comment_min_credit', 0);
1485
+    $verified_contributor = array_search('verified contributor', user_roles(true));
1486
+    if (!isset($account->roles[$verified_contributor])) {
1487 1487
     drupal_set_message(bts(
1488 1488
         'You may only create or modify your user profile after earning @count credits.',
1489 1489
         array('@count' => $min_credit_to_post), NULL, 'boinc:view-profile'
1490 1490
     ), 'warning', FALSE);
1491
-  }
1491
+    }
1492 1492
 
1493
-  // For now, just call the user module profile view function
1494
-  user_build_content($account);
1495
-  return theme('user_profile', $account);
1493
+    // For now, just call the user module profile view function
1494
+    user_build_content($account);
1495
+    return theme('user_profile', $account);
1496 1496
 }
1497 1497
 
1498 1498
 /**
1499 1499
  * Page callback for editing a user profile
1500 1500
  */
1501 1501
 function boincuser_edit_profile($account = null) {
1502
-  // Create the user profile form
1503
-  if (!$account) {
1502
+    // Create the user profile form
1503
+    if (!$account) {
1504 1504
     global $user;
1505 1505
     $account = $user;
1506
-  }
1507
-  // Render the form
1508
-  module_load_include('pages.inc', 'node', 'node');
1509
-  return content_profile_page_edit('profile', $account);
1506
+    }
1507
+    // Render the form
1508
+    module_load_include('pages.inc', 'node', 'node');
1509
+    return content_profile_page_edit('profile', $account);
1510 1510
 }
1511 1511
 
1512 1512
 /**
1513
-  * Join page menu callback.
1514
-  * Display instructions on joining for new or existing BOINC users
1515
-  */
1513
+ * Join page menu callback.
1514
+ * Display instructions on joining for new or existing BOINC users
1515
+ */
1516 1516
 function join_page($type = null) {
1517
-  global $base_url;
1518
-  /* The paths/links to the rules-and-policies page is hardcoded
1517
+    global $base_url;
1518
+    /* The paths/links to the rules-and-policies page is hardcoded
1519 1519
    * here. An improvement would be admin settings for the Join Page
1520 1520
    * where this path could be set.
1521 1521
    */
1522
-  $ruleslinkA = 'rules-and-policies';
1523
-  $ruleslinkB = 'content/rules-and-policies';
1524
-  $site_name = variable_get('site_name', 'Drupal-BOINC');
1525
-  $registration_enabled = variable_get('user_register', 0);
1526
-  $output = '<div class="join">';
1527
-  switch ($type) {
1528
-  case 'boinc':
1522
+    $ruleslinkA = 'rules-and-policies';
1523
+    $ruleslinkB = 'content/rules-and-policies';
1524
+    $site_name = variable_get('site_name', 'Drupal-BOINC');
1525
+    $registration_enabled = variable_get('user_register', 0);
1526
+    $output = '<div class="join">';
1527
+    switch ($type) {
1528
+    case 'boinc':
1529 1529
     $output .= '<ol>';
1530 1530
     if ($registration_enabled) {
1531
-      $output .= '<li>' . bts('First !create_an_account here at @sitename.',
1532
-      array(
1531
+        $output .= '<li>' . bts('First !create_an_account here at @sitename.',
1532
+        array(
1533 1533
         '!create_an_account' => l(bts('create an account', array(), NULL, 'boinc:join-page'), 'user/registration'),
1534 1534
         '@sitename' => $site_name,
1535
-      ), NULL, 'boinc:join-page') . '</li>';
1535
+        ), NULL, 'boinc:join-page') . '</li>';
1536 1536
     }
1537 1537
     $output .= '  <li>' . bts("Install BOINC on this device if not already present.", array(), NULL, 'boinc:join-page') . '</li>';
1538 1538
     $output .= '  <li>' . bts("Select <i>Tools / Add Project</i>. Choose @sitename from the list, or enter @siteurl.",
1539 1539
     array(
1540
-      '@sitename' => $site_name,
1541
-      '@siteurl' => $base_url,
1540
+        '@sitename' => $site_name,
1541
+        '@siteurl' => $base_url,
1542 1542
     ), NULL, 'boinc:join-page') . '</li>';
1543 1543
     if ($registration_enabled) {
1544
-      $output .= '<li>' . bts("If you're running a command-line or pre-5.0 version of BOINC, use <b>!boinccmd</b> to add the project.",
1544
+        $output .= '<li>' . bts("If you're running a command-line or pre-5.0 version of BOINC, use <b>!boinccmd</b> to add the project.",
1545 1545
         array(
1546
-          '!boinccmd' => l('boinccmd --project_attach', 'http://boinc.berkeley.edu/wiki/Boinccmd_tool'),
1546
+            '!boinccmd' => l('boinccmd --project_attach', 'http://boinc.berkeley.edu/wiki/Boinccmd_tool'),
1547 1547
         ), NULL, 'boinc:join-page') . '</li>';
1548 1548
     }
1549 1549
     else {
1550
-      $output .= '<li>' . bts("If you're running a command-line version of BOINC,
1550
+        $output .= '<li>' . bts("If you're running a command-line version of BOINC,
1551 1551
         please follow the <b>!instructionslink</b> to first <i>create an account</i>, and then <i>attach</i> to this project. Use the same project URL as above.",
1552 1552
         array(
1553
-          '!instructionslink' => l('instructions', 'http://boinc.berkeley.edu/wiki/Boinccmd_tool'),
1553
+            '!instructionslink' => l('instructions', 'http://boinc.berkeley.edu/wiki/Boinccmd_tool'),
1554 1554
         ), NULL, 'boinc:join-page') . '</li>';
1555 1555
     }
1556 1556
     $output .= '<li>' . bts("If you're running a pre-5.0 version of BOINC, please
1557 1557
       upgrade to a more recent version of BOINC to create an account
1558 1558
       at @this_project.",
1559
-      array(
1559
+        array(
1560 1560
         '@this_project' => $site_name,
1561
-      ), NULL, 'boinc:join-page') . '</li>';
1561
+        ), NULL, 'boinc:join-page') . '</li>';
1562 1562
     $output .=  '</ol>';
1563 1563
     break;
1564
-  case 'new':
1564
+    case 'new':
1565 1565
   default:
1566 1566
     // Determine if there is a link to rules-and-policies
1567 1567
     //$ruleslink='';
@@ -1576,16 +1576,16 @@  discard block
 block discarded – undo
1576 1576
     // Join page output
1577 1577
     $output .= '<ol>';
1578 1578
     if ($registration_enabled) {
1579
-      $output .= '<li>' . bts('First !create_an_account here at @sitename.',
1580
-      array(
1579
+        $output .= '<li>' . bts('First !create_an_account here at @sitename.',
1580
+        array(
1581 1581
         '!create_an_account' => l(bts('create an account', array(), NULL, 'boinc:join-page'), 'user/registration'),
1582 1582
         '@sitename' => $site_name,
1583
-      ), NULL, 'boinc:join-page') . '</li>';
1583
+        ), NULL, 'boinc:join-page') . '</li>';
1584 1584
     }
1585 1585
     else if ( menu_valid_path(array('link_path' => $ruleslink)) ) {
1586
-      $output .= '  <li>' . bts("Read our !rules_and_policies.", array(
1586
+        $output .= '  <li>' . bts("Read our !rules_and_policies.", array(
1587 1587
         '!rules_and_policies' => l(bts('Rules and Policies', array(), NULL, 'boinc:join-page'), $ruleslink),
1588
-      ), NULL, 'boinc:join-page') . '</li>';
1588
+        ), NULL, 'boinc:join-page') . '</li>';
1589 1589
     }
1590 1590
     $output .= '  <li>' . bts('Download the BOINC desktop software.', array(), NULL, 'boinc:join-page');
1591 1591
     $output .= '    <p>';
@@ -1595,73 +1595,73 @@  discard block
 block discarded – undo
1595 1595
     $output .= '  </li>';
1596 1596
     $output .= '  <li>' . bts('Run the installer.', array(), NULL, 'boinc:join-page') . '</li>';
1597 1597
     $output .= '  <li>' . bts('Choose @sitename from the list, or enter @siteurl.', array(
1598
-      '@sitename' => $site_name,
1599
-      '@siteurl' => $base_url,
1598
+        '@sitename' => $site_name,
1599
+        '@siteurl' => $base_url,
1600 1600
     ), NULL, 'boinc:join-page') . '</li>';
1601 1601
     $output .=  '</ol>';
1602
-  }
1603
-  $output .= '</div>';
1604
-  return $output;
1602
+    }
1603
+    $output .= '</div>';
1604
+    return $output;
1605 1605
 }
1606 1606
 
1607 1607
 /**
1608
-  * Home page content for embedding in Panels page
1609
-  */
1608
+ * Home page content for embedding in Panels page
1609
+ */
1610 1610
 function boincuser_home_page() {
1611
-  global $user;
1612
-  $site_name = variable_get('site_name', 'Drupal-BOINC');
1613
-  // get the front page message from database; this is set in the admin interface under BOINC Other
1614
-  $site_message = variable_get('boinc_other_frontpage','');
1611
+    global $user;
1612
+    $site_name = variable_get('site_name', 'Drupal-BOINC');
1613
+    // get the front page message from database; this is set in the admin interface under BOINC Other
1614
+    $site_message = variable_get('boinc_other_frontpage','');
1615 1615
 
1616
-  // Determine the user of the day
1617
-  $current_uotd = db_fetch_object(db_query("
1616
+    // Determine the user of the day
1617
+    $current_uotd = db_fetch_object(db_query("
1618 1618
     SELECT
1619 1619
       uid,
1620 1620
       uotd_time
1621 1621
     FROM {boincuser}
1622 1622
     ORDER BY uotd_time DESC
1623 1623
     LIMIT 1"
1624
-  ));
1625
-  if ($current_uotd->uotd_time < strtotime('today midnight')) {
1624
+    ));
1625
+    if ($current_uotd->uotd_time < strtotime('today midnight')) {
1626 1626
     $uotd = boincuser_select_user_of_the_day();
1627
-  }
1628
-  else {
1627
+    }
1628
+    else {
1629 1629
     $uotd = user_load($current_uotd->uid);
1630
-  }
1631
-  $uotd_image = boincuser_get_user_profile_image($uotd->uid, FALSE);
1632
-  $output = '<h2 class="pane-title">';
1633
-  $output .= ($user->uid) ? bts('Welcome back!', array(), NULL, 'boinc:front-page') : ($site_name ? bts('What is @this_project?', array('@this_project' => $site_name)) : bts('Welcome!', array(), NULL, 'boinc:front-page'));
1634
-  $output .= '</h2>';
1635
-  $output .= '<div class="boinc-overview balance-height-front">';
1636
-  $output .= '  <div>' . bts($site_message, array(), NULL, "project:front page") . ' ' . l(bts('Learn more', array(), NULL, 'boinc:front-page'), 'about') . '</div>';
1637
-  if ($user->uid) {
1630
+    }
1631
+    $uotd_image = boincuser_get_user_profile_image($uotd->uid, FALSE);
1632
+    $output = '<h2 class="pane-title">';
1633
+    $output .= ($user->uid) ? bts('Welcome back!', array(), NULL, 'boinc:front-page') : ($site_name ? bts('What is @this_project?', array('@this_project' => $site_name)) : bts('Welcome!', array(), NULL, 'boinc:front-page'));
1634
+    $output .= '</h2>';
1635
+    $output .= '<div class="boinc-overview balance-height-front">';
1636
+    $output .= '  <div>' . bts($site_message, array(), NULL, "project:front page") . ' ' . l(bts('Learn more', array(), NULL, 'boinc:front-page'), 'about') . '</div>';
1637
+    if ($user->uid) {
1638 1638
     $output .= '  <div>' . l(bts('View account', array(), NULL, 'boinc:front-page'), 'dashboard', array('attributes' => array('class' => 'join button'))) . '</div>';
1639
-  }
1640
-  else {
1639
+    }
1640
+    else {
1641 1641
     $output .= '  <div>' . l(bts('Join now', array(), NULL, 'boinc:front-page'), 'join', array('attributes' => array('class' => 'join button'))) . '</div>';
1642
-  }
1643
-  $output .= '</div>';
1644
-  $output .= '<div class="boinc-overview-details">';
1645
-  $output .= '  <div class="detail-container">';
1646
-  $output .= '    <a class="user-of-the-day" href="account/' . $uotd->uid . '">';
1647
-  $output .= '      <div class="picture">';
1648
-  $output .= theme('imagefield_image', $uotd_image['image'], $uotd_image['alt'],
1642
+    }
1643
+    $output .= '</div>';
1644
+    $output .= '<div class="boinc-overview-details">';
1645
+    $output .= '  <div class="detail-container">';
1646
+    $output .= '    <a class="user-of-the-day" href="account/' . $uotd->uid . '">';
1647
+    $output .= '      <div class="picture">';
1648
+    $output .= theme('imagefield_image', $uotd_image['image'], $uotd_image['alt'],
1649 1649
     $uotd_image['alt'], array(), FALSE);
1650
-  $output .= '      </div>';
1651
-  $output .= '      <div class="text">' . bts('User of the day', array(), NULL, 'boinc:front-page') . '</div>';
1652
-  $output .= '      <div class="detail">' . $uotd->boincuser_name . '</div>';
1653
-  $output .= '    </a>';
1654
-  $output .= '    <div class="volunteers">';
1655
-  $output .= '      <div class="text">' . bts('Over 500,000 volunteers and counting.', array(), NULL, 'boinc:front-page') . '</div>';
1656
-  $output .= '      <div class="platforms">';
1657
-  $output .= '        <div class="detail platform windows">' . bts('Windows', array(), NULL, 'boinc:front-page') . '</div>';
1658
-  $output .= '        <div class="detail platform mac">' .  bts('Mac', array(), NULL, 'boinc:front-page') . '</div>';
1659
-  $output .= '        <div class="detail platform linux">' . bts('Linux', array(), NULL, 'boinc:front-page') . '</div>';
1660
-  $output .= '      </div>';
1661
-  $output .= '    </div>';
1662
-  $output .= '  </div>';
1663
-  $output .= '</div>';
1664
-  return $output;
1650
+    $output .= '      </div>';
1651
+    $output .= '      <div class="text">' . bts('User of the day', array(), NULL, 'boinc:front-page') . '</div>';
1652
+    $output .= '      <div class="detail">' . $uotd->boincuser_name . '</div>';
1653
+    $output .= '    </a>';
1654
+    $output .= '    <div class="volunteers">';
1655
+    $output .= '      <div class="text">' . bts('Over 500,000 volunteers and counting.', array(), NULL, 'boinc:front-page') . '</div>';
1656
+    $output .= '      <div class="platforms">';
1657
+    $output .= '        <div class="detail platform windows">' . bts('Windows', array(), NULL, 'boinc:front-page') . '</div>';
1658
+    $output .= '        <div class="detail platform mac">' .  bts('Mac', array(), NULL, 'boinc:front-page') . '</div>';
1659
+    $output .= '        <div class="detail platform linux">' . bts('Linux', array(), NULL, 'boinc:front-page') . '</div>';
1660
+    $output .= '      </div>';
1661
+    $output .= '    </div>';
1662
+    $output .= '  </div>';
1663
+    $output .= '</div>';
1664
+    return $output;
1665 1665
 }
1666 1666
 
1667 1667
 /**
@@ -1669,81 +1669,81 @@  discard block
 block discarded – undo
1669 1669
  * Create a new user account based on supplied parameters.
1670 1670
  */
1671 1671
 function boincuser_create_account() {
1672
-  global $base_url;
1672
+    global $base_url;
1673 1673
 
1674
-  require_boinc('boinc_db');
1675
-  require_boinc('user_util');
1676
-  require_boinc('xml');
1677
-  $params = array(
1674
+    require_boinc('boinc_db');
1675
+    require_boinc('user_util');
1676
+    require_boinc('xml');
1677
+    $params = array(
1678 1678
     'email_addr' => isset($_GET['email_addr']) ? $_GET['email_addr'] : '',
1679 1679
     'user_name' => isset($_GET['user_name']) ? $_GET['user_name'] : '',
1680 1680
     'passwd_hash' => isset($_GET['passwd_hash']) ? $_GET['passwd_hash'] : ''
1681
-  );
1681
+    );
1682 1682
   
1683
-  // Begin output
1684
-  xml_header();
1683
+    // Begin output
1684
+    xml_header();
1685 1685
   
1686
-  // Account creation disabled
1687
-  $enablethisRPC = variable_get('boinc_weboptions_enableaccountcreateRPC', TRUE);
1688
-  if (!$enablethisRPC) {
1686
+    // Account creation disabled
1687
+    $enablethisRPC = variable_get('boinc_weboptions_enableaccountcreateRPC', TRUE);
1688
+    if (!$enablethisRPC) {
1689 1689
     $mess = bts('Account creation is done through our Web site. Please register at @url', array(
1690
-      '@url' => $base_url . '/user/registration',
1690
+        '@url' => $base_url . '/user/registration',
1691 1691
     ),
1692 1692
     NULL, 'boinc:create_account');
1693 1693
     xml_error(-208, $mess);
1694
-  }
1695
-  // Invalid invite code
1694
+    }
1695
+    // Invalid invite code
1696 1696
   
1697
-  // Validate input
1698
-  if (user_validate_mail($params['email_addr']) or !is_valid_email_addr($params['email_addr'])) {
1697
+    // Validate input
1698
+    if (user_validate_mail($params['email_addr']) or !is_valid_email_addr($params['email_addr'])) {
1699 1699
     xml_error(-205);
1700
-  }
1700
+    }
1701 1701
 
1702
-  // Make sure user_name is unique and cleaned
1703
-  $unique_name = create_proper_drupalname($params['user_name']);
1704
-  if ($error = user_validate_name($unique_name)) {
1702
+    // Make sure user_name is unique and cleaned
1703
+    $unique_name = create_proper_drupalname($params['user_name']);
1704
+    if ($error = user_validate_name($unique_name)) {
1705 1705
     xml_error(-188, $error);
1706
-  }
1707
-  if (strlen($params['passwd_hash']) != 32) {
1706
+    }
1707
+    if (strlen($params['passwd_hash']) != 32) {
1708 1708
     xml_error(-1, 'password hash length not 32');
1709
-  }
1709
+    }
1710 1710
   
1711
-  // Process input
1712
-  // Check this email against previous email addresses.
1713
-  $tmpuser = BoincUser::lookup_prev_email_addr($params['email_addr']);
1714
-  if ($tmpuser) {
1711
+    // Process input
1712
+    // Check this email against previous email addresses.
1713
+    $tmpuser = BoincUser::lookup_prev_email_addr($params['email_addr']);
1714
+    if ($tmpuser) {
1715 1715
     xml_error(-137);
1716
-  }
1716
+    }
1717 1717
 
1718
-  // Check this email on current email addresses.
1719
-  $boinc_user = BoincUser::lookup_email_addr($params['email_addr']);
1720
-  if ($boinc_user) {
1718
+    // Check this email on current email addresses.
1719
+    $boinc_user = BoincUser::lookup_email_addr($params['email_addr']);
1720
+    if ($boinc_user) {
1721 1721
     // Return authenticator for existing users
1722 1722
     if ( ($params['passwd_hash'] == $boinc_user->passwd_hash) or
1723 1723
     password_verify($params['passwd_hash'], $boinc_user->passwd_hash) ) {
1724
-      $output = array('authenticator' => $boinc_user->authenticator);
1724
+        $output = array('authenticator' => $boinc_user->authenticator);
1725 1725
     }
1726 1726
     else {
1727
-      xml_error(-137);
1727
+        xml_error(-137);
1728 1728
     }
1729
-  }
1730
-  else {
1729
+    }
1730
+    else {
1731 1731
     // Verify that there isn't somehow a Drupal user already (not possible with proper function)
1732 1732
     if ($existing_user = user_load(array('mail' => $params['email_addr']))) {
1733
-      xml_error(-137, 'account error');
1733
+        xml_error(-137, 'account error');
1734 1734
     }
1735 1735
     // Create new account
1736 1736
     $unrestricted_role = array_search('community member', user_roles(true));
1737 1737
 
1738 1738
     $newUser = array(
1739
-      'name' => $unique_name,
1740
-      'pass' => $params['passwd_hash'], // note: passing a hash here requires ALL passwords to be hashed via hook prior to interacting with the hash stored in the db
1741
-      'mail' => $params['email_addr'],
1742
-      'status' => 1,
1743
-      'init' => $params['email_addr'],
1744
-      'roles' => array($unrestricted_role => ''),
1745
-      'boincuser_name' => $params['user_name'],
1746
-      'boinchash_flag' => TRUE,
1739
+        'name' => $unique_name,
1740
+        'pass' => $params['passwd_hash'], // note: passing a hash here requires ALL passwords to be hashed via hook prior to interacting with the hash stored in the db
1741
+        'mail' => $params['email_addr'],
1742
+        'status' => 1,
1743
+        'init' => $params['email_addr'],
1744
+        'roles' => array($unrestricted_role => ''),
1745
+        'boincuser_name' => $params['user_name'],
1746
+        'boinchash_flag' => TRUE,
1747 1747
     );
1748 1748
 
1749 1749
     // Create the drupal user. If the drupal user cannot be created,
@@ -1751,17 +1751,17 @@  discard block
 block discarded – undo
1751 1751
     // The user is created in the 'insert' op in hook_user.
1752 1752
     $user = user_save(null, $newUser);
1753 1753
     if (!$user) {
1754
-      watchdog('boincuser', 'create_account: Failed to create Drupal user account for @email', array('@email' => $params['email_addr']), WATCHDOG_WARNING);
1755
-      xml_error(-137, 'error creating BOINC account');
1754
+        watchdog('boincuser', 'create_account: Failed to create Drupal user account for @email', array('@email' => $params['email_addr']), WATCHDOG_WARNING);
1755
+        xml_error(-137, 'error creating BOINC account');
1756 1756
     }// if drupal user created.
1757 1757
 
1758 1758
     $output = array('authenticator' => $user->boincuser_account_key);
1759
-  }// if existing user found.
1759
+    }// if existing user found.
1760 1760
 
1761
-  // Output authenticator
1762
-  echo " <account_out>\n";
1763
-  echo "   <authenticator>{$output['authenticator']}</authenticator>\n";
1764
-  echo "</account_out>\n";
1761
+    // Output authenticator
1762
+    echo " <account_out>\n";
1763
+    echo "   <authenticator>{$output['authenticator']}</authenticator>\n";
1764
+    echo "</account_out>\n";
1765 1765
 }
1766 1766
 
1767 1767
 /**
@@ -1769,166 +1769,166 @@  discard block
 block discarded – undo
1769 1769
  * account is created using the BOINC clinet.
1770 1770
  */
1771 1771
 function boincuser_account_finish() {
1772
-  global $user;
1772
+    global $user;
1773 1773
 
1774
-  $authtoken = isset($_GET['auth']) ? $_GET['auth'] : '';
1774
+    $authtoken = isset($_GET['auth']) ? $_GET['auth'] : '';
1775 1775
 
1776
-  // Ensure there is a authentication token before continuing
1777
-  if (empty($authtoken)) {
1776
+    // Ensure there is a authentication token before continuing
1777
+    if (empty($authtoken)) {
1778 1778
     drupal_not_found();
1779 1779
     return ;
1780
-  }
1780
+    }
1781 1781
 
1782
-  if (strlen($authtoken) != 32) {
1782
+    if (strlen($authtoken) != 32) {
1783 1783
     drupal_set_message(bts('ERROR: There is no account with that authenticator.', array(), NULL, 'boinc:account-finish'), 'error');
1784 1784
     drupal_goto();
1785
-  }
1785
+    }
1786 1786
 
1787
-  require_boinc('boinc_db');
1788
-  $boinc_user = BoincUser::lookup("authenticator='".addslashes($authtoken)."'");
1789
-  if (!$boinc_user) {
1787
+    require_boinc('boinc_db');
1788
+    $boinc_user = BoincUser::lookup("authenticator='".addslashes($authtoken)."'");
1789
+    if (!$boinc_user) {
1790 1790
     drupal_set_message(bts('ERROR: There is no account with that authenticator.', array(), NULL, 'boinc:account-finish'), 'error');
1791 1791
     drupal_goto();
1792
-  }
1793
-  $user = user_load(get_drupal_id($boinc_user->id));
1792
+    }
1793
+    $user = user_load(get_drupal_id($boinc_user->id));
1794 1794
 
1795
-  if (!$user) {
1795
+    if (!$user) {
1796 1796
     drupal_set_message(bts('ERROR: There was a problem loading your account. Try logging in with your user name and password.', array(), NULL, 'boinc:account-finish'), 'error');
1797 1797
     drupal_goto();
1798
-  }
1798
+    }
1799 1799
 
1800
-  // Lookup path to custom account finish page
1801
-  $customaccountfinishpath = drupal_lookup_path('source', variable_get('boinc_weboptions_accountfinish', '') );
1802
-  if ( menu_valid_path(array('link_path' => $customaccountfinishpath)) ) {
1800
+    // Lookup path to custom account finish page
1801
+    $customaccountfinishpath = drupal_lookup_path('source', variable_get('boinc_weboptions_accountfinish', '') );
1802
+    if ( menu_valid_path(array('link_path' => $customaccountfinishpath)) ) {
1803 1803
     $node = menu_get_object('node', 1, $customaccountfinishpath);
1804 1804
     if ($node) {
1805
-      return node_page_view($node);
1805
+        return node_page_view($node);
1806
+    }
1806 1807
     }
1807
-  }
1808 1808
 
1809
-  // open links in new window
1810
-  $options = array(
1809
+    // open links in new window
1810
+    $options = array(
1811 1811
     'attributes' => array( 'target' => '_blank' ),
1812
-  );
1812
+    );
1813 1813
 
1814
-  // Check moderation page exists
1815
-  $moderationpath = drupal_lookup_path('source', variable_get('boinc_weboptions_moderationpage', '') );
1816
-  if ( menu_valid_path(array('link_path' => $moderationpath)) ) {
1814
+    // Check moderation page exists
1815
+    $moderationpath = drupal_lookup_path('source', variable_get('boinc_weboptions_moderationpage', '') );
1816
+    if ( menu_valid_path(array('link_path' => $moderationpath)) ) {
1817 1817
     $modsentence = bts('Please note: user profiles are subject to !moderation.', array('!moderation' => l(bts('moderation', array(), NULL, 'boinc:account-finish'), $moderationpath, $options)), NULL, 'boinc:account-finish');
1818
-  } else {
1818
+    } else {
1819 1819
     $modsentence = bts('Please note: user profiles are subject to moderation.', array(), NULL, 'boinc:account-finish');
1820
-  }
1820
+    }
1821 1821
 
1822
-  $username = $user->boincuser_name;
1823
-  $site_name = variable_get('site_name', 'Drupal-BOINC');
1824
-  $output = "<p>" . bts('Thank you @user_name for joining @site_name. Your account has been created. Your BOINC client should start working on assigned tasks soon, without any additional action or configuration. Please visit the links below for more information and additional options. (Links will open in a new window.)',
1825
-  array(
1822
+    $username = $user->boincuser_name;
1823
+    $site_name = variable_get('site_name', 'Drupal-BOINC');
1824
+    $output = "<p>" . bts('Thank you @user_name for joining @site_name. Your account has been created. Your BOINC client should start working on assigned tasks soon, without any additional action or configuration. Please visit the links below for more information and additional options. (Links will open in a new window.)',
1825
+    array(
1826 1826
     '@user_name' => $username,
1827 1827
     '@site_name' => $site_name,
1828
-  ), NULL, 'boinc:account-finish') . "</p>";
1828
+    ), NULL, 'boinc:account-finish') . "</p>";
1829 1829
 
1830
-  $links = array(
1830
+    $links = array(
1831 1831
     array(
1832
-      'data' => bts('Change your username at !community_preferences.', array(
1832
+        'data' => bts('Change your username at !community_preferences.', array(
1833 1833
         '!community_preferences' => l(bts('Community Preferences', array(), NULL, 'boinc:account-fininsh'), 'account/prefs/community', $options),
1834
-      ), NULL, 'boinc:account-finish'),
1835
-      'children' => array(
1834
+        ), NULL, 'boinc:account-finish'),
1835
+        'children' => array(
1836 1836
         bts('Your username is used to identify yourself to other volunteers on this Web site.', array(), NULL, 'boinc:account-finish'),
1837 1837
         bts('In addition, you may set your account\'s default language and adjust notification settings.', array(), NULL, 'boinc:account-finish'),
1838
-      ),
1838
+        ),
1839 1839
     ),
1840 1840
     array(
1841
-      'data' => bts('Change your !computing_preferences.', array(
1841
+        'data' => bts('Change your !computing_preferences.', array(
1842 1842
         '!computing_preferences' => l(bts('Computing Preferences', array(), NULL, 'boinc:account-finish'), 'account/prefs', $options),
1843
-      ), NULL, 'boinc:account-finish'),
1844
-      'children' => array(
1843
+        ), NULL, 'boinc:account-finish'),
1844
+        'children' => array(
1845 1845
         bts('You may adjust how much CPU, RAM, and Disk space the BOINC client is allowed to use for tasks on your computer.', array(), NULL, 'boinc:account-finish'),
1846 1846
         bts('By default, you will run @site_name tasks without any additional configuration.', array(
1847
-          '@site_name' => $site_name,
1847
+            '@site_name' => $site_name,
1848 1848
         ), NULL, 'boinc:account-finish'),
1849 1849
         bts('It is recommended new volunteers leave the default settings until they gain experience running some tasks. Ask questions in the !forums to get advice before making changes to a setting you don\'t understand.', array(
1850
-          '!forums' => l(bts('forums', array(), NULL, 'boinc:account-finish'), 'community/forum', $options),
1850
+            '!forums' => l(bts('forums', array(), NULL, 'boinc:account-finish'), 'community/forum', $options),
1851 1851
         ), NULL, 'boinc:account-finish'),
1852
-      ),
1852
+        ),
1853 1853
     ),
1854 1854
     array(
1855 1855
         'data' => bts('Create a !user_profile.', array(
1856
-          '!user_profile' => l(bts('User Profile', array(), NULL, 'boinc:account-finish'), '/account/profile/edit', $options),
1856
+            '!user_profile' => l(bts('User Profile', array(), NULL, 'boinc:account-finish'), '/account/profile/edit', $options),
1857 1857
         ), NULL, 'boinc:account-finish'),
1858
-      'children' => array(
1858
+        'children' => array(
1859 1859
         bts('A user profile will inform other volunteers who you are and why you joined @site_name.', array(
1860
-          '@site_name' => $site_name,
1860
+            '@site_name' => $site_name,
1861 1861
         ), NULL, 'boinc:account-finish'),
1862 1862
         $modsentence,
1863
-      ),
1863
+        ),
1864 1864
     ),
1865 1865
     array(
1866
-      'data' => bts('Join a !team.', array(
1866
+        'data' => bts('Join a !team.', array(
1867 1867
         '!team' => l(bts('Team', array(), NULL, 'boinc:account-finish'), '/community/teams', $options),
1868
-      ), NULL, 'boinc:account-finish'),
1869
-      'children' => array(
1868
+        ), NULL, 'boinc:account-finish'),
1869
+        'children' => array(
1870 1870
         bts('You may join a team, made up of other volunteers.', array(), NULL, 'boinc:account-finish'),
1871
-      ),
1871
+        ),
1872 1872
     ),
1873 1873
     array(
1874
-      'data' => bts('Go to your !account_dashboard.', array(
1874
+        'data' => bts('Go to your !account_dashboard.', array(
1875 1875
         '!account_dashboard'=> l(bts('Account Dashboard', array(), NULL, 'boinc:account-finish'), 'account/dashboard', $options),
1876
-      ), NULL, 'boinc:account-finish'),
1877
-      'children' => array(
1876
+        ), NULL, 'boinc:account-finish'),
1877
+        'children' => array(
1878 1878
         bts('Your account dashboard has information and links about your computer(s) and task(s) assigned.', array(), NULL, 'boinc:account-finish'),
1879
-      ),
1879
+        ),
1880 1880
     ),
1881 1881
     array(
1882
-      'data' => bts('Visit our !help pages.', array(
1882
+        'data' => bts('Visit our !help pages.', array(
1883 1883
         '!help' => l(bts('Help', array(), NULL, 'boinc:account-finish'), '/help', $options)
1884
-      ), NULL, 'boinc:account-finish'),
1885
-      'children' => array(
1884
+        ), NULL, 'boinc:account-finish'),
1885
+        'children' => array(
1886 1886
         bts('Ask for help in our community\'s !forums.', array(
1887
-          '!forums' => l(bts('forums', array(), NULL, 'boinc:account-finish'), 'community/forum', $options)
1887
+            '!forums' => l(bts('forums', array(), NULL, 'boinc:account-finish'), 'community/forum', $options)
1888 1888
         ), NULL, 'boinc:account-finish'),
1889
-      ),
1889
+        ),
1890 1890
     ),
1891
-  );
1891
+    );
1892 1892
 
1893
-  //List of links
1894
-  $output .= theme_item_list($links, $title = NULL, $type='ul');
1893
+    //List of links
1894
+    $output .= theme_item_list($links, $title = NULL, $type='ul');
1895 1895
 
1896
-  return $output;
1896
+    return $output;
1897 1897
 }
1898 1898
 
1899 1899
 /**
1900 1900
  * Determine if the user has permission to control community access
1901 1901
  */
1902 1902
 function boincuser_moderate_community_access() {
1903
-  if (user_access('assign community member role')
1903
+    if (user_access('assign community member role')
1904 1904
   OR user_access('assign all roles')) {
1905 1905
     return TRUE;
1906
-  }
1907
-  return FALSE;
1906
+    }
1907
+    return FALSE;
1908 1908
 }
1909 1909
 
1910 1910
 /**
1911 1911
  * Get the count of items in the moderation queue
1912 1912
  */
1913 1913
 function boincuser_moderation_queue_count($caller = 'user') {
1914
-  $allowed = FALSE;
1915
-  switch ($caller) {
1916
-  case 'cron':
1914
+    $allowed = FALSE;
1915
+    switch ($caller) {
1916
+    case 'cron':
1917 1917
     $allowed = TRUE;
1918 1918
     break;
1919
-  case 'user':
1919
+    case 'user':
1920 1920
   default:
1921 1921
     $allowed = user_access('edit any profile content');
1922
-  }
1923
-  if ($allowed) {
1922
+    }
1923
+    if ($allowed) {
1924 1924
     return db_result(db_query("
1925 1925
       SELECT COUNT(*)
1926 1926
       FROM {node}
1927 1927
       WHERE type = 'profile'
1928 1928
       AND moderate = 1"
1929 1929
     ));
1930
-  }
1931
-  return NULL;
1930
+    }
1931
+    return NULL;
1932 1932
 }
1933 1933
 
1934 1934
 /**
@@ -1937,43 +1937,43 @@  discard block
 block discarded – undo
1937 1937
  * than through the user account info form.
1938 1938
  */
1939 1939
 function boincuser_control($uid = NULL, $action = NULL) {
1940
-  if (!$uid OR !$account = user_load($uid)) {
1940
+    if (!$uid OR !$account = user_load($uid)) {
1941 1941
     // What are you even doing here...
1942 1942
     return FALSE;
1943
-  }
1944
-  switch ($action) {
1945
-  case 'ban':
1943
+    }
1944
+    switch ($action) {
1945
+    case 'ban':
1946 1946
     if (boincuser_moderate_community_access()) {
1947
-      $penalty_period = variable_get('boinc_penalty_period', 7*24*60*60);
1948
-      $boincuser_record = array(
1947
+        $penalty_period = variable_get('boinc_penalty_period', 7*24*60*60);
1948
+        $boincuser_record = array(
1949 1949
         'uid' => $uid,
1950 1950
         'penalty_expiration' => time() + $penalty_period,
1951
-      );
1952
-      drupal_write_record('boincuser', $boincuser_record, 'uid');
1953
-      $community_role = array_search('community member', user_roles(true));
1954
-      if (isset($account->roles[$community_role])) {
1951
+        );
1952
+        drupal_write_record('boincuser', $boincuser_record, 'uid');
1953
+        $community_role = array_search('community member', user_roles(true));
1954
+        if (isset($account->roles[$community_role])) {
1955 1955
         unset($account->roles[$community_role]);
1956 1956
         user_save($account, array('roles' => $account->roles));
1957
-      }
1957
+        }
1958 1958
     }
1959 1959
     break;
1960
-  case 'lift-ban':
1960
+    case 'lift-ban':
1961 1961
     if (boincuser_moderate_community_access()) {
1962
-      $boincuser_record = array(
1962
+        $boincuser_record = array(
1963 1963
         'uid' => $uid,
1964 1964
         'penalty_expiration' => 0,
1965
-      );
1966
-      drupal_write_record('boincuser', $boincuser_record, 'uid');
1967
-      $community_role = array_search('community member', user_roles(true));
1968
-      if (!isset($account->roles[$community_role])) {
1965
+        );
1966
+        drupal_write_record('boincuser', $boincuser_record, 'uid');
1967
+        $community_role = array_search('community member', user_roles(true));
1968
+        if (!isset($account->roles[$community_role])) {
1969 1969
         $account->roles[$community_role] = 'community member';
1970 1970
         user_save($account, array('roles' => $account->roles));
1971
-      }
1971
+        }
1972 1972
     }
1973 1973
     break;
1974
-  default:
1974
+    default:
1975 1975
   }
1976
-  drupal_goto("account/{$account->uid}");
1976
+    drupal_goto("account/{$account->uid}");
1977 1977
 }
1978 1978
 
1979 1979
 /**
@@ -1981,29 +1981,29 @@  discard block
 block discarded – undo
1981 1981
  * moderation flag.
1982 1982
  */
1983 1983
 function boincuser_moderate_profile_approve($account) {
1984
-  $node = new stdClass;
1985
-  $node->type = 'profile';
1986
-  $node->language = '';
1987
-  $nid = content_profile_profile_exists($node, $account->uid);
1988
-  $profile = node_load($nid);
1989
-  $profile->moderate = 0;
1990
-  $profile->status = 1;
1991
-  node_save($profile);
1992
-  drupal_set_message('This profile has been marked as approved.');
1993
-  drupal_goto();
1984
+    $node = new stdClass;
1985
+    $node->type = 'profile';
1986
+    $node->language = '';
1987
+    $nid = content_profile_profile_exists($node, $account->uid);
1988
+    $profile = node_load($nid);
1989
+    $profile->moderate = 0;
1990
+    $profile->status = 1;
1991
+    node_save($profile);
1992
+    drupal_set_message('This profile has been marked as approved.');
1993
+    drupal_goto();
1994 1994
 }
1995 1995
 
1996 1996
 /**
1997 1997
  * Mark a user profile as rejected and notify the user of the reason.
1998 1998
  */
1999 1999
 function boincuser_moderate_profile_reject($uid, $reason = '') {
2000
-  $account = user_load($uid);
2001
-  $node = new stdClass;
2002
-  $node->type = 'profile';
2003
-  $node->language = '';
2004
-  $nid = content_profile_profile_exists($node, $uid);
2005
-  $profile = node_load($nid);
2006
-  if ($profile->nid) {
2000
+    $account = user_load($uid);
2001
+    $node = new stdClass;
2002
+    $node->type = 'profile';
2003
+    $node->language = '';
2004
+    $nid = content_profile_profile_exists($node, $uid);
2005
+    $profile = node_load($nid);
2006
+    if ($profile->nid) {
2007 2007
     global $user;
2008 2008
     global $base_url;
2009 2009
     global $base_path;
@@ -2014,64 +2014,64 @@  discard block
 block discarded – undo
2014 2014
     $profile->status = 0;
2015 2015
     node_save($profile);
2016 2016
     $settings = array(
2017
-      'from' => '',
2018
-      'subject' => "Profile moderation at {$site_name}",
2019
-      'message' => ''
2020
-      . "{$account->boincuser_name},\n"
2021
-      . "\n"
2022
-      . "{$moderator->boincuser_name} has rejected your profile at"
2023
-      . " {$site_name} for the following reason: \n"
2024
-      . "\n"
2025
-      . "{$reason}\n"
2026
-      . "\n"
2027
-      . "\n"
2028
-      . "Since it has not been approved, your profile is not visible to other"
2029
-      . " {$site_name} users. Please make the needed changes here:\n"
2030
-      . "\n"
2031
-      . "{$site_url}account/profile \n"
2032
-      . "\n"
2033
-      . "Thanks, \n"
2034
-      . "\n"
2035
-      . "{$site_name} support team",
2017
+        'from' => '',
2018
+        'subject' => "Profile moderation at {$site_name}",
2019
+        'message' => ''
2020
+        . "{$account->boincuser_name},\n"
2021
+        . "\n"
2022
+        . "{$moderator->boincuser_name} has rejected your profile at"
2023
+        . " {$site_name} for the following reason: \n"
2024
+        . "\n"
2025
+        . "{$reason}\n"
2026
+        . "\n"
2027
+        . "\n"
2028
+        . "Since it has not been approved, your profile is not visible to other"
2029
+        . " {$site_name} users. Please make the needed changes here:\n"
2030
+        . "\n"
2031
+        . "{$site_url}account/profile \n"
2032
+        . "\n"
2033
+        . "Thanks, \n"
2034
+        . "\n"
2035
+        . "{$site_name} support team",
2036 2036
     );
2037 2037
     rules_action_mail_to_user($account, $settings);
2038 2038
     drupal_set_message('This profile has been marked as rejected.');
2039
-  }
2040
-  drupal_goto();
2039
+    }
2040
+    drupal_goto();
2041 2041
 }
2042 2042
 
2043 2043
 /**
2044 2044
  * Ban a user and send a notification of the reason.
2045 2045
  */
2046 2046
 function boincuser_moderate_user_ban($uid, $reason = '', $duration = '') {
2047
-  if (user_access('assign community member role')
2047
+    if (user_access('assign community member role')
2048 2048
   OR user_access('assign all roles')) {
2049 2049
     $account = user_load($uid);
2050 2050
     if ($account->uid) {
2051
-      module_load_include('inc', 'rules', 'modules/system.rules');
2052
-      if ($duration === '') {
2051
+        module_load_include('inc', 'rules', 'modules/system.rules');
2052
+        if ($duration === '') {
2053 2053
         $duration = variable_get('boinc_penalty_period', 7*24*60*60);
2054
-      }
2055
-      $penalty_expiration = ($duration > 0) ? time() + $duration : 4294967295;
2056
-      $boincuser_record = array(
2054
+        }
2055
+        $penalty_expiration = ($duration > 0) ? time() + $duration : 4294967295;
2056
+        $boincuser_record = array(
2057 2057
         'uid' => $uid,
2058 2058
         'penalty_expiration' => $penalty_expiration,
2059
-      );
2060
-      drupal_write_record('boincuser', $boincuser_record, 'uid');
2059
+        );
2060
+        drupal_write_record('boincuser', $boincuser_record, 'uid');
2061 2061
       
2062
-      $community_role = array_search('community member', user_roles(true));
2063
-      if (isset($account->roles[$community_role])) {
2062
+        $community_role = array_search('community member', user_roles(true));
2063
+        if (isset($account->roles[$community_role])) {
2064 2064
         unset($account->roles[$community_role]);
2065 2065
         user_save($account, array('roles' => $account->roles));
2066
-      }
2066
+        }
2067 2067
       
2068
-      global $user;
2069
-      global $base_url;
2070
-      global $base_path;
2071
-      $site_name = variable_get('site_name', 'Drupal-BOINC');
2072
-      $site_url = $base_url . $base_path;
2073
-      $moderator = user_load($user->uid);
2074
-      $settings = array(
2068
+        global $user;
2069
+        global $base_url;
2070
+        global $base_path;
2071
+        $site_name = variable_get('site_name', 'Drupal-BOINC');
2072
+        $site_url = $base_url . $base_path;
2073
+        $moderator = user_load($user->uid);
2074
+        $settings = array(
2075 2075
         'from' => '',
2076 2076
         'subject' => "User moderation at {$site_name}",
2077 2077
         'message' => ''
@@ -2092,12 +2092,12 @@  discard block
 block discarded – undo
2092 2092
         . "Thanks, \n"
2093 2093
         . "\n"
2094 2094
         . "{$site_name} support team",
2095
-      );
2096
-      rules_action_mail_to_user($account, $settings);
2097
-      drupal_set_message('This user has been banned.');
2095
+        );
2096
+        rules_action_mail_to_user($account, $settings);
2097
+        drupal_set_message('This user has been banned.');
2098 2098
     }
2099
-  }
2100
-  drupal_goto();
2099
+    }
2100
+    drupal_goto();
2101 2101
 }
2102 2102
 
2103 2103
 
@@ -2109,15 +2109,15 @@  discard block
 block discarded – undo
2109 2109
  *
2110 2110
  */
2111 2111
 function boincuser_get_weak_auth($boinc_id = null) {
2112
-  if (!$boinc_id) {
2112
+    if (!$boinc_id) {
2113 2113
     global $user;
2114 2114
     $account = user_load($user->uid);
2115 2115
     $boinc_id = $account->boincuser_id;
2116
-  }
2116
+    }
2117 2117
   
2118
-  $boinc_user = boincuser_load($account->boincuser_id);
2118
+    $boinc_user = boincuser_load($account->boincuser_id);
2119 2119
   
2120
-  return weak_auth($boinc_user);
2120
+    return weak_auth($boinc_user);
2121 2121
 }
2122 2122
 
2123 2123
 /**
@@ -2126,75 +2126,75 @@  discard block
 block discarded – undo
2126 2126
  * Drupal User so must be inserted into comments, etc. (not so by default)
2127 2127
  */
2128 2128
 function boincuser_get_user_profile_image($uid, $avatar = TRUE) {
2129
-  // Though the function name implies otherwise, get the avatar by default
2130
-  $image_field = ($avatar) ? 'field_image_fid' : 'field_profile_image_fid';
2131
-  $image_fid = db_result(db_query("
2129
+    // Though the function name implies otherwise, get the avatar by default
2130
+    $image_field = ($avatar) ? 'field_image_fid' : 'field_profile_image_fid';
2131
+    $image_fid = db_result(db_query("
2132 2132
     SELECT ctp.%s
2133 2133
     FROM {content_type_profile} ctp
2134 2134
     INNER JOIN {node} n ON ctp.nid = n.nid
2135 2135
     WHERE n.uid = %d AND n.type = '%s'",
2136 2136
     $image_field, $uid, 'profile'));
2137
-  $user_image['image'] = field_file_load($image_fid);
2138
-  if (!$user_image['image']['filepath']) {
2137
+    $user_image['image'] = field_file_load($image_fid);
2138
+    if (!$user_image['image']['filepath']) {
2139 2139
     // Load the default image if one does not exist
2140 2140
     $account = user_load($uid);
2141 2141
     if ($avatar AND module_exists('gravatar') AND user_access('use gravatar', $account) AND $account->gravatar) {
2142
-      // Use a Gravatar rather than the system default image
2143
-      $options = array(
2142
+        // Use a Gravatar rather than the system default image
2143
+        $options = array(
2144 2144
         'size' => 100,
2145 2145
         'rating' => 'G',
2146
-      );
2147
-      // Get the Gravatar URL and see if the image exists
2148
-      $url = gravatar_get_gravatar($account->mail, $options);
2149
-      $headers = @get_headers($url);
2150
-      if (preg_match("|200|", $headers[0])) {
2146
+        );
2147
+        // Get the Gravatar URL and see if the image exists
2148
+        $url = gravatar_get_gravatar($account->mail, $options);
2149
+        $headers = @get_headers($url);
2150
+        if (preg_match("|200|", $headers[0])) {
2151 2151
         return $url;
2152
-      }
2152
+        }
2153 2153
     }
2154 2154
     // Get default image if nothing else works
2155 2155
     $content_node_widget_settings = db_result(db_query("SELECT widget_settings FROM {content_node_field_instance} WHERE field_name = '%s'", ($avatar ? 'field_image' : 'field_profile_image')));
2156 2156
     $content_node_widget_settings = unserialize($content_node_widget_settings);
2157 2157
     $user_image['image'] = $content_node_widget_settings['default_image'];
2158
-  }
2159
-  $user = user_load($uid);
2160
-  // Use boinc username for image alt/title attributes
2161
-  $user_image['alt'] = $user->boincuser_name;
2162
-  return $user_image;
2158
+    }
2159
+    $user = user_load($uid);
2160
+    // Use boinc username for image alt/title attributes
2161
+    $user_image['alt'] = $user->boincuser_name;
2162
+    return $user_image;
2163 2163
 }
2164 2164
 
2165 2165
 /**
2166 2166
  * Generate a table of a user's projects
2167 2167
  */
2168 2168
 function boincuser_get_projects_table($account = null) {
2169
-  if ($account AND is_numeric($account)) {
2169
+    if ($account AND is_numeric($account)) {
2170 2170
     $account = user_load($account);
2171
-  }
2172
-  $projects = boincuser_get_projects($account);
2173
-  if (!$projects) return bts('no projects...', array(), NULL, 'boinc:account-dashboard');
2171
+    }
2172
+    $projects = boincuser_get_projects($account);
2173
+    if (!$projects) return bts('no projects...', array(), NULL, 'boinc:account-dashboard');
2174 2174
   
2175
-  $output = '';
2176
-  $output .= '<table class="user-projects">' . "\n";
2177
-  $output .= '<thead>' . "\n";
2178
-  $output .= '  <tr>' . "\n";
2179
-  $output .= '    <th>' . bts('Name', array(), NULL, 'boinc:project-name:-1:ignoreoverwrite') . '</th>' . "\n";
2180
-  $output .= '    <th class="numeric">' . bts('Avg credit', array(), NULL, 'boinc:account-dashboard') . '</th>' . "\n";
2181
-  $output .= '    <th class="numeric">' . bts('Total credit', array(), NULL, 'boinc:user-or-team-total-credits') . '</th>' . "\n";
2182
-  $output .= '  </tr>' . "\n";
2183
-  $output .= '</thead>' . "\n";
2184
-  $output .= '<tbody>' . "\n";
2185
-  foreach ($projects AS $project) {
2175
+    $output = '';
2176
+    $output .= '<table class="user-projects">' . "\n";
2177
+    $output .= '<thead>' . "\n";
2178
+    $output .= '  <tr>' . "\n";
2179
+    $output .= '    <th>' . bts('Name', array(), NULL, 'boinc:project-name:-1:ignoreoverwrite') . '</th>' . "\n";
2180
+    $output .= '    <th class="numeric">' . bts('Avg credit', array(), NULL, 'boinc:account-dashboard') . '</th>' . "\n";
2181
+    $output .= '    <th class="numeric">' . bts('Total credit', array(), NULL, 'boinc:user-or-team-total-credits') . '</th>' . "\n";
2182
+    $output .= '  </tr>' . "\n";
2183
+    $output .= '</thead>' . "\n";
2184
+    $output .= '<tbody>' . "\n";
2185
+    foreach ($projects AS $project) {
2186 2186
     $url = rtrim($project->url, '/') . '/show_user.php?userid=' . $project->id;
2187 2187
     $output .= '  <tr>' . "\n";
2188 2188
     $output .= '    <td>' . l($project->name, $url) . '</td>' . "\n";
2189 2189
     $output .= '    <td class="numeric">' . boincwork_format_stats((float) $project->expavg_credit) . '</td>' . "\n"; 
2190 2190
     $output .= '    <td class="numeric">' . boincwork_format_stats((float) $project->total_credit) . '</td>' . "\n";
2191 2191
     $output .= '  </tr>' . "\n";
2192
-  }
2193
-  $output .= '</tbody>' . "\n";
2194
-  $output .= '</table>' . "\n";
2195
-  $more_link = ($account) ? "user/{$account->uid}/stats" : 'account/stats';
2196
-  //$output .= "<div class=\"more-link\"><a href=\"{$more_link}\">More stats</a></div>" . "\n";
2197
-  return $output;
2192
+    }
2193
+    $output .= '</tbody>' . "\n";
2194
+    $output .= '</table>' . "\n";
2195
+    $more_link = ($account) ? "user/{$account->uid}/stats" : 'account/stats';
2196
+    //$output .= "<div class=\"more-link\"><a href=\"{$more_link}\">More stats</a></div>" . "\n";
2197
+    return $output;
2198 2198
 }
2199 2199
 
2200 2200
 /**
@@ -2202,25 +2202,25 @@  discard block
 block discarded – undo
2202 2202
  */
2203 2203
 function boincuser_get_stats_user_data($cpid = null) {
2204 2204
   
2205
-  // [TODO] Set this stuff in site config!
2206
-  $stats_server = 'stats.gridrepublic.org';
2207
-  $stats_rpc = 'rpc/get_user.php';
2205
+    // [TODO] Set this stuff in site config!
2206
+    $stats_server = 'stats.gridrepublic.org';
2207
+    $stats_rpc = 'rpc/get_user.php';
2208 2208
   
2209
-  // Construct query string
2210
-  $get = array(
2209
+    // Construct query string
2210
+    $get = array(
2211 2211
     'cpid' => $cpid
2212
-  );
2213
-  $args = array();
2214
-  foreach ($get as $arg => $value) $args[] = "{$arg}=" . rawurlencode($value);
2215
-  $query = '?' . implode('&', $args);
2212
+    );
2213
+    $args = array();
2214
+    foreach ($get as $arg => $value) $args[] = "{$arg}=" . rawurlencode($value);
2215
+    $query = '?' . implode('&', $args);
2216 2216
   
2217
-  // Load XML from RPC
2218
-  $target_url = "http://{$stats_server}/{$stats_rpc}{$query}";
2219
-  $result = drupal_http_request($target_url);
2220
-  if (in_array($result->code, array(200, 304))) {
2217
+    // Load XML from RPC
2218
+    $target_url = "http://{$stats_server}/{$stats_rpc}{$query}";
2219
+    $result = drupal_http_request($target_url);
2220
+    if (in_array($result->code, array(200, 304))) {
2221 2221
     return simplexml_load_string($result->data);
2222
-  }
2223
-  return NULL;
2222
+    }
2223
+    return NULL;
2224 2224
 }
2225 2225
 
2226 2226
 /**
@@ -2228,15 +2228,15 @@  discard block
 block discarded – undo
2228 2228
  */
2229 2229
 function boincuser_get_projects($account = null) {
2230 2230
   
2231
-  // Use the current user by default
2232
-  if (!$account) {
2231
+    // Use the current user by default
2232
+    if (!$account) {
2233 2233
     global $user;
2234 2234
     $account = user_load($user->uid);
2235
-  }
2235
+    }
2236 2236
   
2237
-  $account_stats = boincuser_get_stats_user_data($account->boincuser_cpid);
2237
+    $account_stats = boincuser_get_stats_user_data($account->boincuser_cpid);
2238 2238
   
2239
-  return ($account_stats AND isset($account_stats->project)) ? $account_stats->project : null;
2239
+    return ($account_stats AND isset($account_stats->project)) ? $account_stats->project : null;
2240 2240
 }
2241 2241
 
2242 2242
 
@@ -2244,11 +2244,11 @@  discard block
 block discarded – undo
2244 2244
  * Get the links to display under the user profile
2245 2245
  */
2246 2246
 function boincuser_get_profile_links($uid) {
2247
-  global $user;
2248
-  $account = user_load($uid);
2249
-  $profile = content_profile_load('profile', $account->uid);
2250
-  $output = '';
2251
-  if ($profile) {
2247
+    global $user;
2248
+    $account = user_load($uid);
2249
+    $profile = content_profile_load('profile', $account->uid);
2250
+    $output = '';
2251
+    if ($profile) {
2252 2252
     $profile_is_approved = ($profile->status AND !$profile->moderate);
2253 2253
     $user_is_moderator = user_access('edit any profile content');
2254 2254
     $is_own_profile = ($user->uid == $account->uid);
@@ -2256,15 +2256,15 @@  discard block
 block discarded – undo
2256 2256
     $links = array();
2257 2257
     
2258 2258
     if ($profile->moderate AND $user_is_moderator) {
2259
-      $links['approve_profile'] = array(
2259
+        $links['approve_profile'] = array(
2260 2260
         'title' => bts('Approve profile', array(), NULL, 'boinc:moderate-user'),
2261 2261
         'href' => "{$profile_moderation_path}/approve",
2262 2262
         'attributes' => array(
2263
-          'title' => bts('Approve this profile content', array(), NULL, 'boinc:moderate-user'),
2264
-          'class' => 'first primary tab',
2263
+            'title' => bts('Approve this profile content', array(), NULL, 'boinc:moderate-user'),
2264
+            'class' => 'first primary tab',
2265 2265
         )
2266
-      );
2267
-      /*$links['edit_profile'] = array(
2266
+        );
2267
+        /*$links['edit_profile'] = array(
2268 2268
         'title' => bts('Edit profile', array(), NULL, 'boinc:moderate-user'),
2269 2269
         'href' => "{$profile_moderation_path}/edit",
2270 2270
         'attributes' => array(
@@ -2272,27 +2272,27 @@  discard block
 block discarded – undo
2272 2272
           'class' => 'tab',
2273 2273
         )
2274 2274
       );*/
2275
-      $links['reject_profile'] = array(
2275
+        $links['reject_profile'] = array(
2276 2276
         'title' => bts('Reject profile', array(), NULL, 'boinc:moderate-user'),
2277 2277
         'href' => "{$profile_moderation_path}/reject",
2278 2278
         'attributes' => array(
2279
-          'title' => bts('Reject this profile content', array(), NULL, 'boinc:moderate-user'),
2280
-          'class' => 'tab',
2279
+            'title' => bts('Reject this profile content', array(), NULL, 'boinc:moderate-user'),
2280
+            'class' => 'tab',
2281 2281
         )
2282
-      );
2282
+        );
2283 2283
     }
2284 2284
     $output .= '<ul class="tab-list">';
2285 2285
     $count = 0;
2286 2286
     foreach ($links as $key => $link) {
2287
-      $output .= '<li class="' . (($count == 0) ? 'first primary ' : '') . 'tab">';
2288
-      $output .= l($link['title'], $link['href'], array('query' => drupal_get_destination()));
2289
-      $output .= '</li>';
2290
-      $count++;
2287
+        $output .= '<li class="' . (($count == 0) ? 'first primary ' : '') . 'tab">';
2288
+        $output .= l($link['title'], $link['href'], array('query' => drupal_get_destination()));
2289
+        $output .= '</li>';
2290
+        $count++;
2291 2291
     }
2292 2292
     $output .= '<li class="' . (($count) ? '' : 'first ') . 'last tab">' . flag_create_link('abuse_user', $account->uid) . '</li>';
2293 2293
     $output .= '</ul>';
2294
-  }
2295
-  return $output;
2294
+    }
2295
+    return $output;
2296 2296
 /*
2297 2297
 <ul class="tab-list">
2298 2298
   <li class="primary first tab">
@@ -2329,36 +2329,36 @@  discard block
 block discarded – undo
2329 2329
  */
2330 2330
 function boincuser_apachesolr_index_documents_alter(array &$documents, $entity, $entity_type, $env_id) {
2331 2331
 
2332
-  foreach ($documents as $document) {
2332
+    foreach ($documents as $document) {
2333 2333
     if ( $document->entity_type=='node' AND $document->bundle=='profile' ) {
2334
-      // Node information.
2335
-      $nid = $document->entity_id;
2336
-      $node = node_load($nid);
2337
-      $account = user_load($node->uid);
2338
-
2339
-      // Use boincuser name and not drupal user name
2340
-      $document->label = apachesolr_clean_text($account->boincuser_name);
2341
-      // Author information
2342
-      if ($node->uid == 0 || strlen($node->name) == 0) {
2334
+        // Node information.
2335
+        $nid = $document->entity_id;
2336
+        $node = node_load($nid);
2337
+        $account = user_load($node->uid);
2338
+
2339
+        // Use boincuser name and not drupal user name
2340
+        $document->label = apachesolr_clean_text($account->boincuser_name);
2341
+        // Author information
2342
+        if ($node->uid == 0 || strlen($node->name) == 0) {
2343 2343
         // @see user_validate_name(). !'0' === TRUE.
2344 2344
         $document->ss_name = '0';
2345
-      }
2346
-      else {
2345
+        }
2346
+        else {
2347 2347
         $document->ss_name = $account->boincuser_name;
2348 2348
         // We want the name to be searchable for keywords.
2349 2349
         $document->tos_name = $account->boincuser_name;
2350
-      }
2350
+        }
2351 2351
 
2352
-      // Rename "Profle" to "User"
2353
-      $document->bundle = "User";
2354
-      $document->bundle_name = "User";
2352
+        // Rename "Profle" to "User"
2353
+        $document->bundle = "User";
2354
+        $document->bundle_name = "User";
2355 2355
 
2356
-      // Replace the Solr document's created field with the date the user 
2357
-      // account was created. This replaces the node creation date typically 
2358
-      // used for indexing nodes.
2359
-      $document->ds_created = apachesolr_date_iso($account->created);
2356
+        // Replace the Solr document's created field with the date the user 
2357
+        // account was created. This replaces the node creation date typically 
2358
+        // used for indexing nodes.
2359
+        $document->ds_created = apachesolr_date_iso($account->created);
2360
+    }
2360 2361
     }
2361
-  }
2362 2362
 
2363 2363
 }
2364 2364
 
@@ -2370,23 +2370,23 @@  discard block
 block discarded – undo
2370 2370
  * Implementation of hook_privatemsg_name_lookup();
2371 2371
  */
2372 2372
 function boincuser_privatemsg_name_lookup($string) {
2373
-  // Get the BOINC ID from the name string, and lookup the
2374
-  // corresponding drupal user.
2375
-  $boincname = substr($string, 0, strrpos($string, '_'));
2376
-  $boincid = substr($string, strrpos($string, '_') + 1);
2377
-  $drupalid = get_drupal_id($boincid);
2378
-
2379
-  // Name has spaced replaced with special UTF-8 characters in
2380
-  // privatemsg module. We need to convert them back to spaces for the
2381
-  // check below.
2382
-  $boincname = preg_replace("/\\xc2\\xa0/", " ", $boincname);
2383
-  if ($drupalid>0) {
2373
+    // Get the BOINC ID from the name string, and lookup the
2374
+    // corresponding drupal user.
2375
+    $boincname = substr($string, 0, strrpos($string, '_'));
2376
+    $boincid = substr($string, strrpos($string, '_') + 1);
2377
+    $drupalid = get_drupal_id($boincid);
2378
+
2379
+    // Name has spaced replaced with special UTF-8 characters in
2380
+    // privatemsg module. We need to convert them back to spaces for the
2381
+    // check below.
2382
+    $boincname = preg_replace("/\\xc2\\xa0/", " ", $boincname);
2383
+    if ($drupalid>0) {
2384 2384
     if ($recipient = user_load(array('uid' => $drupalid))) {
2385
-      // Double-check that the loaded user matches both boincuser_id
2386
-      // and boincuser_name.
2387
-      if ( ($boincid == $recipient->boincuser_id) AND ($boincname == $recipient->boincuser_name) ) {
2385
+        // Double-check that the loaded user matches both boincuser_id
2386
+        // and boincuser_name.
2387
+        if ( ($boincid == $recipient->boincuser_id) AND ($boincname == $recipient->boincuser_name) ) {
2388 2388
         return $recipient;
2389
-      }
2389
+        }
2390
+    }
2390 2391
     }
2391
-  }
2392 2392
 }
Please login to merge, or discard this patch.
default/boinc/modules/boincuser/boincuser_delete/boincuser_delete.module 1 patch
Indentation   +263 added lines, -263 removed lines patch added patch discarded remove patch
@@ -19,15 +19,15 @@  discard block
 block discarded – undo
19 19
  * Implementation of hook_perm().
20 20
  */
21 21
 function boincuser_delete_perm() {
22
-  return array('delete own account');
22
+    return array('delete own account');
23 23
 }
24 24
 
25 25
 /**
26 26
  * Implementation of hook_menu().
27 27
  */
28 28
 function boincuser_delete_menu() {
29
-  $items = array();
30
-  $items['admin/boinc/user_delete'] = array(
29
+    $items = array();
30
+    $items['admin/boinc/user_delete'] = array(
31 31
     'title' => t('Preferences: BOINC user delete'),
32 32
     'description' => t('Configure the BOINC user delete action.'),
33 33
     'page callback' => 'drupal_get_form',
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
     'access arguments' => array('administer users'),
36 36
     'type' => MENU_NORMAL_ITEM,
37 37
     'file' => 'boincuser_delete.admin.inc',
38
-  );
38
+    );
39 39
 
40
-  $items['admin/boinc/user_delete/%'] = array(
40
+    $items['admin/boinc/user_delete/%'] = array(
41 41
     'title' => t('Admin delete user'),
42 42
     'description' => t('Deletes a user as an admin'),
43 43
     'page callback' => 'drupal_get_form',
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
     'access arguments' => array('administer users'),
46 46
     'type' => MENU_CALLBACK,
47 47
     'file' => 'boincuser_delete.admin.inc',
48
-  );
48
+    );
49 49
 
50
-  $items['user/%user/deleteconfirm/%'] = array(
50
+    $items['user/%user/deleteconfirm/%'] = array(
51 51
     'title' => t('Final confirmation for account deletion'),
52 52
     'description' => t('Final confirmation for account deletion'),
53 53
     'page callback' => 'drupal_get_form',
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
     'access callback' => 'boincuser_delete_access',
56 56
     'access arguments' => array(1),
57 57
     'type' => MENU_CALLBACK,
58
-  );
58
+    );
59 59
 
60
-  $items['user/%user/odeleteconfirm/%'] = array(
60
+    $items['user/%user/odeleteconfirm/%'] = array(
61 61
     'title' => t('Final confirmation for account deletion'),
62 62
     'description' => t('Final confirmation for account deletion'),
63 63
     'page callback' => 'drupal_get_form',
@@ -65,204 +65,204 @@  discard block
 block discarded – undo
65 65
     'access callback' => 'boincuser_delete_access',
66 66
     'access arguments' => array(1),
67 67
     'type' => MENU_CALLBACK,
68
-  );
68
+    );
69 69
 
70
-  return $items;
70
+    return $items;
71 71
 }
72 72
 
73 73
 /**
74 74
  * Checks whether a user can delete an account.
75 75
  */
76 76
 function boincuser_delete_access($account) {
77
-  global $user;
78
-  return ((user_access('administer users') || (user_access('delete own account') && $account->uid == $user->uid)) && $account->uid > 0);
77
+    global $user;
78
+    return ((user_access('administer users') || (user_access('delete own account') && $account->uid == $user->uid)) && $account->uid > 0);
79 79
 }
80 80
 
81 81
 /**
82 82
  * Implementation of hook_menu_alter().
83 83
  */
84 84
 function boincuser_delete_menu_alter(&$callbacks) {
85
-  $callbacks['user/%user/delete']['access callback'] = 'boincuser_delete_access';
86
-  $callbacks['user/%user/delete']['access arguments'] = array(1);
87
-  $callbacks['user/%user/delete']['type'] = MENU_CALLBACK;
85
+    $callbacks['user/%user/delete']['access callback'] = 'boincuser_delete_access';
86
+    $callbacks['user/%user/delete']['access arguments'] = array(1);
87
+    $callbacks['user/%user/delete']['type'] = MENU_CALLBACK;
88 88
 }
89 89
 
90 90
 /**
91 91
  * Implementation of hook_form_alter().
92 92
  */
93 93
 function boincuser_delete_form_alter(&$form, $form_state, $form_id) {
94
-  global $user;
94
+    global $user;
95 95
 
96
-  switch($form_id) {
96
+    switch($form_id) {
97 97
     case 'user_profile_form':
98 98
       if ( user_access('delete own account') AND ($form['#uid'] == $user->uid) AND (arg(3)=='') ) {
99 99
         $form['delete'] = array(
100
-          '#type' => 'submit',
101
-          '#value' => bts('Delete Account', array(), null, 'boinc:delete-user-account'),
102
-          '#weight' => 1009,
103
-          '#submit' => array('user_edit_delete_submit'),
104
-          '#prefix' => '<li class="tab">',
105
-          '#suffix' => '</li>',
100
+            '#type' => 'submit',
101
+            '#value' => bts('Delete Account', array(), null, 'boinc:delete-user-account'),
102
+            '#weight' => 1009,
103
+            '#submit' => array('user_edit_delete_submit'),
104
+            '#prefix' => '<li class="tab">',
105
+            '#suffix' => '</li>',
106 106
         );
107
-      }
108
-      else if ( user_access('administer users') ) {
107
+        }
108
+        else if ( user_access('administer users') ) {
109 109
         $form['delete'] = array(
110
-          '#type' => 'submit',
111
-          '#value' => bts('Delete Account', array(), null, 'boinc:delete-user-account'),
112
-          '#weight' => 1009,
113
-          '#submit' => array('_boincuser_delete_goto_admindelete'),
114
-          '#prefix' => '<li class="tab">',
115
-          '#suffix' => '</li>',
110
+            '#type' => 'submit',
111
+            '#value' => bts('Delete Account', array(), null, 'boinc:delete-user-account'),
112
+            '#weight' => 1009,
113
+            '#submit' => array('_boincuser_delete_goto_admindelete'),
114
+            '#prefix' => '<li class="tab">',
115
+            '#suffix' => '</li>',
116 116
         );
117
-      }
118
-      else {
117
+        }
118
+        else {
119 119
         unset($form['delete']);
120
-      }
121
-      break;
120
+        }
121
+        break;
122 122
     case 'user_confirm_delete':
123 123
 
124 124
       $disable_delete = FALSE;
125
-      // If email address was changed less than 7 days (7 * 86400 s)
126
-      // ago, it cannot be changed again.
127
-      $duration = TOKEN_DURATION_ONE_WEEK;
128
-      if (($form['_account']['#value']->boincuser_email_addr_change_time + $duration) > time()) {
125
+        // If email address was changed less than 7 days (7 * 86400 s)
126
+        // ago, it cannot be changed again.
127
+        $duration = TOKEN_DURATION_ONE_WEEK;
128
+        if (($form['_account']['#value']->boincuser_email_addr_change_time + $duration) > time()) {
129 129
         drupal_set_message(
130
-          bts("INFO: Your email address was changed within the past seven (7) days. You may not delete your account until after !time.",
130
+            bts("INFO: Your email address was changed within the past seven (7) days. You may not delete your account until after !time.",
131 131
             array(
132
-              '!time' => date('F j, Y \a\t G:i T', $form['_account']['#value']->boincuser_email_addr_change_time + $duration),
132
+                '!time' => date('F j, Y \a\t G:i T', $form['_account']['#value']->boincuser_email_addr_change_time + $duration),
133 133
             ), NULL, 'boinc:account-credentials-change')
134 134
         , 'info');
135 135
         $disable_delete = TRUE;
136
-      }
136
+        }
137 137
 
138
-      // Configure radio options
139
-      $common_acts = bts("All your posts and comments will be attributed to the Anonymous User. Your user profile will be deleted. Your host information will be deleted. And you will be removed from any team you are a member of.", array(), NULL, 'boinc:delete-user-account');
138
+        // Configure radio options
139
+        $common_acts = bts("All your posts and comments will be attributed to the Anonymous User. Your user profile will be deleted. Your host information will be deleted. And you will be removed from any team you are a member of.", array(), NULL, 'boinc:delete-user-account');
140 140
 
141
-      $deleteoptions = array(
141
+        $deleteoptions = array(
142 142
         'boincuser_delete_softdelete' => bts('<b>Soft delete</b> your account. Your account will be disabled. ', array(), NULL, 'boinc:delete-user-account'),
143 143
         'boincuser_delete_delete' => bts('<b>Delete</b> your account. ', array(), NULL, 'boinc:delete-user-account'),
144
-      );
144
+        );
145 145
 
146
-      $dtypes = variable_get('boincuser_delete_type', 'user_decides');
147
-      // Unset the other option if dtype is set. i.e., if dtype is set
148
-      // to soft delete, unset the hard delete option.  Likewise, add
149
-      // the 'common_acts' sentences to the option that remains.
150
-      switch ($dtypes) {
146
+        $dtypes = variable_get('boincuser_delete_type', 'user_decides');
147
+        // Unset the other option if dtype is set. i.e., if dtype is set
148
+        // to soft delete, unset the hard delete option.  Likewise, add
149
+        // the 'common_acts' sentences to the option that remains.
150
+        switch ($dtypes) {
151 151
         case 'soft_obfuscate':
152 152
           unset($deleteoptions['boincuser_delete_delete']);
153
-          $deleteoptions['boincuser_delete_softdelete'] .= $common_acts;
154
-          break;
153
+            $deleteoptions['boincuser_delete_softdelete'] .= $common_acts;
154
+            break;
155 155
         case 'hard_wipe':
156 156
           unset($deleteoptions['boincuser_delete_softdelete']);
157
-          $deleteoptions['boincuser_delete_delete'] .= $common_acts;
158
-          break;
159
-      }
157
+            $deleteoptions['boincuser_delete_delete'] .= $common_acts;
158
+            break;
159
+        }
160 160
 
161
-      $question = 'Are you sure you want to delete the account <em>' . htmlspecialchars($form['_account']['#value']->boincuser_name) . '</em>?';
162
-      drupal_set_title($question);
161
+        $question = 'Are you sure you want to delete the account <em>' . htmlspecialchars($form['_account']['#value']->boincuser_name) . '</em>?';
162
+        drupal_set_title($question);
163 163
 
164
-      unset($form['description']);
164
+        unset($form['description']);
165 165
 
166
-      $form['main'] = array(
166
+        $form['main'] = array(
167 167
         '#type' => 'fieldset',
168 168
         '#weight' => 1,
169
-      );
169
+        );
170 170
 
171
-      $form['main']['fs1'] = array(
171
+        $form['main']['fs1'] = array(
172 172
         '#type' => 'fieldset',
173 173
         '#title' => bts('Instructions', array(), NULL, 'boinc:delete-user-account'),
174 174
         '#weight' => 10,
175 175
         '#collapsible' => TRUE,
176 176
         '#collapsed' => TRUE,
177
-      );
178
-      $form['main']['fs1']['help'] = array(
177
+        );
178
+        $form['main']['fs1']['help'] = array(
179 179
         '#value' => bts(
180
-          "<p>In order to delete your account, you must provide your password below. You will then be sent an email to the email address on record, with a one-time token that expires in 24-hours. Clicking on this link will bring you to a second form where you must enter your password again. After doing so your account will be deleted.</p>" .
181
-          "<p>If necessary, you may !link first before deleting your account. But you must wait <b>seven (7) days</b> after an email address change before you may delete your account.</p>",
182
-          array(
180
+            "<p>In order to delete your account, you must provide your password below. You will then be sent an email to the email address on record, with a one-time token that expires in 24-hours. Clicking on this link will bring you to a second form where you must enter your password again. After doing so your account will be deleted.</p>" .
181
+            "<p>If necessary, you may !link first before deleting your account. But you must wait <b>seven (7) days</b> after an email address change before you may delete your account.</p>",
182
+            array(
183 183
             '!link' => l(bts('change your email address', array(), NULL, 'boinc:delete-user-account'), '/account/info/edit'),
184
-          ), NULL, 'boinc:delete-user-account'),
184
+            ), NULL, 'boinc:delete-user-account'),
185 185
         '#weight' => 11,
186 186
         '#prefix' => "<div id='delete-instructions'>",
187 187
         '#suffix' => "</div>",
188
-      );
188
+        );
189 189
 
190
-      if ($dtypes == 'user_decides') {
190
+        if ($dtypes == 'user_decides') {
191 191
         $form['main']['common'] = array(
192
-          '#value'  => bts('All choices: ', array(), NULL, 'boinc:delete-user-account') . $common_acts . '<p>' . bts('Disabled means some of your personal data, such as your username and email address, are kept on our systems. Choose \'delete your account\' if you want all personal data to be removed.', array(), NULL, 'boinc:delete-user-account'),
193
-          '#prefix' => "<div id='delete-instructions'>",
194
-          '#suffix' => "</div>",
195
-          '#weight' => 20,
192
+            '#value'  => bts('All choices: ', array(), NULL, 'boinc:delete-user-account') . $common_acts . '<p>' . bts('Disabled means some of your personal data, such as your username and email address, are kept on our systems. Choose \'delete your account\' if you want all personal data to be removed.', array(), NULL, 'boinc:delete-user-account'),
193
+            '#prefix' => "<div id='delete-instructions'>",
194
+            '#suffix' => "</div>",
195
+            '#weight' => 20,
196 196
         );
197
-      }
197
+        }
198 198
 
199
-      $form['main']['user_delete_action'] = array(
199
+        $form['main']['user_delete_action'] = array(
200 200
         '#type' => 'radios',
201 201
         '#options' => $deleteoptions,
202 202
         '#weight' => 21,
203
-      );
204
-      if ($disable_delete) {
203
+        );
204
+        if ($disable_delete) {
205 205
         $form['main']['user_delete_action']['#disabled'] = TRUE;
206
-      }
206
+        }
207 207
 
208
-      // Password field
209
-      if (!$disable_delete) {
208
+        // Password field
209
+        if (!$disable_delete) {
210 210
         $form['main']['current_pass'] = array(
211
-          '#type' => 'password',
212
-          '#title' => bts('Enter your password to delete your account', array(), NULL, 'boinc:delete-user-account'),
213
-          '#size' => 17,
214
-          '#attributes' => array(
211
+            '#type' => 'password',
212
+            '#title' => bts('Enter your password to delete your account', array(), NULL, 'boinc:delete-user-account'),
213
+            '#size' => 17,
214
+            '#attributes' => array(
215 215
             'autocomplete' => 'off',
216
-          ),
217
-          '#prefix' => "<div id='delete-password-field'>",
218
-          '#suffix' => "</div>",
219
-          '#weight' => 25,
216
+            ),
217
+            '#prefix' => "<div id='delete-password-field'>",
218
+            '#suffix' => "</div>",
219
+            '#weight' => 25,
220 220
         );
221
-      }
221
+        }
222 222
 
223
-      $form['separator_bottom'] = array(
223
+        $form['separator_bottom'] = array(
224 224
         '#value' => '<div class="separator buttons"></div>',
225 225
         '#weight' => 999,
226
-      );
226
+        );
227 227
 
228
-      // Configure the action buttons
229
-      $uid = $form['_account']['#value']->uid;
230
-      $form['actions']['#weight'] = 1000;
231
-      $form['actions']['form control tabs prefix'] = array(
228
+        // Configure the action buttons
229
+        $uid = $form['_account']['#value']->uid;
230
+        $form['actions']['#weight'] = 1000;
231
+        $form['actions']['form control tabs prefix'] = array(
232 232
         '#value' => '<ul class="form-control tab-list">',
233 233
         '#weight' => 1001,
234
-      );
235
-
236
-      unset($form['actions']['#prefix']);
237
-      unset($form['actions']['#suffix']);
238
-      $form['actions']['submit']['#prefix'] = '<li class="first tab">';
239
-      $form['actions']['submit']['#suffix'] = '</li>';
240
-      $form['actions']['submit']['#value'] = bts('Submit', array(), NULL, 'boinc:form-submit');
241
-      $form['actions']['submit']['#weight'] = 1002;
242
-      if ($disable_delete) {
234
+        );
235
+
236
+        unset($form['actions']['#prefix']);
237
+        unset($form['actions']['#suffix']);
238
+        $form['actions']['submit']['#prefix'] = '<li class="first tab">';
239
+        $form['actions']['submit']['#suffix'] = '</li>';
240
+        $form['actions']['submit']['#value'] = bts('Submit', array(), NULL, 'boinc:form-submit');
241
+        $form['actions']['submit']['#weight'] = 1002;
242
+        if ($disable_delete) {
243 243
         $form['actions']['submit']['#disabled'] = TRUE;
244 244
         $form['actions']['submit']['#value'] = '';
245
-      }
245
+        }
246 246
 
247
-      $form['actions']['cancel']['#prefix'] = '<li class="tab">';
248
-      $form['actions']['cancel']['#suffix'] = '</li>';
249
-      $form['actions']['cancel']['#weight'] = 1003;
250
-      $form['actions']['cancel']['#value'] = l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'account/info/edit');
251
-      if ($disable_delete) {
247
+        $form['actions']['cancel']['#prefix'] = '<li class="tab">';
248
+        $form['actions']['cancel']['#suffix'] = '</li>';
249
+        $form['actions']['cancel']['#weight'] = 1003;
250
+        $form['actions']['cancel']['#value'] = l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'account/info/edit');
251
+        if ($disable_delete) {
252 252
         $form['actions']['cancel']['#prefix'] = '<li class="first tab">';
253
-      }
253
+        }
254 254
 
255
-      $form['actions']['form control tabs suffix'] = array(
255
+        $form['actions']['form control tabs suffix'] = array(
256 256
         '#value' => '</ul>',
257 257
         '#weight' => 1010,
258
-      );
258
+        );
259 259
 
260
-      $form['#redirect'] = 'account/' . $uid;
261
-      $form['#validate'] = array('boincuser_delete_validate');
262
-      $form['#submit'] = array('boincuser_delete_submit');
263
-      break;
260
+        $form['#redirect'] = 'account/' . $uid;
261
+        $form['#validate'] = array('boincuser_delete_validate');
262
+        $form['#submit'] = array('boincuser_delete_submit');
263
+        break;
264 264
 
265
-  } // switch
265
+    } // switch
266 266
 }
267 267
 
268 268
 
@@ -273,24 +273,24 @@  discard block
 block discarded – undo
273 273
  * password.
274 274
  */
275 275
 function boincuser_delete_validate($form, &$form_state) {
276
-  require_boinc('boinc_db');
276
+    require_boinc('boinc_db');
277 277
 
278
-  if ($form_state['values']['user_delete_action'] == '') {
278
+    if ($form_state['values']['user_delete_action'] == '') {
279 279
     form_set_error('user_delete_action', bts('Please select an action to perform using the radio buttons.', array(), NULL, 'boinc:delete-user-account'));
280
-  }
280
+    }
281 281
 
282
-  // check BOINC user exists
283
-  $account = $form_state['values']['_account'];
284
-  $boinc_user = boincuser_load($account->uid, TRUE);
285
-  if (!$boinc_user) {
282
+    // check BOINC user exists
283
+    $account = $form_state['values']['_account'];
284
+    $boinc_user = boincuser_load($account->uid, TRUE);
285
+    if (!$boinc_user) {
286 286
     return form_set_error('current_pass',
287
-      bts('There was a problem deleting your account. Please contact the site administrators.', array(), NULL, 'boinc:delete-user-account')
287
+        bts('There was a problem deleting your account. Please contact the site administrators.', array(), NULL, 'boinc:delete-user-account')
288 288
     );
289
-  }
289
+    }
290 290
 
291
-  if (_boincuser_delete_validatepasswd($boinc_user, $form_state['values']['current_pass'])) {
291
+    if (_boincuser_delete_validatepasswd($boinc_user, $form_state['values']['current_pass'])) {
292 292
     return true;
293
-  }
293
+    }
294 294
 }
295 295
 
296 296
 /**
@@ -301,39 +301,39 @@  discard block
 block discarded – undo
301 301
  * to delete the account.
302 302
  */
303 303
 function boincuser_delete_submit($form, &$form_state) {
304
-  require_boinc('token');
305
-  global $user;
304
+    require_boinc('token');
305
+    global $user;
306 306
 
307
-  $uid = $form_state['values']['_account']->uid;
308
-  $account = user_load(array('uid' => $uid));
307
+    $uid = $form_state['values']['_account']->uid;
308
+    $account = user_load(array('uid' => $uid));
309 309
 
310
-  if (!$account) {
310
+    if (!$account) {
311 311
     drupal_set_message(bts('ERROR: The user account @uid does not exist.', array('@uid' => $uid), array(), NULL, 'delete-user-account'), 'error');
312 312
     watchdog('user', 'Attempted to cancel non-existing user account UID: %uid.', array('%uid' => $uid), WATCHDOG_ERROR);
313 313
     return;
314
-  }
315
-
316
-  global $base_url;
317
-  global $base_path;
318
-  module_load_include('inc', 'rules', 'modules/system.rules');
319
-  $site_name = variable_get('site_name', 'Drupal-BOINC');
320
-  $site_url = $base_url . $base_path . "user/login";
321
-
322
-  // Perform the requested operation
323
-  $op = $form_state['values']['user_delete_action'];
324
-  // create token with 1 day/24 hour expiration
325
-  $mytoken = create_token($account->boincuser_id, 'D', 24*60*60);
326
-  switch ($op) {
314
+    }
315
+
316
+    global $base_url;
317
+    global $base_path;
318
+    module_load_include('inc', 'rules', 'modules/system.rules');
319
+    $site_name = variable_get('site_name', 'Drupal-BOINC');
320
+    $site_url = $base_url . $base_path . "user/login";
321
+
322
+    // Perform the requested operation
323
+    $op = $form_state['values']['user_delete_action'];
324
+    // create token with 1 day/24 hour expiration
325
+    $mytoken = create_token($account->boincuser_id, 'D', 24*60*60);
326
+    switch ($op) {
327 327
     case 'boincuser_delete_softdelete':
328 328
       $myurl = "${base_url}/user/{$account->uid}/odeleteconfirm/$mytoken";
329
-      break;
329
+        break;
330 330
     case 'boincuser_delete_delete':
331 331
       $myurl = "${base_url}/user/{$account->uid}/deleteconfirm/$mytoken";
332
-      break;
333
-  }
332
+        break;
333
+    }
334 334
 
335
-  $mysubject = "Instructions for account deletion at {$site_name}";
336
-  $mymessage = ''
335
+    $mysubject = "Instructions for account deletion at {$site_name}";
336
+    $mymessage = ''
337 337
     . "{$account->boincuser_name},\n"
338 338
     . "\n"
339 339
     . "We have received a request to DELETE your user account at "
@@ -355,25 +355,25 @@  discard block
 block discarded – undo
355 355
     . "\n"
356 356
     . "{$site_name} support team";
357 357
 
358
-  // Create array for sending email to user to notify account is being
359
-  // disabled/deleted. Then send email.
360
-  $settings = array(
358
+    // Create array for sending email to user to notify account is being
359
+    // disabled/deleted. Then send email.
360
+    $settings = array(
361 361
     'from' => '',
362 362
     'subject' => $mysubject,
363 363
     'message' => $mymessage,
364
-  );
365
-  rules_action_mail_to_user($account, $settings);
364
+    );
365
+    rules_action_mail_to_user($account, $settings);
366 366
 
367
-  drupal_set_message(bts("INFO: You have requested account deletion. Please check your email for further instructions.", array(), NULL, 'boinc:delete-user-account'),'info');
367
+    drupal_set_message(bts("INFO: You have requested account deletion. Please check your email for further instructions.", array(), NULL, 'boinc:delete-user-account'),'info');
368 368
 
369
-  $redirect = variable_get('boincuser_delete_redirect', '<front>');
370
-  // Redirect
371
-  if (!empty($redirect)) {
369
+    $redirect = variable_get('boincuser_delete_redirect', '<front>');
370
+    // Redirect
371
+    if (!empty($redirect)) {
372 372
     drupal_goto($redirect);
373
-  }
374
-  else {
373
+    }
374
+    else {
375 375
     drupal_goto();
376
-  }
376
+    }
377 377
 }
378 378
 
379 379
 
@@ -385,88 +385,88 @@  discard block
 block discarded – undo
385 385
  * The final confirmation form for the user to delete their account.
386 386
  */
387 387
 function boincuser_delete_finalconfirmation(&$form_state, $token) {
388
-  require_boinc('token');
388
+    require_boinc('token');
389 389
 
390
-  global $user;
391
-  $form = array();
390
+    global $user;
391
+    $form = array();
392 392
 
393
-  // check BOINC user exists
394
-  $account = user_load(array('uid' => $user->uid));
395
-  $uid = $user->uid;
396
-  $boincid = $account->boincuser_id;
397
-  // check $token is valid
398
-  if (!is_valid_token($boincid, $token, 'D')) {
393
+    // check BOINC user exists
394
+    $account = user_load(array('uid' => $user->uid));
395
+    $uid = $user->uid;
396
+    $boincid = $account->boincuser_id;
397
+    // check $token is valid
398
+    if (!is_valid_token($boincid, $token, 'D')) {
399 399
     drupal_set_message(bts('ERROR: You have supplied an incorrect (most likely expired) token. Please obtain a new token by !link your account be deleted.',
400 400
     array(
401
-      '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"),
401
+        '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"),
402 402
     ),
403 403
     NULL, 'boinc:delete-user-account'), 'error');
404 404
     drupal_goto();
405
-  }
405
+    }
406 406
 
407
-  // Attach account to this form.
408
-  $form['_account'] = array('#type' => 'value', '#value' => $account);
407
+    // Attach account to this form.
408
+    $form['_account'] = array('#type' => 'value', '#value' => $account);
409 409
 
410
-  // This form is for hard/wipe delete
411
-  $form['_action'] = array('#type' => 'value', '#value' => 'hard_wipe');
410
+    // This form is for hard/wipe delete
411
+    $form['_action'] = array('#type' => 'value', '#value' => 'hard_wipe');
412 412
 
413
-  // Instructions
414
-  $form['main']['fs1'] = array(
413
+    // Instructions
414
+    $form['main']['fs1'] = array(
415 415
     '#type' => 'fieldset',
416 416
     '#title' => bts('Instructions', array(), NULL, 'boinc:delete-user-account'),
417 417
     '#weight' => 10,
418 418
     '#collapsible' => TRUE,
419 419
     '#collapsed' => TRUE,
420
-  );
421
-  $form['main']['fs1']['instructions1'] = array(
420
+    );
421
+    $form['main']['fs1']['instructions1'] = array(
422 422
     '#value' => '<p>'.
423 423
     bts('You are one-step away from deleting your account. Enter your password in the textbox below and click submit. This action is irreversable: once you delete your account, there is no way un-delete.', array(), NULL, 'boinc:delete-user-account').
424 424
     '</p>',
425 425
     '#prefix' => "<div id='delete-instructions'>",
426 426
     '#suffix' => "</div>",
427
-  );
427
+    );
428 428
 
429
-  $form['main']['fs1']['instructions2'] = array(
429
+    $form['main']['fs1']['instructions2'] = array(
430 430
     '#value' => '<p>'.
431 431
     bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account').
432 432
     '</p>',
433 433
     '#prefix' => "<div id='delete-instructions'>",
434 434
     '#suffix' => "</div>",
435
-  );
435
+    );
436 436
 
437
-  // Password field
438
-  $form['main']['current_pass'] = array(
437
+    // Password field
438
+    $form['main']['current_pass'] = array(
439 439
     '#type' => 'password',
440 440
     '#title' => bts('Enter your password to delete your account', array(), NULL, 'boinc:delete-user-account'),
441 441
     '#size' => 17,
442 442
     '#attributes' => array(
443
-      'autocomplete' => 'off',
443
+        'autocomplete' => 'off',
444 444
     ),
445 445
     '#weight' => 25,
446
-  );
446
+    );
447 447
 
448
-  // Form control
449
-  $form['form control tabs prefix'] = array(
448
+    // Form control
449
+    $form['form control tabs prefix'] = array(
450 450
     '#value' => '<ul class="form-control tab-list">',
451 451
     '#weight' => 1001,
452
-  );
453
-  $form['submit'] = array(
452
+    );
453
+    $form['submit'] = array(
454 454
     '#prefix' => '<li class="first tab">',
455 455
     '#type' => 'submit',
456 456
     '#value' => bts('Submit', array(), NULL, 'boinc:form-submit'),
457 457
     '#suffix' => '</li>',
458 458
     '#weight' => 1002,
459
-  );
460
-  $form['form control tabs'] = array(
459
+    );
460
+    $form['form control tabs'] = array(
461 461
     '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>',
462 462
     '#weight' => 1003,
463
-  );
464
-  $form['form control tabs suffix'] = array(
463
+    );
464
+    $form['form control tabs suffix'] = array(
465 465
     '#value' => '</ul>',
466 466
     '#weight' => 1004,
467
-  );
467
+    );
468 468
 
469
-  return $form;
469
+    return $form;
470 470
 }
471 471
 
472 472
 /**
@@ -474,133 +474,133 @@  discard block
 block discarded – undo
474 474
  * the soft/obfuscate method.
475 475
  */
476 476
 function boincuser_delete_softdelconfirmation(&$form_state, $token) {
477
-  require_boinc('token');
477
+    require_boinc('token');
478 478
 
479
-  global $user;
480
-  $form = array();
479
+    global $user;
480
+    $form = array();
481 481
 
482
-  // check BOINC user exists
483
-  $account = user_load(array('uid' => $user->uid));
484
-  $uid = $user->uid;
485
-  $boincid = $account->boincuser_id;
482
+    // check BOINC user exists
483
+    $account = user_load(array('uid' => $user->uid));
484
+    $uid = $user->uid;
485
+    $boincid = $account->boincuser_id;
486 486
 
487
-  // check $token is valid
488
-  if (!is_valid_token($boincid, $token, 'D')) {
487
+    // check $token is valid
488
+    if (!is_valid_token($boincid, $token, 'D')) {
489 489
     drupal_set_message(bts('ERROR: You have supplied an incorrect (most likely expired) token. Please obtain a new token by !link your account be deleted.',
490 490
     array(
491
-      '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"),
491
+        '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"),
492 492
     ),
493 493
     NULL, 'boinc:delete-user-account'), 'error');
494 494
     drupal_goto();
495
-  }
495
+    }
496 496
 
497
-  // Attach account to this form.
498
-  $form['_account'] = array('#type' => 'value', '#value' => $account);
497
+    // Attach account to this form.
498
+    $form['_account'] = array('#type' => 'value', '#value' => $account);
499 499
 
500
-  // This form is for hard/wipe delete
501
-  $form['_action'] = array('#type' => 'value', '#value' => 'soft_obfuscate');
500
+    // This form is for hard/wipe delete
501
+    $form['_action'] = array('#type' => 'value', '#value' => 'soft_obfuscate');
502 502
 
503
-  // Instructions
504
-  $form['main']['fs1'] = array(
503
+    // Instructions
504
+    $form['main']['fs1'] = array(
505 505
     '#type' => 'fieldset',
506 506
     '#title' => bts('Instructions', array(), NULL, 'boinc:delete-user-account'),
507 507
     '#weight' => 10,
508 508
     '#collapsible' => TRUE,
509 509
     '#collapsed' => TRUE,
510
-  );
511
-  $form['main']['fs1']['instructions1'] = array(
510
+    );
511
+    $form['main']['fs1']['instructions1'] = array(
512 512
     '#value' => '<p>'.
513 513
     bts('You are one-step away from deleting your account. Enter your password in the textbox below and click submit. This action is irreversable: once you delete your account, there is no way un-delete.', array(), NULL, 'boinc:delete-user-account').
514 514
     '</p>',
515 515
     '#prefix' => "<div id='delete-instructions'>",
516 516
     '#suffix' => "</div>",
517
-  );
517
+    );
518 518
 
519
-  $form['main']['fs1']['instructions2'] = array(
519
+    $form['main']['fs1']['instructions2'] = array(
520 520
     '#value' => '<p>'.
521 521
     bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account').
522 522
     '</p>',
523 523
     '#prefix' => "<div id='delete-instructions'>",
524 524
     '#suffix' => "</div>",
525
-  );
525
+    );
526 526
 
527
-  // Password field
528
-  $form['main']['current_pass'] = array(
527
+    // Password field
528
+    $form['main']['current_pass'] = array(
529 529
     '#type' => 'password',
530 530
     '#title' => bts('Enter your password to delete your account', array(), NULL, 'boinc:delete-user-account'),
531 531
     '#size' => 17,
532 532
     '#attributes' => array(
533
-      'autocomplete' => 'off',
533
+        'autocomplete' => 'off',
534 534
     ),
535 535
     '#weight' => 25,
536
-  );
536
+    );
537 537
 
538
-  // Form control
539
-  $form['form control tabs prefix'] = array(
538
+    // Form control
539
+    $form['form control tabs prefix'] = array(
540 540
     '#value' => '<ul class="form-control tab-list">',
541 541
     '#weight' => 1001,
542
-  );
543
-  $form['submit'] = array(
542
+    );
543
+    $form['submit'] = array(
544 544
     '#prefix' => '<li class="first tab">',
545 545
     '#type' => 'submit',
546 546
     '#value' => bts('Submit', array(), NULL, 'boinc:form-submit'),
547 547
     '#suffix' => '</li>',
548 548
     '#weight' => 1002,
549
-  );
550
-  $form['form control tabs'] = array(
549
+    );
550
+    $form['form control tabs'] = array(
551 551
     '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>',
552 552
     '#weight' => 1003,
553
-  );
554
-  $form['form control tabs suffix'] = array(
553
+    );
554
+    $form['form control tabs suffix'] = array(
555 555
     '#value' => '</ul>',
556 556
     '#weight' => 1004,
557
-  );
557
+    );
558 558
 
559
-  //set validation and submit to the functions below
560
-  $form['#validate'][] = 'boincuser_delete_finalconfirmation_validate';
561
-  $form['#submit'][] = 'boincuser_delete_finalconfirmation_submit';
562
-  return $form;
559
+    //set validation and submit to the functions below
560
+    $form['#validate'][] = 'boincuser_delete_finalconfirmation_validate';
561
+    $form['#submit'][] = 'boincuser_delete_finalconfirmation_submit';
562
+    return $form;
563 563
 }
564 564
 
565 565
 /**
566 566
  * Validation for final confirmation
567 567
  */
568 568
 function boincuser_delete_finalconfirmation_validate($form, &$form_state) {
569
-  $account = $form_state['values']['_account'];
570
-  $boinc_user = BoincUser::lookup_id($account->boincuser_id);
569
+    $account = $form_state['values']['_account'];
570
+    $boinc_user = BoincUser::lookup_id($account->boincuser_id);
571 571
 
572
-  if (_boincuser_delete_validatepasswd($boinc_user, $form_state['values']['current_pass'])) {
572
+    if (_boincuser_delete_validatepasswd($boinc_user, $form_state['values']['current_pass'])) {
573 573
     return true;
574
-  }
574
+    }
575 575
 }
576 576
 
577 577
 /**
578 578
  * Submit for final confirmation
579 579
  */
580 580
 function boincuser_delete_finalconfirmation_submit($form, &$form_state) {
581
-  global $user;
581
+    global $user;
582 582
 
583
-  // Delete the user
584
-  $account = $form_state['values']['_account'];
585
-  $action = $form_state['values']['_action'];
586
-  _boincuser_delete_deleteuser($account, $action);
583
+    // Delete the user
584
+    $account = $form_state['values']['_account'];
585
+    $action = $form_state['values']['_action'];
586
+    _boincuser_delete_deleteuser($account, $action);
587 587
 
588
-  // Destroy the current session:
589
-  session_destroy();
590
-  // Only variables can be passed by reference workaround.
591
-  $null = NULL;
592
-  user_module_invoke('logout', $null, $user);
588
+    // Destroy the current session:
589
+    session_destroy();
590
+    // Only variables can be passed by reference workaround.
591
+    $null = NULL;
592
+    user_module_invoke('logout', $null, $user);
593 593
 
594
-  // Load the anonymous user
595
-  $user = drupal_anonymous_user();
594
+    // Load the anonymous user
595
+    $user = drupal_anonymous_user();
596 596
 
597
-  $redirect = variable_get('boincuser_delete_redirect', '<front>');
598
-  // Redirect
599
-  if (!empty($redirect)) {
597
+    $redirect = variable_get('boincuser_delete_redirect', '<front>');
598
+    // Redirect
599
+    if (!empty($redirect)) {
600 600
     drupal_goto($redirect);
601
-  }
602
-  else {
601
+    }
602
+    else {
603 603
     drupal_goto();
604
-  }
604
+    }
605 605
 
606 606
 }
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boincuser/includes/boincuser.helpers.inc 1 patch
Indentation   +241 added lines, -241 removed lines patch added patch discarded remove patch
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  */
12 12
 
13 13
 if (!function_exists('user_load_by_mail')) {
14
-  /**
15
-   * user_load_by_mail will be broken out of user_load
16
-   */
17
-  function user_load_by_mail($mail) {
14
+    /**
15
+     * user_load_by_mail will be broken out of user_load
16
+     */
17
+    function user_load_by_mail($mail) {
18 18
     return user_load(array('mail' => $mail));
19
-  }
19
+    }
20 20
 }
21 21
  
22 22
 
@@ -28,14 +28,14 @@  discard block
 block discarded – undo
28 28
  * Get an image object from a given file and cck field
29 29
  */ 
30 30
 function get_cck_image_object($image_path, $field_name, $content_type, $ignore_resolution = FALSE) {
31
-  $field = content_fields($field_name, $content_type); 
32
-  $validators = array_merge(filefield_widget_upload_validators($field), imagefield_widget_upload_validators($field));
33
-  if ($ignore_resolution) {
31
+    $field = content_fields($field_name, $content_type); 
32
+    $validators = array_merge(filefield_widget_upload_validators($field), imagefield_widget_upload_validators($field));
33
+    if ($ignore_resolution) {
34 34
     unset($validators['filefield_validate_image_resolution']);
35
-  }
36
-  $target_path = filefield_widget_file_path($field);
37
-  // Create the image object
38
-  return field_file_save_file($image_path, $validators, $target_path, FILE_EXISTS_REPLACE);
35
+    }
36
+    $target_path = filefield_widget_file_path($field);
37
+    // Create the image object
38
+    return field_file_save_file($image_path, $validators, $target_path, FILE_EXISTS_REPLACE);
39 39
 }
40 40
 
41 41
 
@@ -47,73 +47,73 @@  discard block
 block discarded – undo
47 47
  * 
48 48
  */
49 49
 function boincuser_check_credit_requirements() {
50
-  global $user;
51
-  if (!$user->uid) {
50
+    global $user;
51
+    if (!$user->uid) {
52 52
     return FALSE;
53
-  }
54
-  $account = user_load($user->uid);
55
-  $min_credit_to_post = variable_get('boinc_comment_min_credit', 0);
56
-  $community_role = array_search('community member', user_roles(true));
57
-  $unrestricted_role = array_search('verified contributor', user_roles(true));
53
+    }
54
+    $account = user_load($user->uid);
55
+    $min_credit_to_post = variable_get('boinc_comment_min_credit', 0);
56
+    $community_role = array_search('community member', user_roles(true));
57
+    $unrestricted_role = array_search('verified contributor', user_roles(true));
58 58
   
59
-  // Set user roles based on current penalty status...
60
-  if ($account->boincuser_penalty_expiration > time()) {
59
+    // Set user roles based on current penalty status...
60
+    if ($account->boincuser_penalty_expiration > time()) {
61 61
     drupal_set_message(bts(
62
-      'You are banned from community participation until @date',
63
-      array('@date' => format_date($account->boincuser_penalty_expiration))
62
+        'You are banned from community participation until @date',
63
+        array('@date' => format_date($account->boincuser_penalty_expiration))
64 64
     ), 'warning', FALSE);
65 65
     if (isset($account->roles[$community_role])) {
66
-      // Remove from the community role, if not already
67
-      unset($account->roles[$community_role]);
66
+        // Remove from the community role, if not already
67
+        unset($account->roles[$community_role]);
68 68
     }
69 69
     if (isset($account->roles[$unrestricted_role])) {
70
-      // Likewise, revoke extra privileges
71
-      unset($account->roles[$unrestricted_role]);
70
+        // Likewise, revoke extra privileges
71
+        unset($account->roles[$unrestricted_role]);
72 72
     }
73 73
     user_save($account, array('roles' => $account->roles));
74
-  }
75
-  else {
74
+    }
75
+    else {
76 76
     if (!isset($account->roles[$community_role])) {
77
-      // The user should be a 'community member' role. If the user was
78
-      // previously banned, this will restore that role.
79
-      $account->roles[$community_role] = 'community member';
80
-      user_save($account, array('roles' => $account->roles));
77
+        // The user should be a 'community member' role. If the user was
78
+        // previously banned, this will restore that role.
79
+        $account->roles[$community_role] = 'community member';
80
+        user_save($account, array('roles' => $account->roles));
81 81
     }
82 82
 
83 83
     // ... and total credit.
84 84
     if ($account->boincuser_total_credit >= $min_credit_to_post) {
85
-      if (!isset($account->roles[$unrestricted_role])) {
85
+        if (!isset($account->roles[$unrestricted_role])) {
86 86
         // This user is now above the credit threshold and is allowed full
87 87
         // privileges
88 88
         $account->roles[$unrestricted_role] = 'verified contributor';
89 89
         user_save($account, array('roles' => $account->roles));
90
-      }
90
+        }
91 91
     }
92 92
     else {
93
-      drupal_set_message(bts(
93
+        drupal_set_message(bts(
94 94
         'You must earn @count more credits to be able to post comments on this site and create or modify your user profile.',
95 95
         array('@count' => $min_credit_to_post - $account->boincuser_total_credit)
96
-      ), 'warning', FALSE);
97
-      if (isset($account->roles[$unrestricted_role])) {
96
+        ), 'warning', FALSE);
97
+        if (isset($account->roles[$unrestricted_role])) {
98 98
         // Either the threshold has been raised or credits have been revoked;
99 99
         // this user no longer qualifies for full privileges
100 100
         unset($account->roles[$unrestricted_role]);
101 101
         user_save($account, array('roles' => $account->roles));
102
-      }
102
+        }
103 103
     }
104 104
 
105
-  }
105
+    }
106 106
 }
107 107
 
108 108
 /**
109 109
  * Get the cid of the first comment the user has not seen on a given node
110 110
  */
111 111
 function boincuser_get_first_unread_comment_id($nid, $uid = NULL) {
112
-  if (!$uid) {
112
+    if (!$uid) {
113 113
     global $user;
114 114
     $uid = $user->uid;
115
-  }
116
-  return db_result(db_query("
115
+    }
116
+    return db_result(db_query("
117 117
     SELECT c.cid
118 118
     FROM {node} n
119 119
     INNER JOIN {comments} c ON c.nid = n.nid
@@ -124,40 +124,40 @@  discard block
 block discarded – undo
124 124
     ORDER BY c.timestamp ASC
125 125
     LIMIT 1",
126 126
     $uid, $nid
127
-  ));
127
+    ));
128 128
 }
129 129
 
130 130
 /**
131 131
  * Choose and set the user of the day
132 132
  */
133 133
 function boincuser_select_user_of_the_day() {
134
-  // First get a list of users with recent credit
135
-  db_set_active('boinc_rw');
136
-  $users_with_credit = db_query("
134
+    // First get a list of users with recent credit
135
+    db_set_active('boinc_rw');
136
+    $users_with_credit = db_query("
137 137
     SELECT
138 138
       id
139 139
     FROM {user} u
140 140
     JOIN {profile} p ON p.userid = u.id
141 141
     WHERE expavg_credit > 1
142 142
     ORDER BY uotd_time ASC, RAND()"
143
-  );
144
-  db_set_active('default');
145
-  $active_users = array();
146
-  while ($user_with_credit = db_fetch_object($users_with_credit)) {
143
+    );
144
+    db_set_active('default');
145
+    $active_users = array();
146
+    while ($user_with_credit = db_fetch_object($users_with_credit)) {
147 147
     $active_users[] = $user_with_credit->id;
148
-  }
149
-  $active_users = implode(',', $active_users);
150
-  // Limit to users who have never been user of the day, if there are any
151
-  $never_been_picked = db_result(db_query("
148
+    }
149
+    $active_users = implode(',', $active_users);
150
+    // Limit to users who have never been user of the day, if there are any
151
+    $never_been_picked = db_result(db_query("
152 152
     SELECT COUNT(*)
153 153
     FROM {boincuser} bu
154 154
     WHERE bu.uotd_time = 0
155 155
     " . ($active_users ? " AND bu.boinc_id IN ({$active_users}) " : '')
156
-  ));
157
-  $new_uotd_uid = 0;
158
-  while (!$new_uotd_uid) {
156
+    ));
157
+    $new_uotd_uid = 0;
158
+    while (!$new_uotd_uid) {
159 159
     // Select a user of the day randomly from the pool
160
-      $new_uotd_uid = db_result(db_query("
160
+        $new_uotd_uid = db_result(db_query("
161 161
       SELECT
162 162
         n.uid
163 163
       FROM {node} n
@@ -171,31 +171,31 @@  discard block
 block discarded – undo
171 171
       LIMIT 1"
172 172
     ));
173 173
     if (!$new_uotd_uid) {
174
-      // Can't find a user with a profile; remove constraints on the pool
175
-      if ($never_been_picked) {
174
+        // Can't find a user with a profile; remove constraints on the pool
175
+        if ($never_been_picked) {
176 176
         // Allow users who have been previously selected
177 177
         $never_been_picked = FALSE;
178
-      }
179
-      elseif ($active_users) {
178
+        }
179
+        elseif ($active_users) {
180 180
         // Allow users who are not even active (getting desperate)
181 181
         $active_users = FALSE;
182
-      }
183
-      else {
182
+        }
183
+        else {
184 184
         // Process failed...
185 185
         return FALSE;
186
-      }
186
+        }
187 187
     }
188
-  }
189
-  $uotd = user_load($new_uotd_uid);
190
-  if ($uotd->uid) {
188
+    }
189
+    $uotd = user_load($new_uotd_uid);
190
+    if ($uotd->uid) {
191 191
     db_query("
192 192
       UPDATE {boincuser}
193 193
       SET uotd_time = '%d'
194 194
       WHERE uid = '%d'",
195
-      time(), $uotd->uid
195
+        time(), $uotd->uid
196 196
     );
197
-  }
198
-  return $uotd;
197
+    }
198
+    return $uotd;
199 199
 }
200 200
 
201 201
 
@@ -213,71 +213,71 @@  discard block
 block discarded – undo
213 213
  * new and prev email.
214 214
  */
215 215
 function _boincuser_send_emailchange($account, $new_email=NULL, $prev_email=NULL, $adminuser=FALSE) {
216
-  require_boinc('token');
217
-  module_load_include('inc', 'rules', 'modules/system.rules');
216
+    require_boinc('token');
217
+    module_load_include('inc', 'rules', 'modules/system.rules');
218 218
 
219
-  global $base_url;
220
-  $site_name = variable_get('site_name', 'Drupal-BOINC');
219
+    global $base_url;
220
+    $site_name = variable_get('site_name', 'Drupal-BOINC');
221 221
 
222
-  if (is_null($new_email)) {
222
+    if (is_null($new_email)) {
223 223
     $new_email = $account->mail;
224
-  }
225
-  if (is_null($prev_email)) {
224
+    }
225
+    if (is_null($prev_email)) {
226 226
     $prev_email = $account->boincuser_previous_email_addr;
227
-  }
228
-
229
-  // @todo - set constant in drupal, or use BOINC contsants
230
-  $duration = TOKEN_DURATION_ONE_WEEK;
231
-  $changedate = date('F j, Y \a\t G:i T', time());
232
-  $newdate = date('F j, Y \a\t G:i T', $account->boincuser_email_addr_change_time + $duration);
233
-  $token = create_token($account->boincuser_id, TOKEN_TYPE_CHANGE_EMAIL, $duration);
234
-  if ($adminuser) {
227
+    }
228
+
229
+    // @todo - set constant in drupal, or use BOINC contsants
230
+    $duration = TOKEN_DURATION_ONE_WEEK;
231
+    $changedate = date('F j, Y \a\t G:i T', time());
232
+    $newdate = date('F j, Y \a\t G:i T', $account->boincuser_email_addr_change_time + $duration);
233
+    $token = create_token($account->boincuser_id, TOKEN_TYPE_CHANGE_EMAIL, $duration);
234
+    if ($adminuser) {
235 235
     $graf1 = "Your email address was changed from {$prev_email} to {$new_email} "
236
-      . "on {$changedate}. If you need to reverse this change, please look for "
237
-      . "an email send to the email address: {$prev_email}.\n";
238
-  }
239
-  else {
236
+        . "on {$changedate}. If you need to reverse this change, please look for "
237
+        . "an email send to the email address: {$prev_email}.\n";
238
+    }
239
+    else {
240 240
     $graf1 = "Your email address was changed from {$prev_email} to {$new_email} "
241
-      . "on {$changedate}. You will not be able to change your email address "
242
-      . "until {$newdate}. If you need to reverse this change, please look for "
243
-      . "an email send to the email address: {$prev_email}.\n";
244
-  }
245
-
246
-  // Send email #1 to current address
247
-  $mysubject = "Notification of email change at {$site_name}";
248
-  $mymessage = ''
249
-      . "{$account->boincuser_name},\n"
250
-      . "\n"
251
-      . $graf1
252
-      . "\n"
253
-      . "Thanks, \n"
254
-      . "{$site_name} support team\n";
255
-
256
-  $settings = array(
241
+        . "on {$changedate}. You will not be able to change your email address "
242
+        . "until {$newdate}. If you need to reverse this change, please look for "
243
+        . "an email send to the email address: {$prev_email}.\n";
244
+    }
245
+
246
+    // Send email #1 to current address
247
+    $mysubject = "Notification of email change at {$site_name}";
248
+    $mymessage = ''
249
+        . "{$account->boincuser_name},\n"
250
+        . "\n"
251
+        . $graf1
252
+        . "\n"
253
+        . "Thanks, \n"
254
+        . "{$site_name} support team\n";
255
+
256
+    $settings = array(
257 257
     'from' => '',
258 258
     'to' => $new_email,
259 259
     'subject' => $mysubject,
260 260
     'message' => $mymessage,
261
-  );
262
-  rules_action_mail_to_user($account, $settings);
263
-
264
-  // Send email #2 to previous address.
265
-  $mymessage = ''
266
-      . "Your email address has been changed. If you did not intend to take this action, then please click this link to reverse this change, or copy-and-paste the link into your browser location bar. You will need to change your password as well.\n"
267
-      . "\n"
268
-      . "{$base_url}/user/{$account->uid}/recoveremail/{$token}\n"
269
-      . "\n"
270
-      . "Thanks, \n"
271
-      . "{$site_name} support team\n";
272
-
273
-  $settings = array(
261
+    );
262
+    rules_action_mail_to_user($account, $settings);
263
+
264
+    // Send email #2 to previous address.
265
+    $mymessage = ''
266
+        . "Your email address has been changed. If you did not intend to take this action, then please click this link to reverse this change, or copy-and-paste the link into your browser location bar. You will need to change your password as well.\n"
267
+        . "\n"
268
+        . "{$base_url}/user/{$account->uid}/recoveremail/{$token}\n"
269
+        . "\n"
270
+        . "Thanks, \n"
271
+        . "{$site_name} support team\n";
272
+
273
+    $settings = array(
274 274
     'from' => '',
275 275
     'to' => $prev_email,
276 276
     'subject' => $mysubject,
277 277
     'message' => $mymessage,
278
-  );
278
+    );
279 279
 
280
-  rules_action_mail($settings);
280
+    rules_action_mail($settings);
281 281
 }
282 282
 
283 283
 /**
@@ -287,32 +287,32 @@  discard block
 block discarded – undo
287 287
  *
288 288
  */
289 289
 function create_proper_drupalname($requested_name) {
290
-  if (!$requested_name) {
290
+    if (!$requested_name) {
291 291
     // If the name is empty, set it
292 292
     $requested_name = 'anonymous';
293
-  }
294
-  $same_name_tally = 1;
295
-
296
-  // Remove extra spaces
297
-  $name2 = preg_replace("/ {2,}/", " ", trim($requested_name));
298
-  // Remove any non-valid characters
299
-  $cleaned_name = preg_replace('/[^a-zA-Z0-9_ \.-]/s', '_', $name2);
300
-  // Truncate name
301
-  $name_length = strlen($cleaned_name);
302
-  if ($name_length > 56) {
293
+    }
294
+    $same_name_tally = 1;
295
+
296
+    // Remove extra spaces
297
+    $name2 = preg_replace("/ {2,}/", " ", trim($requested_name));
298
+    // Remove any non-valid characters
299
+    $cleaned_name = preg_replace('/[^a-zA-Z0-9_ \.-]/s', '_', $name2);
300
+    // Truncate name
301
+    $name_length = strlen($cleaned_name);
302
+    if ($name_length > 56) {
303 303
     // Name is limited to 60 characters, but we want to leave space to add a
304 304
     // tally if needed (for users with duplicate names); Limit to 56 chars and
305 305
     // replace the middle of the string with "..." if too long
306 306
     $cleaned_name = substr_replace($cleaned_name, '...', 28, ($name_length-56)+3);
307
-  }
307
+    }
308 308
 
309
-  // Determine if there are duplicate names, if so append a number to end.
310
-  $unique_name = $cleaned_name;
311
-  while (db_result(db_query("SELECT uid FROM {users} WHERE name = '{$unique_name}' LIMIT 1"))) {
309
+    // Determine if there are duplicate names, if so append a number to end.
310
+    $unique_name = $cleaned_name;
311
+    while (db_result(db_query("SELECT uid FROM {users} WHERE name = '{$unique_name}' LIMIT 1"))) {
312 312
     $same_name_tally++;
313 313
     $unique_name = "{$cleaned_name}_{$same_name_tally}";
314
-  }
315
-  return $unique_name;
314
+    }
315
+    return $unique_name;
316 316
 }
317 317
 
318 318
 
@@ -326,9 +326,9 @@  discard block
 block discarded – undo
326 326
  *
327 327
  */
328 328
 function boincuser_check_termsofuse($user) {
329
-  require_boinc('consent');
330
-  $boinc_user = boincuser_load($user->uid, TRUE);
331
-  return check_user_consent($boinc_user, CONSENT_TYPE_ENROLL);
329
+    require_boinc('consent');
330
+    $boinc_user = boincuser_load($user->uid, TRUE);
331
+    return check_user_consent($boinc_user, CONSENT_TYPE_ENROLL);
332 332
 }
333 333
 
334 334
 /**
@@ -339,27 +339,27 @@  discard block
 block discarded – undo
339 339
  *
340 340
  */
341 341
 function boincuser_consentto_termsofuse($user) {
342
-  require_boinc('consent');
343
-  $boinc_user = boincuser_load($user->uid, TRUE);
342
+    require_boinc('consent');
343
+    $boinc_user = boincuser_load($user->uid, TRUE);
344 344
 
345
-  list($checkct, $ctid) = check_consent_type(CONSENT_TYPE_ENROLL);
346
-  if ($checkct) {
345
+    list($checkct, $ctid) = check_consent_type(CONSENT_TYPE_ENROLL);
346
+    if ($checkct) {
347 347
     $rc1 = consent_to_a_policy($boinc_user, $ctid, 1, 0, 'Webform', time());
348 348
     if (!$rc1) {
349
-      drupal_set_message(
349
+        drupal_set_message(
350 350
         bts("ERROR: Database error when attempting to INSERT into table consent with ID=@id. Please contact site administrators.",
351 351
         array('@id' => $boinc_user->id),
352 352
         'NULL', 'boinc:consent-termsofuse'),
353
-      'error');
353
+        'error');
354 354
     }
355 355
     return $rc1;
356
-  }
357
-  else {
356
+    }
357
+    else {
358 358
     drupal_set_message(
359
-      bts('ERROR: Consent type for enrollment not found. Please contact site administrators.', array(), 'NULL', 'boinc:consent-termsofuse'),
359
+        bts('ERROR: Consent type for enrollment not found. Please contact site administrators.', array(), 'NULL', 'boinc:consent-termsofuse'),
360 360
     'error');
361
-  }
362
-  return FALSE;
361
+    }
362
+    return FALSE;
363 363
 }
364 364
 
365 365
 /**
@@ -368,16 +368,16 @@  discard block
 block discarded – undo
368 368
  */
369 369
 function _boincuser_ignore_paths($path, $paths_to_ignore) {
370 370
 
371
-  foreach ($paths_to_ignore as $pi) {
371
+    foreach ($paths_to_ignore as $pi) {
372 372
     // @todo Currently this function uses {} as PHP regexp
373 373
     // delimiters. Curly brace is not really allowed un URLs, but a
374 374
     // more robust function would first check for these curly braces
375 375
     // in the path_to_ignore patterms, just in case.
376 376
     if (preg_match('{' . $pi . '}', $path)) {
377
-      return TRUE;
377
+        return TRUE;
378 378
     }
379
-  }
380
-  return FALSE;
379
+    }
380
+    return FALSE;
381 381
 }
382 382
 
383 383
 /**
@@ -385,20 +385,20 @@  discard block
 block discarded – undo
385 385
  * Drupal's recover email path.
386 386
  */
387 387
 function _boincuser_redirect_recover_email() {
388
-  $params = array(
388
+    $params = array(
389 389
     'boincid' => isset($_GET['id']) ? $_GET['id'] : '',
390 390
     'token' => isset($_GET['token']) ? $_GET['token'] : ''
391
-  );
391
+    );
392 392
 
393
-  // If boincid or token is not present, then go to the home page.
394
-  if (empty($params['boincid']) or empty($params['token'])) {
393
+    // If boincid or token is not present, then go to the home page.
394
+    if (empty($params['boincid']) or empty($params['token'])) {
395 395
     $redirect = '';
396
-  }
397
-  else {
396
+    }
397
+    else {
398 398
     $uid = boincuser_lookup_uid($params['boincid']);
399 399
     $redirect = "/user/${uid}/recoveremail/${params['token']}";
400
-  }
401
-  drupal_goto($redirect);
400
+    }
401
+    drupal_goto($redirect);
402 402
 }
403 403
 
404 404
 /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
@@ -409,17 +409,17 @@  discard block
 block discarded – undo
409 409
  * Require BOINC library
410 410
  */
411 411
 function require_boinc($libraries) {
412
-  if ($include_dir = boinc_get_path('html_inc')) {
412
+    if ($include_dir = boinc_get_path('html_inc')) {
413 413
     $working_dir = getcwd();
414 414
     chdir($include_dir);
415 415
     if (!is_array($libraries)) {
416
-      $libraries = array($libraries);
416
+        $libraries = array($libraries);
417 417
     }
418 418
     foreach ($libraries as $library) {
419
-      require_once("{$library}.inc");
419
+        require_once("{$library}.inc");
420 420
     }
421 421
     chdir($working_dir);
422
-  }
422
+    }
423 423
 }
424 424
 
425 425
 /**
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
  * The path from the BOINC html root must be included (e.g. user/file.php)
428 428
  */
429 429
 function include_boinc($file) {
430
-  if ($include_dir = boinc_get_path()) {
430
+    if ($include_dir = boinc_get_path()) {
431 431
     $include_dir .= '/html';
432 432
     $workingDir = getcwd();
433 433
     $path = dirname($file);
@@ -435,84 +435,84 @@  discard block
 block discarded – undo
435 435
     chdir("{$include_dir}/{$path}");
436 436
     include($file);
437 437
     chdir($workingDir);
438
-  }
438
+    }
439 439
 }
440 440
 
441 441
 /**
442 442
  * Get the BOINC include path
443 443
  */
444 444
 function boinc_get_path($type = 'root') {
445
-  $dir = "boinc_{$type}_dir";
446
-  if ($include_dir = variable_get("boinc_{$type}_dir", '')) {
445
+    $dir = "boinc_{$type}_dir";
446
+    if ($include_dir = variable_get("boinc_{$type}_dir", '')) {
447 447
     return $include_dir;
448
-  }
449
-  else {
448
+    }
449
+    else {
450 450
     // Don't show errors on blacklisted pages
451 451
     $page_blacklist = array(
452
-      'admin/boinc/environment'
452
+        'admin/boinc/environment'
453 453
     );
454 454
     if (!in_array($_GET['q'], $page_blacklist)) {
455
-      watchdog('boincuser', 'The BOINC environment is not configured. Please
455
+        watchdog('boincuser', 'The BOINC environment is not configured. Please
456 456
           !configure_it', array('!configure_it' => l(t('configure it now'),
457 457
             'admin/boinc/environment')), WATCHDOG_WARNING);
458
-      if (user_access('administer site configuration')) {
458
+        if (user_access('administer site configuration')) {
459 459
         drupal_set_message(t('The BOINC environment is not configured. Please
460 460
           !configure_it', array('!configure_it' => l(t('configure it now'),
461 461
             'admin/boinc/environment'))), 'warning', FALSE);
462
-      }
463
-      else {
462
+        }
463
+        else {
464 464
         drupal_set_message(t('There is a problem with the site. Please contact
465 465
           the system administrator.'), 'error', FALSE);
466
-      }
467
-      // Redirect home to display the error message and avoid fatal errors
468
-      // (unless on a blacklisted page)
469
-      $redirect_blacklist = array(
466
+        }
467
+        // Redirect home to display the error message and avoid fatal errors
468
+        // (unless on a blacklisted page)
469
+        $redirect_blacklist = array(
470 470
         'admin/settings/performance',
471 471
         'admin/boinc/environment',
472 472
         'home',
473 473
         ''
474
-      );
475
-      if (!in_array($_GET['q'], $redirect_blacklist)) {
474
+        );
475
+        if (!in_array($_GET['q'], $redirect_blacklist)) {
476 476
         drupal_goto('');
477
-      }
477
+        }
478 478
     }
479 479
     else {
480
-      // Clear the messages on the environment config page
481
-      drupal_get_messages();
480
+        // Clear the messages on the environment config page
481
+        drupal_get_messages();
482 482
     }
483
-  }
484
-  return FALSE;
483
+    }
484
+    return FALSE;
485 485
 }
486 486
 
487 487
 /**
488 488
  * Get the configured scheduler tags
489 489
  */
490 490
 function boinc_get_scheduler_tags() {
491
-  // Don't generate messages for blacklisted pages
492
-  $page_blacklist = array(
491
+    // Don't generate messages for blacklisted pages
492
+    $page_blacklist = array(
493 493
     'admin/boinc/environment',
494 494
     'admin/boinc/scheduler'
495
-  );
496
-  if ($url_config = variable_get('boinc_scheduler_urls', '')) {
495
+    );
496
+    if ($url_config = variable_get('boinc_scheduler_urls', '')) {
497 497
     return explode("\r\n", $url_config);
498
-  }
499
-  elseif (!in_array($_GET['q'], $page_blacklist)) {
498
+    }
499
+    elseif (!in_array($_GET['q'], $page_blacklist)) {
500 500
     watchdog('boincuser', 'The BOINC scheduling server settings are not yet
501 501
         configured. Please !verify for the settings to become effective.',
502
-          array('!verify' => l(t('verify the default values') . ' <strong>' . 
502
+            array('!verify' => l(t('verify the default values') . ' <strong>' . 
503 503
             t('and') . '</strong> ' . t('save the configuration'),
504 504
             'admin/boinc/scheduler', array('html' => TRUE))
505
-          ), WATCHDOG_WARNING);
505
+            ), WATCHDOG_WARNING);
506 506
     if (user_access('administer site configuration')) {
507
-      drupal_set_message(t('The BOINC scheduling server settings are not yet
507
+        drupal_set_message(t('The BOINC scheduling server settings are not yet
508 508
           configured. Please !verify for the settings to become effective',
509 509
             array('!verify' => l(t('verify the default values') . ' <strong>' . 
510
-              t('and') . '</strong> ' . t('save the configuration'),
511
-              'admin/boinc/scheduler', array('html' => TRUE))
510
+                t('and') . '</strong> ' . t('save the configuration'),
511
+                'admin/boinc/scheduler', array('html' => TRUE))
512 512
             )), 'warning', FALSE);
513 513
     }
514
-  }
515
-  return array();
514
+    }
515
+    return array();
516 516
 }
517 517
 
518 518
 /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
@@ -524,41 +524,41 @@  discard block
 block discarded – undo
524 524
  * Determine if a BOINC ID matches the logged in user
525 525
  */
526 526
 function is_current_boinc_user($boinc_id) {
527
-  global $user;
528
-  if (!$user->uid) {
527
+    global $user;
528
+    if (!$user->uid) {
529 529
     return FALSE;
530
-  }
531
-  // boincuser_id is not stored in the global user, so load a new instance
532
-  $drupuser = user_load($user->uid);
533
-  return ($boinc_id == $drupuser->boincuser_id);
530
+    }
531
+    // boincuser_id is not stored in the global user, so load a new instance
532
+    $drupuser = user_load($user->uid);
533
+    return ($boinc_id == $drupuser->boincuser_id);
534 534
 }
535 535
 
536 536
 /**
537 537
  * Convert a BOINC ID to a Drupal ID
538 538
  */
539 539
 function boincuser_lookup_uid($boinc_id) {
540
-  $drupal_id = db_result(db_query("SELECT uid FROM {boincuser} WHERE boinc_id='%d'", $boinc_id));
541
-  return $drupal_id;
540
+    $drupal_id = db_result(db_query("SELECT uid FROM {boincuser} WHERE boinc_id='%d'", $boinc_id));
541
+    return $drupal_id;
542 542
 }
543 543
 function get_drupal_id($boinc_id) {
544
-  return boincuser_lookup_uid($boinc_id);
544
+    return boincuser_lookup_uid($boinc_id);
545 545
 }
546 546
 
547 547
 /**
548 548
  * Get a BOINC user object
549 549
  */
550 550
 function boincuser_load($user_id = NULL, $is_drupal_id = FALSE) {
551
-  if (!$user_id) {
551
+    if (!$user_id) {
552 552
     global $user;
553 553
     $user_id = $user->uid;
554 554
     $is_drupal_id = TRUE;
555
-  }
556
-  if ($is_drupal_id) {
555
+    }
556
+    if ($is_drupal_id) {
557 557
     $account = user_load($user_id);
558 558
     $user_id = $account->boincuser_id;
559
-  }
560
-  require_boinc('boinc_db');
561
-  return BoincUser::lookup_id($user_id);
559
+    }
560
+    require_boinc('boinc_db');
561
+    return BoincUser::lookup_id($user_id);
562 562
 }
563 563
 
564 564
 /**
@@ -568,10 +568,10 @@  discard block
 block discarded – undo
568 568
  * page, delete button.
569 569
  */
570 570
 function _boincuser_node_profile_delete_submit($form, &$form_state) {
571
-  $node = $form['#node'];
572
-  $deleteurl = 'node/'. $node->nid .'/delete';
573
-  $afterq = 'destination=account';
574
-  drupal_goto($deleteurl, $afterq);
571
+    $node = $form['#node'];
572
+    $deleteurl = 'node/'. $node->nid .'/delete';
573
+    $afterq = 'destination=account';
574
+    drupal_goto($deleteurl, $afterq);
575 575
 }
576 576
 
577 577
 /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
@@ -582,8 +582,8 @@  discard block
 block discarded – undo
582 582
  * Wrapper for boinc_version() function
583 583
  */
584 584
 function get_boinc_version($x) {
585
-  require_boinc('host');
586
-  return function_exists('boinc_version') ? boinc_version($x) : 'err!';
585
+    require_boinc('host');
586
+    return function_exists('boinc_version') ? boinc_version($x) : 'err!';
587 587
 }
588 588
   
589 589
 
@@ -592,14 +592,14 @@  discard block
 block discarded – undo
592 592
  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  */
593 593
 
594 594
 /**
595
-  * Generate the friend block header
596
-  */
595
+ * Generate the friend block header
596
+ */
597 597
 function boincuser_views_friends_block_header($context = null) {
598
-  // Get the friend count for the user being viewed
599
-  $view = views_get_current_view();
600
-  $account_id = $view->args[0];
601
-  $friend_count = flag_friend_get_friend_count($account_id);
602
-  return '<h2 class="pane-title">' . bts('Friends (@count)', 
598
+    // Get the friend count for the user being viewed
599
+    $view = views_get_current_view();
600
+    $account_id = $view->args[0];
601
+    $friend_count = flag_friend_get_friend_count($account_id);
602
+    return '<h2 class="pane-title">' . bts('Friends (@count)', 
603 603
     array('@count' => $friend_count)) . '</h2>';
604 604
 }
605 605
 
@@ -608,13 +608,13 @@  discard block
 block discarded – undo
608 608
  * database.
609 609
  */
610 610
 function _boincuser_user_name_autocomplete($string) {
611
-  $matches = array();
612
-  db_set_active('boinc_ro');
613
-  $result = db_query_range("SELECT id,name FROM {user} WHERE name LIKE '%s%'", $string, 0, 10);
614
-  db_set_active('default');
615
-  while ($user = db_fetch_object($result)) {
616
-      $matches[$user->name . '_' . $user->id] = htmlentities($user->name) . " (" . $user->id . ')';
617
-  }
618
-
619
-  drupal_json((object)$matches);
611
+    $matches = array();
612
+    db_set_active('boinc_ro');
613
+    $result = db_query_range("SELECT id,name FROM {user} WHERE name LIKE '%s%'", $string, 0, 10);
614
+    db_set_active('default');
615
+    while ($user = db_fetch_object($result)) {
616
+        $matches[$user->name . '_' . $user->id] = htmlentities($user->name) . " (" . $user->id . ')';
617
+    }
618
+
619
+    drupal_json((object)$matches);
620 620
 }
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boincwork/includes/boincwork.helpers.inc 1 patch
Indentation   +863 added lines, -863 removed lines patch added patch discarded remove patch
@@ -11,19 +11,19 @@  discard block
 block discarded – undo
11 11
  * that was selected
12 12
  */
13 13
 function boincwork_ahah_helper_venue_submit($form, &$form_state) {
14
-  $form_state['storage']['prefs']['preset'] = null;
15
-  ahah_helper_generic_submit($form, $form_state);
14
+    $form_state['storage']['prefs']['preset'] = null;
15
+    ahah_helper_generic_submit($form, $form_state);
16 16
 }
17 17
 
18 18
 /**
19 19
  * Get a predetermined set of preferences
20 20
  */
21 21
 function boincwork_get_preset_prefs($preset = null) {
22
-  $saved_state = variable_get('boincwork_preset_prefs', null);
22
+    $saved_state = variable_get('boincwork_preset_prefs', null);
23 23
   
24
-  // If not configured yet, use these values as for inital
25
-  // computing/general preferences.
26
-  if (!$saved_state) {
24
+    // If not configured yet, use these values as for inital
25
+    // computing/general preferences.
26
+    if (!$saved_state) {
27 27
     // Get BOINC project disk space configurations from config.xml to
28 28
     // fill in initial preference values.
29 29
     require_boinc(array('db', 'prefs'));
@@ -160,88 +160,88 @@  discard block
 block discarded – undo
160 160
           <dont_verify_images>0</dont_verify_images>
161 161
         </preset>
162 162
       </general_preferences>';
163
-  }
163
+    }
164 164
   
165
-  // Convert XML data to array format
166
-  $preset_prefs = load_configuration($saved_state);
165
+    // Convert XML data to array format
166
+    $preset_prefs = load_configuration($saved_state);
167 167
   
168
-  if ($preset) {
168
+    if ($preset) {
169 169
     // Load preset from configuration
170 170
     $preset_prefs = (array) $preset_prefs['general_preferences'];
171 171
     if (isset($preset_prefs['preset'])) {
172
-      if (!is_numeric(key($preset_prefs['preset']))) {
172
+        if (!is_numeric(key($preset_prefs['preset']))) {
173 173
         $preset_prefs['preset'] = array($preset_prefs['preset']);
174
-      }
175
-      foreach ($preset_prefs['preset'] as $key => $prefs) {
174
+        }
175
+        foreach ($preset_prefs['preset'] as $key => $prefs) {
176 176
         if (isset($prefs['@attributes']['name']) AND $prefs['@attributes']['name'] == $preset) {
177
-          return $preset_prefs['preset'][$key];
177
+            return $preset_prefs['preset'][$key];
178
+        }
178 179
         }
179
-      }
180 180
     }
181
-  }
182
-  return $preset_prefs;
181
+    }
182
+    return $preset_prefs;
183 183
 }
184 184
 
185 185
 /**
186 186
  * Load (and validate) the project specific configuration XML
187 187
  */
188 188
 function boincwork_get_project_specific_config() {
189
-  $raw_config_data = variable_get('boinc_project_specific_prefs_config', '');
189
+    $raw_config_data = variable_get('boinc_project_specific_prefs_config', '');
190 190
   
191
-  $xsd = './' . drupal_get_path('module', 'boincwork') . '/includes/projectprefs.xsd';
192
-  libxml_use_internal_errors(true);
191
+    $xsd = './' . drupal_get_path('module', 'boincwork') . '/includes/projectprefs.xsd';
192
+    libxml_use_internal_errors(true);
193 193
   
194
-  $xml = new DomDocument();
195
-  $xml->loadXML($raw_config_data, LIBXML_NOBLANKS);
196
-  if (!$xml->schemaValidate($xsd)) {
194
+    $xml = new DomDocument();
195
+    $xml->loadXML($raw_config_data, LIBXML_NOBLANKS);
196
+    if (!$xml->schemaValidate($xsd)) {
197 197
     $errors = libxml_get_errors();
198 198
     $lines = explode("\r", $raw_config_data);
199 199
     drupal_set_message("{$errors[0]->message} at line {$errors[0]->line}" .
200
-      ': <br/>' . htmlentities($lines[$errors[0]->line - 1]), 'error');
200
+        ': <br/>' . htmlentities($lines[$errors[0]->line - 1]), 'error');
201 201
     return NULL;
202
-  }
202
+    }
203 203
   
204
-  // Convert XML to array for validation
205
-  $xml = load_configuration($raw_config_data);
206
-  return $xml;
204
+    // Convert XML to array for validation
205
+    $xml = load_configuration($raw_config_data);
206
+    return $xml;
207 207
 }
208 208
 
209 209
 /**
210 210
  * Get rules by which to validate project specific data
211 211
  */
212 212
 function boincwork_get_project_specific_config_validation_rules($xml = array()) {
213
-  $rules = array();
214
-  if (!$xml) {
213
+    $rules = array();
214
+    if (!$xml) {
215 215
     // Read the config XML
216 216
     $xml = boincwork_get_project_specific_config();
217 217
     $xml = $xml['project_specific_preferences'];
218
-  }
219
-  foreach ($xml as $type => $elements) {
218
+    }
219
+    foreach ($xml as $type => $elements) {
220 220
     if (is_array($elements) AND !is_numeric(key($elements))) {
221
-      $elements = array($elements);
221
+        $elements = array($elements);
222 222
     }
223 223
     switch ($type) {
224 224
     case 'compound':
225 225
       foreach ($elements as $element) {
226 226
         $name = $element['@attributes']['name'];
227 227
         $rules[$name] = boincwork_get_project_specific_config_validation_rules($element['attributes']);
228
-      }
229
-      break;
228
+        }
229
+        break;
230 230
       
231 231
     case 'text':
232 232
       foreach ($elements as $element) {
233 233
         $name = $element['@attributes']['name'];
234 234
         $rules[$name] = array(
235
-          'datatype' => $element['@attributes']['datatype']
235
+            'datatype' => $element['@attributes']['datatype']
236 236
         );
237 237
         if (isset($element['@attributes']['min'])) {
238
-          $rules[$name]['min'] = $element['@attributes']['min'];
238
+            $rules[$name]['min'] = $element['@attributes']['min'];
239 239
         }
240 240
         if (isset($element['@attributes']['max'])) {
241
-          $rules[$name]['max'] = $element['@attributes']['max'];
241
+            $rules[$name]['max'] = $element['@attributes']['max'];
242 242
         }
243
-      }
244
-      break;
243
+        }
244
+        break;
245 245
     /*
246 246
     case 'radio':
247 247
     case 'dropdown':
@@ -265,24 +265,24 @@  discard block
 block discarded – undo
265 265
       $rules['apps'] = array(
266 266
         'minimum selected' => 1,
267 267
         'list' => array()
268
-      );
269
-      foreach ($elements as $element) {
268
+        );
269
+        foreach ($elements as $element) {
270 270
         foreach ($element['app'] as $app) {
271
-          $name = "app_{$app['@attributes']['id']}";
272
-          $rules['apps']['list'][] = $name;
273
-          //$rules[$name] = array(
274
-          //  'options' => $options
275
-          //);
271
+            $name = "app_{$app['@attributes']['id']}";
272
+            $rules['apps']['list'][] = $name;
273
+            //$rules[$name] = array(
274
+            //  'options' => $options
275
+            //);
276 276
         }
277
-      }
278
-      break;
277
+        }
278
+        break;
279 279
       
280 280
     case 'group':
281 281
       foreach ($elements as $element) {
282 282
         $name = $element['@attributes']['name'];
283 283
         $rules += boincwork_get_project_specific_config_validation_rules($element);
284
-      }
285
-      break;
284
+        }
285
+        break;
286 286
     /*
287 287
     case 'boolean':
288 288
       // Shouldn't need to validate boolean...
@@ -290,39 +290,39 @@  discard block
 block discarded – undo
290 290
       */
291 291
     default:
292 292
     }
293
-  }
294
-  return $rules;
293
+    }
294
+    return $rules;
295 295
 }
296 296
 
297 297
 /**
298 298
  * Define how project specific settings should be saved
299 299
  */
300 300
 function boincwork_format_project_specific_prefs_data($values, $xml = array()) {
301
-  $defaults = array();
302
-  if (!$xml) {
301
+    $defaults = array();
302
+    if (!$xml) {
303 303
     // Read the config XML
304 304
     $xml = boincwork_get_project_specific_config();
305 305
     $xml = $xml['project_specific_preferences'];
306
-  }
307
-  foreach ($xml as $type => $elements) {
306
+    }
307
+    foreach ($xml as $type => $elements) {
308 308
     $structure_data = array();
309 309
     if (is_array($elements) AND !is_numeric(key($elements))) {
310
-      $elements = array($elements);
310
+        $elements = array($elements);
311 311
     }
312 312
     switch ($type) {
313 313
     case 'compound':
314 314
       foreach ($elements as $element) {
315 315
         $name = $element['@attributes']['name'];
316 316
         $default[$name]['@attributes'] = boincwork_format_project_specific_prefs_data($values[$name], $element['attributes']);
317
-      }
318
-      $defaults += $default;
319
-      break;
317
+        }
318
+        $defaults += $default;
319
+        break;
320 320
       
321 321
     case 'group':
322 322
       foreach ($elements as $element) {
323 323
         $defaults += boincwork_format_project_specific_prefs_data($values, $element);
324
-      }
325
-      break;
324
+        }
325
+        break;
326 326
       
327 327
     case 'text':
328 328
     case 'radio':
@@ -331,315 +331,315 @@  discard block
 block discarded – undo
331 331
       foreach ($elements as $element) {
332 332
         $name = $element['@attributes']['name'];
333 333
         if (isset($element['@attributes']['entitytype']) AND $element['@attributes']['entitytype'] == 'attribute') {
334
-          $defaults['@attributes'][$name] = $values[$name];
334
+            $defaults['@attributes'][$name] = $values[$name];
335 335
         }
336 336
         else {
337
-          $defaults[$name] = $values[$name];
337
+            $defaults[$name] = $values[$name];
338 338
         }
339
-      }
340
-      break;
339
+        }
340
+        break;
341 341
     
342 342
     case 'apps':
343 343
       foreach ($elements as $element) {
344 344
         $defaults['app_id'] = array();
345 345
         foreach ($element['app'] as $app) {
346
-          $app_id = $app['@attributes']['id'];
347
-          if ($values['applications']["app_{$app_id}"]) {
346
+            $app_id = $app['@attributes']['id'];
347
+            if ($values['applications']["app_{$app_id}"]) {
348 348
             $defaults['app_id'][] = $app_id;
349
-          }
349
+            }
350 350
         }
351
-      }
352
-      break;
351
+        }
352
+        break;
353 353
       
354 354
     default:
355 355
     }
356
-  }
357
-  return $defaults;
356
+    }
357
+    return $defaults;
358 358
 }
359 359
 
360 360
 /**
361 361
  * Add an element to the form based on its definition
362 362
  */
363 363
 function boincwork_generate_prefs_element(&$form, $type, $elements, $user_prefs = null) {
364
-  switch ($type) {
365
-  case 'text':
364
+    switch ($type) {
365
+    case 'text':
366 366
     if (!is_numeric(key($elements))) {
367
-      $elements = array($elements);
367
+        $elements = array($elements);
368 368
     }
369 369
     foreach ($elements as $element) {
370
-      $name = $element['@attributes']['name'];
371
-      $default = $element['@attributes']['default'];
372
-      $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
373
-      $description = '';
374
-      if (isset($element['description'])) {
370
+        $name = $element['@attributes']['name'];
371
+        $default = $element['@attributes']['default'];
372
+        $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
373
+        $description = '';
374
+        if (isset($element['description'])) {
375 375
         $description = is_array($element['description']) ? $element['description']['@value'] : $element['description'];
376
-      }
376
+        }
377 377
       
378
-      $value = $default;
379
-      $user_pref = $user_prefs;
380
-      $entitytype = isset($element['@attributes']['entitytype']) ? $element['@attributes']['entitytype'] : 'element';
381
-      if ($entitytype == 'attribute') {
378
+        $value = $default;
379
+        $user_pref = $user_prefs;
380
+        $entitytype = isset($element['@attributes']['entitytype']) ? $element['@attributes']['entitytype'] : 'element';
381
+        if ($entitytype == 'attribute') {
382 382
         $user_pref = $user_prefs['@attributes'];
383
-      }
384
-      if (isset($user_pref[$name])) {
383
+        }
384
+        if (isset($user_pref[$name])) {
385 385
         if (is_array($user_pref[$name]) AND isset($user_pref[$name]['@value'])) {
386
-          $value = $user_pref[$name]['@value'];
386
+            $value = $user_pref[$name]['@value'];
387 387
         }
388 388
         else {
389
-          $value = $user_pref[$name];
389
+            $value = $user_pref[$name];
390
+        }
390 391
         }
391
-      }
392 392
       
393
-      // Use appropriate datatype
394
-      if (isset($element['@attributes']['datatype'])) {
393
+        // Use appropriate datatype
394
+        if (isset($element['@attributes']['datatype'])) {
395 395
         switch($element['@attributes']['datatype']) {
396 396
         case 'integer':
397 397
           $value = (int) $value;
398
-          break;
398
+            break;
399 399
           
400 400
         case 'float':
401 401
           $value = number_format((float) $value, 2);
402
-          break;
402
+            break;
403 403
         
404 404
         default:
405 405
         }
406
-      }
406
+        }
407 407
       
408
-      // Translate elements as appropriate
409
-      if ($title) {
408
+        // Translate elements as appropriate
409
+        if ($title) {
410 410
         i18nstrings_update('project:prefs_xml', _boinctranslate_supertrim($title));
411 411
         $title = i18nstrings('project:prefs_xml', _boinctranslate_supertrim($title));
412
-      }
413
-      if ($description) {
412
+        }
413
+        if ($description) {
414 414
         i18nstrings_update('project:prefs_xml', _boinctranslate_supertrim($description));
415 415
         $description = i18nstrings('project:prefs_xml', _boinctranslate_supertrim($description));
416
-      }
416
+        }
417 417
       
418
-      $form[$name] = array(
418
+        $form[$name] = array(
419 419
         '#title' => $title,
420 420
         '#type' => 'textfield',
421 421
         '#default_value' => $value,
422 422
         '#size' => 5,
423 423
         '#description' => $description . bts(' Default value: @default', array('@default' => $default), NULL, 'boinc:account-preferences-project')
424
-      );
424
+        );
425 425
     }
426 426
     break;
427 427
     
428
-  case 'boolean':
428
+    case 'boolean':
429 429
     if (!is_numeric(key($elements))) {
430
-      $elements = array($elements);
430
+        $elements = array($elements);
431 431
     }
432 432
     foreach ($elements as $element) {
433
-      $name = $element['@attributes']['name'];
434
-      $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
435
-      $default = (isset($element['@attributes']['selected']) AND $element['@attributes']['selected'] == 'true') ? 1 : 0;
436
-      $description = '';
437
-      if (isset($element['description'])) {
433
+        $name = $element['@attributes']['name'];
434
+        $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
435
+        $default = (isset($element['@attributes']['selected']) AND $element['@attributes']['selected'] == 'true') ? 1 : 0;
436
+        $description = '';
437
+        if (isset($element['description'])) {
438 438
         $description = is_array($element['description']) ? $element['description']['@value'] : $element['description'];
439
-      }
439
+        }
440 440
       
441
-      $value = $default;
442
-      $user_pref = $user_prefs;
443
-      $entitytype = isset($element['@attributes']['entitytype']) ? $element['@attributes']['entitytype'] : 'element';
444
-      if ($entitytype == 'attribute') {
441
+        $value = $default;
442
+        $user_pref = $user_prefs;
443
+        $entitytype = isset($element['@attributes']['entitytype']) ? $element['@attributes']['entitytype'] : 'element';
444
+        if ($entitytype == 'attribute') {
445 445
         $user_pref = $user_prefs['@attributes'];
446
-      }
447
-      if (isset($user_pref[$name])) {
446
+        }
447
+        if (isset($user_pref[$name])) {
448 448
         if (is_array($user_pref[$name]) AND isset($user_pref[$name]['@value'])) {
449
-          $value = $user_pref[$name]['@value'];
449
+            $value = $user_pref[$name]['@value'];
450 450
         }
451 451
         else {
452
-          $value = $user_pref[$name];
452
+            $value = $user_pref[$name];
453
+        }
453 454
         }
454
-      }
455 455
       
456
-      // Translate elements as appropriate
457
-      if ($title) {
456
+        // Translate elements as appropriate
457
+        if ($title) {
458 458
         i18nstrings_update('project:prefs_xml', _boinctranslate_supertrim($title));
459 459
         $title = i18nstrings('project:prefs_xml', _boinctranslate_supertrim($title));
460
-      }
461
-      if ($description) {
460
+        }
461
+        if ($description) {
462 462
         i18nstrings_update('project:prefs_xml', _boinctranslate_supertrim($description));
463 463
         $description = i18nstrings('project:prefs_xml', _boinctranslate_supertrim($description));
464
-      }
464
+        }
465 465
       
466
-      $form[$name] = array(
466
+        $form[$name] = array(
467 467
         '#title' => $title,
468 468
         '#type' => 'radios',
469 469
         '#options' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')),
470 470
         '#attributes' => array('class' => 'fancy'),
471 471
         '#default_value' => $value,
472 472
         '#description' => $description
473
-      );
473
+        );
474 474
     }
475 475
     break;
476 476
     
477
-  case 'radio':
477
+    case 'radio':
478 478
   case 'dropdown':
479 479
     
480 480
     if (!is_numeric(key($elements))) {
481
-      $elements = array($elements);
481
+        $elements = array($elements);
482 482
     }
483 483
     foreach ($elements as $element) {
484
-      $name = $element['@attributes']['name'];
485
-      $default = null;
486
-      $options = array();
487
-      foreach($element['items']['item'] as $item) {
484
+        $name = $element['@attributes']['name'];
485
+        $default = null;
486
+        $options = array();
487
+        foreach($element['items']['item'] as $item) {
488 488
         if (is_array($item)) {
489
-          $value = $item['@value'];
490
-          if ($default === NULL AND
489
+            $value = $item['@value'];
490
+            if ($default === NULL AND
491 491
               isset($item['@attributes']) AND
492 492
               isset($item['@attributes']['selected'])) {
493 493
             $default = ($item['@attributes']['selected'] == 'true') ? $item['@value'] : null;
494
-          }
494
+            }
495 495
         }
496 496
         else {
497
-          $value = $item;
497
+            $value = $item;
498 498
         }
499 499
         $options[$value] = $value;
500
-      }
501
-      $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
502
-      $description = '';
503
-      if (isset($element['description'])) {
500
+        }
501
+        $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
502
+        $description = '';
503
+        if (isset($element['description'])) {
504 504
         $description = is_array($element['description']) ? $element['description']['@value'] : $element['description'];
505
-      }
506
-      $user_pref = $user_prefs;
507
-      $entitytype = isset($element['@attributes']['entitytype']) ? $element['@attributes']['entitytype'] : 'element';
508
-      if ($entitytype == 'attribute') {
505
+        }
506
+        $user_pref = $user_prefs;
507
+        $entitytype = isset($element['@attributes']['entitytype']) ? $element['@attributes']['entitytype'] : 'element';
508
+        if ($entitytype == 'attribute') {
509 509
         $user_pref = $user_prefs['@attributes'];
510
-      }
511
-      $value = isset($user_pref[$name]) ? $user_pref[$name] : $default;
510
+        }
511
+        $value = isset($user_pref[$name]) ? $user_pref[$name] : $default;
512 512
       
513
-      // Translate elements as appropriate
514
-      if ($title) {
513
+        // Translate elements as appropriate
514
+        if ($title) {
515 515
         i18nstrings_update('project:prefs_xml', _boinctranslate_supertrim($title));
516 516
         $title = i18nstrings('project:prefs_xml', _boinctranslate_supertrim($title));
517
-      }
518
-      if ($description) {
517
+        }
518
+        if ($description) {
519 519
         i18nstrings_update('project:prefs_xml', _boinctranslate_supertrim($description));
520 520
         $description = i18nstrings('project:prefs_xml', _boinctranslate_supertrim($description));
521
-      }
521
+        }
522 522
       
523
-      $form[$name] = array(
523
+        $form[$name] = array(
524 524
         '#title' => $title,
525 525
         '#type' => ($type == 'radio') ? 'radios' : 'select',
526 526
         '#options' => $options,
527 527
         '#attributes' => array('class' => 'fancy'),
528 528
         '#default_value' => $value,
529 529
         '#description' => $description . bts(' Default value: @default', array('@default' =>$default), NULL, 'boinc:account-preferences-project')
530
-      );
530
+        );
531 531
     }
532 532
     break;
533 533
     
534
-  case 'apps':
534
+    case 'apps':
535 535
     $title = is_array($elements['title']) ? $elements['title']['@value'] : $elements['title'];
536 536
     
537
-      // Translate elements as appropriate
538
-      if ($title) {
537
+        // Translate elements as appropriate
538
+        if ($title) {
539 539
         i18nstrings_update('project:prefs_xml', _boinctranslate_supertrim($title));
540 540
         $title = i18nstrings('project:prefs_xml', _boinctranslate_supertrim($title));
541
-      }
541
+        }
542 542
     
543 543
     $form['applications'] = array(
544
-      '#title' => bts('Applications', array(), NULL, 'boinc:account-preferences'),
545
-      '#type' => 'fieldset',
546
-      '#description' => $title,
547
-      '#collapsible' => TRUE,
548
-      '#collapsed' => FALSE
544
+        '#title' => bts('Applications', array(), NULL, 'boinc:account-preferences'),
545
+        '#type' => 'fieldset',
546
+        '#description' => $title,
547
+        '#collapsible' => TRUE,
548
+        '#collapsed' => FALSE
549 549
     );
550 550
     $applications = array();
551 551
     if (!is_array($user_prefs['app_id'])) {
552
-      $user_prefs['app_id'] = array($user_prefs['app_id']);
552
+        $user_prefs['app_id'] = array($user_prefs['app_id']);
553 553
     }
554 554
     foreach ($user_prefs['app_id'] as $app) {
555
-      if (!$app) continue;
556
-      if (is_array($app) AND isset($app['@value'])) {
555
+        if (!$app) continue;
556
+        if (is_array($app) AND isset($app['@value'])) {
557 557
         $app = $app['@value'];
558
-      }
559
-      $applications[] = $app;
558
+        }
559
+        $applications[] = $app;
560 560
     }
561 561
     foreach ($elements['app'] as $app) {
562
-      $app_id = $app['@attributes']['id'];
563
-      $app_name = $app['@value'];
564
-      $app_enabled = TRUE;
565
-      if (isset($app['@attributes']['enabled']) AND
562
+        $app_id = $app['@attributes']['id'];
563
+        $app_name = $app['@value'];
564
+        $app_enabled = TRUE;
565
+        if (isset($app['@attributes']['enabled']) AND
566 566
           $app['@attributes']['enabled'] == 'false') {
567 567
         $app_enabled = FALSE;
568
-      }
569
-      if ($applications) {
568
+        }
569
+        if ($applications) {
570 570
         $checked = in_array($app_id, $applications);
571
-      } else {
571
+        } else {
572 572
         $checked = TRUE;
573 573
         if (isset($app['@attributes']['selected']) AND
574 574
             $app['@attributes']['selected'] == 'false') {
575
-          $checked = FALSE;
575
+            $checked = FALSE;
576 576
         }
577
-      }
578
-      $form['applications']["app_{$app_id}"] = array(
577
+        }
578
+        $form['applications']["app_{$app_id}"] = array(
579 579
         '#title' => $app_name,
580 580
         '#type' => 'checkbox',
581 581
         '#default_value' => ($checked) ? 'x' : false,
582 582
         '#disabled' => !$app_enabled
583
-      );
583
+        );
584 584
     }
585 585
     
586 586
     break;
587 587
     
588
-  case 'group':
588
+    case 'group':
589 589
     if (!is_numeric(key($elements))) {
590
-      $elements = array($elements);
590
+        $elements = array($elements);
591 591
     }
592 592
     foreach ($elements as $key => $element) {
593
-      $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
594
-      $name = str_replace(' ','_',strtolower($title));
595
-      $name = "group_{$name}";
593
+        $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
594
+        $name = str_replace(' ','_',strtolower($title));
595
+        $name = "group_{$name}";
596 596
       
597
-      // Translate elements as appropriate
598
-      if ($title) {
597
+        // Translate elements as appropriate
598
+        if ($title) {
599 599
         i18nstrings_update('project:prefs_xml', _boinctranslate_supertrim($title));
600 600
         $title = i18nstrings('project:prefs_xml', _boinctranslate_supertrim($title));
601
-      }
601
+        }
602 602
       
603
-      $form[$name] = array(
604
-          '#title' => $title,
605
-          '#type' => 'fieldset',
606
-          '#tree' => FALSE,
607
-          //'#description' => t('Notes about this group of fields'),
608
-          '#collapsible' => TRUE,
609
-          '#collapsed' => FALSE
610
-      );
611
-      // Recursively populate the compound element
612
-      foreach ($element as $child_type => $child) {
603
+        $form[$name] = array(
604
+            '#title' => $title,
605
+            '#type' => 'fieldset',
606
+            '#tree' => FALSE,
607
+            //'#description' => t('Notes about this group of fields'),
608
+            '#collapsible' => TRUE,
609
+            '#collapsed' => FALSE
610
+        );
611
+        // Recursively populate the compound element
612
+        foreach ($element as $child_type => $child) {
613 613
         boincwork_generate_prefs_element($form[$name], $child_type, $child, $user_prefs);
614
-      }
614
+        }
615 615
     }
616 616
     break;
617 617
     
618
-  case 'compound':
618
+    case 'compound':
619 619
     if (!is_numeric(key($elements))) {
620
-      $elements = array($elements);
620
+        $elements = array($elements);
621 621
     }
622 622
     foreach ($elements as $element) {
623
-      $name = $element['@attributes']['name'];
624
-      $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
623
+        $name = $element['@attributes']['name'];
624
+        $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
625 625
       
626
-      // Translate elements as appropriate
627
-      if ($title) {
626
+        // Translate elements as appropriate
627
+        if ($title) {
628 628
         i18nstrings_update('project:prefs_xml', _boinctranslate_supertrim($title));
629 629
         $title = i18nstrings('project:prefs_xml', _boinctranslate_supertrim($title));
630
-      }
630
+        }
631 631
       
632
-      $form[$name] = array(
633
-          '#title' => $title,
634
-          '#type' => 'fieldset',
635
-          //'#description' => t('Notes about this group of fields'),
636
-          '#collapsible' => TRUE,
637
-          '#collapsed' => FALSE
638
-      );
639
-      // Recursively populate the compound element
640
-      foreach ($element['attributes'] as $child_type => $child) {
632
+        $form[$name] = array(
633
+            '#title' => $title,
634
+            '#type' => 'fieldset',
635
+            //'#description' => t('Notes about this group of fields'),
636
+            '#collapsible' => TRUE,
637
+            '#collapsed' => FALSE
638
+        );
639
+        // Recursively populate the compound element
640
+        foreach ($element['attributes'] as $child_type => $child) {
641 641
         boincwork_generate_prefs_element($form[$name], $child_type, $child, $user_prefs[$name]['@attributes']);
642
-      }
642
+        }
643 643
     }
644 644
     break;
645 645
     
@@ -655,24 +655,24 @@  discard block
 block discarded – undo
655 655
  */
656 656
 function boincwork_make_prefs_table($prefs, $top_level = TRUE) {
657 657
 
658
-  $prefs_table = array();
659
-  $uncategorized = array();
658
+    $prefs_table = array();
659
+    $uncategorized = array();
660 660
   
661
-  // Parse the project preferences form
662
-  foreach ($prefs as $key => $element) {
661
+    // Parse the project preferences form
662
+    foreach ($prefs as $key => $element) {
663 663
     
664 664
     // Determine which type of element this is and act accordingly
665 665
     $element_type = NULL;
666 666
     if (is_array($element) AND isset($element['#type'])) {
667
-      $element_type = $element['#type'];
667
+        $element_type = $element['#type'];
668 668
     }
669 669
     switch ($element_type) {
670 670
     case 'fieldset':
671 671
       $prefs_table[$key] = array(
672 672
         'name' => $element['#title'],
673 673
         'elements' => boincwork_make_prefs_table($element, FALSE),
674
-      );
675
-      break;
674
+        );
675
+        break;
676 676
     case 'textfield':
677 677
     case 'radios':
678 678
     case 'checkbox':
@@ -682,45 +682,45 @@  discard block
 block discarded – undo
682 682
         switch ($key) {
683 683
         case 'start_hour':
684 684
           $element['#title'] = bts('Compute only between:', array(), NULL, 'boinc:account-preferences-computing');
685
-          break;
685
+            break;
686 686
         case 'net_start_hour':
687 687
           $element['#title'] = bts('Transfer files only between:', array(), NULL, 'boinc:account-preferences-comuting');
688
-          break;
688
+            break;
689 689
         default:
690 690
         }
691
-      }
692
-      $prefs_element = array(
691
+        }
692
+        $prefs_element = array(
693 693
         'name' => (isset($element['#title'])) ? $element['#title'] : '',
694 694
         'description' => (isset($element['#description'])) ? $element['#description'] : '',
695 695
         'default_value' => (isset($element['#default_value'])) ? $element['#default_value'] : NULL,
696
-      );
697
-      if ($top_level) {
696
+        );
697
+        if ($top_level) {
698 698
         $uncategorized[$key] = $prefs_element;
699
-      }
700
-      else {
699
+        }
700
+        else {
701 701
         $prefs_table[$key] = $prefs_element;
702
-      }
703
-      break;
702
+        }
703
+        break;
704 704
     default:
705 705
     }
706
-  }
706
+    }
707 707
   
708
-  if ($prefs_table AND $uncategorized) {
708
+    if ($prefs_table AND $uncategorized) {
709 709
     // Throw any settings that don't fit elsewhere into "other"
710 710
     $prefs_table['other'] = array(
711
-      'name' => bts('Other settings', array(), NULL, 'boinc:account-preferences'),
712
-      'elements' => $uncategorized,
711
+        'name' => bts('Other settings', array(), NULL, 'boinc:account-preferences'),
712
+        'elements' => $uncategorized,
713 713
     );
714
-  }
715
-  elseif ($uncategorized) {
714
+    }
715
+    elseif ($uncategorized) {
716 716
     // If nothing is categorized, output all prefs under a general "settings"
717 717
     $prefs_table['settings'] = array(
718
-      'name' => bts('Settings', array(), NULL, 'boinc:account-preferences'),
719
-      'elements' => $uncategorized,
718
+        'name' => bts('Settings', array(), NULL, 'boinc:account-preferences'),
719
+        'elements' => $uncategorized,
720 720
     );
721
-  }
721
+    }
722 722
   
723
-  return $prefs_table;
723
+    return $prefs_table;
724 724
 }
725 725
  
726 726
 /**
@@ -728,33 +728,33 @@  discard block
 block discarded – undo
728 728
  */
729 729
 function boincwork_load_prefs($type = 'general', $venue = null, $account = null) {
730 730
   
731
-  require_boinc(array('user'));
731
+    require_boinc(array('user'));
732 732
   
733
-  // Load the BOINC user object
734
-  if (!$account) {
733
+    // Load the BOINC user object
734
+    if (!$account) {
735 735
     global $user;
736 736
     $account = $user;
737
-  }
738
-  $account = user_load($account->uid);
739
-  $boincuser = BoincUser::lookup_id($account->boincuser_id);
737
+    }
738
+    $account = user_load($account->uid);
739
+    $boincuser = BoincUser::lookup_id($account->boincuser_id);
740 740
   
741
-  // Load the desired preferences for the user
742
-  $main_prefs = array();
743
-  if ($type == 'project') {
741
+    // Load the desired preferences for the user
742
+    $main_prefs = array();
743
+    if ($type == 'project') {
744 744
     if ($boincuser->project_prefs) {
745
-      $main_prefs = load_configuration($boincuser->project_prefs);
746
-      $main_prefs = (array) $main_prefs['project_preferences'];
745
+        $main_prefs = load_configuration($boincuser->project_prefs);
746
+        $main_prefs = (array) $main_prefs['project_preferences'];
747 747
     }
748
-  }
749
-  else {
748
+    }
749
+    else {
750 750
     if ($boincuser->global_prefs) {
751
-      $main_prefs = load_configuration($boincuser->global_prefs);
752
-      $main_prefs = (array) $main_prefs['global_preferences'];
751
+        $main_prefs = load_configuration($boincuser->global_prefs);
752
+        $main_prefs = (array) $main_prefs['global_preferences'];
753
+    }
753 754
     }
754
-  }
755 755
   
756
-  // Return general preferences or a subset based on venue
757
-  if (!$venue OR $venue == 'generic') {
756
+    // Return general preferences or a subset based on venue
757
+    if (!$venue OR $venue == 'generic') {
758 758
     unset($main_prefs['venue']);
759 759
     // Use the length of the $main_prefs array as a condition as to
760 760
     // whether the preferences have already been set. This is
@@ -762,23 +762,23 @@  discard block
 block discarded – undo
762 762
     if (count($main_prefs) < 3)
763 763
         $main_prefs['@attributes'] = array('cleared' => 1);
764 764
     return $main_prefs;
765
-  }
766
-  else {
765
+    }
766
+    else {
767 767
     if (isset($main_prefs['venue'])) {
768
-      if (!is_numeric(key($main_prefs['venue']))) {
768
+        if (!is_numeric(key($main_prefs['venue']))) {
769 769
         $main_prefs['venue'] = array($main_prefs['venue']);
770
-      }
771
-      foreach ($main_prefs['venue'] as $key => $prefs_venue) {
770
+        }
771
+        foreach ($main_prefs['venue'] as $key => $prefs_venue) {
772 772
         if (isset($prefs_venue['@attributes']['name']) AND $prefs_venue['@attributes']['name'] == $venue) {
773
-          return $main_prefs['venue'][$key];
773
+            return $main_prefs['venue'][$key];
774
+        }
774 775
         }
775
-      }
776 776
     }
777
-  }
777
+    }
778 778
 
779
-  return array(
779
+    return array(
780 780
     '@attributes' => array('name' => $venue, 'cleared' => 1)
781
-  );
781
+    );
782 782
 }
783 783
 
784 784
 /**
@@ -786,104 +786,104 @@  discard block
 block discarded – undo
786 786
  */
787 787
 function boincwork_save_prefs($prefs, $type = 'general', $venue = null, $account = null) {
788 788
   
789
-  require_boinc(array('user'));
789
+    require_boinc(array('user'));
790 790
   
791
-  // Load existing project prefs from the BOINC user object
792
-  if (!$account) {
791
+    // Load existing project prefs from the BOINC user object
792
+    if (!$account) {
793 793
     global $user;
794 794
     $account = $user;
795
-  }
796
-  $account = user_load($account->uid);
797
-  $boincuser = BoincUser::lookup_id($account->boincuser_id);
795
+    }
796
+    $account = user_load($account->uid);
797
+    $boincuser = BoincUser::lookup_id($account->boincuser_id);
798 798
   
799
-  // Load the specified preferences for the user
800
-  $main_prefs = array();
801
-  if ($type == 'project') {
799
+    // Load the specified preferences for the user
800
+    $main_prefs = array();
801
+    if ($type == 'project') {
802 802
     if ($boincuser->project_prefs) {
803
-      $main_prefs = load_configuration($boincuser->project_prefs);
804
-      $main_prefs = (array) $main_prefs['project_preferences'];
803
+        $main_prefs = load_configuration($boincuser->project_prefs);
804
+        $main_prefs = (array) $main_prefs['project_preferences'];
805 805
     }
806
-  }
807
-  else {
806
+    }
807
+    else {
808 808
     if ($boincuser->global_prefs) {
809
-      $main_prefs = load_configuration($boincuser->global_prefs);
810
-      $main_prefs = (array) $main_prefs['global_preferences'];
809
+        $main_prefs = load_configuration($boincuser->global_prefs);
810
+        $main_prefs = (array) $main_prefs['global_preferences'];
811
+    }
811 812
     }
812
-  }
813 813
   
814
-  // Save all preferences or a subset based on venue
815
-  //drupal_set_message('<pre>' . print_r($main_prefs, true) . '</pre>');
816
-  $new_venue = true;
817
-  if (!$venue OR $venue == 'generic') {
814
+    // Save all preferences or a subset based on venue
815
+    //drupal_set_message('<pre>' . print_r($main_prefs, true) . '</pre>');
816
+    $new_venue = true;
817
+    if (!$venue OR $venue == 'generic') {
818 818
     //$main_prefs = $prefs;
819 819
     $main_prefs = $prefs + $main_prefs;
820
-  }
821
-  else {
820
+    }
821
+    else {
822 822
     if (isset($main_prefs['venue'])) {
823
-      if (!is_numeric(key($main_prefs['venue']))) {
823
+        if (!is_numeric(key($main_prefs['venue']))) {
824 824
         $main_prefs['venue'] = array($main_prefs['venue']);
825
-      }
826
-      foreach ($main_prefs['venue'] as $key => $prefs_venue) {
825
+        }
826
+        foreach ($main_prefs['venue'] as $key => $prefs_venue) {
827 827
         if (isset($prefs_venue['@attributes']['name']) AND $prefs_venue['@attributes']['name'] == $venue) {
828
-          if ($prefs) {
828
+            if ($prefs) {
829 829
             $main_prefs['venue'][$key] = $prefs;
830
-          }
831
-          else {
830
+            }
831
+            else {
832 832
             // If prefs is null, clear out this preference set
833 833
             unset($main_prefs['venue'][$key]);
834 834
             if (count($main_prefs['venue']) == 0) {
835
-              // If that was the only preference set configured, unset the
836
-              // venue tag altogether
837
-              unset($main_prefs['venue']);
835
+                // If that was the only preference set configured, unset the
836
+                // venue tag altogether
837
+                unset($main_prefs['venue']);
838 838
             }
839
-          }
840
-          $new_venue = false;
841
-          break;
839
+            }
840
+            $new_venue = false;
841
+            break;
842
+        }
842 843
         }
843
-      }
844 844
     }
845 845
     if ($new_venue) {
846
-      $main_prefs['venue'][] = $prefs;
846
+        $main_prefs['venue'][] = $prefs;
847
+    }
847 848
     }
848
-  }
849 849
 
850
-  // Set modified time
851
-  if ($type == 'project') {
850
+    // Set modified time
851
+    if ($type == 'project') {
852 852
     if (!isset($main_prefs['modified'])) {
853
-      $main_prefs = array_merge(array('modified' => 0), $main_prefs);
853
+        $main_prefs = array_merge(array('modified' => 0), $main_prefs);
854 854
     }
855 855
     $main_prefs['modified'] = time();
856
-  } else {
856
+    } else {
857 857
     if (!isset($main_prefs['mod_time'])) {
858
-      $main_prefs = array_merge(array('mod_time' => 0), $main_prefs);
858
+        $main_prefs = array_merge(array('mod_time' => 0), $main_prefs);
859 859
     }
860 860
     $main_prefs['mod_time'] = time();
861 861
     // unset source information, the Client will fill this in again
862 862
     if (isset($main_prefs['source_project'])) {
863
-      unset($main_prefs['source_project']);
863
+        unset($main_prefs['source_project']);
864 864
     }
865 865
     if (isset($main_prefs['source_scheduler'])) {
866
-      unset($main_prefs['source_scheduler']);
866
+        unset($main_prefs['source_scheduler']);
867
+    }
867 868
     }
868
-  }
869 869
 
870
-  // Convert prefs back to XML and save to database
871
-  $result = null;
872
-  if ($type == 'project') {
870
+    // Convert prefs back to XML and save to database
871
+    $result = null;
872
+    if ($type == 'project') {
873 873
     $main_prefs = array('project_preferences' => $main_prefs);
874 874
     $boincuser->project_prefs = save_configuration($main_prefs);
875 875
     db_set_active('boinc_rw');
876 876
     $result = db_query("UPDATE user SET project_prefs = '{$boincuser->project_prefs}' WHERE id = '{$boincuser->id}'");
877 877
     db_set_active('default');
878
-  }
879
-  else {
878
+    }
879
+    else {
880 880
     $main_prefs = array('global_preferences' => $main_prefs);
881 881
     $boincuser->global_prefs = save_configuration($main_prefs);
882 882
     db_set_active('boinc_rw');
883 883
     $result = db_query("UPDATE user SET global_prefs = '{$boincuser->global_prefs}' WHERE id = '{$boincuser->id}'");
884 884
     db_set_active('default');
885
-  }
886
-  return $result;
885
+    }
886
+    return $result;
887 887
 }
888 888
 
889 889
 
@@ -900,9 +900,9 @@  discard block
 block discarded – undo
900 900
  *username. Called from privacy preference form.
901 901
  */
902 902
 function boincwork_ignore_user_add_user_username($name = NULL) {
903
-  global $user;
903
+    global $user;
904 904
 
905
-  if (isset($name)) {
905
+    if (isset($name)) {
906 906
     // Get the BOINC ID from the name string, and lookup the
907 907
     // corresponding drupal user.
908 908
     $boincname = substr($name, 0, strrpos($name, '_'));
@@ -911,84 +911,84 @@  discard block
 block discarded – undo
911 911
     $iuid = get_drupal_id($boincid);
912 912
 
913 913
     if ($user->uid == $iuid) {
914
-      drupal_set_message(bts('You can\'t add yourself to your own ignore list.', array(), NULL, 'boinc:ignore-user-error-message'), 'error');
915
-      drupal_goto('account/prefs/privacy');
914
+        drupal_set_message(bts('You can\'t add yourself to your own ignore list.', array(), NULL, 'boinc:ignore-user-error-message'), 'error');
915
+        drupal_goto('account/prefs/privacy');
916 916
     }
917 917
 
918 918
     if (is_numeric($iuid) && $iuid > 0) {
919
-      if (!db_result(db_query('SELECT COUNT(iuid) FROM {ignore_user} WHERE uid = %d AND iuid = %d', $user->uid, $iuid))) {
919
+        if (!db_result(db_query('SELECT COUNT(iuid) FROM {ignore_user} WHERE uid = %d AND iuid = %d', $user->uid, $iuid))) {
920 920
         db_query('INSERT INTO {ignore_user} (uid, iuid) VALUES (%d, %d)', $user->uid, $iuid);
921
-      }// endif db_result
921
+        }// endif db_result
922 922
 
923
-      if (module_exists('pm_block_user')) {
923
+        if (module_exists('pm_block_user')) {
924 924
         if (!db_result(db_query('SELECT COUNT(recipient) FROM {pm_block_user} WHERE author = %d AND recipient = %d', $iuid, $user->uid))) {
925
-          db_query('INSERT INTO {pm_block_user} (author, recipient) VALUES (%d, %d)', $iuid, $user->uid);
925
+            db_query('INSERT INTO {pm_block_user} (author, recipient) VALUES (%d, %d)', $iuid, $user->uid);
926 926
         }// endif db_result
927
-      }// endif module_exists('pm_block_user')
927
+        }// endif module_exists('pm_block_user')
928 928
 
929 929
     }// endif $iuid
930
-  }
930
+    }
931 931
 }
932 932
 
933 933
 /**
934 934
  * Add another user's UID to the current user's ignore list.
935 935
  */
936 936
 function boincwork_ignore_user_add_user($iuid = NULL) {
937
-  global $user;
937
+    global $user;
938 938
 
939
-  if ($user->uid == $iuid) {
939
+    if ($user->uid == $iuid) {
940 940
     drupal_set_message(bts('You can\'t add yourself to your own ignore list.', array(), NULL, 'boinc:ignore-user-error-message'), 'error');
941 941
     drupal_goto();
942
-  }
942
+    }
943 943
 
944
-  $otheraccount = user_load($iuid);
944
+    $otheraccount = user_load($iuid);
945 945
 
946
-  if (is_numeric($iuid) && $iuid > 0) {
946
+    if (is_numeric($iuid) && $iuid > 0) {
947 947
     if (!db_result(db_query('SELECT COUNT(iuid) FROM {ignore_user} WHERE uid = %d AND iuid = %d', $user->uid, $iuid))) {
948
-      db_query('INSERT INTO {ignore_user} (uid, iuid) VALUES (%d, %d)', $user->uid, $iuid);
948
+        db_query('INSERT INTO {ignore_user} (uid, iuid) VALUES (%d, %d)', $user->uid, $iuid);
949 949
     }// endif db_result
950 950
 
951 951
     if (module_exists('pm_block_user')) {
952
-      if (!db_result(db_query('SELECT COUNT(recipient) FROM {pm_block_user} WHERE author = %d AND recipient = %d', $iuid, $user->uid))) {
952
+        if (!db_result(db_query('SELECT COUNT(recipient) FROM {pm_block_user} WHERE author = %d AND recipient = %d', $iuid, $user->uid))) {
953 953
         db_query('INSERT INTO {pm_block_user} (author, recipient) VALUES (%d, %d)', $iuid, $user->uid);
954
-      }// endif db_result
954
+        }// endif db_result
955 955
     }// endif module_exists('pm_block_user')
956 956
 
957 957
     drupal_set_message(
958
-      bts('@username has been added to your ignore list. See your !privacy_preferences for more details.',
958
+        bts('@username has been added to your ignore list. See your !privacy_preferences for more details.',
959 959
         array(
960
-          '@username' => $otheraccount->boincuser_name,
961
-          '!privacy_preferences' => l(bts('privacy preferences', array(), NULL, 'boinc:ignore-user-add'), 'account/prefs/privacy'),
960
+            '@username' => $otheraccount->boincuser_name,
961
+            '!privacy_preferences' => l(bts('privacy preferences', array(), NULL, 'boinc:ignore-user-add'), 'account/prefs/privacy'),
962 962
         ),
963 963
         NULL, 'boinc:ignore-user-add'),
964
-      'status');
964
+        'status');
965 965
     drupal_goto();
966
-  }
967
-  else {
966
+    }
967
+    else {
968 968
     drupal_not_found();
969
-  }// endif iuid
969
+    }// endif iuid
970 970
 }
971 971
 
972 972
 /**
973 973
  * Remove user from user's ignore list.
974 974
  */
975 975
 function boincwork_ignore_user_remove_user($iuid = NULL) {
976
-  global $user;
977
-  $otheraccount = user_load($iuid);
976
+    global $user;
977
+    $otheraccount = user_load($iuid);
978 978
 
979
-  db_query('DELETE FROM {ignore_user} WHERE uid = %d AND iuid = %d', $user->uid, $iuid);
980
-  if (module_exists('pm_block_user')) {
979
+    db_query('DELETE FROM {ignore_user} WHERE uid = %d AND iuid = %d', $user->uid, $iuid);
980
+    if (module_exists('pm_block_user')) {
981 981
     db_query('DELETE FROM {pm_block_user} WHERE author = %d AND recipient = %d', $iuid, $user->uid);
982
-  }// endif module_exists
983
-  drupal_set_message(
982
+    }// endif module_exists
983
+    drupal_set_message(
984 984
     bts('@username has been removed from your ignore list. See your !privacy_preferences for more details.',
985
-      array(
985
+        array(
986 986
         '@username' => $otheraccount->boincuser_name,
987 987
         '!privacy_preferences' => l(bts('privacy preferences', array(), NULL, 'boinc:ignore-user-add'), 'account/prefs/privacy'),
988
-      ),
989
-      NULL, 'boinc:ignore-user-add'),
988
+        ),
989
+        NULL, 'boinc:ignore-user-add'),
990 990
     'status');
991
-  drupal_goto('account/prefs/privacy');
991
+    drupal_goto('account/prefs/privacy');
992 992
 }
993 993
 
994 994
 /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
@@ -1002,18 +1002,18 @@  discard block
 block discarded – undo
1002 1002
  */
1003 1003
 function boincwork_load_privacyconsenttypes() {
1004 1004
 
1005
-  db_set_active('boinc_rw');
1006
-  $db_result = db_query("SELECT id,shortname,description FROM consent_type WHERE enabled=1 AND privacypref=1 ORDER by project_specific ASC");
1007
-  db_set_active('drupal');
1005
+    db_set_active('boinc_rw');
1006
+    $db_result = db_query("SELECT id,shortname,description FROM consent_type WHERE enabled=1 AND privacypref=1 ORDER by project_specific ASC");
1007
+    db_set_active('drupal');
1008 1008
 
1009
-  if ($db_result) {
1009
+    if ($db_result) {
1010 1010
     $consent_types = array();
1011 1011
     while ($result = db_fetch_array($db_result)) {
1012
-      $consent_types[] = $result;
1012
+        $consent_types[] = $result;
1013 1013
     }
1014 1014
     return $consent_types;
1015
-  }
1016
-  return array();
1015
+    }
1016
+    return array();
1017 1017
 }
1018 1018
 
1019 1019
 /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
@@ -1025,94 +1025,94 @@  discard block
 block discarded – undo
1025 1025
  */ 
1026 1026
 function boincwork_set_default_venue($venue = '') {
1027 1027
   
1028
-  global $user;
1029
-  $account = user_load($user->uid);
1028
+    global $user;
1029
+    $account = user_load($user->uid);
1030 1030
   
1031
-  if ($venue == 'generic') {
1031
+    if ($venue == 'generic') {
1032 1032
     $venue = '';
1033
-  }
1033
+    }
1034 1034
   
1035
-  db_set_active('boinc_rw');
1036
-  db_query("
1035
+    db_set_active('boinc_rw');
1036
+    db_query("
1037 1037
     UPDATE user
1038 1038
     SET venue = '%s'
1039 1039
     WHERE id = %d",
1040 1040
     $venue, $account->boincuser_id
1041
-  );
1042
-  db_set_active('default');
1041
+    );
1042
+    db_set_active('default');
1043 1043
 }
1044 1044
 
1045 1045
 /**
1046 1046
  * Recursively validate submitted form values against a set of rules
1047 1047
  */ 
1048 1048
 function boincwork_validate_form($validation_rules, $values, $path = array()) {
1049
-  foreach ($validation_rules as $field => $rules) {
1049
+    foreach ($validation_rules as $field => $rules) {
1050 1050
     $parents = $path;
1051 1051
     if (is_array($values[$field])) {
1052
-      // Process nested form elements
1053
-      $parents[] = $field;
1054
-      boincwork_validate_form($rules, $values[$field], $parents);
1052
+        // Process nested form elements
1053
+        $parents[] = $field;
1054
+        boincwork_validate_form($rules, $values[$field], $parents);
1055 1055
     }
1056 1056
     else {
1057
-      if ($parents) {
1057
+        if ($parents) {
1058 1058
         // form_set_error() identifies nested form elements with '][' as a
1059 1059
         // delimiter between each parent and child element
1060 1060
         $parents[] = $field;
1061 1061
         $form_field = implode('][', $parents);
1062
-      }
1063
-      else {
1062
+        }
1063
+        else {
1064 1064
         $form_field = $field;
1065
-      }
1066
-      if (isset($rules['datatype']) AND !boincwork_validate_datatype($values[$field], $rules['datatype'])) {
1065
+        }
1066
+        if (isset($rules['datatype']) AND !boincwork_validate_datatype($values[$field], $rules['datatype'])) {
1067 1067
         form_set_error($form_field, bts('Invalid data type for @field', array('@field' => $field), NULL, 'boinc:account-preferences'));
1068
-      }
1069
-      if (isset($rules['min']) AND $values[$field] < $rules['min']) {
1068
+        }
1069
+        if (isset($rules['min']) AND $values[$field] < $rules['min']) {
1070 1070
         form_set_error($form_field, bts('Minimum value not met for @field', array('@field' => $field), NULL, 'boinc:account-preferences'));
1071
-      }
1072
-      if (isset($rules['max']) AND $values[$field] > $rules['max']) {
1071
+        }
1072
+        if (isset($rules['max']) AND $values[$field] > $rules['max']) {
1073 1073
         form_set_error($form_field, bts('Maximum value exceeded for @field', array('@field' => $field), NULL, 'boinc:account-preferences'));
1074
-      }
1074
+        }
1075
+    }
1075 1076
     }
1076
-  }
1077 1077
 }
1078 1078
 
1079 1079
 /**
1080 1080
  * Check that numeric data conforms to specifications
1081 1081
  */
1082 1082
 function boincwork_validate_datatype($data, $datatype = NULL) {
1083
-  switch ($datatype) {
1084
-  case 'float':
1083
+    switch ($datatype) {
1084
+    case 'float':
1085 1085
     if (!is_numeric($data)) {
1086
-      return FALSE;
1086
+        return FALSE;
1087 1087
     }
1088 1088
     $data += 0.0;
1089 1089
     if (!is_float($data)) {
1090
-      return FALSE;
1090
+        return FALSE;
1091 1091
     }
1092 1092
     break;
1093 1093
     
1094
-  case 'integer':
1094
+    case 'integer':
1095 1095
     if (!is_numeric($data)) {
1096
-      return FALSE;
1096
+        return FALSE;
1097 1097
     }
1098 1098
     $data += 0;
1099 1099
     if (!is_int($data)) {
1100
-      return FALSE;
1100
+        return FALSE;
1101 1101
     }
1102 1102
     break;
1103 1103
   
1104
-  case 'text':
1104
+    case 'text':
1105 1105
   default:
1106 1106
     
1107 1107
   }
1108
-  return TRUE;
1108
+    return TRUE;
1109 1109
 }
1110 1110
 
1111 1111
 /**
1112 1112
  * Format a number to be displayed using a maximum number of digits
1113 1113
  */ 
1114 1114
 function boincwork_format_stats($number, $max_digits = 4) {
1115
-  $suffix = array(
1115
+    $suffix = array(
1116 1116
     0 => '',
1117 1117
     1 => 'k',
1118 1118
     2 => 'M',
@@ -1122,94 +1122,94 @@  discard block
 block discarded – undo
1122 1122
     6 => 'E',
1123 1123
     7 => 'Z',
1124 1124
     8 => 'Y'
1125
-  );
1126
-  if (!is_numeric($number)) $number = 0;
1125
+    );
1126
+    if (!is_numeric($number)) $number = 0;
1127 1127
   
1128
-  $digits = floor(log($number, 10)) + 1;
1129
-  $magnitude = 0;
1130
-  $precision = 0;
1131
-  if ($digits > $max_digits) {
1128
+    $digits = floor(log($number, 10)) + 1;
1129
+    $magnitude = 0;
1130
+    $precision = 0;
1131
+    if ($digits > $max_digits) {
1132 1132
     $magnitude = floor(($digits - ($max_digits - 3)) / 3);
1133 1133
     $precision = $max_digits - ($digits - ($magnitude * 3) + 1);
1134 1134
     $number = round($number / pow(1000, $magnitude), $precision);
1135
-  }
1136
-  $number = number_format($number, $precision) . (($magnitude) ? "{$suffix[$magnitude]}" : '');
1135
+    }
1136
+    $number = number_format($number, $precision) . (($magnitude) ? "{$suffix[$magnitude]}" : '');
1137 1137
   
1138
-  return $number;
1138
+    return $number;
1139 1139
 }
1140 1140
 
1141
-  //------------------------------------------------------------------------------------------------
1142
-  //  load_configuration(): Convert structured text/xml to array
1143
-  //------------------------------------------------------------------------------------------------
1141
+    //------------------------------------------------------------------------------------------------
1142
+    //  load_configuration(): Convert structured text/xml to array
1143
+    //------------------------------------------------------------------------------------------------
1144 1144
   
1145
-  function load_configuration($text)
1146
-  {
1147
-      if (preg_match('/^\<\?xml .*\?\>$/i', $text)) return null;
1148
-      if ($xml = text_to_xml($text)) return xml_to_array($xml);
1149
-      return false;
1150
-  }
1145
+    function load_configuration($text)
1146
+    {
1147
+        if (preg_match('/^\<\?xml .*\?\>$/i', $text)) return null;
1148
+        if ($xml = text_to_xml($text)) return xml_to_array($xml);
1149
+        return false;
1150
+    }
1151 1151
   
1152
-  //------------------------------------------------------------------------------------------------
1153
-  //  save_configuration(): Convert array to structured text/xml
1154
-  //------------------------------------------------------------------------------------------------
1152
+    //------------------------------------------------------------------------------------------------
1153
+    //  save_configuration(): Convert array to structured text/xml
1154
+    //------------------------------------------------------------------------------------------------
1155 1155
   
1156
-  function save_configuration($array)
1157
-  {
1158
-      if ($xml = array_to_xml($array)) return xml_to_text($xml, false, true);
1159
-      return false;
1160
-  }
1156
+    function save_configuration($array)
1157
+    {
1158
+        if ($xml = array_to_xml($array)) return xml_to_text($xml, false, true);
1159
+        return false;
1160
+    }
1161 1161
   
1162
-  //------------------------------------------------------------------------------------------------
1163
-  //  array_to_xml(): Take a multidimensional array and convert it to a structured
1164
-  //  DOM XML object
1165
-  //------------------------------------------------------------------------------------------------
1162
+    //------------------------------------------------------------------------------------------------
1163
+    //  array_to_xml(): Take a multidimensional array and convert it to a structured
1164
+    //  DOM XML object
1165
+    //------------------------------------------------------------------------------------------------
1166 1166
   
1167
-  function array_to_xml($array, $dom = false, $parent_node = false) {
1167
+    function array_to_xml($array, $dom = false, $parent_node = false) {
1168 1168
     $is_root = false;
1169 1169
     if (!$dom) $dom = new DomDocument('1.0');
1170 1170
     if (!$parent_node) {
1171
-      $parent_node = $dom;
1172
-      $is_root = true;
1171
+        $parent_node = $dom;
1172
+        $is_root = true;
1173 1173
     }
1174 1174
     // Created an intermediate array to attempt to sort by @position
1175 1175
     $ordered_array = array();
1176 1176
     $unordered_array = array();
1177 1177
     foreach ($array as $name => $value) {
1178
-      if ($is_root) {
1178
+        if ($is_root) {
1179 1179
         $unordered_array[] = $array;
1180 1180
         break;
1181
-      }
1182
-      if (is_array($value)) {
1181
+        }
1182
+        if (is_array($value)) {
1183 1183
         if (is_numeric(key($value))) {
1184
-          foreach ($value as $item) {
1184
+            foreach ($value as $item) {
1185 1185
             if (is_array($item) AND isset($item['@position'])) {
1186
-              $ordered_array[$item['@position']] = array(
1186
+                $ordered_array[$item['@position']] = array(
1187 1187
                 $name => $item
1188
-              );
1188
+                );
1189 1189
             }
1190 1190
             else {
1191
-              $unordered_array[] = array(
1191
+                $unordered_array[] = array(
1192 1192
                 $name => $item
1193
-              );
1193
+                );
1194
+            }
1194 1195
             }
1195
-          }
1196 1196
         }
1197 1197
         elseif (isset($value['@position'])) {
1198
-          $ordered_array[$value['@position']] = array(
1198
+            $ordered_array[$value['@position']] = array(
1199 1199
             $name => $value
1200
-          );
1200
+            );
1201 1201
         }
1202 1202
         else {
1203
-          $unordered_array[] = array(
1203
+            $unordered_array[] = array(
1204 1204
             $name => $value
1205
-          );
1205
+            );
1206 1206
         }
1207
-      }
1208
-      else {
1207
+        }
1208
+        else {
1209 1209
         $unordered_array[] = array(
1210
-          $name => $value
1210
+            $name => $value
1211 1211
         );
1212
-      }
1212
+        }
1213 1213
     }
1214 1214
     
1215 1215
     // Now append items without explicit positions at the end
@@ -1217,39 +1217,39 @@  discard block
 block discarded – undo
1217 1217
     
1218 1218
     // Convert to XML...
1219 1219
     foreach ($primed_array as $item) {
1220
-      list($name, $value) = each($item);
1221
-      if (strcmp($name, '@attributes') == 0) {
1220
+        list($name, $value) = each($item);
1221
+        if (strcmp($name, '@attributes') == 0) {
1222 1222
         if (!is_array($value)) continue;
1223 1223
         foreach ($value as $attributeName => $attributeValue) {
1224
-          $parent_node->setAttribute($attributeName, $attributeValue);
1224
+            $parent_node->setAttribute($attributeName, $attributeValue);
1225 1225
         }
1226
-      } elseif (strcmp($name, '@value') == 0) {
1226
+        } elseif (strcmp($name, '@value') == 0) {
1227 1227
         if (isset($value)) $parent_node->nodeValue = $value;
1228
-      } elseif (strcmp($name, '@position') == 0) {
1228
+        } elseif (strcmp($name, '@position') == 0) {
1229 1229
         continue;
1230
-      } else {
1230
+        } else {
1231 1231
         if (is_numeric($name)) {
1232
-          $name = $parent_node->tagName;
1232
+            $name = $parent_node->tagName;
1233 1233
         }
1234 1234
         $current_item = $dom->createElement($name);
1235 1235
         if (is_array($value)) {
1236
-          if (is_numeric(key($value))) {
1236
+            if (is_numeric(key($value))) {
1237 1237
             $current_node = $parent_node->appendChild($current_item);
1238 1238
             $current_node = array_to_xml($value, $dom, $current_node);
1239 1239
             $child_count = $current_node->childNodes->length;
1240 1240
             for ($i = 0; $i < $child_count; $i++) {
1241
-              $parent_node->appendChild($current_node->childNodes->item(0));
1241
+                $parent_node->appendChild($current_node->childNodes->item(0));
1242 1242
             }
1243 1243
             $parent_node->removeChild($current_node);
1244
-          } else {
1244
+            } else {
1245 1245
             $current_node = $dom->appendChild($current_item);
1246 1246
             $parent_node->appendChild(array_to_xml($value, $dom, $current_node));
1247
-          }
1247
+            }
1248 1248
         } else {
1249
-          if (isset($value)) $current_item->nodeValue = $value;
1250
-          $parent_node->appendChild($current_item);
1249
+            if (isset($value)) $current_item->nodeValue = $value;
1250
+            $parent_node->appendChild($current_item);
1251
+        }
1251 1252
         }
1252
-      }
1253 1253
     }
1254 1254
     /*
1255 1255
     foreach ($array as $name => $value) {
@@ -1285,114 +1285,114 @@  discard block
 block discarded – undo
1285 1285
       }
1286 1286
     }*/
1287 1287
     return $parent_node;
1288
-  }
1288
+    }
1289 1289
   
1290
-  //------------------------------------------------------------------------------------------------
1291
-  //  xml_to_text(): Convert an XML DOM object to string format
1292
-  //------------------------------------------------------------------------------------------------
1290
+    //------------------------------------------------------------------------------------------------
1291
+    //  xml_to_text(): Convert an XML DOM object to string format
1292
+    //------------------------------------------------------------------------------------------------
1293 1293
   
1294
-  function xml_to_text($xml, $include_xml_declaration = true, $add_carriage_returns = false)
1295
-  {
1296
-      $xml->formatOutput = true;
1297
-      $text = $xml->saveXML();
1298
-      if (!$include_xml_declaration) {
1294
+    function xml_to_text($xml, $include_xml_declaration = true, $add_carriage_returns = false)
1295
+    {
1296
+        $xml->formatOutput = true;
1297
+        $text = $xml->saveXML();
1298
+        if (!$include_xml_declaration) {
1299 1299
         $text = preg_replace('/<\?xml version=.*\?>\s*/i', '', $text, 1);
1300
-      }
1301
-      if ($add_carriage_returns) {;
1300
+        }
1301
+        if ($add_carriage_returns) {;
1302 1302
         $text = preg_replace('/\n/i', "\r\n", $text);
1303
-      }
1304
-      return trim($text);
1305
-  }
1303
+        }
1304
+        return trim($text);
1305
+    }
1306 1306
   
1307
-  //------------------------------------------------------------------------------------------------
1308
-  //  text_to_xml(): Convert an XML DOM object to string format
1309
-  //------------------------------------------------------------------------------------------------
1307
+    //------------------------------------------------------------------------------------------------
1308
+    //  text_to_xml(): Convert an XML DOM object to string format
1309
+    //------------------------------------------------------------------------------------------------
1310 1310
   
1311
-  function text_to_xml($text) {
1311
+    function text_to_xml($text) {
1312 1312
     $xml = new DomDocument();
1313 1313
     if ( !($xml->loadXML($text)) ) return false;
1314 1314
     return $xml;
1315
-  }
1315
+    }
1316 1316
   
1317 1317
   
1318
-  //------------------------------------------------------------------------------------------------
1319
-  //  xml_to_array(): Convert an XML DOM object to array format
1320
-  //------------------------------------------------------------------------------------------------
1318
+    //------------------------------------------------------------------------------------------------
1319
+    //  xml_to_array(): Convert an XML DOM object to array format
1320
+    //------------------------------------------------------------------------------------------------
1321 1321
   
1322
-  function xml_to_array($xml) {
1323
-      $node = $xml->firstChild; //$xml->first_child();
1324
-      $result = '';
1325
-      $index = 1;
1326
-      $position = 0;
1327
-      while (!is_null($node)) {
1328
-          switch ($node->nodeType) {
1329
-          case XML_TEXT_NODE:
1322
+    function xml_to_array($xml) {
1323
+        $node = $xml->firstChild; //$xml->first_child();
1324
+        $result = '';
1325
+        $index = 1;
1326
+        $position = 0;
1327
+        while (!is_null($node)) {
1328
+            switch ($node->nodeType) {
1329
+            case XML_TEXT_NODE:
1330 1330
               if (trim($node->nodeValue)  != '') $result = $node->nodeValue;
1331
-              break;
1332
-          case XML_ELEMENT_NODE:
1331
+                break;
1332
+            case XML_ELEMENT_NODE:
1333 1333
               $node_name = $node->nodeName;
1334
-              $parent = $node->parentNode;
1335
-              $sibling = $node->nextSibling;
1334
+                $parent = $node->parentNode;
1335
+                $sibling = $node->nextSibling;
1336 1336
               
1337
-              // Determine if this node forms a set with siblings (share a node name)
1338
-              while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->nextSibling;
1339
-              if (!$sibling) {
1340
-                  $sibling = $node->previousSibling;
1341
-                  while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->previousSibling;
1342
-              }
1337
+                // Determine if this node forms a set with siblings (share a node name)
1338
+                while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->nextSibling;
1339
+                if (!$sibling) {
1340
+                    $sibling = $node->previousSibling;
1341
+                    while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->previousSibling;
1342
+                }
1343 1343
               
1344
-              if ($sibling) {
1345
-                  $result[$node_name][$index] = '';
1346
-                  if ($node->childNodes) {
1347
-                      $result[$node_name][$index] = xml_to_array($node) ;
1348
-                  }
1349
-                  if ($node->hasAttributes()) {
1350
-                      $attributes = $node->attributes;
1351
-                      if ($result[$node_name][$index] !== '' AND !is_array($result[$node_name][$index])) {
1352
-                          $result[$node_name][$index] = array('@value' => $result[$node_name][$index]);
1353
-                      }
1354
-                      foreach ($attributes as $key => $attribute) {
1355
-                          $result[$node_name][$index]['@attributes'][$attribute->name] = $attribute->value;
1356
-                      }
1357
-                  }
1358
-                  // Retain the position of the element
1359
-                  if (!is_array($result[$node_name][$index])) {
1344
+                if ($sibling) {
1345
+                    $result[$node_name][$index] = '';
1346
+                    if ($node->childNodes) {
1347
+                        $result[$node_name][$index] = xml_to_array($node) ;
1348
+                    }
1349
+                    if ($node->hasAttributes()) {
1350
+                        $attributes = $node->attributes;
1351
+                        if ($result[$node_name][$index] !== '' AND !is_array($result[$node_name][$index])) {
1352
+                            $result[$node_name][$index] = array('@value' => $result[$node_name][$index]);
1353
+                        }
1354
+                        foreach ($attributes as $key => $attribute) {
1355
+                            $result[$node_name][$index]['@attributes'][$attribute->name] = $attribute->value;
1356
+                        }
1357
+                    }
1358
+                    // Retain the position of the element
1359
+                    if (!is_array($result[$node_name][$index])) {
1360 1360
                     $result[$node_name][$index] = array(
1361
-                      '@value' => $result[$node_name][$index]
1361
+                        '@value' => $result[$node_name][$index]
1362 1362
                     );
1363
-                  }
1364
-                  $result[$node_name][$index]['@position'] = $position;
1365
-                  $position++;
1366
-                  $index++;
1367
-              } else {
1368
-                  $result[$node_name] = '';
1369
-                  if ($node->childNodes) {
1370
-                      $result[$node_name] = xml_to_array($node) ;
1371
-                  }
1372
-                  if ($node->hasAttributes()) {
1373
-                      $attributes = $node->attributes;
1374
-                      if ($result[$node_name] !== '' AND !is_array($result[$node_name])) {
1375
-                          $result[$node_name] = array('@value' => $result[$node_name]);
1376
-                      }
1377
-                      foreach($attributes as $key => $attribute) {
1378
-                          $result[$node_name]['@attributes'][$attribute->name] = $attribute->value;
1379
-                      }
1380
-                  }
1381
-                  // Retain the position of the element
1382
-                  if (!is_array($result[$node_name])) {
1363
+                    }
1364
+                    $result[$node_name][$index]['@position'] = $position;
1365
+                    $position++;
1366
+                    $index++;
1367
+                } else {
1368
+                    $result[$node_name] = '';
1369
+                    if ($node->childNodes) {
1370
+                        $result[$node_name] = xml_to_array($node) ;
1371
+                    }
1372
+                    if ($node->hasAttributes()) {
1373
+                        $attributes = $node->attributes;
1374
+                        if ($result[$node_name] !== '' AND !is_array($result[$node_name])) {
1375
+                            $result[$node_name] = array('@value' => $result[$node_name]);
1376
+                        }
1377
+                        foreach($attributes as $key => $attribute) {
1378
+                            $result[$node_name]['@attributes'][$attribute->name] = $attribute->value;
1379
+                        }
1380
+                    }
1381
+                    // Retain the position of the element
1382
+                    if (!is_array($result[$node_name])) {
1383 1383
                     $result[$node_name] = array(
1384
-                      '@value' => $result[$node_name]
1384
+                        '@value' => $result[$node_name]
1385 1385
                     );
1386
-                  }
1387
-                  $result[$node_name]['@position'] = $position;
1388
-                  $position++;
1389
-              }
1390
-              break;
1391
-          }
1392
-          $node = $node->nextSibling;
1393
-      }
1394
-      return $result;
1395
-  }
1386
+                    }
1387
+                    $result[$node_name]['@position'] = $position;
1388
+                    $position++;
1389
+                }
1390
+                break;
1391
+            }
1392
+            $node = $node->nextSibling;
1393
+        }
1394
+        return $result;
1395
+    }
1396 1396
   
1397 1397
 
1398 1398
 /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
@@ -1400,172 +1400,172 @@  discard block
 block discarded – undo
1400 1400
  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  */
1401 1401
 
1402 1402
 /**
1403
-  * Determine output for host list views when no hosts are found.
1404
-  */
1403
+ * Determine output for host list views when no hosts are found.
1404
+ */
1405 1405
 function boincwork_views_host_list_empty_text($context = NULL) {
1406 1406
   
1407
-  // Pull the BOINC user ID from the view arguments to get show_hosts 
1408
-  // preference for that user
1409
-  require_boinc('boinc_db');
1410
-  $view = views_get_current_view();
1411
-  $account = user_load($view->args[0]);
1412
-  $boincuser = BoincUser::lookup_id($account->boincuser_id);
1407
+    // Pull the BOINC user ID from the view arguments to get show_hosts 
1408
+    // preference for that user
1409
+    require_boinc('boinc_db');
1410
+    $view = views_get_current_view();
1411
+    $account = user_load($view->args[0]);
1412
+    $boincuser = BoincUser::lookup_id($account->boincuser_id);
1413 1413
   
1414
-  // Determine if hosts are associated at all or just hidden
1415
-  $output = '';
1416
-  if ($boincuser->show_hosts) {
1414
+    // Determine if hosts are associated at all or just hidden
1415
+    $output = '';
1416
+    if ($boincuser->show_hosts) {
1417 1417
     switch($context) {
1418 1418
     case 'active':
1419 1419
       $output .=  '<h2>' . bts('No active computers', array(), NULL, 'boinc:host-list') . '</h2>';
1420
-      $output .=  '<p>' . bts('This user has no computers that have been'
1421
-      . ' active in the last 30 days.', array(), NULL, 'boinc:host-list') . '</p>';
1422
-      break;
1420
+        $output .=  '<p>' . bts('This user has no computers that have been'
1421
+        . ' active in the last 30 days.', array(), NULL, 'boinc:host-list') . '</p>';
1422
+        break;
1423 1423
       
1424 1424
     case 'preferences':
1425 1425
       $output .=  '<h2>' . bts('No computers', array(), NULL, 'boinc:host-list') . '</h2>';
1426
-      $output .=  '<p>' . bts('There are no computers assigned to this'
1427
-      . ' preference set.', array(), NULL, 'boinc:host-list') . '</p>';
1428
-      break;
1426
+        $output .=  '<p>' . bts('There are no computers assigned to this'
1427
+        . ' preference set.', array(), NULL, 'boinc:host-list') . '</p>';
1428
+        break;
1429 1429
     
1430 1430
     default:
1431 1431
       $output .=  '<h2>' . bts('Computers pending', array(), NULL, 'boinc:host-list') . '</h2>';
1432
-      $output .=  '<p>' . bts('This user does not yet have any associated'
1433
-      . ' computers. Computers will be displayed when they have earned their'
1434
-      . ' first credits.', array(), NULL, 'boinc:host-list') . '</p>';
1432
+        $output .=  '<p>' . bts('This user does not yet have any associated'
1433
+        . ' computers. Computers will be displayed when they have earned their'
1434
+        . ' first credits.', array(), NULL, 'boinc:host-list') . '</p>';
1435 1435
     }
1436
-  }
1437
-  else {
1436
+    }
1437
+    else {
1438 1438
     $output .=  '<h2>' . bts('Computers hidden', array(), NULL, 'boinc:host-list') . '</h2>';
1439 1439
     $output .=  '<p>' . bts('This user has chosen not to show information'
1440 1440
     . ' about their computers.', array(), NULL, 'boinc:host-list') . '</p>';
1441
-  }
1442
-  return $output;
1441
+    }
1442
+    return $output;
1443 1443
 }
1444 1444
 
1445 1445
 /**
1446
-  * Determine output for task list views when no tasks are found.
1447
-  */
1446
+ * Determine output for task list views when no tasks are found.
1447
+ */
1448 1448
 function boincwork_views_task_list_empty_text($context = NULL) {
1449 1449
   
1450
-  // 
1451
-  $output = '';
1452
-  switch($context) {
1453
-  default:
1450
+    // 
1451
+    $output = '';
1452
+    switch($context) {
1453
+    default:
1454 1454
     $output .=  '<h2>' . bts('No @type tasks', array('@type' => $context), NULL, 'boinc:task-list')
1455 1455
     . '</h2>';
1456 1456
     $output .=  '<p>' . bts('There are no tasks of this type on record', array(), NULL, 'boinc:task-list')
1457 1457
     . '</p>';
1458
-  }
1459
-  return $output;
1458
+    }
1459
+    return $output;
1460 1460
 }
1461 1461
 
1462 1462
 /**
1463
-  * Output links to perform host actions
1464
-  */
1463
+ * Output links to perform host actions
1464
+ */
1465 1465
 function boincwork_host_action_links($host_id) {
1466
-  $output = '';
1467
-  if (boincwork_host_user_is_owner($host_id)) {
1466
+    $output = '';
1467
+    if (boincwork_host_user_is_owner($host_id)) {
1468 1468
     // Show merge hosts option
1469 1469
     $output = '<ul class="tab-list"><li class="first tab">';
1470 1470
     $output .= l(bts('Merge', array(), NULL, 'boinc:form-merge'), "host/{$host_id}/merge");
1471 1471
     $output .= '</li>';
1472 1472
     // If host has no tasks, allow the host to be deleted
1473 1473
     if (!boincwork_host_get_task_count($host_id)) {
1474
-      $output .= '<li class="tab">';
1475
-      $output .= l(bts('Delete', array(), NULL, 'boinc:form-delete'), "host/{$host_id}/delete",
1474
+        $output .= '<li class="tab">';
1475
+        $output .= l(bts('Delete', array(), NULL, 'boinc:form-delete'), "host/{$host_id}/delete",
1476 1476
         array(
1477
-          'attributes' => array(
1477
+            'attributes' => array(
1478 1478
             'onclick' => 'return confirm(\'' . bts('This will delete host @id'
1479
-              . ' from your account forever. Are you sure this is OK?',
1480
-              array('@id' => $host_id),
1481
-              NULL, 'boinc:account-host-delete') . '\')'
1482
-          )
1479
+                . ' from your account forever. Are you sure this is OK?',
1480
+                array('@id' => $host_id),
1481
+                NULL, 'boinc:account-host-delete') . '\')'
1482
+            )
1483 1483
         )
1484
-      );
1485
-      $output .= '</li>';
1484
+        );
1485
+        $output .= '</li>';
1486 1486
     }
1487 1487
     $output .= '</ul>';
1488
-  }
1489
-  return $output;
1488
+    }
1489
+    return $output;
1490 1490
 }
1491 1491
 
1492 1492
 /**
1493 1493
  * Get details for a given host
1494 1494
  */
1495 1495
 function boincwork_host_get_info($host_id) {
1496
-  db_set_active('boinc_ro');
1497
-  $host = db_fetch_object(db_query(
1496
+    db_set_active('boinc_ro');
1497
+    $host = db_fetch_object(db_query(
1498 1498
     "SELECT * FROM {host} WHERE id = '%d'",
1499 1499
     $host_id
1500
-  ));
1501
-  db_set_active('default');
1502
-  return $host;
1500
+    ));
1501
+    db_set_active('default');
1502
+    return $host;
1503 1503
 }
1504 1504
 
1505 1505
 /**
1506 1506
  * Get the number of tasks associated with a given host
1507 1507
  */
1508 1508
 function boincwork_host_get_task_count($host_id) {
1509
-  db_set_active('boinc_ro');
1510
-  $count = db_result(db_query(
1509
+    db_set_active('boinc_ro');
1510
+    $count = db_result(db_query(
1511 1511
     "SELECT COUNT(*) FROM {result} WHERE hostid = '%d'",
1512 1512
     $host_id
1513
-  ));
1514
-  db_set_active('default');
1515
-  return $count;
1513
+    ));
1514
+    db_set_active('default');
1515
+    return $count;
1516 1516
 }
1517 1517
 
1518 1518
 /**
1519 1519
  * Check whether a user is the owner of a host
1520 1520
  */
1521 1521
 function boincwork_host_user_is_owner($host_id, $uid = NULL) {
1522
-  if (!$uid) {
1522
+    if (!$uid) {
1523 1523
     global $user;
1524 1524
     $uid = $user->uid;
1525
-  }
1526
-  $account = user_load($uid);
1527
-  // Get host owner
1528
-  db_set_active('boinc_ro');
1529
-  $owner = db_result(db_query(
1525
+    }
1526
+    $account = user_load($uid);
1527
+    // Get host owner
1528
+    db_set_active('boinc_ro');
1529
+    $owner = db_result(db_query(
1530 1530
     "SELECT userid FROM {host} WHERE id = '%d'",
1531 1531
     $host_id
1532
-  ));
1533
-  db_set_active('default');
1534
-  return ($account->boincuser_id === $owner);
1532
+    ));
1533
+    db_set_active('default');
1534
+    return ($account->boincuser_id === $owner);
1535 1535
 }
1536 1536
 
1537 1537
 /**
1538
-  * Determine output for host last contact time
1539
-  */
1538
+ * Determine output for host last contact time
1539
+ */
1540 1540
 function boincwork_host_last_contact($timestamp, $host_id = NULL, $context = NULL) {
1541
-  $output = '---';
1542
-  $root_log_dir = variable_get('boinc_host_sched_logs_dir', '');
1543
-  $log = '';
1544
-  if ($timestamp) {
1541
+    $output = '---';
1542
+    $root_log_dir = variable_get('boinc_host_sched_logs_dir', '');
1543
+    $log = '';
1544
+    if ($timestamp) {
1545 1545
     $output = date('j M Y G:i:s T', $timestamp);
1546
-  }
1547
-  if ($root_log_dir AND $host_id) {
1546
+    }
1547
+    if ($root_log_dir AND $host_id) {
1548 1548
     $subdir = substr($host_id, 0, -3) OR $subdir = 0;
1549 1549
     $log = implode('/', array($root_log_dir, $subdir, $host_id));
1550
-  }
1551
-  if ($log AND file_exists($log)) {
1550
+    }
1551
+    if ($log AND file_exists($log)) {
1552 1552
     $output = l($output, "host/{$host_id}/log");
1553
-  }
1554
-  return $output;
1553
+    }
1554
+    return $output;
1555 1555
 }
1556 1556
 
1557 1557
 /**
1558 1558
  * 
1559 1559
  */
1560 1560
 function boincwork_host_venue_selector($host_id) {
1561
-  $output = '';
1562
-  if (function_exists('jump_quickly')) {
1561
+    $output = '';
1562
+    if (function_exists('jump_quickly')) {
1563 1563
     $path = "host/{$host_id}/set-venue";
1564 1564
     $venues = array(
1565
-      "{$path}/generic" => bts('Generic', array(), NULL, 'boinc:account-preferences-location'),
1566
-      "{$path}/home" => bts('Home', array(), NULL, 'boinc:account-preferences-location:-1:ignoreoverwrite'),
1567
-      "{$path}/work" => bts('Work', array(), NULL, 'boinc:account-preferences-location'),
1568
-      "{$path}/school" => bts('School', array(), NULL, 'boinc:account-preferences-location')
1565
+        "{$path}/generic" => bts('Generic', array(), NULL, 'boinc:account-preferences-location'),
1566
+        "{$path}/home" => bts('Home', array(), NULL, 'boinc:account-preferences-location:-1:ignoreoverwrite'),
1567
+        "{$path}/work" => bts('Work', array(), NULL, 'boinc:account-preferences-location'),
1568
+        "{$path}/school" => bts('School', array(), NULL, 'boinc:account-preferences-location')
1569 1569
     );
1570 1570
     variable_set('jump_use_js_venues-Array', 1);
1571 1571
     drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js');
@@ -1573,34 +1573,34 @@  discard block
 block discarded – undo
1573 1573
     // Get current venue
1574 1574
     db_set_active('boinc_ro');
1575 1575
     $venue = db_result(db_query(
1576
-      "SELECT venue FROM {host} WHERE id = '%d'",
1577
-      $host_id
1576
+        "SELECT venue FROM {host} WHERE id = '%d'",
1577
+        $host_id
1578 1578
     ));
1579 1579
     db_set_active('default');
1580 1580
     $output .= jump_quickly($venues, 'venues', 1, "{$path}/{$venue}");
1581
-  }
1582
-  return $output;
1581
+    }
1582
+    return $output;
1583 1583
 }
1584 1584
 
1585 1585
 /**
1586
-  * Determine output for task reported time / deadline
1587
-  */
1586
+ * Determine output for task reported time / deadline
1587
+ */
1588 1588
 function boincwork_task_time_reported($received_time = NULL, $deadline = NULL, $context = NULL) {
1589
-  $output = '---';
1590
-  if ($received_time OR $deadline) {
1589
+    $output = '---';
1590
+    if ($received_time OR $deadline) {
1591 1591
     $timestamp = ($received_time) ? $received_time : $deadline;
1592 1592
     $output = date('j M Y G:i:s T', $timestamp);
1593 1593
     // Add a wrapper to deadline text
1594 1594
     if (!$received_time) {
1595
-      if (time() < $deadline) {
1595
+        if (time() < $deadline) {
1596 1596
         $output = '<span class="on-time">' . $output . '</span>';
1597
-      }
1598
-      else {
1597
+        }
1598
+        else {
1599 1599
         $output = '<span class="past-due">' . $output . '</span>';
1600
-      }
1600
+        }
1601 1601
     }
1602
-  }
1603
-  return $output;
1602
+    }
1603
+    return $output;
1604 1604
 }
1605 1605
 
1606 1606
 /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
@@ -1631,345 +1631,345 @@  discard block
 block discarded – undo
1631 1631
  *   Number of table row to display per page. Defaults to 20.
1632 1632
  */
1633 1633
 function boincwork_tasktable($category = 0, $queryid = 1, $tselect = NULL, $app_id = 0, $tablerows = 20) {
1634
-  // Check type parameter, if not (0,2) then return an error.
1635
-  if ( ($category!=0) AND ($category!=1) AND ($category!=2) ) {
1634
+    // Check type parameter, if not (0,2) then return an error.
1635
+    if ( ($category!=0) AND ($category!=1) AND ($category!=2) ) {
1636 1636
     watchdog('boincwork', 'task table called with invalid category = %category', array('%category' => $category), WATCHDOG_WARNING);
1637 1637
     return '';
1638
-  }
1638
+    }
1639 1639
 
1640
-  require_boinc( array('util', 'result') );
1640
+    require_boinc( array('util', 'result') );
1641 1641
 
1642
-  global $language;
1643
-  $locality=$language->language;
1644
-  $nf = new NumberFormatter($locality, NumberFormatter::DECIMAL);
1645
-  $nf->setAttribute(NumberFormatter::MIN_FRACTION_DIGITS, 0);
1646
-  $nf->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, 0);
1642
+    global $language;
1643
+    $locality=$language->language;
1644
+    $nf = new NumberFormatter($locality, NumberFormatter::DECIMAL);
1645
+    $nf->setAttribute(NumberFormatter::MIN_FRACTION_DIGITS, 0);
1646
+    $nf->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, 0);
1647 1647
 
1648
-  $output = '';
1648
+    $output = '';
1649 1649
 
1650
-  $state_hnames = array(
1650
+    $state_hnames = array(
1651 1651
     STATE_ALL => 'All',
1652 1652
     STATE_IN_PROGRESS => 'In progress',
1653 1653
     STATE_PENDING => 'Pending',
1654 1654
     STATE_VALID => 'Valid',
1655 1655
     STATE_INVALID => 'Invalid',
1656 1656
     STATE_ERROR => 'Error',
1657
-  );
1658
-  // Array (hash) to count total number of results/tasks, and their states.
1659
-  $taskstates = array(
1657
+    );
1658
+    // Array (hash) to count total number of results/tasks, and their states.
1659
+    $taskstates = array(
1660 1660
     STATE_ALL => 0,
1661 1661
     STATE_IN_PROGRESS => 0,
1662 1662
     STATE_PENDING => 0,
1663 1663
     STATE_VALID => 0,
1664 1664
     STATE_INVALID => 0,
1665 1665
     STATE_ERROR => 0,
1666
-  );
1667
-  // Array to hold pretty-print result data to be displayed in a table.
1668
-  $resultdata = array();
1669
-  // Arrays for applications. Form below uses $applications as parameter.
1670
-  $application_map = array();
1671
-  $application_select_count = array();
1672
-  $applications = array();
1673
-
1674
-  // BOINC DB queries for results, application names
1675
-  db_set_active('boinc_ro');
1676
-
1677
-  // Query to retreive all results, in order to calculate status for a
1678
-  // host with application names for each result.
1679
-  $sqlall = "SELECT user_friendly_name,"
1680
-      ."r.appid as appid,"
1681
-      ."r.server_state AS server_state,"
1682
-      ."r.outcome AS outcome,"
1683
-      ."r.client_state AS client_state,"
1684
-      ."r.validate_state AS validate_state,"
1685
-      ."r.exit_status AS exit_status "
1686
-      ."FROM {result} AS r "
1687
-      ."INNER JOIN {app} AS a "
1688
-      ."ON r.appid=a.id ";
1689
-
1690
-  // Use userid, hostid, or workunitid
1691
-  if ($category==0) {
1666
+    );
1667
+    // Array to hold pretty-print result data to be displayed in a table.
1668
+    $resultdata = array();
1669
+    // Arrays for applications. Form below uses $applications as parameter.
1670
+    $application_map = array();
1671
+    $application_select_count = array();
1672
+    $applications = array();
1673
+
1674
+    // BOINC DB queries for results, application names
1675
+    db_set_active('boinc_ro');
1676
+
1677
+    // Query to retreive all results, in order to calculate status for a
1678
+    // host with application names for each result.
1679
+    $sqlall = "SELECT user_friendly_name,"
1680
+        ."r.appid as appid,"
1681
+        ."r.server_state AS server_state,"
1682
+        ."r.outcome AS outcome,"
1683
+        ."r.client_state AS client_state,"
1684
+        ."r.validate_state AS validate_state,"
1685
+        ."r.exit_status AS exit_status "
1686
+        ."FROM {result} AS r "
1687
+        ."INNER JOIN {app} AS a "
1688
+        ."ON r.appid=a.id ";
1689
+
1690
+    // Use userid, hostid, or workunitid
1691
+    if ($category==0) {
1692 1692
     $sqlall .= " WHERE r.userid='%s' ";
1693
-  }
1694
-  elseif ($category==1) {
1693
+    }
1694
+    elseif ($category==1) {
1695 1695
     $sqlall .= " WHERE r.workunitid='%s' ";
1696
-  }
1697
-  elseif ($category==2) {
1696
+    }
1697
+    elseif ($category==2) {
1698 1698
     $sqlall .= " WHERE r.hostid='%s' ";
1699
-  }
1700
-  $sqlall .= " ORDER BY user_friendly_name";
1701
-  $dbres_all = db_query($sqlall, $queryid);
1702
-  db_set_active('default');
1699
+    }
1700
+    $sqlall .= " ORDER BY user_friendly_name";
1701
+    $dbres_all = db_query($sqlall, $queryid);
1702
+    db_set_active('default');
1703 1703
 
1704
-  // Loop 1 of DB results
1705
-  if ($dbres_all) {
1704
+    // Loop 1 of DB results
1705
+    if ($dbres_all) {
1706 1706
     while ($result = db_fetch_object($dbres_all)) {
1707
-      $mystate = state_num($result);
1708
-      if ( ($result->appid==$app_id) OR ($app_id==0) OR ($app_id==-1) ) {
1707
+        $mystate = state_num($result);
1708
+        if ( ($result->appid==$app_id) OR ($app_id==0) OR ($app_id==-1) ) {
1709 1709
         $taskstates[STATE_ALL]++;
1710 1710
         switch ($mystate) {
1711 1711
         case STATE_IN_PROGRESS:
1712 1712
           $taskstates[STATE_IN_PROGRESS]++;
1713
-          break;
1713
+            break;
1714 1714
         case STATE_PENDING:
1715 1715
           $taskstates[STATE_PENDING]++;
1716
-          break;
1716
+            break;
1717 1717
         case STATE_VALID:
1718 1718
           $taskstates[STATE_VALID]++;
1719
-          break;
1719
+            break;
1720 1720
         case STATE_INVALID:
1721 1721
           $taskstates[STATE_INVALID]++;
1722
-          break;
1722
+            break;
1723 1723
         case STATE_ERROR:
1724 1724
           $taskstates[STATE_ERROR]++;
1725
-          break;
1725
+            break;
1726 1726
         }
1727
-      }// if app_id
1727
+        }// if app_id
1728 1728
 
1729
-      //map holds a map between app ids and user friendly names for all applications.
1730
-      $application_map[$result->appid] = $result->user_friendly_name;
1731
-      if ( ($mystate == $tselect) OR ($tselect==STATE_ALL) ) {
1729
+        //map holds a map between app ids and user friendly names for all applications.
1730
+        $application_map[$result->appid] = $result->user_friendly_name;
1731
+        if ( ($mystate == $tselect) OR ($tselect==STATE_ALL) ) {
1732 1732
         //count of appids in the results.
1733 1733
         $application_select_count[$result->appid]++;
1734
-      }// if mystate
1734
+        }// if mystate
1735 1735
 
1736 1736
     }// while
1737
-  }
1738
-  else {
1739
-  }
1737
+    }
1738
+    else {
1739
+    }
1740 1740
   
1741
-  // Entry for all applications.
1742
-  $allcount = $application_select_count ? array_sum($application_select_count) : 0;
1743
-  $applications[-1] = bts('Application', array(), NULL, 'boinc:task-table');
1744
-  $applications[0] = bts('All applications', array(), NULL, 'boinc:task-table') . ' (' . $allcount . ')';
1745
-  // Create application filter from application_map and application_select_count.
1746
-  foreach($application_map as $akey => $aname) {
1741
+    // Entry for all applications.
1742
+    $allcount = $application_select_count ? array_sum($application_select_count) : 0;
1743
+    $applications[-1] = bts('Application', array(), NULL, 'boinc:task-table');
1744
+    $applications[0] = bts('All applications', array(), NULL, 'boinc:task-table') . ' (' . $allcount . ')';
1745
+    // Create application filter from application_map and application_select_count.
1746
+    foreach($application_map as $akey => $aname) {
1747 1747
     $acount = 0;
1748 1748
     if ( $application_select_count and array_key_exists($akey, $application_select_count) ) {
1749
-      $acount = $application_select_count[$akey];
1749
+        $acount = $application_select_count[$akey];
1750 1750
     }
1751 1751
     $applications[$akey] = $aname . ' ('. $acount . ')';
1752
-  }
1753
-  // Header array for (sub) results table.
1754
-  $resultheader = array(
1752
+    }
1753
+    // Header array for (sub) results table.
1754
+    $resultheader = array(
1755 1755
     array(
1756
-      'data' => bts('Task ID', array(), NULL, 'boinc:task-table'),
1757
-      'field' => 'id',
1756
+        'data' => bts('Task ID', array(), NULL, 'boinc:task-table'),
1757
+        'field' => 'id',
1758 1758
     ),
1759 1759
     array(
1760
-      'data' => bts('Workunit ID', array(), NULL, 'boinc:task-table'),
1761
-      'field' => 'workunitid',
1760
+        'data' => bts('Workunit ID', array(), NULL, 'boinc:task-table'),
1761
+        'field' => 'workunitid',
1762 1762
     ),
1763 1763
     array(
1764
-      'data' => bts('Computer', array(), NULL, 'boinc:task-table'),
1765
-      'field' => 'hostid',
1764
+        'data' => bts('Computer', array(), NULL, 'boinc:task-table'),
1765
+        'field' => 'hostid',
1766 1766
     ),
1767 1767
     array(
1768
-      'data' => bts('Sent', array(), NULL, 'boinc:task-table'),
1769
-      'field' => 'sent_time',
1768
+        'data' => bts('Sent', array(), NULL, 'boinc:task-table'),
1769
+        'field' => 'sent_time',
1770 1770
     ),
1771 1771
     array(
1772
-      'data' => bts('Time Reported or Deadline', array(), NULL, 'boinc:task-table')
1772
+        'data' => bts('Time Reported or Deadline', array(), NULL, 'boinc:task-table')
1773 1773
     ),
1774 1774
     array(
1775
-      'data' => bts('Status', array(), NULL, 'boinc:task-table')
1775
+        'data' => bts('Status', array(), NULL, 'boinc:task-table')
1776 1776
     ),
1777 1777
     array(
1778
-      'data' => bts('Run time', array(), NULL, 'boinc:task-table'),
1779
-      'field' => 'elapsed_time',
1778
+        'data' => bts('Run time', array(), NULL, 'boinc:task-table'),
1779
+        'field' => 'elapsed_time',
1780 1780
     ),
1781 1781
     array(
1782
-      'data' => bts('CPU time', array(), NULL, 'boinc:task-table'),
1783
-      'field' => 'cpu_time',
1782
+        'data' => bts('CPU time', array(), NULL, 'boinc:task-table'),
1783
+        'field' => 'cpu_time',
1784 1784
     ),
1785 1785
     array(
1786
-      'data' => bts('Granted Credit', array(), NULL, 'boinc:task-table'),
1787
-      'field' => 'granted_credit',
1786
+        'data' => bts('Granted Credit', array(), NULL, 'boinc:task-table'),
1787
+        'field' => 'granted_credit',
1788 1788
     ),
1789 1789
     // Application is a column, but won't be added until after tablesort_sql().
1790
-  );
1791
-
1792
-  // Query to retreive a subset of the total results for the results table.
1793
-  db_set_active('boinc_ro');
1794
-  $sqlsub = "SELECT r.id AS id,"
1795
-      ."r.name AS name,"
1796
-      ."r.workunitid AS workunitid,"
1797
-      ."r.hostid as hostid,"
1798
-      ."r.sent_time AS sent_time,"
1799
-      ."r.received_time AS received_time,"
1800
-      ."r.report_deadline AS report_deadline,"
1801
-      ."r.server_state AS server_state,"
1802
-      ."r.outcome AS outcome,"
1803
-      ."r.client_state AS client_state,"
1804
-      ."r.validate_state AS validate_state,"
1805
-      ."r.exit_status AS exit_status,"
1806
-      ."r.elapsed_time AS elapsed_time,"
1807
-      ."r.cpu_time AS cpu_time,"
1808
-      ."r.granted_credit AS granted_credit,"
1809
-      ."r.appid AS appid,"
1810
-      ."r.app_version_id AS app_version_id,"
1811
-      ."a.user_friendly_name,"
1812
-      ."av.version_num AS version_number,"
1813
-      ."av.plan_class AS plan_class,"
1814
-      ."pl.name AS platform "
1815
-      ."FROM {result} AS r "
1816
-      ."INNER JOIN {app} AS a "
1817
-      ."ON r.appid=a.id "
1818
-      ."LEFT JOIN {app_version} AS av "
1819
-      ."ON r.app_version_id=av.id "
1820
-      ."LEFT JOIN {platform} AS pl "
1821
-      ."ON av.platformid=pl.id ";
1822
-
1823
-  // Build an array for the WHERE clauses. The individual clauses are
1824
-  // placed into an array, and implode() is used to combine them into
1825
-  // a WHERE statement for the sql query. If no such clauses are added
1826
-  // to the array, then no WHERE statement will be included.
1827
-  $sqlwhere = array();
1828
-
1829
-  // Use userid, hostid, or workunitid
1830
-  if ($category==0) {
1790
+    );
1791
+
1792
+    // Query to retreive a subset of the total results for the results table.
1793
+    db_set_active('boinc_ro');
1794
+    $sqlsub = "SELECT r.id AS id,"
1795
+        ."r.name AS name,"
1796
+        ."r.workunitid AS workunitid,"
1797
+        ."r.hostid as hostid,"
1798
+        ."r.sent_time AS sent_time,"
1799
+        ."r.received_time AS received_time,"
1800
+        ."r.report_deadline AS report_deadline,"
1801
+        ."r.server_state AS server_state,"
1802
+        ."r.outcome AS outcome,"
1803
+        ."r.client_state AS client_state,"
1804
+        ."r.validate_state AS validate_state,"
1805
+        ."r.exit_status AS exit_status,"
1806
+        ."r.elapsed_time AS elapsed_time,"
1807
+        ."r.cpu_time AS cpu_time,"
1808
+        ."r.granted_credit AS granted_credit,"
1809
+        ."r.appid AS appid,"
1810
+        ."r.app_version_id AS app_version_id,"
1811
+        ."a.user_friendly_name,"
1812
+        ."av.version_num AS version_number,"
1813
+        ."av.plan_class AS plan_class,"
1814
+        ."pl.name AS platform "
1815
+        ."FROM {result} AS r "
1816
+        ."INNER JOIN {app} AS a "
1817
+        ."ON r.appid=a.id "
1818
+        ."LEFT JOIN {app_version} AS av "
1819
+        ."ON r.app_version_id=av.id "
1820
+        ."LEFT JOIN {platform} AS pl "
1821
+        ."ON av.platformid=pl.id ";
1822
+
1823
+    // Build an array for the WHERE clauses. The individual clauses are
1824
+    // placed into an array, and implode() is used to combine them into
1825
+    // a WHERE statement for the sql query. If no such clauses are added
1826
+    // to the array, then no WHERE statement will be included.
1827
+    $sqlwhere = array();
1828
+
1829
+    // Use userid, hostid, or workunitid
1830
+    if ($category==0) {
1831 1831
     $sqlwhere[] = "r.userid = '%s'";
1832
-  }
1833
-  elseif ($category==1) {
1832
+    }
1833
+    elseif ($category==1) {
1834 1834
     $sqlwhere[] = "r.workunitid = '%s'";
1835
-  }
1836
-  elseif ($category==2) {
1835
+    }
1836
+    elseif ($category==2) {
1837 1837
     $sqlwhere[] = "r.hostid = '%s'";
1838
-  }
1838
+    }
1839 1839
 
1840
-  // Append additional where clauses based on task selection.
1841
-  switch ($tselect) {
1842
-  case STATE_IN_PROGRESS:
1840
+    // Append additional where clauses based on task selection.
1841
+    switch ($tselect) {
1842
+    case STATE_IN_PROGRESS:
1843 1843
     $sqlwhere[] = "r.server_state = 4";
1844 1844
     break;
1845
-  case STATE_PENDING:
1845
+    case STATE_PENDING:
1846 1846
     $sqlwhere[] = "(r.server_state = 5) AND (r.outcome = 1) AND (r.validate_state >= 0) AND (r.validate_state <= 0 OR r.validate_state >= 4) AND (r.validate_state <= 4)";
1847 1847
     break;
1848
-  case STATE_VALID:
1848
+    case STATE_VALID:
1849 1849
     $sqlwhere[] = "(r.server_state = 5) AND (r.outcome = 1) AND (r.validate_state = 1)";
1850 1850
     break;
1851
-  case STATE_INVALID:
1851
+    case STATE_INVALID:
1852 1852
     $sqlwhere[] = "(r.server_state = 5) AND ((r.outcome = 6) OR ((r.outcome = 1) AND ((r.validate_state = 2) OR (r.validate_state = 3) OR (r.validate_state = 5))))";
1853 1853
     break;
1854
-  case STATE_ERROR:
1854
+    case STATE_ERROR:
1855 1855
     $sqlwhere[] = "(r.server_state = 5) AND (r.outcome >= 3) AND (r.outcome <= 4 OR r.outcome >= 7) AND (r.outcome <= 7)";
1856 1856
     break;
1857
-  default:
1857
+    default:
1858 1858
   }
1859 1859
 
1860
-  if (is_numeric($app_id) AND $app_id>0 ) {
1860
+    if (is_numeric($app_id) AND $app_id>0 ) {
1861 1861
     $sqlwhere[] = "r.appid = '%s'";
1862 1862
     if ($sqlwhere)  $sqlsub .= " WHERE " . implode(' AND ', $sqlwhere);
1863 1863
     $dbres_sub = pager_query( $sqlsub . tablesort_sql($resultheader), $tablerows, 0, NULL, $queryid, $app_id);
1864
-  }
1865
-  else {
1864
+    }
1865
+    else {
1866 1866
     if ($sqlwhere)  $sqlsub .= " WHERE " . implode(' AND ', $sqlwhere);
1867 1867
     $dbres_sub = pager_query( $sqlsub . tablesort_sql($resultheader), $tablerows, 0, NULL, $queryid);
1868
-  }
1869
-  db_set_active('default');
1868
+    }
1869
+    db_set_active('default');
1870 1870
 
1871
-  // Loop 2 over DB results.
1872
-  if ($dbres_sub) {
1871
+    // Loop 2 over DB results.
1872
+    if ($dbres_sub) {
1873 1873
     while ($result = db_fetch_object($dbres_sub)) {
1874
-      // state_num() function changes $result object, clone $result
1875
-      // object for use in state_num()
1876
-      // check if state matches selection
1877
-      if ( (state_num(clone $result) == $tselect) OR ($tselect==STATE_ALL) ) {
1874
+        // state_num() function changes $result object, clone $result
1875
+        // object for use in state_num()
1876
+        // check if state matches selection
1877
+        if ( (state_num(clone $result) == $tselect) OR ($tselect==STATE_ALL) ) {
1878 1878
         // create pretty result row
1879 1879
         $prettyresult = array(
1880
-          array(
1880
+            array(
1881 1881
             'data' => l($result->name, "task/{$result->id}"),
1882 1882
             'class' => 'task-name',
1883
-          ),
1884
-          l($result->workunitid, "workunit/{$result->workunitid}"),
1885
-          l($result->hostid, "host/{$result->hostid}"),
1886
-          date('j M Y G:i:s T', $result->sent_time),
1887
-          boincwork_task_time_reported($result->received_time, $result->report_deadline),
1888
-          state_string($result),
1889
-          $nf->format($result->elapsed_time),
1890
-          $nf->format($result->cpu_time),
1891
-          $nf->format($result->granted_credit),
1892
-          array(
1883
+            ),
1884
+            l($result->workunitid, "workunit/{$result->workunitid}"),
1885
+            l($result->hostid, "host/{$result->hostid}"),
1886
+            date('j M Y G:i:s T', $result->sent_time),
1887
+            boincwork_task_time_reported($result->received_time, $result->report_deadline),
1888
+            state_string($result),
1889
+            $nf->format($result->elapsed_time),
1890
+            $nf->format($result->cpu_time),
1891
+            $nf->format($result->granted_credit),
1892
+            array(
1893 1893
             'data' => $result->user_friendly_name . " " . pretty_application_version($result->app_version_id,$result->version_number, $result->plan_class, $result->platform),
1894 1894
             'class' => 'task-app',
1895
-          ),
1895
+            ),
1896 1896
         );
1897 1897
         $resultdata[] = array_values($prettyresult);
1898
-      }
1898
+        }
1899 1899
     }// while
1900
-  }
1901
-  else {
1902
-  }
1903
-  // Begin result navigation
1900
+    }
1901
+    else {
1902
+    }
1903
+    // Begin result navigation
1904 1904
 
1905
-  // Set pathprefix based on type
1906
-  if ($category==0) {
1905
+    // Set pathprefix based on type
1906
+    if ($category==0) {
1907 1907
     $pathprefix = 'account/tasks';
1908
-  }
1909
-  elseif ($category==1) {
1908
+    }
1909
+    elseif ($category==1) {
1910 1910
     $pathprefix = 'workunit/' . $queryid . '/tasks';
1911
-  }
1912
-  elseif ($category==2) {
1911
+    }
1912
+    elseif ($category==2) {
1913 1913
     $pathprefix = 'host/' . $queryid . '/tasks';
1914
-  }
1915
-  // Need an "All" tab as well, maps to app_id of zero.
1916
-  $application_map[0] = bts('All', array(), NULL, 'boinc:task-table');
1917
-  $stitems = array();
1918
-  foreach ($taskstates as $state => $numstates) {
1914
+    }
1915
+    // Need an "All" tab as well, maps to app_id of zero.
1916
+    $application_map[0] = bts('All', array(), NULL, 'boinc:task-table');
1917
+    $stitems = array();
1918
+    foreach ($taskstates as $state => $numstates) {
1919 1919
     $mypath = $pathprefix . '/' . $state . '/' . $app_id;
1920 1920
     if ($state==STATE_ALL) {
1921
-      $ltext = '<span class="tab task-app-name">' . bts('All', array(), NULL, 'boinc:task-table') . ' (' . $numstates . ')</span>';
1921
+        $ltext = '<span class="tab task-app-name">' . bts('All', array(), NULL, 'boinc:task-table') . ' (' . $numstates . ')</span>';
1922 1922
     }
1923 1923
     else {
1924
-      $ltext = '<span class="tab">' . bts($state_hnames[$state], array(), NULL, 'boinc:task-table') . ' (' . $numstates . ')</span>';
1924
+        $ltext = '<span class="tab">' . bts($state_hnames[$state], array(), NULL, 'boinc:task-table') . ' (' . $numstates . ')</span>';
1925 1925
     }
1926 1926
     $myitem = array(
1927
-      'data' => l($ltext, $mypath, array('html' => TRUE) ),
1927
+        'data' => l($ltext, $mypath, array('html' => TRUE) ),
1928 1928
     );
1929 1929
     if ($state==$tselect) {
1930
-      $myitem['class'] = 'active';
1930
+        $myitem['class'] = 'active';
1931 1931
     }
1932 1932
     $stitems[] = $myitem;
1933
-  }
1934
-  // Add reset button
1935
-  $mypath = $pathprefix . '/0/0';
1936
-  $ltext = '<span class="tab">' . bts('Reset', array(), NULL, 'boinc:task-table') . '</span>';
1937
-  $stitems[] = array( 'data' => l($ltext, $mypath, array('html' => TRUE) ) );
1933
+    }
1934
+    // Add reset button
1935
+    $mypath = $pathprefix . '/0/0';
1936
+    $ltext = '<span class="tab">' . bts('Reset', array(), NULL, 'boinc:task-table') . '</span>';
1937
+    $stitems[] = array( 'data' => l($ltext, $mypath, array('html' => TRUE) ) );
1938 1938
 
1939
-  $output .= theme_item_list($stitems, NULL, 'ul' . ' class="tabs secondary clearfix"');
1939
+    $output .= theme_item_list($stitems, NULL, 'ul' . ' class="tabs secondary clearfix"');
1940 1940
 
1941
-  // Application select-drop down form
1942
-  // Hack to place Application form into header
1943
-  // App ID of zero maps to "-1" for drop-down box.
1944
-  if ($app_id==0) {
1941
+    // Application select-drop down form
1942
+    // Hack to place Application form into header
1943
+    // App ID of zero maps to "-1" for drop-down box.
1944
+    if ($app_id==0) {
1945 1945
     $app_id=-1;
1946
-  }
1947
-  $resultheader[] = drupal_get_form('boincwork_selectapp_form', $applications, $app_id);
1946
+    }
1947
+    $resultheader[] = drupal_get_form('boincwork_selectapp_form', $applications, $app_id);
1948 1948
 
1949
-  // Begin table of results
1950
-  if ( is_array($resultheader) AND is_array($resultdata) ) {
1949
+    // Begin table of results
1950
+    if ( is_array($resultheader) AND is_array($resultdata) ) {
1951 1951
 
1952 1952
     // Take advantage of the fact that $category is the same as the row/column we want to remove.
1953 1953
     if ( ($category==1) OR ($category==2) ) {
1954
-      unset($resultheader[$category]);
1955
-      delete_col($resultdata, $category);
1954
+        unset($resultheader[$category]);
1955
+        delete_col($resultdata, $category);
1956 1956
     }
1957 1957
 
1958 1958
     $output .= theme_table($resultheader, $resultdata);
1959 1959
     if (count($resultdata) > 0) {
1960
-      $output .= theme('pager');
1960
+        $output .= theme('pager');
1961 1961
     }
1962
-  }
1963
-  return $output;
1962
+    }
1963
+    return $output;
1964 1964
 }
1965 1965
 
1966 1966
 /**
1967 1967
  * Function to delete a column from an array.
1968 1968
  */
1969 1969
 function delete_col(&$array, $offset) {
1970
-  return array_walk($array, function (&$v) use ($offset) {
1971
-     array_splice($v, $offset, 1);
1972
-  });
1970
+    return array_walk($array, function (&$v) use ($offset) {
1971
+        array_splice($v, $offset, 1);
1972
+    });
1973 1973
 }
1974 1974
 
1975 1975
 /**
@@ -1989,7 +1989,7 @@  discard block
 block discarded – undo
1989 1989
  *  platform name, may be NULL
1990 1990
  */
1991 1991
 function pretty_application_version($appverid, $vernum, $plan_class, $plfm) {
1992
-  switch ($appverid) {
1992
+    switch ($appverid) {
1993 1993
     case ANON_PLATFORM_UNKNOWN:
1994 1994
       return "Anonymous platform";
1995 1995
     case ANON_PLATFORM_CPU:
@@ -2008,11 +2008,11 @@  discard block
 block discarded – undo
2008 2008
       // that is not handled by the above case statements.
2009 2009
       if ($appverid < 0) {
2010 2010
         return "Unknown Anonymous platform";
2011
-      }
2012
-      else {
2011
+        }
2012
+        else {
2013 2013
         $prettyv = sprintf("%d.%02d", $vernum/100, $vernum%100);
2014 2014
         $prettyc = ($plan_class) ? "($av->plan_class)" : '';
2015 2015
         return "v$prettyv $prettyc $plfm";
2016
-      }
2017
-  }
2016
+        }
2017
+    }
2018 2018
 }
Please login to merge, or discard this patch.
html/user/server_status.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -188,9 +188,9 @@
 block discarded – undo
188 188
     
189 189
     global $server_version;
190 190
     if ( isset($server_version) ) {
191
-       $url = "https://github.com/BOINC/boinc/tree/server_release/";
192
-       $url .= explode(".", $server_version)[0] . "." . explode(".", $server_version)[1] . "/" . "$server_version";
193
-       echo "Upstream server release: <a href=\"" . $url . "\">$server_version</a> <br>";
191
+        $url = "https://github.com/BOINC/boinc/tree/server_release/";
192
+        $url .= explode(".", $server_version)[0] . "." . explode(".", $server_version)[1] . "/" . "$server_version";
193
+        echo "Upstream server release: <a href=\"" . $url . "\">$server_version</a> <br>";
194 194
     }
195 195
 
196 196
     if ($j->db_revision) {
Please login to merge, or discard this patch.
drupal/sites/all/features/boinc_standard/boinc_standard.features.inc 1 patch
Indentation   +1047 added lines, -1047 removed lines patch added patch discarded remove patch
@@ -4,38 +4,38 @@  discard block
 block discarded – undo
4 4
  * Implementation of hook_ctools_plugin_api().
5 5
  */
6 6
 function boinc_standard_ctools_plugin_api() {
7
-  list($module, $api) = func_get_args();
8
-  if ($module == "input_formats" && $api == "input_formats") {
7
+    list($module, $api) = func_get_args();
8
+    if ($module == "input_formats" && $api == "input_formats") {
9 9
     return array("version" => 1);
10
-  }
11
-  elseif ($module == "page_manager" && $api == "pages_default") {
10
+    }
11
+    elseif ($module == "page_manager" && $api == "pages_default") {
12 12
     return array("version" => 1);
13
-  }
14
-  elseif ($module == "panels_mini" && $api == "panels_default") {
13
+    }
14
+    elseif ($module == "panels_mini" && $api == "panels_default") {
15 15
     return array("version" => 1);
16
-  }
17
-  elseif ($module == "strongarm" && $api == "strongarm") {
16
+    }
17
+    elseif ($module == "strongarm" && $api == "strongarm") {
18 18
     return array("version" => 1);
19
-  }
20
-  elseif ($module == "wysiwyg" && $api == "wysiwyg") {
19
+    }
20
+    elseif ($module == "wysiwyg" && $api == "wysiwyg") {
21 21
     return array("version" => 2);
22
-  }
22
+    }
23 23
 }
24 24
 
25 25
 /**
26 26
  * Implementation of hook_flag_default_flags().
27 27
  */
28 28
 function boinc_standard_flag_default_flags() {
29
-  $flags = array();
30
-  // Exported flag: "Comment Abuse".
31
-  $flags['abuse_comment'] = array(
29
+    $flags = array();
30
+    // Exported flag: "Comment Abuse".
31
+    $flags['abuse_comment'] = array(
32 32
     'content_type' => 'comment',
33 33
     'title' => 'Comment Abuse',
34 34
     'global' => FALSE,
35 35
     'types' => array(
36
-      '0' => 'forum',
37
-      '1' => 'news',
38
-      '2' => 'team_forum',
36
+        '0' => 'forum',
37
+        '1' => 'news',
38
+        '2' => 'team_forum',
39 39
     ),
40 40
     'flag_short' => 'Report',
41 41
     'flag_long' => 'Report this content as offensive.',
@@ -46,31 +46,31 @@  discard block
 block discarded – undo
46 46
     'unflag_denied_text' => '',
47 47
     'link_type' => 'toggle',
48 48
     'roles' => array(
49
-      'flag' => array(
49
+        'flag' => array(
50 50
         '0' => 2,
51
-      ),
52
-      'unflag' => array(
51
+        ),
52
+        'unflag' => array(
53 53
         '0' => 2,
54
-      ),
54
+        ),
55 55
     ),
56 56
     'weight' => 0,
57 57
     'access_author' => '',
58 58
     'show_on_comment' => 1,
59 59
     'module' => 'boinc_standard',
60 60
     'locked' => array(
61
-      '0' => 'name',
61
+        '0' => 'name',
62 62
     ),
63 63
     'api_version' => 2,
64
-  );
65
-  // Exported flag: "Node Abuse".
66
-  $flags['abuse_node'] = array(
64
+    );
65
+    // Exported flag: "Node Abuse".
66
+    $flags['abuse_node'] = array(
67 67
     'content_type' => 'node',
68 68
     'title' => 'Node Abuse',
69 69
     'global' => FALSE,
70 70
     'types' => array(
71
-      '0' => 'forum',
72
-      '1' => 'profile',
73
-      '2' => 'team_forum',
71
+        '0' => 'forum',
72
+        '1' => 'profile',
73
+        '2' => 'team_forum',
74 74
     ),
75 75
     'flag_short' => 'Report',
76 76
     'flag_long' => 'Report this content as offensive.',
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
     'unflag_denied_text' => '',
82 82
     'link_type' => 'toggle',
83 83
     'roles' => array(
84
-      'flag' => array(
84
+        'flag' => array(
85 85
         '0' => 2,
86
-      ),
87
-      'unflag' => array(
86
+        ),
87
+        'unflag' => array(
88 88
         '0' => 2,
89
-      ),
89
+        ),
90 90
     ),
91 91
     'weight' => 0,
92 92
     'show_on_page' => 1,
@@ -96,12 +96,12 @@  discard block
 block discarded – undo
96 96
     'i18n' => '0',
97 97
     'module' => 'boinc_standard',
98 98
     'locked' => array(
99
-      '0' => 'name',
99
+        '0' => 'name',
100 100
     ),
101 101
     'api_version' => 2,
102
-  );
103
-  // Exported flag: "User Abuse".
104
-  $flags['abuse_user'] = array(
102
+    );
103
+    // Exported flag: "User Abuse".
104
+    $flags['abuse_user'] = array(
105 105
     'content_type' => 'user',
106 106
     'title' => 'User Abuse',
107 107
     'global' => '0',
@@ -115,12 +115,12 @@  discard block
 block discarded – undo
115 115
     'unflag_denied_text' => '',
116 116
     'link_type' => 'confirm',
117 117
     'roles' => array(
118
-      'flag' => array(
118
+        'flag' => array(
119 119
         '0' => '2',
120
-      ),
121
-      'unflag' => array(
120
+        ),
121
+        'unflag' => array(
122 122
         '0' => '2',
123
-      ),
123
+        ),
124 124
     ),
125 125
     'weight' => 0,
126 126
     'show_on_profile' => TRUE,
@@ -129,19 +129,19 @@  discard block
 block discarded – undo
129 129
     'unflag_confirmation' => 'Are you sure you want to remove your report of this user?',
130 130
     'module' => 'boinc_standard',
131 131
     'locked' => array(
132
-      '0' => 'name',
132
+        '0' => 'name',
133 133
     ),
134 134
     'api_version' => 2,
135
-  );
136
-  // Exported flag: "Subscriptions".
137
-  $flags['subscriptions'] = array(
135
+    );
136
+    // Exported flag: "Subscriptions".
137
+    $flags['subscriptions'] = array(
138 138
     'content_type' => 'node',
139 139
     'title' => 'Subscriptions',
140 140
     'global' => '0',
141 141
     'types' => array(
142
-      '0' => 'forum',
143
-      '1' => 'news',
144
-      '2' => 'team_forum',
142
+        '0' => 'forum',
143
+        '1' => 'news',
144
+        '2' => 'team_forum',
145 145
     ),
146 146
     'flag_short' => 'subscribe',
147 147
     'flag_long' => 'Subscribe to this topic',
@@ -152,12 +152,12 @@  discard block
 block discarded – undo
152 152
     'unflag_denied_text' => '',
153 153
     'link_type' => 'toggle',
154 154
     'roles' => array(
155
-      'flag' => array(
155
+        'flag' => array(
156 156
         '0' => 2,
157
-      ),
158
-      'unflag' => array(
157
+        ),
158
+        'unflag' => array(
159 159
         '0' => 2,
160
-      ),
160
+        ),
161 161
     ),
162 162
     'weight' => 0,
163 163
     'show_on_page' => 1,
@@ -167,11 +167,11 @@  discard block
 block discarded – undo
167 167
     'i18n' => '0',
168 168
     'module' => 'boinc_standard',
169 169
     'locked' => array(
170
-      '0' => 'name',
170
+        '0' => 'name',
171 171
     ),
172 172
     'api_version' => 2,
173
-  );
174
-  return $flags;
173
+    );
174
+    return $flags;
175 175
 
176 176
 }
177 177
 
@@ -179,2146 +179,2146 @@  discard block
 block discarded – undo
179 179
  * Implementation of hook_node_info().
180 180
  */
181 181
 function boinc_standard_node_info() {
182
-  $items = array(
182
+    $items = array(
183 183
     'page' => array(
184
-      'name' => t('Page'),
185
-      'module' => 'features',
186
-      'description' => t('A <em>page</em>, similar in form to a <em>story</em>, is a simple method for creating and displaying information that rarely changes, such as an "About us" section of a website. By default, a <em>page</em> entry does not allow visitor comments and is not featured on the site\'s initial home page.'),
187
-      'has_title' => '1',
188
-      'title_label' => t('Title'),
189
-      'has_body' => '1',
190
-      'body_label' => t('Body'),
191
-      'min_word_count' => '0',
192
-      'help' => '',
184
+        'name' => t('Page'),
185
+        'module' => 'features',
186
+        'description' => t('A <em>page</em>, similar in form to a <em>story</em>, is a simple method for creating and displaying information that rarely changes, such as an "About us" section of a website. By default, a <em>page</em> entry does not allow visitor comments and is not featured on the site\'s initial home page.'),
187
+        'has_title' => '1',
188
+        'title_label' => t('Title'),
189
+        'has_body' => '1',
190
+        'body_label' => t('Body'),
191
+        'min_word_count' => '0',
192
+        'help' => '',
193 193
     ),
194
-  );
195
-  return $items;
194
+    );
195
+    return $items;
196 196
 }
197 197
 
198 198
 /**
199 199
  * Implementation of hook_rules_defaults().
200 200
  */
201 201
 function boinc_standard_rules_defaults() {
202
-  return array(
202
+    return array(
203 203
     'rules' => array(
204
-      'rules_comment_converted_to_new_forum_topic_by_moderator_or_admin' => array(
204
+        'rules_comment_converted_to_new_forum_topic_by_moderator_or_admin' => array(
205 205
         '#type' => 'rule',
206 206
         '#set' => 'event_boinccore_comment_convert',
207 207
         '#label' => 'Comment is converted to new forum topic by moderator or admin',
208 208
         '#active' => 1,
209 209
         '#weight' => '0',
210 210
         '#categories' => array(
211
-          '0' => 'boinc_standard',
212
-          '1' => 'moderator notification',
211
+            '0' => 'boinc_standard',
212
+            '1' => 'moderator notification',
213 213
         ),
214 214
         '#status' => 'default',
215 215
         '#conditions' => array(),
216 216
         '#actions' => array(
217
-          '0' => array(
217
+            '0' => array(
218 218
             '#info' => array(
219
-              'label' => 'Notify moderators via email',
220
-              'module' => 'BOINC core',
221
-              'eval input' => array(
219
+                'label' => 'Notify moderators via email',
220
+                'module' => 'BOINC core',
221
+                'eval input' => array(
222 222
                 '0' => 'subject',
223 223
                 '1' => 'message',
224 224
                 '2' => 'from',
225
-              ),
225
+                ),
226 226
             ),
227 227
             '#name' => 'boinccore_rules_action_mail_to_moderators',
228 228
             '#settings' => array(
229
-              'from' => '',
230
-              'subject' => 'Comment at [:global:site-name] converted to new forum topic',
231
-              'message' => "Comment has been converted to new forum topic by moderator/admin [user:display-name].\r\n\r\nLink: <?php print url('node/' . \$node->nid, array('absolute' => TRUE, 'language' => 'en')); ?>",
232
-              '#eval input' => array(
229
+                'from' => '',
230
+                'subject' => 'Comment at [:global:site-name] converted to new forum topic',
231
+                'message' => "Comment has been converted to new forum topic by moderator/admin [user:display-name].\r\n\r\nLink: <?php print url('node/' . \$node->nid, array('absolute' => TRUE, 'language' => 'en')); ?>",
232
+                '#eval input' => array(
233 233
                 'token_rules_input_evaluator' => array(
234
-                  'subject' => array(
234
+                    'subject' => array(
235 235
                     '0' => ':global',
236
-                  ),
237
-                  'message' => array(
236
+                    ),
237
+                    'message' => array(
238 238
                     '0' => 'user',
239 239
                     '1' => ':global',
240
-                  ),
241
-                  'from' => array(
240
+                    ),
241
+                    'from' => array(
242 242
                     '0' => ':global',
243
-                  ),
243
+                    ),
244 244
                 ),
245 245
                 'rules_input_evaluator_php' => array(
246
-                  'message' => array(
246
+                    'message' => array(
247 247
                     '0' => 'node',
248
-                  ),
248
+                    ),
249
+                ),
249 250
                 ),
250
-              ),
251 251
             ),
252 252
             '#type' => 'action',
253 253
             '#weight' => 0.0,
254
-          ),
254
+            ),
255 255
         ),
256 256
         '#version' => 6003,
257
-      ),
258
-      'rules_comment_deleted_by_admin' => array(
257
+        ),
258
+        'rules_comment_deleted_by_admin' => array(
259 259
         '#type' => 'rule',
260 260
         '#set' => 'event_comment_delete',
261 261
         '#label' => 'Comment deleted by admin',
262 262
         '#active' => 1,
263 263
         '#weight' => '0',
264 264
         '#categories' => array(
265
-          '0' => 'moderator notification',
266
-          '1' => 'boinc_standard',
265
+            '0' => 'moderator notification',
266
+            '1' => 'boinc_standard',
267 267
         ),
268 268
         '#status' => 'default',
269 269
         '#conditions' => array(),
270 270
         '#actions' => array(
271
-          '0' => array(
271
+            '0' => array(
272 272
             '#type' => 'action',
273 273
             '#settings' => array(
274
-              'from' => '',
275
-              'subject' => 'Comment deleted at [:global:site-name] by admin',
276
-              'message' => "Comment to [node:type] topic '[node:title]' deleted by admin [user:display-name].\r\n\r\nLink: <?php print url('node/' . \$node->nid, array('absolute' => TRUE, 'language' => 'en')); ?>",
277
-              '#eval input' => array(
274
+                'from' => '',
275
+                'subject' => 'Comment deleted at [:global:site-name] by admin',
276
+                'message' => "Comment to [node:type] topic '[node:title]' deleted by admin [user:display-name].\r\n\r\nLink: <?php print url('node/' . \$node->nid, array('absolute' => TRUE, 'language' => 'en')); ?>",
277
+                '#eval input' => array(
278 278
                 'token_rules_input_evaluator' => array(
279
-                  'subject' => array(
279
+                    'subject' => array(
280 280
                     '0' => ':global',
281
-                  ),
282
-                  'message' => array(
281
+                    ),
282
+                    'message' => array(
283 283
                     '0' => 'node',
284 284
                     '1' => 'user',
285 285
                     '2' => ':global',
286
-                  ),
287
-                  'from' => array(
286
+                    ),
287
+                    'from' => array(
288 288
                     '0' => ':global',
289
-                  ),
289
+                    ),
290 290
                 ),
291 291
                 'rules_input_evaluator_php' => array(
292
-                  'message' => array(
292
+                    'message' => array(
293 293
                     '0' => 'node',
294
-                  ),
294
+                    ),
295
+                ),
295 296
                 ),
296
-              ),
297 297
             ),
298 298
             '#name' => 'boinccore_rules_action_mail_to_moderators',
299 299
             '#info' => array(
300
-              'label' => 'Notify moderators via email',
301
-              'module' => 'BOINC core',
302
-              'eval input' => array(
300
+                'label' => 'Notify moderators via email',
301
+                'module' => 'BOINC core',
302
+                'eval input' => array(
303 303
                 '0' => 'subject',
304 304
                 '1' => 'message',
305 305
                 '2' => 'from',
306
-              ),
306
+                ),
307 307
             ),
308 308
             '#weight' => 0.0,
309
-          ),
309
+            ),
310 310
         ),
311 311
         '#version' => 6003,
312
-      ),
313
-      'rules_comment_edited_by_moderator_or_admin' => array(
312
+        ),
313
+        'rules_comment_edited_by_moderator_or_admin' => array(
314 314
         '#type' => 'rule',
315 315
         '#set' => 'event_comment_update',
316 316
         '#label' => 'Comment is edited by moderator or admin',
317 317
         '#active' => 1,
318 318
         '#weight' => '0',
319 319
         '#categories' => array(
320
-          '0' => 'boinc_standard',
321
-          '1' => 'moderator notification',
320
+            '0' => 'boinc_standard',
321
+            '1' => 'moderator notification',
322 322
         ),
323 323
         '#status' => 'default',
324 324
         '#conditions' => array(
325
-          '0' => array(
325
+            '0' => array(
326 326
             '#negate' => 1,
327 327
             '#weight' => 0.0,
328 328
             '#info' => array(
329
-              'label' => 'Compare two users: acting user (who edited the comment) is NOT the comment author',
330
-              'label callback' => FALSE,
331
-              'arguments' => array(
329
+                'label' => 'Compare two users: acting user (who edited the comment) is NOT the comment author',
330
+                'label callback' => FALSE,
331
+                'arguments' => array(
332 332
                 'user1' => array(
333
-                  'type' => 'user',
334
-                  'label' => 'User account 1',
333
+                    'type' => 'user',
334
+                    'label' => 'User account 1',
335 335
                 ),
336 336
                 'user2' => array(
337
-                  'type' => 'user',
338
-                  'label' => 'User account 2',
337
+                    'type' => 'user',
338
+                    'label' => 'User account 2',
339
+                ),
339 340
                 ),
340
-              ),
341
-              'module' => 'User',
341
+                'module' => 'User',
342 342
             ),
343 343
             '#name' => 'rules_condition_user_comparison',
344 344
             '#settings' => array(
345
-              '#argument map' => array(
345
+                '#argument map' => array(
346 346
                 'user1' => 'user',
347 347
                 'user2' => 'comment_author',
348
-              ),
348
+                ),
349 349
             ),
350 350
             '#type' => 'condition',
351
-          ),
351
+            ),
352 352
         ),
353 353
         '#actions' => array(
354
-          '0' => array(
354
+            '0' => array(
355 355
             '#type' => 'action',
356 356
             '#settings' => array(
357
-              'from' => '',
358
-              'subject' => 'Comment edited at [:global:site-name] by moderator or admin',
359
-              'message' => "Comment has been edited by moderator/admin [user:display-name]\r\n\r\nLink: <?php print url('<front>', array('absolute' => TRUE, 'language' => 'en')); ?>/goto/comment/[comment:comment-cid]",
360
-              '#eval input' => array(
357
+                'from' => '',
358
+                'subject' => 'Comment edited at [:global:site-name] by moderator or admin',
359
+                'message' => "Comment has been edited by moderator/admin [user:display-name]\r\n\r\nLink: <?php print url('<front>', array('absolute' => TRUE, 'language' => 'en')); ?>/goto/comment/[comment:comment-cid]",
360
+                '#eval input' => array(
361 361
                 'token_rules_input_evaluator' => array(
362
-                  'subject' => array(
362
+                    'subject' => array(
363 363
                     '0' => ':global',
364
-                  ),
365
-                  'message' => array(
364
+                    ),
365
+                    'message' => array(
366 366
                     '0' => 'comment',
367 367
                     '1' => 'user',
368 368
                     '2' => ':global',
369
-                  ),
370
-                  'from' => array(
369
+                    ),
370
+                    'from' => array(
371 371
                     '0' => ':global',
372
-                  ),
372
+                    ),
373 373
                 ),
374 374
                 'rules_input_evaluator_php' => array(
375
-                  'message' => array(),
375
+                    'message' => array(),
376
+                ),
376 377
                 ),
377
-              ),
378 378
             ),
379 379
             '#name' => 'boinccore_rules_action_mail_to_moderators',
380 380
             '#info' => array(
381
-              'label' => 'Notify moderators via email',
382
-              'module' => 'BOINC core',
383
-              'eval input' => array(
381
+                'label' => 'Notify moderators via email',
382
+                'module' => 'BOINC core',
383
+                'eval input' => array(
384 384
                 '0' => 'subject',
385 385
                 '1' => 'message',
386 386
                 '2' => 'from',
387
-              ),
387
+                ),
388 388
             ),
389 389
             '#weight' => 0.0,
390
-          ),
390
+            ),
391 391
         ),
392 392
         '#version' => 6003,
393
-      ),
394
-      'rules_comment_is_published_unhidden_by_moderator_or_admin' => array(
393
+        ),
394
+        'rules_comment_is_published_unhidden_by_moderator_or_admin' => array(
395 395
         '#type' => 'rule',
396 396
         '#set' => 'event_boinccore_comment_unhidden',
397 397
         '#label' => 'Comment is unhidden by moderator or admin',
398 398
         '#active' => 1,
399 399
         '#weight' => '0',
400 400
         '#categories' => array(
401
-          '0' => 'boinc_standard',
402
-          '1' => 'moderator notification',
401
+            '0' => 'boinc_standard',
402
+            '1' => 'moderator notification',
403 403
         ),
404 404
         '#status' => 'default',
405 405
         '#conditions' => array(
406
-          '0' => array(
406
+            '0' => array(
407 407
             '#type' => 'condition',
408 408
             '#settings' => array(
409
-              '#argument map' => array(
409
+                '#argument map' => array(
410 410
                 'user1' => 'user',
411 411
                 'user2' => 'comment_author',
412
-              ),
412
+                ),
413 413
             ),
414 414
             '#name' => 'rules_condition_user_comparison',
415 415
             '#info' => array(
416
-              'label' => 'Compare two users: acting user (who unhid the comment) is NOT the comment author',
417
-              'label callback' => FALSE,
418
-              'arguments' => array(
416
+                'label' => 'Compare two users: acting user (who unhid the comment) is NOT the comment author',
417
+                'label callback' => FALSE,
418
+                'arguments' => array(
419 419
                 'user1' => array(
420
-                  'type' => 'user',
421
-                  'label' => 'User account 1',
420
+                    'type' => 'user',
421
+                    'label' => 'User account 1',
422 422
                 ),
423 423
                 'user2' => array(
424
-                  'type' => 'user',
425
-                  'label' => 'User account 2',
424
+                    'type' => 'user',
425
+                    'label' => 'User account 2',
426
+                ),
426 427
                 ),
427
-              ),
428
-              'module' => 'User',
428
+                'module' => 'User',
429 429
             ),
430 430
             '#negate' => 1,
431 431
             '#weight' => 0.0,
432
-          ),
432
+            ),
433 433
         ),
434 434
         '#actions' => array(
435
-          '0' => array(
435
+            '0' => array(
436 436
             '#info' => array(
437
-              'label' => 'Notify moderators via email',
438
-              'module' => 'BOINC core',
439
-              'eval input' => array(
437
+                'label' => 'Notify moderators via email',
438
+                'module' => 'BOINC core',
439
+                'eval input' => array(
440 440
                 '0' => 'subject',
441 441
                 '1' => 'message',
442 442
                 '2' => 'from',
443
-              ),
443
+                ),
444 444
             ),
445 445
             '#name' => 'boinccore_rules_action_mail_to_moderators',
446 446
             '#settings' => array(
447
-              'from' => '',
448
-              'subject' => 'Comment at [:global:site-name] unhidden by moderator or admin',
449
-              'message' => "Comment has been unhidden by moderator/admin [user:display-name].\r\n\r\nLink: <?php print url('<front>', array('absolute' => TRUE, 'language' => 'en')); ?>/goto/comment/[comment:comment-cid]",
450
-              '#eval input' => array(
447
+                'from' => '',
448
+                'subject' => 'Comment at [:global:site-name] unhidden by moderator or admin',
449
+                'message' => "Comment has been unhidden by moderator/admin [user:display-name].\r\n\r\nLink: <?php print url('<front>', array('absolute' => TRUE, 'language' => 'en')); ?>/goto/comment/[comment:comment-cid]",
450
+                '#eval input' => array(
451 451
                 'token_rules_input_evaluator' => array(
452
-                  'subject' => array(
452
+                    'subject' => array(
453 453
                     '0' => ':global',
454
-                  ),
455
-                  'message' => array(
454
+                    ),
455
+                    'message' => array(
456 456
                     '0' => 'comment',
457 457
                     '1' => 'user',
458 458
                     '2' => ':global',
459
-                  ),
460
-                  'from' => array(
459
+                    ),
460
+                    'from' => array(
461 461
                     '0' => ':global',
462
-                  ),
462
+                    ),
463 463
                 ),
464 464
                 'rules_input_evaluator_php' => array(
465
-                  'message' => array(),
465
+                    'message' => array(),
466
+                ),
466 467
                 ),
467
-              ),
468 468
             ),
469 469
             '#type' => 'action',
470 470
             '#weight' => 0.0,
471
-          ),
471
+            ),
472 472
         ),
473 473
         '#version' => 6003,
474
-      ),
475
-      'rules_comment_is_unpublished_hidden_by_moderator_or_admin' => array(
474
+        ),
475
+        'rules_comment_is_unpublished_hidden_by_moderator_or_admin' => array(
476 476
         '#type' => 'rule',
477 477
         '#set' => 'event_comment_unpublish',
478 478
         '#label' => 'Comment is hidden by moderator or admin',
479 479
         '#active' => 1,
480 480
         '#weight' => '0',
481 481
         '#categories' => array(
482
-          '0' => 'boinc_standard',
483
-          '1' => 'moderator notification',
482
+            '0' => 'boinc_standard',
483
+            '1' => 'moderator notification',
484 484
         ),
485 485
         '#status' => 'default',
486 486
         '#conditions' => array(
487
-          '0' => array(
487
+            '0' => array(
488 488
             '#weight' => 0.0,
489 489
             '#negate' => 1,
490 490
             '#info' => array(
491
-              'label' => 'Compare two users: acting user (who hid the comment) is NOT the comment author',
492
-              'label callback' => FALSE,
493
-              'arguments' => array(
491
+                'label' => 'Compare two users: acting user (who hid the comment) is NOT the comment author',
492
+                'label callback' => FALSE,
493
+                'arguments' => array(
494 494
                 'user1' => array(
495
-                  'type' => 'user',
496
-                  'label' => 'User account 1',
495
+                    'type' => 'user',
496
+                    'label' => 'User account 1',
497 497
                 ),
498 498
                 'user2' => array(
499
-                  'type' => 'user',
500
-                  'label' => 'User account 2',
499
+                    'type' => 'user',
500
+                    'label' => 'User account 2',
501
+                ),
501 502
                 ),
502
-              ),
503
-              'module' => 'User',
503
+                'module' => 'User',
504 504
             ),
505 505
             '#name' => 'rules_condition_user_comparison',
506 506
             '#type' => 'condition',
507 507
             '#settings' => array(
508
-              '#argument map' => array(
508
+                '#argument map' => array(
509 509
                 'user1' => 'user',
510 510
                 'user2' => 'comment_author',
511
-              ),
511
+                ),
512
+            ),
512 513
             ),
513
-          ),
514 514
         ),
515 515
         '#actions' => array(
516
-          '0' => array(
516
+            '0' => array(
517 517
             '#type' => 'action',
518 518
             '#settings' => array(
519
-              'from' => '',
520
-              'subject' => 'Comment at [:global:site-name] hidden by moderator or admin',
521
-              'message' => "Comment has been hidden by moderator/admin [user:display-name].\r\n\r\nLink: <?php print url('<front>', array('absolute' => TRUE, 'language' => 'en')); ?>/goto/comment/[comment:comment-cid]",
522
-              '#eval input' => array(
519
+                'from' => '',
520
+                'subject' => 'Comment at [:global:site-name] hidden by moderator or admin',
521
+                'message' => "Comment has been hidden by moderator/admin [user:display-name].\r\n\r\nLink: <?php print url('<front>', array('absolute' => TRUE, 'language' => 'en')); ?>/goto/comment/[comment:comment-cid]",
522
+                '#eval input' => array(
523 523
                 'token_rules_input_evaluator' => array(
524
-                  'subject' => array(
524
+                    'subject' => array(
525 525
                     '0' => ':global',
526
-                  ),
527
-                  'message' => array(
526
+                    ),
527
+                    'message' => array(
528 528
                     '0' => 'comment',
529 529
                     '1' => 'user',
530 530
                     '2' => ':global',
531
-                  ),
532
-                  'from' => array(
531
+                    ),
532
+                    'from' => array(
533 533
                     '0' => ':global',
534
-                  ),
534
+                    ),
535 535
                 ),
536 536
                 'rules_input_evaluator_php' => array(
537
-                  'message' => array(),
537
+                    'message' => array(),
538
+                ),
538 539
                 ),
539
-              ),
540 540
             ),
541 541
             '#name' => 'boinccore_rules_action_mail_to_moderators',
542 542
             '#info' => array(
543
-              'label' => 'Notify moderators via email',
544
-              'module' => 'BOINC core',
545
-              'eval input' => array(
543
+                'label' => 'Notify moderators via email',
544
+                'module' => 'BOINC core',
545
+                'eval input' => array(
546 546
                 '0' => 'subject',
547 547
                 '1' => 'message',
548 548
                 '2' => 'from',
549
-              ),
549
+                ),
550 550
             ),
551 551
             '#weight' => 0.0,
552
-          ),
552
+            ),
553 553
         ),
554 554
         '#version' => 6003,
555
-      ),
556
-      'rules_forum_topic_is_edited_by_moderator_or_admin' => array(
555
+        ),
556
+        'rules_forum_topic_is_edited_by_moderator_or_admin' => array(
557 557
         '#type' => 'rule',
558 558
         '#set' => 'event_node_update',
559 559
         '#label' => 'Forum topic is edited by moderator or admin',
560 560
         '#active' => 1,
561 561
         '#weight' => '0',
562 562
         '#categories' => array(
563
-          '0' => 'boinc_standard',
564
-          '1' => 'moderator notification',
563
+            '0' => 'boinc_standard',
564
+            '1' => 'moderator notification',
565 565
         ),
566 566
         '#status' => 'default',
567 567
         '#conditions' => array(
568
-          '0' => array(
568
+            '0' => array(
569 569
             '#weight' => 0.0,
570 570
             '#type' => 'condition',
571 571
             '#settings' => array(
572
-              'roles' => array(
572
+                'roles' => array(
573 573
                 '0' => 3519698132,
574 574
                 '1' => 1271379760,
575
-              ),
576
-              'operation' => 'OR',
577
-              '#argument map' => array(
575
+                ),
576
+                'operation' => 'OR',
577
+                '#argument map' => array(
578 578
                 'user' => 'user',
579
-              ),
579
+                ),
580 580
             ),
581 581
             '#name' => 'rules_condition_user_hasrole',
582 582
             '#info' => array(
583
-              'label' => 'User has role(s): administrator or moderator',
584
-              'label callback' => FALSE,
585
-              'arguments' => array(
583
+                'label' => 'User has role(s): administrator or moderator',
584
+                'label callback' => FALSE,
585
+                'arguments' => array(
586 586
                 'user' => array(
587
-                  'type' => 'user',
588
-                  'label' => 'User',
587
+                    'type' => 'user',
588
+                    'label' => 'User',
589
+                ),
589 590
                 ),
590
-              ),
591
-              'module' => 'User',
591
+                'module' => 'User',
592 592
             ),
593
-          ),
594
-          '1' => array(
593
+            ),
594
+            '1' => array(
595 595
             '#weight' => 0.0,
596 596
             '0' => array(
597
-              '#weight' => 0.0,
598
-              '#info' => array(
597
+                '#weight' => 0.0,
598
+                '#info' => array(
599 599
                 'label' => 'Updated content is Forum topic',
600 600
                 'arguments' => array(
601
-                  'node' => array(
601
+                    'node' => array(
602 602
                     'type' => 'node',
603 603
                     'label' => 'Content',
604
-                  ),
604
+                    ),
605 605
                 ),
606 606
                 'module' => 'Node',
607
-              ),
608
-              '#name' => 'rules_condition_content_is_type',
609
-              '#settings' => array(
607
+                ),
608
+                '#name' => 'rules_condition_content_is_type',
609
+                '#settings' => array(
610 610
                 'type' => array(
611
-                  'forum' => 'forum',
611
+                    'forum' => 'forum',
612 612
                 ),
613 613
                 '#argument map' => array(
614
-                  'node' => 'node',
614
+                    'node' => 'node',
615
+                ),
615 616
                 ),
616
-              ),
617
-              '#type' => 'condition',
617
+                '#type' => 'condition',
618 618
             ),
619 619
             '#type' => 'OR',
620 620
             '1' => array(
621
-              '#type' => 'condition',
622
-              '#settings' => array(
621
+                '#type' => 'condition',
622
+                '#settings' => array(
623 623
                 'type' => array(
624
-                  'team_forum' => 'team_forum',
624
+                    'team_forum' => 'team_forum',
625 625
                 ),
626 626
                 '#argument map' => array(
627
-                  'node' => 'node',
627
+                    'node' => 'node',
628 628
                 ),
629
-              ),
630
-              '#name' => 'rules_condition_content_is_type',
631
-              '#info' => array(
629
+                ),
630
+                '#name' => 'rules_condition_content_is_type',
631
+                '#info' => array(
632 632
                 'label' => 'Updated content is Team forum topic',
633 633
                 'arguments' => array(
634
-                  'node' => array(
634
+                    'node' => array(
635 635
                     'type' => 'node',
636 636
                     'label' => 'Content',
637
-                  ),
637
+                    ),
638 638
                 ),
639 639
                 'module' => 'Node',
640
-              ),
641
-              '#weight' => 0.0,
640
+                ),
641
+                '#weight' => 0.0,
642 642
             ),
643
-          ),
644
-          '2' => array(
643
+            ),
644
+            '2' => array(
645 645
             '#weight' => 0.0,
646 646
             '#info' => array(
647
-              'label' => 'PHP code: content changed',
648
-              'label callback' => FALSE,
649
-              'module' => 'PHP',
650
-              'eval input' => array(
647
+                'label' => 'PHP code: content changed',
648
+                'label callback' => FALSE,
649
+                'module' => 'PHP',
650
+                'eval input' => array(
651 651
                 '0' => 'code',
652
-              ),
652
+                ),
653 653
             ),
654 654
             '#name' => 'rules_condition_custom_php',
655 655
             '#settings' => array(
656
-              'code' => 'return ($node->body != $node_unchanged->body);',
657
-              'vars' => array(
656
+                'code' => 'return ($node->body != $node_unchanged->body);',
657
+                'vars' => array(
658 658
                 '0' => 'node',
659 659
                 '1' => 'node_unchanged',
660
-              ),
661
-              '#eval input' => array(
660
+                ),
661
+                '#eval input' => array(
662 662
                 'token_rules_input_evaluator' => array(
663
-                  'code' => array(
663
+                    'code' => array(
664 664
                     '0' => ':global',
665
-                  ),
665
+                    ),
666
+                ),
666 667
                 ),
667
-              ),
668 668
             ),
669 669
             '#type' => 'condition',
670
-          ),
670
+            ),
671 671
         ),
672 672
         '#actions' => array(
673
-          '0' => array(
673
+            '0' => array(
674 674
             '#type' => 'action',
675 675
             '#settings' => array(
676
-              'from' => '',
677
-              'subject' => 'Forum topic at [:global:site-name] edited by moderator/admin',
678
-              'message' => "[node:type] topic '[node:title]' has been edited by moderator/admin [user:display-name].\r\n\r\nLink: <?php print url('node/' . \$node->nid, array('absolute' => TRUE, 'language' => 'en')); ?>",
679
-              '#eval input' => array(
676
+                'from' => '',
677
+                'subject' => 'Forum topic at [:global:site-name] edited by moderator/admin',
678
+                'message' => "[node:type] topic '[node:title]' has been edited by moderator/admin [user:display-name].\r\n\r\nLink: <?php print url('node/' . \$node->nid, array('absolute' => TRUE, 'language' => 'en')); ?>",
679
+                '#eval input' => array(
680 680
                 'token_rules_input_evaluator' => array(
681
-                  'subject' => array(
681
+                    'subject' => array(
682 682
                     '0' => ':global',
683
-                  ),
684
-                  'message' => array(
683
+                    ),
684
+                    'message' => array(
685 685
                     '0' => 'node',
686 686
                     '1' => 'user',
687 687
                     '2' => ':global',
688
-                  ),
689
-                  'from' => array(
688
+                    ),
689
+                    'from' => array(
690 690
                     '0' => ':global',
691
-                  ),
691
+                    ),
692 692
                 ),
693 693
                 'rules_input_evaluator_php' => array(
694
-                  'message' => array(
694
+                    'message' => array(
695 695
                     '0' => 'node',
696
-                  ),
696
+                    ),
697
+                ),
697 698
                 ),
698
-              ),
699 699
             ),
700 700
             '#name' => 'boinccore_rules_action_mail_to_moderators',
701 701
             '#info' => array(
702
-              'label' => 'Notify moderators via email',
703
-              'module' => 'BOINC core',
704
-              'eval input' => array(
702
+                'label' => 'Notify moderators via email',
703
+                'module' => 'BOINC core',
704
+                'eval input' => array(
705 705
                 '0' => 'subject',
706 706
                 '1' => 'message',
707 707
                 '2' => 'from',
708
-              ),
708
+                ),
709 709
             ),
710 710
             '#weight' => 0.0,
711
-          ),
711
+            ),
712 712
         ),
713 713
         '#version' => 6003,
714
-      ),
715
-      'rules_forum_topic_is_hidden_by_moderator_admin' => array(
714
+        ),
715
+        'rules_forum_topic_is_hidden_by_moderator_admin' => array(
716 716
         '#type' => 'rule',
717 717
         '#set' => 'event_node_update',
718 718
         '#label' => 'Forum topic is hidden by moderator/admin',
719 719
         '#active' => 1,
720 720
         '#weight' => '0',
721 721
         '#categories' => array(
722
-          '0' => 'boinc_standard',
723
-          '1' => 'moderator notification',
722
+            '0' => 'boinc_standard',
723
+            '1' => 'moderator notification',
724 724
         ),
725 725
         '#status' => 'default',
726 726
         '#conditions' => array(
727
-          '0' => array(
727
+            '0' => array(
728 728
             '#type' => 'condition',
729 729
             '#settings' => array(
730
-              'roles' => array(
730
+                'roles' => array(
731 731
                 '0' => 3519698132,
732 732
                 '1' => 1271379760,
733
-              ),
734
-              'operation' => 'OR',
735
-              '#argument map' => array(
733
+                ),
734
+                'operation' => 'OR',
735
+                '#argument map' => array(
736 736
                 'user' => 'user',
737
-              ),
737
+                ),
738 738
             ),
739 739
             '#name' => 'rules_condition_user_hasrole',
740 740
             '#info' => array(
741
-              'label' => 'User has role(s): administrator or moderator',
742
-              'label callback' => FALSE,
743
-              'arguments' => array(
741
+                'label' => 'User has role(s): administrator or moderator',
742
+                'label callback' => FALSE,
743
+                'arguments' => array(
744 744
                 'user' => array(
745
-                  'type' => 'user',
746
-                  'label' => 'User',
745
+                    'type' => 'user',
746
+                    'label' => 'User',
747
+                ),
747 748
                 ),
748
-              ),
749
-              'module' => 'User',
749
+                'module' => 'User',
750 750
             ),
751 751
             '#weight' => 0.0,
752
-          ),
753
-          '1' => array(
752
+            ),
753
+            '1' => array(
754 754
             '#weight' => 0.0,
755 755
             '0' => array(
756
-              '#weight' => 0.0,
757
-              '#type' => 'condition',
758
-              '#settings' => array(
756
+                '#weight' => 0.0,
757
+                '#type' => 'condition',
758
+                '#settings' => array(
759 759
                 'type' => array(
760
-                  'forum' => 'forum',
760
+                    'forum' => 'forum',
761 761
                 ),
762 762
                 '#argument map' => array(
763
-                  'node' => 'node',
763
+                    'node' => 'node',
764 764
                 ),
765
-              ),
766
-              '#name' => 'rules_condition_content_is_type',
767
-              '#info' => array(
765
+                ),
766
+                '#name' => 'rules_condition_content_is_type',
767
+                '#info' => array(
768 768
                 'label' => 'Updated content is Forum topic',
769 769
                 'arguments' => array(
770
-                  'node' => array(
770
+                    'node' => array(
771 771
                     'type' => 'node',
772 772
                     'label' => 'Content',
773
-                  ),
773
+                    ),
774 774
                 ),
775 775
                 'module' => 'Node',
776
-              ),
776
+                ),
777 777
             ),
778 778
             '#type' => 'OR',
779 779
             '1' => array(
780
-              '#type' => 'condition',
781
-              '#settings' => array(
780
+                '#type' => 'condition',
781
+                '#settings' => array(
782 782
                 'type' => array(
783
-                  'team_forum' => 'team_forum',
783
+                    'team_forum' => 'team_forum',
784 784
                 ),
785 785
                 '#argument map' => array(
786
-                  'node' => 'node',
786
+                    'node' => 'node',
787
+                ),
787 788
                 ),
788
-              ),
789
-              '#name' => 'rules_condition_content_is_type',
790
-              '#info' => array(
789
+                '#name' => 'rules_condition_content_is_type',
790
+                '#info' => array(
791 791
                 'label' => 'Updated content is Team forum topic',
792 792
                 'arguments' => array(
793
-                  'node' => array(
793
+                    'node' => array(
794 794
                     'type' => 'node',
795 795
                     'label' => 'Content',
796
-                  ),
796
+                    ),
797 797
                 ),
798 798
                 'module' => 'Node',
799
-              ),
800
-              '#weight' => 0.0,
799
+                ),
800
+                '#weight' => 0.0,
801
+            ),
801 802
             ),
802
-          ),
803
-          '3' => array(
803
+            '3' => array(
804 804
             '#weight' => 0.0,
805 805
             '#info' => array(
806
-              'label' => 'PHP code: node content unchanged',
807
-              'label callback' => FALSE,
808
-              'module' => 'PHP',
809
-              'eval input' => array(
806
+                'label' => 'PHP code: node content unchanged',
807
+                'label callback' => FALSE,
808
+                'module' => 'PHP',
809
+                'eval input' => array(
810 810
                 '0' => 'code',
811
-              ),
811
+                ),
812 812
             ),
813 813
             '#name' => 'rules_condition_custom_php',
814 814
             '#settings' => array(
815
-              'code' => 'return $node->body == $node_unchanged->body;',
816
-              'vars' => array(
815
+                'code' => 'return $node->body == $node_unchanged->body;',
816
+                'vars' => array(
817 817
                 '0' => 'node',
818 818
                 '1' => 'node_unchanged',
819
-              ),
820
-              '#eval input' => array(
819
+                ),
820
+                '#eval input' => array(
821 821
                 'token_rules_input_evaluator' => array(
822
-                  'code' => array(
822
+                    'code' => array(
823 823
                     '0' => ':global',
824
-                  ),
824
+                    ),
825
+                ),
825 826
                 ),
826
-              ),
827 827
             ),
828 828
             '#type' => 'condition',
829
-          ),
830
-          '4' => array(
829
+            ),
830
+            '4' => array(
831 831
             '#weight' => 0.0,
832 832
             '#info' => array(
833
-              'label' => 'PHP code: node status changed to hidden',
834
-              'label callback' => FALSE,
835
-              'module' => 'PHP',
836
-              'eval input' => array(
833
+                'label' => 'PHP code: node status changed to hidden',
834
+                'label callback' => FALSE,
835
+                'module' => 'PHP',
836
+                'eval input' => array(
837 837
                 '0' => 'code',
838
-              ),
838
+                ),
839 839
             ),
840 840
             '#name' => 'rules_condition_custom_php',
841 841
             '#type' => 'condition',
842 842
             '#settings' => array(
843
-              'code' => 'return $node_unchanged->status == 1 && $node->status == 0;',
844
-              'vars' => array(
843
+                'code' => 'return $node_unchanged->status == 1 && $node->status == 0;',
844
+                'vars' => array(
845 845
                 '0' => 'node',
846 846
                 '1' => 'node_unchanged',
847
-              ),
848
-              '#eval input' => array(
847
+                ),
848
+                '#eval input' => array(
849 849
                 'token_rules_input_evaluator' => array(
850
-                  'code' => array(
850
+                    'code' => array(
851 851
                     '0' => ':global',
852
-                  ),
852
+                    ),
853
+                ),
853 854
                 ),
854
-              ),
855 855
             ),
856
-          ),
856
+            ),
857 857
         ),
858 858
         '#actions' => array(
859
-          '0' => array(
859
+            '0' => array(
860 860
             '#info' => array(
861
-              'label' => 'Notify moderators via email',
862
-              'module' => 'BOINC core',
863
-              'eval input' => array(
861
+                'label' => 'Notify moderators via email',
862
+                'module' => 'BOINC core',
863
+                'eval input' => array(
864 864
                 '0' => 'subject',
865 865
                 '1' => 'message',
866 866
                 '2' => 'from',
867
-              ),
867
+                ),
868 868
             ),
869 869
             '#name' => 'boinccore_rules_action_mail_to_moderators',
870 870
             '#settings' => array(
871
-              'from' => '',
872
-              'subject' => 'Forum topic at [:global:site-name] hidden by moderator/admin',
873
-              'message' => "[node:type] topic '[node:title]' has been hidden by moderator/admin [user:display-name].\r\n\r\nLink: <?php print url('node/' . \$node->nid, array('absolute' => TRUE, 'language' => 'en')); ?>",
874
-              '#eval input' => array(
871
+                'from' => '',
872
+                'subject' => 'Forum topic at [:global:site-name] hidden by moderator/admin',
873
+                'message' => "[node:type] topic '[node:title]' has been hidden by moderator/admin [user:display-name].\r\n\r\nLink: <?php print url('node/' . \$node->nid, array('absolute' => TRUE, 'language' => 'en')); ?>",
874
+                '#eval input' => array(
875 875
                 'token_rules_input_evaluator' => array(
876
-                  'subject' => array(
876
+                    'subject' => array(
877 877
                     '0' => ':global',
878
-                  ),
879
-                  'message' => array(
878
+                    ),
879
+                    'message' => array(
880 880
                     '0' => 'node',
881 881
                     '1' => 'user',
882 882
                     '2' => ':global',
883
-                  ),
884
-                  'from' => array(
883
+                    ),
884
+                    'from' => array(
885 885
                     '0' => ':global',
886
-                  ),
886
+                    ),
887 887
                 ),
888 888
                 'rules_input_evaluator_php' => array(
889
-                  'message' => array(
889
+                    'message' => array(
890 890
                     '0' => 'node',
891
-                  ),
891
+                    ),
892
+                ),
892 893
                 ),
893
-              ),
894 894
             ),
895 895
             '#type' => 'action',
896 896
             '#weight' => 0.0,
897
-          ),
897
+            ),
898 898
         ),
899 899
         '#version' => 6003,
900
-      ),
901
-      'rules_forum_topic_is_moved_to_a_different_forum_by_moderator_or_admin' => array(
900
+        ),
901
+        'rules_forum_topic_is_moved_to_a_different_forum_by_moderator_or_admin' => array(
902 902
         '#type' => 'rule',
903 903
         '#set' => 'event_node_update',
904 904
         '#label' => 'Forum topic is moved to a different forum by moderator or admin',
905 905
         '#active' => 1,
906 906
         '#weight' => '0',
907 907
         '#categories' => array(
908
-          '0' => 'boinc_standard',
909
-          '1' => 'moderator notification',
908
+            '0' => 'boinc_standard',
909
+            '1' => 'moderator notification',
910 910
         ),
911 911
         '#status' => 'default',
912 912
         '#conditions' => array(
913
-          '0' => array(
913
+            '0' => array(
914 914
             '#weight' => 0.0,
915 915
             '#type' => 'condition',
916 916
             '#settings' => array(
917
-              'roles' => array(
917
+                'roles' => array(
918 918
                 '0' => 3519698132,
919 919
                 '1' => 1271379760,
920
-              ),
921
-              'operation' => 'OR',
922
-              '#argument map' => array(
920
+                ),
921
+                'operation' => 'OR',
922
+                '#argument map' => array(
923 923
                 'user' => 'user',
924
-              ),
924
+                ),
925 925
             ),
926 926
             '#name' => 'rules_condition_user_hasrole',
927 927
             '#info' => array(
928
-              'label' => 'User has role(s): administrator or moderator',
929
-              'label callback' => FALSE,
930
-              'arguments' => array(
928
+                'label' => 'User has role(s): administrator or moderator',
929
+                'label callback' => FALSE,
930
+                'arguments' => array(
931 931
                 'user' => array(
932
-                  'type' => 'user',
933
-                  'label' => 'User',
932
+                    'type' => 'user',
933
+                    'label' => 'User',
934 934
                 ),
935
-              ),
936
-              'module' => 'User',
935
+                ),
936
+                'module' => 'User',
937
+            ),
937 938
             ),
938
-          ),
939
-          '1' => array(
939
+            '1' => array(
940 940
             '#weight' => 0.0,
941 941
             '0' => array(
942
-              '#weight' => 0.0,
943
-              '#info' => array(
942
+                '#weight' => 0.0,
943
+                '#info' => array(
944 944
                 'label' => 'Updated content is Forum topic',
945 945
                 'arguments' => array(
946
-                  'node' => array(
946
+                    'node' => array(
947 947
                     'type' => 'node',
948 948
                     'label' => 'Content',
949
-                  ),
949
+                    ),
950 950
                 ),
951 951
                 'module' => 'Node',
952
-              ),
953
-              '#name' => 'rules_condition_content_is_type',
954
-              '#settings' => array(
952
+                ),
953
+                '#name' => 'rules_condition_content_is_type',
954
+                '#settings' => array(
955 955
                 'type' => array(
956
-                  'forum' => 'forum',
956
+                    'forum' => 'forum',
957 957
                 ),
958 958
                 '#argument map' => array(
959
-                  'node' => 'node',
959
+                    'node' => 'node',
960 960
                 ),
961
-              ),
962
-              '#type' => 'condition',
961
+                ),
962
+                '#type' => 'condition',
963 963
             ),
964 964
             '#type' => 'OR',
965 965
             '1' => array(
966
-              '#type' => 'condition',
967
-              '#settings' => array(
966
+                '#type' => 'condition',
967
+                '#settings' => array(
968 968
                 'type' => array(
969
-                  'team_forum' => 'team_forum',
969
+                    'team_forum' => 'team_forum',
970 970
                 ),
971 971
                 '#argument map' => array(
972
-                  'node' => 'node',
972
+                    'node' => 'node',
973
+                ),
973 974
                 ),
974
-              ),
975
-              '#name' => 'rules_condition_content_is_type',
976
-              '#info' => array(
975
+                '#name' => 'rules_condition_content_is_type',
976
+                '#info' => array(
977 977
                 'label' => 'Updated content is Team forum topic',
978 978
                 'arguments' => array(
979
-                  'node' => array(
979
+                    'node' => array(
980 980
                     'type' => 'node',
981 981
                     'label' => 'Content',
982
-                  ),
982
+                    ),
983 983
                 ),
984 984
                 'module' => 'Node',
985
-              ),
986
-              '#weight' => 0.0,
985
+                ),
986
+                '#weight' => 0.0,
987 987
             ),
988
-          ),
989
-          '2' => array(
988
+            ),
989
+            '2' => array(
990 990
             '#weight' => 0.0,
991 991
             '#info' => array(
992
-              'label' => 'PHP code: node moved to new forum parent',
993
-              'label callback' => FALSE,
994
-              'module' => 'PHP',
995
-              'eval input' => array(
992
+                'label' => 'PHP code: node moved to new forum parent',
993
+                'label callback' => FALSE,
994
+                'module' => 'PHP',
995
+                'eval input' => array(
996 996
                 '0' => 'code',
997
-              ),
997
+                ),
998 998
             ),
999 999
             '#name' => 'rules_condition_custom_php',
1000 1000
             '#settings' => array(
1001
-              'code' => 'return ($node->tid != $node_unchanged->tid);',
1002
-              'vars' => array(
1001
+                'code' => 'return ($node->tid != $node_unchanged->tid);',
1002
+                'vars' => array(
1003 1003
                 '0' => 'node',
1004 1004
                 '1' => 'node_unchanged',
1005
-              ),
1006
-              '#eval input' => array(
1005
+                ),
1006
+                '#eval input' => array(
1007 1007
                 'token_rules_input_evaluator' => array(
1008
-                  'code' => array(
1008
+                    'code' => array(
1009 1009
                     '0' => ':global',
1010
-                  ),
1010
+                    ),
1011
+                ),
1011 1012
                 ),
1012
-              ),
1013 1013
             ),
1014 1014
             '#type' => 'condition',
1015
-          ),
1015
+            ),
1016 1016
         ),
1017 1017
         '#actions' => array(
1018
-          '0' => array(
1018
+            '0' => array(
1019 1019
             '#type' => 'action',
1020 1020
             '#settings' => array(
1021
-              'from' => '',
1022
-              'subject' => 'Forum topic at [:global:site-name] moved by moderator/admin',
1023
-              'message' => "[node:type] topic '[node:title]' has been moved by moderator/admin [user:display-name].\r\n\r\nLink: <?php print url('node/' . \$node->nid, array('absolute' => TRUE, 'language' => 'en')); ?>",
1024
-              '#eval input' => array(
1021
+                'from' => '',
1022
+                'subject' => 'Forum topic at [:global:site-name] moved by moderator/admin',
1023
+                'message' => "[node:type] topic '[node:title]' has been moved by moderator/admin [user:display-name].\r\n\r\nLink: <?php print url('node/' . \$node->nid, array('absolute' => TRUE, 'language' => 'en')); ?>",
1024
+                '#eval input' => array(
1025 1025
                 'token_rules_input_evaluator' => array(
1026
-                  'subject' => array(
1026
+                    'subject' => array(
1027 1027
                     '0' => ':global',
1028
-                  ),
1029
-                  'message' => array(
1028
+                    ),
1029
+                    'message' => array(
1030 1030
                     '0' => 'node',
1031 1031
                     '1' => 'user',
1032 1032
                     '2' => ':global',
1033
-                  ),
1034
-                  'from' => array(
1033
+                    ),
1034
+                    'from' => array(
1035 1035
                     '0' => ':global',
1036
-                  ),
1036
+                    ),
1037 1037
                 ),
1038 1038
                 'rules_input_evaluator_php' => array(
1039
-                  'message' => array(
1039
+                    'message' => array(
1040 1040
                     '0' => 'node',
1041
-                  ),
1041
+                    ),
1042
+                ),
1042 1043
                 ),
1043
-              ),
1044 1044
             ),
1045 1045
             '#name' => 'boinccore_rules_action_mail_to_moderators',
1046 1046
             '#info' => array(
1047
-              'label' => 'Notify moderators via email',
1048
-              'module' => 'BOINC core',
1049
-              'eval input' => array(
1047
+                'label' => 'Notify moderators via email',
1048
+                'module' => 'BOINC core',
1049
+                'eval input' => array(
1050 1050
                 '0' => 'subject',
1051 1051
                 '1' => 'message',
1052 1052
                 '2' => 'from',
1053
-              ),
1053
+                ),
1054 1054
             ),
1055 1055
             '#weight' => 0.0,
1056
-          ),
1056
+            ),
1057 1057
         ),
1058 1058
         '#version' => 6003,
1059
-      ),
1060
-      'rules_forum_topic_is_unhidden_by_moderator_admin' => array(
1059
+        ),
1060
+        'rules_forum_topic_is_unhidden_by_moderator_admin' => array(
1061 1061
         '#type' => 'rule',
1062 1062
         '#set' => 'event_node_update',
1063 1063
         '#label' => 'Forum topic is unhidden by moderator/admin',
1064 1064
         '#active' => 1,
1065 1065
         '#weight' => '0',
1066 1066
         '#categories' => array(
1067
-          '0' => 'boinc_standard',
1068
-          '1' => 'moderator notification',
1067
+            '0' => 'boinc_standard',
1068
+            '1' => 'moderator notification',
1069 1069
         ),
1070 1070
         '#status' => 'default',
1071 1071
         '#conditions' => array(
1072
-          '0' => array(
1072
+            '0' => array(
1073 1073
             '#type' => 'condition',
1074 1074
             '#settings' => array(
1075
-              'roles' => array(
1075
+                'roles' => array(
1076 1076
                 '0' => 3519698132,
1077 1077
                 '1' => 1271379760,
1078
-              ),
1079
-              'operation' => 'OR',
1080
-              '#argument map' => array(
1078
+                ),
1079
+                'operation' => 'OR',
1080
+                '#argument map' => array(
1081 1081
                 'user' => 'user',
1082
-              ),
1082
+                ),
1083 1083
             ),
1084 1084
             '#name' => 'rules_condition_user_hasrole',
1085 1085
             '#info' => array(
1086
-              'label' => 'User has role(s): administrator or moderator',
1087
-              'label callback' => FALSE,
1088
-              'arguments' => array(
1086
+                'label' => 'User has role(s): administrator or moderator',
1087
+                'label callback' => FALSE,
1088
+                'arguments' => array(
1089 1089
                 'user' => array(
1090
-                  'type' => 'user',
1091
-                  'label' => 'User',
1090
+                    'type' => 'user',
1091
+                    'label' => 'User',
1092 1092
                 ),
1093
-              ),
1094
-              'module' => 'User',
1093
+                ),
1094
+                'module' => 'User',
1095 1095
             ),
1096 1096
             '#weight' => 0.0,
1097
-          ),
1098
-          '1' => array(
1097
+            ),
1098
+            '1' => array(
1099 1099
             '#type' => 'OR',
1100 1100
             '0' => array(
1101
-              '#info' => array(
1101
+                '#info' => array(
1102 1102
                 'label' => 'Updated content is Forum topic',
1103 1103
                 'arguments' => array(
1104
-                  'node' => array(
1104
+                    'node' => array(
1105 1105
                     'type' => 'node',
1106 1106
                     'label' => 'Content',
1107
-                  ),
1107
+                    ),
1108 1108
                 ),
1109 1109
                 'module' => 'Node',
1110
-              ),
1111
-              '#name' => 'rules_condition_content_is_type',
1112
-              '#settings' => array(
1110
+                ),
1111
+                '#name' => 'rules_condition_content_is_type',
1112
+                '#settings' => array(
1113 1113
                 'type' => array(
1114
-                  'forum' => 'forum',
1114
+                    'forum' => 'forum',
1115 1115
                 ),
1116 1116
                 '#argument map' => array(
1117
-                  'node' => 'node',
1117
+                    'node' => 'node',
1118
+                ),
1118 1119
                 ),
1119
-              ),
1120
-              '#type' => 'condition',
1121
-              '#weight' => 0.0,
1120
+                '#type' => 'condition',
1121
+                '#weight' => 0.0,
1122 1122
             ),
1123 1123
             '#weight' => 0.0,
1124 1124
             '1' => array(
1125
-              '#weight' => 0.0,
1126
-              '#info' => array(
1125
+                '#weight' => 0.0,
1126
+                '#info' => array(
1127 1127
                 'label' => 'Updated content is Team forum topic',
1128 1128
                 'arguments' => array(
1129
-                  'node' => array(
1129
+                    'node' => array(
1130 1130
                     'type' => 'node',
1131 1131
                     'label' => 'Content',
1132
-                  ),
1132
+                    ),
1133 1133
                 ),
1134 1134
                 'module' => 'Node',
1135
-              ),
1136
-              '#name' => 'rules_condition_content_is_type',
1137
-              '#settings' => array(
1135
+                ),
1136
+                '#name' => 'rules_condition_content_is_type',
1137
+                '#settings' => array(
1138 1138
                 'type' => array(
1139
-                  'team_forum' => 'team_forum',
1139
+                    'team_forum' => 'team_forum',
1140 1140
                 ),
1141 1141
                 '#argument map' => array(
1142
-                  'node' => 'node',
1142
+                    'node' => 'node',
1143
+                ),
1143 1144
                 ),
1144
-              ),
1145
-              '#type' => 'condition',
1145
+                '#type' => 'condition',
1146 1146
             ),
1147
-          ),
1148
-          '3' => array(
1147
+            ),
1148
+            '3' => array(
1149 1149
             '#type' => 'condition',
1150 1150
             '#settings' => array(
1151
-              'code' => 'return $node->body == $node_unchanged->body;',
1152
-              'vars' => array(
1151
+                'code' => 'return $node->body == $node_unchanged->body;',
1152
+                'vars' => array(
1153 1153
                 '0' => 'node',
1154 1154
                 '1' => 'node_unchanged',
1155
-              ),
1156
-              '#eval input' => array(
1155
+                ),
1156
+                '#eval input' => array(
1157 1157
                 'token_rules_input_evaluator' => array(
1158
-                  'code' => array(
1158
+                    'code' => array(
1159 1159
                     '0' => ':global',
1160
-                  ),
1160
+                    ),
1161
+                ),
1161 1162
                 ),
1162
-              ),
1163 1163
             ),
1164 1164
             '#name' => 'rules_condition_custom_php',
1165 1165
             '#info' => array(
1166
-              'label' => 'PHP code: node content is unchanged',
1167
-              'label callback' => FALSE,
1168
-              'module' => 'PHP',
1169
-              'eval input' => array(
1166
+                'label' => 'PHP code: node content is unchanged',
1167
+                'label callback' => FALSE,
1168
+                'module' => 'PHP',
1169
+                'eval input' => array(
1170 1170
                 '0' => 'code',
1171
-              ),
1171
+                ),
1172 1172
             ),
1173 1173
             '#weight' => 0.0,
1174
-          ),
1175
-          '4' => array(
1174
+            ),
1175
+            '4' => array(
1176 1176
             '#type' => 'condition',
1177 1177
             '#settings' => array(
1178
-              'code' => 'return $node_unchanged->status == 0 && $node->status == 1;',
1179
-              'vars' => array(
1178
+                'code' => 'return $node_unchanged->status == 0 && $node->status == 1;',
1179
+                'vars' => array(
1180 1180
                 '0' => 'node',
1181 1181
                 '1' => 'node_unchanged',
1182
-              ),
1183
-              '#eval input' => array(
1182
+                ),
1183
+                '#eval input' => array(
1184 1184
                 'token_rules_input_evaluator' => array(
1185
-                  'code' => array(
1185
+                    'code' => array(
1186 1186
                     '0' => ':global',
1187
-                  ),
1187
+                    ),
1188
+                ),
1188 1189
                 ),
1189
-              ),
1190 1190
             ),
1191 1191
             '#name' => 'rules_condition_custom_php',
1192 1192
             '#info' => array(
1193
-              'label' => 'PHP code: node status changed to unhidden',
1194
-              'label callback' => FALSE,
1195
-              'module' => 'PHP',
1196
-              'eval input' => array(
1193
+                'label' => 'PHP code: node status changed to unhidden',
1194
+                'label callback' => FALSE,
1195
+                'module' => 'PHP',
1196
+                'eval input' => array(
1197 1197
                 '0' => 'code',
1198
-              ),
1198
+                ),
1199 1199
             ),
1200 1200
             '#weight' => 0.0,
1201
-          ),
1201
+            ),
1202 1202
         ),
1203 1203
         '#actions' => array(
1204
-          '0' => array(
1204
+            '0' => array(
1205 1205
             '#info' => array(
1206
-              'label' => 'Notify moderators via email',
1207
-              'module' => 'BOINC core',
1208
-              'eval input' => array(
1206
+                'label' => 'Notify moderators via email',
1207
+                'module' => 'BOINC core',
1208
+                'eval input' => array(
1209 1209
                 '0' => 'subject',
1210 1210
                 '1' => 'message',
1211 1211
                 '2' => 'from',
1212
-              ),
1212
+                ),
1213 1213
             ),
1214 1214
             '#name' => 'boinccore_rules_action_mail_to_moderators',
1215 1215
             '#settings' => array(
1216
-              'from' => '',
1217
-              'subject' => 'Forum topic at [:global:site-name] unhidden by moderator/admin',
1218
-              'message' => "[node:type] topic '[node:title]' has been unhidden by moderator/admin [user:display-name].\r\n\r\nLink: <?php print url('node/' . \$node->nid, array('absolute' => TRUE, 'language' => 'en')); ?>",
1219
-              '#eval input' => array(
1216
+                'from' => '',
1217
+                'subject' => 'Forum topic at [:global:site-name] unhidden by moderator/admin',
1218
+                'message' => "[node:type] topic '[node:title]' has been unhidden by moderator/admin [user:display-name].\r\n\r\nLink: <?php print url('node/' . \$node->nid, array('absolute' => TRUE, 'language' => 'en')); ?>",
1219
+                '#eval input' => array(
1220 1220
                 'token_rules_input_evaluator' => array(
1221
-                  'subject' => array(
1221
+                    'subject' => array(
1222 1222
                     '0' => ':global',
1223
-                  ),
1224
-                  'message' => array(
1223
+                    ),
1224
+                    'message' => array(
1225 1225
                     '0' => 'node',
1226 1226
                     '1' => 'user',
1227 1227
                     '2' => ':global',
1228
-                  ),
1229
-                  'from' => array(
1228
+                    ),
1229
+                    'from' => array(
1230 1230
                     '0' => ':global',
1231
-                  ),
1231
+                    ),
1232 1232
                 ),
1233 1233
                 'rules_input_evaluator_php' => array(
1234
-                  'message' => array(
1234
+                    'message' => array(
1235 1235
                     '0' => 'node',
1236
-                  ),
1236
+                    ),
1237
+                ),
1237 1238
                 ),
1238
-              ),
1239 1239
             ),
1240 1240
             '#type' => 'action',
1241 1241
             '#weight' => 0.0,
1242
-          ),
1242
+            ),
1243 1243
         ),
1244 1244
         '#version' => 6003,
1245
-      ),
1246
-      'rules_forum_topic_locked_by_moderator_admin' => array(
1245
+        ),
1246
+        'rules_forum_topic_locked_by_moderator_admin' => array(
1247 1247
         '#type' => 'rule',
1248 1248
         '#set' => 'event_node_update',
1249 1249
         '#label' => 'Forum topic locked by moderator/admin',
1250 1250
         '#active' => 1,
1251 1251
         '#weight' => '0',
1252 1252
         '#categories' => array(
1253
-          '0' => 'boinc_standard',
1254
-          '1' => 'moderator notification',
1253
+            '0' => 'boinc_standard',
1254
+            '1' => 'moderator notification',
1255 1255
         ),
1256 1256
         '#status' => 'default',
1257 1257
         '#conditions' => array(
1258
-          '0' => array(
1258
+            '0' => array(
1259 1259
             '#type' => 'condition',
1260 1260
             '#settings' => array(
1261
-              'roles' => array(
1261
+                'roles' => array(
1262 1262
                 '0' => 3519698132,
1263 1263
                 '1' => 1271379760,
1264
-              ),
1265
-              'operation' => 'OR',
1266
-              '#argument map' => array(
1264
+                ),
1265
+                'operation' => 'OR',
1266
+                '#argument map' => array(
1267 1267
                 'user' => 'user',
1268
-              ),
1268
+                ),
1269 1269
             ),
1270 1270
             '#name' => 'rules_condition_user_hasrole',
1271 1271
             '#info' => array(
1272
-              'label' => 'User has role(s): administrator or moderator',
1273
-              'label callback' => FALSE,
1274
-              'arguments' => array(
1272
+                'label' => 'User has role(s): administrator or moderator',
1273
+                'label callback' => FALSE,
1274
+                'arguments' => array(
1275 1275
                 'user' => array(
1276
-                  'type' => 'user',
1277
-                  'label' => 'User',
1276
+                    'type' => 'user',
1277
+                    'label' => 'User',
1278
+                ),
1278 1279
                 ),
1279
-              ),
1280
-              'module' => 'User',
1280
+                'module' => 'User',
1281 1281
             ),
1282 1282
             '#weight' => 0.0,
1283
-          ),
1284
-          '1' => array(
1283
+            ),
1284
+            '1' => array(
1285 1285
             '#weight' => 0.0,
1286 1286
             '0' => array(
1287
-              '#weight' => 0.0,
1288
-              '#type' => 'condition',
1289
-              '#settings' => array(
1287
+                '#weight' => 0.0,
1288
+                '#type' => 'condition',
1289
+                '#settings' => array(
1290 1290
                 'type' => array(
1291
-                  'forum' => 'forum',
1291
+                    'forum' => 'forum',
1292 1292
                 ),
1293 1293
                 '#argument map' => array(
1294
-                  'node' => 'node',
1294
+                    'node' => 'node',
1295
+                ),
1295 1296
                 ),
1296
-              ),
1297
-              '#name' => 'rules_condition_content_is_type',
1298
-              '#info' => array(
1297
+                '#name' => 'rules_condition_content_is_type',
1298
+                '#info' => array(
1299 1299
                 'label' => 'Updated content is Forum topic',
1300 1300
                 'arguments' => array(
1301
-                  'node' => array(
1301
+                    'node' => array(
1302 1302
                     'type' => 'node',
1303 1303
                     'label' => 'Content',
1304
-                  ),
1304
+                    ),
1305 1305
                 ),
1306 1306
                 'module' => 'Node',
1307
-              ),
1307
+                ),
1308 1308
             ),
1309 1309
             '#type' => 'OR',
1310 1310
             '1' => array(
1311
-              '#type' => 'condition',
1312
-              '#settings' => array(
1311
+                '#type' => 'condition',
1312
+                '#settings' => array(
1313 1313
                 'type' => array(
1314
-                  'team_forum' => 'team_forum',
1314
+                    'team_forum' => 'team_forum',
1315 1315
                 ),
1316 1316
                 '#argument map' => array(
1317
-                  'node' => 'node',
1317
+                    'node' => 'node',
1318
+                ),
1318 1319
                 ),
1319
-              ),
1320
-              '#name' => 'rules_condition_content_is_type',
1321
-              '#info' => array(
1320
+                '#name' => 'rules_condition_content_is_type',
1321
+                '#info' => array(
1322 1322
                 'label' => 'Updated content is Team forum topic',
1323 1323
                 'arguments' => array(
1324
-                  'node' => array(
1324
+                    'node' => array(
1325 1325
                     'type' => 'node',
1326 1326
                     'label' => 'Content',
1327
-                  ),
1327
+                    ),
1328 1328
                 ),
1329 1329
                 'module' => 'Node',
1330
-              ),
1331
-              '#weight' => 0.0,
1330
+                ),
1331
+                '#weight' => 0.0,
1332
+            ),
1332 1333
             ),
1333
-          ),
1334
-          '3' => array(
1334
+            '3' => array(
1335 1335
             '#weight' => 0.0,
1336 1336
             '#info' => array(
1337
-              'label' => 'PHP code: node content unchanged',
1338
-              'label callback' => FALSE,
1339
-              'module' => 'PHP',
1340
-              'eval input' => array(
1337
+                'label' => 'PHP code: node content unchanged',
1338
+                'label callback' => FALSE,
1339
+                'module' => 'PHP',
1340
+                'eval input' => array(
1341 1341
                 '0' => 'code',
1342
-              ),
1342
+                ),
1343 1343
             ),
1344 1344
             '#name' => 'rules_condition_custom_php',
1345 1345
             '#settings' => array(
1346
-              'code' => 'return $node->body == $node_unchanged->body;',
1347
-              'vars' => array(
1346
+                'code' => 'return $node->body == $node_unchanged->body;',
1347
+                'vars' => array(
1348 1348
                 '0' => 'node',
1349 1349
                 '1' => 'node_unchanged',
1350
-              ),
1351
-              '#eval input' => array(
1350
+                ),
1351
+                '#eval input' => array(
1352 1352
                 'token_rules_input_evaluator' => array(
1353
-                  'code' => array(
1353
+                    'code' => array(
1354 1354
                     '0' => ':global',
1355
-                  ),
1355
+                    ),
1356
+                ),
1356 1357
                 ),
1357
-              ),
1358 1358
             ),
1359 1359
             '#type' => 'condition',
1360
-          ),
1361
-          '4' => array(
1360
+            ),
1361
+            '4' => array(
1362 1362
             '#weight' => 0.0,
1363 1363
             '#info' => array(
1364
-              'label' => 'PHP code: node locked',
1365
-              'label callback' => FALSE,
1366
-              'module' => 'PHP',
1367
-              'eval input' => array(
1364
+                'label' => 'PHP code: node locked',
1365
+                'label callback' => FALSE,
1366
+                'module' => 'PHP',
1367
+                'eval input' => array(
1368 1368
                 '0' => 'code',
1369
-              ),
1369
+                ),
1370 1370
             ),
1371 1371
             '#name' => 'rules_condition_custom_php',
1372 1372
             '#type' => 'condition',
1373 1373
             '#settings' => array(
1374
-              'code' => 'return $node_unchanged->comment == 2 && $node->comment == 1;',
1375
-              'vars' => array(
1374
+                'code' => 'return $node_unchanged->comment == 2 && $node->comment == 1;',
1375
+                'vars' => array(
1376 1376
                 '0' => 'node',
1377 1377
                 '1' => 'node_unchanged',
1378
-              ),
1379
-              '#eval input' => array(
1378
+                ),
1379
+                '#eval input' => array(
1380 1380
                 'token_rules_input_evaluator' => array(
1381
-                  'code' => array(
1381
+                    'code' => array(
1382 1382
                     '0' => ':global',
1383
-                  ),
1383
+                    ),
1384
+                ),
1384 1385
                 ),
1385
-              ),
1386 1386
             ),
1387
-          ),
1387
+            ),
1388 1388
         ),
1389 1389
         '#actions' => array(
1390
-          '0' => array(
1390
+            '0' => array(
1391 1391
             '#info' => array(
1392
-              'label' => 'Notify moderators via email',
1393
-              'module' => 'BOINC core',
1394
-              'eval input' => array(
1392
+                'label' => 'Notify moderators via email',
1393
+                'module' => 'BOINC core',
1394
+                'eval input' => array(
1395 1395
                 '0' => 'subject',
1396 1396
                 '1' => 'message',
1397 1397
                 '2' => 'from',
1398
-              ),
1398
+                ),
1399 1399
             ),
1400 1400
             '#name' => 'boinccore_rules_action_mail_to_moderators',
1401 1401
             '#settings' => array(
1402
-              'from' => '',
1403
-              'subject' => 'Forum topic at [:global:site-name] locked by moderator/admin',
1404
-              'message' => "[node:type] topic '[node:title]' has been locked by moderator/admin [user:display-name].\r\n\r\nLink: <?php print url('node/' . \$node->nid, array('absolute' => TRUE, 'language' => 'en')); ?>",
1405
-              '#eval input' => array(
1402
+                'from' => '',
1403
+                'subject' => 'Forum topic at [:global:site-name] locked by moderator/admin',
1404
+                'message' => "[node:type] topic '[node:title]' has been locked by moderator/admin [user:display-name].\r\n\r\nLink: <?php print url('node/' . \$node->nid, array('absolute' => TRUE, 'language' => 'en')); ?>",
1405
+                '#eval input' => array(
1406 1406
                 'token_rules_input_evaluator' => array(
1407
-                  'subject' => array(
1407
+                    'subject' => array(
1408 1408
                     '0' => ':global',
1409
-                  ),
1410
-                  'message' => array(
1409
+                    ),
1410
+                    'message' => array(
1411 1411
                     '0' => 'node',
1412 1412
                     '1' => 'user',
1413 1413
                     '2' => ':global',
1414
-                  ),
1415
-                  'from' => array(
1414
+                    ),
1415
+                    'from' => array(
1416 1416
                     '0' => ':global',
1417
-                  ),
1417
+                    ),
1418 1418
                 ),
1419 1419
                 'rules_input_evaluator_php' => array(
1420
-                  'message' => array(
1420
+                    'message' => array(
1421 1421
                     '0' => 'node',
1422
-                  ),
1422
+                    ),
1423
+                ),
1423 1424
                 ),
1424
-              ),
1425 1425
             ),
1426 1426
             '#type' => 'action',
1427 1427
             '#weight' => 0.0,
1428
-          ),
1428
+            ),
1429 1429
         ),
1430 1430
         '#version' => 6003,
1431
-      ),
1432
-      'rules_forum_topic_marked_sticky_by_moderator_admin' => array(
1431
+        ),
1432
+        'rules_forum_topic_marked_sticky_by_moderator_admin' => array(
1433 1433
         '#type' => 'rule',
1434 1434
         '#set' => 'event_node_update',
1435 1435
         '#label' => 'Forum topic marked sticky by moderator/admin',
1436 1436
         '#active' => 1,
1437 1437
         '#weight' => '0',
1438 1438
         '#categories' => array(
1439
-          '0' => 'boinc_standard',
1440
-          '1' => 'moderator notification',
1439
+            '0' => 'boinc_standard',
1440
+            '1' => 'moderator notification',
1441 1441
         ),
1442 1442
         '#status' => 'default',
1443 1443
         '#conditions' => array(
1444
-          '0' => array(
1444
+            '0' => array(
1445 1445
             '#type' => 'condition',
1446 1446
             '#settings' => array(
1447
-              'roles' => array(
1447
+                'roles' => array(
1448 1448
                 '0' => 3519698132,
1449 1449
                 '1' => 1271379760,
1450
-              ),
1451
-              'operation' => 'OR',
1452
-              '#argument map' => array(
1450
+                ),
1451
+                'operation' => 'OR',
1452
+                '#argument map' => array(
1453 1453
                 'user' => 'user',
1454
-              ),
1454
+                ),
1455 1455
             ),
1456 1456
             '#name' => 'rules_condition_user_hasrole',
1457 1457
             '#info' => array(
1458
-              'label' => 'User has role(s): administrator or moderator',
1459
-              'label callback' => FALSE,
1460
-              'arguments' => array(
1458
+                'label' => 'User has role(s): administrator or moderator',
1459
+                'label callback' => FALSE,
1460
+                'arguments' => array(
1461 1461
                 'user' => array(
1462
-                  'type' => 'user',
1463
-                  'label' => 'User',
1462
+                    'type' => 'user',
1463
+                    'label' => 'User',
1464 1464
                 ),
1465
-              ),
1466
-              'module' => 'User',
1465
+                ),
1466
+                'module' => 'User',
1467 1467
             ),
1468 1468
             '#weight' => 0.0,
1469
-          ),
1470
-          '1' => array(
1469
+            ),
1470
+            '1' => array(
1471 1471
             '#weight' => 0.0,
1472 1472
             '0' => array(
1473
-              '#weight' => 0.0,
1474
-              '#type' => 'condition',
1475
-              '#settings' => array(
1473
+                '#weight' => 0.0,
1474
+                '#type' => 'condition',
1475
+                '#settings' => array(
1476 1476
                 'type' => array(
1477
-                  'forum' => 'forum',
1477
+                    'forum' => 'forum',
1478 1478
                 ),
1479 1479
                 '#argument map' => array(
1480
-                  'node' => 'node',
1480
+                    'node' => 'node',
1481
+                ),
1481 1482
                 ),
1482
-              ),
1483
-              '#name' => 'rules_condition_content_is_type',
1484
-              '#info' => array(
1483
+                '#name' => 'rules_condition_content_is_type',
1484
+                '#info' => array(
1485 1485
                 'label' => 'Updated content is Forum topic',
1486 1486
                 'arguments' => array(
1487
-                  'node' => array(
1487
+                    'node' => array(
1488 1488
                     'type' => 'node',
1489 1489
                     'label' => 'Content',
1490
-                  ),
1490
+                    ),
1491 1491
                 ),
1492 1492
                 'module' => 'Node',
1493
-              ),
1493
+                ),
1494 1494
             ),
1495 1495
             '#type' => 'OR',
1496 1496
             '1' => array(
1497
-              '#type' => 'condition',
1498
-              '#settings' => array(
1497
+                '#type' => 'condition',
1498
+                '#settings' => array(
1499 1499
                 'type' => array(
1500
-                  'team_forum' => 'team_forum',
1500
+                    'team_forum' => 'team_forum',
1501 1501
                 ),
1502 1502
                 '#argument map' => array(
1503
-                  'node' => 'node',
1503
+                    'node' => 'node',
1504 1504
                 ),
1505
-              ),
1506
-              '#name' => 'rules_condition_content_is_type',
1507
-              '#info' => array(
1505
+                ),
1506
+                '#name' => 'rules_condition_content_is_type',
1507
+                '#info' => array(
1508 1508
                 'label' => 'Updated content is Team forum topic',
1509 1509
                 'arguments' => array(
1510
-                  'node' => array(
1510
+                    'node' => array(
1511 1511
                     'type' => 'node',
1512 1512
                     'label' => 'Content',
1513
-                  ),
1513
+                    ),
1514 1514
                 ),
1515 1515
                 'module' => 'Node',
1516
-              ),
1517
-              '#weight' => 0.0,
1516
+                ),
1517
+                '#weight' => 0.0,
1518 1518
             ),
1519
-          ),
1520
-          '3' => array(
1519
+            ),
1520
+            '3' => array(
1521 1521
             '#weight' => 0.0,
1522 1522
             '#info' => array(
1523
-              'label' => 'PHP code: node content unchanged',
1524
-              'label callback' => FALSE,
1525
-              'module' => 'PHP',
1526
-              'eval input' => array(
1523
+                'label' => 'PHP code: node content unchanged',
1524
+                'label callback' => FALSE,
1525
+                'module' => 'PHP',
1526
+                'eval input' => array(
1527 1527
                 '0' => 'code',
1528
-              ),
1528
+                ),
1529 1529
             ),
1530 1530
             '#name' => 'rules_condition_custom_php',
1531 1531
             '#settings' => array(
1532
-              'code' => 'return $node->body == $node_unchanged->body;',
1533
-              'vars' => array(
1532
+                'code' => 'return $node->body == $node_unchanged->body;',
1533
+                'vars' => array(
1534 1534
                 '0' => 'node',
1535 1535
                 '1' => 'node_unchanged',
1536
-              ),
1537
-              '#eval input' => array(
1536
+                ),
1537
+                '#eval input' => array(
1538 1538
                 'token_rules_input_evaluator' => array(
1539
-                  'code' => array(
1539
+                    'code' => array(
1540 1540
                     '0' => ':global',
1541
-                  ),
1541
+                    ),
1542
+                ),
1542 1543
                 ),
1543
-              ),
1544 1544
             ),
1545 1545
             '#type' => 'condition',
1546
-          ),
1547
-          '4' => array(
1546
+            ),
1547
+            '4' => array(
1548 1548
             '#weight' => 0.0,
1549 1549
             '#info' => array(
1550
-              'label' => 'PHP code: node made sticky',
1551
-              'label callback' => FALSE,
1552
-              'module' => 'PHP',
1553
-              'eval input' => array(
1550
+                'label' => 'PHP code: node made sticky',
1551
+                'label callback' => FALSE,
1552
+                'module' => 'PHP',
1553
+                'eval input' => array(
1554 1554
                 '0' => 'code',
1555
-              ),
1555
+                ),
1556 1556
             ),
1557 1557
             '#name' => 'rules_condition_custom_php',
1558 1558
             '#type' => 'condition',
1559 1559
             '#settings' => array(
1560
-              'code' => 'return $node_unchanged->sticky == 0 && $node->sticky == 1;',
1561
-              'vars' => array(
1560
+                'code' => 'return $node_unchanged->sticky == 0 && $node->sticky == 1;',
1561
+                'vars' => array(
1562 1562
                 '0' => 'node',
1563 1563
                 '1' => 'node_unchanged',
1564
-              ),
1565
-              '#eval input' => array(
1564
+                ),
1565
+                '#eval input' => array(
1566 1566
                 'token_rules_input_evaluator' => array(
1567
-                  'code' => array(
1567
+                    'code' => array(
1568 1568
                     '0' => ':global',
1569
-                  ),
1569
+                    ),
1570 1570
                 ),
1571
-              ),
1571
+                ),
1572
+            ),
1572 1573
             ),
1573
-          ),
1574 1574
         ),
1575 1575
         '#actions' => array(
1576
-          '0' => array(
1576
+            '0' => array(
1577 1577
             '#info' => array(
1578
-              'label' => 'Notify moderators via email',
1579
-              'module' => 'BOINC core',
1580
-              'eval input' => array(
1578
+                'label' => 'Notify moderators via email',
1579
+                'module' => 'BOINC core',
1580
+                'eval input' => array(
1581 1581
                 '0' => 'subject',
1582 1582
                 '1' => 'message',
1583 1583
                 '2' => 'from',
1584
-              ),
1584
+                ),
1585 1585
             ),
1586 1586
             '#name' => 'boinccore_rules_action_mail_to_moderators',
1587 1587
             '#settings' => array(
1588
-              'from' => '',
1589
-              'subject' => 'Forum topic at [:global:site-name] marked sticky by moderator/admin',
1590
-              'message' => "[node:type] topic '[node:title]' has been marked sticky by moderator/admin [user:display-name].\r\n\r\nLink: <?php print url('node/' . \$node->nid, array('absolute' => TRUE, 'language' => 'en')); ?>",
1591
-              '#eval input' => array(
1588
+                'from' => '',
1589
+                'subject' => 'Forum topic at [:global:site-name] marked sticky by moderator/admin',
1590
+                'message' => "[node:type] topic '[node:title]' has been marked sticky by moderator/admin [user:display-name].\r\n\r\nLink: <?php print url('node/' . \$node->nid, array('absolute' => TRUE, 'language' => 'en')); ?>",
1591
+                '#eval input' => array(
1592 1592
                 'token_rules_input_evaluator' => array(
1593
-                  'subject' => array(
1593
+                    'subject' => array(
1594 1594
                     '0' => ':global',
1595
-                  ),
1596
-                  'message' => array(
1595
+                    ),
1596
+                    'message' => array(
1597 1597
                     '0' => 'node',
1598 1598
                     '1' => 'user',
1599 1599
                     '2' => ':global',
1600
-                  ),
1601
-                  'from' => array(
1600
+                    ),
1601
+                    'from' => array(
1602 1602
                     '0' => ':global',
1603
-                  ),
1603
+                    ),
1604 1604
                 ),
1605 1605
                 'rules_input_evaluator_php' => array(
1606
-                  'message' => array(
1606
+                    'message' => array(
1607 1607
                     '0' => 'node',
1608
-                  ),
1608
+                    ),
1609
+                ),
1609 1610
                 ),
1610
-              ),
1611 1611
             ),
1612 1612
             '#type' => 'action',
1613 1613
             '#weight' => 0.0,
1614
-          ),
1614
+            ),
1615 1615
         ),
1616 1616
         '#version' => 6003,
1617
-      ),
1618
-      'rules_forum_topic_marked_unsticky_by_moderator_admin' => array(
1617
+        ),
1618
+        'rules_forum_topic_marked_unsticky_by_moderator_admin' => array(
1619 1619
         '#type' => 'rule',
1620 1620
         '#set' => 'event_node_update',
1621 1621
         '#label' => 'Forum topic marked unsticky by moderator/admin',
1622 1622
         '#active' => 1,
1623 1623
         '#weight' => '0',
1624 1624
         '#categories' => array(
1625
-          '0' => 'boinc_standard',
1626
-          '1' => 'moderator notification',
1625
+            '0' => 'boinc_standard',
1626
+            '1' => 'moderator notification',
1627 1627
         ),
1628 1628
         '#status' => 'default',
1629 1629
         '#conditions' => array(
1630
-          '0' => array(
1630
+            '0' => array(
1631 1631
             '#type' => 'condition',
1632 1632
             '#settings' => array(
1633
-              'roles' => array(
1633
+                'roles' => array(
1634 1634
                 '0' => 3519698132,
1635 1635
                 '1' => 1271379760,
1636
-              ),
1637
-              'operation' => 'OR',
1638
-              '#argument map' => array(
1636
+                ),
1637
+                'operation' => 'OR',
1638
+                '#argument map' => array(
1639 1639
                 'user' => 'user',
1640
-              ),
1640
+                ),
1641 1641
             ),
1642 1642
             '#name' => 'rules_condition_user_hasrole',
1643 1643
             '#info' => array(
1644
-              'label' => 'User has role(s): administrator or moderator',
1645
-              'label callback' => FALSE,
1646
-              'arguments' => array(
1644
+                'label' => 'User has role(s): administrator or moderator',
1645
+                'label callback' => FALSE,
1646
+                'arguments' => array(
1647 1647
                 'user' => array(
1648
-                  'type' => 'user',
1649
-                  'label' => 'User',
1648
+                    'type' => 'user',
1649
+                    'label' => 'User',
1650
+                ),
1650 1651
                 ),
1651
-              ),
1652
-              'module' => 'User',
1652
+                'module' => 'User',
1653 1653
             ),
1654 1654
             '#weight' => 0.0,
1655
-          ),
1656
-          '1' => array(
1655
+            ),
1656
+            '1' => array(
1657 1657
             '#weight' => 0.0,
1658 1658
             '0' => array(
1659
-              '#weight' => 0.0,
1660
-              '#type' => 'condition',
1661
-              '#settings' => array(
1659
+                '#weight' => 0.0,
1660
+                '#type' => 'condition',
1661
+                '#settings' => array(
1662 1662
                 'type' => array(
1663
-                  'forum' => 'forum',
1663
+                    'forum' => 'forum',
1664 1664
                 ),
1665 1665
                 '#argument map' => array(
1666
-                  'node' => 'node',
1666
+                    'node' => 'node',
1667 1667
                 ),
1668
-              ),
1669
-              '#name' => 'rules_condition_content_is_type',
1670
-              '#info' => array(
1668
+                ),
1669
+                '#name' => 'rules_condition_content_is_type',
1670
+                '#info' => array(
1671 1671
                 'label' => 'Updated content is Forum topic',
1672 1672
                 'arguments' => array(
1673
-                  'node' => array(
1673
+                    'node' => array(
1674 1674
                     'type' => 'node',
1675 1675
                     'label' => 'Content',
1676
-                  ),
1676
+                    ),
1677 1677
                 ),
1678 1678
                 'module' => 'Node',
1679
-              ),
1679
+                ),
1680 1680
             ),
1681 1681
             '#type' => 'OR',
1682 1682
             '1' => array(
1683
-              '#type' => 'condition',
1684
-              '#settings' => array(
1683
+                '#type' => 'condition',
1684
+                '#settings' => array(
1685 1685
                 'type' => array(
1686
-                  'team_forum' => 'team_forum',
1686
+                    'team_forum' => 'team_forum',
1687 1687
                 ),
1688 1688
                 '#argument map' => array(
1689
-                  'node' => 'node',
1689
+                    'node' => 'node',
1690
+                ),
1690 1691
                 ),
1691
-              ),
1692
-              '#name' => 'rules_condition_content_is_type',
1693
-              '#info' => array(
1692
+                '#name' => 'rules_condition_content_is_type',
1693
+                '#info' => array(
1694 1694
                 'label' => 'Updated content is Team forum topic',
1695 1695
                 'arguments' => array(
1696
-                  'node' => array(
1696
+                    'node' => array(
1697 1697
                     'type' => 'node',
1698 1698
                     'label' => 'Content',
1699
-                  ),
1699
+                    ),
1700 1700
                 ),
1701 1701
                 'module' => 'Node',
1702
-              ),
1703
-              '#weight' => 0.0,
1702
+                ),
1703
+                '#weight' => 0.0,
1704
+            ),
1704 1705
             ),
1705
-          ),
1706
-          '3' => array(
1706
+            '3' => array(
1707 1707
             '#weight' => 0.0,
1708 1708
             '#info' => array(
1709
-              'label' => 'PHP code: node content unchanged',
1710
-              'label callback' => FALSE,
1711
-              'module' => 'PHP',
1712
-              'eval input' => array(
1709
+                'label' => 'PHP code: node content unchanged',
1710
+                'label callback' => FALSE,
1711
+                'module' => 'PHP',
1712
+                'eval input' => array(
1713 1713
                 '0' => 'code',
1714
-              ),
1714
+                ),
1715 1715
             ),
1716 1716
             '#name' => 'rules_condition_custom_php',
1717 1717
             '#settings' => array(
1718
-              'code' => 'return $node->body == $node_unchanged->body;',
1719
-              'vars' => array(
1718
+                'code' => 'return $node->body == $node_unchanged->body;',
1719
+                'vars' => array(
1720 1720
                 '0' => 'node',
1721 1721
                 '1' => 'node_unchanged',
1722
-              ),
1723
-              '#eval input' => array(
1722
+                ),
1723
+                '#eval input' => array(
1724 1724
                 'token_rules_input_evaluator' => array(
1725
-                  'code' => array(
1725
+                    'code' => array(
1726 1726
                     '0' => ':global',
1727
-                  ),
1727
+                    ),
1728
+                ),
1728 1729
                 ),
1729
-              ),
1730 1730
             ),
1731 1731
             '#type' => 'condition',
1732
-          ),
1733
-          '4' => array(
1732
+            ),
1733
+            '4' => array(
1734 1734
             '#weight' => 0.0,
1735 1735
             '#info' => array(
1736
-              'label' => 'PHP code: node made sticky',
1737
-              'label callback' => FALSE,
1738
-              'module' => 'PHP',
1739
-              'eval input' => array(
1736
+                'label' => 'PHP code: node made sticky',
1737
+                'label callback' => FALSE,
1738
+                'module' => 'PHP',
1739
+                'eval input' => array(
1740 1740
                 '0' => 'code',
1741
-              ),
1741
+                ),
1742 1742
             ),
1743 1743
             '#name' => 'rules_condition_custom_php',
1744 1744
             '#type' => 'condition',
1745 1745
             '#settings' => array(
1746
-              'code' => 'return $node_unchanged->sticky == 1 && $node->sticky == 0;',
1747
-              'vars' => array(
1746
+                'code' => 'return $node_unchanged->sticky == 1 && $node->sticky == 0;',
1747
+                'vars' => array(
1748 1748
                 '0' => 'node',
1749 1749
                 '1' => 'node_unchanged',
1750
-              ),
1751
-              '#eval input' => array(
1750
+                ),
1751
+                '#eval input' => array(
1752 1752
                 'token_rules_input_evaluator' => array(
1753
-                  'code' => array(
1753
+                    'code' => array(
1754 1754
                     '0' => ':global',
1755
-                  ),
1755
+                    ),
1756
+                ),
1756 1757
                 ),
1757
-              ),
1758 1758
             ),
1759
-          ),
1759
+            ),
1760 1760
         ),
1761 1761
         '#actions' => array(
1762
-          '0' => array(
1762
+            '0' => array(
1763 1763
             '#info' => array(
1764
-              'label' => 'Notify moderators via email',
1765
-              'module' => 'BOINC core',
1766
-              'eval input' => array(
1764
+                'label' => 'Notify moderators via email',
1765
+                'module' => 'BOINC core',
1766
+                'eval input' => array(
1767 1767
                 '0' => 'subject',
1768 1768
                 '1' => 'message',
1769 1769
                 '2' => 'from',
1770
-              ),
1770
+                ),
1771 1771
             ),
1772 1772
             '#name' => 'boinccore_rules_action_mail_to_moderators',
1773 1773
             '#settings' => array(
1774
-              'from' => '',
1775
-              'subject' => 'Forum topic at [:global:site-name] marked unsticky by moderator/admin',
1776
-              'message' => "[node:type] topic '[node:title]' has been marked unsticky by moderator/admin [user:display-name].\r\n\\r\nLink: <?php print url('node/' . \$node->nid, array('absolute' => TRUE, 'language' => 'en')); ?>",
1777
-              '#eval input' => array(
1774
+                'from' => '',
1775
+                'subject' => 'Forum topic at [:global:site-name] marked unsticky by moderator/admin',
1776
+                'message' => "[node:type] topic '[node:title]' has been marked unsticky by moderator/admin [user:display-name].\r\n\\r\nLink: <?php print url('node/' . \$node->nid, array('absolute' => TRUE, 'language' => 'en')); ?>",
1777
+                '#eval input' => array(
1778 1778
                 'token_rules_input_evaluator' => array(
1779
-                  'subject' => array(
1779
+                    'subject' => array(
1780 1780
                     '0' => ':global',
1781
-                  ),
1782
-                  'message' => array(
1781
+                    ),
1782
+                    'message' => array(
1783 1783
                     '0' => 'node',
1784 1784
                     '1' => 'user',
1785 1785
                     '2' => ':global',
1786
-                  ),
1787
-                  'from' => array(
1786
+                    ),
1787
+                    'from' => array(
1788 1788
                     '0' => ':global',
1789
-                  ),
1789
+                    ),
1790 1790
                 ),
1791 1791
                 'rules_input_evaluator_php' => array(
1792
-                  'message' => array(
1792
+                    'message' => array(
1793 1793
                     '0' => 'node',
1794
-                  ),
1794
+                    ),
1795
+                ),
1795 1796
                 ),
1796
-              ),
1797 1797
             ),
1798 1798
             '#type' => 'action',
1799 1799
             '#weight' => 0.0,
1800
-          ),
1800
+            ),
1801 1801
         ),
1802 1802
         '#version' => 6003,
1803
-      ),
1804
-      'rules_forum_topic_nenamed_title_by_moderator_or_admin' => array(
1803
+        ),
1804
+        'rules_forum_topic_nenamed_title_by_moderator_or_admin' => array(
1805 1805
         '#type' => 'rule',
1806 1806
         '#set' => 'event_node_update',
1807 1807
         '#label' => 'Forum topic renamed title by moderator or admin',
1808 1808
         '#active' => 1,
1809 1809
         '#weight' => '0',
1810 1810
         '#categories' => array(
1811
-          '0' => 'boinc_standard',
1812
-          '1' => 'moderator notification',
1811
+            '0' => 'boinc_standard',
1812
+            '1' => 'moderator notification',
1813 1813
         ),
1814 1814
         '#status' => 'default',
1815 1815
         '#conditions' => array(
1816
-          '0' => array(
1816
+            '0' => array(
1817 1817
             '#weight' => 0.0,
1818 1818
             '#type' => 'condition',
1819 1819
             '#settings' => array(
1820
-              'roles' => array(
1820
+                'roles' => array(
1821 1821
                 '0' => 3519698132,
1822 1822
                 '1' => 1271379760,
1823
-              ),
1824
-              'operation' => 'OR',
1825
-              '#argument map' => array(
1823
+                ),
1824
+                'operation' => 'OR',
1825
+                '#argument map' => array(
1826 1826
                 'user' => 'user',
1827
-              ),
1827
+                ),
1828 1828
             ),
1829 1829
             '#name' => 'rules_condition_user_hasrole',
1830 1830
             '#info' => array(
1831
-              'label' => 'User has role(s): administrator or moderator',
1832
-              'label callback' => FALSE,
1833
-              'arguments' => array(
1831
+                'label' => 'User has role(s): administrator or moderator',
1832
+                'label callback' => FALSE,
1833
+                'arguments' => array(
1834 1834
                 'user' => array(
1835
-                  'type' => 'user',
1836
-                  'label' => 'User',
1835
+                    'type' => 'user',
1836
+                    'label' => 'User',
1837 1837
                 ),
1838
-              ),
1839
-              'module' => 'User',
1838
+                ),
1839
+                'module' => 'User',
1840
+            ),
1840 1841
             ),
1841
-          ),
1842
-          '1' => array(
1842
+            '1' => array(
1843 1843
             '#weight' => 0.0,
1844 1844
             '0' => array(
1845
-              '#weight' => 0.0,
1846
-              '#info' => array(
1845
+                '#weight' => 0.0,
1846
+                '#info' => array(
1847 1847
                 'label' => 'Updated content is Forum topic',
1848 1848
                 'arguments' => array(
1849
-                  'node' => array(
1849
+                    'node' => array(
1850 1850
                     'type' => 'node',
1851 1851
                     'label' => 'Content',
1852
-                  ),
1852
+                    ),
1853 1853
                 ),
1854 1854
                 'module' => 'Node',
1855
-              ),
1856
-              '#name' => 'rules_condition_content_is_type',
1857
-              '#settings' => array(
1855
+                ),
1856
+                '#name' => 'rules_condition_content_is_type',
1857
+                '#settings' => array(
1858 1858
                 'type' => array(
1859
-                  'forum' => 'forum',
1859
+                    'forum' => 'forum',
1860 1860
                 ),
1861 1861
                 '#argument map' => array(
1862
-                  'node' => 'node',
1862
+                    'node' => 'node',
1863 1863
                 ),
1864
-              ),
1865
-              '#type' => 'condition',
1864
+                ),
1865
+                '#type' => 'condition',
1866 1866
             ),
1867 1867
             '#type' => 'OR',
1868 1868
             '1' => array(
1869
-              '#type' => 'condition',
1870
-              '#settings' => array(
1869
+                '#type' => 'condition',
1870
+                '#settings' => array(
1871 1871
                 'type' => array(
1872
-                  'team_forum' => 'team_forum',
1872
+                    'team_forum' => 'team_forum',
1873 1873
                 ),
1874 1874
                 '#argument map' => array(
1875
-                  'node' => 'node',
1875
+                    'node' => 'node',
1876
+                ),
1876 1877
                 ),
1877
-              ),
1878
-              '#name' => 'rules_condition_content_is_type',
1879
-              '#info' => array(
1878
+                '#name' => 'rules_condition_content_is_type',
1879
+                '#info' => array(
1880 1880
                 'label' => 'Updated content is Team forum topic',
1881 1881
                 'arguments' => array(
1882
-                  'node' => array(
1882
+                    'node' => array(
1883 1883
                     'type' => 'node',
1884 1884
                     'label' => 'Content',
1885
-                  ),
1885
+                    ),
1886 1886
                 ),
1887 1887
                 'module' => 'Node',
1888
-              ),
1889
-              '#weight' => 0.0,
1888
+                ),
1889
+                '#weight' => 0.0,
1890 1890
             ),
1891
-          ),
1892
-          '2' => array(
1891
+            ),
1892
+            '2' => array(
1893 1893
             '#weight' => 0.0,
1894 1894
             '#info' => array(
1895
-              'label' => 'PHP code: title changed',
1896
-              'label callback' => FALSE,
1897
-              'module' => 'PHP',
1898
-              'eval input' => array(
1895
+                'label' => 'PHP code: title changed',
1896
+                'label callback' => FALSE,
1897
+                'module' => 'PHP',
1898
+                'eval input' => array(
1899 1899
                 '0' => 'code',
1900
-              ),
1900
+                ),
1901 1901
             ),
1902 1902
             '#name' => 'rules_condition_custom_php',
1903 1903
             '#settings' => array(
1904
-              'code' => 'return ($node->title != $node_unchanged->title);',
1905
-              'vars' => array(
1904
+                'code' => 'return ($node->title != $node_unchanged->title);',
1905
+                'vars' => array(
1906 1906
                 '0' => 'node',
1907 1907
                 '1' => 'node_unchanged',
1908
-              ),
1909
-              '#eval input' => array(
1908
+                ),
1909
+                '#eval input' => array(
1910 1910
                 'token_rules_input_evaluator' => array(
1911
-                  'code' => array(
1911
+                    'code' => array(
1912 1912
                     '0' => ':global',
1913
-                  ),
1913
+                    ),
1914
+                ),
1914 1915
                 ),
1915
-              ),
1916 1916
             ),
1917 1917
             '#type' => 'condition',
1918
-          ),
1918
+            ),
1919 1919
         ),
1920 1920
         '#actions' => array(
1921
-          '0' => array(
1921
+            '0' => array(
1922 1922
             '#type' => 'action',
1923 1923
             '#settings' => array(
1924
-              'from' => '',
1925
-              'subject' => 'Forum topic at [:global:site-name] renamed by moderator/admin',
1926
-              'message' => "[node:type] topic '[node:title]' has its title renamed by moderator/admin [user:display-name].\r\n\r\nLink: <?php print url('node/' . \$node->nid, array('absolute' => TRUE, 'language' => 'en')); ?>",
1927
-              '#eval input' => array(
1924
+                'from' => '',
1925
+                'subject' => 'Forum topic at [:global:site-name] renamed by moderator/admin',
1926
+                'message' => "[node:type] topic '[node:title]' has its title renamed by moderator/admin [user:display-name].\r\n\r\nLink: <?php print url('node/' . \$node->nid, array('absolute' => TRUE, 'language' => 'en')); ?>",
1927
+                '#eval input' => array(
1928 1928
                 'token_rules_input_evaluator' => array(
1929
-                  'subject' => array(
1929
+                    'subject' => array(
1930 1930
                     '0' => ':global',
1931
-                  ),
1932
-                  'message' => array(
1931
+                    ),
1932
+                    'message' => array(
1933 1933
                     '0' => 'node',
1934 1934
                     '1' => 'user',
1935 1935
                     '2' => ':global',
1936
-                  ),
1937
-                  'from' => array(
1936
+                    ),
1937
+                    'from' => array(
1938 1938
                     '0' => ':global',
1939
-                  ),
1939
+                    ),
1940 1940
                 ),
1941 1941
                 'rules_input_evaluator_php' => array(
1942
-                  'message' => array(
1942
+                    'message' => array(
1943 1943
                     '0' => 'node',
1944
-                  ),
1944
+                    ),
1945
+                ),
1945 1946
                 ),
1946
-              ),
1947 1947
             ),
1948 1948
             '#name' => 'boinccore_rules_action_mail_to_moderators',
1949 1949
             '#info' => array(
1950
-              'label' => 'Notify moderators via email',
1951
-              'module' => 'BOINC core',
1952
-              'eval input' => array(
1950
+                'label' => 'Notify moderators via email',
1951
+                'module' => 'BOINC core',
1952
+                'eval input' => array(
1953 1953
                 '0' => 'subject',
1954 1954
                 '1' => 'message',
1955 1955
                 '2' => 'from',
1956
-              ),
1956
+                ),
1957 1957
             ),
1958 1958
             '#weight' => 0.0,
1959
-          ),
1959
+            ),
1960 1960
         ),
1961 1961
         '#version' => 6003,
1962
-      ),
1963
-      'rules_forum_topic_unlocked_by_moderator_admin' => array(
1962
+        ),
1963
+        'rules_forum_topic_unlocked_by_moderator_admin' => array(
1964 1964
         '#type' => 'rule',
1965 1965
         '#set' => 'event_node_update',
1966 1966
         '#label' => 'Forum topic unlocked by moderator/admin',
1967 1967
         '#active' => 1,
1968 1968
         '#weight' => '0',
1969 1969
         '#categories' => array(
1970
-          '0' => 'boinc_standard',
1971
-          '1' => 'moderator notification',
1970
+            '0' => 'boinc_standard',
1971
+            '1' => 'moderator notification',
1972 1972
         ),
1973 1973
         '#status' => 'default',
1974 1974
         '#conditions' => array(
1975
-          '0' => array(
1975
+            '0' => array(
1976 1976
             '#type' => 'condition',
1977 1977
             '#settings' => array(
1978
-              'roles' => array(
1978
+                'roles' => array(
1979 1979
                 '0' => 3519698132,
1980 1980
                 '1' => 1271379760,
1981
-              ),
1982
-              'operation' => 'OR',
1983
-              '#argument map' => array(
1981
+                ),
1982
+                'operation' => 'OR',
1983
+                '#argument map' => array(
1984 1984
                 'user' => 'user',
1985
-              ),
1985
+                ),
1986 1986
             ),
1987 1987
             '#name' => 'rules_condition_user_hasrole',
1988 1988
             '#info' => array(
1989
-              'label' => 'User has role(s): administrator or moderator',
1990
-              'label callback' => FALSE,
1991
-              'arguments' => array(
1989
+                'label' => 'User has role(s): administrator or moderator',
1990
+                'label callback' => FALSE,
1991
+                'arguments' => array(
1992 1992
                 'user' => array(
1993
-                  'type' => 'user',
1994
-                  'label' => 'User',
1993
+                    'type' => 'user',
1994
+                    'label' => 'User',
1995 1995
                 ),
1996
-              ),
1997
-              'module' => 'User',
1996
+                ),
1997
+                'module' => 'User',
1998 1998
             ),
1999 1999
             '#weight' => 0.0,
2000
-          ),
2001
-          '1' => array(
2000
+            ),
2001
+            '1' => array(
2002 2002
             '#weight' => 0.0,
2003 2003
             '0' => array(
2004
-              '#weight' => 0.0,
2005
-              '#type' => 'condition',
2006
-              '#settings' => array(
2004
+                '#weight' => 0.0,
2005
+                '#type' => 'condition',
2006
+                '#settings' => array(
2007 2007
                 'type' => array(
2008
-                  'forum' => 'forum',
2008
+                    'forum' => 'forum',
2009 2009
                 ),
2010 2010
                 '#argument map' => array(
2011
-                  'node' => 'node',
2011
+                    'node' => 'node',
2012 2012
                 ),
2013
-              ),
2014
-              '#name' => 'rules_condition_content_is_type',
2015
-              '#info' => array(
2013
+                ),
2014
+                '#name' => 'rules_condition_content_is_type',
2015
+                '#info' => array(
2016 2016
                 'label' => 'Updated content is Forum topic',
2017 2017
                 'arguments' => array(
2018
-                  'node' => array(
2018
+                    'node' => array(
2019 2019
                     'type' => 'node',
2020 2020
                     'label' => 'Content',
2021
-                  ),
2021
+                    ),
2022 2022
                 ),
2023 2023
                 'module' => 'Node',
2024
-              ),
2024
+                ),
2025 2025
             ),
2026 2026
             '#type' => 'OR',
2027 2027
             '1' => array(
2028
-              '#type' => 'condition',
2029
-              '#settings' => array(
2028
+                '#type' => 'condition',
2029
+                '#settings' => array(
2030 2030
                 'type' => array(
2031
-                  'team_forum' => 'team_forum',
2031
+                    'team_forum' => 'team_forum',
2032 2032
                 ),
2033 2033
                 '#argument map' => array(
2034
-                  'node' => 'node',
2034
+                    'node' => 'node',
2035 2035
                 ),
2036
-              ),
2037
-              '#name' => 'rules_condition_content_is_type',
2038
-              '#info' => array(
2036
+                ),
2037
+                '#name' => 'rules_condition_content_is_type',
2038
+                '#info' => array(
2039 2039
                 'label' => 'Updated content is Team forum topic',
2040 2040
                 'arguments' => array(
2041
-                  'node' => array(
2041
+                    'node' => array(
2042 2042
                     'type' => 'node',
2043 2043
                     'label' => 'Content',
2044
-                  ),
2044
+                    ),
2045 2045
                 ),
2046 2046
                 'module' => 'Node',
2047
-              ),
2048
-              '#weight' => 0.0,
2047
+                ),
2048
+                '#weight' => 0.0,
2049 2049
             ),
2050
-          ),
2051
-          '3' => array(
2050
+            ),
2051
+            '3' => array(
2052 2052
             '#weight' => 0.0,
2053 2053
             '#info' => array(
2054
-              'label' => 'PHP code: node content unchanged',
2055
-              'label callback' => FALSE,
2056
-              'module' => 'PHP',
2057
-              'eval input' => array(
2054
+                'label' => 'PHP code: node content unchanged',
2055
+                'label callback' => FALSE,
2056
+                'module' => 'PHP',
2057
+                'eval input' => array(
2058 2058
                 '0' => 'code',
2059
-              ),
2059
+                ),
2060 2060
             ),
2061 2061
             '#name' => 'rules_condition_custom_php',
2062 2062
             '#settings' => array(
2063
-              'code' => 'return $node->body == $node_unchanged->body;',
2064
-              'vars' => array(
2063
+                'code' => 'return $node->body == $node_unchanged->body;',
2064
+                'vars' => array(
2065 2065
                 '0' => 'node',
2066 2066
                 '1' => 'node_unchanged',
2067
-              ),
2068
-              '#eval input' => array(
2067
+                ),
2068
+                '#eval input' => array(
2069 2069
                 'token_rules_input_evaluator' => array(
2070
-                  'code' => array(
2070
+                    'code' => array(
2071 2071
                     '0' => ':global',
2072
-                  ),
2072
+                    ),
2073
+                ),
2073 2074
                 ),
2074
-              ),
2075 2075
             ),
2076 2076
             '#type' => 'condition',
2077
-          ),
2078
-          '4' => array(
2077
+            ),
2078
+            '4' => array(
2079 2079
             '#weight' => 0.0,
2080 2080
             '#info' => array(
2081
-              'label' => 'PHP code: node unlocked',
2082
-              'label callback' => FALSE,
2083
-              'module' => 'PHP',
2084
-              'eval input' => array(
2081
+                'label' => 'PHP code: node unlocked',
2082
+                'label callback' => FALSE,
2083
+                'module' => 'PHP',
2084
+                'eval input' => array(
2085 2085
                 '0' => 'code',
2086
-              ),
2086
+                ),
2087 2087
             ),
2088 2088
             '#name' => 'rules_condition_custom_php',
2089 2089
             '#type' => 'condition',
2090 2090
             '#settings' => array(
2091
-              'code' => 'return $node_unchanged->comment == 1 && $node->comment == 2;',
2092
-              'vars' => array(
2091
+                'code' => 'return $node_unchanged->comment == 1 && $node->comment == 2;',
2092
+                'vars' => array(
2093 2093
                 '0' => 'node',
2094 2094
                 '1' => 'node_unchanged',
2095
-              ),
2096
-              '#eval input' => array(
2095
+                ),
2096
+                '#eval input' => array(
2097 2097
                 'token_rules_input_evaluator' => array(
2098
-                  'code' => array(
2098
+                    'code' => array(
2099 2099
                     '0' => ':global',
2100
-                  ),
2100
+                    ),
2101 2101
                 ),
2102
-              ),
2102
+                ),
2103
+            ),
2103 2104
             ),
2104
-          ),
2105 2105
         ),
2106 2106
         '#actions' => array(
2107
-          '0' => array(
2107
+            '0' => array(
2108 2108
             '#info' => array(
2109
-              'label' => 'Notify moderators via email',
2110
-              'module' => 'BOINC core',
2111
-              'eval input' => array(
2109
+                'label' => 'Notify moderators via email',
2110
+                'module' => 'BOINC core',
2111
+                'eval input' => array(
2112 2112
                 '0' => 'subject',
2113 2113
                 '1' => 'message',
2114 2114
                 '2' => 'from',
2115
-              ),
2115
+                ),
2116 2116
             ),
2117 2117
             '#name' => 'boinccore_rules_action_mail_to_moderators',
2118 2118
             '#settings' => array(
2119
-              'from' => '',
2120
-              'subject' => 'Forum topic at [:global:site-name] unlocked by moderator/admin',
2121
-              'message' => "[node:type] topic '[node:title]' has been unlocked by moderator/admin [user:display-name].\r\n\r\nLink: <?php print url('node/' . \$node->nid, array('absolute' => TRUE, 'language' => 'en')); ?>",
2122
-              '#eval input' => array(
2119
+                'from' => '',
2120
+                'subject' => 'Forum topic at [:global:site-name] unlocked by moderator/admin',
2121
+                'message' => "[node:type] topic '[node:title]' has been unlocked by moderator/admin [user:display-name].\r\n\r\nLink: <?php print url('node/' . \$node->nid, array('absolute' => TRUE, 'language' => 'en')); ?>",
2122
+                '#eval input' => array(
2123 2123
                 'token_rules_input_evaluator' => array(
2124
-                  'subject' => array(
2124
+                    'subject' => array(
2125 2125
                     '0' => ':global',
2126
-                  ),
2127
-                  'message' => array(
2126
+                    ),
2127
+                    'message' => array(
2128 2128
                     '0' => 'node',
2129 2129
                     '1' => 'user',
2130 2130
                     '2' => ':global',
2131
-                  ),
2132
-                  'from' => array(
2131
+                    ),
2132
+                    'from' => array(
2133 2133
                     '0' => ':global',
2134
-                  ),
2134
+                    ),
2135 2135
                 ),
2136 2136
                 'rules_input_evaluator_php' => array(
2137
-                  'message' => array(
2137
+                    'message' => array(
2138 2138
                     '0' => 'node',
2139
-                  ),
2139
+                    ),
2140
+                ),
2140 2141
                 ),
2141
-              ),
2142 2142
             ),
2143 2143
             '#type' => 'action',
2144 2144
             '#weight' => 0.0,
2145
-          ),
2145
+            ),
2146 2146
         ),
2147 2147
         '#version' => 6003,
2148
-      ),
2149
-      'rules_offensive_comment_reported' => array(
2148
+        ),
2149
+        'rules_offensive_comment_reported' => array(
2150 2150
         '#type' => 'rule',
2151 2151
         '#set' => 'event_flag_flagged_abuse_comment',
2152 2152
         '#label' => 'Offensive comment reported',
2153 2153
         '#active' => 1,
2154 2154
         '#weight' => '0',
2155 2155
         '#categories' => array(
2156
-          '0' => 'moderator notification',
2157
-          '1' => 'boinc_standard',
2156
+            '0' => 'moderator notification',
2157
+            '1' => 'boinc_standard',
2158 2158
         ),
2159 2159
         '#status' => 'default',
2160 2160
         '#conditions' => array(),
2161 2161
         '#actions' => array(
2162
-          '1' => array(
2162
+            '1' => array(
2163 2163
             '#info' => array(
2164
-              'label' => 'Notify moderators via email',
2165
-              'module' => 'BOINC core',
2166
-              'eval input' => array(
2164
+                'label' => 'Notify moderators via email',
2165
+                'module' => 'BOINC core',
2166
+                'eval input' => array(
2167 2167
                 '0' => 'subject',
2168 2168
                 '1' => 'message',
2169 2169
                 '2' => 'from',
2170
-              ),
2170
+                ),
2171 2171
             ),
2172 2172
             '#name' => 'boinccore_rules_action_mail_to_moderators',
2173 2173
             '#settings' => array(
2174
-              'from' => '',
2175
-              'subject' => 'Report of offensive [node:type] comment at [:global:site-name]',
2176
-              'message' => "[flagging_user:display-name] has reported the following comment on [node:type] content as being offensive or inappropriate for the [:global:site-name] site:\r\n\r\n<?php print url('<front>', array('absolute' => TRUE, 'language' => 'en')); ?>/goto/comment/[comment:comment-cid]\r\n\r\nTotal reports of this comment: [comment:flag-abuse-comment-count]",
2177
-              '#eval input' => array(
2174
+                'from' => '',
2175
+                'subject' => 'Report of offensive [node:type] comment at [:global:site-name]',
2176
+                'message' => "[flagging_user:display-name] has reported the following comment on [node:type] content as being offensive or inappropriate for the [:global:site-name] site:\r\n\r\n<?php print url('<front>', array('absolute' => TRUE, 'language' => 'en')); ?>/goto/comment/[comment:comment-cid]\r\n\r\nTotal reports of this comment: [comment:flag-abuse-comment-count]",
2177
+                '#eval input' => array(
2178 2178
                 'token_rules_input_evaluator' => array(
2179
-                  'subject' => array(
2179
+                    'subject' => array(
2180 2180
                     '0' => 'node',
2181 2181
                     '1' => ':global',
2182
-                  ),
2183
-                  'message' => array(
2182
+                    ),
2183
+                    'message' => array(
2184 2184
                     '0' => 'flagging_user',
2185 2185
                     '1' => 'comment',
2186 2186
                     '2' => 'node',
2187 2187
                     '3' => ':global',
2188
-                  ),
2189
-                  'from' => array(
2188
+                    ),
2189
+                    'from' => array(
2190 2190
                     '0' => ':global',
2191
-                  ),
2191
+                    ),
2192 2192
                 ),
2193 2193
                 'rules_input_evaluator_php' => array(
2194
-                  'message' => array(),
2194
+                    'message' => array(),
2195
+                ),
2195 2196
                 ),
2196
-              ),
2197 2197
             ),
2198 2198
             '#type' => 'action',
2199 2199
             '#weight' => 0.0,
2200
-          ),
2200
+            ),
2201 2201
         ),
2202 2202
         '#version' => 6003,
2203
-      ),
2204
-      'rules_offensive_content_reported' => array(
2203
+        ),
2204
+        'rules_offensive_content_reported' => array(
2205 2205
         '#type' => 'rule',
2206 2206
         '#set' => 'event_flag_flagged_abuse_node',
2207 2207
         '#label' => 'Offensive content reported',
2208 2208
         '#active' => 1,
2209 2209
         '#weight' => '0',
2210 2210
         '#categories' => array(
2211
-          '0' => 'moderator notification',
2212
-          'boinc_standard' => 'boinc_standard',
2211
+            '0' => 'moderator notification',
2212
+            'boinc_standard' => 'boinc_standard',
2213 2213
         ),
2214 2214
         '#status' => 'default',
2215 2215
         '#conditions' => array(),
2216 2216
         '#actions' => array(
2217
-          '1' => array(
2217
+            '1' => array(
2218 2218
             '#type' => 'action',
2219 2219
             '#settings' => array(
2220
-              'from' => '',
2221
-              'subject' => 'Report of offensive [node:type] content at [:global:site-name]',
2222
-              'message' => "[flagging_user:display-name] has reported the following [node:type] content as being offensive or inappropriate for the [:global:site-name] site:\r\n\r\n<?php print url('node/' . \$node->nid, array('absolute' => TRUE, 'language' => 'en')); ?>\r\n\r\nTotal reports of this content: [node:flag-abuse-node-count]",
2223
-              '#eval input' => array(
2220
+                'from' => '',
2221
+                'subject' => 'Report of offensive [node:type] content at [:global:site-name]',
2222
+                'message' => "[flagging_user:display-name] has reported the following [node:type] content as being offensive or inappropriate for the [:global:site-name] site:\r\n\r\n<?php print url('node/' . \$node->nid, array('absolute' => TRUE, 'language' => 'en')); ?>\r\n\r\nTotal reports of this content: [node:flag-abuse-node-count]",
2223
+                '#eval input' => array(
2224 2224
                 'token_rules_input_evaluator' => array(
2225
-                  'subject' => array(
2225
+                    'subject' => array(
2226 2226
                     '0' => 'node',
2227 2227
                     '1' => ':global',
2228
-                  ),
2229
-                  'message' => array(
2228
+                    ),
2229
+                    'message' => array(
2230 2230
                     '0' => 'flagging_user',
2231 2231
                     '1' => 'node',
2232 2232
                     '2' => ':global',
2233
-                  ),
2234
-                  'from' => array(
2233
+                    ),
2234
+                    'from' => array(
2235 2235
                     '0' => ':global',
2236
-                  ),
2236
+                    ),
2237 2237
                 ),
2238 2238
                 'rules_input_evaluator_php' => array(
2239
-                  'message' => array(
2239
+                    'message' => array(
2240 2240
                     '0' => 'node',
2241
-                  ),
2241
+                    ),
2242
+                ),
2242 2243
                 ),
2243
-              ),
2244 2244
             ),
2245 2245
             '#name' => 'boinccore_rules_action_mail_to_moderators',
2246 2246
             '#info' => array(
2247
-              'label' => 'Notify moderators via email',
2248
-              'module' => 'BOINC core',
2249
-              'eval input' => array(
2247
+                'label' => 'Notify moderators via email',
2248
+                'module' => 'BOINC core',
2249
+                'eval input' => array(
2250 2250
                 '0' => 'subject',
2251 2251
                 '1' => 'message',
2252 2252
                 '2' => 'from',
2253
-              ),
2253
+                ),
2254 2254
             ),
2255 2255
             '#weight' => 0.0,
2256
-          ),
2256
+            ),
2257 2257
         ),
2258 2258
         '#version' => 6003,
2259
-      ),
2260
-      'rules_offensive_user_reported' => array(
2259
+        ),
2260
+        'rules_offensive_user_reported' => array(
2261 2261
         '#type' => 'rule',
2262 2262
         '#set' => 'event_flag_flagged_abuse_user',
2263 2263
         '#label' => 'Offensive user reported',
2264 2264
         '#active' => 1,
2265 2265
         '#weight' => '0',
2266 2266
         '#categories' => array(
2267
-          '0' => 'moderator notification',
2268
-          'boinc_standard' => 'boinc_standard',
2267
+            '0' => 'moderator notification',
2268
+            'boinc_standard' => 'boinc_standard',
2269 2269
         ),
2270 2270
         '#status' => 'default',
2271 2271
         '#conditions' => array(),
2272 2272
         '#actions' => array(
2273
-          '1' => array(
2273
+            '1' => array(
2274 2274
             '#type' => 'action',
2275 2275
             '#settings' => array(
2276
-              'from' => '',
2277
-              'subject' => 'Report of offensive user at [:global:site-name]',
2278
-              'message' => "[flagging_user:display-name] has reported [account:display-name] for inappropriate behavior:\r\n\r\n<?php print url(\'<front>\', array(\'absolute\' => TRUE, \'language\' => \'en\')); ?>/account/[account:uid]\r\n\r\nTotal current reports of this user: [account:flag-abuse-user-count]",
2279
-              '#eval input' => array(
2276
+                'from' => '',
2277
+                'subject' => 'Report of offensive user at [:global:site-name]',
2278
+                'message' => "[flagging_user:display-name] has reported [account:display-name] for inappropriate behavior:\r\n\r\n<?php print url(\'<front>\', array(\'absolute\' => TRUE, \'language\' => \'en\')); ?>/account/[account:uid]\r\n\r\nTotal current reports of this user: [account:flag-abuse-user-count]",
2279
+                '#eval input' => array(
2280 2280
                 'token_rules_input_evaluator' => array(
2281
-                  'subject' => array(
2281
+                    'subject' => array(
2282 2282
                     '0' => ':global',
2283
-                  ),
2284
-                  'message' => array(
2283
+                    ),
2284
+                    'message' => array(
2285 2285
                     '0' => 'flagging_user',
2286 2286
                     '1' => 'account',
2287 2287
                     '2' => ':global',
2288
-                  ),
2289
-                  'from' => array(
2288
+                    ),
2289
+                    'from' => array(
2290 2290
                     '0' => ':global',
2291
-                  ),
2291
+                    ),
2292 2292
                 ),
2293 2293
                 'rules_input_evaluator_php' => array(
2294
-                  'message' => array(),
2294
+                    'message' => array(),
2295
+                ),
2295 2296
                 ),
2296
-              ),
2297 2297
             ),
2298 2298
             '#name' => 'boinccore_rules_action_mail_to_moderators',
2299 2299
             '#info' => array(
2300
-              'label' => 'Notify moderators via email',
2301
-              'module' => 'BOINC core',
2302
-              'eval input' => array(
2300
+                'label' => 'Notify moderators via email',
2301
+                'module' => 'BOINC core',
2302
+                'eval input' => array(
2303 2303
                 '0' => 'subject',
2304 2304
                 '1' => 'message',
2305 2305
                 '2' => 'from',
2306
-              ),
2306
+                ),
2307 2307
             ),
2308 2308
             '#weight' => 0.0,
2309
-          ),
2309
+            ),
2310 2310
         ),
2311 2311
         '#version' => 6003,
2312
-      ),
2312
+        ),
2313 2313
     ),
2314
-  );
2314
+    );
2315 2315
 }
2316 2316
 
2317 2317
 /**
2318 2318
  * Implementation of hook_views_api().
2319 2319
  */
2320 2320
 function boinc_standard_views_api() {
2321
-  return array(
2321
+    return array(
2322 2322
     'api' => '2',
2323
-  );
2323
+    );
2324 2324
 }
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boincwork/includes/boincwork.forms.inc 1 patch
Indentation   +949 added lines, -949 removed lines patch added patch discarded remove patch
@@ -15,16 +15,16 @@  discard block
 block discarded – undo
15 15
  * The structure of the general preferences form
16 16
  */
17 17
 function boincwork_generalprefs_form(&$form_state, $venue, $prefs_preset = null, $advanced = FALSE) {
18
-  $form = array();
19
-  $prefs = null;
20
-  $established = TRUE;
18
+    $form = array();
19
+    $prefs = null;
20
+    $established = TRUE;
21 21
   
22
-  // Enable AHAH form support for dynamically updating content based on preset
23
-  ahah_helper_register($form, $form_state);
22
+    // Enable AHAH form support for dynamically updating content based on preset
23
+    ahah_helper_register($form, $form_state);
24 24
   
25
-  if (!$prefs_preset) {
25
+    if (!$prefs_preset) {
26 26
     if (isset($form_state['storage']['prefs']['preset'])) {
27
-      $prefs_preset = $form_state['storage']['prefs']['preset'];
27
+        $prefs_preset = $form_state['storage']['prefs']['preset'];
28 28
     }
29 29
     
30 30
     // Load preferences from BOINC account
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     
33 33
     // Take note if this is not an established preference set on the account
34 34
     if (isset($prefs['@attributes']['cleared'])) {
35
-      $established = FALSE;
35
+        $established = FALSE;
36 36
     }
37 37
     
38 38
     // Determine if a preset is selected or if these are custom settings
@@ -47,45 +47,45 @@  discard block
 block discarded – undo
47 47
             $prefs_preset = $prefs['preset']['@value'];
48 48
         }
49 49
     }// if !$prefs_preset
50
-  }
51
-  // Extract mod_time tag if present, because it will be erased with
52
-  // boincwork_get_preset_prefs() below.
53
-  $mod_time = null;
54
-  if (isset($prefs['mod_time']['@value'])) {
55
-      $mod_time = $prefs['mod_time']['@value'];
56
-  }
57
-
58
-  if (isset($form_state['storage']['wip'])) {
59
-      switch ($prefs_preset) {
60
-      case 'standard':
50
+    }
51
+    // Extract mod_time tag if present, because it will be erased with
52
+    // boincwork_get_preset_prefs() below.
53
+    $mod_time = null;
54
+    if (isset($prefs['mod_time']['@value'])) {
55
+        $mod_time = $prefs['mod_time']['@value'];
56
+    }
57
+
58
+    if (isset($form_state['storage']['wip'])) {
59
+        switch ($prefs_preset) {
60
+        case 'standard':
61 61
       case 'maximum':
62 62
       case 'green':
63 63
       case 'minimum':
64 64
           $prefs = boincwork_get_preset_prefs($prefs_preset);
65
-          break;
66
-      case 'custom':
65
+            break;
66
+        case 'custom':
67 67
       default:
68 68
           // Just keeps prefs as they are
69 69
           unset($prefs['preset']);
70
-          break;
71
-      }// switch
72
-  } else {
73
-      $form_state['storage']['wip'] = TRUE;
74
-      if ( !in_array($prefs_preset, array('standard','maximum','green','minimum','custom')) ) {
75
-          if ($established) {
76
-              $prefs_preset = 'custom';
77
-          } else {
78
-              $prefs_preset = 'standard';
79
-              $prefs = boincwork_get_preset_prefs($prefs_preset);
80
-          }// if $established
81
-      }// if $prefs_preset
82
-  }// if WIP
83
-  
84
-  // This set of preferences is used in the form if no preferences
85
-  // have been set above, in variable $prefs.
86
-  require_boinc(array('db', 'prefs'));
87
-  $disk_space_config = get_disk_space_config();
88
-  $default = array(
70
+            break;
71
+        }// switch
72
+    } else {
73
+        $form_state['storage']['wip'] = TRUE;
74
+        if ( !in_array($prefs_preset, array('standard','maximum','green','minimum','custom')) ) {
75
+            if ($established) {
76
+                $prefs_preset = 'custom';
77
+            } else {
78
+                $prefs_preset = 'standard';
79
+                $prefs = boincwork_get_preset_prefs($prefs_preset);
80
+            }// if $established
81
+        }// if $prefs_preset
82
+    }// if WIP
83
+  
84
+    // This set of preferences is used in the form if no preferences
85
+    // have been set above, in variable $prefs.
86
+    require_boinc(array('db', 'prefs'));
87
+    $disk_space_config = get_disk_space_config();
88
+    $default = array(
89 89
     'preset' => $prefs_preset,
90 90
     // Processing...
91 91
     'run_on_batteries' => 0,
@@ -120,385 +120,385 @@  discard block
 block discarded – undo
120 120
     'daily_xfer_limit_mb' => 0,
121 121
     'daily_xfer_period_days' => 0,
122 122
     'dont_verify_images' => 0
123
-  );
124
-  foreach ($default as $name => $value) {
123
+    );
124
+    foreach ($default as $name => $value) {
125 125
     if (isset($prefs[$name])) {
126
-      if (is_array($prefs[$name])) {
126
+        if (is_array($prefs[$name])) {
127 127
         if (isset($prefs[$name]['@value'])) {
128
-          $default[$name] = $prefs[$name]['@value'];
128
+            $default[$name] = $prefs[$name]['@value'];
129
+        }
129 130
         }
130
-      }
131
-      else {
131
+        else {
132 132
         $default[$name] = $prefs[$name];
133
-      }
133
+        }
134
+    }
134 135
     }
135
-  }
136 136
 
137
-  // Standard option sets
138
-  $form['boolean_options'] = array(
137
+    // Standard option sets
138
+    $form['boolean_options'] = array(
139 139
     '#type' => 'value',
140 140
     '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes'))
141
-  );
142
-  $form['hour_options'] = array(
141
+    );
142
+    $form['hour_options'] = array(
143 143
     '#type' => 'value',
144 144
     '#value' => array('0:00','1:00','2:00','3:00','4:00', 
145
-     '5:00','6:00','7:00','8:00','9:00','10:00','11:00', 
146
-     '12:00','13:00','14:00','15:00','16:00','17:00',
147
-     '18:00','19:00','20:00','21:00','22:00','23:00')
148
-  );
149
-  
150
-  // Identify preference sets that are established to distinguish what has been
151
-  // saved to the database from what is just showing default values
152
-  $form['#established'] = $established;
145
+        '5:00','6:00','7:00','8:00','9:00','10:00','11:00', 
146
+        '12:00','13:00','14:00','15:00','16:00','17:00',
147
+        '18:00','19:00','20:00','21:00','22:00','23:00')
148
+    );
149
+  
150
+    // Identify preference sets that are established to distinguish what has been
151
+    // saved to the database from what is just showing default values
152
+    $form['#established'] = $established;
153 153
    
154
-  // Set up the preference container for AHAH
155
-  $form['prefs'] = array(
154
+    // Set up the preference container for AHAH
155
+    $form['prefs'] = array(
156 156
     '#title' => '',
157 157
     '#type' => 'fieldset',
158 158
     '#prefix' => '<div id="prefs-wrapper">', // This is our wrapper div.
159 159
     '#attributes' => array('class' => 'ahah-container'),
160 160
     '#suffix' => '</div>',
161 161
     '#tree'   => TRUE
162
-  );
163
-  //$form['prefs']['debug'] = array('#value' => '<pre>' . print_r($form_state, true) . '</pre>');
162
+    );
163
+    //$form['prefs']['debug'] = array('#value' => '<pre>' . print_r($form_state, true) . '</pre>');
164 164
   
165
-  // Hidden elements
166
-  $form['prefs']['modified'] = array(
165
+    // Hidden elements
166
+    $form['prefs']['modified'] = array(
167 167
     '#type' => 'hidden',
168 168
     '#value' => $mod_time
169
-  );
170
-  $form['prefs']['venue'] = array(
169
+    );
170
+    $form['prefs']['venue'] = array(
171 171
     '#type' => 'hidden',
172 172
     '#value' => $venue
173
-  );
173
+    );
174 174
   
175
-  $form['prefs']['separator_top'] = array(
175
+    $form['prefs']['separator_top'] = array(
176 176
     '#value' => '<div class="separator"></div>'
177
-  );
177
+    );
178 178
   
179
-  // Simplified selectors
180
-  $form['prefs']['preset'] = array(
181
-      '#title' => bts('Presets', array(), NULL, 'boinc:account-preferences-preset:-1:for a user to choose a computing or project preference preset.'),
179
+    // Simplified selectors
180
+    $form['prefs']['preset'] = array(
181
+        '#title' => bts('Presets', array(), NULL, 'boinc:account-preferences-preset:-1:for a user to choose a computing or project preference preset.'),
182 182
     '#type' => 'radios',
183 183
     '#description' => ' ',
184 184
     '#options' => array(
185
-      'standard' => bts('Standard', array(), NULL, 'boinc:account-preferences-preset'),
186
-      'maximum' => bts('Maximum', array(), NULL, 'boinc:account-preferences-preset'),
187
-      'green' => bts('Green', array(), NULL, 'boinc:account-preferences-preset'),
188
-      'minimum' => bts('Minimum', array(), NULL, 'boinc:account-preferences-preset'),
189
-      'custom' => bts('Custom', array(), NULL, 'boinc:account-preferences-preset')
185
+        'standard' => bts('Standard', array(), NULL, 'boinc:account-preferences-preset'),
186
+        'maximum' => bts('Maximum', array(), NULL, 'boinc:account-preferences-preset'),
187
+        'green' => bts('Green', array(), NULL, 'boinc:account-preferences-preset'),
188
+        'minimum' => bts('Minimum', array(), NULL, 'boinc:account-preferences-preset'),
189
+        'custom' => bts('Custom', array(), NULL, 'boinc:account-preferences-preset')
190 190
     ),
191 191
     '#prefix' => '<div class="simple-form-controls">',
192 192
     '#suffix' => '</div>',
193 193
     '#default_value' => $default['preset'],
194 194
     '#ahah' => array(
195
-      'event' => 'change',
196
-      'path' => ahah_helper_path(array('prefs')),
197
-      'wrapper' => 'prefs-wrapper'
195
+        'event' => 'change',
196
+        'path' => ahah_helper_path(array('prefs')),
197
+        'wrapper' => 'prefs-wrapper'
198 198
     )
199
-  );
200
-  $form['prefs']['select preset'] = array(
199
+    );
200
+    $form['prefs']['select preset'] = array(
201 201
     '#type'  => 'submit',
202 202
     '#value' => bts('Update preset', array(), NULL, 'boinc:account-preferences-preset'),
203 203
     '#submit' => array('ahah_helper_generic_submit'),
204 204
     // The 'no-js' class only displays this button if javascript is disabled
205 205
     '#attributes' => array('class' => 'no-js'),
206
-  );
206
+    );
207 207
   
208
-  // Advanced preferences
209
-  $form['prefs']['advanced'] = array(
208
+    // Advanced preferences
209
+    $form['prefs']['advanced'] = array(
210 210
     '#title' => bts('Advanced settings', array(), NULL, 'boinc:account-preferences-option'),
211 211
     '#type' => 'fieldset',
212 212
     '#description' => '',
213 213
     '#collapsible' => TRUE,
214 214
     '#collapsed' => !$advanced,
215 215
     '#attributes' => array('class' => 'advanced-settings'),
216
-  );
216
+    );
217 217
   
218
-  // Processing preferences
218
+    // Processing preferences
219 219
   
220
-  $form['prefs']['advanced']['anchor'] = array(
220
+    $form['prefs']['advanced']['anchor'] = array(
221 221
     '#value' => '<a name="advanced"></a>'
222
-  );
222
+    );
223 223
   
224
-  $form['prefs']['advanced']['separator_top'] = array(
224
+    $form['prefs']['advanced']['separator_top'] = array(
225 225
     '#value' => '<div class="separator"></div>'
226
-  );
226
+    );
227 227
   
228
-  $form['prefs']['advanced']['processor'] = array(
228
+    $form['prefs']['advanced']['processor'] = array(
229 229
     '#title' => bts('Processor usage', array(), NULL, 'boinc:account-preferences-computing'),
230 230
     '#type' => 'fieldset',
231 231
     '#description' => '',
232 232
     '#collapsible' => FALSE,
233 233
     '#collapsed' => FALSE
234
-  );
235
-  $form['prefs']['advanced']['processor']['run_on_batteries'] = array(
234
+    );
235
+    $form['prefs']['advanced']['processor']['run_on_batteries'] = array(
236 236
     '#title' => bts('Suspend when computer is on battery?', array(), NULL, 'boinc:account-preferences-computing'),
237 237
     '#type' => 'radios',
238 238
     '#description' => bts('Suspends computing on portables when running on battery power.', array(), NULL, 'boinc:account-preferences-computing'),
239 239
     '#options' => $form['boolean_options']['#value'],
240 240
     '#attributes' => array('class' => 'fancy'),
241 241
     '#default_value' => ($default['run_on_batteries']) ? 0 : 1 // intentional inversion of setting
242
-  );
243
-  $form['prefs']['advanced']['processor']['run_if_user_active'] = array(
242
+    );
243
+    $form['prefs']['advanced']['processor']['run_if_user_active'] = array(
244 244
     '#title' => bts('Suspend when computer is in use?', array(), NULL, 'boinc:account-preferences-computing'),
245 245
     '#type' => 'radios',
246 246
     '#description' => bts("Suspends computing and file transfers when you're using the computer.", array(), NULL, 'boinc:account-preferences-computing'),
247 247
     '#options' => $form['boolean_options']['#value'],
248 248
     '#attributes' => array('class' => 'fancy'),
249 249
     '#default_value' => ($default['run_if_user_active']) ? 0 : 1 // intentional inversion of setting
250
-  );
251
-  $form['prefs']['advanced']['processor']['run_gpu_if_user_active'] = array(
250
+    );
251
+    $form['prefs']['advanced']['processor']['run_gpu_if_user_active'] = array(
252 252
     '#title' => bts('Suspend GPU computing when computer is in use?', array(), NULL, 'boinc:account-preferences-computing'),
253 253
     '#type' => 'radios',
254 254
     '#description' => bts("Suspends GPU computing when you're using the computer.", array(), NULL, 'boinc:account-preferences-computing'),
255 255
     '#options' => $form['boolean_options']['#value'],
256 256
     '#attributes' => array('class' => 'fancy'),
257 257
     '#default_value' => ($default['run_gpu_if_user_active']) ? 0 : 1 // intentional inversion of setting
258
-  );
259
-  $form['prefs']['advanced']['processor']['idle_time_to_run'] = array(
260
-      '#title' => bts('"In use" means mouse/keyboard input in last', array(), NULL, 'boinc:account-preferences-computing'),
258
+    );
259
+    $form['prefs']['advanced']['processor']['idle_time_to_run'] = array(
260
+        '#title' => bts('"In use" means mouse/keyboard input in last', array(), NULL, 'boinc:account-preferences-computing'),
261 261
     '#type' => 'textfield',
262 262
     '#field_suffix' => bts('minutes', array(), NULL, 'boinc:unit-of-time'),
263 263
     '#default_value' => $default['idle_time_to_run'],
264 264
     '#size' => 1,
265 265
     '#description' => bts('This determines when the computer is considered "in use".', array(), NULL, 'boinc:account-preferences-computing')
266
-  );
267
-  $form['prefs']['advanced']['processor']['suspend_if_no_recent_input'] = array(
266
+    );
267
+    $form['prefs']['advanced']['processor']['suspend_if_no_recent_input'] = array(
268 268
     '#title' => bts('Suspend when no mouse/keyboard input in last', array(), NULL, 'boinc:account-preferences-computing'),
269 269
     '#type' => 'textfield',
270 270
     '#field_suffix' => bts('minutes', array(), NULL, 'boinc:unit-of-time'),
271 271
     '#default_value' => $default['suspend_if_no_recent_input'],
272 272
     '#size' => 1,
273 273
     '#description' => bts('This allows some computers to enter low-power mode when not in use.', array(), NULL, 'boinc:account-preferences-computing')
274
-  );
275
-  $form['prefs']['advanced']['processor']['suspend_cpu_usage'] = array(
274
+    );
275
+    $form['prefs']['advanced']['processor']['suspend_cpu_usage'] = array(
276 276
     '#title' => bts('Suspend when non-BOINC CPU usage is above', array(), NULL, 'boinc:account-preferences-computing'),
277 277
     '#type' => 'textfield',
278 278
     '#field_suffix' => '%',
279 279
     '#default_value' => $default['suspend_cpu_usage'],
280 280
     '#size' => 1,
281 281
     '#description' => bts('Suspend computing when your computer is busy running other programs.', array(), NULL, 'boinc:account-preferences-computing'),
282
-  );
283
-  $form['prefs']['advanced']['processor']['hour_label'] = array(
282
+    );
283
+    $form['prefs']['advanced']['processor']['hour_label'] = array(
284 284
     '#value' => '<div class="form-item"><label>' . bts('Compute only between:', array(), NULL, 'boinc:account-preferences-computing') . '</label></div>'
285
-  );
286
-  $form['prefs']['advanced']['processor']['start_hour'] = array(
285
+    );
286
+    $form['prefs']['advanced']['processor']['start_hour'] = array(
287 287
     '#type' => 'select',
288 288
     '#options' => $form['hour_options']['#value'],
289 289
     '#default_value' => $default['start_hour']
290
-  );
291
-  $form['prefs']['advanced']['processor']['hour_delimiter'] = array(
290
+    );
291
+    $form['prefs']['advanced']['processor']['hour_delimiter'] = array(
292 292
     '#value' => '<span>' . bts('and', array(), NULL, 'boinc:account-preference') . '</span>'
293
-  );
294
-  $form['prefs']['advanced']['processor']['end_hour'] = array(
293
+    );
294
+    $form['prefs']['advanced']['processor']['end_hour'] = array(
295 295
     '#type' => 'select',
296 296
     '#options' => $form['hour_options']['#value'],
297 297
     '#default_value' => $default['end_hour']
298
-  );
299
-  $form['prefs']['advanced']['processor']['hour_description'] = array(
298
+    );
299
+    $form['prefs']['advanced']['processor']['hour_description'] = array(
300 300
     '#value' => '<div class="form-item slim"><div class="description">' . bts('Compute only during a particular period each day.', array(), NULL, 'boinc:account-preferences-computing') . '</div></div>'
301
-  );
302
-  $form['prefs']['advanced']['processor']['leave_apps_in_memory'] = array(
301
+    );
302
+    $form['prefs']['advanced']['processor']['leave_apps_in_memory'] = array(
303 303
     '#title' => bts('Leave non-GPU tasks in memory while suspended?', array(), NULL, 'boinc:account-preferences-computing'),
304 304
     '#type' => 'radios',
305 305
     '#options' => $form['boolean_options']['#value'],
306 306
     '#attributes' => array('class' => 'fancy'),
307 307
     '#default_value' => $default['leave_apps_in_memory'],
308 308
     '#description' => bts('If "Yes", suspended tasks stay in memory, and resume with no work lost. If "No", suspended tasks are removed from memory, and resume from their last checkpoint.', array(), NULL, 'boinc:account-preferences-computing')
309
-  );
310
-  $form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes'] = array(
309
+    );
310
+    $form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes'] = array(
311 311
     '#title' => bts('Switch between tasks every', array(), NULL, 'boinc:account-preferences-computing'),
312 312
     '#type' => 'textfield',
313 313
     '#field_suffix' => bts('minutes', array(), NULL, 'boinc:unit-of-time'),
314 314
     '#default_value' => $default['cpu_scheduling_period_minutes'],
315 315
     '#size' => 1,
316 316
     '#description' => bts('If you run several projects, BOINC may switch between them this often.', array(), NULL, 'boinc:account-preferences-computing')
317
-  );
318
-  $form['prefs']['advanced']['processor']['max_ncpus_pct'] = array(
317
+    );
318
+    $form['prefs']['advanced']['processor']['max_ncpus_pct'] = array(
319 319
     '#title' => bts('Use at most', array(), NULL, 'boinc:account-preferences-computing'),
320 320
     '#type' => 'textfield',
321 321
     '#field_suffix' => bts('% of the processors', array(), NULL, 'boinc:account-preferences-computing'),
322 322
     '#default_value' => $default['max_ncpus_pct'],
323 323
     '#size' => 1,
324 324
     '#description' => bts('Keep some CPUs free for other applications. Example: 75% means use 6 cores on an 8-core CPU.', array(), NULL, 'boinc:account-preferences-computing'),
325
-  );
326
-  $form['prefs']['advanced']['processor']['cpu_usage_limit'] = array(
325
+    );
326
+    $form['prefs']['advanced']['processor']['cpu_usage_limit'] = array(
327 327
     '#title' => bts('Use at most', array(), NULL, 'boinc:account-preferences-computing'),
328 328
     '#type' => 'textfield',
329 329
     '#field_suffix' => bts('% of the CPU time', array(), NULL, 'boinc:account-preferences-computing'),
330 330
     '#default_value' => $default['cpu_usage_limit'],
331 331
     '#size' => 1,
332 332
     '#description' => bts('Suspend/resume computing every few seconds to reduce CPU temperature and energy usage. Example: 75% means compute for 3 seconds, wait for 1 second, and repeat.', array(), NULL, 'boinc:account-preferences-computing')
333
-  );
333
+    );
334 334
   
335
-  // Disk and memory preferences
336
-  $form['prefs']['advanced']['storage'] = array(
335
+    // Disk and memory preferences
336
+    $form['prefs']['advanced']['storage'] = array(
337 337
     '#title' => bts('Disk and memory usage', array(), NULL, 'boinc:account-preferences-computing'),
338 338
     '#type' => 'fieldset',
339 339
     '#description' => '',
340 340
     '#collapsible' => FALSE,
341 341
     '#collapsed' => FALSE
342
-  );
343
-  $form['prefs']['advanced']['storage']['disk_max_used_gb'] = array(
342
+    );
343
+    $form['prefs']['advanced']['storage']['disk_max_used_gb'] = array(
344 344
     '#title' => bts('Disk: use no more than', array(), NULL, 'boinc:account-preferences-computing'),
345 345
     '#type' => 'textfield',
346 346
     '#field_suffix' => 'GB',
347 347
     '#default_value' => $default['disk_max_used_gb'],
348 348
     '#size' => 1,
349 349
     '#description' => bts('Limit the total amount of disk space used by BOINC.', array(), NULL, 'boinc:account-preferences-computing'),
350
-  ); 
351
-  $form['prefs']['advanced']['storage']['disk_min_free_gb'] = array(
350
+    ); 
351
+    $form['prefs']['advanced']['storage']['disk_min_free_gb'] = array(
352 352
     '#title' => bts('Disk: leave at least', array(), NULL, 'boinc:account-preferences-computing'),
353 353
     '#type' => 'textfield',
354 354
     '#field_suffix' => 'GB free',
355 355
     '#default_value' => $default['disk_min_free_gb'],
356 356
     '#size' => 1,
357 357
     '#description' => bts('Limit disk usage to leave this much free space on the volume where BOINC stores data.', array(), NULL, 'boinc:account-preferences-computing'),
358
-  );
359
-  $form['prefs']['advanced']['storage']['disk_max_used_pct'] = array(
358
+    );
359
+    $form['prefs']['advanced']['storage']['disk_max_used_pct'] = array(
360 360
     '#title' => bts('Disk: use no more than', array(), NULL, 'boinc:account-preferences-computing'),
361 361
     '#type' => 'textfield',
362 362
     '#field_suffix' => bts('% of total', array(), NULL, 'boinc:account-preferences-computing'),
363 363
     '#default_value' => $default['disk_max_used_pct'],
364 364
     '#size' => 1,
365 365
     '#description' => bts('Limit the percentage of disk space used by BOINC on the volume where it stores data.', array(), NULL, 'boinc:account-preferences-computing')
366
-  ); 
367
-  $form['prefs']['advanced']['storage']['disk_interval'] = array(
366
+    ); 
367
+    $form['prefs']['advanced']['storage']['disk_interval'] = array(
368 368
     '#title' => bts('Request tasks to checkpoint at most every', array(), NULL, 'boinc:account-preferences-computing'),
369 369
     '#type' => 'textfield',
370 370
     '#field_suffix' => bts('seconds', array(), NULL, 'boinc:unit-of-time'),
371 371
     '#default_value' => $default['disk_interval'],
372 372
     '#size' => 1,
373 373
     '#description' => bts('This controls how often tasks save their state to disk, so that later they can be continued from that point.', array(), NULL, 'boinc:account-preferences-computing')
374
-  );
375
-  $form['prefs']['advanced']['storage']['vm_max_used_pct'] = array(
374
+    );
375
+    $form['prefs']['advanced']['storage']['vm_max_used_pct'] = array(
376 376
     '#title' => bts('Page/swap file: use at most', array(), NULL, 'boinc:account-preferences-computing'),
377 377
     '#type' => 'textfield',
378 378
     '#field_suffix' => bts('% of total', array(), NULL, 'boinc:account-preferences-computing'),
379 379
     '#default_value' => $default['vm_max_used_pct'],
380 380
     '#size' => 1,
381 381
     '#description' => bts('Limit the swap space (page file) used by BOINC.', array(), NULL, 'boinc:account-preferences-computing')
382
-  );
383
-  $form['prefs']['advanced']['storage']['ram_max_used_busy_pct'] = array(
382
+    );
383
+    $form['prefs']['advanced']['storage']['ram_max_used_busy_pct'] = array(
384 384
     '#title' => bts('Memory: when computer is in use, use at most', array(), NULL, 'boinc:account-preferences-computing'),
385 385
     '#type' => 'textfield',
386 386
     '#field_suffix' => bts('% of total', array(), NULL, 'boinc:account-preferences-computing'),
387 387
     '#default_value' => $default['ram_max_used_busy_pct'],
388 388
     '#size' => 1,
389 389
     '#description' => bts("Limit the memory used by BOINC when you're using the computer.", array(), NULL, 'boinc:account-preferences-computing')
390
-  );
391
-  $form['prefs']['advanced']['storage']['ram_max_used_idle_pct'] = array(
390
+    );
391
+    $form['prefs']['advanced']['storage']['ram_max_used_idle_pct'] = array(
392 392
     '#title' => bts('Memory: when computer is not in use, use at most', array(), NULL, 'boinc:account-preferences-computing'),
393 393
     '#type' => 'textfield',
394 394
     '#field_suffix' => bts('% of total', array(), NULL, 'boinc:account-preferences-computing'),
395 395
     '#default_value' => $default['ram_max_used_idle_pct'],
396 396
     '#size' => 1,
397 397
     '#description' => bts("Limit the memory used by BOINC when you're not using the computer.", array(), NULL, 'boinc:account-preferences-computing')
398
-  );
398
+    );
399 399
   
400
-  // Network preferences
401
-  $form['prefs']['advanced']['network'] = array(
400
+    // Network preferences
401
+    $form['prefs']['advanced']['network'] = array(
402 402
     '#title' => bts('Network usage', array(), NULL, 'boinc:account-preferences-computing'),
403 403
     '#type' => 'fieldset',
404 404
     '#description' => '',
405 405
     '#collapsible' => FALSE,
406 406
     '#collapsed' => FALSE
407
-  );
408
-  $form['prefs']['advanced']['network']['work_buf_min_days'] = array(
407
+    );
408
+    $form['prefs']['advanced']['network']['work_buf_min_days'] = array(
409 409
     '#title' => bts('Store at least', array(), NULL, 'boinc:account-preferences-computing'),
410 410
     '#type' => 'textfield',
411 411
     '#field_suffix' => bts('days of work', array(), NULL, 'boinc:account-preferences-computing'),
412 412
     '#default_value' => $default['work_buf_min_days'],
413 413
     '#size' => 1,
414 414
     '#description' => bts('Store at least enough tasks to keep the computer busy for this long.', array(), NULL, 'boinc:account-preferences-computing')
415
-  ); 
416
-  $form['prefs']['advanced']['network']['work_buf_additional_days'] = array(
415
+    ); 
416
+    $form['prefs']['advanced']['network']['work_buf_additional_days'] = array(
417 417
     '#title' => bts('Store up to an additional', array(), NULL, 'boinc:account-preferences-computing'),
418 418
     '#type' => 'textfield',
419 419
     '#field_suffix' => bts('days', array(), NULL, 'boinc:unit-of-time'),
420 420
     '#default_value' => $default['work_buf_additional_days'],
421 421
     '#size' => 1,
422 422
     '#description' => bts('Store additional tasks above the minimum level.  Determines how much work is requested when contacting a project.', array(), NULL, 'boinc:account-preferences-computing')
423
-  ); 
424
-  $form['prefs']['advanced']['network']['confirm_before_connecting'] = array(
423
+    ); 
424
+    $form['prefs']['advanced']['network']['confirm_before_connecting'] = array(
425 425
     '#title' => bts('Confirm before connecting to Internet?', array(), NULL, 'boinc:account-preferences-computing'),
426 426
     '#type' => 'radios',
427 427
     '#options' => $form['boolean_options']['#value'],
428 428
     '#attributes' => array('class' => 'fancy'),
429 429
     '#default_value' => $default['confirm_before_connecting'],
430 430
     '#description' => bts('Useful only if you have a modem, ISDN or VPN connection.', array(), NULL, 'boinc:account-preferences-computing')
431
-  ); 
432
-  $form['prefs']['advanced']['network']['hangup_if_dialed'] = array(
431
+    ); 
432
+    $form['prefs']['advanced']['network']['hangup_if_dialed'] = array(
433 433
     '#title' => bts('Disconnect when done?', array(), NULL, 'boinc:account-preferences-computing'),
434 434
     '#type' => 'radios',
435 435
     '#options' => $form['boolean_options']['#value'],
436 436
     '#attributes' => array('class' => 'fancy'),
437 437
     '#default_value' => $default['hangup_if_dialed'],
438 438
     '#description' => bts('Useful only if you have a modem, ISDN or VPN connection.', array(), NULL, 'boinc:account-preferences-computing')
439
-  );
440
-  $form['prefs']['advanced']['network']['max_bytes_sec_down'] = array(
439
+    );
440
+    $form['prefs']['advanced']['network']['max_bytes_sec_down'] = array(
441 441
     '#title' => bts('Limit download rate to', array(), NULL, 'boinc:account-preferences-computing'),
442 442
     '#type' => 'textfield',
443 443
     '#field_suffix' => 'Kbytes/sec',
444 444
     '#default_value' => $default['max_bytes_sec_down']/1000,
445 445
     '#size' => 1,
446 446
     '#description' => bts('Limit the download rate of file transfers.', array(), NULL, 'boinc:account-preferences-computing')
447
-  ); 
448
-  $form['prefs']['advanced']['network']['max_bytes_sec_up'] = array(
447
+    ); 
448
+    $form['prefs']['advanced']['network']['max_bytes_sec_up'] = array(
449 449
     '#title' => bts('Limit upload rate to', array(), NULL, 'boinc:account-preferences-computing'),
450 450
     '#type' => 'textfield',
451 451
     '#field_suffix' => 'Kbytes/sec',
452 452
     '#default_value' => $default['max_bytes_sec_up']/1000,
453 453
     '#size' => 1,
454 454
     '#description' => bts('Limit the upload rate of file transfers.', array(), NULL, 'boinc:account-preferences-computing')
455
-  );
456
-  $form['prefs']['advanced']['network']['hour_label'] = array(
455
+    );
456
+    $form['prefs']['advanced']['network']['hour_label'] = array(
457 457
     '#value' => '<div class="form-item"><label>' . bts('Transfer files only between', array(), NULL, 'boinc:account-preferences-computing') . '</label></div>'
458
-  );
459
-  $form['prefs']['advanced']['network']['net_start_hour'] = array(
458
+    );
459
+    $form['prefs']['advanced']['network']['net_start_hour'] = array(
460 460
     '#type' => 'select',
461 461
     '#options' => $form['hour_options']['#value'],
462 462
     '#default_value' => $default['net_start_hour']
463
-  );
464
-  $form['prefs']['advanced']['network']['hour_delimiter'] = array(
463
+    );
464
+    $form['prefs']['advanced']['network']['hour_delimiter'] = array(
465 465
     '#value' => '<span>' . bts('and', array(), NULL, 'boinc:account-preference') . '</span>'
466
-  );
467
-  $form['prefs']['advanced']['network']['net_end_hour'] = array(
466
+    );
467
+    $form['prefs']['advanced']['network']['net_end_hour'] = array(
468 468
     '#type' => 'select',
469 469
     '#options' => $form['hour_options']['#value'],
470 470
     '#default_value' => $default['net_end_hour']
471
-  );
472
-  $form['prefs']['advanced']['network']['hour_description'] = array(
471
+    );
472
+    $form['prefs']['advanced']['network']['hour_description'] = array(
473 473
     '#value' => '<div class="form-item slim"><div class="description">' . bts('Transfer files only during a particular period each day.', array(), NULL, 'boinc:account-preferences-computing') . '</div></div>'
474
-  ); 
475
-  $form['prefs']['advanced']['network']['daily_xfer_limit_mb'] = array(
474
+    ); 
475
+    $form['prefs']['advanced']['network']['daily_xfer_limit_mb'] = array(
476 476
     '#title' => bts('Limit usage to', array(), NULL, 'boinc:account-preferences-computing'),
477 477
     '#type' => 'textfield',
478 478
     '#field_suffix' => 'Mbytes',
479 479
     '#default_value' => $default['daily_xfer_limit_mb'],
480 480
     '#size' => 1
481
-  ); 
482
-  $form['prefs']['advanced']['network']['daily_xfer_period_days'] = array(
481
+    ); 
482
+    $form['prefs']['advanced']['network']['daily_xfer_period_days'] = array(
483 483
     '#field_prefix' => 'every',
484 484
     '#type' => 'textfield',
485 485
     '#field_suffix' => bts('days', array(), NULL, 'boinc:unit-of-time'),
486 486
     '#default_value' => $default['daily_xfer_period_days'],
487 487
     '#size' => 1,
488 488
     '#description' => bts('Example: BOINC should transfer at most 2000 MB of data every 30 days.', array(), NULL, 'boinc:account-preferences-computing'),
489
-  ); 
490
-  $form['prefs']['advanced']['network']['dont_verify_images'] = array(
489
+    ); 
490
+    $form['prefs']['advanced']['network']['dont_verify_images'] = array(
491 491
     '#title' => bts('Skip data verification for image files?', array(), NULL, 'boinc:account-preferences-computing'),
492 492
     '#type' => 'radios',
493 493
     '#options' => $form['boolean_options']['#value'],
494 494
     '#attributes' => array('class' => 'fancy'),
495 495
     '#default_value' => $default['dont_verify_images'],
496 496
     '#description' => bts('Only select "Yes" if your Internet provider modifies image files. Skipping verification reduces the security of BOINC.', array(), NULL, 'boinc:account-preferences-computing')
497
-  );
497
+    );
498 498
   
499
-  // The "fancy radios" are made via javascript on document load. In order for
500
-  // these to work with AHAH, we need this crazy setTimeout() call.
501
-  $form['prefs']['fancy-radios'] = array(
499
+    // The "fancy radios" are made via javascript on document load. In order for
500
+    // these to work with AHAH, we need this crazy setTimeout() call.
501
+    $form['prefs']['fancy-radios'] = array(
502 502
     '#value' => '
503 503
       <script>
504 504
         setTimeout(
@@ -509,177 +509,177 @@  discard block
 block discarded – undo
509 509
           300
510 510
         )
511 511
       </script>'
512
-  );
513
-  $form['prefs']['view advanced'] = array(
512
+    );
513
+    $form['prefs']['view advanced'] = array(
514 514
     '#type' => 'hidden',
515 515
     '#value' => 1
516
-  );
516
+    );
517 517
   
518
-  $form['prefs']['separator_bottom'] = array(
518
+    $form['prefs']['separator_bottom'] = array(
519 519
     '#value' => '<div class="separator buttons"></div>'
520
-  );
520
+    );
521 521
   
522
-  // Form control
523
-  $form['prefs']['form control tabs prefix'] = array(
522
+    // Form control
523
+    $form['prefs']['form control tabs prefix'] = array(
524 524
     '#value' => '<ul class="form-control tab-list">'
525
-  );
526
-  $form['prefs']['submit'] = array(
525
+    );
526
+    $form['prefs']['submit'] = array(
527 527
     '#prefix' => '<li class="first tab">',
528 528
     '#type' => 'submit',
529 529
     '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'),
530 530
     '#suffix' => '</li>'
531
-  );
532
-  $form['prefs']['form control tabs'] = array(
531
+    );
532
+    $form['prefs']['form control tabs'] = array(
533 533
     '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), drupal_get_path_alias("account/prefs/computing/edit")) . '</li>'
534
-  );
535
-  if ($venue AND $venue != 'generic') {
534
+    );
535
+    if ($venue AND $venue != 'generic') {
536 536
     global $base_path;
537 537
     $form['prefs']['form control tabs']['#value'] .= '<li class="tab">' . 
538
-      l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/computing/clear/{$venue}",
538
+        l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/computing/clear/{$venue}",
539 539
         array(
540
-          'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/computing/combined')),
541
-          'attributes' => array(
540
+            'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/computing/combined')),
541
+            'attributes' => array(
542 542
             'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the @name preference set. Are you sure?',
543
-              array('@name' => $venue), NULL, 'boinc:account-preferences') . '\')'
544
-          )
543
+                array('@name' => $venue), NULL, 'boinc:account-preferences') . '\')'
544
+            )
545 545
         )
546
-      ) . '</li>';
547
-  }
548
-  $form['prefs']['view control'] = array(
546
+        ) . '</li>';
547
+    }
548
+    $form['prefs']['view control'] = array(
549 549
     '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/computing/combined') . '</li>'
550
-  );
551
-  $form['prefs']['form control tabs suffix'] = array(
550
+    );
551
+    $form['prefs']['form control tabs suffix'] = array(
552 552
     '#value' => '</ul>'
553
-  );
554
-  $form['#submit'][] = 'boincwork_generalprefs_form_submit';
553
+    );
554
+    $form['#submit'][] = 'boincwork_generalprefs_form_submit';
555 555
   
556
-  return $form;
556
+    return $form;
557 557
 }
558 558
 
559 559
 /**
560
-  * Validate the general preferences form.
561
-  */
560
+ * Validate the general preferences form.
561
+ */
562 562
 function boincwork_generalprefs_form_validate($form, &$form_state) {
563
-  require_boinc('util');
564
-  $values = $form_state['values']['prefs']['advanced'];
565
-  
566
-  //drupal_set_message('<pre>' . print_r($form_state['values'], true) . '</pre>');
567
-  // Verify all non-boolean user input values and notify form API of failures
568
-  
569
-  // Processing preferences
570
-  if (!verify_numeric($values['processor']['idle_time_to_run'], 1, 9999)) form_set_error('idle_time_to_run', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['idle_time_to_run']['#title']} [x] {$form['prefs']['advanced']['processor']['idle_time_to_run']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
571
-  if (!verify_numeric($values['processor']['suspend_if_no_recent_input'], 0, 9999)) form_set_error('suspend_if_no_recent_input', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['suspend_if_no_recent_input']['#title']} [x] {$form['prefs']['advanced']['processor']['suspend_if_no_recent_input']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
572
-  if (!verify_numeric($values['processor']['suspend_cpu_usage'], 0, 100)) form_set_error('suspend_cpu_usage', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['suspend_cpu_usage']['#title']} [x] {$form['prefs']['advanced']['processor']['suspend_cpu_usage']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
573
-  if (!verify_numeric($values['processor']['start_hour'], 0, 23)) form_set_error('start_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['start_hour']['#title']} [x] {$form['prefs']['advanced']['processor']['start_hour']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
574
-  if (!verify_numeric($values['processor']['end_hour'], 0, 23)) form_set_error('end_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['end_hour']['#title']} [x] {$form['prefs']['advanced']['processor']['end_hour']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
575
-  if (!verify_numeric($values['processor']['cpu_scheduling_period_minutes'], 1, 9999)) form_set_error('cpu_scheduling_period_minutes', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes']['#title']} [x] {$form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
576
-  if (!verify_numeric($values['processor']['max_ncpus_pct'], 0, 100)) form_set_error('max_ncpus_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['max_ncpus_pct']['#title']} [x] {$form['prefs']['advanced']['processor']['max_ncpus_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
577
-  if (!verify_numeric($values['processor']['cpu_usage_limit'], 0, 100)) form_set_error('cpu_usage_limit', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['cpu_usage_limit']['#title']} [x] {$form['prefs']['advanced']['processor']['cpu_usage_limit']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
578
-
579
-  // Storage preferences
580
-  if (!verify_numeric($values['storage']['disk_max_used_gb'], 0, 9999999)) form_set_error('disk_max_used_gb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_max_used_gb']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_max_used_gb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
581
-  if (!verify_numeric($values['storage']['disk_min_free_gb'], 0.001, 9999999)) form_set_error('disk_min_free_gb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_min_free_gb']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_min_free_gb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
582
-  if (!verify_numeric($values['storage']['disk_max_used_pct'], 0, 100)) form_set_error('disk_max_used_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_max_used_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_max_used_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
583
-  if (!verify_numeric($values['storage']['disk_interval'], 0, 9999999)) form_set_error('disk_interval', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_interval']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_interval']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
584
-  if (!verify_numeric($values['storage']['vm_max_used_pct'], 0, 100)) form_set_error('vm_max_used_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['vm_max_used_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['vm_max_used_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
585
-  if (!verify_numeric($values['storage']['ram_max_used_busy_pct'], 0, 100)) form_set_error('ram_max_used_busy_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['ram_max_used_busy_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['ram_max_used_busy_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
586
-  if (!verify_numeric($values['storage']['ram_max_used_idle_pct'], 0, 100)) form_set_error('ram_max_used_idle_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['ram_max_used_idle_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['ram_max_used_idle_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
587
-
588
-  // Network preferences
589
-  if (!verify_numeric($values['network']['work_buf_min_days'], 0, 10)) form_set_error('work_buf_min_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['work_buf_min_days']['#title']} [x] {$form['prefs']['advanced']['network']['work_buf_min_days']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
590
-  if (!verify_numeric($values['network']['work_buf_additional_days'], 0, 10)) form_set_error('work_buf_additional_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['work_buf_additional_days']['#title']} [x] {$form['prefs']['advanced']['network']['work_buf_additional_days']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
591
-  if (!verify_numeric($values['network']['max_bytes_sec_down'], 0, 9999.999)) form_set_error('max_bytes_sec_down', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['max_bytes_sec_down']['#title']} [x] {$form['prefs']['advanced']['network']['max_bytes_sec_down']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
592
-  if (!verify_numeric($values['network']['max_bytes_sec_up'], 0, 9999.999)) form_set_error('max_bytes_sec_up', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['max_bytes_sec_up']['#title']} [x] {$form['prefs']['advanced']['network']['max_bytes_sec_up']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
593
-  if (!verify_numeric($values['network']['net_start_hour'], 0, 23)) form_set_error('net_start_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['net_start_hour']['#title']} [x] {$form['prefs']['advanced']['network']['net_start_hour']['#field_suffix']}"), NULL, 'boinc:account-prefrences-computing'));
594
-  if (!verify_numeric($values['network']['net_end_hour'], 0, 23)) form_set_error('net_end_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['net_end_hour']['#title']} [x] {$form['prefs']['advanced']['network']['net_end_hour']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
595
-  if (!verify_numeric($values['network']['daily_xfer_limit_mb'], 0, 9999999)) form_set_error('daily_xfer_limit_mb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#title']} [x] {$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
596
-  if (!verify_numeric($values['network']['daily_xfer_period_days'], 0, 9999999)) form_set_error('daily_xfer_period_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#title']} [x] {$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
563
+    require_boinc('util');
564
+    $values = $form_state['values']['prefs']['advanced'];
565
+  
566
+    //drupal_set_message('<pre>' . print_r($form_state['values'], true) . '</pre>');
567
+    // Verify all non-boolean user input values and notify form API of failures
568
+  
569
+    // Processing preferences
570
+    if (!verify_numeric($values['processor']['idle_time_to_run'], 1, 9999)) form_set_error('idle_time_to_run', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['idle_time_to_run']['#title']} [x] {$form['prefs']['advanced']['processor']['idle_time_to_run']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
571
+    if (!verify_numeric($values['processor']['suspend_if_no_recent_input'], 0, 9999)) form_set_error('suspend_if_no_recent_input', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['suspend_if_no_recent_input']['#title']} [x] {$form['prefs']['advanced']['processor']['suspend_if_no_recent_input']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
572
+    if (!verify_numeric($values['processor']['suspend_cpu_usage'], 0, 100)) form_set_error('suspend_cpu_usage', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['suspend_cpu_usage']['#title']} [x] {$form['prefs']['advanced']['processor']['suspend_cpu_usage']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
573
+    if (!verify_numeric($values['processor']['start_hour'], 0, 23)) form_set_error('start_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['start_hour']['#title']} [x] {$form['prefs']['advanced']['processor']['start_hour']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
574
+    if (!verify_numeric($values['processor']['end_hour'], 0, 23)) form_set_error('end_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['end_hour']['#title']} [x] {$form['prefs']['advanced']['processor']['end_hour']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
575
+    if (!verify_numeric($values['processor']['cpu_scheduling_period_minutes'], 1, 9999)) form_set_error('cpu_scheduling_period_minutes', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes']['#title']} [x] {$form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
576
+    if (!verify_numeric($values['processor']['max_ncpus_pct'], 0, 100)) form_set_error('max_ncpus_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['max_ncpus_pct']['#title']} [x] {$form['prefs']['advanced']['processor']['max_ncpus_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
577
+    if (!verify_numeric($values['processor']['cpu_usage_limit'], 0, 100)) form_set_error('cpu_usage_limit', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['cpu_usage_limit']['#title']} [x] {$form['prefs']['advanced']['processor']['cpu_usage_limit']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
578
+
579
+    // Storage preferences
580
+    if (!verify_numeric($values['storage']['disk_max_used_gb'], 0, 9999999)) form_set_error('disk_max_used_gb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_max_used_gb']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_max_used_gb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
581
+    if (!verify_numeric($values['storage']['disk_min_free_gb'], 0.001, 9999999)) form_set_error('disk_min_free_gb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_min_free_gb']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_min_free_gb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
582
+    if (!verify_numeric($values['storage']['disk_max_used_pct'], 0, 100)) form_set_error('disk_max_used_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_max_used_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_max_used_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
583
+    if (!verify_numeric($values['storage']['disk_interval'], 0, 9999999)) form_set_error('disk_interval', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_interval']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_interval']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
584
+    if (!verify_numeric($values['storage']['vm_max_used_pct'], 0, 100)) form_set_error('vm_max_used_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['vm_max_used_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['vm_max_used_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
585
+    if (!verify_numeric($values['storage']['ram_max_used_busy_pct'], 0, 100)) form_set_error('ram_max_used_busy_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['ram_max_used_busy_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['ram_max_used_busy_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
586
+    if (!verify_numeric($values['storage']['ram_max_used_idle_pct'], 0, 100)) form_set_error('ram_max_used_idle_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['ram_max_used_idle_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['ram_max_used_idle_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
587
+
588
+    // Network preferences
589
+    if (!verify_numeric($values['network']['work_buf_min_days'], 0, 10)) form_set_error('work_buf_min_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['work_buf_min_days']['#title']} [x] {$form['prefs']['advanced']['network']['work_buf_min_days']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
590
+    if (!verify_numeric($values['network']['work_buf_additional_days'], 0, 10)) form_set_error('work_buf_additional_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['work_buf_additional_days']['#title']} [x] {$form['prefs']['advanced']['network']['work_buf_additional_days']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
591
+    if (!verify_numeric($values['network']['max_bytes_sec_down'], 0, 9999.999)) form_set_error('max_bytes_sec_down', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['max_bytes_sec_down']['#title']} [x] {$form['prefs']['advanced']['network']['max_bytes_sec_down']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
592
+    if (!verify_numeric($values['network']['max_bytes_sec_up'], 0, 9999.999)) form_set_error('max_bytes_sec_up', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['max_bytes_sec_up']['#title']} [x] {$form['prefs']['advanced']['network']['max_bytes_sec_up']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
593
+    if (!verify_numeric($values['network']['net_start_hour'], 0, 23)) form_set_error('net_start_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['net_start_hour']['#title']} [x] {$form['prefs']['advanced']['network']['net_start_hour']['#field_suffix']}"), NULL, 'boinc:account-prefrences-computing'));
594
+    if (!verify_numeric($values['network']['net_end_hour'], 0, 23)) form_set_error('net_end_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['net_end_hour']['#title']} [x] {$form['prefs']['advanced']['network']['net_end_hour']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
595
+    if (!verify_numeric($values['network']['daily_xfer_limit_mb'], 0, 9999999)) form_set_error('daily_xfer_limit_mb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#title']} [x] {$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
596
+    if (!verify_numeric($values['network']['daily_xfer_period_days'], 0, 9999999)) form_set_error('daily_xfer_period_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#title']} [x] {$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
597 597
 }
598 598
 
599 599
 /**
600
-  * Handle post-validation submission of general preferences form.
601
-  */
600
+ * Handle post-validation submission of general preferences form.
601
+ */
602 602
 function boincwork_generalprefs_form_submit($form, &$form_state) {
603
-  global $user;
604
-  $account = user_load($user->uid);
605
-  
606
-  $values = $form_state['values']['prefs']['advanced'];
607
-  $venue = $form_state['values']['prefs']['venue'];
608
-  $preset = $form_state['values']['prefs']['preset'];
609
-  
610
-  // Load preferences from BOINC account
611
-  $prefs = boincwork_load_prefs('general', $venue);
612
-  
613
-  // Processing preferences
614
-  $prefs['run_on_batteries'] = ($values['processor']['run_on_batteries']) ? 0 : 1;
615
-  $prefs['run_if_user_active'] = ($values['processor']['run_if_user_active']) ? 0 : 1;
616
-  $prefs['run_gpu_if_user_active'] = ($values['processor']['run_gpu_if_user_active']) ? 0 : 1;
617
-  $prefs['idle_time_to_run'] = $values['processor']['idle_time_to_run'];
618
-  $prefs['suspend_if_no_recent_input'] = $values['processor']['suspend_if_no_recent_input'];
619
-  $prefs['suspend_cpu_usage'] = $values['processor']['suspend_cpu_usage'];
620
-  $prefs['start_hour'] = $values['processor']['start_hour'];
621
-  $prefs['end_hour'] = $values['processor']['end_hour'];
622
-  $prefs['leave_apps_in_memory'] = ($values['processor']['leave_apps_in_memory']) ? 1 : 0;
623
-  $prefs['cpu_scheduling_period_minutes'] = $values['processor']['cpu_scheduling_period_minutes'];
624
-  $prefs['max_ncpus_pct'] = $values['processor']['max_ncpus_pct'];
625
-  $prefs['cpu_usage_limit'] = $values['processor']['cpu_usage_limit'];
626
-  
627
-  // Storage preferences
628
-  $prefs['disk_max_used_gb'] = $values['storage']['disk_max_used_gb'];
629
-  $prefs['disk_min_free_gb'] = $values['storage']['disk_min_free_gb'];
630
-  $prefs['disk_max_used_pct'] = $values['storage']['disk_max_used_pct'];
631
-  $prefs['disk_interval'] = $values['storage']['disk_interval'];
632
-  $prefs['vm_max_used_pct'] = $values['storage']['vm_max_used_pct'];
633
-  $prefs['ram_max_used_busy_pct'] = $values['storage']['ram_max_used_busy_pct'];
634
-  $prefs['ram_max_used_idle_pct'] = $values['storage']['ram_max_used_idle_pct'];
635
-  
636
-  // Network preferences
637
-  $prefs['work_buf_min_days'] = $values['network']['work_buf_min_days'];
638
-  $prefs['work_buf_additional_days'] = $values['network']['work_buf_additional_days'];
639
-  $prefs['confirm_before_connecting'] = ($values['network']['confirm_before_connecting']) ? 1 : 0;
640
-  $prefs['hangup_if_dialed'] = ($values['network']['hangup_if_dialed']) ? 1 : 0;
641
-  $prefs['max_bytes_sec_down'] = $values['network']['max_bytes_sec_down']*1000;
642
-  $prefs['max_bytes_sec_up'] = $values['network']['max_bytes_sec_up']*1000;
643
-  $prefs['net_start_hour'] = $values['network']['net_start_hour'];
644
-  $prefs['net_end_hour'] = $values['network']['net_end_hour'];
645
-  $prefs['daily_xfer_limit_mb'] = $values['network']['daily_xfer_limit_mb'];
646
-  $prefs['daily_xfer_period_days'] = $values['network']['daily_xfer_period_days'];
647
-  $prefs['dont_verify_images'] = ($values['network']['dont_verify_images']) ? 1 : 0;
648
-
649
-  // transform old way to store the preset into new way
650
-  // ideally this should already have happened in boincwork_generalprefs_form()
651
-  if (isset($prefs['@attributes']['preset'])) {
603
+    global $user;
604
+    $account = user_load($user->uid);
605
+  
606
+    $values = $form_state['values']['prefs']['advanced'];
607
+    $venue = $form_state['values']['prefs']['venue'];
608
+    $preset = $form_state['values']['prefs']['preset'];
609
+  
610
+    // Load preferences from BOINC account
611
+    $prefs = boincwork_load_prefs('general', $venue);
612
+  
613
+    // Processing preferences
614
+    $prefs['run_on_batteries'] = ($values['processor']['run_on_batteries']) ? 0 : 1;
615
+    $prefs['run_if_user_active'] = ($values['processor']['run_if_user_active']) ? 0 : 1;
616
+    $prefs['run_gpu_if_user_active'] = ($values['processor']['run_gpu_if_user_active']) ? 0 : 1;
617
+    $prefs['idle_time_to_run'] = $values['processor']['idle_time_to_run'];
618
+    $prefs['suspend_if_no_recent_input'] = $values['processor']['suspend_if_no_recent_input'];
619
+    $prefs['suspend_cpu_usage'] = $values['processor']['suspend_cpu_usage'];
620
+    $prefs['start_hour'] = $values['processor']['start_hour'];
621
+    $prefs['end_hour'] = $values['processor']['end_hour'];
622
+    $prefs['leave_apps_in_memory'] = ($values['processor']['leave_apps_in_memory']) ? 1 : 0;
623
+    $prefs['cpu_scheduling_period_minutes'] = $values['processor']['cpu_scheduling_period_minutes'];
624
+    $prefs['max_ncpus_pct'] = $values['processor']['max_ncpus_pct'];
625
+    $prefs['cpu_usage_limit'] = $values['processor']['cpu_usage_limit'];
626
+  
627
+    // Storage preferences
628
+    $prefs['disk_max_used_gb'] = $values['storage']['disk_max_used_gb'];
629
+    $prefs['disk_min_free_gb'] = $values['storage']['disk_min_free_gb'];
630
+    $prefs['disk_max_used_pct'] = $values['storage']['disk_max_used_pct'];
631
+    $prefs['disk_interval'] = $values['storage']['disk_interval'];
632
+    $prefs['vm_max_used_pct'] = $values['storage']['vm_max_used_pct'];
633
+    $prefs['ram_max_used_busy_pct'] = $values['storage']['ram_max_used_busy_pct'];
634
+    $prefs['ram_max_used_idle_pct'] = $values['storage']['ram_max_used_idle_pct'];
635
+  
636
+    // Network preferences
637
+    $prefs['work_buf_min_days'] = $values['network']['work_buf_min_days'];
638
+    $prefs['work_buf_additional_days'] = $values['network']['work_buf_additional_days'];
639
+    $prefs['confirm_before_connecting'] = ($values['network']['confirm_before_connecting']) ? 1 : 0;
640
+    $prefs['hangup_if_dialed'] = ($values['network']['hangup_if_dialed']) ? 1 : 0;
641
+    $prefs['max_bytes_sec_down'] = $values['network']['max_bytes_sec_down']*1000;
642
+    $prefs['max_bytes_sec_up'] = $values['network']['max_bytes_sec_up']*1000;
643
+    $prefs['net_start_hour'] = $values['network']['net_start_hour'];
644
+    $prefs['net_end_hour'] = $values['network']['net_end_hour'];
645
+    $prefs['daily_xfer_limit_mb'] = $values['network']['daily_xfer_limit_mb'];
646
+    $prefs['daily_xfer_period_days'] = $values['network']['daily_xfer_period_days'];
647
+    $prefs['dont_verify_images'] = ($values['network']['dont_verify_images']) ? 1 : 0;
648
+
649
+    // transform old way to store the preset into new way
650
+    // ideally this should already have happened in boincwork_generalprefs_form()
651
+    if (isset($prefs['@attributes']['preset'])) {
652 652
     $prefs['preset'] = $prefs['@attributes']['preset'];
653 653
     unset($prefs['@attributes']['preset']);
654
-  }
655
-  // Save the preset selection (or lack thereof)
656
-  if (!$preset OR $preset == 'custom') {
654
+    }
655
+    // Save the preset selection (or lack thereof)
656
+    if (!$preset OR $preset == 'custom') {
657 657
     $prefs['preset'] = 'custom';
658
-  }
659
-  else {
658
+    }
659
+    else {
660 660
     $prefs['preset'] = $preset;
661
-  }
661
+    }
662 662
   
663
-  // If this is a new preference set, be sure to unset the "cleared" attribute
664
-  if (isset($prefs['@attributes']['cleared'])) {
663
+    // If this is a new preference set, be sure to unset the "cleared" attribute
664
+    if (isset($prefs['@attributes']['cleared'])) {
665 665
     unset($prefs['@attributes']['cleared']);
666
-  }
666
+    }
667 667
   
668
-  // Update database
669
-  $result = boincwork_save_prefs($prefs, 'general', $venue);
668
+    // Update database
669
+    $result = boincwork_save_prefs($prefs, 'general', $venue);
670 670
   
671
-  if (!$result) {
671
+    if (!$result) {
672 672
     watchdog('boincwork', 'Error updating global prefs for user @id: @message', array('@id' => $account->id, '@message' => mysqli_error()), WATCHDOG_ERROR);
673 673
     drupal_set_message(t('Your changes could not be saved. Please contact support!'), 'error');
674
-  }
675
-  elseif (!drupal_get_messages('status', FALSE)) {
674
+    }
675
+    elseif (!drupal_get_messages('status', FALSE)) {
676 676
     // Show this message if the set wasn't created automatically (in which case
677 677
     // there is a message tailored to that) {
678 678
     drupal_set_message(t('Your preferences have been updated.
679 679
       Client-related preferences will take effect when your computer 
680 680
       communicates with @project or you issue the "Update"
681 681
       command from the BOINC client.', array('@project' => PROJECT)));
682
-  }
682
+    }
683 683
 }
684 684
 
685 685
 
@@ -691,88 +691,88 @@  discard block
 block discarded – undo
691 691
  * Find compatible hosts for merging
692 692
  */
693 693
 function boincwork_host_get_compatible_hosts($host_id) {
694
-  require_boinc('host');
695
-  global $user;
696
-  $account = user_load($user->uid);
697
-  $compatible_hosts = array();
698
-  $host_count = 0;
699
-  db_set_active('boinc_ro');
700
-  $current_host = db_fetch_object(db_query("
694
+    require_boinc('host');
695
+    global $user;
696
+    $account = user_load($user->uid);
697
+    $compatible_hosts = array();
698
+    $host_count = 0;
699
+    db_set_active('boinc_ro');
700
+    $current_host = db_fetch_object(db_query("
701 701
     SELECT id, domain_name, create_time, total_credit, rpc_time, os_name,
702 702
       p_vendor, p_model
703 703
     FROM {host}
704 704
     WHERE userid = '%d' AND id = '%d'",
705 705
     $account->boincuser_id, $host_id
706
-  ));
707
-  db_set_active('default');
708
-  $current_host->task_count = boincwork_host_get_task_count($current_host->id);
709
-  $current_host->is_new = !$current_host->total_credit AND !$current_host->task_count;
710
-  // Get the list of all other hosts owned by this user for comparison
711
-  db_set_active('boinc_ro');
712
-  $all_other_hosts = db_query("
706
+    ));
707
+    db_set_active('default');
708
+    $current_host->task_count = boincwork_host_get_task_count($current_host->id);
709
+    $current_host->is_new = !$current_host->total_credit AND !$current_host->task_count;
710
+    // Get the list of all other hosts owned by this user for comparison
711
+    db_set_active('boinc_ro');
712
+    $all_other_hosts = db_query("
713 713
     SELECT id, domain_name, create_time, total_credit, rpc_time, os_name,
714 714
       p_vendor, p_model
715 715
     FROM {host}
716 716
     WHERE userid = '%d' AND id <> '%d'",
717 717
     $account->boincuser_id, $host_id
718
-  );
719
-  db_set_active('default');
720
-  // Compare all hosts to see if any are plausible duplicates
721
-  while ($other_host = db_fetch_object($all_other_hosts)) {
718
+    );
719
+    db_set_active('default');
720
+    // Compare all hosts to see if any are plausible duplicates
721
+    while ($other_host = db_fetch_object($all_other_hosts)) {
722 722
     // First, disqualify if hosts were active at the same time
723 723
     if (!$current_host->is_new) {
724
-      $other_host->task_count = boincwork_host_get_task_count($other_host->id);
725
-      $other_host->is_new = !$other_host->total_credit AND !$other_host->task_count;
726
-      if (!$other_host->is_new) {
724
+        $other_host->task_count = boincwork_host_get_task_count($other_host->id);
725
+        $other_host->is_new = !$other_host->total_credit AND !$other_host->task_count;
726
+        if (!$other_host->is_new) {
727 727
         // If both hosts being compared are not new, see if times overlap
728 728
         if (!times_disjoint($current_host, $other_host)) {
729
-          // Hosts were active at the same time; can't be a duplicate
730
-          continue;
729
+            // Hosts were active at the same time; can't be a duplicate
730
+            continue;
731
+        }
731 732
         }
732
-      }
733 733
     }
734 734
     // Next, disqualify if hosts have different OS platforms
735 735
     if (!os_compatible($current_host, $other_host)) {
736
-      // Hosts have different OS platforms; not really a duplicate
737
-      continue;
736
+        // Hosts have different OS platforms; not really a duplicate
737
+        continue;
738 738
     }
739 739
     // Finally, disqualify if hosts have different CPUs
740 740
     if (!cpus_compatible($current_host, $other_host)) {
741
-      // CPUs don't match; not a duplicate
742
-      continue;
741
+        // CPUs don't match; not a duplicate
742
+        continue;
743 743
     }
744 744
     // If not disqualified, this host is available for merging
745 745
     $hosts[] = $other_host;
746 746
     $host_count++;
747 747
     if ($host_count == 500) {
748
-      // This is enough!
749
-      break;
748
+        // This is enough!
749
+        break;
750 750
     }
751
-  }
752
-  return $hosts;
751
+    }
752
+    return $hosts;
753 753
 }
754 754
 
755 755
 /**
756 756
  * Perform the database updates to merge the old host into the new host
757 757
  */
758 758
 function boincwork_host_merge($old_host, $new_host, &$message = NULL) {
759
-  // Decay the average credit of the two hosts
760
-  require_boinc('credit');
761
-  $now = time();
762
-  update_average($now, 0, 0, $old_host->expavg_credit, $old_host->expavg_time);
763
-  update_average($now, 0, 0, $new_host->expavg_credit, $new_host->expavg_time);
764
-  
765
-  // Update the database:
766
-  // - add credit from old host to new host
767
-  // - change results to refer to the new host
768
-  // - put old host in "zombie" state (userid=0, rpc_seqno=[new_host_id])
769
-  
770
-  $total_credit = $old_host->total_credit + $new_host->total_credit;
771
-  $recent_credit = $old_host->expavg_credit + $new_host->expavg_credit;
772
-  
773
-  // Move credit from the old host to the new host
774
-  db_set_active('boinc_rw');
775
-  $credit_updated = db_query("
759
+    // Decay the average credit of the two hosts
760
+    require_boinc('credit');
761
+    $now = time();
762
+    update_average($now, 0, 0, $old_host->expavg_credit, $old_host->expavg_time);
763
+    update_average($now, 0, 0, $new_host->expavg_credit, $new_host->expavg_time);
764
+  
765
+    // Update the database:
766
+    // - add credit from old host to new host
767
+    // - change results to refer to the new host
768
+    // - put old host in "zombie" state (userid=0, rpc_seqno=[new_host_id])
769
+  
770
+    $total_credit = $old_host->total_credit + $new_host->total_credit;
771
+    $recent_credit = $old_host->expavg_credit + $new_host->expavg_credit;
772
+  
773
+    // Move credit from the old host to the new host
774
+    db_set_active('boinc_rw');
775
+    $credit_updated = db_query("
776 776
     UPDATE {host}
777 777
     SET
778 778
       total_credit = '%d',
@@ -780,34 +780,34 @@  discard block
 block discarded – undo
780 780
       expavg_time = '%d'
781 781
     WHERE id = '%d'",
782 782
     $total_credit, $recent_credit, $now, $new_host->id
783
-  );
784
-  db_set_active('default');
785
-  if (!$credit_updated) {
783
+    );
784
+    db_set_active('default');
785
+    if (!$credit_updated) {
786 786
     if ($message !== NULL) {
787
-      $message = bts('Could not update credit', array(), NULL, 'boinc:account-host-merge');
787
+        $message = bts('Could not update credit', array(), NULL, 'boinc:account-host-merge');
788 788
     }
789 789
     return FALSE;
790
-  }
790
+    }
791 791
   
792
-  // Move results from the old host to the new host
793
-  db_set_active('boinc_rw');
794
-  $results_updated = db_query("
792
+    // Move results from the old host to the new host
793
+    db_set_active('boinc_rw');
794
+    $results_updated = db_query("
795 795
     UPDATE {result}
796 796
     SET hostid = '%d'
797 797
     WHERE hostid = '%d'",
798 798
     $new_host->id, $old_host->id
799
-  );
800
-  db_set_active('default');
801
-  if (!$results_updated) {
799
+    );
800
+    db_set_active('default');
801
+    if (!$results_updated) {
802 802
     if ($message !== NULL) {
803
-      $message = bts('Could not update results', array(), NULL, 'boinc:account-host-merge');
803
+        $message = bts('Could not update results', array(), NULL, 'boinc:account-host-merge');
804 804
     }
805 805
     return FALSE;
806
-  }
806
+    }
807 807
   
808
-  // Retire the old host
809
-  db_set_active('boinc_rw');
810
-  $old_host_retired = db_query("
808
+    // Retire the old host
809
+    db_set_active('boinc_rw');
810
+    $old_host_retired = db_query("
811 811
     UPDATE {host}
812 812
     SET
813 813
       total_credit = '0',
@@ -816,16 +816,16 @@  discard block
 block discarded – undo
816 816
       rpc_seqno = '%d'
817 817
     WHERE id = '%d'",
818 818
     $new_host->id, $old_host->id
819
-  );
820
-  db_set_active('default');
821
-  if (!$old_host_retired) {
819
+    );
820
+    db_set_active('default');
821
+    if (!$old_host_retired) {
822 822
     if ($message !== NULL) {
823
-      $message = bts('Could not retire old computer', array(), NULL, 'boinc:account-host-merge');
823
+        $message = bts('Could not retire old computer', array(), NULL, 'boinc:account-host-merge');
824 824
     }
825 825
     return FALSE;
826
-  }
826
+    }
827 827
   
828
-  return TRUE;
828
+    return TRUE;
829 829
 }
830 830
 
831 831
 /**
@@ -833,75 +833,75 @@  discard block
 block discarded – undo
833 833
  */
834 834
 function boincwork_host_merge_form(&$form_state, $host_id) {
835 835
 
836
-  if (!boincwork_host_user_is_owner($host_id)) {
836
+    if (!boincwork_host_user_is_owner($host_id)) {
837 837
     drupal_goto("host/{$host_id}");
838
-  }
838
+    }
839 839
   
840
-  $form = array();
841
-  $form_state['storage']['current_host_id'] = $host_id;
842
-  $current_host = boincwork_host_get_info($host_id);
840
+    $form = array();
841
+    $form_state['storage']['current_host_id'] = $host_id;
842
+    $current_host = boincwork_host_get_info($host_id);
843 843
   
844
-  // Get hosts that could be merged with this one
845
-  $hosts = boincwork_host_get_compatible_hosts($host_id);
844
+    // Get hosts that could be merged with this one
845
+    $hosts = boincwork_host_get_compatible_hosts($host_id);
846 846
   
847
-  if (!$hosts) {
847
+    if (!$hosts) {
848 848
     drupal_set_message(t('There are no computers eligible for merging with this
849 849
       one'), 'warning'
850 850
     );
851 851
     drupal_goto("host/{$host_id}");
852
-  }
852
+    }
853 853
   
854
-  $form['overview'] = array(
854
+    $form['overview'] = array(
855 855
     '#value' => '<p>' . bts('Sometimes BOINC assigns separate identities to'
856
-      . ' the same computer by mistake. You can correct this by merging old'
857
-      . ' identities with the newest one.', array(), NULL, 'boinc:account-host-merge') . '</p>'
858
-      . '<p>'
859
-      . bts('Check the computers that are the same as @name'
860
-      . ' (created on @date at @time with computer ID @id)',
856
+        . ' the same computer by mistake. You can correct this by merging old'
857
+        . ' identities with the newest one.', array(), NULL, 'boinc:account-host-merge') . '</p>'
858
+        . '<p>'
859
+        . bts('Check the computers that are the same as @name'
860
+        . ' (created on @date at @time with computer ID @id)',
861 861
         array(
862
-          '@name' => $current_host->domain_name,
863
-          '@date' => date('j M Y', $current_host->create_time),
864
-          '@time' => date('G:i:s T', $current_host->create_time),
865
-          '@id' => $current_host->id,
862
+            '@name' => $current_host->domain_name,
863
+            '@date' => date('j M Y', $current_host->create_time),
864
+            '@time' => date('G:i:s T', $current_host->create_time),
865
+            '@id' => $current_host->id,
866 866
         ),
867 867
         NULL, 'boinc:account-host-merge') . '</p>',
868
-  );
868
+    );
869 869
   
870
-  $options = array();
871
-  foreach ($hosts as $host) {
870
+    $options = array();
871
+    foreach ($hosts as $host) {
872 872
     $options[$host->id] = array(
873
-      $host->domain_name,
874
-      date('j M Y G:i:s T', $host->create_time),
875
-      $host->id,
873
+        $host->domain_name,
874
+        date('j M Y G:i:s T', $host->create_time),
875
+        $host->id,
876 876
     );
877
-  }
877
+    }
878 878
   
879
-  $form['merge'] = array(
879
+    $form['merge'] = array(
880 880
     '#title' => '',
881 881
     '#type' => 'tableselect',
882 882
     '#header' => array(bts('Name', array(), NULL, 'boinc:details:-1:name-of-the-host-or-task-or-workunit-etc-being-viewed-ignoreoverwrite'), bts('Created', array(), NULL, 'boinc:host-details'), bts('Computer ID', array(), NULL, 'boinc:host-list')),
883 883
     '#options' => $options,
884
-  );
884
+    );
885 885
   
886
-  $form['prefs']['separator_bottom'] = array(
887
-  //  '#value' => '<div class="separator buttons"></div>'
888
-  );
886
+    $form['prefs']['separator_bottom'] = array(
887
+    //  '#value' => '<div class="separator buttons"></div>'
888
+    );
889 889
   
890
-  // Form control
891
-  $form['prefs']['form control tabs prefix'] = array(
890
+    // Form control
891
+    $form['prefs']['form control tabs prefix'] = array(
892 892
     '#value' => '<ul class="form-control tab-list">'
893
-  );
894
-  $form['prefs']['submit'] = array(
893
+    );
894
+    $form['prefs']['submit'] = array(
895 895
     '#prefix' => '<li class="first tab">',
896 896
     '#type' => 'submit',
897 897
     '#value' => bts('Merge', array(), NULL, 'boinc:form-merge'),
898 898
     '#suffix' => '</li>'
899
-  );
900
-  $form['prefs']['form control tabs'] = array(
899
+    );
900
+    $form['prefs']['form control tabs'] = array(
901 901
     '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "host/{$host_id}") . '</li>'
902
-  );
902
+    );
903 903
   
904
-  return $form;
904
+    return $form;
905 905
 }
906 906
 
907 907
 /**
@@ -914,76 +914,76 @@  discard block
 block discarded – undo
914 914
  * Handle submission of the merge host form
915 915
  */
916 916
 function boincwork_host_merge_form_submit($form, &$form_state) {
917
-  $merged = array();
918
-  $errors = array();
919
-  $current_host_id = $form_state['storage']['current_host_id'];
920
-  $current_host = boincwork_host_get_info($current_host_id);
921
-  $selected_hosts = array_filter($form_state['values']['merge']);
917
+    $merged = array();
918
+    $errors = array();
919
+    $current_host_id = $form_state['storage']['current_host_id'];
920
+    $current_host = boincwork_host_get_info($current_host_id);
921
+    $selected_hosts = array_filter($form_state['values']['merge']);
922 922
   
923
-  foreach ($selected_hosts as $host_id) {
923
+    foreach ($selected_hosts as $host_id) {
924 924
     // Attempt to merge each host, noting the results
925 925
     $message = '';
926 926
     $old_host = boincwork_host_get_info($host_id);
927 927
     if (boincwork_host_merge($old_host, $current_host, $message)) {
928
-      $merged[$old_host->id] = $old_host->id;
929
-      $current_host = boincwork_host_get_info($current_host_id);
928
+        $merged[$old_host->id] = $old_host->id;
929
+        $current_host = boincwork_host_get_info($current_host_id);
930 930
     }
931 931
     else {
932
-      $errors[$old_host->id] = $message;
932
+        $errors[$old_host->id] = $message;
933
+    }
933 934
     }
934
-  }
935 935
   
936
-  if ($merged) {
936
+    if ($merged) {
937 937
     // Generate a natural language list of IDs that were merged
938 938
     $oxford_comma = ',';
939 939
     $conjunction = bts('and', array(), NULL, 'boinc:account-preference');
940 940
     $list = array_keys($merged);
941 941
     $last = array_pop($list);
942 942
     if ($list) {
943
-      if (count($merged) == 2) {
943
+        if (count($merged) == 2) {
944 944
         $oxford_comma = '';
945
-      }
946
-      $list = implode(', ', $list) . $oxford_comma . ' ' . $conjunction . ' ' . $last;
945
+        }
946
+        $list = implode(', ', $list) . $oxford_comma . ' ' . $conjunction . ' ' . $last;
947 947
     }
948 948
     else {
949
-      $list = $last;
949
+        $list = $last;
950 950
     }
951 951
     if (count($merged) == 1) {
952
-      drupal_set_message(bts(
952
+        drupal_set_message(bts(
953 953
         'Computer @old_id has been merged successfully into @id.',
954 954
         array(
955
-          '@old_id' => $list,
956
-          '@id' => $current_host_id
955
+            '@old_id' => $list,
956
+            '@id' => $current_host_id
957 957
         ),
958 958
         NULL, 'boinc:account-host-merge'));
959 959
     }
960 960
     else {
961
-      drupal_set_message(bts(
961
+        drupal_set_message(bts(
962 962
         'Computers @old_ids have been merged successfully into @id.',
963 963
         array(
964
-          '@old_ids' => $list,
965
-          '@id' => $current_host_id
964
+            '@old_ids' => $list,
965
+            '@id' => $current_host_id
966 966
         ),
967 967
         NULL, 'boinc:account-host-merge'));
968 968
     }
969
-  }
969
+    }
970 970
   
971
-  if ($errors) {
971
+    if ($errors) {
972 972
     // Report any hosts that failed to merge
973 973
     foreach ($errors as $id => $error) {
974
-      drupal_set_message(
974
+        drupal_set_message(
975 975
         bts('Computer @old_id failed to merge: @message',
976
-          array(
976
+            array(
977 977
             '@old_id' => $id,
978 978
             '@message' => $error,
979
-          ),
980
-          NULL, 'boinc:account-host-merge'),
979
+            ),
980
+            NULL, 'boinc:account-host-merge'),
981 981
         'warning'
982
-      );
982
+        );
983
+    }
983 984
     }
984
-  }
985 985
   
986
-  drupal_goto("host/{$current_host_id}");
986
+    drupal_goto("host/{$current_host_id}");
987 987
 }
988 988
 
989 989
 /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
@@ -995,44 +995,44 @@  discard block
 block discarded – undo
995 995
  */
996 996
 function boincwork_projectprefs_form(&$form_state, $venue) {
997 997
   
998
-  global $user;
999
-  $account = user_load($user->uid);
998
+    global $user;
999
+    $account = user_load($user->uid);
1000 1000
   
1001
-  $established = TRUE;
1001
+    $established = TRUE;
1002 1002
   
1003
-  // Get availability of special BOINC preferences
1004
-  require_boinc(array('util'));
1005
-  $app_types = get_app_types();
1003
+    // Get availability of special BOINC preferences
1004
+    require_boinc(array('util'));
1005
+    $app_types = get_app_types();
1006 1006
   
1007
-  // Load any existing preferences from BOINC account
1008
-  $prefs = boincwork_load_prefs('project', $venue);
1007
+    // Load any existing preferences from BOINC account
1008
+    $prefs = boincwork_load_prefs('project', $venue);
1009 1009
   
1010
-  // Take note if this is not an established preference set on the account
1011
-  if (isset($prefs['@attributes']['cleared'])) {
1010
+    // Take note if this is not an established preference set on the account
1011
+    if (isset($prefs['@attributes']['cleared'])) {
1012 1012
     $established = FALSE;
1013
-  }
1013
+    }
1014 1014
 
1015
-  // Extract modified tag if present
1016
-  $modified = NULL;
1017
-  if (isset($prefs['modified']['@value'])) {
1015
+    // Extract modified tag if present
1016
+    $modified = NULL;
1017
+    if (isset($prefs['modified']['@value'])) {
1018 1018
     $modified = $prefs['modified']['@value'];
1019
-  }
1019
+    }
1020 1020
 
1021
-  $venue_is_default = FALSE;
1022
-  if ($account->boincuser_default_pref_set) {
1021
+    $venue_is_default = FALSE;
1022
+    if ($account->boincuser_default_pref_set) {
1023 1023
     if ($account->boincuser_default_pref_set == $venue) {
1024
-      $venue_is_default = TRUE;
1024
+        $venue_is_default = TRUE;
1025 1025
     }
1026
-  }
1027
-  elseif (!$venue OR $venue == 'generic') {
1026
+    }
1027
+    elseif (!$venue OR $venue == 'generic') {
1028 1028
     $venue_is_default = TRUE;
1029
-  }
1030
-  else {
1029
+    }
1030
+    else {
1031 1031
     $venue_is_default = FALSE;
1032
-  }
1032
+    }
1033 1033
   
1034
-  // Define form defaults
1035
-  $default = array(
1034
+    // Define form defaults
1035
+    $default = array(
1036 1036
     'resource_share' => 100,
1037 1037
     'no_cpu' => 0,
1038 1038
     'no_cuda' => 0,
@@ -1040,333 +1040,333 @@  discard block
 block discarded – undo
1040 1040
     'no_intel_gpu' => 0,
1041 1041
     'default_venue' => $venue_is_default,
1042 1042
     'allow_beta_work' => $prefs['allow_beta_work'],
1043
-  );
1044
-  foreach ($default as $name => $value) {
1043
+    );
1044
+    foreach ($default as $name => $value) {
1045 1045
     if (isset($prefs[$name])) {
1046
-      if (is_array($prefs[$name])) {
1046
+        if (is_array($prefs[$name])) {
1047 1047
         if (isset($prefs[$name]['@value'])) {
1048
-          $default[$name] = $prefs[$name]['@value'];
1048
+            $default[$name] = $prefs[$name]['@value'];
1049 1049
         }
1050
-      }
1051
-      else {
1050
+        }
1051
+        else {
1052 1052
         $default[$name] = $prefs[$name];
1053
-      }
1053
+        }
1054
+    }
1054 1055
     }
1055
-  }
1056 1056
   
1057
-  // Standard option sets
1058
-  $form['boolean_options'] = array(
1057
+    // Standard option sets
1058
+    $form['boolean_options'] = array(
1059 1059
     '#type' => 'value',
1060 1060
     '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes'))
1061
-  );
1061
+    );
1062 1062
   
1063
-  // Identify preference sets that are established to distinguish what has been
1064
-  // saved to the database from what is just showing default values
1065
-  $form['#established'] = $established;
1063
+    // Identify preference sets that are established to distinguish what has been
1064
+    // saved to the database from what is just showing default values
1065
+    $form['#established'] = $established;
1066 1066
   
1067
-  // Top level form options
1068
-  $form['#tree'] = TRUE;
1067
+    // Top level form options
1068
+    $form['#tree'] = TRUE;
1069 1069
   
1070
-  // Hidden elements
1071
-  $form['modified'] = array(
1070
+    // Hidden elements
1071
+    $form['modified'] = array(
1072 1072
     '#type' => 'hidden',
1073 1073
     '#value' => $modified,
1074
-  );
1075
-  $form['venue'] = array(
1074
+    );
1075
+    $form['venue'] = array(
1076 1076
     '#type' => 'hidden',
1077 1077
     '#value' => $venue,
1078
-  );
1078
+    );
1079 1079
   
1080
-  $form['separator_top'] = array(
1080
+    $form['separator_top'] = array(
1081 1081
     '#value' => '<div class="separator"></div>'
1082
-  );
1082
+    );
1083 1083
   
1084
-  // Common project preferences  
1085
-  $form['resource'] = array(
1084
+    // Common project preferences  
1085
+    $form['resource'] = array(
1086 1086
     '#title' => bts('Resource settings', array(), NULL, 'boinc:account-preferences-project'),
1087 1087
     '#type' => 'fieldset',
1088 1088
     '#description' => null,
1089 1089
     '#collapsible' => TRUE,
1090 1090
     '#collapsed' => FALSE
1091
-  );
1092
-  $form['resource']['resource_share'] = array(
1091
+    );
1092
+    $form['resource']['resource_share'] = array(
1093 1093
     '#title' => bts('Resource share', array(), NULL, 'boinc:account-preferences-project'),
1094 1094
     '#type' => 'textfield',
1095 1095
     '#default_value' => $default['resource_share'],
1096 1096
     '#size' => 5,
1097 1097
     '#description' => bts("Determines the proportion of your computer's resources allocated to this project. Example: if you participate in two BOINC projects with resource shares of 100 and 200, the first will get 1/3 of your resources and the second will get 2/3.", array(), NULL, 'boinc:account-preferences-project')
1098
-  );
1099
-  if ($app_types->count > 1) {
1098
+    );
1099
+    if ($app_types->count > 1) {
1100 1100
     if ($app_types->cpu) {
1101
-      $form['resource']['no_cpu'] = array(
1101
+        $form['resource']['no_cpu'] = array(
1102 1102
         '#title' => bts('Use CPU', array(), NULL, 'boinc:account-preferences-project'),
1103 1103
         '#type' => 'radios',
1104 1104
         '#options' => $form['boolean_options']['#value'],
1105 1105
         '#attributes' => array('class' => 'fancy'),
1106 1106
         '#default_value' => $default['no_cpu'] ? 0 : 1,
1107 1107
         '#description' => bts('Request CPU-only tasks from this project.', array(), NULL, 'boinc:account-preferences-project')
1108
-      );
1108
+        );
1109 1109
     }
1110 1110
     if ($app_types->cuda) {
1111
-      $form['resource']['no_cuda'] = array(
1111
+        $form['resource']['no_cuda'] = array(
1112 1112
         '#title' => bts('Use NVIDIA GPU', array(), NULL, 'boinc:account-preferences-project'),
1113 1113
         '#type' => 'radios',
1114 1114
         '#options' => $form['boolean_options']['#value'],
1115 1115
         '#attributes' => array('class' => 'fancy'),
1116 1116
         '#default_value' => $default['no_cuda'] ? 0 : 1,
1117 1117
         '#description' => bts('Request NVIDIA GPU tasks from this project.', array(), NULL, 'boinc:account-preferences-project')
1118
-      );
1118
+        );
1119 1119
     }
1120 1120
     if ($app_types->ati) {
1121
-      $form['resource']['no_ati'] = array(
1121
+        $form['resource']['no_ati'] = array(
1122 1122
         '#title' => bts('Use AMD GPU', array(), NULL, 'boinc:account-preferences-project'),
1123 1123
         '#type' => 'radios',
1124 1124
         '#options' => $form['boolean_options']['#value'],
1125 1125
         '#attributes' => array('class' => 'fancy'),
1126 1126
         '#default_value' => $default['no_ati'] ? 0 : 1,
1127 1127
         '#description' => bts('Request AMD GPU tasks from this project.', array(), NULL, 'boinc:account-preferences-project')
1128
-      );
1128
+        );
1129 1129
     }
1130 1130
     if ($app_types->intel_gpu) {
1131
-      $form['resource']['no_intel_gpu'] = array(
1131
+        $form['resource']['no_intel_gpu'] = array(
1132 1132
         '#title' => bts('Use INTEL GPU', array(), NULL, 'boinc:account-preferences-project'),
1133 1133
         '#type' => 'radios',
1134 1134
         '#options' => $form['boolean_options']['#value'],
1135 1135
         '#attributes' => array('class' => 'fancy'),
1136 1136
         '#default_value' => $default['no_intel_gpu'] ? 0 : 1,
1137 1137
         '#description' => bts('Request Intel GPU tasks from this project.', array(), NULL, 'boinc:account-preferences-project')
1138
-      );
1138
+        );
1139
+    }
1139 1140
     }
1140
-  }
1141 1141
   
1142
-  if (variable_get('boinc_prefs_options_beta', FALSE)) {
1142
+    if (variable_get('boinc_prefs_options_beta', FALSE)) {
1143 1143
     $form['beta'] = array(
1144
-      '#title' => bts('Beta settings', array(), NULL, 'boinc:account-preferences-project'),
1145
-      '#type' => 'fieldset',
1146
-      '#description' => null,
1147
-      '#collapsible' => TRUE,
1148
-      '#collapsed' => FALSE
1144
+        '#title' => bts('Beta settings', array(), NULL, 'boinc:account-preferences-project'),
1145
+        '#type' => 'fieldset',
1146
+        '#description' => null,
1147
+        '#collapsible' => TRUE,
1148
+        '#collapsed' => FALSE
1149 1149
     );
1150 1150
     $form['beta']['allow_beta_work'] = array(
1151
-      '#title' => bts('Run test applications?', array(), NULL, 'boinc:account-preferences-project'),
1152
-      '#type' => 'radios',
1153
-      '#options' => $form['boolean_options']['#value'],
1154
-      '#attributes' => array('class' => 'fancy'),
1155
-      '#default_value' => ($default['allow_beta_work']) ? 1 : 0,
1156
-      '#description' => bts('This helps us develop applications, but may cause jobs to fail on your computer', array(), NULL, 'boinc:account-preferences-project')
1151
+        '#title' => bts('Run test applications?', array(), NULL, 'boinc:account-preferences-project'),
1152
+        '#type' => 'radios',
1153
+        '#options' => $form['boolean_options']['#value'],
1154
+        '#attributes' => array('class' => 'fancy'),
1155
+        '#default_value' => ($default['allow_beta_work']) ? 1 : 0,
1156
+        '#description' => bts('This helps us develop applications, but may cause jobs to fail on your computer', array(), NULL, 'boinc:account-preferences-project')
1157 1157
     );
1158
-  }
1158
+    }
1159 1159
   
1160
-  // Add project specific prefs to the form
1161
-  boincwork_add_project_specific_prefs($form, $prefs);
1160
+    // Add project specific prefs to the form
1161
+    boincwork_add_project_specific_prefs($form, $prefs);
1162 1162
   
1163
-  // Set whether to use this preference set by default for new computers
1164
-  $form['default_set'] = array(
1163
+    // Set whether to use this preference set by default for new computers
1164
+    $form['default_set'] = array(
1165 1165
     '#title' => bts('Default set', array(), NULL, 'boinc:account-preferences-project'),
1166 1166
     '#type' => 'fieldset',
1167 1167
     '#description' => null,
1168 1168
     '#collapsible' => TRUE,
1169 1169
     '#collapsed' => FALSE
1170
-  );
1171
-  $form['default_set']['default_venue'] = array(
1170
+    );
1171
+    $form['default_set']['default_venue'] = array(
1172 1172
     '#title' => bts('Set used for new computers', array(), NULL, 'boinc:account-preferences-project'),
1173 1173
     '#type' => 'radios',
1174 1174
     '#options' => $form['boolean_options']['#value'],
1175 1175
     '#attributes' => array('class' => 'fancy'),
1176 1176
     '#default_value' => $default['default_venue'] ? 1 : 0,
1177 1177
     '#description' => ''
1178
-  );
1178
+    );
1179 1179
   
1180
-  $form['prefs']['separator_bottom'] = array(
1180
+    $form['prefs']['separator_bottom'] = array(
1181 1181
     '#value' => '<div class="separator buttons"></div>'
1182
-  );
1182
+    );
1183 1183
   
1184
-  // Form control
1185
-  $form['prefs']['form control tabs prefix'] = array(
1184
+    // Form control
1185
+    $form['prefs']['form control tabs prefix'] = array(
1186 1186
     '#value' => '<ul class="form-control tab-list">'
1187
-  );
1188
-  $form['prefs']['submit'] = array(
1187
+    );
1188
+    $form['prefs']['submit'] = array(
1189 1189
     '#prefix' => '<li class="first tab">',
1190 1190
     '#type' => 'submit',
1191 1191
     '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'),
1192 1192
     '#suffix' => '</li>'
1193
-  );
1194
-  $form['prefs']['form control tabs'] = array(
1193
+    );
1194
+    $form['prefs']['form control tabs'] = array(
1195 1195
     '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>'
1196
-  );
1197
-  if ($venue AND $venue != 'generic') {
1196
+    );
1197
+    if ($venue AND $venue != 'generic') {
1198 1198
     global $base_path;
1199 1199
     $form['prefs']['form control tabs']['#value'] .= '<li class="tab">' . 
1200
-      l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/project/clear/{$venue}",
1200
+        l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/project/clear/{$venue}",
1201 1201
         array(
1202
-          'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/project/combined')),
1203
-          'attributes' => array(
1202
+            'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/project/combined')),
1203
+            'attributes' => array(
1204 1204
             'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the @name preference set. Are you sure?',
1205
-              array('@name' => $venue), NULL, 'boinc:account-preferences') . '\')'
1206
-          )
1205
+                array('@name' => $venue), NULL, 'boinc:account-preferences') . '\')'
1206
+            )
1207 1207
         )
1208
-      ) . '</li>';
1209
-  }
1210
-  $form['prefs']['view control'] = array(
1211
-      '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/project/combined') . '</li>'
1212
-  );
1213
-  $form['prefs']['form control tabs suffix'] = array(
1208
+        ) . '</li>';
1209
+    }
1210
+    $form['prefs']['view control'] = array(
1211
+        '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/project/combined') . '</li>'
1212
+    );
1213
+    $form['prefs']['form control tabs suffix'] = array(
1214 1214
     '#value' => '</ul>'
1215
-  );
1215
+    );
1216 1216
   
1217
-  return $form;
1217
+    return $form;
1218 1218
 }
1219 1219
 
1220 1220
 /**
1221 1221
  * Add project specific preferences to the project preferences form
1222 1222
  */
1223 1223
 function boincwork_add_project_specific_prefs(&$form, $prefs) {
1224
-  // Load project specific preferences from XML config
1225
-  $xml = boincwork_get_project_specific_config();
1224
+    // Load project specific preferences from XML config
1225
+    $xml = boincwork_get_project_specific_config();
1226 1226
   
1227
-  // Respect the order of the top level elements
1228
-  $ordered_array = array();
1229
-  $unordered_array = array();
1230
-  foreach ($xml['project_specific_preferences'] as $type => $element) {
1227
+    // Respect the order of the top level elements
1228
+    $ordered_array = array();
1229
+    $unordered_array = array();
1230
+    foreach ($xml['project_specific_preferences'] as $type => $element) {
1231 1231
     if (is_array($element) AND is_numeric(key($element))) {
1232
-      foreach ($element as $ordered_element) {
1232
+        foreach ($element as $ordered_element) {
1233 1233
         if (isset($ordered_element['@position'])) {
1234
-          $ordered_array[$ordered_element['@position']] = array($type => $ordered_element);
1234
+            $ordered_array[$ordered_element['@position']] = array($type => $ordered_element);
1235 1235
         }
1236 1236
         else {
1237
-          $unordered_array[] = array($type => $ordered_element);
1237
+            $unordered_array[] = array($type => $ordered_element);
1238
+        }
1238 1239
         }
1239
-      }
1240 1240
     }
1241 1241
     elseif (isset($element['@position'])) {
1242
-      $ordered_array[$element['@position']] = array($type => $element);
1242
+        $ordered_array[$element['@position']] = array($type => $element);
1243 1243
     }
1244 1244
     else {
1245
-      $unordered_array[] = array($type => $element);
1245
+        $unordered_array[] = array($type => $element);
1246
+    }
1246 1247
     }
1247
-  }
1248
-  ksort($ordered_array);
1249
-  $primed_array = array_merge($ordered_array, $unordered_array);
1250
-  $xml = array('project_specific_preferences' => $primed_array);
1248
+    ksort($ordered_array);
1249
+    $primed_array = array_merge($ordered_array, $unordered_array);
1250
+    $xml = array('project_specific_preferences' => $primed_array);
1251 1251
     
1252
-  foreach ($xml['project_specific_preferences'] as $wrapped_element) {
1252
+    foreach ($xml['project_specific_preferences'] as $wrapped_element) {
1253 1253
     $type = key($wrapped_element);
1254 1254
     $element= reset($wrapped_element);
1255 1255
     boincwork_generate_prefs_element($form, $type, $element, $prefs['project_specific']);
1256
-  }
1256
+    }
1257 1257
 }
1258 1258
 
1259 1259
 /**
1260
-  * Validate the project preferences form.
1261
-  */
1260
+ * Validate the project preferences form.
1261
+ */
1262 1262
 function boincwork_projectprefs_form_validate($form, &$form_state) {
1263 1263
   
1264
-  // Verify all text user input values and notify form API of failures
1265
-  $validation_rules = array(
1264
+    // Verify all text user input values and notify form API of failures
1265
+    $validation_rules = array(
1266 1266
     'resource' => array(
1267
-      'resource_share' => array(
1267
+        'resource_share' => array(
1268 1268
         'datatype' => 'integer',
1269 1269
         'min' => 0
1270
-      ),
1270
+        ),
1271 1271
     ),
1272
-  );
1272
+    );
1273 1273
   
1274
-  // Add validation rules for project specific settings
1275
-  $validation_rules += boincwork_get_project_specific_config_validation_rules();
1274
+    // Add validation rules for project specific settings
1275
+    $validation_rules += boincwork_get_project_specific_config_validation_rules();
1276 1276
   
1277
-  // Perform validation
1278
-  boincwork_validate_form($validation_rules, $form_state['values']);
1277
+    // Perform validation
1278
+    boincwork_validate_form($validation_rules, $form_state['values']);
1279 1279
   
1280
-  // Check for app validation
1281
-  if (isset($validation_rules['apps'])) {
1280
+    // Check for app validation
1281
+    if (isset($validation_rules['apps'])) {
1282 1282
     if (isset($validation_rules['apps']['minimum selected'])
1283 1283
         AND $validation_rules['apps']['minimum selected'] > 0) {
1284
-      $apps_selected = 0;
1285
-      foreach ($validation_rules['apps']['list'] as $app) {
1284
+        $apps_selected = 0;
1285
+        foreach ($validation_rules['apps']['list'] as $app) {
1286 1286
         if ($form_state['values']['applications'][$app]) $apps_selected++;
1287
-      }
1288
-      if ($apps_selected < $validation_rules['apps']['minimum selected']) {
1287
+        }
1288
+        if ($apps_selected < $validation_rules['apps']['minimum selected']) {
1289 1289
         form_set_error(
1290
-          'applications',
1291
-          bts('At least one application must be selected', array(), NULL, 'boinc:account-preferences-project')
1290
+            'applications',
1291
+            bts('At least one application must be selected', array(), NULL, 'boinc:account-preferences-project')
1292 1292
         );
1293
-      }
1294
-      if ($apps_selected == count($validation_rules['apps']['list'])) {
1293
+        }
1294
+        if ($apps_selected == count($validation_rules['apps']['list'])) {
1295 1295
         foreach ($validation_rules['apps']['list'] as $app) {
1296
-          unset($form_state['values']['applications'][$app]);
1296
+            unset($form_state['values']['applications'][$app]);
1297 1297
         }
1298 1298
         $form_state['storage']['all apps selected'] = TRUE;
1299
-      }
1299
+        }
1300
+    }
1300 1301
     }
1301
-  }
1302 1302
 }
1303 1303
 
1304 1304
 /**
1305
-  * Handle post-validation submission of project preferences form.
1306
-  */
1305
+ * Handle post-validation submission of project preferences form.
1306
+ */
1307 1307
 function boincwork_projectprefs_form_submit($form, &$form_state) {
1308
-  global $user;
1309
-  global $site_name;
1308
+    global $user;
1309
+    global $site_name;
1310 1310
   
1311
-  require_boinc(array('util'));
1312
-  $app_types = get_app_types();
1311
+    require_boinc(array('util'));
1312
+    $app_types = get_app_types();
1313 1313
   
1314
-  $account = user_load($user->uid);
1315
-  $edit = $form_state['values'];
1316
-  $venue = $edit['venue'];
1314
+    $account = user_load($user->uid);
1315
+    $edit = $form_state['values'];
1316
+    $venue = $edit['venue'];
1317 1317
   
1318
-  // Load preferences from BOINC account
1319
-  $prefs = boincwork_load_prefs('project', $venue);
1318
+    // Load preferences from BOINC account
1319
+    $prefs = boincwork_load_prefs('project', $venue);
1320 1320
   
1321
-  // Resource preferences
1322
-  $prefs['resource_share'] = $edit['resource']['resource_share'];
1323
-  if ($app_types->count > 1) {
1321
+    // Resource preferences
1322
+    $prefs['resource_share'] = $edit['resource']['resource_share'];
1323
+    if ($app_types->count > 1) {
1324 1324
     if ($app_types->cpu) $prefs['no_cpu'] = ($edit['resource']['no_cpu']) ? 0 : 1;
1325 1325
     if ($app_types->cuda) $prefs['no_cuda'] = ($edit['resource']['no_cuda']) ? 0 : 1;
1326 1326
     if ($app_types->ati) $prefs['no_ati'] = ($edit['resource']['no_ati']) ? 0 : 1;
1327 1327
     if ($app_types->intel_gpu) $prefs['no_intel_gpu'] = ($edit['resource']['no_intel_gpu']) ? 0 : 1;
1328
-  }
1328
+    }
1329 1329
   
1330
-  // Beta preferences
1331
-  if (variable_get('boinc_prefs_options_beta', FALSE)) {
1330
+    // Beta preferences
1331
+    if (variable_get('boinc_prefs_options_beta', FALSE)) {
1332 1332
     $prefs['allow_beta_work'] = ($edit['beta']['allow_beta_work']) ? 1 : 0;
1333
-  }
1333
+    }
1334 1334
   
1335
-  // Load project specific preferences from XML config
1336
-  $xml = boincwork_get_project_specific_config();
1337
-  $updated_prefs = array(
1335
+    // Load project specific preferences from XML config
1336
+    $xml = boincwork_get_project_specific_config();
1337
+    $updated_prefs = array(
1338 1338
     'project_specific' => boincwork_format_project_specific_prefs_data($edit)
1339
-  );
1340
-  $prefs = $updated_prefs + $prefs;
1339
+    );
1340
+    $prefs = $updated_prefs + $prefs;
1341 1341
   
1342
-  // Don't specify apps if all are selected
1343
-  if (isset($form_state['storage']['all apps selected'])) {
1342
+    // Don't specify apps if all are selected
1343
+    if (isset($form_state['storage']['all apps selected'])) {
1344 1344
     unset($prefs['project_specific']['app_id']);
1345 1345
     unset($form_state['storage']['all apps selected']);
1346
-  }
1346
+    }
1347 1347
   
1348
-  // If this is a new preference set, be sure to unset the "cleared" attribute
1349
-  if (isset($prefs['@attributes']['cleared'])) {
1348
+    // If this is a new preference set, be sure to unset the "cleared" attribute
1349
+    if (isset($prefs['@attributes']['cleared'])) {
1350 1350
     unset($prefs['@attributes']['cleared']);
1351
-  }
1351
+    }
1352 1352
   
1353
-  // Save preferences back to the BOINC account
1354
-  $result = boincwork_save_prefs($prefs, 'project', $venue);
1353
+    // Save preferences back to the BOINC account
1354
+    $result = boincwork_save_prefs($prefs, 'project', $venue);
1355 1355
   
1356
-  // Update the user's default preference set
1357
-  if ($edit['default_set']['default_venue']) {
1356
+    // Update the user's default preference set
1357
+    if ($edit['default_set']['default_venue']) {
1358 1358
     boincwork_set_default_venue($venue);
1359
-  }
1360
-  elseif ($venue == $account->boincuser_default_pref_set) {
1359
+    }
1360
+    elseif ($venue == $account->boincuser_default_pref_set) {
1361 1361
     // User has cleared out the default venue setting
1362 1362
     boincwork_set_default_venue();
1363
-  }
1363
+    }
1364 1364
   
1365
-  if (!$result) {
1365
+    if (!$result) {
1366 1366
     watchdog('boincwork', 'Error updating project prefs for user @id: @message', array('@id' => $user->id, '@message' => mysqli_error()), WATCHDOG_ERROR);
1367 1367
     drupal_set_message(t('Your changes could not be saved. Please contact support!'), 'error');
1368
-  }
1369
-  elseif (!drupal_get_messages('status', FALSE)) {
1368
+    }
1369
+    elseif (!drupal_get_messages('status', FALSE)) {
1370 1370
     // Show this message if the set wasn't created automatically (in which case
1371 1371
     // there is a message tailored to that)
1372 1372
     drupal_set_message(t('Your preferences have been updated.
@@ -1374,53 +1374,53 @@  discard block
 block discarded – undo
1374 1374
         communicates with @project or you issue the "Update"
1375 1375
         command from the BOINC client.', 
1376 1376
         array('@project' => $site_name)));
1377
-  }
1377
+    }
1378 1378
 }
1379 1379
 
1380 1380
 /**
1381 1381
  * The structure of the community preferences form
1382 1382
  */
1383 1383
 function communityprefs_form(&$form_state) {
1384
-  global $user;
1385
-  $account = user_load($user->uid);
1386
-  $form = array();
1387
-  
1388
-  // Pull in some elements from the profile form
1389
-  $profile_form_state = array();
1390
-  $profile = new stdClass();
1391
-  $profile->type = 'profile';
1392
-  $profile->language = '';
1393
-  if ($profile_nid = content_profile_profile_exists($profile, $account->uid)) {
1384
+    global $user;
1385
+    $account = user_load($user->uid);
1386
+    $form = array();
1387
+  
1388
+    // Pull in some elements from the profile form
1389
+    $profile_form_state = array();
1390
+    $profile = new stdClass();
1391
+    $profile->type = 'profile';
1392
+    $profile->language = '';
1393
+    if ($profile_nid = content_profile_profile_exists($profile, $account->uid)) {
1394 1394
     $profile_node = node_load($profile_nid);
1395 1395
     $form_state['storage']['profile_node'] = $profile_node;
1396 1396
     module_load_include('inc', 'node', 'node.pages');    
1397 1397
     $profile_form = drupal_retrieve_form('profile_node_form', $profile_form_state, $profile_node);
1398 1398
     drupal_prepare_form('profile_node_form', $profile_form, $profile_form_state);
1399
-  }
1399
+    }
1400 1400
   
1401
-  // Standard option sets
1402
-  $form['boolean_options'] = array(
1401
+    // Standard option sets
1402
+    $form['boolean_options'] = array(
1403 1403
     '#type' => 'value',
1404 1404
     '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes'))
1405
-  );
1405
+    );
1406 1406
   
1407
-  $default = array(
1407
+    $default = array(
1408 1408
     'pm_send_notification' => '', // This is set already in pm_email_notify_user
1409 1409
     'friend_notification' => isset($account->friend_notification) ? $account->friend_notification : 0,
1410 1410
     'comments_per_page' => (isset($account->comments_per_page) AND $account->comments_per_page) ? $account->comments_per_page : variable_get('comment_default_per_page_forum', 50),
1411 1411
     'comments_order' => (isset($account->sort) AND $account->sort) ? $account->sort : variable_get('comment_default_order_forum', COMMENT_ORDER_OLDEST_FIRST),
1412
-  );
1412
+    );
1413 1413
   
1414
-  // General options
1415
-  $form['general'] = array(
1414
+    // General options
1415
+    $form['general'] = array(
1416 1416
     '#type' => 'fieldset',
1417 1417
     '#title' => bts('General settings', array(), NULL, 'boinc:account-preferences-community'),
1418 1418
     '#weight' => 0,
1419 1419
     '#collapsible' => TRUE,
1420 1420
     '#collapsed' => FALSE
1421
-  );
1422
-  // Add the BOINC user name (non-unique, user editable)
1423
-  $form['general']['boincuser_name'] = array(
1421
+    );
1422
+    // Add the BOINC user name (non-unique, user editable)
1423
+    $form['general']['boincuser_name'] = array(
1424 1424
     '#type' => 'textfield',
1425 1425
     '#title' => bts('Name', array(), NULL, 'boinc:user-or-team-name'),
1426 1426
     '#default_value' => $account->boincuser_name,
@@ -1428,252 +1428,252 @@  discard block
 block discarded – undo
1428 1428
     '#required' => TRUE,
1429 1429
     '#description' => '',
1430 1430
     '#size' => 40
1431
-  );
1432
-  // Time zone
1433
-  if (variable_get('configurable_timezones', 1)) {
1431
+    );
1432
+    // Time zone
1433
+    if (variable_get('configurable_timezones', 1)) {
1434 1434
     $zones = _system_zonelist();
1435 1435
     $form['general']['timezone'] = array(
1436
-      '#type' => 'select',
1437
-      '#title' => bts('Time zone', array(), NULL, 'boinc:account-preferences-community'),
1438
-      '#default_value' => ($account->timezone !== NULL) ? $account->timezone : variable_get('date_default_timezone', 0),
1439
-      '#options' => $zones,
1440
-      '#description' => '',
1436
+        '#type' => 'select',
1437
+        '#title' => bts('Time zone', array(), NULL, 'boinc:account-preferences-community'),
1438
+        '#default_value' => ($account->timezone !== NULL) ? $account->timezone : variable_get('date_default_timezone', 0),
1439
+        '#options' => $zones,
1440
+        '#description' => '',
1441 1441
     );
1442
-  }
1442
+    }
1443 1443
   
1444
-  // Notification options
1445
-  $form['notifications'] = array(
1444
+    // Notification options
1445
+    $form['notifications'] = array(
1446 1446
     '#type' => 'fieldset',
1447 1447
     '#title' => bts('Notification settings', array(), NULL, 'boinc:account-preferences-community'),
1448 1448
     '#weight' => 5,
1449 1449
     '#collapsible' => TRUE,
1450 1450
     '#collapsed' => FALSE
1451
-  );
1452
-  // Pull in private message notification handling and tweak the form
1453
-  $pm_notify = pm_email_notify_user('form', $edit, $account, 'account');
1454
-  $form['notifications']['pm_send_notifications'] = array_replace(
1451
+    );
1452
+    // Pull in private message notification handling and tweak the form
1453
+    $pm_notify = pm_email_notify_user('form', $edit, $account, 'account');
1454
+    $form['notifications']['pm_send_notifications'] = array_replace(
1455 1455
     $pm_notify['enable_pm_mail']['pm_send_notifications'],
1456 1456
     array(
1457
-      '#type' => 'radios',
1458
-      '#title' => bts('Receive email notification for private messages?', array(), NULL, 'boinc:account-preferences-community'),
1459
-      '#description' => ' ',
1460
-      '#options' => $form['boolean_options']['#value'],
1461
-      '#attributes' => array('class' => 'fancy')
1457
+        '#type' => 'radios',
1458
+        '#title' => bts('Receive email notification for private messages?', array(), NULL, 'boinc:account-preferences-community'),
1459
+        '#description' => ' ',
1460
+        '#options' => $form['boolean_options']['#value'],
1461
+        '#attributes' => array('class' => 'fancy')
1462 1462
     )
1463
-  );
1464
-  $form['notifications']['friend_notification'] = array(
1463
+    );
1464
+    $form['notifications']['friend_notification'] = array(
1465 1465
     '#type' => 'radios',
1466 1466
     '#title' => bts('Receive email notification for friend requests?', array(), NULL, 'boinc:account-preferences-community'),
1467 1467
     '#description' => ' ',
1468 1468
     '#options' => array(0 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), -1 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')),
1469 1469
     '#attributes' => array('class' => 'fancy'),
1470 1470
     '#default_value' => $default['friend_notification']
1471
-  );
1471
+    );
1472 1472
   
1473
-  // Internationalization options
1474
-  if (module_exists('internationalization')) {
1473
+    // Internationalization options
1474
+    if (module_exists('internationalization')) {
1475 1475
     $languages = language_list('enabled');
1476 1476
     $languages = $languages[1];
1477 1477
     $names = array();
1478 1478
     foreach ($languages as $langcode => $item) {
1479
-      $name = t($item->name);
1480
-      $names[check_plain($langcode)] = check_plain($name . ($item->native != $name ? ' ('. $item->native .')' : ''));
1479
+        $name = t($item->name);
1480
+        $names[check_plain($langcode)] = check_plain($name . ($item->native != $name ? ' ('. $item->native .')' : ''));
1481 1481
     }
1482 1482
     $form['locale'] = array(
1483
-      '#type' => 'fieldset',
1484
-      '#title' => bts('Language settings', array(), NULL, 'boinc:account-preferences-community'),
1485
-      '#weight' => 10,
1486
-      '#collapsible' => TRUE,
1487
-      '#collapsed' => FALSE,
1483
+        '#type' => 'fieldset',
1484
+        '#title' => bts('Language settings', array(), NULL, 'boinc:account-preferences-community'),
1485
+        '#weight' => 10,
1486
+        '#collapsible' => TRUE,
1487
+        '#collapsed' => FALSE,
1488 1488
     );
1489 1489
 
1490 1490
     // Get language negotiation settings.
1491 1491
     $mode = variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE);
1492 1492
     $user_preferred_language = user_preferred_language($account);
1493 1493
     $form['locale']['language'] = array(
1494
-      '#type' => 'select',
1495
-      '#title' => bts('Language', array(), NULL, 'boinc:account-preferences-community'),
1496
-      '#default_value' => check_plain($user_preferred_language->language),
1497
-      '#options' => $names,
1498
-      '#description' => ($mode == LANGUAGE_NEGOTIATION_PATH) ? bts("This account's default language for e-mails and preferred language for site presentation.", array(), NULL, 'boinc:account-preferences-community') : bts("This account's default language for e-mails.", array(), NULL, 'boinc:account-preferences-community'),
1494
+        '#type' => 'select',
1495
+        '#title' => bts('Language', array(), NULL, 'boinc:account-preferences-community'),
1496
+        '#default_value' => check_plain($user_preferred_language->language),
1497
+        '#options' => $names,
1498
+        '#description' => ($mode == LANGUAGE_NEGOTIATION_PATH) ? bts("This account's default language for e-mails and preferred language for site presentation.", array(), NULL, 'boinc:account-preferences-community') : bts("This account's default language for e-mails.", array(), NULL, 'boinc:account-preferences-community'),
1499 1499
     );
1500
-  }
1500
+    }
1501 1501
   
1502
-  // Avatar options
1503
-  $form['gravatar'] = array(
1502
+    // Avatar options
1503
+    $form['gravatar'] = array(
1504 1504
     '#type' => 'item',
1505 1505
     '#value' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, it will be used for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail), NULL, 'boinc:account-preferences-community'),
1506 1506
     '#description' => bts('Your Gravatar will not be shown if you upload a user picture.', array(), NULL, 'boinc:account-preferences-community'),
1507
-  );
1508
-  if (user_access('disable own gravatar', $account)) {
1507
+    );
1508
+    if (user_access('disable own gravatar', $account)) {
1509 1509
     $form['gravatar'] = array(
1510
-      '#type' => 'checkbox',
1511
-      '#title' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, use it for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail), NULL, 'boinc:account-preferences-community'),
1512
-      '#description' => bts('Gravatar will not be shown if an avatar is uploaded.', array(), NULL, 'boinc:account-preferences-community'),
1513
-      '#default_value' => isset($account->gravatar) ? $account->gravatar : 0,
1514
-      '#disabled' => !empty($account->picture),
1515
-    );
1516
-  }
1517
-  $form['gravatar']['#weight'] = 15;
1518
-  $form['gravatar']['#prefix'] = '<fieldset class="collapsible"><legend><a href="#">' . bts('Avatar settings', array(), NULL, 'boinc:account-preferences-community') . '</a></legend>';
1519
-  // Upload an avatar (pulled from profile_node_form):
1520
-  if (!empty($profile_form['field_image'])) {
1510
+        '#type' => 'checkbox',
1511
+        '#title' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, use it for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail), NULL, 'boinc:account-preferences-community'),
1512
+        '#description' => bts('Gravatar will not be shown if an avatar is uploaded.', array(), NULL, 'boinc:account-preferences-community'),
1513
+        '#default_value' => isset($account->gravatar) ? $account->gravatar : 0,
1514
+        '#disabled' => !empty($account->picture),
1515
+    );
1516
+    }
1517
+    $form['gravatar']['#weight'] = 15;
1518
+    $form['gravatar']['#prefix'] = '<fieldset class="collapsible"><legend><a href="#">' . bts('Avatar settings', array(), NULL, 'boinc:account-preferences-community') . '</a></legend>';
1519
+    // Upload an avatar (pulled from profile_node_form):
1520
+    if (!empty($profile_form['field_image'])) {
1521 1521
     $form['field_image'] = $profile_form['field_image'];
1522
-  }
1523
-  else {
1522
+    }
1523
+    else {
1524 1524
     $form['field_image'] = array(
1525
-      '#value' => '<div class="form-item">'
1525
+        '#value' => '<div class="form-item">'
1526 1526
         . '<label class="placeholder">'
1527 1527
         . bts('This is not available until your profile is set up.', array(), NULL, 'boinc:account-preferences-community')
1528 1528
         . '</label>'
1529 1529
         . l(bts('Create a profile', array(), NULL, 'boinc:account-preferences-community'), 'account/profile/edit', array('attributes' => array('class' => 'form-link')))
1530 1530
         . '</div>',
1531 1531
     );
1532
-  }
1533
-  $form['field_image'][0]['#title'] = bts('Upload an avatar', array(), NULL, 'boinc:account-preferences-community');
1534
-  $form['field_image']['#weight'] = 20;
1535
-  $form['field_image']['#suffix'] = '</fieldset>';
1532
+    }
1533
+    $form['field_image'][0]['#title'] = bts('Upload an avatar', array(), NULL, 'boinc:account-preferences-community');
1534
+    $form['field_image']['#weight'] = 20;
1535
+    $form['field_image']['#suffix'] = '</fieldset>';
1536 1536
   
1537
-  // Forum options
1538
-  $form['forums'] = array(
1537
+    // Forum options
1538
+    $form['forums'] = array(
1539 1539
     '#type' => 'fieldset',
1540 1540
     '#title' => bts('Forum settings', array(), NULL, 'boinc:account-preferences-community'),
1541 1541
     '#weight' => 25,
1542 1542
     '#collapsible' => TRUE,
1543 1543
     '#collapsed' => FALSE
1544
-  );
1545
-  $form['forums']['comments_per_page'] = array(
1544
+    );
1545
+    $form['forums']['comments_per_page'] = array(
1546 1546
     '#type' => 'select',
1547 1547
     '#title' => bts('In discussion topics, show at most @comments_per_page', array('@comments_per_page' => ''), NULL, 'boinc:account-preferences-community'),
1548 1548
     '#options' => array(10 => 10, 20 => 20, 30 => 30, 50 => 50, 100 => 100),
1549 1549
     '#default_value' => $default['comments_per_page']
1550
-  );
1551
-  // Can't have a typical Drupal form suffix on a select box?
1552
-  $form['forums']['comments_per_page_suffix'] = array(
1550
+    );
1551
+    // Can't have a typical Drupal form suffix on a select box?
1552
+    $form['forums']['comments_per_page_suffix'] = array(
1553 1553
     '#value' => '<span>' . bts('comments per page', array(), NULL, 'boinc:account-preferences-community') . '</span>'
1554
-  );
1555
-  $form['forums']['comments_order'] = array(
1554
+    );
1555
+    $form['forums']['comments_order'] = array(
1556 1556
     '#type' => 'select',
1557 1557
     '#title' => bts('Sort comments in discussions', array(), NULL, 'boinc:account-preferences-community'),
1558 1558
     '#options' => array(1 => bts('Newest post first', array(), NULL, 'boinc:account-preferences-community'), 2 => bts('Oldest post first', array(), NULL, 'boinc:account-preferences-community')),
1559 1559
     '#default_value' => $default['comments_order']
1560
-  );
1561
-  // Signature (pulled from user_edit_form):
1562
-  if (variable_get('user_signatures', 0) && module_exists('comment')) {
1560
+    );
1561
+    // Signature (pulled from user_edit_form):
1562
+    if (variable_get('user_signatures', 0) && module_exists('comment')) {
1563 1563
     $form['forums']['signature'] = array(
1564
-      '#type' => 'textarea',
1565
-      '#title' => bts('Signature', array(), NULL, 'boinc:account-preferences-community'),
1566
-      '#description' => bts('Your signature will be publicly displayed at the end of your comments.', array(), NULL, 'boinc:account-preferences-community'),
1567
-      '#default_value' => $account->signature
1568
-      );
1564
+        '#type' => 'textarea',
1565
+        '#title' => bts('Signature', array(), NULL, 'boinc:account-preferences-community'),
1566
+        '#description' => bts('Your signature will be publicly displayed at the end of your comments.', array(), NULL, 'boinc:account-preferences-community'),
1567
+        '#default_value' => $account->signature
1568
+        );
1569 1569
     // Prevent a "validation error" message when the user attempts to save with a default value they
1570 1570
     // do not have access to.
1571 1571
     if (!filter_access($account->signature_format) && empty($_POST)) {
1572
-      drupal_set_message(t("The signature input format has been set to a format you don't have access to. It will be changed to a format you have access to when you save this page."));
1573
-      $edit['signature_format'] = FILTER_FORMAT_DEFAULT;
1572
+        drupal_set_message(t("The signature input format has been set to a format you don't have access to. It will be changed to a format you have access to when you save this page."));
1573
+        $edit['signature_format'] = FILTER_FORMAT_DEFAULT;
1574 1574
     }
1575 1575
     $form['forums']['signature_format'] = filter_form($account->signature_format, NULL, array('signature_format'));
1576 1576
     // Optionally hide signatures from comments
1577 1577
     $form['forums']['hide_signatures'] = array(
1578
-      '#type' => 'radios',
1579
-      '#title' => bts('Hide signatures in forums', array(), NULL, 'boinc:account-preferences-community'),
1580
-      '#description' => ' ',
1581
-      '#options' => $form['boolean_options']['#value'],
1582
-      '#attributes' => array('class' => 'fancy'),
1583
-      '#default_value' => isset($account->hide_signatures) ? $account->hide_signatures : 0,
1578
+        '#type' => 'radios',
1579
+        '#title' => bts('Hide signatures in forums', array(), NULL, 'boinc:account-preferences-community'),
1580
+        '#description' => ' ',
1581
+        '#options' => $form['boolean_options']['#value'],
1582
+        '#attributes' => array('class' => 'fancy'),
1583
+        '#default_value' => isset($account->hide_signatures) ? $account->hide_signatures : 0,
1584 1584
     );
1585
-  }
1585
+    }
1586 1586
 
1587
-  //Bottom separator
1588
-  $form['separator_bottom'] = array(
1587
+    //Bottom separator
1588
+    $form['separator_bottom'] = array(
1589 1589
     '#value' => '<div class="separator buttons"></div>',
1590 1590
     '#weight' => 999,
1591
-  );
1591
+    );
1592 1592
   
1593
-  // Form control
1594
-  $form['form control tabs prefix'] = array(
1593
+    // Form control
1594
+    $form['form control tabs prefix'] = array(
1595 1595
     '#value' => '<ul class="form-control tab-list">',
1596 1596
     '#weight' => 1001,
1597
-  );
1598
-  $form['submit'] = array(
1597
+    );
1598
+    $form['submit'] = array(
1599 1599
     '#prefix' => '<li class="first tab">',
1600 1600
     '#type' => 'submit',
1601 1601
     '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'),
1602 1602
     '#suffix' => '</li>',
1603 1603
     '#weight' => 1002,
1604
-  );
1605
-  $form['form control tabs'] = array(
1604
+    );
1605
+    $form['form control tabs'] = array(
1606 1606
     '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>',
1607 1607
     '#weight' => 1003,
1608
-  );
1609
-  $form['form control tabs suffix'] = array(
1608
+    );
1609
+    $form['form control tabs suffix'] = array(
1610 1610
     '#value' => '</ul>',
1611 1611
     '#weight' => 1004,
1612
-  );
1613
-  return $form;
1612
+    );
1613
+    return $form;
1614 1614
 }
1615 1615
 
1616 1616
 /**
1617
-  * Handle validation submission of community preferences form.
1618
-  */
1617
+ * Handle validation submission of community preferences form.
1618
+ */
1619 1619
 function communityprefs_form_validate($form, &$form_state) {
1620
-  // require_boinc();
1621
-  global $user;
1622
-  $account = user_load($user->uid);
1623
-  $boinc_user = BoincUser::lookup_id($account->boincuser_id);
1624
-  $edit = $form_state['values'];
1620
+    // require_boinc();
1621
+    global $user;
1622
+    $account = user_load($user->uid);
1623
+    $boinc_user = BoincUser::lookup_id($account->boincuser_id);
1624
+    $edit = $form_state['values'];
1625 1625
 
1626
-  if ($edit['boincuser_name'] != $boinc_user->name) {
1626
+    if ($edit['boincuser_name'] != $boinc_user->name) {
1627 1627
     $blacklist1 = preg_split('/\r\n|\r|\n/', variable_get('boinc_weboptions_blacklisted_usernames', "admin\nadministrator\nmoderator"));
1628 1628
     $blacklist2 = array();
1629 1629
     if (is_array($blacklist1)) {
1630
-      $blacklist2 = array_map('strtolower', $blacklist1);
1630
+        $blacklist2 = array_map('strtolower', $blacklist1);
1631 1631
     }
1632 1632
     if (in_array(strtolower($edit['boincuser_name']), $blacklist2)) {
1633
-      form_set_error('boincuser_name',
1633
+        form_set_error('boincuser_name',
1634 1634
         bts('You may not use username @blname, as that name is not allowed. Please choose another name.',
1635 1635
             array('@blname' => $edit['boincuser_name']),
1636 1636
             NULL, 'boinc:account-preferences-community'));
1637
-      return false;
1637
+        return false;
1638
+    }
1638 1639
     }
1639
-  }
1640 1640
 
1641
-  return true;
1641
+    return true;
1642 1642
 }
1643 1643
 
1644 1644
 /**
1645
-  * Handle post-validation submission of community preferences form.
1646
-  */
1645
+ * Handle post-validation submission of community preferences form.
1646
+ */
1647 1647
 function communityprefs_form_submit($form, &$form_state) {
1648
-  require_boinc('boinc_db');
1649
-  global $user;
1650
-  $account = user_load($user->uid);
1651
-  $boinc_user = BoincUser::lookup_id($account->boincuser_id);
1652
-  $edit = $form_state['values'];
1653
-  $profile_node = $form_state['storage']['profile_node'];
1654
-  
1655
-  // Display name
1656
-  if ($edit['boincuser_name'] != $boinc_user->name) {
1648
+    require_boinc('boinc_db');
1649
+    global $user;
1650
+    $account = user_load($user->uid);
1651
+    $boinc_user = BoincUser::lookup_id($account->boincuser_id);
1652
+    $edit = $form_state['values'];
1653
+    $profile_node = $form_state['storage']['profile_node'];
1654
+  
1655
+    // Display name
1656
+    if ($edit['boincuser_name'] != $boinc_user->name) {
1657 1657
     $boincuser_name = $edit['boincuser_name'];
1658 1658
     $result = $boinc_user->update(
1659 1659
         "name='{$boincuser_name}'"
1660 1660
     );
1661
-  }
1661
+    }
1662 1662
   
1663
-  // Private message settings
1664
-  pm_email_notify_user('submit', $edit, $user);
1663
+    // Private message settings
1664
+    pm_email_notify_user('submit', $edit, $user);
1665 1665
   
1666
-  // Avatar settings - only set if profile_node exists.
1667
-  if ($profile_node) {
1666
+    // Avatar settings - only set if profile_node exists.
1667
+    if ($profile_node) {
1668 1668
     if (!$edit['field_image']) $edit['field_image'] = array();
1669 1669
     $profile_node->field_image = $edit['field_image'];
1670 1670
     node_save($profile_node);
1671 1671
     // Flush this from the node cache or changes won't show up immediately!
1672 1672
     $profile_node = node_load($profile_node->nid, NULL, TRUE);
1673
-  }
1673
+    }
1674 1674
 
1675
-  // All other settings
1676
-  $settings = array(
1675
+    // All other settings
1676
+    $settings = array(
1677 1677
     'signature' => $edit['signature'],
1678 1678
     'signature_format' => $edit['signature_format'],
1679 1679
     'timezone' => $edit['timezone'],
@@ -1682,183 +1682,183 @@  discard block
 block discarded – undo
1682 1682
     'hide_signatures' => $edit['hide_signatures'],
1683 1683
     'sort' => $edit['comments_order'],
1684 1684
     'gravatar' => $edit['gravatar'],
1685
-  );
1686
-  if (module_exists('internationalization')) {
1685
+    );
1686
+    if (module_exists('internationalization')) {
1687 1687
     $settings['language'] = $edit['language'];
1688 1688
     global $language;
1689 1689
     if ($user->language != $edit['language']) {
1690
-      global $base_url;
1691
-      if ($edit['language'] != language_default('language')) {
1690
+        global $base_url;
1691
+        if ($edit['language'] != language_default('language')) {
1692 1692
         $form_state['redirect'] = $base_url . '/' . $edit['language'] . '/' . $_GET['q'];
1693
-      }
1694
-      else {
1693
+        }
1694
+        else {
1695 1695
         $form_state['redirect'] = $base_url . '/' . $_GET['q'];
1696
-      }
1696
+        }
1697 1697
     }
1698
-  }
1699
-  user_save($user, $settings);
1698
+    }
1699
+    user_save($user, $settings);
1700 1700
   
1701
-  drupal_set_message(bts('Your community preferences have been updated.', array(), NULL, 'boinc:account-preferences-community'));
1701
+    drupal_set_message(bts('Your community preferences have been updated.', array(), NULL, 'boinc:account-preferences-community'));
1702 1702
   
1703
-  // Form will not redirect if storage is set; not good if language changes
1704
-  unset($form_state['storage']);
1703
+    // Form will not redirect if storage is set; not good if language changes
1704
+    unset($form_state['storage']);
1705 1705
 }
1706 1706
 
1707 1707
 /**
1708 1708
  * The structure of the privacy preferences form
1709 1709
  */
1710 1710
 function boincwork_privacyprefs_form(&$form_state) {
1711
-  require_boinc(array('user', 'prefs', 'util', 'consent'));
1711
+    require_boinc(array('user', 'prefs', 'util', 'consent'));
1712 1712
   
1713
-  global $user;
1714
-  $account = user_load($user->uid);
1715
-  $boincuser = BoincUser::lookup_id($account->boincuser_id);
1713
+    global $user;
1714
+    $account = user_load($user->uid);
1715
+    $boincuser = BoincUser::lookup_id($account->boincuser_id);
1716 1716
   
1717
-  // Load preferences from BOINC account
1718
-  $prefs = boincwork_load_prefs('project');
1717
+    // Load preferences from BOINC account
1718
+    $prefs = boincwork_load_prefs('project');
1719 1719
   
1720
-  //if (!$prefs AND !$initialize_if_empty) return null;
1720
+    //if (!$prefs AND !$initialize_if_empty) return null;
1721 1721
 
1722
-  $privacy_consent_types = boincwork_load_privacyconsenttypes();
1722
+    $privacy_consent_types = boincwork_load_privacyconsenttypes();
1723 1723
   
1724
-  // Define form defaults
1725
-  $default = array(
1724
+    // Define form defaults
1725
+    $default = array(
1726 1726
     'privacy' => array(
1727
-      'send_email' => ($boincuser->send_email) ? 1 : 0,
1728
-      'show_hosts' => ($boincuser->show_hosts) ? 1 : 0
1727
+        'send_email' => ($boincuser->send_email) ? 1 : 0,
1728
+        'show_hosts' => ($boincuser->show_hosts) ? 1 : 0
1729 1729
     )
1730
-  );
1730
+    );
1731 1731
   
1732
-  // Standard option sets
1733
-  $form['boolean_options'] = array(
1732
+    // Standard option sets
1733
+    $form['boolean_options'] = array(
1734 1734
     '#type' => 'value',
1735 1735
     '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes'))
1736
-  );
1736
+    );
1737 1737
   
1738
-  $form['privacy'] = array(
1738
+    $form['privacy'] = array(
1739 1739
     '#title' => bts('Privacy settings', array(), NULL, 'boinc:account-preferences-privacy'),
1740 1740
     '#type' => 'fieldset',
1741 1741
     '#description' => null,
1742 1742
     '#collapsible' => TRUE,
1743 1743
     '#collapsed' => FALSE
1744
-  );
1745
-  $form['privacy']['send_email'] = array(
1744
+    );
1745
+    $form['privacy']['send_email'] = array(
1746 1746
     '#title' => bts('Is it OK for @project and your team (if any) to email you?', array('@project' => variable_get('site_name', 'Drupal-BOINC')), NULL, 'boinc:account-preferences-privacy'),
1747 1747
     '#type' => 'radios',
1748 1748
     '#options' => $form['boolean_options']['#value'],
1749 1749
     '#attributes' => array('class' => 'fancy'),
1750 1750
     '#default_value' => $default['privacy']['send_email']
1751
-  );
1752
-  $form['privacy']['show_hosts'] = array(
1751
+    );
1752
+    $form['privacy']['show_hosts'] = array(
1753 1753
     '#title' => bts('Should @project show your computers on its web site?', array('@project' => variable_get('site_name', 'Drupal-BOINC')), NULL, 'boinc:account-preferences-privacy'),
1754 1754
     '#description' => bts('At times, you may be asked to enable this option in order to receive help from the forums. Advanced users may need to be able to inspect your computers\' information in order to help diagnose any problems.', array(), NULL, 'boinc:account-preferences-privacy'),
1755 1755
     '#type' => 'radios',
1756 1756
     '#options' => $form['boolean_options']['#value'],
1757 1757
     '#attributes' => array('class' => 'fancy'),
1758 1758
     '#default_value' => $default['privacy']['show_hosts']
1759
-  );
1759
+    );
1760 1760
 
1761
-  // Loop over privacy consent types and create form question for each
1762
-  // option that deals with privacy.
1763
-  foreach ($privacy_consent_types as $ct) {
1761
+    // Loop over privacy consent types and create form question for each
1762
+    // option that deals with privacy.
1763
+    foreach ($privacy_consent_types as $ct) {
1764 1764
 
1765 1765
     $currstate = (check_user_consent($boincuser, $ct['shortname'])) ? 1 : 0 ;
1766 1766
     // Set name to 'privacyconsent_SHORTNAME', which can be parsed
1767 1767
     // later in the submit function.
1768 1768
     $form['privacy']['privacyconsent_'.$ct['shortname']] = array(
1769
-      '#title' => bts($ct['description'], array(), NULL, 'boinc:account-preferences-privacy'),
1770
-      '#type' => 'radios',
1771
-      '#options' => $form['boolean_options']['#value'],
1772
-      '#attributes' => array('class' => 'fancy'),
1773
-      '#default_value' => $currstate,
1769
+        '#title' => bts($ct['description'], array(), NULL, 'boinc:account-preferences-privacy'),
1770
+        '#type' => 'radios',
1771
+        '#options' => $form['boolean_options']['#value'],
1772
+        '#attributes' => array('class' => 'fancy'),
1773
+        '#default_value' => $currstate,
1774 1774
     );
1775
-  }
1775
+    }
1776 1776
 
1777
-  // Ignore and block users
1778
-  if (module_exists('ignore_user')) {
1777
+    // Ignore and block users
1778
+    if (module_exists('ignore_user')) {
1779 1779
     $form['ignoreblock'] = array(
1780
-      '#title' => bts('Ignore Users', array(), NULL, 'boinc:account-preferences-privacy'),
1781
-      '#type' => 'fieldset',
1782
-      '#description' => bts('<p>You may ignore users in the forums and block users from sending you private messages.<p>', array(), NULL, 'boinc:ignore-user-help'),
1783
-      '#collapsible' => TRUE,
1784
-      '#collapsed' => FALSE
1780
+        '#title' => bts('Ignore Users', array(), NULL, 'boinc:account-preferences-privacy'),
1781
+        '#type' => 'fieldset',
1782
+        '#description' => bts('<p>You may ignore users in the forums and block users from sending you private messages.<p>', array(), NULL, 'boinc:ignore-user-help'),
1783
+        '#collapsible' => TRUE,
1784
+        '#collapsed' => FALSE
1785 1785
     );
1786 1786
 
1787 1787
     // Table for ignored users
1788 1788
     $form['ignoreblock']['current_ignore_section'] = array(
1789
-      '#type' => 'item',
1790
-      '#value' => bts('Current users on your Ignore List', array(), NULL, 'boinc:ignore-user-list'),
1791
-      '#prefix' => '<h4>',
1792
-      '#suffix' => '</h4>',
1793
-      '#weight' => -20,
1789
+        '#type' => 'item',
1790
+        '#value' => bts('Current users on your Ignore List', array(), NULL, 'boinc:ignore-user-list'),
1791
+        '#prefix' => '<h4>',
1792
+        '#suffix' => '</h4>',
1793
+        '#weight' => -20,
1794 1794
     );
1795 1795
 
1796 1796
     $ignored_users = _ignore_user_ignored_users();
1797 1797
     foreach ($ignored_users as $ignored_user) {
1798
-      $form['ignoreblock']['username'][$ignored_user['iuid']] = array(
1798
+        $form['ignoreblock']['username'][$ignored_user['iuid']] = array(
1799 1799
         '#value' => $ignored_user['username'],
1800
-      );
1801
-      $form['ignoreblock']['delete'][$ignored_user['iuid']] = array(
1800
+        );
1801
+        $form['ignoreblock']['delete'][$ignored_user['iuid']] = array(
1802 1802
         '#value' => l(
1803
-          bts('delete', array(), NULL, 'boinc:ignore-user-delete-button'),
1804
-          'account/prefs/privacy/ignore_user/remove/'. $ignored_user['iuid'],
1805
-          array()
1803
+            bts('delete', array(), NULL, 'boinc:ignore-user-delete-button'),
1804
+            'account/prefs/privacy/ignore_user/remove/'. $ignored_user['iuid'],
1805
+            array()
1806 1806
         ),
1807
-      );
1807
+        );
1808 1808
     }
1809 1809
     $form['ignoreblock']['pager'] = array('#value' => theme('pager', NULL, 10, 0));
1810 1810
 
1811 1811
     // Sub-form to add user to ignore list
1812 1812
     $form['ignoreblock']['add_ignore_user_section'] = array(
1813
-      '#type' => 'item',
1814
-      '#value' => bts('Add user to Ignore List', array(), NULL, 'boinc:ignore-user-add'),
1815
-      '#prefix' => '<h4>',
1816
-      '#suffix' => '</h4>',
1817
-      '#weight' => 10,
1813
+        '#type' => 'item',
1814
+        '#value' => bts('Add user to Ignore List', array(), NULL, 'boinc:ignore-user-add'),
1815
+        '#prefix' => '<h4>',
1816
+        '#suffix' => '</h4>',
1817
+        '#weight' => 10,
1818 1818
     );
1819 1819
 
1820 1820
     $form['ignoreblock']['addusername_toignorelist'] = array(
1821
-      '#type' => 'textfield',
1822
-      '#title' => bts('Username', array(), NULL, 'boinc:ignore-user-searchbox'),
1823
-      '#description' => bts('To lookup a username start typing in the search box. A list of usernames will appear as you type. The number appearing in the suffix is the BOINC id. You can find a user\'s BOINC id on their user profile page.', array(), NULL, 'boinc:ignore-user-searchbox-help'),
1824
-      '#weight' => 11,
1825
-      '#size' => 50,
1826
-      '#autocomplete_path' => 'boincuser/autocomplete',
1821
+        '#type' => 'textfield',
1822
+        '#title' => bts('Username', array(), NULL, 'boinc:ignore-user-searchbox'),
1823
+        '#description' => bts('To lookup a username start typing in the search box. A list of usernames will appear as you type. The number appearing in the suffix is the BOINC id. You can find a user\'s BOINC id on their user profile page.', array(), NULL, 'boinc:ignore-user-searchbox-help'),
1824
+        '#weight' => 11,
1825
+        '#size' => 50,
1826
+        '#autocomplete_path' => 'boincuser/autocomplete',
1827 1827
     );
1828 1828
 
1829 1829
     $form['ignoreblock']['addusername_submit'] = array(
1830
-      '#type' => 'submit',
1831
-      '#value' => bts('Ignore user', array(), NULL, 'boinc:ignore-user-add'),
1832
-      '#submit' => array('_boincwork_ignore_list_form_submit'),
1833
-      '#weight' => 12,
1834
-      '#attributes' => array('class' => 'add_ignore_user'),
1830
+        '#type' => 'submit',
1831
+        '#value' => bts('Ignore user', array(), NULL, 'boinc:ignore-user-add'),
1832
+        '#submit' => array('_boincwork_ignore_list_form_submit'),
1833
+        '#weight' => 12,
1834
+        '#attributes' => array('class' => 'add_ignore_user'),
1835 1835
     );
1836
-  }// endif module_exists
1836
+    }// endif module_exists
1837 1837
 
1838
-  $form['prefs']['separator_bottom'] = array(
1838
+    $form['prefs']['separator_bottom'] = array(
1839 1839
     '#value' => '<div class="separator buttons"></div>'
1840
-  );
1840
+    );
1841 1841
   
1842
-  // Form control
1843
-  $form['prefs']['form control tabs prefix'] = array(
1842
+    // Form control
1843
+    $form['prefs']['form control tabs prefix'] = array(
1844 1844
     '#value' => '<ul class="form-control tab-list">'
1845
-  );
1846
-  $form['prefs']['submit'] = array(
1845
+    );
1846
+    $form['prefs']['submit'] = array(
1847 1847
     '#prefix' => '<li class="first tab">',
1848 1848
     '#type' => 'submit',
1849 1849
     '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'),
1850 1850
     '#validate' => array('boincwork_privacyprefs_form_validate'),
1851 1851
     '#submit' => array('boincwork_privacyprefs_form_submit'),
1852 1852
     '#suffix' => '</li>'
1853
-  );
1854
-  $form['prefs']['form control tabs'] = array(
1853
+    );
1854
+    $form['prefs']['form control tabs'] = array(
1855 1855
     '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>'
1856
-  );
1857
-  $form['prefs']['form control tabs suffix'] = array(
1856
+    );
1857
+    $form['prefs']['form control tabs suffix'] = array(
1858 1858
     '#value' => '</ul>'
1859
-  );
1859
+    );
1860 1860
   
1861
-  return $form;
1861
+    return $form;
1862 1862
 }
1863 1863
 
1864 1864
 /**
@@ -1866,93 +1866,93 @@  discard block
 block discarded – undo
1866 1866
  */
1867 1867
 function theme_boincwork_privacyprefs_form($form) {
1868 1868
 
1869
-  $output = '';
1870
-  $output .= drupal_render($form['privacy']);
1869
+    $output = '';
1870
+    $output .= drupal_render($form['privacy']);
1871 1871
 
1872
-  $header = array(
1872
+    $header = array(
1873 1873
     bts('Username', array(), NULL, 'boinc:ignore-user-list'),
1874 1874
     bts('Operations', array(), NULL, 'boinc:ignore-user-list')
1875
-  );
1875
+    );
1876 1876
 
1877
-  $rows = array();
1878
-  if (isset($form['ignoreblock']['username']) && is_array($form['ignoreblock']['username'])) {
1877
+    $rows = array();
1878
+    if (isset($form['ignoreblock']['username']) && is_array($form['ignoreblock']['username'])) {
1879 1879
     foreach (element_children($form['ignoreblock']['username']) as $key) {
1880
-      $row = array();
1881
-      $row[] = drupal_render($form['ignoreblock']['username'][$key]);
1882
-      $row[] = drupal_render($form['ignoreblock']['delete'][$key]);
1883
-      $rows[] = $row;
1880
+        $row = array();
1881
+        $row[] = drupal_render($form['ignoreblock']['username'][$key]);
1882
+        $row[] = drupal_render($form['ignoreblock']['delete'][$key]);
1883
+        $rows[] = $row;
1884
+    }
1884 1885
     }
1885
-  }
1886
-  else {
1886
+    else {
1887 1887
     $rows[] = array(
1888
-      array(
1888
+        array(
1889 1889
         'data' => bts('You have not added any users to your Ignore List.', array(), NULL, 'boinc:ignore-user-list'),
1890 1890
         'colspan' => '2',
1891
-      )
1891
+        )
1892 1892
     );
1893
-  }
1893
+    }
1894 1894
 
1895
-  $attr = array('class' => 'ignore_user');
1896
-  $form['ignoreblock']['current_list']['ignored_users']['#value'] = theme('table', $header, $rows, $attr);
1897
-  $output .= drupal_render($form['current_list']);
1895
+    $attr = array('class' => 'ignore_user');
1896
+    $form['ignoreblock']['current_list']['ignored_users']['#value'] = theme('table', $header, $rows, $attr);
1897
+    $output .= drupal_render($form['current_list']);
1898 1898
 
1899
-  if ($form['pager']['#value']) {
1899
+    if ($form['pager']['#value']) {
1900 1900
     $output .= drupal_render($form['pager']);
1901
-  }
1901
+    }
1902 1902
 
1903
-  $output .= drupal_render($form);
1903
+    $output .= drupal_render($form);
1904 1904
 
1905
-  return $output;
1905
+    return $output;
1906 1906
 }
1907 1907
 
1908 1908
 /**
1909
-  * Validate the privacy preferences form.
1910
-  */
1909
+ * Validate the privacy preferences form.
1910
+ */
1911 1911
 function boincwork_privacyprefs_form_validate($form, &$form_state) {
1912
-  require_boinc('util');
1912
+    require_boinc('util');
1913 1913
   
1914
-  // Verify all non-boolean user input values and notify form API of failures
1915
-  // ... currently there are no non-boolean values!
1914
+    // Verify all non-boolean user input values and notify form API of failures
1915
+    // ... currently there are no non-boolean values!
1916 1916
 }
1917 1917
 
1918 1918
 /**
1919
-  * Handle post-validation submission of privacy preferences form.
1920
-  */
1919
+ * Handle post-validation submission of privacy preferences form.
1920
+ */
1921 1921
 function boincwork_privacyprefs_form_submit($form, &$form_state) {
1922
-  require_boinc(array('user', 'prefs', 'consent'));
1922
+    require_boinc(array('user', 'prefs', 'consent'));
1923 1923
 
1924
-  global $user;
1925
-  $account = user_load($user->uid);
1924
+    global $user;
1925
+    $account = user_load($user->uid);
1926 1926
 
1927
-  // Load BOINC account
1928
-  $boincuser = BoincUser::lookup_id($account->boincuser_id);
1927
+    // Load BOINC account
1928
+    $boincuser = BoincUser::lookup_id($account->boincuser_id);
1929 1929
   
1930
-  // Privacy preferences
1931
-  $boincuser->send_email = ($form_state['values']['send_email']) ? true : false;
1932
-  $boincuser->show_hosts = ($form_state['values']['show_hosts']) ? true : false;
1930
+    // Privacy preferences
1931
+    $boincuser->send_email = ($form_state['values']['send_email']) ? true : false;
1932
+    $boincuser->show_hosts = ($form_state['values']['show_hosts']) ? true : false;
1933 1933
 
1934
-  // Privacy consent options, extract the 'privacyconsent_SHORTNAME'
1935
-  // from values array, and loop over them; each is checked with
1936
-  // check_consent_type(). Also check the current state of the option
1937
-  // in the database. If the form value is a new state, then set it.
1938
-  $result = preg_grep("/^privacyconsent/", array_keys($form_state['values']));
1939
-  $privacyconsent_prefs = array_intersect_key($form_state['values'], array_flip($result));
1940
-  foreach ($privacyconsent_prefs as $name => $newstate) {
1934
+    // Privacy consent options, extract the 'privacyconsent_SHORTNAME'
1935
+    // from values array, and loop over them; each is checked with
1936
+    // check_consent_type(). Also check the current state of the option
1937
+    // in the database. If the form value is a new state, then set it.
1938
+    $result = preg_grep("/^privacyconsent/", array_keys($form_state['values']));
1939
+    $privacyconsent_prefs = array_intersect_key($form_state['values'], array_flip($result));
1940
+    foreach ($privacyconsent_prefs as $name => $newstate) {
1941 1941
     $subname = explode('_', $name)[1];
1942 1942
     $currstate = (check_user_consent($boincuser, $subname)) ? 1 : 0 ;
1943 1943
     list($checkct, $ctid) = check_consent_type($subname);
1944 1944
     if ($checkct && ($currstate != $newstate)) {
1945
-      consent_to_a_policy($boincuser, $ctid, $newstate, 0, 'Webform', time());
1945
+        consent_to_a_policy($boincuser, $ctid, $newstate, 0, 'Webform', time());
1946
+    }
1946 1947
     }
1947
-  }
1948 1948
 
1949
-  //project_prefs_update($boincuser, $main_prefs);
1949
+    //project_prefs_update($boincuser, $main_prefs);
1950 1950
   
1951
-  db_set_active('boinc_rw');
1952
-  db_query("UPDATE user SET send_email = '{$boincuser->send_email}', show_hosts = '{$boincuser->show_hosts}' WHERE id = '{$boincuser->id}'");
1953
-  db_set_active('default');
1951
+    db_set_active('boinc_rw');
1952
+    db_query("UPDATE user SET send_email = '{$boincuser->send_email}', show_hosts = '{$boincuser->show_hosts}' WHERE id = '{$boincuser->id}'");
1953
+    db_set_active('default');
1954 1954
   
1955
-  drupal_set_message(t('Your privacy preferences have been updated.'));
1955
+    drupal_set_message(t('Your privacy preferences have been updated.'));
1956 1956
 }
1957 1957
 
1958 1958
 /**
@@ -1960,14 +1960,14 @@  discard block
 block discarded – undo
1960 1960
  * ignore list.
1961 1961
  */
1962 1962
 function _boincwork_ignore_list_form_submit($form, $form_state) {
1963
-  boincwork_ignore_user_add_user_username($form_state['values']['addusername_toignorelist']);
1964
-  drupal_set_message(
1963
+    boincwork_ignore_user_add_user_username($form_state['values']['addusername_toignorelist']);
1964
+    drupal_set_message(
1965 1965
     bts('@username has been added to your ignore list. See your !privacy_preferences for more details.',
1966
-      array(
1966
+        array(
1967 1967
         '@username' => $form_state['values']['addusername_toignorelist'],
1968 1968
         '!privacy_preferences' => l(bts('privacy preferences', array(), NULL, 'boinc:ignore-user-add'), 'account/prefs/privacy'),
1969
-      ),
1970
-      NULL, 'boinc:ignore-user-add'),
1969
+        ),
1970
+        NULL, 'boinc:ignore-user-add'),
1971 1971
     'status');
1972 1972
 }
1973 1973
 
@@ -1976,37 +1976,37 @@  discard block
 block discarded – undo
1976 1976
  */
1977 1977
 function boincwork_selectapp_form(&$form_state, $apps, $current_app) {
1978 1978
 
1979
-  $form['selectapp'] = array(
1979
+    $form['selectapp'] = array(
1980 1980
     '#type' => 'select',
1981 1981
     '#attributes' => array(
1982
-      'class' => 'task-app-filter',
1983
-      'onchange' => 'this.form.submit();',
1982
+        'class' => 'task-app-filter',
1983
+        'onchange' => 'this.form.submit();',
1984 1984
     ),
1985 1985
     '#default_value' => $current_app,
1986 1986
     '#options' => $apps,
1987 1987
     '#post_render' => array('_boincwork_selectapp_form_callback'),
1988
-  );
1988
+    );
1989 1989
 
1990
-  // Class task-app-filter-submit for this form is used in
1991
-  // theming. CSS sets 'display:none' if javascript is present. Thus
1992
-  // only non-js users/browsers will see the Apply Filter button.
1993
-  $form['submit'] = array(
1990
+    // Class task-app-filter-submit for this form is used in
1991
+    // theming. CSS sets 'display:none' if javascript is present. Thus
1992
+    // only non-js users/browsers will see the Apply Filter button.
1993
+    $form['submit'] = array(
1994 1994
     '#type' => 'submit',
1995 1995
     '#value' => bts('Apply Filter', array(), NULL, 'boinc:form-save'),
1996 1996
     '#attributes' => array('class' => 'js-hide',),
1997
-  );
1997
+    );
1998 1998
 
1999
-  return $form;
1999
+    return $form;
2000 2000
 }
2001 2001
 
2002 2002
 /**
2003 2003
  * Submit function for select appliacation form.
2004 2004
  */
2005 2005
 function boincwork_selectapp_form_submit($form, &$form_state) {
2006
-  $myargs = arg();
2007
-  array_pop($myargs);
2008
-  $newpath = implode('/', $myargs ) . '/' . $form['selectapp']['#value'];
2009
-  $form_state['redirect'] = $newpath;
2006
+    $myargs = arg();
2007
+    array_pop($myargs);
2008
+    $newpath = implode('/', $myargs ) . '/' . $form['selectapp']['#value'];
2009
+    $form_state['redirect'] = $newpath;
2010 2010
 }
2011 2011
 
2012 2012
 /**
@@ -2016,7 +2016,7 @@  discard block
 block discarded – undo
2016 2016
  * 'title' for the Application drop down box.
2017 2017
  */
2018 2018
 function _boincwork_selectapp_form_callback($theContent, $theElement) {
2019
-  $disabled = '<option value="-1" disabled hidden';
2020
-  $newContent = preg_replace('/<option value="-1"/', $disabled, $theContent);
2021
-  return $newContent;
2019
+    $disabled = '<option value="-1" disabled hidden';
2020
+    $newContent = preg_replace('/<option value="-1"/', $disabled, $theContent);
2021
+    return $newContent;
2022 2022
 }
Please login to merge, or discard this patch.