Completed
Pull Request — master (#1949)
by Christian
14:07
created
drupal/sites/default/boinc/modules/boincuser/boincuser.module 1 patch
Indentation   +615 added lines, -615 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 arguments' => array('access content'),
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 arguments' => array('access content'),
49 49
     'type' => MENU_DEFAULT_LOCAL_TASK,
50 50
     'weight' => 0
51
-  );
52
-  $items['account/profile/edit'] = array(
51
+    );
52
+    $items['account/profile/edit'] = array(
53 53
     'title' => 'Edit',
54 54
     'description' => 'Edit a user profile',
55 55
     'page callback' => 'boincuser_edit_profile',
56 56
     'access arguments' => array('access content'),
57 57
     'type' => MENU_LOCAL_TASK,
58 58
     'weight' => 5
59
-  );
60
-  $items['account/team'] = array(
59
+    );
60
+    $items['account/team'] = array(
61 61
     'title' => 'User team',
62 62
     'description' => '',
63 63
     'page callback' => 'boincuser_goto_team',
64 64
     'access callback' => 'user_is_logged_in',
65 65
     'type' => MENU_CALLBACK,
66
-  );
67
-  $items['moderate/profile/%user/approve'] = array(
66
+    );
67
+    $items['moderate/profile/%user/approve'] = array(
68 68
     'title' => 'Profile approval',
69 69
     'description' => 'Approve profile content',
70 70
     'page callback' => 'boincuser_moderate_profile_approve',
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
     'access arguments' => array('edit any profile content'),
73 73
     'type' => MENU_CALLBACK,
74 74
     'weight' => 5
75
-  );
76
-  $items['moderate/profile/%user/edit'] = array(
75
+    );
76
+    $items['moderate/profile/%user/edit'] = array(
77 77
     'title' => 'Profile editor',
78 78
     'description' => 'Edit a user profile',
79 79
     'page callback' => 'boincuser_edit_profile',
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
     'access arguments' => array('edit any profile content'),
82 82
     'type' => MENU_CALLBACK,
83 83
     'weight' => 5
84
-  );
85
-  $items['moderate/profile/%/reject'] = array(
84
+    );
85
+    $items['moderate/profile/%/reject'] = array(
86 86
     'title' => bts('Reject profile', array(), NULL, 'boinc:moderate-user'),
87 87
     'description' => 'Reject profile content',
88 88
     'page callback' => 'drupal_get_form',
@@ -90,52 +90,52 @@  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_control'] = array(
132
+    );
133
+    $items['user_control'] = array(
134 134
     'page callback' => 'boincuser_control',
135 135
     'access arguments' => array('access user profiles'),
136 136
     'type' => MENU_CALLBACK
137
-  );
138
-  $items['admin/boinc'] = array(
137
+    );
138
+    $items['admin/boinc'] = array(
139 139
     'title' => 'BOINC configuration',
140 140
     'position' => 'right',
141 141
     'weight' => -8,
@@ -143,8 +143,8 @@  discard block
 block discarded – undo
143 143
     'access arguments' => array('administer site configuration'),
144 144
     'file' => 'system.admin.inc',
145 145
     'file path' => drupal_get_path('module', 'system'),
146
-  );
147
-  $items['admin/boinc/environment'] = array(
146
+    );
147
+    $items['admin/boinc/environment'] = array(
148 148
     'title' => 'Environment: General',
149 149
     'description' => 'Set paths to BOINC functions and any other necessary
150 150
       variables that establish a BOINC environment.',
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
     'access arguments' => array('administer site configuration'),
154 154
     'type' => MENU_NORMAL_ITEM,
155 155
     'file' => 'boincuser.admin.inc'
156
-  );
157
-  $items['admin/boinc/scheduler'] = array(
156
+    );
157
+    $items['admin/boinc/scheduler'] = array(
158 158
     'title' => 'Environment: Scheduling server URLs',
159 159
     'description' => 'Set BOINC scheduler options.',
160 160
     'page callback' => 'drupal_get_form',
@@ -162,8 +162,8 @@  discard block
 block discarded – undo
162 162
     'access arguments' => array('administer site configuration'),
163 163
     'type' => MENU_NORMAL_ITEM,
164 164
     'file' => 'boincuser.admin.inc'
165
-  );
166
-  $items['admin/boinc/other'] = array(
165
+    );
166
+    $items['admin/boinc/other'] = array(
167 167
     'title' => 'Other Options',
168 168
     'description' => 'Set other BOINC options.',
169 169
     'page callback' => 'drupal_get_form',
@@ -171,42 +171,42 @@  discard block
 block discarded – undo
171 171
     'access arguments' => array('administer site configuration'),
172 172
     'type' => MENU_NORMAL_ITEM,
173 173
     'file' => 'boincuser.admin.inc'
174
-  );
174
+    );
175 175
   
176
-  $items['create_account.php'] = array(
176
+    $items['create_account.php'] = array(
177 177
     'title' => 'Create Account RPC',
178 178
     'description' => 'RPC for creating user accounts.',
179 179
     'page callback' => 'boincuser_create_account',
180 180
     'access callback' => TRUE,
181 181
     'type' => MENU_CALLBACK
182
-  );
183
-  return $items;
182
+    );
183
+    return $items;
184 184
 }
185 185
 
186 186
 /**
187 187
  *
188 188
  */
189 189
 function boincuser_init() {
190
-  // Skip this check for charts, which are loaded separately
191
-  // (may get duplicate or unexpected messages otherwise)
192
-  if (substr($_GET['q'], 0, 7) == 'charts/') {
190
+    // Skip this check for charts, which are loaded separately
191
+    // (may get duplicate or unexpected messages otherwise)
192
+    if (substr($_GET['q'], 0, 7) == 'charts/') {
193 193
     return;
194
-  }
194
+    }
195 195
 
196
-  // If admin user, do some basic site functionality checks
197
-  if (user_access('administer site configuration')) {
196
+    // If admin user, do some basic site functionality checks
197
+    if (user_access('administer site configuration')) {
198 198
     // Ensure we have a configured BOINC environment
199 199
     boinc_get_path();
200 200
     boinc_get_scheduler_tags();
201
-  }
201
+    }
202 202
   
203
-  // Check credits for the verified contributor role
204
-  boincuser_check_credit_requirements();
203
+    // Check credits for the verified contributor role
204
+    boincuser_check_credit_requirements();
205 205
   
206
-  if (module_exists('boincteam')) {
206
+    if (module_exists('boincteam')) {
207 207
     // Display any persistent team messages
208 208
     boincteam_show_messages();
209
-  }
209
+    }
210 210
 }
211 211
 
212 212
 /**
@@ -214,8 +214,8 @@  discard block
 block discarded – undo
214 214
  * Drupal user operations
215 215
  */
216 216
 function boincuser_user($op, &$edit, &$account, $category = NULL) {
217
-  // Handle BOINC integration for users with UID > 1 (skip anonymous and admin)
218
-  if ($account->uid > 1) {
217
+    // Handle BOINC integration for users with UID > 1 (skip anonymous and admin)
218
+    if ($account->uid > 1) {
219 219
     switch($op) {
220 220
     case 'load':
221 221
       // User loading; insert BOINC data into the user object
@@ -223,11 +223,11 @@  discard block
 block discarded – undo
223 223
         SELECT boinc_id, penalty_expiration
224 224
         FROM {boincuser} WHERE uid = %d",
225 225
         $account->uid
226
-      ));
227
-      $account->boincuser_id = $drupal_user->boinc_id;
228
-      $account->boincuser_penalty_expiration = $drupal_user->penalty_expiration;
229
-      db_set_active('boinc');
230
-      $boinc_user = db_fetch_object(db_query("
226
+        ));
227
+        $account->boincuser_id = $drupal_user->boinc_id;
228
+        $account->boincuser_penalty_expiration = $drupal_user->penalty_expiration;
229
+        db_set_active('boinc');
230
+        $boinc_user = db_fetch_object(db_query("
231 231
         SELECT
232 232
           name,
233 233
           authenticator,
@@ -241,27 +241,27 @@  discard block
 block discarded – undo
241 241
         FROM {user}
242 242
         WHERE id = %d",
243 243
         $account->boincuser_id
244
-      ));
245
-      $account->boincuser_name = $boinc_user->name;
246
-      $account->boincuser_account_key = $boinc_user->authenticator;
247
-      $account->boincuser_weak_auth = md5($boinc_user->authenticator . $boinc_user->passwd_hash);
248
-      $account->boincuser_total_credit = round($boinc_user->total_credit);
249
-      $account->boincuser_expavg_credit = round($boinc_user->expavg_credit);
250
-      $account->boincuser_expavg_time = round($boinc_user->expavg_time);
251
-      $account->boincuser_cpid = md5($boinc_user->cross_project_id . $account->mail);
252
-      $account->boincuser_default_pref_set = $boinc_user->venue;
253
-      $account->boincteam_id = $boinc_user->teamid;
254
-      db_set_active('default');
255
-      // Set Drupal team ID
256
-      $account->team = NULL;
257
-      if ($account->boincteam_id) {
244
+        ));
245
+        $account->boincuser_name = $boinc_user->name;
246
+        $account->boincuser_account_key = $boinc_user->authenticator;
247
+        $account->boincuser_weak_auth = md5($boinc_user->authenticator . $boinc_user->passwd_hash);
248
+        $account->boincuser_total_credit = round($boinc_user->total_credit);
249
+        $account->boincuser_expavg_credit = round($boinc_user->expavg_credit);
250
+        $account->boincuser_expavg_time = round($boinc_user->expavg_time);
251
+        $account->boincuser_cpid = md5($boinc_user->cross_project_id . $account->mail);
252
+        $account->boincuser_default_pref_set = $boinc_user->venue;
253
+        $account->boincteam_id = $boinc_user->teamid;
254
+        db_set_active('default');
255
+        // Set Drupal team ID
256
+        $account->team = NULL;
257
+        if ($account->boincteam_id) {
258 258
         $account->team = db_result(db_query("
259 259
           SELECT nid FROM {boincteam} WHERE team_id = %d",
260
-          $account->boincteam_id
260
+            $account->boincteam_id
261 261
         ));
262
-      }
263
-      // Set post count
264
-      $account->post_count = db_result(db_query("
262
+        }
263
+        // Set post count
264
+        $account->post_count = db_result(db_query("
265 265
         SELECT COUNT(*) +
266 266
         (
267 267
           SELECT COUNT(*) FROM {node}
@@ -274,8 +274,8 @@  discard block
 block discarded – undo
274 274
         WHERE comments.uid = '%d'
275 275
         AND node.status = 1",
276 276
         $account->uid, $account->uid
277
-      ));
278
-      break;
277
+        ));
278
+        break;
279 279
       
280 280
     case 'view':
281 281
       // SAMPLE: Add BOINC data to the user profile
@@ -303,95 +303,95 @@  discard block
 block discarded – undo
303 303
           if (!boincuser_register_validate($edit)) {
304 304
             // BOINC user validation failed for registration; set an error accordingly
305 305
             form_set_error('mail', bts('An account already exists for @email. Log in or request password assistance to access your @project account.', array('@email' => $edit['mail'], '@project' => PROJECT), NULL, 'boinc:add-new-user'));
306
-          }
307
-          else {
306
+            }
307
+            else {
308 308
             // Save profile information for use during Insert
309 309
             $_SESSION['profileInfo'] = array(
310
-              'country' => $edit['field_country'][0]['value'],
311
-              'zip' => $edit['field_zip'][0]['value'],                  
312
-              'url' => $edit['field_url'][0]['value'],
313
-              'background' => $edit['field_background'][0]['value'],
314
-              'opinions' => $edit['field_opinions'][0]['value']
310
+                'country' => $edit['field_country'][0]['value'],
311
+                'zip' => $edit['field_zip'][0]['value'],                  
312
+                'url' => $edit['field_url'][0]['value'],
313
+                'background' => $edit['field_background'][0]['value'],
314
+                'opinions' => $edit['field_opinions'][0]['value']
315 315
             );
316 316
             // With BOINC validation passed, make sure name is unique
317 317
             $edit['name'] = find_unique_name($edit['boincuser_name']);
318
-          }
319
-          break;
318
+            }
319
+            break;
320 320
           
321 321
         case 'user_account':
322 322
           // Validate data before updating user account info
323 323
           boincuser_account_validate($edit, $account);
324
-          break;
324
+            break;
325 325
         
326 326
         default:
327 327
           
328 328
         }
329 329
         // We don't want to save validation source, so remove it
330 330
         $edit['validation_source'] = null;
331
-      }
332
-      break;
331
+        }
332
+        break;
333 333
       
