@@ -94,64 +94,64 @@ discard block |
||
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 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.', 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 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.', 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); |
@@ -303,56 +303,56 @@ discard block |
||
303 | 303 | // create token with 1 day/24 hour expiration |
304 | 304 | $mytoken = create_token($account->boincuser_id, 'D', 24*60*60); |
305 | 305 | switch ($op) { |
306 | - case 'boincuser_delete_softdelete': |
|
307 | - $myurl = "${base_url}/user/{$account->uid}/odeleteconfirm/$mytoken"; |
|
308 | - break; |
|
309 | - case 'boincuser_delete_delete': |
|
310 | - $myurl = "${base_url}/user/{$account->uid}/deleteconfirm/$mytoken"; |
|
306 | + case 'boincuser_delete_softdelete': |
|
307 | + $myurl = "${base_url}/user/{$account->uid}/odeleteconfirm/$mytoken"; |
|
311 | 308 | break; |
312 | - } |
|
313 | - |
|
314 | - $mysubject = "Instructions for account deletion at {$site_name}"; |
|
315 | - $mymessage = '' |
|
316 | - . "{$account->boincuser_name},\n" |
|
317 | - . "\n" |
|
318 | - . "We have received a request to DELETE your user account at " |
|
319 | - . "${site_name}. Below in this email is a one-time token you must " |
|
320 | - . "use. Either click on the link or copy-and-paste the URL into your " |
|
321 | - . "browser address bar. Then you will be required to enter your password " |
|
322 | - . "again to confirm your identity.\n" |
|
323 | - . "\n" |
|
324 | - . "${myurl}\n" |
|
325 | - . "\n" |
|
326 | - . "This one-time token will expire in 24 hours. Afterwards you must " |
|
327 | - . "re-request deletion of your account in order to generate a new token.\n" |
|
328 | - . "\n" |
|
329 | - . "If you did not initiate this request, please login to the " |
|
330 | - . "${site_name} Web site (${site_url}) and " |
|
331 | - . "then contact the administrators.\n" |
|
332 | - . "\n" |
|
333 | - . "Thanks, \n" |
|
334 | - . "\n" |
|
335 | - . "{$site_name} support team"; |
|
336 | - |
|
337 | - // Create array for sending email to user to notify account is being |
|
338 | - // disabled/deleted. Then send email. |
|
339 | - $settings = array( |
|
340 | - 'from' => '', |
|
341 | - 'subject' => $mysubject, |
|
342 | - 'message' => $mymessage, |
|
343 | - ); |
|
344 | - rules_action_mail_to_user($account, $settings); |
|
345 | - |
|
346 | - drupal_set_message(bts("INFO: You have requested account deletion. Please check your email for further instructions.", array(), NULL, 'boinc:delete-user-account'),'info'); |
|
309 | +case 'boincuser_delete_delete': |
|
310 | + $myurl = "${base_url}/user/{$account->uid}/deleteconfirm/$mytoken"; |
|
311 | + break; |
|
312 | +} |
|
347 | 313 | |
348 | - $redirect = variable_get('boincuser_delete_redirect', '<front>'); |
|
349 | - // Redirect |
|
350 | - if (!empty($redirect)) { |
|
351 | - drupal_goto($redirect); |
|
352 | - } |
|
353 | - else { |
|
354 | - drupal_goto(); |
|
355 | - } |
|
314 | +$mysubject = "Instructions for account deletion at {$site_name}"; |
|
315 | +$mymessage = '' |
|
316 | +. "{$account->boincuser_name},\n" |
|
317 | +. "\n" |
|
318 | +. "We have received a request to DELETE your user account at " |
|
319 | +. "${site_name}. Below in this email is a one-time token you must " |
|
320 | +. "use. Either click on the link or copy-and-paste the URL into your " |
|
321 | +. "browser address bar. Then you will be required to enter your password " |
|
322 | +. "again to confirm your identity.\n" |
|
323 | +. "\n" |
|
324 | +. "${myurl}\n" |
|
325 | +. "\n" |
|
326 | +. "This one-time token will expire in 24 hours. Afterwards you must " |
|
327 | +. "re-request deletion of your account in order to generate a new token.\n" |
|
328 | +. "\n" |
|
329 | +. "If you did not initiate this request, please login to the " |
|
330 | +. "${site_name} Web site (${site_url}) and " |
|
331 | +. "then contact the administrators.\n" |
|
332 | +. "\n" |
|
333 | +. "Thanks, \n" |
|
334 | +. "\n" |
|
335 | +. "{$site_name} support team"; |
|
336 | + |
|
337 | +// Create array for sending email to user to notify account is being |
|
338 | +// disabled/deleted. Then send email. |
|
339 | +$settings = array( |
|
340 | +'from' => '', |
|
341 | +'subject' => $mysubject, |
|
342 | +'message' => $mymessage, |
|
343 | +); |
|
344 | +rules_action_mail_to_user($account, $settings); |
|
345 | + |
|
346 | +drupal_set_message(bts("INFO: You have requested account deletion. Please check your email for further instructions.", array(), NULL, 'boinc:delete-user-account'),'info'); |
|
347 | + |
|
348 | +$redirect = variable_get('boincuser_delete_redirect', '<front>'); |
|
349 | +// Redirect |
|
350 | +if (!empty($redirect)) { |
|
351 | +drupal_goto($redirect); |
|
352 | +} |
|
353 | +else { |
|
354 | +drupal_goto(); |
|
355 | +} |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | |
@@ -364,77 +364,77 @@ discard block |
||
364 | 364 | * The final confirmation form for the user to delete their account. |
365 | 365 | */ |
366 | 366 | function boincuser_delete_finalconfirmation(&$form_state, $token) { |
367 | - require_boinc('token'); |
|
368 | - |
|
369 | - global $user; |
|
370 | - $form = array(); |
|
371 | - |
|
372 | - // check BOINC user exists |
|
373 | - $account = user_load(array('uid' => $user->uid)); |
|
374 | - $uid = $user->uid; |
|
375 | - $boincid = $account->boincuser_id; |
|
376 | - // check $token is valid |
|
377 | - if (!is_valid_token($boincid, $token, 'D')) { |
|
378 | - 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.', |
|
379 | - array( |
|
380 | - '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"), |
|
381 | - ), |
|
382 | - NULL, 'boinc:delete-user-account'), 'error'); |
|
383 | - drupal_goto(); |
|
384 | - } |
|
385 | - |
|
386 | - // Attach account to this form. |
|
387 | - $form['_account'] = array('#type' => 'value', '#value' => $account); |
|
388 | - |
|
389 | - // This form is for hard/wipe delete |
|
390 | - $form['_action'] = array('#type' => 'value', '#value' => 'hard_wipe'); |
|
391 | - |
|
392 | - // Instructions |
|
393 | - $form['main']['instructions1'] = array( |
|
394 | - '#value' => '<p>'. |
|
395 | - 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'). |
|
396 | - '</p>', |
|
397 | - ); |
|
398 | - |
|
399 | - $form['main']['instructions2'] = array( |
|
400 | - '#value' => '<p>'. |
|
401 | - bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account'). |
|
402 | - '</p>', |
|
403 | - ); |
|
404 | - |
|
405 | - // Password field |
|
406 | - $form['main']['current_pass'] = array( |
|
407 | - '#type' => 'password', |
|
408 | - '#title' => bts('Enter your password before clicking Submit', array(), NULL, 'boinc:delete-user-account'), |
|
409 | - '#size' => 17, |
|
410 | - '#attributes' => array( |
|
411 | - 'autocomplete' => 'off', |
|
412 | - ), |
|
413 | - '#weight' => 25, |
|
414 | - ); |
|
415 | - |
|
416 | - // Form control |
|
417 | - $form['form control tabs prefix'] = array( |
|
418 | - '#value' => '<ul class="form-control tab-list">', |
|
419 | - '#weight' => 1001, |
|
420 | - ); |
|
421 | - $form['submit'] = array( |
|
422 | - '#prefix' => '<li class="first tab">', |
|
423 | - '#type' => 'submit', |
|
424 | - '#value' => bts('Submit', array(), NULL, 'boinc:form-submit'), |
|
425 | - '#suffix' => '</li>', |
|
426 | - '#weight' => 1002, |
|
427 | - ); |
|
428 | - $form['form control tabs'] = array( |
|
429 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>', |
|
430 | - '#weight' => 1003, |
|
431 | - ); |
|
432 | - $form['form control tabs suffix'] = array( |
|
433 | - '#value' => '</ul>', |
|
434 | - '#weight' => 1004, |
|
435 | - ); |
|
367 | +require_boinc('token'); |
|
368 | + |
|
369 | +global $user; |
|
370 | +$form = array(); |
|
371 | + |
|
372 | +// check BOINC user exists |
|
373 | +$account = user_load(array('uid' => $user->uid)); |
|
374 | +$uid = $user->uid; |
|
375 | +$boincid = $account->boincuser_id; |
|
376 | +// check $token is valid |
|
377 | +if (!is_valid_token($boincid, $token, 'D')) { |
|
378 | +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.', |
|
379 | +array( |
|
380 | + '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"), |
|
381 | +), |
|
382 | +NULL, 'boinc:delete-user-account'), 'error'); |
|
383 | +drupal_goto(); |
|
384 | +} |
|
436 | 385 | |
437 | - return $form; |
|
386 | +// Attach account to this form. |
|
387 | +$form['_account'] = array('#type' => 'value', '#value' => $account); |
|
388 | + |
|
389 | +// This form is for hard/wipe delete |
|
390 | +$form['_action'] = array('#type' => 'value', '#value' => 'hard_wipe'); |
|
391 | + |
|
392 | +// Instructions |
|
393 | +$form['main']['instructions1'] = array( |
|
394 | +'#value' => '<p>'. |
|
395 | +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'). |
|
396 | +'</p>', |
|
397 | +); |
|
398 | + |
|
399 | +$form['main']['instructions2'] = array( |
|
400 | +'#value' => '<p>'. |
|
401 | +bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account'). |
|
402 | +'</p>', |
|
403 | +); |
|
404 | + |
|
405 | +// Password field |
|
406 | +$form['main']['current_pass'] = array( |
|
407 | +'#type' => 'password', |
|
408 | +'#title' => bts('Enter your password before clicking Submit', array(), NULL, 'boinc:delete-user-account'), |
|
409 | +'#size' => 17, |
|
410 | +'#attributes' => array( |
|
411 | + 'autocomplete' => 'off', |
|
412 | +), |
|
413 | +'#weight' => 25, |
|
414 | +); |
|
415 | + |
|
416 | +// Form control |
|
417 | +$form['form control tabs prefix'] = array( |
|
418 | +'#value' => '<ul class="form-control tab-list">', |
|
419 | +'#weight' => 1001, |
|
420 | +); |
|
421 | +$form['submit'] = array( |
|
422 | +'#prefix' => '<li class="first tab">', |
|
423 | +'#type' => 'submit', |
|
424 | +'#value' => bts('Submit', array(), NULL, 'boinc:form-submit'), |
|
425 | +'#suffix' => '</li>', |
|
426 | +'#weight' => 1002, |
|
427 | +); |
|
428 | +$form['form control tabs'] = array( |
|
429 | +'#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>', |
|
430 | +'#weight' => 1003, |
|
431 | +); |
|
432 | +$form['form control tabs suffix'] = array( |
|
433 | +'#value' => '</ul>', |
|
434 | +'#weight' => 1004, |
|
435 | +); |
|
436 | + |
|
437 | +return $form; |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | /** |
@@ -442,122 +442,122 @@ discard block |
||
442 | 442 | * the soft/obfuscate method. |
443 | 443 | */ |
444 | 444 | function boincuser_delete_softdelconfirmation(&$form_state, $token) { |
445 | - require_boinc('token'); |
|
446 | - |
|
447 | - global $user; |
|
448 | - $form = array(); |
|
449 | - |
|
450 | - // check BOINC user exists |
|
451 | - $account = user_load(array('uid' => $user->uid)); |
|
452 | - $uid = $user->uid; |
|
453 | - $boincid = $account->boincuser_id; |
|
454 | - |
|
455 | - // check $token is valid |
|
456 | - if (!is_valid_token($boincid, $token, 'D')) { |
|
457 | - 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.', |
|
458 | - array( |
|
459 | - '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"), |
|
460 | - ), |
|
461 | - NULL, 'boinc:delete-user-account'), 'error'); |
|
462 | - drupal_goto(); |
|
463 | - } |
|
464 | - |
|
465 | - // Attach account to this form. |
|
466 | - $form['_account'] = array('#type' => 'value', '#value' => $account); |
|
467 | - |
|
468 | - // This form is for hard/wipe delete |
|
469 | - $form['_action'] = array('#type' => 'value', '#value' => 'soft_obfuscate'); |
|
470 | - |
|
471 | - // Instructions |
|
472 | - $form['main']['instructions1'] = array( |
|
473 | - '#value' => '<p>'. |
|
474 | - 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'). |
|
475 | - '</p>', |
|
476 | - ); |
|
477 | - |
|
478 | - $form['main']['instructions2'] = array( |
|
479 | - '#value' => '<p>'. |
|
480 | - bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account'). |
|
481 | - '</p>', |
|
482 | - ); |
|
483 | - |
|
484 | - // Password field |
|
485 | - $form['main']['current_pass'] = array( |
|
486 | - '#type' => 'password', |
|
487 | - '#title' => bts('Enter your password before clicking Submit', array(), NULL, 'boinc:delete-user-account'), |
|
488 | - '#size' => 17, |
|
489 | - '#attributes' => array( |
|
490 | - 'autocomplete' => 'off', |
|
491 | - ), |
|
492 | - '#weight' => 25, |
|
493 | - ); |
|
494 | - |
|
495 | - // Form control |
|
496 | - $form['form control tabs prefix'] = array( |
|
497 | - '#value' => '<ul class="form-control tab-list">', |
|
498 | - '#weight' => 1001, |
|
499 | - ); |
|
500 | - $form['submit'] = array( |
|
501 | - '#prefix' => '<li class="first tab">', |
|
502 | - '#type' => 'submit', |
|
503 | - '#value' => bts('Submit', array(), NULL, 'boinc:form-submit'), |
|
504 | - '#suffix' => '</li>', |
|
505 | - '#weight' => 1002, |
|
506 | - ); |
|
507 | - $form['form control tabs'] = array( |
|
508 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>', |
|
509 | - '#weight' => 1003, |
|
510 | - ); |
|
511 | - $form['form control tabs suffix'] = array( |
|
512 | - '#value' => '</ul>', |
|
513 | - '#weight' => 1004, |
|
514 | - ); |
|
445 | +require_boinc('token'); |
|
446 | + |
|
447 | +global $user; |
|
448 | +$form = array(); |
|
449 | + |
|
450 | +// check BOINC user exists |
|
451 | +$account = user_load(array('uid' => $user->uid)); |
|
452 | +$uid = $user->uid; |
|
453 | +$boincid = $account->boincuser_id; |
|
454 | + |
|
455 | +// check $token is valid |
|
456 | +if (!is_valid_token($boincid, $token, 'D')) { |
|
457 | +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.', |
|
458 | +array( |
|
459 | + '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"), |
|
460 | +), |
|
461 | +NULL, 'boinc:delete-user-account'), 'error'); |
|
462 | +drupal_goto(); |
|
463 | +} |
|
515 | 464 | |
516 | - //set validation and submit to the functions below |
|
517 | - $form['#validate'][] = 'boincuser_delete_finalconfirmation_validate'; |
|
518 | - $form['#submit'][] = 'boincuser_delete_finalconfirmation_submit'; |
|
519 | - return $form; |
|
465 | +// Attach account to this form. |
|
466 | +$form['_account'] = array('#type' => 'value', '#value' => $account); |
|
467 | + |
|
468 | +// This form is for hard/wipe delete |
|
469 | +$form['_action'] = array('#type' => 'value', '#value' => 'soft_obfuscate'); |
|
470 | + |
|
471 | +// Instructions |
|
472 | +$form['main']['instructions1'] = array( |
|
473 | +'#value' => '<p>'. |
|
474 | +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'). |
|
475 | +'</p>', |
|
476 | +); |
|
477 | + |
|
478 | +$form['main']['instructions2'] = array( |
|
479 | +'#value' => '<p>'. |
|
480 | +bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account'). |
|
481 | +'</p>', |
|
482 | +); |
|
483 | + |
|
484 | +// Password field |
|
485 | +$form['main']['current_pass'] = array( |
|
486 | +'#type' => 'password', |
|
487 | +'#title' => bts('Enter your password before clicking Submit', array(), NULL, 'boinc:delete-user-account'), |
|
488 | +'#size' => 17, |
|
489 | +'#attributes' => array( |
|
490 | + 'autocomplete' => 'off', |
|
491 | +), |
|
492 | +'#weight' => 25, |
|
493 | +); |
|
494 | + |
|
495 | +// Form control |
|
496 | +$form['form control tabs prefix'] = array( |
|
497 | +'#value' => '<ul class="form-control tab-list">', |
|
498 | +'#weight' => 1001, |
|
499 | +); |
|
500 | +$form['submit'] = array( |
|
501 | +'#prefix' => '<li class="first tab">', |
|
502 | +'#type' => 'submit', |
|
503 | +'#value' => bts('Submit', array(), NULL, 'boinc:form-submit'), |
|
504 | +'#suffix' => '</li>', |
|
505 | +'#weight' => 1002, |
|
506 | +); |
|
507 | +$form['form control tabs'] = array( |
|
508 | +'#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>', |
|
509 | +'#weight' => 1003, |
|
510 | +); |
|
511 | +$form['form control tabs suffix'] = array( |
|
512 | +'#value' => '</ul>', |
|
513 | +'#weight' => 1004, |
|
514 | +); |
|
515 | + |
|
516 | +//set validation and submit to the functions below |
|
517 | +$form['#validate'][] = 'boincuser_delete_finalconfirmation_validate'; |
|
518 | +$form['#submit'][] = 'boincuser_delete_finalconfirmation_submit'; |
|
519 | +return $form; |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | /** |
523 | 523 | * Validation for final confirmation |
524 | 524 | */ |
525 | 525 | function boincuser_delete_finalconfirmation_validate($form, &$form_state) { |
526 | - $account = $form_state['values']['_account']; |
|
527 | - $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
526 | +$account = $form_state['values']['_account']; |
|
527 | +$boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
528 | 528 | |
529 | - if (_boincuser_delete_validatepasswd($boinc_user, $form_state['values']['current_pass'])) { |
|
530 | - return true; |
|
531 | - } |
|
529 | +if (_boincuser_delete_validatepasswd($boinc_user, $form_state['values']['current_pass'])) { |
|
530 | +return true; |
|
531 | +} |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | /** |
535 | 535 | * Submit for final confirmation |
536 | 536 | */ |
537 | 537 | function boincuser_delete_finalconfirmation_submit($form, &$form_state) { |
538 | - global $user; |
|
539 | - |
|
540 | - // Delete the user |
|
541 | - $account = $form_state['values']['_account']; |
|
542 | - $action = $form_state['values']['_action']; |
|
543 | - _boincuser_delete_deleteuser($account, $action); |
|
544 | - |
|
545 | - // Destroy the current session: |
|
546 | - session_destroy(); |
|
547 | - // Only variables can be passed by reference workaround. |
|
548 | - $null = NULL; |
|
549 | - user_module_invoke('logout', $null, $user); |
|
550 | - |
|
551 | - // Load the anonymous user |
|
552 | - $user = drupal_anonymous_user(); |
|
553 | - |
|
554 | - $redirect = variable_get('boincuser_delete_redirect', '<front>'); |
|
555 | - // Redirect |
|
556 | - if (!empty($redirect)) { |
|
557 | - drupal_goto($redirect); |
|
558 | - } |
|
559 | - else { |
|
560 | - drupal_goto(); |
|
561 | - } |
|
538 | +global $user; |
|
539 | + |
|
540 | +// Delete the user |
|
541 | +$account = $form_state['values']['_account']; |
|
542 | +$action = $form_state['values']['_action']; |
|
543 | +_boincuser_delete_deleteuser($account, $action); |
|
544 | + |
|
545 | +// Destroy the current session: |
|
546 | +session_destroy(); |
|
547 | +// Only variables can be passed by reference workaround. |
|
548 | +$null = NULL; |
|
549 | +user_module_invoke('logout', $null, $user); |
|
550 | + |
|
551 | +// Load the anonymous user |
|
552 | +$user = drupal_anonymous_user(); |
|
553 | + |
|
554 | +$redirect = variable_get('boincuser_delete_redirect', '<front>'); |
|
555 | +// Redirect |
|
556 | +if (!empty($redirect)) { |
|
557 | +drupal_goto($redirect); |
|
558 | +} |
|
559 | +else { |
|
560 | +drupal_goto(); |
|
561 | +} |
|
562 | 562 | |
563 | 563 | } |
@@ -9,28 +9,28 @@ discard block |
||
9 | 9 | * Helper functions |
10 | 10 | */ |
11 | 11 | function _boincuser_delete_goto_admindelete($form, &$form_state) { |
12 | - drupal_goto('/admin/boinc/user_delete/' . $form['#uid']); |
|
12 | +drupal_goto('/admin/boinc/user_delete/' . $form['#uid']); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | function _boincuser_delete_cancel($form, &$form_state) { |
16 | - drupal_goto('/user/' . $form['#uid'] . '/edit'); |
|
16 | +drupal_goto('/user/' . $form['#uid'] . '/edit'); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Validation user password function. |
21 | 21 | */ |
22 | 22 | function _boincuser_delete_validatepasswd($boinc_user, $current_pass) { |
23 | - if (!$current_pass) { |
|
24 | - return form_set_error('current_pass', bts('Authentication is required when requesting account deletion.', array(), NULL, 'boinc:delete-user-account')); |
|
25 | - } |
|
23 | +if (!$current_pass) { |
|
24 | +return form_set_error('current_pass', bts('Authentication is required when requesting account deletion.', array(), NULL, 'boinc:delete-user-account')); |
|
25 | +} |
|
26 | 26 | |
27 | - $given_hash = md5($current_pass . $boinc_user->email_addr); |
|
27 | +$given_hash = md5($current_pass . $boinc_user->email_addr); |
|
28 | 28 | |
29 | - if ( (!password_verify($given_hash, $boinc_user->passwd_hash)) and ($given_hash != $boinc_user->passwd_hash) ) { |
|
30 | - return form_set_error('current_pass', bts('Password entered is not valid. Please verify that it is correct.', array(), NULL, 'boinc:delete-user-account')); |
|
31 | - } |
|
29 | +if ( (!password_verify($given_hash, $boinc_user->passwd_hash)) and ($given_hash != $boinc_user->passwd_hash) ) { |
|
30 | +return form_set_error('current_pass', bts('Password entered is not valid. Please verify that it is correct.', array(), NULL, 'boinc:delete-user-account')); |
|
31 | +} |
|
32 | 32 | |
33 | - return true; |
|
33 | +return true; |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -41,52 +41,52 @@ discard block |
||
41 | 41 | * Delete the user function. |
42 | 42 | */ |
43 | 43 | function _boincuser_delete_deleteuser($account, $action=NULL) { |
44 | - require_boinc('user_util'); |
|
45 | - require_boinc('delete_account'); |
|
46 | - |
|
47 | - $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
48 | - |
|
49 | - // watchdog message |
|
50 | - watchdog('boincuser_delete', 'Deleting account drupal UID: %uid, BOINC id: %boincuser_id., BOINC displayname: %displayname', |
|
51 | - array( |
|
52 | - '%uid' => $account->uid, |
|
53 | - '%boincuser_id' => $account->boincuser_id, |
|
54 | - '%displayname' => $account->boincuser_name, |
|
55 | - ), WATCHDOG_NOTICE); |
|
56 | - |
|
57 | - // delete the account - This will delete the boinc user from the |
|
58 | - // boinc project database, and then delete the Drupal user using the |
|
59 | - // hook_user() functions. |
|
60 | - |
|
61 | - switch ($action) { |
|
62 | - case 'soft_obfuscate': |
|
63 | - obfuscate_account($boinc_user); |
|
64 | - _boincuser_delete_comment_reassign($account); |
|
65 | - _boincuser_delete_node_reassign($account); |
|
66 | - _boincuser_delete_privatemsg_delete($account); |
|
67 | - _boincuser_delete_friends($account); |
|
68 | - // delete the user's profile |
|
69 | - $profile = content_profile_load('profile', $account->uid); |
|
70 | - node_delete($profile->$nid); |
|
71 | - // Drupal account - |
|
72 | - // * 'block'/disable the account |
|
73 | - // * set name, mail, pass, and init to deleted |
|
74 | - // * erase signature |
|
75 | - $myarray = array( |
|
76 | - 'status' => 0, |
|
77 | - 'name' => 'deleted_' . time() . '_' . random_string(), |
|
78 | - 'mail' => 'deleted_' . time() . '_' . random_string(), |
|
79 | - 'pass' => 'deleted_' . time() . '_' . random_string(), |
|
80 | - 'signature' => '', |
|
81 | - 'init' => 'deleted_' . time() . '_' . random_string(), |
|
82 | - ); |
|
83 | - user_save($account, $myarray); |
|
84 | - break; |
|
85 | - case 'hard_wipe': |
|
86 | - wipe_account($boinc_user); |
|
87 | - user_delete(array(), $account->uid); |
|
88 | - break; |
|
89 | - } |
|
44 | +require_boinc('user_util'); |
|
45 | +require_boinc('delete_account'); |
|
46 | + |
|
47 | +$boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
48 | + |
|
49 | +// watchdog message |
|
50 | +watchdog('boincuser_delete', 'Deleting account drupal UID: %uid, BOINC id: %boincuser_id., BOINC displayname: %displayname', |
|
51 | +array( |
|
52 | +'%uid' => $account->uid, |
|
53 | +'%boincuser_id' => $account->boincuser_id, |
|
54 | +'%displayname' => $account->boincuser_name, |
|
55 | +), WATCHDOG_NOTICE); |
|
56 | + |
|
57 | +// delete the account - This will delete the boinc user from the |
|
58 | +// boinc project database, and then delete the Drupal user using the |
|
59 | +// hook_user() functions. |
|
60 | + |
|
61 | +switch ($action) { |
|
62 | +case 'soft_obfuscate': |
|
63 | +obfuscate_account($boinc_user); |
|
64 | +_boincuser_delete_comment_reassign($account); |
|
65 | +_boincuser_delete_node_reassign($account); |
|
66 | +_boincuser_delete_privatemsg_delete($account); |
|
67 | +_boincuser_delete_friends($account); |
|
68 | +// delete the user's profile |
|
69 | +$profile = content_profile_load('profile', $account->uid); |
|
70 | +node_delete($profile->$nid); |
|
71 | +// Drupal account - |
|
72 | +// * 'block'/disable the account |
|
73 | +// * set name, mail, pass, and init to deleted |
|
74 | +// * erase signature |
|
75 | +$myarray = array( |
|
76 | +'status' => 0, |
|
77 | +'name' => 'deleted_' . time() . '_' . random_string(), |
|
78 | +'mail' => 'deleted_' . time() . '_' . random_string(), |
|
79 | +'pass' => 'deleted_' . time() . '_' . random_string(), |
|
80 | +'signature' => '', |
|
81 | +'init' => 'deleted_' . time() . '_' . random_string(), |
|
82 | +); |
|
83 | +user_save($account, $myarray); |
|
84 | +break; |
|
85 | +case 'hard_wipe': |
|
86 | +wipe_account($boinc_user); |
|
87 | +user_delete(array(), $account->uid); |
|
88 | +break; |
|
89 | +} |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |