Completed
Pull Request — master (#2567)
by
unknown
14:55
created
drupal/sites/default/boinc/modules/boincuser/boincuser.module 1 patch
Indentation   +778 added lines, -778 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 callback' => 'user_is_logged_in',
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,89 +179,89 @@  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
-  return $items;
202
+    );
203
+    return $items;
204 204
 }
205 205
 
206 206
 /**
207 207
  * Implementation of hook_init()
208 208
  */
209 209
 function boincuser_init() {
210
-  global $user;
211
-  // Skip this check for charts, which are loaded separately
212
-  // (may get duplicate or unexpected messages otherwise)
213
-  if (substr($_GET['q'], 0, 7) == 'charts/') {
210
+    global $user;
211
+    // Skip this check for charts, which are loaded separately
212
+    // (may get duplicate or unexpected messages otherwise)
213
+    if (substr($_GET['q'], 0, 7) == 'charts/') {
214 214
     return;
215
-  }
215
+    }
216 216
 
217
-  // If admin user, do some basic site functionality checks
218
-  if (user_access('administer site configuration')) {
217
+    // If admin user, do some basic site functionality checks
218
+    if (user_access('administer site configuration')) {
219 219
     // Ensure we have a configured BOINC environment
220 220
     boinc_get_path();
221 221
     boinc_get_scheduler_tags();
222
-  }
222
+    }
223 223
   
224
-  // Check credits for the verified contributor role
225
-  boincuser_check_credit_requirements();
224
+    // Check credits for the verified contributor role
225
+    boincuser_check_credit_requirements();
226 226
   
227
-  if (module_exists('boincteam')) {
227
+    if (module_exists('boincteam')) {
228 228
     // Display any persistent team messages
229 229
     boincteam_show_messages();
230
-  }
230
+    }
231 231
 
232
-  // Check if user has agreed to the terms of use. If not, send the
233
-  // user to the terms-of-use form. This is only makes sense if the
234
-  // termsofuse is enabled, by having text in the termsofuse variable.
235
-  $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE);
236
-  $termsofuse = variable_get('boinc_weboptions_termsofuse', '');
237
-  if ( (!empty($termsofuse)) and ($user->uid) ) {
232
+    // Check if user has agreed to the terms of use. If not, send the
233
+    // user to the terms-of-use form. This is only makes sense if the
234
+    // termsofuse is enabled, by having text in the termsofuse variable.
235
+    $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE);
236
+    $termsofuse = variable_get('boinc_weboptions_termsofuse', '');
237
+    if ( (!empty($termsofuse)) and ($user->uid) ) {
238 238
     if ( !boincuser_check_termsofuse($user) and ($existinguser_tou) ) {
239 239
 
240
-      // Admins are exempt, otherwise the admin may not be able to
241
-      // access the site!
242
-      $administrator_role = array_search('administrator', user_roles(true));
243
-      if (!isset($user->roles[$administrator_role])) {
240
+        // Admins are exempt, otherwise the admin may not be able to
241
+        // access the site!
242
+        $administrator_role = array_search('administrator', user_roles(true));
243
+        if (!isset($user->roles[$administrator_role])) {
244 244
         $path = drupal_get_path_alias($_GET['q']);
245 245
 
246 246
         // Any paths that should NOT be redirected go here.
247 247
         // @todo - replace this static array with one that allows
248 248
         // admins to specify custom paths (patterns) to ignore.
249 249
         $paths_to_ignore = array(
250
-          'user/termsofuse',
251
-          'logout',
252
-          'privacy',
253
-          'moderation',
250
+            'user/termsofuse',
251
+            'logout',
252
+            'privacy',
253
+            'moderation',
254 254
         );
255 255
         if (module_exists('boincuser_delete')) {
256
-          $paths_to_ignore[] = 'user/' . $user->uid . '/delete';
257
-          $paths_to_ignore[] = 'user/' . $user->uid . '/deleteconfirm/*';
256
+            $paths_to_ignore[] = 'user/' . $user->uid . '/delete';
257
+            $paths_to_ignore[] = 'user/' . $user->uid . '/deleteconfirm/*';
258 258
         }
259 259
         if (!_boincuser_ignore_paths($path, $paths_to_ignore)) {
260
-          drupal_goto('user/termsofuse');
260
+            drupal_goto('user/termsofuse');
261
+        }
261 262
         }
262
-      }
263 263
     }
264
-  }
264
+    }
265 265
 }
266 266
 
267 267
 /**
@@ -269,13 +269,13 @@  discard block
 block discarded – undo
269 269
  * Drupal user operations
270 270
  */
271 271
 function boincuser_user($op, &$edit, &$account, $category = NULL) {
272
-  require_boinc('boinc_db');
273
-  require_boinc('user');
274
-  require_boinc('xml');
272
+    require_boinc('boinc_db');
273
+    require_boinc('user');
274
+    require_boinc('xml');
275 275
 
276
-  require_boinc('password_compat/password');
277
-  // Handle BOINC integration for users with UID > 1 (skip anonymous and admin)
278
-  if ($account->uid > 1) {
276
+    require_boinc('password_compat/password');
277
+    // Handle BOINC integration for users with UID > 1 (skip anonymous and admin)
278
+    if ($account->uid > 1) {
279 279
     switch($op) {
280 280
     case 'load':
281 281
       // User loading; insert BOINC data into the user object
@@ -283,11 +283,11 @@  discard block
 block discarded – undo
283 283
         SELECT boinc_id, penalty_expiration
284 284
         FROM {boincuser} WHERE uid = %d",
285 285
         $account->uid
286
-      ));
287
-      $account->boincuser_id = $drupal_user->boinc_id;
288
-      $account->boincuser_penalty_expiration = $drupal_user->penalty_expiration;
289
-      db_set_active('boinc_rw');
290
-      $boinc_user = db_fetch_object(db_query("
286
+        ));
287
+        $account->boincuser_id = $drupal_user->boinc_id;
288
+        $account->boincuser_penalty_expiration = $drupal_user->penalty_expiration;
289
+        db_set_active('boinc_rw');
290
+        $boinc_user = db_fetch_object(db_query("
291 291
         SELECT
292 292
           name,
293 293
           authenticator,
@@ -301,27 +301,27 @@  discard block
 block discarded – undo
301 301
         FROM {user}
302 302
         WHERE id = %d",
303 303
         $account->boincuser_id
304
-      ));
305
-      $account->boincuser_name = $boinc_user->name;
306
-      $account->boincuser_account_key = $boinc_user->authenticator;
307
-      $account->boincuser_weak_auth = md5($boinc_user->authenticator . $boinc_user->passwd_hash);
308
-      $account->boincuser_total_credit = round($boinc_user->total_credit);
309
-      $account->boincuser_expavg_credit = round($boinc_user->expavg_credit);
310
-      $account->boincuser_expavg_time = round($boinc_user->expavg_time);
311
-      $account->boincuser_cpid = md5($boinc_user->cross_project_id . $account->mail);
312
-      $account->boincuser_default_pref_set = $boinc_user->venue;
313
-      $account->boincteam_id = $boinc_user->teamid;
314
-      db_set_active('default');
315
-      // Set Drupal team ID
316
-      $account->team = NULL;
317
-      if ($account->boincteam_id) {
304
+        ));
305
+        $account->boincuser_name = $boinc_user->name;
306
+        $account->boincuser_account_key = $boinc_user->authenticator;
307
+        $account->boincuser_weak_auth = md5($boinc_user->authenticator . $boinc_user->passwd_hash);
308
+        $account->boincuser_total_credit = round($boinc_user->total_credit);
309
+        $account->boincuser_expavg_credit = round($boinc_user->expavg_credit);
310
+        $account->boincuser_expavg_time = round($boinc_user->expavg_time);
311
+        $account->boincuser_cpid = md5($boinc_user->cross_project_id . $account->mail);
312
+        $account->boincuser_default_pref_set = $boinc_user->venue;
313
+        $account->boincteam_id = $boinc_user->teamid;
314
+        db_set_active('default');
315
+        // Set Drupal team ID
316
+        $account->team = NULL;
317
+        if ($account->boincteam_id) {
318 318
         $account->team = db_result(db_query("
319 319
           SELECT nid FROM {boincteam} WHERE team_id = %d",
320
-          $account->boincteam_id
320
+            $account->boincteam_id
321 321
         ));
322
-      }
323
-      // Set post count
324
-      $account->post_count = db_result(db_query("
322
+        }
323
+        // Set post count
324
+        $account->post_count = db_result(db_query("
325 325
         SELECT COUNT(*) +
326 326
         (
327 327
           SELECT COUNT(*) FROM {node}
@@ -334,8 +334,8 @@  discard block
 block discarded – undo
334 334
         WHERE comments.uid = '%d'
335 335
         AND node.status = 1",
336 336
         $account->uid, $account->uid
337
-      ));
338
-      break;
337
+        ));
338
+        break;
339 339
       
340 340
     case 'view':
341 341
       // SAMPLE: Add BOINC data to the user profile
@@ -361,60 +361,60 @@  discard block
 block discarded – undo
361 361
         case 'user_account':
362 362
           // Validate data before updating user account info
363 363
           boincuser_account_validate($edit, $account);
364
-          break;
364
+            break;
365 365
         
366 366
         default:
367 367
           
368 368
         }
369 369
         // We don't want to save validation source, so remove it
370 370
         $edit['validation_source'] = null;
371
-      }
372
-      break;
371
+        }
372
+        break;
373 373
       
374 374
     case 'insert':
375 375
       // New user being added to the system
376 376
       $imported = $_SESSION['importedUser'];
377
-      unset($_SESSION['importedUser']);
377
+        unset($_SESSION['importedUser']);
378 378
       
379
-      watchdog(
379
+        watchdog(
380 380
         'boincuser',
381 381
         'Creating user account for %email_addr',
382 382
         array('%email_addr' => $edit['mail']),
383 383
         WATCHDOG_NOTICE
384
-      );
384
+        );
385 385
       
386
-      // The create_acount RPC will call this block of code when
387
-      // user_save() is used. If user is registering using the Web
388
-      // registration form, create a BOINC user and relationships.
389
-      // Create a BOINC account unless importing from BOINC.
390
-      if (!$imported) {
386
+        // The create_acount RPC will call this block of code when
387
+        // user_save() is used. If user is registering using the Web
388
+        // registration form, create a BOINC user and relationships.
389
+        // Create a BOINC account unless importing from BOINC.
390
+        if (!$imported) {
391 391
 
392 392
         if ($edit['boincuser_name']) {
393
-          $myname = $edit['boincuser_name'];
393
+            $myname = $edit['boincuser_name'];
394 394
         }
395 395
         else if ($edit['name']) {
396
-          $myname = $edit['name'];
396
+            $myname = $edit['name'];
397 397
         }
398 398
         else {
399
-          $myname = 'noname';
399
+            $myname = 'noname';
400 400
         }
401 401
 
402 402
         $user_params = array(
403
-          'email_addr' => $edit['mail'],
404
-          'name' => $myname,
405
-          'passwd_hash' => password_hash( md5($edit['pass'].$edit['mail']) , PASSWORD_DEFAULT ),
403
+            'email_addr' => $edit['mail'],
404
+            'name' => $myname,
405
+            'passwd_hash' => password_hash( md5($edit['pass'].$edit['mail']) , PASSWORD_DEFAULT ),
406 406
         );
407 407
         $boinc_user = boincuser_register_make_user($user_params);
408 408
         if (!$boinc_user) {
409
-          // Account exists with this email addr
410
-          form_set_error('email', bts('Error creating BOINC account.', array(), NULL, 'boinc:add-new-user'));
411
-          return;
409
+            // Account exists with this email addr
410
+            form_set_error('email', bts('Error creating BOINC account.', array(), NULL, 'boinc:add-new-user'));
411
+            return;
412 412
         }
413 413
 
414 414
         // Add user to community role by default (not banned)
415 415
         $unrestricted_role = array_search('community member', user_roles(true)); 
416 416
         $edit['roles'] = array(
417
-          $unrestricted_role => ''
417
+            $unrestricted_role => ''
418 418
         );
419 419
 
420 420
         // Disable show_hosts flag, set to TRUE by default
@@ -425,20 +425,20 @@  discard block
 block discarded – undo
425 425
         // Cross reference Drupal account with BOINC
426 426
         $reference = db_query("INSERT INTO {boincuser} SET uid='%d', boinc_id='%d'", $account->uid, $boinc_user->id);
427 427
         if (!$reference) {
428
-          drupal_set_message(t('Error connecting BOINC account.'), 'error');
429
-          return;
428
+            drupal_set_message(t('Error connecting BOINC account.'), 'error');
429
+            return;
430 430
         }
431 431
 
432 432
         // if terms of use exist, the user must agree.
433 433
         $termsofuse = variable_get('boinc_weboptions_termsofuse', '');
434 434
         if (!empty($termsofuse)) {
435
-          $reference2 = boincuser_consentto_termsofuse($account);
435
+            $reference2 = boincuser_consentto_termsofuse($account);
436 436
         }
437 437
 
438 438
         // Don't save custom fields to the Drupal user object
439 439
         $edit['boincuser_name'] = null;
440
-      }
441
-      break;
440
+        }
441
+        break;
442 442
       
443 443
     case 'update':
444 444
       if (isset($edit['update_source'])) {
@@ -448,9 +448,9 @@  discard block
 block discarded – undo
448 448
         case 'user_account':
449 449
           // Ensure that BOINC data is altered
450 450
           $boinc_user = BoincUser::lookup_id($account->boincuser_id);
451
-          $changing_email = ($edit['mail'] AND $edit['mail'] != $boinc_user->email_addr) ? true : false;
452
-          $changing_pass = ($edit['pass']) ? true : false;
453
-          if ($changing_email OR $changing_pass) {
451
+            $changing_email = ($edit['mail'] AND $edit['mail'] != $boinc_user->email_addr) ? true : false;
452
+            $changing_pass = ($edit['pass']) ? true : false;
453
+            if ($changing_email OR $changing_pass) {
454 454
             // Set password hash appropriately
455 455
             $passwd = ($edit['pass']) ? $edit['pass'] : $edit['current_pass'];
456 456
             $passwd_hash = password_hash( md5($passwd.$edit['mail']), PASSWORD_DEFAULT );
@@ -459,39 +459,39 @@  discard block
 block discarded – undo
459 459
             $result = $boinc_user->update(
460 460
                 "email_addr='{$email_addr}', passwd_hash='{$passwd_hash}'"
461 461
             );
462
-          }
463
-          break;
462
+            }
463
+            break;
464 464
         case 'user_profile':
465 465
           if ($edit['boincuser_name'] != $boinc_user->name) {
466 466
             $boincuser_name = $edit['boincuser_name'];
467 467
             $result = $boinc_user->update(
468 468
                 "name='{$boincuser_name}'"
469 469
             );
470
-          }
471
-          break;
470
+            }
471
+            break;
472 472
         default:
473 473
         }
474 474
         // We don't want to save update source or duplicate custom fields, so
475 475
         // remove them before continuing to core Drupal routines
476 476
         $edit['update_source'] = null;
477 477
         $edit['boincuser_name'] = null;
478
-      }
479
-      break;
478
+        }
479
+        break;
480 480
 