334 334
     case 'insert':
335 335
       // New user being added to the system
336 336
       $profile_info = $_SESSION['profileInfo'];
337
-      $imported = $_SESSION['importedUser'];
338
-      unset($_SESSION['profileInfo']);
339
-      unset($_SESSION['importedUser']);
337
+        $imported = $_SESSION['importedUser'];
338
+        unset($_SESSION['profileInfo']);
339
+        unset($_SESSION['importedUser']);
340 340
       
341
-      watchdog(
341
+        watchdog(
342 342
         'boincuser',
343 343
         'Creating user account for %email_addr',
344 344
         array('%email_addr' => $edit['mail']),
345 345
         WATCHDOG_NOTICE
346
-      );
346
+        );
347 347
       
348
-      // NOTE: Registrations are normally handled via the create_account RPC,
349
-      // so the following will not run (kept in case form registration is used)
348
+        // NOTE: Registrations are normally handled via the create_account RPC,
349
+        // so the following will not run (kept in case form registration is used)
350 350
       
351
-      // If from the registration form, create a BOINC user and relationships
351
+        // If from the registration form, create a BOINC user and relationships
352 352
       
353
-      if ($profile_info and !$imported) {
353
+        if ($profile_info and !$imported) {
354 354
         // Create a BOINC account unless importing from BOINC
355 355
         $user_params = array(
356
-          'email_addr' => $edit['mail'],
357
-          'name' => $edit['boincuser_name'],
358
-          'passwd_hash' => md5($edit['pass'].$edit['mail']),
359
-          'country' => $profile_info['country'],
360
-          'postal_code' => $profile_info['zip']
356
+            'email_addr' => $edit['mail'],
357
+            'name' => $edit['boincuser_name'],
358
+            'passwd_hash' => md5($edit['pass'].$edit['mail']),
359
+            'country' => $profile_info['country'],
360
+            'postal_code' => $profile_info['zip']
361 361
         );
362 362
         $boinc_user = boincuser_register_make_user($user_params);
363 363
         if (!$boinc_user) {
364
-          // Account exists with this email addr
365
-          form_set_error('email', bts('Error creating BOINC account.', array(), NULL, 'boinc:add-new-user'));
366
-          return;
364
+            // Account exists with this email addr
365
+            form_set_error('email', bts('Error creating BOINC account.', array(), NULL, 'boinc:add-new-user'));
366
+            return;
367 367
         }
368 368
         // Add user to community role by default (not banned)
369 369
         $unrestricted_role = array_search('community member', user_roles(true)); 
370 370
         $edit['roles'] = array(
371
-          $unrestricted_role => ''
371
+            $unrestricted_role => ''
372 372
         );
373 373
         // Set profile data in BOINC db
374 374
         db_set_active('boinc');
375 375
         // TODO: add language, image support; error handling
376 376
         $reference = db_query("INSERT INTO {profile} SET userid='%d', response1='%s', response2='%s', verification=0", $boinc_user->id, $profile_info['background'], $profile_info['opinions']);
377 377
         if (!$reference) {
378
-          drupal_set_message(t('Error creating BOINC profile.'), 'error');
378
+            drupal_set_message(t('Error creating BOINC profile.'), 'error');
379 379
         }
380 380
         $reference = db_query("UPDATE {user} SET url='%s' WHERE id='%d'", $profile_info['url'], $boinc_user->id);
381 381
         if (!$reference) {
382
-          drupal_set_message(t('Error updating BOINC account.'), 'error');
382
+            drupal_set_message(t('Error updating BOINC account.'), 'error');
383 383
         }
384 384
         db_set_active('default');
385 385
         // Cross reference Drupal account with BOINC
386 386
         $reference = db_query("INSERT INTO {boincuser} SET uid='%d', boinc_id='%d'", $account->uid, $boinc_user->id);
387 387
         if (!$reference) {
388
-          drupal_set_message(t('Error connecting BOINC account.'), 'error');
389
-          return;
388
+            drupal_set_message(t('Error connecting BOINC account.'), 'error');
389
+            return;
390 390
         }
391 391
         // Don't save custom fields to the Drupal user object
392 392
         $edit['boincuser_name'] = null;
393
-      }
394
-      break;
393
+        }
394
+        break;
395 395
       
396 396
     case 'update':
397 397
       if (isset($edit['update_source'])) {
@@ -401,9 +401,9 @@  discard block
 block discarded – undo
401 401
         case 'user_account':
402 402
           // Ensure that BOINC data is altered
403 403
           $boinc_user = BoincUser::lookup_id($account->boincuser_id);
404
-          $changing_email = ($edit['mail'] AND $edit['mail'] != $boinc_user->email_addr) ? true : false;
405
-          $changing_pass = ($edit['pass']) ? true : false;
406
-          if ($changing_email OR $changing_pass) {
404
+            $changing_email = ($edit['mail'] AND $edit['mail'] != $boinc_user->email_addr) ? true : false;
405
+            $changing_pass = ($edit['pass']) ? true : false;
406
+            if ($changing_email OR $changing_pass) {
407 407
             // Set password hash appropriately
408 408
             $passwd = ($edit['pass']) ? $edit['pass'] : $edit['current_pass'];
409 409
             $passwd_hash = md5($passwd.$edit['mail']);
@@ -412,29 +412,29 @@  discard block
 block discarded – undo
412 412
             $result = $boinc_user->update(
413 413
                 "email_addr='{$email_addr}', passwd_hash='{$passwd_hash}'"
414 414
             );
415
-          }
416
-          break;
415
+            }
416
+            break;
417 417
         case 'user_profile':
418 418
           if ($edit['boincuser_name'] != $boinc_user->name) {
419 419
             $boincuser_name = $edit['boincuser_name'];
420 420
             $result = $boinc_user->update(
421 421
                 "name='{$boincuser_name}'"
422 422
             );
423
-          }
424
-          break;
423
+            }
424
+            break;
425 425
         default:
426 426
         }
427 427
         // We don't want to save update source or duplicate custom fields, so
428 428
         // remove them before continuing to core Drupal routines
429 429
         $edit['update_source'] = null;
430 430
         $edit['boincuser_name'] = null;
431
-      }
432
-      break;
431
+        }
432
+        break;
433 433
       
434 434
     default:
435 435
       
436 436
     }
437
-  }
437
+    }
438 438
 }
439 439
 
440 440
 /**
@@ -442,13 +442,13 @@  discard block
 block discarded – undo
442 442
  * Obsolete in Drupal 7...
443 443
  */
444 444
 function boincuser_nodeapi(&$node, $op, $a3 = null, $a4 = null) {
445
-  // In Drupal 7, these operation cases will all exist as their own hooks,
446
-  // so let's approximate that here so that this function can simply be removed
447
-  // upon migration to 7
448
-  switch($op) {
449
-  case 'update':
445
+    // In Drupal 7, these operation cases will all exist as their own hooks,
446
+    // so let's approximate that here so that this function can simply be removed
447
+    // upon migration to 7
448
+    switch($op) {
449
+    case 'update':
450 450
     boincuser_node_update($node);
451
-  }
451
+    }
452 452
 }
453 453
 
454 454
 /**
@@ -456,8 +456,8 @@  discard block
 block discarded – undo
456 456
  * is updated (forward compatible to Drupal 7)
457 457
  */
458 458
 function boincuser_node_update($node) {
459
-  switch($node->type) {
460
-  case 'profile':
459
+    switch($node->type) {
460
+    case 'profile':
461 461
     // Update the BOINC database directly
462 462
     $account = user_load($node->uid);
463 463
     // Save user account data
@@ -469,11 +469,11 @@  discard block
 block discarded – undo
469 469
       UPDATE user
470 470
       SET country = '%s', postal_code = '%s', url = '%s', has_profile = 1
471 471
       WHERE id = %d",
472
-      $country, $postal_code, $url, $account->boincuser_id
472
+        $country, $postal_code, $url, $account->boincuser_id
473 473
     );
474 474
     db_set_active('default');
475 475
     if (!$account_updated) {
476
-      drupal_set_message(t('Error saving BOINC account info.'), 'error');
476
+        drupal_set_message(t('Error saving BOINC account info.'), 'error');
477 477
     }
478 478
     // Save profile data
479 479
     $response1 = $node->field_background[0]['value'];
@@ -484,16 +484,16 @@  discard block
 block discarded – undo
484 484
       SET userid = %d, response1 = '%s', response2 = '%s'
485 485
       ON DUPLICATE KEY UPDATE
486 486
         response1 = '%s', response2 = '%s'",
487
-      $account->boincuser_id, $response1, $response2,
488
-      $response1, $response2
487
+        $account->boincuser_id, $response1, $response2,
488
+        $response1, $response2
489 489
     );
490 490
     db_set_active('default');
491 491
     if (!$profile_updated) {
492
-      drupal_set_message(t('Error saving BOINC profile.'), 'error');
492
+        drupal_set_message(t('Error saving BOINC profile.'), 'error');
493 493
     }
494 494
     break;
495 495
     
496
-  default:
496
+    default:
497 497
     
498 498
   }
499 499
 }
@@ -502,19 +502,19 @@  discard block
 block discarded – undo
502 502
 * Implementation of hook_views_api()
503 503
 */
504 504
 function boincuser_views_api() {
505
-  return array(
505
+    return array(
506 506
     'api' => 2.0,
507 507
     'path' => drupal_get_path('module', 'boincuser')
508
-  );
508
+    );
509 509
 }
510 510
 
511 511
 /**
512 512
 * Implementation of hook_form_alter()
513 513
 */
514 514
 function boincuser_form_alter(&$form, $form_state, $form_id) {
515
-  global $user;
516
-  switch ($form_id) {
517
-  case 'flag_confirm':
515
+    global $user;
516
+    switch ($form_id) {
517
+    case 'flag_confirm':
518 518
     // The URL seems to be the only way to put any kind of context to this
519 519
     // request!
520 520
     $action = arg(2);
@@ -523,25 +523,25 @@  discard block
 block discarded – undo
523 523
     
524 524
     // Wrap action buttons for styling consistency
525 525
     $form['form control tabs prefix'] = array(
526
-      '#value' => '<ul class="form-control tab-list">',
527
-      '#weight' => 1001,
526
+        '#value' => '<ul class="form-control tab-list">',
527
+        '#weight' => 1001,
528 528
     );
529 529
     
530 530
     switch ($flag_type) {
531 531
     case 'friend':
532 532
       $friend_id = $form['content_id']['#value'];
533
-      $flag = flag_get_flag('friend');
534
-      $friend_status = flag_friend_determine_friend_status($flag, $friend_id, $user->uid);
533
+        $flag = flag_get_flag('friend');
534
+        $friend_status = flag_friend_determine_friend_status($flag, $friend_id, $user->uid);
535 535
       
536
-      // General friend form overrides
537
-      $form['flag_friend_submit']['#prefix'] = '<li class="first tab">';
538
-      $form['flag_friend_submit']['#value'] = bts('Send request', array(), NULL, 'boinc:friends-page');
539
-      $form['flag_friend_submit']['#type'] = 'submit';
540
-      $form['flag_friend_submit']['#suffix'] = '</li>';
541
-      $form['flag_friend_submit']['#weight'] = 1002;
536
+        // General friend form overrides
537
+        $form['flag_friend_submit']['#prefix'] = '<li class="first tab">';
538
+        $form['flag_friend_submit']['#value'] = bts('Send request', array(), NULL, 'boinc:friends-page');
539
+        $form['flag_friend_submit']['#type'] = 'submit';
540
+        $form['flag_friend_submit']['#suffix'] = '</li>';
541
+        $form['flag_friend_submit']['#weight'] = 1002;
542 542
       
543
-      switch ($friend_status) {
544
-      case FLAG_FRIEND_BOTH:
543
+        switch ($friend_status) {
544
+        case FLAG_FRIEND_BOTH:
545 545
       case FLAG_FRIEND_FLAGGED:
546 546
         unset($form['actions']);
547 547
         $form['flag_friend_submit']['#value'] = bts('Remove friend', array(), NULL, 'boinc:friends-remove');
@@ -550,53 +550,53 @@  discard block
 block discarded – undo
550 550
         $form['#submit'][] = 'boincuser_fix_unfriend_form_submit';
551 551
         $form['#submit'][] = $final_handler;
552 552
         break;
553
-      case FLAG_FRIEND_PENDING:
553
+        case FLAG_FRIEND_PENDING:
554 554
         unset($form['actions']);
555 555
         $form['flag_friend_submit']['#value'] = bts('Remove request', array(), NULL, 'boinc:friends-page');
556 556
         break;
557
-      case FLAG_FRIEND_APPROVAL:
557
+        case FLAG_FRIEND_APPROVAL:
558 558
         if ($action == 'flag') {
559
-          $form['flag_friend_submit']['#value'] = bts('Approve request', array(), NULL, 'boinc:friends-page');
559
+            $form['flag_friend_submit']['#value'] = bts('Approve request', array(), NULL, 'boinc:friends-page');
560 560
         }
561 561
         elseif ($action == 'unflag') {
562
-          unset($form['actions']);
563
-          $form['flag_friend_submit']['#value'] = bts('Deny request', array(), NULL, 'boinc:friends-page');
562
+            unset($form['actions']);
563
+            $form['flag_friend_submit']['#value'] = bts('Deny request', array(), NULL, 'boinc:friends-page');
564 564
         }
565 565
         break;
566
-      case FLAG_FRIEND_UNFLAGGED:
566
+        case FLAG_FRIEND_UNFLAGGED:
567 567
       default:
568 568
         $user_links[] = array(
569
-          'title' => bts('Add as friend', array(), NULL, 'boinc:friends-add'),
570
-          'href' => "flag/confirm/flag/friend/{$account->uid}"
569
+            'title' => bts('Add as friend', array(), NULL, 'boinc:friends-add'),
570
+            'href' => "flag/confirm/flag/friend/{$account->uid}"
571 571
         );
572
-      }
573
-      break;
572
+        }
573
+        break;
574 574
       
575 575
     default:
576 576
     }
577 577
     
578 578
     $form['cancel'] = array(
579
-      '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $cancel_dest) . '</li>',
580
-      '#weight' => 1004,
579
+        '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $cancel_dest) . '</li>',
580
+        '#weight' => 1004,
581 581
     );
582 582
     $form['form control tabs suffix'] = array(
583
-      '#value' => '</ul>',
584
-      '#weight' => 1010,
583
+        '#value' => '</ul>',
584
+        '#weight' => 1010,
585 585
     );
586 586
     
587 587
     break;
588 588
     
589
-  // General node edit form
590
-  case 'news_node_form':
589
+    // General node edit form
590
+    case 'news_node_form':
591 591
     $form['separator_bottom'] = array(
592
-      '#value' => '<div class="separator buttons"></div>',
593
-      '#weight' => 999,
592
+        '#value' => '<div class="separator buttons"></div>',
593
+        '#weight' => 999,
594 594
     );
595 595
     
596 596
     // Wrap action buttons for styling consistency
597 597
     $form['buttons']['form control tabs prefix'] = array(
598
-      '#value' => '<ul class="form-control tab-list">',
599
-      '#weight' => 1001,
598
+        '#value' => '<ul class="form-control tab-list">',
599
+        '#weight' => 1001,
600 600
     );
601 601
     $form['buttons']['submit']['#prefix'] = '<li class="first tab">';
602 602
     $form['buttons']['submit']['#value'] = bts('Save changes', array(), NULL, 'boinc:form-save');
@@ -609,15 +609,15 @@  discard block
 block discarded – undo
609 609
     $form['buttons']['preview_changes']['#suffix'] = '</li>';
610 610
     $form['buttons']['preview_changes']['#weight'] = 1004;
611 611
     $form['buttons']['cancel'] = array(
612
-      '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "node/{$form['nid']['#value']}") . '</li>',
613
-      '#weight' => 1005,
612
+        '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "node/{$form['nid']['#value']}") . '</li>',
613
+        '#weight' => 1005,
614 614
     );
615 615
     $form['buttons']['delete']['#prefix'] = '<li class="tab">';
616 616
     $form['buttons']['delete']['#suffix'] = '</li>';
617 617
     $form['buttons']['delete']['#weight'] = 1006;
618 618
     $form['buttons']['form control tabs suffix'] = array(
619
-      '#value' => '</ul>',
620
-      '#weight' => 1010,
619
+        '#value' => '</ul>',
620
+        '#weight' => 1010,
621 621
     );
622 622
     
623 623
     // Preview is ugly, unset until it works
@@ -625,16 +625,16 @@  discard block
 block discarded – undo
625 625
 
626 626
     break;
627 627
   
628
-  case 'node_delete_confirm':
628
+    case 'node_delete_confirm':
629 629
     $form['separator_bottom'] = array(
630
-      '#value' => '<div class="separator buttons"></div>',
631
-      '#weight' => 999,
630
+        '#value' => '<div class="separator buttons"></div>',
631
+        '#weight' => 999,
632 632
     );
633 633
     
634 634
     // Wrap action buttons for styling consistency
635 635
     $form['actions']['form control tabs prefix'] = array(
636
-      '#value' => '<ul class="form-control tab-list">',
637
-      '#weight' => 1001,
636
+        '#value' => '<ul class="form-control tab-list">',
637
+        '#weight' => 1001,
638 638
     );
639 639
     $form['actions']['submit']['#prefix'] = '<li class="first tab">';
640 640
     $form['actions']['submit']['#value'] = bts('Delete', array(), NULL, 'boinc:form-delete');
@@ -642,23 +642,23 @@  discard block
 block discarded – undo
642 642
     $form['actions']['submit']['#weight'] = 1002;
643 643
     $form['actions']['cancel'] = array(
644 644
         '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "node/{$form['nid']['#value']}") . '</li>',
645
-      '#weight' => 1005,
645
+        '#weight' => 1005,
646 646
     );
647 647
     $form['actions']['form control tabs suffix'] = array(
648
-      '#value' => '</ul>',
649
-      '#weight' => 1010,
648
+        '#value' => '</ul>',
649
+        '#weight' => 1010,
650 650
     );
651 651
     $form['#redirect'] = 'account/profile';
652 652
     break;
653 653
     
654
-  case 'privatemsg_new':
654
+    case 'privatemsg_new':
655 655
     
656 656
     $form['privatemsg']['body']['#title'] = '';
657 657
     
658 658
     // Wrap action buttons for styling consistency
659 659
     $form['privatemsg']['form control tabs prefix'] = array(
660
-      '#value' => '<ul class="form-control tab-list">',
661
-      '#weight' => 1001,
660
+        '#value' => '<ul class="form-control tab-list">',
661
+        '#weight' => 1001,
662 662
     );
663 663
     $form['privatemsg']['submit']['#prefix'] = '<li class="first tab">';
664 664
     $form['privatemsg']['submit']['#value'] = bts('Send message', array(), NULL, 'boinc:private-message');
@@ -668,26 +668,26 @@  discard block
 block discarded – undo
668 668
     $form['privatemsg']['preview']['#suffix'] = '</li>';
669 669
     $form['privatemsg']['preview']['#weight'] = 1003;
670 670
     $form['privatemsg']['cancel'] = array(
671
-      '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>',
672
-      '#weight' => 1004,
671
+        '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>',
672
+        '#weight' => 1004,
673 673
     );
674 674
     $form['privatemsg']['form control tabs suffix'] = array(
675
-      '#value' => '</ul>',
676
-      '#weight' => 1010,
675
+        '#value' => '</ul>',
676
+        '#weight' => 1010,
677 677
     );
678 678
     
679 679
     unset($form['privatemsg']['recipient_display']);
680 680
     
681 681
     break;
682 682
     
683
-  // Login form
684
-  case 'user_login':
683
+    // Login form
684
+    case 'user_login':
685 685
   case 'user_login_block':
686 686
       drupal_set_title(bts('Login', array(), NULL, 'boinc:menu-link'));
687 687
     // Replace name with email in login form
688 688
     unset($form['name']);
689 689
     array_unshift($form, array(
690
-      'email' => array(
690
+        'email' => array(
691 691
         '#type' => 'textfield',
692 692
         '#title' => bts('Email address', array(), NULL, 'boinc:email-address-to-login'),
693 693
         '#size' => ($form_id == 'user_login_block') ? 15 : 60,
@@ -695,18 +695,18 @@  discard block
 block discarded – undo
695 695
         '#required' => TRUE,
696 696
         '#attributes' => array('tabindex' => '1'),
697 697
         '#description' => bts('Enter your @s email address.', array('@s' => variable_get('site_name', 'Drupal-BOINC')), NULL, 'boinc:standard-login-page')
698
-      ),
699
-      'validation_source' => array(
698
+        ),
699
+        'validation_source' => array(
700 700
         '#type' => 'hidden',
701 701
         '#value' => 'user_login'
702
-      )
702
+        )
703 703
     ));
704 704
     $form['#redirect'] = 'home';
705 705
     
706 706
     // Wrap action buttons for styling consistency
707 707
     $form['buttons']['form control tabs prefix'] = array(
708
-      '#value' => '<ul class="form-control tab-list">',
709
-      '#weight' => 1001,
708
+        '#value' => '<ul class="form-control tab-list">',
709
+        '#weight' => 1001,
710 710
     );
711 711
     $form['buttons']['submit'] = $form['submit'];
712 712
     $form['buttons']['submit']['#prefix'] = '<li class="first tab">';
@@ -714,8 +714,8 @@  discard block
 block discarded – undo
714 714
     $form['buttons']['submit']['#suffix'] = '</li>';
715 715
     $form['buttons']['submit']['#weight'] = 1002;
716 716
     $form['buttons']['form control tabs suffix'] = array(
717
-      '#value' => '</ul>',
718
-      '#weight' => 1010,
717
+        '#value' => '</ul>',
718
+        '#weight' => 1010,
719 719
     );
720 720
     unset($form['submit']);
721 721
     
@@ -724,23 +724,23 @@  discard block
 block discarded – undo
724 724
     isset($form['buttons']['submit']['#attributes']) ? array_push($form['buttons']['submit']['#attributes'], array('tabindex' => '3')) : $form['buttons']['submit']['#attributes'] = array('tabindex' => '3');
725 725
     // If the user login form is being submitted, use BOINC validation handler.
726 726
     if (isset($form_state['post']['email']) and isset($form_state['post']['pass'])) {
727
-      // Find the local validation function's entry so we can replace it.
728
-      $array_key = array_search('user_login_authenticate_validate', $form['#validate']);
729
-      if ($array_key === FALSE) {
727
+        // Find the local validation function's entry so we can replace it.
728
+        $array_key = array_search('user_login_authenticate_validate', $form['#validate']);
729
+        if ($array_key === FALSE) {
730 730
         // Could not find it. Some other module must have run form_alter().
731 731
         // We will simply add our validation just before the final validator.
732 732
         $final_validator = array_pop($form['#validate']);
733 733
         $form['#validate'][] = 'boincuser_login_validate';
734 734
         $form['#validate'][] = $final_validator;
735
-      } else {
735
+        } else {
736 736
         // Replace the local validation function with BOINC validation
737 737
         $form['#validate'][$array_key] = 'boincuser_login_validate';
738
-      }
738
+        }
739 739
     }
740 740
     break;
741 741
     
742
-  // User credentials form
743
-  case 'user_profile_form':
742
+    // User credentials form
743
+    case 'user_profile_form':
744 744
     
745 745
     // Use the displaly name as the title, not the username
746 746
     $account = user_load($form['#uid']);
@@ -750,7 +750,7 @@  discard block
 block discarded – undo
750 750
     // coming from the password reset function
751 751
     $reset_pass = (strpos($_SERVER['HTTP_REFERER'], "/user/reset/{$form['#uid']}") === FALSE) ? 0 : 1;
752 752
     if ($reset_pass) {
753
-      $_SESSION['reset_pass'] = 1;
753
+        $_SESSION['reset_pass'] = 1;
754 754
     }
755 755
     
756 756
     $form['account']['name']['#size'] = 40;
@@ -759,50 +759,50 @@  discard block
 block discarded – undo
759 759
     $form['account']['pass']['#size'] = 17;
760 760
     
761 761
     if (!$reset_pass AND ($user->uid == $account->uid OR !user_access('administer users'))) {
762
-      // Add a password authenticator, required to change email or pw
763
-      $form['account']['current_pass'] = array(
762
+        // Add a password authenticator, required to change email or pw
763
+        $form['account']['current_pass'] = array(
764 764
         '#type' => 'password',
765 765
         '#title' => bts('Enter your password to save changes', array(), NULL, 'boinc:account-credentials-change'),
766 766
         '#description' => bts('Enter your current password if changing your email
767 767
           address or password.', array(), NULL, 'boinc:account-credentials-change'),
768 768
         '#size' => 17,
769 769
         '#attributes' => array(
770
-          'autocomplete' => 'off',
770
+            'autocomplete' => 'off',
771 771
         ),
772
-      );
772
+        );
773 773
     }
774 774
     
775 775
     // Add account keys, CPID, etc
776 776
     $form['account']['boincuser_id'] = array(
777
-      '#value' => '
777
+        '#value' => '
778 778
         <div class="form-item">
779 779
           <label>' . bts('BOINC user ID', array(), NULL, 'boinc:account-credentials-change') . '</label>
780 780
           <span>' . $account->boincuser_id . '</span>
781 781
         </div>',
782 782
     );
783 783
     $form['account']['user_id'] = array(
784
-      '#value' => '
784
+        '#value' => '
785 785
         <div class="form-item">
786 786
           <label>' . bts('Drupal user ID', array(), NULL, 'boinc:account-credentials-change') . '</label>
787 787
           <span>' . $account->uid . '</span>
788 788
         </div>',
789 789
     );
790 790
     $form['account']['account_key'] = array(
791
-      '#value' => '
791
+        '#value' => '
792 792
         <div class="form-item">
793 793
           <label>' . bts('Account key', array(), NULL, 'boinc:account-credentials-change') . '</label>
794 794
           <span>' . $account->boincuser_account_key . '</span>
795 795
         </div>',
796 796
     );
797 797
     $form['account']['weak_account_key'] = array(
798
-      '#value' => '
798
+        '#value' => '
799 799
         <div class="form-item">
800 800
           <label>' . bts('Weak account key', array(), NULL, 'boinc:account-credentials-change') . '</label>
801 801
           <span>' . "{$account->boincuser_id}_{$account->boincuser_weak_auth}" . '</span>
802 802
         </div>',
803 803
     );
804 804
     $form['account']['cpid'] = array(
805
-      '#value' => '
805
+        '#value' => '
806 806
         <div class="form-item">
807 807
           <label>' . bts('Cross-project ID', array(), NULL, 'boinc:account-credentials-change') . '</label>
808 808
           <span>' . $account->boincuser_cpid . '</span>
@@ -810,30 +810,30 @@  discard block
 block discarded – undo
810 810
     );
811 811
     
812 812
     $form['account']['separator_bottom'] = array(
813
-      '#value' => '<div class="separator buttons"></div>'
813
+        '#value' => '<div class="separator buttons"></div>'
814 814
     );
815 815
     
816 816
     // Wrap action buttons for styling consistency
817 817
     $form['form control tabs prefix'] = array(
818
-      '#value' => '<ul class="form-control tab-list">',
819
-      '#weight' => 1001,
818
+        '#value' => '<ul class="form-control tab-list">',
819
+        '#weight' => 1001,
820 820
     );
821 821
     $form['submit']['#prefix'] = '<li class="first tab">';
822 822
     $form['submit']['#value'] = bts('Save changes', array(), NULL, 'boinc:form-save');
823 823
     $form['submit']['#suffix'] = '</li>';
824 824
     $form['submit']['#weight'] = 1002;
825 825
     if (isset($form['delete']) AND is_array($form['delete'])) {
826
-      $form['delete']['#prefix'] = '<li class="tab">';
827
-      $form['delete']['#suffix'] = '</li>';
828
-      $form['delete']['#weight'] = 1003;
826
+        $form['delete']['#prefix'] = '<li class="tab">';
827
+        $form['delete']['#suffix'] = '</li>';
828
+        $form['delete']['#weight'] = 1003;
829 829
     }
830 830
     $form['cancel'] = array(
831
-      '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>',
832
-      '#weight' => 1004,
831
+        '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>',
832
+        '#weight' => 1004,
833 833
     );
834 834
     $form['form control tabs suffix'] = array(
835
-      '#value' => '</ul>',
836
-      '#weight' => 1010,
835
+        '#value' => '</ul>',
836
+        '#weight' => 1010,
837 837
     );
838 838
     
839 839
     // Rearrange form elements
@@ -864,41 +864,41 @@  discard block
 block discarded – undo
864 864
     
865 865
     // Internal fields to indicate where these user changes are taking place
866 866
     array_unshift($form, array(
867
-      'validation_source' => array(
867
+        'validation_source' => array(
868 868
         '#type' => 'hidden',
869 869
         '#value' => 'user_account'
870
-      ),
871
-      'update_source' => array(
870
+        ),
871
+        'update_source' => array(
872 872
         '#type' => 'hidden',
873 873
         '#value' => 'user_account'
874
-      )
874
+        )
875 875
     ));
876 876
     
877 877
     break;
878 878
     
879
-  case 'profile_node_form':
879
+    case 'profile_node_form':
880 880
     
881 881
     // Use the display name as the title, not the username
882 882
     $account = user_load($form['uid']['#value']);
883 883
     drupal_set_title($account->boincuser_name);
884 884
     
885 885
     $form['separator_bottom'] = array(
886
-      '#value' => '<div class="separator buttons"></div>',
887
-      '#weight' => 999,
886
+        '#value' => '<div class="separator buttons"></div>',
887
+        '#weight' => 999,
888 888
     );
889 889
     
890 890
     if (module_exists('captcha')) {
891
-      // Add an optional captcha
892
-      $form['profile_captcha'] = array(
891
+        // Add an optional captcha
892
+        $form['profile_captcha'] = array(
893 893
         '#type' => 'captcha',
894 894
         '#weight' => 1000,
895
-      );
895
+        );
896 896
     }
897 897
     
898 898
     // Wrap action buttons for styling consistency
899 899
     $form['buttons']['form control tabs prefix'] = array(
900
-      '#value' => '<ul class="form-control tab-list">',
901
-      '#weight' => 1001,
900
+        '#value' => '<ul class="form-control tab-list">',
901
+        '#weight' => 1001,
902 902
     );
903 903
     $form['buttons']['submit']['#prefix'] = '<li class="first tab">';
904 904
     $form['buttons']['submit']['#value'] = bts('Save changes', array(), NULL, 'boinc:form-save');
@@ -911,15 +911,15 @@  discard block
 block discarded – undo
911 911
     $form['buttons']['preview_changes']['#suffix'] = '</li>';
912 912
     $form['buttons']['preview_changes']['#weight'] = 1004;
913 913
     $form['buttons']['cancel'] = array(
914
-      '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>',
915
-      '#weight' => 1005,
914
+        '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>',
915
+        '#weight' => 1005,
916 916
     );
917 917
     $form['buttons']['delete']['#prefix'] = '<li class="tab">';
918 918
     $form['buttons']['delete']['#suffix'] = '</li>';
919 919
     $form['buttons']['delete']['#weight'] = 1006;
920 920
     $form['buttons']['form control tabs suffix'] = array(
921
-      '#value' => '</ul>',
922
-      '#weight' => 1010,
921
+        '#value' => '</ul>',
922
+        '#weight' => 1010,
923 923
     );
924 924
     
925 925
     $form['#after_build'][] = 'boincuser_profile_node_form_after_build';
@@ -936,79 +936,79 @@  discard block
 block discarded – undo
936 936
     
937 937
     // Internal fields to indicate where these user changes are taking place
938 938
     array_unshift($form, array(
939
-      'validation_source' => array(
939
+        'validation_source' => array(
940 940
         '#type' => 'hidden',
941 941
         '#value' => 'user_profile'
942
-      ),
943
-      'update_source' => array(
942
+        ),
943
+        'update_source' => array(
944 944
         '#type' => 'hidden',
945 945
         '#value' => 'user_profile'
946
-      )
946
+        )
947 947
     ));
948 948
     break;
949 949
   
950
-  // Registration form
951
-  case 'user_register':
950
+    // Registration form
951
+    case 'user_register':
952 952
     array_unshift($form, array(
953
-      'boincuser_name' => array(
953
+        'boincuser_name' => array(
954 954
         '#type' => 'textfield', 
955 955
         '#title' => bts('Name', array(), NULL, 'boinc:user-or-team-name'), 
956 956
         '#default_value' => $edit['boincuser_name'], 
957 957
         '#maxlength' => USERNAME_MAX_LENGTH, 
958 958
         '#description' => bts('Spaces are allowed; punctuation is not allowed except for periods, hyphens, and underscores.', array(), NULL, 'boinc:user-register'), 
959 959
         '#required' => TRUE
960
-      ),
961
-      'validation_source' => array(
960
+        ),
961
+        'validation_source' => array(
962 962
         '#type' => 'hidden',
963 963
         '#value' => 'user_register'
964
-      )
964
+        )
965 965
     ));
966 966
     // Set name temporarily to dummy value to beat validation
967 967
     $form['name'] = array(
968
-      '#type' => 'hidden',
969
-      '#value' => rand() . '.' . time()
968
+        '#type' => 'hidden',
969
+        '#value' => rand() . '.' . time()
970 970
     );
971 971
     
972 972
     if (module_exists('captcha')) {
973
-      // Add an optional captcha
974
-      $form['register_captcha'] = array(
973
+        // Add an optional captcha
974
+        $form['register_captcha'] = array(
975 975
         '#type' => 'captcha',
976 976
         '#weight' => 1000,
977
-      );
977
+        );
978 978
     }
979 979
     
980 980
     $form['submit']['#weight'] = 1001;
981 981
     break;
982 982
     
983
-  // Request new password form
984
-  case 'user_pass':
983
+    // Request new password form
984
+    case 'user_pass':
985 985
     drupal_set_title(bts('Forgot password', array(), NULL, 'boinc:forgot-password'));
986 986
     // Replace name/email text box with email only; retain "name" label
987 987
     // for compatibility with standard Drupal submit function
988 988
     unset($form['name']);
989 989
     array_unshift($form, array(
990
-      'name' => array(
990
+        'name' => array(
991 991
         '#type' => 'textfield',
992 992
         '#title' => bts('Email address', array(), NULL, 'boinc:email-address-to-login'),
993 993
         '#size' => 60,
994 994
         '#maxlength' => EMAIL_MAX_LENGTH,
995 995
         '#required' => TRUE,
996 996
         '#description' => bts(
997
-          'Enter your email address to receive instructions for resetting your password (or use the !authenticator_login).',
998
-          array(
997
+            'Enter your email address to receive instructions for resetting your password (or use the !authenticator_login).',
998
+            array(
999 999
             '!authenticator_login' => l(
1000
-              bts('authenticator-based login', array(), NULL, 'boinc:forgot-password'),
1001
-              'user/login/auth'
1000
+                bts('authenticator-based login', array(), NULL, 'boinc:forgot-password'),
1001
+                'user/login/auth'
1002
+            )
1002 1003
             )
1003
-          )
1004 1004
         , NULL, 'boinc:forgot-password'),
1005
-      ),
1005
+        ),
1006 1006
     ));
1007 1007
     
1008 1008
     // Wrap action buttons for styling consistency
1009 1009
     $form['buttons']['form control tabs prefix'] = array(
1010
-      '#value' => '<ul class="form-control tab-list">',
1011
-      '#weight' => 1001,
1010
+        '#value' => '<ul class="form-control tab-list">',
1011
+        '#weight' => 1001,
1012 1012
     );
1013 1013
     $form['buttons']['submit'] = $form['submit'];
1014 1014
     $form['buttons']['submit']['#prefix'] = '<li class="first tab">';
@@ -1016,26 +1016,26 @@  discard block
 block discarded – undo
1016 1016
     $form['buttons']['submit']['#suffix'] = '</li>';
1017 1017
     $form['buttons']['submit']['#weight'] = 1002;
1018 1018
     $form['buttons']['cancel'] = array(
1019
-      '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'user/login') . '</li>',
1020
-      '#weight' => 1005,
1019
+        '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'user/login') . '</li>',
1020
+        '#weight' => 1005,
1021 1021
     );
1022 1022
     $form['buttons']['form control tabs suffix'] = array(
1023
-      '#value' => '</ul>',
1024
-      '#weight' => 1010,
1023
+        '#value' => '</ul>',
1024
+        '#weight' => 1010,
1025 1025
     );
1026 1026
     unset($form['submit']);
1027 1027
     
1028 1028
     // If the form is being submitted, use BOINC validation handler.
1029 1029
     if (isset($form_state['post']['name'])) {
1030
-      // Prepend the BOINC validation function to local validation
1031
-      array_unshift($form['#validate'], 'boincuser_request_pass_validate');
1030
+        // Prepend the BOINC validation function to local validation
1031
+        array_unshift($form['#validate'], 'boincuser_request_pass_validate');
1032 1032
     }
1033 1033
     break;
1034 1034
     
1035
-  case 'views_exposed_form':
1035
+    case 'views_exposed_form':
1036 1036
       $form['submit']['#value'] = bts('Search', array(), NULL, 'boinc:search-user');
1037 1037
     break;
1038
-  }
1038
+    }
1039 1039
 }
1040 1040
 
1041 1041
 /**
@@ -1043,10 +1043,10 @@  discard block
 block discarded – undo
1043 1043
  * built; this is called from boincuser_form_alter()
1044 1044
  */
1045 1045
 function boincuser_profile_node_form_after_build($form, &$form_state) {
1046
-  // Move to community prefs form
1047
-  $form_state['storage']['avatar'] = $form['field_image'];
1048
-  unset($form['field_image']);
1049
-  return $form;
1046
+    // Move to community prefs form
1047
+    $form_state['storage']['avatar'] = $form['field_image'];
1048
+    unset($form['field_image']);
1049
+    return $form;
1050 1050
 }
1051 1051
 
1052 1052
 /**
@@ -1054,8 +1054,8 @@  discard block
 block discarded – undo
1054 1054
  * @see http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hook_elements/6
1055 1055
  */
1056 1056
 function boincuser_elements() {
1057
-  $type['password_confirm']['#process'][] = 'boincuser_process_password_confirm';
1058
-  return $type;
1057
+    $type['password_confirm']['#process'][] = 'boincuser_process_password_confirm';
1058
+    return $type;
1059 1059
 }
1060 1060
 
1061 1061
 /**
@@ -1063,11 +1063,11 @@  discard block
 block discarded – undo
1063 1063
  * profile form
1064 1064
  */
1065 1065
 function boincuser_process_password_confirm($element) {
1066
-  // Check if parent element is "account".
1067
-  if ($element['#array_parents'][0] == 'account') {
1066
+    // Check if parent element is "account".
1067
+    if ($element['#array_parents'][0] == 'account') {
1068 1068
     $element['pass1']['#title'] = bts('Change password', array(), NULL, 'boinc:forgot-password');
1069
-  }
1070
-  return $element;
1069
+    }
1070
+    return $element;
1071 1071
 }
1072 1072
 
1073 1073
 /**
@@ -1075,40 +1075,40 @@  discard block
 block discarded – undo
1075 1075
  * Register theme functions for use in this module.
1076 1076
  */
1077 1077
 function boincuser_theme($existing, $type, $theme, $path) {
1078
-  return array(
1078
+    return array(
1079 1079
     'boincuser_user_pass' => array(
1080
-      'arguments' => array()
1080
+        'arguments' => array()
1081 1081
     )
1082
-  );
1082
+    );
1083 1083
 }
1084 1084
 
1085 1085
 /**
1086 1086
  * Implementation of hook_token_values
1087 1087
  */
1088 1088
 function boincuser_token_values($type, $object = NULL, $options = array()) {
1089
-  if ($type == 'user') {
1089
+    if ($type == 'user') {
1090 1090
     $account = user_load($object->uid);
1091 1091
     $tokens['display-name'] = $account->boincuser_name;
1092 1092
     return $tokens;
1093
-  }
1093
+    }
1094 1094
 }
1095 1095
 
1096 1096
 /**
1097 1097
  * Implementation of hook_token_list
1098 1098
  */
1099 1099
 function boincuser_token_list($type = 'all') {
1100
-  if ($type == 'user' || $type == 'all') {
1100
+    if ($type == 'user' || $type == 'all') {
1101 1101
     $tokens['user']['display-name']      = t("The user's name that should be displayed");
1102 1102
     return $tokens;
1103
-  }
1103
+    }
1104 1104
 }
1105 1105
 
1106 1106
 /**
1107 1107
  * Implementation of hook_views_pre_execute()
1108 1108
  */
1109 1109
 function boincuser_views_pre_execute(&$view) {
1110
-  $account_id = $view->args[0];
1111
-  if ($view->name=="user_activity") {
1110
+    $account_id = $view->args[0];
1111
+    if ($view->name=="user_activity") {
1112 1112
     // Run the following custom query for the user_activity view
1113 1113
     $view->build_info['query']= "
1114 1114
       SELECT node_revisions.vid AS vid,
@@ -1140,7 +1140,7 @@  discard block
 block discarded – undo
1140 1140
     
1141 1141
     // count_query determines the pager.  Do this so the right item count is returned.
1142 1142
     $view->build_info['count_query'] = $view->build_info['query'];
1143
-  }
1143
+    }
1144 1144
 }
1145 1145
 
1146 1146
 
@@ -1152,17 +1152,17 @@  discard block
 block discarded – undo
1152 1152
  * Page callback shortcut to recent posts for the logged in user
1153 1153
  */
1154 1154
 function boincuser_goto_recent_posts() {
1155
-  global $user;
1156
-  drupal_goto("account/{$user->uid}/posts");
1155
+    global $user;
1156
+    drupal_goto("account/{$user->uid}/posts");
1157 1157
 }
1158 1158
 
1159 1159
 /**
1160 1160
  * Page callback shortcut to the team of the logged in user
1161 1161
  */
1162 1162
 function boincuser_goto_team() {
1163
-  global $user;
1164
-  $account = user_load($user->uid);
1165
-  drupal_goto("community/teams/{$account->team}");
1163
+    global $user;
1164
+    $account = user_load($user->uid);
1165
+    drupal_goto("community/teams/{$account->team}");
1166 1166
 }
1167 1167
 
1168 1168
 /**
@@ -1171,58 +1171,58 @@  discard block
 block discarded – undo
1171 1171
  * user profile pages, so use a wrapper for display
1172 1172
  */
1173 1173
 function boincuser_view_profile($account = null) {
1174
-  // Create the user profile page
1175
-  if (!$account) {
1174
+    // Create the user profile page
1175
+    if (!$account) {
1176 1176
     global $user;
1177 1177
     $account = $user;
1178
-  }
1179
-  // For now, just call the user module profile view function
1180
-  user_build_content($account);
1181
-  return theme('user_profile', $account);
1178
+    }
1179
+    // For now, just call the user module profile view function
1180
+    user_build_content($account);
1181
+    return theme('user_profile', $account);
1182 1182
 }
1183 1183
 
1184 1184
 /**
1185 1185
  * Page callback for editing a user profile
1186 1186
  */
1187 1187
 function boincuser_edit_profile($account = null) {
1188
-  // Create the user profile form
1189
-  if (!$account) {
1188
+    // Create the user profile form
1189
+    if (!$account) {
1190 1190
     global $user;
1191 1191
     $account = $user;
1192
-  }
1193
-  // Render the form
1194
-  module_load_include('pages.inc', 'node', 'node');
1195
-  return content_profile_page_edit('profile', $account);
1192
+    }
1193
+    // Render the form
1194
+    module_load_include('pages.inc', 'node', 'node');
1195
+    return content_profile_page_edit('profile', $account);
1196 1196
 }
1197 1197
 
1198 1198
 /**
1199
-  * Join page menu callback.
1200
-  * Display instructions on joining for new or existing BOINC users
1201
-  */
1199
+ * Join page menu callback.
1200
+ * Display instructions on joining for new or existing BOINC users
1201
+ */
1202 1202
 function join_page($type = null) {
1203
-  global $base_url;
1204
-  $registration_enabled = variable_get('user_register', 0);
1205
-  $output = '<div class="join">';
1206
-  switch ($type) {
1207
-  case 'boinc':
1203
+    global $base_url;
1204
+    $registration_enabled = variable_get('user_register', 0);
1205
+    $output = '<div class="join">';
1206
+    switch ($type) {
1207
+    case 'boinc':
1208 1208
     $output .= '<p>' . bts("If you're already running BOINC, select <i>Add
1209 1209
       Project</i>.", array(), NULL, 'boinc:join-page') . '</p>';
1210 1210
     if ($registration_enabled) {
1211
-      $output .= '<p>' . bts("If you're running a command-line or pre-5.0 version
1211
+        $output .= '<p>' . bts("If you're running a command-line or pre-5.0 version
1212 1212
         of BOINC, !create_an_account first.", array('!create_an_account' => 
1213 1213
         l(bts('create an account'), 'user/registration')), array(), NULL, 'boinc:join-page') . '</p>';
1214 1214
     }
1215 1215
     else {
1216
-      $output .= '<p>' . bts("If you're running a command-line version of BOINC,
1216
+        $output .= '<p>' . bts("If you're running a command-line version of BOINC,
1217 1217
         first use the BOINC Manager software (elsewhere if necessary) to create an
1218 1218
         an account at this project, then use that account to connect with the
1219 1219
         command-line version.", array(), NULL, 'boinc:join-page') . '</p>';
1220
-      $output .= '<p>' . bts("If you're running a pre-5.0 version of BOINC, please
1220
+        $output .= '<p>' . bts("If you're running a pre-5.0 version of BOINC, please
1221 1221
         upgrade to a more recent version to create an account
1222 1222
         at this project.", array(), NULL, 'boinc:join-page') . '</p>';
1223 1223
     }
1224 1224
     break;
1225
-  case 'new':
1225
+    case 'new':
1226 1226
   default:
1227 1227
     $output .= '<ol>';
1228 1228
     $output .= '  <li>' . bts('Download the desktop software', array(), NULL, 'boinc:join-page');
@@ -1239,69 +1239,69 @@  discard block
 block discarded – undo
1239 1239
     $output .= '  <li>' . bts('When prompted enter @siteurl', array(
1240 1240
         '@siteurl' => $base_url), NULL, 'boinc:join-page') . '</li>';
1241 1241
     $output .=  '</ol>';
1242
-  }
1243
-  $output .= '</div>';
1244
-  return $output;
1242
+    }
1243
+    $output .= '</div>';
1244
+    return $output;
1245 1245
 }
1246 1246
 
1247 1247
 /**
1248
-  * Home page content for embedding in Panels page
1249
-  */
1248
+ * Home page content for embedding in Panels page
1249
+ */
1250 1250
 function boincuser_home_page() {
1251
-  global $user;
1252
-  $site_name = variable_get('site_name', 'Drupal-BOINC');
1253
-  // get the front page message from database; this is set in the admin interface under BOINC Other
1254
-  $site_message = variable_get('boinc_other_frontpage','');
1251
+    global $user;
1252
+    $site_name = variable_get('site_name', 'Drupal-BOINC');
1253
+    // get the front page message from database; this is set in the admin interface under BOINC Other
1254
+    $site_message = variable_get('boinc_other_frontpage','');
1255 1255
 
1256
-  // Determine the user of the day
1257
-  $current_uotd = db_fetch_object(db_query("
1256
+    // Determine the user of the day
1257
+    $current_uotd = db_fetch_object(db_query("
1258 1258
     SELECT
1259 1259
       uid,
1260 1260
       uotd_time
1261 1261
     FROM {boincuser}
1262 1262
     ORDER BY uotd_time DESC
1263 1263
     LIMIT 1"
1264
-  ));
1265
-  if ($current_uotd->uotd_time < strtotime('today midnight')) {
1264
+    ));
1265
+    if ($current_uotd->uotd_time < strtotime('today midnight')) {
1266 1266
     $uotd = boincuser_select_user_of_the_day();
1267
-  }
1268
-  else {
1267
+    }
1268
+    else {
1269 1269
     $uotd = user_load($current_uotd->uid);
1270
-  }
1271
-  $uotd_image = boincuser_get_user_profile_image($uotd->uid, FALSE);
1272
-  $output = '<h2 class="pane-title">';
1273
-  $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'));
1274
-  $output .= '</h2>';
1275
-  $output .= '<div class="boinc-overview balance-height-front">';
1276
-  $output .= '  <div>' . bts($site_message, array(), NULL, "project:front page") . ' ' . l(bts('Learn more', array(), NULL, 'boinc:front-page'), 'about') . '</div>';
1277
-  if ($user->uid) {
1270
+    }
1271
+    $uotd_image = boincuser_get_user_profile_image($uotd->uid, FALSE);
1272
+    $output = '<h2 class="pane-title">';
1273
+    $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'));
1274
+    $output .= '</h2>';
1275
+    $output .= '<div class="boinc-overview balance-height-front">';
1276
+    $output .= '  <div>' . bts($site_message, array(), NULL, "project:front page") . ' ' . l(bts('Learn more', array(), NULL, 'boinc:front-page'), 'about') . '</div>';
1277
+    if ($user->uid) {
1278 1278
     $output .= '  <div>' . l(bts('View account', array(), NULL, 'boinc:front-page'), 'dashboard', array('attributes' => array('class' => 'join button'))) . '</div>';
1279
-  }
1280
-  else {
1279
+    }
1280
+    else {
1281 1281
     $output .= '  <div>' . l(bts('Join now', array(), NULL, 'boinc:front-page'), 'join', array('attributes' => array('class' => 'join button'))) . '</div>';
1282
-  }
1283
-  $output .= '</div>';
1284
-  $output .= '<div class="boinc-overview-details">';
1285
-  $output .= '  <div class="detail-container">';
1286
-  $output .= '    <a class="user-of-the-day" href="account/' . $uotd->uid . '">';
1287
-  $output .= '      <div class="picture">';
1288
-  $output .= theme('imagefield_image', $uotd_image['image'], $uotd_image['alt'],
1282
+    }
1283
+    $output .= '</div>';
1284
+    $output .= '<div class="boinc-overview-details">';
1285
+    $output .= '  <div class="detail-container">';
1286
+    $output .= '    <a class="user-of-the-day" href="account/' . $uotd->uid . '">';
1287
+    $output .= '      <div class="picture">';
1288
+    $output .= theme('imagefield_image', $uotd_image['image'], $uotd_image['alt'],
1289 1289
     $uotd_image['alt'], array(), FALSE);
1290
-  $output .= '      </div>';
1291
-  $output .= '      <div class="text">' . bts('User of the day', array(), NULL, 'boinc:front-page') . '</div>';
1292
-  $output .= '      <div class="detail">' . $uotd->boincuser_name . '</div>';
1293
-  $output .= '    </a>';
1294
-  $output .= '    <div class="volunteers">';
1295
-  $output .= '      <div class="text">' . bts('Over 500,000 volunteers and counting.', array(), NULL, 'boinc:front-page') . '</div>';
1296
-  $output .= '      <div class="platforms">';
1297
-  $output .= '        <div class="detail platform windows">' . bts('Windows', array(), NULL, 'boinc:front-page') . '</div>';
1298
-  $output .= '        <div class="detail platform mac">' .  bts('Mac', array(), NULL, 'boinc:front-page') . '</div>';
1299
-  $output .= '        <div class="detail platform linux">' . bts('Linux', array(), NULL, 'boinc:front-page') . '</div>';
1300
-  $output .= '      </div>';
1301
-  $output .= '    </div>';
1302
-  $output .= '  </div>';
1303
-  $output .= '</div>';
1304
-  return $output;
1290
+    $output .= '      </div>';
1291
+    $output .= '      <div class="text">' . bts('User of the day', array(), NULL, 'boinc:front-page') . '</div>';
1292
+    $output .= '      <div class="detail">' . $uotd->boincuser_name . '</div>';
1293
+    $output .= '    </a>';
1294
+    $output .= '    <div class="volunteers">';
1295
+    $output .= '      <div class="text">' . bts('Over 500,000 volunteers and counting.', array(), NULL, 'boinc:front-page') . '</div>';
1296
+    $output .= '      <div class="platforms">';
1297
+    $output .= '        <div class="detail platform windows">' . bts('Windows', array(), NULL, 'boinc:front-page') . '</div>';
1298
+    $output .= '        <div class="detail platform mac">' .  bts('Mac', array(), NULL, 'boinc:front-page') . '</div>';
1299
+    $output .= '        <div class="detail platform linux">' . bts('Linux', array(), NULL, 'boinc:front-page') . '</div>';
1300
+    $output .= '      </div>';
1301
+    $output .= '    </div>';
1302
+    $output .= '  </div>';
1303
+    $output .= '</div>';
1304
+    return $output;
1305 1305
 }
1306 1306
 
1307 1307
 /**
@@ -1309,50 +1309,50 @@  discard block
 block discarded – undo
1309 1309
  * Create a new user account based on supplied parameters.
1310 1310
  */
1311 1311
 function boincuser_create_account() {
1312
-  require_boinc('boinc_db');
1313
-  require_boinc('user');
1314
-  require_boinc('xml');
1315
-  $params = array(
1312
+    require_boinc('boinc_db');
1313
+    require_boinc('user');
1314
+    require_boinc('xml');
1315
+    $params = array(
1316 1316
     'email_addr' => isset($_GET['email_addr']) ? $_GET['email_addr'] : '',
1317 1317
     'user_name' => isset($_GET['user_name']) ? $_GET['user_name'] : '',
1318 1318
     'passwd_hash' => isset($_GET['passwd_hash']) ? $_GET['passwd_hash'] : ''
1319
-  );
1319
+    );
1320 1320
   
1321
-  // Begin output
1322
-  xml_header();
1321
+    // Begin output
1322
+    xml_header();
1323 1323
   
1324
-  // Account creation disabled
1324
+    // Account creation disabled
1325 1325
   
1326
-  // Invalid invite code
1326
+    // Invalid invite code
1327 1327
   
1328
-  // Validate input
1329
-  if (user_validate_mail($params['email_addr']) or !is_valid_email_addr($params['email_addr'])) {
1328
+    // Validate input
1329
+    if (user_validate_mail($params['email_addr']) or !is_valid_email_addr($params['email_addr'])) {
1330 1330
     xml_error(-205);
1331
-  }
1331
+    }
1332 1332
 
1333
-  $decode_name = urldecode($params['user_name']);
1334
-  $cleaned_name = preg_replace('/[^a-zA-Z0-9_ \.-]/s', '_', $decode_name);
1335
-  if ($error = user_validate_name($cleaned_name)) {
1333
+    $decode_name = urldecode($params['user_name']);
1334
+    $cleaned_name = preg_replace('/[^a-zA-Z0-9_ \.-]/s', '_', $decode_name);
1335
+    if ($error = user_validate_name($cleaned_name)) {
1336 1336
     xml_error(-188, $error);
1337
-  }
1338
-  if (strlen($params['passwd_hash']) != 32) {
1337
+    }
1338
+    if (strlen($params['passwd_hash']) != 32) {
1339 1339
     xml_error(-1, 'password hash length not 32');
1340
-  }
1340
+    }
1341 1341
   
1342
-  // Process input
1343
-  $boinc_user = BoincUser::lookup_email_addr($params['email_addr']);
1344
-  if ($boinc_user) {
1342
+    // Process input
1343
+    $boinc_user = BoincUser::lookup_email_addr($params['email_addr']);
1344
+    if ($boinc_user) {
1345 1345
     // Return authenticator for existing users
1346 1346
     if ($params['passwd_hash'] == $boinc_user->passwd_hash) {
1347
-      $output = array('authenticator' => $boinc_user->authenticator);
1347
+        $output = array('authenticator' => $boinc_user->authenticator);
1348 1348
     } else {
1349
-      xml_error(-137);
1349
+        xml_error(-137);
1350 1350
     }
1351
-  }
1352
-  else {
1351
+    }
1352
+    else {
1353 1353
     // Verify that there isn't somehow a Drupal user already (not possible with proper function)
1354 1354
     if ($existing_user = user_load(array('mail' => $params['email_addr']))) {
1355
-      xml_error(-137, 'account error');
1355
+        xml_error(-137, 'account error');
1356 1356
     }
1357 1357
     // Create new account
1358 1358
     $unrestricted_role = array_search('community member', user_roles(true));
@@ -1361,73 +1361,73 @@  discard block
 block discarded – undo
1361 1361
     $unique_name = find_unique_name($params['user_name']);
1362 1362
 
1363 1363
     $newUser = array(
1364
-      'name' => $unique_name,
1365
-      '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
1366
-      'mail' => $params['email_addr'],
1367
-      'status' => 1,
1368
-      'init' => $params['email_addr'],
1369
-      'roles' => array($unrestricted_role => ''),
1364
+        'name' => $unique_name,
1365
+        '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
1366
+        'mail' => $params['email_addr'],
1367
+        'status' => 1,
1368
+        'init' => $params['email_addr'],
1369
+        'roles' => array($unrestricted_role => ''),
1370 1370
     );
1371 1371
 
1372 1372
     // Create the drupal user. If the drupal user cannot be created, then stop with error message.
1373 1373
     $user = user_save(null, $newUser);
1374 1374
     if ($user) {
1375
-      // Create the BOINC user.
1376
-      $boinc_user = make_user($params['email_addr'], $params['user_name'], $params['passwd_hash'], 'International');
1377
-      if ($boinc_user) {
1375
+        // Create the BOINC user.
1376
+        $boinc_user = make_user($params['email_addr'], $params['user_name'], $params['passwd_hash'], 'International');
1377
+        if ($boinc_user) {
1378 1378
         // Cross reference Drupal account with BOINC.
1379 1379
         $reference = db_query("INSERT INTO {boincuser} SET uid=%d, boinc_id=%d", $user->uid, $boinc_user->id);
1380 1380
         if (!$reference) {
1381
-          xml_error(-1, 'error connecting BOINC account to Drupal');
1381
+            xml_error(-1, 'error connecting BOINC account to Drupal');
1382
+        }
1382 1383
         }
1383
-      }
1384
-      else {
1384
+        else {
1385 1385
         xml_error(-137);
1386
-      }// if boinc user created.
1386
+        }// if boinc user created.
1387 1387
     }
1388 1388
     else {
1389
-      watchdog('boincuser', 'create_accout: Failed to create Drupal user account for @email', array('@email' => $params['email_addr']), WATCHDOG_WARNING);
1390
-      xml_error(-1, 'error creating Drupal user account');
1389
+        watchdog('boincuser', 'create_accout: Failed to create Drupal user account for @email', array('@email' => $params['email_addr']), WATCHDOG_WARNING);
1390
+        xml_error(-1, 'error creating Drupal user account');
1391 1391
     }// if drupal user created.
1392
-  }// if existing user found.
1393
-  echo " <account_out>\n";
1394
-  echo "   <authenticator>{$boinc_user->authenticator}</authenticator>\n";
1395
-  echo "</account_out>\n";
1392
+    }// if existing user found.
1393
+    echo " <account_out>\n";
1394
+    echo "   <authenticator>{$boinc_user->authenticator}</authenticator>\n";
1395
+    echo "</account_out>\n";
1396 1396
 }
1397 1397
 
1398 1398
 /**
1399 1399
  * Determine if the user has permission to control community access
1400 1400
  */
1401 1401
 function boincuser_moderate_community_access() {
1402
-  if (user_access('assign community member role')
1402
+    if (user_access('assign community member role')
1403 1403
   OR user_access('assign all roles')) {
1404 1404
     return TRUE;
1405
-  }
1406
-  return FALSE;
1405
+    }
1406
+    return FALSE;
1407 1407
 }
1408 1408
 
1409 1409
 /**
1410 1410
  * Get the count of items in the moderation queue
1411 1411
  */
1412 1412
 function boincuser_moderation_queue_count($caller = 'user') {
1413
-  $allowed = FALSE;
1414
-  switch ($caller) {
1415
-  case 'cron':
1413
+    $allowed = FALSE;
1414
+    switch ($caller) {
1415
+    case 'cron':
1416 1416
     $allowed = TRUE;
1417 1417
     break;
1418
-  case 'user':
1418
+    case 'user':
1419 1419
   default:
1420 1420
     $allowed = user_access('edit any profile content');
1421
-  }
1422
-  if ($allowed) {
1421
+    }
1422
+    if ($allowed) {
1423 1423
     return db_result(db_query("
1424 1424
       SELECT COUNT(*)
1425 1425
       FROM {node}
1426 1426
       WHERE type = 'profile'
1427 1427
       AND moderate = 1"
1428 1428
     ));
1429
-  }
1430
-  return NULL;
1429
+    }
1430
+    return NULL;
1431 1431
 }
1432 1432
 
1433 1433
 /**
@@ -1436,43 +1436,43 @@  discard block
 block discarded – undo
1436 1436
  * than through the user account info form.
1437 1437
  */
1438 1438
 function boincuser_control($uid = NULL, $action = NULL) {
1439
-  if (!$uid OR !$account = user_load($uid)) {
1439
+    if (!$uid OR !$account = user_load($uid)) {
1440 1440
     // What are you even doing here...
1441 1441
     return FALSE;
1442
-  }
1443
-  switch ($action) {
1444
-  case 'ban':
1442
+    }
1443
+    switch ($action) {
1444
+    case 'ban':
1445 1445
     if (boincuser_moderate_community_access()) {
1446
-      $penalty_period = variable_get('boinc_penalty_period', 7*24*60*60);
1447
-      $boincuser_record = array(
1446
+        $penalty_period = variable_get('boinc_penalty_period', 7*24*60*60);
1447
+        $boincuser_record = array(
1448 1448
         'uid' => $uid,
1449 1449
         'penalty_expiration' => time() + $penalty_period,
1450
-      );
1451
-      drupal_write_record('boincuser', $boincuser_record, 'uid');
1452
-      $community_role = array_search('community member', user_roles(true));
1453
-      if (isset($account->roles[$community_role])) {
1450
+        );
1451
+        drupal_write_record('boincuser', $boincuser_record, 'uid');
1452
+        $community_role = array_search('community member', user_roles(true));
1453
+        if (isset($account->roles[$community_role])) {
1454 1454
         unset($account->roles[$community_role]);
1455 1455
         user_save($account, array('roles' => $account->roles));
1456
-      }
1456
+        }
1457 1457
     }
1458 1458
     break;
1459
-  case 'lift-ban':
1459
+    case 'lift-ban':
1460 1460
     if (boincuser_moderate_community_access()) {
1461
-      $boincuser_record = array(
1461
+        $boincuser_record = array(
1462 1462
         'uid' => $uid,
1463 1463
         'penalty_expiration' => 0,
1464
-      );
1465
-      drupal_write_record('boincuser', $boincuser_record, 'uid');
1466
-      $community_role = array_search('community member', user_roles(true));
1467
-      if (!isset($account->roles[$community_role])) {
1464
+        );
1465
+        drupal_write_record('boincuser', $boincuser_record, 'uid');
1466
+        $community_role = array_search('community member', user_roles(true));
1467
+        if (!isset($account->roles[$community_role])) {
1468 1468
         $account->roles[$community_role] = 'community member';
1469 1469
         user_save($account, array('roles' => $account->roles));
1470
-      }
1470
+        }
1471 1471
     }
1472 1472
     break;
1473
-  default:
1473
+    default:
1474 1474
   }
1475
-  drupal_goto("account/{$account->uid}");
1475
+    drupal_goto("account/{$account->uid}");
1476 1476
 }
1477 1477
 
1478 1478
 /**
@@ -1480,29 +1480,29 @@  discard block
 block discarded – undo
1480 1480
  * moderation flag.
1481 1481
  */
1482 1482
 function boincuser_moderate_profile_approve($account) {
1483
-  $node = new stdClass;
1484
-  $node->type = 'profile';
1485
-  $node->language = '';
1486
-  $nid = content_profile_profile_exists($node, $account->uid);
1487
-  $profile = node_load($nid);
1488
-  $profile->moderate = 0;
1489
-  $profile->status = 1;
1490
-  node_save($profile);
1491
-  drupal_set_message('This profile has been marked as approved.');
1492
-  drupal_goto();
1483
+    $node = new stdClass;
1484
+    $node->type = 'profile';
1485
+    $node->language = '';
1486
+    $nid = content_profile_profile_exists($node, $account->uid);
1487
+    $profile = node_load($nid);
1488
+    $profile->moderate = 0;
1489
+    $profile->status = 1;
1490
+    node_save($profile);
1491
+    drupal_set_message('This profile has been marked as approved.');
1492
+    drupal_goto();
1493 1493
 }
1494 1494
 
1495 1495
 /**
1496 1496
  * Mark a user profile as rejected and notify the user of the reason.
1497 1497
  */
1498 1498
 function boincuser_moderate_profile_reject($uid, $reason = '') {
1499
-  $account = user_load($uid);
1500
-  $node = new stdClass;
1501
-  $node->type = 'profile';
1502
-  $node->language = '';
1503
-  $nid = content_profile_profile_exists($node, $uid);
1504
-  $profile = node_load($nid);
1505
-  if ($profile->nid) {
1499
+    $account = user_load($uid);
1500
+    $node = new stdClass;
1501
+    $node->type = 'profile';
1502
+    $node->language = '';
1503
+    $nid = content_profile_profile_exists($node, $uid);
1504
+    $profile = node_load($nid);
1505
+    if ($profile->nid) {
1506 1506
     global $user;
1507 1507
     global $base_url;
1508 1508
     global $base_path;
@@ -1513,64 +1513,64 @@  discard block
 block discarded – undo
1513 1513
     $profile->status = 0;
1514 1514
     node_save($profile);
1515 1515
     $settings = array(
1516
-      'from' => '',
1517
-      'subject' => "Profile moderation at {$site_name}",
1518
-      'message' => ''
1519
-      . "{$account->boincuser_name},\n"
1520
-      . "\n"
1521
-      . "{$moderator->boincuser_name} has rejected your profile at"
1522
-      . " {$site_name} for the following reason: \n"
1523
-      . "\n"
1524
-      . "{$reason}\n"
1525
-      . "\n"
1526
-      . "\n"
1527
-      . "Since it has not been approved, your profile is not visible to other"
1528
-      . " {$site_name} users. Please make the needed changes here:\n"
1529
-      . "\n"
1530
-      . "{$site_url}account/profile \n"
1531
-      . "\n"
1532
-      . "Thanks, \n"
1533
-      . "\n"
1534
-      . "{$site_name} support team",
1516
+        'from' => '',
1517
+        'subject' => "Profile moderation at {$site_name}",
1518
+        'message' => ''
1519
+        . "{$account->boincuser_name},\n"
1520
+        . "\n"
1521
+        . "{$moderator->boincuser_name} has rejected your profile at"
1522
+        . " {$site_name} for the following reason: \n"
1523
+        . "\n"
1524
+        . "{$reason}\n"
1525
+        . "\n"
1526
+        . "\n"
1527
+        . "Since it has not been approved, your profile is not visible to other"
1528
+        . " {$site_name} users. Please make the needed changes here:\n"
1529
+        . "\n"
1530
+        . "{$site_url}account/profile \n"
1531
+        . "\n"
1532
+        . "Thanks, \n"
1533
+        . "\n"
1534
+        . "{$site_name} support team",
1535 1535
     );
1536 1536
     rules_action_mail_to_user($account, $settings);
1537 1537
     drupal_set_message('This profile has been marked as rejected.');
1538
-  }
1539
-  drupal_goto();
1538
+    }
1539
+    drupal_goto();
1540 1540
 }
1541 1541
 
1542 1542
 /**
1543 1543
  * Ban a user and send a notification of the reason.
1544 1544
  */
1545 1545
 function boincuser_moderate_user_ban($uid, $reason = '', $duration = '') {
1546
-  if (user_access('assign community member role')
1546
+    if (user_access('assign community member role')
1547 1547
   OR user_access('assign all roles')) {
1548 1548
     $account = user_load($uid);
1549 1549
     if ($account->uid) {
1550
-      module_load_include('inc', 'rules', 'modules/system.rules');
1551
-      if ($duration === '') {
1550
+        module_load_include('inc', 'rules', 'modules/system.rules');
1551
+        if ($duration === '') {
1552 1552
         $duration = variable_get('boinc_penalty_period', 7*24*60*60);
1553
-      }
1554
-      $penalty_expiration = ($duration > 0) ? time() + $duration : 4294967295;
1555
-      $boincuser_record = array(
1553
+        }
1554
+        $penalty_expiration = ($duration > 0) ? time() + $duration : 4294967295;
1555
+        $boincuser_record = array(
1556 1556
         'uid' => $uid,
1557 1557
         'penalty_expiration' => $penalty_expiration,
1558
-      );
1559
-      drupal_write_record('boincuser', $boincuser_record, 'uid');
1558
+        );
1559
+        drupal_write_record('boincuser', $boincuser_record, 'uid');
1560 1560
       
1561
-      $community_role = array_search('community member', user_roles(true));
1562
-      if (isset($account->roles[$community_role])) {
1561
+        $community_role = array_search('community member', user_roles(true));
1562
+        if (isset($account->roles[$community_role])) {
1563 1563
         unset($account->roles[$community_role]);
1564 1564
         user_save($account, array('roles' => $account->roles));
1565
-      }
1565
+        }
1566 1566
       
1567
-      global $user;
1568
-      global $base_url;
1569
-      global $base_path;
1570
-      $site_name = variable_get('site_name',  'Drupal-BOINC');
1571
-      $site_url = $base_url . $base_path;
1572
-      $moderator = user_load($user->uid);
1573
-      $settings = array(
1567
+        global $user;
1568
+        global $base_url;
1569
+        global $base_path;
1570
+        $site_name = variable_get('site_name',  'Drupal-BOINC');
1571
+        $site_url = $base_url . $base_path;
1572
+        $moderator = user_load($user->uid);
1573
+        $settings = array(
1574 1574
         'from' => '',
1575 1575
         'subject' => "User moderation at {$site_name}",
1576 1576
         'message' => ''
@@ -1591,12 +1591,12 @@  discard block
 block discarded – undo
1591 1591
         . "Thanks, \n"
1592 1592
         . "\n"
1593 1593
         . "{$site_name} support team",
1594
-      );
1595
-      rules_action_mail_to_user($account, $settings);
1596
-      drupal_set_message('This user has been banned.');
1594
+        );
1595
+        rules_action_mail_to_user($account, $settings);
1596
+        drupal_set_message('This user has been banned.');
1597 1597
     }
1598
-  }
1599
-  drupal_goto();
1598
+    }
1599
+    drupal_goto();
1600 1600
 }
1601 1601
 
1602 1602
 
@@ -1608,15 +1608,15 @@  discard block
 block discarded – undo
1608 1608
  *
1609 1609
  */
1610 1610
 function boincuser_get_weak_auth($boinc_id = null) {
1611
-  if (!$boinc_id) {
1611
+    if (!$boinc_id) {
1612 1612
     global $user;
1613 1613
     $account = user_load($user->uid);
1614 1614
     $boinc_id = $account->boincuser_id;
1615
-  }
1615
+    }
1616 1616
   
1617
-  $boinc_user = boincuser_load($account->boincuser_id);
1617
+    $boinc_user = boincuser_load($account->boincuser_id);
1618 1618
   
1619
-  return weak_auth($boinc_user);
1619
+    return weak_auth($boinc_user);
1620 1620
 }
1621 1621
 
1622 1622
 /**
@@ -1625,74 +1625,74 @@  discard block
 block discarded – undo
1625 1625
  * Drupal User so must be inserted into comments, etc. (not so by default)
1626 1626
  */
1627 1627
 function boincuser_get_user_profile_image($uid, $avatar = TRUE) {
1628
-  // Though the function name implies otherwise, get the avatar by default
1629
-  $image_field = ($avatar) ? 'field_image_fid' : 'field_profile_image_fid';
1630
-  $image_fid = db_result(db_query("
1628
+    // Though the function name implies otherwise, get the avatar by default
1629
+    $image_field = ($avatar) ? 'field_image_fid' : 'field_profile_image_fid';
1630
+    $image_fid = db_result(db_query("
1631 1631
     SELECT ctp.%s
1632 1632
     FROM {content_type_profile} ctp
1633 1633
     INNER JOIN {node} n ON ctp.nid = n.nid
1634 1634
     WHERE n.uid = %d AND n.type = '%s'",
1635 1635
     $image_field, $uid, 'profile'));
1636
-  $user_image['image'] = field_file_load($image_fid);
1637
-  if (!$user_image['image']['filepath']) {
1636
+    $user_image['image'] = field_file_load($image_fid);
1637
+    if (!$user_image['image']['filepath']) {
1638 1638
     // Load the default image if one does not exist
1639 1639
     $account = user_load($uid);
1640 1640
     if ($avatar AND module_exists('gravatar') AND user_access('use gravatar', $account) AND $account->gravatar) {
1641
-      // Use a Gravatar rather than the system default image
1642
-      $options = array(
1641
+        // Use a Gravatar rather than the system default image
1642
+        $options = array(
1643 1643
         'size' => 100,
1644 1644
         'rating' => 'G',
1645
-      );
1646
-      // Get the Gravatar URL and see if the image exists
1647
-      $url = gravatar_get_gravatar($account->mail, $options);
1648
-      $headers = @get_headers($url);
1649
-      if (preg_match("|200|", $headers[0])) {
1645
+        );
1646
+        // Get the Gravatar URL and see if the image exists
1647
+        $url = gravatar_get_gravatar($account->mail, $options);
1648
+        $headers = @get_headers($url);
1649
+        if (preg_match("|200|", $headers[0])) {
1650 1650
         return $url;
1651
-      }
1651
+        }
1652 1652
     }
1653 1653
     // Get default image if nothing else works
1654 1654
     $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')));
1655 1655
     $content_node_widget_settings = unserialize($content_node_widget_settings);
1656 1656
     $user_image['image'] = $content_node_widget_settings['default_image'];
1657
-  }
1658
-  $user = user_load($uid);
1659
-  $user_image['alt'] = $user->name;
1660
-  return $user_image;
1657
+    }
1658
+    $user = user_load($uid);
1659
+    $user_image['alt'] = $user->name;
1660
+    return $user_image;
1661 1661
 }
1662 1662
 
1663 1663
 /**
1664 1664
  * Generate a table of a user's projects
1665 1665
  */
1666 1666
 function boincuser_get_projects_table($account = null) {
1667
-  if ($account AND is_numeric($account)) {
1667
+    if ($account AND is_numeric($account)) {
1668 1668
     $account = user_load($account);
1669
-  }
1670
-  $projects = boincuser_get_projects($account);
1671
-  if (!$projects) return bts('no projects...', array(), NULL, 'boinc:account-dashboard');
1669
+    }
1670
+    $projects = boincuser_get_projects($account);
1671
+    if (!$projects) return bts('no projects...', array(), NULL, 'boinc:account-dashboard');
1672 1672
   
1673
-  $output = '';
1674
-  $output .= '<table class="user-projects">' . "\n";
1675
-  $output .= '<thead>' . "\n";
1676
-  $output .= '  <tr>' . "\n";
1677
-  $output .= '    <th>' . bts('Name', array(), NULL, 'boinc:project-name:-1:ignoreoverwrite') . '</th>' . "\n";
1678
-  $output .= '    <th class="numeric">' . bts('Avg credit', array(), NULL, 'boinc:account-dashboard') . '</th>' . "\n";
1679
-  $output .= '    <th class="numeric">' . bts('Total credit', array(), NULL, 'boinc:user-or-team-total-credits') . '</th>' . "\n";
1680
-  $output .= '  </tr>' . "\n";
1681
-  $output .= '</thead>' . "\n";
1682
-  $output .= '<tbody>' . "\n";
1683
-  foreach ($projects AS $project) {
1673
+    $output = '';
1674
+    $output .= '<table class="user-projects">' . "\n";
1675
+    $output .= '<thead>' . "\n";
1676
+    $output .= '  <tr>' . "\n";
1677
+    $output .= '    <th>' . bts('Name', array(), NULL, 'boinc:project-name:-1:ignoreoverwrite') . '</th>' . "\n";
1678
+    $output .= '    <th class="numeric">' . bts('Avg credit', array(), NULL, 'boinc:account-dashboard') . '</th>' . "\n";
1679
+    $output .= '    <th class="numeric">' . bts('Total credit', array(), NULL, 'boinc:user-or-team-total-credits') . '</th>' . "\n";
1680
+    $output .= '  </tr>' . "\n";
1681
+    $output .= '</thead>' . "\n";
1682
+    $output .= '<tbody>' . "\n";
1683
+    foreach ($projects AS $project) {
1684 1684
     $url = rtrim($project->url, '/') . '/show_user.php?userid=' . $project->id;
1685 1685
     $output .= '  <tr>' . "\n";
1686 1686
     $output .= '    <td>' . l($project->name, $url) . '</td>' . "\n";
1687 1687
     $output .= '    <td class="numeric">' . boincwork_format_stats((float) $project->expavg_credit) . '</td>' . "\n"; 
1688 1688
     $output .= '    <td class="numeric">' . boincwork_format_stats((float) $project->total_credit) . '</td>' . "\n";
1689 1689
     $output .= '  </tr>' . "\n";
1690
-  }
1691
-  $output .= '</tbody>' . "\n";
1692
-  $output .= '</table>' . "\n";
1693
-  $more_link = ($account) ? "user/{$account->uid}/stats" : 'account/stats';
1694
-  //$output .= "<div class=\"more-link\"><a href=\"{$more_link}\">More stats</a></div>" . "\n";
1695
-  return $output;
1690
+    }
1691
+    $output .= '</tbody>' . "\n";
1692
+    $output .= '</table>' . "\n";
1693
+    $more_link = ($account) ? "user/{$account->uid}/stats" : 'account/stats';
1694
+    //$output .= "<div class=\"more-link\"><a href=\"{$more_link}\">More stats</a></div>" . "\n";
1695
+    return $output;
1696 1696
 }
1697 1697
 
1698 1698
 /**
@@ -1700,25 +1700,25 @@  discard block
 block discarded – undo
1700 1700
  */
1701 1701
 function boincuser_get_stats_user_data($cpid = null) {
1702 1702
   
1703
-  // [TODO] Set this stuff in site config!
1704
-  $stats_server = 'stats.gridrepublic.org';
1705
-  $stats_rpc = 'rpc/get_user.php';
1703
+    // [TODO] Set this stuff in site config!
1704
+    $stats_server = 'stats.gridrepublic.org';
1705
+    $stats_rpc = 'rpc/get_user.php';
1706 1706
   
1707
-  // Construct query string
1708
-  $get = array(
1707
+    // Construct query string
1708
+    $get = array(
1709 1709
     'cpid' => $cpid
1710
-  );
1711
-  $args = array();
1712
-  foreach ($get as $arg => $value) $args[] = "{$arg}=" . rawurlencode($value);
1713
-  $query = '?' . implode('&', $args);
1710
+    );
1711
+    $args = array();
1712
+    foreach ($get as $arg => $value) $args[] = "{$arg}=" . rawurlencode($value);
1713
+    $query = '?' . implode('&', $args);
1714 1714
   
1715
-  // Load XML from RPC
1716
-  $target_url = "http://{$stats_server}/{$stats_rpc}{$query}";
1717
-  $result = drupal_http_request($target_url);
1718
-  if (in_array($result->code, array(200, 304))) {
1715
+    // Load XML from RPC
1716
+    $target_url = "http://{$stats_server}/{$stats_rpc}{$query}";
1717
+    $result = drupal_http_request($target_url);
1718
+    if (in_array($result->code, array(200, 304))) {
1719 1719
     return simplexml_load_string($result->data);
1720
-  }
1721
-  return NULL;
1720
+    }
1721
+    return NULL;
1722 1722
 }
1723 1723
 
1724 1724
 /**
@@ -1726,15 +1726,15 @@  discard block
 block discarded – undo
1726 1726
  */
1727 1727
 function boincuser_get_projects($account = null) {
1728 1728
   
1729
-  // Use the current user by default
1730
-  if (!$account) {
1729
+    // Use the current user by default
1730
+    if (!$account) {
1731 1731
     global $user;
1732 1732
     $account = user_load($user->uid);
1733
-  }
1733
+    }
1734 1734
   
1735
-  $account_stats = boincuser_get_stats_user_data($account->boincuser_cpid);
1735
+    $account_stats = boincuser_get_stats_user_data($account->boincuser_cpid);
1736 1736
   
1737
-  return ($account_stats AND isset($account_stats->project)) ? $account_stats->project : null;
1737
+    return ($account_stats AND isset($account_stats->project)) ? $account_stats->project : null;
1738 1738
 }
1739 1739
 
1740 1740
 
@@ -1742,11 +1742,11 @@  discard block
 block discarded – undo
1742 1742
  * Get the links to display under the user profile
1743 1743
  */
1744 1744
 function boincuser_get_profile_links($uid) {
1745
-  global $user;
1746
-  $account = user_load($uid);
1747
-  $profile = content_profile_load('profile', $account->uid);
1748
-  $output = '';
1749
-  if ($profile) {
1745
+    global $user;
1746
+    $account = user_load($uid);
1747
+    $profile = content_profile_load('profile', $account->uid);
1748
+    $output = '';
1749
+    if ($profile) {
1750 1750
     $profile_is_approved = ($profile->status AND !$profile->moderate);
1751 1751
     $user_is_moderator = user_access('edit any profile content');
1752 1752
     $is_own_profile = ($user->uid == $account->uid);
@@ -1754,15 +1754,15 @@  discard block
 block discarded – undo
1754 1754
     $links = array();
1755 1755
     
1756 1756
     if ($profile->moderate AND $user_is_moderator) {
1757
-      $links['approve_profile'] = array(
1757
+        $links['approve_profile'] = array(
1758 1758
         'title' => bts('Approve profile', array(), NULL, 'boinc:moderate-user'),
1759 1759
         'href' => "{$profile_moderation_path}/approve",
1760 1760
         'attributes' => array(
1761
-          'title' => bts('Approve this profile content', array(), NULL, 'boinc:moderate-user'),
1762
-          'class' => 'first primary tab',
1761
+            'title' => bts('Approve this profile content', array(), NULL, 'boinc:moderate-user'),
1762
+            'class' => 'first primary tab',
1763 1763
         )
1764
-      );
1765
-      /*$links['edit_profile'] = array(
1764
+        );
1765
+        /*$links['edit_profile'] = array(
1766 1766
         'title' => bts('Edit profile', array(), NULL, 'boinc:moderate-user'),
1767 1767
         'href' => "{$profile_moderation_path}/edit",
1768 1768
         'attributes' => array(
@@ -1770,27 +1770,27 @@  discard block
 block discarded – undo
1770 1770
           'class' => 'tab',
1771 1771
         )
1772 1772
       );*/
1773
-      $links['reject_profile'] = array(
1773
+        $links['reject_profile'] = array(
1774 1774
         'title' => bts('Reject profile', array(), NULL, 'boinc:moderate-user'),
1775 1775
         'href' => "{$profile_moderation_path}/reject",
1776 1776
         'attributes' => array(
1777
-          'title' => bts('Reject this profile content', array(), NULL, 'boinc:moderate-user'),
1778
-          'class' => 'tab',
1777
+            'title' => bts('Reject this profile content', array(), NULL, 'boinc:moderate-user'),
1778
+            'class' => 'tab',
1779 1779
         )
1780
-      );
1780
+        );
1781 1781
     }
1782 1782
     $output .= '<ul class="tab-list">';
1783 1783
     $count = 0;
1784 1784
     foreach ($links as $key => $link) {
1785
-      $output .= '<li class="' . (($count == 0) ? 'first primary ' : '') . 'tab">';
1786
-      $output .= l($link['title'], $link['href'], array('query' => drupal_get_destination()));
1787
-      $output .= '</li>';
1788
-      $count++;
1785
+        $output .= '<li class="' . (($count == 0) ? 'first primary ' : '') . 'tab">';
1786
+        $output .= l($link['title'], $link['href'], array('query' => drupal_get_destination()));
1787
+        $output .= '</li>';
1788
+        $count++;
1789 1789
     }
1790 1790
     $output .= '<li class="' . (($count) ? '' : 'first ') . 'last tab">' . flag_create_link('abuse_user', $account->uid) . '</li>';
1791 1791
     $output .= '</ul>';
1792
-  }
1793
-  return $output;
1792
+    }
1793
+    return $output;
1794 1794
 /*
1795 1795
 <ul class="tab-list">
1796 1796
   <li class="primary first tab">
@@ -1827,35 +1827,35 @@  discard block
 block discarded – undo
1827 1827
  */
1828 1828
 function boincuser_apachesolr_index_documents_alter(array &$documents, $entity, $entity_type, $env_id) {
1829 1829
 
1830
-  foreach ($documents as $document) {
1830
+    foreach ($documents as $document) {
1831 1831
     if ( $document->entity_type=='node' AND $document->bundle=='profile' ) {
1832
-      // Node information.
1833
-      $nid = $document->entity_id;
1834
-      $node = node_load($nid);
1835
-      $account = user_load($node->uid);
1832
+        // Node information.
1833
+        $nid = $document->entity_id;
1834
+        $node = node_load($nid);
1835
+        $account = user_load($node->uid);
1836 1836
 
1837
-      // Use boincuser name and not drupal user name
1838
-      $document->label = apachesolr_clean_text($account->boincuser_name);
1839
-      // Author information
1840
-      if ($node->uid == 0 || strlen($node->name) == 0) {
1837
+        // Use boincuser name and not drupal user name
1838
+        $document->label = apachesolr_clean_text($account->boincuser_name);
1839
+        // Author information
1840
+        if ($node->uid == 0 || strlen($node->name) == 0) {
1841 1841
         // @see user_validate_name(). !'0' === TRUE.
1842 1842
         $document->ss_name = '0';
1843
-      }
1844
-      else {
1843
+        }
1844
+        else {
1845 1845
         $document->ss_name = $account->boincuser_name;
1846 1846
         // We want the name to be searchable for keywords.
1847 1847
         $document->tos_name = $account->boincuser_name;
1848
-      }
1848
+        }
1849 1849
 
1850
-      // Rename "Profle" to "User"
1851
-      $document->bundle = "User";
1852
-      $document->bundle_name = "User";
1850
+        // Rename "Profle" to "User"
1851
+        $document->bundle = "User";
1852
+        $document->bundle_name = "User";
1853 1853
 
1854
-      // Replace the Solr document's created field with the date the user 
1855
-      // account was created. This replaces the node creation date typically 
1856
-      // used for indexing nodes.
1857
-      $document->ds_created = apachesolr_date_iso($account->created);
1854
+        // Replace the Solr document's created field with the date the user 
1855
+        // account was created. This replaces the node creation date typically 
1856
+        // used for indexing nodes.
1857
+        $document->ds_created = apachesolr_date_iso($account->created);
1858
+    }
1858 1859
     }
1859
-  }
1860 1860
 
1861 1861
 }
Please login to merge, or discard this patch.