@@ -18,15 +18,15 @@ discard block |
||
18 | 18 | */ |
19 | 19 | function boinc_solr_search_block($op = 'list', $delta = 0, $edit = array()) { |
20 | 20 | switch ($op) { |
21 | - case 'list': |
|
22 | - return boinc_solr_search_block_info(); |
|
23 | - break; |
|
24 | - case 'view': |
|
25 | - return boinc_solr_search_block_view($delta); |
|
26 | - break; |
|
27 | - case 'configure': |
|
28 | - case 'save': |
|
29 | - default: |
|
21 | + case 'list': |
|
22 | + return boinc_solr_search_block_info(); |
|
23 | + break; |
|
24 | + case 'view': |
|
25 | + return boinc_solr_search_block_view($delta); |
|
26 | + break; |
|
27 | + case 'configure': |
|
28 | + case 'save': |
|
29 | + default: |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 | |
@@ -53,26 +53,26 @@ discard block |
||
53 | 53 | function boinc_solr_search_block_view($delta = 0) { |
54 | 54 | $block = array(); |
55 | 55 | switch($delta) { |
56 | - case 'boinc_solr_search_0': |
|
57 | - $items = array( |
|
58 | - bts('By default a search matches ANY search term. Results with more than one term will be presented higher in the search results.', array(), NULL, 'boinc:search-help-sidebar-block'), |
|
59 | - bts('You may use \'AND\' to have the search engine return results with ALL search terms.', array(), NULL, 'boinc:search-help-sidebar-block'), |
|
60 | - bts('For example, searching for \'boinc AND client\' will only contain results with words boinc and client.', array(), NULL, 'boinc:search-help-sidebar-block') |
|
61 | - ); |
|
56 | + case 'boinc_solr_search_0': |
|
57 | + $items = array( |
|
58 | + bts('By default a search matches ANY search term. Results with more than one term will be presented higher in the search results.', array(), NULL, 'boinc:search-help-sidebar-block'), |
|
59 | + bts('You may use \'AND\' to have the search engine return results with ALL search terms.', array(), NULL, 'boinc:search-help-sidebar-block'), |
|
60 | + bts('For example, searching for \'boinc AND client\' will only contain results with words boinc and client.', array(), NULL, 'boinc:search-help-sidebar-block') |
|
61 | + ); |
|
62 | 62 | |
63 | - drupal_add_js('misc/collapse.js'); |
|
64 | - // For Drupal 7 the format of the array changes, see https://api.drupal.org/api/drupal/includes%21form.inc/function/theme_fieldset/7.x for details. |
|
65 | - $collapsible_item = array( |
|
66 | - '#title' => bts('Search Help', array(), NULL, 'boinc:search-help-sidebar-block'), |
|
67 | - '#description' => theme_item_list($items), |
|
68 | - '#collapsible' => TRUE, |
|
69 | - '#collapsed' => TRUE, |
|
70 | - '#attributes' => array( |
|
71 | - 'class' => 'search-help-block', |
|
72 | - ), |
|
73 | - ); |
|
74 | - $block['content'] = theme('fieldset', $collapsible_item); |
|
75 | - break; |
|
63 | + drupal_add_js('misc/collapse.js'); |
|
64 | + // For Drupal 7 the format of the array changes, see https://api.drupal.org/api/drupal/includes%21form.inc/function/theme_fieldset/7.x for details. |
|
65 | + $collapsible_item = array( |
|
66 | + '#title' => bts('Search Help', array(), NULL, 'boinc:search-help-sidebar-block'), |
|
67 | + '#description' => theme_item_list($items), |
|
68 | + '#collapsible' => TRUE, |
|
69 | + '#collapsed' => TRUE, |
|
70 | + '#attributes' => array( |
|
71 | + 'class' => 'search-help-block', |
|
72 | + ), |
|
73 | + ); |
|
74 | + $block['content'] = theme('fieldset', $collapsible_item); |
|
75 | + break; |
|
76 | 76 | } |
77 | 77 | return $block; |
78 | 78 | } |
@@ -50,47 +50,47 @@ discard block |
||
50 | 50 | } |
51 | 51 | $resultLength = 0; |
52 | 52 | switch ($algo) { |
53 | - case PASSWORD_BCRYPT: |
|
54 | - $cost = PASSWORD_BCRYPT_DEFAULT_COST; |
|
55 | - if (isset($options['cost'])) { |
|
56 | - $cost = (int) $options['cost']; |
|
57 | - if ($cost < 4 || $cost > 31) { |
|
58 | - trigger_error(sprintf("password_hash(): Invalid bcrypt cost parameter specified: %d", $cost), E_USER_WARNING); |
|
59 | - return null; |
|
60 | - } |
|
53 | + case PASSWORD_BCRYPT: |
|
54 | + $cost = PASSWORD_BCRYPT_DEFAULT_COST; |
|
55 | + if (isset($options['cost'])) { |
|
56 | + $cost = (int) $options['cost']; |
|
57 | + if ($cost < 4 || $cost > 31) { |
|
58 | + trigger_error(sprintf("password_hash(): Invalid bcrypt cost parameter specified: %d", $cost), E_USER_WARNING); |
|
59 | + return null; |
|
61 | 60 | } |
62 | - // The length of salt to generate |
|
63 | - $raw_salt_len = 16; |
|
64 | - // The length required in the final serialization |
|
65 | - $required_salt_len = 22; |
|
66 | - $hash_format = sprintf("$2y$%02d$", $cost); |
|
67 | - // The expected length of the final crypt() output |
|
68 | - $resultLength = 60; |
|
69 | - break; |
|
70 | - default: |
|
71 | - trigger_error(sprintf("password_hash(): Unknown password hashing algorithm: %s", $algo), E_USER_WARNING); |
|
72 | - return null; |
|
61 | + } |
|
62 | + // The length of salt to generate |
|
63 | + $raw_salt_len = 16; |
|
64 | + // The length required in the final serialization |
|
65 | + $required_salt_len = 22; |
|
66 | + $hash_format = sprintf("$2y$%02d$", $cost); |
|
67 | + // The expected length of the final crypt() output |
|
68 | + $resultLength = 60; |
|
69 | + break; |
|
70 | + default: |
|
71 | + trigger_error(sprintf("password_hash(): Unknown password hashing algorithm: %s", $algo), E_USER_WARNING); |
|
72 | + return null; |
|
73 | 73 | } |
74 | 74 | $salt_req_encoding = false; |
75 | 75 | if (isset($options['salt'])) { |
76 | 76 | switch (gettype($options['salt'])) { |
77 | - case 'NULL': |
|
78 | - case 'boolean': |
|
79 | - case 'integer': |
|
80 | - case 'double': |
|
81 | - case 'string': |
|
77 | + case 'NULL': |
|
78 | + case 'boolean': |
|
79 | + case 'integer': |
|
80 | + case 'double': |
|
81 | + case 'string': |
|
82 | + $salt = (string) $options['salt']; |
|
83 | + break; |
|
84 | + case 'object': |
|
85 | + if (method_exists($options['salt'], '__tostring')) { |
|
82 | 86 | $salt = (string) $options['salt']; |
83 | 87 | break; |
84 | - case 'object': |
|
85 | - if (method_exists($options['salt'], '__tostring')) { |
|
86 | - $salt = (string) $options['salt']; |
|
87 | - break; |
|
88 | - } |
|
89 | - case 'array': |
|
90 | - case 'resource': |
|
91 | - default: |
|
92 | - trigger_error('password_hash(): Non-string salt parameter supplied', E_USER_WARNING); |
|
93 | - return null; |
|
88 | + } |
|
89 | + case 'array': |
|
90 | + case 'resource': |
|
91 | + default: |
|
92 | + trigger_error('password_hash(): Non-string salt parameter supplied', E_USER_WARNING); |
|
93 | + return null; |
|
94 | 94 | } |
95 | 95 | if (PasswordCompat\binary\_strlen($salt) < $required_salt_len) { |
96 | 96 | trigger_error(sprintf("password_hash(): Provided salt is too short: %d expecting %d", PasswordCompat\binary\_strlen($salt), $required_salt_len), E_USER_WARNING); |
@@ -212,12 +212,12 @@ discard block |
||
212 | 212 | return true; |
213 | 213 | } |
214 | 214 | switch ($algo) { |
215 | - case PASSWORD_BCRYPT: |
|
216 | - $cost = isset($options['cost']) ? (int) $options['cost'] : PASSWORD_BCRYPT_DEFAULT_COST; |
|
217 | - if ($cost !== $info['options']['cost']) { |
|
218 | - return true; |
|
219 | - } |
|
220 | - break; |
|
215 | + case PASSWORD_BCRYPT: |
|
216 | + $cost = isset($options['cost']) ? (int) $options['cost'] : PASSWORD_BCRYPT_DEFAULT_COST; |
|
217 | + if ($cost !== $info['options']['cost']) { |
|
218 | + return true; |
|
219 | + } |
|
220 | + break; |
|
221 | 221 | } |
222 | 222 | return false; |
223 | 223 | } |
@@ -13,45 +13,45 @@ discard block |
||
13 | 13 | * a form array |
14 | 14 | */ |
15 | 15 | function boincuser_delete_settings() { |
16 | - $form = array(); |
|
17 | - |
|
18 | - $default = array( |
|
19 | - 'boincuser_delete_type' => variable_get('boincuser_delete_type', ''), |
|
20 | - 'boincuser_delete_redirect' => variable_get('boincuser_delete_redirect', '<front>'), |
|
21 | - ); |
|
22 | - |
|
23 | - $form['options'] = array( |
|
24 | - '#type' => 'fieldset', |
|
25 | - '#title' => t('Options'), |
|
26 | - ); |
|
27 | - $form['options']['help'] = array( |
|
28 | - '#value' => t('When a user deletes their account, which option is shown to the user? A soft/obfusate delete, a hard/wipe delete, or let the user chose between the two.'), |
|
29 | - '#weight' => 11, |
|
30 | - ); |
|
31 | - $form['options']['boincuser_delete_type'] = array( |
|
32 | - '#type' => 'radios', |
|
33 | - '#title' => t('Type of delete'), |
|
34 | - '#default_value' => $default['boincuser_delete_type'], |
|
35 | - '#options' => array( |
|
36 | - 'soft_obfuscate' => t('A soft/obfuscate delete. User\'s account is disabled, but some data is deleted.'), |
|
37 | - 'hard_wipe' => t('A hard/wipe delete. User\'s account is deleted along with many data.'), |
|
38 | - 'user_decides' => t('User is presented with radio buttons where they choose between the two options above.'), |
|
39 | - ), |
|
40 | - '#weight' => 21, |
|
41 | - ); |
|
42 | - |
|
43 | - $form['redirect'] = array( |
|
44 | - '#type' => 'fieldset', |
|
45 | - '#title' => t('Redirect'), |
|
46 | - ); |
|
47 | - $form['redirect']['boincuser_delete_redirect'] = array( |
|
48 | - '#type' => 'textfield', |
|
49 | - '#title' => t('Redirection page'), |
|
50 | - '#default_value' => $default['boincuser_delete_redirect'], |
|
51 | - '#description' => t('Choose where to redirect your users after account deletion. Any valid Drupal path will do, e.g. %front or %node', array('%front' => '<front>', '%node' => 'node/1')), |
|
52 | - ); |
|
53 | - |
|
54 | - return system_settings_form($form); |
|
16 | +$form = array(); |
|
17 | + |
|
18 | +$default = array( |
|
19 | +'boincuser_delete_type' => variable_get('boincuser_delete_type', ''), |
|
20 | +'boincuser_delete_redirect' => variable_get('boincuser_delete_redirect', '<front>'), |
|
21 | +); |
|
22 | + |
|
23 | +$form['options'] = array( |
|
24 | +'#type' => 'fieldset', |
|
25 | +'#title' => t('Options'), |
|
26 | +); |
|
27 | +$form['options']['help'] = array( |
|
28 | +'#value' => t('When a user deletes their account, which option is shown to the user? A soft/obfusate delete, a hard/wipe delete, or let the user chose between the two.'), |
|
29 | +'#weight' => 11, |
|
30 | +); |
|
31 | +$form['options']['boincuser_delete_type'] = array( |
|
32 | +'#type' => 'radios', |
|
33 | +'#title' => t('Type of delete'), |
|
34 | +'#default_value' => $default['boincuser_delete_type'], |
|
35 | +'#options' => array( |
|
36 | + 'soft_obfuscate' => t('A soft/obfuscate delete. User\'s account is disabled, but some data is deleted.'), |
|
37 | + 'hard_wipe' => t('A hard/wipe delete. User\'s account is deleted along with many data.'), |
|
38 | + 'user_decides' => t('User is presented with radio buttons where they choose between the two options above.'), |
|
39 | +), |
|
40 | +'#weight' => 21, |
|
41 | +); |
|
42 | + |
|
43 | +$form['redirect'] = array( |
|
44 | +'#type' => 'fieldset', |
|
45 | +'#title' => t('Redirect'), |
|
46 | +); |
|
47 | +$form['redirect']['boincuser_delete_redirect'] = array( |
|
48 | +'#type' => 'textfield', |
|
49 | +'#title' => t('Redirection page'), |
|
50 | +'#default_value' => $default['boincuser_delete_redirect'], |
|
51 | +'#description' => t('Choose where to redirect your users after account deletion. Any valid Drupal path will do, e.g. %front or %node', array('%front' => '<front>', '%node' => 'node/1')), |
|
52 | +); |
|
53 | + |
|
54 | +return system_settings_form($form); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
@@ -60,124 +60,124 @@ discard block |
||
60 | 60 | * password checks. |
61 | 61 | */ |
62 | 62 | function boincuser_delete_admindelete(&$form_state, $uid) { |
63 | - $form = array(); |
|
64 | - |
|
65 | - $form['#uid'] = $uid; |
|
66 | - |
|
67 | - $form['account']['help'] = array( |
|
68 | - '#value' => "<p>" . t("This form will delete this user <strong>without any email notification</strong> sent to the user. Be very careful in deleting users using this form. Once you select the delete type, check the checkbox, enter your password, and click submit, the user's account will be deleted. This will occur <strong>immediately</strong>. There is no 'undo'!") . "</p><p>" . t("You are deleting the following user, link opens in new window:") . "</p>", |
|
69 | - '#weight' => -1, |
|
70 | - '#prefix' => "<div id='delete-instructions'>", |
|
71 | - '#suffix' => "</div>", |
|
63 | +$form = array(); |
|
64 | + |
|
65 | +$form['#uid'] = $uid; |
|
66 | + |
|
67 | +$form['account']['help'] = array( |
|
68 | +'#value' => "<p>" . t("This form will delete this user <strong>without any email notification</strong> sent to the user. Be very careful in deleting users using this form. Once you select the delete type, check the checkbox, enter your password, and click submit, the user's account will be deleted. This will occur <strong>immediately</strong>. There is no 'undo'!") . "</p><p>" . t("You are deleting the following user, link opens in new window:") . "</p>", |
|
69 | +'#weight' => -1, |
|
70 | +'#prefix' => "<div id='delete-instructions'>", |
|
71 | +'#suffix' => "</div>", |
|
72 | +); |
|
73 | + |
|
74 | +$account = user_load($uid); |
|
75 | +if ($account) { |
|
76 | +drupal_set_title($account->boincuser_name); |
|
77 | + |
|
78 | +$form['account']['boincuser_name'] = array( |
|
79 | + '#value' => t('<li>BOINC username (public displayname): ') . l("{$account->boincuser_name}", "account/{$account->uid}", array('attributes' => array('target' => '_blank'))), |
|
80 | +); |
|
81 | +$form['account']['boincuser_id'] = array( |
|
82 | + '#value' => t('<li>BOINC user ID: ') . $account->boincuser_id, |
|
83 | +); |
|
84 | +$form['account']['drupal_name'] = array( |
|
85 | + '#value' => t('<li>Drupal username (internal): ') . $account->name, |
|
86 | +); |
|
87 | +$form['account']['user_id'] = array( |
|
88 | + '#value' => t('<li>Drupal user ID: ') . $account->uid, |
|
89 | +); |
|
90 | + |
|
91 | +$form['account']['user_delete_action'] = array( |
|
92 | + '#type' => 'radios', |
|
93 | + '#options' => array( |
|
94 | + 'soft_obfuscate' => bts('<b>Soft delete</b> the account. The account will be disabled, and all posts/comments will be attributed to the Anonymous User. The user profile will be deleted, the host information deleted, and the user will be removed from any team.', array(), NULL, 'boinc:delete-user-account'), |
|
95 | + 'hard_wipe' => bts('<b>Delete</b> the account. The account will be deleted, and all posts/comments will be attributed to the Anonymous User. The user profile will be deleted.', array(), NULL, 'boinc:delete-user-account'),), |
|
72 | 96 | ); |
73 | 97 | |
74 | - $account = user_load($uid); |
|
75 | - if ($account) { |
|
76 | - drupal_set_title($account->boincuser_name); |
|
77 | - |
|
78 | - $form['account']['boincuser_name'] = array( |
|
79 | - '#value' => t('<li>BOINC username (public displayname): ') . l("{$account->boincuser_name}", "account/{$account->uid}", array('attributes' => array('target' => '_blank'))), |
|
80 | - ); |
|
81 | - $form['account']['boincuser_id'] = array( |
|
82 | - '#value' => t('<li>BOINC user ID: ') . $account->boincuser_id, |
|
83 | - ); |
|
84 | - $form['account']['drupal_name'] = array( |
|
85 | - '#value' => t('<li>Drupal username (internal): ') . $account->name, |
|
86 | - ); |
|
87 | - $form['account']['user_id'] = array( |
|
88 | - '#value' => t('<li>Drupal user ID: ') . $account->uid, |
|
89 | - ); |
|
90 | - |
|
91 | - $form['account']['user_delete_action'] = array( |
|
92 | - '#type' => 'radios', |
|
93 | - '#options' => array( |
|
94 | - 'soft_obfuscate' => bts('<b>Soft delete</b> the account. The account will be disabled, and all posts/comments will be attributed to the Anonymous User. The user profile will be deleted, the host information deleted, and the user will be removed from any team.', array(), NULL, 'boinc:delete-user-account'), |
|
95 | - 'hard_wipe' => bts('<b>Delete</b> the account. The account will be deleted, and all posts/comments will be attributed to the Anonymous User. The user profile will be deleted.', array(), NULL, 'boinc:delete-user-account'),), |
|
96 | - ); |
|
97 | - |
|
98 | - $form['account']['surecheckbox'] = array( |
|
99 | - '#type' => 'checkbox', |
|
100 | - '#title' => t('I am <strong>sure</strong> I know what I am doing. I am <u><strong>deleting user</strong></u> %name.', |
|
101 | - array('%name' => $account->boincuser_name) |
|
102 | - ), |
|
103 | - '#default_value' => FALSE, |
|
104 | - ); |
|
105 | - |
|
106 | - $form['account']['current_pass'] = array( |
|
107 | - '#type' => 'password', |
|
108 | - '#title' => bts('Enter your password before clicking Submit, or click Cancel to return to the user\'s edit page', array(), NULL, 'boinc:delete-user-account'), |
|
109 | - '#size' => 17, |
|
110 | - '#attributes' => array( |
|
111 | - 'autocomplete' => 'off', |
|
112 | - ), |
|
113 | - '#weight' => 25, |
|
114 | - ); |
|
115 | - |
|
116 | - // Action buttons |
|
117 | - $form['actions']['submit'] = array( |
|
118 | - '#type' => 'submit', |
|
119 | - '#value' => t('Submit'), |
|
120 | - ); |
|
121 | - $form['actions']['cancel'] = array( |
|
122 | - '#type' => 'button', |
|
123 | - '#value' => t('Cancel'), |
|
124 | - '#executes_submit_callback' => TRUE, |
|
125 | - '#validate' => array(), |
|
126 | - '#submit' => array('_boincuser_delete_cancel'), |
|
127 | - ); |
|
128 | - |
|
129 | - $form['#redirect'] = 'account'; |
|
130 | - } |
|
131 | - else { |
|
132 | - $form['noaccount'] = array( |
|
133 | - '#value' => t('No such user with UID: %uid', array('%uid' => $uid)), |
|
134 | - ); |
|
135 | - } |
|
136 | - |
|
137 | - return $form; |
|
98 | +$form['account']['surecheckbox'] = array( |
|
99 | + '#type' => 'checkbox', |
|
100 | + '#title' => t('I am <strong>sure</strong> I know what I am doing. I am <u><strong>deleting user</strong></u> %name.', |
|
101 | + array('%name' => $account->boincuser_name) |
|
102 | + ), |
|
103 | + '#default_value' => FALSE, |
|
104 | +); |
|
105 | + |
|
106 | +$form['account']['current_pass'] = array( |
|
107 | + '#type' => 'password', |
|
108 | + '#title' => bts('Enter your password before clicking Submit, or click Cancel to return to the user\'s edit page', array(), NULL, 'boinc:delete-user-account'), |
|
109 | + '#size' => 17, |
|
110 | + '#attributes' => array( |
|
111 | + 'autocomplete' => 'off', |
|
112 | + ), |
|
113 | + '#weight' => 25, |
|
114 | +); |
|
115 | + |
|
116 | +// Action buttons |
|
117 | +$form['actions']['submit'] = array( |
|
118 | + '#type' => 'submit', |
|
119 | + '#value' => t('Submit'), |
|
120 | +); |
|
121 | +$form['actions']['cancel'] = array( |
|
122 | + '#type' => 'button', |
|
123 | + '#value' => t('Cancel'), |
|
124 | + '#executes_submit_callback' => TRUE, |
|
125 | + '#validate' => array(), |
|
126 | + '#submit' => array('_boincuser_delete_cancel'), |
|
127 | +); |
|
128 | + |
|
129 | +$form['#redirect'] = 'account'; |
|
130 | +} |
|
131 | +else { |
|
132 | +$form['noaccount'] = array( |
|
133 | + '#value' => t('No such user with UID: %uid', array('%uid' => $uid)), |
|
134 | +); |
|
135 | +} |
|
136 | + |
|
137 | +return $form; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
141 | 141 | * Validation function for admin delete user. |
142 | 142 | */ |
143 | 143 | function boincuser_delete_admindelete_validate($form, &$form_state) { |
144 | - global $user; |
|
145 | - $boinc_user = boincuser_load($user->uid, TRUE); |
|
144 | +global $user; |
|
145 | +$boinc_user = boincuser_load($user->uid, TRUE); |
|
146 | 146 | |
147 | - if ($form_state['values']['user_delete_action'] == '') { |
|
148 | - form_set_error('user_delete_action', t('Please select an action to perform using the radio buttons.')); |
|
149 | - } |
|
147 | +if ($form_state['values']['user_delete_action'] == '') { |
|
148 | +form_set_error('user_delete_action', t('Please select an action to perform using the radio buttons.')); |
|
149 | +} |
|
150 | 150 | |
151 | - if ( ($form_state['values']['user_delete_action'] != 'soft_obfuscate') and ($form_state['values']['user_delete_action'] != 'hard_wipe') ) { |
|
152 | - form_set_error('user_delete_action', t('User Delete action not a predefined value, unknown error in radio buttons.')); |
|
153 | - } |
|
151 | +if ( ($form_state['values']['user_delete_action'] != 'soft_obfuscate') and ($form_state['values']['user_delete_action'] != 'hard_wipe') ) { |
|
152 | +form_set_error('user_delete_action', t('User Delete action not a predefined value, unknown error in radio buttons.')); |
|
153 | +} |
|
154 | 154 | |
155 | - if (!($form_state['values']['surecheckbox'])) { |
|
156 | - return form_set_error('surecheckbox', t('Please confirm you are sure you want to delete this account.')); |
|
157 | - } |
|
155 | +if (!($form_state['values']['surecheckbox'])) { |
|
156 | +return form_set_error('surecheckbox', t('Please confirm you are sure you want to delete this account.')); |
|
157 | +} |
|
158 | 158 | |
159 | - if (_boincuser_delete_validatepasswd($boinc_user, $form_state['values']['current_pass'])) { |
|
160 | - return true; |
|
161 | - } |
|
159 | +if (_boincuser_delete_validatepasswd($boinc_user, $form_state['values']['current_pass'])) { |
|
160 | +return true; |
|
161 | +} |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
165 | 165 | * Submit function for admin delete user. |
166 | 166 | */ |
167 | 167 | function boincuser_delete_admindelete_submit($form, &$form_state) { |
168 | - // This is the account to be deleted, and not the administrator's |
|
169 | - // account. |
|
170 | - $account = user_load(array('uid' => $form['#uid'])); |
|
171 | - $action = $form_state['values']['user_delete_action']; |
|
168 | +// This is the account to be deleted, and not the administrator's |
|
169 | +// account. |
|
170 | +$account = user_load(array('uid' => $form['#uid'])); |
|
171 | +$action = $form_state['values']['user_delete_action']; |
|
172 | 172 | |
173 | - drupal_set_message(t('WARNING: Account @displayname, Drupal UID=@uid has been deleted.', |
|
174 | - array( |
|
175 | - '@uid' => $form['#uid'], |
|
176 | - '@displayname' => $account->boincuser_name, |
|
177 | - )), 'warning'); |
|
173 | +drupal_set_message(t('WARNING: Account @displayname, Drupal UID=@uid has been deleted.', |
|
174 | +array( |
|
175 | + '@uid' => $form['#uid'], |
|
176 | + '@displayname' => $account->boincuser_name, |
|
177 | +)), 'warning'); |
|
178 | 178 | |
179 | - // Delete the user |
|
180 | - _boincuser_delete_deleteuser($account, $action); |
|
179 | +// Delete the user |
|
180 | +_boincuser_delete_deleteuser($account, $action); |
|
181 | 181 | |
182 | - drupal_goto('/admin/boinc/user_delete'); |
|
182 | +drupal_goto('/admin/boinc/user_delete'); |
|
183 | 183 | } |
@@ -59,37 +59,37 @@ |
||
59 | 59 | // hook_user() functions. |
60 | 60 | |
61 | 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 | - default: |
|
90 | - watchdog('boincuser_delete', 'Delete action is %action, which is not \'soft_obfuscate\' or \'hard_wipe\'.', array( |
|
91 | - '%action' => $action, |
|
92 | - ), WATCHDOG_ERROR); |
|
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 | + default: |
|
90 | + watchdog('boincuser_delete', 'Delete action is %action, which is not \'soft_obfuscate\' or \'hard_wipe\'.', array( |
|
91 | + '%action' => $action, |
|
92 | + ), WATCHDOG_ERROR); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 |
@@ -94,69 +94,69 @@ 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 | - $common_acts = bts("All your posts and comments will be attributed to the Anonymous User. Your user profile will be deleted. Your host information will be deleted. And you will be removed from any team you are a member of.", array(), NULL, 'boinc:delete-user-account'); |
|
140 | - |
|
141 | - $deleteoptions = array( |
|
142 | - 'boincuser_delete_softdelete' => bts('<b>Soft delete</b> your account. Your account will be disabled. ', array(), NULL, 'boinc:delete-user-account'), |
|
143 | - 'boincuser_delete_delete' => bts('<b>Delete</b> your account. ', 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>', |
|
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>', |
|
144 | 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 | + $common_acts = bts("All your posts and comments will be attributed to the Anonymous User. Your user profile will be deleted. Your host information will be deleted. And you will be removed from any team you are a member of.", array(), NULL, 'boinc:delete-user-account'); |
|
140 | + |
|
141 | + $deleteoptions = array( |
|
142 | + 'boincuser_delete_softdelete' => bts('<b>Soft delete</b> your account. Your account will be disabled. ', array(), NULL, 'boinc:delete-user-account'), |
|
143 | + 'boincuser_delete_delete' => bts('<b>Delete</b> your account. ', array(), NULL, 'boinc:delete-user-account'), |
|
144 | + ); |
|
145 | 145 | |
146 | - $dtypes = variable_get('boincuser_delete_type', 'user_decides'); |
|
147 | - // Unset the other option if dtype is set. i.e., if dtype is set |
|
148 | - // to soft delete, unset the hard delete option. Likewise, add |
|
149 | - // the 'common_acts' sentences to the option that remains. |
|
150 | - switch ($dtypes) { |
|
151 | - case 'soft_obfuscate': |
|
152 | - unset($deleteoptions['boincuser_delete_delete']); |
|
153 | - $deleteoptions['boincuser_delete_softdelete'] .= $common_acts; |
|
154 | - break; |
|
155 | - case 'hard_wipe': |
|
156 | - unset($deleteoptions['boincuser_delete_softdelete']); |
|
157 | - $deleteoptions['boincuser_delete_delete'] .= $common_acts; |
|
158 | - break; |
|
159 | - } |
|
146 | + $dtypes = variable_get('boincuser_delete_type', 'user_decides'); |
|
147 | + // Unset the other option if dtype is set. i.e., if dtype is set |
|
148 | + // to soft delete, unset the hard delete option. Likewise, add |
|
149 | + // the 'common_acts' sentences to the option that remains. |
|
150 | + switch ($dtypes) { |
|
151 | + case 'soft_obfuscate': |
|
152 | + unset($deleteoptions['boincuser_delete_delete']); |
|
153 | + $deleteoptions['boincuser_delete_softdelete'] .= $common_acts; |
|
154 | + break; |
|
155 | + case 'hard_wipe': |
|
156 | + unset($deleteoptions['boincuser_delete_softdelete']); |
|
157 | + $deleteoptions['boincuser_delete_delete'] .= $common_acts; |
|
158 | + break; |
|
159 | + } |
|
160 | 160 | |
161 | 161 | $question = 'Are you sure you want to delete the account <em>' . htmlspecialchars($form['_account']['#value']->boincuser_name) . '</em>?'; |
162 | 162 | drupal_set_title($question); |
@@ -324,56 +324,56 @@ discard block |
||
324 | 324 | // create token with 1 day/24 hour expiration |
325 | 325 | $mytoken = create_token($account->boincuser_id, 'D', 24*60*60); |
326 | 326 | switch ($op) { |
327 | - case 'boincuser_delete_softdelete': |
|
328 | - $myurl = "${base_url}/user/{$account->uid}/odeleteconfirm/$mytoken"; |
|
327 | + case 'boincuser_delete_softdelete': |
|
328 | + $myurl = "${base_url}/user/{$account->uid}/odeleteconfirm/$mytoken"; |
|
329 | 329 | break; |
330 | - case 'boincuser_delete_delete': |
|
331 | - $myurl = "${base_url}/user/{$account->uid}/deleteconfirm/$mytoken"; |
|
332 | - break; |
|
333 | - } |
|
334 | - |
|
335 | - $mysubject = "Instructions for account deletion at {$site_name}"; |
|
336 | - $mymessage = '' |
|
337 | - . "{$account->boincuser_name},\n" |
|
338 | - . "\n" |
|
339 | - . "We have received a request to DELETE your user account at " |
|
340 | - . "${site_name}. Below in this email is a one-time token you must " |
|
341 | - . "use. Either click on the link or copy-and-paste the URL into your " |
|
342 | - . "browser address bar. Then you will be required to enter your password " |
|
343 | - . "again to confirm your identity.\n" |
|
344 | - . "\n" |
|
345 | - . "${myurl}\n" |
|
346 | - . "\n" |
|
347 | - . "This one-time token will expire in 24 hours. Afterwards you must " |
|
348 | - . "re-request deletion of your account in order to generate a new token.\n" |
|
349 | - . "\n" |
|
350 | - . "If you did not initiate this request, please login to the " |
|
351 | - . "${site_name} Web site (${site_url}) and " |
|
352 | - . "then contact the administrators.\n" |
|
353 | - . "\n" |
|
354 | - . "Thanks, \n" |
|
355 | - . "\n" |
|
356 | - . "{$site_name} support team"; |
|
357 | - |
|
358 | - // Create array for sending email to user to notify account is being |
|
359 | - // disabled/deleted. Then send email. |
|
360 | - $settings = array( |
|
361 | - 'from' => '', |
|
362 | - 'subject' => $mysubject, |
|
363 | - 'message' => $mymessage, |
|
364 | - ); |
|
365 | - rules_action_mail_to_user($account, $settings); |
|
366 | - |
|
367 | - drupal_set_message(bts("INFO: You have requested account deletion. Please check your email for further instructions.", array(), NULL, 'boinc:delete-user-account'),'info'); |
|
330 | +case 'boincuser_delete_delete': |
|
331 | + $myurl = "${base_url}/user/{$account->uid}/deleteconfirm/$mytoken"; |
|
332 | + break; |
|
333 | +} |
|
368 | 334 | |
369 | - $redirect = variable_get('boincuser_delete_redirect', '<front>'); |
|
370 | - // Redirect |
|
371 | - if (!empty($redirect)) { |
|
372 | - drupal_goto($redirect); |
|
373 | - } |
|
374 | - else { |
|
375 | - drupal_goto(); |
|
376 | - } |
|
335 | +$mysubject = "Instructions for account deletion at {$site_name}"; |
|
336 | +$mymessage = '' |
|
337 | +. "{$account->boincuser_name},\n" |
|
338 | +. "\n" |
|
339 | +. "We have received a request to DELETE your user account at " |
|
340 | +. "${site_name}. Below in this email is a one-time token you must " |
|
341 | +. "use. Either click on the link or copy-and-paste the URL into your " |
|
342 | +. "browser address bar. Then you will be required to enter your password " |
|
343 | +. "again to confirm your identity.\n" |
|
344 | +. "\n" |
|
345 | +. "${myurl}\n" |
|
346 | +. "\n" |
|
347 | +. "This one-time token will expire in 24 hours. Afterwards you must " |
|
348 | +. "re-request deletion of your account in order to generate a new token.\n" |
|
349 | +. "\n" |
|
350 | +. "If you did not initiate this request, please login to the " |
|
351 | +. "${site_name} Web site (${site_url}) and " |
|
352 | +. "then contact the administrators.\n" |
|
353 | +. "\n" |
|
354 | +. "Thanks, \n" |
|
355 | +. "\n" |
|
356 | +. "{$site_name} support team"; |
|
357 | + |
|
358 | +// Create array for sending email to user to notify account is being |
|
359 | +// disabled/deleted. Then send email. |
|
360 | +$settings = array( |
|
361 | +'from' => '', |
|
362 | +'subject' => $mysubject, |
|
363 | +'message' => $mymessage, |
|
364 | +); |
|
365 | +rules_action_mail_to_user($account, $settings); |
|
366 | + |
|
367 | +drupal_set_message(bts("INFO: You have requested account deletion. Please check your email for further instructions.", array(), NULL, 'boinc:delete-user-account'),'info'); |
|
368 | + |
|
369 | +$redirect = variable_get('boincuser_delete_redirect', '<front>'); |
|
370 | +// Redirect |
|
371 | +if (!empty($redirect)) { |
|
372 | +drupal_goto($redirect); |
|
373 | +} |
|
374 | +else { |
|
375 | +drupal_goto(); |
|
376 | +} |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | |
@@ -385,88 +385,88 @@ discard block |
||
385 | 385 | * The final confirmation form for the user to delete their account. |
386 | 386 | */ |
387 | 387 | function boincuser_delete_finalconfirmation(&$form_state, $token) { |
388 | - require_boinc('token'); |
|
389 | - |
|
390 | - global $user; |
|
391 | - $form = array(); |
|
392 | - |
|
393 | - // check BOINC user exists |
|
394 | - $account = user_load(array('uid' => $user->uid)); |
|
395 | - $uid = $user->uid; |
|
396 | - $boincid = $account->boincuser_id; |
|
397 | - // check $token is valid |
|
398 | - if (!is_valid_token($boincid, $token, 'D')) { |
|
399 | - drupal_set_message(bts('ERROR: You have supplied an incorrect (most likely expired) token. Please obtain a new token by !link your account be deleted.', |
|
400 | - array( |
|
401 | - '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"), |
|
402 | - ), |
|
403 | - NULL, 'boinc:delete-user-account'), 'error'); |
|
404 | - drupal_goto(); |
|
405 | - } |
|
406 | - |
|
407 | - // Attach account to this form. |
|
408 | - $form['_account'] = array('#type' => 'value', '#value' => $account); |
|
409 | - |
|
410 | - // This form is for hard/wipe delete |
|
411 | - $form['_action'] = array('#type' => 'value', '#value' => 'hard_wipe'); |
|
412 | - |
|
413 | - // Instructions |
|
414 | - $form['main']['fs1'] = array( |
|
415 | - '#type' => 'fieldset', |
|
416 | - '#title' => bts('Instructions', array(), NULL, 'boinc:delete-user-account'), |
|
417 | - '#weight' => 10, |
|
418 | - '#collapsible' => TRUE, |
|
419 | - '#collapsed' => TRUE, |
|
420 | - ); |
|
421 | - $form['main']['fs1']['instructions1'] = array( |
|
422 | - '#value' => '<p>'. |
|
423 | - bts('You are one-step away from deleting your account. Enter your password in the textbox below and click submit. This action is irreversable: once you delete your account, there is no way un-delete.', array(), NULL, 'boinc:delete-user-account'). |
|
424 | - '</p>', |
|
425 | - '#prefix' => "<div id='delete-instructions'>", |
|
426 | - '#suffix' => "</div>", |
|
427 | - ); |
|
428 | - |
|
429 | - $form['main']['fs1']['instructions2'] = array( |
|
430 | - '#value' => '<p>'. |
|
431 | - bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account'). |
|
432 | - '</p>', |
|
433 | - '#prefix' => "<div id='delete-instructions'>", |
|
434 | - '#suffix' => "</div>", |
|
435 | - ); |
|
436 | - |
|
437 | - // Password field |
|
438 | - $form['main']['current_pass'] = array( |
|
439 | - '#type' => 'password', |
|
440 | - '#title' => bts('Enter your password to delete your account', array(), NULL, 'boinc:delete-user-account'), |
|
441 | - '#size' => 17, |
|
442 | - '#attributes' => array( |
|
443 | - 'autocomplete' => 'off', |
|
444 | - ), |
|
445 | - '#weight' => 25, |
|
446 | - ); |
|
447 | - |
|
448 | - // Form control |
|
449 | - $form['form control tabs prefix'] = array( |
|
450 | - '#value' => '<ul class="form-control tab-list">', |
|
451 | - '#weight' => 1001, |
|
452 | - ); |
|
453 | - $form['submit'] = array( |
|
454 | - '#prefix' => '<li class="first tab">', |
|
455 | - '#type' => 'submit', |
|
456 | - '#value' => bts('Submit', array(), NULL, 'boinc:form-submit'), |
|
457 | - '#suffix' => '</li>', |
|
458 | - '#weight' => 1002, |
|
459 | - ); |
|
460 | - $form['form control tabs'] = array( |
|
461 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>', |
|
462 | - '#weight' => 1003, |
|
463 | - ); |
|
464 | - $form['form control tabs suffix'] = array( |
|
465 | - '#value' => '</ul>', |
|
466 | - '#weight' => 1004, |
|
467 | - ); |
|
388 | +require_boinc('token'); |
|
389 | + |
|
390 | +global $user; |
|
391 | +$form = array(); |
|
392 | + |
|
393 | +// check BOINC user exists |
|
394 | +$account = user_load(array('uid' => $user->uid)); |
|
395 | +$uid = $user->uid; |
|
396 | +$boincid = $account->boincuser_id; |
|
397 | +// check $token is valid |
|
398 | +if (!is_valid_token($boincid, $token, 'D')) { |
|
399 | +drupal_set_message(bts('ERROR: You have supplied an incorrect (most likely expired) token. Please obtain a new token by !link your account be deleted.', |
|
400 | +array( |
|
401 | + '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"), |
|
402 | +), |
|
403 | +NULL, 'boinc:delete-user-account'), 'error'); |
|
404 | +drupal_goto(); |
|
405 | +} |
|
468 | 406 | |
469 | - return $form; |
|
407 | +// Attach account to this form. |
|
408 | +$form['_account'] = array('#type' => 'value', '#value' => $account); |
|
409 | + |
|
410 | +// This form is for hard/wipe delete |
|
411 | +$form['_action'] = array('#type' => 'value', '#value' => 'hard_wipe'); |
|
412 | + |
|
413 | +// Instructions |
|
414 | +$form['main']['fs1'] = array( |
|
415 | +'#type' => 'fieldset', |
|
416 | +'#title' => bts('Instructions', array(), NULL, 'boinc:delete-user-account'), |
|
417 | +'#weight' => 10, |
|
418 | +'#collapsible' => TRUE, |
|
419 | +'#collapsed' => TRUE, |
|
420 | +); |
|
421 | +$form['main']['fs1']['instructions1'] = array( |
|
422 | +'#value' => '<p>'. |
|
423 | +bts('You are one-step away from deleting your account. Enter your password in the textbox below and click submit. This action is irreversable: once you delete your account, there is no way un-delete.', array(), NULL, 'boinc:delete-user-account'). |
|
424 | +'</p>', |
|
425 | +'#prefix' => "<div id='delete-instructions'>", |
|
426 | +'#suffix' => "</div>", |
|
427 | +); |
|
428 | + |
|
429 | +$form['main']['fs1']['instructions2'] = array( |
|
430 | +'#value' => '<p>'. |
|
431 | +bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account'). |
|
432 | +'</p>', |
|
433 | +'#prefix' => "<div id='delete-instructions'>", |
|
434 | +'#suffix' => "</div>", |
|
435 | +); |
|
436 | + |
|
437 | +// Password field |
|
438 | +$form['main']['current_pass'] = array( |
|
439 | +'#type' => 'password', |
|
440 | +'#title' => bts('Enter your password to delete your account', array(), NULL, 'boinc:delete-user-account'), |
|
441 | +'#size' => 17, |
|
442 | +'#attributes' => array( |
|
443 | + 'autocomplete' => 'off', |
|
444 | +), |
|
445 | +'#weight' => 25, |
|
446 | +); |
|
447 | + |
|
448 | +// Form control |
|
449 | +$form['form control tabs prefix'] = array( |
|
450 | +'#value' => '<ul class="form-control tab-list">', |
|
451 | +'#weight' => 1001, |
|
452 | +); |
|
453 | +$form['submit'] = array( |
|
454 | +'#prefix' => '<li class="first tab">', |
|
455 | +'#type' => 'submit', |
|
456 | +'#value' => bts('Submit', array(), NULL, 'boinc:form-submit'), |
|
457 | +'#suffix' => '</li>', |
|
458 | +'#weight' => 1002, |
|
459 | +); |
|
460 | +$form['form control tabs'] = array( |
|
461 | +'#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>', |
|
462 | +'#weight' => 1003, |
|
463 | +); |
|
464 | +$form['form control tabs suffix'] = array( |
|
465 | +'#value' => '</ul>', |
|
466 | +'#weight' => 1004, |
|
467 | +); |
|
468 | + |
|
469 | +return $form; |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | /** |
@@ -474,133 +474,133 @@ discard block |
||
474 | 474 | * the soft/obfuscate method. |
475 | 475 | */ |
476 | 476 | function boincuser_delete_softdelconfirmation(&$form_state, $token) { |
477 | - require_boinc('token'); |
|
478 | - |
|
479 | - global $user; |
|
480 | - $form = array(); |
|
481 | - |
|
482 | - // check BOINC user exists |
|
483 | - $account = user_load(array('uid' => $user->uid)); |
|
484 | - $uid = $user->uid; |
|
485 | - $boincid = $account->boincuser_id; |
|
486 | - |
|
487 | - // check $token is valid |
|
488 | - if (!is_valid_token($boincid, $token, 'D')) { |
|
489 | - drupal_set_message(bts('ERROR: You have supplied an incorrect (most likely expired) token. Please obtain a new token by !link your account be deleted.', |
|
490 | - array( |
|
491 | - '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"), |
|
492 | - ), |
|
493 | - NULL, 'boinc:delete-user-account'), 'error'); |
|
494 | - drupal_goto(); |
|
495 | - } |
|
496 | - |
|
497 | - // Attach account to this form. |
|
498 | - $form['_account'] = array('#type' => 'value', '#value' => $account); |
|
499 | - |
|
500 | - // This form is for hard/wipe delete |
|
501 | - $form['_action'] = array('#type' => 'value', '#value' => 'soft_obfuscate'); |
|
502 | - |
|
503 | - // Instructions |
|
504 | - $form['main']['fs1'] = array( |
|
505 | - '#type' => 'fieldset', |
|
506 | - '#title' => bts('Instructions', array(), NULL, 'boinc:delete-user-account'), |
|
507 | - '#weight' => 10, |
|
508 | - '#collapsible' => TRUE, |
|
509 | - '#collapsed' => TRUE, |
|
510 | - ); |
|
511 | - $form['main']['fs1']['instructions1'] = array( |
|
512 | - '#value' => '<p>'. |
|
513 | - bts('You are one-step away from deleting your account. Enter your password in the textbox below and click submit. This action is irreversable: once you delete your account, there is no way un-delete.', array(), NULL, 'boinc:delete-user-account'). |
|
514 | - '</p>', |
|
515 | - '#prefix' => "<div id='delete-instructions'>", |
|
516 | - '#suffix' => "</div>", |
|
517 | - ); |
|
518 | - |
|
519 | - $form['main']['fs1']['instructions2'] = array( |
|
520 | - '#value' => '<p>'. |
|
521 | - bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account'). |
|
522 | - '</p>', |
|
523 | - '#prefix' => "<div id='delete-instructions'>", |
|
524 | - '#suffix' => "</div>", |
|
525 | - ); |
|
526 | - |
|
527 | - // Password field |
|
528 | - $form['main']['current_pass'] = array( |
|
529 | - '#type' => 'password', |
|
530 | - '#title' => bts('Enter your password to delete your account', array(), NULL, 'boinc:delete-user-account'), |
|
531 | - '#size' => 17, |
|
532 | - '#attributes' => array( |
|
533 | - 'autocomplete' => 'off', |
|
534 | - ), |
|
535 | - '#weight' => 25, |
|
536 | - ); |
|
537 | - |
|
538 | - // Form control |
|
539 | - $form['form control tabs prefix'] = array( |
|
540 | - '#value' => '<ul class="form-control tab-list">', |
|
541 | - '#weight' => 1001, |
|
542 | - ); |
|
543 | - $form['submit'] = array( |
|
544 | - '#prefix' => '<li class="first tab">', |
|
545 | - '#type' => 'submit', |
|
546 | - '#value' => bts('Submit', array(), NULL, 'boinc:form-submit'), |
|
547 | - '#suffix' => '</li>', |
|
548 | - '#weight' => 1002, |
|
549 | - ); |
|
550 | - $form['form control tabs'] = array( |
|
551 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>', |
|
552 | - '#weight' => 1003, |
|
553 | - ); |
|
554 | - $form['form control tabs suffix'] = array( |
|
555 | - '#value' => '</ul>', |
|
556 | - '#weight' => 1004, |
|
557 | - ); |
|
477 | +require_boinc('token'); |
|
478 | + |
|
479 | +global $user; |
|
480 | +$form = array(); |
|
481 | + |
|
482 | +// check BOINC user exists |
|
483 | +$account = user_load(array('uid' => $user->uid)); |
|
484 | +$uid = $user->uid; |
|
485 | +$boincid = $account->boincuser_id; |
|
486 | + |
|
487 | +// check $token is valid |
|
488 | +if (!is_valid_token($boincid, $token, 'D')) { |
|
489 | +drupal_set_message(bts('ERROR: You have supplied an incorrect (most likely expired) token. Please obtain a new token by !link your account be deleted.', |
|
490 | +array( |
|
491 | + '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"), |
|
492 | +), |
|
493 | +NULL, 'boinc:delete-user-account'), 'error'); |
|
494 | +drupal_goto(); |
|
495 | +} |
|
558 | 496 | |
559 | - //set validation and submit to the functions below |
|
560 | - $form['#validate'][] = 'boincuser_delete_finalconfirmation_validate'; |
|
561 | - $form['#submit'][] = 'boincuser_delete_finalconfirmation_submit'; |
|
562 | - return $form; |
|
497 | +// Attach account to this form. |
|
498 | +$form['_account'] = array('#type' => 'value', '#value' => $account); |
|
499 | + |
|
500 | +// This form is for hard/wipe delete |
|
501 | +$form['_action'] = array('#type' => 'value', '#value' => 'soft_obfuscate'); |
|
502 | + |
|
503 | +// Instructions |
|
504 | +$form['main']['fs1'] = array( |
|
505 | +'#type' => 'fieldset', |
|
506 | +'#title' => bts('Instructions', array(), NULL, 'boinc:delete-user-account'), |
|
507 | +'#weight' => 10, |
|
508 | +'#collapsible' => TRUE, |
|
509 | +'#collapsed' => TRUE, |
|
510 | +); |
|
511 | +$form['main']['fs1']['instructions1'] = array( |
|
512 | +'#value' => '<p>'. |
|
513 | +bts('You are one-step away from deleting your account. Enter your password in the textbox below and click submit. This action is irreversable: once you delete your account, there is no way un-delete.', array(), NULL, 'boinc:delete-user-account'). |
|
514 | +'</p>', |
|
515 | +'#prefix' => "<div id='delete-instructions'>", |
|
516 | +'#suffix' => "</div>", |
|
517 | +); |
|
518 | + |
|
519 | +$form['main']['fs1']['instructions2'] = array( |
|
520 | +'#value' => '<p>'. |
|
521 | +bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account'). |
|
522 | +'</p>', |
|
523 | +'#prefix' => "<div id='delete-instructions'>", |
|
524 | +'#suffix' => "</div>", |
|
525 | +); |
|
526 | + |
|
527 | +// Password field |
|
528 | +$form['main']['current_pass'] = array( |
|
529 | +'#type' => 'password', |
|
530 | +'#title' => bts('Enter your password to delete your account', array(), NULL, 'boinc:delete-user-account'), |
|
531 | +'#size' => 17, |
|
532 | +'#attributes' => array( |
|
533 | + 'autocomplete' => 'off', |
|
534 | +), |
|
535 | +'#weight' => 25, |
|
536 | +); |
|
537 | + |
|
538 | +// Form control |
|
539 | +$form['form control tabs prefix'] = array( |
|
540 | +'#value' => '<ul class="form-control tab-list">', |
|
541 | +'#weight' => 1001, |
|
542 | +); |
|
543 | +$form['submit'] = array( |
|
544 | +'#prefix' => '<li class="first tab">', |
|
545 | +'#type' => 'submit', |
|
546 | +'#value' => bts('Submit', array(), NULL, 'boinc:form-submit'), |
|
547 | +'#suffix' => '</li>', |
|
548 | +'#weight' => 1002, |
|
549 | +); |
|
550 | +$form['form control tabs'] = array( |
|
551 | +'#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>', |
|
552 | +'#weight' => 1003, |
|
553 | +); |
|
554 | +$form['form control tabs suffix'] = array( |
|
555 | +'#value' => '</ul>', |
|
556 | +'#weight' => 1004, |
|
557 | +); |
|
558 | + |
|
559 | +//set validation and submit to the functions below |
|
560 | +$form['#validate'][] = 'boincuser_delete_finalconfirmation_validate'; |
|
561 | +$form['#submit'][] = 'boincuser_delete_finalconfirmation_submit'; |
|
562 | +return $form; |
|
563 | 563 | } |
564 | 564 | |
565 | 565 | /** |
566 | 566 | * Validation for final confirmation |
567 | 567 | */ |
568 | 568 | function boincuser_delete_finalconfirmation_validate($form, &$form_state) { |
569 | - $account = $form_state['values']['_account']; |
|
570 | - $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
569 | +$account = $form_state['values']['_account']; |
|
570 | +$boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
571 | 571 | |
572 | - if (_boincuser_delete_validatepasswd($boinc_user, $form_state['values']['current_pass'])) { |
|
573 | - return true; |
|
574 | - } |
|
572 | +if (_boincuser_delete_validatepasswd($boinc_user, $form_state['values']['current_pass'])) { |
|
573 | +return true; |
|
574 | +} |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | /** |
578 | 578 | * Submit for final confirmation |
579 | 579 | */ |
580 | 580 | function boincuser_delete_finalconfirmation_submit($form, &$form_state) { |
581 | - global $user; |
|
582 | - |
|
583 | - // Delete the user |
|
584 | - $account = $form_state['values']['_account']; |
|
585 | - $action = $form_state['values']['_action']; |
|
586 | - _boincuser_delete_deleteuser($account, $action); |
|
587 | - |
|
588 | - // Destroy the current session: |
|
589 | - session_destroy(); |
|
590 | - // Only variables can be passed by reference workaround. |
|
591 | - $null = NULL; |
|
592 | - user_module_invoke('logout', $null, $user); |
|
593 | - |
|
594 | - // Load the anonymous user |
|
595 | - $user = drupal_anonymous_user(); |
|
596 | - |
|
597 | - $redirect = variable_get('boincuser_delete_redirect', '<front>'); |
|
598 | - // Redirect |
|
599 | - if (!empty($redirect)) { |
|
600 | - drupal_goto($redirect); |
|
601 | - } |
|
602 | - else { |
|
603 | - drupal_goto(); |
|
604 | - } |
|
581 | +global $user; |
|
582 | + |
|
583 | +// Delete the user |
|
584 | +$account = $form_state['values']['_account']; |
|
585 | +$action = $form_state['values']['_action']; |
|
586 | +_boincuser_delete_deleteuser($account, $action); |
|
587 | + |
|
588 | +// Destroy the current session: |
|
589 | +session_destroy(); |
|
590 | +// Only variables can be passed by reference workaround. |
|
591 | +$null = NULL; |
|
592 | +user_module_invoke('logout', $null, $user); |
|
593 | + |
|
594 | +// Load the anonymous user |
|
595 | +$user = drupal_anonymous_user(); |
|
596 | + |
|
597 | +$redirect = variable_get('boincuser_delete_redirect', '<front>'); |
|
598 | +// Redirect |
|
599 | +if (!empty($redirect)) { |
|
600 | +drupal_goto($redirect); |
|
601 | +} |
|
602 | +else { |
|
603 | +drupal_goto(); |
|
604 | +} |
|
605 | 605 | |
606 | 606 | } |
@@ -35,63 +35,63 @@ |
||
35 | 35 | start_table(); |
36 | 36 | |
37 | 37 | switch($table){ |
38 | - case "platform": |
|
39 | - break; |
|
40 | - case "app": |
|
41 | - break; |
|
42 | - case "app_version": |
|
43 | - print_detail_field(); |
|
44 | - print_query_field(); |
|
45 | - break; |
|
46 | - case "host": |
|
47 | - echo " |
|
38 | +case "platform": |
|
39 | + break; |
|
40 | +case "app": |
|
41 | + break; |
|
42 | +case "app_version": |
|
43 | + print_detail_field(); |
|
44 | + print_query_field(); |
|
45 | + break; |
|
46 | +case "host": |
|
47 | + echo " |
|
48 | 48 | <tr> |
49 | 49 | <td align=\"right\">Show Aggregate Information</td> |
50 | 50 | <td> |
51 | 51 | "; |
52 | - print_checkbox("", "show_aggregate", $show_aggregate); |
|
53 | - echo " |
|
52 | + print_checkbox("", "show_aggregate", $show_aggregate); |
|
53 | + echo " |
|
54 | 54 | </td> |
55 | 55 | </tr> |
56 | 56 | "; |
57 | - print_detail_field(); |
|
58 | - print_query_field(); |
|
59 | - break; |
|
60 | - case "workunit": |
|
61 | - print_detail_field(); |
|
62 | - print_query_field(); |
|
63 | - echo "<input type=\"hidden\" name=\"sort_by\" value=\"id\">\n"; |
|
64 | - break; |
|
65 | - case "result": |
|
66 | - echo "<tr><td align=\"right\">Server state</td><td> "; |
|
67 | - server_state_select(); |
|
68 | - echo "</td></tr>\n"; |
|
69 | - //print_text_field( "Batch number:", "batch", $batch ); |
|
70 | - echo "<tr><td align=\"right\">Outcome</td><td>"; |
|
71 | - outcome_select(); |
|
72 | - echo "</td></tr>\n"; |
|
73 | - echo "<tr><td align=\"right\">Client state</td><td>"; |
|
74 | - client_state_select(); |
|
75 | - echo "</td></tr>\n"; |
|
76 | - echo "<tr><td align=\"right\">Validate state</td><td>"; |
|
77 | - validate_state_select(); |
|
78 | - echo "</td></tr>\n"; |
|
79 | - echo "<tr><td align=\"right\">Sort by</td><td>"; |
|
80 | - result_sort_select(); |
|
81 | - sort_order_select(); |
|
82 | - echo "</td></tr>\n"; |
|
83 | - print_detail_field(); |
|
84 | - print_query_field(); |
|
85 | - break; |
|
86 | - case "team": |
|
87 | - print_query_field(); |
|
88 | - break; |
|
89 | - case "user": |
|
90 | - print_query_field(); |
|
91 | - break; |
|
92 | - default: |
|
93 | - echo "Unknown table name\n"; |
|
94 | - exit(); |
|
57 | + print_detail_field(); |
|
58 | + print_query_field(); |
|
59 | + break; |
|
60 | +case "workunit": |
|
61 | + print_detail_field(); |
|
62 | + print_query_field(); |
|
63 | + echo "<input type=\"hidden\" name=\"sort_by\" value=\"id\">\n"; |
|
64 | + break; |
|
65 | +case "result": |
|
66 | + echo "<tr><td align=\"right\">Server state</td><td> "; |
|
67 | + server_state_select(); |
|
68 | + echo "</td></tr>\n"; |
|
69 | + //print_text_field( "Batch number:", "batch", $batch ); |
|
70 | + echo "<tr><td align=\"right\">Outcome</td><td>"; |
|
71 | + outcome_select(); |
|
72 | + echo "</td></tr>\n"; |
|
73 | + echo "<tr><td align=\"right\">Client state</td><td>"; |
|
74 | + client_state_select(); |
|
75 | + echo "</td></tr>\n"; |
|
76 | + echo "<tr><td align=\"right\">Validate state</td><td>"; |
|
77 | + validate_state_select(); |
|
78 | + echo "</td></tr>\n"; |
|
79 | + echo "<tr><td align=\"right\">Sort by</td><td>"; |
|
80 | + result_sort_select(); |
|
81 | + sort_order_select(); |
|
82 | + echo "</td></tr>\n"; |
|
83 | + print_detail_field(); |
|
84 | + print_query_field(); |
|
85 | + break; |
|
86 | +case "team": |
|
87 | + print_query_field(); |
|
88 | + break; |
|
89 | +case "user": |
|
90 | + print_query_field(); |
|
91 | + break; |
|
92 | +default: |
|
93 | + echo "Unknown table name\n"; |
|
94 | + exit(); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | row2("Number of entries to show", "<input name=\"nresults\" value=\"20\">"); |
@@ -27,295 +27,295 @@ discard block |
||
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 arguments' => array('edit own profile content'), |
|
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 arguments' => array('edit own profile content'), |
|
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 | - ); |
|
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; |
|
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 | + |
|
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 | - // The site will not function correctly if these are not exempt! |
|
263 | - $paths0 = array( |
|
264 | - 'user/termsofuse', |
|
265 | - 'logout', |
|
266 | - 'account/info/edit', |
|
267 | - 'user/' . $user->uid . '/edit', |
|
268 | - 'user/' . $user->uid . '/recoveremail/*', |
|
269 | - 'recover_email.php', |
|
270 | - ); |
|
271 | - if (module_exists('boincuser_delete')) { |
|
272 | - $paths0[] = 'user/' . $user->uid . '/delete'; |
|
273 | - $paths0[] = 'user/' . $user->uid . '/deleteconfirm/*'; |
|
274 | - $paths0[] = 'user/' . $user->uid . '/odeleteconfirm/*'; |
|
275 | - } |
|
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 | + // The site will not function correctly if these are not exempt! |
|
263 | + $paths0 = array( |
|
264 | + 'user/termsofuse', |
|
265 | + 'logout', |
|
266 | + 'account/info/edit', |
|
267 | + 'user/' . $user->uid . '/edit', |
|
268 | + 'user/' . $user->uid . '/recoveremail/*', |
|
269 | + 'recover_email.php', |
|
270 | + ); |
|
271 | + if (module_exists('boincuser_delete')) { |
|
272 | + $paths0[] = 'user/' . $user->uid . '/delete'; |
|
273 | + $paths0[] = 'user/' . $user->uid . '/deleteconfirm/*'; |
|
274 | + $paths0[] = 'user/' . $user->uid . '/odeleteconfirm/*'; |
|
275 | + } |
|
276 | 276 | |
277 | - // Paths added by the admin |
|
278 | - $paths1 = preg_split('/\r\n|\r|\n/', variable_get('boinc_weboptions_pathstoignore', "moderation\ncontent/moderation\nprivacy")); |
|
279 | - $paths2 = array(); |
|
280 | - if (is_array($paths1)) { |
|
281 | - $paths2 = array_map('strtolower', $paths1); |
|
282 | - } |
|
277 | + // Paths added by the admin |
|
278 | + $paths1 = preg_split('/\r\n|\r|\n/', variable_get('boinc_weboptions_pathstoignore', "moderation\ncontent/moderation\nprivacy")); |
|
279 | + $paths2 = array(); |
|
280 | + if (is_array($paths1)) { |
|
281 | + $paths2 = array_map('strtolower', $paths1); |
|
282 | + } |
|
283 | 283 | |
284 | - // paths to ignore |
|
285 | - $paths_to_ignore = array_unique( array_merge($paths0, $paths2) ); |
|
284 | + // paths to ignore |
|
285 | + $paths_to_ignore = array_unique( array_merge($paths0, $paths2) ); |
|
286 | 286 | |
287 | - if (!_boincuser_ignore_paths($path, $paths_to_ignore)) { |
|
288 | - drupal_goto('user/termsofuse'); |
|
289 | - } |
|
290 | - } |
|
287 | + if (!_boincuser_ignore_paths($path, $paths_to_ignore)) { |
|
288 | + drupal_goto('user/termsofuse'); |
|
291 | 289 | } |
292 | 290 | } |
293 | 291 | } |
292 | +} |
|
293 | +} |
|
294 | 294 | |
295 | 295 | /** |
296 | 296 | * Implementation of hook_user(); add custom actions to standard |
297 | 297 | * Drupal user operations |
298 | 298 | */ |
299 | 299 | function boincuser_user($op, &$edit, &$account, $category = NULL) { |
300 | - require_boinc('boinc_db'); |
|
301 | - require_boinc('user'); |
|
302 | - require_boinc('xml'); |
|
303 | - |
|
304 | - require_boinc('password_compat/password'); |
|
305 | - // Handle BOINC integration for users with UID > 1 (skip anonymous and admin) |
|
306 | - if (isset($account->uid) && ($account->uid > 1)) { |
|
307 | - switch($op) { |
|
308 | - case 'load': |
|
309 | - // User loading; insert BOINC data into the user object |
|
310 | - $drupal_user = db_fetch_object(db_query(" |
|
300 | +require_boinc('boinc_db'); |
|
301 | +require_boinc('user'); |
|
302 | +require_boinc('xml'); |
|
303 | + |
|
304 | +require_boinc('password_compat/password'); |
|
305 | +// Handle BOINC integration for users with UID > 1 (skip anonymous and admin) |
|
306 | +if (isset($account->uid) && ($account->uid > 1)) { |
|
307 | +switch($op) { |
|
308 | +case 'load': |
|
309 | +// User loading; insert BOINC data into the user object |
|
310 | +$drupal_user = db_fetch_object(db_query(" |
|
311 | 311 | SELECT boinc_id, penalty_expiration |
312 | 312 | FROM {boincuser} WHERE uid = %d", |
313 | - $account->uid |
|
314 | - )); |
|
315 | - $account->boincuser_id = $drupal_user->boinc_id; |
|
316 | - $account->boincuser_penalty_expiration = $drupal_user->penalty_expiration; |
|
317 | - db_set_active('boinc_rw'); |
|
318 | - $boinc_user = db_fetch_object(db_query(" |
|
313 | +$account->uid |
|
314 | +)); |
|
315 | +$account->boincuser_id = $drupal_user->boinc_id; |
|
316 | +$account->boincuser_penalty_expiration = $drupal_user->penalty_expiration; |
|
317 | +db_set_active('boinc_rw'); |
|
318 | +$boinc_user = db_fetch_object(db_query(" |
|
319 | 319 | SELECT |
320 | 320 | name, |
321 | 321 | authenticator, |
@@ -330,30 +330,30 @@ discard block |
||
330 | 330 | email_addr_change_time |
331 | 331 | FROM {user} |
332 | 332 | WHERE id = %d", |
333 | - $account->boincuser_id |
|
334 | - )); |
|
335 | - $account->boincuser_name = $boinc_user->name; |
|
336 | - $account->boincuser_account_key = $boinc_user->authenticator; |
|
337 | - $account->boincuser_weak_auth = md5($boinc_user->authenticator . $boinc_user->passwd_hash); |
|
338 | - $account->boincuser_total_credit = round($boinc_user->total_credit); |
|
339 | - $account->boincuser_expavg_credit = round($boinc_user->expavg_credit); |
|
340 | - $account->boincuser_expavg_time = round($boinc_user->expavg_time); |
|
341 | - $account->boincuser_cpid = md5($boinc_user->cross_project_id . $account->mail); |
|
342 | - $account->boincuser_default_pref_set = $boinc_user->venue; |
|
343 | - $account->boincteam_id = $boinc_user->teamid; |
|
344 | - $account->boincuser_previous_email_addr = $boinc_user->previous_email_addr; |
|
345 | - $account->boincuser_email_addr_change_time = $boinc_user->email_addr_change_time; |
|
346 | - db_set_active('default'); |
|
347 | - // Set Drupal team ID |
|
348 | - $account->team = NULL; |
|
349 | - if ($account->boincteam_id) { |
|
350 | - $account->team = db_result(db_query(" |
|
333 | +$account->boincuser_id |
|
334 | +)); |
|
335 | +$account->boincuser_name = $boinc_user->name; |
|
336 | +$account->boincuser_account_key = $boinc_user->authenticator; |
|
337 | +$account->boincuser_weak_auth = md5($boinc_user->authenticator . $boinc_user->passwd_hash); |
|
338 | +$account->boincuser_total_credit = round($boinc_user->total_credit); |
|
339 | +$account->boincuser_expavg_credit = round($boinc_user->expavg_credit); |
|
340 | +$account->boincuser_expavg_time = round($boinc_user->expavg_time); |
|
341 | +$account->boincuser_cpid = md5($boinc_user->cross_project_id . $account->mail); |
|
342 | +$account->boincuser_default_pref_set = $boinc_user->venue; |
|
343 | +$account->boincteam_id = $boinc_user->teamid; |
|
344 | +$account->boincuser_previous_email_addr = $boinc_user->previous_email_addr; |
|
345 | +$account->boincuser_email_addr_change_time = $boinc_user->email_addr_change_time; |
|
346 | +db_set_active('default'); |
|
347 | +// Set Drupal team ID |
|
348 | +$account->team = NULL; |
|
349 | +if ($account->boincteam_id) { |
|
350 | +$account->team = db_result(db_query(" |
|
351 | 351 | SELECT nid FROM {boincteam} WHERE team_id = %d", |
352 | - $account->boincteam_id |
|
353 | - )); |
|
354 | - } |
|
355 | - // Set post count |
|
356 | - $account->post_count = db_result(db_query(" |
|
352 | +$account->boincteam_id |
|
353 | +)); |
|
354 | +} |
|
355 | +// Set post count |
|
356 | +$account->post_count = db_result(db_query(" |
|
357 | 357 | SELECT COUNT(*) + |
358 | 358 | ( |
359 | 359 | SELECT COUNT(*) FROM {node} |
@@ -365,13 +365,13 @@ discard block |
||
365 | 365 | INNER JOIN node ON comments.nid = node.nid |
366 | 366 | WHERE comments.uid = '%d' |
367 | 367 | AND node.status = 1", |
368 | - $account->uid, $account->uid |
|
369 | - )); |
|
370 | - break; |
|
368 | +$account->uid, $account->uid |
|
369 | +)); |
|
370 | +break; |
|
371 | 371 | |
372 | - case 'view': |
|
373 | - // SAMPLE: Add BOINC data to the user profile |
|
374 | - /*$account->content['summary']['boinc_id'] = array( |
|
372 | +case 'view': |
|
373 | +// SAMPLE: Add BOINC data to the user profile |
|
374 | +/*$account->content['summary']['boinc_id'] = array( |
|
375 | 375 | '#type' => 'user_profile_item', |
376 | 376 | '#title' => bts('BIONC ID'), |
377 | 377 | '#value' => $account->boincuser_id, |
@@ -385,174 +385,174 @@ discard block |
||
385 | 385 | '#attributes' => array('class' => 'boinc-data'), |
386 | 386 | '#weight' => 10 |
387 | 387 | );*/ |
388 | - break; |
|
388 | +break; |
|
389 | 389 | |
390 | - case 'validate': |
|
391 | - if (isset($edit['validation_source'])) { |
|
392 | - switch ($edit['validation_source']) { |
|
393 | - case 'user_account': |
|
394 | - // Validate data before updating user account info |
|
395 | - boincuser_account_validate($edit, $account); |
|
396 | - break; |
|
390 | +case 'validate': |
|
391 | +if (isset($edit['validation_source'])) { |
|
392 | +switch ($edit['validation_source']) { |
|
393 | +case 'user_account': |
|
394 | +// Validate data before updating user account info |
|
395 | +boincuser_account_validate($edit, $account); |
|
396 | +break; |
|
397 | 397 | |
398 | - default: |
|
398 | +default: |
|
399 | 399 | |
400 | - } |
|
401 | - // We don't want to save validation source, so remove it |
|
402 | - $edit['validation_source'] = null; |
|
403 | - } |
|
404 | - break; |
|
400 | +} |
|
401 | + // We don't want to save validation source, so remove it |
|
402 | + $edit['validation_source'] = null; |
|
403 | + } |
|
404 | + break; |
|
405 | + |
|
406 | +case 'insert': |
|
407 | + // New user being added to the system |
|
408 | + $imported = $_SESSION['importedUser']; |
|
409 | + unset($_SESSION['importedUser']); |
|
410 | + |
|
411 | + watchdog( |
|
412 | + 'boincuser', |
|
413 | + 'Creating user account for %email_addr', |
|
414 | + array('%email_addr' => $edit['mail']), |
|
415 | + WATCHDOG_NOTICE |
|
416 | + ); |
|
405 | 417 | |
406 | - case 'insert': |
|
407 | - // New user being added to the system |
|
408 | - $imported = $_SESSION['importedUser']; |
|
409 | - unset($_SESSION['importedUser']); |
|
418 | + // The create_acount RPC will call this block of code when |
|
419 | + // user_save() is used. If user is registering using the Web |
|
420 | + // registration form, create a BOINC user and relationships. |
|
421 | + // Create a BOINC account unless importing from BOINC. |
|
422 | + if (!$imported) { |
|
410 | 423 | |
411 | - watchdog( |
|
412 | - 'boincuser', |
|
413 | - 'Creating user account for %email_addr', |
|
414 | - array('%email_addr' => $edit['mail']), |
|
415 | - WATCHDOG_NOTICE |
|
416 | - ); |
|
424 | + // set email address lower-case |
|
425 | + $lower_email_addr = strtolower($edit['mail']); |
|
417 | 426 | |
418 | - // The create_acount RPC will call this block of code when |
|
419 | - // user_save() is used. If user is registering using the Web |
|
420 | - // registration form, create a BOINC user and relationships. |
|
421 | - // Create a BOINC account unless importing from BOINC. |
|
422 | - if (!$imported) { |
|
427 | + if ($edit['boincuser_name']) { |
|
428 | + $myname = $edit['boincuser_name']; |
|
429 | + } |
|
430 | + else if ($edit['name']) { |
|
431 | + $myname = $edit['name']; |
|
432 | + } |
|
433 | + else { |
|
434 | + $myname = 'noname'; |
|
435 | + } |
|
423 | 436 | |
424 | - // set email address lower-case |
|
425 | - $lower_email_addr = strtolower($edit['mail']); |
|
437 | + $user_params = array( |
|
438 | + 'email_addr' => $lower_email_addr, |
|
439 | + 'name' => $myname, |
|
440 | + ); |
|
426 | 441 | |
427 | - if ($edit['boincuser_name']) { |
|
428 | - $myname = $edit['boincuser_name']; |
|
429 | - } |
|
430 | - else if ($edit['name']) { |
|
431 | - $myname = $edit['name']; |
|
432 | - } |
|
433 | - else { |
|
434 | - $myname = 'noname'; |
|
435 | - } |
|
442 | + // If the 'pass' variable is already a hash, then don't hash it again. |
|
443 | + if ($edit['boinchash_flag']) { |
|
444 | + $user_params['passwd_hash'] = $edit['pass']; |
|
445 | + } |
|
446 | + else { |
|
447 | + // The passwd_hash here is only the md5() hash. This is |
|
448 | + // because BOINC make_user(), called later, will run |
|
449 | + // password_hash() on this md5 hash. |
|
450 | + $user_params['passwd_hash'] = md5($edit['pass'].$lower_email_addr); |
|
451 | + } |
|
436 | 452 | |
437 | - $user_params = array( |
|
438 | - 'email_addr' => $lower_email_addr, |
|
439 | - 'name' => $myname, |
|
440 | - ); |
|
453 | + $boinc_user = boincuser_register_make_user($user_params); |
|
454 | + if (!$boinc_user) { |
|
455 | + // Account exists with this email addr |
|
456 | + form_set_error('email', bts('Error creating BOINC account.', array(), NULL, 'boinc:add-new-user')); |
|
457 | + return; |
|
458 | + } |
|
441 | 459 | |
442 | - // If the 'pass' variable is already a hash, then don't hash it again. |
|
443 | - if ($edit['boinchash_flag']) { |
|
444 | - $user_params['passwd_hash'] = $edit['pass']; |
|
445 | - } |
|
446 | - else { |
|
447 | - // The passwd_hash here is only the md5() hash. This is |
|
448 | - // because BOINC make_user(), called later, will run |
|
449 | - // password_hash() on this md5 hash. |
|
450 | - $user_params['passwd_hash'] = md5($edit['pass'].$lower_email_addr); |
|
451 | - } |
|
460 | + // Add user to community role by default (not banned) |
|
461 | + $unrestricted_role = array_search('community member', user_roles(true)); |
|
462 | + $edit['roles'] = array( |
|
463 | + $unrestricted_role => '' |
|
464 | + ); |
|
452 | 465 | |
453 | - $boinc_user = boincuser_register_make_user($user_params); |
|
454 | - if (!$boinc_user) { |
|
455 | - // Account exists with this email addr |
|
456 | - form_set_error('email', bts('Error creating BOINC account.', array(), NULL, 'boinc:add-new-user')); |
|
457 | - return; |
|
458 | - } |
|
466 | + // Disable show_hosts flag, set to TRUE by default |
|
467 | + db_set_active('boinc_rw'); |
|
468 | + db_query("UPDATE {user} SET show_hosts=0 WHERE id='%d'", $boinc_user->id); |
|
469 | + db_set_active('default'); |
|
459 | 470 | |
460 | - // Add user to community role by default (not banned) |
|
461 | - $unrestricted_role = array_search('community member', user_roles(true)); |
|
462 | - $edit['roles'] = array( |
|
463 | - $unrestricted_role => '' |
|
464 | - ); |
|
471 | + // Cross reference Drupal account with BOINC |
|
472 | + $reference = db_query("INSERT INTO {boincuser} SET uid='%d', boinc_id='%d'", $account->uid, $boinc_user->id); |
|
473 | + if (!$reference) { |
|
474 | + drupal_set_message(t('Error connecting BOINC account.'), 'error'); |
|
475 | + return; |
|
476 | + } |
|
465 | 477 | |
466 | - // Disable show_hosts flag, set to TRUE by default |
|
467 | - db_set_active('boinc_rw'); |
|
468 | - db_query("UPDATE {user} SET show_hosts=0 WHERE id='%d'", $boinc_user->id); |
|
469 | - db_set_active('default'); |
|
478 | + // if terms of use exist, the user must agree. |
|
479 | + $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
480 | + if (!empty($termsofuse)) { |
|
481 | + $reference2 = boincuser_consentto_termsofuse($account); |
|
482 | + } |
|
470 | 483 | |
471 | - // Cross reference Drupal account with BOINC |
|
472 | - $reference = db_query("INSERT INTO {boincuser} SET uid='%d', boinc_id='%d'", $account->uid, $boinc_user->id); |
|
473 | - if (!$reference) { |
|
474 | - drupal_set_message(t('Error connecting BOINC account.'), 'error'); |
|
475 | - return; |
|
476 | - } |
|
484 | + // Don't save custom fields to the Drupal user object |
|
485 | + $edit['boincuser_name'] = null; |
|
486 | + $edit['boinchash_flag'] = null; |
|
487 | + // Set email address to lower case in Drupal users table |
|
488 | + if ($account) { |
|
489 | + user_save($account, array('mail' => $lower_email_addr)); |
|
490 | + } |
|
491 | + } |
|
492 | + break; |
|
493 | + |
|
494 | +case 'update': |
|
495 | + if (isset($edit['update_source'])) { |
|
496 | + require_boinc('boinc_db'); |
|
497 | + $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
498 | + switch ($edit['update_source']) { |
|
499 | + case 'user_account': |
|
500 | + // Ensure that BOINC data is altered |
|
501 | + |
|
502 | + $changing_email = ($edit['mail'] AND $edit['mail'] != $boinc_user->email_addr) ? true : false; |
|
503 | + $changing_pass = ($edit['pass']) ? true : false; |
|
504 | + if ($changing_email OR $changing_pass) { |
|
505 | + // set email address to lower-case |
|
506 | + $lower_email_addr = strtolower($edit['mail']); |
|
507 | + |
|
508 | + // Set password hash appropriately |
|
509 | + $passwd = ($edit['pass']) ? $edit['pass'] : $edit['current_pass']; |
|
510 | + $passwd_hash = password_hash( md5($passwd.$lower_email_addr), PASSWORD_DEFAULT ); |
|
511 | + // Algorithm for changing email and/or password |
|
512 | + if ($changing_email) { |
|
513 | + // locally store current email to set as previous email |
|
514 | + $prev_email = $account->mail; |
|
515 | + $mytime = (user_access('administer users')) ? $boinc_user->email_addr_change_time : time(); |
|
516 | + $querypart = "email_addr='{$lower_email_addr}', passwd_hash='{$passwd_hash}', previous_email_addr = '{$prev_email}', email_addr_change_time = $mytime"; |
|
517 | + } |
|
518 | + else { |
|
519 | + $querypart = "email_addr='{$lower_email_addr}', passwd_hash='{$passwd_hash}'"; |
|
520 | + } |
|
477 | 521 | |
478 | - // if terms of use exist, the user must agree. |
|
479 | - $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
480 | - if (!empty($termsofuse)) { |
|
481 | - $reference2 = boincuser_consentto_termsofuse($account); |
|
482 | - } |
|
522 | + // Update user account information |
|
523 | + $result = $boinc_user->update($querypart); |
|
483 | 524 | |
484 | - // Don't save custom fields to the Drupal user object |
|
485 | - $edit['boincuser_name'] = null; |
|
486 | - $edit['boinchash_flag'] = null; |
|
487 | - // Set email address to lower case in Drupal users table |
|
488 | - if ($account) { |
|
489 | - user_save($account, array('mail' => $lower_email_addr)); |
|
490 | - } |
|
491 | - } |
|
492 | - break; |
|
525 | + if ($changing_email) { |
|
526 | + // reload account |
|
527 | + $account = user_load($account->uid); |
|
528 | + _boincuser_send_emailchange($account, $lower_email_addr, $prev_email, user_access('administer users')); |
|
529 | + } |
|
493 | 530 | |
494 | - case 'update': |
|
495 | - if (isset($edit['update_source'])) { |
|
496 | - require_boinc('boinc_db'); |
|
497 | - $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
498 | - switch ($edit['update_source']) { |
|
499 | - case 'user_account': |
|
500 | - // Ensure that BOINC data is altered |
|
501 | - |
|
502 | - $changing_email = ($edit['mail'] AND $edit['mail'] != $boinc_user->email_addr) ? true : false; |
|
503 | - $changing_pass = ($edit['pass']) ? true : false; |
|
504 | - if ($changing_email OR $changing_pass) { |
|
505 | - // set email address to lower-case |
|
506 | - $lower_email_addr = strtolower($edit['mail']); |
|
507 | - |
|
508 | - // Set password hash appropriately |
|
509 | - $passwd = ($edit['pass']) ? $edit['pass'] : $edit['current_pass']; |
|
510 | - $passwd_hash = password_hash( md5($passwd.$lower_email_addr), PASSWORD_DEFAULT ); |
|
511 | - // Algorithm for changing email and/or password |
|
512 | - if ($changing_email) { |
|
513 | - // locally store current email to set as previous email |
|
514 | - $prev_email = $account->mail; |
|
515 | - $mytime = (user_access('administer users')) ? $boinc_user->email_addr_change_time : time(); |
|
516 | - $querypart = "email_addr='{$lower_email_addr}', passwd_hash='{$passwd_hash}', previous_email_addr = '{$prev_email}', email_addr_change_time = $mytime"; |
|
517 | - } |
|
518 | - else { |
|
519 | - $querypart = "email_addr='{$lower_email_addr}', passwd_hash='{$passwd_hash}'"; |
|
520 | - } |
|
521 | - |
|
522 | - // Update user account information |
|
523 | - $result = $boinc_user->update($querypart); |
|
524 | - |
|
525 | - if ($changing_email) { |
|
526 | - // reload account |
|
527 | - $account = user_load($account->uid); |
|
528 | - _boincuser_send_emailchange($account, $lower_email_addr, $prev_email, user_access('administer users')); |
|
529 | - } |
|
530 | - |
|
531 | - // Change email to edit to lower-case version, this sets |
|
532 | - // email in Drupal database to the lower-case email |
|
533 | - // address. |
|
534 | - $edit['mail'] = strtolower($lower_email_addr); |
|
535 | - } |
|
536 | - |
|
537 | - // Change boinc username |
|
538 | - if ($edit['boincuser_name'] and ($edit['boincuser_name'] != $boinc_user->name)) { |
|
539 | - $boincuser_name = $edit['boincuser_name']; |
|
540 | - $result = $boinc_user->update( |
|
541 | - "name='{$boincuser_name}'" |
|
542 | - ); |
|
543 | - } |
|
544 | - |
|
545 | - break; |
|
546 | - case 'user_profile': |
|
547 | - if ($edit['boincuser_name'] != $boinc_user->name) { |
|
548 | - $boincuser_name = $edit['boincuser_name']; |
|
549 | - $result = $boinc_user->update( |
|
550 | - "name='{$boincuser_name}'" |
|
551 | - ); |
|
552 | - } |
|
553 | - break; |
|
554 | - default: |
|
555 | - } |
|
531 | + // Change email to edit to lower-case version, this sets |
|
532 | + // email in Drupal database to the lower-case email |
|
533 | + // address. |
|
534 | + $edit['mail'] = strtolower($lower_email_addr); |
|
535 | + } |
|
536 | + |
|
537 | + // Change boinc username |
|
538 | + if ($edit['boincuser_name'] and ($edit['boincuser_name'] != $boinc_user->name)) { |
|
539 | + $boincuser_name = $edit['boincuser_name']; |
|
540 | + $result = $boinc_user->update( |
|
541 | + "name='{$boincuser_name}'" |
|
542 | + ); |
|
543 | + } |
|
544 | + |
|
545 | + break; |
|
546 | + case 'user_profile': |
|
547 | + if ($edit['boincuser_name'] != $boinc_user->name) { |
|
548 | + $boincuser_name = $edit['boincuser_name']; |
|
549 | + $result = $boinc_user->update( |
|
550 | + "name='{$boincuser_name}'" |
|
551 | + ); |
|
552 | + } |
|
553 | + break; |
|
554 | + default: |
|
555 | + } |
|
556 | 556 | // We don't want to save update source or duplicate custom fields, so |
557 | 557 | // remove them before continuing to core Drupal routines |
558 | 558 | $edit['update_source'] = null; |
@@ -561,17 +561,17 @@ discard block |
||
561 | 561 | } |
562 | 562 | break; |
563 | 563 | |
564 | - case 'login': |
|
565 | - // Function is forward compatible to Drupal 7 |
|
566 | - boincuser_user_login($edit, $account); |
|
567 | - break; |
|
564 | +case 'login': |
|
565 | + // Function is forward compatible to Drupal 7 |
|
566 | + boincuser_user_login($edit, $account); |
|
567 | + break; |
|
568 | 568 | |
569 | - case 'delete': |
|
570 | - // Function is forward compatible to Drupal 7 |
|
571 | - boincuser_user_delete($account); |
|
572 | - break; |
|
569 | +case 'delete': |
|
570 | + // Function is forward compatible to Drupal 7 |
|
571 | + boincuser_user_delete($account); |
|
572 | + break; |
|
573 | 573 | |
574 | - default: |
|
574 | +default: |
|
575 | 575 | |
576 | 576 | } |
577 | 577 | } |
@@ -301,125 +301,125 @@ |
||
301 | 301 | } |
302 | 302 | |
303 | 303 | switch ($form_state['values']['import']) { |
304 | - case 'users': |
|
305 | - boincimport_users(); |
|
306 | - break; |
|
307 | - |
|
308 | - case 'teams': |
|
309 | - boincimport_teams(); |
|
310 | - if (!variable_get('boincimport_import_team_successful', 0)) { |
|
311 | - $_SESSION['boincimport_stage_selected'] = 'teams'; |
|
312 | - } |
|
313 | - else { |
|
314 | - $_SESSION['boincimport_stage_selected'] = 'friends'; |
|
315 | - } |
|
316 | - break; |
|
304 | + case 'users': |
|
305 | + boincimport_users(); |
|
306 | + break; |
|
317 | 307 | |
318 | - case 'friends': |
|
319 | - boincimport_friends(); |
|
320 | - if (!variable_get('boincimport_import_friend_successful', 0)) { |
|
321 | - $_SESSION['boincimport_stage_selected'] = 'friends'; |
|
322 | - } |
|
323 | - else { |
|
324 | - $_SESSION['boincimport_stage_selected'] = 'preferences'; |
|
325 | - } |
|
326 | - break; |
|
308 | + case 'teams': |
|
309 | + boincimport_teams(); |
|
310 | + if (!variable_get('boincimport_import_team_successful', 0)) { |
|
311 | + $_SESSION['boincimport_stage_selected'] = 'teams'; |
|
312 | + } |
|
313 | + else { |
|
314 | + $_SESSION['boincimport_stage_selected'] = 'friends'; |
|
315 | + } |
|
316 | + break; |
|
327 | 317 | |
328 | - case 'preferences': |
|
329 | - boincimport_preferences(); |
|
330 | - if (!variable_get('boincimport_import_preferences_successful', 0)) { |
|
331 | - $_SESSION['boincimport_stage_selected'] = 'preferences'; |
|
332 | - } |
|
333 | - else { |
|
334 | - $_SESSION['boincimport_stage_selected'] = 'private messages'; |
|
335 | - } |
|
336 | - break; |
|
318 | + case 'friends': |
|
319 | + boincimport_friends(); |
|
320 | + if (!variable_get('boincimport_import_friend_successful', 0)) { |
|
321 | + $_SESSION['boincimport_stage_selected'] = 'friends'; |
|
322 | + } |
|
323 | + else { |
|
324 | + $_SESSION['boincimport_stage_selected'] = 'preferences'; |
|
325 | + } |
|
326 | + break; |
|
337 | 327 | |
338 | - case 'private messages': |
|
339 | - boincimport_private_msgs(); |
|
340 | - if (!variable_get('boincimport_import_private_msg_successful', 0)) { |
|
341 | - $_SESSION['boincimport_stage_selected'] = 'private messages'; |
|
342 | - } |
|
343 | - else { |
|
344 | - $_SESSION['boincimport_stage_selected'] = 'categories'; |
|
345 | - } |
|
346 | - break; |
|
328 | + case 'preferences': |
|
329 | + boincimport_preferences(); |
|
330 | + if (!variable_get('boincimport_import_preferences_successful', 0)) { |
|
331 | + $_SESSION['boincimport_stage_selected'] = 'preferences'; |
|
332 | + } |
|
333 | + else { |
|
334 | + $_SESSION['boincimport_stage_selected'] = 'private messages'; |
|
335 | + } |
|
336 | + break; |
|
347 | 337 | |
348 | - case 'categories': |
|
349 | - boincimport_forum_categories(); |
|
350 | - if (!variable_get('boincimport_import_category_successful', 0)) { |
|
351 | - $_SESSION['boincimport_stage_selected'] = 'categories'; |
|
352 | - } |
|
353 | - else { |
|
354 | - $_SESSION['boincimport_stage_selected'] = 'topics'; |
|
355 | - } |
|
356 | - break; |
|
338 | + case 'private messages': |
|
339 | + boincimport_private_msgs(); |
|
340 | + if (!variable_get('boincimport_import_private_msg_successful', 0)) { |
|
341 | + $_SESSION['boincimport_stage_selected'] = 'private messages'; |
|
342 | + } |
|
343 | + else { |
|
344 | + $_SESSION['boincimport_stage_selected'] = 'categories'; |
|
345 | + } |
|
346 | + break; |
|
357 | 347 | |
358 | - case 'topics': |
|
359 | - boincimport_forum_topics(); |
|
360 | - if (!variable_get('boincimport_import_topic_successful', 0)) { |
|
361 | - $_SESSION['boincimport_stage_selected'] = 'topics'; |
|
362 | - } |
|
363 | - else { |
|
364 | - $_SESSION['boincimport_stage_selected'] = 'posts'; |
|
365 | - } |
|
366 | - break; |
|
348 | + case 'categories': |
|
349 | + boincimport_forum_categories(); |
|
350 | + if (!variable_get('boincimport_import_category_successful', 0)) { |
|
351 | + $_SESSION['boincimport_stage_selected'] = 'categories'; |
|
352 | + } |
|
353 | + else { |
|
354 | + $_SESSION['boincimport_stage_selected'] = 'topics'; |
|
355 | + } |
|
356 | + break; |
|
367 | 357 | |
368 | - case 'posts': |
|
369 | - boincimport_forum_posts(); |
|
370 | - if (!variable_get('boincimport_import_post_successful', 0)) { |
|
371 | - $_SESSION['boincimport_stage_selected'] = 'posts'; |
|
372 | - } |
|
373 | - else { |
|
374 | - $_SESSION['boincimport_stage_selected'] = 'url'; |
|
375 | - } |
|
376 | - break; |
|
358 | + case 'topics': |
|
359 | + boincimport_forum_topics(); |
|
360 | + if (!variable_get('boincimport_import_topic_successful', 0)) { |
|
361 | + $_SESSION['boincimport_stage_selected'] = 'topics'; |
|
362 | + } |
|
363 | + else { |
|
364 | + $_SESSION['boincimport_stage_selected'] = 'posts'; |
|
365 | + } |
|
366 | + break; |
|
377 | 367 | |
378 | - case 'team forums': |
|
379 | - boincimport_team_forums(); |
|
380 | - if (!variable_get('boincimport_team_forum_successful', 0)) { |
|
381 | - $_SESSION['boincimport_stage_selected'] = 'team forums'; |
|
382 | - } |
|
383 | - else { |
|
384 | - $_SESSION['boincimport_stage_selected'] = 'team topics'; |
|
385 | - } |
|
386 | - break; |
|
368 | + case 'posts': |
|
369 | + boincimport_forum_posts(); |
|
370 | + if (!variable_get('boincimport_import_post_successful', 0)) { |
|
371 | + $_SESSION['boincimport_stage_selected'] = 'posts'; |
|
372 | + } |
|
373 | + else { |
|
374 | + $_SESSION['boincimport_stage_selected'] = 'url'; |
|
375 | + } |
|
376 | + break; |
|
387 | 377 | |
388 | - case 'team topics': |
|
389 | - boincimport_team_forum_topics(); |
|
390 | - if (!variable_get('boincimport_team_topic_successful', 0)) { |
|
391 | - $_SESSION['boincimport_stage_selected'] = 'team topics'; |
|
392 | - } |
|
393 | - else { |
|
394 | - $_SESSION['boincimport_stage_selected'] = 'team posts'; |
|
395 | - } |
|
396 | - break; |
|
378 | + case 'team forums': |
|
379 | + boincimport_team_forums(); |
|
380 | + if (!variable_get('boincimport_team_forum_successful', 0)) { |
|
381 | + $_SESSION['boincimport_stage_selected'] = 'team forums'; |
|
382 | + } |
|
383 | + else { |
|
384 | + $_SESSION['boincimport_stage_selected'] = 'team topics'; |
|
385 | + } |
|
386 | + break; |
|
397 | 387 | |
398 | - case 'team posts': |
|
399 | - boincimport_team_forum_posts(); |
|
400 | - if (!variable_get('boincimport_team_post_successful', 0)) { |
|
401 | - $_SESSION['boincimport_stage_selected'] = 'team posts'; |
|
402 | - } |
|
403 | - else { |
|
404 | - $_SESSION['boincimport_stage_selected'] = 'url'; |
|
405 | - } |
|
406 | - break; |
|
388 | + case 'team topics': |
|
389 | + boincimport_team_forum_topics(); |
|
390 | + if (!variable_get('boincimport_team_topic_successful', 0)) { |
|
391 | + $_SESSION['boincimport_stage_selected'] = 'team topics'; |
|
392 | + } |
|
393 | + else { |
|
394 | + $_SESSION['boincimport_stage_selected'] = 'team posts'; |
|
395 | + } |
|
396 | + break; |
|
407 | 397 | |
408 | - case 'url': |
|
409 | - boincimport_replace_urls(); |
|
410 | - if (!variable_get('boincimport_replace_url_successful', 0)) { |
|
411 | - $_SESSION['boincimport_stage_selected'] = 'url'; |
|
412 | - } |
|
413 | - else { |
|
414 | - drupal_set_message('Congratulations. Import Finished'); |
|
415 | - drupal_set_message('Please visit the '. l('Post migration configuration', 'admin/boinc/import/post_configuration') .' page'); |
|
416 | - watchdog('boincimport', 'Import process is complete', array(), WATCHDOG_INFO); |
|
417 | - unset($_SESSION['boincimport_stage_selected']); |
|
418 | - } |
|
419 | - break; |
|
420 | - default: |
|
421 | - $_SESSION['boincimport_stage_selected'] = 'users'; |
|
422 | - break; |
|
398 | + case 'team posts': |
|
399 | + boincimport_team_forum_posts(); |
|
400 | + if (!variable_get('boincimport_team_post_successful', 0)) { |
|
401 | + $_SESSION['boincimport_stage_selected'] = 'team posts'; |
|
402 | + } |
|
403 | + else { |
|
404 | + $_SESSION['boincimport_stage_selected'] = 'url'; |
|
405 | + } |
|
406 | + break; |
|
407 | + |
|
408 | + case 'url': |
|
409 | + boincimport_replace_urls(); |
|
410 | + if (!variable_get('boincimport_replace_url_successful', 0)) { |
|
411 | + $_SESSION['boincimport_stage_selected'] = 'url'; |
|
412 | + } |
|
413 | + else { |
|
414 | + drupal_set_message('Congratulations. Import Finished'); |
|
415 | + drupal_set_message('Please visit the '. l('Post migration configuration', 'admin/boinc/import/post_configuration') .' page'); |
|
416 | + watchdog('boincimport', 'Import process is complete', array(), WATCHDOG_INFO); |
|
417 | + unset($_SESSION['boincimport_stage_selected']); |
|
418 | + } |
|
419 | + break; |
|
420 | + default: |
|
421 | + $_SESSION['boincimport_stage_selected'] = 'users'; |
|
422 | + break; |
|
423 | 423 | } |
424 | 424 | } |
425 | 425 |
@@ -643,9 +643,9 @@ discard block |
||
643 | 643 | } |
644 | 644 | break; |
645 | 645 | |
646 | - default: |
|
647 | - // Don't generate form elements for things that aren't explicitly form |
|
648 | - // elements (i.e. 'title', '@attributes' keys, and the like) |
|
646 | + default: |
|
647 | + // Don't generate form elements for things that aren't explicitly form |
|
648 | + // elements (i.e. 'title', '@attributes' keys, and the like) |
|
649 | 649 | } |
650 | 650 | } |
651 | 651 | |
@@ -1990,31 +1990,31 @@ discard block |
||
1990 | 1990 | */ |
1991 | 1991 | function pretty_application_version($appverid, $vernum, $plan_class, $plfm) { |
1992 | 1992 | switch ($appverid) { |
1993 | - case ANON_PLATFORM_UNKNOWN: |
|
1994 | - return "Anonymous platform"; |
|
1995 | - case ANON_PLATFORM_CPU: |
|
1996 | - return "Anonymous platform CPU"; |
|
1997 | - case ANON_PLATFORM_NVIDIA: |
|
1998 | - return "Anonymous platform NVIDIA GPU"; |
|
1999 | - case ANON_PLATFORM_ATI: |
|
2000 | - return "Anonymous platform AMD GPU"; |
|
2001 | - case ANON_PLATFORM_INTEL_GPU: |
|
2002 | - return "Anonymous platform Intel GPU"; |
|
2003 | - case ANON_PLATFORM_APPLE_GPU: |
|
2004 | - return "Anonymous platform Apple GPU"; |
|
2005 | - case 0: |
|
2006 | - return "---"; |
|
2007 | - default: |
|
2008 | - // Handle the case where the appversid is still negative. This |
|
2009 | - // may be cause BOINC has introduced a new anonymous platform |
|
2010 | - // that is not handled by the above case statements. |
|
2011 | - if ($appverid < 0) { |
|
2012 | - return "Unknown Anonymous platform"; |
|
2013 | - } |
|
2014 | - else { |
|
2015 | - $prettyv = sprintf("%d.%02d", $vernum/100, $vernum%100); |
|
2016 | - $prettyc = ($plan_class) ? "($av->plan_class)" : ''; |
|
2017 | - return "v$prettyv $prettyc $plfm"; |
|
2018 | - } |
|
1993 | + case ANON_PLATFORM_UNKNOWN: |
|
1994 | + return "Anonymous platform"; |
|
1995 | + case ANON_PLATFORM_CPU: |
|
1996 | + return "Anonymous platform CPU"; |
|
1997 | + case ANON_PLATFORM_NVIDIA: |
|
1998 | + return "Anonymous platform NVIDIA GPU"; |
|
1999 | + case ANON_PLATFORM_ATI: |
|
2000 | + return "Anonymous platform AMD GPU"; |
|
2001 | + case ANON_PLATFORM_INTEL_GPU: |
|
2002 | + return "Anonymous platform Intel GPU"; |
|
2003 | + case ANON_PLATFORM_APPLE_GPU: |
|
2004 | + return "Anonymous platform Apple GPU"; |
|
2005 | + case 0: |
|
2006 | + return "---"; |
|
2007 | + default: |
|
2008 | + // Handle the case where the appversid is still negative. This |
|
2009 | + // may be cause BOINC has introduced a new anonymous platform |
|
2010 | + // that is not handled by the above case statements. |
|
2011 | + if ($appverid < 0) { |
|
2012 | + return "Unknown Anonymous platform"; |
|
2013 | + } |
|
2014 | + else { |
|
2015 | + $prettyv = sprintf("%d.%02d", $vernum/100, $vernum%100); |
|
2016 | + $prettyc = ($plan_class) ? "($av->plan_class)" : ''; |
|
2017 | + return "v$prettyv $prettyc $plfm"; |
|
2018 | + } |
|
2019 | 2019 | } |
2020 | 2020 | } |