481 481
     case 'login':
482 482
       // Function is forward compatible to Drupal 7
483 483
       boincuser_user_login($edit, $account);
484
-      break;
484
+        break;
485 485
 
486 486
     case 'delete':
487 487
       // Function is forward compatible to Drupal 7
488 488
       boincuser_user_delete($account);
489
-      break;
489
+        break;
490 490
 
491 491
     default:
492 492
       
493 493
     }
494
-  }
494
+    }
495 495
 }
496 496
 
497 497
 /**
@@ -500,31 +500,31 @@  discard block
 block discarded – undo
500 500
  *(forward compatible to Drupal 7).
501 501
  */
502 502
 function boincuser_user_login(&$edit, $account) {
503
-  $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE);
504
-  $termsofuse = variable_get('boinc_weboptions_termsofuse', '');
503
+    $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE);
504
+    $termsofuse = variable_get('boinc_weboptions_termsofuse', '');
505 505
 
506
-  // Check if user has agreed to terms of use.
507
-  if ( (!empty($termsofuse)) and ($account->uid) and 
506
+    // Check if user has agreed to terms of use.
507
+    if ( (!empty($termsofuse)) and ($account->uid) and 
508 508
        (!boincuser_check_termsofuse($account)) and ($existinguser_tou) ) {
509 509
 
510 510
     // Admins are exempted.
511 511
     $administrator_role = array_search('administrator', user_roles(true));
512 512
     if (!isset($account->roles[$administrator_role])) {
513 513
 
514
-      // Find and save the current destination and use as an parameter
515
-      // to send the user back to here he/she came from.
516
-      $np = ltrim('user/termsofuse', '/');
517
-      $path_for_destination = rawurlencode($np);
514
+        // Find and save the current destination and use as an parameter
515
+        // to send the user back to here he/she came from.
516
+        $np = ltrim('user/termsofuse', '/');
517
+        $path_for_destination = rawurlencode($np);
518 518
 
519
-      $query_for_destination = '';
520
-      $prevdest = $_REQUEST['destination'];
521
-      if ($prevdest) {
519
+        $query_for_destination = '';
520
+        $prevdest = $_REQUEST['destination'];
521
+        if ($prevdest) {
522 522
         $query_for_destination = '?destination=' . $prevdest;
523
-      }
524
-      $_REQUEST['destination'] = $path_for_destination . $query_for_destination;
523
+        }
524
+        $_REQUEST['destination'] = $path_for_destination . $query_for_destination;
525 525
 
526 526
     }
527
-  }
527
+    }
528 528
 }
529 529
 
530 530
 /**
@@ -533,16 +533,16 @@  discard block
 block discarded – undo
533 533
  */
534 534
 function boincuser_user_delete($account) {
535 535
 
536
-  $boincid = $account->boincuser_id;
537
-  // bug in comment module, remove user name from comments. Find all
538
-  // comments with uid=0 and clear the field 'name'.
539
-  $qrc1 = db_query("UPDATE {comments} SET comments.name='' WHERE comments.uid=0");
536
+    $boincid = $account->boincuser_id;
537
+    // bug in comment module, remove user name from comments. Find all
538
+    // comments with uid=0 and clear the field 'name'.
539
+    $qrc1 = db_query("UPDATE {comments} SET comments.name='' WHERE comments.uid=0");
540 540
 
541
-  // Delete entry in drupal boincuser table.
542
-  $qrc2 = db_query("DELETE FROM {boincuser} WHERE uid=%d", $account->uid);
543
-  if (!$qrc2) {
541
+    // Delete entry in drupal boincuser table.
542
+    $qrc2 = db_query("DELETE FROM {boincuser} WHERE uid=%d", $account->uid);
543
+    if (!$qrc2) {
544 544
     watchdog('user', 'Error deleting user account, boincuser table UID: %uid.', array('%uid' => $account->uid), WATCHDOG_ERROR);
545
-  }
545
+    }
546 546
 }
547 547
 
548 548
 
@@ -551,13 +551,13 @@  discard block
 block discarded – undo
551 551
  * Obsolete in Drupal 7...
552 552
  */
553 553
 function boincuser_nodeapi(&$node, $op, $a3 = null, $a4 = null) {
554
-  // In Drupal 7, these operation cases will all exist as their own hooks,
555
-  // so let's approximate that here so that this function can simply be removed
556
-  // upon migration to 7
557
-  switch($op) {
558
-  case 'update':
554
+    // In Drupal 7, these operation cases will all exist as their own hooks,
555
+    // so let's approximate that here so that this function can simply be removed
556
+    // upon migration to 7
557
+    switch($op) {
558
+    case 'update':
559 559
     boincuser_node_update($node);
560
-  }
560
+    }
561 561
 }
562 562
 
563 563
 /**
@@ -565,8 +565,8 @@  discard block
 block discarded – undo
565 565
  * is updated (forward compatible to Drupal 7)
566 566
  */
567 567
 function boincuser_node_update($node) {
568
-  switch($node->type) {
569
-  case 'profile':
568
+    switch($node->type) {
569
+    case 'profile':
570 570
     // Update the BOINC database directly
571 571
     $account = user_load($node->uid);
572 572
     // Save user account data
@@ -578,11 +578,11 @@  discard block
 block discarded – undo
578 578
       UPDATE user
579 579
       SET country = '%s', postal_code = '%s', url = '%s', has_profile = 1
580 580
       WHERE id = %d",
581
-      $country, $postal_code, $url, $account->boincuser_id
581
+        $country, $postal_code, $url, $account->boincuser_id
582 582
     );
583 583
     db_set_active('default');
584 584
     if (!$account_updated) {
585
-      drupal_set_message(t('Error saving BOINC account info.'), 'error');
585
+        drupal_set_message(t('Error saving BOINC account info.'), 'error');
586 586
     }
587 587
     // Save profile data
588 588
     $response1 = $node->field_background[0]['value'];
@@ -593,16 +593,16 @@  discard block
 block discarded – undo
593 593
       SET userid = %d, response1 = '%s', response2 = '%s'
594 594
       ON DUPLICATE KEY UPDATE
595 595
         response1 = '%s', response2 = '%s'",
596
-      $account->boincuser_id, $response1, $response2,
597
-      $response1, $response2
596
+        $account->boincuser_id, $response1, $response2,
597
+        $response1, $response2
598 598
     );
599 599
     db_set_active('default');
600 600
     if (!$profile_updated) {
601
-      drupal_set_message(t('Error saving BOINC profile.'), 'error');
601
+        drupal_set_message(t('Error saving BOINC profile.'), 'error');
602 602
     }
603 603
     break;
604 604
     
605
-  default:
605
+    default:
606 606
     
607 607
   }
608 608
 }
@@ -611,19 +611,19 @@  discard block
 block discarded – undo
611 611
 * Implementation of hook_views_api()
612 612
 */
613 613
 function boincuser_views_api() {
614
-  return array(
614
+    return array(
615 615
     'api' => 2.0,
616 616
     'path' => drupal_get_path('module', 'boincuser')
617
-  );
617
+    );
618 618
 }
619 619
 
620 620
 /**
621 621
 * Implementation of hook_form_alter()
622 622
 */
