Passed
Pull Request — master (#2667)
by Christian
08:59
created
default/boinc/modules/boincuser/boincuser_delete/boincuser_delete.module 1 patch
Switch Indentation   +277 added lines, -277 removed lines patch added patch discarded remove patch
@@ -94,64 +94,64 @@  discard block
 block discarded – undo
94 94
   global $user;
95 95
 
96 96
   switch($form_id) {
97
-    case 'user_profile_form':
98
-      if ( user_access('delete own account') AND ($form['#uid'] == $user->uid) AND (arg(3)=='') ) {
99
-        $form['delete'] = array(
100
-          '#type' => 'submit',
101
-          '#value' => bts('Delete Account', array(), null, 'boinc:delete-user-account'),
102
-          '#weight' => 1009,
103
-          '#submit' => array('user_edit_delete_submit'),
104
-          '#prefix' => '<li class="tab">',
105
-          '#suffix' => '</li>',
106
-        );
107
-      }
108
-      else if ( user_access('administer users') ) {
109
-        $form['delete'] = array(
110
-          '#type' => 'submit',
111
-          '#value' => bts('Delete Account', array(), null, 'boinc:delete-user-account'),
112
-          '#weight' => 1009,
113
-          '#submit' => array('_boincuser_delete_goto_admindelete'),
114
-          '#prefix' => '<li class="tab">',
115
-          '#suffix' => '</li>',
116
-        );
117
-      }
118
-      else {
119
-        unset($form['delete']);
120
-      }
121
-      break;
122
-    case 'user_confirm_delete':
123
-
124
-      $disable_delete = FALSE;
125
-      // If email address was changed less than 7 days (7 * 86400 s)
126
-      // ago, it cannot be changed again.
127
-      $duration = TOKEN_DURATION_ONE_WEEK;
128
-      if (($form['_account']['#value']->boincuser_email_addr_change_time + $duration) > time()) {
129
-        drupal_set_message(
130
-          bts("INFO: Your email address was changed within the past seven (7) days. You may not delete your account until after !time.",
131
-            array(
132
-              '!time' => date('F j, Y \a\t G:i T', $form['_account']['#value']->boincuser_email_addr_change_time + $duration),
133
-            ), NULL, 'boinc:account-credentials-change')
134
-        , 'info');
135
-        $disable_delete = TRUE;
136
-      }
137
-
138
-      // Configure radio options
139
-      $deleteoptions = array(
140
-        'boincuser_delete_softdelete' => bts('<b>Soft delete</b> the account. Afterwards your account will be disabled, and all posts/comments will be attributed to the Anonymous User. However, your user profile will be deleted, your host information will be deleted, and you will be removed from any team you are a member of.', array(), NULL, 'boinc:delete-user-account'),
141
-        'boincuser_delete_delete' => bts('<b>Delete</b> the account. Afterwards your account will be deleted, and all posts/comments will be attributed to the Anonymous User. Your user profile will be deleted, and your host information will be deleted.', array(), NULL, 'boinc:delete-user-account'),
97
+  case 'user_profile_form':
98
+    if ( user_access('delete own account') AND ($form['#uid'] == $user->uid) AND (arg(3)=='') ) {
99
+      $form['delete'] = array(
100
+        '#type' => 'submit',
101
+        '#value' => bts('Delete Account', array(), null, 'boinc:delete-user-account'),
102
+        '#weight' => 1009,
103
+        '#submit' => array('user_edit_delete_submit'),
104
+        '#prefix' => '<li class="tab">',
105
+        '#suffix' => '</li>',
142 106
       );
107
+    }
108
+    else if ( user_access('administer users') ) {
109
+      $form['delete'] = array(
110
+        '#type' => 'submit',
111
+        '#value' => bts('Delete Account', array(), null, 'boinc:delete-user-account'),
112
+        '#weight' => 1009,
113
+        '#submit' => array('_boincuser_delete_goto_admindelete'),
114
+        '#prefix' => '<li class="tab">',
115
+        '#suffix' => '</li>',
116
+      );
117
+    }
118
+    else {
119
+      unset($form['delete']);
120
+    }
121
+    break;
122
+  case 'user_confirm_delete':
123
+
124
+    $disable_delete = FALSE;
125
+    // If email address was changed less than 7 days (7 * 86400 s)
126
+    // ago, it cannot be changed again.
127
+    $duration = TOKEN_DURATION_ONE_WEEK;
128
+    if (($form['_account']['#value']->boincuser_email_addr_change_time + $duration) > time()) {
129
+      drupal_set_message(
130
+        bts("INFO: Your email address was changed within the past seven (7) days. You may not delete your account until after !time.",
131
+          array(
132
+            '!time' => date('F j, Y \a\t G:i T', $form['_account']['#value']->boincuser_email_addr_change_time + $duration),
133
+          ), NULL, 'boinc:account-credentials-change')
134
+      , 'info');
135
+      $disable_delete = TRUE;
136
+    }
137
+
138
+    // Configure radio options
139
+    $deleteoptions = array(
140
+      'boincuser_delete_softdelete' => bts('<b>Soft delete</b> the account. Afterwards your account will be disabled, and all posts/comments will be attributed to the Anonymous User. However, your user profile will be deleted, your host information will be deleted, and you will be removed from any team you are a member of.', array(), NULL, 'boinc:delete-user-account'),
141
+      'boincuser_delete_delete' => bts('<b>Delete</b> the account. Afterwards your account will be deleted, and all posts/comments will be attributed to the Anonymous User. Your user profile will be deleted, and your host information will be deleted.', array(), NULL, 'boinc:delete-user-account'),
142
+    );
143 143
 
144
-      $dtypes = variable_get('boincuser_delete_type', 'user_decides');
145
-      // unset the other option if dtype is set. i.e., if dtype is set
146
-      // to soft delete, unset the hard delete option.
147
-      switch ($dtypes) {
148
-        case 'soft_obfuscate':
149
-          unset($deleteoptions['boincuser_delete_delete']);
150
-          break;
151
-        case 'hard_wipe':
152
-          unset($deleteoptions['boincuser_delete_softdelete']);
153
-          break;
154
-      }
144
+    $dtypes = variable_get('boincuser_delete_type', 'user_decides');
145
+    // unset the other option if dtype is set. i.e., if dtype is set
146
+    // to soft delete, unset the hard delete option.
147
+    switch ($dtypes) {
148
+    case 'soft_obfuscate':
149
+    unset($deleteoptions['boincuser_delete_delete']);
150
+    break;
151
+    case 'hard_wipe':
152
+    unset($deleteoptions['boincuser_delete_softdelete']);
153
+    break;
154
+    }
155 155
 
156 156
       $question = 'Are you sure you want to delete the account <em>' . htmlspecialchars($form['_account']['#value']->boincuser_name) . '</em>?';
157 157
       drupal_set_title($question);
@@ -301,56 +301,56 @@  discard block
 block discarded – undo
301 301
   // create token with 1 day/24 hour expiration
302 302
   $mytoken = create_token($account->boincuser_id, 'D', 24*60*60);
303 303
   switch ($op) {
304
-    case 'boincuser_delete_softdelete':
305
-      $myurl = "${base_url}/user/{$account->uid}/odeleteconfirm/$mytoken";
306
-      break;
307
-    case 'boincuser_delete_delete':
308
-      $myurl = "${base_url}/user/{$account->uid}/deleteconfirm/$mytoken";
304
+  case 'boincuser_delete_softdelete':
305
+    $myurl = "${base_url}/user/{$account->uid}/odeleteconfirm/$mytoken";
309 306
       break;
310
-  }
311
-
312
-  $mysubject = "Instructions for account deletion at {$site_name}";
313
-  $mymessage = ''
314
-    . "{$account->boincuser_name},\n"
315
-    . "\n"
316
-    . "We have received a request to DELETE your user account at "
317
-    . "${site_name}. Below in this email is a one-time token you must "
318
-    . "use. Either click on the link or copy-and-paste the URL into your "
319
-    . "browser address bar. Then you will be required to enter your password "
320
-    . "again to confirm your identity.\n"
321
-    . "\n"
322
-    . "${myurl}\n"
323
-    . "\n"
324
-    . "This one-time token will expire in 24 hours. Afterwards you must "
325
-    . "re-request deletion of your account in order to generate a new token.\n"
326
-    . "\n"
327
-    . "If you did not initiate this request, please login to the "
328
-    . "${site_name} Web site (${site_url}) and "
329
-    . "then contact the administrators.\n"
330
-    . "\n"
331
-    . "Thanks, \n"
332
-    . "\n"
333
-    . "{$site_name} support team";
334
-
335
-  // Create array for sending email to user to notify account is being
336
-  // disabled/deleted. Then send email.
337
-  $settings = array(
338
-    'from' => '',
339
-    'subject' => $mysubject,
340
-    'message' => $mymessage,
341
-  );
342
-  rules_action_mail_to_user($account, $settings);
343
-
344
-  drupal_set_message(bts("INFO: You have requested account deletion. Please check your email for further instructions.", array(), NULL, 'boinc:delete-user-account'),'info');
307
+case 'boincuser_delete_delete':
308
+  $myurl = "${base_url}/user/{$account->uid}/deleteconfirm/$mytoken";
309
+  break;
310
+}
345 311
 
346
-  $redirect = variable_get('boincuser_delete_redirect', '<front>');
347
-  // Redirect
348
-  if (!empty($redirect)) {
349
-    drupal_goto($redirect);
350
-  }
351
-  else {
352
-    drupal_goto();
353
-  }
312
+$mysubject = "Instructions for account deletion at {$site_name}";
313
+$mymessage = ''
314
+. "{$account->boincuser_name},\n"
315
+. "\n"
316
+. "We have received a request to DELETE your user account at "
317
+. "${site_name}. Below in this email is a one-time token you must "
318
+. "use. Either click on the link or copy-and-paste the URL into your "
319
+. "browser address bar. Then you will be required to enter your password "
320
+. "again to confirm your identity.\n"
321
+. "\n"
322
+. "${myurl}\n"
323
+. "\n"
324
+. "This one-time token will expire in 24 hours. Afterwards you must "
325
+. "re-request deletion of your account in order to generate a new token.\n"
326
+. "\n"
327
+. "If you did not initiate this request, please login to the "
328
+. "${site_name} Web site (${site_url}) and "
329
+. "then contact the administrators.\n"
330
+. "\n"
331
+. "Thanks, \n"
332
+. "\n"
333
+. "{$site_name} support team";
334
+
335
+// Create array for sending email to user to notify account is being
336
+// disabled/deleted. Then send email.
337
+$settings = array(
338
+'from' => '',
339
+'subject' => $mysubject,
340
+'message' => $mymessage,
341
+);
342
+rules_action_mail_to_user($account, $settings);
343
+
344
+drupal_set_message(bts("INFO: You have requested account deletion. Please check your email for further instructions.", array(), NULL, 'boinc:delete-user-account'),'info');
345
+
346
+$redirect = variable_get('boincuser_delete_redirect', '<front>');
347
+// Redirect
348
+if (!empty($redirect)) {
349
+drupal_goto($redirect);
350
+}
351
+else {
352
+drupal_goto();
353
+}
354 354
 }
355 355
 
356 356
 
@@ -362,77 +362,77 @@  discard block
 block discarded – undo
362 362
  * The final confirmation form for the user to delete their account.
363 363
  */
364 364
 function boincuser_delete_finalconfirmation(&$form_state, $token) {
365
-  require_boinc('token');
366
-
367
-  global $user;
368
-  $form = array();
369
-
370
-  // check BOINC user exists
371
-  $account = user_load(array('uid' => $user->uid));
372
-  $uid = $user->uid;
373
-  $boincid = $account->boincuser_id;
374
-  // check $token is valid
375
-  if (!is_valid_token($boincid, $token, 'D')) {
376
-    drupal_set_message(bts('ERROR: You have supplied an incorrect (most likely expired) token. Please obtain a new token by !link your account be deleted.',
377
-    array(
378
-      '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"),
379
-    ),
380
-    NULL, 'boinc:delete-user-account'), 'error');
381
-    drupal_goto();
382
-  }
383
-
384
-  // Attach account to this form.
385
-  $form['_account'] = array('#type' => 'value', '#value' => $account);
386
-
387
-  // This form is for hard/wipe delete
388
-  $form['_action'] = array('#type' => 'value', '#value' => 'hard_wipe');
389
-
390
-  // Instructions
391
-  $form['main']['instructions1'] = array(
392
-    '#value' => '<p>'.
393
-    bts('You are one-step away from deleting your account. Enter your password in the textbox below and click submit. This action is irreversable: once you delete your account, there is no way un-delete.', array(), NULL, 'boinc:delete-user-account').
394
-    '</p>',
395
-  );
396
-
397
-  $form['main']['instructions2'] = array(
398
-    '#value' => '<p>'.
399
-    bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account').
400
-    '</p>',
401
-  );
402
-
403
-  // Password field
404
-  $form['main']['current_pass'] = array(
405
-    '#type' => 'password',
406
-    '#title' => bts('Enter your password before clicking Submit', array(), NULL, 'boinc:delete-user-account'),
407
-    '#size' => 17,
408
-    '#attributes' => array(
409
-      'autocomplete' => 'off',
410
-    ),
411
-    '#weight' => 25,
412
-  );
413
-
414
-  // Form control
415
-  $form['form control tabs prefix'] = array(
416
-    '#value' => '<ul class="form-control tab-list">',
417
-    '#weight' => 1001,
418
-  );
419
-  $form['submit'] = array(
420
-    '#prefix' => '<li class="first tab">',
421
-    '#type' => 'submit',
422
-    '#value' => bts('Submit', array(), NULL, 'boinc:form-submit'),
423
-    '#suffix' => '</li>',
424
-    '#weight' => 1002,
425
-  );
426
-  $form['form control tabs'] = array(
427
-    '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>',
428
-    '#weight' => 1003,
429
-  );
430
-  $form['form control tabs suffix'] = array(
431
-    '#value' => '</ul>',
432
-    '#weight' => 1004,
433
-  );
365
+require_boinc('token');
366
+
367
+global $user;
368
+$form = array();
369
+
370
+// check BOINC user exists
371
+$account = user_load(array('uid' => $user->uid));
372
+$uid = $user->uid;
373
+$boincid = $account->boincuser_id;
374
+// check $token is valid
375
+if (!is_valid_token($boincid, $token, 'D')) {
376
+drupal_set_message(bts('ERROR: You have supplied an incorrect (most likely expired) token. Please obtain a new token by !link your account be deleted.',
377
+array(
378
+  '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"),
379
+),
380
+NULL, 'boinc:delete-user-account'), 'error');
381
+drupal_goto();
382
+}
434 383
 
435
-  return $form;
384
+// Attach account to this form.
385
+$form['_account'] = array('#type' => 'value', '#value' => $account);
386
+
387
+// This form is for hard/wipe delete
388
+$form['_action'] = array('#type' => 'value', '#value' => 'hard_wipe');
389
+
390
+// Instructions
391
+$form['main']['instructions1'] = array(
392
+'#value' => '<p>'.
393
+bts('You are one-step away from deleting your account. Enter your password in the textbox below and click submit. This action is irreversable: once you delete your account, there is no way un-delete.', array(), NULL, 'boinc:delete-user-account').
394
+'</p>',
395
+);
396
+
397
+$form['main']['instructions2'] = array(
398
+'#value' => '<p>'.
399
+bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account').
400
+'</p>',
401
+);
402
+
403
+// Password field
404
+$form['main']['current_pass'] = array(
405
+'#type' => 'password',
406
+'#title' => bts('Enter your password before clicking Submit', array(), NULL, 'boinc:delete-user-account'),
407
+'#size' => 17,
408
+'#attributes' => array(
409
+  'autocomplete' => 'off',
410
+),
411
+'#weight' => 25,
412
+);
413
+
414
+// Form control
415
+$form['form control tabs prefix'] = array(
416
+'#value' => '<ul class="form-control tab-list">',
417
+'#weight' => 1001,
418
+);
419
+$form['submit'] = array(
420
+'#prefix' => '<li class="first tab">',
421
+'#type' => 'submit',
422
+'#value' => bts('Submit', array(), NULL, 'boinc:form-submit'),
423
+'#suffix' => '</li>',
424
+'#weight' => 1002,
425
+);
426
+$form['form control tabs'] = array(
427
+'#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>',
428
+'#weight' => 1003,
429
+);
430
+$form['form control tabs suffix'] = array(
431
+'#value' => '</ul>',
432
+'#weight' => 1004,
433
+);
434
+
435
+return $form;
436 436
 }
437 437
 
438 438
 /**
@@ -440,122 +440,122 @@  discard block
 block discarded – undo
440 440
  * the soft/obfuscate method.
441 441
  */
442 442
 function boincuser_delete_softdelconfirmation(&$form_state, $token) {
443
-  require_boinc('token');
444
-
445
-  global $user;
446
-  $form = array();
447
-
448
-  // check BOINC user exists
449
-  $account = user_load(array('uid' => $user->uid));
450
-  $uid = $user->uid;
451
-  $boincid = $account->boincuser_id;
452
-
453
-  // check $token is valid
454
-  if (!is_valid_token($boincid, $token, 'D')) {
455
-    drupal_set_message(bts('ERROR: You have supplied an incorrect (most likely expired) token. Please obtain a new token by !link your account be deleted.',
456
-    array(
457
-      '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"),
458
-    ),
459
-    NULL, 'boinc:delete-user-account'), 'error');
460
-    drupal_goto();
461
-  }
462
-
463
-  // Attach account to this form.
464
-  $form['_account'] = array('#type' => 'value', '#value' => $account);
465
-
466
-  // This form is for hard/wipe delete
467
-  $form['_action'] = array('#type' => 'value', '#value' => 'soft_obfuscate');
468
-
469
-  // Instructions
470
-  $form['main']['instructions1'] = array(
471
-    '#value' => '<p>'.
472
-    bts('You are one-step away from deleting your account. Enter your password in the textbox below and click submit. This action is irreversable: once you delete your account, there is no way un-delete.', array(), NULL, 'boinc:delete-user-account').
473
-    '</p>',
474
-  );
475
-
476
-  $form['main']['instructions2'] = array(
477
-    '#value' => '<p>'.
478
-    bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account').
479
-    '</p>',
480
-  );
481
-
482
-  // Password field
483
-  $form['main']['current_pass'] = array(
484
-    '#type' => 'password',
485
-    '#title' => bts('Enter your password before clicking Submit', array(), NULL, 'boinc:delete-user-account'),
486
-    '#size' => 17,
487
-    '#attributes' => array(
488
-      'autocomplete' => 'off',
489
-    ),
490
-    '#weight' => 25,
491
-  );
492
-
493
-  // Form control
494
-  $form['form control tabs prefix'] = array(
495
-    '#value' => '<ul class="form-control tab-list">',
496
-    '#weight' => 1001,
497
-  );
498
-  $form['submit'] = array(
499
-    '#prefix' => '<li class="first tab">',
500
-    '#type' => 'submit',
501
-    '#value' => bts('Submit', array(), NULL, 'boinc:form-submit'),
502
-    '#suffix' => '</li>',
503
-    '#weight' => 1002,
504
-  );
505
-  $form['form control tabs'] = array(
506
-    '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>',
507
-    '#weight' => 1003,
508
-  );
509
-  $form['form control tabs suffix'] = array(
510
-    '#value' => '</ul>',
511
-    '#weight' => 1004,
512
-  );
443
+require_boinc('token');
444
+
445
+global $user;
446
+$form = array();
447
+
448
+// check BOINC user exists
449
+$account = user_load(array('uid' => $user->uid));
450
+$uid = $user->uid;
451
+$boincid = $account->boincuser_id;
452
+
453
+// check $token is valid
454
+if (!is_valid_token($boincid, $token, 'D')) {
455
+drupal_set_message(bts('ERROR: You have supplied an incorrect (most likely expired) token. Please obtain a new token by !link your account be deleted.',
456
+array(
457
+  '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"),
458
+),
459
+NULL, 'boinc:delete-user-account'), 'error');
460
+drupal_goto();
461
+}
513 462
 
514
-  //set validation and submit to the functions below
515
-  $form['#validate'][] = 'boincuser_delete_finalconfirmation_validate';
516
-  $form['#submit'][] = 'boincuser_delete_finalconfirmation_submit';
517
-  return $form;
463
+// Attach account to this form.
464
+$form['_account'] = array('#type' => 'value', '#value' => $account);
465
+
466
+// This form is for hard/wipe delete
467
+$form['_action'] = array('#type' => 'value', '#value' => 'soft_obfuscate');
468
+
469
+// Instructions
470
+$form['main']['instructions1'] = array(
471
+'#value' => '<p>'.
472
+bts('You are one-step away from deleting your account. Enter your password in the textbox below and click submit. This action is irreversable: once you delete your account, there is no way un-delete.', array(), NULL, 'boinc:delete-user-account').
473
+'</p>',
474
+);
475
+
476
+$form['main']['instructions2'] = array(
477
+'#value' => '<p>'.
478
+bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account').
479
+'</p>',
480
+);
481
+
482
+// Password field
483
+$form['main']['current_pass'] = array(
484
+'#type' => 'password',
485
+'#title' => bts('Enter your password before clicking Submit', array(), NULL, 'boinc:delete-user-account'),
486
+'#size' => 17,
487
+'#attributes' => array(
488
+  'autocomplete' => 'off',
489
+),
490
+'#weight' => 25,
491
+);
492
+
493
+// Form control
494
+$form['form control tabs prefix'] = array(
495
+'#value' => '<ul class="form-control tab-list">',
496
+'#weight' => 1001,
497
+);
498
+$form['submit'] = array(
499
+'#prefix' => '<li class="first tab">',
500
+'#type' => 'submit',
501
+'#value' => bts('Submit', array(), NULL, 'boinc:form-submit'),
502
+'#suffix' => '</li>',
503
+'#weight' => 1002,
504
+);
505
+$form['form control tabs'] = array(
506
+'#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>',
507
+'#weight' => 1003,
508
+);
509
+$form['form control tabs suffix'] = array(
510
+'#value' => '</ul>',
511
+'#weight' => 1004,
512
+);
513
+
514
+//set validation and submit to the functions below
515
+$form['#validate'][] = 'boincuser_delete_finalconfirmation_validate';
516
+$form['#submit'][] = 'boincuser_delete_finalconfirmation_submit';
517
+return $form;
518 518
 }
519 519
 
520 520
 /**
521 521
  * Validation for final confirmation
522 522
  */
523 523
 function boincuser_delete_finalconfirmation_validate($form, &$form_state) {
524
-  $account = $form_state['values']['_account'];
525
-  $boinc_user = BoincUser::lookup_id($account->boincuser_id);
524
+$account = $form_state['values']['_account'];
525
+$boinc_user = BoincUser::lookup_id($account->boincuser_id);
526 526
 
527
-  if (_boincuser_delete_validatepasswd($boinc_user, $form_state['values']['current_pass'])) {
528
-    return true;
529
-  }
527
+if (_boincuser_delete_validatepasswd($boinc_user, $form_state['values']['current_pass'])) {
528
+return true;
529
+}
530 530
 }
531 531
 
532 532
 /**
533 533
  * Submit for final confirmation
534 534
  */
535 535
 function boincuser_delete_finalconfirmation_submit($form, &$form_state) {
536
-  global $user;
537
-
538
-  // Delete the user
539
-  $account = $form_state['values']['_account'];
540
-  $action = $form_state['values']['_action'];
541
-  _boincuser_delete_deleteuser($account, $action);
542
-
543
-  // Destroy the current session:
544
-  session_destroy();
545
-  // Only variables can be passed by reference workaround.
546
-  $null = NULL;
547
-  user_module_invoke('logout', $null, $user);
548
-
549
-  // Load the anonymous user
550
-  $user = drupal_anonymous_user();
551
-
552
-  $redirect = variable_get('boincuser_delete_redirect', '<front>');
553
-  // Redirect
554
-  if (!empty($redirect)) {
555
-    drupal_goto($redirect);
556
-  }
557
-  else {
558
-    drupal_goto();
559
-  }
536
+global $user;
537
+
538
+// Delete the user
539
+$account = $form_state['values']['_account'];
540
+$action = $form_state['values']['_action'];
541
+_boincuser_delete_deleteuser($account, $action);
542
+
543
+// Destroy the current session:
544
+session_destroy();
545
+// Only variables can be passed by reference workaround.
546
+$null = NULL;
547
+user_module_invoke('logout', $null, $user);
548
+
549
+// Load the anonymous user
550
+$user = drupal_anonymous_user();
551
+
552
+$redirect = variable_get('boincuser_delete_redirect', '<front>');
553
+// Redirect
554
+if (!empty($redirect)) {
555
+drupal_goto($redirect);
556
+}
557
+else {
558
+drupal_goto();
559
+}
560 560
 
561 561
 }
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boincuser/boincuser.module 1 patch
Switch Indentation   +436 added lines, -436 removed lines patch added patch discarded remove patch
@@ -27,287 +27,287 @@  discard block
 block discarded – undo
27 27
  * with defined URL paths
28 28
  */
29 29
 function boincuser_menu() {
30
-  $items['account/posts'] = array(
31
-    'title' => 'Recent posts',
32
-    'description' => '',
33
-    'page callback' => 'boincuser_goto_recent_posts',
34
-    'access callback' => 'user_is_logged_in',
35
-    'type' => MENU_CALLBACK,
36
-  );
37
-  $items['account/profile'] = array(
38
-    'title' => '',
39
-    'description' => '',
40
-    'page callback' => 'boincuser_view_profile',
41
-    'access callback' => 'user_is_logged_in',
42
-    'type' => MENU_NORMAL_ITEM
43
-  );
44
-  $items['account/profile/view'] = array(
45
-    'title' => 'View',
46
-    'description' => 'Show a user profile',
47
-    'page callback' => 'boincuser_view_profile',
48
-    'access callback' => 'user_is_logged_in',
49
-    'type' => MENU_DEFAULT_LOCAL_TASK,
50
-    'weight' => 0
51
-  );
52
-  $items['account/profile/edit'] = array(
53
-    'title' => 'Edit',
54
-    'description' => 'Edit a user profile',
55
-    'page callback' => 'boincuser_edit_profile',
56
-    'access callback' => 'user_is_logged_in',
57
-    'type' => MENU_LOCAL_TASK,
58
-    'weight' => 5
59
-  );
60
-  $items['account/team'] = array(
61
-    'title' => 'User team',
62
-    'description' => '',
63
-    'page callback' => 'boincuser_goto_team',
64
-    'access callback' => 'user_is_logged_in',
65
-    'type' => MENU_CALLBACK,
66
-  );
67
-  $items['moderate/profile/%user/approve'] = array(
68
-    'title' => 'Profile approval',
69
-    'description' => 'Approve profile content',
70
-    'page callback' => 'boincuser_moderate_profile_approve',
71
-    'page arguments' => array(2),
72
-    'access arguments' => array('edit any profile content'),
73
-    'type' => MENU_CALLBACK,
74
-    'weight' => 5
75
-  );
76
-  $items['moderate/profile/%user/edit'] = array(
77
-    'title' => 'Profile editor',
78
-    'description' => 'Edit a user profile',
79
-    'page callback' => 'boincuser_edit_profile',
80
-    'page arguments' => array(2),
81
-    'access arguments' => array('edit any profile content'),
82
-    'type' => MENU_CALLBACK,
83
-    'weight' => 5
84
-  );
85
-  $items['moderate/profile/%/reject'] = array(
86
-    'title' => bts('Reject profile', array(), NULL, 'boinc:moderate-user'),
87
-    'description' => 'Reject profile content',
88
-    'page callback' => 'drupal_get_form',
89
-    'page arguments' => array('boincuser_moderate_profile_reject_form', 2),
90
-    'access arguments' => array('edit any profile content'),
91
-    'type' => MENU_CALLBACK,
92
-    'weight' => 5
93
-  );
94
-  $items['moderate/user/%/ban'] = array(
95
-    'title' => bts('Ban user', array(), NULL, 'boinc:moderate-ban-user'),
96
-    'description' => 'Ban a user from using community features',
97
-    'page callback' => 'drupal_get_form',
98
-    'page arguments' => array('boincuser_moderate_user_ban_form', 2),
99
-    'access callback' => 'boincuser_moderate_community_access',
100
-    'type' => MENU_CALLBACK,
101
-  );
102
-  $items['join'] = array(
103
-    'title' => '',
104
-    'description' => '',
105
-    'page callback' => 'join_page',
106
-    'access arguments' => array('access content'),
107
-    'type' => MENU_NORMAL_ITEM
108
-  );
109
-  $items['join/new'] = array(
110
-    'title' => bts("I'm new"),
111
-    'page callback' => 'join_page',
112
-    'page arguments' => array(1),
113
-    'access arguments' => array('access content'),
114
-    'type' => MENU_DEFAULT_LOCAL_TASK,
115
-    'weight' => 0
116
-  );
117
-  $items['join/boinc'] = array(
118
-    'title' => bts("I'm a BOINC user"),
119
-    'page callback' => 'join_page',
120
-    'page arguments' => array(1),
121
-    'access arguments' => array('access content'),
122
-    'type' => MENU_LOCAL_TASK,
123
-    'weight' => 5
124
-  );
125
-  $items['user/login/auth'] = array(
126
-    'title' => bts('Authenticator login', array(), NULL, 'boinc:authenticator-login-page'),
127
-    'description' => 'Log in using a user authenticator',
128
-    'page callback' => 'drupal_get_form',
129
-    'page arguments' => array('boincuser_authloginform'),
130
-    'access arguments' => array('access content'),
131
-    'type' => MENU_CALLBACK,
132
-  );
133
-  $items['user/termsofuse'] = array(
134
-    'title' => bts('Terms of Use', array(), NULL, 'boinc:termsofuse-form'),
135
-    'description' => 'A site\'s term of use.',
136
-    'page callback' => 'drupal_get_form',
137
-    'page arguments' => array('boincuser_termsofuse_form'),
138
-    'access callback' => 'user_is_logged_in',
139
-    'type' => MENU_CALLBACK,
140
-  );
141
-  $items['user_control'] = array(
142
-    'page callback' => 'boincuser_control',
143
-    'access arguments' => array('access user profiles'),
144
-    'type' => MENU_CALLBACK
145
-  );
146
-  $items['admin/boinc'] = array(
147
-    'title' => 'BOINC configuration',
148
-    'position' => 'right',
149
-    'weight' => -8,
150
-    'page callback' => 'system_admin_menu_block_page',
151
-    'access arguments' => array('administer site configuration'),
152
-    'file' => 'system.admin.inc',
153
-    'file path' => drupal_get_path('module', 'system'),
154
-  );
155
-  $items['admin/boinc/environment'] = array(
156
-    'title' => 'Environment: General',
157
-    'description' => 'Set paths to BOINC functions and any other necessary
30
+$items['account/posts'] = array(
31
+'title' => 'Recent posts',
32
+'description' => '',
33
+'page callback' => 'boincuser_goto_recent_posts',
34
+'access callback' => 'user_is_logged_in',
35
+'type' => MENU_CALLBACK,
36
+);
37
+$items['account/profile'] = array(
38
+'title' => '',
39
+'description' => '',
40
+'page callback' => 'boincuser_view_profile',
41
+'access callback' => 'user_is_logged_in',
42
+'type' => MENU_NORMAL_ITEM
43
+);
44
+$items['account/profile/view'] = array(
45
+'title' => 'View',
46
+'description' => 'Show a user profile',
47
+'page callback' => 'boincuser_view_profile',
48
+'access callback' => 'user_is_logged_in',
49
+'type' => MENU_DEFAULT_LOCAL_TASK,
50
+'weight' => 0
51
+);
52
+$items['account/profile/edit'] = array(
53
+'title' => 'Edit',
54
+'description' => 'Edit a user profile',
55
+'page callback' => 'boincuser_edit_profile',
56
+'access callback' => 'user_is_logged_in',
57
+'type' => MENU_LOCAL_TASK,
58
+'weight' => 5
59
+);
60
+$items['account/team'] = array(
61
+'title' => 'User team',
62
+'description' => '',
63
+'page callback' => 'boincuser_goto_team',
64
+'access callback' => 'user_is_logged_in',
65
+'type' => MENU_CALLBACK,
66
+);
67
+$items['moderate/profile/%user/approve'] = array(
68
+'title' => 'Profile approval',
69
+'description' => 'Approve profile content',
70
+'page callback' => 'boincuser_moderate_profile_approve',
71
+'page arguments' => array(2),
72
+'access arguments' => array('edit any profile content'),
73
+'type' => MENU_CALLBACK,
74
+'weight' => 5
75
+);
76
+$items['moderate/profile/%user/edit'] = array(
77
+'title' => 'Profile editor',
78
+'description' => 'Edit a user profile',
79
+'page callback' => 'boincuser_edit_profile',
80
+'page arguments' => array(2),
81
+'access arguments' => array('edit any profile content'),
82
+'type' => MENU_CALLBACK,
83
+'weight' => 5
84
+);
85
+$items['moderate/profile/%/reject'] = array(
86
+'title' => bts('Reject profile', array(), NULL, 'boinc:moderate-user'),
87
+'description' => 'Reject profile content',
88
+'page callback' => 'drupal_get_form',
89
+'page arguments' => array('boincuser_moderate_profile_reject_form', 2),
90
+'access arguments' => array('edit any profile content'),
91
+'type' => MENU_CALLBACK,
92
+'weight' => 5
93
+);
94
+$items['moderate/user/%/ban'] = array(
95
+'title' => bts('Ban user', array(), NULL, 'boinc:moderate-ban-user'),
96
+'description' => 'Ban a user from using community features',
97
+'page callback' => 'drupal_get_form',
98
+'page arguments' => array('boincuser_moderate_user_ban_form', 2),
99
+'access callback' => 'boincuser_moderate_community_access',
100
+'type' => MENU_CALLBACK,
101
+);
102
+$items['join'] = array(
103
+'title' => '',
104
+'description' => '',
105
+'page callback' => 'join_page',
106
+'access arguments' => array('access content'),
107
+'type' => MENU_NORMAL_ITEM
108
+);
109
+$items['join/new'] = array(
110
+'title' => bts("I'm new"),
111
+'page callback' => 'join_page',
112
+'page arguments' => array(1),
113
+'access arguments' => array('access content'),
114
+'type' => MENU_DEFAULT_LOCAL_TASK,
115
+'weight' => 0
116
+);
117
+$items['join/boinc'] = array(
118
+'title' => bts("I'm a BOINC user"),
119
+'page callback' => 'join_page',
120
+'page arguments' => array(1),
121
+'access arguments' => array('access content'),
122
+'type' => MENU_LOCAL_TASK,
123
+'weight' => 5
124
+);
125
+$items['user/login/auth'] = array(
126
+'title' => bts('Authenticator login', array(), NULL, 'boinc:authenticator-login-page'),
127
+'description' => 'Log in using a user authenticator',
128
+'page callback' => 'drupal_get_form',
129
+'page arguments' => array('boincuser_authloginform'),
130
+'access arguments' => array('access content'),
131
+'type' => MENU_CALLBACK,
132
+);
133
+$items['user/termsofuse'] = array(
134
+'title' => bts('Terms of Use', array(), NULL, 'boinc:termsofuse-form'),
135
+'description' => 'A site\'s term of use.',
136
+'page callback' => 'drupal_get_form',
137
+'page arguments' => array('boincuser_termsofuse_form'),
138
+'access callback' => 'user_is_logged_in',
139
+'type' => MENU_CALLBACK,
140
+);
141
+$items['user_control'] = array(
142
+'page callback' => 'boincuser_control',
143
+'access arguments' => array('access user profiles'),
144
+'type' => MENU_CALLBACK
145
+);
146
+$items['admin/boinc'] = array(
147
+'title' => 'BOINC configuration',
148
+'position' => 'right',
149
+'weight' => -8,
150
+'page callback' => 'system_admin_menu_block_page',
151
+'access arguments' => array('administer site configuration'),
152
+'file' => 'system.admin.inc',
153
+'file path' => drupal_get_path('module', 'system'),
154
+);
155
+$items['admin/boinc/environment'] = array(
156
+'title' => 'Environment: General',
157
+'description' => 'Set paths to BOINC functions and any other necessary
158 158
       variables that establish a BOINC environment.',
159
-    'page callback' => 'drupal_get_form',
160
-    'page arguments' => array('boincuser_admin_environment'),
161
-    'access arguments' => array('administer site configuration'),
162
-    'type' => MENU_NORMAL_ITEM,
163
-    'file' => 'boincuser.admin.inc'
164
-  );
165
-  $items['admin/boinc/scheduler'] = array(
166
-    'title' => 'Environment: Scheduling server URLs',
167
-    'description' => 'Set BOINC scheduler options.',
168
-    'page callback' => 'drupal_get_form',
169
-    'page arguments' => array('boincuser_admin_scheduler'),
170
-    'access arguments' => array('administer site configuration'),
171
-    'type' => MENU_NORMAL_ITEM,
172
-    'file' => 'boincuser.admin.inc'
173
-  );
174
-  $items['admin/boinc/weboptions'] = array(
175
-    'title' => 'Environment: Website Options',
176
-    'description' => 'Set options configuring this Drupal-BOINC Web site.',
177
-    'page callback' => 'drupal_get_form',
178
-    'page arguments' => array('boincuser_admin_weboptions'),
179
-    'access arguments' => array('administer site configuration'),
180
-    'type' => MENU_NORMAL_ITEM,
181
-    'file' => 'boincuser.admin.inc'
182
-  );
159
+'page callback' => 'drupal_get_form',
160
+'page arguments' => array('boincuser_admin_environment'),
161
+'access arguments' => array('administer site configuration'),
162
+'type' => MENU_NORMAL_ITEM,
163
+'file' => 'boincuser.admin.inc'
164
+);
165
+$items['admin/boinc/scheduler'] = array(
166
+'title' => 'Environment: Scheduling server URLs',
167
+'description' => 'Set BOINC scheduler options.',
168
+'page callback' => 'drupal_get_form',
169
+'page arguments' => array('boincuser_admin_scheduler'),
170
+'access arguments' => array('administer site configuration'),
171
+'type' => MENU_NORMAL_ITEM,
172
+'file' => 'boincuser.admin.inc'
173
+);
174
+$items['admin/boinc/weboptions'] = array(
175
+'title' => 'Environment: Website Options',
176
+'description' => 'Set options configuring this Drupal-BOINC Web site.',
177
+'page callback' => 'drupal_get_form',
178
+'page arguments' => array('boincuser_admin_weboptions'),
179
+'access arguments' => array('administer site configuration'),
180
+'type' => MENU_NORMAL_ITEM,
181
+'file' => 'boincuser.admin.inc'
182
+);
183 183
   
184
-  $items['create_account.php'] = array(
185
-    'title' => 'Create Account RPC',
186
-    'description' => 'RPC for creating user accounts.',
187
-    'page callback' => 'boincuser_create_account',
188
-    'access callback' => TRUE,
189
-    'type' => MENU_CALLBACK
190
-  );
191
-  $items['account_finish.php'] = array(
192
-    'title' => 'Welcome to ' . variable_get('site_name', 'Drupal-BOINC'),
193
-    'description' => 'RPC for after a user has created an account.',
194
-    'page callback' => 'boincuser_account_finish',
195
-    'access callback' => TRUE,
196
-    'type' => MENU_CALLBACK,
197
-  );
198
-  $items['boincuser/autocomplete'] = array(
199
-    'page callback' => '_boincuser_user_name_autocomplete',
200
-    'access callback' => TRUE,
201
-    'type' => MENU_CALLBACK,
202
-  );
203
-  $items['user/%user/recoveremail/%'] = array(
204
-    'title' => t('Recover previous email'),
205
-    'description' => t('Form to revert email to previous address.'),
206
-    'page callback' => 'drupal_get_form',
207
-    'page arguments' => array('boincuser_revertemail', 3),
208
-    'access callback' => 'user_is_logged_in',
209
-    'type' => MENU_CALLBACK,
210
-  );
211
-  $items['recover_email.php'] = array(
212
-    'title' => t('Recover previous email'),
213
-    'description' => t('redirect'),
214
-    'page callback' => '_boincuser_redirect_recover_email',
215
-    'access callback' => TRUE,
216
-    'type' => MENU_CALLBACK,
217
-  );
218
-  return $items;
184
+$items['create_account.php'] = array(
185
+'title' => 'Create Account RPC',
186
+'description' => 'RPC for creating user accounts.',
187
+'page callback' => 'boincuser_create_account',
188
+'access callback' => TRUE,
189
+'type' => MENU_CALLBACK
190
+);
191
+$items['account_finish.php'] = array(
192
+'title' => 'Welcome to ' . variable_get('site_name', 'Drupal-BOINC'),
193
+'description' => 'RPC for after a user has created an account.',
194
+'page callback' => 'boincuser_account_finish',
195
+'access callback' => TRUE,
196
+'type' => MENU_CALLBACK,
197
+);
198
+$items['boincuser/autocomplete'] = array(
199
+'page callback' => '_boincuser_user_name_autocomplete',
200
+'access callback' => TRUE,
201
+'type' => MENU_CALLBACK,
202
+);
203
+$items['user/%user/recoveremail/%'] = array(
204
+'title' => t('Recover previous email'),
205
+'description' => t('Form to revert email to previous address.'),
206
+'page callback' => 'drupal_get_form',
207
+'page arguments' => array('boincuser_revertemail', 3),
208
+'access callback' => 'user_is_logged_in',
209
+'type' => MENU_CALLBACK,
210
+);
211
+$items['recover_email.php'] = array(
212
+'title' => t('Recover previous email'),
213
+'description' => t('redirect'),
214
+'page callback' => '_boincuser_redirect_recover_email',
215
+'access callback' => TRUE,
216
+'type' => MENU_CALLBACK,
217
+);
218
+return $items;
219 219
 }
220 220
 
221 221
 /**
222 222
  * Implementation of hook_init()
223 223
  */
224 224
 function boincuser_init() {
225
-  global $user;
226
-  // Skip this check for charts, which are loaded separately
227
-  // (may get duplicate or unexpected messages otherwise)
228
-  if (substr($_GET['q'], 0, 7) == 'charts/') {
229
-    return;
230
-  }
225
+global $user;
226
+// Skip this check for charts, which are loaded separately
227
+// (may get duplicate or unexpected messages otherwise)
228
+if (substr($_GET['q'], 0, 7) == 'charts/') {
229
+return;
230
+}
231 231
 
232
-  // If admin user, do some basic site functionality checks
233
-  if (user_access('administer site configuration')) {
234
-    // Ensure we have a configured BOINC environment
235
-    boinc_get_path();
236
-    boinc_get_scheduler_tags();
237
-  }
232
+// If admin user, do some basic site functionality checks
233
+if (user_access('administer site configuration')) {
234
+// Ensure we have a configured BOINC environment
235
+boinc_get_path();
236
+boinc_get_scheduler_tags();
237
+}
238 238
   
239
-  // Check credits for the verified contributor role
240
-  boincuser_check_credit_requirements();
239
+// Check credits for the verified contributor role
240
+boincuser_check_credit_requirements();
241 241
   
242
-  if (module_exists('boincteam')) {
243
-    // Display any persistent team messages
244
-    boincteam_show_messages();
245
-  }
242
+if (module_exists('boincteam')) {
243
+// Display any persistent team messages
244
+boincteam_show_messages();
245
+}
246 246
 
247
-  // Check if user has agreed to the terms of use. If not, send the
248
-  // user to the terms-of-use form. This is only makes sense if the
249
-  // termsofuse is enabled, by having text in the termsofuse variable.
250
-  $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE);
251
-  $termsofuse = variable_get('boinc_weboptions_termsofuse', '');
252
-  if ( (!empty($termsofuse)) and ($user->uid) ) {
253
-    if ( !boincuser_check_termsofuse($user) and ($existinguser_tou) ) {
254
-
255
-      // Admins are exempt, otherwise the admin may not be able to
256
-      // access the site!
257
-      $administrator_role = array_search('administrator', user_roles(true));
258
-      if (!isset($user->roles[$administrator_role])) {
259
-        $path = drupal_get_path_alias($_GET['q']);
260
-
261
-        // Any paths that should NOT be redirected go here.
262
-        // @todo - replace this static array with one that allows
263
-        // admins to specify custom paths (patterns) to ignore.
264
-        $paths_to_ignore = array(
265
-          'user/termsofuse',
266
-          'logout',
267
-          'privacy',
268
-          'moderation',
269
-          'account/info/edit',
270
-          'user/' . $user->uid . '/edit',
271
-          'user/' . $user->uid . '/recoveremail/*',
272
-          'recover_email.php',
273
-        );
274
-        if (module_exists('boincuser_delete')) {
275
-          $paths_to_ignore[] = 'user/' . $user->uid . '/delete';
276
-          $paths_to_ignore[] = 'user/' . $user->uid . '/deleteconfirm/*';
277
-          $paths_to_ignore[] = 'user/' . $user->uid . '/odeleteconfirm/*';
278
-        }
279
-        if (!_boincuser_ignore_paths($path, $paths_to_ignore)) {
280
-          drupal_goto('user/termsofuse');
281
-        }
282
-      }
247
+// Check if user has agreed to the terms of use. If not, send the
248
+// user to the terms-of-use form. This is only makes sense if the
249
+// termsofuse is enabled, by having text in the termsofuse variable.
250
+$existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE);
251
+$termsofuse = variable_get('boinc_weboptions_termsofuse', '');
252
+if ( (!empty($termsofuse)) and ($user->uid) ) {
253
+if ( !boincuser_check_termsofuse($user) and ($existinguser_tou) ) {
254
+
255
+  // Admins are exempt, otherwise the admin may not be able to
256
+  // access the site!
257
+  $administrator_role = array_search('administrator', user_roles(true));
258
+  if (!isset($user->roles[$administrator_role])) {
259
+    $path = drupal_get_path_alias($_GET['q']);
260
+
261
+    // Any paths that should NOT be redirected go here.
262
+    // @todo - replace this static array with one that allows
263
+    // admins to specify custom paths (patterns) to ignore.
264
+    $paths_to_ignore = array(
265
+      'user/termsofuse',
266
+      'logout',
267
+      'privacy',
268
+      'moderation',
269
+      'account/info/edit',
270
+      'user/' . $user->uid . '/edit',
271
+      'user/' . $user->uid . '/recoveremail/*',
272
+      'recover_email.php',
273
+    );
274
+    if (module_exists('boincuser_delete')) {
275
+      $paths_to_ignore[] = 'user/' . $user->uid . '/delete';
276
+      $paths_to_ignore[] = 'user/' . $user->uid . '/deleteconfirm/*';
277
+      $paths_to_ignore[] = 'user/' . $user->uid . '/odeleteconfirm/*';
278
+    }
279
+    if (!_boincuser_ignore_paths($path, $paths_to_ignore)) {
280
+      drupal_goto('user/termsofuse');
283 281
     }
284 282
   }
285 283
 }
284
+}
285
+}
286 286
 
287 287
 /**
288 288
  * Implementation of hook_user(); add custom actions to standard
289 289
  * Drupal user operations
290 290
  */
291 291
 function boincuser_user($op, &$edit, &$account, $category = NULL) {
292
-  require_boinc('boinc_db');
293
-  require_boinc('user');
294
-  require_boinc('xml');
295
-
296
-  require_boinc('password_compat/password');
297
-  // Handle BOINC integration for users with UID > 1 (skip anonymous and admin)
298
-  if ($account->uid > 1) {
299
-    switch($op) {
300
-    case 'load':
301
-      // User loading; insert BOINC data into the user object
302
-      $drupal_user = db_fetch_object(db_query("
292
+require_boinc('boinc_db');
293
+require_boinc('user');
294
+require_boinc('xml');
295
+
296
+require_boinc('password_compat/password');
297
+// Handle BOINC integration for users with UID > 1 (skip anonymous and admin)
298
+if ($account->uid > 1) {
299
+switch($op) {
300
+case 'load':
301
+// User loading; insert BOINC data into the user object
302
+$drupal_user = db_fetch_object(db_query("
303 303
         SELECT boinc_id, penalty_expiration
304 304
         FROM {boincuser} WHERE uid = %d",
305
-        $account->uid
306
-      ));
307
-      $account->boincuser_id = $drupal_user->boinc_id;
308
-      $account->boincuser_penalty_expiration = $drupal_user->penalty_expiration;
309
-      db_set_active('boinc_rw');
310
-      $boinc_user = db_fetch_object(db_query("
305
+$account->uid
306
+));
307
+$account->boincuser_id = $drupal_user->boinc_id;
308
+$account->boincuser_penalty_expiration = $drupal_user->penalty_expiration;
309
+db_set_active('boinc_rw');
310
+$boinc_user = db_fetch_object(db_query("
311 311
         SELECT
312 312
           name,
313 313
           authenticator,
@@ -322,30 +322,30 @@  discard block
 block discarded – undo
322 322
           email_addr_change_time
323 323
         FROM {user}
324 324
         WHERE id = %d",
325
-        $account->boincuser_id
326
-      ));
327
-      $account->boincuser_name = $boinc_user->name;
328
-      $account->boincuser_account_key = $boinc_user->authenticator;
329
-      $account->boincuser_weak_auth = md5($boinc_user->authenticator . $boinc_user->passwd_hash);
330
-      $account->boincuser_total_credit = round($boinc_user->total_credit);
331
-      $account->boincuser_expavg_credit = round($boinc_user->expavg_credit);
332
-      $account->boincuser_expavg_time = round($boinc_user->expavg_time);
333
-      $account->boincuser_cpid = md5($boinc_user->cross_project_id . $account->mail);
334
-      $account->boincuser_default_pref_set = $boinc_user->venue;
335
-      $account->boincteam_id = $boinc_user->teamid;
336
-      $account->boincuser_previous_email_addr = $boinc_user->previous_email_addr;
337
-      $account->boincuser_email_addr_change_time = $boinc_user->email_addr_change_time;
338
-      db_set_active('default');
339
-      // Set Drupal team ID
340
-      $account->team = NULL;
341
-      if ($account->boincteam_id) {
342
-        $account->team = db_result(db_query("
325
+$account->boincuser_id
326
+));
327
+$account->boincuser_name = $boinc_user->name;
328
+$account->boincuser_account_key = $boinc_user->authenticator;
329
+$account->boincuser_weak_auth = md5($boinc_user->authenticator . $boinc_user->passwd_hash);
330
+$account->boincuser_total_credit = round($boinc_user->total_credit);
331
+$account->boincuser_expavg_credit = round($boinc_user->expavg_credit);
332
+$account->boincuser_expavg_time = round($boinc_user->expavg_time);
333
+$account->boincuser_cpid = md5($boinc_user->cross_project_id . $account->mail);
334
+$account->boincuser_default_pref_set = $boinc_user->venue;
335
+$account->boincteam_id = $boinc_user->teamid;
336
+$account->boincuser_previous_email_addr = $boinc_user->previous_email_addr;
337
+$account->boincuser_email_addr_change_time = $boinc_user->email_addr_change_time;
338
+db_set_active('default');
339
+// Set Drupal team ID
340
+$account->team = NULL;
341
+if ($account->boincteam_id) {
342
+$account->team = db_result(db_query("
343 343
           SELECT nid FROM {boincteam} WHERE team_id = %d",
344
-          $account->boincteam_id
345
-        ));
346
-      }
347
-      // Set post count
348
-      $account->post_count = db_result(db_query("
344
+$account->boincteam_id
345
+));
346
+}
347
+// Set post count
348
+$account->post_count = db_result(db_query("
349 349
         SELECT COUNT(*) +
350 350
         (
351 351
           SELECT COUNT(*) FROM {node}
@@ -357,13 +357,13 @@  discard block
 block discarded – undo
357 357
         INNER JOIN node ON comments.nid = node.nid
358 358
         WHERE comments.uid = '%d'
359 359
         AND node.status = 1",
360
-        $account->uid, $account->uid
361
-      ));
362
-      break;
360
+$account->uid, $account->uid
361
+));
362
+break;
363 363
       
364
-    case 'view':
365
-      // SAMPLE: Add BOINC data to the user profile
366
-      /*$account->content['summary']['boinc_id'] = array(
364
+case 'view':
365
+// SAMPLE: Add BOINC data to the user profile
366
+/*$account->content['summary']['boinc_id'] = array(
367 367
         '#type' => 'user_profile_item',
368 368
         '#title' => bts('BIONC ID'),
369 369
         '#value' => $account->boincuser_id,
@@ -377,161 +377,161 @@  discard block
 block discarded – undo
377 377
         '#attributes' => array('class' => 'boinc-data'),
378 378
         '#weight' => 10
379 379
       );*/
380
-      break;
380
+break;
381 381
       
382
-    case 'validate':
383
-      if (isset($edit['validation_source'])) {
384
-        switch ($edit['validation_source']) {
385
-        case 'user_account':
386
-          // Validate data before updating user account info
387
-          boincuser_account_validate($edit, $account);
388
-          break;
382
+case 'validate':
383
+if (isset($edit['validation_source'])) {
384
+switch ($edit['validation_source']) {
385
+case 'user_account':
386
+// Validate data before updating user account info
387
+boincuser_account_validate($edit, $account);
388
+break;
389 389
         
390
-        default:
390
+default:
391 391
           
392
-        }
393
-        // We don't want to save validation source, so remove it
394
-        $edit['validation_source'] = null;
395
-      }
396
-      break;
392
+}
393
+    // We don't want to save validation source, so remove it
394
+    $edit['validation_source'] = null;
395
+  }
396
+  break;
397 397
       
398
-    case 'insert':
399
-      // New user being added to the system
400
-      $imported = $_SESSION['importedUser'];
401
-      unset($_SESSION['importedUser']);
398
+case 'insert':
399
+  // New user being added to the system
400
+  $imported = $_SESSION['importedUser'];
401
+  unset($_SESSION['importedUser']);
402 402
       
403
-      watchdog(
404
-        'boincuser',
405
-        'Creating user account for %email_addr',
406
-        array('%email_addr' => $edit['mail']),
407
-        WATCHDOG_NOTICE
408
-      );
403
+  watchdog(
404
+    'boincuser',
405
+    'Creating user account for %email_addr',
406
+    array('%email_addr' => $edit['mail']),
407
+    WATCHDOG_NOTICE
408
+  );
409 409
       
410
-      // The create_acount RPC will call this block of code when
411
-      // user_save() is used. If user is registering using the Web
412
-      // registration form, create a BOINC user and relationships.
413
-      // Create a BOINC account unless importing from BOINC.
414
-      if (!$imported) {
415
-
416
-        if ($edit['boincuser_name']) {
417
-          $myname = $edit['boincuser_name'];
418
-        }
419
-        else if ($edit['name']) {
420
-          $myname = $edit['name'];
421
-        }
422
-        else {
423
-          $myname = 'noname';
424
-        }
410
+  // The create_acount RPC will call this block of code when
411
+  // user_save() is used. If user is registering using the Web
412
+  // registration form, create a BOINC user and relationships.
413
+  // Create a BOINC account unless importing from BOINC.
414
+  if (!$imported) {
415
+
416
+    if ($edit['boincuser_name']) {
417
+      $myname = $edit['boincuser_name'];
418
+    }
419
+    else if ($edit['name']) {
420
+      $myname = $edit['name'];
421
+    }
422
+    else {
423
+      $myname = 'noname';
424
+    }
425 425
 
426
-        $user_params = array(
427
-          'email_addr' => $edit['mail'],
428
-          'name' => $myname,
429
-        );
426
+    $user_params = array(
427
+      'email_addr' => $edit['mail'],
428
+      'name' => $myname,
429
+    );
430 430
 
431
-        // If the 'pass' variable is already a hash, then don't hash it again.
432
-        if ($edit['boinchash_flag']) {
433
-          $user_params['passwd_hash'] = $edit['pass'];
434
-        }
435
-        else {
436
-          // The passwd_hash here is only the md5() hash. This is
437
-          // because BOINC make_user(), called later, will run
438
-          // password_hash() on this md5 hash.
439
-          $user_params['passwd_hash'] = md5($edit['pass'].$edit['mail']);
440
-        }
431
+    // If the 'pass' variable is already a hash, then don't hash it again.
432
+    if ($edit['boinchash_flag']) {
433
+      $user_params['passwd_hash'] = $edit['pass'];
434
+    }
435
+    else {
436
+      // The passwd_hash here is only the md5() hash. This is
437
+      // because BOINC make_user(), called later, will run
438
+      // password_hash() on this md5 hash.
439
+      $user_params['passwd_hash'] = md5($edit['pass'].$edit['mail']);
440
+    }
441 441
 
442
-        $boinc_user = boincuser_register_make_user($user_params);
443
-        if (!$boinc_user) {
444
-          // Account exists with this email addr
445
-          form_set_error('email', bts('Error creating BOINC account.', array(), NULL, 'boinc:add-new-user'));
446
-          return;
447
-        }
442
+    $boinc_user = boincuser_register_make_user($user_params);
443
+    if (!$boinc_user) {
444
+      // Account exists with this email addr
445
+      form_set_error('email', bts('Error creating BOINC account.', array(), NULL, 'boinc:add-new-user'));
446
+      return;
447
+    }
448 448
 
449
-        // Add user to community role by default (not banned)
450
-        $unrestricted_role = array_search('community member', user_roles(true)); 
451
-        $edit['roles'] = array(
452
-          $unrestricted_role => ''
453
-        );
449
+    // Add user to community role by default (not banned)
450
+    $unrestricted_role = array_search('community member', user_roles(true)); 
451
+    $edit['roles'] = array(
452
+      $unrestricted_role => ''
453
+    );
454 454
 
455
-        // Disable show_hosts flag, set to TRUE by default
456
-        db_set_active('boinc_rw');
457
-        db_query("UPDATE {user} SET show_hosts=0 WHERE id='%d'", $boinc_user->id);
458
-        db_set_active('default');
455
+    // Disable show_hosts flag, set to TRUE by default
456
+    db_set_active('boinc_rw');
457
+    db_query("UPDATE {user} SET show_hosts=0 WHERE id='%d'", $boinc_user->id);
458
+    db_set_active('default');
459 459
 
460
-        // Cross reference Drupal account with BOINC
461
-        $reference = db_query("INSERT INTO {boincuser} SET uid='%d', boinc_id='%d'", $account->uid, $boinc_user->id);
462
-        if (!$reference) {
463
-          drupal_set_message(t('Error connecting BOINC account.'), 'error');
464
-          return;
465
-        }
460
+    // Cross reference Drupal account with BOINC
461
+    $reference = db_query("INSERT INTO {boincuser} SET uid='%d', boinc_id='%d'", $account->uid, $boinc_user->id);
462
+    if (!$reference) {
463
+      drupal_set_message(t('Error connecting BOINC account.'), 'error');
464
+      return;
465
+    }
466 466
 
467
-        // if terms of use exist, the user must agree.
468
-        $termsofuse = variable_get('boinc_weboptions_termsofuse', '');
469
-        if (!empty($termsofuse)) {
470
-          $reference2 = boincuser_consentto_termsofuse($account);
471
-        }
467
+    // if terms of use exist, the user must agree.
468
+    $termsofuse = variable_get('boinc_weboptions_termsofuse', '');
469
+    if (!empty($termsofuse)) {
470
+      $reference2 = boincuser_consentto_termsofuse($account);
471
+    }
472 472
 
473
-        // Don't save custom fields to the Drupal user object
474
-        $edit['boincuser_name'] = null;
475
-        $edit['boinchash_flag'] = null;
476
-      }
477
-      break;
473
+    // Don't save custom fields to the Drupal user object
474
+    $edit['boincuser_name'] = null;
475
+    $edit['boinchash_flag'] = null;
476
+  }
477
+  break;
478 478
       
479
-    case 'update':
480
-      if (isset($edit['update_source'])) {
481
-        require_boinc('boinc_db');
482
-        $boinc_user = BoincUser::lookup_id($account->boincuser_id);
483
-        switch ($edit['update_source']) {
484
-        case 'user_account':
485
-          // Ensure that BOINC data is altered
486
-
487
-          $changing_email = ($edit['mail'] AND $edit['mail'] != $boinc_user->email_addr) ? true : false;
488
-          $changing_pass = ($edit['pass']) ? true : false;
489
-          if ($changing_email OR $changing_pass) {
490
-            // Set password hash appropriately
491
-            $passwd = ($edit['pass']) ? $edit['pass'] : $edit['current_pass'];
492
-            $passwd_hash = password_hash( md5($passwd.$edit['mail']), PASSWORD_DEFAULT );
493
-            $email_addr = $edit['mail'];
494
-
495
-            // Algorithm for changing email and/or password
496
-            if ($changing_email) {
497
-              // locally store current email to set as previous email
498
-              $prev_email = $account->mail;
499
-              $mytime = (user_access('administer users')) ? $boinc_user->email_addr_change_time : time();
500
-              $querypart = "email_addr='{$email_addr}', passwd_hash='{$passwd_hash}', previous_email_addr = '{$prev_email}', email_addr_change_time = $mytime";
501
-            }
502
-            else {
503
-              $querypart = "email_addr='{$email_addr}', passwd_hash='{$passwd_hash}'";
504
-            }
505
-
506
-            // Update user account information
507
-            $result = $boinc_user->update($querypart);
508
-
509
-            if ($changing_email) {
510
-              // reload account
511
-              $account = user_load($account->uid);
512
-              _boincuser_send_emailchange($account, $email_addr, $prev_email, user_access('administer users'));
513
-            }
514
-          }
515
-
516
-          // Change boinc username
517
-          if ($edit['boincuser_name'] and ($edit['boincuser_name'] != $boinc_user->name)) {
518
-            $boincuser_name = $edit['boincuser_name'];
519
-            $result = $boinc_user->update(
520
-                "name='{$boincuser_name}'"
521
-            );
522
-          }
523
-
524
-          break;
525
-        case 'user_profile':
526
-          if ($edit['boincuser_name'] != $boinc_user->name) {
527
-            $boincuser_name = $edit['boincuser_name'];
528
-            $result = $boinc_user->update(
529
-                "name='{$boincuser_name}'"
530
-            );
531
-          }
532
-          break;
533
-        default:
534
-        }
479
+case 'update':
480
+  if (isset($edit['update_source'])) {
481
+    require_boinc('boinc_db');
482
+    $boinc_user = BoincUser::lookup_id($account->boincuser_id);
483
+    switch ($edit['update_source']) {
484
+    case 'user_account':
485
+    // Ensure that BOINC data is altered
486
+
487
+    $changing_email = ($edit['mail'] AND $edit['mail'] != $boinc_user->email_addr) ? true : false;
488
+    $changing_pass = ($edit['pass']) ? true : false;
489
+    if ($changing_email OR $changing_pass) {
490
+    // Set password hash appropriately
491
+    $passwd = ($edit['pass']) ? $edit['pass'] : $edit['current_pass'];
492
+    $passwd_hash = password_hash( md5($passwd.$edit['mail']), PASSWORD_DEFAULT );
493
+    $email_addr = $edit['mail'];
494
+
495
+    // Algorithm for changing email and/or password
496
+    if ($changing_email) {
497
+    // locally store current email to set as previous email
498
+    $prev_email = $account->mail;
499
+    $mytime = (user_access('administer users')) ? $boinc_user->email_addr_change_time : time();
500
+    $querypart = "email_addr='{$email_addr}', passwd_hash='{$passwd_hash}', previous_email_addr = '{$prev_email}', email_addr_change_time = $mytime";
501
+    }
502
+    else {
503
+    $querypart = "email_addr='{$email_addr}', passwd_hash='{$passwd_hash}'";
504
+    }
505
+
506
+    // Update user account information
507
+    $result = $boinc_user->update($querypart);
508
+
509
+    if ($changing_email) {
510
+    // reload account
511
+    $account = user_load($account->uid);
512
+    _boincuser_send_emailchange($account, $email_addr, $prev_email, user_access('administer users'));
513
+    }
514
+    }
515
+
516
+    // Change boinc username
517
+    if ($edit['boincuser_name'] and ($edit['boincuser_name'] != $boinc_user->name)) {
518
+    $boincuser_name = $edit['boincuser_name'];
519
+    $result = $boinc_user->update(
520
+    "name='{$boincuser_name}'"
521
+    );
522
+    }
523
+
524
+    break;
525
+    case 'user_profile':
526
+    if ($edit['boincuser_name'] != $boinc_user->name) {
527
+    $boincuser_name = $edit['boincuser_name'];
528
+    $result = $boinc_user->update(
529
+    "name='{$boincuser_name}'"
530
+    );
531
+    }
532
+    break;
533
+    default:
534
+    }
535 535
         // We don't want to save update source or duplicate custom fields, so
536 536
         // remove them before continuing to core Drupal routines
537 537
         $edit['update_source'] = null;
@@ -539,17 +539,17 @@  discard block
 block discarded – undo
539 539
       }
540 540
       break;
541 541
 
542
-    case 'login':
543
-      // Function is forward compatible to Drupal 7
544
-      boincuser_user_login($edit, $account);
545
-      break;
542
+case 'login':
543
+  // Function is forward compatible to Drupal 7
544
+  boincuser_user_login($edit, $account);
545
+  break;
546 546
 
547
-    case 'delete':
548
-      // Function is forward compatible to Drupal 7
549
-      boincuser_user_delete($account);
550
-      break;
547
+case 'delete':
548
+  // Function is forward compatible to Drupal 7
549
+  boincuser_user_delete($account);
550
+  break;
551 551
 
552
-    default:
552
+default:
553 553
       
554 554
     }
555 555
   }
Please login to merge, or discard this patch.