@@ -19,15 +19,15 @@ discard block |
||
19 | 19 | * Implementation of hook_perm(). |
20 | 20 | */ |
21 | 21 | function boincuser_delete_perm() { |
22 | - return array('delete own account'); |
|
22 | + return array('delete own account'); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Implementation of hook_menu(). |
27 | 27 | */ |
28 | 28 | function boincuser_delete_menu() { |
29 | - $items = array(); |
|
30 | - $items['admin/boinc/user_delete'] = array( |
|
29 | + $items = array(); |
|
30 | + $items['admin/boinc/user_delete'] = array( |
|
31 | 31 | 'title' => t('Preferences: BOINC user delete'), |
32 | 32 | 'description' => t('Configure the BOINC user delete action.'), |
33 | 33 | 'page callback' => 'drupal_get_form', |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | 'access arguments' => array('administer users'), |
36 | 36 | 'type' => MENU_NORMAL_ITEM, |
37 | 37 | 'file' => 'boincuser_delete.admin.inc', |
38 | - ); |
|
38 | + ); |
|
39 | 39 | |
40 | - $items['admin/boinc/user_delete/%'] = array( |
|
40 | + $items['admin/boinc/user_delete/%'] = array( |
|
41 | 41 | 'title' => t('Admin delete user'), |
42 | 42 | 'description' => t('Deletes a user as an admin'), |
43 | 43 | 'page callback' => 'drupal_get_form', |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | 'access arguments' => array('administer users'), |
46 | 46 | 'type' => MENU_CALLBACK, |
47 | 47 | 'file' => 'boincuser_delete.admin.inc', |
48 | - ); |
|
48 | + ); |
|
49 | 49 | |
50 | - $items['user/%user/deleteconfirm/%'] = array( |
|
50 | + $items['user/%user/deleteconfirm/%'] = array( |
|
51 | 51 | 'title' => t('Final confirmation for account deletion'), |
52 | 52 | 'description' => t('Final confirmation for account deletion'), |
53 | 53 | 'page callback' => 'drupal_get_form', |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | 'access callback' => 'boincuser_delete_access', |
56 | 56 | 'access arguments' => array(1), |
57 | 57 | 'type' => MENU_CALLBACK, |
58 | - ); |
|
58 | + ); |
|
59 | 59 | |
60 | - $items['user/%user/odeleteconfirm/%'] = array( |
|
60 | + $items['user/%user/odeleteconfirm/%'] = array( |
|
61 | 61 | 'title' => t('Final confirmation for account deletion'), |
62 | 62 | 'description' => t('Final confirmation for account deletion'), |
63 | 63 | 'page callback' => 'drupal_get_form', |
@@ -65,181 +65,181 @@ discard block |
||
65 | 65 | 'access callback' => 'boincuser_delete_access', |
66 | 66 | 'access arguments' => array(1), |
67 | 67 | 'type' => MENU_CALLBACK, |
68 | - ); |
|
68 | + ); |
|
69 | 69 | |
70 | - return $items; |
|
70 | + return $items; |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
74 | 74 | * Checks whether a user can delete an account. |
75 | 75 | */ |
76 | 76 | function boincuser_delete_access($account) { |
77 | - global $user; |
|
78 | - return ((user_access('administer users') || (user_access('delete own account') && $account->uid == $user->uid)) && $account->uid > 0); |
|
77 | + global $user; |
|
78 | + return ((user_access('administer users') || (user_access('delete own account') && $account->uid == $user->uid)) && $account->uid > 0); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Implementation of hook_menu_alter(). |
83 | 83 | */ |
84 | 84 | function boincuser_delete_menu_alter(&$callbacks) { |
85 | - $callbacks['user/%user/delete']['access callback'] = 'boincuser_delete_access'; |
|
86 | - $callbacks['user/%user/delete']['access arguments'] = array(1); |
|
87 | - $callbacks['user/%user/delete']['type'] = MENU_CALLBACK; |
|
85 | + $callbacks['user/%user/delete']['access callback'] = 'boincuser_delete_access'; |
|
86 | + $callbacks['user/%user/delete']['access arguments'] = array(1); |
|
87 | + $callbacks['user/%user/delete']['type'] = MENU_CALLBACK; |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
91 | 91 | * Implementation of hook_form_alter(). |
92 | 92 | */ |
93 | 93 | function boincuser_delete_form_alter(&$form, $form_state, $form_id) { |
94 | - global $user; |
|
94 | + global $user; |
|
95 | 95 | |
96 | - switch($form_id) { |
|
96 | + switch($form_id) { |
|
97 | 97 | case 'user_profile_form': |
98 | 98 | if ( user_access('delete own account') AND ($form['#uid'] == $user->uid) AND (arg(3)=='') ) { |
99 | 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>', |
|
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 | 106 | ); |
107 | - } |
|
108 | - else if ( user_access('administer users') ) { |
|
107 | + } |
|
108 | + else if ( user_access('administer users') ) { |
|
109 | 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>', |
|
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 | 116 | ); |
117 | - } |
|
118 | - else { |
|
117 | + } |
|
118 | + else { |
|
119 | 119 | unset($form['delete']); |
120 | - } |
|
121 | - break; |
|
120 | + } |
|
121 | + break; |
|
122 | 122 | case 'user_confirm_delete': |
123 | 123 | |
124 | 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()) { |
|
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 | 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.", |
|
130 | + bts("INFO: Your email address was changed within the past seven (7) days. You may not delete your account until after !time.", |
|
131 | 131 | array( |
132 | - '!time' => date('F j, Y \a\t G:i T', $form['_account']['#value']->boincuser_email_addr_change_time + $duration), |
|
132 | + '!time' => date('F j, Y \a\t G:i T', $form['_account']['#value']->boincuser_email_addr_change_time + $duration), |
|
133 | 133 | ), NULL, 'boinc:account-credentials-change') |
134 | 134 | , 'info'); |
135 | 135 | $disable_delete = TRUE; |
136 | - } |
|
136 | + } |
|
137 | 137 | |
138 | - // Configure radio options |
|
139 | - $deleteoptions = array( |
|
138 | + // Configure radio options |
|
139 | + $deleteoptions = array( |
|
140 | 140 | 'boincuser_delete_softdelete' => bts('<b>Soft delete</b> the account. Afterwards your account will be disabled, and all posts/comments will be attributed to the Anonymous User. However, your user profile will be deleted, your host information will be deleted, and you will be removed from any team you are a member of.', array(), NULL, 'boinc:delete-user-account'), |
141 | 141 | 'boincuser_delete_delete' => bts('<b>Delete</b> the account. Afterwards your account will be deleted, and all posts/comments will be attributed to the Anonymous User. Your user profile will be deleted, and your host information will be deleted.', array(), NULL, 'boinc:delete-user-account'), |
142 | - ); |
|
142 | + ); |
|
143 | 143 | |
144 | - $dtypes = variable_get('boincuser_delete_type', 'user_decides'); |
|
145 | - // unset the other option if dtype is set. i.e., if dtype is set |
|
146 | - // to soft delete, unset the hard delete option. |
|
147 | - switch ($dtypes) { |
|
144 | + $dtypes = variable_get('boincuser_delete_type', 'user_decides'); |
|
145 | + // unset the other option if dtype is set. i.e., if dtype is set |
|
146 | + // to soft delete, unset the hard delete option. |
|
147 | + switch ($dtypes) { |
|
148 | 148 | case 'soft_obfuscate': |
149 | 149 | unset($deleteoptions['boincuser_delete_delete']); |
150 | - break; |
|
150 | + break; |
|
151 | 151 | case 'hard_wipe': |
152 | 152 | unset($deleteoptions['boincuser_delete_softdelete']); |
153 | - break; |
|
154 | - } |
|
153 | + break; |
|
154 | + } |
|
155 | 155 | |
156 | - $question = 'Are you sure you want to delete the account <em>' . htmlspecialchars($form['_account']['#value']->boincuser_name) . '</em>?'; |
|
157 | - drupal_set_title($question); |
|
156 | + $question = 'Are you sure you want to delete the account <em>' . htmlspecialchars($form['_account']['#value']->boincuser_name) . '</em>?'; |
|
157 | + drupal_set_title($question); |
|
158 | 158 | |
159 | - unset($form['description']); |
|
159 | + unset($form['description']); |
|
160 | 160 | |
161 | - $form['main'] = array( |
|
161 | + $form['main'] = array( |
|
162 | 162 | '#type' => 'fieldset', |
163 | 163 | '#weight' => 1, |
164 | - ); |
|
164 | + ); |
|
165 | 165 | |
166 | - $form['main']['help'] = array( |
|
166 | + $form['main']['help'] = array( |
|
167 | 167 | '#value' => bts( |
168 | - "<p><b>Instructions:</b> In order to delete your account, you must provide your password below. You will then be sent an email to the email address on record, with a one-time token that expires in 24-hours. Clicking on this link will bring you to a second form where you must enter your password again. After doing so your account will be deleted.</p>" . |
|
169 | - "<p>If necessary, you may !link first before deleting your account. But you must wait <b>seven (7) days</b> after an email address change before you may delete your account.</p>", |
|
170 | - array( |
|
168 | + "<p><b>Instructions:</b> In order to delete your account, you must provide your password below. You will then be sent an email to the email address on record, with a one-time token that expires in 24-hours. Clicking on this link will bring you to a second form where you must enter your password again. After doing so your account will be deleted.</p>" . |
|
169 | + "<p>If necessary, you may !link first before deleting your account. But you must wait <b>seven (7) days</b> after an email address change before you may delete your account.</p>", |
|
170 | + array( |
|
171 | 171 | '!link' => l(bts('change your email address', array(), NULL, 'boinc:delete-user-account'), '/account/info/edit'), |
172 | - ), NULL, 'boinc:delete-user-account'), |
|
172 | + ), NULL, 'boinc:delete-user-account'), |
|
173 | 173 | '#weight' => 11, |
174 | 174 | '#prefix' => "<div id='delete-instructions'>", |
175 | 175 | '#suffix' => "</div>", |
176 | - ); |
|
176 | + ); |
|
177 | 177 | |
178 | - $form['main']['user_delete_action'] = array( |
|
178 | + $form['main']['user_delete_action'] = array( |
|
179 | 179 | '#type' => 'radios', |
180 | 180 | '#options' => $deleteoptions, |
181 | 181 | '#weight' => 21, |
182 | - ); |
|
183 | - if ($disable_delete) { |
|
182 | + ); |
|
183 | + if ($disable_delete) { |
|
184 | 184 | $form['main']['user_delete_action']['#disabled'] = TRUE; |
185 | - } |
|
185 | + } |
|
186 | 186 | |
187 | - $form['separator_bottom'] = array( |
|
187 | + $form['separator_bottom'] = array( |
|
188 | 188 | '#value' => '<div class="separator buttons"></div>', |
189 | 189 | '#weight' => 999, |
190 | - ); |
|
190 | + ); |
|
191 | 191 | |
192 | - // Password field |
|
193 | - if (!$disable_delete) { |
|
192 | + // Password field |
|
193 | + if (!$disable_delete) { |
|
194 | 194 | $form['main']['current_pass'] = array( |
195 | - '#type' => 'password', |
|
196 | - '#title' => bts('Enter your password before clicking Submit', array(), NULL, 'boinc:delete-user-account'), |
|
197 | - '#size' => 17, |
|
198 | - '#attributes' => array( |
|
195 | + '#type' => 'password', |
|
196 | + '#title' => bts('Enter your password before clicking Submit', array(), NULL, 'boinc:delete-user-account'), |
|
197 | + '#size' => 17, |
|
198 | + '#attributes' => array( |
|
199 | 199 | 'autocomplete' => 'off', |
200 | - ), |
|
201 | - '#weight' => 25, |
|
200 | + ), |
|
201 | + '#weight' => 25, |
|
202 | 202 | ); |
203 | - } |
|
203 | + } |
|
204 | 204 | |
205 | - // Configure the action buttons |
|
206 | - $uid = $form['_account']['#value']->uid; |
|
207 | - $form['actions']['#weight'] = 1000; |
|
208 | - $form['actions']['form control tabs prefix'] = array( |
|
205 | + // Configure the action buttons |
|
206 | + $uid = $form['_account']['#value']->uid; |
|
207 | + $form['actions']['#weight'] = 1000; |
|
208 | + $form['actions']['form control tabs prefix'] = array( |
|
209 | 209 | '#value' => '<ul class="form-control tab-list">', |
210 | 210 | '#weight' => 1001, |
211 | - ); |
|
212 | - |
|
213 | - unset($form['actions']['#prefix']); |
|
214 | - unset($form['actions']['#suffix']); |
|
215 | - $form['actions']['submit']['#prefix'] = '<li class="first tab">'; |
|
216 | - $form['actions']['submit']['#suffix'] = '</li>'; |
|
217 | - $form['actions']['submit']['#value'] = bts('Submit', array(), NULL, 'boinc:form-submit'); |
|
218 | - $form['actions']['submit']['#weight'] = 1002; |
|
219 | - if ($disable_delete) { |
|
211 | + ); |
|
212 | + |
|
213 | + unset($form['actions']['#prefix']); |
|
214 | + unset($form['actions']['#suffix']); |
|
215 | + $form['actions']['submit']['#prefix'] = '<li class="first tab">'; |
|
216 | + $form['actions']['submit']['#suffix'] = '</li>'; |
|
217 | + $form['actions']['submit']['#value'] = bts('Submit', array(), NULL, 'boinc:form-submit'); |
|
218 | + $form['actions']['submit']['#weight'] = 1002; |
|
219 | + if ($disable_delete) { |
|
220 | 220 | $form['actions']['submit']['#disabled'] = TRUE; |
221 | 221 | $form['actions']['submit']['#value'] = ''; |
222 | - } |
|
222 | + } |
|
223 | 223 | |
224 | - $form['actions']['cancel']['#prefix'] = '<li class="tab">'; |
|
225 | - $form['actions']['cancel']['#suffix'] = '</li>'; |
|
226 | - $form['actions']['cancel']['#weight'] = 1003; |
|
227 | - $form['actions']['cancel']['#value'] = l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'account/info/edit'); |
|
228 | - if ($disable_delete) { |
|
224 | + $form['actions']['cancel']['#prefix'] = '<li class="tab">'; |
|
225 | + $form['actions']['cancel']['#suffix'] = '</li>'; |
|
226 | + $form['actions']['cancel']['#weight'] = 1003; |
|
227 | + $form['actions']['cancel']['#value'] = l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'account/info/edit'); |
|
228 | + if ($disable_delete) { |
|
229 | 229 | $form['actions']['cancel']['#prefix'] = '<li class="first tab">'; |
230 | - } |
|
230 | + } |
|
231 | 231 | |
232 | - $form['actions']['form control tabs suffix'] = array( |
|
232 | + $form['actions']['form control tabs suffix'] = array( |
|
233 | 233 | '#value' => '</ul>', |
234 | 234 | '#weight' => 1010, |
235 | - ); |
|
235 | + ); |
|
236 | 236 | |
237 | - $form['#redirect'] = 'account/' . $uid; |
|
238 | - $form['#validate'] = array('boincuser_delete_validate'); |
|
239 | - $form['#submit'] = array('boincuser_delete_submit'); |
|
240 | - break; |
|
237 | + $form['#redirect'] = 'account/' . $uid; |
|
238 | + $form['#validate'] = array('boincuser_delete_validate'); |
|
239 | + $form['#submit'] = array('boincuser_delete_submit'); |
|
240 | + break; |
|
241 | 241 | |
242 | - } // switch |
|
242 | + } // switch |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | |
@@ -250,24 +250,24 @@ discard block |
||
250 | 250 | * password. |
251 | 251 | */ |
252 | 252 | function boincuser_delete_validate($form, &$form_state) { |
253 | - require_boinc('boinc_db'); |
|
253 | + require_boinc('boinc_db'); |
|
254 | 254 | |
255 | - if ($form_state['values']['user_delete_action'] == '') { |
|
255 | + if ($form_state['values']['user_delete_action'] == '') { |
|
256 | 256 | form_set_error('user_delete_action', bts('Please select an action to perform using the radio buttons.', array(), NULL, 'boinc:delete-user-account')); |
257 | - } |
|
257 | + } |
|
258 | 258 | |
259 | - // check BOINC user exists |
|
260 | - $account = $form_state['values']['_account']; |
|
261 | - $boinc_user = boincuser_load($account->uid, TRUE); |
|
262 | - if (!$boinc_user) { |
|
259 | + // check BOINC user exists |
|
260 | + $account = $form_state['values']['_account']; |
|
261 | + $boinc_user = boincuser_load($account->uid, TRUE); |
|
262 | + if (!$boinc_user) { |
|
263 | 263 | return form_set_error('current_pass', |
264 | - bts('There was a problem deleting your account. Please contact the site administrators.', array(), NULL, 'boinc:delete-user-account') |
|
264 | + bts('There was a problem deleting your account. Please contact the site administrators.', array(), NULL, 'boinc:delete-user-account') |
|
265 | 265 | ); |
266 | - } |
|
266 | + } |
|
267 | 267 | |
268 | - if (_boincuser_delete_validatepasswd($boinc_user, $form_state['values']['current_pass'])) { |
|
268 | + if (_boincuser_delete_validatepasswd($boinc_user, $form_state['values']['current_pass'])) { |
|
269 | 269 | return true; |
270 | - } |
|
270 | + } |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
@@ -278,39 +278,39 @@ discard block |
||
278 | 278 | * to delete the account. |
279 | 279 | */ |
280 | 280 | function boincuser_delete_submit($form, &$form_state) { |
281 | - require_boinc('token'); |
|
282 | - global $user; |
|
281 | + require_boinc('token'); |
|
282 | + global $user; |
|
283 | 283 | |
284 | - $uid = $form_state['values']['_account']->uid; |
|
285 | - $account = user_load(array('uid' => $uid)); |
|
284 | + $uid = $form_state['values']['_account']->uid; |
|
285 | + $account = user_load(array('uid' => $uid)); |
|
286 | 286 | |
287 | - if (!$account) { |
|
287 | + if (!$account) { |
|
288 | 288 | drupal_set_message(bts('ERROR: The user account @uid does not exist.', array('@uid' => $uid), array(), NULL, 'delete-user-account'), 'error'); |
289 | 289 | watchdog('user', 'Attempted to cancel non-existing user account UID: %uid.', array('%uid' => $uid), WATCHDOG_ERROR); |
290 | 290 | return; |
291 | - } |
|
292 | - |
|
293 | - global $base_url; |
|
294 | - global $base_path; |
|
295 | - module_load_include('inc', 'rules', 'modules/system.rules'); |
|
296 | - $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
297 | - $site_url = $base_url . $base_path . "user/login"; |
|
298 | - |
|
299 | - // Perform the requested operation |
|
300 | - $op = $form_state['values']['user_delete_action']; |
|
301 | - // create token with 1 day/24 hour expiration |
|
302 | - $mytoken = create_token($account->boincuser_id, 'D', 24*60*60); |
|
303 | - switch ($op) { |
|
291 | + } |
|
292 | + |
|
293 | + global $base_url; |
|
294 | + global $base_path; |
|
295 | + module_load_include('inc', 'rules', 'modules/system.rules'); |
|
296 | + $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
297 | + $site_url = $base_url . $base_path . "user/login"; |
|
298 | + |
|
299 | + // Perform the requested operation |
|
300 | + $op = $form_state['values']['user_delete_action']; |
|
301 | + // create token with 1 day/24 hour expiration |
|
302 | + $mytoken = create_token($account->boincuser_id, 'D', 24*60*60); |
|
303 | + switch ($op) { |
|
304 | 304 | case 'boincuser_delete_softdelete': |
305 | 305 | $myurl = "${base_url}/user/{$account->uid}/odeleteconfirm/$mytoken"; |
306 | - break; |
|
306 | + break; |
|
307 | 307 | case 'boincuser_delete_delete': |
308 | 308 | $myurl = "${base_url}/user/{$account->uid}/deleteconfirm/$mytoken"; |
309 | - break; |
|
310 | - } |
|
309 | + break; |
|
310 | + } |
|
311 | 311 | |
312 | - $mysubject = "Instructions for account deletion at {$site_name}"; |
|
313 | - $mymessage = '' |
|
312 | + $mysubject = "Instructions for account deletion at {$site_name}"; |
|
313 | + $mymessage = '' |
|
314 | 314 | . "{$account->boincuser_name},\n" |
315 | 315 | . "\n" |
316 | 316 | . "We have received a request to DELETE your user account at " |
@@ -332,25 +332,25 @@ discard block |
||
332 | 332 | . "\n" |
333 | 333 | . "{$site_name} support team"; |
334 | 334 | |
335 | - // Create array for sending email to user to notify account is being |
|
336 | - // disabled/deleted. Then send email. |
|
337 | - $settings = array( |
|
335 | + // Create array for sending email to user to notify account is being |
|
336 | + // disabled/deleted. Then send email. |
|
337 | + $settings = array( |
|
338 | 338 | 'from' => '', |
339 | 339 | 'subject' => $mysubject, |
340 | 340 | 'message' => $mymessage, |
341 | - ); |
|
342 | - rules_action_mail_to_user($account, $settings); |
|
341 | + ); |
|
342 | + rules_action_mail_to_user($account, $settings); |
|
343 | 343 | |
344 | - drupal_set_message(bts("INFO: You have requested account deletion. Please check your email for further instructions.", array(), NULL, 'boinc:delete-user-account'),'info'); |
|
344 | + drupal_set_message(bts("INFO: You have requested account deletion. Please check your email for further instructions.", array(), NULL, 'boinc:delete-user-account'),'info'); |
|
345 | 345 | |
346 | - $redirect = variable_get('boincuser_delete_redirect', '<front>'); |
|
347 | - // Redirect |
|
348 | - if (!empty($redirect)) { |
|
346 | + $redirect = variable_get('boincuser_delete_redirect', '<front>'); |
|
347 | + // Redirect |
|
348 | + if (!empty($redirect)) { |
|
349 | 349 | drupal_goto($redirect); |
350 | - } |
|
351 | - else { |
|
350 | + } |
|
351 | + else { |
|
352 | 352 | drupal_goto(); |
353 | - } |
|
353 | + } |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | |
@@ -362,77 +362,77 @@ discard block |
||
362 | 362 | * The final confirmation form for the user to delete their account. |
363 | 363 | */ |
364 | 364 | function boincuser_delete_finalconfirmation(&$form_state, $token) { |
365 | - require_boinc('token'); |
|
365 | + require_boinc('token'); |
|
366 | 366 | |
367 | - global $user; |
|
368 | - $form = array(); |
|
367 | + global $user; |
|
368 | + $form = array(); |
|
369 | 369 | |
370 | - // check BOINC user exists |
|
371 | - $account = user_load(array('uid' => $user->uid)); |
|
372 | - $uid = $user->uid; |
|
373 | - $boincid = $account->boincuser_id; |
|
374 | - // check $token is valid |
|
375 | - if (!is_valid_token($boincid, $token, 'D')) { |
|
370 | + // check BOINC user exists |
|
371 | + $account = user_load(array('uid' => $user->uid)); |
|
372 | + $uid = $user->uid; |
|
373 | + $boincid = $account->boincuser_id; |
|
374 | + // check $token is valid |
|
375 | + if (!is_valid_token($boincid, $token, 'D')) { |
|
376 | 376 | drupal_set_message(bts('ERROR: You have supplied an incorrect (most likely expired) token. Please obtain a new token by !link your account be deleted.', |
377 | 377 | array( |
378 | - '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"), |
|
378 | + '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"), |
|
379 | 379 | ), |
380 | 380 | NULL, 'boinc:delete-user-account'), 'error'); |
381 | 381 | drupal_goto(); |
382 | - } |
|
382 | + } |
|
383 | 383 | |
384 | - // Attach account to this form. |
|
385 | - $form['_account'] = array('#type' => 'value', '#value' => $account); |
|
384 | + // Attach account to this form. |
|
385 | + $form['_account'] = array('#type' => 'value', '#value' => $account); |
|
386 | 386 | |
387 | - // This form is for hard/wipe delete |
|
388 | - $form['_action'] = array('#type' => 'value', '#value' => 'hard_wipe'); |
|
387 | + // This form is for hard/wipe delete |
|
388 | + $form['_action'] = array('#type' => 'value', '#value' => 'hard_wipe'); |
|
389 | 389 | |
390 | - // Instructions |
|
391 | - $form['main']['instructions1'] = array( |
|
390 | + // Instructions |
|
391 | + $form['main']['instructions1'] = array( |
|
392 | 392 | '#value' => '<p>'. |
393 | 393 | bts('You are one-step away from deleting your account. Enter your password in the textbox below and click submit. This action is irreversable: once you delete your account, there is no way un-delete.', array(), NULL, 'boinc:delete-user-account'). |
394 | 394 | '</p>', |
395 | - ); |
|
395 | + ); |
|
396 | 396 | |
397 | - $form['main']['instructions2'] = array( |
|
397 | + $form['main']['instructions2'] = array( |
|
398 | 398 | '#value' => '<p>'. |
399 | 399 | bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account'). |
400 | 400 | '</p>', |
401 | - ); |
|
401 | + ); |
|
402 | 402 | |
403 | - // Password field |
|
404 | - $form['main']['current_pass'] = array( |
|
403 | + // Password field |
|
404 | + $form['main']['current_pass'] = array( |
|
405 | 405 | '#type' => 'password', |
406 | 406 | '#title' => bts('Enter your password before clicking Submit', array(), NULL, 'boinc:delete-user-account'), |
407 | 407 | '#size' => 17, |
408 | 408 | '#attributes' => array( |
409 | - 'autocomplete' => 'off', |
|
409 | + 'autocomplete' => 'off', |
|
410 | 410 | ), |
411 | 411 | '#weight' => 25, |
412 | - ); |
|
412 | + ); |
|
413 | 413 | |
414 | - // Form control |
|
415 | - $form['form control tabs prefix'] = array( |
|
414 | + // Form control |
|
415 | + $form['form control tabs prefix'] = array( |
|
416 | 416 | '#value' => '<ul class="form-control tab-list">', |
417 | 417 | '#weight' => 1001, |
418 | - ); |
|
419 | - $form['submit'] = array( |
|
418 | + ); |
|
419 | + $form['submit'] = array( |
|
420 | 420 | '#prefix' => '<li class="first tab">', |
421 | 421 | '#type' => 'submit', |
422 | 422 | '#value' => bts('Submit', array(), NULL, 'boinc:form-submit'), |
423 | 423 | '#suffix' => '</li>', |
424 | 424 | '#weight' => 1002, |
425 | - ); |
|
426 | - $form['form control tabs'] = array( |
|
425 | + ); |
|
426 | + $form['form control tabs'] = array( |
|
427 | 427 | '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>', |
428 | 428 | '#weight' => 1003, |
429 | - ); |
|
430 | - $form['form control tabs suffix'] = array( |
|
429 | + ); |
|
430 | + $form['form control tabs suffix'] = array( |
|
431 | 431 | '#value' => '</ul>', |
432 | 432 | '#weight' => 1004, |
433 | - ); |
|
433 | + ); |
|
434 | 434 | |
435 | - return $form; |
|
435 | + return $form; |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | /** |
@@ -440,122 +440,122 @@ discard block |
||
440 | 440 | * the soft/obfuscate method. |
441 | 441 | */ |
442 | 442 | function boincuser_delete_softdelconfirmation(&$form_state, $token) { |
443 | - require_boinc('token'); |
|
443 | + require_boinc('token'); |
|
444 | 444 | |
445 | - global $user; |
|
446 | - $form = array(); |
|
445 | + global $user; |
|
446 | + $form = array(); |
|
447 | 447 | |
448 | - // check BOINC user exists |
|
449 | - $account = user_load(array('uid' => $user->uid)); |
|
450 | - $uid = $user->uid; |
|
451 | - $boincid = $account->boincuser_id; |
|
448 | + // check BOINC user exists |
|
449 | + $account = user_load(array('uid' => $user->uid)); |
|
450 | + $uid = $user->uid; |
|
451 | + $boincid = $account->boincuser_id; |
|
452 | 452 | |
453 | - // check $token is valid |
|
454 | - if (!is_valid_token($boincid, $token, 'D')) { |
|
453 | + // check $token is valid |
|
454 | + if (!is_valid_token($boincid, $token, 'D')) { |
|
455 | 455 | drupal_set_message(bts('ERROR: You have supplied an incorrect (most likely expired) token. Please obtain a new token by !link your account be deleted.', |
456 | 456 | array( |
457 | - '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"), |
|
457 | + '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"), |
|
458 | 458 | ), |
459 | 459 | NULL, 'boinc:delete-user-account'), 'error'); |
460 | 460 | drupal_goto(); |
461 | - } |
|
461 | + } |
|
462 | 462 | |
463 | - // Attach account to this form. |
|
464 | - $form['_account'] = array('#type' => 'value', '#value' => $account); |
|
463 | + // Attach account to this form. |
|
464 | + $form['_account'] = array('#type' => 'value', '#value' => $account); |
|
465 | 465 | |
466 | - // This form is for hard/wipe delete |
|
467 | - $form['_action'] = array('#type' => 'value', '#value' => 'soft_obfuscate'); |
|
466 | + // This form is for hard/wipe delete |
|
467 | + $form['_action'] = array('#type' => 'value', '#value' => 'soft_obfuscate'); |
|
468 | 468 | |
469 | - // Instructions |
|
470 | - $form['main']['instructions1'] = array( |
|
469 | + // Instructions |
|
470 | + $form['main']['instructions1'] = array( |
|
471 | 471 | '#value' => '<p>'. |
472 | 472 | bts('You are one-step away from deleting your account. Enter your password in the textbox below and click submit. This action is irreversable: once you delete your account, there is no way un-delete.', array(), NULL, 'boinc:delete-user-account'). |
473 | 473 | '</p>', |
474 | - ); |
|
474 | + ); |
|
475 | 475 | |
476 | - $form['main']['instructions2'] = array( |
|
476 | + $form['main']['instructions2'] = array( |
|
477 | 477 | '#value' => '<p>'. |
478 | 478 | bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account'). |
479 | 479 | '</p>', |
480 | - ); |
|
480 | + ); |
|
481 | 481 | |
482 | - // Password field |
|
483 | - $form['main']['current_pass'] = array( |
|
482 | + // Password field |
|
483 | + $form['main']['current_pass'] = array( |
|
484 | 484 | '#type' => 'password', |
485 | 485 | '#title' => bts('Enter your password before clicking Submit', array(), NULL, 'boinc:delete-user-account'), |
486 | 486 | '#size' => 17, |
487 | 487 | '#attributes' => array( |
488 | - 'autocomplete' => 'off', |
|
488 | + 'autocomplete' => 'off', |
|
489 | 489 | ), |
490 | 490 | '#weight' => 25, |
491 | - ); |
|
491 | + ); |
|
492 | 492 | |
493 | - // Form control |
|
494 | - $form['form control tabs prefix'] = array( |
|
493 | + // Form control |
|
494 | + $form['form control tabs prefix'] = array( |
|
495 | 495 | '#value' => '<ul class="form-control tab-list">', |
496 | 496 | '#weight' => 1001, |
497 | - ); |
|
498 | - $form['submit'] = array( |
|
497 | + ); |
|
498 | + $form['submit'] = array( |
|
499 | 499 | '#prefix' => '<li class="first tab">', |
500 | 500 | '#type' => 'submit', |
501 | 501 | '#value' => bts('Submit', array(), NULL, 'boinc:form-submit'), |
502 | 502 | '#suffix' => '</li>', |
503 | 503 | '#weight' => 1002, |
504 | - ); |
|
505 | - $form['form control tabs'] = array( |
|
504 | + ); |
|
505 | + $form['form control tabs'] = array( |
|
506 | 506 | '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>', |
507 | 507 | '#weight' => 1003, |
508 | - ); |
|
509 | - $form['form control tabs suffix'] = array( |
|
508 | + ); |
|
509 | + $form['form control tabs suffix'] = array( |
|
510 | 510 | '#value' => '</ul>', |
511 | 511 | '#weight' => 1004, |
512 | - ); |
|
512 | + ); |
|
513 | 513 | |
514 | - //set validation and submit to the functions below |
|
515 | - $form['#validate'][] = 'boincuser_delete_finalconfirmation_validate'; |
|
516 | - $form['#submit'][] = 'boincuser_delete_finalconfirmation_submit'; |
|
517 | - return $form; |
|
514 | + //set validation and submit to the functions below |
|
515 | + $form['#validate'][] = 'boincuser_delete_finalconfirmation_validate'; |
|
516 | + $form['#submit'][] = 'boincuser_delete_finalconfirmation_submit'; |
|
517 | + return $form; |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | /** |
521 | 521 | * Validation for final confirmation |
522 | 522 | */ |
523 | 523 | function boincuser_delete_finalconfirmation_validate($form, &$form_state) { |
524 | - $account = $form_state['values']['_account']; |
|
525 | - $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
524 | + $account = $form_state['values']['_account']; |
|
525 | + $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
526 | 526 | |
527 | - if (_boincuser_delete_validatepasswd($boinc_user, $form_state['values']['current_pass'])) { |
|
527 | + if (_boincuser_delete_validatepasswd($boinc_user, $form_state['values']['current_pass'])) { |
|
528 | 528 | return true; |
529 | - } |
|
529 | + } |
|
530 | 530 | } |
531 | 531 | |
532 | 532 | /** |
533 | 533 | * Submit for final confirmation |
534 | 534 | */ |
535 | 535 | function boincuser_delete_finalconfirmation_submit($form, &$form_state) { |
536 | - global $user; |
|
536 | + global $user; |
|
537 | 537 | |
538 | - // Delete the user |
|
539 | - $account = $form_state['values']['_account']; |
|
540 | - $action = $form_state['values']['_action']; |
|
541 | - _boincuser_delete_deleteuser($account, $action); |
|
538 | + // Delete the user |
|
539 | + $account = $form_state['values']['_account']; |
|
540 | + $action = $form_state['values']['_action']; |
|
541 | + _boincuser_delete_deleteuser($account, $action); |
|
542 | 542 | |
543 | - // Destroy the current session: |
|
544 | - session_destroy(); |
|
545 | - // Only variables can be passed by reference workaround. |
|
546 | - $null = NULL; |
|
547 | - user_module_invoke('logout', $null, $user); |
|
543 | + // Destroy the current session: |
|
544 | + session_destroy(); |
|
545 | + // Only variables can be passed by reference workaround. |
|
546 | + $null = NULL; |
|
547 | + user_module_invoke('logout', $null, $user); |
|
548 | 548 | |
549 | - // Load the anonymous user |
|
550 | - $user = drupal_anonymous_user(); |
|
549 | + // Load the anonymous user |
|
550 | + $user = drupal_anonymous_user(); |
|
551 | 551 | |
552 | - $redirect = variable_get('boincuser_delete_redirect', '<front>'); |
|
553 | - // Redirect |
|
554 | - if (!empty($redirect)) { |
|
552 | + $redirect = variable_get('boincuser_delete_redirect', '<front>'); |
|
553 | + // Redirect |
|
554 | + if (!empty($redirect)) { |
|
555 | 555 | drupal_goto($redirect); |
556 | - } |
|
557 | - else { |
|
556 | + } |
|
557 | + else { |
|
558 | 558 | drupal_goto(); |
559 | - } |
|
559 | + } |
|
560 | 560 | |
561 | 561 | } |
@@ -94,64 +94,64 @@ discard block |
||
94 | 94 | global $user; |
95 | 95 | |
96 | 96 | switch($form_id) { |
97 | - case 'user_profile_form': |
|
98 | - if ( user_access('delete own account') AND ($form['#uid'] == $user->uid) AND (arg(3)=='') ) { |
|
99 | - $form['delete'] = array( |
|
100 | - '#type' => 'submit', |
|
101 | - '#value' => bts('Delete Account', array(), null, 'boinc:delete-user-account'), |
|
102 | - '#weight' => 1009, |
|
103 | - '#submit' => array('user_edit_delete_submit'), |
|
104 | - '#prefix' => '<li class="tab">', |
|
105 | - '#suffix' => '</li>', |
|
106 | - ); |
|
107 | - } |
|
108 | - else if ( user_access('administer users') ) { |
|
109 | - $form['delete'] = array( |
|
110 | - '#type' => 'submit', |
|
111 | - '#value' => bts('Delete Account', array(), null, 'boinc:delete-user-account'), |
|
112 | - '#weight' => 1009, |
|
113 | - '#submit' => array('_boincuser_delete_goto_admindelete'), |
|
114 | - '#prefix' => '<li class="tab">', |
|
115 | - '#suffix' => '</li>', |
|
116 | - ); |
|
117 | - } |
|
118 | - else { |
|
119 | - unset($form['delete']); |
|
120 | - } |
|
121 | - break; |
|
122 | - case 'user_confirm_delete': |
|
123 | - |
|
124 | - $disable_delete = FALSE; |
|
125 | - // If email address was changed less than 7 days (7 * 86400 s) |
|
126 | - // ago, it cannot be changed again. |
|
127 | - $duration = TOKEN_DURATION_ONE_WEEK; |
|
128 | - if (($form['_account']['#value']->boincuser_email_addr_change_time + $duration) > time()) { |
|
129 | - drupal_set_message( |
|
130 | - bts("INFO: Your email address was changed within the past seven (7) days. You may not delete your account until after !time.", |
|
131 | - array( |
|
132 | - '!time' => date('F j, Y \a\t G:i T', $form['_account']['#value']->boincuser_email_addr_change_time + $duration), |
|
133 | - ), NULL, 'boinc:account-credentials-change') |
|
134 | - , 'info'); |
|
135 | - $disable_delete = TRUE; |
|
136 | - } |
|
137 | - |
|
138 | - // Configure radio options |
|
139 | - $deleteoptions = array( |
|
140 | - 'boincuser_delete_softdelete' => bts('<b>Soft delete</b> the account. Afterwards your account will be disabled, and all posts/comments will be attributed to the Anonymous User. However, your user profile will be deleted, your host information will be deleted, and you will be removed from any team you are a member of.', array(), NULL, 'boinc:delete-user-account'), |
|
141 | - 'boincuser_delete_delete' => bts('<b>Delete</b> the account. Afterwards your account will be deleted, and all posts/comments will be attributed to the Anonymous User. Your user profile will be deleted, and your host information will be deleted.', array(), NULL, 'boinc:delete-user-account'), |
|
97 | + case 'user_profile_form': |
|
98 | + if ( user_access('delete own account') AND ($form['#uid'] == $user->uid) AND (arg(3)=='') ) { |
|
99 | + $form['delete'] = array( |
|
100 | + '#type' => 'submit', |
|
101 | + '#value' => bts('Delete Account', array(), null, 'boinc:delete-user-account'), |
|
102 | + '#weight' => 1009, |
|
103 | + '#submit' => array('user_edit_delete_submit'), |
|
104 | + '#prefix' => '<li class="tab">', |
|
105 | + '#suffix' => '</li>', |
|
142 | 106 | ); |
107 | + } |
|
108 | + else if ( user_access('administer users') ) { |
|
109 | + $form['delete'] = array( |
|
110 | + '#type' => 'submit', |
|
111 | + '#value' => bts('Delete Account', array(), null, 'boinc:delete-user-account'), |
|
112 | + '#weight' => 1009, |
|
113 | + '#submit' => array('_boincuser_delete_goto_admindelete'), |
|
114 | + '#prefix' => '<li class="tab">', |
|
115 | + '#suffix' => '</li>', |
|
116 | + ); |
|
117 | + } |
|
118 | + else { |
|
119 | + unset($form['delete']); |
|
120 | + } |
|
121 | + break; |
|
122 | + case 'user_confirm_delete': |
|
123 | + |
|
124 | + $disable_delete = FALSE; |
|
125 | + // If email address was changed less than 7 days (7 * 86400 s) |
|
126 | + // ago, it cannot be changed again. |
|
127 | + $duration = TOKEN_DURATION_ONE_WEEK; |
|
128 | + if (($form['_account']['#value']->boincuser_email_addr_change_time + $duration) > time()) { |
|
129 | + drupal_set_message( |
|
130 | + bts("INFO: Your email address was changed within the past seven (7) days. You may not delete your account until after !time.", |
|
131 | + array( |
|
132 | + '!time' => date('F j, Y \a\t G:i T', $form['_account']['#value']->boincuser_email_addr_change_time + $duration), |
|
133 | + ), NULL, 'boinc:account-credentials-change') |
|
134 | + , 'info'); |
|
135 | + $disable_delete = TRUE; |
|
136 | + } |
|
137 | + |
|
138 | + // Configure radio options |
|
139 | + $deleteoptions = array( |
|
140 | + 'boincuser_delete_softdelete' => bts('<b>Soft delete</b> the account. Afterwards your account will be disabled, and all posts/comments will be attributed to the Anonymous User. However, your user profile will be deleted, your host information will be deleted, and you will be removed from any team you are a member of.', array(), NULL, 'boinc:delete-user-account'), |
|
141 | + 'boincuser_delete_delete' => bts('<b>Delete</b> the account. Afterwards your account will be deleted, and all posts/comments will be attributed to the Anonymous User. Your user profile will be deleted, and your host information will be deleted.', array(), NULL, 'boinc:delete-user-account'), |
|
142 | + ); |
|
143 | 143 | |
144 | - $dtypes = variable_get('boincuser_delete_type', 'user_decides'); |
|
145 | - // unset the other option if dtype is set. i.e., if dtype is set |
|
146 | - // to soft delete, unset the hard delete option. |
|
147 | - switch ($dtypes) { |
|
148 | - case 'soft_obfuscate': |
|
149 | - unset($deleteoptions['boincuser_delete_delete']); |
|
150 | - break; |
|
151 | - case 'hard_wipe': |
|
152 | - unset($deleteoptions['boincuser_delete_softdelete']); |
|
153 | - break; |
|
154 | - } |
|
144 | + $dtypes = variable_get('boincuser_delete_type', 'user_decides'); |
|
145 | + // unset the other option if dtype is set. i.e., if dtype is set |
|
146 | + // to soft delete, unset the hard delete option. |
|
147 | + switch ($dtypes) { |
|
148 | + case 'soft_obfuscate': |
|
149 | + unset($deleteoptions['boincuser_delete_delete']); |
|
150 | + break; |
|
151 | + case 'hard_wipe': |
|
152 | + unset($deleteoptions['boincuser_delete_softdelete']); |
|
153 | + break; |
|
154 | + } |
|
155 | 155 | |
156 | 156 | $question = 'Are you sure you want to delete the account <em>' . htmlspecialchars($form['_account']['#value']->boincuser_name) . '</em>?'; |
157 | 157 | drupal_set_title($question); |
@@ -301,56 +301,56 @@ discard block |
||
301 | 301 | // create token with 1 day/24 hour expiration |
302 | 302 | $mytoken = create_token($account->boincuser_id, 'D', 24*60*60); |
303 | 303 | switch ($op) { |
304 | - case 'boincuser_delete_softdelete': |
|
305 | - $myurl = "${base_url}/user/{$account->uid}/odeleteconfirm/$mytoken"; |
|
306 | - break; |
|
307 | - case 'boincuser_delete_delete': |
|
308 | - $myurl = "${base_url}/user/{$account->uid}/deleteconfirm/$mytoken"; |
|
304 | + case 'boincuser_delete_softdelete': |
|
305 | + $myurl = "${base_url}/user/{$account->uid}/odeleteconfirm/$mytoken"; |
|
309 | 306 | break; |
310 | - } |
|
311 | - |
|
312 | - $mysubject = "Instructions for account deletion at {$site_name}"; |
|
313 | - $mymessage = '' |
|
314 | - . "{$account->boincuser_name},\n" |
|
315 | - . "\n" |
|
316 | - . "We have received a request to DELETE your user account at " |
|
317 | - . "${site_name}. Below in this email is a one-time token you must " |
|
318 | - . "use. Either click on the link or copy-and-paste the URL into your " |
|
319 | - . "browser address bar. Then you will be required to enter your password " |
|
320 | - . "again to confirm your identity.\n" |
|
321 | - . "\n" |
|
322 | - . "${myurl}\n" |
|
323 | - . "\n" |
|
324 | - . "This one-time token will expire in 24 hours. Afterwards you must " |
|
325 | - . "re-request deletion of your account in order to generate a new token.\n" |
|
326 | - . "\n" |
|
327 | - . "If you did not initiate this request, please login to the " |
|
328 | - . "${site_name} Web site (${site_url}) and " |
|
329 | - . "then contact the administrators.\n" |
|
330 | - . "\n" |
|
331 | - . "Thanks, \n" |
|
332 | - . "\n" |
|
333 | - . "{$site_name} support team"; |
|
334 | - |
|
335 | - // Create array for sending email to user to notify account is being |
|
336 | - // disabled/deleted. Then send email. |
|
337 | - $settings = array( |
|
338 | - 'from' => '', |
|
339 | - 'subject' => $mysubject, |
|
340 | - 'message' => $mymessage, |
|
341 | - ); |
|
342 | - rules_action_mail_to_user($account, $settings); |
|
343 | - |
|
344 | - drupal_set_message(bts("INFO: You have requested account deletion. Please check your email for further instructions.", array(), NULL, 'boinc:delete-user-account'),'info'); |
|
307 | +case 'boincuser_delete_delete': |
|
308 | + $myurl = "${base_url}/user/{$account->uid}/deleteconfirm/$mytoken"; |
|
309 | + break; |
|
310 | +} |
|
345 | 311 | |
346 | - $redirect = variable_get('boincuser_delete_redirect', '<front>'); |
|
347 | - // Redirect |
|
348 | - if (!empty($redirect)) { |
|
349 | - drupal_goto($redirect); |
|
350 | - } |
|
351 | - else { |
|
352 | - drupal_goto(); |
|
353 | - } |
|
312 | +$mysubject = "Instructions for account deletion at {$site_name}"; |
|
313 | +$mymessage = '' |
|
314 | +. "{$account->boincuser_name},\n" |
|
315 | +. "\n" |
|
316 | +. "We have received a request to DELETE your user account at " |
|
317 | +. "${site_name}. Below in this email is a one-time token you must " |
|
318 | +. "use. Either click on the link or copy-and-paste the URL into your " |
|
319 | +. "browser address bar. Then you will be required to enter your password " |
|
320 | +. "again to confirm your identity.\n" |
|
321 | +. "\n" |
|
322 | +. "${myurl}\n" |
|
323 | +. "\n" |
|
324 | +. "This one-time token will expire in 24 hours. Afterwards you must " |
|
325 | +. "re-request deletion of your account in order to generate a new token.\n" |
|
326 | +. "\n" |
|
327 | +. "If you did not initiate this request, please login to the " |
|
328 | +. "${site_name} Web site (${site_url}) and " |
|
329 | +. "then contact the administrators.\n" |
|
330 | +. "\n" |
|
331 | +. "Thanks, \n" |
|
332 | +. "\n" |
|
333 | +. "{$site_name} support team"; |
|
334 | + |
|
335 | +// Create array for sending email to user to notify account is being |
|
336 | +// disabled/deleted. Then send email. |
|
337 | +$settings = array( |
|
338 | +'from' => '', |
|
339 | +'subject' => $mysubject, |
|
340 | +'message' => $mymessage, |
|
341 | +); |
|
342 | +rules_action_mail_to_user($account, $settings); |
|
343 | + |
|
344 | +drupal_set_message(bts("INFO: You have requested account deletion. Please check your email for further instructions.", array(), NULL, 'boinc:delete-user-account'),'info'); |
|
345 | + |
|
346 | +$redirect = variable_get('boincuser_delete_redirect', '<front>'); |
|
347 | +// Redirect |
|
348 | +if (!empty($redirect)) { |
|
349 | +drupal_goto($redirect); |
|
350 | +} |
|
351 | +else { |
|
352 | +drupal_goto(); |
|
353 | +} |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | |
@@ -362,77 +362,77 @@ discard block |
||
362 | 362 | * The final confirmation form for the user to delete their account. |
363 | 363 | */ |
364 | 364 | function boincuser_delete_finalconfirmation(&$form_state, $token) { |
365 | - require_boinc('token'); |
|
366 | - |
|
367 | - global $user; |
|
368 | - $form = array(); |
|
369 | - |
|
370 | - // check BOINC user exists |
|
371 | - $account = user_load(array('uid' => $user->uid)); |
|
372 | - $uid = $user->uid; |
|
373 | - $boincid = $account->boincuser_id; |
|
374 | - // check $token is valid |
|
375 | - if (!is_valid_token($boincid, $token, 'D')) { |
|
376 | - drupal_set_message(bts('ERROR: You have supplied an incorrect (most likely expired) token. Please obtain a new token by !link your account be deleted.', |
|
377 | - array( |
|
378 | - '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"), |
|
379 | - ), |
|
380 | - NULL, 'boinc:delete-user-account'), 'error'); |
|
381 | - drupal_goto(); |
|
382 | - } |
|
383 | - |
|
384 | - // Attach account to this form. |
|
385 | - $form['_account'] = array('#type' => 'value', '#value' => $account); |
|
386 | - |
|
387 | - // This form is for hard/wipe delete |
|
388 | - $form['_action'] = array('#type' => 'value', '#value' => 'hard_wipe'); |
|
389 | - |
|
390 | - // Instructions |
|
391 | - $form['main']['instructions1'] = array( |
|
392 | - '#value' => '<p>'. |
|
393 | - bts('You are one-step away from deleting your account. Enter your password in the textbox below and click submit. This action is irreversable: once you delete your account, there is no way un-delete.', array(), NULL, 'boinc:delete-user-account'). |
|
394 | - '</p>', |
|
395 | - ); |
|
396 | - |
|
397 | - $form['main']['instructions2'] = array( |
|
398 | - '#value' => '<p>'. |
|
399 | - bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account'). |
|
400 | - '</p>', |
|
401 | - ); |
|
402 | - |
|
403 | - // Password field |
|
404 | - $form['main']['current_pass'] = array( |
|
405 | - '#type' => 'password', |
|
406 | - '#title' => bts('Enter your password before clicking Submit', array(), NULL, 'boinc:delete-user-account'), |
|
407 | - '#size' => 17, |
|
408 | - '#attributes' => array( |
|
409 | - 'autocomplete' => 'off', |
|
410 | - ), |
|
411 | - '#weight' => 25, |
|
412 | - ); |
|
413 | - |
|
414 | - // Form control |
|
415 | - $form['form control tabs prefix'] = array( |
|
416 | - '#value' => '<ul class="form-control tab-list">', |
|
417 | - '#weight' => 1001, |
|
418 | - ); |
|
419 | - $form['submit'] = array( |
|
420 | - '#prefix' => '<li class="first tab">', |
|
421 | - '#type' => 'submit', |
|
422 | - '#value' => bts('Submit', array(), NULL, 'boinc:form-submit'), |
|
423 | - '#suffix' => '</li>', |
|
424 | - '#weight' => 1002, |
|
425 | - ); |
|
426 | - $form['form control tabs'] = array( |
|
427 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>', |
|
428 | - '#weight' => 1003, |
|
429 | - ); |
|
430 | - $form['form control tabs suffix'] = array( |
|
431 | - '#value' => '</ul>', |
|
432 | - '#weight' => 1004, |
|
433 | - ); |
|
365 | +require_boinc('token'); |
|
366 | + |
|
367 | +global $user; |
|
368 | +$form = array(); |
|
369 | + |
|
370 | +// check BOINC user exists |
|
371 | +$account = user_load(array('uid' => $user->uid)); |
|
372 | +$uid = $user->uid; |
|
373 | +$boincid = $account->boincuser_id; |
|
374 | +// check $token is valid |
|
375 | +if (!is_valid_token($boincid, $token, 'D')) { |
|
376 | +drupal_set_message(bts('ERROR: You have supplied an incorrect (most likely expired) token. Please obtain a new token by !link your account be deleted.', |
|
377 | +array( |
|
378 | + '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"), |
|
379 | +), |
|
380 | +NULL, 'boinc:delete-user-account'), 'error'); |
|
381 | +drupal_goto(); |
|
382 | +} |
|
434 | 383 | |
435 | - return $form; |
|
384 | +// Attach account to this form. |
|
385 | +$form['_account'] = array('#type' => 'value', '#value' => $account); |
|
386 | + |
|
387 | +// This form is for hard/wipe delete |
|
388 | +$form['_action'] = array('#type' => 'value', '#value' => 'hard_wipe'); |
|
389 | + |
|
390 | +// Instructions |
|
391 | +$form['main']['instructions1'] = array( |
|
392 | +'#value' => '<p>'. |
|
393 | +bts('You are one-step away from deleting your account. Enter your password in the textbox below and click submit. This action is irreversable: once you delete your account, there is no way un-delete.', array(), NULL, 'boinc:delete-user-account'). |
|
394 | +'</p>', |
|
395 | +); |
|
396 | + |
|
397 | +$form['main']['instructions2'] = array( |
|
398 | +'#value' => '<p>'. |
|
399 | +bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account'). |
|
400 | +'</p>', |
|
401 | +); |
|
402 | + |
|
403 | +// Password field |
|
404 | +$form['main']['current_pass'] = array( |
|
405 | +'#type' => 'password', |
|
406 | +'#title' => bts('Enter your password before clicking Submit', array(), NULL, 'boinc:delete-user-account'), |
|
407 | +'#size' => 17, |
|
408 | +'#attributes' => array( |
|
409 | + 'autocomplete' => 'off', |
|
410 | +), |
|
411 | +'#weight' => 25, |
|
412 | +); |
|
413 | + |
|
414 | +// Form control |
|
415 | +$form['form control tabs prefix'] = array( |
|
416 | +'#value' => '<ul class="form-control tab-list">', |
|
417 | +'#weight' => 1001, |
|
418 | +); |
|
419 | +$form['submit'] = array( |
|
420 | +'#prefix' => '<li class="first tab">', |
|
421 | +'#type' => 'submit', |
|
422 | +'#value' => bts('Submit', array(), NULL, 'boinc:form-submit'), |
|
423 | +'#suffix' => '</li>', |
|
424 | +'#weight' => 1002, |
|
425 | +); |
|
426 | +$form['form control tabs'] = array( |
|
427 | +'#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>', |
|
428 | +'#weight' => 1003, |
|
429 | +); |
|
430 | +$form['form control tabs suffix'] = array( |
|
431 | +'#value' => '</ul>', |
|
432 | +'#weight' => 1004, |
|
433 | +); |
|
434 | + |
|
435 | +return $form; |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | /** |
@@ -440,122 +440,122 @@ discard block |
||
440 | 440 | * the soft/obfuscate method. |
441 | 441 | */ |
442 | 442 | function boincuser_delete_softdelconfirmation(&$form_state, $token) { |
443 | - require_boinc('token'); |
|
444 | - |
|
445 | - global $user; |
|
446 | - $form = array(); |
|
447 | - |
|
448 | - // check BOINC user exists |
|
449 | - $account = user_load(array('uid' => $user->uid)); |
|
450 | - $uid = $user->uid; |
|
451 | - $boincid = $account->boincuser_id; |
|
452 | - |
|
453 | - // check $token is valid |
|
454 | - if (!is_valid_token($boincid, $token, 'D')) { |
|
455 | - drupal_set_message(bts('ERROR: You have supplied an incorrect (most likely expired) token. Please obtain a new token by !link your account be deleted.', |
|
456 | - array( |
|
457 | - '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"), |
|
458 | - ), |
|
459 | - NULL, 'boinc:delete-user-account'), 'error'); |
|
460 | - drupal_goto(); |
|
461 | - } |
|
462 | - |
|
463 | - // Attach account to this form. |
|
464 | - $form['_account'] = array('#type' => 'value', '#value' => $account); |
|
465 | - |
|
466 | - // This form is for hard/wipe delete |
|
467 | - $form['_action'] = array('#type' => 'value', '#value' => 'soft_obfuscate'); |
|
468 | - |
|
469 | - // Instructions |
|
470 | - $form['main']['instructions1'] = array( |
|
471 | - '#value' => '<p>'. |
|
472 | - bts('You are one-step away from deleting your account. Enter your password in the textbox below and click submit. This action is irreversable: once you delete your account, there is no way un-delete.', array(), NULL, 'boinc:delete-user-account'). |
|
473 | - '</p>', |
|
474 | - ); |
|
475 | - |
|
476 | - $form['main']['instructions2'] = array( |
|
477 | - '#value' => '<p>'. |
|
478 | - bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account'). |
|
479 | - '</p>', |
|
480 | - ); |
|
481 | - |
|
482 | - // Password field |
|
483 | - $form['main']['current_pass'] = array( |
|
484 | - '#type' => 'password', |
|
485 | - '#title' => bts('Enter your password before clicking Submit', array(), NULL, 'boinc:delete-user-account'), |
|
486 | - '#size' => 17, |
|
487 | - '#attributes' => array( |
|
488 | - 'autocomplete' => 'off', |
|
489 | - ), |
|
490 | - '#weight' => 25, |
|
491 | - ); |
|
492 | - |
|
493 | - // Form control |
|
494 | - $form['form control tabs prefix'] = array( |
|
495 | - '#value' => '<ul class="form-control tab-list">', |
|
496 | - '#weight' => 1001, |
|
497 | - ); |
|
498 | - $form['submit'] = array( |
|
499 | - '#prefix' => '<li class="first tab">', |
|
500 | - '#type' => 'submit', |
|
501 | - '#value' => bts('Submit', array(), NULL, 'boinc:form-submit'), |
|
502 | - '#suffix' => '</li>', |
|
503 | - '#weight' => 1002, |
|
504 | - ); |
|
505 | - $form['form control tabs'] = array( |
|
506 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>', |
|
507 | - '#weight' => 1003, |
|
508 | - ); |
|
509 | - $form['form control tabs suffix'] = array( |
|
510 | - '#value' => '</ul>', |
|
511 | - '#weight' => 1004, |
|
512 | - ); |
|
443 | +require_boinc('token'); |
|
444 | + |
|
445 | +global $user; |
|
446 | +$form = array(); |
|
447 | + |
|
448 | +// check BOINC user exists |
|
449 | +$account = user_load(array('uid' => $user->uid)); |
|
450 | +$uid = $user->uid; |
|
451 | +$boincid = $account->boincuser_id; |
|
452 | + |
|
453 | +// check $token is valid |
|
454 | +if (!is_valid_token($boincid, $token, 'D')) { |
|
455 | +drupal_set_message(bts('ERROR: You have supplied an incorrect (most likely expired) token. Please obtain a new token by !link your account be deleted.', |
|
456 | +array( |
|
457 | + '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"), |
|
458 | +), |
|
459 | +NULL, 'boinc:delete-user-account'), 'error'); |
|
460 | +drupal_goto(); |
|
461 | +} |
|
513 | 462 | |
514 | - //set validation and submit to the functions below |
|
515 | - $form['#validate'][] = 'boincuser_delete_finalconfirmation_validate'; |
|
516 | - $form['#submit'][] = 'boincuser_delete_finalconfirmation_submit'; |
|
517 | - return $form; |
|
463 | +// Attach account to this form. |
|
464 | +$form['_account'] = array('#type' => 'value', '#value' => $account); |
|
465 | + |
|
466 | +// This form is for hard/wipe delete |
|
467 | +$form['_action'] = array('#type' => 'value', '#value' => 'soft_obfuscate'); |
|
468 | + |
|
469 | +// Instructions |
|
470 | +$form['main']['instructions1'] = array( |
|
471 | +'#value' => '<p>'. |
|
472 | +bts('You are one-step away from deleting your account. Enter your password in the textbox below and click submit. This action is irreversable: once you delete your account, there is no way un-delete.', array(), NULL, 'boinc:delete-user-account'). |
|
473 | +'</p>', |
|
474 | +); |
|
475 | + |
|
476 | +$form['main']['instructions2'] = array( |
|
477 | +'#value' => '<p>'. |
|
478 | +bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account'). |
|
479 | +'</p>', |
|
480 | +); |
|
481 | + |
|
482 | +// Password field |
|
483 | +$form['main']['current_pass'] = array( |
|
484 | +'#type' => 'password', |
|
485 | +'#title' => bts('Enter your password before clicking Submit', array(), NULL, 'boinc:delete-user-account'), |
|
486 | +'#size' => 17, |
|
487 | +'#attributes' => array( |
|
488 | + 'autocomplete' => 'off', |
|
489 | +), |
|
490 | +'#weight' => 25, |
|
491 | +); |
|
492 | + |
|
493 | +// Form control |
|
494 | +$form['form control tabs prefix'] = array( |
|
495 | +'#value' => '<ul class="form-control tab-list">', |
|
496 | +'#weight' => 1001, |
|
497 | +); |
|
498 | +$form['submit'] = array( |
|
499 | +'#prefix' => '<li class="first tab">', |
|
500 | +'#type' => 'submit', |
|
501 | +'#value' => bts('Submit', array(), NULL, 'boinc:form-submit'), |
|
502 | +'#suffix' => '</li>', |
|
503 | +'#weight' => 1002, |
|
504 | +); |
|
505 | +$form['form control tabs'] = array( |
|
506 | +'#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>', |
|
507 | +'#weight' => 1003, |
|
508 | +); |
|
509 | +$form['form control tabs suffix'] = array( |
|
510 | +'#value' => '</ul>', |
|
511 | +'#weight' => 1004, |
|
512 | +); |
|
513 | + |
|
514 | +//set validation and submit to the functions below |
|
515 | +$form['#validate'][] = 'boincuser_delete_finalconfirmation_validate'; |
|
516 | +$form['#submit'][] = 'boincuser_delete_finalconfirmation_submit'; |
|
517 | +return $form; |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | /** |
521 | 521 | * Validation for final confirmation |
522 | 522 | */ |
523 | 523 | function boincuser_delete_finalconfirmation_validate($form, &$form_state) { |
524 | - $account = $form_state['values']['_account']; |
|
525 | - $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
524 | +$account = $form_state['values']['_account']; |
|
525 | +$boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
526 | 526 | |
527 | - if (_boincuser_delete_validatepasswd($boinc_user, $form_state['values']['current_pass'])) { |
|
528 | - return true; |
|
529 | - } |
|
527 | +if (_boincuser_delete_validatepasswd($boinc_user, $form_state['values']['current_pass'])) { |
|
528 | +return true; |
|
529 | +} |
|
530 | 530 | } |
531 | 531 | |
532 | 532 | /** |
533 | 533 | * Submit for final confirmation |
534 | 534 | */ |
535 | 535 | function boincuser_delete_finalconfirmation_submit($form, &$form_state) { |
536 | - global $user; |
|
537 | - |
|
538 | - // Delete the user |
|
539 | - $account = $form_state['values']['_account']; |
|
540 | - $action = $form_state['values']['_action']; |
|
541 | - _boincuser_delete_deleteuser($account, $action); |
|
542 | - |
|
543 | - // Destroy the current session: |
|
544 | - session_destroy(); |
|
545 | - // Only variables can be passed by reference workaround. |
|
546 | - $null = NULL; |
|
547 | - user_module_invoke('logout', $null, $user); |
|
548 | - |
|
549 | - // Load the anonymous user |
|
550 | - $user = drupal_anonymous_user(); |
|
551 | - |
|
552 | - $redirect = variable_get('boincuser_delete_redirect', '<front>'); |
|
553 | - // Redirect |
|
554 | - if (!empty($redirect)) { |
|
555 | - drupal_goto($redirect); |
|
556 | - } |
|
557 | - else { |
|
558 | - drupal_goto(); |
|
559 | - } |
|
536 | +global $user; |
|
537 | + |
|
538 | +// Delete the user |
|
539 | +$account = $form_state['values']['_account']; |
|
540 | +$action = $form_state['values']['_action']; |
|
541 | +_boincuser_delete_deleteuser($account, $action); |
|
542 | + |
|
543 | +// Destroy the current session: |
|
544 | +session_destroy(); |
|
545 | +// Only variables can be passed by reference workaround. |
|
546 | +$null = NULL; |
|
547 | +user_module_invoke('logout', $null, $user); |
|
548 | + |
|
549 | +// Load the anonymous user |
|
550 | +$user = drupal_anonymous_user(); |
|
551 | + |
|
552 | +$redirect = variable_get('boincuser_delete_redirect', '<front>'); |
|
553 | +// Redirect |
|
554 | +if (!empty($redirect)) { |
|
555 | +drupal_goto($redirect); |
|
556 | +} |
|
557 | +else { |
|
558 | +drupal_goto(); |
|
559 | +} |
|
560 | 560 | |
561 | 561 | } |
@@ -93,9 +93,9 @@ discard block |
||
93 | 93 | function boincuser_delete_form_alter(&$form, $form_state, $form_id) { |
94 | 94 | global $user; |
95 | 95 | |
96 | - switch($form_id) { |
|
96 | + switch ($form_id) { |
|
97 | 97 | case 'user_profile_form': |
98 | - if ( user_access('delete own account') AND ($form['#uid'] == $user->uid) AND (arg(3)=='') ) { |
|
98 | + if (user_access('delete own account') AND ($form['#uid'] == $user->uid) AND (arg(3) == '')) { |
|
99 | 99 | $form['delete'] = array( |
100 | 100 | '#type' => 'submit', |
101 | 101 | '#value' => bts('Delete Account', array(), null, 'boinc:delete-user-account'), |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | '#suffix' => '</li>', |
106 | 106 | ); |
107 | 107 | } |
108 | - else if ( user_access('administer users') ) { |
|
108 | + else if (user_access('administer users')) { |
|
109 | 109 | $form['delete'] = array( |
110 | 110 | '#type' => 'submit', |
111 | 111 | '#value' => bts('Delete Account', array(), null, 'boinc:delete-user-account'), |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | break; |
154 | 154 | } |
155 | 155 | |
156 | - $question = 'Are you sure you want to delete the account <em>' . htmlspecialchars($form['_account']['#value']->boincuser_name) . '</em>?'; |
|
156 | + $question = 'Are you sure you want to delete the account <em>'.htmlspecialchars($form['_account']['#value']->boincuser_name).'</em>?'; |
|
157 | 157 | drupal_set_title($question); |
158 | 158 | |
159 | 159 | unset($form['description']); |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | |
166 | 166 | $form['main']['help'] = array( |
167 | 167 | '#value' => bts( |
168 | - "<p><b>Instructions:</b> In order to delete your account, you must provide your password below. You will then be sent an email to the email address on record, with a one-time token that expires in 24-hours. Clicking on this link will bring you to a second form where you must enter your password again. After doing so your account will be deleted.</p>" . |
|
168 | + "<p><b>Instructions:</b> In order to delete your account, you must provide your password below. You will then be sent an email to the email address on record, with a one-time token that expires in 24-hours. Clicking on this link will bring you to a second form where you must enter your password again. After doing so your account will be deleted.</p>". |
|
169 | 169 | "<p>If necessary, you may !link first before deleting your account. But you must wait <b>seven (7) days</b> after an email address change before you may delete your account.</p>", |
170 | 170 | array( |
171 | 171 | '!link' => l(bts('change your email address', array(), NULL, 'boinc:delete-user-account'), '/account/info/edit'), |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | '#weight' => 1010, |
235 | 235 | ); |
236 | 236 | |
237 | - $form['#redirect'] = 'account/' . $uid; |
|
237 | + $form['#redirect'] = 'account/'.$uid; |
|
238 | 238 | $form['#validate'] = array('boincuser_delete_validate'); |
239 | 239 | $form['#submit'] = array('boincuser_delete_submit'); |
240 | 240 | break; |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | global $base_path; |
295 | 295 | module_load_include('inc', 'rules', 'modules/system.rules'); |
296 | 296 | $site_name = variable_get('site_name', 'Drupal-BOINC'); |
297 | - $site_url = $base_url . $base_path . "user/login"; |
|
297 | + $site_url = $base_url.$base_path."user/login"; |
|
298 | 298 | |
299 | 299 | // Perform the requested operation |
300 | 300 | $op = $form_state['values']['user_delete_action']; |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | ); |
342 | 342 | rules_action_mail_to_user($account, $settings); |
343 | 343 | |
344 | - drupal_set_message(bts("INFO: You have requested account deletion. Please check your email for further instructions.", array(), NULL, 'boinc:delete-user-account'),'info'); |
|
344 | + drupal_set_message(bts("INFO: You have requested account deletion. Please check your email for further instructions.", array(), NULL, 'boinc:delete-user-account'), 'info'); |
|
345 | 345 | |
346 | 346 | $redirect = variable_get('boincuser_delete_redirect', '<front>'); |
347 | 347 | // Redirect |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | '#weight' => 1002, |
425 | 425 | ); |
426 | 426 | $form['form control tabs'] = array( |
427 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>', |
|
427 | + '#value' => '<li class="tab">'.l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/").'</li>', |
|
428 | 428 | '#weight' => 1003, |
429 | 429 | ); |
430 | 430 | $form['form control tabs suffix'] = array( |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | '#weight' => 1002, |
504 | 504 | ); |
505 | 505 | $form['form control tabs'] = array( |
506 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>', |
|
506 | + '#value' => '<li class="tab">'.l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/").'</li>', |
|
507 | 507 | '#weight' => 1003, |
508 | 508 | ); |
509 | 509 | $form['form control tabs suffix'] = array( |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | |
96 | 96 | switch($form_id) { |
97 | 97 | case 'user_profile_form': |
98 | - if ( user_access('delete own account') AND ($form['#uid'] == $user->uid) AND (arg(3)=='') ) { |
|
98 | + if ( user_access('delete own account') and ($form['#uid'] == $user->uid) and (arg(3)=='') ) { |
|
99 | 99 | $form['delete'] = array( |
100 | 100 | '#type' => 'submit', |
101 | 101 | '#value' => bts('Delete Account', array(), null, 'boinc:delete-user-account'), |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | break; |
122 | 122 | case 'user_confirm_delete': |
123 | 123 | |
124 | - $disable_delete = FALSE; |
|
124 | + $disable_delete = false; |
|
125 | 125 | // If email address was changed less than 7 days (7 * 86400 s) |
126 | 126 | // ago, it cannot be changed again. |
127 | 127 | $duration = TOKEN_DURATION_ONE_WEEK; |
@@ -130,15 +130,15 @@ discard block |
||
130 | 130 | bts("INFO: Your email address was changed within the past seven (7) days. You may not delete your account until after !time.", |
131 | 131 | array( |
132 | 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') |
|
133 | + ), null, 'boinc:account-credentials-change') |
|
134 | 134 | , 'info'); |
135 | - $disable_delete = TRUE; |
|
135 | + $disable_delete = true; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | // Configure radio options |
139 | 139 | $deleteoptions = array( |
140 | - 'boincuser_delete_softdelete' => bts('<b>Soft delete</b> the account. Afterwards your account will be disabled, and all posts/comments will be attributed to the Anonymous User. However, your user profile will be deleted, your host information will be deleted, and you will be removed from any team you are a member of.', array(), NULL, 'boinc:delete-user-account'), |
|
141 | - 'boincuser_delete_delete' => bts('<b>Delete</b> the account. Afterwards your account will be deleted, and all posts/comments will be attributed to the Anonymous User. Your user profile will be deleted, and your host information will be deleted.', array(), NULL, 'boinc:delete-user-account'), |
|
140 | + 'boincuser_delete_softdelete' => bts('<b>Soft delete</b> the account. Afterwards your account will be disabled, and all posts/comments will be attributed to the Anonymous User. However, your user profile will be deleted, your host information will be deleted, and you will be removed from any team you are a member of.', array(), null, 'boinc:delete-user-account'), |
|
141 | + 'boincuser_delete_delete' => bts('<b>Delete</b> the account. Afterwards your account will be deleted, and all posts/comments will be attributed to the Anonymous User. Your user profile will be deleted, and your host information will be deleted.', array(), null, 'boinc:delete-user-account'), |
|
142 | 142 | ); |
143 | 143 | |
144 | 144 | $dtypes = variable_get('boincuser_delete_type', 'user_decides'); |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | "<p><b>Instructions:</b> In order to delete your account, you must provide your password below. You will then be sent an email to the email address on record, with a one-time token that expires in 24-hours. Clicking on this link will bring you to a second form where you must enter your password again. After doing so your account will be deleted.</p>" . |
169 | 169 | "<p>If necessary, you may !link first before deleting your account. But you must wait <b>seven (7) days</b> after an email address change before you may delete your account.</p>", |
170 | 170 | array( |
171 | - '!link' => l(bts('change your email address', array(), NULL, 'boinc:delete-user-account'), '/account/info/edit'), |
|
172 | - ), NULL, 'boinc:delete-user-account'), |
|
171 | + '!link' => l(bts('change your email address', array(), null, 'boinc:delete-user-account'), '/account/info/edit'), |
|
172 | + ), null, 'boinc:delete-user-account'), |
|
173 | 173 | '#weight' => 11, |
174 | 174 | '#prefix' => "<div id='delete-instructions'>", |
175 | 175 | '#suffix' => "</div>", |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | '#weight' => 21, |
182 | 182 | ); |
183 | 183 | if ($disable_delete) { |
184 | - $form['main']['user_delete_action']['#disabled'] = TRUE; |
|
184 | + $form['main']['user_delete_action']['#disabled'] = true; |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | $form['separator_bottom'] = array( |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | if (!$disable_delete) { |
194 | 194 | $form['main']['current_pass'] = array( |
195 | 195 | '#type' => 'password', |
196 | - '#title' => bts('Enter your password before clicking Submit', array(), NULL, 'boinc:delete-user-account'), |
|
196 | + '#title' => bts('Enter your password before clicking Submit', array(), null, 'boinc:delete-user-account'), |
|
197 | 197 | '#size' => 17, |
198 | 198 | '#attributes' => array( |
199 | 199 | 'autocomplete' => 'off', |
@@ -214,17 +214,17 @@ discard block |
||
214 | 214 | unset($form['actions']['#suffix']); |
215 | 215 | $form['actions']['submit']['#prefix'] = '<li class="first tab">'; |
216 | 216 | $form['actions']['submit']['#suffix'] = '</li>'; |
217 | - $form['actions']['submit']['#value'] = bts('Submit', array(), NULL, 'boinc:form-submit'); |
|
217 | + $form['actions']['submit']['#value'] = bts('Submit', array(), null, 'boinc:form-submit'); |
|
218 | 218 | $form['actions']['submit']['#weight'] = 1002; |
219 | 219 | if ($disable_delete) { |
220 | - $form['actions']['submit']['#disabled'] = TRUE; |
|
220 | + $form['actions']['submit']['#disabled'] = true; |
|
221 | 221 | $form['actions']['submit']['#value'] = ''; |
222 | 222 | } |
223 | 223 | |
224 | 224 | $form['actions']['cancel']['#prefix'] = '<li class="tab">'; |
225 | 225 | $form['actions']['cancel']['#suffix'] = '</li>'; |
226 | 226 | $form['actions']['cancel']['#weight'] = 1003; |
227 | - $form['actions']['cancel']['#value'] = l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'account/info/edit'); |
|
227 | + $form['actions']['cancel']['#value'] = l(bts('Cancel', array(), null, 'boinc:form-cancel'), 'account/info/edit'); |
|
228 | 228 | if ($disable_delete) { |
229 | 229 | $form['actions']['cancel']['#prefix'] = '<li class="first tab">'; |
230 | 230 | } |
@@ -253,15 +253,15 @@ discard block |
||
253 | 253 | require_boinc('boinc_db'); |
254 | 254 | |
255 | 255 | if ($form_state['values']['user_delete_action'] == '') { |
256 | - form_set_error('user_delete_action', bts('Please select an action to perform using the radio buttons.', array(), NULL, 'boinc:delete-user-account')); |
|
256 | + form_set_error('user_delete_action', bts('Please select an action to perform using the radio buttons.', array(), null, 'boinc:delete-user-account')); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | // check BOINC user exists |
260 | 260 | $account = $form_state['values']['_account']; |
261 | - $boinc_user = boincuser_load($account->uid, TRUE); |
|
261 | + $boinc_user = boincuser_load($account->uid, true); |
|
262 | 262 | if (!$boinc_user) { |
263 | 263 | return form_set_error('current_pass', |
264 | - bts('There was a problem deleting your account. Please contact the site administrators.', array(), NULL, 'boinc:delete-user-account') |
|
264 | + bts('There was a problem deleting your account. Please contact the site administrators.', array(), null, 'boinc:delete-user-account') |
|
265 | 265 | ); |
266 | 266 | } |
267 | 267 | |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | $account = user_load(array('uid' => $uid)); |
286 | 286 | |
287 | 287 | if (!$account) { |
288 | - drupal_set_message(bts('ERROR: The user account @uid does not exist.', array('@uid' => $uid), array(), NULL, 'delete-user-account'), 'error'); |
|
288 | + drupal_set_message(bts('ERROR: The user account @uid does not exist.', array('@uid' => $uid), array(), null, 'delete-user-account'), 'error'); |
|
289 | 289 | watchdog('user', 'Attempted to cancel non-existing user account UID: %uid.', array('%uid' => $uid), WATCHDOG_ERROR); |
290 | 290 | return; |
291 | 291 | } |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | ); |
342 | 342 | rules_action_mail_to_user($account, $settings); |
343 | 343 | |
344 | - drupal_set_message(bts("INFO: You have requested account deletion. Please check your email for further instructions.", array(), NULL, 'boinc:delete-user-account'),'info'); |
|
344 | + drupal_set_message(bts("INFO: You have requested account deletion. Please check your email for further instructions.", array(), null, 'boinc:delete-user-account'),'info'); |
|
345 | 345 | |
346 | 346 | $redirect = variable_get('boincuser_delete_redirect', '<front>'); |
347 | 347 | // Redirect |
@@ -375,9 +375,9 @@ discard block |
||
375 | 375 | if (!is_valid_token($boincid, $token, 'D')) { |
376 | 376 | drupal_set_message(bts('ERROR: You have supplied an incorrect (most likely expired) token. Please obtain a new token by !link your account be deleted.', |
377 | 377 | array( |
378 | - '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"), |
|
378 | + '!link' => l(bts('re-requesting', array(), null, 'boinc:delete-user-account'), "/user/${uid}/delete"), |
|
379 | 379 | ), |
380 | - NULL, 'boinc:delete-user-account'), 'error'); |
|
380 | + null, 'boinc:delete-user-account'), 'error'); |
|
381 | 381 | drupal_goto(); |
382 | 382 | } |
383 | 383 | |
@@ -390,20 +390,20 @@ discard block |
||
390 | 390 | // Instructions |
391 | 391 | $form['main']['instructions1'] = array( |
392 | 392 | '#value' => '<p>'. |
393 | - bts('You are one-step away from deleting your account. Enter your password in the textbox below and click submit. This action is irreversable: once you delete your account, there is no way un-delete.', array(), NULL, 'boinc:delete-user-account'). |
|
393 | + bts('You are one-step away from deleting your account. Enter your password in the textbox below and click submit. This action is irreversable: once you delete your account, there is no way un-delete.', array(), null, 'boinc:delete-user-account'). |
|
394 | 394 | '</p>', |
395 | 395 | ); |
396 | 396 | |
397 | 397 | $form['main']['instructions2'] = array( |
398 | 398 | '#value' => '<p>'. |
399 | - bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account'). |
|
399 | + bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), null, 'boinc:delete-user-account'). |
|
400 | 400 | '</p>', |
401 | 401 | ); |
402 | 402 | |
403 | 403 | // Password field |
404 | 404 | $form['main']['current_pass'] = array( |
405 | 405 | '#type' => 'password', |
406 | - '#title' => bts('Enter your password before clicking Submit', array(), NULL, 'boinc:delete-user-account'), |
|
406 | + '#title' => bts('Enter your password before clicking Submit', array(), null, 'boinc:delete-user-account'), |
|
407 | 407 | '#size' => 17, |
408 | 408 | '#attributes' => array( |
409 | 409 | 'autocomplete' => 'off', |
@@ -419,12 +419,12 @@ discard block |
||
419 | 419 | $form['submit'] = array( |
420 | 420 | '#prefix' => '<li class="first tab">', |
421 | 421 | '#type' => 'submit', |
422 | - '#value' => bts('Submit', array(), NULL, 'boinc:form-submit'), |
|
422 | + '#value' => bts('Submit', array(), null, 'boinc:form-submit'), |
|
423 | 423 | '#suffix' => '</li>', |
424 | 424 | '#weight' => 1002, |
425 | 425 | ); |
426 | 426 | $form['form control tabs'] = array( |
427 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>', |
|
427 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), null, 'boinc:form-cancel'), "account/") . '</li>', |
|
428 | 428 | '#weight' => 1003, |
429 | 429 | ); |
430 | 430 | $form['form control tabs suffix'] = array( |
@@ -454,9 +454,9 @@ discard block |
||
454 | 454 | if (!is_valid_token($boincid, $token, 'D')) { |
455 | 455 | drupal_set_message(bts('ERROR: You have supplied an incorrect (most likely expired) token. Please obtain a new token by !link your account be deleted.', |
456 | 456 | array( |
457 | - '!link' => l(bts('re-requesting', array(), NULL, 'boinc:delete-user-account'), "/user/${uid}/delete"), |
|
457 | + '!link' => l(bts('re-requesting', array(), null, 'boinc:delete-user-account'), "/user/${uid}/delete"), |
|
458 | 458 | ), |
459 | - NULL, 'boinc:delete-user-account'), 'error'); |
|
459 | + null, 'boinc:delete-user-account'), 'error'); |
|
460 | 460 | drupal_goto(); |
461 | 461 | } |
462 | 462 | |
@@ -469,20 +469,20 @@ discard block |
||
469 | 469 | // Instructions |
470 | 470 | $form['main']['instructions1'] = array( |
471 | 471 | '#value' => '<p>'. |
472 | - bts('You are one-step away from deleting your account. Enter your password in the textbox below and click submit. This action is irreversable: once you delete your account, there is no way un-delete.', array(), NULL, 'boinc:delete-user-account'). |
|
472 | + bts('You are one-step away from deleting your account. Enter your password in the textbox below and click submit. This action is irreversable: once you delete your account, there is no way un-delete.', array(), null, 'boinc:delete-user-account'). |
|
473 | 473 | '</p>', |
474 | 474 | ); |
475 | 475 | |
476 | 476 | $form['main']['instructions2'] = array( |
477 | 477 | '#value' => '<p>'. |
478 | - bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), NULL, 'boinc:delete-user-account'). |
|
478 | + bts('If you wish to cancel, click cancel and you will be taken to your account dashboard.', array(), null, 'boinc:delete-user-account'). |
|
479 | 479 | '</p>', |
480 | 480 | ); |
481 | 481 | |
482 | 482 | // Password field |
483 | 483 | $form['main']['current_pass'] = array( |
484 | 484 | '#type' => 'password', |
485 | - '#title' => bts('Enter your password before clicking Submit', array(), NULL, 'boinc:delete-user-account'), |
|
485 | + '#title' => bts('Enter your password before clicking Submit', array(), null, 'boinc:delete-user-account'), |
|
486 | 486 | '#size' => 17, |
487 | 487 | '#attributes' => array( |
488 | 488 | 'autocomplete' => 'off', |
@@ -498,12 +498,12 @@ discard block |
||
498 | 498 | $form['submit'] = array( |
499 | 499 | '#prefix' => '<li class="first tab">', |
500 | 500 | '#type' => 'submit', |
501 | - '#value' => bts('Submit', array(), NULL, 'boinc:form-submit'), |
|
501 | + '#value' => bts('Submit', array(), null, 'boinc:form-submit'), |
|
502 | 502 | '#suffix' => '</li>', |
503 | 503 | '#weight' => 1002, |
504 | 504 | ); |
505 | 505 | $form['form control tabs'] = array( |
506 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/") . '</li>', |
|
506 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), null, 'boinc:form-cancel'), "account/") . '</li>', |
|
507 | 507 | '#weight' => 1003, |
508 | 508 | ); |
509 | 509 | $form['form control tabs suffix'] = array( |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | // Destroy the current session: |
544 | 544 | session_destroy(); |
545 | 545 | // Only variables can be passed by reference workaround. |
546 | - $null = NULL; |
|
546 | + $null = null; |
|
547 | 547 | user_module_invoke('logout', $null, $user); |
548 | 548 | |
549 | 549 | // Load the anonymous user |
@@ -27,44 +27,44 @@ discard block |
||
27 | 27 | * with defined URL paths |
28 | 28 | */ |
29 | 29 | function boincuser_menu() { |
30 | - $items['account/posts'] = array( |
|
30 | + $items['account/posts'] = array( |
|
31 | 31 | 'title' => 'Recent posts', |
32 | 32 | 'description' => '', |
33 | 33 | 'page callback' => 'boincuser_goto_recent_posts', |
34 | 34 | 'access callback' => 'user_is_logged_in', |
35 | 35 | 'type' => MENU_CALLBACK, |
36 | - ); |
|
37 | - $items['account/profile'] = array( |
|
36 | + ); |
|
37 | + $items['account/profile'] = array( |
|
38 | 38 | 'title' => '', |
39 | 39 | 'description' => '', |
40 | 40 | 'page callback' => 'boincuser_view_profile', |
41 | 41 | 'access callback' => 'user_is_logged_in', |
42 | 42 | 'type' => MENU_NORMAL_ITEM |
43 | - ); |
|
44 | - $items['account/profile/view'] = array( |
|
43 | + ); |
|
44 | + $items['account/profile/view'] = array( |
|
45 | 45 | 'title' => 'View', |
46 | 46 | 'description' => 'Show a user profile', |
47 | 47 | 'page callback' => 'boincuser_view_profile', |
48 | 48 | 'access callback' => 'user_is_logged_in', |
49 | 49 | 'type' => MENU_DEFAULT_LOCAL_TASK, |
50 | 50 | 'weight' => 0 |
51 | - ); |
|
52 | - $items['account/profile/edit'] = array( |
|
51 | + ); |
|
52 | + $items['account/profile/edit'] = array( |
|
53 | 53 | 'title' => 'Edit', |
54 | 54 | 'description' => 'Edit a user profile', |
55 | 55 | 'page callback' => 'boincuser_edit_profile', |
56 | 56 | 'access callback' => 'user_is_logged_in', |
57 | 57 | 'type' => MENU_LOCAL_TASK, |
58 | 58 | 'weight' => 5 |
59 | - ); |
|
60 | - $items['account/team'] = array( |
|
59 | + ); |
|
60 | + $items['account/team'] = array( |
|
61 | 61 | 'title' => 'User team', |
62 | 62 | 'description' => '', |
63 | 63 | 'page callback' => 'boincuser_goto_team', |
64 | 64 | 'access callback' => 'user_is_logged_in', |
65 | 65 | 'type' => MENU_CALLBACK, |
66 | - ); |
|
67 | - $items['moderate/profile/%user/approve'] = array( |
|
66 | + ); |
|
67 | + $items['moderate/profile/%user/approve'] = array( |
|
68 | 68 | 'title' => 'Profile approval', |
69 | 69 | 'description' => 'Approve profile content', |
70 | 70 | 'page callback' => 'boincuser_moderate_profile_approve', |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | 'access arguments' => array('edit any profile content'), |
73 | 73 | 'type' => MENU_CALLBACK, |
74 | 74 | 'weight' => 5 |
75 | - ); |
|
76 | - $items['moderate/profile/%user/edit'] = array( |
|
75 | + ); |
|
76 | + $items['moderate/profile/%user/edit'] = array( |
|
77 | 77 | 'title' => 'Profile editor', |
78 | 78 | 'description' => 'Edit a user profile', |
79 | 79 | 'page callback' => 'boincuser_edit_profile', |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | 'access arguments' => array('edit any profile content'), |
82 | 82 | 'type' => MENU_CALLBACK, |
83 | 83 | 'weight' => 5 |
84 | - ); |
|
85 | - $items['moderate/profile/%/reject'] = array( |
|
84 | + ); |
|
85 | + $items['moderate/profile/%/reject'] = array( |
|
86 | 86 | 'title' => bts('Reject profile', array(), NULL, 'boinc:moderate-user'), |
87 | 87 | 'description' => 'Reject profile content', |
88 | 88 | 'page callback' => 'drupal_get_form', |
@@ -90,60 +90,60 @@ discard block |
||
90 | 90 | 'access arguments' => array('edit any profile content'), |
91 | 91 | 'type' => MENU_CALLBACK, |
92 | 92 | 'weight' => 5 |
93 | - ); |
|
94 | - $items['moderate/user/%/ban'] = array( |
|
93 | + ); |
|
94 | + $items['moderate/user/%/ban'] = array( |
|
95 | 95 | 'title' => bts('Ban user', array(), NULL, 'boinc:moderate-ban-user'), |
96 | 96 | 'description' => 'Ban a user from using community features', |
97 | 97 | 'page callback' => 'drupal_get_form', |
98 | 98 | 'page arguments' => array('boincuser_moderate_user_ban_form', 2), |
99 | 99 | 'access callback' => 'boincuser_moderate_community_access', |
100 | 100 | 'type' => MENU_CALLBACK, |
101 | - ); |
|
102 | - $items['join'] = array( |
|
101 | + ); |
|
102 | + $items['join'] = array( |
|
103 | 103 | 'title' => '', |
104 | 104 | 'description' => '', |
105 | 105 | 'page callback' => 'join_page', |
106 | 106 | 'access arguments' => array('access content'), |
107 | 107 | 'type' => MENU_NORMAL_ITEM |
108 | - ); |
|
109 | - $items['join/new'] = array( |
|
108 | + ); |
|
109 | + $items['join/new'] = array( |
|
110 | 110 | 'title' => bts("I'm new"), |
111 | 111 | 'page callback' => 'join_page', |
112 | 112 | 'page arguments' => array(1), |
113 | 113 | 'access arguments' => array('access content'), |
114 | 114 | 'type' => MENU_DEFAULT_LOCAL_TASK, |
115 | 115 | 'weight' => 0 |
116 | - ); |
|
117 | - $items['join/boinc'] = array( |
|
116 | + ); |
|
117 | + $items['join/boinc'] = array( |
|
118 | 118 | 'title' => bts("I'm a BOINC user"), |
119 | 119 | 'page callback' => 'join_page', |
120 | 120 | 'page arguments' => array(1), |
121 | 121 | 'access arguments' => array('access content'), |
122 | 122 | 'type' => MENU_LOCAL_TASK, |
123 | 123 | 'weight' => 5 |
124 | - ); |
|
125 | - $items['user/login/auth'] = array( |
|
124 | + ); |
|
125 | + $items['user/login/auth'] = array( |
|
126 | 126 | 'title' => bts('Authenticator login', array(), NULL, 'boinc:authenticator-login-page'), |
127 | 127 | 'description' => 'Log in using a user authenticator', |
128 | 128 | 'page callback' => 'drupal_get_form', |
129 | 129 | 'page arguments' => array('boincuser_authloginform'), |
130 | 130 | 'access arguments' => array('access content'), |
131 | 131 | 'type' => MENU_CALLBACK, |
132 | - ); |
|
133 | - $items['user/termsofuse'] = array( |
|
132 | + ); |
|
133 | + $items['user/termsofuse'] = array( |
|
134 | 134 | 'title' => bts('Terms of Use', array(), NULL, 'boinc:termsofuse-form'), |
135 | 135 | 'description' => 'A site\'s term of use.', |
136 | 136 | 'page callback' => 'drupal_get_form', |
137 | 137 | 'page arguments' => array('boincuser_termsofuse_form'), |
138 | 138 | 'access callback' => 'user_is_logged_in', |
139 | 139 | 'type' => MENU_CALLBACK, |
140 | - ); |
|
141 | - $items['user_control'] = array( |
|
140 | + ); |
|
141 | + $items['user_control'] = array( |
|
142 | 142 | 'page callback' => 'boincuser_control', |
143 | 143 | 'access arguments' => array('access user profiles'), |
144 | 144 | 'type' => MENU_CALLBACK |
145 | - ); |
|
146 | - $items['admin/boinc'] = array( |
|
145 | + ); |
|
146 | + $items['admin/boinc'] = array( |
|
147 | 147 | 'title' => 'BOINC configuration', |
148 | 148 | 'position' => 'right', |
149 | 149 | 'weight' => -8, |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | 'access arguments' => array('administer site configuration'), |
152 | 152 | 'file' => 'system.admin.inc', |
153 | 153 | 'file path' => drupal_get_path('module', 'system'), |
154 | - ); |
|
155 | - $items['admin/boinc/environment'] = array( |
|
154 | + ); |
|
155 | + $items['admin/boinc/environment'] = array( |
|
156 | 156 | 'title' => 'Environment: General', |
157 | 157 | 'description' => 'Set paths to BOINC functions and any other necessary |
158 | 158 | variables that establish a BOINC environment.', |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | 'access arguments' => array('administer site configuration'), |
162 | 162 | 'type' => MENU_NORMAL_ITEM, |
163 | 163 | 'file' => 'boincuser.admin.inc' |
164 | - ); |
|
165 | - $items['admin/boinc/scheduler'] = array( |
|
164 | + ); |
|
165 | + $items['admin/boinc/scheduler'] = array( |
|
166 | 166 | 'title' => 'Environment: Scheduling server URLs', |
167 | 167 | 'description' => 'Set BOINC scheduler options.', |
168 | 168 | 'page callback' => 'drupal_get_form', |
@@ -170,8 +170,8 @@ discard block |
||
170 | 170 | 'access arguments' => array('administer site configuration'), |
171 | 171 | 'type' => MENU_NORMAL_ITEM, |
172 | 172 | 'file' => 'boincuser.admin.inc' |
173 | - ); |
|
174 | - $items['admin/boinc/weboptions'] = array( |
|
173 | + ); |
|
174 | + $items['admin/boinc/weboptions'] = array( |
|
175 | 175 | 'title' => 'Environment: Website Options', |
176 | 176 | 'description' => 'Set options configuring this Drupal-BOINC Web site.', |
177 | 177 | 'page callback' => 'drupal_get_form', |
@@ -179,109 +179,109 @@ discard block |
||
179 | 179 | 'access arguments' => array('administer site configuration'), |
180 | 180 | 'type' => MENU_NORMAL_ITEM, |
181 | 181 | 'file' => 'boincuser.admin.inc' |
182 | - ); |
|
182 | + ); |
|
183 | 183 | |
184 | - $items['create_account.php'] = array( |
|
184 | + $items['create_account.php'] = array( |
|
185 | 185 | 'title' => 'Create Account RPC', |
186 | 186 | 'description' => 'RPC for creating user accounts.', |
187 | 187 | 'page callback' => 'boincuser_create_account', |
188 | 188 | 'access callback' => TRUE, |
189 | 189 | 'type' => MENU_CALLBACK |
190 | - ); |
|
191 | - $items['account_finish.php'] = array( |
|
190 | + ); |
|
191 | + $items['account_finish.php'] = array( |
|
192 | 192 | 'title' => 'Welcome to ' . variable_get('site_name', 'Drupal-BOINC'), |
193 | 193 | 'description' => 'RPC for after a user has created an account.', |
194 | 194 | 'page callback' => 'boincuser_account_finish', |
195 | 195 | 'access callback' => TRUE, |
196 | 196 | 'type' => MENU_CALLBACK, |
197 | - ); |
|
198 | - $items['boincuser/autocomplete'] = array( |
|
197 | + ); |
|
198 | + $items['boincuser/autocomplete'] = array( |
|
199 | 199 | 'page callback' => '_boincuser_user_name_autocomplete', |
200 | 200 | 'access callback' => TRUE, |
201 | 201 | 'type' => MENU_CALLBACK, |
202 | - ); |
|
203 | - $items['user/%user/recoveremail/%'] = array( |
|
202 | + ); |
|
203 | + $items['user/%user/recoveremail/%'] = array( |
|
204 | 204 | 'title' => t('Recover previous email'), |
205 | 205 | 'description' => t('Form to revert email to previous address.'), |
206 | 206 | 'page callback' => 'drupal_get_form', |
207 | 207 | 'page arguments' => array('boincuser_revertemail', 3), |
208 | 208 | 'access callback' => 'user_is_logged_in', |
209 | 209 | 'type' => MENU_CALLBACK, |
210 | - ); |
|
211 | - $items['recover_email.php'] = array( |
|
210 | + ); |
|
211 | + $items['recover_email.php'] = array( |
|
212 | 212 | 'title' => t('Recover previous email'), |
213 | 213 | 'description' => t('redirect'), |
214 | 214 | 'page callback' => '_boincuser_redirect_recover_email', |
215 | 215 | 'access callback' => TRUE, |
216 | 216 | 'type' => MENU_CALLBACK, |
217 | - ); |
|
218 | - return $items; |
|
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/') { |
|
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 | 229 | return; |
230 | - } |
|
230 | + } |
|
231 | 231 | |
232 | - // If admin user, do some basic site functionality checks |
|
233 | - if (user_access('administer site configuration')) { |
|
232 | + // If admin user, do some basic site functionality checks |
|
233 | + if (user_access('administer site configuration')) { |
|
234 | 234 | // Ensure we have a configured BOINC environment |
235 | 235 | boinc_get_path(); |
236 | 236 | boinc_get_scheduler_tags(); |
237 | - } |
|
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')) { |
|
242 | + if (module_exists('boincteam')) { |
|
243 | 243 | // Display any persistent team messages |
244 | 244 | boincteam_show_messages(); |
245 | - } |
|
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) ) { |
|
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 | 253 | if ( !boincuser_check_termsofuse($user) and ($existinguser_tou) ) { |
254 | 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])) { |
|
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 | 259 | $path = drupal_get_path_alias($_GET['q']); |
260 | 260 | |
261 | 261 | // Any paths that should NOT be redirected go here. |
262 | 262 | // @todo - replace this static array with one that allows |
263 | 263 | // admins to specify custom paths (patterns) to ignore. |
264 | 264 | $paths_to_ignore = array( |
265 | - 'user/termsofuse', |
|
266 | - 'logout', |
|
267 | - 'privacy', |
|
268 | - 'moderation', |
|
269 | - 'account/info/edit', |
|
270 | - 'user/' . $user->uid . '/edit', |
|
271 | - 'user/' . $user->uid . '/recoveremail/*', |
|
272 | - 'recover_email.php', |
|
265 | + 'user/termsofuse', |
|
266 | + 'logout', |
|
267 | + 'privacy', |
|
268 | + 'moderation', |
|
269 | + 'account/info/edit', |
|
270 | + 'user/' . $user->uid . '/edit', |
|
271 | + 'user/' . $user->uid . '/recoveremail/*', |
|
272 | + 'recover_email.php', |
|
273 | 273 | ); |
274 | 274 | if (module_exists('boincuser_delete')) { |
275 | - $paths_to_ignore[] = 'user/' . $user->uid . '/delete'; |
|
276 | - $paths_to_ignore[] = 'user/' . $user->uid . '/deleteconfirm/*'; |
|
277 | - $paths_to_ignore[] = 'user/' . $user->uid . '/odeleteconfirm/*'; |
|
275 | + $paths_to_ignore[] = 'user/' . $user->uid . '/delete'; |
|
276 | + $paths_to_ignore[] = 'user/' . $user->uid . '/deleteconfirm/*'; |
|
277 | + $paths_to_ignore[] = 'user/' . $user->uid . '/odeleteconfirm/*'; |
|
278 | 278 | } |
279 | 279 | if (!_boincuser_ignore_paths($path, $paths_to_ignore)) { |
280 | - drupal_goto('user/termsofuse'); |
|
280 | + drupal_goto('user/termsofuse'); |
|
281 | + } |
|
281 | 282 | } |
282 | - } |
|
283 | 283 | } |
284 | - } |
|
284 | + } |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | /** |
@@ -289,13 +289,13 @@ discard block |
||
289 | 289 | * Drupal user operations |
290 | 290 | */ |
291 | 291 | function boincuser_user($op, &$edit, &$account, $category = NULL) { |
292 | - require_boinc('boinc_db'); |
|
293 | - require_boinc('user'); |
|
294 | - require_boinc('xml'); |
|
292 | + require_boinc('boinc_db'); |
|
293 | + require_boinc('user'); |
|
294 | + require_boinc('xml'); |
|
295 | 295 | |
296 | - require_boinc('password_compat/password'); |
|
297 | - // Handle BOINC integration for users with UID > 1 (skip anonymous and admin) |
|
298 | - if ($account->uid > 1) { |
|
296 | + require_boinc('password_compat/password'); |
|
297 | + // Handle BOINC integration for users with UID > 1 (skip anonymous and admin) |
|
298 | + if ($account->uid > 1) { |
|
299 | 299 | switch($op) { |
300 | 300 | case 'load': |
301 | 301 | // User loading; insert BOINC data into the user object |
@@ -303,11 +303,11 @@ discard block |
||
303 | 303 | SELECT boinc_id, penalty_expiration |
304 | 304 | FROM {boincuser} WHERE uid = %d", |
305 | 305 | $account->uid |
306 | - )); |
|
307 | - $account->boincuser_id = $drupal_user->boinc_id; |
|
308 | - $account->boincuser_penalty_expiration = $drupal_user->penalty_expiration; |
|
309 | - db_set_active('boinc_rw'); |
|
310 | - $boinc_user = db_fetch_object(db_query(" |
|
306 | + )); |
|
307 | + $account->boincuser_id = $drupal_user->boinc_id; |
|
308 | + $account->boincuser_penalty_expiration = $drupal_user->penalty_expiration; |
|
309 | + db_set_active('boinc_rw'); |
|
310 | + $boinc_user = db_fetch_object(db_query(" |
|
311 | 311 | SELECT |
312 | 312 | name, |
313 | 313 | authenticator, |
@@ -323,29 +323,29 @@ discard block |
||
323 | 323 | FROM {user} |
324 | 324 | WHERE id = %d", |
325 | 325 | $account->boincuser_id |
326 | - )); |
|
327 | - $account->boincuser_name = $boinc_user->name; |
|
328 | - $account->boincuser_account_key = $boinc_user->authenticator; |
|
329 | - $account->boincuser_weak_auth = md5($boinc_user->authenticator . $boinc_user->passwd_hash); |
|
330 | - $account->boincuser_total_credit = round($boinc_user->total_credit); |
|
331 | - $account->boincuser_expavg_credit = round($boinc_user->expavg_credit); |
|
332 | - $account->boincuser_expavg_time = round($boinc_user->expavg_time); |
|
333 | - $account->boincuser_cpid = md5($boinc_user->cross_project_id . $account->mail); |
|
334 | - $account->boincuser_default_pref_set = $boinc_user->venue; |
|
335 | - $account->boincteam_id = $boinc_user->teamid; |
|
336 | - $account->boincuser_previous_email_addr = $boinc_user->previous_email_addr; |
|
337 | - $account->boincuser_email_addr_change_time = $boinc_user->email_addr_change_time; |
|
338 | - db_set_active('default'); |
|
339 | - // Set Drupal team ID |
|
340 | - $account->team = NULL; |
|
341 | - if ($account->boincteam_id) { |
|
326 | + )); |
|
327 | + $account->boincuser_name = $boinc_user->name; |
|
328 | + $account->boincuser_account_key = $boinc_user->authenticator; |
|
329 | + $account->boincuser_weak_auth = md5($boinc_user->authenticator . $boinc_user->passwd_hash); |
|
330 | + $account->boincuser_total_credit = round($boinc_user->total_credit); |
|
331 | + $account->boincuser_expavg_credit = round($boinc_user->expavg_credit); |
|
332 | + $account->boincuser_expavg_time = round($boinc_user->expavg_time); |
|
333 | + $account->boincuser_cpid = md5($boinc_user->cross_project_id . $account->mail); |
|
334 | + $account->boincuser_default_pref_set = $boinc_user->venue; |
|
335 | + $account->boincteam_id = $boinc_user->teamid; |
|
336 | + $account->boincuser_previous_email_addr = $boinc_user->previous_email_addr; |
|
337 | + $account->boincuser_email_addr_change_time = $boinc_user->email_addr_change_time; |
|
338 | + db_set_active('default'); |
|
339 | + // Set Drupal team ID |
|
340 | + $account->team = NULL; |
|
341 | + if ($account->boincteam_id) { |
|
342 | 342 | $account->team = db_result(db_query(" |
343 | 343 | SELECT nid FROM {boincteam} WHERE team_id = %d", |
344 | - $account->boincteam_id |
|
344 | + $account->boincteam_id |
|
345 | 345 | )); |
346 | - } |
|
347 | - // Set post count |
|
348 | - $account->post_count = db_result(db_query(" |
|
346 | + } |
|
347 | + // Set post count |
|
348 | + $account->post_count = db_result(db_query(" |
|
349 | 349 | SELECT COUNT(*) + |
350 | 350 | ( |
351 | 351 | SELECT COUNT(*) FROM {node} |
@@ -358,8 +358,8 @@ discard block |
||
358 | 358 | WHERE comments.uid = '%d' |
359 | 359 | AND node.status = 1", |
360 | 360 | $account->uid, $account->uid |
361 | - )); |
|
362 | - break; |
|
361 | + )); |
|
362 | + break; |
|
363 | 363 | |
364 | 364 | case 'view': |
365 | 365 | // SAMPLE: Add BOINC data to the user profile |
@@ -385,71 +385,71 @@ discard block |
||
385 | 385 | case 'user_account': |
386 | 386 | // Validate data before updating user account info |
387 | 387 | boincuser_account_validate($edit, $account); |
388 | - break; |
|
388 | + break; |
|
389 | 389 | |
390 | 390 | default: |
391 | 391 | |
392 | 392 | } |
393 | 393 | // We don't want to save validation source, so remove it |
394 | 394 | $edit['validation_source'] = null; |
395 | - } |
|
396 | - break; |
|
395 | + } |
|
396 | + break; |
|
397 | 397 | |
398 | 398 | case 'insert': |
399 | 399 | // New user being added to the system |
400 | 400 | $imported = $_SESSION['importedUser']; |
401 | - unset($_SESSION['importedUser']); |
|
401 | + unset($_SESSION['importedUser']); |
|
402 | 402 | |
403 | - watchdog( |
|
403 | + watchdog( |
|
404 | 404 | 'boincuser', |
405 | 405 | 'Creating user account for %email_addr', |
406 | 406 | array('%email_addr' => $edit['mail']), |
407 | 407 | WATCHDOG_NOTICE |
408 | - ); |
|
408 | + ); |
|
409 | 409 | |
410 | - // The create_acount RPC will call this block of code when |
|
411 | - // user_save() is used. If user is registering using the Web |
|
412 | - // registration form, create a BOINC user and relationships. |
|
413 | - // Create a BOINC account unless importing from BOINC. |
|
414 | - if (!$imported) { |
|
410 | + // The create_acount RPC will call this block of code when |
|
411 | + // user_save() is used. If user is registering using the Web |
|
412 | + // registration form, create a BOINC user and relationships. |
|
413 | + // Create a BOINC account unless importing from BOINC. |
|
414 | + if (!$imported) { |
|
415 | 415 | |
416 | 416 | if ($edit['boincuser_name']) { |
417 | - $myname = $edit['boincuser_name']; |
|
417 | + $myname = $edit['boincuser_name']; |
|
418 | 418 | } |
419 | 419 | else if ($edit['name']) { |
420 | - $myname = $edit['name']; |
|
420 | + $myname = $edit['name']; |
|
421 | 421 | } |
422 | 422 | else { |
423 | - $myname = 'noname'; |
|
423 | + $myname = 'noname'; |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | $user_params = array( |
427 | - 'email_addr' => $edit['mail'], |
|
428 | - 'name' => $myname, |
|
427 | + 'email_addr' => $edit['mail'], |
|
428 | + 'name' => $myname, |
|
429 | 429 | ); |
430 | 430 | |
431 | 431 | // If the 'pass' variable is already a hash, then don't hash it again. |
432 | 432 | if ($edit['boinchash_flag']) { |
433 | - $user_params['passwd_hash'] = $edit['pass']; |
|
433 | + $user_params['passwd_hash'] = $edit['pass']; |
|
434 | 434 | } |
435 | 435 | else { |
436 | - // The passwd_hash here is only the md5() hash. This is |
|
437 | - // because BOINC make_user(), called later, will run |
|
438 | - // password_hash() on this md5 hash. |
|
439 | - $user_params['passwd_hash'] = md5($edit['pass'].$edit['mail']); |
|
436 | + // The passwd_hash here is only the md5() hash. This is |
|
437 | + // because BOINC make_user(), called later, will run |
|
438 | + // password_hash() on this md5 hash. |
|
439 | + $user_params['passwd_hash'] = md5($edit['pass'].$edit['mail']); |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | $boinc_user = boincuser_register_make_user($user_params); |
443 | 443 | if (!$boinc_user) { |
444 | - // Account exists with this email addr |
|
445 | - form_set_error('email', bts('Error creating BOINC account.', array(), NULL, 'boinc:add-new-user')); |
|
446 | - return; |
|
444 | + // Account exists with this email addr |
|
445 | + form_set_error('email', bts('Error creating BOINC account.', array(), NULL, 'boinc:add-new-user')); |
|
446 | + return; |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | // Add user to community role by default (not banned) |
450 | 450 | $unrestricted_role = array_search('community member', user_roles(true)); |
451 | 451 | $edit['roles'] = array( |
452 | - $unrestricted_role => '' |
|
452 | + $unrestricted_role => '' |
|
453 | 453 | ); |
454 | 454 | |
455 | 455 | // Disable show_hosts flag, set to TRUE by default |
@@ -460,21 +460,21 @@ discard block |
||
460 | 460 | // Cross reference Drupal account with BOINC |
461 | 461 | $reference = db_query("INSERT INTO {boincuser} SET uid='%d', boinc_id='%d'", $account->uid, $boinc_user->id); |
462 | 462 | if (!$reference) { |
463 | - drupal_set_message(t('Error connecting BOINC account.'), 'error'); |
|
464 | - return; |
|
463 | + drupal_set_message(t('Error connecting BOINC account.'), 'error'); |
|
464 | + return; |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | // if terms of use exist, the user must agree. |
468 | 468 | $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
469 | 469 | if (!empty($termsofuse)) { |
470 | - $reference2 = boincuser_consentto_termsofuse($account); |
|
470 | + $reference2 = boincuser_consentto_termsofuse($account); |
|
471 | 471 | } |
472 | 472 | |
473 | 473 | // Don't save custom fields to the Drupal user object |
474 | 474 | $edit['boincuser_name'] = null; |
475 | 475 | $edit['boinchash_flag'] = null; |
476 | - } |
|
477 | - break; |
|
476 | + } |
|
477 | + break; |
|
478 | 478 | |
479 | 479 | case 'update': |
480 | 480 | if (isset($edit['update_source'])) { |
@@ -485,8 +485,8 @@ discard block |
||
485 | 485 | // Ensure that BOINC data is altered |
486 | 486 | |
487 | 487 | $changing_email = ($edit['mail'] AND $edit['mail'] != $boinc_user->email_addr) ? true : false; |
488 | - $changing_pass = ($edit['pass']) ? true : false; |
|
489 | - if ($changing_email OR $changing_pass) { |
|
488 | + $changing_pass = ($edit['pass']) ? true : false; |
|
489 | + if ($changing_email OR $changing_pass) { |
|
490 | 490 | // Set password hash appropriately |
491 | 491 | $passwd = ($edit['pass']) ? $edit['pass'] : $edit['current_pass']; |
492 | 492 | $passwd_hash = password_hash( md5($passwd.$edit['mail']), PASSWORD_DEFAULT ); |
@@ -494,65 +494,65 @@ discard block |
||
494 | 494 | |
495 | 495 | // Algorithm for changing email and/or password |
496 | 496 | if ($changing_email) { |
497 | - // locally store current email to set as previous email |
|
498 | - $prev_email = $account->mail; |
|
499 | - $mytime = (user_access('administer users')) ? $boinc_user->email_addr_change_time : time(); |
|
500 | - $querypart = "email_addr='{$email_addr}', passwd_hash='{$passwd_hash}', previous_email_addr = '{$prev_email}', email_addr_change_time = $mytime"; |
|
497 | + // locally store current email to set as previous email |
|
498 | + $prev_email = $account->mail; |
|
499 | + $mytime = (user_access('administer users')) ? $boinc_user->email_addr_change_time : time(); |
|
500 | + $querypart = "email_addr='{$email_addr}', passwd_hash='{$passwd_hash}', previous_email_addr = '{$prev_email}', email_addr_change_time = $mytime"; |
|
501 | 501 | } |
502 | 502 | else { |
503 | - $querypart = "email_addr='{$email_addr}', passwd_hash='{$passwd_hash}'"; |
|
503 | + $querypart = "email_addr='{$email_addr}', passwd_hash='{$passwd_hash}'"; |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | // Update user account information |
507 | 507 | $result = $boinc_user->update($querypart); |
508 | 508 | |
509 | 509 | if ($changing_email) { |
510 | - // reload account |
|
511 | - $account = user_load($account->uid); |
|
512 | - _boincuser_send_emailchange($account, $email_addr, $prev_email, user_access('administer users')); |
|
510 | + // reload account |
|
511 | + $account = user_load($account->uid); |
|
512 | + _boincuser_send_emailchange($account, $email_addr, $prev_email, user_access('administer users')); |
|
513 | + } |
|
513 | 514 | } |
514 | - } |
|
515 | 515 | |
516 | - // Change boinc username |
|
517 | - if ($edit['boincuser_name'] and ($edit['boincuser_name'] != $boinc_user->name)) { |
|
516 | + // Change boinc username |
|
517 | + if ($edit['boincuser_name'] and ($edit['boincuser_name'] != $boinc_user->name)) { |
|
518 | 518 | $boincuser_name = $edit['boincuser_name']; |
519 | 519 | $result = $boinc_user->update( |
520 | 520 | "name='{$boincuser_name}'" |
521 | 521 | ); |
522 | - } |
|
522 | + } |
|
523 | 523 | |
524 | - break; |
|
524 | + break; |
|
525 | 525 | case 'user_profile': |
526 | 526 | if ($edit['boincuser_name'] != $boinc_user->name) { |
527 | 527 | $boincuser_name = $edit['boincuser_name']; |
528 | 528 | $result = $boinc_user->update( |
529 | 529 | "name='{$boincuser_name}'" |
530 | 530 | ); |
531 | - } |
|
532 | - break; |
|
531 | + } |
|
532 | + break; |
|
533 | 533 | default: |
534 | 534 | } |
535 | 535 | // We don't want to save update source or duplicate custom fields, so |
536 | 536 | // remove them before continuing to core Drupal routines |
537 | 537 | $edit['update_source'] = null; |
538 | 538 | $edit['boincuser_name'] = null; |
539 | - } |
|
540 | - break; |
|
539 | + } |
|
540 | + break; |
|
541 | 541 | |
542 | 542 | case 'login': |
543 | 543 | // Function is forward compatible to Drupal 7 |
544 | 544 | boincuser_user_login($edit, $account); |
545 | - break; |
|
545 | + break; |
|
546 | 546 | |
547 | 547 | case 'delete': |
548 | 548 | // Function is forward compatible to Drupal 7 |
549 | 549 | boincuser_user_delete($account); |
550 | - break; |
|
550 | + break; |
|
551 | 551 | |
552 | 552 | default: |
553 | 553 | |
554 | 554 | } |
555 | - } |
|
555 | + } |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | /** |
@@ -561,39 +561,39 @@ discard block |
||
561 | 561 | *(forward compatible to Drupal 7). |
562 | 562 | */ |
563 | 563 | function boincuser_user_login(&$edit, $account) { |
564 | - $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE); |
|
565 | - $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
566 | - |
|
567 | - // Use the same code as boincuser_form_alter(), for case |
|
568 | - // 'user_profile_form', if the refering page is the user password |
|
569 | - // reset form, then do not check for terms of use. |
|
570 | - $reset_pass = (strpos($_SERVER['HTTP_REFERER'], "/user/reset/$account->uid") === FALSE) ? 0 : 1; |
|
571 | - if ($reset_pass) { |
|
564 | + $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE); |
|
565 | + $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
566 | + |
|
567 | + // Use the same code as boincuser_form_alter(), for case |
|
568 | + // 'user_profile_form', if the refering page is the user password |
|
569 | + // reset form, then do not check for terms of use. |
|
570 | + $reset_pass = (strpos($_SERVER['HTTP_REFERER'], "/user/reset/$account->uid") === FALSE) ? 0 : 1; |
|
571 | + if ($reset_pass) { |
|
572 | 572 | return; |
573 | - } |
|
573 | + } |
|
574 | 574 | |
575 | - // Check if user has agreed to terms of use. |
|
576 | - if ( (!empty($termsofuse)) and ($account->uid) and |
|
575 | + // Check if user has agreed to terms of use. |
|
576 | + if ( (!empty($termsofuse)) and ($account->uid) and |
|
577 | 577 | (!boincuser_check_termsofuse($account)) and ($existinguser_tou) ) { |
578 | 578 | |
579 | 579 | // Admins are exempted. |
580 | 580 | $administrator_role = array_search('administrator', user_roles(true)); |
581 | 581 | if (!isset($account->roles[$administrator_role])) { |
582 | 582 | |
583 | - // Find and save the current destination and use as an parameter |
|
584 | - // to send the user back to here he/she came from. |
|
585 | - $np = ltrim('user/termsofuse', '/'); |
|
586 | - $path_for_destination = rawurlencode($np); |
|
583 | + // Find and save the current destination and use as an parameter |
|
584 | + // to send the user back to here he/she came from. |
|
585 | + $np = ltrim('user/termsofuse', '/'); |
|
586 | + $path_for_destination = rawurlencode($np); |
|
587 | 587 | |
588 | - $query_for_destination = ''; |
|
589 | - $prevdest = $_REQUEST['destination']; |
|
590 | - if ($prevdest) { |
|
588 | + $query_for_destination = ''; |
|
589 | + $prevdest = $_REQUEST['destination']; |
|
590 | + if ($prevdest) { |
|
591 | 591 | $query_for_destination = '?destination=' . $prevdest; |
592 | - } |
|
593 | - $_REQUEST['destination'] = $path_for_destination . $query_for_destination; |
|
592 | + } |
|
593 | + $_REQUEST['destination'] = $path_for_destination . $query_for_destination; |
|
594 | 594 | |
595 | 595 | } |
596 | - } |
|
596 | + } |
|
597 | 597 | } |
598 | 598 | |
599 | 599 | /** |
@@ -602,16 +602,16 @@ discard block |
||
602 | 602 | */ |
603 | 603 | function boincuser_user_delete($account) { |
604 | 604 | |
605 | - $boincid = $account->boincuser_id; |
|
606 | - // bug in comment module, remove user name from comments. Find all |
|
607 | - // comments with uid=0 and clear the field 'name'. |
|
608 | - $qrc1 = db_query("UPDATE {comments} SET comments.name='' WHERE comments.uid=0"); |
|
605 | + $boincid = $account->boincuser_id; |
|
606 | + // bug in comment module, remove user name from comments. Find all |
|
607 | + // comments with uid=0 and clear the field 'name'. |
|
608 | + $qrc1 = db_query("UPDATE {comments} SET comments.name='' WHERE comments.uid=0"); |
|
609 | 609 | |
610 | - // Delete entry in drupal boincuser table. |
|
611 | - $qrc2 = db_query("DELETE FROM {boincuser} WHERE uid=%d", $account->uid); |
|
612 | - if (!$qrc2) { |
|
610 | + // Delete entry in drupal boincuser table. |
|
611 | + $qrc2 = db_query("DELETE FROM {boincuser} WHERE uid=%d", $account->uid); |
|
612 | + if (!$qrc2) { |
|
613 | 613 | watchdog('user', 'Error deleting user account, boincuser table UID: %uid.', array('%uid' => $account->uid), WATCHDOG_ERROR); |
614 | - } |
|
614 | + } |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | |
@@ -620,13 +620,13 @@ discard block |
||
620 | 620 | * Obsolete in Drupal 7... |
621 | 621 | */ |
622 | 622 | function boincuser_nodeapi(&$node, $op, $a3 = null, $a4 = null) { |
623 | - // In Drupal 7, these operation cases will all exist as their own hooks, |
|
624 | - // so let's approximate that here so that this function can simply be removed |
|
625 | - // upon migration to 7 |
|
626 | - switch($op) { |
|
627 | - case 'update': |
|
623 | + // In Drupal 7, these operation cases will all exist as their own hooks, |
|
624 | + // so let's approximate that here so that this function can simply be removed |
|
625 | + // upon migration to 7 |
|
626 | + switch($op) { |
|
627 | + case 'update': |
|
628 | 628 | boincuser_node_update($node); |
629 | - } |
|
629 | + } |
|
630 | 630 | } |
631 | 631 | |
632 | 632 | /** |
@@ -634,8 +634,8 @@ discard block |
||
634 | 634 | * is updated (forward compatible to Drupal 7) |
635 | 635 | */ |
636 | 636 | function boincuser_node_update($node) { |
637 | - switch($node->type) { |
|
638 | - case 'profile': |
|
637 | + switch($node->type) { |
|
638 | + case 'profile': |
|
639 | 639 | // Update the BOINC database directly |
640 | 640 | $account = user_load($node->uid); |
641 | 641 | // Save user account data |
@@ -647,11 +647,11 @@ discard block |
||
647 | 647 | UPDATE user |
648 | 648 | SET country = '%s', postal_code = '%s', url = '%s', has_profile = 1 |
649 | 649 | WHERE id = %d", |
650 | - $country, $postal_code, $url, $account->boincuser_id |
|
650 | + $country, $postal_code, $url, $account->boincuser_id |
|
651 | 651 | ); |
652 | 652 | db_set_active('default'); |
653 | 653 | if (!$account_updated) { |
654 | - drupal_set_message(t('Error saving BOINC account info.'), 'error'); |
|
654 | + drupal_set_message(t('Error saving BOINC account info.'), 'error'); |
|
655 | 655 | } |
656 | 656 | // Save profile data |
657 | 657 | $response1 = $node->field_background[0]['value']; |
@@ -662,16 +662,16 @@ discard block |
||
662 | 662 | SET userid = %d, response1 = '%s', response2 = '%s' |
663 | 663 | ON DUPLICATE KEY UPDATE |
664 | 664 | response1 = '%s', response2 = '%s'", |
665 | - $account->boincuser_id, $response1, $response2, |
|
666 | - $response1, $response2 |
|
665 | + $account->boincuser_id, $response1, $response2, |
|
666 | + $response1, $response2 |
|
667 | 667 | ); |
668 | 668 | db_set_active('default'); |
669 | 669 | if (!$profile_updated) { |
670 | - drupal_set_message(t('Error saving BOINC profile.'), 'error'); |
|
670 | + drupal_set_message(t('Error saving BOINC profile.'), 'error'); |
|
671 | 671 | } |
672 | 672 | break; |
673 | 673 | |
674 | - default: |
|
674 | + default: |
|
675 | 675 | |
676 | 676 | } |
677 | 677 | } |
@@ -680,21 +680,21 @@ discard block |
||
680 | 680 | * Implementation of hook_views_api() |
681 | 681 | */ |
682 | 682 | function boincuser_views_api() { |
683 | - return array( |
|
683 | + return array( |
|
684 | 684 | 'api' => 2.0, |
685 | 685 | 'path' => drupal_get_path('module', 'boincuser') |
686 | - ); |
|
686 | + ); |
|
687 | 687 | } |
688 | 688 | |
689 | 689 | /** |
690 | 690 | * Implementation of hook_form_alter() |
691 | 691 | */ |
692 | 692 | function boincuser_form_alter(&$form, $form_state, $form_id) { |
693 | - require_boinc('token'); |
|
693 | + require_boinc('token'); |
|
694 | 694 | |
695 | - global $user; |
|
696 | - switch ($form_id) { |
|
697 | - case 'flag_confirm': |
|
695 | + global $user; |
|
696 | + switch ($form_id) { |
|
697 | + case 'flag_confirm': |
|
698 | 698 | // The URL seems to be the only way to put any kind of context to this |
699 | 699 | // request! |
700 | 700 | $action = arg(2); |
@@ -703,25 +703,25 @@ discard block |
||
703 | 703 | |
704 | 704 | // Wrap action buttons for styling consistency |
705 | 705 | $form['form control tabs prefix'] = array( |
706 | - '#value' => '<ul class="form-control tab-list">', |
|
707 | - '#weight' => 1001, |
|
706 | + '#value' => '<ul class="form-control tab-list">', |
|
707 | + '#weight' => 1001, |
|
708 | 708 | ); |
709 | 709 | |
710 | 710 | switch ($flag_type) { |
711 | 711 | case 'friend': |
712 | 712 | $friend_id = $form['content_id']['#value']; |
713 | - $flag = flag_get_flag('friend'); |
|
714 | - $friend_status = flag_friend_determine_friend_status($flag, $friend_id, $user->uid); |
|
713 | + $flag = flag_get_flag('friend'); |
|
714 | + $friend_status = flag_friend_determine_friend_status($flag, $friend_id, $user->uid); |
|
715 | 715 | |
716 | - // General friend form overrides |
|
717 | - $form['flag_friend_submit']['#prefix'] = '<li class="first tab">'; |
|
718 | - $form['flag_friend_submit']['#value'] = bts('Send request', array(), NULL, 'boinc:friends-page'); |
|
719 | - $form['flag_friend_submit']['#type'] = 'submit'; |
|
720 | - $form['flag_friend_submit']['#suffix'] = '</li>'; |
|
721 | - $form['flag_friend_submit']['#weight'] = 1002; |
|
716 | + // General friend form overrides |
|
717 | + $form['flag_friend_submit']['#prefix'] = '<li class="first tab">'; |
|
718 | + $form['flag_friend_submit']['#value'] = bts('Send request', array(), NULL, 'boinc:friends-page'); |
|
719 | + $form['flag_friend_submit']['#type'] = 'submit'; |
|
720 | + $form['flag_friend_submit']['#suffix'] = '</li>'; |
|
721 | + $form['flag_friend_submit']['#weight'] = 1002; |
|
722 | 722 | |
723 | - switch ($friend_status) { |
|
724 | - case FLAG_FRIEND_BOTH: |
|
723 | + switch ($friend_status) { |
|
724 | + case FLAG_FRIEND_BOTH: |
|
725 | 725 | case FLAG_FRIEND_FLAGGED: |
726 | 726 | unset($form['actions']); |
727 | 727 | $form['flag_friend_submit']['#value'] = bts('Remove friend', array(), NULL, 'boinc:friends-remove'); |
@@ -730,53 +730,53 @@ discard block |
||
730 | 730 | $form['#submit'][] = 'boincuser_fix_unfriend_form_submit'; |
731 | 731 | $form['#submit'][] = $final_handler; |
732 | 732 | break; |
733 | - case FLAG_FRIEND_PENDING: |
|
733 | + case FLAG_FRIEND_PENDING: |
|
734 | 734 | unset($form['actions']); |
735 | 735 | $form['flag_friend_submit']['#value'] = bts('Remove request', array(), NULL, 'boinc:friends-page'); |
736 | 736 | break; |
737 | - case FLAG_FRIEND_APPROVAL: |
|
737 | + case FLAG_FRIEND_APPROVAL: |
|
738 | 738 | if ($action == 'flag') { |
739 | - $form['flag_friend_submit']['#value'] = bts('Approve request', array(), NULL, 'boinc:friends-page'); |
|
739 | + $form['flag_friend_submit']['#value'] = bts('Approve request', array(), NULL, 'boinc:friends-page'); |
|
740 | 740 | } |
741 | 741 | elseif ($action == 'unflag') { |
742 | - unset($form['actions']); |
|
743 | - $form['flag_friend_submit']['#value'] = bts('Deny request', array(), NULL, 'boinc:friends-page'); |
|
742 | + unset($form['actions']); |
|
743 | + $form['flag_friend_submit']['#value'] = bts('Deny request', array(), NULL, 'boinc:friends-page'); |
|
744 | 744 | } |
745 | 745 | break; |
746 | - case FLAG_FRIEND_UNFLAGGED: |
|
746 | + case FLAG_FRIEND_UNFLAGGED: |
|
747 | 747 | default: |
748 | 748 | $user_links[] = array( |
749 | - 'title' => bts('Add as friend', array(), NULL, 'boinc:friends-add'), |
|
750 | - 'href' => "flag/confirm/flag/friend/{$account->uid}" |
|
749 | + 'title' => bts('Add as friend', array(), NULL, 'boinc:friends-add'), |
|
750 | + 'href' => "flag/confirm/flag/friend/{$account->uid}" |
|
751 | 751 | ); |
752 | - } |
|
753 | - break; |
|
752 | + } |
|
753 | + break; |
|
754 | 754 | |
755 | 755 | default: |
756 | 756 | } |
757 | 757 | |
758 | 758 | $form['cancel'] = array( |
759 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $cancel_dest) . '</li>', |
|
760 | - '#weight' => 1004, |
|
759 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $cancel_dest) . '</li>', |
|
760 | + '#weight' => 1004, |
|
761 | 761 | ); |
762 | 762 | $form['form control tabs suffix'] = array( |
763 | - '#value' => '</ul>', |
|
764 | - '#weight' => 1010, |
|
763 | + '#value' => '</ul>', |
|
764 | + '#weight' => 1010, |
|
765 | 765 | ); |
766 | 766 | |
767 | 767 | break; |
768 | 768 | |
769 | - // General node edit form |
|
770 | - case 'news_node_form': |
|
769 | + // General node edit form |
|
770 | + case 'news_node_form': |
|
771 | 771 | $form['separator_bottom'] = array( |
772 | - '#value' => '<div class="separator buttons"></div>', |
|
773 | - '#weight' => 999, |
|
772 | + '#value' => '<div class="separator buttons"></div>', |
|
773 | + '#weight' => 999, |
|
774 | 774 | ); |
775 | 775 | |
776 | 776 | // Wrap action buttons for styling consistency |
777 | 777 | $form['buttons']['form control tabs prefix'] = array( |
778 | - '#value' => '<ul class="form-control tab-list">', |
|
779 | - '#weight' => 1001, |
|
778 | + '#value' => '<ul class="form-control tab-list">', |
|
779 | + '#weight' => 1001, |
|
780 | 780 | ); |
781 | 781 | $form['buttons']['submit']['#prefix'] = '<li class="first tab">'; |
782 | 782 | $form['buttons']['submit']['#value'] = bts('Save changes', array(), NULL, 'boinc:form-save'); |
@@ -789,15 +789,15 @@ discard block |
||
789 | 789 | $form['buttons']['preview_changes']['#suffix'] = '</li>'; |
790 | 790 | $form['buttons']['preview_changes']['#weight'] = 1004; |
791 | 791 | $form['buttons']['cancel'] = array( |
792 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "node/{$form['nid']['#value']}") . '</li>', |
|
793 | - '#weight' => 1005, |
|
792 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "node/{$form['nid']['#value']}") . '</li>', |
|
793 | + '#weight' => 1005, |
|
794 | 794 | ); |
795 | 795 | $form['buttons']['delete']['#prefix'] = '<li class="tab">'; |
796 | 796 | $form['buttons']['delete']['#suffix'] = '</li>'; |
797 | 797 | $form['buttons']['delete']['#weight'] = 1006; |
798 | 798 | $form['buttons']['form control tabs suffix'] = array( |
799 | - '#value' => '</ul>', |
|
800 | - '#weight' => 1010, |
|
799 | + '#value' => '</ul>', |
|
800 | + '#weight' => 1010, |
|
801 | 801 | ); |
802 | 802 | |
803 | 803 | // Preview is ugly, unset until it works |
@@ -805,16 +805,16 @@ discard block |
||
805 | 805 | |
806 | 806 | break; |
807 | 807 | |
808 | - case 'node_delete_confirm': |
|
808 | + case 'node_delete_confirm': |
|
809 | 809 | $form['separator_bottom'] = array( |
810 | - '#value' => '<div class="separator buttons"></div>', |
|
811 | - '#weight' => 999, |
|
810 | + '#value' => '<div class="separator buttons"></div>', |
|
811 | + '#weight' => 999, |
|
812 | 812 | ); |
813 | 813 | |
814 | 814 | // Wrap action buttons for styling consistency |
815 | 815 | $form['actions']['form control tabs prefix'] = array( |
816 | - '#value' => '<ul class="form-control tab-list">', |
|
817 | - '#weight' => 1001, |
|
816 | + '#value' => '<ul class="form-control tab-list">', |
|
817 | + '#weight' => 1001, |
|
818 | 818 | ); |
819 | 819 | $form['actions']['submit']['#prefix'] = '<li class="first tab">'; |
820 | 820 | $form['actions']['submit']['#value'] = bts('Delete', array(), NULL, 'boinc:form-delete'); |
@@ -822,23 +822,23 @@ discard block |
||
822 | 822 | $form['actions']['submit']['#weight'] = 1002; |
823 | 823 | $form['actions']['cancel'] = array( |
824 | 824 | '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "node/{$form['nid']['#value']}") . '</li>', |
825 | - '#weight' => 1005, |
|
825 | + '#weight' => 1005, |
|
826 | 826 | ); |
827 | 827 | $form['actions']['form control tabs suffix'] = array( |
828 | - '#value' => '</ul>', |
|
829 | - '#weight' => 1010, |
|
828 | + '#value' => '</ul>', |
|
829 | + '#weight' => 1010, |
|
830 | 830 | ); |
831 | 831 | $form['#redirect'] = 'account/profile'; |
832 | 832 | break; |
833 | 833 | |
834 | - case 'privatemsg_new': |
|
834 | + case 'privatemsg_new': |
|
835 | 835 | |
836 | 836 | $form['privatemsg']['body']['#title'] = ''; |
837 | 837 | |
838 | 838 | // Wrap action buttons for styling consistency |
839 | 839 | $form['privatemsg']['form control tabs prefix'] = array( |
840 | - '#value' => '<ul class="form-control tab-list">', |
|
841 | - '#weight' => 1001, |
|
840 | + '#value' => '<ul class="form-control tab-list">', |
|
841 | + '#weight' => 1001, |
|
842 | 842 | ); |
843 | 843 | $form['privatemsg']['submit']['#prefix'] = '<li class="first tab">'; |
844 | 844 | $form['privatemsg']['submit']['#value'] = bts('Send message', array(), NULL, 'boinc:private-message'); |
@@ -848,26 +848,26 @@ discard block |
||
848 | 848 | $form['privatemsg']['preview']['#suffix'] = '</li>'; |
849 | 849 | $form['privatemsg']['preview']['#weight'] = 1003; |
850 | 850 | $form['privatemsg']['cancel'] = array( |
851 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
852 | - '#weight' => 1004, |
|
851 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
852 | + '#weight' => 1004, |
|
853 | 853 | ); |
854 | 854 | $form['privatemsg']['form control tabs suffix'] = array( |
855 | - '#value' => '</ul>', |
|
856 | - '#weight' => 1010, |
|
855 | + '#value' => '</ul>', |
|
856 | + '#weight' => 1010, |
|
857 | 857 | ); |
858 | 858 | |
859 | 859 | unset($form['privatemsg']['recipient_display']); |
860 | 860 | |
861 | 861 | break; |
862 | 862 | |
863 | - // Login form |
|
864 | - case 'user_login': |
|
863 | + // Login form |
|
864 | + case 'user_login': |
|
865 | 865 | case 'user_login_block': |
866 | 866 | drupal_set_title(bts('Login', array(), NULL, 'boinc:menu-link')); |
867 | 867 | // Replace name with email in login form |
868 | 868 | unset($form['name']); |
869 | 869 | array_unshift($form, array( |
870 | - 'email' => array( |
|
870 | + 'email' => array( |
|
871 | 871 | '#type' => 'textfield', |
872 | 872 | '#title' => bts('Email address', array(), NULL, 'boinc:email-address-to-login'), |
873 | 873 | '#size' => ($form_id == 'user_login_block') ? 15 : 60, |
@@ -875,18 +875,18 @@ discard block |
||
875 | 875 | '#required' => TRUE, |
876 | 876 | '#attributes' => array('tabindex' => '1'), |
877 | 877 | '#description' => bts('Enter your @s email address.', array('@s' => variable_get('site_name', 'Drupal-BOINC')), NULL, 'boinc:standard-login-page') |
878 | - ), |
|
879 | - 'validation_source' => array( |
|
878 | + ), |
|
879 | + 'validation_source' => array( |
|
880 | 880 | '#type' => 'hidden', |
881 | 881 | '#value' => 'user_login' |
882 | - ) |
|
882 | + ) |
|
883 | 883 | )); |
884 | 884 | $form['#redirect'] = 'home'; |
885 | 885 | |
886 | 886 | // Wrap action buttons for styling consistency |
887 | 887 | $form['buttons']['form control tabs prefix'] = array( |
888 | - '#value' => '<ul class="form-control tab-list">', |
|
889 | - '#weight' => 1001, |
|
888 | + '#value' => '<ul class="form-control tab-list">', |
|
889 | + '#weight' => 1001, |
|
890 | 890 | ); |
891 | 891 | $form['buttons']['submit'] = $form['submit']; |
892 | 892 | $form['buttons']['submit']['#prefix'] = '<li class="first tab">'; |
@@ -894,8 +894,8 @@ discard block |
||
894 | 894 | $form['buttons']['submit']['#suffix'] = '</li>'; |
895 | 895 | $form['buttons']['submit']['#weight'] = 1002; |
896 | 896 | $form['buttons']['form control tabs suffix'] = array( |
897 | - '#value' => '</ul>', |
|
898 | - '#weight' => 1010, |
|
897 | + '#value' => '</ul>', |
|
898 | + '#weight' => 1010, |
|
899 | 899 | ); |
900 | 900 | unset($form['submit']); |
901 | 901 | |
@@ -904,23 +904,23 @@ discard block |
||
904 | 904 | isset($form['buttons']['submit']['#attributes']) ? array_push($form['buttons']['submit']['#attributes'], array('tabindex' => '3')) : $form['buttons']['submit']['#attributes'] = array('tabindex' => '3'); |
905 | 905 | // If the user login form is being submitted, use BOINC validation handler. |
906 | 906 | if (isset($form_state['post']['email']) and isset($form_state['post']['pass'])) { |
907 | - // Find the local validation function's entry so we can replace it. |
|
908 | - $array_key = array_search('user_login_authenticate_validate', $form['#validate']); |
|
909 | - if ($array_key === FALSE) { |
|
907 | + // Find the local validation function's entry so we can replace it. |
|
908 | + $array_key = array_search('user_login_authenticate_validate', $form['#validate']); |
|
909 | + if ($array_key === FALSE) { |
|
910 | 910 | // Could not find it. Some other module must have run form_alter(). |
911 | 911 | // We will simply add our validation just before the final validator. |
912 | 912 | $final_validator = array_pop($form['#validate']); |
913 | 913 | $form['#validate'][] = 'boincuser_login_validate'; |
914 | 914 | $form['#validate'][] = $final_validator; |
915 | - } else { |
|
915 | + } else { |
|
916 | 916 | // Replace the local validation function with BOINC validation |
917 | 917 | $form['#validate'][$array_key] = 'boincuser_login_validate'; |
918 | - } |
|
918 | + } |
|
919 | 919 | } |
920 | 920 | break; |
921 | 921 | |
922 | - // User credentials form |
|
923 | - case 'user_profile_form': |
|
922 | + // User credentials form |
|
923 | + case 'user_profile_form': |
|
924 | 924 | |
925 | 925 | // Use the displaly name as the title, not the username |
926 | 926 | $account = user_load($form['#uid']); |
@@ -928,28 +928,28 @@ discard block |
||
928 | 928 | |
929 | 929 | // Message for admins |
930 | 930 | if (user_access('administer users')) { |
931 | - drupal_set_message( |
|
931 | + drupal_set_message( |
|
932 | 932 | bts('WARNING: You are editing the information for user. Please note: you may change a user\'s password by itself. But to change the user\'s email address you must change both the email address and the password simultaneously.') |
933 | - , 'warning'); |
|
933 | + , 'warning'); |
|
934 | 934 | } |
935 | 935 | |
936 | 936 | // Set special message if user has not agreed to TOU |
937 | 937 | $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE); |
938 | 938 | $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
939 | 939 | if ( (!boincuser_check_termsofuse($account)) and ($existinguser_tou) and (!empty($termsofuse)) and (!user_access('administer users')) ) { |
940 | - drupal_set_message( |
|
940 | + drupal_set_message( |
|
941 | 941 | bts('INFO: You have not agreed to the terms of use for @project. You may use this form to change your email address and/or password. Please note: you may not delete your account within seven (7) days of changing your email address.', |
942 | 942 | array( |
943 | - '@project' => variable_get('site_name','Drupal-BOINC'), |
|
943 | + '@project' => variable_get('site_name','Drupal-BOINC'), |
|
944 | 944 | ), NULL, 'boinc:account-credentials-change') |
945 | - , 'info'); |
|
945 | + , 'info'); |
|
946 | 946 | } |
947 | 947 | |
948 | 948 | // A bit hackish... but don't require the user to enter his password if |
949 | 949 | // coming from the password reset function |
950 | 950 | $reset_pass = (strpos($_SERVER['HTTP_REFERER'], "/user/reset/{$form['#uid']}") === FALSE) ? 0 : 1; |
951 | 951 | if ($reset_pass) { |
952 | - $_SESSION['reset_pass'] = 1; |
|
952 | + $_SESSION['reset_pass'] = 1; |
|
953 | 953 | } |
954 | 954 | |
955 | 955 | // Adjust form elements already present |
@@ -961,8 +961,8 @@ discard block |
||
961 | 961 | $form['account']['pass']['#size'] = 17; |
962 | 962 | |
963 | 963 | if (user_access('administer users')) { |
964 | - // Add BOINC username (aka displayname) |
|
965 | - $form['account']['boincuser_name'] = array( |
|
964 | + // Add BOINC username (aka displayname) |
|
965 | + $form['account']['boincuser_name'] = array( |
|
966 | 966 | '#type' => 'textfield', |
967 | 967 | '#title' => bts('BOINC Username', array(), NULL, 'boinc:user-or-team-name'), |
968 | 968 | '#default_value' => $account->boincuser_name, |
@@ -970,68 +970,68 @@ discard block |
||
970 | 970 | '#required' => TRUE, |
971 | 971 | '#description' => bts('This is the BOINC (external) username. This is the same setting as found in Account -> Preferences -> Community.', array(), NULL, 'boinc:username-change'), |
972 | 972 | '#size' => 40, |
973 | - ); |
|
973 | + ); |
|
974 | 974 | } |
975 | 975 | |
976 | 976 | // If email address was changed less than 7 days (7 * 86400 s) |
977 | 977 | // ago, it cannot be changed again. |
978 | 978 | $duration = TOKEN_DURATION_ONE_WEEK; |
979 | 979 | if (($account->boincuser_email_addr_change_time + $duration) > time() and (!user_access('administer users'))) { |
980 | - $form['account']['mail']['#required'] = FALSE; |
|
981 | - $form['account']['mailhelp'] = array( |
|
980 | + $form['account']['mail']['#required'] = FALSE; |
|
981 | + $form['account']['mailhelp'] = array( |
|
982 | 982 | '#value' => bts("You email address was changed within the past seven (7) days. Please look for an email to !prev_email if you need to revert this change. You may change your email address on !time.", |
983 | - array( |
|
983 | + array( |
|
984 | 984 | '!prev_email' => $account->boincuser_previous_email_addr, |
985 | 985 | '!time' => date('F j, Y \a\t G:i T', $account->boincuser_email_addr_change_time + $duration), |
986 | - ), NULL, 'boinc:account-credentials-change'), |
|
987 | - ); |
|
986 | + ), NULL, 'boinc:account-credentials-change'), |
|
987 | + ); |
|
988 | 988 | } |
989 | 989 | |
990 | 990 | if (!$reset_pass AND ($user->uid == $account->uid OR !user_access('administer users'))) { |
991 | - // Add a password authenticator, required to change email or pw |
|
992 | - $form['account']['current_pass'] = array( |
|
991 | + // Add a password authenticator, required to change email or pw |
|
992 | + $form['account']['current_pass'] = array( |
|
993 | 993 | '#type' => 'password', |
994 | 994 | '#title' => bts('Enter your password to save changes', array(), NULL, 'boinc:account-credentials-change'), |
995 | 995 | '#description' => bts('Enter your current password if changing your email |
996 | 996 | address or password.', array(), NULL, 'boinc:account-credentials-change'), |
997 | 997 | '#size' => 17, |
998 | 998 | '#attributes' => array( |
999 | - 'autocomplete' => 'off', |
|
999 | + 'autocomplete' => 'off', |
|
1000 | 1000 | ), |
1001 | - ); |
|
1001 | + ); |
|
1002 | 1002 | } |
1003 | 1003 | |
1004 | 1004 | // Add account keys, CPID, etc |
1005 | 1005 | $form['account']['boincuser_id'] = array( |
1006 | - '#value' => ' |
|
1006 | + '#value' => ' |
|
1007 | 1007 | <div class="form-item"> |
1008 | 1008 | <label>' . bts('BOINC user ID', array(), NULL, 'boinc:account-credentials-change') . '</label> |
1009 | 1009 | <span>' . $account->boincuser_id . '</span> |
1010 | 1010 | </div>', |
1011 | 1011 | ); |
1012 | 1012 | $form['account']['user_id'] = array( |
1013 | - '#value' => ' |
|
1013 | + '#value' => ' |
|
1014 | 1014 | <div class="form-item"> |
1015 | 1015 | <label>' . bts('Drupal user ID', array(), NULL, 'boinc:account-credentials-change') . '</label> |
1016 | 1016 | <span>' . $account->uid . '</span> |
1017 | 1017 | </div>', |
1018 | 1018 | ); |
1019 | 1019 | $form['account']['account_key'] = array( |
1020 | - '#value' => ' |
|
1020 | + '#value' => ' |
|
1021 | 1021 | <div class="form-item"> |
1022 | 1022 | <label>' . bts('Account key', array(), NULL, 'boinc:account-credentials-change') . '</label> |
1023 | 1023 | <span>' . $account->boincuser_account_key . '</span> |
1024 | 1024 | </div>', |
1025 | 1025 | ); |
1026 | 1026 | $form['account']['weak_account_key'] = array( |
1027 | - '#value' => ' |
|
1027 | + '#value' => ' |
|
1028 | 1028 | <div class="form-item"> |
1029 | 1029 | <label>' . bts('Weak account key', array(), NULL, 'boinc:account-credentials-change') . '</label> |
1030 | 1030 | <span>' . "{$account->boincuser_id}_{$account->boincuser_weak_auth}" . '</span> |
1031 | 1031 | </div>', |
1032 | 1032 | ); |
1033 | 1033 | $form['account']['cpid'] = array( |
1034 | - '#value' => ' |
|
1034 | + '#value' => ' |
|
1035 | 1035 | <div class="form-item"> |
1036 | 1036 | <label>' . bts('Cross-project ID', array(), NULL, 'boinc:account-credentials-change') . '</label> |
1037 | 1037 | <span>' . $account->boincuser_cpid . '</span> |
@@ -1039,30 +1039,30 @@ discard block |
||
1039 | 1039 | ); |
1040 | 1040 | |
1041 | 1041 | $form['account']['separator_bottom'] = array( |
1042 | - '#value' => '<div class="separator buttons"></div>' |
|
1042 | + '#value' => '<div class="separator buttons"></div>' |
|
1043 | 1043 | ); |
1044 | 1044 | |
1045 | 1045 | // Wrap action buttons for styling consistency |
1046 | 1046 | $form['form control tabs prefix'] = array( |
1047 | - '#value' => '<ul class="form-control tab-list">', |
|
1048 | - '#weight' => 1001, |
|
1047 | + '#value' => '<ul class="form-control tab-list">', |
|
1048 | + '#weight' => 1001, |
|
1049 | 1049 | ); |
1050 | 1050 | $form['submit']['#prefix'] = '<li class="first tab">'; |
1051 | 1051 | $form['submit']['#value'] = bts('Save changes', array(), NULL, 'boinc:form-save'); |
1052 | 1052 | $form['submit']['#suffix'] = '</li>'; |
1053 | 1053 | $form['submit']['#weight'] = 1002; |
1054 | 1054 | $form['cancel'] = array( |
1055 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
1056 | - '#weight' => 1003, |
|
1055 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
1056 | + '#weight' => 1003, |
|
1057 | 1057 | ); |
1058 | 1058 | if (isset($form['delete']) AND is_array($form['delete'])) { |
1059 | - $form['delete']['#prefix'] = '<li class="first alt tab">'; |
|
1060 | - $form['delete']['#suffix'] = '</li>'; |
|
1061 | - $form['delete']['#weight'] = 1004; |
|
1059 | + $form['delete']['#prefix'] = '<li class="first alt tab">'; |
|
1060 | + $form['delete']['#suffix'] = '</li>'; |
|
1061 | + $form['delete']['#weight'] = 1004; |
|
1062 | 1062 | } |
1063 | 1063 | $form['form control tabs suffix'] = array( |
1064 | - '#value' => '</ul>', |
|
1065 | - '#weight' => 1010, |
|
1064 | + '#value' => '</ul>', |
|
1065 | + '#weight' => 1010, |
|
1066 | 1066 | ); |
1067 | 1067 | |
1068 | 1068 | // Rearrange form elements |
@@ -1082,7 +1082,7 @@ discard block |
||
1082 | 1082 | // Remove redundant / unnecessary form elements |
1083 | 1083 | unset($form['theme_select']); |
1084 | 1084 | if (!module_exists('boincuser_delete')) { |
1085 | - unset($form['delete']); |
|
1085 | + unset($form['delete']); |
|
1086 | 1086 | } |
1087 | 1087 | |
1088 | 1088 | // These are on the Community preferences form (boincwork module) |
@@ -1098,18 +1098,18 @@ discard block |
||
1098 | 1098 | |
1099 | 1099 | // Internal fields to indicate where these user changes are taking place |
1100 | 1100 | array_unshift($form, array( |
1101 | - 'validation_source' => array( |
|
1101 | + 'validation_source' => array( |
|
1102 | 1102 | '#type' => 'hidden', |
1103 | 1103 | '#value' => 'user_account' |
1104 | - ), |
|
1105 | - 'update_source' => array( |
|
1104 | + ), |
|
1105 | + 'update_source' => array( |
|
1106 | 1106 | '#type' => 'hidden', |
1107 | 1107 | '#value' => 'user_account' |
1108 | - ) |
|
1108 | + ) |
|
1109 | 1109 | )); |
1110 | 1110 | break; |
1111 | 1111 | |
1112 | - case 'profile_node_form': |
|
1112 | + case 'profile_node_form': |
|
1113 | 1113 | |
1114 | 1114 | // Use the display name as the title, not the username |
1115 | 1115 | $account = user_load($form['uid']['#value']); |
@@ -1120,22 +1120,22 @@ discard block |
||
1120 | 1120 | $form['title']['#access'] = FALSE; |
1121 | 1121 | |
1122 | 1122 | $form['separator_bottom'] = array( |
1123 | - '#value' => '<div class="separator buttons"></div>', |
|
1124 | - '#weight' => 999, |
|
1123 | + '#value' => '<div class="separator buttons"></div>', |
|
1124 | + '#weight' => 999, |
|
1125 | 1125 | ); |
1126 | 1126 | |
1127 | 1127 | if (module_exists('captcha')) { |
1128 | - // Add an optional captcha |
|
1129 | - $form['profile_captcha'] = array( |
|
1128 | + // Add an optional captcha |
|
1129 | + $form['profile_captcha'] = array( |
|
1130 | 1130 | '#type' => 'captcha', |
1131 | 1131 | '#weight' => 1000, |
1132 | - ); |
|
1132 | + ); |
|
1133 | 1133 | } |
1134 | 1134 | |
1135 | 1135 | // Wrap action buttons for styling consistency |
1136 | 1136 | $form['buttons']['form control tabs prefix'] = array( |
1137 | - '#value' => '<ul class="form-control tab-list">', |
|
1138 | - '#weight' => 1001, |
|
1137 | + '#value' => '<ul class="form-control tab-list">', |
|
1138 | + '#weight' => 1001, |
|
1139 | 1139 | ); |
1140 | 1140 | $form['buttons']['submit']['#prefix'] = '<li class="first tab">'; |
1141 | 1141 | $form['buttons']['submit']['#value'] = bts('Save changes', array(), NULL, 'boinc:form-save'); |
@@ -1148,8 +1148,8 @@ discard block |
||
1148 | 1148 | $form['buttons']['preview_changes']['#suffix'] = '</li>'; |
1149 | 1149 | $form['buttons']['preview_changes']['#weight'] = 1004; |
1150 | 1150 | $form['buttons']['cancel'] = array( |
1151 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
1152 | - '#weight' => 1005, |
|
1151 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
1152 | + '#weight' => 1005, |
|
1153 | 1153 | ); |
1154 | 1154 | $form['buttons']['delete']['#prefix'] = '<li class="tab">'; |
1155 | 1155 | $form['buttons']['delete']['#suffix'] = '</li>'; |
@@ -1157,8 +1157,8 @@ discard block |
||
1157 | 1157 | $form['buttons']['delete']['#weight'] = 1006; |
1158 | 1158 | $form['buttons']['delete']['#submit'] = array('_boincuser_node_profile_delete_submit'); |
1159 | 1159 | $form['buttons']['form control tabs suffix'] = array( |
1160 | - '#value' => '</ul>', |
|
1161 | - '#weight' => 1010, |
|
1160 | + '#value' => '</ul>', |
|
1161 | + '#weight' => 1010, |
|
1162 | 1162 | ); |
1163 | 1163 | |
1164 | 1164 | $form['#after_build'][] = 'boincuser_profile_node_form_after_build'; |
@@ -1171,74 +1171,74 @@ discard block |
||
1171 | 1171 | |
1172 | 1172 | // Internal fields to indicate where these user changes are taking place |
1173 | 1173 | array_unshift($form, array( |
1174 | - 'validation_source' => array( |
|
1174 | + 'validation_source' => array( |
|
1175 | 1175 | '#type' => 'hidden', |
1176 | 1176 | '#value' => 'user_profile' |
1177 | - ), |
|
1178 | - 'update_source' => array( |
|
1177 | + ), |
|
1178 | + 'update_source' => array( |
|
1179 | 1179 | '#type' => 'hidden', |
1180 | 1180 | '#value' => 'user_profile' |
1181 | - ) |
|
1181 | + ) |
|
1182 | 1182 | )); |
1183 | 1183 | break; |
1184 | 1184 | |
1185 | - // Registration form |
|
1186 | - case 'user_register': |
|
1185 | + // Registration form |
|
1186 | + case 'user_register': |
|
1187 | 1187 | array_unshift($form, array( |
1188 | - 'boincuser_name' => array( |
|
1188 | + 'boincuser_name' => array( |
|
1189 | 1189 | '#type' => 'textfield', |
1190 | 1190 | '#title' => bts('Name', array(), NULL, 'boinc:user-or-team-name'), |
1191 | 1191 | '#default_value' => $edit['boincuser_name'], |
1192 | 1192 | '#maxlength' => USERNAME_MAX_LENGTH, |
1193 | 1193 | '#description' => bts('Spaces are allowed; punctuation is not allowed except for periods, hyphens, and underscores.', array(), NULL, 'boinc:user-register'), |
1194 | 1194 | '#required' => TRUE |
1195 | - ), |
|
1195 | + ), |
|
1196 | 1196 | )); |
1197 | 1197 | // Set name temporarily to dummy value to beat validation |
1198 | 1198 | $form['name'] = array( |
1199 | - '#type' => 'hidden', |
|
1200 | - '#value' => rand() . '.' . time() |
|
1199 | + '#type' => 'hidden', |
|
1200 | + '#value' => rand() . '.' . time() |
|
1201 | 1201 | ); |
1202 | 1202 | |
1203 | 1203 | // Terms of use section |
1204 | 1204 | $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
1205 | 1205 | if (!empty($termsofuse)) { |
1206 | - $form['title1'] = array( |
|
1206 | + $form['title1'] = array( |
|
1207 | 1207 | '#weight' => -12, |
1208 | 1208 | '#value' => '<h2>' . bts(variable_get('boinc_weboptions_registrationtitle', 'Please read and acknowledge our terms of use'), array(), NULL, 'project:user-register' ) . '</h2>', |
1209 | 1209 | '#prefix' => '<div id="register-title1">', |
1210 | 1210 | '#suffix' => '</div>', |
1211 | - ); |
|
1211 | + ); |
|
1212 | 1212 | |
1213 | - $form['termsofuse'] = array( |
|
1213 | + $form['termsofuse'] = array( |
|
1214 | 1214 | '#weight' => -10, |
1215 | 1215 | '#value' => bts($termsofuse, array(), NULL, 'project:user-register'), |
1216 | 1216 | '#prefix' => '<div id="register-termsofuse">', |
1217 | 1217 | '#suffix' => '</div>', |
1218 | - ); |
|
1218 | + ); |
|
1219 | 1219 | |
1220 | - $form['agreeTOU'] = array( |
|
1220 | + $form['agreeTOU'] = array( |
|
1221 | 1221 | '#type' => 'checkbox', |
1222 | 1222 | '#title' => bts(variable_get('boinc_weboptions_agreequestion', 'Do you agree with the above terms of use?'), array(), NULL, 'project:user-register'), |
1223 | 1223 | '#weight' => -8, |
1224 | 1224 | '#prefix' => '<div id="register-checkbox">', |
1225 | 1225 | '#suffix' => '</div>', |
1226 | - ); |
|
1226 | + ); |
|
1227 | 1227 | } |
1228 | 1228 | |
1229 | 1229 | $form['title2'] = array( |
1230 | - '#weight' => -6, |
|
1231 | - '#value' => '<h2>' . bts(variable_get('boinc_weboptions_registrationtitle2', 'Fill in your name, email, and choose a secure passphrase.'), array(), NULL, 'project:user-register') . '</h2>', |
|
1232 | - '#prefix' => '<div id="register-title2">', |
|
1233 | - '#suffix' => '</div>', |
|
1230 | + '#weight' => -6, |
|
1231 | + '#value' => '<h2>' . bts(variable_get('boinc_weboptions_registrationtitle2', 'Fill in your name, email, and choose a secure passphrase.'), array(), NULL, 'project:user-register') . '</h2>', |
|
1232 | + '#prefix' => '<div id="register-title2">', |
|
1233 | + '#suffix' => '</div>', |
|
1234 | 1234 | ); |
1235 | 1235 | |
1236 | 1236 | if (module_exists('captcha')) { |
1237 | - // Add an optional captcha |
|
1238 | - $form['register_captcha'] = array( |
|
1237 | + // Add an optional captcha |
|
1238 | + $form['register_captcha'] = array( |
|
1239 | 1239 | '#type' => 'captcha', |
1240 | 1240 | '#weight' => 1000, |
1241 | - ); |
|
1241 | + ); |
|
1242 | 1242 | } |
1243 | 1243 | |
1244 | 1244 | $form['#validate'][] = 'boincuser_register_validate'; |
@@ -1246,35 +1246,35 @@ discard block |
||
1246 | 1246 | $form['submit']['#weight'] = 1001; |
1247 | 1247 | break; |
1248 | 1248 | |
1249 | - // Request new password form |
|
1250 | - case 'user_pass': |
|
1249 | + // Request new password form |
|
1250 | + case 'user_pass': |
|
1251 | 1251 | drupal_set_title(bts('Forgot password', array(), NULL, 'boinc:forgot-password')); |
1252 | 1252 | // Replace name/email text box with email only; retain "name" label |
1253 | 1253 | // for compatibility with standard Drupal submit function |
1254 | 1254 | unset($form['name']); |
1255 | 1255 | array_unshift($form, array( |
1256 | - 'name' => array( |
|
1256 | + 'name' => array( |
|
1257 | 1257 | '#type' => 'textfield', |
1258 | 1258 | '#title' => bts('Email address', array(), NULL, 'boinc:email-address-to-login'), |
1259 | 1259 | '#size' => 60, |
1260 | 1260 | '#maxlength' => EMAIL_MAX_LENGTH, |
1261 | 1261 | '#required' => TRUE, |
1262 | 1262 | '#description' => bts( |
1263 | - 'Enter your email address to receive instructions for resetting your password (or use the !authenticator_login).', |
|
1264 | - array( |
|
1263 | + 'Enter your email address to receive instructions for resetting your password (or use the !authenticator_login).', |
|
1264 | + array( |
|
1265 | 1265 | '!authenticator_login' => l( |
1266 | - bts('authenticator-based login', array(), NULL, 'boinc:forgot-password'), |
|
1267 | - 'user/login/auth' |
|
1266 | + bts('authenticator-based login', array(), NULL, 'boinc:forgot-password'), |
|
1267 | + 'user/login/auth' |
|
1268 | + ) |
|
1268 | 1269 | ) |
1269 | - ) |
|
1270 | 1270 | , NULL, 'boinc:forgot-password'), |
1271 | - ), |
|
1271 | + ), |
|
1272 | 1272 | )); |
1273 | 1273 | |
1274 | 1274 | // Wrap action buttons for styling consistency |
1275 | 1275 | $form['buttons']['form control tabs prefix'] = array( |
1276 | - '#value' => '<ul class="form-control tab-list">', |
|
1277 | - '#weight' => 1001, |
|
1276 | + '#value' => '<ul class="form-control tab-list">', |
|
1277 | + '#weight' => 1001, |
|
1278 | 1278 | ); |
1279 | 1279 | $form['buttons']['submit'] = $form['submit']; |
1280 | 1280 | $form['buttons']['submit']['#prefix'] = '<li class="first tab">'; |
@@ -1282,26 +1282,26 @@ discard block |
||
1282 | 1282 | $form['buttons']['submit']['#suffix'] = '</li>'; |
1283 | 1283 | $form['buttons']['submit']['#weight'] = 1002; |
1284 | 1284 | $form['buttons']['cancel'] = array( |
1285 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'user/login') . '</li>', |
|
1286 | - '#weight' => 1005, |
|
1285 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'user/login') . '</li>', |
|
1286 | + '#weight' => 1005, |
|
1287 | 1287 | ); |
1288 | 1288 | $form['buttons']['form control tabs suffix'] = array( |
1289 | - '#value' => '</ul>', |
|
1290 | - '#weight' => 1010, |
|
1289 | + '#value' => '</ul>', |
|
1290 | + '#weight' => 1010, |
|
1291 | 1291 | ); |
1292 | 1292 | unset($form['submit']); |
1293 | 1293 | |
1294 | 1294 | // If the form is being submitted, use BOINC validation handler. |
1295 | 1295 | if (isset($form_state['post']['name'])) { |
1296 | - // Prepend the BOINC validation function to local validation |
|
1297 | - array_unshift($form['#validate'], 'boincuser_request_pass_validate'); |
|
1296 | + // Prepend the BOINC validation function to local validation |
|
1297 | + array_unshift($form['#validate'], 'boincuser_request_pass_validate'); |
|
1298 | 1298 | } |
1299 | 1299 | break; |
1300 | 1300 | |
1301 | - case 'views_exposed_form': |
|
1301 | + case 'views_exposed_form': |
|
1302 | 1302 | $form['submit']['#value'] = bts('Search', array(), NULL, 'boinc:search-user'); |
1303 | 1303 | break; |
1304 | - } |
|
1304 | + } |
|
1305 | 1305 | } |
1306 | 1306 | |
1307 | 1307 | /** |
@@ -1309,10 +1309,10 @@ discard block |
||
1309 | 1309 | * built; this is called from boincuser_form_alter() |
1310 | 1310 | */ |
1311 | 1311 | function boincuser_profile_node_form_after_build($form, &$form_state) { |
1312 | - // Move to community prefs form |
|
1313 | - $form_state['storage']['avatar'] = $form['field_image']; |
|
1314 | - unset($form['field_image']); |
|
1315 | - return $form; |
|
1312 | + // Move to community prefs form |
|
1313 | + $form_state['storage']['avatar'] = $form['field_image']; |
|
1314 | + unset($form['field_image']); |
|
1315 | + return $form; |
|
1316 | 1316 | } |
1317 | 1317 | |
1318 | 1318 | /** |
@@ -1320,8 +1320,8 @@ discard block |
||
1320 | 1320 | * @see http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hook_elements/6 |
1321 | 1321 | */ |
1322 | 1322 | function boincuser_elements() { |
1323 | - $type['password_confirm']['#process'][] = 'boincuser_process_password_confirm'; |
|
1324 | - return $type; |
|
1323 | + $type['password_confirm']['#process'][] = 'boincuser_process_password_confirm'; |
|
1324 | + return $type; |
|
1325 | 1325 | } |
1326 | 1326 | |
1327 | 1327 | /** |
@@ -1329,11 +1329,11 @@ discard block |
||
1329 | 1329 | * profile form |
1330 | 1330 | */ |
1331 | 1331 | function boincuser_process_password_confirm($element) { |
1332 | - // Check if parent element is "account". |
|
1333 | - if ($element['#array_parents'][0] == 'account') { |
|
1332 | + // Check if parent element is "account". |
|
1333 | + if ($element['#array_parents'][0] == 'account') { |
|
1334 | 1334 | $element['pass1']['#title'] = bts('Change password', array(), NULL, 'boinc:forgot-password'); |
1335 | - } |
|
1336 | - return $element; |
|
1335 | + } |
|
1336 | + return $element; |
|
1337 | 1337 | } |
1338 | 1338 | |
1339 | 1339 | /** |
@@ -1341,40 +1341,40 @@ discard block |
||
1341 | 1341 | * Register theme functions for use in this module. |
1342 | 1342 | */ |
1343 | 1343 | function boincuser_theme($existing, $type, $theme, $path) { |
1344 | - return array( |
|
1344 | + return array( |
|
1345 | 1345 | 'boincuser_user_pass' => array( |
1346 | - 'arguments' => array() |
|
1346 | + 'arguments' => array() |
|
1347 | 1347 | ) |
1348 | - ); |
|
1348 | + ); |
|
1349 | 1349 | } |
1350 | 1350 | |
1351 | 1351 | /** |
1352 | 1352 | * Implementation of hook_token_values |
1353 | 1353 | */ |
1354 | 1354 | function boincuser_token_values($type, $object = NULL, $options = array()) { |
1355 | - if ($type == 'user') { |
|
1355 | + if ($type == 'user') { |
|
1356 | 1356 | $account = user_load($object->uid); |
1357 | 1357 | $tokens['display-name'] = $account->boincuser_name; |
1358 | 1358 | return $tokens; |
1359 | - } |
|
1359 | + } |
|
1360 | 1360 | } |
1361 | 1361 | |
1362 | 1362 | /** |
1363 | 1363 | * Implementation of hook_token_list |
1364 | 1364 | */ |
1365 | 1365 | function boincuser_token_list($type = 'all') { |
1366 | - if ($type == 'user' || $type == 'all') { |
|
1366 | + if ($type == 'user' || $type == 'all') { |
|
1367 | 1367 | $tokens['user']['display-name'] = t("The user's name that should be displayed"); |
1368 | 1368 | return $tokens; |
1369 | - } |
|
1369 | + } |
|
1370 | 1370 | } |
1371 | 1371 | |
1372 | 1372 | /** |
1373 | 1373 | * Implementation of hook_views_pre_execute() |
1374 | 1374 | */ |
1375 | 1375 | function boincuser_views_pre_execute(&$view) { |
1376 | - $account_id = $view->args[0]; |
|
1377 | - if ($view->name=="user_activity") { |
|
1376 | + $account_id = $view->args[0]; |
|
1377 | + if ($view->name=="user_activity") { |
|
1378 | 1378 | // Run the following custom query for the user_activity view |
1379 | 1379 | $view->build_info['query']= " |
1380 | 1380 | SELECT node_revisions.vid AS vid, |
@@ -1406,25 +1406,25 @@ discard block |
||
1406 | 1406 | |
1407 | 1407 | // count_query determines the pager. Do this so the right item count is returned. |
1408 | 1408 | $view->build_info['count_query'] = $view->build_info['query']; |
1409 | - } |
|
1409 | + } |
|
1410 | 1410 | } |
1411 | 1411 | |
1412 | 1412 | /** |
1413 | 1413 | * Implementation of hook_cron() |
1414 | 1414 | */ |
1415 | 1415 | function boincuser_cron() { |
1416 | - // Delete expired users in the BOINC database, user_delete table. |
|
1417 | - require_boinc('boinc_db'); |
|
1418 | - $num_deleted = BoincUserDeleted::delete_expired(); |
|
1419 | - if ($num_deleted>0) { |
|
1416 | + // Delete expired users in the BOINC database, user_delete table. |
|
1417 | + require_boinc('boinc_db'); |
|
1418 | + $num_deleted = BoincUserDeleted::delete_expired(); |
|
1419 | + if ($num_deleted>0) { |
|
1420 | 1420 | watchdog('boincuser', "Deleted ${num_deleted} users from user_deleted table", WATCHDOG_NOTICE); |
1421 | - } |
|
1421 | + } |
|
1422 | 1422 | |
1423 | - // Delete expired tokens from token table |
|
1424 | - $tokens_deleted = BoincToken::delete_expired(); |
|
1425 | - if ($tokens_deleted>0) { |
|
1423 | + // Delete expired tokens from token table |
|
1424 | + $tokens_deleted = BoincToken::delete_expired(); |
|
1425 | + if ($tokens_deleted>0) { |
|
1426 | 1426 | watchdog('boincuser', "Deleted ${tokens_deleted} tokens from token table", WATCHDOG_NOTICE); |
1427 | - } |
|
1427 | + } |
|
1428 | 1428 | } |
1429 | 1429 | |
1430 | 1430 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -1435,17 +1435,17 @@ discard block |
||
1435 | 1435 | * Page callback shortcut to recent posts for the logged in user |
1436 | 1436 | */ |
1437 | 1437 | function boincuser_goto_recent_posts() { |
1438 | - global $user; |
|
1439 | - drupal_goto("account/{$user->uid}/posts"); |
|
1438 | + global $user; |
|
1439 | + drupal_goto("account/{$user->uid}/posts"); |
|
1440 | 1440 | } |
1441 | 1441 | |
1442 | 1442 | /** |
1443 | 1443 | * Page callback shortcut to the team of the logged in user |
1444 | 1444 | */ |
1445 | 1445 | function boincuser_goto_team() { |
1446 | - global $user; |
|
1447 | - $account = user_load($user->uid); |
|
1448 | - drupal_goto("community/teams/{$account->team}"); |
|
1446 | + global $user; |
|
1447 | + $account = user_load($user->uid); |
|
1448 | + drupal_goto("community/teams/{$account->team}"); |
|
1449 | 1449 | } |
1450 | 1450 | |
1451 | 1451 | /** |
@@ -1454,83 +1454,83 @@ discard block |
||
1454 | 1454 | * user profile pages, so use a wrapper for display |
1455 | 1455 | */ |
1456 | 1456 | function boincuser_view_profile($account = null) { |
1457 | - // Create the user profile page |
|
1458 | - if (!$account) { |
|
1457 | + // Create the user profile page |
|
1458 | + if (!$account) { |
|
1459 | 1459 | global $user; |
1460 | 1460 | $account = $user; |
1461 | - } |
|
1462 | - // For now, just call the user module profile view function |
|
1463 | - user_build_content($account); |
|
1464 | - return theme('user_profile', $account); |
|
1461 | + } |
|
1462 | + // For now, just call the user module profile view function |
|
1463 | + user_build_content($account); |
|
1464 | + return theme('user_profile', $account); |
|
1465 | 1465 | } |
1466 | 1466 | |
1467 | 1467 | /** |
1468 | 1468 | * Page callback for editing a user profile |
1469 | 1469 | */ |
1470 | 1470 | function boincuser_edit_profile($account = null) { |
1471 | - // Create the user profile form |
|
1472 | - if (!$account) { |
|
1471 | + // Create the user profile form |
|
1472 | + if (!$account) { |
|
1473 | 1473 | global $user; |
1474 | 1474 | $account = $user; |
1475 | - } |
|
1476 | - // Render the form |
|
1477 | - module_load_include('pages.inc', 'node', 'node'); |
|
1478 | - return content_profile_page_edit('profile', $account); |
|
1475 | + } |
|
1476 | + // Render the form |
|
1477 | + module_load_include('pages.inc', 'node', 'node'); |
|
1478 | + return content_profile_page_edit('profile', $account); |
|
1479 | 1479 | } |
1480 | 1480 | |
1481 | 1481 | /** |
1482 | - * Join page menu callback. |
|
1483 | - * Display instructions on joining for new or existing BOINC users |
|
1484 | - */ |
|
1482 | + * Join page menu callback. |
|
1483 | + * Display instructions on joining for new or existing BOINC users |
|
1484 | + */ |
|
1485 | 1485 | function join_page($type = null) { |
1486 | - global $base_url; |
|
1487 | - /* The paths/links to the rules-and-policies page is hardcoded |
|
1486 | + global $base_url; |
|
1487 | + /* The paths/links to the rules-and-policies page is hardcoded |
|
1488 | 1488 | * here. An improvement would be admin settings for the Join Page |
1489 | 1489 | * where this path could be set. |
1490 | 1490 | */ |
1491 | - $ruleslinkA = 'rules-and-policies'; |
|
1492 | - $ruleslinkB = 'content/rules-and-policies'; |
|
1493 | - $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
1494 | - $registration_enabled = variable_get('user_register', 0); |
|
1495 | - $output = '<div class="join">'; |
|
1496 | - switch ($type) { |
|
1497 | - case 'boinc': |
|
1491 | + $ruleslinkA = 'rules-and-policies'; |
|
1492 | + $ruleslinkB = 'content/rules-and-policies'; |
|
1493 | + $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
1494 | + $registration_enabled = variable_get('user_register', 0); |
|
1495 | + $output = '<div class="join">'; |
|
1496 | + switch ($type) { |
|
1497 | + case 'boinc': |
|
1498 | 1498 | $output .= '<ol>'; |
1499 | 1499 | if ($registration_enabled) { |
1500 | - $output .= '<li>' . bts('First !create_an_account here at @sitename.', |
|
1501 | - array( |
|
1500 | + $output .= '<li>' . bts('First !create_an_account here at @sitename.', |
|
1501 | + array( |
|
1502 | 1502 | '!create_an_account' => l(bts('create an account', array(), NULL, 'boinc:join-page'), 'user/registration'), |
1503 | 1503 | '@sitename' => $site_name, |
1504 | - ), NULL, 'boinc:join-page') . '</li>'; |
|
1504 | + ), NULL, 'boinc:join-page') . '</li>'; |
|
1505 | 1505 | } |
1506 | 1506 | $output .= ' <li>' . bts("Install BOINC on this device if not already present.", array(), NULL, 'boinc:join-page') . '</li>'; |
1507 | 1507 | $output .= ' <li>' . bts("Select <i>Tools / Add Project</i>. Choose @sitename from the list, or enter @siteurl.", |
1508 | 1508 | array( |
1509 | - '@sitename' => $site_name, |
|
1510 | - '@siteurl' => $base_url, |
|
1509 | + '@sitename' => $site_name, |
|
1510 | + '@siteurl' => $base_url, |
|
1511 | 1511 | ), NULL, 'boinc:join-page') . '</li>'; |
1512 | 1512 | if ($registration_enabled) { |
1513 | - $output .= '<li>' . bts("If you're running a command-line or pre-5.0 version of BOINC, use <b>!boinccmd</b> to add the project.", |
|
1513 | + $output .= '<li>' . bts("If you're running a command-line or pre-5.0 version of BOINC, use <b>!boinccmd</b> to add the project.", |
|
1514 | 1514 | array( |
1515 | - '!boinccmd' => l('boinccmd --project_attach', 'http://boinc.berkeley.edu/wiki/Boinccmd_tool'), |
|
1515 | + '!boinccmd' => l('boinccmd --project_attach', 'http://boinc.berkeley.edu/wiki/Boinccmd_tool'), |
|
1516 | 1516 | ), NULL, 'boinc:join-page') . '</li>'; |
1517 | 1517 | } |
1518 | 1518 | else { |
1519 | - $output .= '<li>' . bts("If you're running a command-line version of BOINC, |
|
1519 | + $output .= '<li>' . bts("If you're running a command-line version of BOINC, |
|
1520 | 1520 | please follow the <b>!instructionslink</b> to first <i>create an account</i>, and then <i>attach</i> to this project. Use the same project URL as above.", |
1521 | 1521 | array( |
1522 | - '!instructionslink' => l('instructions', 'http://boinc.berkeley.edu/wiki/Boinccmd_tool'), |
|
1522 | + '!instructionslink' => l('instructions', 'http://boinc.berkeley.edu/wiki/Boinccmd_tool'), |
|
1523 | 1523 | ), NULL, 'boinc:join-page') . '</li>'; |
1524 | 1524 | } |
1525 | 1525 | $output .= '<li>' . bts("If you're running a pre-5.0 version of BOINC, please |
1526 | 1526 | upgrade to a more recent version of BOINC to create an account |
1527 | 1527 | at @this_project.", |
1528 | - array( |
|
1528 | + array( |
|
1529 | 1529 | '@this_project' => $site_name, |
1530 | - ), NULL, 'boinc:join-page') . '</li>'; |
|
1530 | + ), NULL, 'boinc:join-page') . '</li>'; |
|
1531 | 1531 | $output .= '</ol>'; |
1532 | 1532 | break; |
1533 | - case 'new': |
|
1533 | + case 'new': |
|
1534 | 1534 | default: |
1535 | 1535 | // Determine if there is a link to rules-and-policies |
1536 | 1536 | //$ruleslink=''; |
@@ -1545,16 +1545,16 @@ discard block |
||
1545 | 1545 | // Join page output |
1546 | 1546 | $output .= '<ol>'; |
1547 | 1547 | if ($registration_enabled) { |
1548 | - $output .= '<li>' . bts('First !create_an_account here at @sitename.', |
|
1549 | - array( |
|
1548 | + $output .= '<li>' . bts('First !create_an_account here at @sitename.', |
|
1549 | + array( |
|
1550 | 1550 | '!create_an_account' => l(bts('create an account', array(), NULL, 'boinc:join-page'), 'user/registration'), |
1551 | 1551 | '@sitename' => $site_name, |
1552 | - ), NULL, 'boinc:join-page') . '</li>'; |
|
1552 | + ), NULL, 'boinc:join-page') . '</li>'; |
|
1553 | 1553 | } |
1554 | 1554 | else if ( menu_valid_path(array('link_path' => $ruleslink)) ) { |
1555 | - $output .= ' <li>' . bts("Read our !rules_and_policies.", array( |
|
1555 | + $output .= ' <li>' . bts("Read our !rules_and_policies.", array( |
|
1556 | 1556 | '!rules_and_policies' => l(bts('Rules and Policies', array(), NULL, 'boinc:join-page'), $ruleslink), |
1557 | - ), NULL, 'boinc:join-page') . '</li>'; |
|
1557 | + ), NULL, 'boinc:join-page') . '</li>'; |
|
1558 | 1558 | } |
1559 | 1559 | $output .= ' <li>' . bts('Download the BOINC desktop software.', array(), NULL, 'boinc:join-page'); |
1560 | 1560 | $output .= ' <p>'; |
@@ -1564,73 +1564,73 @@ discard block |
||
1564 | 1564 | $output .= ' </li>'; |
1565 | 1565 | $output .= ' <li>' . bts('Run the installer.', array(), NULL, 'boinc:join-page') . '</li>'; |
1566 | 1566 | $output .= ' <li>' . bts('Choose @sitename from the list, or enter @siteurl.', array( |
1567 | - '@sitename' => $site_name, |
|
1568 | - '@siteurl' => $base_url, |
|
1567 | + '@sitename' => $site_name, |
|
1568 | + '@siteurl' => $base_url, |
|
1569 | 1569 | ), NULL, 'boinc:join-page') . '</li>'; |
1570 | 1570 | $output .= '</ol>'; |
1571 | - } |
|
1572 | - $output .= '</div>'; |
|
1573 | - return $output; |
|
1571 | + } |
|
1572 | + $output .= '</div>'; |
|
1573 | + return $output; |
|
1574 | 1574 | } |
1575 | 1575 | |
1576 | 1576 | /** |
1577 | - * Home page content for embedding in Panels page |
|
1578 | - */ |
|
1577 | + * Home page content for embedding in Panels page |
|
1578 | + */ |
|
1579 | 1579 | function boincuser_home_page() { |
1580 | - global $user; |
|
1581 | - $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
1582 | - // get the front page message from database; this is set in the admin interface under BOINC Other |
|
1583 | - $site_message = variable_get('boinc_other_frontpage',''); |
|
1580 | + global $user; |
|
1581 | + $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
1582 | + // get the front page message from database; this is set in the admin interface under BOINC Other |
|
1583 | + $site_message = variable_get('boinc_other_frontpage',''); |
|
1584 | 1584 | |
1585 | - // Determine the user of the day |
|
1586 | - $current_uotd = db_fetch_object(db_query(" |
|
1585 | + // Determine the user of the day |
|
1586 | + $current_uotd = db_fetch_object(db_query(" |
|
1587 | 1587 | SELECT |
1588 | 1588 | uid, |
1589 | 1589 | uotd_time |
1590 | 1590 | FROM {boincuser} |
1591 | 1591 | ORDER BY uotd_time DESC |
1592 | 1592 | LIMIT 1" |
1593 | - )); |
|
1594 | - if ($current_uotd->uotd_time < strtotime('today midnight')) { |
|
1593 | + )); |
|
1594 | + if ($current_uotd->uotd_time < strtotime('today midnight')) { |
|
1595 | 1595 | $uotd = boincuser_select_user_of_the_day(); |
1596 | - } |
|
1597 | - else { |
|
1596 | + } |
|
1597 | + else { |
|
1598 | 1598 | $uotd = user_load($current_uotd->uid); |
1599 | - } |
|
1600 | - $uotd_image = boincuser_get_user_profile_image($uotd->uid, FALSE); |
|
1601 | - $output = '<h2 class="pane-title">'; |
|
1602 | - $output .= ($user->uid) ? bts('Welcome back!', array(), NULL, 'boinc:front-page') : ($site_name ? bts('What is @this_project?', array('@this_project' => $site_name)) : bts('Welcome!', array(), NULL, 'boinc:front-page')); |
|
1603 | - $output .= '</h2>'; |
|
1604 | - $output .= '<div class="boinc-overview balance-height-front">'; |
|
1605 | - $output .= ' <div>' . bts($site_message, array(), NULL, "project:front page") . ' ' . l(bts('Learn more', array(), NULL, 'boinc:front-page'), 'about') . '</div>'; |
|
1606 | - if ($user->uid) { |
|
1599 | + } |
|
1600 | + $uotd_image = boincuser_get_user_profile_image($uotd->uid, FALSE); |
|
1601 | + $output = '<h2 class="pane-title">'; |
|
1602 | + $output .= ($user->uid) ? bts('Welcome back!', array(), NULL, 'boinc:front-page') : ($site_name ? bts('What is @this_project?', array('@this_project' => $site_name)) : bts('Welcome!', array(), NULL, 'boinc:front-page')); |
|
1603 | + $output .= '</h2>'; |
|
1604 | + $output .= '<div class="boinc-overview balance-height-front">'; |
|
1605 | + $output .= ' <div>' . bts($site_message, array(), NULL, "project:front page") . ' ' . l(bts('Learn more', array(), NULL, 'boinc:front-page'), 'about') . '</div>'; |
|
1606 | + if ($user->uid) { |
|
1607 | 1607 | $output .= ' <div>' . l(bts('View account', array(), NULL, 'boinc:front-page'), 'dashboard', array('attributes' => array('class' => 'join button'))) . '</div>'; |
1608 | - } |
|
1609 | - else { |
|
1608 | + } |
|
1609 | + else { |
|
1610 | 1610 | $output .= ' <div>' . l(bts('Join now', array(), NULL, 'boinc:front-page'), 'join', array('attributes' => array('class' => 'join button'))) . '</div>'; |
1611 | - } |
|
1612 | - $output .= '</div>'; |
|
1613 | - $output .= '<div class="boinc-overview-details">'; |
|
1614 | - $output .= ' <div class="detail-container">'; |
|
1615 | - $output .= ' <a class="user-of-the-day" href="account/' . $uotd->uid . '">'; |
|
1616 | - $output .= ' <div class="picture">'; |
|
1617 | - $output .= theme('imagefield_image', $uotd_image['image'], $uotd_image['alt'], |
|
1611 | + } |
|
1612 | + $output .= '</div>'; |
|
1613 | + $output .= '<div class="boinc-overview-details">'; |
|
1614 | + $output .= ' <div class="detail-container">'; |
|
1615 | + $output .= ' <a class="user-of-the-day" href="account/' . $uotd->uid . '">'; |
|
1616 | + $output .= ' <div class="picture">'; |
|
1617 | + $output .= theme('imagefield_image', $uotd_image['image'], $uotd_image['alt'], |
|
1618 | 1618 | $uotd_image['alt'], array(), FALSE); |
1619 | - $output .= ' </div>'; |
|
1620 | - $output .= ' <div class="text">' . bts('User of the day', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1621 | - $output .= ' <div class="detail">' . $uotd->boincuser_name . '</div>'; |
|
1622 | - $output .= ' </a>'; |
|
1623 | - $output .= ' <div class="volunteers">'; |
|
1624 | - $output .= ' <div class="text">' . bts('Over 500,000 volunteers and counting.', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1625 | - $output .= ' <div class="platforms">'; |
|
1626 | - $output .= ' <div class="detail platform windows">' . bts('Windows', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1627 | - $output .= ' <div class="detail platform mac">' . bts('Mac', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1628 | - $output .= ' <div class="detail platform linux">' . bts('Linux', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1629 | - $output .= ' </div>'; |
|
1630 | - $output .= ' </div>'; |
|
1631 | - $output .= ' </div>'; |
|
1632 | - $output .= '</div>'; |
|
1633 | - return $output; |
|
1619 | + $output .= ' </div>'; |
|
1620 | + $output .= ' <div class="text">' . bts('User of the day', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1621 | + $output .= ' <div class="detail">' . $uotd->boincuser_name . '</div>'; |
|
1622 | + $output .= ' </a>'; |
|
1623 | + $output .= ' <div class="volunteers">'; |
|
1624 | + $output .= ' <div class="text">' . bts('Over 500,000 volunteers and counting.', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1625 | + $output .= ' <div class="platforms">'; |
|
1626 | + $output .= ' <div class="detail platform windows">' . bts('Windows', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1627 | + $output .= ' <div class="detail platform mac">' . bts('Mac', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1628 | + $output .= ' <div class="detail platform linux">' . bts('Linux', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1629 | + $output .= ' </div>'; |
|
1630 | + $output .= ' </div>'; |
|
1631 | + $output .= ' </div>'; |
|
1632 | + $output .= '</div>'; |
|
1633 | + return $output; |
|
1634 | 1634 | } |
1635 | 1635 | |
1636 | 1636 | /** |
@@ -1638,81 +1638,81 @@ discard block |
||
1638 | 1638 | * Create a new user account based on supplied parameters. |
1639 | 1639 | */ |
1640 | 1640 | function boincuser_create_account() { |
1641 | - global $base_url; |
|
1641 | + global $base_url; |
|
1642 | 1642 | |
1643 | - require_boinc('boinc_db'); |
|
1644 | - require_boinc('user_util'); |
|
1645 | - require_boinc('xml'); |
|
1646 | - $params = array( |
|
1643 | + require_boinc('boinc_db'); |
|
1644 | + require_boinc('user_util'); |
|
1645 | + require_boinc('xml'); |
|
1646 | + $params = array( |
|
1647 | 1647 | 'email_addr' => isset($_GET['email_addr']) ? $_GET['email_addr'] : '', |
1648 | 1648 | 'user_name' => isset($_GET['user_name']) ? $_GET['user_name'] : '', |
1649 | 1649 | 'passwd_hash' => isset($_GET['passwd_hash']) ? $_GET['passwd_hash'] : '' |
1650 | - ); |
|
1650 | + ); |
|
1651 | 1651 | |
1652 | - // Begin output |
|
1653 | - xml_header(); |
|
1652 | + // Begin output |
|
1653 | + xml_header(); |
|
1654 | 1654 | |
1655 | - // Account creation disabled |
|
1656 | - $enablethisRPC = variable_get('boinc_weboptions_enableaccountcreateRPC', TRUE); |
|
1657 | - if (!$enablethisRPC) { |
|
1655 | + // Account creation disabled |
|
1656 | + $enablethisRPC = variable_get('boinc_weboptions_enableaccountcreateRPC', TRUE); |
|
1657 | + if (!$enablethisRPC) { |
|
1658 | 1658 | $mess = bts('Account creation is done through our Web site. Please register at @url', array( |
1659 | - '@url' => $base_url . '/user/registration', |
|
1659 | + '@url' => $base_url . '/user/registration', |
|
1660 | 1660 | ), |
1661 | 1661 | NULL, 'boinc:create_account'); |
1662 | 1662 | xml_error(-208, $mess); |
1663 | - } |
|
1664 | - // Invalid invite code |
|
1663 | + } |
|
1664 | + // Invalid invite code |
|
1665 | 1665 | |
1666 | - // Validate input |
|
1667 | - if (user_validate_mail($params['email_addr']) or !is_valid_email_addr($params['email_addr'])) { |
|
1666 | + // Validate input |
|
1667 | + if (user_validate_mail($params['email_addr']) or !is_valid_email_addr($params['email_addr'])) { |
|
1668 | 1668 | xml_error(-205); |
1669 | - } |
|
1669 | + } |
|
1670 | 1670 | |
1671 | - // Make sure user_name is unique and cleaned |
|
1672 | - $unique_name = create_proper_drupalname($params['user_name']); |
|
1673 | - if ($error = user_validate_name($unique_name)) { |
|
1671 | + // Make sure user_name is unique and cleaned |
|
1672 | + $unique_name = create_proper_drupalname($params['user_name']); |
|
1673 | + if ($error = user_validate_name($unique_name)) { |
|
1674 | 1674 | xml_error(-188, $error); |
1675 | - } |
|
1676 | - if (strlen($params['passwd_hash']) != 32) { |
|
1675 | + } |
|
1676 | + if (strlen($params['passwd_hash']) != 32) { |
|
1677 | 1677 | xml_error(-1, 'password hash length not 32'); |
1678 | - } |
|
1678 | + } |
|
1679 | 1679 | |
1680 | - // Process input |
|
1681 | - // Check this email against previous email addresses. |
|
1682 | - $tmpuser = BoincUser::lookup_prev_email_addr($params['email_addr']); |
|
1683 | - if ($tmpuser) { |
|
1680 | + // Process input |
|
1681 | + // Check this email against previous email addresses. |
|
1682 | + $tmpuser = BoincUser::lookup_prev_email_addr($params['email_addr']); |
|
1683 | + if ($tmpuser) { |
|
1684 | 1684 | xml_error(-137); |
1685 | - } |
|
1685 | + } |
|
1686 | 1686 | |
1687 | - // Check this email on current email addresses. |
|
1688 | - $boinc_user = BoincUser::lookup_email_addr($params['email_addr']); |
|
1689 | - if ($boinc_user) { |
|
1687 | + // Check this email on current email addresses. |
|
1688 | + $boinc_user = BoincUser::lookup_email_addr($params['email_addr']); |
|
1689 | + if ($boinc_user) { |
|
1690 | 1690 | // Return authenticator for existing users |
1691 | 1691 | if ( ($params['passwd_hash'] == $boinc_user->passwd_hash) or |
1692 | 1692 | password_verify($params['passwd_hash'], $boinc_user->passwd_hash) ) { |
1693 | - $output = array('authenticator' => $boinc_user->authenticator); |
|
1693 | + $output = array('authenticator' => $boinc_user->authenticator); |
|
1694 | 1694 | } |
1695 | 1695 | else { |
1696 | - xml_error(-137); |
|
1696 | + xml_error(-137); |
|
1697 | 1697 | } |
1698 | - } |
|
1699 | - else { |
|
1698 | + } |
|
1699 | + else { |
|
1700 | 1700 | // Verify that there isn't somehow a Drupal user already (not possible with proper function) |
1701 | 1701 | if ($existing_user = user_load(array('mail' => $params['email_addr']))) { |
1702 | - xml_error(-137, 'account error'); |
|
1702 | + xml_error(-137, 'account error'); |
|
1703 | 1703 | } |
1704 | 1704 | // Create new account |
1705 | 1705 | $unrestricted_role = array_search('community member', user_roles(true)); |
1706 | 1706 | |
1707 | 1707 | $newUser = array( |
1708 | - 'name' => $unique_name, |
|
1709 | - 'pass' => $params['passwd_hash'], // note: passing a hash here requires ALL passwords to be hashed via hook prior to interacting with the hash stored in the db |
|
1710 | - 'mail' => $params['email_addr'], |
|
1711 | - 'status' => 1, |
|
1712 | - 'init' => $params['email_addr'], |
|
1713 | - 'roles' => array($unrestricted_role => ''), |
|
1714 | - 'boincuser_name' => $params['user_name'], |
|
1715 | - 'boinchash_flag' => TRUE, |
|
1708 | + 'name' => $unique_name, |
|
1709 | + 'pass' => $params['passwd_hash'], // note: passing a hash here requires ALL passwords to be hashed via hook prior to interacting with the hash stored in the db |
|
1710 | + 'mail' => $params['email_addr'], |
|
1711 | + 'status' => 1, |
|
1712 | + 'init' => $params['email_addr'], |
|
1713 | + 'roles' => array($unrestricted_role => ''), |
|
1714 | + 'boincuser_name' => $params['user_name'], |
|
1715 | + 'boinchash_flag' => TRUE, |
|
1716 | 1716 | ); |
1717 | 1717 | |
1718 | 1718 | // Create the drupal user. If the drupal user cannot be created, |
@@ -1720,17 +1720,17 @@ discard block |
||
1720 | 1720 | // The user is created in the 'insert' op in hook_user. |
1721 | 1721 | $user = user_save(null, $newUser); |
1722 | 1722 | if (!$user) { |
1723 | - watchdog('boincuser', 'create_account: Failed to create Drupal user account for @email', array('@email' => $params['email_addr']), WATCHDOG_WARNING); |
|
1724 | - xml_error(-137, 'error creating BOINC account'); |
|
1723 | + watchdog('boincuser', 'create_account: Failed to create Drupal user account for @email', array('@email' => $params['email_addr']), WATCHDOG_WARNING); |
|
1724 | + xml_error(-137, 'error creating BOINC account'); |
|
1725 | 1725 | }// if drupal user created. |
1726 | 1726 | |
1727 | 1727 | $output = array('authenticator' => $user->boincuser_account_key); |
1728 | - }// if existing user found. |
|
1728 | + }// if existing user found. |
|
1729 | 1729 | |
1730 | - // Output authenticator |
|
1731 | - echo " <account_out>\n"; |
|
1732 | - echo " <authenticator>{$output['authenticator']}</authenticator>\n"; |
|
1733 | - echo "</account_out>\n"; |
|
1730 | + // Output authenticator |
|
1731 | + echo " <account_out>\n"; |
|
1732 | + echo " <authenticator>{$output['authenticator']}</authenticator>\n"; |
|
1733 | + echo "</account_out>\n"; |
|
1734 | 1734 | } |
1735 | 1735 | |
1736 | 1736 | /** |
@@ -1738,166 +1738,166 @@ discard block |
||
1738 | 1738 | * account is created using the BOINC clinet. |
1739 | 1739 | */ |
1740 | 1740 | function boincuser_account_finish() { |
1741 | - global $user; |
|
1741 | + global $user; |
|
1742 | 1742 | |
1743 | - $authtoken = isset($_GET['auth']) ? $_GET['auth'] : ''; |
|
1743 | + $authtoken = isset($_GET['auth']) ? $_GET['auth'] : ''; |
|
1744 | 1744 | |
1745 | - // Ensure there is a authentication token before continuing |
|
1746 | - if (empty($authtoken)) { |
|
1745 | + // Ensure there is a authentication token before continuing |
|
1746 | + if (empty($authtoken)) { |
|
1747 | 1747 | drupal_not_found(); |
1748 | 1748 | return ; |
1749 | - } |
|
1749 | + } |
|
1750 | 1750 | |
1751 | - if (strlen($authtoken) != 32) { |
|
1751 | + if (strlen($authtoken) != 32) { |
|
1752 | 1752 | drupal_set_message(bts('ERROR: There is no account with that authenticator.', array(), NULL, 'boinc:account-finish'), 'error'); |
1753 | 1753 | drupal_goto(); |
1754 | - } |
|
1754 | + } |
|
1755 | 1755 | |
1756 | - require_boinc('boinc_db'); |
|
1757 | - $boinc_user = BoincUser::lookup("authenticator='".addslashes($authtoken)."'"); |
|
1758 | - if (!$boinc_user) { |
|
1756 | + require_boinc('boinc_db'); |
|
1757 | + $boinc_user = BoincUser::lookup("authenticator='".addslashes($authtoken)."'"); |
|
1758 | + if (!$boinc_user) { |
|
1759 | 1759 | drupal_set_message(bts('ERROR: There is no account with that authenticator.', array(), NULL, 'boinc:account-finish'), 'error'); |
1760 | 1760 | drupal_goto(); |
1761 | - } |
|
1762 | - $user = user_load(get_drupal_id($boinc_user->id)); |
|
1761 | + } |
|
1762 | + $user = user_load(get_drupal_id($boinc_user->id)); |
|
1763 | 1763 | |
1764 | - if (!$user) { |
|
1764 | + if (!$user) { |
|
1765 | 1765 | drupal_set_message(bts('ERROR: There was a problem loading your account. Try logging in with your user name and password.', array(), NULL, 'boinc:account-finish'), 'error'); |
1766 | 1766 | drupal_goto(); |
1767 | - } |
|
1767 | + } |
|
1768 | 1768 | |
1769 | - // Lookup path to custom account finish page |
|
1770 | - $customaccountfinishpath = drupal_lookup_path('source', variable_get('boinc_weboptions_accountfinish', '') ); |
|
1771 | - if ( menu_valid_path(array('link_path' => $customaccountfinishpath)) ) { |
|
1769 | + // Lookup path to custom account finish page |
|
1770 | + $customaccountfinishpath = drupal_lookup_path('source', variable_get('boinc_weboptions_accountfinish', '') ); |
|
1771 | + if ( menu_valid_path(array('link_path' => $customaccountfinishpath)) ) { |
|
1772 | 1772 | $node = menu_get_object('node', 1, $customaccountfinishpath); |
1773 | 1773 | if ($node) { |
1774 | - return node_page_view($node); |
|
1774 | + return node_page_view($node); |
|
1775 | + } |
|
1775 | 1776 | } |
1776 | - } |
|
1777 | 1777 | |
1778 | - // open links in new window |
|
1779 | - $options = array( |
|
1778 | + // open links in new window |
|
1779 | + $options = array( |
|
1780 | 1780 | 'attributes' => array( 'target' => '_blank' ), |
1781 | - ); |
|
1781 | + ); |
|
1782 | 1782 | |
1783 | - // Check moderation page exists |
|
1784 | - $moderationpath = drupal_lookup_path('source', variable_get('boinc_weboptions_moderationpage', '') ); |
|
1785 | - if ( menu_valid_path(array('link_path' => $moderationpath)) ) { |
|
1783 | + // Check moderation page exists |
|
1784 | + $moderationpath = drupal_lookup_path('source', variable_get('boinc_weboptions_moderationpage', '') ); |
|
1785 | + if ( menu_valid_path(array('link_path' => $moderationpath)) ) { |
|
1786 | 1786 | $modsentence = bts('Please note: user profiles are subject to !moderation.', array('!moderation' => l(bts('moderation', array(), NULL, 'boinc:account-finish'), $moderationpath, $options)), NULL, 'boinc:account-finish'); |
1787 | - } else { |
|
1787 | + } else { |
|
1788 | 1788 | $modsentence = bts('Please note: user profiles are subject to moderation.', array(), NULL, 'boinc:account-finish'); |
1789 | - } |
|
1789 | + } |
|
1790 | 1790 | |
1791 | - $username = $user->boincuser_name; |
|
1792 | - $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
1793 | - $output = "<p>" . bts('Thank you @user_name for joining @site_name. Your account has been created. Your BOINC client should start working on assigned tasks soon, without any additional action or configuration. Please visit the links below for more information and additional options. (Links will open in a new window.)', |
|
1794 | - array( |
|
1791 | + $username = $user->boincuser_name; |
|
1792 | + $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
1793 | + $output = "<p>" . bts('Thank you @user_name for joining @site_name. Your account has been created. Your BOINC client should start working on assigned tasks soon, without any additional action or configuration. Please visit the links below for more information and additional options. (Links will open in a new window.)', |
|
1794 | + array( |
|
1795 | 1795 | '@user_name' => $username, |
1796 | 1796 | '@site_name' => $site_name, |
1797 | - ), NULL, 'boinc:account-finish') . "</p>"; |
|
1797 | + ), NULL, 'boinc:account-finish') . "</p>"; |
|
1798 | 1798 | |
1799 | - $links = array( |
|
1799 | + $links = array( |
|
1800 | 1800 | array( |
1801 | - 'data' => bts('Change your username at !community_preferences.', array( |
|
1801 | + 'data' => bts('Change your username at !community_preferences.', array( |
|
1802 | 1802 | '!community_preferences' => l(bts('Community Preferences', array(), NULL, 'boinc:account-fininsh'), 'account/prefs/community', $options), |
1803 | - ), NULL, 'boinc:account-finish'), |
|
1804 | - 'children' => array( |
|
1803 | + ), NULL, 'boinc:account-finish'), |
|
1804 | + 'children' => array( |
|
1805 | 1805 | bts('Your username is used to identify yourself to other volunteers on this Web site.', array(), NULL, 'boinc:account-finish'), |
1806 | 1806 | bts('In addition, you may set your account\'s default language and adjust notification settings.', array(), NULL, 'boinc:account-finish'), |
1807 | - ), |
|
1807 | + ), |
|
1808 | 1808 | ), |
1809 | 1809 | array( |
1810 | - 'data' => bts('Change your !computing_preferences.', array( |
|
1810 | + 'data' => bts('Change your !computing_preferences.', array( |
|
1811 | 1811 | '!computing_preferences' => l(bts('Computing Preferences', array(), NULL, 'boinc:account-finish'), 'account/prefs', $options), |
1812 | - ), NULL, 'boinc:account-finish'), |
|
1813 | - 'children' => array( |
|
1812 | + ), NULL, 'boinc:account-finish'), |
|
1813 | + 'children' => array( |
|
1814 | 1814 | bts('You may adjust how much CPU, RAM, and Disk space the BOINC client is allowed to use for tasks on your computer.', array(), NULL, 'boinc:account-finish'), |
1815 | 1815 | bts('By default, you will run @site_name tasks without any additional configuration.', array( |
1816 | - '@site_name' => $site_name, |
|
1816 | + '@site_name' => $site_name, |
|
1817 | 1817 | ), NULL, 'boinc:account-finish'), |
1818 | 1818 | bts('It is recommended new volunteers leave the default settings until they gain experience running some tasks. Ask questions in the !forums to get advice before making changes to a setting you don\'t understand.', array( |
1819 | - '!forums' => l(bts('forums', array(), NULL, 'boinc:account-finish'), 'community/forum', $options), |
|
1819 | + '!forums' => l(bts('forums', array(), NULL, 'boinc:account-finish'), 'community/forum', $options), |
|
1820 | 1820 | ), NULL, 'boinc:account-finish'), |
1821 | - ), |
|
1821 | + ), |
|
1822 | 1822 | ), |
1823 | 1823 | array( |
1824 | 1824 | 'data' => bts('Create a !user_profile.', array( |
1825 | - '!user_profile' => l(bts('User Profile', array(), NULL, 'boinc:account-finish'), '/account/profile/edit', $options), |
|
1825 | + '!user_profile' => l(bts('User Profile', array(), NULL, 'boinc:account-finish'), '/account/profile/edit', $options), |
|
1826 | 1826 | ), NULL, 'boinc:account-finish'), |
1827 | - 'children' => array( |
|
1827 | + 'children' => array( |
|
1828 | 1828 | bts('A user profile will inform other volunteers who you are and why you joined @site_name.', array( |
1829 | - '@site_name' => $site_name, |
|
1829 | + '@site_name' => $site_name, |
|
1830 | 1830 | ), NULL, 'boinc:account-finish'), |
1831 | 1831 | $modsentence, |
1832 | - ), |
|
1832 | + ), |
|
1833 | 1833 | ), |
1834 | 1834 | array( |
1835 | - 'data' => bts('Join a !team.', array( |
|
1835 | + 'data' => bts('Join a !team.', array( |
|
1836 | 1836 | '!team' => l(bts('Team', array(), NULL, 'boinc:account-finish'), '/community/teams', $options), |
1837 | - ), NULL, 'boinc:account-finish'), |
|
1838 | - 'children' => array( |
|
1837 | + ), NULL, 'boinc:account-finish'), |
|
1838 | + 'children' => array( |
|
1839 | 1839 | bts('You may join a team, made up of other volunteers.', array(), NULL, 'boinc:account-finish'), |
1840 | - ), |
|
1840 | + ), |
|
1841 | 1841 | ), |
1842 | 1842 | array( |
1843 | - 'data' => bts('Go to your !account_dashboard.', array( |
|
1843 | + 'data' => bts('Go to your !account_dashboard.', array( |
|
1844 | 1844 | '!account_dashboard'=> l(bts('Account Dashboard', array(), NULL, 'boinc:account-finish'), 'account/dashboard', $options), |
1845 | - ), NULL, 'boinc:account-finish'), |
|
1846 | - 'children' => array( |
|
1845 | + ), NULL, 'boinc:account-finish'), |
|
1846 | + 'children' => array( |
|
1847 | 1847 | bts('Your account dashboard has information and links about your computer(s) and task(s) assigned.', array(), NULL, 'boinc:account-finish'), |
1848 | - ), |
|
1848 | + ), |
|
1849 | 1849 | ), |
1850 | 1850 | array( |
1851 | - 'data' => bts('Visit our !help pages.', array( |
|
1851 | + 'data' => bts('Visit our !help pages.', array( |
|
1852 | 1852 | '!help' => l(bts('Help', array(), NULL, 'boinc:account-finish'), '/help', $options) |
1853 | - ), NULL, 'boinc:account-finish'), |
|
1854 | - 'children' => array( |
|
1853 | + ), NULL, 'boinc:account-finish'), |
|
1854 | + 'children' => array( |
|
1855 | 1855 | bts('Ask for help in our community\'s !forums.', array( |
1856 | - '!forums' => l(bts('forums', array(), NULL, 'boinc:account-finish'), 'community/forum', $options) |
|
1856 | + '!forums' => l(bts('forums', array(), NULL, 'boinc:account-finish'), 'community/forum', $options) |
|
1857 | 1857 | ), NULL, 'boinc:account-finish'), |
1858 | - ), |
|
1858 | + ), |
|
1859 | 1859 | ), |
1860 | - ); |
|
1860 | + ); |
|
1861 | 1861 | |
1862 | - //List of links |
|
1863 | - $output .= theme_item_list($links, $title = NULL, $type='ul'); |
|
1862 | + //List of links |
|
1863 | + $output .= theme_item_list($links, $title = NULL, $type='ul'); |
|
1864 | 1864 | |
1865 | - return $output; |
|
1865 | + return $output; |
|
1866 | 1866 | } |
1867 | 1867 | |
1868 | 1868 | /** |
1869 | 1869 | * Determine if the user has permission to control community access |
1870 | 1870 | */ |
1871 | 1871 | function boincuser_moderate_community_access() { |
1872 | - if (user_access('assign community member role') |
|
1872 | + if (user_access('assign community member role') |
|
1873 | 1873 | OR user_access('assign all roles')) { |
1874 | 1874 | return TRUE; |
1875 | - } |
|
1876 | - return FALSE; |
|
1875 | + } |
|
1876 | + return FALSE; |
|
1877 | 1877 | } |
1878 | 1878 | |
1879 | 1879 | /** |
1880 | 1880 | * Get the count of items in the moderation queue |
1881 | 1881 | */ |
1882 | 1882 | function boincuser_moderation_queue_count($caller = 'user') { |
1883 | - $allowed = FALSE; |
|
1884 | - switch ($caller) { |
|
1885 | - case 'cron': |
|
1883 | + $allowed = FALSE; |
|
1884 | + switch ($caller) { |
|
1885 | + case 'cron': |
|
1886 | 1886 | $allowed = TRUE; |
1887 | 1887 | break; |
1888 | - case 'user': |
|
1888 | + case 'user': |
|
1889 | 1889 | default: |
1890 | 1890 | $allowed = user_access('edit any profile content'); |
1891 | - } |
|
1892 | - if ($allowed) { |
|
1891 | + } |
|
1892 | + if ($allowed) { |
|
1893 | 1893 | return db_result(db_query(" |
1894 | 1894 | SELECT COUNT(*) |
1895 | 1895 | FROM {node} |
1896 | 1896 | WHERE type = 'profile' |
1897 | 1897 | AND moderate = 1" |
1898 | 1898 | )); |
1899 | - } |
|
1900 | - return NULL; |
|
1899 | + } |
|
1900 | + return NULL; |
|
1901 | 1901 | } |
1902 | 1902 | |
1903 | 1903 | /** |
@@ -1906,43 +1906,43 @@ discard block |
||
1906 | 1906 | * than through the user account info form. |
1907 | 1907 | */ |
1908 | 1908 | function boincuser_control($uid = NULL, $action = NULL) { |
1909 | - if (!$uid OR !$account = user_load($uid)) { |
|
1909 | + if (!$uid OR !$account = user_load($uid)) { |
|
1910 | 1910 | // What are you even doing here... |
1911 | 1911 | return FALSE; |
1912 | - } |
|
1913 | - switch ($action) { |
|
1914 | - case 'ban': |
|
1912 | + } |
|
1913 | + switch ($action) { |
|
1914 | + case 'ban': |
|
1915 | 1915 | if (boincuser_moderate_community_access()) { |
1916 | - $penalty_period = variable_get('boinc_penalty_period', 7*24*60*60); |
|
1917 | - $boincuser_record = array( |
|
1916 | + $penalty_period = variable_get('boinc_penalty_period', 7*24*60*60); |
|
1917 | + $boincuser_record = array( |
|
1918 | 1918 | 'uid' => $uid, |
1919 | 1919 | 'penalty_expiration' => time() + $penalty_period, |
1920 | - ); |
|
1921 | - drupal_write_record('boincuser', $boincuser_record, 'uid'); |
|
1922 | - $community_role = array_search('community member', user_roles(true)); |
|
1923 | - if (isset($account->roles[$community_role])) { |
|
1920 | + ); |
|
1921 | + drupal_write_record('boincuser', $boincuser_record, 'uid'); |
|
1922 | + $community_role = array_search('community member', user_roles(true)); |
|
1923 | + if (isset($account->roles[$community_role])) { |
|
1924 | 1924 | unset($account->roles[$community_role]); |
1925 | 1925 | user_save($account, array('roles' => $account->roles)); |
1926 | - } |
|
1926 | + } |
|
1927 | 1927 | } |
1928 | 1928 | break; |
1929 | - case 'lift-ban': |
|
1929 | + case 'lift-ban': |
|
1930 | 1930 | if (boincuser_moderate_community_access()) { |
1931 | - $boincuser_record = array( |
|
1931 | + $boincuser_record = array( |
|
1932 | 1932 | 'uid' => $uid, |
1933 | 1933 | 'penalty_expiration' => 0, |
1934 | - ); |
|
1935 | - drupal_write_record('boincuser', $boincuser_record, 'uid'); |
|
1936 | - $community_role = array_search('community member', user_roles(true)); |
|
1937 | - if (!isset($account->roles[$community_role])) { |
|
1934 | + ); |
|
1935 | + drupal_write_record('boincuser', $boincuser_record, 'uid'); |
|
1936 | + $community_role = array_search('community member', user_roles(true)); |
|
1937 | + if (!isset($account->roles[$community_role])) { |
|
1938 | 1938 | $account->roles[$community_role] = 'community member'; |
1939 | 1939 | user_save($account, array('roles' => $account->roles)); |
1940 | - } |
|
1940 | + } |
|
1941 | 1941 | } |
1942 | 1942 | break; |
1943 | - default: |
|
1943 | + default: |
|
1944 | 1944 | } |
1945 | - drupal_goto("account/{$account->uid}"); |
|
1945 | + drupal_goto("account/{$account->uid}"); |
|
1946 | 1946 | } |
1947 | 1947 | |
1948 | 1948 | /** |
@@ -1950,29 +1950,29 @@ discard block |
||
1950 | 1950 | * moderation flag. |
1951 | 1951 | */ |
1952 | 1952 | function boincuser_moderate_profile_approve($account) { |
1953 | - $node = new stdClass; |
|
1954 | - $node->type = 'profile'; |
|
1955 | - $node->language = ''; |
|
1956 | - $nid = content_profile_profile_exists($node, $account->uid); |
|
1957 | - $profile = node_load($nid); |
|
1958 | - $profile->moderate = 0; |
|
1959 | - $profile->status = 1; |
|
1960 | - node_save($profile); |
|
1961 | - drupal_set_message('This profile has been marked as approved.'); |
|
1962 | - drupal_goto(); |
|
1953 | + $node = new stdClass; |
|
1954 | + $node->type = 'profile'; |
|
1955 | + $node->language = ''; |
|
1956 | + $nid = content_profile_profile_exists($node, $account->uid); |
|
1957 | + $profile = node_load($nid); |
|
1958 | + $profile->moderate = 0; |
|
1959 | + $profile->status = 1; |
|
1960 | + node_save($profile); |
|
1961 | + drupal_set_message('This profile has been marked as approved.'); |
|
1962 | + drupal_goto(); |
|
1963 | 1963 | } |
1964 | 1964 | |
1965 | 1965 | /** |
1966 | 1966 | * Mark a user profile as rejected and notify the user of the reason. |
1967 | 1967 | */ |
1968 | 1968 | function boincuser_moderate_profile_reject($uid, $reason = '') { |
1969 | - $account = user_load($uid); |
|
1970 | - $node = new stdClass; |
|
1971 | - $node->type = 'profile'; |
|
1972 | - $node->language = ''; |
|
1973 | - $nid = content_profile_profile_exists($node, $uid); |
|
1974 | - $profile = node_load($nid); |
|
1975 | - if ($profile->nid) { |
|
1969 | + $account = user_load($uid); |
|
1970 | + $node = new stdClass; |
|
1971 | + $node->type = 'profile'; |
|
1972 | + $node->language = ''; |
|
1973 | + $nid = content_profile_profile_exists($node, $uid); |
|
1974 | + $profile = node_load($nid); |
|
1975 | + if ($profile->nid) { |
|
1976 | 1976 | global $user; |
1977 | 1977 | global $base_url; |
1978 | 1978 | global $base_path; |
@@ -1983,64 +1983,64 @@ discard block |
||
1983 | 1983 | $profile->status = 0; |
1984 | 1984 | node_save($profile); |
1985 | 1985 | $settings = array( |
1986 | - 'from' => '', |
|
1987 | - 'subject' => "Profile moderation at {$site_name}", |
|
1988 | - 'message' => '' |
|
1989 | - . "{$account->boincuser_name},\n" |
|
1990 | - . "\n" |
|
1991 | - . "{$moderator->boincuser_name} has rejected your profile at" |
|
1992 | - . " {$site_name} for the following reason: \n" |
|
1993 | - . "\n" |
|
1994 | - . "{$reason}\n" |
|
1995 | - . "\n" |
|
1996 | - . "\n" |
|
1997 | - . "Since it has not been approved, your profile is not visible to other" |
|
1998 | - . " {$site_name} users. Please make the needed changes here:\n" |
|
1999 | - . "\n" |
|
2000 | - . "{$site_url}account/profile \n" |
|
2001 | - . "\n" |
|
2002 | - . "Thanks, \n" |
|
2003 | - . "\n" |
|
2004 | - . "{$site_name} support team", |
|
1986 | + 'from' => '', |
|
1987 | + 'subject' => "Profile moderation at {$site_name}", |
|
1988 | + 'message' => '' |
|
1989 | + . "{$account->boincuser_name},\n" |
|
1990 | + . "\n" |
|
1991 | + . "{$moderator->boincuser_name} has rejected your profile at" |
|
1992 | + . " {$site_name} for the following reason: \n" |
|
1993 | + . "\n" |
|
1994 | + . "{$reason}\n" |
|
1995 | + . "\n" |
|
1996 | + . "\n" |
|
1997 | + . "Since it has not been approved, your profile is not visible to other" |
|
1998 | + . " {$site_name} users. Please make the needed changes here:\n" |
|
1999 | + . "\n" |
|
2000 | + . "{$site_url}account/profile \n" |
|
2001 | + . "\n" |
|
2002 | + . "Thanks, \n" |
|
2003 | + . "\n" |
|
2004 | + . "{$site_name} support team", |
|
2005 | 2005 | ); |
2006 | 2006 | rules_action_mail_to_user($account, $settings); |
2007 | 2007 | drupal_set_message('This profile has been marked as rejected.'); |
2008 | - } |
|
2009 | - drupal_goto(); |
|
2008 | + } |
|
2009 | + drupal_goto(); |
|
2010 | 2010 | } |
2011 | 2011 | |
2012 | 2012 | /** |
2013 | 2013 | * Ban a user and send a notification of the reason. |
2014 | 2014 | */ |
2015 | 2015 | function boincuser_moderate_user_ban($uid, $reason = '', $duration = '') { |
2016 | - if (user_access('assign community member role') |
|
2016 | + if (user_access('assign community member role') |
|
2017 | 2017 | OR user_access('assign all roles')) { |
2018 | 2018 | $account = user_load($uid); |
2019 | 2019 | if ($account->uid) { |
2020 | - module_load_include('inc', 'rules', 'modules/system.rules'); |
|
2021 | - if ($duration === '') { |
|
2020 | + module_load_include('inc', 'rules', 'modules/system.rules'); |
|
2021 | + if ($duration === '') { |
|
2022 | 2022 | $duration = variable_get('boinc_penalty_period', 7*24*60*60); |
2023 | - } |
|
2024 | - $penalty_expiration = ($duration > 0) ? time() + $duration : 4294967295; |
|
2025 | - $boincuser_record = array( |
|
2023 | + } |
|
2024 | + $penalty_expiration = ($duration > 0) ? time() + $duration : 4294967295; |
|
2025 | + $boincuser_record = array( |
|
2026 | 2026 | 'uid' => $uid, |
2027 | 2027 | 'penalty_expiration' => $penalty_expiration, |
2028 | - ); |
|
2029 | - drupal_write_record('boincuser', $boincuser_record, 'uid'); |
|
2028 | + ); |
|
2029 | + drupal_write_record('boincuser', $boincuser_record, 'uid'); |
|
2030 | 2030 | |
2031 | - $community_role = array_search('community member', user_roles(true)); |
|
2032 | - if (isset($account->roles[$community_role])) { |
|
2031 | + $community_role = array_search('community member', user_roles(true)); |
|
2032 | + if (isset($account->roles[$community_role])) { |
|
2033 | 2033 | unset($account->roles[$community_role]); |
2034 | 2034 | user_save($account, array('roles' => $account->roles)); |
2035 | - } |
|
2035 | + } |
|
2036 | 2036 | |
2037 | - global $user; |
|
2038 | - global $base_url; |
|
2039 | - global $base_path; |
|
2040 | - $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
2041 | - $site_url = $base_url . $base_path; |
|
2042 | - $moderator = user_load($user->uid); |
|
2043 | - $settings = array( |
|
2037 | + global $user; |
|
2038 | + global $base_url; |
|
2039 | + global $base_path; |
|
2040 | + $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
2041 | + $site_url = $base_url . $base_path; |
|
2042 | + $moderator = user_load($user->uid); |
|
2043 | + $settings = array( |
|
2044 | 2044 | 'from' => '', |
2045 | 2045 | 'subject' => "User moderation at {$site_name}", |
2046 | 2046 | 'message' => '' |
@@ -2061,12 +2061,12 @@ discard block |
||
2061 | 2061 | . "Thanks, \n" |
2062 | 2062 | . "\n" |
2063 | 2063 | . "{$site_name} support team", |
2064 | - ); |
|
2065 | - rules_action_mail_to_user($account, $settings); |
|
2066 | - drupal_set_message('This user has been banned.'); |
|
2064 | + ); |
|
2065 | + rules_action_mail_to_user($account, $settings); |
|
2066 | + drupal_set_message('This user has been banned.'); |
|
2067 | 2067 | } |
2068 | - } |
|
2069 | - drupal_goto(); |
|
2068 | + } |
|
2069 | + drupal_goto(); |
|
2070 | 2070 | } |
2071 | 2071 | |
2072 | 2072 | |
@@ -2078,15 +2078,15 @@ discard block |
||
2078 | 2078 | * |
2079 | 2079 | */ |
2080 | 2080 | function boincuser_get_weak_auth($boinc_id = null) { |
2081 | - if (!$boinc_id) { |
|
2081 | + if (!$boinc_id) { |
|
2082 | 2082 | global $user; |
2083 | 2083 | $account = user_load($user->uid); |
2084 | 2084 | $boinc_id = $account->boincuser_id; |
2085 | - } |
|
2085 | + } |
|
2086 | 2086 | |
2087 | - $boinc_user = boincuser_load($account->boincuser_id); |
|
2087 | + $boinc_user = boincuser_load($account->boincuser_id); |
|
2088 | 2088 | |
2089 | - return weak_auth($boinc_user); |
|
2089 | + return weak_auth($boinc_user); |
|
2090 | 2090 | } |
2091 | 2091 | |
2092 | 2092 | /** |
@@ -2095,75 +2095,75 @@ discard block |
||
2095 | 2095 | * Drupal User so must be inserted into comments, etc. (not so by default) |
2096 | 2096 | */ |
2097 | 2097 | function boincuser_get_user_profile_image($uid, $avatar = TRUE) { |
2098 | - // Though the function name implies otherwise, get the avatar by default |
|
2099 | - $image_field = ($avatar) ? 'field_image_fid' : 'field_profile_image_fid'; |
|
2100 | - $image_fid = db_result(db_query(" |
|
2098 | + // Though the function name implies otherwise, get the avatar by default |
|
2099 | + $image_field = ($avatar) ? 'field_image_fid' : 'field_profile_image_fid'; |
|
2100 | + $image_fid = db_result(db_query(" |
|
2101 | 2101 | SELECT ctp.%s |
2102 | 2102 | FROM {content_type_profile} ctp |
2103 | 2103 | INNER JOIN {node} n ON ctp.nid = n.nid |
2104 | 2104 | WHERE n.uid = %d AND n.type = '%s'", |
2105 | 2105 | $image_field, $uid, 'profile')); |
2106 | - $user_image['image'] = field_file_load($image_fid); |
|
2107 | - if (!$user_image['image']['filepath']) { |
|
2106 | + $user_image['image'] = field_file_load($image_fid); |
|
2107 | + if (!$user_image['image']['filepath']) { |
|
2108 | 2108 | // Load the default image if one does not exist |
2109 | 2109 | $account = user_load($uid); |
2110 | 2110 | if ($avatar AND module_exists('gravatar') AND user_access('use gravatar', $account) AND $account->gravatar) { |
2111 | - // Use a Gravatar rather than the system default image |
|
2112 | - $options = array( |
|
2111 | + // Use a Gravatar rather than the system default image |
|
2112 | + $options = array( |
|
2113 | 2113 | 'size' => 100, |
2114 | 2114 | 'rating' => 'G', |
2115 | - ); |
|
2116 | - // Get the Gravatar URL and see if the image exists |
|
2117 | - $url = gravatar_get_gravatar($account->mail, $options); |
|
2118 | - $headers = @get_headers($url); |
|
2119 | - if (preg_match("|200|", $headers[0])) { |
|
2115 | + ); |
|
2116 | + // Get the Gravatar URL and see if the image exists |
|
2117 | + $url = gravatar_get_gravatar($account->mail, $options); |
|
2118 | + $headers = @get_headers($url); |
|
2119 | + if (preg_match("|200|", $headers[0])) { |
|
2120 | 2120 | return $url; |
2121 | - } |
|
2121 | + } |
|
2122 | 2122 | } |
2123 | 2123 | // Get default image if nothing else works |
2124 | 2124 | $content_node_widget_settings = db_result(db_query("SELECT widget_settings FROM {content_node_field_instance} WHERE field_name = '%s'", ($avatar ? 'field_image' : 'field_profile_image'))); |
2125 | 2125 | $content_node_widget_settings = unserialize($content_node_widget_settings); |
2126 | 2126 | $user_image['image'] = $content_node_widget_settings['default_image']; |
2127 | - } |
|
2128 | - $user = user_load($uid); |
|
2129 | - // Use boinc username for image alt/title attributes |
|
2130 | - $user_image['alt'] = $user->boincuser_name; |
|
2131 | - return $user_image; |
|
2127 | + } |
|
2128 | + $user = user_load($uid); |
|
2129 | + // Use boinc username for image alt/title attributes |
|
2130 | + $user_image['alt'] = $user->boincuser_name; |
|
2131 | + return $user_image; |
|
2132 | 2132 | } |
2133 | 2133 | |
2134 | 2134 | /** |
2135 | 2135 | * Generate a table of a user's projects |
2136 | 2136 | */ |
2137 | 2137 | function boincuser_get_projects_table($account = null) { |
2138 | - if ($account AND is_numeric($account)) { |
|
2138 | + if ($account AND is_numeric($account)) { |
|
2139 | 2139 | $account = user_load($account); |
2140 | - } |
|
2141 | - $projects = boincuser_get_projects($account); |
|
2142 | - if (!$projects) return bts('no projects...', array(), NULL, 'boinc:account-dashboard'); |
|
2140 | + } |
|
2141 | + $projects = boincuser_get_projects($account); |
|
2142 | + if (!$projects) return bts('no projects...', array(), NULL, 'boinc:account-dashboard'); |
|
2143 | 2143 | |
2144 | - $output = ''; |
|
2145 | - $output .= '<table class="user-projects">' . "\n"; |
|
2146 | - $output .= '<thead>' . "\n"; |
|
2147 | - $output .= ' <tr>' . "\n"; |
|
2148 | - $output .= ' <th>' . bts('Name', array(), NULL, 'boinc:project-name:-1:ignoreoverwrite') . '</th>' . "\n"; |
|
2149 | - $output .= ' <th class="numeric">' . bts('Avg credit', array(), NULL, 'boinc:account-dashboard') . '</th>' . "\n"; |
|
2150 | - $output .= ' <th class="numeric">' . bts('Total credit', array(), NULL, 'boinc:user-or-team-total-credits') . '</th>' . "\n"; |
|
2151 | - $output .= ' </tr>' . "\n"; |
|
2152 | - $output .= '</thead>' . "\n"; |
|
2153 | - $output .= '<tbody>' . "\n"; |
|
2154 | - foreach ($projects AS $project) { |
|
2144 | + $output = ''; |
|
2145 | + $output .= '<table class="user-projects">' . "\n"; |
|
2146 | + $output .= '<thead>' . "\n"; |
|
2147 | + $output .= ' <tr>' . "\n"; |
|
2148 | + $output .= ' <th>' . bts('Name', array(), NULL, 'boinc:project-name:-1:ignoreoverwrite') . '</th>' . "\n"; |
|
2149 | + $output .= ' <th class="numeric">' . bts('Avg credit', array(), NULL, 'boinc:account-dashboard') . '</th>' . "\n"; |
|
2150 | + $output .= ' <th class="numeric">' . bts('Total credit', array(), NULL, 'boinc:user-or-team-total-credits') . '</th>' . "\n"; |
|
2151 | + $output .= ' </tr>' . "\n"; |
|
2152 | + $output .= '</thead>' . "\n"; |
|
2153 | + $output .= '<tbody>' . "\n"; |
|
2154 | + foreach ($projects AS $project) { |
|
2155 | 2155 | $url = rtrim($project->url, '/') . '/show_user.php?userid=' . $project->id; |
2156 | 2156 | $output .= ' <tr>' . "\n"; |
2157 | 2157 | $output .= ' <td>' . l($project->name, $url) . '</td>' . "\n"; |
2158 | 2158 | $output .= ' <td class="numeric">' . boincwork_format_stats((float) $project->expavg_credit) . '</td>' . "\n"; |
2159 | 2159 | $output .= ' <td class="numeric">' . boincwork_format_stats((float) $project->total_credit) . '</td>' . "\n"; |
2160 | 2160 | $output .= ' </tr>' . "\n"; |
2161 | - } |
|
2162 | - $output .= '</tbody>' . "\n"; |
|
2163 | - $output .= '</table>' . "\n"; |
|
2164 | - $more_link = ($account) ? "user/{$account->uid}/stats" : 'account/stats'; |
|
2165 | - //$output .= "<div class=\"more-link\"><a href=\"{$more_link}\">More stats</a></div>" . "\n"; |
|
2166 | - return $output; |
|
2161 | + } |
|
2162 | + $output .= '</tbody>' . "\n"; |
|
2163 | + $output .= '</table>' . "\n"; |
|
2164 | + $more_link = ($account) ? "user/{$account->uid}/stats" : 'account/stats'; |
|
2165 | + //$output .= "<div class=\"more-link\"><a href=\"{$more_link}\">More stats</a></div>" . "\n"; |
|
2166 | + return $output; |
|
2167 | 2167 | } |
2168 | 2168 | |
2169 | 2169 | /** |
@@ -2171,25 +2171,25 @@ discard block |
||
2171 | 2171 | */ |
2172 | 2172 | function boincuser_get_stats_user_data($cpid = null) { |
2173 | 2173 | |
2174 | - // [TODO] Set this stuff in site config! |
|
2175 | - $stats_server = 'stats.gridrepublic.org'; |
|
2176 | - $stats_rpc = 'rpc/get_user.php'; |
|
2174 | + // [TODO] Set this stuff in site config! |
|
2175 | + $stats_server = 'stats.gridrepublic.org'; |
|
2176 | + $stats_rpc = 'rpc/get_user.php'; |
|
2177 | 2177 | |
2178 | - // Construct query string |
|
2179 | - $get = array( |
|
2178 | + // Construct query string |
|
2179 | + $get = array( |
|
2180 | 2180 | 'cpid' => $cpid |
2181 | - ); |
|
2182 | - $args = array(); |
|
2183 | - foreach ($get as $arg => $value) $args[] = "{$arg}=" . rawurlencode($value); |
|
2184 | - $query = '?' . implode('&', $args); |
|
2181 | + ); |
|
2182 | + $args = array(); |
|
2183 | + foreach ($get as $arg => $value) $args[] = "{$arg}=" . rawurlencode($value); |
|
2184 | + $query = '?' . implode('&', $args); |
|
2185 | 2185 | |
2186 | - // Load XML from RPC |
|
2187 | - $target_url = "http://{$stats_server}/{$stats_rpc}{$query}"; |
|
2188 | - $result = drupal_http_request($target_url); |
|
2189 | - if (in_array($result->code, array(200, 304))) { |
|
2186 | + // Load XML from RPC |
|
2187 | + $target_url = "http://{$stats_server}/{$stats_rpc}{$query}"; |
|
2188 | + $result = drupal_http_request($target_url); |
|
2189 | + if (in_array($result->code, array(200, 304))) { |
|
2190 | 2190 | return simplexml_load_string($result->data); |
2191 | - } |
|
2192 | - return NULL; |
|
2191 | + } |
|
2192 | + return NULL; |
|
2193 | 2193 | } |
2194 | 2194 | |
2195 | 2195 | /** |
@@ -2197,15 +2197,15 @@ discard block |
||
2197 | 2197 | */ |
2198 | 2198 | function boincuser_get_projects($account = null) { |
2199 | 2199 | |
2200 | - // Use the current user by default |
|
2201 | - if (!$account) { |
|
2200 | + // Use the current user by default |
|
2201 | + if (!$account) { |
|
2202 | 2202 | global $user; |
2203 | 2203 | $account = user_load($user->uid); |
2204 | - } |
|
2204 | + } |
|
2205 | 2205 | |
2206 | - $account_stats = boincuser_get_stats_user_data($account->boincuser_cpid); |
|
2206 | + $account_stats = boincuser_get_stats_user_data($account->boincuser_cpid); |
|
2207 | 2207 | |
2208 | - return ($account_stats AND isset($account_stats->project)) ? $account_stats->project : null; |
|
2208 | + return ($account_stats AND isset($account_stats->project)) ? $account_stats->project : null; |
|
2209 | 2209 | } |
2210 | 2210 | |
2211 | 2211 | |
@@ -2213,11 +2213,11 @@ discard block |
||
2213 | 2213 | * Get the links to display under the user profile |
2214 | 2214 | */ |
2215 | 2215 | function boincuser_get_profile_links($uid) { |
2216 | - global $user; |
|
2217 | - $account = user_load($uid); |
|
2218 | - $profile = content_profile_load('profile', $account->uid); |
|
2219 | - $output = ''; |
|
2220 | - if ($profile) { |
|
2216 | + global $user; |
|
2217 | + $account = user_load($uid); |
|
2218 | + $profile = content_profile_load('profile', $account->uid); |
|
2219 | + $output = ''; |
|
2220 | + if ($profile) { |
|
2221 | 2221 | $profile_is_approved = ($profile->status AND !$profile->moderate); |
2222 | 2222 | $user_is_moderator = user_access('edit any profile content'); |
2223 | 2223 | $is_own_profile = ($user->uid == $account->uid); |
@@ -2225,15 +2225,15 @@ discard block |
||
2225 | 2225 | $links = array(); |
2226 | 2226 | |
2227 | 2227 | if ($profile->moderate AND $user_is_moderator) { |
2228 | - $links['approve_profile'] = array( |
|
2228 | + $links['approve_profile'] = array( |
|
2229 | 2229 | 'title' => bts('Approve profile', array(), NULL, 'boinc:moderate-user'), |
2230 | 2230 | 'href' => "{$profile_moderation_path}/approve", |
2231 | 2231 | 'attributes' => array( |
2232 | - 'title' => bts('Approve this profile content', array(), NULL, 'boinc:moderate-user'), |
|
2233 | - 'class' => 'first primary tab', |
|
2232 | + 'title' => bts('Approve this profile content', array(), NULL, 'boinc:moderate-user'), |
|
2233 | + 'class' => 'first primary tab', |
|
2234 | 2234 | ) |
2235 | - ); |
|
2236 | - /*$links['edit_profile'] = array( |
|
2235 | + ); |
|
2236 | + /*$links['edit_profile'] = array( |
|
2237 | 2237 | 'title' => bts('Edit profile', array(), NULL, 'boinc:moderate-user'), |
2238 | 2238 | 'href' => "{$profile_moderation_path}/edit", |
2239 | 2239 | 'attributes' => array( |
@@ -2241,27 +2241,27 @@ discard block |
||
2241 | 2241 | 'class' => 'tab', |
2242 | 2242 | ) |
2243 | 2243 | );*/ |
2244 | - $links['reject_profile'] = array( |
|
2244 | + $links['reject_profile'] = array( |
|
2245 | 2245 | 'title' => bts('Reject profile', array(), NULL, 'boinc:moderate-user'), |
2246 | 2246 | 'href' => "{$profile_moderation_path}/reject", |
2247 | 2247 | 'attributes' => array( |
2248 | - 'title' => bts('Reject this profile content', array(), NULL, 'boinc:moderate-user'), |
|
2249 | - 'class' => 'tab', |
|
2248 | + 'title' => bts('Reject this profile content', array(), NULL, 'boinc:moderate-user'), |
|
2249 | + 'class' => 'tab', |
|
2250 | 2250 | ) |
2251 | - ); |
|
2251 | + ); |
|
2252 | 2252 | } |
2253 | 2253 | $output .= '<ul class="tab-list">'; |
2254 | 2254 | $count = 0; |
2255 | 2255 | foreach ($links as $key => $link) { |
2256 | - $output .= '<li class="' . (($count == 0) ? 'first primary ' : '') . 'tab">'; |
|
2257 | - $output .= l($link['title'], $link['href'], array('query' => drupal_get_destination())); |
|
2258 | - $output .= '</li>'; |
|
2259 | - $count++; |
|
2256 | + $output .= '<li class="' . (($count == 0) ? 'first primary ' : '') . 'tab">'; |
|
2257 | + $output .= l($link['title'], $link['href'], array('query' => drupal_get_destination())); |
|
2258 | + $output .= '</li>'; |
|
2259 | + $count++; |
|
2260 | 2260 | } |
2261 | 2261 | $output .= '<li class="' . (($count) ? '' : 'first ') . 'last tab">' . flag_create_link('abuse_user', $account->uid) . '</li>'; |
2262 | 2262 | $output .= '</ul>'; |
2263 | - } |
|
2264 | - return $output; |
|
2263 | + } |
|
2264 | + return $output; |
|
2265 | 2265 | /* |
2266 | 2266 | <ul class="tab-list"> |
2267 | 2267 | <li class="primary first tab"> |
@@ -2298,36 +2298,36 @@ discard block |
||
2298 | 2298 | */ |
2299 | 2299 | function boincuser_apachesolr_index_documents_alter(array &$documents, $entity, $entity_type, $env_id) { |
2300 | 2300 | |
2301 | - foreach ($documents as $document) { |
|
2301 | + foreach ($documents as $document) { |
|
2302 | 2302 | if ( $document->entity_type=='node' AND $document->bundle=='profile' ) { |
2303 | - // Node information. |
|
2304 | - $nid = $document->entity_id; |
|
2305 | - $node = node_load($nid); |
|
2306 | - $account = user_load($node->uid); |
|
2307 | - |
|
2308 | - // Use boincuser name and not drupal user name |
|
2309 | - $document->label = apachesolr_clean_text($account->boincuser_name); |
|
2310 | - // Author information |
|
2311 | - if ($node->uid == 0 || strlen($node->name) == 0) { |
|
2303 | + // Node information. |
|
2304 | + $nid = $document->entity_id; |
|
2305 | + $node = node_load($nid); |
|
2306 | + $account = user_load($node->uid); |
|
2307 | + |
|
2308 | + // Use boincuser name and not drupal user name |
|
2309 | + $document->label = apachesolr_clean_text($account->boincuser_name); |
|
2310 | + // Author information |
|
2311 | + if ($node->uid == 0 || strlen($node->name) == 0) { |
|
2312 | 2312 | // @see user_validate_name(). !'0' === TRUE. |
2313 | 2313 | $document->ss_name = '0'; |
2314 | - } |
|
2315 | - else { |
|
2314 | + } |
|
2315 | + else { |
|
2316 | 2316 | $document->ss_name = $account->boincuser_name; |
2317 | 2317 | // We want the name to be searchable for keywords. |
2318 | 2318 | $document->tos_name = $account->boincuser_name; |
2319 | - } |
|
2319 | + } |
|
2320 | 2320 | |
2321 | - // Rename "Profle" to "User" |
|
2322 | - $document->bundle = "User"; |
|
2323 | - $document->bundle_name = "User"; |
|
2321 | + // Rename "Profle" to "User" |
|
2322 | + $document->bundle = "User"; |
|
2323 | + $document->bundle_name = "User"; |
|
2324 | 2324 | |
2325 | - // Replace the Solr document's created field with the date the user |
|
2326 | - // account was created. This replaces the node creation date typically |
|
2327 | - // used for indexing nodes. |
|
2328 | - $document->ds_created = apachesolr_date_iso($account->created); |
|
2325 | + // Replace the Solr document's created field with the date the user |
|
2326 | + // account was created. This replaces the node creation date typically |
|
2327 | + // used for indexing nodes. |
|
2328 | + $document->ds_created = apachesolr_date_iso($account->created); |
|
2329 | + } |
|
2329 | 2330 | } |
2330 | - } |
|
2331 | 2331 | |
2332 | 2332 | } |
2333 | 2333 | |
@@ -2339,23 +2339,23 @@ discard block |
||
2339 | 2339 | * Implementation of hook_privatemsg_name_lookup(); |
2340 | 2340 | */ |
2341 | 2341 | function boincuser_privatemsg_name_lookup($string) { |
2342 | - // Get the BOINC ID from the name string, and lookup the |
|
2343 | - // corresponding drupal user. |
|
2344 | - $boincname = substr($string, 0, strrpos($string, '_')); |
|
2345 | - $boincid = substr($string, strrpos($string, '_') + 1); |
|
2346 | - $drupalid = get_drupal_id($boincid); |
|
2347 | - |
|
2348 | - // Name has spaced replaced with special UTF-8 characters in |
|
2349 | - // privatemsg module. We need to convert them back to spaces for the |
|
2350 | - // check below. |
|
2351 | - $boincname = preg_replace("/\\xc2\\xa0/", " ", $boincname); |
|
2352 | - if ($drupalid>0) { |
|
2342 | + // Get the BOINC ID from the name string, and lookup the |
|
2343 | + // corresponding drupal user. |
|
2344 | + $boincname = substr($string, 0, strrpos($string, '_')); |
|
2345 | + $boincid = substr($string, strrpos($string, '_') + 1); |
|
2346 | + $drupalid = get_drupal_id($boincid); |
|
2347 | + |
|
2348 | + // Name has spaced replaced with special UTF-8 characters in |
|
2349 | + // privatemsg module. We need to convert them back to spaces for the |
|
2350 | + // check below. |
|
2351 | + $boincname = preg_replace("/\\xc2\\xa0/", " ", $boincname); |
|
2352 | + if ($drupalid>0) { |
|
2353 | 2353 | if ($recipient = user_load(array('uid' => $drupalid))) { |
2354 | - // Double-check that the loaded user matches both boincuser_id |
|
2355 | - // and boincuser_name. |
|
2356 | - if ( ($boincid == $recipient->boincuser_id) AND ($boincname == $recipient->boincuser_name) ) { |
|
2354 | + // Double-check that the loaded user matches both boincuser_id |
|
2355 | + // and boincuser_name. |
|
2356 | + if ( ($boincid == $recipient->boincuser_id) AND ($boincname == $recipient->boincuser_name) ) { |
|
2357 | 2357 | return $recipient; |
2358 | - } |
|
2358 | + } |
|
2359 | + } |
|
2359 | 2360 | } |
2360 | - } |
|
2361 | 2361 | } |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | 'type' => MENU_CALLBACK |
190 | 190 | ); |
191 | 191 | $items['account_finish.php'] = array( |
192 | - 'title' => 'Welcome to ' . variable_get('site_name', 'Drupal-BOINC'), |
|
192 | + 'title' => 'Welcome to '.variable_get('site_name', 'Drupal-BOINC'), |
|
193 | 193 | 'description' => 'RPC for after a user has created an account.', |
194 | 194 | 'page callback' => 'boincuser_account_finish', |
195 | 195 | 'access callback' => TRUE, |
@@ -249,8 +249,8 @@ discard block |
||
249 | 249 | // termsofuse is enabled, by having text in the termsofuse variable. |
250 | 250 | $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE); |
251 | 251 | $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
252 | - if ( (!empty($termsofuse)) and ($user->uid) ) { |
|
253 | - if ( !boincuser_check_termsofuse($user) and ($existinguser_tou) ) { |
|
252 | + if ((!empty($termsofuse)) and ($user->uid)) { |
|
253 | + if (!boincuser_check_termsofuse($user) and ($existinguser_tou)) { |
|
254 | 254 | |
255 | 255 | // Admins are exempt, otherwise the admin may not be able to |
256 | 256 | // access the site! |
@@ -267,14 +267,14 @@ discard block |
||
267 | 267 | 'privacy', |
268 | 268 | 'moderation', |
269 | 269 | 'account/info/edit', |
270 | - 'user/' . $user->uid . '/edit', |
|
271 | - 'user/' . $user->uid . '/recoveremail/*', |
|
270 | + 'user/'.$user->uid.'/edit', |
|
271 | + 'user/'.$user->uid.'/recoveremail/*', |
|
272 | 272 | 'recover_email.php', |
273 | 273 | ); |
274 | 274 | if (module_exists('boincuser_delete')) { |
275 | - $paths_to_ignore[] = 'user/' . $user->uid . '/delete'; |
|
276 | - $paths_to_ignore[] = 'user/' . $user->uid . '/deleteconfirm/*'; |
|
277 | - $paths_to_ignore[] = 'user/' . $user->uid . '/odeleteconfirm/*'; |
|
275 | + $paths_to_ignore[] = 'user/'.$user->uid.'/delete'; |
|
276 | + $paths_to_ignore[] = 'user/'.$user->uid.'/deleteconfirm/*'; |
|
277 | + $paths_to_ignore[] = 'user/'.$user->uid.'/odeleteconfirm/*'; |
|
278 | 278 | } |
279 | 279 | if (!_boincuser_ignore_paths($path, $paths_to_ignore)) { |
280 | 280 | drupal_goto('user/termsofuse'); |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | require_boinc('password_compat/password'); |
297 | 297 | // Handle BOINC integration for users with UID > 1 (skip anonymous and admin) |
298 | 298 | if ($account->uid > 1) { |
299 | - switch($op) { |
|
299 | + switch ($op) { |
|
300 | 300 | case 'load': |
301 | 301 | // User loading; insert BOINC data into the user object |
302 | 302 | $drupal_user = db_fetch_object(db_query(" |
@@ -326,11 +326,11 @@ discard block |
||
326 | 326 | )); |
327 | 327 | $account->boincuser_name = $boinc_user->name; |
328 | 328 | $account->boincuser_account_key = $boinc_user->authenticator; |
329 | - $account->boincuser_weak_auth = md5($boinc_user->authenticator . $boinc_user->passwd_hash); |
|
329 | + $account->boincuser_weak_auth = md5($boinc_user->authenticator.$boinc_user->passwd_hash); |
|
330 | 330 | $account->boincuser_total_credit = round($boinc_user->total_credit); |
331 | 331 | $account->boincuser_expavg_credit = round($boinc_user->expavg_credit); |
332 | 332 | $account->boincuser_expavg_time = round($boinc_user->expavg_time); |
333 | - $account->boincuser_cpid = md5($boinc_user->cross_project_id . $account->mail); |
|
333 | + $account->boincuser_cpid = md5($boinc_user->cross_project_id.$account->mail); |
|
334 | 334 | $account->boincuser_default_pref_set = $boinc_user->venue; |
335 | 335 | $account->boincteam_id = $boinc_user->teamid; |
336 | 336 | $account->boincuser_previous_email_addr = $boinc_user->previous_email_addr; |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | if ($changing_email OR $changing_pass) { |
490 | 490 | // Set password hash appropriately |
491 | 491 | $passwd = ($edit['pass']) ? $edit['pass'] : $edit['current_pass']; |
492 | - $passwd_hash = password_hash( md5($passwd.$edit['mail']), PASSWORD_DEFAULT ); |
|
492 | + $passwd_hash = password_hash(md5($passwd.$edit['mail']), PASSWORD_DEFAULT); |
|
493 | 493 | $email_addr = $edit['mail']; |
494 | 494 | |
495 | 495 | // Algorithm for changing email and/or password |
@@ -573,8 +573,8 @@ discard block |
||
573 | 573 | } |
574 | 574 | |
575 | 575 | // Check if user has agreed to terms of use. |
576 | - if ( (!empty($termsofuse)) and ($account->uid) and |
|
577 | - (!boincuser_check_termsofuse($account)) and ($existinguser_tou) ) { |
|
576 | + if ((!empty($termsofuse)) and ($account->uid) and |
|
577 | + (!boincuser_check_termsofuse($account)) and ($existinguser_tou)) { |
|
578 | 578 | |
579 | 579 | // Admins are exempted. |
580 | 580 | $administrator_role = array_search('administrator', user_roles(true)); |
@@ -588,9 +588,9 @@ discard block |
||
588 | 588 | $query_for_destination = ''; |
589 | 589 | $prevdest = $_REQUEST['destination']; |
590 | 590 | if ($prevdest) { |
591 | - $query_for_destination = '?destination=' . $prevdest; |
|
591 | + $query_for_destination = '?destination='.$prevdest; |
|
592 | 592 | } |
593 | - $_REQUEST['destination'] = $path_for_destination . $query_for_destination; |
|
593 | + $_REQUEST['destination'] = $path_for_destination.$query_for_destination; |
|
594 | 594 | |
595 | 595 | } |
596 | 596 | } |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | // In Drupal 7, these operation cases will all exist as their own hooks, |
624 | 624 | // so let's approximate that here so that this function can simply be removed |
625 | 625 | // upon migration to 7 |
626 | - switch($op) { |
|
626 | + switch ($op) { |
|
627 | 627 | case 'update': |
628 | 628 | boincuser_node_update($node); |
629 | 629 | } |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | * is updated (forward compatible to Drupal 7) |
635 | 635 | */ |
636 | 636 | function boincuser_node_update($node) { |
637 | - switch($node->type) { |
|
637 | + switch ($node->type) { |
|
638 | 638 | case 'profile': |
639 | 639 | // Update the BOINC database directly |
640 | 640 | $account = user_load($node->uid); |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | } |
757 | 757 | |
758 | 758 | $form['cancel'] = array( |
759 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $cancel_dest) . '</li>', |
|
759 | + '#value' => '<li class="tab">'.l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $cancel_dest).'</li>', |
|
760 | 760 | '#weight' => 1004, |
761 | 761 | ); |
762 | 762 | $form['form control tabs suffix'] = array( |
@@ -789,7 +789,7 @@ discard block |
||
789 | 789 | $form['buttons']['preview_changes']['#suffix'] = '</li>'; |
790 | 790 | $form['buttons']['preview_changes']['#weight'] = 1004; |
791 | 791 | $form['buttons']['cancel'] = array( |
792 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "node/{$form['nid']['#value']}") . '</li>', |
|
792 | + '#value' => '<li class="tab">'.l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "node/{$form['nid']['#value']}").'</li>', |
|
793 | 793 | '#weight' => 1005, |
794 | 794 | ); |
795 | 795 | $form['buttons']['delete']['#prefix'] = '<li class="tab">'; |
@@ -821,7 +821,7 @@ discard block |
||
821 | 821 | $form['actions']['submit']['#suffix'] = '</li>'; |
822 | 822 | $form['actions']['submit']['#weight'] = 1002; |
823 | 823 | $form['actions']['cancel'] = array( |
824 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "node/{$form['nid']['#value']}") . '</li>', |
|
824 | + '#value' => '<li class="tab">'.l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "node/{$form['nid']['#value']}").'</li>', |
|
825 | 825 | '#weight' => 1005, |
826 | 826 | ); |
827 | 827 | $form['actions']['form control tabs suffix'] = array( |
@@ -848,7 +848,7 @@ discard block |
||
848 | 848 | $form['privatemsg']['preview']['#suffix'] = '</li>'; |
849 | 849 | $form['privatemsg']['preview']['#weight'] = 1003; |
850 | 850 | $form['privatemsg']['cancel'] = array( |
851 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
851 | + '#value' => '<li class="tab">'.l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']).'</li>', |
|
852 | 852 | '#weight' => 1004, |
853 | 853 | ); |
854 | 854 | $form['privatemsg']['form control tabs suffix'] = array( |
@@ -936,11 +936,11 @@ discard block |
||
936 | 936 | // Set special message if user has not agreed to TOU |
937 | 937 | $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE); |
938 | 938 | $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
939 | - if ( (!boincuser_check_termsofuse($account)) and ($existinguser_tou) and (!empty($termsofuse)) and (!user_access('administer users')) ) { |
|
939 | + if ((!boincuser_check_termsofuse($account)) and ($existinguser_tou) and (!empty($termsofuse)) and (!user_access('administer users'))) { |
|
940 | 940 | drupal_set_message( |
941 | 941 | bts('INFO: You have not agreed to the terms of use for @project. You may use this form to change your email address and/or password. Please note: you may not delete your account within seven (7) days of changing your email address.', |
942 | 942 | array( |
943 | - '@project' => variable_get('site_name','Drupal-BOINC'), |
|
943 | + '@project' => variable_get('site_name', 'Drupal-BOINC'), |
|
944 | 944 | ), NULL, 'boinc:account-credentials-change') |
945 | 945 | , 'info'); |
946 | 946 | } |
@@ -1005,36 +1005,36 @@ discard block |
||
1005 | 1005 | $form['account']['boincuser_id'] = array( |
1006 | 1006 | '#value' => ' |
1007 | 1007 | <div class="form-item"> |
1008 | - <label>' . bts('BOINC user ID', array(), NULL, 'boinc:account-credentials-change') . '</label> |
|
1009 | - <span>' . $account->boincuser_id . '</span> |
|
1008 | + <label>' . bts('BOINC user ID', array(), NULL, 'boinc:account-credentials-change').'</label> |
|
1009 | + <span>' . $account->boincuser_id.'</span> |
|
1010 | 1010 | </div>', |
1011 | 1011 | ); |
1012 | 1012 | $form['account']['user_id'] = array( |
1013 | 1013 | '#value' => ' |
1014 | 1014 | <div class="form-item"> |
1015 | - <label>' . bts('Drupal user ID', array(), NULL, 'boinc:account-credentials-change') . '</label> |
|
1016 | - <span>' . $account->uid . '</span> |
|
1015 | + <label>' . bts('Drupal user ID', array(), NULL, 'boinc:account-credentials-change').'</label> |
|
1016 | + <span>' . $account->uid.'</span> |
|
1017 | 1017 | </div>', |
1018 | 1018 | ); |
1019 | 1019 | $form['account']['account_key'] = array( |
1020 | 1020 | '#value' => ' |
1021 | 1021 | <div class="form-item"> |
1022 | - <label>' . bts('Account key', array(), NULL, 'boinc:account-credentials-change') . '</label> |
|
1023 | - <span>' . $account->boincuser_account_key . '</span> |
|
1022 | + <label>' . bts('Account key', array(), NULL, 'boinc:account-credentials-change').'</label> |
|
1023 | + <span>' . $account->boincuser_account_key.'</span> |
|
1024 | 1024 | </div>', |
1025 | 1025 | ); |
1026 | 1026 | $form['account']['weak_account_key'] = array( |
1027 | 1027 | '#value' => ' |
1028 | 1028 | <div class="form-item"> |
1029 | - <label>' . bts('Weak account key', array(), NULL, 'boinc:account-credentials-change') . '</label> |
|
1030 | - <span>' . "{$account->boincuser_id}_{$account->boincuser_weak_auth}" . '</span> |
|
1029 | + <label>' . bts('Weak account key', array(), NULL, 'boinc:account-credentials-change').'</label> |
|
1030 | + <span>' . "{$account->boincuser_id}_{$account->boincuser_weak_auth}".'</span> |
|
1031 | 1031 | </div>', |
1032 | 1032 | ); |
1033 | 1033 | $form['account']['cpid'] = array( |
1034 | 1034 | '#value' => ' |
1035 | 1035 | <div class="form-item"> |
1036 | - <label>' . bts('Cross-project ID', array(), NULL, 'boinc:account-credentials-change') . '</label> |
|
1037 | - <span>' . $account->boincuser_cpid . '</span> |
|
1036 | + <label>' . bts('Cross-project ID', array(), NULL, 'boinc:account-credentials-change').'</label> |
|
1037 | + <span>' . $account->boincuser_cpid.'</span> |
|
1038 | 1038 | </div>', |
1039 | 1039 | ); |
1040 | 1040 | |
@@ -1052,7 +1052,7 @@ discard block |
||
1052 | 1052 | $form['submit']['#suffix'] = '</li>'; |
1053 | 1053 | $form['submit']['#weight'] = 1002; |
1054 | 1054 | $form['cancel'] = array( |
1055 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
1055 | + '#value' => '<li class="tab">'.l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']).'</li>', |
|
1056 | 1056 | '#weight' => 1003, |
1057 | 1057 | ); |
1058 | 1058 | if (isset($form['delete']) AND is_array($form['delete'])) { |
@@ -1148,7 +1148,7 @@ discard block |
||
1148 | 1148 | $form['buttons']['preview_changes']['#suffix'] = '</li>'; |
1149 | 1149 | $form['buttons']['preview_changes']['#weight'] = 1004; |
1150 | 1150 | $form['buttons']['cancel'] = array( |
1151 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
1151 | + '#value' => '<li class="tab">'.l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']).'</li>', |
|
1152 | 1152 | '#weight' => 1005, |
1153 | 1153 | ); |
1154 | 1154 | $form['buttons']['delete']['#prefix'] = '<li class="tab">'; |
@@ -1197,7 +1197,7 @@ discard block |
||
1197 | 1197 | // Set name temporarily to dummy value to beat validation |
1198 | 1198 | $form['name'] = array( |
1199 | 1199 | '#type' => 'hidden', |
1200 | - '#value' => rand() . '.' . time() |
|
1200 | + '#value' => rand().'.'.time() |
|
1201 | 1201 | ); |
1202 | 1202 | |
1203 | 1203 | // Terms of use section |
@@ -1205,7 +1205,7 @@ discard block |
||
1205 | 1205 | if (!empty($termsofuse)) { |
1206 | 1206 | $form['title1'] = array( |
1207 | 1207 | '#weight' => -12, |
1208 | - '#value' => '<h2>' . bts(variable_get('boinc_weboptions_registrationtitle', 'Please read and acknowledge our terms of use'), array(), NULL, 'project:user-register' ) . '</h2>', |
|
1208 | + '#value' => '<h2>'.bts(variable_get('boinc_weboptions_registrationtitle', 'Please read and acknowledge our terms of use'), array(), NULL, 'project:user-register').'</h2>', |
|
1209 | 1209 | '#prefix' => '<div id="register-title1">', |
1210 | 1210 | '#suffix' => '</div>', |
1211 | 1211 | ); |
@@ -1228,7 +1228,7 @@ discard block |
||
1228 | 1228 | |
1229 | 1229 | $form['title2'] = array( |
1230 | 1230 | '#weight' => -6, |
1231 | - '#value' => '<h2>' . bts(variable_get('boinc_weboptions_registrationtitle2', 'Fill in your name, email, and choose a secure passphrase.'), array(), NULL, 'project:user-register') . '</h2>', |
|
1231 | + '#value' => '<h2>'.bts(variable_get('boinc_weboptions_registrationtitle2', 'Fill in your name, email, and choose a secure passphrase.'), array(), NULL, 'project:user-register').'</h2>', |
|
1232 | 1232 | '#prefix' => '<div id="register-title2">', |
1233 | 1233 | '#suffix' => '</div>', |
1234 | 1234 | ); |
@@ -1282,7 +1282,7 @@ discard block |
||
1282 | 1282 | $form['buttons']['submit']['#suffix'] = '</li>'; |
1283 | 1283 | $form['buttons']['submit']['#weight'] = 1002; |
1284 | 1284 | $form['buttons']['cancel'] = array( |
1285 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'user/login') . '</li>', |
|
1285 | + '#value' => '<li class="tab">'.l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'user/login').'</li>', |
|
1286 | 1286 | '#weight' => 1005, |
1287 | 1287 | ); |
1288 | 1288 | $form['buttons']['form control tabs suffix'] = array( |
@@ -1364,7 +1364,7 @@ discard block |
||
1364 | 1364 | */ |
1365 | 1365 | function boincuser_token_list($type = 'all') { |
1366 | 1366 | if ($type == 'user' || $type == 'all') { |
1367 | - $tokens['user']['display-name'] = t("The user's name that should be displayed"); |
|
1367 | + $tokens['user']['display-name'] = t("The user's name that should be displayed"); |
|
1368 | 1368 | return $tokens; |
1369 | 1369 | } |
1370 | 1370 | } |
@@ -1374,9 +1374,9 @@ discard block |
||
1374 | 1374 | */ |
1375 | 1375 | function boincuser_views_pre_execute(&$view) { |
1376 | 1376 | $account_id = $view->args[0]; |
1377 | - if ($view->name=="user_activity") { |
|
1377 | + if ($view->name == "user_activity") { |
|
1378 | 1378 | // Run the following custom query for the user_activity view |
1379 | - $view->build_info['query']= " |
|
1379 | + $view->build_info['query'] = " |
|
1380 | 1380 | SELECT node_revisions.vid AS vid, |
1381 | 1381 | node.nid AS node_nid, |
1382 | 1382 | node.uid AS users_node_uid, |
@@ -1416,13 +1416,13 @@ discard block |
||
1416 | 1416 | // Delete expired users in the BOINC database, user_delete table. |
1417 | 1417 | require_boinc('boinc_db'); |
1418 | 1418 | $num_deleted = BoincUserDeleted::delete_expired(); |
1419 | - if ($num_deleted>0) { |
|
1419 | + if ($num_deleted > 0) { |
|
1420 | 1420 | watchdog('boincuser', "Deleted ${num_deleted} users from user_deleted table", WATCHDOG_NOTICE); |
1421 | 1421 | } |
1422 | 1422 | |
1423 | 1423 | // Delete expired tokens from token table |
1424 | 1424 | $tokens_deleted = BoincToken::delete_expired(); |
1425 | - if ($tokens_deleted>0) { |
|
1425 | + if ($tokens_deleted > 0) { |
|
1426 | 1426 | watchdog('boincuser', "Deleted ${tokens_deleted} tokens from token table", WATCHDOG_NOTICE); |
1427 | 1427 | } |
1428 | 1428 | } |
@@ -1497,38 +1497,38 @@ discard block |
||
1497 | 1497 | case 'boinc': |
1498 | 1498 | $output .= '<ol>'; |
1499 | 1499 | if ($registration_enabled) { |
1500 | - $output .= '<li>' . bts('First !create_an_account here at @sitename.', |
|
1500 | + $output .= '<li>'.bts('First !create_an_account here at @sitename.', |
|
1501 | 1501 | array( |
1502 | 1502 | '!create_an_account' => l(bts('create an account', array(), NULL, 'boinc:join-page'), 'user/registration'), |
1503 | 1503 | '@sitename' => $site_name, |
1504 | - ), NULL, 'boinc:join-page') . '</li>'; |
|
1504 | + ), NULL, 'boinc:join-page').'</li>'; |
|
1505 | 1505 | } |
1506 | - $output .= ' <li>' . bts("Install BOINC on this device if not already present.", array(), NULL, 'boinc:join-page') . '</li>'; |
|
1507 | - $output .= ' <li>' . bts("Select <i>Tools / Add Project</i>. Choose @sitename from the list, or enter @siteurl.", |
|
1506 | + $output .= ' <li>'.bts("Install BOINC on this device if not already present.", array(), NULL, 'boinc:join-page').'</li>'; |
|
1507 | + $output .= ' <li>'.bts("Select <i>Tools / Add Project</i>. Choose @sitename from the list, or enter @siteurl.", |
|
1508 | 1508 | array( |
1509 | 1509 | '@sitename' => $site_name, |
1510 | 1510 | '@siteurl' => $base_url, |
1511 | - ), NULL, 'boinc:join-page') . '</li>'; |
|
1511 | + ), NULL, 'boinc:join-page').'</li>'; |
|
1512 | 1512 | if ($registration_enabled) { |
1513 | - $output .= '<li>' . bts("If you're running a command-line or pre-5.0 version of BOINC, use <b>!boinccmd</b> to add the project.", |
|
1513 | + $output .= '<li>'.bts("If you're running a command-line or pre-5.0 version of BOINC, use <b>!boinccmd</b> to add the project.", |
|
1514 | 1514 | array( |
1515 | 1515 | '!boinccmd' => l('boinccmd --project_attach', 'http://boinc.berkeley.edu/wiki/Boinccmd_tool'), |
1516 | - ), NULL, 'boinc:join-page') . '</li>'; |
|
1516 | + ), NULL, 'boinc:join-page').'</li>'; |
|
1517 | 1517 | } |
1518 | 1518 | else { |
1519 | - $output .= '<li>' . bts("If you're running a command-line version of BOINC, |
|
1519 | + $output .= '<li>'.bts("If you're running a command-line version of BOINC, |
|
1520 | 1520 | please follow the <b>!instructionslink</b> to first <i>create an account</i>, and then <i>attach</i> to this project. Use the same project URL as above.", |
1521 | 1521 | array( |
1522 | 1522 | '!instructionslink' => l('instructions', 'http://boinc.berkeley.edu/wiki/Boinccmd_tool'), |
1523 | - ), NULL, 'boinc:join-page') . '</li>'; |
|
1523 | + ), NULL, 'boinc:join-page').'</li>'; |
|
1524 | 1524 | } |
1525 | - $output .= '<li>' . bts("If you're running a pre-5.0 version of BOINC, please |
|
1525 | + $output .= '<li>'.bts("If you're running a pre-5.0 version of BOINC, please |
|
1526 | 1526 | upgrade to a more recent version of BOINC to create an account |
1527 | 1527 | at @this_project.", |
1528 | 1528 | array( |
1529 | 1529 | '@this_project' => $site_name, |
1530 | - ), NULL, 'boinc:join-page') . '</li>'; |
|
1531 | - $output .= '</ol>'; |
|
1530 | + ), NULL, 'boinc:join-page').'</li>'; |
|
1531 | + $output .= '</ol>'; |
|
1532 | 1532 | break; |
1533 | 1533 | case 'new': |
1534 | 1534 | default: |
@@ -1540,34 +1540,34 @@ discard block |
||
1540 | 1540 | // $ruleslink = drupal_lookup_path('source', $ruleslinkB); |
1541 | 1541 | //} |
1542 | 1542 | |
1543 | - $ruleslink = drupal_lookup_path('source', variable_get('boinc_weboptions_rulespolicies', '') ); |
|
1543 | + $ruleslink = drupal_lookup_path('source', variable_get('boinc_weboptions_rulespolicies', '')); |
|
1544 | 1544 | |
1545 | 1545 | // Join page output |
1546 | 1546 | $output .= '<ol>'; |
1547 | 1547 | if ($registration_enabled) { |
1548 | - $output .= '<li>' . bts('First !create_an_account here at @sitename.', |
|
1548 | + $output .= '<li>'.bts('First !create_an_account here at @sitename.', |
|
1549 | 1549 | array( |
1550 | 1550 | '!create_an_account' => l(bts('create an account', array(), NULL, 'boinc:join-page'), 'user/registration'), |
1551 | 1551 | '@sitename' => $site_name, |
1552 | - ), NULL, 'boinc:join-page') . '</li>'; |
|
1552 | + ), NULL, 'boinc:join-page').'</li>'; |
|
1553 | 1553 | } |
1554 | - else if ( menu_valid_path(array('link_path' => $ruleslink)) ) { |
|
1555 | - $output .= ' <li>' . bts("Read our !rules_and_policies.", array( |
|
1554 | + else if (menu_valid_path(array('link_path' => $ruleslink))) { |
|
1555 | + $output .= ' <li>'.bts("Read our !rules_and_policies.", array( |
|
1556 | 1556 | '!rules_and_policies' => l(bts('Rules and Policies', array(), NULL, 'boinc:join-page'), $ruleslink), |
1557 | - ), NULL, 'boinc:join-page') . '</li>'; |
|
1557 | + ), NULL, 'boinc:join-page').'</li>'; |
|
1558 | 1558 | } |
1559 | - $output .= ' <li>' . bts('Download the BOINC desktop software.', array(), NULL, 'boinc:join-page'); |
|
1559 | + $output .= ' <li>'.bts('Download the BOINC desktop software.', array(), NULL, 'boinc:join-page'); |
|
1560 | 1560 | $output .= ' <p>'; |
1561 | 1561 | $output .= ' <a class="button" href="http://boinc.berkeley.edu/download.php">Download</a>'; |
1562 | 1562 | $output .= ' </p>'; |
1563 | - $output .= ' ' . bts("For Android devices, download BOINC from the Google Play Store or Amazon App Store.", array(), NULL, 'boinc:join-page'); |
|
1563 | + $output .= ' '.bts("For Android devices, download BOINC from the Google Play Store or Amazon App Store.", array(), NULL, 'boinc:join-page'); |
|
1564 | 1564 | $output .= ' </li>'; |
1565 | - $output .= ' <li>' . bts('Run the installer.', array(), NULL, 'boinc:join-page') . '</li>'; |
|
1566 | - $output .= ' <li>' . bts('Choose @sitename from the list, or enter @siteurl.', array( |
|
1565 | + $output .= ' <li>'.bts('Run the installer.', array(), NULL, 'boinc:join-page').'</li>'; |
|
1566 | + $output .= ' <li>'.bts('Choose @sitename from the list, or enter @siteurl.', array( |
|
1567 | 1567 | '@sitename' => $site_name, |
1568 | 1568 | '@siteurl' => $base_url, |
1569 | - ), NULL, 'boinc:join-page') . '</li>'; |
|
1570 | - $output .= '</ol>'; |
|
1569 | + ), NULL, 'boinc:join-page').'</li>'; |
|
1570 | + $output .= '</ol>'; |
|
1571 | 1571 | } |
1572 | 1572 | $output .= '</div>'; |
1573 | 1573 | return $output; |
@@ -1580,7 +1580,7 @@ discard block |
||
1580 | 1580 | global $user; |
1581 | 1581 | $site_name = variable_get('site_name', 'Drupal-BOINC'); |
1582 | 1582 | // get the front page message from database; this is set in the admin interface under BOINC Other |
1583 | - $site_message = variable_get('boinc_other_frontpage',''); |
|
1583 | + $site_message = variable_get('boinc_other_frontpage', ''); |
|
1584 | 1584 | |
1585 | 1585 | // Determine the user of the day |
1586 | 1586 | $current_uotd = db_fetch_object(db_query(" |
@@ -1602,30 +1602,30 @@ discard block |
||
1602 | 1602 | $output .= ($user->uid) ? bts('Welcome back!', array(), NULL, 'boinc:front-page') : ($site_name ? bts('What is @this_project?', array('@this_project' => $site_name)) : bts('Welcome!', array(), NULL, 'boinc:front-page')); |
1603 | 1603 | $output .= '</h2>'; |
1604 | 1604 | $output .= '<div class="boinc-overview balance-height-front">'; |
1605 | - $output .= ' <div>' . bts($site_message, array(), NULL, "project:front page") . ' ' . l(bts('Learn more', array(), NULL, 'boinc:front-page'), 'about') . '</div>'; |
|
1605 | + $output .= ' <div>'.bts($site_message, array(), NULL, "project:front page").' '.l(bts('Learn more', array(), NULL, 'boinc:front-page'), 'about').'</div>'; |
|
1606 | 1606 | if ($user->uid) { |
1607 | - $output .= ' <div>' . l(bts('View account', array(), NULL, 'boinc:front-page'), 'dashboard', array('attributes' => array('class' => 'join button'))) . '</div>'; |
|
1607 | + $output .= ' <div>'.l(bts('View account', array(), NULL, 'boinc:front-page'), 'dashboard', array('attributes' => array('class' => 'join button'))).'</div>'; |
|
1608 | 1608 | } |
1609 | 1609 | else { |
1610 | - $output .= ' <div>' . l(bts('Join now', array(), NULL, 'boinc:front-page'), 'join', array('attributes' => array('class' => 'join button'))) . '</div>'; |
|
1610 | + $output .= ' <div>'.l(bts('Join now', array(), NULL, 'boinc:front-page'), 'join', array('attributes' => array('class' => 'join button'))).'</div>'; |
|
1611 | 1611 | } |
1612 | 1612 | $output .= '</div>'; |
1613 | 1613 | $output .= '<div class="boinc-overview-details">'; |
1614 | 1614 | $output .= ' <div class="detail-container">'; |
1615 | - $output .= ' <a class="user-of-the-day" href="account/' . $uotd->uid . '">'; |
|
1615 | + $output .= ' <a class="user-of-the-day" href="account/'.$uotd->uid.'">'; |
|
1616 | 1616 | $output .= ' <div class="picture">'; |
1617 | 1617 | $output .= theme('imagefield_image', $uotd_image['image'], $uotd_image['alt'], |
1618 | 1618 | $uotd_image['alt'], array(), FALSE); |
1619 | 1619 | $output .= ' </div>'; |
1620 | - $output .= ' <div class="text">' . bts('User of the day', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1621 | - $output .= ' <div class="detail">' . $uotd->boincuser_name . '</div>'; |
|
1620 | + $output .= ' <div class="text">'.bts('User of the day', array(), NULL, 'boinc:front-page').'</div>'; |
|
1621 | + $output .= ' <div class="detail">'.$uotd->boincuser_name.'</div>'; |
|
1622 | 1622 | $output .= ' </a>'; |
1623 | 1623 | $output .= ' <div class="volunteers">'; |
1624 | - $output .= ' <div class="text">' . bts('Over 500,000 volunteers and counting.', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1624 | + $output .= ' <div class="text">'.bts('Over 500,000 volunteers and counting.', array(), NULL, 'boinc:front-page').'</div>'; |
|
1625 | 1625 | $output .= ' <div class="platforms">'; |
1626 | - $output .= ' <div class="detail platform windows">' . bts('Windows', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1627 | - $output .= ' <div class="detail platform mac">' . bts('Mac', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1628 | - $output .= ' <div class="detail platform linux">' . bts('Linux', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1626 | + $output .= ' <div class="detail platform windows">'.bts('Windows', array(), NULL, 'boinc:front-page').'</div>'; |
|
1627 | + $output .= ' <div class="detail platform mac">'.bts('Mac', array(), NULL, 'boinc:front-page').'</div>'; |
|
1628 | + $output .= ' <div class="detail platform linux">'.bts('Linux', array(), NULL, 'boinc:front-page').'</div>'; |
|
1629 | 1629 | $output .= ' </div>'; |
1630 | 1630 | $output .= ' </div>'; |
1631 | 1631 | $output .= ' </div>'; |
@@ -1656,7 +1656,7 @@ discard block |
||
1656 | 1656 | $enablethisRPC = variable_get('boinc_weboptions_enableaccountcreateRPC', TRUE); |
1657 | 1657 | if (!$enablethisRPC) { |
1658 | 1658 | $mess = bts('Account creation is done through our Web site. Please register at @url', array( |
1659 | - '@url' => $base_url . '/user/registration', |
|
1659 | + '@url' => $base_url.'/user/registration', |
|
1660 | 1660 | ), |
1661 | 1661 | NULL, 'boinc:create_account'); |
1662 | 1662 | xml_error(-208, $mess); |
@@ -1688,8 +1688,8 @@ discard block |
||
1688 | 1688 | $boinc_user = BoincUser::lookup_email_addr($params['email_addr']); |
1689 | 1689 | if ($boinc_user) { |
1690 | 1690 | // Return authenticator for existing users |
1691 | - if ( ($params['passwd_hash'] == $boinc_user->passwd_hash) or |
|
1692 | - password_verify($params['passwd_hash'], $boinc_user->passwd_hash) ) { |
|
1691 | + if (($params['passwd_hash'] == $boinc_user->passwd_hash) or |
|
1692 | + password_verify($params['passwd_hash'], $boinc_user->passwd_hash)) { |
|
1693 | 1693 | $output = array('authenticator' => $boinc_user->authenticator); |
1694 | 1694 | } |
1695 | 1695 | else { |
@@ -1745,7 +1745,7 @@ discard block |
||
1745 | 1745 | // Ensure there is a authentication token before continuing |
1746 | 1746 | if (empty($authtoken)) { |
1747 | 1747 | drupal_not_found(); |
1748 | - return ; |
|
1748 | + return; |
|
1749 | 1749 | } |
1750 | 1750 | |
1751 | 1751 | if (strlen($authtoken) != 32) { |
@@ -1767,8 +1767,8 @@ discard block |
||
1767 | 1767 | } |
1768 | 1768 | |
1769 | 1769 | // Lookup path to custom account finish page |
1770 | - $customaccountfinishpath = drupal_lookup_path('source', variable_get('boinc_weboptions_accountfinish', '') ); |
|
1771 | - if ( menu_valid_path(array('link_path' => $customaccountfinishpath)) ) { |
|
1770 | + $customaccountfinishpath = drupal_lookup_path('source', variable_get('boinc_weboptions_accountfinish', '')); |
|
1771 | + if (menu_valid_path(array('link_path' => $customaccountfinishpath))) { |
|
1772 | 1772 | $node = menu_get_object('node', 1, $customaccountfinishpath); |
1773 | 1773 | if ($node) { |
1774 | 1774 | return node_page_view($node); |
@@ -1777,12 +1777,12 @@ discard block |
||
1777 | 1777 | |
1778 | 1778 | // open links in new window |
1779 | 1779 | $options = array( |
1780 | - 'attributes' => array( 'target' => '_blank' ), |
|
1780 | + 'attributes' => array('target' => '_blank'), |
|
1781 | 1781 | ); |
1782 | 1782 | |
1783 | 1783 | // Check moderation page exists |
1784 | - $moderationpath = drupal_lookup_path('source', variable_get('boinc_weboptions_moderationpage', '') ); |
|
1785 | - if ( menu_valid_path(array('link_path' => $moderationpath)) ) { |
|
1784 | + $moderationpath = drupal_lookup_path('source', variable_get('boinc_weboptions_moderationpage', '')); |
|
1785 | + if (menu_valid_path(array('link_path' => $moderationpath))) { |
|
1786 | 1786 | $modsentence = bts('Please note: user profiles are subject to !moderation.', array('!moderation' => l(bts('moderation', array(), NULL, 'boinc:account-finish'), $moderationpath, $options)), NULL, 'boinc:account-finish'); |
1787 | 1787 | } else { |
1788 | 1788 | $modsentence = bts('Please note: user profiles are subject to moderation.', array(), NULL, 'boinc:account-finish'); |
@@ -1790,11 +1790,11 @@ discard block |
||
1790 | 1790 | |
1791 | 1791 | $username = $user->boincuser_name; |
1792 | 1792 | $site_name = variable_get('site_name', 'Drupal-BOINC'); |
1793 | - $output = "<p>" . bts('Thank you @user_name for joining @site_name. Your account has been created. Your BOINC client should start working on assigned tasks soon, without any additional action or configuration. Please visit the links below for more information and additional options. (Links will open in a new window.)', |
|
1793 | + $output = "<p>".bts('Thank you @user_name for joining @site_name. Your account has been created. Your BOINC client should start working on assigned tasks soon, without any additional action or configuration. Please visit the links below for more information and additional options. (Links will open in a new window.)', |
|
1794 | 1794 | array( |
1795 | 1795 | '@user_name' => $username, |
1796 | 1796 | '@site_name' => $site_name, |
1797 | - ), NULL, 'boinc:account-finish') . "</p>"; |
|
1797 | + ), NULL, 'boinc:account-finish')."</p>"; |
|
1798 | 1798 | |
1799 | 1799 | $links = array( |
1800 | 1800 | array( |
@@ -1860,7 +1860,7 @@ discard block |
||
1860 | 1860 | ); |
1861 | 1861 | |
1862 | 1862 | //List of links |
1863 | - $output .= theme_item_list($links, $title = NULL, $type='ul'); |
|
1863 | + $output .= theme_item_list($links, $title = NULL, $type = 'ul'); |
|
1864 | 1864 | |
1865 | 1865 | return $output; |
1866 | 1866 | } |
@@ -1977,7 +1977,7 @@ discard block |
||
1977 | 1977 | global $base_url; |
1978 | 1978 | global $base_path; |
1979 | 1979 | $site_name = variable_get('site_name', 'Drupal-BOINC'); |
1980 | - $site_url = $base_url . $base_path; |
|
1980 | + $site_url = $base_url.$base_path; |
|
1981 | 1981 | $moderator = user_load($user->uid); |
1982 | 1982 | $profile->moderate = 0; |
1983 | 1983 | $profile->status = 0; |
@@ -2038,7 +2038,7 @@ discard block |
||
2038 | 2038 | global $base_url; |
2039 | 2039 | global $base_path; |
2040 | 2040 | $site_name = variable_get('site_name', 'Drupal-BOINC'); |
2041 | - $site_url = $base_url . $base_path; |
|
2041 | + $site_url = $base_url.$base_path; |
|
2042 | 2042 | $moderator = user_load($user->uid); |
2043 | 2043 | $settings = array( |
2044 | 2044 | 'from' => '', |
@@ -2142,25 +2142,25 @@ discard block |
||
2142 | 2142 | if (!$projects) return bts('no projects...', array(), NULL, 'boinc:account-dashboard'); |
2143 | 2143 | |
2144 | 2144 | $output = ''; |
2145 | - $output .= '<table class="user-projects">' . "\n"; |
|
2146 | - $output .= '<thead>' . "\n"; |
|
2147 | - $output .= ' <tr>' . "\n"; |
|
2148 | - $output .= ' <th>' . bts('Name', array(), NULL, 'boinc:project-name:-1:ignoreoverwrite') . '</th>' . "\n"; |
|
2149 | - $output .= ' <th class="numeric">' . bts('Avg credit', array(), NULL, 'boinc:account-dashboard') . '</th>' . "\n"; |
|
2150 | - $output .= ' <th class="numeric">' . bts('Total credit', array(), NULL, 'boinc:user-or-team-total-credits') . '</th>' . "\n"; |
|
2151 | - $output .= ' </tr>' . "\n"; |
|
2152 | - $output .= '</thead>' . "\n"; |
|
2153 | - $output .= '<tbody>' . "\n"; |
|
2145 | + $output .= '<table class="user-projects">'."\n"; |
|
2146 | + $output .= '<thead>'."\n"; |
|
2147 | + $output .= ' <tr>'."\n"; |
|
2148 | + $output .= ' <th>'.bts('Name', array(), NULL, 'boinc:project-name:-1:ignoreoverwrite').'</th>'."\n"; |
|
2149 | + $output .= ' <th class="numeric">'.bts('Avg credit', array(), NULL, 'boinc:account-dashboard').'</th>'."\n"; |
|
2150 | + $output .= ' <th class="numeric">'.bts('Total credit', array(), NULL, 'boinc:user-or-team-total-credits').'</th>'."\n"; |
|
2151 | + $output .= ' </tr>'."\n"; |
|
2152 | + $output .= '</thead>'."\n"; |
|
2153 | + $output .= '<tbody>'."\n"; |
|
2154 | 2154 | foreach ($projects AS $project) { |
2155 | - $url = rtrim($project->url, '/') . '/show_user.php?userid=' . $project->id; |
|
2156 | - $output .= ' <tr>' . "\n"; |
|
2157 | - $output .= ' <td>' . l($project->name, $url) . '</td>' . "\n"; |
|
2158 | - $output .= ' <td class="numeric">' . boincwork_format_stats((float) $project->expavg_credit) . '</td>' . "\n"; |
|
2159 | - $output .= ' <td class="numeric">' . boincwork_format_stats((float) $project->total_credit) . '</td>' . "\n"; |
|
2160 | - $output .= ' </tr>' . "\n"; |
|
2155 | + $url = rtrim($project->url, '/').'/show_user.php?userid='.$project->id; |
|
2156 | + $output .= ' <tr>'."\n"; |
|
2157 | + $output .= ' <td>'.l($project->name, $url).'</td>'."\n"; |
|
2158 | + $output .= ' <td class="numeric">'.boincwork_format_stats((float)$project->expavg_credit).'</td>'."\n"; |
|
2159 | + $output .= ' <td class="numeric">'.boincwork_format_stats((float)$project->total_credit).'</td>'."\n"; |
|
2160 | + $output .= ' </tr>'."\n"; |
|
2161 | 2161 | } |
2162 | - $output .= '</tbody>' . "\n"; |
|
2163 | - $output .= '</table>' . "\n"; |
|
2162 | + $output .= '</tbody>'."\n"; |
|
2163 | + $output .= '</table>'."\n"; |
|
2164 | 2164 | $more_link = ($account) ? "user/{$account->uid}/stats" : 'account/stats'; |
2165 | 2165 | //$output .= "<div class=\"more-link\"><a href=\"{$more_link}\">More stats</a></div>" . "\n"; |
2166 | 2166 | return $output; |
@@ -2180,8 +2180,8 @@ discard block |
||
2180 | 2180 | 'cpid' => $cpid |
2181 | 2181 | ); |
2182 | 2182 | $args = array(); |
2183 | - foreach ($get as $arg => $value) $args[] = "{$arg}=" . rawurlencode($value); |
|
2184 | - $query = '?' . implode('&', $args); |
|
2183 | + foreach ($get as $arg => $value) $args[] = "{$arg}=".rawurlencode($value); |
|
2184 | + $query = '?'.implode('&', $args); |
|
2185 | 2185 | |
2186 | 2186 | // Load XML from RPC |
2187 | 2187 | $target_url = "http://{$stats_server}/{$stats_rpc}{$query}"; |
@@ -2253,12 +2253,12 @@ discard block |
||
2253 | 2253 | $output .= '<ul class="tab-list">'; |
2254 | 2254 | $count = 0; |
2255 | 2255 | foreach ($links as $key => $link) { |
2256 | - $output .= '<li class="' . (($count == 0) ? 'first primary ' : '') . 'tab">'; |
|
2256 | + $output .= '<li class="'.(($count == 0) ? 'first primary ' : '').'tab">'; |
|
2257 | 2257 | $output .= l($link['title'], $link['href'], array('query' => drupal_get_destination())); |
2258 | 2258 | $output .= '</li>'; |
2259 | 2259 | $count++; |
2260 | 2260 | } |
2261 | - $output .= '<li class="' . (($count) ? '' : 'first ') . 'last tab">' . flag_create_link('abuse_user', $account->uid) . '</li>'; |
|
2261 | + $output .= '<li class="'.(($count) ? '' : 'first ').'last tab">'.flag_create_link('abuse_user', $account->uid).'</li>'; |
|
2262 | 2262 | $output .= '</ul>'; |
2263 | 2263 | } |
2264 | 2264 | return $output; |
@@ -2299,7 +2299,7 @@ discard block |
||
2299 | 2299 | function boincuser_apachesolr_index_documents_alter(array &$documents, $entity, $entity_type, $env_id) { |
2300 | 2300 | |
2301 | 2301 | foreach ($documents as $document) { |
2302 | - if ( $document->entity_type=='node' AND $document->bundle=='profile' ) { |
|
2302 | + if ($document->entity_type == 'node' AND $document->bundle == 'profile') { |
|
2303 | 2303 | // Node information. |
2304 | 2304 | $nid = $document->entity_id; |
2305 | 2305 | $node = node_load($nid); |
@@ -2349,11 +2349,11 @@ discard block |
||
2349 | 2349 | // privatemsg module. We need to convert them back to spaces for the |
2350 | 2350 | // check below. |
2351 | 2351 | $boincname = preg_replace("/\\xc2\\xa0/", " ", $boincname); |
2352 | - if ($drupalid>0) { |
|
2352 | + if ($drupalid > 0) { |
|
2353 | 2353 | if ($recipient = user_load(array('uid' => $drupalid))) { |
2354 | 2354 | // Double-check that the loaded user matches both boincuser_id |
2355 | 2355 | // and boincuser_name. |
2356 | - if ( ($boincid == $recipient->boincuser_id) AND ($boincname == $recipient->boincuser_name) ) { |
|
2356 | + if (($boincid == $recipient->boincuser_id) AND ($boincname == $recipient->boincuser_name)) { |
|
2357 | 2357 | return $recipient; |
2358 | 2358 | } |
2359 | 2359 | } |
@@ -415,11 +415,9 @@ discard block |
||
415 | 415 | |
416 | 416 | if ($edit['boincuser_name']) { |
417 | 417 | $myname = $edit['boincuser_name']; |
418 | - } |
|
419 | - else if ($edit['name']) { |
|
418 | + } else if ($edit['name']) { |
|
420 | 419 | $myname = $edit['name']; |
421 | - } |
|
422 | - else { |
|
420 | + } else { |
|
423 | 421 | $myname = 'noname'; |
424 | 422 | } |
425 | 423 | |
@@ -431,8 +429,7 @@ discard block |
||
431 | 429 | // If the 'pass' variable is already a hash, then don't hash it again. |
432 | 430 | if ($edit['boinchash_flag']) { |
433 | 431 | $user_params['passwd_hash'] = $edit['pass']; |
434 | - } |
|
435 | - else { |
|
432 | + } else { |
|
436 | 433 | // The passwd_hash here is only the md5() hash. This is |
437 | 434 | // because BOINC make_user(), called later, will run |
438 | 435 | // password_hash() on this md5 hash. |
@@ -498,8 +495,7 @@ discard block |
||
498 | 495 | $prev_email = $account->mail; |
499 | 496 | $mytime = (user_access('administer users')) ? $boinc_user->email_addr_change_time : time(); |
500 | 497 | $querypart = "email_addr='{$email_addr}', passwd_hash='{$passwd_hash}', previous_email_addr = '{$prev_email}', email_addr_change_time = $mytime"; |
501 | - } |
|
502 | - else { |
|
498 | + } else { |
|
503 | 499 | $querypart = "email_addr='{$email_addr}', passwd_hash='{$passwd_hash}'"; |
504 | 500 | } |
505 | 501 | |
@@ -737,8 +733,7 @@ discard block |
||
737 | 733 | case FLAG_FRIEND_APPROVAL: |
738 | 734 | if ($action == 'flag') { |
739 | 735 | $form['flag_friend_submit']['#value'] = bts('Approve request', array(), NULL, 'boinc:friends-page'); |
740 | - } |
|
741 | - elseif ($action == 'unflag') { |
|
736 | + } elseif ($action == 'unflag') { |
|
742 | 737 | unset($form['actions']); |
743 | 738 | $form['flag_friend_submit']['#value'] = bts('Deny request', array(), NULL, 'boinc:friends-page'); |
744 | 739 | } |
@@ -1514,8 +1509,7 @@ discard block |
||
1514 | 1509 | array( |
1515 | 1510 | '!boinccmd' => l('boinccmd --project_attach', 'http://boinc.berkeley.edu/wiki/Boinccmd_tool'), |
1516 | 1511 | ), NULL, 'boinc:join-page') . '</li>'; |
1517 | - } |
|
1518 | - else { |
|
1512 | + } else { |
|
1519 | 1513 | $output .= '<li>' . bts("If you're running a command-line version of BOINC, |
1520 | 1514 | please follow the <b>!instructionslink</b> to first <i>create an account</i>, and then <i>attach</i> to this project. Use the same project URL as above.", |
1521 | 1515 | array( |
@@ -1550,8 +1544,7 @@ discard block |
||
1550 | 1544 | '!create_an_account' => l(bts('create an account', array(), NULL, 'boinc:join-page'), 'user/registration'), |
1551 | 1545 | '@sitename' => $site_name, |
1552 | 1546 | ), NULL, 'boinc:join-page') . '</li>'; |
1553 | - } |
|
1554 | - else if ( menu_valid_path(array('link_path' => $ruleslink)) ) { |
|
1547 | + } else if ( menu_valid_path(array('link_path' => $ruleslink)) ) { |
|
1555 | 1548 | $output .= ' <li>' . bts("Read our !rules_and_policies.", array( |
1556 | 1549 | '!rules_and_policies' => l(bts('Rules and Policies', array(), NULL, 'boinc:join-page'), $ruleslink), |
1557 | 1550 | ), NULL, 'boinc:join-page') . '</li>'; |
@@ -1593,8 +1586,7 @@ discard block |
||
1593 | 1586 | )); |
1594 | 1587 | if ($current_uotd->uotd_time < strtotime('today midnight')) { |
1595 | 1588 | $uotd = boincuser_select_user_of_the_day(); |
1596 | - } |
|
1597 | - else { |
|
1589 | + } else { |
|
1598 | 1590 | $uotd = user_load($current_uotd->uid); |
1599 | 1591 | } |
1600 | 1592 | $uotd_image = boincuser_get_user_profile_image($uotd->uid, FALSE); |
@@ -1605,8 +1597,7 @@ discard block |
||
1605 | 1597 | $output .= ' <div>' . bts($site_message, array(), NULL, "project:front page") . ' ' . l(bts('Learn more', array(), NULL, 'boinc:front-page'), 'about') . '</div>'; |
1606 | 1598 | if ($user->uid) { |
1607 | 1599 | $output .= ' <div>' . l(bts('View account', array(), NULL, 'boinc:front-page'), 'dashboard', array('attributes' => array('class' => 'join button'))) . '</div>'; |
1608 | - } |
|
1609 | - else { |
|
1600 | + } else { |
|
1610 | 1601 | $output .= ' <div>' . l(bts('Join now', array(), NULL, 'boinc:front-page'), 'join', array('attributes' => array('class' => 'join button'))) . '</div>'; |
1611 | 1602 | } |
1612 | 1603 | $output .= '</div>'; |
@@ -1691,12 +1682,10 @@ discard block |
||
1691 | 1682 | if ( ($params['passwd_hash'] == $boinc_user->passwd_hash) or |
1692 | 1683 | password_verify($params['passwd_hash'], $boinc_user->passwd_hash) ) { |
1693 | 1684 | $output = array('authenticator' => $boinc_user->authenticator); |
1694 | - } |
|
1695 | - else { |
|
1685 | + } else { |
|
1696 | 1686 | xml_error(-137); |
1697 | 1687 | } |
1698 | - } |
|
1699 | - else { |
|
1688 | + } else { |
|
1700 | 1689 | // Verify that there isn't somehow a Drupal user already (not possible with proper function) |
1701 | 1690 | if ($existing_user = user_load(array('mail' => $params['email_addr']))) { |
1702 | 1691 | xml_error(-137, 'account error'); |
@@ -2180,7 +2169,9 @@ discard block |
||
2180 | 2169 | 'cpid' => $cpid |
2181 | 2170 | ); |
2182 | 2171 | $args = array(); |
2183 | - foreach ($get as $arg => $value) $args[] = "{$arg}=" . rawurlencode($value); |
|
2172 | + foreach ($get as $arg => $value) { |
|
2173 | + $args[] = "{$arg}=" . rawurlencode($value); |
|
2174 | + } |
|
2184 | 2175 | $query = '?' . implode('&', $args); |
2185 | 2176 | |
2186 | 2177 | // Load XML from RPC |
@@ -2311,8 +2302,7 @@ discard block |
||
2311 | 2302 | if ($node->uid == 0 || strlen($node->name) == 0) { |
2312 | 2303 | // @see user_validate_name(). !'0' === TRUE. |
2313 | 2304 | $document->ss_name = '0'; |
2314 | - } |
|
2315 | - else { |
|
2305 | + } else { |
|
2316 | 2306 | $document->ss_name = $account->boincuser_name; |
2317 | 2307 | // We want the name to be searchable for keywords. |
2318 | 2308 | $document->tos_name = $account->boincuser_name; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | 'weight' => 5 |
84 | 84 | ); |
85 | 85 | $items['moderate/profile/%/reject'] = array( |
86 | - 'title' => bts('Reject profile', array(), NULL, 'boinc:moderate-user'), |
|
86 | + 'title' => bts('Reject profile', array(), null, 'boinc:moderate-user'), |
|
87 | 87 | 'description' => 'Reject profile content', |
88 | 88 | 'page callback' => 'drupal_get_form', |
89 | 89 | 'page arguments' => array('boincuser_moderate_profile_reject_form', 2), |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | 'weight' => 5 |
93 | 93 | ); |
94 | 94 | $items['moderate/user/%/ban'] = array( |
95 | - 'title' => bts('Ban user', array(), NULL, 'boinc:moderate-ban-user'), |
|
95 | + 'title' => bts('Ban user', array(), null, 'boinc:moderate-ban-user'), |
|
96 | 96 | 'description' => 'Ban a user from using community features', |
97 | 97 | 'page callback' => 'drupal_get_form', |
98 | 98 | 'page arguments' => array('boincuser_moderate_user_ban_form', 2), |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | 'weight' => 5 |
124 | 124 | ); |
125 | 125 | $items['user/login/auth'] = array( |
126 | - 'title' => bts('Authenticator login', array(), NULL, 'boinc:authenticator-login-page'), |
|
126 | + 'title' => bts('Authenticator login', array(), null, 'boinc:authenticator-login-page'), |
|
127 | 127 | 'description' => 'Log in using a user authenticator', |
128 | 128 | 'page callback' => 'drupal_get_form', |
129 | 129 | 'page arguments' => array('boincuser_authloginform'), |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | 'type' => MENU_CALLBACK, |
132 | 132 | ); |
133 | 133 | $items['user/termsofuse'] = array( |
134 | - 'title' => bts('Terms of Use', array(), NULL, 'boinc:termsofuse-form'), |
|
134 | + 'title' => bts('Terms of Use', array(), null, 'boinc:termsofuse-form'), |
|
135 | 135 | 'description' => 'A site\'s term of use.', |
136 | 136 | 'page callback' => 'drupal_get_form', |
137 | 137 | 'page arguments' => array('boincuser_termsofuse_form'), |
@@ -185,19 +185,19 @@ discard block |
||
185 | 185 | 'title' => 'Create Account RPC', |
186 | 186 | 'description' => 'RPC for creating user accounts.', |
187 | 187 | 'page callback' => 'boincuser_create_account', |
188 | - 'access callback' => TRUE, |
|
188 | + 'access callback' => true, |
|
189 | 189 | 'type' => MENU_CALLBACK |
190 | 190 | ); |
191 | 191 | $items['account_finish.php'] = array( |
192 | 192 | 'title' => 'Welcome to ' . variable_get('site_name', 'Drupal-BOINC'), |
193 | 193 | 'description' => 'RPC for after a user has created an account.', |
194 | 194 | 'page callback' => 'boincuser_account_finish', |
195 | - 'access callback' => TRUE, |
|
195 | + 'access callback' => true, |
|
196 | 196 | 'type' => MENU_CALLBACK, |
197 | 197 | ); |
198 | 198 | $items['boincuser/autocomplete'] = array( |
199 | 199 | 'page callback' => '_boincuser_user_name_autocomplete', |
200 | - 'access callback' => TRUE, |
|
200 | + 'access callback' => true, |
|
201 | 201 | 'type' => MENU_CALLBACK, |
202 | 202 | ); |
203 | 203 | $items['user/%user/recoveremail/%'] = array( |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | 'title' => t('Recover previous email'), |
213 | 213 | 'description' => t('redirect'), |
214 | 214 | 'page callback' => '_boincuser_redirect_recover_email', |
215 | - 'access callback' => TRUE, |
|
215 | + 'access callback' => true, |
|
216 | 216 | 'type' => MENU_CALLBACK, |
217 | 217 | ); |
218 | 218 | return $items; |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | // Check if user has agreed to the terms of use. If not, send the |
248 | 248 | // user to the terms-of-use form. This is only makes sense if the |
249 | 249 | // termsofuse is enabled, by having text in the termsofuse variable. |
250 | - $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE); |
|
250 | + $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', false); |
|
251 | 251 | $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
252 | 252 | if ( (!empty($termsofuse)) and ($user->uid) ) { |
253 | 253 | if ( !boincuser_check_termsofuse($user) and ($existinguser_tou) ) { |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | * Implementation of hook_user(); add custom actions to standard |
289 | 289 | * Drupal user operations |
290 | 290 | */ |
291 | -function boincuser_user($op, &$edit, &$account, $category = NULL) { |
|
291 | +function boincuser_user($op, &$edit, &$account, $category = null) { |
|
292 | 292 | require_boinc('boinc_db'); |
293 | 293 | require_boinc('user'); |
294 | 294 | require_boinc('xml'); |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | $account->boincuser_email_addr_change_time = $boinc_user->email_addr_change_time; |
338 | 338 | db_set_active('default'); |
339 | 339 | // Set Drupal team ID |
340 | - $account->team = NULL; |
|
340 | + $account->team = null; |
|
341 | 341 | if ($account->boincteam_id) { |
342 | 342 | $account->team = db_result(db_query(" |
343 | 343 | SELECT nid FROM {boincteam} WHERE team_id = %d", |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | $boinc_user = boincuser_register_make_user($user_params); |
443 | 443 | if (!$boinc_user) { |
444 | 444 | // Account exists with this email addr |
445 | - form_set_error('email', bts('Error creating BOINC account.', array(), NULL, 'boinc:add-new-user')); |
|
445 | + form_set_error('email', bts('Error creating BOINC account.', array(), null, 'boinc:add-new-user')); |
|
446 | 446 | return; |
447 | 447 | } |
448 | 448 | |
@@ -484,9 +484,9 @@ discard block |
||
484 | 484 | case 'user_account': |
485 | 485 | // Ensure that BOINC data is altered |
486 | 486 | |
487 | - $changing_email = ($edit['mail'] AND $edit['mail'] != $boinc_user->email_addr) ? true : false; |
|
487 | + $changing_email = ($edit['mail'] and $edit['mail'] != $boinc_user->email_addr) ? true : false; |
|
488 | 488 | $changing_pass = ($edit['pass']) ? true : false; |
489 | - if ($changing_email OR $changing_pass) { |
|
489 | + if ($changing_email or $changing_pass) { |
|
490 | 490 | // Set password hash appropriately |
491 | 491 | $passwd = ($edit['pass']) ? $edit['pass'] : $edit['current_pass']; |
492 | 492 | $passwd_hash = password_hash( md5($passwd.$edit['mail']), PASSWORD_DEFAULT ); |
@@ -561,13 +561,13 @@ discard block |
||
561 | 561 | *(forward compatible to Drupal 7). |
562 | 562 | */ |
563 | 563 | function boincuser_user_login(&$edit, $account) { |
564 | - $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE); |
|
564 | + $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', false); |
|
565 | 565 | $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
566 | 566 | |
567 | 567 | // Use the same code as boincuser_form_alter(), for case |
568 | 568 | // 'user_profile_form', if the refering page is the user password |
569 | 569 | // reset form, then do not check for terms of use. |
570 | - $reset_pass = (strpos($_SERVER['HTTP_REFERER'], "/user/reset/$account->uid") === FALSE) ? 0 : 1; |
|
570 | + $reset_pass = (strpos($_SERVER['HTTP_REFERER'], "/user/reset/$account->uid") === false) ? 0 : 1; |
|
571 | 571 | if ($reset_pass) { |
572 | 572 | return; |
573 | 573 | } |
@@ -715,7 +715,7 @@ discard block |
||
715 | 715 | |
716 | 716 | // General friend form overrides |
717 | 717 | $form['flag_friend_submit']['#prefix'] = '<li class="first tab">'; |
718 | - $form['flag_friend_submit']['#value'] = bts('Send request', array(), NULL, 'boinc:friends-page'); |
|
718 | + $form['flag_friend_submit']['#value'] = bts('Send request', array(), null, 'boinc:friends-page'); |
|
719 | 719 | $form['flag_friend_submit']['#type'] = 'submit'; |
720 | 720 | $form['flag_friend_submit']['#suffix'] = '</li>'; |
721 | 721 | $form['flag_friend_submit']['#weight'] = 1002; |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | case FLAG_FRIEND_BOTH: |
725 | 725 | case FLAG_FRIEND_FLAGGED: |
726 | 726 | unset($form['actions']); |
727 | - $form['flag_friend_submit']['#value'] = bts('Remove friend', array(), NULL, 'boinc:friends-remove'); |
|
727 | + $form['flag_friend_submit']['#value'] = bts('Remove friend', array(), null, 'boinc:friends-remove'); |
|
728 | 728 | // Add in our hack handler to fix the flag_friend module |
729 | 729 | $final_handler = array_pop($form['#submit']); |
730 | 730 | $form['#submit'][] = 'boincuser_fix_unfriend_form_submit'; |
@@ -732,21 +732,21 @@ discard block |
||
732 | 732 | break; |
733 | 733 | case FLAG_FRIEND_PENDING: |
734 | 734 | unset($form['actions']); |
735 | - $form['flag_friend_submit']['#value'] = bts('Remove request', array(), NULL, 'boinc:friends-page'); |
|
735 | + $form['flag_friend_submit']['#value'] = bts('Remove request', array(), null, 'boinc:friends-page'); |
|
736 | 736 | break; |
737 | 737 | case FLAG_FRIEND_APPROVAL: |
738 | 738 | if ($action == 'flag') { |
739 | - $form['flag_friend_submit']['#value'] = bts('Approve request', array(), NULL, 'boinc:friends-page'); |
|
739 | + $form['flag_friend_submit']['#value'] = bts('Approve request', array(), null, 'boinc:friends-page'); |
|
740 | 740 | } |
741 | 741 | elseif ($action == 'unflag') { |
742 | 742 | unset($form['actions']); |
743 | - $form['flag_friend_submit']['#value'] = bts('Deny request', array(), NULL, 'boinc:friends-page'); |
|
743 | + $form['flag_friend_submit']['#value'] = bts('Deny request', array(), null, 'boinc:friends-page'); |
|
744 | 744 | } |
745 | 745 | break; |
746 | 746 | case FLAG_FRIEND_UNFLAGGED: |
747 | 747 | default: |
748 | 748 | $user_links[] = array( |
749 | - 'title' => bts('Add as friend', array(), NULL, 'boinc:friends-add'), |
|
749 | + 'title' => bts('Add as friend', array(), null, 'boinc:friends-add'), |
|
750 | 750 | 'href' => "flag/confirm/flag/friend/{$account->uid}" |
751 | 751 | ); |
752 | 752 | } |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | } |
757 | 757 | |
758 | 758 | $form['cancel'] = array( |
759 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $cancel_dest) . '</li>', |
|
759 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), null, 'boinc:form-cancel'), $cancel_dest) . '</li>', |
|
760 | 760 | '#weight' => 1004, |
761 | 761 | ); |
762 | 762 | $form['form control tabs suffix'] = array( |
@@ -779,7 +779,7 @@ discard block |
||
779 | 779 | '#weight' => 1001, |
780 | 780 | ); |
781 | 781 | $form['buttons']['submit']['#prefix'] = '<li class="first tab">'; |
782 | - $form['buttons']['submit']['#value'] = bts('Save changes', array(), NULL, 'boinc:form-save'); |
|
782 | + $form['buttons']['submit']['#value'] = bts('Save changes', array(), null, 'boinc:form-save'); |
|
783 | 783 | $form['buttons']['submit']['#suffix'] = '</li>'; |
784 | 784 | $form['buttons']['submit']['#weight'] = 1002; |
785 | 785 | $form['buttons']['preview']['#prefix'] = '<li class="tab">'; |
@@ -789,7 +789,7 @@ discard block |
||
789 | 789 | $form['buttons']['preview_changes']['#suffix'] = '</li>'; |
790 | 790 | $form['buttons']['preview_changes']['#weight'] = 1004; |
791 | 791 | $form['buttons']['cancel'] = array( |
792 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "node/{$form['nid']['#value']}") . '</li>', |
|
792 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), null, 'boinc:form-cancel'), "node/{$form['nid']['#value']}") . '</li>', |
|
793 | 793 | '#weight' => 1005, |
794 | 794 | ); |
795 | 795 | $form['buttons']['delete']['#prefix'] = '<li class="tab">'; |
@@ -817,11 +817,11 @@ discard block |
||
817 | 817 | '#weight' => 1001, |
818 | 818 | ); |
819 | 819 | $form['actions']['submit']['#prefix'] = '<li class="first tab">'; |
820 | - $form['actions']['submit']['#value'] = bts('Delete', array(), NULL, 'boinc:form-delete'); |
|
820 | + $form['actions']['submit']['#value'] = bts('Delete', array(), null, 'boinc:form-delete'); |
|
821 | 821 | $form['actions']['submit']['#suffix'] = '</li>'; |
822 | 822 | $form['actions']['submit']['#weight'] = 1002; |
823 | 823 | $form['actions']['cancel'] = array( |
824 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "node/{$form['nid']['#value']}") . '</li>', |
|
824 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), null, 'boinc:form-cancel'), "node/{$form['nid']['#value']}") . '</li>', |
|
825 | 825 | '#weight' => 1005, |
826 | 826 | ); |
827 | 827 | $form['actions']['form control tabs suffix'] = array( |
@@ -841,14 +841,14 @@ discard block |
||
841 | 841 | '#weight' => 1001, |
842 | 842 | ); |
843 | 843 | $form['privatemsg']['submit']['#prefix'] = '<li class="first tab">'; |
844 | - $form['privatemsg']['submit']['#value'] = bts('Send message', array(), NULL, 'boinc:private-message'); |
|
844 | + $form['privatemsg']['submit']['#value'] = bts('Send message', array(), null, 'boinc:private-message'); |
|
845 | 845 | $form['privatemsg']['submit']['#suffix'] = '</li>'; |
846 | 846 | $form['privatemsg']['submit']['#weight'] = 1002; |
847 | 847 | $form['privatemsg']['preview']['#prefix'] = '<li class="tab">'; |
848 | 848 | $form['privatemsg']['preview']['#suffix'] = '</li>'; |
849 | 849 | $form['privatemsg']['preview']['#weight'] = 1003; |
850 | 850 | $form['privatemsg']['cancel'] = array( |
851 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
851 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), null, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
852 | 852 | '#weight' => 1004, |
853 | 853 | ); |
854 | 854 | $form['privatemsg']['form control tabs suffix'] = array( |
@@ -863,18 +863,18 @@ discard block |
||
863 | 863 | // Login form |
864 | 864 | case 'user_login': |
865 | 865 | case 'user_login_block': |
866 | - drupal_set_title(bts('Login', array(), NULL, 'boinc:menu-link')); |
|
866 | + drupal_set_title(bts('Login', array(), null, 'boinc:menu-link')); |
|
867 | 867 | // Replace name with email in login form |
868 | 868 | unset($form['name']); |
869 | 869 | array_unshift($form, array( |
870 | 870 | 'email' => array( |
871 | 871 | '#type' => 'textfield', |
872 | - '#title' => bts('Email address', array(), NULL, 'boinc:email-address-to-login'), |
|
872 | + '#title' => bts('Email address', array(), null, 'boinc:email-address-to-login'), |
|
873 | 873 | '#size' => ($form_id == 'user_login_block') ? 15 : 60, |
874 | 874 | '#maxlength' => EMAIL_MAX_LENGTH, |
875 | - '#required' => TRUE, |
|
875 | + '#required' => true, |
|
876 | 876 | '#attributes' => array('tabindex' => '1'), |
877 | - '#description' => bts('Enter your @s email address.', array('@s' => variable_get('site_name', 'Drupal-BOINC')), NULL, 'boinc:standard-login-page') |
|
877 | + '#description' => bts('Enter your @s email address.', array('@s' => variable_get('site_name', 'Drupal-BOINC')), null, 'boinc:standard-login-page') |
|
878 | 878 | ), |
879 | 879 | 'validation_source' => array( |
880 | 880 | '#type' => 'hidden', |
@@ -890,7 +890,7 @@ discard block |
||
890 | 890 | ); |
891 | 891 | $form['buttons']['submit'] = $form['submit']; |
892 | 892 | $form['buttons']['submit']['#prefix'] = '<li class="first tab">'; |
893 | - $form['buttons']['submit']['#value'] = bts('Log in', array(), NULL, 'boinc:standard-login-page'); |
|
893 | + $form['buttons']['submit']['#value'] = bts('Log in', array(), null, 'boinc:standard-login-page'); |
|
894 | 894 | $form['buttons']['submit']['#suffix'] = '</li>'; |
895 | 895 | $form['buttons']['submit']['#weight'] = 1002; |
896 | 896 | $form['buttons']['form control tabs suffix'] = array( |
@@ -906,7 +906,7 @@ discard block |
||
906 | 906 | if (isset($form_state['post']['email']) and isset($form_state['post']['pass'])) { |
907 | 907 | // Find the local validation function's entry so we can replace it. |
908 | 908 | $array_key = array_search('user_login_authenticate_validate', $form['#validate']); |
909 | - if ($array_key === FALSE) { |
|
909 | + if ($array_key === false) { |
|
910 | 910 | // Could not find it. Some other module must have run form_alter(). |
911 | 911 | // We will simply add our validation just before the final validator. |
912 | 912 | $final_validator = array_pop($form['#validate']); |
@@ -934,26 +934,26 @@ discard block |
||
934 | 934 | } |
935 | 935 | |
936 | 936 | // Set special message if user has not agreed to TOU |
937 | - $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE); |
|
937 | + $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', false); |
|
938 | 938 | $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
939 | 939 | if ( (!boincuser_check_termsofuse($account)) and ($existinguser_tou) and (!empty($termsofuse)) and (!user_access('administer users')) ) { |
940 | 940 | drupal_set_message( |
941 | 941 | bts('INFO: You have not agreed to the terms of use for @project. You may use this form to change your email address and/or password. Please note: you may not delete your account within seven (7) days of changing your email address.', |
942 | 942 | array( |
943 | 943 | '@project' => variable_get('site_name','Drupal-BOINC'), |
944 | - ), NULL, 'boinc:account-credentials-change') |
|
944 | + ), null, 'boinc:account-credentials-change') |
|
945 | 945 | , 'info'); |
946 | 946 | } |
947 | 947 | |
948 | 948 | // A bit hackish... but don't require the user to enter his password if |
949 | 949 | // coming from the password reset function |
950 | - $reset_pass = (strpos($_SERVER['HTTP_REFERER'], "/user/reset/{$form['#uid']}") === FALSE) ? 0 : 1; |
|
950 | + $reset_pass = (strpos($_SERVER['HTTP_REFERER'], "/user/reset/{$form['#uid']}") === false) ? 0 : 1; |
|
951 | 951 | if ($reset_pass) { |
952 | 952 | $_SESSION['reset_pass'] = 1; |
953 | 953 | } |
954 | 954 | |
955 | 955 | // Adjust form elements already present |
956 | - $form['account']['name']['#title'] = bts('Drupal Username', array(), NULL, 'boinc:drupal-username'); |
|
956 | + $form['account']['name']['#title'] = bts('Drupal Username', array(), null, 'boinc:drupal-username'); |
|
957 | 957 | $form['account']['name']['#size'] = 40; |
958 | 958 | $form['account']['name']['#attributes']['autocomplete'] = 'off'; |
959 | 959 | $form['account']['name']['#description'] .= '<p>This is the drupal (internal) username. The title above shows the BOINC username, which is the display name used publicly that the user can change in Community Preferences.'; |
@@ -964,11 +964,11 @@ discard block |
||
964 | 964 | // Add BOINC username (aka displayname) |
965 | 965 | $form['account']['boincuser_name'] = array( |
966 | 966 | '#type' => 'textfield', |
967 | - '#title' => bts('BOINC Username', array(), NULL, 'boinc:user-or-team-name'), |
|
967 | + '#title' => bts('BOINC Username', array(), null, 'boinc:user-or-team-name'), |
|
968 | 968 | '#default_value' => $account->boincuser_name, |
969 | 969 | '#maxlength' => USERNAME_MAX_LENGTH, |
970 | - '#required' => TRUE, |
|
971 | - '#description' => bts('This is the BOINC (external) username. This is the same setting as found in Account -> Preferences -> Community.', array(), NULL, 'boinc:username-change'), |
|
970 | + '#required' => true, |
|
971 | + '#description' => bts('This is the BOINC (external) username. This is the same setting as found in Account -> Preferences -> Community.', array(), null, 'boinc:username-change'), |
|
972 | 972 | '#size' => 40, |
973 | 973 | ); |
974 | 974 | } |
@@ -977,23 +977,23 @@ discard block |
||
977 | 977 | // ago, it cannot be changed again. |
978 | 978 | $duration = TOKEN_DURATION_ONE_WEEK; |
979 | 979 | if (($account->boincuser_email_addr_change_time + $duration) > time() and (!user_access('administer users'))) { |
980 | - $form['account']['mail']['#required'] = FALSE; |
|
980 | + $form['account']['mail']['#required'] = false; |
|
981 | 981 | $form['account']['mailhelp'] = array( |
982 | 982 | '#value' => bts("You email address was changed within the past seven (7) days. Please look for an email to !prev_email if you need to revert this change. You may change your email address on !time.", |
983 | 983 | array( |
984 | 984 | '!prev_email' => $account->boincuser_previous_email_addr, |
985 | 985 | '!time' => date('F j, Y \a\t G:i T', $account->boincuser_email_addr_change_time + $duration), |
986 | - ), NULL, 'boinc:account-credentials-change'), |
|
986 | + ), null, 'boinc:account-credentials-change'), |
|
987 | 987 | ); |
988 | 988 | } |
989 | 989 | |
990 | - if (!$reset_pass AND ($user->uid == $account->uid OR !user_access('administer users'))) { |
|
990 | + if (!$reset_pass and ($user->uid == $account->uid or !user_access('administer users'))) { |
|
991 | 991 | // Add a password authenticator, required to change email or pw |
992 | 992 | $form['account']['current_pass'] = array( |
993 | 993 | '#type' => 'password', |
994 | - '#title' => bts('Enter your password to save changes', array(), NULL, 'boinc:account-credentials-change'), |
|
994 | + '#title' => bts('Enter your password to save changes', array(), null, 'boinc:account-credentials-change'), |
|
995 | 995 | '#description' => bts('Enter your current password if changing your email |
996 | - address or password.', array(), NULL, 'boinc:account-credentials-change'), |
|
996 | + address or password.', array(), null, 'boinc:account-credentials-change'), |
|
997 | 997 | '#size' => 17, |
998 | 998 | '#attributes' => array( |
999 | 999 | 'autocomplete' => 'off', |
@@ -1005,35 +1005,35 @@ discard block |
||
1005 | 1005 | $form['account']['boincuser_id'] = array( |
1006 | 1006 | '#value' => ' |
1007 | 1007 | <div class="form-item"> |
1008 | - <label>' . bts('BOINC user ID', array(), NULL, 'boinc:account-credentials-change') . '</label> |
|
1008 | + <label>' . bts('BOINC user ID', array(), null, 'boinc:account-credentials-change') . '</label> |
|
1009 | 1009 | <span>' . $account->boincuser_id . '</span> |
1010 | 1010 | </div>', |
1011 | 1011 | ); |
1012 | 1012 | $form['account']['user_id'] = array( |
1013 | 1013 | '#value' => ' |
1014 | 1014 | <div class="form-item"> |
1015 | - <label>' . bts('Drupal user ID', array(), NULL, 'boinc:account-credentials-change') . '</label> |
|
1015 | + <label>' . bts('Drupal user ID', array(), null, 'boinc:account-credentials-change') . '</label> |
|
1016 | 1016 | <span>' . $account->uid . '</span> |
1017 | 1017 | </div>', |
1018 | 1018 | ); |
1019 | 1019 | $form['account']['account_key'] = array( |
1020 | 1020 | '#value' => ' |
1021 | 1021 | <div class="form-item"> |
1022 | - <label>' . bts('Account key', array(), NULL, 'boinc:account-credentials-change') . '</label> |
|
1022 | + <label>' . bts('Account key', array(), null, 'boinc:account-credentials-change') . '</label> |
|
1023 | 1023 | <span>' . $account->boincuser_account_key . '</span> |
1024 | 1024 | </div>', |
1025 | 1025 | ); |
1026 | 1026 | $form['account']['weak_account_key'] = array( |
1027 | 1027 | '#value' => ' |
1028 | 1028 | <div class="form-item"> |
1029 | - <label>' . bts('Weak account key', array(), NULL, 'boinc:account-credentials-change') . '</label> |
|
1029 | + <label>' . bts('Weak account key', array(), null, 'boinc:account-credentials-change') . '</label> |
|
1030 | 1030 | <span>' . "{$account->boincuser_id}_{$account->boincuser_weak_auth}" . '</span> |
1031 | 1031 | </div>', |
1032 | 1032 | ); |
1033 | 1033 | $form['account']['cpid'] = array( |
1034 | 1034 | '#value' => ' |
1035 | 1035 | <div class="form-item"> |
1036 | - <label>' . bts('Cross-project ID', array(), NULL, 'boinc:account-credentials-change') . '</label> |
|
1036 | + <label>' . bts('Cross-project ID', array(), null, 'boinc:account-credentials-change') . '</label> |
|
1037 | 1037 | <span>' . $account->boincuser_cpid . '</span> |
1038 | 1038 | </div>', |
1039 | 1039 | ); |
@@ -1048,14 +1048,14 @@ discard block |
||
1048 | 1048 | '#weight' => 1001, |
1049 | 1049 | ); |
1050 | 1050 | $form['submit']['#prefix'] = '<li class="first tab">'; |
1051 | - $form['submit']['#value'] = bts('Save changes', array(), NULL, 'boinc:form-save'); |
|
1051 | + $form['submit']['#value'] = bts('Save changes', array(), null, 'boinc:form-save'); |
|
1052 | 1052 | $form['submit']['#suffix'] = '</li>'; |
1053 | 1053 | $form['submit']['#weight'] = 1002; |
1054 | 1054 | $form['cancel'] = array( |
1055 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
1055 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), null, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
1056 | 1056 | '#weight' => 1003, |
1057 | 1057 | ); |
1058 | - if (isset($form['delete']) AND is_array($form['delete'])) { |
|
1058 | + if (isset($form['delete']) and is_array($form['delete'])) { |
|
1059 | 1059 | $form['delete']['#prefix'] = '<li class="first alt tab">'; |
1060 | 1060 | $form['delete']['#suffix'] = '</li>'; |
1061 | 1061 | $form['delete']['#weight'] = 1004; |
@@ -1117,7 +1117,7 @@ discard block |
||
1117 | 1117 | |
1118 | 1118 | // Set form['title'], but hide it |
1119 | 1119 | $form['title']['#default_value'] = $account->boincuser_name; |
1120 | - $form['title']['#access'] = FALSE; |
|
1120 | + $form['title']['#access'] = false; |
|
1121 | 1121 | |
1122 | 1122 | $form['separator_bottom'] = array( |
1123 | 1123 | '#value' => '<div class="separator buttons"></div>', |
@@ -1138,7 +1138,7 @@ discard block |
||
1138 | 1138 | '#weight' => 1001, |
1139 | 1139 | ); |
1140 | 1140 | $form['buttons']['submit']['#prefix'] = '<li class="first tab">'; |
1141 | - $form['buttons']['submit']['#value'] = bts('Save changes', array(), NULL, 'boinc:form-save'); |
|
1141 | + $form['buttons']['submit']['#value'] = bts('Save changes', array(), null, 'boinc:form-save'); |
|
1142 | 1142 | $form['buttons']['submit']['#suffix'] = '</li>'; |
1143 | 1143 | $form['buttons']['submit']['#weight'] = 1002; |
1144 | 1144 | $form['buttons']['preview']['#prefix'] = '<li class="tab">'; |
@@ -1148,12 +1148,12 @@ discard block |
||
1148 | 1148 | $form['buttons']['preview_changes']['#suffix'] = '</li>'; |
1149 | 1149 | $form['buttons']['preview_changes']['#weight'] = 1004; |
1150 | 1150 | $form['buttons']['cancel'] = array( |
1151 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
1151 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), null, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
1152 | 1152 | '#weight' => 1005, |
1153 | 1153 | ); |
1154 | 1154 | $form['buttons']['delete']['#prefix'] = '<li class="tab">'; |
1155 | 1155 | $form['buttons']['delete']['#suffix'] = '</li>'; |
1156 | - $form['buttons']['delete']['#value'] = bts('Clear User Profile', array(), NULL, 'boinc:form-save'); |
|
1156 | + $form['buttons']['delete']['#value'] = bts('Clear User Profile', array(), null, 'boinc:form-save'); |
|
1157 | 1157 | $form['buttons']['delete']['#weight'] = 1006; |
1158 | 1158 | $form['buttons']['delete']['#submit'] = array('_boincuser_node_profile_delete_submit'); |
1159 | 1159 | $form['buttons']['form control tabs suffix'] = array( |
@@ -1187,11 +1187,11 @@ discard block |
||
1187 | 1187 | array_unshift($form, array( |
1188 | 1188 | 'boincuser_name' => array( |
1189 | 1189 | '#type' => 'textfield', |
1190 | - '#title' => bts('Name', array(), NULL, 'boinc:user-or-team-name'), |
|
1190 | + '#title' => bts('Name', array(), null, 'boinc:user-or-team-name'), |
|
1191 | 1191 | '#default_value' => $edit['boincuser_name'], |
1192 | 1192 | '#maxlength' => USERNAME_MAX_LENGTH, |
1193 | - '#description' => bts('Spaces are allowed; punctuation is not allowed except for periods, hyphens, and underscores.', array(), NULL, 'boinc:user-register'), |
|
1194 | - '#required' => TRUE |
|
1193 | + '#description' => bts('Spaces are allowed; punctuation is not allowed except for periods, hyphens, and underscores.', array(), null, 'boinc:user-register'), |
|
1194 | + '#required' => true |
|
1195 | 1195 | ), |
1196 | 1196 | )); |
1197 | 1197 | // Set name temporarily to dummy value to beat validation |
@@ -1205,21 +1205,21 @@ discard block |
||
1205 | 1205 | if (!empty($termsofuse)) { |
1206 | 1206 | $form['title1'] = array( |
1207 | 1207 | '#weight' => -12, |
1208 | - '#value' => '<h2>' . bts(variable_get('boinc_weboptions_registrationtitle', 'Please read and acknowledge our terms of use'), array(), NULL, 'project:user-register' ) . '</h2>', |
|
1208 | + '#value' => '<h2>' . bts(variable_get('boinc_weboptions_registrationtitle', 'Please read and acknowledge our terms of use'), array(), null, 'project:user-register' ) . '</h2>', |
|
1209 | 1209 | '#prefix' => '<div id="register-title1">', |
1210 | 1210 | '#suffix' => '</div>', |
1211 | 1211 | ); |
1212 | 1212 | |
1213 | 1213 | $form['termsofuse'] = array( |
1214 | 1214 | '#weight' => -10, |
1215 | - '#value' => bts($termsofuse, array(), NULL, 'project:user-register'), |
|
1215 | + '#value' => bts($termsofuse, array(), null, 'project:user-register'), |
|
1216 | 1216 | '#prefix' => '<div id="register-termsofuse">', |
1217 | 1217 | '#suffix' => '</div>', |
1218 | 1218 | ); |
1219 | 1219 | |
1220 | 1220 | $form['agreeTOU'] = array( |
1221 | 1221 | '#type' => 'checkbox', |
1222 | - '#title' => bts(variable_get('boinc_weboptions_agreequestion', 'Do you agree with the above terms of use?'), array(), NULL, 'project:user-register'), |
|
1222 | + '#title' => bts(variable_get('boinc_weboptions_agreequestion', 'Do you agree with the above terms of use?'), array(), null, 'project:user-register'), |
|
1223 | 1223 | '#weight' => -8, |
1224 | 1224 | '#prefix' => '<div id="register-checkbox">', |
1225 | 1225 | '#suffix' => '</div>', |
@@ -1228,7 +1228,7 @@ discard block |
||
1228 | 1228 | |
1229 | 1229 | $form['title2'] = array( |
1230 | 1230 | '#weight' => -6, |
1231 | - '#value' => '<h2>' . bts(variable_get('boinc_weboptions_registrationtitle2', 'Fill in your name, email, and choose a secure passphrase.'), array(), NULL, 'project:user-register') . '</h2>', |
|
1231 | + '#value' => '<h2>' . bts(variable_get('boinc_weboptions_registrationtitle2', 'Fill in your name, email, and choose a secure passphrase.'), array(), null, 'project:user-register') . '</h2>', |
|
1232 | 1232 | '#prefix' => '<div id="register-title2">', |
1233 | 1233 | '#suffix' => '</div>', |
1234 | 1234 | ); |
@@ -1248,26 +1248,26 @@ discard block |
||
1248 | 1248 | |
1249 | 1249 | // Request new password form |
1250 | 1250 | case 'user_pass': |
1251 | - drupal_set_title(bts('Forgot password', array(), NULL, 'boinc:forgot-password')); |
|
1251 | + drupal_set_title(bts('Forgot password', array(), null, 'boinc:forgot-password')); |
|
1252 | 1252 | // Replace name/email text box with email only; retain "name" label |
1253 | 1253 | // for compatibility with standard Drupal submit function |
1254 | 1254 | unset($form['name']); |
1255 | 1255 | array_unshift($form, array( |
1256 | 1256 | 'name' => array( |
1257 | 1257 | '#type' => 'textfield', |
1258 | - '#title' => bts('Email address', array(), NULL, 'boinc:email-address-to-login'), |
|
1258 | + '#title' => bts('Email address', array(), null, 'boinc:email-address-to-login'), |
|
1259 | 1259 | '#size' => 60, |
1260 | 1260 | '#maxlength' => EMAIL_MAX_LENGTH, |
1261 | - '#required' => TRUE, |
|
1261 | + '#required' => true, |
|
1262 | 1262 | '#description' => bts( |
1263 | 1263 | 'Enter your email address to receive instructions for resetting your password (or use the !authenticator_login).', |
1264 | 1264 | array( |
1265 | 1265 | '!authenticator_login' => l( |
1266 | - bts('authenticator-based login', array(), NULL, 'boinc:forgot-password'), |
|
1266 | + bts('authenticator-based login', array(), null, 'boinc:forgot-password'), |
|
1267 | 1267 | 'user/login/auth' |
1268 | 1268 | ) |
1269 | 1269 | ) |
1270 | - , NULL, 'boinc:forgot-password'), |
|
1270 | + , null, 'boinc:forgot-password'), |
|
1271 | 1271 | ), |
1272 | 1272 | )); |
1273 | 1273 | |
@@ -1278,11 +1278,11 @@ discard block |
||
1278 | 1278 | ); |
1279 | 1279 | $form['buttons']['submit'] = $form['submit']; |
1280 | 1280 | $form['buttons']['submit']['#prefix'] = '<li class="first tab">'; |
1281 | - $form['buttons']['submit']['#value'] = bts('Send', array(), NULL, 'boinc:form-send'); |
|
1281 | + $form['buttons']['submit']['#value'] = bts('Send', array(), null, 'boinc:form-send'); |
|
1282 | 1282 | $form['buttons']['submit']['#suffix'] = '</li>'; |
1283 | 1283 | $form['buttons']['submit']['#weight'] = 1002; |
1284 | 1284 | $form['buttons']['cancel'] = array( |
1285 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'user/login') . '</li>', |
|
1285 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), null, 'boinc:form-cancel'), 'user/login') . '</li>', |
|
1286 | 1286 | '#weight' => 1005, |
1287 | 1287 | ); |
1288 | 1288 | $form['buttons']['form control tabs suffix'] = array( |
@@ -1299,7 +1299,7 @@ discard block |
||
1299 | 1299 | break; |
1300 | 1300 | |
1301 | 1301 | case 'views_exposed_form': |
1302 | - $form['submit']['#value'] = bts('Search', array(), NULL, 'boinc:search-user'); |
|
1302 | + $form['submit']['#value'] = bts('Search', array(), null, 'boinc:search-user'); |
|
1303 | 1303 | break; |
1304 | 1304 | } |
1305 | 1305 | } |
@@ -1331,7 +1331,7 @@ discard block |
||
1331 | 1331 | function boincuser_process_password_confirm($element) { |
1332 | 1332 | // Check if parent element is "account". |
1333 | 1333 | if ($element['#array_parents'][0] == 'account') { |
1334 | - $element['pass1']['#title'] = bts('Change password', array(), NULL, 'boinc:forgot-password'); |
|
1334 | + $element['pass1']['#title'] = bts('Change password', array(), null, 'boinc:forgot-password'); |
|
1335 | 1335 | } |
1336 | 1336 | return $element; |
1337 | 1337 | } |
@@ -1351,7 +1351,7 @@ discard block |
||
1351 | 1351 | /** |
1352 | 1352 | * Implementation of hook_token_values |
1353 | 1353 | */ |
1354 | -function boincuser_token_values($type, $object = NULL, $options = array()) { |
|
1354 | +function boincuser_token_values($type, $object = null, $options = array()) { |
|
1355 | 1355 | if ($type == 'user') { |
1356 | 1356 | $account = user_load($object->uid); |
1357 | 1357 | $tokens['display-name'] = $account->boincuser_name; |
@@ -1417,13 +1417,13 @@ discard block |
||
1417 | 1417 | require_boinc('boinc_db'); |
1418 | 1418 | $num_deleted = BoincUserDeleted::delete_expired(); |
1419 | 1419 | if ($num_deleted>0) { |
1420 | - watchdog('boincuser', "Deleted ${num_deleted} users from user_deleted table", WATCHDOG_NOTICE); |
|
1420 | + watchdog('boincuser', "deleted ${num_deleted} users from user_deleted table", WATCHDOG_NOTICE); |
|
1421 | 1421 | } |
1422 | 1422 | |
1423 | 1423 | // Delete expired tokens from token table |
1424 | 1424 | $tokens_deleted = BoincToken::delete_expired(); |
1425 | 1425 | if ($tokens_deleted>0) { |
1426 | - watchdog('boincuser', "Deleted ${tokens_deleted} tokens from token table", WATCHDOG_NOTICE); |
|
1426 | + watchdog('boincuser', "deleted ${tokens_deleted} tokens from token table", WATCHDOG_NOTICE); |
|
1427 | 1427 | } |
1428 | 1428 | } |
1429 | 1429 | |
@@ -1499,35 +1499,35 @@ discard block |
||
1499 | 1499 | if ($registration_enabled) { |
1500 | 1500 | $output .= '<li>' . bts('First !create_an_account here at @sitename.', |
1501 | 1501 | array( |
1502 | - '!create_an_account' => l(bts('create an account', array(), NULL, 'boinc:join-page'), 'user/registration'), |
|
1502 | + '!create_an_account' => l(bts('create an account', array(), null, 'boinc:join-page'), 'user/registration'), |
|
1503 | 1503 | '@sitename' => $site_name, |
1504 | - ), NULL, 'boinc:join-page') . '</li>'; |
|
1504 | + ), null, 'boinc:join-page') . '</li>'; |
|
1505 | 1505 | } |
1506 | - $output .= ' <li>' . bts("Install BOINC on this device if not already present.", array(), NULL, 'boinc:join-page') . '</li>'; |
|
1506 | + $output .= ' <li>' . bts("Install BOINC on this device if not already present.", array(), null, 'boinc:join-page') . '</li>'; |
|
1507 | 1507 | $output .= ' <li>' . bts("Select <i>Tools / Add Project</i>. Choose @sitename from the list, or enter @siteurl.", |
1508 | 1508 | array( |
1509 | 1509 | '@sitename' => $site_name, |
1510 | 1510 | '@siteurl' => $base_url, |
1511 | - ), NULL, 'boinc:join-page') . '</li>'; |
|
1511 | + ), null, 'boinc:join-page') . '</li>'; |
|
1512 | 1512 | if ($registration_enabled) { |
1513 | 1513 | $output .= '<li>' . bts("If you're running a command-line or pre-5.0 version of BOINC, use <b>!boinccmd</b> to add the project.", |
1514 | 1514 | array( |
1515 | 1515 | '!boinccmd' => l('boinccmd --project_attach', 'http://boinc.berkeley.edu/wiki/Boinccmd_tool'), |
1516 | - ), NULL, 'boinc:join-page') . '</li>'; |
|
1516 | + ), null, 'boinc:join-page') . '</li>'; |
|
1517 | 1517 | } |
1518 | 1518 | else { |
1519 | 1519 | $output .= '<li>' . bts("If you're running a command-line version of BOINC, |
1520 | 1520 | please follow the <b>!instructionslink</b> to first <i>create an account</i>, and then <i>attach</i> to this project. Use the same project URL as above.", |
1521 | 1521 | array( |
1522 | 1522 | '!instructionslink' => l('instructions', 'http://boinc.berkeley.edu/wiki/Boinccmd_tool'), |
1523 | - ), NULL, 'boinc:join-page') . '</li>'; |
|
1523 | + ), null, 'boinc:join-page') . '</li>'; |
|
1524 | 1524 | } |
1525 | 1525 | $output .= '<li>' . bts("If you're running a pre-5.0 version of BOINC, please |
1526 | 1526 | upgrade to a more recent version of BOINC to create an account |
1527 | 1527 | at @this_project.", |
1528 | 1528 | array( |
1529 | 1529 | '@this_project' => $site_name, |
1530 | - ), NULL, 'boinc:join-page') . '</li>'; |
|
1530 | + ), null, 'boinc:join-page') . '</li>'; |
|
1531 | 1531 | $output .= '</ol>'; |
1532 | 1532 | break; |
1533 | 1533 | case 'new': |
@@ -1547,26 +1547,26 @@ discard block |
||
1547 | 1547 | if ($registration_enabled) { |
1548 | 1548 | $output .= '<li>' . bts('First !create_an_account here at @sitename.', |
1549 | 1549 | array( |
1550 | - '!create_an_account' => l(bts('create an account', array(), NULL, 'boinc:join-page'), 'user/registration'), |
|
1550 | + '!create_an_account' => l(bts('create an account', array(), null, 'boinc:join-page'), 'user/registration'), |
|
1551 | 1551 | '@sitename' => $site_name, |
1552 | - ), NULL, 'boinc:join-page') . '</li>'; |
|
1552 | + ), null, 'boinc:join-page') . '</li>'; |
|
1553 | 1553 | } |
1554 | 1554 | else if ( menu_valid_path(array('link_path' => $ruleslink)) ) { |
1555 | 1555 | $output .= ' <li>' . bts("Read our !rules_and_policies.", array( |
1556 | - '!rules_and_policies' => l(bts('Rules and Policies', array(), NULL, 'boinc:join-page'), $ruleslink), |
|
1557 | - ), NULL, 'boinc:join-page') . '</li>'; |
|
1556 | + '!rules_and_policies' => l(bts('Rules and Policies', array(), null, 'boinc:join-page'), $ruleslink), |
|
1557 | + ), null, 'boinc:join-page') . '</li>'; |
|
1558 | 1558 | } |
1559 | - $output .= ' <li>' . bts('Download the BOINC desktop software.', array(), NULL, 'boinc:join-page'); |
|
1559 | + $output .= ' <li>' . bts('Download the BOINC desktop software.', array(), null, 'boinc:join-page'); |
|
1560 | 1560 | $output .= ' <p>'; |
1561 | 1561 | $output .= ' <a class="button" href="http://boinc.berkeley.edu/download.php">Download</a>'; |
1562 | 1562 | $output .= ' </p>'; |
1563 | - $output .= ' ' . bts("For Android devices, download BOINC from the Google Play Store or Amazon App Store.", array(), NULL, 'boinc:join-page'); |
|
1563 | + $output .= ' ' . bts("For Android devices, download BOINC from the Google Play Store or Amazon App Store.", array(), null, 'boinc:join-page'); |
|
1564 | 1564 | $output .= ' </li>'; |
1565 | - $output .= ' <li>' . bts('Run the installer.', array(), NULL, 'boinc:join-page') . '</li>'; |
|
1565 | + $output .= ' <li>' . bts('Run the installer.', array(), null, 'boinc:join-page') . '</li>'; |
|
1566 | 1566 | $output .= ' <li>' . bts('Choose @sitename from the list, or enter @siteurl.', array( |
1567 | 1567 | '@sitename' => $site_name, |
1568 | 1568 | '@siteurl' => $base_url, |
1569 | - ), NULL, 'boinc:join-page') . '</li>'; |
|
1569 | + ), null, 'boinc:join-page') . '</li>'; |
|
1570 | 1570 | $output .= '</ol>'; |
1571 | 1571 | } |
1572 | 1572 | $output .= '</div>'; |
@@ -1597,17 +1597,17 @@ discard block |
||
1597 | 1597 | else { |
1598 | 1598 | $uotd = user_load($current_uotd->uid); |
1599 | 1599 | } |
1600 | - $uotd_image = boincuser_get_user_profile_image($uotd->uid, FALSE); |
|
1600 | + $uotd_image = boincuser_get_user_profile_image($uotd->uid, false); |
|
1601 | 1601 | $output = '<h2 class="pane-title">'; |
1602 | - $output .= ($user->uid) ? bts('Welcome back!', array(), NULL, 'boinc:front-page') : ($site_name ? bts('What is @this_project?', array('@this_project' => $site_name)) : bts('Welcome!', array(), NULL, 'boinc:front-page')); |
|
1602 | + $output .= ($user->uid) ? bts('Welcome back!', array(), null, 'boinc:front-page') : ($site_name ? bts('What is @this_project?', array('@this_project' => $site_name)) : bts('Welcome!', array(), null, 'boinc:front-page')); |
|
1603 | 1603 | $output .= '</h2>'; |
1604 | 1604 | $output .= '<div class="boinc-overview balance-height-front">'; |
1605 | - $output .= ' <div>' . bts($site_message, array(), NULL, "project:front page") . ' ' . l(bts('Learn more', array(), NULL, 'boinc:front-page'), 'about') . '</div>'; |
|
1605 | + $output .= ' <div>' . bts($site_message, array(), null, "project:front page") . ' ' . l(bts('Learn more', array(), null, 'boinc:front-page'), 'about') . '</div>'; |
|
1606 | 1606 | if ($user->uid) { |
1607 | - $output .= ' <div>' . l(bts('View account', array(), NULL, 'boinc:front-page'), 'dashboard', array('attributes' => array('class' => 'join button'))) . '</div>'; |
|
1607 | + $output .= ' <div>' . l(bts('View account', array(), null, 'boinc:front-page'), 'dashboard', array('attributes' => array('class' => 'join button'))) . '</div>'; |
|
1608 | 1608 | } |
1609 | 1609 | else { |
1610 | - $output .= ' <div>' . l(bts('Join now', array(), NULL, 'boinc:front-page'), 'join', array('attributes' => array('class' => 'join button'))) . '</div>'; |
|
1610 | + $output .= ' <div>' . l(bts('Join now', array(), null, 'boinc:front-page'), 'join', array('attributes' => array('class' => 'join button'))) . '</div>'; |
|
1611 | 1611 | } |
1612 | 1612 | $output .= '</div>'; |
1613 | 1613 | $output .= '<div class="boinc-overview-details">'; |
@@ -1615,17 +1615,17 @@ discard block |
||
1615 | 1615 | $output .= ' <a class="user-of-the-day" href="account/' . $uotd->uid . '">'; |
1616 | 1616 | $output .= ' <div class="picture">'; |
1617 | 1617 | $output .= theme('imagefield_image', $uotd_image['image'], $uotd_image['alt'], |
1618 | - $uotd_image['alt'], array(), FALSE); |
|
1618 | + $uotd_image['alt'], array(), false); |
|
1619 | 1619 | $output .= ' </div>'; |
1620 | - $output .= ' <div class="text">' . bts('User of the day', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1620 | + $output .= ' <div class="text">' . bts('User of the day', array(), null, 'boinc:front-page') . '</div>'; |
|
1621 | 1621 | $output .= ' <div class="detail">' . $uotd->boincuser_name . '</div>'; |
1622 | 1622 | $output .= ' </a>'; |
1623 | 1623 | $output .= ' <div class="volunteers">'; |
1624 | - $output .= ' <div class="text">' . bts('Over 500,000 volunteers and counting.', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1624 | + $output .= ' <div class="text">' . bts('Over 500,000 volunteers and counting.', array(), null, 'boinc:front-page') . '</div>'; |
|
1625 | 1625 | $output .= ' <div class="platforms">'; |
1626 | - $output .= ' <div class="detail platform windows">' . bts('Windows', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1627 | - $output .= ' <div class="detail platform mac">' . bts('Mac', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1628 | - $output .= ' <div class="detail platform linux">' . bts('Linux', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1626 | + $output .= ' <div class="detail platform windows">' . bts('Windows', array(), null, 'boinc:front-page') . '</div>'; |
|
1627 | + $output .= ' <div class="detail platform mac">' . bts('Mac', array(), null, 'boinc:front-page') . '</div>'; |
|
1628 | + $output .= ' <div class="detail platform linux">' . bts('Linux', array(), null, 'boinc:front-page') . '</div>'; |
|
1629 | 1629 | $output .= ' </div>'; |
1630 | 1630 | $output .= ' </div>'; |
1631 | 1631 | $output .= ' </div>'; |
@@ -1653,12 +1653,12 @@ discard block |
||
1653 | 1653 | xml_header(); |
1654 | 1654 | |
1655 | 1655 | // Account creation disabled |
1656 | - $enablethisRPC = variable_get('boinc_weboptions_enableaccountcreateRPC', TRUE); |
|
1656 | + $enablethisRPC = variable_get('boinc_weboptions_enableaccountcreateRPC', true); |
|
1657 | 1657 | if (!$enablethisRPC) { |
1658 | 1658 | $mess = bts('Account creation is done through our Web site. Please register at @url', array( |
1659 | 1659 | '@url' => $base_url . '/user/registration', |
1660 | 1660 | ), |
1661 | - NULL, 'boinc:create_account'); |
|
1661 | + null, 'boinc:create_account'); |
|
1662 | 1662 | xml_error(-208, $mess); |
1663 | 1663 | } |
1664 | 1664 | // Invalid invite code |
@@ -1712,7 +1712,7 @@ discard block |
||
1712 | 1712 | 'init' => $params['email_addr'], |
1713 | 1713 | 'roles' => array($unrestricted_role => ''), |
1714 | 1714 | 'boincuser_name' => $params['user_name'], |
1715 | - 'boinchash_flag' => TRUE, |
|
1715 | + 'boinchash_flag' => true, |
|
1716 | 1716 | ); |
1717 | 1717 | |
1718 | 1718 | // Create the drupal user. If the drupal user cannot be created, |
@@ -1749,20 +1749,20 @@ discard block |
||
1749 | 1749 | } |
1750 | 1750 | |
1751 | 1751 | if (strlen($authtoken) != 32) { |
1752 | - drupal_set_message(bts('ERROR: There is no account with that authenticator.', array(), NULL, 'boinc:account-finish'), 'error'); |
|
1752 | + drupal_set_message(bts('ERROR: There is no account with that authenticator.', array(), null, 'boinc:account-finish'), 'error'); |
|
1753 | 1753 | drupal_goto(); |
1754 | 1754 | } |
1755 | 1755 | |
1756 | 1756 | require_boinc('boinc_db'); |
1757 | 1757 | $boinc_user = BoincUser::lookup("authenticator='".addslashes($authtoken)."'"); |
1758 | 1758 | if (!$boinc_user) { |
1759 | - drupal_set_message(bts('ERROR: There is no account with that authenticator.', array(), NULL, 'boinc:account-finish'), 'error'); |
|
1759 | + drupal_set_message(bts('ERROR: There is no account with that authenticator.', array(), null, 'boinc:account-finish'), 'error'); |
|
1760 | 1760 | drupal_goto(); |
1761 | 1761 | } |
1762 | 1762 | $user = user_load(get_drupal_id($boinc_user->id)); |
1763 | 1763 | |
1764 | 1764 | if (!$user) { |
1765 | - drupal_set_message(bts('ERROR: There was a problem loading your account. Try logging in with your user name and password.', array(), NULL, 'boinc:account-finish'), 'error'); |
|
1765 | + drupal_set_message(bts('ERROR: There was a problem loading your account. Try logging in with your user name and password.', array(), null, 'boinc:account-finish'), 'error'); |
|
1766 | 1766 | drupal_goto(); |
1767 | 1767 | } |
1768 | 1768 | |
@@ -1783,9 +1783,9 @@ discard block |
||
1783 | 1783 | // Check moderation page exists |
1784 | 1784 | $moderationpath = drupal_lookup_path('source', variable_get('boinc_weboptions_moderationpage', '') ); |
1785 | 1785 | if ( menu_valid_path(array('link_path' => $moderationpath)) ) { |
1786 | - $modsentence = bts('Please note: user profiles are subject to !moderation.', array('!moderation' => l(bts('moderation', array(), NULL, 'boinc:account-finish'), $moderationpath, $options)), NULL, 'boinc:account-finish'); |
|
1786 | + $modsentence = bts('Please note: user profiles are subject to !moderation.', array('!moderation' => l(bts('moderation', array(), null, 'boinc:account-finish'), $moderationpath, $options)), null, 'boinc:account-finish'); |
|
1787 | 1787 | } else { |
1788 | - $modsentence = bts('Please note: user profiles are subject to moderation.', array(), NULL, 'boinc:account-finish'); |
|
1788 | + $modsentence = bts('Please note: user profiles are subject to moderation.', array(), null, 'boinc:account-finish'); |
|
1789 | 1789 | } |
1790 | 1790 | |
1791 | 1791 | $username = $user->boincuser_name; |
@@ -1794,73 +1794,73 @@ discard block |
||
1794 | 1794 | array( |
1795 | 1795 | '@user_name' => $username, |
1796 | 1796 | '@site_name' => $site_name, |
1797 | - ), NULL, 'boinc:account-finish') . "</p>"; |
|
1797 | + ), null, 'boinc:account-finish') . "</p>"; |
|
1798 | 1798 | |
1799 | 1799 | $links = array( |
1800 | 1800 | array( |
1801 | 1801 | 'data' => bts('Change your username at !community_preferences.', array( |
1802 | - '!community_preferences' => l(bts('Community Preferences', array(), NULL, 'boinc:account-fininsh'), 'account/prefs/community', $options), |
|
1803 | - ), NULL, 'boinc:account-finish'), |
|
1802 | + '!community_preferences' => l(bts('Community Preferences', array(), null, 'boinc:account-fininsh'), 'account/prefs/community', $options), |
|
1803 | + ), null, 'boinc:account-finish'), |
|
1804 | 1804 | 'children' => array( |
1805 | - bts('Your username is used to identify yourself to other volunteers on this Web site.', array(), NULL, 'boinc:account-finish'), |
|
1806 | - bts('In addition, you may set your account\'s default language and adjust notification settings.', array(), NULL, 'boinc:account-finish'), |
|
1805 | + bts('Your username is used to identify yourself to other volunteers on this Web site.', array(), null, 'boinc:account-finish'), |
|
1806 | + bts('In addition, you may set your account\'s default language and adjust notification settings.', array(), null, 'boinc:account-finish'), |
|
1807 | 1807 | ), |
1808 | 1808 | ), |
1809 | 1809 | array( |
1810 | 1810 | 'data' => bts('Change your !computing_preferences.', array( |
1811 | - '!computing_preferences' => l(bts('Computing Preferences', array(), NULL, 'boinc:account-finish'), 'account/prefs', $options), |
|
1812 | - ), NULL, 'boinc:account-finish'), |
|
1811 | + '!computing_preferences' => l(bts('Computing Preferences', array(), null, 'boinc:account-finish'), 'account/prefs', $options), |
|
1812 | + ), null, 'boinc:account-finish'), |
|
1813 | 1813 | 'children' => array( |
1814 | - bts('You may adjust how much CPU, RAM, and Disk space the BOINC client is allowed to use for tasks on your computer.', array(), NULL, 'boinc:account-finish'), |
|
1814 | + bts('You may adjust how much CPU, RAM, and Disk space the BOINC client is allowed to use for tasks on your computer.', array(), null, 'boinc:account-finish'), |
|
1815 | 1815 | bts('By default, you will run @site_name tasks without any additional configuration.', array( |
1816 | 1816 | '@site_name' => $site_name, |
1817 | - ), NULL, 'boinc:account-finish'), |
|
1817 | + ), null, 'boinc:account-finish'), |
|
1818 | 1818 | bts('It is recommended new volunteers leave the default settings until they gain experience running some tasks. Ask questions in the !forums to get advice before making changes to a setting you don\'t understand.', array( |
1819 | - '!forums' => l(bts('forums', array(), NULL, 'boinc:account-finish'), 'community/forum', $options), |
|
1820 | - ), NULL, 'boinc:account-finish'), |
|
1819 | + '!forums' => l(bts('forums', array(), null, 'boinc:account-finish'), 'community/forum', $options), |
|
1820 | + ), null, 'boinc:account-finish'), |
|
1821 | 1821 | ), |
1822 | 1822 | ), |
1823 | 1823 | array( |
1824 | 1824 | 'data' => bts('Create a !user_profile.', array( |
1825 | - '!user_profile' => l(bts('User Profile', array(), NULL, 'boinc:account-finish'), '/account/profile/edit', $options), |
|
1826 | - ), NULL, 'boinc:account-finish'), |
|
1825 | + '!user_profile' => l(bts('User Profile', array(), null, 'boinc:account-finish'), '/account/profile/edit', $options), |
|
1826 | + ), null, 'boinc:account-finish'), |
|
1827 | 1827 | 'children' => array( |
1828 | 1828 | bts('A user profile will inform other volunteers who you are and why you joined @site_name.', array( |
1829 | 1829 | '@site_name' => $site_name, |
1830 | - ), NULL, 'boinc:account-finish'), |
|
1830 | + ), null, 'boinc:account-finish'), |
|
1831 | 1831 | $modsentence, |
1832 | 1832 | ), |
1833 | 1833 | ), |
1834 | 1834 | array( |
1835 | 1835 | 'data' => bts('Join a !team.', array( |
1836 | - '!team' => l(bts('Team', array(), NULL, 'boinc:account-finish'), '/community/teams', $options), |
|
1837 | - ), NULL, 'boinc:account-finish'), |
|
1836 | + '!team' => l(bts('Team', array(), null, 'boinc:account-finish'), '/community/teams', $options), |
|
1837 | + ), null, 'boinc:account-finish'), |
|
1838 | 1838 | 'children' => array( |
1839 | - bts('You may join a team, made up of other volunteers.', array(), NULL, 'boinc:account-finish'), |
|
1839 | + bts('You may join a team, made up of other volunteers.', array(), null, 'boinc:account-finish'), |
|
1840 | 1840 | ), |
1841 | 1841 | ), |
1842 | 1842 | array( |
1843 | 1843 | 'data' => bts('Go to your !account_dashboard.', array( |
1844 | - '!account_dashboard'=> l(bts('Account Dashboard', array(), NULL, 'boinc:account-finish'), 'account/dashboard', $options), |
|
1845 | - ), NULL, 'boinc:account-finish'), |
|
1844 | + '!account_dashboard'=> l(bts('Account Dashboard', array(), null, 'boinc:account-finish'), 'account/dashboard', $options), |
|
1845 | + ), null, 'boinc:account-finish'), |
|
1846 | 1846 | 'children' => array( |
1847 | - bts('Your account dashboard has information and links about your computer(s) and task(s) assigned.', array(), NULL, 'boinc:account-finish'), |
|
1847 | + bts('Your account dashboard has information and links about your computer(s) and task(s) assigned.', array(), null, 'boinc:account-finish'), |
|
1848 | 1848 | ), |
1849 | 1849 | ), |
1850 | 1850 | array( |
1851 | 1851 | 'data' => bts('Visit our !help pages.', array( |
1852 | - '!help' => l(bts('Help', array(), NULL, 'boinc:account-finish'), '/help', $options) |
|
1853 | - ), NULL, 'boinc:account-finish'), |
|
1852 | + '!help' => l(bts('Help', array(), null, 'boinc:account-finish'), '/help', $options) |
|
1853 | + ), null, 'boinc:account-finish'), |
|
1854 | 1854 | 'children' => array( |
1855 | 1855 | bts('Ask for help in our community\'s !forums.', array( |
1856 | - '!forums' => l(bts('forums', array(), NULL, 'boinc:account-finish'), 'community/forum', $options) |
|
1857 | - ), NULL, 'boinc:account-finish'), |
|
1856 | + '!forums' => l(bts('forums', array(), null, 'boinc:account-finish'), 'community/forum', $options) |
|
1857 | + ), null, 'boinc:account-finish'), |
|
1858 | 1858 | ), |
1859 | 1859 | ), |
1860 | 1860 | ); |
1861 | 1861 | |
1862 | 1862 | //List of links |
1863 | - $output .= theme_item_list($links, $title = NULL, $type='ul'); |
|
1863 | + $output .= theme_item_list($links, $title = null, $type='ul'); |
|
1864 | 1864 | |
1865 | 1865 | return $output; |
1866 | 1866 | } |
@@ -1870,20 +1870,20 @@ discard block |
||
1870 | 1870 | */ |
1871 | 1871 | function boincuser_moderate_community_access() { |
1872 | 1872 | if (user_access('assign community member role') |
1873 | - OR user_access('assign all roles')) { |
|
1874 | - return TRUE; |
|
1873 | + or user_access('assign all roles')) { |
|
1874 | + return true; |
|
1875 | 1875 | } |
1876 | - return FALSE; |
|
1876 | + return false; |
|
1877 | 1877 | } |
1878 | 1878 | |
1879 | 1879 | /** |
1880 | 1880 | * Get the count of items in the moderation queue |
1881 | 1881 | */ |
1882 | 1882 | function boincuser_moderation_queue_count($caller = 'user') { |
1883 | - $allowed = FALSE; |
|
1883 | + $allowed = false; |
|
1884 | 1884 | switch ($caller) { |
1885 | 1885 | case 'cron': |
1886 | - $allowed = TRUE; |
|
1886 | + $allowed = true; |
|
1887 | 1887 | break; |
1888 | 1888 | case 'user': |
1889 | 1889 | default: |
@@ -1897,7 +1897,7 @@ discard block |
||
1897 | 1897 | AND moderate = 1" |
1898 | 1898 | )); |
1899 | 1899 | } |
1900 | - return NULL; |
|
1900 | + return null; |
|
1901 | 1901 | } |
1902 | 1902 | |
1903 | 1903 | /** |
@@ -1905,10 +1905,10 @@ discard block |
||
1905 | 1905 | * Allow community membership status to be set for users by direct link rather |
1906 | 1906 | * than through the user account info form. |
1907 | 1907 | */ |
1908 | -function boincuser_control($uid = NULL, $action = NULL) { |
|
1909 | - if (!$uid OR !$account = user_load($uid)) { |
|
1908 | +function boincuser_control($uid = null, $action = null) { |
|
1909 | + if (!$uid or !$account = user_load($uid)) { |
|
1910 | 1910 | // What are you even doing here... |
1911 | - return FALSE; |
|
1911 | + return false; |
|
1912 | 1912 | } |
1913 | 1913 | switch ($action) { |
1914 | 1914 | case 'ban': |
@@ -2014,7 +2014,7 @@ discard block |
||
2014 | 2014 | */ |
2015 | 2015 | function boincuser_moderate_user_ban($uid, $reason = '', $duration = '') { |
2016 | 2016 | if (user_access('assign community member role') |
2017 | - OR user_access('assign all roles')) { |
|
2017 | + or user_access('assign all roles')) { |
|
2018 | 2018 | $account = user_load($uid); |
2019 | 2019 | if ($account->uid) { |
2020 | 2020 | module_load_include('inc', 'rules', 'modules/system.rules'); |
@@ -2094,7 +2094,7 @@ discard block |
||
2094 | 2094 | * User profile image is managed by the content_profile module rather than core |
2095 | 2095 | * Drupal User so must be inserted into comments, etc. (not so by default) |
2096 | 2096 | */ |
2097 | -function boincuser_get_user_profile_image($uid, $avatar = TRUE) { |
|
2097 | +function boincuser_get_user_profile_image($uid, $avatar = true) { |
|
2098 | 2098 | // Though the function name implies otherwise, get the avatar by default |
2099 | 2099 | $image_field = ($avatar) ? 'field_image_fid' : 'field_profile_image_fid'; |
2100 | 2100 | $image_fid = db_result(db_query(" |
@@ -2107,7 +2107,7 @@ discard block |
||
2107 | 2107 | if (!$user_image['image']['filepath']) { |
2108 | 2108 | // Load the default image if one does not exist |
2109 | 2109 | $account = user_load($uid); |
2110 | - if ($avatar AND module_exists('gravatar') AND user_access('use gravatar', $account) AND $account->gravatar) { |
|
2110 | + if ($avatar and module_exists('gravatar') and user_access('use gravatar', $account) and $account->gravatar) { |
|
2111 | 2111 | // Use a Gravatar rather than the system default image |
2112 | 2112 | $options = array( |
2113 | 2113 | 'size' => 100, |
@@ -2135,23 +2135,23 @@ discard block |
||
2135 | 2135 | * Generate a table of a user's projects |
2136 | 2136 | */ |
2137 | 2137 | function boincuser_get_projects_table($account = null) { |
2138 | - if ($account AND is_numeric($account)) { |
|
2138 | + if ($account and is_numeric($account)) { |
|
2139 | 2139 | $account = user_load($account); |
2140 | 2140 | } |
2141 | 2141 | $projects = boincuser_get_projects($account); |
2142 | - if (!$projects) return bts('no projects...', array(), NULL, 'boinc:account-dashboard'); |
|
2142 | + if (!$projects) return bts('no projects...', array(), null, 'boinc:account-dashboard'); |
|
2143 | 2143 | |
2144 | 2144 | $output = ''; |
2145 | 2145 | $output .= '<table class="user-projects">' . "\n"; |
2146 | 2146 | $output .= '<thead>' . "\n"; |
2147 | 2147 | $output .= ' <tr>' . "\n"; |
2148 | - $output .= ' <th>' . bts('Name', array(), NULL, 'boinc:project-name:-1:ignoreoverwrite') . '</th>' . "\n"; |
|
2149 | - $output .= ' <th class="numeric">' . bts('Avg credit', array(), NULL, 'boinc:account-dashboard') . '</th>' . "\n"; |
|
2150 | - $output .= ' <th class="numeric">' . bts('Total credit', array(), NULL, 'boinc:user-or-team-total-credits') . '</th>' . "\n"; |
|
2148 | + $output .= ' <th>' . bts('Name', array(), null, 'boinc:project-name:-1:ignoreoverwrite') . '</th>' . "\n"; |
|
2149 | + $output .= ' <th class="numeric">' . bts('Avg credit', array(), null, 'boinc:account-dashboard') . '</th>' . "\n"; |
|
2150 | + $output .= ' <th class="numeric">' . bts('Total credit', array(), null, 'boinc:user-or-team-total-credits') . '</th>' . "\n"; |
|
2151 | 2151 | $output .= ' </tr>' . "\n"; |
2152 | 2152 | $output .= '</thead>' . "\n"; |
2153 | 2153 | $output .= '<tbody>' . "\n"; |
2154 | - foreach ($projects AS $project) { |
|
2154 | + foreach ($projects as $project) { |
|
2155 | 2155 | $url = rtrim($project->url, '/') . '/show_user.php?userid=' . $project->id; |
2156 | 2156 | $output .= ' <tr>' . "\n"; |
2157 | 2157 | $output .= ' <td>' . l($project->name, $url) . '</td>' . "\n"; |
@@ -2189,7 +2189,7 @@ discard block |
||
2189 | 2189 | if (in_array($result->code, array(200, 304))) { |
2190 | 2190 | return simplexml_load_string($result->data); |
2191 | 2191 | } |
2192 | - return NULL; |
|
2192 | + return null; |
|
2193 | 2193 | } |
2194 | 2194 | |
2195 | 2195 | /** |
@@ -2205,7 +2205,7 @@ discard block |
||
2205 | 2205 | |
2206 | 2206 | $account_stats = boincuser_get_stats_user_data($account->boincuser_cpid); |
2207 | 2207 | |
2208 | - return ($account_stats AND isset($account_stats->project)) ? $account_stats->project : null; |
|
2208 | + return ($account_stats and isset($account_stats->project)) ? $account_stats->project : null; |
|
2209 | 2209 | } |
2210 | 2210 | |
2211 | 2211 | |
@@ -2218,18 +2218,18 @@ discard block |
||
2218 | 2218 | $profile = content_profile_load('profile', $account->uid); |
2219 | 2219 | $output = ''; |
2220 | 2220 | if ($profile) { |
2221 | - $profile_is_approved = ($profile->status AND !$profile->moderate); |
|
2221 | + $profile_is_approved = ($profile->status and !$profile->moderate); |
|
2222 | 2222 | $user_is_moderator = user_access('edit any profile content'); |
2223 | 2223 | $is_own_profile = ($user->uid == $account->uid); |
2224 | 2224 | $profile_moderation_path = "moderate/profile/{$account->uid}"; |
2225 | 2225 | $links = array(); |
2226 | 2226 | |
2227 | - if ($profile->moderate AND $user_is_moderator) { |
|
2227 | + if ($profile->moderate and $user_is_moderator) { |
|
2228 | 2228 | $links['approve_profile'] = array( |
2229 | - 'title' => bts('Approve profile', array(), NULL, 'boinc:moderate-user'), |
|
2229 | + 'title' => bts('Approve profile', array(), null, 'boinc:moderate-user'), |
|
2230 | 2230 | 'href' => "{$profile_moderation_path}/approve", |
2231 | 2231 | 'attributes' => array( |
2232 | - 'title' => bts('Approve this profile content', array(), NULL, 'boinc:moderate-user'), |
|
2232 | + 'title' => bts('Approve this profile content', array(), null, 'boinc:moderate-user'), |
|
2233 | 2233 | 'class' => 'first primary tab', |
2234 | 2234 | ) |
2235 | 2235 | ); |
@@ -2242,10 +2242,10 @@ discard block |
||
2242 | 2242 | ) |
2243 | 2243 | );*/ |
2244 | 2244 | $links['reject_profile'] = array( |
2245 | - 'title' => bts('Reject profile', array(), NULL, 'boinc:moderate-user'), |
|
2245 | + 'title' => bts('Reject profile', array(), null, 'boinc:moderate-user'), |
|
2246 | 2246 | 'href' => "{$profile_moderation_path}/reject", |
2247 | 2247 | 'attributes' => array( |
2248 | - 'title' => bts('Reject this profile content', array(), NULL, 'boinc:moderate-user'), |
|
2248 | + 'title' => bts('Reject this profile content', array(), null, 'boinc:moderate-user'), |
|
2249 | 2249 | 'class' => 'tab', |
2250 | 2250 | ) |
2251 | 2251 | ); |
@@ -2299,7 +2299,7 @@ discard block |
||
2299 | 2299 | function boincuser_apachesolr_index_documents_alter(array &$documents, $entity, $entity_type, $env_id) { |
2300 | 2300 | |
2301 | 2301 | foreach ($documents as $document) { |
2302 | - if ( $document->entity_type=='node' AND $document->bundle=='profile' ) { |
|
2302 | + if ( $document->entity_type=='node' and $document->bundle=='profile' ) { |
|
2303 | 2303 | // Node information. |
2304 | 2304 | $nid = $document->entity_id; |
2305 | 2305 | $node = node_load($nid); |
@@ -2353,7 +2353,7 @@ discard block |
||
2353 | 2353 | if ($recipient = user_load(array('uid' => $drupalid))) { |
2354 | 2354 | // Double-check that the loaded user matches both boincuser_id |
2355 | 2355 | // and boincuser_name. |
2356 | - if ( ($boincid == $recipient->boincuser_id) AND ($boincname == $recipient->boincuser_name) ) { |
|
2356 | + if ( ($boincid == $recipient->boincuser_id) and ($boincname == $recipient->boincuser_name) ) { |
|
2357 | 2357 | return $recipient; |
2358 | 2358 | } |
2359 | 2359 | } |
@@ -27,287 +27,287 @@ 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 callback' => 'user_is_logged_in', |
|
57 | - 'type' => MENU_LOCAL_TASK, |
|
58 | - 'weight' => 5 |
|
59 | - ); |
|
60 | - $items['account/team'] = array( |
|
61 | - 'title' => 'User team', |
|
62 | - 'description' => '', |
|
63 | - 'page callback' => 'boincuser_goto_team', |
|
64 | - 'access callback' => 'user_is_logged_in', |
|
65 | - 'type' => MENU_CALLBACK, |
|
66 | - ); |
|
67 | - $items['moderate/profile/%user/approve'] = array( |
|
68 | - 'title' => 'Profile approval', |
|
69 | - 'description' => 'Approve profile content', |
|
70 | - 'page callback' => 'boincuser_moderate_profile_approve', |
|
71 | - 'page arguments' => array(2), |
|
72 | - 'access arguments' => array('edit any profile content'), |
|
73 | - 'type' => MENU_CALLBACK, |
|
74 | - 'weight' => 5 |
|
75 | - ); |
|
76 | - $items['moderate/profile/%user/edit'] = array( |
|
77 | - 'title' => 'Profile editor', |
|
78 | - 'description' => 'Edit a user profile', |
|
79 | - 'page callback' => 'boincuser_edit_profile', |
|
80 | - 'page arguments' => array(2), |
|
81 | - 'access arguments' => array('edit any profile content'), |
|
82 | - 'type' => MENU_CALLBACK, |
|
83 | - 'weight' => 5 |
|
84 | - ); |
|
85 | - $items['moderate/profile/%/reject'] = array( |
|
86 | - 'title' => bts('Reject profile', array(), NULL, 'boinc:moderate-user'), |
|
87 | - 'description' => 'Reject profile content', |
|
88 | - 'page callback' => 'drupal_get_form', |
|
89 | - 'page arguments' => array('boincuser_moderate_profile_reject_form', 2), |
|
90 | - 'access arguments' => array('edit any profile content'), |
|
91 | - 'type' => MENU_CALLBACK, |
|
92 | - 'weight' => 5 |
|
93 | - ); |
|
94 | - $items['moderate/user/%/ban'] = array( |
|
95 | - 'title' => bts('Ban user', array(), NULL, 'boinc:moderate-ban-user'), |
|
96 | - 'description' => 'Ban a user from using community features', |
|
97 | - 'page callback' => 'drupal_get_form', |
|
98 | - 'page arguments' => array('boincuser_moderate_user_ban_form', 2), |
|
99 | - 'access callback' => 'boincuser_moderate_community_access', |
|
100 | - 'type' => MENU_CALLBACK, |
|
101 | - ); |
|
102 | - $items['join'] = array( |
|
103 | - 'title' => '', |
|
104 | - 'description' => '', |
|
105 | - 'page callback' => 'join_page', |
|
106 | - 'access arguments' => array('access content'), |
|
107 | - 'type' => MENU_NORMAL_ITEM |
|
108 | - ); |
|
109 | - $items['join/new'] = array( |
|
110 | - 'title' => bts("I'm new"), |
|
111 | - 'page callback' => 'join_page', |
|
112 | - 'page arguments' => array(1), |
|
113 | - 'access arguments' => array('access content'), |
|
114 | - 'type' => MENU_DEFAULT_LOCAL_TASK, |
|
115 | - 'weight' => 0 |
|
116 | - ); |
|
117 | - $items['join/boinc'] = array( |
|
118 | - 'title' => bts("I'm a BOINC user"), |
|
119 | - 'page callback' => 'join_page', |
|
120 | - 'page arguments' => array(1), |
|
121 | - 'access arguments' => array('access content'), |
|
122 | - 'type' => MENU_LOCAL_TASK, |
|
123 | - 'weight' => 5 |
|
124 | - ); |
|
125 | - $items['user/login/auth'] = array( |
|
126 | - 'title' => bts('Authenticator login', array(), NULL, 'boinc:authenticator-login-page'), |
|
127 | - 'description' => 'Log in using a user authenticator', |
|
128 | - 'page callback' => 'drupal_get_form', |
|
129 | - 'page arguments' => array('boincuser_authloginform'), |
|
130 | - 'access arguments' => array('access content'), |
|
131 | - 'type' => MENU_CALLBACK, |
|
132 | - ); |
|
133 | - $items['user/termsofuse'] = array( |
|
134 | - 'title' => bts('Terms of Use', array(), NULL, 'boinc:termsofuse-form'), |
|
135 | - 'description' => 'A site\'s term of use.', |
|
136 | - 'page callback' => 'drupal_get_form', |
|
137 | - 'page arguments' => array('boincuser_termsofuse_form'), |
|
138 | - 'access callback' => 'user_is_logged_in', |
|
139 | - 'type' => MENU_CALLBACK, |
|
140 | - ); |
|
141 | - $items['user_control'] = array( |
|
142 | - 'page callback' => 'boincuser_control', |
|
143 | - 'access arguments' => array('access user profiles'), |
|
144 | - 'type' => MENU_CALLBACK |
|
145 | - ); |
|
146 | - $items['admin/boinc'] = array( |
|
147 | - 'title' => 'BOINC configuration', |
|
148 | - 'position' => 'right', |
|
149 | - 'weight' => -8, |
|
150 | - 'page callback' => 'system_admin_menu_block_page', |
|
151 | - 'access arguments' => array('administer site configuration'), |
|
152 | - 'file' => 'system.admin.inc', |
|
153 | - 'file path' => drupal_get_path('module', 'system'), |
|
154 | - ); |
|
155 | - $items['admin/boinc/environment'] = array( |
|
156 | - 'title' => 'Environment: General', |
|
157 | - 'description' => 'Set paths to BOINC functions and any other necessary |
|
30 | +$items['account/posts'] = array( |
|
31 | +'title' => 'Recent posts', |
|
32 | +'description' => '', |
|
33 | +'page callback' => 'boincuser_goto_recent_posts', |
|
34 | +'access callback' => 'user_is_logged_in', |
|
35 | +'type' => MENU_CALLBACK, |
|
36 | +); |
|
37 | +$items['account/profile'] = array( |
|
38 | +'title' => '', |
|
39 | +'description' => '', |
|
40 | +'page callback' => 'boincuser_view_profile', |
|
41 | +'access callback' => 'user_is_logged_in', |
|
42 | +'type' => MENU_NORMAL_ITEM |
|
43 | +); |
|
44 | +$items['account/profile/view'] = array( |
|
45 | +'title' => 'View', |
|
46 | +'description' => 'Show a user profile', |
|
47 | +'page callback' => 'boincuser_view_profile', |
|
48 | +'access callback' => 'user_is_logged_in', |
|
49 | +'type' => MENU_DEFAULT_LOCAL_TASK, |
|
50 | +'weight' => 0 |
|
51 | +); |
|
52 | +$items['account/profile/edit'] = array( |
|
53 | +'title' => 'Edit', |
|
54 | +'description' => 'Edit a user profile', |
|
55 | +'page callback' => 'boincuser_edit_profile', |
|
56 | +'access callback' => 'user_is_logged_in', |
|
57 | +'type' => MENU_LOCAL_TASK, |
|
58 | +'weight' => 5 |
|
59 | +); |
|
60 | +$items['account/team'] = array( |
|
61 | +'title' => 'User team', |
|
62 | +'description' => '', |
|
63 | +'page callback' => 'boincuser_goto_team', |
|
64 | +'access callback' => 'user_is_logged_in', |
|
65 | +'type' => MENU_CALLBACK, |
|
66 | +); |
|
67 | +$items['moderate/profile/%user/approve'] = array( |
|
68 | +'title' => 'Profile approval', |
|
69 | +'description' => 'Approve profile content', |
|
70 | +'page callback' => 'boincuser_moderate_profile_approve', |
|
71 | +'page arguments' => array(2), |
|
72 | +'access arguments' => array('edit any profile content'), |
|
73 | +'type' => MENU_CALLBACK, |
|
74 | +'weight' => 5 |
|
75 | +); |
|
76 | +$items['moderate/profile/%user/edit'] = array( |
|
77 | +'title' => 'Profile editor', |
|
78 | +'description' => 'Edit a user profile', |
|
79 | +'page callback' => 'boincuser_edit_profile', |
|
80 | +'page arguments' => array(2), |
|
81 | +'access arguments' => array('edit any profile content'), |
|
82 | +'type' => MENU_CALLBACK, |
|
83 | +'weight' => 5 |
|
84 | +); |
|
85 | +$items['moderate/profile/%/reject'] = array( |
|
86 | +'title' => bts('Reject profile', array(), NULL, 'boinc:moderate-user'), |
|
87 | +'description' => 'Reject profile content', |
|
88 | +'page callback' => 'drupal_get_form', |
|
89 | +'page arguments' => array('boincuser_moderate_profile_reject_form', 2), |
|
90 | +'access arguments' => array('edit any profile content'), |
|
91 | +'type' => MENU_CALLBACK, |
|
92 | +'weight' => 5 |
|
93 | +); |
|
94 | +$items['moderate/user/%/ban'] = array( |
|
95 | +'title' => bts('Ban user', array(), NULL, 'boinc:moderate-ban-user'), |
|
96 | +'description' => 'Ban a user from using community features', |
|
97 | +'page callback' => 'drupal_get_form', |
|
98 | +'page arguments' => array('boincuser_moderate_user_ban_form', 2), |
|
99 | +'access callback' => 'boincuser_moderate_community_access', |
|
100 | +'type' => MENU_CALLBACK, |
|
101 | +); |
|
102 | +$items['join'] = array( |
|
103 | +'title' => '', |
|
104 | +'description' => '', |
|
105 | +'page callback' => 'join_page', |
|
106 | +'access arguments' => array('access content'), |
|
107 | +'type' => MENU_NORMAL_ITEM |
|
108 | +); |
|
109 | +$items['join/new'] = array( |
|
110 | +'title' => bts("I'm new"), |
|
111 | +'page callback' => 'join_page', |
|
112 | +'page arguments' => array(1), |
|
113 | +'access arguments' => array('access content'), |
|
114 | +'type' => MENU_DEFAULT_LOCAL_TASK, |
|
115 | +'weight' => 0 |
|
116 | +); |
|
117 | +$items['join/boinc'] = array( |
|
118 | +'title' => bts("I'm a BOINC user"), |
|
119 | +'page callback' => 'join_page', |
|
120 | +'page arguments' => array(1), |
|
121 | +'access arguments' => array('access content'), |
|
122 | +'type' => MENU_LOCAL_TASK, |
|
123 | +'weight' => 5 |
|
124 | +); |
|
125 | +$items['user/login/auth'] = array( |
|
126 | +'title' => bts('Authenticator login', array(), NULL, 'boinc:authenticator-login-page'), |
|
127 | +'description' => 'Log in using a user authenticator', |
|
128 | +'page callback' => 'drupal_get_form', |
|
129 | +'page arguments' => array('boincuser_authloginform'), |
|
130 | +'access arguments' => array('access content'), |
|
131 | +'type' => MENU_CALLBACK, |
|
132 | +); |
|
133 | +$items['user/termsofuse'] = array( |
|
134 | +'title' => bts('Terms of Use', array(), NULL, 'boinc:termsofuse-form'), |
|
135 | +'description' => 'A site\'s term of use.', |
|
136 | +'page callback' => 'drupal_get_form', |
|
137 | +'page arguments' => array('boincuser_termsofuse_form'), |
|
138 | +'access callback' => 'user_is_logged_in', |
|
139 | +'type' => MENU_CALLBACK, |
|
140 | +); |
|
141 | +$items['user_control'] = array( |
|
142 | +'page callback' => 'boincuser_control', |
|
143 | +'access arguments' => array('access user profiles'), |
|
144 | +'type' => MENU_CALLBACK |
|
145 | +); |
|
146 | +$items['admin/boinc'] = array( |
|
147 | +'title' => 'BOINC configuration', |
|
148 | +'position' => 'right', |
|
149 | +'weight' => -8, |
|
150 | +'page callback' => 'system_admin_menu_block_page', |
|
151 | +'access arguments' => array('administer site configuration'), |
|
152 | +'file' => 'system.admin.inc', |
|
153 | +'file path' => drupal_get_path('module', 'system'), |
|
154 | +); |
|
155 | +$items['admin/boinc/environment'] = array( |
|
156 | +'title' => 'Environment: General', |
|
157 | +'description' => 'Set paths to BOINC functions and any other necessary |
|
158 | 158 | variables that establish a BOINC environment.', |
159 | - 'page callback' => 'drupal_get_form', |
|
160 | - 'page arguments' => array('boincuser_admin_environment'), |
|
161 | - 'access arguments' => array('administer site configuration'), |
|
162 | - 'type' => MENU_NORMAL_ITEM, |
|
163 | - 'file' => 'boincuser.admin.inc' |
|
164 | - ); |
|
165 | - $items['admin/boinc/scheduler'] = array( |
|
166 | - 'title' => 'Environment: Scheduling server URLs', |
|
167 | - 'description' => 'Set BOINC scheduler options.', |
|
168 | - 'page callback' => 'drupal_get_form', |
|
169 | - 'page arguments' => array('boincuser_admin_scheduler'), |
|
170 | - 'access arguments' => array('administer site configuration'), |
|
171 | - 'type' => MENU_NORMAL_ITEM, |
|
172 | - 'file' => 'boincuser.admin.inc' |
|
173 | - ); |
|
174 | - $items['admin/boinc/weboptions'] = array( |
|
175 | - 'title' => 'Environment: Website Options', |
|
176 | - 'description' => 'Set options configuring this Drupal-BOINC Web site.', |
|
177 | - 'page callback' => 'drupal_get_form', |
|
178 | - 'page arguments' => array('boincuser_admin_weboptions'), |
|
179 | - 'access arguments' => array('administer site configuration'), |
|
180 | - 'type' => MENU_NORMAL_ITEM, |
|
181 | - 'file' => 'boincuser.admin.inc' |
|
182 | - ); |
|
159 | +'page callback' => 'drupal_get_form', |
|
160 | +'page arguments' => array('boincuser_admin_environment'), |
|
161 | +'access arguments' => array('administer site configuration'), |
|
162 | +'type' => MENU_NORMAL_ITEM, |
|
163 | +'file' => 'boincuser.admin.inc' |
|
164 | +); |
|
165 | +$items['admin/boinc/scheduler'] = array( |
|
166 | +'title' => 'Environment: Scheduling server URLs', |
|
167 | +'description' => 'Set BOINC scheduler options.', |
|
168 | +'page callback' => 'drupal_get_form', |
|
169 | +'page arguments' => array('boincuser_admin_scheduler'), |
|
170 | +'access arguments' => array('administer site configuration'), |
|
171 | +'type' => MENU_NORMAL_ITEM, |
|
172 | +'file' => 'boincuser.admin.inc' |
|
173 | +); |
|
174 | +$items['admin/boinc/weboptions'] = array( |
|
175 | +'title' => 'Environment: Website Options', |
|
176 | +'description' => 'Set options configuring this Drupal-BOINC Web site.', |
|
177 | +'page callback' => 'drupal_get_form', |
|
178 | +'page arguments' => array('boincuser_admin_weboptions'), |
|
179 | +'access arguments' => array('administer site configuration'), |
|
180 | +'type' => MENU_NORMAL_ITEM, |
|
181 | +'file' => 'boincuser.admin.inc' |
|
182 | +); |
|
183 | 183 | |
184 | - $items['create_account.php'] = array( |
|
185 | - 'title' => 'Create Account RPC', |
|
186 | - 'description' => 'RPC for creating user accounts.', |
|
187 | - 'page callback' => 'boincuser_create_account', |
|
188 | - 'access callback' => TRUE, |
|
189 | - 'type' => MENU_CALLBACK |
|
190 | - ); |
|
191 | - $items['account_finish.php'] = array( |
|
192 | - 'title' => 'Welcome to ' . variable_get('site_name', 'Drupal-BOINC'), |
|
193 | - 'description' => 'RPC for after a user has created an account.', |
|
194 | - 'page callback' => 'boincuser_account_finish', |
|
195 | - 'access callback' => TRUE, |
|
196 | - 'type' => MENU_CALLBACK, |
|
197 | - ); |
|
198 | - $items['boincuser/autocomplete'] = array( |
|
199 | - 'page callback' => '_boincuser_user_name_autocomplete', |
|
200 | - 'access callback' => TRUE, |
|
201 | - 'type' => MENU_CALLBACK, |
|
202 | - ); |
|
203 | - $items['user/%user/recoveremail/%'] = array( |
|
204 | - 'title' => t('Recover previous email'), |
|
205 | - 'description' => t('Form to revert email to previous address.'), |
|
206 | - 'page callback' => 'drupal_get_form', |
|
207 | - 'page arguments' => array('boincuser_revertemail', 3), |
|
208 | - 'access callback' => 'user_is_logged_in', |
|
209 | - 'type' => MENU_CALLBACK, |
|
210 | - ); |
|
211 | - $items['recover_email.php'] = array( |
|
212 | - 'title' => t('Recover previous email'), |
|
213 | - 'description' => t('redirect'), |
|
214 | - 'page callback' => '_boincuser_redirect_recover_email', |
|
215 | - 'access callback' => TRUE, |
|
216 | - 'type' => MENU_CALLBACK, |
|
217 | - ); |
|
218 | - return $items; |
|
184 | +$items['create_account.php'] = array( |
|
185 | +'title' => 'Create Account RPC', |
|
186 | +'description' => 'RPC for creating user accounts.', |
|
187 | +'page callback' => 'boincuser_create_account', |
|
188 | +'access callback' => TRUE, |
|
189 | +'type' => MENU_CALLBACK |
|
190 | +); |
|
191 | +$items['account_finish.php'] = array( |
|
192 | +'title' => 'Welcome to ' . variable_get('site_name', 'Drupal-BOINC'), |
|
193 | +'description' => 'RPC for after a user has created an account.', |
|
194 | +'page callback' => 'boincuser_account_finish', |
|
195 | +'access callback' => TRUE, |
|
196 | +'type' => MENU_CALLBACK, |
|
197 | +); |
|
198 | +$items['boincuser/autocomplete'] = array( |
|
199 | +'page callback' => '_boincuser_user_name_autocomplete', |
|
200 | +'access callback' => TRUE, |
|
201 | +'type' => MENU_CALLBACK, |
|
202 | +); |
|
203 | +$items['user/%user/recoveremail/%'] = array( |
|
204 | +'title' => t('Recover previous email'), |
|
205 | +'description' => t('Form to revert email to previous address.'), |
|
206 | +'page callback' => 'drupal_get_form', |
|
207 | +'page arguments' => array('boincuser_revertemail', 3), |
|
208 | +'access callback' => 'user_is_logged_in', |
|
209 | +'type' => MENU_CALLBACK, |
|
210 | +); |
|
211 | +$items['recover_email.php'] = array( |
|
212 | +'title' => t('Recover previous email'), |
|
213 | +'description' => t('redirect'), |
|
214 | +'page callback' => '_boincuser_redirect_recover_email', |
|
215 | +'access callback' => TRUE, |
|
216 | +'type' => MENU_CALLBACK, |
|
217 | +); |
|
218 | +return $items; |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
222 | 222 | * Implementation of hook_init() |
223 | 223 | */ |
224 | 224 | function boincuser_init() { |
225 | - global $user; |
|
226 | - // Skip this check for charts, which are loaded separately |
|
227 | - // (may get duplicate or unexpected messages otherwise) |
|
228 | - if (substr($_GET['q'], 0, 7) == 'charts/') { |
|
229 | - return; |
|
230 | - } |
|
225 | +global $user; |
|
226 | +// Skip this check for charts, which are loaded separately |
|
227 | +// (may get duplicate or unexpected messages otherwise) |
|
228 | +if (substr($_GET['q'], 0, 7) == 'charts/') { |
|
229 | +return; |
|
230 | +} |
|
231 | 231 | |
232 | - // If admin user, do some basic site functionality checks |
|
233 | - if (user_access('administer site configuration')) { |
|
234 | - // Ensure we have a configured BOINC environment |
|
235 | - boinc_get_path(); |
|
236 | - boinc_get_scheduler_tags(); |
|
237 | - } |
|
232 | +// If admin user, do some basic site functionality checks |
|
233 | +if (user_access('administer site configuration')) { |
|
234 | +// Ensure we have a configured BOINC environment |
|
235 | +boinc_get_path(); |
|
236 | +boinc_get_scheduler_tags(); |
|
237 | +} |
|
238 | 238 | |
239 | - // Check credits for the verified contributor role |
|
240 | - boincuser_check_credit_requirements(); |
|
239 | +// Check credits for the verified contributor role |
|
240 | +boincuser_check_credit_requirements(); |
|
241 | 241 | |
242 | - if (module_exists('boincteam')) { |
|
243 | - // Display any persistent team messages |
|
244 | - boincteam_show_messages(); |
|
245 | - } |
|
242 | +if (module_exists('boincteam')) { |
|
243 | +// Display any persistent team messages |
|
244 | +boincteam_show_messages(); |
|
245 | +} |
|
246 | 246 | |
247 | - // Check if user has agreed to the terms of use. If not, send the |
|
248 | - // user to the terms-of-use form. This is only makes sense if the |
|
249 | - // termsofuse is enabled, by having text in the termsofuse variable. |
|
250 | - $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE); |
|
251 | - $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
252 | - if ( (!empty($termsofuse)) and ($user->uid) ) { |
|
253 | - if ( !boincuser_check_termsofuse($user) and ($existinguser_tou) ) { |
|
254 | - |
|
255 | - // Admins are exempt, otherwise the admin may not be able to |
|
256 | - // access the site! |
|
257 | - $administrator_role = array_search('administrator', user_roles(true)); |
|
258 | - if (!isset($user->roles[$administrator_role])) { |
|
259 | - $path = drupal_get_path_alias($_GET['q']); |
|
260 | - |
|
261 | - // Any paths that should NOT be redirected go here. |
|
262 | - // @todo - replace this static array with one that allows |
|
263 | - // admins to specify custom paths (patterns) to ignore. |
|
264 | - $paths_to_ignore = array( |
|
265 | - 'user/termsofuse', |
|
266 | - 'logout', |
|
267 | - 'privacy', |
|
268 | - 'moderation', |
|
269 | - 'account/info/edit', |
|
270 | - 'user/' . $user->uid . '/edit', |
|
271 | - 'user/' . $user->uid . '/recoveremail/*', |
|
272 | - 'recover_email.php', |
|
273 | - ); |
|
274 | - if (module_exists('boincuser_delete')) { |
|
275 | - $paths_to_ignore[] = 'user/' . $user->uid . '/delete'; |
|
276 | - $paths_to_ignore[] = 'user/' . $user->uid . '/deleteconfirm/*'; |
|
277 | - $paths_to_ignore[] = 'user/' . $user->uid . '/odeleteconfirm/*'; |
|
278 | - } |
|
279 | - if (!_boincuser_ignore_paths($path, $paths_to_ignore)) { |
|
280 | - drupal_goto('user/termsofuse'); |
|
281 | - } |
|
282 | - } |
|
247 | +// Check if user has agreed to the terms of use. If not, send the |
|
248 | +// user to the terms-of-use form. This is only makes sense if the |
|
249 | +// termsofuse is enabled, by having text in the termsofuse variable. |
|
250 | +$existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE); |
|
251 | +$termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
252 | +if ( (!empty($termsofuse)) and ($user->uid) ) { |
|
253 | +if ( !boincuser_check_termsofuse($user) and ($existinguser_tou) ) { |
|
254 | + |
|
255 | + // Admins are exempt, otherwise the admin may not be able to |
|
256 | + // access the site! |
|
257 | + $administrator_role = array_search('administrator', user_roles(true)); |
|
258 | + if (!isset($user->roles[$administrator_role])) { |
|
259 | + $path = drupal_get_path_alias($_GET['q']); |
|
260 | + |
|
261 | + // Any paths that should NOT be redirected go here. |
|
262 | + // @todo - replace this static array with one that allows |
|
263 | + // admins to specify custom paths (patterns) to ignore. |
|
264 | + $paths_to_ignore = array( |
|
265 | + 'user/termsofuse', |
|
266 | + 'logout', |
|
267 | + 'privacy', |
|
268 | + 'moderation', |
|
269 | + 'account/info/edit', |
|
270 | + 'user/' . $user->uid . '/edit', |
|
271 | + 'user/' . $user->uid . '/recoveremail/*', |
|
272 | + 'recover_email.php', |
|
273 | + ); |
|
274 | + if (module_exists('boincuser_delete')) { |
|
275 | + $paths_to_ignore[] = 'user/' . $user->uid . '/delete'; |
|
276 | + $paths_to_ignore[] = 'user/' . $user->uid . '/deleteconfirm/*'; |
|
277 | + $paths_to_ignore[] = 'user/' . $user->uid . '/odeleteconfirm/*'; |
|
278 | + } |
|
279 | + if (!_boincuser_ignore_paths($path, $paths_to_ignore)) { |
|
280 | + drupal_goto('user/termsofuse'); |
|
283 | 281 | } |
284 | 282 | } |
285 | 283 | } |
284 | +} |
|
285 | +} |
|
286 | 286 | |
287 | 287 | /** |
288 | 288 | * Implementation of hook_user(); add custom actions to standard |
289 | 289 | * Drupal user operations |
290 | 290 | */ |
291 | 291 | function boincuser_user($op, &$edit, &$account, $category = NULL) { |
292 | - require_boinc('boinc_db'); |
|
293 | - require_boinc('user'); |
|
294 | - require_boinc('xml'); |
|
295 | - |
|
296 | - require_boinc('password_compat/password'); |
|
297 | - // Handle BOINC integration for users with UID > 1 (skip anonymous and admin) |
|
298 | - if ($account->uid > 1) { |
|
299 | - switch($op) { |
|
300 | - case 'load': |
|
301 | - // User loading; insert BOINC data into the user object |
|
302 | - $drupal_user = db_fetch_object(db_query(" |
|
292 | +require_boinc('boinc_db'); |
|
293 | +require_boinc('user'); |
|
294 | +require_boinc('xml'); |
|
295 | + |
|
296 | +require_boinc('password_compat/password'); |
|
297 | +// Handle BOINC integration for users with UID > 1 (skip anonymous and admin) |
|
298 | +if ($account->uid > 1) { |
|
299 | +switch($op) { |
|
300 | +case 'load': |
|
301 | +// User loading; insert BOINC data into the user object |
|
302 | +$drupal_user = db_fetch_object(db_query(" |
|
303 | 303 | SELECT boinc_id, penalty_expiration |
304 | 304 | FROM {boincuser} WHERE uid = %d", |
305 | - $account->uid |
|
306 | - )); |
|
307 | - $account->boincuser_id = $drupal_user->boinc_id; |
|
308 | - $account->boincuser_penalty_expiration = $drupal_user->penalty_expiration; |
|
309 | - db_set_active('boinc_rw'); |
|
310 | - $boinc_user = db_fetch_object(db_query(" |
|
305 | +$account->uid |
|
306 | +)); |
|
307 | +$account->boincuser_id = $drupal_user->boinc_id; |
|
308 | +$account->boincuser_penalty_expiration = $drupal_user->penalty_expiration; |
|
309 | +db_set_active('boinc_rw'); |
|
310 | +$boinc_user = db_fetch_object(db_query(" |
|
311 | 311 | SELECT |
312 | 312 | name, |
313 | 313 | authenticator, |
@@ -322,30 +322,30 @@ discard block |
||
322 | 322 | email_addr_change_time |
323 | 323 | FROM {user} |
324 | 324 | WHERE id = %d", |
325 | - $account->boincuser_id |
|
326 | - )); |
|
327 | - $account->boincuser_name = $boinc_user->name; |
|
328 | - $account->boincuser_account_key = $boinc_user->authenticator; |
|
329 | - $account->boincuser_weak_auth = md5($boinc_user->authenticator . $boinc_user->passwd_hash); |
|
330 | - $account->boincuser_total_credit = round($boinc_user->total_credit); |
|
331 | - $account->boincuser_expavg_credit = round($boinc_user->expavg_credit); |
|
332 | - $account->boincuser_expavg_time = round($boinc_user->expavg_time); |
|
333 | - $account->boincuser_cpid = md5($boinc_user->cross_project_id . $account->mail); |
|
334 | - $account->boincuser_default_pref_set = $boinc_user->venue; |
|
335 | - $account->boincteam_id = $boinc_user->teamid; |
|
336 | - $account->boincuser_previous_email_addr = $boinc_user->previous_email_addr; |
|
337 | - $account->boincuser_email_addr_change_time = $boinc_user->email_addr_change_time; |
|
338 | - db_set_active('default'); |
|
339 | - // Set Drupal team ID |
|
340 | - $account->team = NULL; |
|
341 | - if ($account->boincteam_id) { |
|
342 | - $account->team = db_result(db_query(" |
|
325 | +$account->boincuser_id |
|
326 | +)); |
|
327 | +$account->boincuser_name = $boinc_user->name; |
|
328 | +$account->boincuser_account_key = $boinc_user->authenticator; |
|
329 | +$account->boincuser_weak_auth = md5($boinc_user->authenticator . $boinc_user->passwd_hash); |
|
330 | +$account->boincuser_total_credit = round($boinc_user->total_credit); |
|
331 | +$account->boincuser_expavg_credit = round($boinc_user->expavg_credit); |
|
332 | +$account->boincuser_expavg_time = round($boinc_user->expavg_time); |
|
333 | +$account->boincuser_cpid = md5($boinc_user->cross_project_id . $account->mail); |
|
334 | +$account->boincuser_default_pref_set = $boinc_user->venue; |
|
335 | +$account->boincteam_id = $boinc_user->teamid; |
|
336 | +$account->boincuser_previous_email_addr = $boinc_user->previous_email_addr; |
|
337 | +$account->boincuser_email_addr_change_time = $boinc_user->email_addr_change_time; |
|
338 | +db_set_active('default'); |
|
339 | +// Set Drupal team ID |
|
340 | +$account->team = NULL; |
|
341 | +if ($account->boincteam_id) { |
|
342 | +$account->team = db_result(db_query(" |
|
343 | 343 | SELECT nid FROM {boincteam} WHERE team_id = %d", |
344 | - $account->boincteam_id |
|
345 | - )); |
|
346 | - } |
|
347 | - // Set post count |
|
348 | - $account->post_count = db_result(db_query(" |
|
344 | +$account->boincteam_id |
|
345 | +)); |
|
346 | +} |
|
347 | +// Set post count |
|
348 | +$account->post_count = db_result(db_query(" |
|
349 | 349 | SELECT COUNT(*) + |
350 | 350 | ( |
351 | 351 | SELECT COUNT(*) FROM {node} |
@@ -357,13 +357,13 @@ discard block |
||
357 | 357 | INNER JOIN node ON comments.nid = node.nid |
358 | 358 | WHERE comments.uid = '%d' |
359 | 359 | AND node.status = 1", |
360 | - $account->uid, $account->uid |
|
361 | - )); |
|
362 | - break; |
|
360 | +$account->uid, $account->uid |
|
361 | +)); |
|
362 | +break; |
|
363 | 363 | |
364 | - case 'view': |
|
365 | - // SAMPLE: Add BOINC data to the user profile |
|
366 | - /*$account->content['summary']['boinc_id'] = array( |
|
364 | +case 'view': |
|
365 | +// SAMPLE: Add BOINC data to the user profile |
|
366 | +/*$account->content['summary']['boinc_id'] = array( |
|
367 | 367 | '#type' => 'user_profile_item', |
368 | 368 | '#title' => bts('BIONC ID'), |
369 | 369 | '#value' => $account->boincuser_id, |
@@ -377,161 +377,161 @@ discard block |
||
377 | 377 | '#attributes' => array('class' => 'boinc-data'), |
378 | 378 | '#weight' => 10 |
379 | 379 | );*/ |
380 | - break; |
|
380 | +break; |
|
381 | 381 | |
382 | - case 'validate': |
|
383 | - if (isset($edit['validation_source'])) { |
|
384 | - switch ($edit['validation_source']) { |
|
385 | - case 'user_account': |
|
386 | - // Validate data before updating user account info |
|
387 | - boincuser_account_validate($edit, $account); |
|
388 | - break; |
|
382 | +case 'validate': |
|
383 | +if (isset($edit['validation_source'])) { |
|
384 | +switch ($edit['validation_source']) { |
|
385 | +case 'user_account': |
|
386 | +// Validate data before updating user account info |
|
387 | +boincuser_account_validate($edit, $account); |
|
388 | +break; |
|
389 | 389 | |
390 | - default: |
|
390 | +default: |
|
391 | 391 | |
392 | - } |
|
393 | - // We don't want to save validation source, so remove it |
|
394 | - $edit['validation_source'] = null; |
|
395 | - } |
|
396 | - break; |
|
392 | +} |
|
393 | + // We don't want to save validation source, so remove it |
|
394 | + $edit['validation_source'] = null; |
|
395 | + } |
|
396 | + break; |
|
397 | 397 | |
398 | - case 'insert': |
|
399 | - // New user being added to the system |
|
400 | - $imported = $_SESSION['importedUser']; |
|
401 | - unset($_SESSION['importedUser']); |
|
398 | +case 'insert': |
|
399 | + // New user being added to the system |
|
400 | + $imported = $_SESSION['importedUser']; |
|
401 | + unset($_SESSION['importedUser']); |
|
402 | 402 | |
403 | - watchdog( |
|
404 | - 'boincuser', |
|
405 | - 'Creating user account for %email_addr', |
|
406 | - array('%email_addr' => $edit['mail']), |
|
407 | - WATCHDOG_NOTICE |
|
408 | - ); |
|
403 | + watchdog( |
|
404 | + 'boincuser', |
|
405 | + 'Creating user account for %email_addr', |
|
406 | + array('%email_addr' => $edit['mail']), |
|
407 | + WATCHDOG_NOTICE |
|
408 | + ); |
|
409 | 409 | |
410 | - // The create_acount RPC will call this block of code when |
|
411 | - // user_save() is used. If user is registering using the Web |
|
412 | - // registration form, create a BOINC user and relationships. |
|
413 | - // Create a BOINC account unless importing from BOINC. |
|
414 | - if (!$imported) { |
|
415 | - |
|
416 | - if ($edit['boincuser_name']) { |
|
417 | - $myname = $edit['boincuser_name']; |
|
418 | - } |
|
419 | - else if ($edit['name']) { |
|
420 | - $myname = $edit['name']; |
|
421 | - } |
|
422 | - else { |
|
423 | - $myname = 'noname'; |
|
424 | - } |
|
410 | + // The create_acount RPC will call this block of code when |
|
411 | + // user_save() is used. If user is registering using the Web |
|
412 | + // registration form, create a BOINC user and relationships. |
|
413 | + // Create a BOINC account unless importing from BOINC. |
|
414 | + if (!$imported) { |
|
415 | + |
|
416 | + if ($edit['boincuser_name']) { |
|
417 | + $myname = $edit['boincuser_name']; |
|
418 | + } |
|
419 | + else if ($edit['name']) { |
|
420 | + $myname = $edit['name']; |
|
421 | + } |
|
422 | + else { |
|
423 | + $myname = 'noname'; |
|
424 | + } |
|
425 | 425 | |
426 | - $user_params = array( |
|
427 | - 'email_addr' => $edit['mail'], |
|
428 | - 'name' => $myname, |
|
429 | - ); |
|
426 | + $user_params = array( |
|
427 | + 'email_addr' => $edit['mail'], |
|
428 | + 'name' => $myname, |
|
429 | + ); |
|
430 | 430 | |
431 | - // If the 'pass' variable is already a hash, then don't hash it again. |
|
432 | - if ($edit['boinchash_flag']) { |
|
433 | - $user_params['passwd_hash'] = $edit['pass']; |
|
434 | - } |
|
435 | - else { |
|
436 | - // The passwd_hash here is only the md5() hash. This is |
|
437 | - // because BOINC make_user(), called later, will run |
|
438 | - // password_hash() on this md5 hash. |
|
439 | - $user_params['passwd_hash'] = md5($edit['pass'].$edit['mail']); |
|
440 | - } |
|
431 | + // If the 'pass' variable is already a hash, then don't hash it again. |
|
432 | + if ($edit['boinchash_flag']) { |
|
433 | + $user_params['passwd_hash'] = $edit['pass']; |
|
434 | + } |
|
435 | + else { |
|
436 | + // The passwd_hash here is only the md5() hash. This is |
|
437 | + // because BOINC make_user(), called later, will run |
|
438 | + // password_hash() on this md5 hash. |
|
439 | + $user_params['passwd_hash'] = md5($edit['pass'].$edit['mail']); |
|
440 | + } |
|
441 | 441 | |
442 | - $boinc_user = boincuser_register_make_user($user_params); |
|
443 | - if (!$boinc_user) { |
|
444 | - // Account exists with this email addr |
|
445 | - form_set_error('email', bts('Error creating BOINC account.', array(), NULL, 'boinc:add-new-user')); |
|
446 | - return; |
|
447 | - } |
|
442 | + $boinc_user = boincuser_register_make_user($user_params); |
|
443 | + if (!$boinc_user) { |
|
444 | + // Account exists with this email addr |
|
445 | + form_set_error('email', bts('Error creating BOINC account.', array(), NULL, 'boinc:add-new-user')); |
|
446 | + return; |
|
447 | + } |
|
448 | 448 | |
449 | - // Add user to community role by default (not banned) |
|
450 | - $unrestricted_role = array_search('community member', user_roles(true)); |
|
451 | - $edit['roles'] = array( |
|
452 | - $unrestricted_role => '' |
|
453 | - ); |
|
449 | + // Add user to community role by default (not banned) |
|
450 | + $unrestricted_role = array_search('community member', user_roles(true)); |
|
451 | + $edit['roles'] = array( |
|
452 | + $unrestricted_role => '' |
|
453 | + ); |
|
454 | 454 | |
455 | - // Disable show_hosts flag, set to TRUE by default |
|
456 | - db_set_active('boinc_rw'); |
|
457 | - db_query("UPDATE {user} SET show_hosts=0 WHERE id='%d'", $boinc_user->id); |
|
458 | - db_set_active('default'); |
|
455 | + // Disable show_hosts flag, set to TRUE by default |
|
456 | + db_set_active('boinc_rw'); |
|
457 | + db_query("UPDATE {user} SET show_hosts=0 WHERE id='%d'", $boinc_user->id); |
|
458 | + db_set_active('default'); |
|
459 | 459 | |
460 | - // Cross reference Drupal account with BOINC |
|
461 | - $reference = db_query("INSERT INTO {boincuser} SET uid='%d', boinc_id='%d'", $account->uid, $boinc_user->id); |
|
462 | - if (!$reference) { |
|
463 | - drupal_set_message(t('Error connecting BOINC account.'), 'error'); |
|
464 | - return; |
|
465 | - } |
|
460 | + // Cross reference Drupal account with BOINC |
|
461 | + $reference = db_query("INSERT INTO {boincuser} SET uid='%d', boinc_id='%d'", $account->uid, $boinc_user->id); |
|
462 | + if (!$reference) { |
|
463 | + drupal_set_message(t('Error connecting BOINC account.'), 'error'); |
|
464 | + return; |
|
465 | + } |
|
466 | 466 | |
467 | - // if terms of use exist, the user must agree. |
|
468 | - $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
469 | - if (!empty($termsofuse)) { |
|
470 | - $reference2 = boincuser_consentto_termsofuse($account); |
|
471 | - } |
|
467 | + // if terms of use exist, the user must agree. |
|
468 | + $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
469 | + if (!empty($termsofuse)) { |
|
470 | + $reference2 = boincuser_consentto_termsofuse($account); |
|
471 | + } |
|
472 | 472 | |
473 | - // Don't save custom fields to the Drupal user object |
|
474 | - $edit['boincuser_name'] = null; |
|
475 | - $edit['boinchash_flag'] = null; |
|
476 | - } |
|
477 | - break; |
|
473 | + // Don't save custom fields to the Drupal user object |
|
474 | + $edit['boincuser_name'] = null; |
|
475 | + $edit['boinchash_flag'] = null; |
|
476 | + } |
|
477 | + break; |
|
478 | 478 | |
479 | - case 'update': |
|
480 | - if (isset($edit['update_source'])) { |
|
481 | - require_boinc('boinc_db'); |
|
482 | - $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
483 | - switch ($edit['update_source']) { |
|
484 | - case 'user_account': |
|
485 | - // Ensure that BOINC data is altered |
|
486 | - |
|
487 | - $changing_email = ($edit['mail'] AND $edit['mail'] != $boinc_user->email_addr) ? true : false; |
|
488 | - $changing_pass = ($edit['pass']) ? true : false; |
|
489 | - if ($changing_email OR $changing_pass) { |
|
490 | - // Set password hash appropriately |
|
491 | - $passwd = ($edit['pass']) ? $edit['pass'] : $edit['current_pass']; |
|
492 | - $passwd_hash = password_hash( md5($passwd.$edit['mail']), PASSWORD_DEFAULT ); |
|
493 | - $email_addr = $edit['mail']; |
|
494 | - |
|
495 | - // Algorithm for changing email and/or password |
|
496 | - if ($changing_email) { |
|
497 | - // locally store current email to set as previous email |
|
498 | - $prev_email = $account->mail; |
|
499 | - $mytime = (user_access('administer users')) ? $boinc_user->email_addr_change_time : time(); |
|
500 | - $querypart = "email_addr='{$email_addr}', passwd_hash='{$passwd_hash}', previous_email_addr = '{$prev_email}', email_addr_change_time = $mytime"; |
|
501 | - } |
|
502 | - else { |
|
503 | - $querypart = "email_addr='{$email_addr}', passwd_hash='{$passwd_hash}'"; |
|
504 | - } |
|
505 | - |
|
506 | - // Update user account information |
|
507 | - $result = $boinc_user->update($querypart); |
|
508 | - |
|
509 | - if ($changing_email) { |
|
510 | - // reload account |
|
511 | - $account = user_load($account->uid); |
|
512 | - _boincuser_send_emailchange($account, $email_addr, $prev_email, user_access('administer users')); |
|
513 | - } |
|
514 | - } |
|
515 | - |
|
516 | - // Change boinc username |
|
517 | - if ($edit['boincuser_name'] and ($edit['boincuser_name'] != $boinc_user->name)) { |
|
518 | - $boincuser_name = $edit['boincuser_name']; |
|
519 | - $result = $boinc_user->update( |
|
520 | - "name='{$boincuser_name}'" |
|
521 | - ); |
|
522 | - } |
|
523 | - |
|
524 | - break; |
|
525 | - case 'user_profile': |
|
526 | - if ($edit['boincuser_name'] != $boinc_user->name) { |
|
527 | - $boincuser_name = $edit['boincuser_name']; |
|
528 | - $result = $boinc_user->update( |
|
529 | - "name='{$boincuser_name}'" |
|
530 | - ); |
|
531 | - } |
|
532 | - break; |
|
533 | - default: |
|
534 | - } |
|
479 | +case 'update': |
|
480 | + if (isset($edit['update_source'])) { |
|
481 | + require_boinc('boinc_db'); |
|
482 | + $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
483 | + switch ($edit['update_source']) { |
|
484 | + case 'user_account': |
|
485 | + // Ensure that BOINC data is altered |
|
486 | + |
|
487 | + $changing_email = ($edit['mail'] AND $edit['mail'] != $boinc_user->email_addr) ? true : false; |
|
488 | + $changing_pass = ($edit['pass']) ? true : false; |
|
489 | + if ($changing_email OR $changing_pass) { |
|
490 | + // Set password hash appropriately |
|
491 | + $passwd = ($edit['pass']) ? $edit['pass'] : $edit['current_pass']; |
|
492 | + $passwd_hash = password_hash( md5($passwd.$edit['mail']), PASSWORD_DEFAULT ); |
|
493 | + $email_addr = $edit['mail']; |
|
494 | + |
|
495 | + // Algorithm for changing email and/or password |
|
496 | + if ($changing_email) { |
|
497 | + // locally store current email to set as previous email |
|
498 | + $prev_email = $account->mail; |
|
499 | + $mytime = (user_access('administer users')) ? $boinc_user->email_addr_change_time : time(); |
|
500 | + $querypart = "email_addr='{$email_addr}', passwd_hash='{$passwd_hash}', previous_email_addr = '{$prev_email}', email_addr_change_time = $mytime"; |
|
501 | + } |
|
502 | + else { |
|
503 | + $querypart = "email_addr='{$email_addr}', passwd_hash='{$passwd_hash}'"; |
|
504 | + } |
|
505 | + |
|
506 | + // Update user account information |
|
507 | + $result = $boinc_user->update($querypart); |
|
508 | + |
|
509 | + if ($changing_email) { |
|
510 | + // reload account |
|
511 | + $account = user_load($account->uid); |
|
512 | + _boincuser_send_emailchange($account, $email_addr, $prev_email, user_access('administer users')); |
|
513 | + } |
|
514 | + } |
|
515 | + |
|
516 | + // Change boinc username |
|
517 | + if ($edit['boincuser_name'] and ($edit['boincuser_name'] != $boinc_user->name)) { |
|
518 | + $boincuser_name = $edit['boincuser_name']; |
|
519 | + $result = $boinc_user->update( |
|
520 | + "name='{$boincuser_name}'" |
|
521 | + ); |
|
522 | + } |
|
523 | + |
|
524 | + break; |
|
525 | + case 'user_profile': |
|
526 | + if ($edit['boincuser_name'] != $boinc_user->name) { |
|
527 | + $boincuser_name = $edit['boincuser_name']; |
|
528 | + $result = $boinc_user->update( |
|
529 | + "name='{$boincuser_name}'" |
|
530 | + ); |
|
531 | + } |
|
532 | + break; |
|
533 | + default: |
|
534 | + } |
|
535 | 535 | // We don't want to save update source or duplicate custom fields, so |
536 | 536 | // remove them before continuing to core Drupal routines |
537 | 537 | $edit['update_source'] = null; |
@@ -539,17 +539,17 @@ discard block |
||
539 | 539 | } |
540 | 540 | break; |
541 | 541 | |
542 | - case 'login': |
|
543 | - // Function is forward compatible to Drupal 7 |
|
544 | - boincuser_user_login($edit, $account); |
|
545 | - break; |
|
542 | +case 'login': |
|
543 | + // Function is forward compatible to Drupal 7 |
|
544 | + boincuser_user_login($edit, $account); |
|
545 | + break; |
|
546 | 546 | |
547 | - case 'delete': |
|
548 | - // Function is forward compatible to Drupal 7 |
|
549 | - boincuser_user_delete($account); |
|
550 | - break; |
|
547 | +case 'delete': |
|
548 | + // Function is forward compatible to Drupal 7 |
|
549 | + boincuser_user_delete($account); |
|
550 | + break; |
|
551 | 551 | |
552 | - default: |
|
552 | +default: |
|
553 | 553 | |
554 | 554 | } |
555 | 555 | } |