623 623
 function boincuser_form_alter(&$form, $form_state, $form_id) {
624
-  global $user;
625
-  switch ($form_id) {
626
-  case 'flag_confirm':
624
+    global $user;
625
+    switch ($form_id) {
626
+    case 'flag_confirm':
627 627
     // The URL seems to be the only way to put any kind of context to this
628 628
     // request!
629 629
     $action = arg(2);
@@ -632,25 +632,25 @@  discard block
 block discarded – undo
632 632
     
633 633
     // Wrap action buttons for styling consistency
634 634
     $form['form control tabs prefix'] = array(
635
-      '#value' => '<ul class="form-control tab-list">',
636
-      '#weight' => 1001,
635
+        '#value' => '<ul class="form-control tab-list">',
636
+        '#weight' => 1001,
637 637
     );
638 638
     
639 639
     switch ($flag_type) {
640 640
     case 'friend':
641 641
       $friend_id = $form['content_id']['#value'];
642
-      $flag = flag_get_flag('friend');
643
-      $friend_status = flag_friend_determine_friend_status($flag, $friend_id, $user->uid);
642
+        $flag = flag_get_flag('friend');
643
+        $friend_status = flag_friend_determine_friend_status($flag, $friend_id, $user->uid);
644 644
       
645
-      // General friend form overrides
646
-      $form['flag_friend_submit']['#prefix'] = '<li class="first tab">';
647
-      $form['flag_friend_submit']['#value'] = bts('Send request', array(), NULL, 'boinc:friends-page');
648
-      $form['flag_friend_submit']['#type'] = 'submit';
649
-      $form['flag_friend_submit']['#suffix'] = '</li>';
650
-      $form['flag_friend_submit']['#weight'] = 1002;
645
+        // General friend form overrides
646
+        $form['flag_friend_submit']['#prefix'] = '<li class="first tab">';
647
+        $form['flag_friend_submit']['#value'] = bts('Send request', array(), NULL, 'boinc:friends-page');
648
+        $form['flag_friend_submit']['#type'] = 'submit';
649
+        $form['flag_friend_submit']['#suffix'] = '</li>';
650
+        $form['flag_friend_submit']['#weight'] = 1002;
651 651
       
652
-      switch ($friend_status) {
653
-      case FLAG_FRIEND_BOTH:
652
+        switch ($friend_status) {
653
+        case FLAG_FRIEND_BOTH:
654 654
       case FLAG_FRIEND_FLAGGED:
655 655
         unset($form['actions']);
656 656
         $form['flag_friend_submit']['#value'] = bts('Remove friend', array(), NULL, 'boinc:friends-remove');
@@ -659,53 +659,53 @@  discard block
 block discarded – undo
659 659
         $form['#submit'][] = 'boincuser_fix_unfriend_form_submit';
660 660
         $form['#submit'][] = $final_handler;
661 661
         break;
662
-      case FLAG_FRIEND_PENDING:
662
+        case FLAG_FRIEND_PENDING:
663 663
         unset($form['actions']);
664 664
         $form['flag_friend_submit']['#value'] = bts('Remove request', array(), NULL, 'boinc:friends-page');
665 665
         break;
666
-      case FLAG_FRIEND_APPROVAL:
666
+        case FLAG_FRIEND_APPROVAL:
667 667
         if ($action == 'flag') {
668
-          $form['flag_friend_submit']['#value'] = bts('Approve request', array(), NULL, 'boinc:friends-page');
668
+            $form['flag_friend_submit']['#value'] = bts('Approve request', array(), NULL, 'boinc:friends-page');
669 669
         }
670 670
         elseif ($action == 'unflag') {
671
-          unset($form['actions']);
672
-          $form['flag_friend_submit']['#value'] = bts('Deny request', array(), NULL, 'boinc:friends-page');
671
+            unset($form['actions']);
672
+            $form['flag_friend_submit']['#value'] = bts('Deny request', array(), NULL, 'boinc:friends-page');
673 673
         }
674 674
         break;
675
-      case FLAG_FRIEND_UNFLAGGED:
675
+        case FLAG_FRIEND_UNFLAGGED:
676 676
       default:
677 677
         $user_links[] = array(
678
-          'title' => bts('Add as friend', array(), NULL, 'boinc:friends-add'),
679
-          'href' => "flag/confirm/flag/friend/{$account->uid}"
678
+            'title' => bts('Add as friend', array(), NULL, 'boinc:friends-add'),
679
+            'href' => "flag/confirm/flag/friend/{$account->uid}"
680 680
         );
681
-      }
682
-      break;
681
+        }
682
+        break;
683 683
       
684 684
     default:
685 685
     }
686 686
     
687 687
     $form['cancel'] = array(
688
-      '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $cancel_dest) . '</li>',
689
-      '#weight' => 1004,
688
+        '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $cancel_dest) . '</li>',
689
+        '#weight' => 1004,
690 690
     );
691 691
     $form['form control tabs suffix'] = array(
692
-      '#value' => '</ul>',
693
-      '#weight' => 1010,
692
+        '#value' => '</ul>',
693
+        '#weight' => 1010,
694 694
     );
695 695
     
696 696
     break;
697 697
     
698
-  // General node edit form
699
-  case 'news_node_form':
698
+    // General node edit form
699
+    case 'news_node_form':
700 700
     $form['separator_bottom'] = array(
701
-      '#value' => '<div class="separator buttons"></div>',
702
-      '#weight' => 999,
701
+        '#value' => '<div class="separator buttons"></div>',
702
+        '#weight' => 999,
703 703
     );
704 704
     
705 705
     // Wrap action buttons for styling consistency
706 706
     $form['buttons']['form control tabs prefix'] = array(
707
-      '#value' => '<ul class="form-control tab-list">',
708
-      '#weight' => 1001,
707
+        '#value' => '<ul class="form-control tab-list">',
708
+        '#weight' => 1001,
709 709
     );
710 710
     $form['buttons']['submit']['#prefix'] = '<li class="first tab">';
711 711
     $form['buttons']['submit']['#value'] = bts('Save changes', array(), NULL, 'boinc:form-save');
@@ -718,15 +718,15 @@  discard block
 block discarded – undo
718 718
     $form['buttons']['preview_changes']['#suffix'] = '</li>';
719 719
     $form['buttons']['preview_changes']['#weight'] = 1004;
720 720
     $form['buttons']['cancel'] = array(
721
-      '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "node/{$form['nid']['#value']}") . '</li>',
722
-      '#weight' => 1005,
721
+        '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "node/{$form['nid']['#value']}") . '</li>',
722
+        '#weight' => 1005,
723 723
     );
724 724
     $form['buttons']['delete']['#prefix'] = '<li class="tab">';
725 725
     $form['buttons']['delete']['#suffix'] = '</li>';
726 726
     $form['buttons']['delete']['#weight'] = 1006;
727 727
     $form['buttons']['form control tabs suffix'] = array(
728
-      '#value' => '</ul>',
729
-      '#weight' => 1010,
728
+        '#value' => '</ul>',
729
+        '#weight' => 1010,
730 730
     );
731 731
     
732 732
     // Preview is ugly, unset until it works
@@ -734,16 +734,16 @@  discard block
 block discarded – undo
734 734
 
735 735
     break;
736 736
   
737
-  case 'node_delete_confirm':
737
+    case 'node_delete_confirm':
738 738
     $form['separator_bottom'] = array(
739
-      '#value' => '<div class="separator buttons"></div>',
740
-      '#weight' => 999,
739
+        '#value' => '<div class="separator buttons"></div>',
740
+        '#weight' => 999,
741 741
     );
742 742
     
743 743
     // Wrap action buttons for styling consistency
744 744
     $form['actions']['form control tabs prefix'] = array(
745
-      '#value' => '<ul class="form-control tab-list">',
746
-      '#weight' => 1001,
745
+        '#value' => '<ul class="form-control tab-list">',
746
+        '#weight' => 1001,
747 747
     );
748 748
     $form['actions']['submit']['#prefix'] = '<li class="first tab">';
749 749
     $form['actions']['submit']['#value'] = bts('Delete', array(), NULL, 'boinc:form-delete');
@@ -751,23 +751,23 @@  discard block
 block discarded – undo
751 751
     $form['actions']['submit']['#weight'] = 1002;
752 752
     $form['actions']['cancel'] = array(
753 753
         '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "node/{$form['nid']['#value']}") . '</li>',
754
-      '#weight' => 1005,
754
+        '#weight' => 1005,
755 755
     );
756 756
     $form['actions']['form control tabs suffix'] = array(
757
-      '#value' => '</ul>',
758
-      '#weight' => 1010,
757
+        '#value' => '</ul>',
758
+        '#weight' => 1010,
759 759
     );
760 760
     $form['#redirect'] = 'account/profile';
761 761
     break;
762 762
     
763
-  case 'privatemsg_new':
763
+    case 'privatemsg_new':
764 764
     
765 765
     $form['privatemsg']['body']['#title'] = '';
766 766
     
767 767
     // Wrap action buttons for styling consistency
768 768
     $form['privatemsg']['form control tabs prefix'] = array(
769
-      '#value' => '<ul class="form-control tab-list">',
770
-      '#weight' => 1001,
769
+        '#value' => '<ul class="form-control tab-list">',
770
+        '#weight' => 1001,
771 771
     );
772 772
     $form['privatemsg']['submit']['#prefix'] = '<li class="first tab">';
773 773
     $form['privatemsg']['submit']['#value'] = bts('Send message', array(), NULL, 'boinc:private-message');
@@ -777,26 +777,26 @@  discard block
 block discarded – undo
777 777
     $form['privatemsg']['preview']['#suffix'] = '</li>';
778 778
     $form['privatemsg']['preview']['#weight'] = 1003;
779 779
     $form['privatemsg']['cancel'] = array(
780
-      '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>',
781
-      '#weight' => 1004,
780
+        '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>',
781
+        '#weight' => 1004,
782 782
     );
783 783
     $form['privatemsg']['form control tabs suffix'] = array(
784
-      '#value' => '</ul>',
785
-      '#weight' => 1010,
784
+        '#value' => '</ul>',
785
+        '#weight' => 1010,
786 786
     );
787 787
     
788 788
     unset($form['privatemsg']['recipient_display']);
789 789
     
790 790
     break;
791 791
     
792
-  // Login form
793
-  case 'user_login':
792
+    // Login form
793
+    case 'user_login':
794 794
   case 'user_login_block':
795 795
       drupal_set_title(bts('Login', array(), NULL, 'boinc:menu-link'));
796 796
     // Replace name with email in login form
797 797
     unset($form['name']);
798 798
     array_unshift($form, array(
799
-      'email' => array(
799
+        'email' => array(
800 800
         '#type' => 'textfield',
801 801
         '#title' => bts('Email address', array(), NULL, 'boinc:email-address-to-login'),
802 802
         '#size' => ($form_id == 'user_login_block') ? 15 : 60,
@@ -804,18 +804,18 @@  discard block
 block discarded – undo
804 804
         '#required' => TRUE,
805 805
         '#attributes' => array('tabindex' => '1'),
806 806
         '#description' => bts('Enter your @s email address.', array('@s' => variable_get('site_name', 'Drupal-BOINC')), NULL, 'boinc:standard-login-page')
807
-      ),
808
-      'validation_source' => array(
807
+        ),
808
+        'validation_source' => array(
809 809
         '#type' => 'hidden',
810 810
         '#value' => 'user_login'
811
-      )
811
+        )
812 812
     ));
813 813
     $form['#redirect'] = 'home';
814 814
     
815 815
     // Wrap action buttons for styling consistency
816 816
     $form['buttons']['form control tabs prefix'] = array(
817
-      '#value' => '<ul class="form-control tab-list">',
818
-      '#weight' => 1001,
817
+        '#value' => '<ul class="form-control tab-list">',
818
+        '#weight' => 1001,
819 819
     );
820 820
     $form['buttons']['submit'] = $form['submit'];
821 821
     $form['buttons']['submit']['#prefix'] = '<li class="first tab">';
@@ -823,8 +823,8 @@  discard block
 block discarded – undo
823 823
     $form['buttons']['submit']['#suffix'] = '</li>';
824 824
     $form['buttons']['submit']['#weight'] = 1002;
825 825
     $form['buttons']['form control tabs suffix'] = array(
826
-      '#value' => '</ul>',
827
-      '#weight' => 1010,
826
+        '#value' => '</ul>',
827
+        '#weight' => 1010,
828 828
     );
829 829
     unset($form['submit']);
830 830
     
@@ -833,23 +833,23 @@  discard block
 block discarded – undo
833 833
     isset($form['buttons']['submit']['#attributes']) ? array_push($form['buttons']['submit']['#attributes'], array('tabindex' => '3')) : $form['buttons']['submit']['#attributes'] = array('tabindex' => '3');
834 834
     // If the user login form is being submitted, use BOINC validation handler.
835 835
     if (isset($form_state['post']['email']) and isset($form_state['post']['pass'])) {
836
-      // Find the local validation function's entry so we can replace it.
837
-      $array_key = array_search('user_login_authenticate_validate', $form['#validate']);
838
-      if ($array_key === FALSE) {
836
+        // Find the local validation function's entry so we can replace it.
837
+        $array_key = array_search('user_login_authenticate_validate', $form['#validate']);
838
+        if ($array_key === FALSE) {
839 839
         // Could not find it. Some other module must have run form_alter().
840 840
         // We will simply add our validation just before the final validator.
841 841
         $final_validator = array_pop($form['#validate']);
842 842
         $form['#validate'][] = 'boincuser_login_validate';
843 843
         $form['#validate'][] = $final_validator;
844
-      } else {
844
+        } else {
845 845
         // Replace the local validation function with BOINC validation
846 846
         $form['#validate'][$array_key] = 'boincuser_login_validate';
847
-      }
847
+        }
848 848
     }
849 849
     break;
850 850
     
851
-  // User credentials form
852
-  case 'user_profile_form':
851
+    // User credentials form
852
+    case 'user_profile_form':
853 853
     
854 854
     // Use the displaly name as the title, not the username
855 855
     $account = user_load($form['#uid']);
@@ -859,7 +859,7 @@  discard block
 block discarded – undo
859 859
     // coming from the password reset function
860 860
     $reset_pass = (strpos($_SERVER['HTTP_REFERER'], "/user/reset/{$form['#uid']}") === FALSE) ? 0 : 1;
861 861
     if ($reset_pass) {
862
-      $_SESSION['reset_pass'] = 1;
862
+        $_SESSION['reset_pass'] = 1;
863 863
     }
864 864
 
865 865
     // Adjust form elements already present
@@ -871,50 +871,50 @@  discard block
 block discarded – undo
871 871
     $form['account']['pass']['#size'] = 17;
872 872
 
873 873
     if (!$reset_pass AND ($user->uid == $account->uid OR !user_access('administer users'))) {
874
-      // Add a password authenticator, required to change email or pw
875
-      $form['account']['current_pass'] = array(
874
+        // Add a password authenticator, required to change email or pw
875
+        $form['account']['current_pass'] = array(
876 876
         '#type' => 'password',
877 877
         '#title' => bts('Enter your password to save changes', array(), NULL, 'boinc:account-credentials-change'),
878 878
         '#description' => bts('Enter your current password if changing your email
879 879
           address or password.', array(), NULL, 'boinc:account-credentials-change'),
880 880
         '#size' => 17,
881 881
         '#attributes' => array(
882
-          'autocomplete' => 'off',
882
+            'autocomplete' => 'off',
883 883
         ),
884
-      );
884
+        );
885 885
     }
886 886
     
887 887
     // Add account keys, CPID, etc
888 888
     $form['account']['boincuser_id'] = array(
889
-      '#value' => '
889
+        '#value' => '
890 890
         <div class="form-item">
891 891
           <label>' . bts('BOINC user ID', array(), NULL, 'boinc:account-credentials-change') . '</label>
892 892
           <span>' . $account->boincuser_id . '</span>
893 893
         </div>',
894 894
     );
895 895
     $form['account']['user_id'] = array(
896
-      '#value' => '
896
+        '#value' => '
897 897
         <div class="form-item">
898 898
           <label>' . bts('Drupal user ID', array(), NULL, 'boinc:account-credentials-change') . '</label>
899 899
           <span>' . $account->uid . '</span>
900 900
         </div>',
901 901
     );
902 902
     $form['account']['account_key'] = array(
903
-      '#value' => '
903
+        '#value' => '
904 904
         <div class="form-item">
905 905
           <label>' . bts('Account key', array(), NULL, 'boinc:account-credentials-change') . '</label>
906 906
           <span>' . $account->boincuser_account_key . '</span>
907 907
         </div>',
908 908
     );
909 909
     $form['account']['weak_account_key'] = array(
910
-      '#value' => '
910
+        '#value' => '
911 911
         <div class="form-item">
912 912
           <label>' . bts('Weak account key', array(), NULL, 'boinc:account-credentials-change') . '</label>
913 913
           <span>' . "{$account->boincuser_id}_{$account->boincuser_weak_auth}" . '</span>
914 914
         </div>',
915 915
     );
916 916
     $form['account']['cpid'] = array(
917
-      '#value' => '
917
+        '#value' => '
918 918
         <div class="form-item">
919 919
           <label>' . bts('Cross-project ID', array(), NULL, 'boinc:account-credentials-change') . '</label>
920 920
           <span>' . $account->boincuser_cpid . '</span>
@@ -922,30 +922,30 @@  discard block
 block discarded – undo
922 922
     );
923 923
     
924 924
     $form['account']['separator_bottom'] = array(
925
-      '#value' => '<div class="separator buttons"></div>'
925
+        '#value' => '<div class="separator buttons"></div>'
926 926
     );
927 927
     
928 928
     // Wrap action buttons for styling consistency
929 929
     $form['form control tabs prefix'] = array(
930
-      '#value' => '<ul class="form-control tab-list">',
931
-      '#weight' => 1001,
930
+        '#value' => '<ul class="form-control tab-list">',
931
+        '#weight' => 1001,
932 932
     );
933 933
     $form['submit']['#prefix'] = '<li class="first tab">';
934 934
     $form['submit']['#value'] = bts('Save changes', array(), NULL, 'boinc:form-save');
935 935
     $form['submit']['#suffix'] = '</li>';
936 936
     $form['submit']['#weight'] = 1002;
937 937
     $form['cancel'] = array(
938
-      '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>',
939
-      '#weight' => 1003,
938
+        '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>',
939
+        '#weight' => 1003,
940 940
     );
941 941
     if (isset($form['delete']) AND is_array($form['delete'])) {
942
-      $form['delete']['#prefix'] = '<li class="first alt tab">';
943
-      $form['delete']['#suffix'] = '</li>';
944
-      $form['delete']['#weight'] = 1004;
942
+        $form['delete']['#prefix'] = '<li class="first alt tab">';
943
+        $form['delete']['#suffix'] = '</li>';
944
+        $form['delete']['#weight'] = 1004;
945 945
     }
946 946
     $form['form control tabs suffix'] = array(
947
-      '#value' => '</ul>',
948
-      '#weight' => 1010,
947
+        '#value' => '</ul>',
948
+        '#weight' => 1010,
949 949
     );
950 950
     
951 951
     // Rearrange form elements
@@ -962,7 +962,7 @@  discard block
 block discarded – undo
962 962
     // Remove redundant / unnecessary form elements
963 963
     unset($form['theme_select']);
964 964
     if (!module_exists('boincuser_delete')) {
965
-      unset($form['delete']);
965
+        unset($form['delete']);
966 966
     }
967 967
     
968 968
     // These are on the Community preferences form (boincwork module)
@@ -978,40 +978,40 @@  discard block
 block discarded – undo
978 978
     
979 979
     // Internal fields to indicate where these user changes are taking place
980 980
     array_unshift($form, array(
981
-      'validation_source' => array(
981
+        'validation_source' => array(
982 982
         '#type' => 'hidden',
983 983
         '#value' => 'user_account'
984
-      ),
985
-      'update_source' => array(
984
+        ),
985
+        'update_source' => array(
986 986
         '#type' => 'hidden',
987 987
         '#value' => 'user_account'
988
-      )
988
+        )
989 989
     ));
990 990
     break;
991 991
     
992
-  case 'profile_node_form':
992
+    case 'profile_node_form':
993 993
     
994 994
     // Use the display name as the title, not the username
995 995
     $account = user_load($form['uid']['#value']);
996 996
     drupal_set_title($account->boincuser_name);
997 997
     
998 998
     $form['separator_bottom'] = array(
999
-      '#value' => '<div class="separator buttons"></div>',
1000
-      '#weight' => 999,
999
+        '#value' => '<div class="separator buttons"></div>',
1000
+        '#weight' => 999,
1001 1001
     );
1002 1002
     
1003 1003
     if (module_exists('captcha')) {
1004
-      // Add an optional captcha
1005
-      $form['profile_captcha'] = array(
1004
+        // Add an optional captcha
1005
+        $form['profile_captcha'] = array(
1006 1006
         '#type' => 'captcha',
1007 1007
         '#weight' => 1000,
1008
-      );
1008
+        );
1009 1009
     }
1010 1010
     
1011 1011
     // Wrap action buttons for styling consistency
1012 1012
     $form['buttons']['form control tabs prefix'] = array(
1013
-      '#value' => '<ul class="form-control tab-list">',
1014
-      '#weight' => 1001,
1013
+        '#value' => '<ul class="form-control tab-list">',
1014
+        '#weight' => 1001,
1015 1015
     );
1016 1016
     $form['buttons']['submit']['#prefix'] = '<li class="first tab">';
1017 1017
     $form['buttons']['submit']['#value'] = bts('Save changes', array(), NULL, 'boinc:form-save');
@@ -1024,8 +1024,8 @@  discard block
 block discarded – undo
1024 1024
     $form['buttons']['preview_changes']['#suffix'] = '</li>';
1025 1025
     $form['buttons']['preview_changes']['#weight'] = 1004;
1026 1026
     $form['buttons']['cancel'] = array(
1027
-      '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>',
1028
-      '#weight' => 1005,
1027
+        '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>',
1028
+        '#weight' => 1005,
1029 1029
     );
1030 1030
     $form['buttons']['delete']['#prefix'] = '<li class="tab">';
1031 1031
     $form['buttons']['delete']['#suffix'] = '</li>';
@@ -1033,8 +1033,8 @@  discard block
 block discarded – undo
1033 1033
     $form['buttons']['delete']['#weight'] = 1006;
1034 1034
     $form['buttons']['delete']['#submit'] = array('_boincuser_node_profile_delete_submit');
1035 1035
     $form['buttons']['form control tabs suffix'] = array(
1036
-      '#value' => '</ul>',
1037
-      '#weight' => 1010,
1036
+        '#value' => '</ul>',
1037
+        '#weight' => 1010,
1038 1038
     );
1039 1039
     
1040 1040
     $form['#after_build'][] = 'boincuser_profile_node_form_after_build';
@@ -1048,74 +1048,74 @@  discard block
 block discarded – undo
1048 1048
     
1049 1049
     // Internal fields to indicate where these user changes are taking place
1050 1050
     array_unshift($form, array(
1051
-      'validation_source' => array(
1051
+        'validation_source' => array(
1052 1052
         '#type' => 'hidden',
1053 1053
         '#value' => 'user_profile'
1054
-      ),
1055
-      'update_source' => array(
1054
+        ),
1055
+        'update_source' => array(
1056 1056
         '#type' => 'hidden',
1057 1057
         '#value' => 'user_profile'
1058
-      )
1058
+        )
1059 1059
     ));
1060 1060
     break;
1061 1061
   
1062
-  // Registration form
1063
-  case 'user_register':
1062
+    // Registration form
1063
+    case 'user_register':
1064 1064
     array_unshift($form, array(
1065
-      'boincuser_name' => array(
1065
+        'boincuser_name' => array(
1066 1066
         '#type' => 'textfield', 
1067 1067
         '#title' => bts('Name', array(), NULL, 'boinc:user-or-team-name'), 
1068 1068
         '#default_value' => $edit['boincuser_name'], 
1069 1069
         '#maxlength' => USERNAME_MAX_LENGTH, 
1070 1070
         '#description' => bts('Spaces are allowed; punctuation is not allowed except for periods, hyphens, and underscores.', array(), NULL, 'boinc:user-register'), 
1071 1071
         '#required' => TRUE
1072
-      ),
1072
+        ),
1073 1073
     ));
1074 1074
     // Set name temporarily to dummy value to beat validation
1075 1075
     $form['name'] = array(
1076
-      '#type' => 'hidden',
1077
-      '#value' => rand() . '.' . time()
1076
+        '#type' => 'hidden',
1077
+        '#value' => rand() . '.' . time()
1078 1078
     );
1079 1079
     
1080 1080
     // Terms of use section
1081 1081
     $termsofuse = variable_get('boinc_weboptions_termsofuse', '');
1082 1082
     if (!empty($termsofuse)) {
1083
-      $form['title1'] = array(
1083
+        $form['title1'] = array(
1084 1084
         '#weight' => -12,
1085 1085
         '#value' => '<h2>' . bts(variable_get('boinc_weboptions_registrationtitle', 'Please read and acknowledge our terms of use'), array(), NULL, 'project:user-register' ) . '</h2>',
1086 1086
         '#prefix' => '<div id="register-title1">',
1087 1087
         '#suffix' => '</div>',
1088
-      );
1088
+        );
1089 1089
 
1090
-      $form['termsofuse'] = array(
1090
+        $form['termsofuse'] = array(
1091 1091
         '#weight' => -10,
1092 1092
         '#value' => bts($termsofuse, array(), NULL, 'project:user-register'),
1093 1093
         '#prefix' => '<div id="register-termsofuse">',
1094 1094
         '#suffix' => '</div>',
1095
-      );
1095
+        );
1096 1096
 
1097
-      $form['agreeTOU'] = array(
1097
+        $form['agreeTOU'] = array(
1098 1098
         '#type' => 'checkbox',
1099 1099
         '#title' => bts(variable_get('boinc_weboptions_agreequestion', 'Do you agree with the above terms of use?'), array(), NULL, 'project:user-register'),
1100 1100
         '#weight' => -8,
1101 1101
         '#prefix' => '<div id="register-checkbox">',
1102 1102
         '#suffix' => '</div>',
1103
-      );
1103
+        );
1104 1104
     }
1105 1105
 
1106 1106
     $form['title2'] = array(
1107
-      '#weight' => -6,
1108
-      '#value' => '<h2>' . bts(variable_get('boinc_weboptions_registrationtitle2', 'Fill in your name, email, and choose a secure passphrase.'), array(), NULL, 'project:user-register') . '</h2>',
1109
-      '#prefix' => '<div id="register-title2">',
1110
-      '#suffix' => '</div>',
1107
+        '#weight' => -6,
1108
+        '#value' => '<h2>' . bts(variable_get('boinc_weboptions_registrationtitle2', 'Fill in your name, email, and choose a secure passphrase.'), array(), NULL, 'project:user-register') . '</h2>',
1109
+        '#prefix' => '<div id="register-title2">',
1110
+        '#suffix' => '</div>',
1111 1111
     );
1112 1112
 
1113 1113
     if (module_exists('captcha')) {
1114
-      // Add an optional captcha
1115
-      $form['register_captcha'] = array(
1114
+        // Add an optional captcha
1115
+        $form['register_captcha'] = array(
1116 1116
         '#type' => 'captcha',
1117 1117
         '#weight' => 1000,
1118
-      );
1118
+        );
1119 1119
     }
1120 1120
     
1121 1121
     $form['#validate'][] = 'boincuser_register_validate';
@@ -1123,35 +1123,35 @@  discard block
 block discarded – undo
1123 1123
     $form['submit']['#weight'] = 1001;
1124 1124
     break;
1125 1125
     
1126
-  // Request new password form
1127
-  case 'user_pass':
1126
+    // Request new password form
1127
+    case 'user_pass':
1128 1128
     drupal_set_title(bts('Forgot password', array(), NULL, 'boinc:forgot-password'));
1129 1129
     // Replace name/email text box with email only; retain "name" label
1130 1130
     // for compatibility with standard Drupal submit function
1131 1131
     unset($form['name']);
1132 1132
     array_unshift($form, array(
1133
-      'name' => array(
1133
+        'name' => array(
1134 1134
         '#type' => 'textfield',
1135 1135
         '#title' => bts('Email address', array(), NULL, 'boinc:email-address-to-login'),
1136 1136
         '#size' => 60,
1137 1137
         '#maxlength' => EMAIL_MAX_LENGTH,
1138 1138
         '#required' => TRUE,
1139 1139
         '#description' => bts(
1140
-          'Enter your email address to receive instructions for resetting your password (or use the !authenticator_login).',
1141
-          array(
1140
+            'Enter your email address to receive instructions for resetting your password (or use the !authenticator_login).',
1141
+            array(
1142 1142
             '!authenticator_login' => l(
1143
-              bts('authenticator-based login', array(), NULL, 'boinc:forgot-password'),
1144
-              'user/login/auth'
1143
+                bts('authenticator-based login', array(), NULL, 'boinc:forgot-password'),
1144
+                'user/login/auth'
1145
+            )
1145 1146
             )
1146
-          )
1147 1147
         , NULL, 'boinc:forgot-password'),
1148
-      ),
1148
+        ),
1149 1149
     ));
1150 1150
     
1151 1151
     // Wrap action buttons for styling consistency
1152 1152
     $form['buttons']['form control tabs prefix'] = array(
1153
-      '#value' => '<ul class="form-control tab-list">',
1154
-      '#weight' => 1001,
1153
+        '#value' => '<ul class="form-control tab-list">',
1154
+        '#weight' => 1001,
1155 1155
     );
1156 1156
     $form['buttons']['submit'] = $form['submit'];
1157 1157
     $form['buttons']['submit']['#prefix'] = '<li class="first tab">';
@@ -1159,26 +1159,26 @@  discard block
 block discarded – undo
1159 1159
     $form['buttons']['submit']['#suffix'] = '</li>';
1160 1160
     $form['buttons']['submit']['#weight'] = 1002;
1161 1161
     $form['buttons']['cancel'] = array(
1162
-      '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'user/login') . '</li>',
1163
-      '#weight' => 1005,
1162
+        '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'user/login') . '</li>',
1163
+        '#weight' => 1005,
1164 1164
     );
1165 1165
     $form['buttons']['form control tabs suffix'] = array(
1166
-      '#value' => '</ul>',
1167
-      '#weight' => 1010,
1166
+        '#value' => '</ul>',
1167
+        '#weight' => 1010,
1168 1168
     );
1169 1169
     unset($form['submit']);
1170 1170
     
1171 1171
     // If the form is being submitted, use BOINC validation handler.
1172 1172
     if (isset($form_state['post']['name'])) {
1173
-      // Prepend the BOINC validation function to local validation
1174
-      array_unshift($form['#validate'], 'boincuser_request_pass_validate');
1173
+        // Prepend the BOINC validation function to local validation
1174
+        array_unshift($form['#validate'], 'boincuser_request_pass_validate');
1175 1175
     }
1176 1176
     break;
1177 1177
     
1178
-  case 'views_exposed_form':
1178
+    case 'views_exposed_form':
1179 1179
       $form['submit']['#value'] = bts('Search', array(), NULL, 'boinc:search-user');
1180 1180
     break;
1181
-  }
1181
+    }
1182 1182
 }
1183 1183
 
1184 1184
 /**
@@ -1186,10 +1186,10 @@  discard block
 block discarded – undo
1186 1186
  * built; this is called from boincuser_form_alter()
1187 1187
  */
1188 1188
 function boincuser_profile_node_form_after_build($form, &$form_state) {
1189
-  // Move to community prefs form
1190
-  $form_state['storage']['avatar'] = $form['field_image'];
1191
-  unset($form['field_image']);
1192
-  return $form;
1189
+    // Move to community prefs form
1190
+    $form_state['storage']['avatar'] = $form['field_image'];
1191
+    unset($form['field_image']);
1192
+    return $form;
1193 1193
 }
1194 1194
 
1195 1195
 /**
@@ -1197,8 +1197,8 @@  discard block
 block discarded – undo
1197 1197
  * @see http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hook_elements/6
1198 1198
  */
1199 1199
 function boincuser_elements() {
1200
-  $type['password_confirm']['#process'][] = 'boincuser_process_password_confirm';
1201
-  return $type;
1200
+    $type['password_confirm']['#process'][] = 'boincuser_process_password_confirm';
1201
+    return $type;
1202 1202
 }
1203 1203
 
1204 1204
 /**
@@ -1206,11 +1206,11 @@  discard block
 block discarded – undo
1206 1206
  * profile form
1207 1207
  */
1208 1208
 function boincuser_process_password_confirm($element) {
1209
-  // Check if parent element is "account".
1210
-  if ($element['#array_parents'][0] == 'account') {
1209
+    // Check if parent element is "account".
1210
+    if ($element['#array_parents'][0] == 'account') {
1211 1211
     $element['pass1']['#title'] = bts('Change password', array(), NULL, 'boinc:forgot-password');
1212
-  }
1213
-  return $element;
1212
+    }
1213
+    return $element;
1214 1214
 }
1215 1215
 
1216 1216
 /**
@@ -1218,40 +1218,40 @@  discard block
 block discarded – undo
1218 1218
  * Register theme functions for use in this module.
1219 1219
  */
1220 1220
 function boincuser_theme($existing, $type, $theme, $path) {
1221
-  return array(
1221
+    return array(
1222 1222
     'boincuser_user_pass' => array(
1223
-      'arguments' => array()
1223
+        'arguments' => array()
1224 1224
     )
1225
-  );
1225
+    );
1226 1226
 }
1227 1227
 
1228 1228
 /**
1229 1229
  * Implementation of hook_token_values
1230 1230
  */
1231 1231
 function boincuser_token_values($type, $object = NULL, $options = array()) {
1232
-  if ($type == 'user') {
1232
+    if ($type == 'user') {
1233 1233
     $account = user_load($object->uid);
1234 1234
     $tokens['display-name'] = $account->boincuser_name;
1235 1235
     return $tokens;
1236
-  }
1236
+    }
1237 1237
 }
1238 1238
 
1239 1239
 /**
1240 1240
  * Implementation of hook_token_list
1241 1241
  */
1242 1242
 function boincuser_token_list($type = 'all') {
1243
-  if ($type == 'user' || $type == 'all') {
1243
+    if ($type == 'user' || $type == 'all') {
1244 1244
     $tokens['user']['display-name']      = t("The user's name that should be displayed");
1245 1245
     return $tokens;
1246
-  }
1246
+    }
1247 1247
 }
1248 1248
 
1249 1249
 /**
1250 1250
  * Implementation of hook_views_pre_execute()
1251 1251
  */
1252 1252
 function boincuser_views_pre_execute(&$view) {
1253
-  $account_id = $view->args[0];
1254
-  if ($view->name=="user_activity") {
1253
+    $account_id = $view->args[0];
1254
+    if ($view->name=="user_activity") {
1255 1255
     // Run the following custom query for the user_activity view
1256 1256
     $view->build_info['query']= "
1257 1257
       SELECT node_revisions.vid AS vid,
@@ -1283,25 +1283,25 @@  discard block
 block discarded – undo
1283 1283
     
1284 1284
     // count_query determines the pager.  Do this so the right item count is returned.
1285 1285
     $view->build_info['count_query'] = $view->build_info['query'];
1286
-  }
1286
+    }
1287 1287
 }
1288 1288
 
1289 1289
 /**
1290 1290
  * Implementation of hook_cron()
1291 1291
  */
1292 1292
 function boincuser_cron() {
1293
-  // Delete expired users in the BOINC database, user_delete table.
1294
-  require_boinc('boinc_db');
1295
-  $num_deleted = BoincUserDeleted::delete_expired();
1296
-  if ($num_deleted>0) {
1293
+    // Delete expired users in the BOINC database, user_delete table.
1294
+    require_boinc('boinc_db');
1295
+    $num_deleted = BoincUserDeleted::delete_expired();
1296
+    if ($num_deleted>0) {
1297 1297
     watchdog('boincuser', "Deleted ${num_deleted} users from user_deleted table", WATCHDOG_NOTICE);
1298
-  }
1298
+    }
1299 1299
 
1300
-  // Delete expired tokens from token table
1301
-  $tokens_deleted = BoincToken::delete_expired();
1302
-  if ($tokens_deleted>0) {
1300
+    // Delete expired tokens from token table
1301
+    $tokens_deleted = BoincToken::delete_expired();
1302
+    if ($tokens_deleted>0) {
1303 1303
     watchdog('boincuser', "Deleted ${tokens_deleted} tokens from token table", WATCHDOG_NOTICE);
1304
-  }
1304
+    }
1305 1305
 }
1306 1306
 
1307 1307
 /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
@@ -1312,17 +1312,17 @@  discard block
 block discarded – undo
1312 1312
  * Page callback shortcut to recent posts for the logged in user
1313 1313
  */
1314 1314
 function boincuser_goto_recent_posts() {
1315
-  global $user;
1316
-  drupal_goto("account/{$user->uid}/posts");
1315
+    global $user;
1316
+    drupal_goto("account/{$user->uid}/posts");
1317 1317
 }
1318 1318
 
1319 1319
 /**
1320 1320
  * Page callback shortcut to the team of the logged in user
1321 1321
  */
1322 1322
 function boincuser_goto_team() {
1323
-  global $user;
1324
-  $account = user_load($user->uid);
1325
-  drupal_goto("community/teams/{$account->team}");
1323
+    global $user;
1324
+    $account = user_load($user->uid);
1325
+    drupal_goto("community/teams/{$account->team}");
1326 1326
 }
1327 1327
 
1328 1328
 /**
@@ -1331,83 +1331,83 @@  discard block
 block discarded – undo
1331 1331
  * user profile pages, so use a wrapper for display
1332 1332
  */
1333 1333
 function boincuser_view_profile($account = null) {
1334
-  // Create the user profile page
1335
-  if (!$account) {
1334
+    // Create the user profile page
1335
+    if (!$account) {
1336 1336
     global $user;
1337 1337
     $account = $user;
1338
-  }
1339
-  // For now, just call the user module profile view function
1340
-  user_build_content($account);
1341
-  return theme('user_profile', $account);
1338
+    }
1339
+    // For now, just call the user module profile view function
1340
+    user_build_content($account);
1341
+    return theme('user_profile', $account);
1342 1342
 }
1343 1343
 
1344 1344
 /**
1345 1345
  * Page callback for editing a user profile
1346 1346
  */
1347 1347
 function boincuser_edit_profile($account = null) {
1348
-  // Create the user profile form
1349
-  if (!$account) {
1348
+    // Create the user profile form
1349
+    if (!$account) {
1350 1350
     global $user;
1351 1351
     $account = $user;
1352
-  }
1353
-  // Render the form
1354
-  module_load_include('pages.inc', 'node', 'node');
1355
-  return content_profile_page_edit('profile', $account);
1352
+    }
1353
+    // Render the form
1354
+    module_load_include('pages.inc', 'node', 'node');
1355
+    return content_profile_page_edit('profile', $account);
1356 1356
 }
1357 1357
 
1358 1358
 /**
1359
-  * Join page menu callback.
1360
-  * Display instructions on joining for new or existing BOINC users
1361
-  */
1359
+ * Join page menu callback.
1360
+ * Display instructions on joining for new or existing BOINC users
1361
+ */
1362 1362
 function join_page($type = null) {
1363
-  global $base_url;
1364
-  /* The paths/links to the rules-and-policies page is hardcoded
1363
+    global $base_url;
1364
+    /* The paths/links to the rules-and-policies page is hardcoded
1365 1365
    * here. An improvement would be admin settings for the Join Page
1366 1366
    * where this path could be set.
1367 1367
    */
1368
-  $ruleslinkA = 'rules-and-policies';
1369
-  $ruleslinkB = 'content/rules-and-policies';
1370
-  $site_name = variable_get('site_name', 'Drupal-BOINC');
1371
-  $registration_enabled = variable_get('user_register', 0);
1372
-  $output = '<div class="join">';
1373
-  switch ($type) {
1374
-  case 'boinc':
1368
+    $ruleslinkA = 'rules-and-policies';
1369
+    $ruleslinkB = 'content/rules-and-policies';
1370
+    $site_name = variable_get('site_name', 'Drupal-BOINC');
1371
+    $registration_enabled = variable_get('user_register', 0);
1372
+    $output = '<div class="join">';
1373
+    switch ($type) {
1374
+    case 'boinc':
1375 1375
     $output .= '<ol>';
1376 1376
     if ($registration_enabled) {
1377
-      $output .= '<li>' . bts('First !create_an_account here at @sitename.',
1378
-      array(
1377
+        $output .= '<li>' . bts('First !create_an_account here at @sitename.',
1378
+        array(
1379 1379
         '!create_an_account' => l(bts('create an account', array(), NULL, 'boinc:join-page'), 'user/registration'),
1380 1380
         '@sitename' => $site_name,
1381
-      ), NULL, 'boinc:join-page') . '</li>';
1381
+        ), NULL, 'boinc:join-page') . '</li>';
1382 1382
     }
1383 1383
     $output .= '  <li>' . bts("Install BOINC on this device if not already present.", array(), NULL, 'boinc:join-page') . '</li>';
1384 1384
     $output .= '  <li>' . bts("Select <i>Tools / Add Project</i>. Choose @sitename from the list, or enter @siteurl.",
1385 1385
     array(
1386
-      '@sitename' => $site_name,
1387
-      '@siteurl' => $base_url,
1386
+        '@sitename' => $site_name,
1387
+        '@siteurl' => $base_url,
1388 1388
     ), NULL, 'boinc:join-page') . '</li>';
1389 1389
     if ($registration_enabled) {
1390
-      $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.",
1390
+        $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.",
1391 1391
         array(
1392
-          '!boinccmd' => l('boinccmd --project_attach', 'http://boinc.berkeley.edu/wiki/Boinccmd_tool'),
1392
+            '!boinccmd' => l('boinccmd --project_attach', 'http://boinc.berkeley.edu/wiki/Boinccmd_tool'),
1393 1393
         ), NULL, 'boinc:join-page') . '</li>';
1394 1394
     }
1395 1395
     else {
1396
-      $output .= '<li>' . bts("If you're running a command-line version of BOINC,
1396
+        $output .= '<li>' . bts("If you're running a command-line version of BOINC,
1397 1397
         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.",
1398 1398
         array(
1399
-          '!instructionslink' => l('instructions', 'http://boinc.berkeley.edu/wiki/Boinccmd_tool'),
1399
+            '!instructionslink' => l('instructions', 'http://boinc.berkeley.edu/wiki/Boinccmd_tool'),
1400 1400
         ), NULL, 'boinc:join-page') . '</li>';
1401 1401
     }
1402 1402
     $output .= '<li>' . bts("If you're running a pre-5.0 version of BOINC, please
1403 1403
       upgrade to a more recent version of BOINC to create an account
1404 1404
       at @this_project.",
1405
-      array(
1405
+        array(
1406 1406
         '@this_project' => $site_name,
1407
-      ), NULL, 'boinc:join-page') . '</li>';
1407
+        ), NULL, 'boinc:join-page') . '</li>';
1408 1408
     $output .=  '</ol>';
1409 1409
     break;
1410
-  case 'new':
1410
+    case 'new':
1411 1411
   default:
1412 1412
     // Determine if there is a link to rules-and-policies
1413 1413
     //$ruleslink='';
@@ -1422,16 +1422,16 @@  discard block
 block discarded – undo
1422 1422
     // Join page output
1423 1423
     $output .= '<ol>';
1424 1424
     if ($registration_enabled) {
1425
-      $output .= '<li>' . bts('First !create_an_account here at @sitename.',
1426
-      array(
1425
+        $output .= '<li>' . bts('First !create_an_account here at @sitename.',
1426
+        array(
1427 1427
         '!create_an_account' => l(bts('create an account', array(), NULL, 'boinc:join-page'), 'user/registration'),
1428 1428
         '@sitename' => $site_name,
1429
-      ), NULL, 'boinc:join-page') . '</li>';
1429
+        ), NULL, 'boinc:join-page') . '</li>';
1430 1430
     }
1431 1431
     else if ( menu_valid_path(array('link_path' => $ruleslink)) ) {
1432
-      $output .= '  <li>' . bts("Read our !rules_and_policies.", array(
1432
+        $output .= '  <li>' . bts("Read our !rules_and_policies.", array(
1433 1433
         '!rules_and_policies' => l(bts('Rules and Policies', array(), NULL, 'boinc:join-page'), $ruleslink),
1434
-      ), NULL, 'boinc:join-page') . '</li>';
1434
+        ), NULL, 'boinc:join-page') . '</li>';
1435 1435
     }
1436 1436
     $output .= '  <li>' . bts('Download the BOINC desktop software.', array(), NULL, 'boinc:join-page');
1437 1437
     $output .= '    <p>';
@@ -1441,73 +1441,73 @@  discard block
 block discarded – undo
1441 1441
     $output .= '  </li>';
1442 1442
     $output .= '  <li>' . bts('Run the installer.', array(), NULL, 'boinc:join-page') . '</li>';
1443 1443
     $output .= '  <li>' . bts('Choose @sitename from the list, or enter @siteurl.', array(
1444
-      '@sitename' => $site_name,
1445
-      '@siteurl' => $base_url,
1444
+        '@sitename' => $site_name,
1445
+        '@siteurl' => $base_url,
1446 1446
     ), NULL, 'boinc:join-page') . '</li>';
1447 1447
     $output .=  '</ol>';
1448
-  }
1449
-  $output .= '</div>';
1450
-  return $output;
1448
+    }
1449
+    $output .= '</div>';
1450
+    return $output;
1451 1451
 }
1452 1452
 
1453 1453
 /**
1454
-  * Home page content for embedding in Panels page
1455
-  */
1454
+ * Home page content for embedding in Panels page
1455
+ */
1456 1456
 function boincuser_home_page() {
1457
-  global $user;
1458
-  $site_name = variable_get('site_name', 'Drupal-BOINC');
1459
-  // get the front page message from database; this is set in the admin interface under BOINC Other
1460
-  $site_message = variable_get('boinc_other_frontpage','');
1457
+    global $user;
1458
+    $site_name = variable_get('site_name', 'Drupal-BOINC');
1459
+    // get the front page message from database; this is set in the admin interface under BOINC Other
1460
+    $site_message = variable_get('boinc_other_frontpage','');
1461 1461
 
1462
-  // Determine the user of the day
1463
-  $current_uotd = db_fetch_object(db_query("
1462
+    // Determine the user of the day
1463
+    $current_uotd = db_fetch_object(db_query("
1464 1464
     SELECT
1465 1465
       uid,
1466 1466
       uotd_time
1467 1467
     FROM {boincuser}
1468 1468
     ORDER BY uotd_time DESC
1469 1469
     LIMIT 1"
1470
-  ));
1471
-  if ($current_uotd->uotd_time < strtotime('today midnight')) {
1470
+    ));
1471
+    if ($current_uotd->uotd_time < strtotime('today midnight')) {
1472 1472
     $uotd = boincuser_select_user_of_the_day();
1473
-  }
1474
-  else {
1473
+    }
1474
+    else {
1475 1475
     $uotd = user_load($current_uotd->uid);
1476
-  }
1477
-  $uotd_image = boincuser_get_user_profile_image($uotd->uid, FALSE);
1478
-  $output = '<h2 class="pane-title">';
1479
-  $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'));
1480
-  $output .= '</h2>';
1481
-  $output .= '<div class="boinc-overview balance-height-front">';
1482
-  $output .= '  <div>' . bts($site_message, array(), NULL, "project:front page") . ' ' . l(bts('Learn more', array(), NULL, 'boinc:front-page'), 'about') . '</div>';
1483
-  if ($user->uid) {
1476
+    }
1477
+    $uotd_image = boincuser_get_user_profile_image($uotd->uid, FALSE);
1478
+    $output = '<h2 class="pane-title">';
1479
+    $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'));
1480
+    $output .= '</h2>';
1481
+    $output .= '<div class="boinc-overview balance-height-front">';
1482
+    $output .= '  <div>' . bts($site_message, array(), NULL, "project:front page") . ' ' . l(bts('Learn more', array(), NULL, 'boinc:front-page'), 'about') . '</div>';
1483
+    if ($user->uid) {
1484 1484
     $output .= '  <div>' . l(bts('View account', array(), NULL, 'boinc:front-page'), 'dashboard', array('attributes' => array('class' => 'join button'))) . '</div>';
1485
-  }
1486
-  else {
1485
+    }
1486
+    else {
1487 1487
     $output .= '  <div>' . l(bts('Join now', array(), NULL, 'boinc:front-page'), 'join', array('attributes' => array('class' => 'join button'))) . '</div>';
1488
-  }
1489
-  $output .= '</div>';
1490
-  $output .= '<div class="boinc-overview-details">';
1491
-  $output .= '  <div class="detail-container">';
1492
-  $output .= '    <a class="user-of-the-day" href="account/' . $uotd->uid . '">';
1493
-  $output .= '      <div class="picture">';
1494
-  $output .= theme('imagefield_image', $uotd_image['image'], $uotd_image['alt'],
1488
+    }
1489
+    $output .= '</div>';
1490
+    $output .= '<div class="boinc-overview-details">';
1491
+    $output .= '  <div class="detail-container">';
1492
+    $output .= '    <a class="user-of-the-day" href="account/' . $uotd->uid . '">';
1493
+    $output .= '      <div class="picture">';
1494
+    $output .= theme('imagefield_image', $uotd_image['image'], $uotd_image['alt'],
1495 1495
     $uotd_image['alt'], array(), FALSE);
1496
-  $output .= '      </div>';
1497
-  $output .= '      <div class="text">' . bts('User of the day', array(), NULL, 'boinc:front-page') . '</div>';
1498
-  $output .= '      <div class="detail">' . $uotd->boincuser_name . '</div>';
1499
-  $output .= '    </a>';
1500
-  $output .= '    <div class="volunteers">';
1501
-  $output .= '      <div class="text">' . bts('Over 500,000 volunteers and counting.', array(), NULL, 'boinc:front-page') . '</div>';
1502
-  $output .= '      <div class="platforms">';
1503
-  $output .= '        <div class="detail platform windows">' . bts('Windows', array(), NULL, 'boinc:front-page') . '</div>';
1504
-  $output .= '        <div class="detail platform mac">' .  bts('Mac', array(), NULL, 'boinc:front-page') . '</div>';
1505
-  $output .= '        <div class="detail platform linux">' . bts('Linux', array(), NULL, 'boinc:front-page') . '</div>';
1506
-  $output .= '      </div>';
1507
-  $output .= '    </div>';
1508
-  $output .= '  </div>';
1509
-  $output .= '</div>';
1510
-  return $output;
1496
+    $output .= '      </div>';
1497
+    $output .= '      <div class="text">' . bts('User of the day', array(), NULL, 'boinc:front-page') . '</div>';
1498
+    $output .= '      <div class="detail">' . $uotd->boincuser_name . '</div>';
1499
+    $output .= '    </a>';
1500
+    $output .= '    <div class="volunteers">';
1501
+    $output .= '      <div class="text">' . bts('Over 500,000 volunteers and counting.', array(), NULL, 'boinc:front-page') . '</div>';
1502
+    $output .= '      <div class="platforms">';
1503
+    $output .= '        <div class="detail platform windows">' . bts('Windows', array(), NULL, 'boinc:front-page') . '</div>';
1504
+    $output .= '        <div class="detail platform mac">' .  bts('Mac', array(), NULL, 'boinc:front-page') . '</div>';
1505
+    $output .= '        <div class="detail platform linux">' . bts('Linux', array(), NULL, 'boinc:front-page') . '</div>';
1506
+    $output .= '      </div>';
1507
+    $output .= '    </div>';
1508
+    $output .= '  </div>';
1509
+    $output .= '</div>';
1510
+    return $output;
1511 1511
 }
1512 1512
 
1513 1513
 /**
@@ -1515,73 +1515,73 @@  discard block
 block discarded – undo
1515 1515
  * Create a new user account based on supplied parameters.
1516 1516
  */
1517 1517
 function boincuser_create_account() {
1518
-  global $base_url;
1518
+    global $base_url;
1519 1519
 
1520
-  require_boinc('boinc_db');
1521
-  require_boinc('user_util');
1522
-  require_boinc('xml');
1523
-  $params = array(
1520
+    require_boinc('boinc_db');
1521
+    require_boinc('user_util');
1522
+    require_boinc('xml');
1523
+    $params = array(
1524 1524
     'email_addr' => isset($_GET['email_addr']) ? $_GET['email_addr'] : '',
1525 1525
     'user_name' => isset($_GET['user_name']) ? $_GET['user_name'] : '',
1526 1526
     'passwd_hash' => isset($_GET['passwd_hash']) ? $_GET['passwd_hash'] : ''
1527
-  );
1527
+    );
1528 1528
   
1529
-  // Begin output
1530
-  xml_header();
1529
+    // Begin output
1530
+    xml_header();
1531 1531
   
1532
-  // Account creation disabled
1533
-  $enablethisRPC = variable_get('boinc_weboptions_enableaccountcreateRPC', TRUE);
1534
-  if (!$enablethisRPC) {
1532
+    // Account creation disabled
1533
+    $enablethisRPC = variable_get('boinc_weboptions_enableaccountcreateRPC', TRUE);
1534
+    if (!$enablethisRPC) {
1535 1535
     $mess = bts('Account creation is done through our Web site. Please register at @url', array(
1536
-      '@url' => $base_url . '/user/registration',
1536
+        '@url' => $base_url . '/user/registration',
1537 1537
     ),
1538 1538
     NULL, 'boinc:create_account');
1539 1539
     xml_error(-208, $mess);
1540
-  }
1541
-  // Invalid invite code
1540
+    }
1541
+    // Invalid invite code
1542 1542
   
1543
-  // Validate input
1544
-  if (user_validate_mail($params['email_addr']) or !is_valid_email_addr($params['email_addr'])) {
1543
+    // Validate input
1544
+    if (user_validate_mail($params['email_addr']) or !is_valid_email_addr($params['email_addr'])) {
1545 1545
     xml_error(-205);
1546
-  }
1546
+    }
1547 1547
 
1548
-  // Make sure user_name is unique and cleaned
1549
-  $unique_name = create_proper_drupalname($params['user_name']);
1550
-  if ($error = user_validate_name($unique_name)) {
1548
+    // Make sure user_name is unique and cleaned
1549
+    $unique_name = create_proper_drupalname($params['user_name']);
1550
+    if ($error = user_validate_name($unique_name)) {
1551 1551
     xml_error(-188, $error);
1552
-  }
1553
-  if (strlen($params['passwd_hash']) != 32) {
1552
+    }
1553
+    if (strlen($params['passwd_hash']) != 32) {
1554 1554
     xml_error(-1, 'password hash length not 32');
1555
-  }
1555
+    }
1556 1556
   
1557
-  // Process input
1558
-  $boinc_user = BoincUser::lookup_email_addr($params['email_addr']);
1559
-  if ($boinc_user) {
1557
+    // Process input
1558
+    $boinc_user = BoincUser::lookup_email_addr($params['email_addr']);
1559
+    if ($boinc_user) {
1560 1560
     // Return authenticator for existing users
1561 1561
     if ( ($params['passwd_hash'] == $boinc_user->passwd_hash) or
1562 1562
     password_verify($params['passwd_hash'], $boinc_user->passwd_hash) ) {
1563
-      $output = array('authenticator' => $boinc_user->authenticator);
1563
+        $output = array('authenticator' => $boinc_user->authenticator);
1564 1564
     }
1565 1565
     else {
1566
-      xml_error(-137);
1566
+        xml_error(-137);
1567 1567
     }
1568
-  }
1569
-  else {
1568
+    }
1569
+    else {
1570 1570
     // Verify that there isn't somehow a Drupal user already (not possible with proper function)
1571 1571
     if ($existing_user = user_load(array('mail' => $params['email_addr']))) {
1572
-      xml_error(-137, 'account error');
1572
+        xml_error(-137, 'account error');
1573 1573
     }
1574 1574
     // Create new account
1575 1575
     $unrestricted_role = array_search('community member', user_roles(true));
1576 1576
 
1577 1577
     $newUser = array(
1578
-      'name' => $unique_name,
1579
-      'pass' => null, // $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
1580
-      'mail' => $params['email_addr'],
1581
-      'status' => 1,
1582
-      'init' => $params['email_addr'],
1583
-      'roles' => array($unrestricted_role => ''),
1584
-      'boincuser_name' => $params['user_name'],
1578
+        'name' => $unique_name,
1579
+        'pass' => null, // $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
1580
+        'mail' => $params['email_addr'],
1581
+        'status' => 1,
1582
+        'init' => $params['email_addr'],
1583
+        'roles' => array($unrestricted_role => ''),
1584
+        'boincuser_name' => $params['user_name'],
1585 1585
     );
1586 1586
 
1587 1587
     // Create the drupal user. If the drupal user cannot be created,
@@ -1589,17 +1589,17 @@  discard block
 block discarded – undo
1589 1589
     // The user is created in the 'insert' op in hook_user.
1590 1590
     $user = user_save(null, $newUser);
1591 1591
     if (!$user) {
1592
-      watchdog('boincuser', 'create_account: Failed to create Drupal user account for @email', array('@email' => $params['email_addr']), WATCHDOG_WARNING);
1593
-      xml_error(-137, 'error creating BOINC account');
1592
+        watchdog('boincuser', 'create_account: Failed to create Drupal user account for @email', array('@email' => $params['email_addr']), WATCHDOG_WARNING);
1593
+        xml_error(-137, 'error creating BOINC account');
1594 1594
     }// if drupal user created.
1595 1595
 
1596 1596
     $output = array('authenticator' => $user->boincuser_account_key);
1597
-  }// if existing user found.
1597
+    }// if existing user found.
1598 1598
 
1599
-  // Output authenticator
1600
-  echo " <account_out>\n";
1601
-  echo "   <authenticator>{$output['authenticator']}</authenticator>\n";
1602
-  echo "</account_out>\n";
1599
+    // Output authenticator
1600
+    echo " <account_out>\n";
1601
+    echo "   <authenticator>{$output['authenticator']}</authenticator>\n";
1602
+    echo "</account_out>\n";
1603 1603
 }
1604 1604
 
1605 1605
 /**
@@ -1607,166 +1607,166 @@  discard block
 block discarded – undo
1607 1607
  * account is created using the BOINC clinet.
1608 1608
  */
1609 1609
 function boincuser_account_finish() {
1610
-  global $user;
1610
+    global $user;
1611 1611
 
1612
-  $authtoken = isset($_GET['auth']) ? $_GET['auth'] : '';
1612
+    $authtoken = isset($_GET['auth']) ? $_GET['auth'] : '';
1613 1613
 
1614
-  // Ensure there is a authentication token before continuing
1615
-  if (empty($authtoken)) {
1614
+    // Ensure there is a authentication token before continuing
1615
+    if (empty($authtoken)) {
1616 1616
     drupal_not_found();
1617 1617
     return ;
1618
-  }
1618
+    }
1619 1619
 
1620
-  if (strlen($authtoken) != 32) {
1620
+    if (strlen($authtoken) != 32) {
1621 1621
     drupal_set_message(bts('ERROR: There is no account with that authenticator.', array(), NULL, 'boinc:account-finish'), 'error');
1622 1622
     drupal_goto();
1623
-  }
1623
+    }
1624 1624
 
1625
-  require_boinc('boinc_db');
1626
-  $boinc_user = BoincUser::lookup("authenticator='".addslashes($authtoken)."'");
1627
-  if (!$boinc_user) {
1625
+    require_boinc('boinc_db');
1626
+    $boinc_user = BoincUser::lookup("authenticator='".addslashes($authtoken)."'");
1627
+    if (!$boinc_user) {
1628 1628
     drupal_set_message(bts('ERROR: There is no account with that authenticator.', array(), NULL, 'boinc:account-finish'), 'error');
1629 1629
     drupal_goto();
1630
-  }
1631
-  $user = user_load(get_drupal_id($boinc_user->id));
1630
+    }
1631
+    $user = user_load(get_drupal_id($boinc_user->id));
1632 1632
 
1633
-  if (!$user) {
1633
+    if (!$user) {
1634 1634
     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');
1635 1635
     drupal_goto();
1636
-  }
1636
+    }
1637 1637
 
1638
-  // Lookup path to custom account finish page
1639
-  $customaccountfinishpath = drupal_lookup_path('source', variable_get('boinc_weboptions_accountfinish', '') );
1640
-  if ( menu_valid_path(array('link_path' => $customaccountfinishpath)) ) {
1638
+    // Lookup path to custom account finish page
1639
+    $customaccountfinishpath = drupal_lookup_path('source', variable_get('boinc_weboptions_accountfinish', '') );
1640
+    if ( menu_valid_path(array('link_path' => $customaccountfinishpath)) ) {
1641 1641
     $node = menu_get_object('node', 1, $customaccountfinishpath);
1642 1642
     if ($node) {
1643
-      return node_page_view($node);
1643
+        return node_page_view($node);
1644
+    }
1644 1645
     }
1645
-  }
1646 1646
 
1647
-  // open links in new window
1648
-  $options = array(
1647
+    // open links in new window
1648
+    $options = array(
1649 1649
     'attributes' => array( 'target' => '_blank' ),
1650
-  );
1650
+    );
1651 1651
 
1652
-  // Check moderation page exists
1653
-  $moderationpath = drupal_lookup_path('source', variable_get('boinc_weboptions_moderationpage', '') );
1654
-  if ( menu_valid_path(array('link_path' => $moderationpath)) ) {
1652
+    // Check moderation page exists
1653
+    $moderationpath = drupal_lookup_path('source', variable_get('boinc_weboptions_moderationpage', '') );
1654
+    if ( menu_valid_path(array('link_path' => $moderationpath)) ) {
1655 1655
     $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');
1656
-  } else {
1656
+    } else {
1657 1657
     $modsentence = bts('Please note: user profiles are subject to moderation.', array(), NULL, 'boinc:account-finish');
1658
-  }
1658
+    }
1659 1659
 
1660
-  $username = $user->boincuser_name;
1661
-  $site_name = variable_get('site_name', 'Drupal-BOINC');
1662
-  $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.)',
1663
-  array(
1660
+    $username = $user->boincuser_name;
1661
+    $site_name = variable_get('site_name', 'Drupal-BOINC');
1662
+    $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.)',
1663
+    array(
1664 1664
     '@user_name' => $username,
1665 1665
     '@site_name' => $site_name,
1666
-  ), NULL, 'boinc:account-finish') . "</p>";
1666
+    ), NULL, 'boinc:account-finish') . "</p>";
1667 1667
 
1668
-  $links = array(
1668
+    $links = array(
1669 1669
     array(
1670
-      'data' => bts('Change your username at !community_preferences.', array(
1670
+        'data' => bts('Change your username at !community_preferences.', array(
1671 1671
         '!community_preferences' => l(bts('Community Preferences', array(), NULL, 'boinc:account-fininsh'), 'account/prefs/community', $options),
1672
-      ), NULL, 'boinc:account-finish'),
1673
-      'children' => array(
1672
+        ), NULL, 'boinc:account-finish'),
1673
+        'children' => array(
1674 1674
         bts('Your username is used to identify yourself to other volunteers on this Web site.', array(), NULL, 'boinc:account-finish'),
1675 1675
         bts('In addition, you may set your account\'s default language and adjust notification settings.', array(), NULL, 'boinc:account-finish'),
1676
-      ),
1676
+        ),
1677 1677
     ),
1678 1678
     array(
1679
-      'data' => bts('Change your !computing_preferences.', array(
1679
+        'data' => bts('Change your !computing_preferences.', array(
1680 1680
         '!computing_preferences' => l(bts('Computing Preferences', array(), NULL, 'boinc:account-finish'), 'account/prefs', $options),
1681
-      ), NULL, 'boinc:account-finish'),
1682
-      'children' => array(
1681
+        ), NULL, 'boinc:account-finish'),
1682
+        'children' => array(
1683 1683
         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'),
1684 1684
         bts('By default, you will run @site_name tasks without any additional configuration.', array(
1685
-          '@site_name' => $site_name,
1685
+            '@site_name' => $site_name,
1686 1686
         ), NULL, 'boinc:account-finish'),
1687 1687
         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(
1688
-          '!forums' => l(bts('forums', array(), NULL, 'boinc:account-finish'), 'community/forum', $options),
1688
+            '!forums' => l(bts('forums', array(), NULL, 'boinc:account-finish'), 'community/forum', $options),
1689 1689
         ), NULL, 'boinc:account-finish'),
1690
-      ),
1690
+        ),
1691 1691
     ),
1692 1692
     array(
1693 1693
         'data' => bts('Create a !user_profile.', array(
1694
-          '!user_profile' => l(bts('User Profile', array(), NULL, 'boinc:account-finish'), '/account/profile/edit', $options),
1694
+            '!user_profile' => l(bts('User Profile', array(), NULL, 'boinc:account-finish'), '/account/profile/edit', $options),
1695 1695
         ), NULL, 'boinc:account-finish'),
1696
-      'children' => array(
1696
+        'children' => array(
1697 1697
         bts('A user profile will inform other volunteers who you are and why you joined @site_name.', array(
1698
-          '@site_name' => $site_name,
1698
+            '@site_name' => $site_name,
1699 1699
         ), NULL, 'boinc:account-finish'),
1700 1700
         $modsentence,
1701
-      ),
1701
+        ),
1702 1702
     ),
1703 1703
     array(
1704
-      'data' => bts('Join a !team.', array(
1704
+        'data' => bts('Join a !team.', array(
1705 1705
         '!team' => l(bts('Team', array(), NULL, 'boinc:account-finish'), '/community/teams', $options),
1706
-      ), NULL, 'boinc:account-finish'),
1707
-      'children' => array(
1706
+        ), NULL, 'boinc:account-finish'),
1707
+        'children' => array(
1708 1708
         bts('You may join a team, made up of other volunteers.', array(), NULL, 'boinc:account-finish'),
1709
-      ),
1709
+        ),
1710 1710
     ),
1711 1711
     array(
1712
-      'data' => bts('Go to your !account_dashboard.', array(
1712
+        'data' => bts('Go to your !account_dashboard.', array(
1713 1713
         '!account_dashboard'=> l(bts('Account Dashboard', array(), NULL, 'boinc:account-finish'), 'account/dashboard', $options),
1714
-      ), NULL, 'boinc:account-finish'),
1715
-      'children' => array(
1714
+        ), NULL, 'boinc:account-finish'),
1715
+        'children' => array(
1716 1716
         bts('Your account dashboard has information and links about your computer(s) and task(s) assigned.', array(), NULL, 'boinc:account-finish'),
1717
-      ),
1717
+        ),
1718 1718
     ),
1719 1719
     array(
1720
-      'data' => bts('Visit our !help pages.', array(
1720
+        'data' => bts('Visit our !help pages.', array(
1721 1721
         '!help' => l(bts('Help', array(), NULL, 'boinc:account-finish'), '/help', $options)
1722
-      ), NULL, 'boinc:account-finish'),
1723
-      'children' => array(
1722
+        ), NULL, 'boinc:account-finish'),
1723
+        'children' => array(
1724 1724
         bts('Ask for help in our community\'s !forums.', array(
1725
-          '!forums' => l(bts('forums', array(), NULL, 'boinc:account-finish'), 'community/forum', $options)
1725
+            '!forums' => l(bts('forums', array(), NULL, 'boinc:account-finish'), 'community/forum', $options)
1726 1726
         ), NULL, 'boinc:account-finish'),
1727
-      ),
1727
+        ),
1728 1728
     ),
1729
-  );
1729
+    );
1730 1730
 
1731
-  //List of links
1732
-  $output .= theme_item_list($links, $title = NULL, $type='ul');
1731
+    //List of links
1732
+    $output .= theme_item_list($links, $title = NULL, $type='ul');
1733 1733
 
1734
-  return $output;
1734
+    return $output;
1735 1735
 }
1736 1736
 
1737 1737
 /**
1738 1738
  * Determine if the user has permission to control community access
1739 1739
  */
1740 1740
 function boincuser_moderate_community_access() {
1741
-  if (user_access('assign community member role')
1741
+    if (user_access('assign community member role')
1742 1742
   OR user_access('assign all roles')) {
1743 1743
     return TRUE;
1744
-  }
1745
-  return FALSE;
1744
+    }
1745
+    return FALSE;
1746 1746
 }
1747 1747
 
1748 1748
 /**
1749 1749
  * Get the count of items in the moderation queue
1750 1750
  */
1751 1751
 function boincuser_moderation_queue_count($caller = 'user') {
1752
-  $allowed = FALSE;
1753
-  switch ($caller) {
1754
-  case 'cron':
1752
+    $allowed = FALSE;
1753
+    switch ($caller) {
1754
+    case 'cron':
1755 1755
     $allowed = TRUE;
1756 1756
     break;
1757
-  case 'user':
1757
+    case 'user':
1758 1758
   default:
1759 1759
     $allowed = user_access('edit any profile content');
1760
-  }
1761
-  if ($allowed) {
1760
+    }
1761
+    if ($allowed) {
1762 1762
     return db_result(db_query("
1763 1763
       SELECT COUNT(*)
1764 1764
       FROM {node}
1765 1765
       WHERE type = 'profile'
1766 1766
       AND moderate = 1"
1767 1767
     ));
1768
-  }
1769
-  return NULL;
1768
+    }
1769
+    return NULL;
1770 1770
 }
1771 1771
 
1772 1772
 /**
@@ -1775,43 +1775,43 @@  discard block
 block discarded – undo
1775 1775
  * than through the user account info form.
1776 1776
  */
1777 1777
 function boincuser_control($uid = NULL, $action = NULL) {
1778
-  if (!$uid OR !$account = user_load($uid)) {
1778
+    if (!$uid OR !$account = user_load($uid)) {
1779 1779
     // What are you even doing here...
1780 1780
     return FALSE;
1781
-  }
1782
-  switch ($action) {
1783
-  case 'ban':
1781
+    }
1782
+    switch ($action) {
1783
+    case 'ban':
1784 1784
     if (boincuser_moderate_community_access()) {
1785
-      $penalty_period = variable_get('boinc_penalty_period', 7*24*60*60);
1786
-      $boincuser_record = array(
1785
+        $penalty_period = variable_get('boinc_penalty_period', 7*24*60*60);
1786
+        $boincuser_record = array(
1787 1787
         'uid' => $uid,
1788 1788
         'penalty_expiration' => time() + $penalty_period,
1789
-      );
1790
-      drupal_write_record('boincuser', $boincuser_record, 'uid');
1791
-      $community_role = array_search('community member', user_roles(true));
1792
-      if (isset($account->roles[$community_role])) {
1789
+        );
1790
+        drupal_write_record('boincuser', $boincuser_record, 'uid');
1791
+        $community_role = array_search('community member', user_roles(true));
1792
+        if (isset($account->roles[$community_role])) {
1793 1793
         unset($account->roles[$community_role]);
1794 1794
         user_save($account, array('roles' => $account->roles));
1795
-      }
1795
+        }
1796 1796
     }
1797 1797
     break;
1798
-  case 'lift-ban':
1798
+    case 'lift-ban':
1799 1799
     if (boincuser_moderate_community_access()) {
1800
-      $boincuser_record = array(
1800
+        $boincuser_record = array(
1801 1801
         'uid' => $uid,
1802 1802
         'penalty_expiration' => 0,
1803
-      );
1804
-      drupal_write_record('boincuser', $boincuser_record, 'uid');
1805
-      $community_role = array_search('community member', user_roles(true));
1806
-      if (!isset($account->roles[$community_role])) {
1803
+        );
1804
+        drupal_write_record('boincuser', $boincuser_record, 'uid');
1805
+        $community_role = array_search('community member', user_roles(true));
1806
+        if (!isset($account->roles[$community_role])) {
1807 1807
         $account->roles[$community_role] = 'community member';
1808 1808
         user_save($account, array('roles' => $account->roles));
1809
-      }
1809
+        }
1810 1810
     }
1811 1811
     break;
1812
-  default:
1812
+    default:
1813 1813
   }
1814
-  drupal_goto("account/{$account->uid}");
1814
+    drupal_goto("account/{$account->uid}");
1815 1815
 }
1816 1816
 
1817 1817
 /**
@@ -1819,29 +1819,29 @@  discard block
 block discarded – undo
1819 1819
  * moderation flag.
1820 1820
  */
1821 1821
 function boincuser_moderate_profile_approve($account) {
1822
-  $node = new stdClass;
1823
-  $node->type = 'profile';
1824
-  $node->language = '';
1825
-  $nid = content_profile_profile_exists($node, $account->uid);
1826
-  $profile = node_load($nid);
1827
-  $profile->moderate = 0;
1828
-  $profile->status = 1;
1829
-  node_save($profile);
1830
-  drupal_set_message('This profile has been marked as approved.');
1831
-  drupal_goto();
1822
+    $node = new stdClass;
1823
+    $node->type = 'profile';
1824
+    $node->language = '';
1825
+    $nid = content_profile_profile_exists($node, $account->uid);
1826
+    $profile = node_load($nid);
1827
+    $profile->moderate = 0;
1828
+    $profile->status = 1;
1829
+    node_save($profile);
1830
+    drupal_set_message('This profile has been marked as approved.');
1831
+    drupal_goto();
1832 1832
 }
1833 1833
 
1834 1834
 /**
1835 1835
  * Mark a user profile as rejected and notify the user of the reason.
1836 1836
  */
1837 1837
 function boincuser_moderate_profile_reject($uid, $reason = '') {
1838
-  $account = user_load($uid);
1839
-  $node = new stdClass;
1840
-  $node->type = 'profile';
1841
-  $node->language = '';
1842
-  $nid = content_profile_profile_exists($node, $uid);
1843
-  $profile = node_load($nid);
1844
-  if ($profile->nid) {
1838
+    $account = user_load($uid);
1839
+    $node = new stdClass;
1840
+    $node->type = 'profile';
1841
+    $node->language = '';
1842
+    $nid = content_profile_profile_exists($node, $uid);
1843
+    $profile = node_load($nid);
1844
+    if ($profile->nid) {
1845 1845
     global $user;
1846 1846
     global $base_url;
1847 1847
     global $base_path;
@@ -1852,64 +1852,64 @@  discard block
 block discarded – undo
1852 1852
     $profile->status = 0;
1853 1853
     node_save($profile);
1854 1854
     $settings = array(
1855
-      'from' => '',
1856
-      'subject' => "Profile moderation at {$site_name}",
1857
-      'message' => ''
1858
-      . "{$account->boincuser_name},\n"
1859
-      . "\n"
1860
-      . "{$moderator->boincuser_name} has rejected your profile at"
1861
-      . " {$site_name} for the following reason: \n"
1862
-      . "\n"
1863
-      . "{$reason}\n"
1864
-      . "\n"
1865
-      . "\n"
1866
-      . "Since it has not been approved, your profile is not visible to other"
1867
-      . " {$site_name} users. Please make the needed changes here:\n"
1868
-      . "\n"
1869
-      . "{$site_url}account/profile \n"
1870
-      . "\n"
1871
-      . "Thanks, \n"
1872
-      . "\n"
1873
-      . "{$site_name} support team",
1855
+        'from' => '',
1856
+        'subject' => "Profile moderation at {$site_name}",
1857
+        'message' => ''
1858
+        . "{$account->boincuser_name},\n"
1859
+        . "\n"
1860
+        . "{$moderator->boincuser_name} has rejected your profile at"
1861
+        . " {$site_name} for the following reason: \n"
1862
+        . "\n"
1863
+        . "{$reason}\n"
1864
+        . "\n"
1865
+        . "\n"
1866
+        . "Since it has not been approved, your profile is not visible to other"
1867
+        . " {$site_name} users. Please make the needed changes here:\n"
1868
+        . "\n"
1869
+        . "{$site_url}account/profile \n"
1870
+        . "\n"
1871
+        . "Thanks, \n"
1872
+        . "\n"
1873
+        . "{$site_name} support team",
1874 1874
     );
1875 1875
     rules_action_mail_to_user($account, $settings);
1876 1876
     drupal_set_message('This profile has been marked as rejected.');
1877
-  }
1878
-  drupal_goto();
1877
+    }
1878
+    drupal_goto();
1879 1879
 }
1880 1880
 
1881 1881
 /**
1882 1882
  * Ban a user and send a notification of the reason.
1883 1883
  */
1884 1884
 function boincuser_moderate_user_ban($uid, $reason = '', $duration = '') {
1885
-  if (user_access('assign community member role')
1885
+    if (user_access('assign community member role')
1886 1886
   OR user_access('assign all roles')) {
1887 1887
     $account = user_load($uid);
1888 1888
     if ($account->uid) {
1889
-      module_load_include('inc', 'rules', 'modules/system.rules');
1890
-      if ($duration === '') {
1889
+        module_load_include('inc', 'rules', 'modules/system.rules');
1890
+        if ($duration === '') {
1891 1891
         $duration = variable_get('boinc_penalty_period', 7*24*60*60);
1892
-      }
1893
-      $penalty_expiration = ($duration > 0) ? time() + $duration : 4294967295;
1894
-      $boincuser_record = array(
1892
+        }
1893
+        $penalty_expiration = ($duration > 0) ? time() + $duration : 4294967295;
1894
+        $boincuser_record = array(
1895 1895
         'uid' => $uid,
1896 1896
         'penalty_expiration' => $penalty_expiration,
1897
-      );
1898
-      drupal_write_record('boincuser', $boincuser_record, 'uid');
1897
+        );
1898
+        drupal_write_record('boincuser', $boincuser_record, 'uid');
1899 1899
       
1900
-      $community_role = array_search('community member', user_roles(true));
1901
-      if (isset($account->roles[$community_role])) {
1900
+        $community_role = array_search('community member', user_roles(true));
1901
+        if (isset($account->roles[$community_role])) {
1902 1902
         unset($account->roles[$community_role]);
1903 1903
         user_save($account, array('roles' => $account->roles));
1904
-      }
1904
+        }
1905 1905
       
1906
-      global $user;
1907
-      global $base_url;
1908
-      global $base_path;
1909
-      $site_name = variable_get('site_name', 'Drupal-BOINC');
1910
-      $site_url = $base_url . $base_path;
1911
-      $moderator = user_load($user->uid);
1912
-      $settings = array(
1906
+        global $user;
1907
+        global $base_url;
1908
+        global $base_path;
1909
+        $site_name = variable_get('site_name', 'Drupal-BOINC');
1910
+        $site_url = $base_url . $base_path;
1911
+        $moderator = user_load($user->uid);
1912
+        $settings = array(
1913 1913
         'from' => '',
1914 1914
         'subject' => "User moderation at {$site_name}",
1915 1915
         'message' => ''
@@ -1930,12 +1930,12 @@  discard block
 block discarded – undo
1930 1930
         . "Thanks, \n"
1931 1931
         . "\n"
1932 1932
         . "{$site_name} support team",
1933
-      );
1934
-      rules_action_mail_to_user($account, $settings);
1935
-      drupal_set_message('This user has been banned.');
1933
+        );
1934
+        rules_action_mail_to_user($account, $settings);
1935
+        drupal_set_message('This user has been banned.');
1936 1936
     }
1937
-  }
1938
-  drupal_goto();
1937
+    }
1938
+    drupal_goto();
1939 1939
 }
1940 1940
 
1941 1941
 
@@ -1947,15 +1947,15 @@  discard block
 block discarded – undo
1947 1947
  *
1948 1948
  */
1949 1949
 function boincuser_get_weak_auth($boinc_id = null) {
1950
-  if (!$boinc_id) {
1950
+    if (!$boinc_id) {
1951 1951
     global $user;
1952 1952
     $account = user_load($user->uid);
1953 1953
     $boinc_id = $account->boincuser_id;
1954
-  }
1954
+    }
1955 1955
   
1956
-  $boinc_user = boincuser_load($account->boincuser_id);
1956
+    $boinc_user = boincuser_load($account->boincuser_id);
1957 1957
   
1958
-  return weak_auth($boinc_user);
1958
+    return weak_auth($boinc_user);
1959 1959
 }
1960 1960
 
1961 1961
 /**
@@ -1964,75 +1964,75 @@  discard block
 block discarded – undo
1964 1964
  * Drupal User so must be inserted into comments, etc. (not so by default)
1965 1965
  */
1966 1966
 function boincuser_get_user_profile_image($uid, $avatar = TRUE) {
1967
-  // Though the function name implies otherwise, get the avatar by default
1968
-  $image_field = ($avatar) ? 'field_image_fid' : 'field_profile_image_fid';
1969
-  $image_fid = db_result(db_query("
1967
+    // Though the function name implies otherwise, get the avatar by default
1968
+    $image_field = ($avatar) ? 'field_image_fid' : 'field_profile_image_fid';
1969
+    $image_fid = db_result(db_query("
1970 1970
     SELECT ctp.%s
1971 1971
     FROM {content_type_profile} ctp
1972 1972
     INNER JOIN {node} n ON ctp.nid = n.nid
1973 1973
     WHERE n.uid = %d AND n.type = '%s'",
1974 1974
     $image_field, $uid, 'profile'));
1975
-  $user_image['image'] = field_file_load($image_fid);
1976
-  if (!$user_image['image']['filepath']) {
1975
+    $user_image['image'] = field_file_load($image_fid);
1976
+    if (!$user_image['image']['filepath']) {
1977 1977
     // Load the default image if one does not exist
1978 1978
     $account = user_load($uid);
1979 1979
     if ($avatar AND module_exists('gravatar') AND user_access('use gravatar', $account) AND $account->gravatar) {
1980
-      // Use a Gravatar rather than the system default image
1981
-      $options = array(
1980
+        // Use a Gravatar rather than the system default image
1981
+        $options = array(
1982 1982
         'size' => 100,
1983 1983
         'rating' => 'G',
1984
-      );
1985
-      // Get the Gravatar URL and see if the image exists
1986
-      $url = gravatar_get_gravatar($account->mail, $options);
1987
-      $headers = @get_headers($url);
1988
-      if (preg_match("|200|", $headers[0])) {
1984
+        );
1985
+        // Get the Gravatar URL and see if the image exists
1986
+        $url = gravatar_get_gravatar($account->mail, $options);
1987
+        $headers = @get_headers($url);
1988
+        if (preg_match("|200|", $headers[0])) {
1989 1989
         return $url;
1990
-      }
1990
+        }
1991 1991
     }
1992 1992
     // Get default image if nothing else works
1993 1993
     $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')));
1994 1994
     $content_node_widget_settings = unserialize($content_node_widget_settings);
1995 1995
     $user_image['image'] = $content_node_widget_settings['default_image'];
1996
-  }
1997
-  $user = user_load($uid);
1998
-  // Use boinc username for image alt/title attributes
1999
-  $user_image['alt'] = $user->boincuser_name;
2000
-  return $user_image;
1996
+    }
1997
+    $user = user_load($uid);
1998
+    // Use boinc username for image alt/title attributes
1999
+    $user_image['alt'] = $user->boincuser_name;
2000
+    return $user_image;
2001 2001
 }
2002 2002
 
2003 2003
 /**
2004 2004
  * Generate a table of a user's projects
2005 2005
  */
2006 2006
 function boincuser_get_projects_table($account = null) {
2007
-  if ($account AND is_numeric($account)) {
2007
+    if ($account AND is_numeric($account)) {
2008 2008
     $account = user_load($account);
2009
-  }
2010
-  $projects = boincuser_get_projects($account);
2011
-  if (!$projects) return bts('no projects...', array(), NULL, 'boinc:account-dashboard');
2009
+    }
2010
+    $projects = boincuser_get_projects($account);
2011
+    if (!$projects) return bts('no projects...', array(), NULL, 'boinc:account-dashboard');
2012 2012
   
2013
-  $output = '';
2014
-  $output .= '<table class="user-projects">' . "\n";
2015
-  $output .= '<thead>' . "\n";
2016
-  $output .= '  <tr>' . "\n";
2017
-  $output .= '    <th>' . bts('Name', array(), NULL, 'boinc:project-name:-1:ignoreoverwrite') . '</th>' . "\n";
2018
-  $output .= '    <th class="numeric">' . bts('Avg credit', array(), NULL, 'boinc:account-dashboard') . '</th>' . "\n";
2019
-  $output .= '    <th class="numeric">' . bts('Total credit', array(), NULL, 'boinc:user-or-team-total-credits') . '</th>' . "\n";
2020
-  $output .= '  </tr>' . "\n";
2021
-  $output .= '</thead>' . "\n";
2022
-  $output .= '<tbody>' . "\n";
2023
-  foreach ($projects AS $project) {
2013
+    $output = '';
2014
+    $output .= '<table class="user-projects">' . "\n";
2015
+    $output .= '<thead>' . "\n";
2016
+    $output .= '  <tr>' . "\n";
2017
+    $output .= '    <th>' . bts('Name', array(), NULL, 'boinc:project-name:-1:ignoreoverwrite') . '</th>' . "\n";
2018
+    $output .= '    <th class="numeric">' . bts('Avg credit', array(), NULL, 'boinc:account-dashboard') . '</th>' . "\n";
2019
+    $output .= '    <th class="numeric">' . bts('Total credit', array(), NULL, 'boinc:user-or-team-total-credits') . '</th>' . "\n";
2020
+    $output .= '  </tr>' . "\n";
2021
+    $output .= '</thead>' . "\n";
2022
+    $output .= '<tbody>' . "\n";
2023
+    foreach ($projects AS $project) {
2024 2024
     $url = rtrim($project->url, '/') . '/show_user.php?userid=' . $project->id;
2025 2025
     $output .= '  <tr>' . "\n";
2026 2026
     $output .= '    <td>' . l($project->name, $url) . '</td>' . "\n";
2027 2027
     $output .= '    <td class="numeric">' . boincwork_format_stats((float) $project->expavg_credit) . '</td>' . "\n"; 
2028 2028
     $output .= '    <td class="numeric">' . boincwork_format_stats((float) $project->total_credit) . '</td>' . "\n";
2029 2029
     $output .= '  </tr>' . "\n";
2030
-  }
2031
-  $output .= '</tbody>' . "\n";
2032
-  $output .= '</table>' . "\n";
2033
-  $more_link = ($account) ? "user/{$account->uid}/stats" : 'account/stats';
2034
-  //$output .= "<div class=\"more-link\"><a href=\"{$more_link}\">More stats</a></div>" . "\n";
2035
-  return $output;
2030
+    }
2031
+    $output .= '</tbody>' . "\n";
2032
+    $output .= '</table>' . "\n";
2033
+    $more_link = ($account) ? "user/{$account->uid}/stats" : 'account/stats';
2034
+    //$output .= "<div class=\"more-link\"><a href=\"{$more_link}\">More stats</a></div>" . "\n";
2035
+    return $output;
2036 2036
 }
2037 2037
 
2038 2038
 /**
@@ -2040,25 +2040,25 @@  discard block
 block discarded – undo
2040 2040
  */
2041 2041
 function boincuser_get_stats_user_data($cpid = null) {
2042 2042
   
2043
-  // [TODO] Set this stuff in site config!
2044
-  $stats_server = 'stats.gridrepublic.org';
2045
-  $stats_rpc = 'rpc/get_user.php';
2043
+    // [TODO] Set this stuff in site config!
2044
+    $stats_server = 'stats.gridrepublic.org';
2045
+    $stats_rpc = 'rpc/get_user.php';
2046 2046
   
2047
-  // Construct query string
2048
-  $get = array(
2047
+    // Construct query string
2048
+    $get = array(
2049 2049
     'cpid' => $cpid
2050
-  );
2051
-  $args = array();
2052
-  foreach ($get as $arg => $value) $args[] = "{$arg}=" . rawurlencode($value);
2053
-  $query = '?' . implode('&', $args);
2050
+    );
2051
+    $args = array();
2052
+    foreach ($get as $arg => $value) $args[] = "{$arg}=" . rawurlencode($value);
2053
+    $query = '?' . implode('&', $args);
2054 2054
   
2055
-  // Load XML from RPC
2056
-  $target_url = "http://{$stats_server}/{$stats_rpc}{$query}";
2057
-  $result = drupal_http_request($target_url);
2058
-  if (in_array($result->code, array(200, 304))) {
2055
+    // Load XML from RPC
2056
+    $target_url = "http://{$stats_server}/{$stats_rpc}{$query}";
2057
+    $result = drupal_http_request($target_url);
2058
+    if (in_array($result->code, array(200, 304))) {
2059 2059
     return simplexml_load_string($result->data);
2060
-  }
2061
-  return NULL;
2060
+    }
2061
+    return NULL;
2062 2062
 }
2063 2063
 
2064 2064
 /**
@@ -2066,15 +2066,15 @@  discard block
 block discarded – undo
2066 2066
  */
2067 2067
 function boincuser_get_projects($account = null) {
2068 2068
   
2069
-  // Use the current user by default
2070
-  if (!$account) {
2069
+    // Use the current user by default
2070
+    if (!$account) {
2071 2071
     global $user;
2072 2072
     $account = user_load($user->uid);
2073
-  }
2073
+    }
2074 2074
   
2075
-  $account_stats = boincuser_get_stats_user_data($account->boincuser_cpid);
2075
+    $account_stats = boincuser_get_stats_user_data($account->boincuser_cpid);
2076 2076
   
2077
-  return ($account_stats AND isset($account_stats->project)) ? $account_stats->project : null;
2077
+    return ($account_stats AND isset($account_stats->project)) ? $account_stats->project : null;
2078 2078
 }
2079 2079
 
2080 2080
 
@@ -2082,11 +2082,11 @@  discard block
 block discarded – undo
2082 2082
  * Get the links to display under the user profile
2083 2083
  */
2084 2084
 function boincuser_get_profile_links($uid) {
2085
-  global $user;
2086
-  $account = user_load($uid);
2087
-  $profile = content_profile_load('profile', $account->uid);
2088
-  $output = '';
2089
-  if ($profile) {
2085
+    global $user;
2086
+    $account = user_load($uid);
2087
+    $profile = content_profile_load('profile', $account->uid);
2088
+    $output = '';
2089
+    if ($profile) {
2090 2090
     $profile_is_approved = ($profile->status AND !$profile->moderate);
2091 2091
     $user_is_moderator = user_access('edit any profile content');
2092 2092
     $is_own_profile = ($user->uid == $account->uid);
@@ -2094,15 +2094,15 @@  discard block
 block discarded – undo
2094 2094
     $links = array();
2095 2095
     
2096 2096
     if ($profile->moderate AND $user_is_moderator) {
2097
-      $links['approve_profile'] = array(
2097
+        $links['approve_profile'] = array(
2098 2098
         'title' => bts('Approve profile', array(), NULL, 'boinc:moderate-user'),
2099 2099
         'href' => "{$profile_moderation_path}/approve",
2100 2100
         'attributes' => array(
2101
-          'title' => bts('Approve this profile content', array(), NULL, 'boinc:moderate-user'),
2102
-          'class' => 'first primary tab',
2101
+            'title' => bts('Approve this profile content', array(), NULL, 'boinc:moderate-user'),
2102
+            'class' => 'first primary tab',
2103 2103
         )
2104
-      );
2105
-      /*$links['edit_profile'] = array(
2104
+        );
2105
+        /*$links['edit_profile'] = array(
2106 2106
         'title' => bts('Edit profile', array(), NULL, 'boinc:moderate-user'),
2107 2107
         'href' => "{$profile_moderation_path}/edit",
2108 2108
         'attributes' => array(
@@ -2110,27 +2110,27 @@  discard block
 block discarded – undo
2110 2110
           'class' => 'tab',
2111 2111
         )
2112 2112
       );*/
2113
-      $links['reject_profile'] = array(
2113
+        $links['reject_profile'] = array(
2114 2114
         'title' => bts('Reject profile', array(), NULL, 'boinc:moderate-user'),
2115 2115
         'href' => "{$profile_moderation_path}/reject",
2116 2116
         'attributes' => array(
2117
-          'title' => bts('Reject this profile content', array(), NULL, 'boinc:moderate-user'),
2118
-          'class' => 'tab',
2117
+            'title' => bts('Reject this profile content', array(), NULL, 'boinc:moderate-user'),
2118
+            'class' => 'tab',
2119 2119
         )
2120
-      );
2120
+        );
2121 2121
     }
2122 2122
     $output .= '<ul class="tab-list">';
2123 2123
     $count = 0;
2124 2124
     foreach ($links as $key => $link) {
2125
-      $output .= '<li class="' . (($count == 0) ? 'first primary ' : '') . 'tab">';
2126
-      $output .= l($link['title'], $link['href'], array('query' => drupal_get_destination()));
2127
-      $output .= '</li>';
2128
-      $count++;
2125
+        $output .= '<li class="' . (($count == 0) ? 'first primary ' : '') . 'tab">';
2126
+        $output .= l($link['title'], $link['href'], array('query' => drupal_get_destination()));
2127
+        $output .= '</li>';
2128
+        $count++;
2129 2129
     }
2130 2130
     $output .= '<li class="' . (($count) ? '' : 'first ') . 'last tab">' . flag_create_link('abuse_user', $account->uid) . '</li>';
2131 2131
     $output .= '</ul>';
2132
-  }
2133
-  return $output;
2132
+    }
2133
+    return $output;
2134 2134
 /*
2135 2135
 <ul class="tab-list">
2136 2136
   <li class="primary first tab">
@@ -2167,36 +2167,36 @@  discard block
 block discarded – undo
2167 2167
  */
2168 2168
 function boincuser_apachesolr_index_documents_alter(array &$documents, $entity, $entity_type, $env_id) {
2169 2169
 
2170
-  foreach ($documents as $document) {
2170
+    foreach ($documents as $document) {
2171 2171
     if ( $document->entity_type=='node' AND $document->bundle=='profile' ) {
2172
-      // Node information.
2173
-      $nid = $document->entity_id;
2174
-      $node = node_load($nid);
2175
-      $account = user_load($node->uid);
2176
-
2177
-      // Use boincuser name and not drupal user name
2178
-      $document->label = apachesolr_clean_text($account->boincuser_name);
2179
-      // Author information
2180
-      if ($node->uid == 0 || strlen($node->name) == 0) {
2172
+        // Node information.
2173
+        $nid = $document->entity_id;
2174
+        $node = node_load($nid);
2175
+        $account = user_load($node->uid);
2176
+
2177
+        // Use boincuser name and not drupal user name
2178
+        $document->label = apachesolr_clean_text($account->boincuser_name);
2179
+        // Author information
2180
+        if ($node->uid == 0 || strlen($node->name) == 0) {
2181 2181
         // @see user_validate_name(). !'0' === TRUE.
2182 2182
         $document->ss_name = '0';
2183
-      }
2184
-      else {
2183
+        }
2184
+        else {
2185 2185
         $document->ss_name = $account->boincuser_name;
2186 2186
         // We want the name to be searchable for keywords.
2187 2187
         $document->tos_name = $account->boincuser_name;
2188
-      }
2188
+        }
2189 2189
 
2190
-      // Rename "Profle" to "User"
2191
-      $document->bundle = "User";
2192
-      $document->bundle_name = "User";
2190
+        // Rename "Profle" to "User"
2191
+        $document->bundle = "User";
2192
+        $document->bundle_name = "User";
2193 2193
 
2194
-      // Replace the Solr document's created field with the date the user 
2195
-      // account was created. This replaces the node creation date typically 
2196
-      // used for indexing nodes.
2197
-      $document->ds_created = apachesolr_date_iso($account->created);
2194
+        // Replace the Solr document's created field with the date the user 
2195
+        // account was created. This replaces the node creation date typically 
2196
+        // used for indexing nodes.
2197
+        $document->ds_created = apachesolr_date_iso($account->created);
2198
+    }
2198 2199
     }
2199
-  }
2200 2200
 
2201 2201
 }
2202 2202
 
@@ -2208,23 +2208,23 @@  discard block
 block discarded – undo
2208 2208
  * Implementation of hook_privatemsg_name_lookup();
2209 2209
  */
2210 2210
 function boincuser_privatemsg_name_lookup($string) {
2211
-  // Get the BOINC ID from the name string, and lookup the
2212
-  // corresponding drupal user.
2213
-  $boincname = substr($string, 0, strrpos($string, '_'));
2214
-  $boincid = substr($string, strrpos($string, '_') + 1);
2215
-  $drupalid = get_drupal_id($boincid);
2216
-
2217
-  // Name has spaced replaced with special UTF-8 characters in
2218
-  // privatemsg module. We need to convert them back to spaces for the
2219
-  // check below.
2220
-  $boincname = preg_replace("/\\xc2\\xa0/", " ", $boincname);
2221
-  if ($drupalid>0) {
2211
+    // Get the BOINC ID from the name string, and lookup the
2212
+    // corresponding drupal user.
2213
+    $boincname = substr($string, 0, strrpos($string, '_'));
2214
+    $boincid = substr($string, strrpos($string, '_') + 1);
2215
+    $drupalid = get_drupal_id($boincid);
2216
+
2217
+    // Name has spaced replaced with special UTF-8 characters in
2218
+    // privatemsg module. We need to convert them back to spaces for the
2219
+    // check below.
2220
+    $boincname = preg_replace("/\\xc2\\xa0/", " ", $boincname);
2221
+    if ($drupalid>0) {
2222 2222
     if ($recipient = user_load(array('uid' => $drupalid))) {
2223
-      // Double-check that the loaded user matches both boincuser_id
2224
-      // and boincuser_name.
2225
-      if ( ($boincid == $recipient->boincuser_id) AND ($boincname == $recipient->boincuser_name) ) {
2223
+        // Double-check that the loaded user matches both boincuser_id
2224
+        // and boincuser_name.
2225
+        if ( ($boincid == $recipient->boincuser_id) AND ($boincname == $recipient->boincuser_name) ) {
2226 2226
         return $recipient;
2227
-      }
2227
+        }
2228
+    }
2228 2229
     }
2229
-  }
2230 2230
 }
Please login to merge, or discard this patch.