Passed
Pull Request — master (#3042)
by Christian
07:09
created
drupal/sites/default/boinc/modules/boincwork/includes/boincwork.helpers.inc 1 patch
Switch Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -643,9 +643,9 @@  discard block
 block discarded – undo
643 643
     }
644 644
     break;
645 645
     
646
-    default:
647
-      // Don't generate form elements for things that aren't explicitly form
648
-      // elements (i.e. 'title', '@attributes' keys, and the like)
646
+  default:
647
+    // Don't generate form elements for things that aren't explicitly form
648
+    // elements (i.e. 'title', '@attributes' keys, and the like)
649 649
   }
650 650
 }
651 651
 
@@ -1990,29 +1990,29 @@  discard block
 block discarded – undo
1990 1990
  */
1991 1991
 function pretty_application_version($appverid, $vernum, $plan_class, $plfm) {
1992 1992
   switch ($appverid) {
1993
-    case ANON_PLATFORM_UNKNOWN:
1994
-      return "Anonymous platform";
1995
-    case ANON_PLATFORM_CPU:
1996
-      return "Anonymous platform CPU";
1997
-    case ANON_PLATFORM_NVIDIA:
1998
-      return "Anonymous platform NVIDIA GPU";
1999
-    case ANON_PLATFORM_ATI:
2000
-      return "Anonymous platform AMD GPU";
2001
-    case ANON_PLATFORM_INTEL:
2002
-      return "Anonymous platform Intel GPU";
2003
-    case 0:
2004
-      return "---";
2005
-    default:
2006
-      // Handle the case where the appversid is still negative. This
2007
-      // may be cause BOINC has introduced a new anonymous platform
2008
-      // that is not handled by the above case statements.
2009
-      if ($appverid < 0) {
2010
-        return "Unknown Anonymous platform";
2011
-      }
2012
-      else {
2013
-        $prettyv = sprintf("%d.%02d", $vernum/100, $vernum%100);
2014
-        $prettyc = ($plan_class) ? "($av->plan_class)" : '';
2015
-        return "v$prettyv $prettyc $plfm";
2016
-      }
1993
+  case ANON_PLATFORM_UNKNOWN:
1994
+    return "Anonymous platform";
1995
+  case ANON_PLATFORM_CPU:
1996
+    return "Anonymous platform CPU";
1997
+  case ANON_PLATFORM_NVIDIA:
1998
+    return "Anonymous platform NVIDIA GPU";
1999
+  case ANON_PLATFORM_ATI:
2000
+    return "Anonymous platform AMD GPU";
2001
+  case ANON_PLATFORM_INTEL:
2002
+    return "Anonymous platform Intel GPU";
2003
+  case 0:
2004
+    return "---";
2005
+  default:
2006
+    // Handle the case where the appversid is still negative. This
2007
+    // may be cause BOINC has introduced a new anonymous platform
2008
+    // that is not handled by the above case statements.
2009
+    if ($appverid < 0) {
2010
+      return "Unknown Anonymous platform";
2011
+    }
2012
+    else {
2013
+      $prettyv = sprintf("%d.%02d", $vernum/100, $vernum%100);
2014
+      $prettyc = ($plan_class) ? "($av->plan_class)" : '';
2015
+      return "v$prettyv $prettyc $plfm";
2016
+    }
2017 2017
   }
2018 2018
 }
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boincuser/includes/boincuser.forms.inc 1 patch
Switch Indentation   +667 added lines, -667 removed lines patch added patch discarded remove patch
@@ -15,59 +15,59 @@  discard block
 block discarded – undo
15 15
  * Form validation handler for login
16 16
  */
17 17
 function boincuser_login_validate($form, &$form_state) {
18
-  /* // SAMPLE: To try validation with Drupal first...
18
+/* // SAMPLE: To try validation with Drupal first...
19 19
   global $user;
20 20
   if (!empty($user->uid)) {
21 21
     // Authentication with Drupal was successful
22 22
     return;
23 23
   }*/
24 24
   
25
-  // Set name for logging purposes
26
-  $form_state['values']['name'] = $form_state['values']['email'];
25
+// Set name for logging purposes
26
+$form_state['values']['name'] = $form_state['values']['email'];
27 27
   
28
-  // Bypass BOINC validation if passed the name of user 1
29
-  $user_1 = user_load(1);
30
-  if ($form_state['values']['email'] == $user_1->name) {
31
-    user_authenticate($form_state['values']);
32
-    return;
33
-  }
28
+// Bypass BOINC validation if passed the name of user 1
29
+$user_1 = user_load(1);
30
+if ($form_state['values']['email'] == $user_1->name) {
31
+user_authenticate($form_state['values']);
32
+return;
33
+}
34 34
   
35
-  // Call our custom authentication function to check for an existing BOINC user
36
-  if (!boincuser_login_authenticate($form_state['values'])) {
37
-    // Authentication failed; set an error accordingly
38
-    form_set_error('name', bts('Sorry, unrecognized email address or password.', array(), NULL, 'boinc:forgot-password') . ' ' . l(bts('Have you forgotten your password?', array(), NULL, 'boinc:forgot-password'), 'user/password'));
39
-  }
35
+// Call our custom authentication function to check for an existing BOINC user
36
+if (!boincuser_login_authenticate($form_state['values'])) {
37
+// Authentication failed; set an error accordingly
38
+form_set_error('name', bts('Sorry, unrecognized email address or password.', array(), NULL, 'boinc:forgot-password') . ' ' . l(bts('Have you forgotten your password?', array(), NULL, 'boinc:forgot-password'), 'user/password'));
39
+}
40 40
 }
41 41
 
42 42
 /**
43 43
  * Custom authentication function to check BOINC account information
44 44
  */
45 45
 function boincuser_login_authenticate($form_values) {
46
-  global $boincuser_authenticated;
47
-  $lower_email_addr = strtolower($form_values['email']);
48
-  $passwd = $form_values['pass'];
49
-  $passwd_hash = md5($passwd.$lower_email_addr);
46
+global $boincuser_authenticated;
47
+$lower_email_addr = strtolower($form_values['email']);
48
+$passwd = $form_values['pass'];
49
+$passwd_hash = md5($passwd.$lower_email_addr);
50 50
   
51
-  // Include BOINC user library
52
-  require_boinc('boinc_db');
53
-  require_boinc('user_util');
51
+// Include BOINC user library
52
+require_boinc('boinc_db');
53
+require_boinc('user_util');
54 54
 
55
-  // Get the BOINC user and check credentials
56
-  $boinc_user = BoincUser::lookup_email_addr($lower_email_addr);
57
-  if (!$boinc_user) return false;
55
+// Get the BOINC user and check credentials
56
+$boinc_user = BoincUser::lookup_email_addr($lower_email_addr);
57
+if (!$boinc_user) return false;
58 58
 
59
-  if (!check_passwd_hash($boinc_user, $passwd_hash)) {
60
-    return false;
61
-  }
59
+if (!check_passwd_hash($boinc_user, $passwd_hash)) {
60
+return false;
61
+}
62 62
 
63
-  // BOINC authentication successful; log in and synchronize accounts
64
-  boincuser_login_register($boinc_user);
65
-  // Write session, update timestamp, run user 'login' hook.
66
-  user_authenticate_finalize($form_values);
67
-  // Use a global variable to save the fact that we did authentication.
68
-  $boincuser_authenticated = true;
63
+// BOINC authentication successful; log in and synchronize accounts
64
+boincuser_login_register($boinc_user);
65
+// Write session, update timestamp, run user 'login' hook.
66
+user_authenticate_finalize($form_values);
67
+// Use a global variable to save the fact that we did authentication.
68
+$boincuser_authenticated = true;
69 69
 
70
-  return true;
70
+return true;
71 71
 }
72 72
 
73 73
 /**
@@ -75,18 +75,18 @@  discard block
 block discarded – undo
75 75
  * Drupal accounts
76 76
  */
77 77
 function boincuser_login_register($boinc_user) {
78
-  global $user;
79
-  require_boinc('boinc_db');
80
-  // If a Drupal account already exists, log in
81
-  $existing_user = user_load(array('mail' => $boinc_user->email_addr));
82
-  if (!empty($existing_user->uid)) {
83
-    $user = $existing_user;
84
-  } else {
85
-    // Create a Drupal user from the BOINC user
86
-    if ($user = boincuser_register_make_drupal_user($boinc_user)) {
87
-      watchdog('user', 'New external user: %email using module %module.', array('%email' => $email_addr, '%module' => $module), WATCHDOG_NOTICE, l(t('edit'), 'user/'. $user->uid .'/edit'));
88
-    }
89
-  }
78
+global $user;
79
+require_boinc('boinc_db');
80
+// If a Drupal account already exists, log in
81
+$existing_user = user_load(array('mail' => $boinc_user->email_addr));
82
+if (!empty($existing_user->uid)) {
83
+$user = $existing_user;
84
+} else {
85
+// Create a Drupal user from the BOINC user
86
+if ($user = boincuser_register_make_drupal_user($boinc_user)) {
87
+  watchdog('user', 'New external user: %email using module %module.', array('%email' => $email_addr, '%module' => $module), WATCHDOG_NOTICE, l(t('edit'), 'user/'. $user->uid .'/edit'));
88
+}
89
+}
90 90
 }
91 91
 
92 92
 
@@ -98,277 +98,277 @@  discard block
 block discarded – undo
98 98
  * New user registration validation handler.
99 99
  */
100 100
 function boincuser_register_validate($form, &$form_state) {
101
-  // Include BOINC database objects library
102
-  require_boinc('boinc_db');
103
-
104
-  // Check terms of use agreement
105
-  $termsofuse = variable_get('boinc_weboptions_termsofuse', '');
106
-  if (!empty($termsofuse)) {
107
-    if (!$form_state['values']['agreeTOU']) {
108
-      form_set_error('termsofuse', bts('ERROR: You must acknowledge our terms of use by clicking the checkbox before registering for an account.', NULL, 'boinc:register-new-user'));
109
-      return false;
110
-    }
111
-  }
101
+// Include BOINC database objects library
102
+require_boinc('boinc_db');
103
+
104
+// Check terms of use agreement
105
+$termsofuse = variable_get('boinc_weboptions_termsofuse', '');
106
+if (!empty($termsofuse)) {
107
+if (!$form_state['values']['agreeTOU']) {
108
+  form_set_error('termsofuse', bts('ERROR: You must acknowledge our terms of use by clicking the checkbox before registering for an account.', NULL, 'boinc:register-new-user'));
109
+  return false;
110
+}
111
+}
112 112
 
113
-  // Lower-case the email address
114
-  $lower_email_addr = strtolower($form_state['values']['mail']);
115
-  $tmp_user = BoincUser::lookup_prev_email_addr($lower_email_addr);
116
-  if ($tmp_user) {
117
-    // User already exists
118
-    form_set_error('mail', bts('An account already exists for @email. Contact the administrators for @project for additional help.',
119
-      array(
120
-        '@email' => $lower_email_addr,
121
-        '@project' => variable_get('site_name', 'Drupal-BOINC'), NULL, 'boinc:add-new-user',
122
-      )
123
-    , NULL, 'boinc:register-new-user'));
124
-  }
113
+// Lower-case the email address
114
+$lower_email_addr = strtolower($form_state['values']['mail']);
115
+$tmp_user = BoincUser::lookup_prev_email_addr($lower_email_addr);
116
+if ($tmp_user) {
117
+// User already exists
118
+form_set_error('mail', bts('An account already exists for @email. Contact the administrators for @project for additional help.',
119
+  array(
120
+    '@email' => $lower_email_addr,
121
+    '@project' => variable_get('site_name', 'Drupal-BOINC'), NULL, 'boinc:add-new-user',
122
+  )
123
+, NULL, 'boinc:register-new-user'));
124
+}
125 125
 
126
-  // Check for an existing BOINC user
127
-  // This is somewhat redundent as Drupal will also check if the email
128
-  // is a duplicate. However, in the case where there is no Drupal
129
-  // account, but a BOINC account exists with this email, the check
130
-  // will fail.
131
-  $boinc_user = BoincUser::lookup_email_addr($lower_email_addr);
132
-  if ($boinc_user) {
133
-    // User already exists
134
-    form_set_error('mail', bts('An account already exists for @email. Log in or request password assistance to access your @project account.', array('@email' => $lower_email_addr, '@project' => PROJECT), NULL, 'boinc:add-new-user'));
135
-    return false;
136
-  }
126
+// Check for an existing BOINC user
127
+// This is somewhat redundent as Drupal will also check if the email
128
+// is a duplicate. However, in the case where there is no Drupal
129
+// account, but a BOINC account exists with this email, the check
130
+// will fail.
131
+$boinc_user = BoincUser::lookup_email_addr($lower_email_addr);
132
+if ($boinc_user) {
133
+// User already exists
134
+form_set_error('mail', bts('An account already exists for @email. Log in or request password assistance to access your @project account.', array('@email' => $lower_email_addr, '@project' => PROJECT), NULL, 'boinc:add-new-user'));
135
+return false;
136
+}
137 137
 
138
-  // Check Drupal name is not a duplicate, and create a proper drupal
139
-  // name from the boinc username.
140
-  $form_state['values']['name'] = create_proper_drupalname($form_state['values']['boincuser_name']);
138
+// Check Drupal name is not a duplicate, and create a proper drupal
139
+// name from the boinc username.
140
+$form_state['values']['name'] = create_proper_drupalname($form_state['values']['boincuser_name']);
141 141
 
142
-  return true;
142
+return true;
143 143
 }
144 144
 
145 145
 /**
146 146
  * Create BOINC account
147 147
  */
148 148
 function boincuser_register_make_user($params) {    
149
-  // Include BOINC user library
150
-  require_boinc('user_util');
151
-  // Create the BOINC user
152
-  $boinc_user = make_user($params['email_addr'], $params['name'], $params['passwd_hash'], $params['country'], $params['postal_code']);
153
-  return $boinc_user;
149
+// Include BOINC user library
150
+require_boinc('user_util');
151
+// Create the BOINC user
152
+$boinc_user = make_user($params['email_addr'], $params['name'], $params['passwd_hash'], $params['country'], $params['postal_code']);
153
+return $boinc_user;
154 154
 }
155 155
 
156 156
 /**
157 157
  * Create Drupal account from existing BOINC account
158 158
  */
159 159
 function boincuser_register_make_drupal_user($boinc_user) {
160
-  $account = null;
161
-  if (is_numeric($boinc_user)) {
162
-    $boinc_user = boincuser_load($boinc_user);
163
-  }
164
-  if ($boinc_user) {
165
-    $account = boincuser_create_drupal_user($boinc_user);
166
-    if ($account) {
167
-      boincuser_create_drupal_profile($account, $boinc_user);
168
-    }
169
-  }
170
-  return $account;
160
+$account = null;
161
+if (is_numeric($boinc_user)) {
162
+$boinc_user = boincuser_load($boinc_user);
163
+}
164
+if ($boinc_user) {
165
+$account = boincuser_create_drupal_user($boinc_user);
166
+if ($account) {
167
+  boincuser_create_drupal_profile($account, $boinc_user);
168
+}
169
+}
170
+return $account;
171 171
 }
172 172
 
173 173
 function boincuser_create_drupal_user($boinc_user) {
174
-  require_boinc('forum_db');
175
-  BoincForumPrefs::lookup($boinc_user);
176
-  $account = NULL;
177
-  $module = 'boincuser';
174
+require_boinc('forum_db');
175
+BoincForumPrefs::lookup($boinc_user);
176
+$account = NULL;
177
+$module = 'boincuser';
178 178
   
179
-  // Verify that this account has not already been imported
180
-  $already_imported = db_result(db_query('
179
+// Verify that this account has not already been imported
180
+$already_imported = db_result(db_query('
181 181
     SELECT COUNT(*) FROM {boincuser} WHERE boinc_id = %d',
182
-    $boinc_user->id)
183
-  );
184
-  if ($already_imported) {
185
-    return NULL;
186
-  }
182
+$boinc_user->id)
183
+);
184
+if ($already_imported) {
185
+return NULL;
186
+}
187 187
   
188
-  // Email is limited to 64 characters...
189
-  $boinc_email = substr($boinc_user->email_addr, 0, 64);
188
+// Email is limited to 64 characters...
189
+$boinc_email = substr($boinc_user->email_addr, 0, 64);
190 190
   
191
-  // Email should be unique
192
-  $already_imported = db_result(db_query("
191
+// Email should be unique
192
+$already_imported = db_result(db_query("
193 193
     SELECT COUNT(*) FROM {users} WHERE mail = '%s'",
194
-    $boinc_email)
195
-  );
196
-  if ($already_imported) {
197
-    drupal_set_message(t('An account for @email already exists', array('@email' => $boinc_email)), 'warning');
198
-    watchdog('boincimport', 'An account for @email already exists', array('@email' => $boinc_email), WATCHDOG_WARNING); 
199
-    return NULL;
200
-  }
201
-  
202
-  // Make sure name is unique
203
-  $unique_name = create_proper_drupalname($boinc_user->name);
204
-  
205
-  $userinfo = array(
206
-    'name' => $unique_name,
207
-    'pass' => $boinc_user->passwd_hash,
208
-    'mail' => $boinc_email,
209
-    'signature' => $boinc_user->prefs->signature,
210
-    'created' => $boinc_user->create_time,
211
-    'init' => $boinc_email,
212
-    'status' => 1,
213
-    "authname_{$module}" => $boinc_email,
214
-    'access' => time()
215
-  );
216
-  
217
-  $in_penalty = ($boinc_user->prefs->banished_until > time());
194
+$boinc_email)
195
+);
196
+if ($already_imported) {
197
+drupal_set_message(t('An account for @email already exists', array('@email' => $boinc_email)), 'warning');
198
+watchdog('boincimport', 'An account for @email already exists', array('@email' => $boinc_email), WATCHDOG_WARNING); 
199
+return NULL;
200
+}
218 201
   
219
-  // Add user to community member role (if no current penalty)
220
-  if (!$in_penalty) {
221
-    $community_role = array_search('community member', user_roles(true)); 
222
-    $userinfo['roles'] = array(
223
-      $community_role => ''
224
-    );
225
-  }
202
+// Make sure name is unique
203
+$unique_name = create_proper_drupalname($boinc_user->name);
204
+  
205
+$userinfo = array(
206
+'name' => $unique_name,
207
+'pass' => $boinc_user->passwd_hash,
208
+'mail' => $boinc_email,
209
+'signature' => $boinc_user->prefs->signature,
210
+'created' => $boinc_user->create_time,
211
+'init' => $boinc_email,
212
+'status' => 1,
213
+"authname_{$module}" => $boinc_email,
214
+'access' => time()
215
+);
216
+  
217
+$in_penalty = ($boinc_user->prefs->banished_until > time());
218
+  
219
+// Add user to community member role (if no current penalty)
220
+if (!$in_penalty) {
221
+$community_role = array_search('community member', user_roles(true)); 
222
+$userinfo['roles'] = array(
223
+  $community_role => ''
224
+);
225
+}
226 226
   
227
-  // Mark account as imported so a BOINC account is not created on Insert (i.e. user_save)
228
-  $_SESSION['importedUser'] = true;
229
-  $account = user_save('', $userinfo);
227
+// Mark account as imported so a BOINC account is not created on Insert (i.e. user_save)
228
+$_SESSION['importedUser'] = true;
229
+$account = user_save('', $userinfo);
230 230
   
231
-  // Drupal overrides the original registration date, so update to the correct date
232
-  $account = user_save($account, array('created' => $userinfo['created']));
231
+// Drupal overrides the original registration date, so update to the correct date
232
+$account = user_save($account, array('created' => $userinfo['created']));
233 233
   
234
-  // Terminate if an error occured during user_save().
235
-  if (!$account) {
236
-    drupal_set_message(t("Error saving user account."), 'error');
237
-    return NULL;
238
-  }
234
+// Terminate if an error occured during user_save().
235
+if (!$account) {
236
+drupal_set_message(t("Error saving user account."), 'error');
237
+return NULL;
238
+}
239 239
   
240
-  // Cross reference the Drupal and BOINC accounts
241
-  boincuser_account_cross_reference($account->uid, $boinc_user->id);
240
+// Cross reference the Drupal and BOINC accounts
241
+boincuser_account_cross_reference($account->uid, $boinc_user->id);
242 242
   
243
-  if ($in_penalty) {
244
-    // Import the timestamp of when the penalty period will be over
245
-    $boincuser_record = array(
246
-      'uid' => $account->uid,
247
-      'penalty_expiration' => $boinc_user->prefs->banished_until,
248
-    );
249
-    drupal_write_record('boincuser', $boincuser_record, 'uid');
250
-  }
243
+if ($in_penalty) {
244
+// Import the timestamp of when the penalty period will be over
245
+$boincuser_record = array(
246
+  'uid' => $account->uid,
247
+  'penalty_expiration' => $boinc_user->prefs->banished_until,
248
+);
249
+drupal_write_record('boincuser', $boincuser_record, 'uid');
250
+}
251 251
   
252
-  return $account;
252
+return $account;
253 253
 }
254 254
 
255 255
 function boincuser_create_drupal_profile($account, $boinc_user) {
256 256
   
257
-  require_boinc('forum_db');
258
-  BoincForumPrefs::lookup($boinc_user);
259
-  
260
-  $image_dir = boinc_get_path('user_image');
261
-  
262
-  // Automatically create a content profile
263
-  $now = time();
264
-  $profile_background = null;
265
-  $profile_opinions = null;
266
-  $profile_image = null;
267
-  $avatar_image = null;
268
-  $profile_approved = NULL;
269
-  
270
-  // Load the BOINC profile, if available
271
-  if ($boinc_user->has_profile) {
272
-    $boinc_profile = BoincProfile::lookup("userid={$boinc_user->id}");
273
-    $profile_background = $boinc_profile->response1;
274
-    $profile_opinions = $boinc_profile->response2;
275
-    if ($boinc_profile->has_picture) {
276
-      // Load picture; load validators; determine where to store it in Drupal
277
-      $image_path = "{$image_dir}/{$boinc_user->id}.jpg";
278
-      $profile_image = get_cck_image_object($image_path, 'field_profile_image', 'profile', TRUE);
279
-      // If the user does not have a different image as an avatar, use this one
280
-      if (!$boinc_user->prefs->avatar) {
281
-        $avatar_image = get_cck_image_object($image_path, 'field_image', 'profile', TRUE);
282
-      }
283
-    }
284
-    if ($boinc_user->prefs->avatar) {
285
-      $image_path = "{$image_dir}/{$boinc_user->id}_avatar.jpg";
286
-      $avatar_image = get_cck_image_object($image_path, 'field_image', 'profile', TRUE);
287
-    }
288
-    $profile_approved = $boinc_profile->verification ? TRUE : FALSE;
257
+require_boinc('forum_db');
258
+BoincForumPrefs::lookup($boinc_user);
259
+  
260
+$image_dir = boinc_get_path('user_image');
261
+  
262
+// Automatically create a content profile
263
+$now = time();
264
+$profile_background = null;
265
+$profile_opinions = null;
266
+$profile_image = null;
267
+$avatar_image = null;
268
+$profile_approved = NULL;
269
+  
270
+// Load the BOINC profile, if available
271
+if ($boinc_user->has_profile) {
272
+$boinc_profile = BoincProfile::lookup("userid={$boinc_user->id}");
273
+$profile_background = $boinc_profile->response1;
274
+$profile_opinions = $boinc_profile->response2;
275
+if ($boinc_profile->has_picture) {
276
+  // Load picture; load validators; determine where to store it in Drupal
277
+  $image_path = "{$image_dir}/{$boinc_user->id}.jpg";
278
+  $profile_image = get_cck_image_object($image_path, 'field_profile_image', 'profile', TRUE);
279
+  // If the user does not have a different image as an avatar, use this one
280
+  if (!$boinc_user->prefs->avatar) {
281
+    $avatar_image = get_cck_image_object($image_path, 'field_image', 'profile', TRUE);
289 282
   }
290
-  $default_input_format = db_result(db_query("
283
+}
284
+if ($boinc_user->prefs->avatar) {
285
+  $image_path = "{$image_dir}/{$boinc_user->id}_avatar.jpg";
286
+  $avatar_image = get_cck_image_object($image_path, 'field_image', 'profile', TRUE);
287
+}
288
+$profile_approved = $boinc_profile->verification ? TRUE : FALSE;
289
+}
290
+$default_input_format = db_result(db_query("
291 291
     SELECT format FROM {filter_formats} WHERE name = '%s'", 'Rich text'));
292
-  if (!$default_input_format) $default_input_format = 1;
293
-  
294
-  // Populate the profile object
295
-  $profile_node = new stdClass();
296
-  $profile_node->title = $boinc_user->name;
297
-  $profile_node->uid = $account->uid;
298
-  $profile_node->body = '';
299
-  $profile_node->type = 'profile'; 
300
-  $profile_node->created = $now;
301
-  $profile_node->changed = $now;
302
-  $profile_node->status = 1;
303
-  $profile_node->promote = 0;
304
-  $profile_node->sticky = 0;
305
-  $profile_node->format = $default_input_format;
306
-  $profile_node->name = $account->name; // Set to link profile to account uid!
307
-  $profile_node->field_country[]['value'] = $boinc_user->country;
308
-  $profile_node->field_zip[]['value'] = $boinc_user->postal_code;
309
-  $profile_node->field_url[]['value'] = $boinc_user->url;
310
-  $profile_node->field_background[]['value'] = $profile_background;
311
-  $profile_node->field_opinions[]['value'] = $profile_opinions;
312
-  $profile_node->field_image[] = $avatar_image;
313
-  $profile_node->field_profile_image[] = $profile_image;
314
-  
315
-  // Save the profile object to the database
316
-  // This will automatically set the author uid if node->name has been set
317
-  $profile_node = node_submit($profile_node);
318
-  node_save($profile_node);
319
-  
320
-  // Mark profile as approved if it has already been vetted somehow
321
-  if ($profile_approved OR !$boinc_user->has_profile) {
322
-    $profile_node->moderate = 0;
323
-    node_save($profile_node);
324
-  }
292
+if (!$default_input_format) $default_input_format = 1;
293
+  
294
+// Populate the profile object
295
+$profile_node = new stdClass();
296
+$profile_node->title = $boinc_user->name;
297
+$profile_node->uid = $account->uid;
298
+$profile_node->body = '';
299
+$profile_node->type = 'profile'; 
300
+$profile_node->created = $now;
301
+$profile_node->changed = $now;
302
+$profile_node->status = 1;
303
+$profile_node->promote = 0;
304
+$profile_node->sticky = 0;
305
+$profile_node->format = $default_input_format;
306
+$profile_node->name = $account->name; // Set to link profile to account uid!
307
+$profile_node->field_country[]['value'] = $boinc_user->country;
308
+$profile_node->field_zip[]['value'] = $boinc_user->postal_code;
309
+$profile_node->field_url[]['value'] = $boinc_user->url;
310
+$profile_node->field_background[]['value'] = $profile_background;
311
+$profile_node->field_opinions[]['value'] = $profile_opinions;
312
+$profile_node->field_image[] = $avatar_image;
313
+$profile_node->field_profile_image[] = $profile_image;
314
+  
315
+// Save the profile object to the database
316
+// This will automatically set the author uid if node->name has been set
317
+$profile_node = node_submit($profile_node);
318
+node_save($profile_node);
319
+  
320
+// Mark profile as approved if it has already been vetted somehow
321
+if ($profile_approved OR !$boinc_user->has_profile) {
322
+$profile_node->moderate = 0;
323
+node_save($profile_node);
324
+}
325 325
   
326
-  return;
326
+return;
327 327
 }
328 328
 
329 329
 function boincuser_account_cross_reference($uid, $boinc_id) {
330
-    // Cross reference Drupal account with BOINC
331
-    $reference = db_query("INSERT INTO {boincuser} SET uid=%d, boinc_id=%d", $uid, $boinc_id);
332
-    if (!$reference) {
333
-      drupal_set_message(t("Error connecting BOINC account."), 'error');
334
-      return false;
335
-    }
336
-    return true;
330
+// Cross reference Drupal account with BOINC
331
+$reference = db_query("INSERT INTO {boincuser} SET uid=%d, boinc_id=%d", $uid, $boinc_id);
332
+if (!$reference) {
333
+  drupal_set_message(t("Error connecting BOINC account."), 'error');
334
+  return false;
335
+}
336
+return true;
337 337
 }
338 338
 
339 339
 /**
340 340
  * Convert any BOINC forum thread subscriptions to Drupal flag subscriptions
341 341
  */
342 342
 function boincuser_pull_subscriptions($account = NULL) {
343
-  if (!$account) {
344
-    global $user;
345
-    $account = user_load($user->id);
346
-  }
347
-  elseif (is_numeric($account)) {
348
-    $account = user_load($account);
349
-  }
343
+if (!$account) {
344
+global $user;
345
+$account = user_load($user->id);
346
+}
347
+elseif (is_numeric($account)) {
348
+$account = user_load($account);
349
+}
350 350
   
351
-  // Get any subscriptions for this user
352
-  db_set_active('boinc_rw');
353
-  $subscriptions = db_query('
351
+// Get any subscriptions for this user
352
+db_set_active('boinc_rw');
353
+$subscriptions = db_query('
354 354
     SELECT threadid FROM {subscriptions}
355 355
     WHERE userid = %d', $account->boincuser_id);
356
-  db_set_active('default');
356
+db_set_active('default');
357 357
   
358
-  $flag = flag_get_flag('subscriptions') or die('no "subscriptions" flag defined');
359
-  $count = 0;
360
-  while ($thread_id = db_result($subscriptions)) {
361
-    // For each BOINC thread ID subscribed, look up the corresponding node ID
362
-    $nid = db_result(db_query('
358
+$flag = flag_get_flag('subscriptions') or die('no "subscriptions" flag defined');
359
+$count = 0;
360
+while ($thread_id = db_result($subscriptions)) {
361
+// For each BOINC thread ID subscribed, look up the corresponding node ID
362
+$nid = db_result(db_query('
363 363
       SELECT nid FROM {boincimport_temp_topic}
364 364
       WHERE topic_id = %d', $thread_id));
365
-    // Flag this node for the user
366
-    if ($nid > 0) {
367
-      $flag->flag('flag', $nid, $account);
368
-      $count++;
369
-    }
370
-  }
371
-  return $count;
365
+// Flag this node for the user
366
+if ($nid > 0) {
367
+  $flag->flag('flag', $nid, $account);
368
+  $count++;
369
+}
370
+}
371
+return $count;
372 372
 }
373 373
 
374 374
 
@@ -380,66 +380,66 @@  discard block
 block discarded – undo
380 380
  * User account update validation handler.
381 381
  */
382 382
 function boincuser_account_validate($edit, $account) {
383
-  // Include BOINC database objects library, load BOINC account data
384
-  require_boinc('boinc_db');
385
-  $boinc_user = BoincUser::lookup_email_addr($account->mail);
386
-  $changing_email = ($edit['mail'] AND $edit['mail'] != $account->mail) ? true : false;
387
-  $changing_pass = ($edit['pass']) ? true : false;
388
-  if ($changing_email) {
389
-    // E-mail address is set to change; check for an existing BOINC user
390
-    // Check previous email addresses as well, this user's current
391
-    // email cannot be the same as another user's previous email
392
-    // address.
393
-
394
-    // set email address lower-case
395
-    $edit['mail'] = strtolower($edit['mail']);
396
-
397
-    $boinc_user_already_exists = ( BoincUser::lookup_email_addr($edit['mail']) || BoincUser::lookup_prev_email_addr($edit['mail']) );
398
-    if ($boinc_user_already_exists) {
399
-      form_set_error('mail', bts('A BOINC account already exists for @email.', array('@email' => $edit['mail']), NULL, 'boinc:add-new-user'));
400
-    }
401
-
402
-    // Check email has not been changed in last X days (default X=7).
403
-    $duration = 86400 * 7;
404
-    if ( (($boinc_user->email_addr_change_time + $duration) > time()) and (!(user_access('administer users'))) ) {
405
-      form_set_error('email_addr_change_time',
406
-        bts('Your email address was changed within the past seven (7) days. You must wait until !futuredate to change your email again. If you need to reverse this change, please look for an email sent to !prev_email_addr.',
407
-        array(
408
-          '!futuredate' => date('F j, Y \a\t H:i T', $boinc_user->email_addr_change_time + $duration),
409
-          '!prev_email_addr' => $boinc_user->previous_email_addr,
410
-        ),
411
-        NULL, 'boinc:account-credentials-change')
412
-      );
413
-    }
414
-  }
383
+// Include BOINC database objects library, load BOINC account data
384
+require_boinc('boinc_db');
385
+$boinc_user = BoincUser::lookup_email_addr($account->mail);
386
+$changing_email = ($edit['mail'] AND $edit['mail'] != $account->mail) ? true : false;
387
+$changing_pass = ($edit['pass']) ? true : false;
388
+if ($changing_email) {
389
+// E-mail address is set to change; check for an existing BOINC user
390
+// Check previous email addresses as well, this user's current
391
+// email cannot be the same as another user's previous email
392
+// address.
393
+
394
+// set email address lower-case
395
+$edit['mail'] = strtolower($edit['mail']);
396
+
397
+$boinc_user_already_exists = ( BoincUser::lookup_email_addr($edit['mail']) || BoincUser::lookup_prev_email_addr($edit['mail']) );
398
+if ($boinc_user_already_exists) {
399
+  form_set_error('mail', bts('A BOINC account already exists for @email.', array('@email' => $edit['mail']), NULL, 'boinc:add-new-user'));
400
+}
415 401
 
416
-  // If user is changing email or password, require that the current
417
-  // password has been given as well.
418
-  if (($changing_email OR $changing_pass) AND !user_access('administer users')) {
419
-    // If changing email or password, require current password
420
-    // (except in cases where password is being reset)
421
-    if (isset($_SESSION['reset_pass'])) {
422
-      unset($_SESSION['reset_pass']);
423
-    }
424
-    else {
425
-      $given_hash = md5($edit['current_pass'] . strtolower($account->mail));
426
-      if (!$edit['current_pass']) {
427
-        form_set_error('current_pass', bts('Authentication is required when changing E-mail address or setting new password.', array(), NULL, 'boinc:account-credentials-change'));
428
-      }
429
-      elseif ( (!password_verify($given_hash, $boinc_user->passwd_hash)) and ($given_hash != $boinc_user->passwd_hash) ) {
430
-        form_set_error('current_pass', bts('Password entered is not valid. Please verify that it is correct.', array(), NULL, 'boinc:account-credentials-change'));
431
-      }
432
-
433
-    }
434
-  }
402
+// Check email has not been changed in last X days (default X=7).
403
+$duration = 86400 * 7;
404
+if ( (($boinc_user->email_addr_change_time + $duration) > time()) and (!(user_access('administer users'))) ) {
405
+  form_set_error('email_addr_change_time',
406
+    bts('Your email address was changed within the past seven (7) days. You must wait until !futuredate to change your email again. If you need to reverse this change, please look for an email sent to !prev_email_addr.',
407
+    array(
408
+      '!futuredate' => date('F j, Y \a\t H:i T', $boinc_user->email_addr_change_time + $duration),
409
+      '!prev_email_addr' => $boinc_user->previous_email_addr,
410
+    ),
411
+    NULL, 'boinc:account-credentials-change')
412
+  );
413
+}
414
+}
435 415
 
436
-  // If an admin tries to change the email and NOT the password, show
437
-  // error message. BOINC requires both to be changed together.
438
-  if ($changing_email AND !$changing_pass AND user_access('administer users')) {
439
-    form_set_error('pass', bts('If changing a user\'s email, you must also change the password simultaneously.', array(), NULL, 'boinc:account-credentials-change'));
416
+// If user is changing email or password, require that the current
417
+// password has been given as well.
418
+if (($changing_email OR $changing_pass) AND !user_access('administer users')) {
419
+// If changing email or password, require current password
420
+// (except in cases where password is being reset)
421
+if (isset($_SESSION['reset_pass'])) {
422
+  unset($_SESSION['reset_pass']);
423
+}
424
+else {
425
+  $given_hash = md5($edit['current_pass'] . strtolower($account->mail));
426
+  if (!$edit['current_pass']) {
427
+    form_set_error('current_pass', bts('Authentication is required when changing E-mail address or setting new password.', array(), NULL, 'boinc:account-credentials-change'));
440 428
   }
429
+  elseif ( (!password_verify($given_hash, $boinc_user->passwd_hash)) and ($given_hash != $boinc_user->passwd_hash) ) {
430
+    form_set_error('current_pass', bts('Password entered is not valid. Please verify that it is correct.', array(), NULL, 'boinc:account-credentials-change'));
431
+  }
432
+
433
+}
434
+}
435
+
436
+// If an admin tries to change the email and NOT the password, show
437
+// error message. BOINC requires both to be changed together.
438
+if ($changing_email AND !$changing_pass AND user_access('administer users')) {
439
+form_set_error('pass', bts('If changing a user\'s email, you must also change the password simultaneously.', array(), NULL, 'boinc:account-credentials-change'));
440
+}
441 441
   
442
-  // Expansion required to allow account key in place of passwd...?
442
+// Expansion required to allow account key in place of passwd...?
443 443
   
444 444
 }
445 445
 
@@ -452,125 +452,125 @@  discard block
 block discarded – undo
452 452
  * Password request validation handler.
453 453
  */
454 454
 function boincuser_request_pass_validate($form, &$form_state) {
455
-  $edit = $form_state['values'];
456
-  // The Drupal submit function expects a "name" field, even though
457
-  // it contains an email address and we will not allow a user name
458
-  if (!$edit['name']) form_set_error('name', bts('Please enter your email address', array(), NULL, 'boinc:forgot-password'));
459
-  elseif (!valid_email_address($edit['name'])) form_set_error('name', bts('@email is not a well formed email address, please verify', array('@email' => $edit['name']), NULL, 'boinc:forgot-password'));
460
-  else {
461
-    // set email addrress to lower case
462
-    $lower_email_addr = strtolower($edit['name']);
463
-
464
-    // First look for an existing Drupal account
465
-    if ($account = user_load_by_mail($lower_email_addr)) return;
466
-    // Otherwise, check the BOINC db for this email address
467
-    require_boinc('boinc_db');
468
-    $boinc_user = BoincUser::lookup_email_addr($lower_email_addr);
469
-    if ($boinc_user) {
470
-      // If the user is in BOINC but not Drupal, bring them over...
471
-      boincuser_register_make_drupal_user($boinc_user);
472
-    } else {
473
-      // If there is no existing BOINC user either, show an error
474
-      form_set_error('name', bts('No account exists for @email -- please create an account using a BOINC client -- !instructions',
475
-      array(
476
-          '@email' => $edit['name'],
477
-          '!instructions' => l(bts('Instructions', array(), NULL, 'boinc:forgot-password'), 'join')
478
-      ), NULL, 'boinc:forgot-password'));
479
-    }
480
-  }
455
+$edit = $form_state['values'];
456
+// The Drupal submit function expects a "name" field, even though
457
+// it contains an email address and we will not allow a user name
458
+if (!$edit['name']) form_set_error('name', bts('Please enter your email address', array(), NULL, 'boinc:forgot-password'));
459
+elseif (!valid_email_address($edit['name'])) form_set_error('name', bts('@email is not a well formed email address, please verify', array('@email' => $edit['name']), NULL, 'boinc:forgot-password'));
460
+else {
461
+// set email addrress to lower case
462
+$lower_email_addr = strtolower($edit['name']);
463
+
464
+// First look for an existing Drupal account
465
+if ($account = user_load_by_mail($lower_email_addr)) return;
466
+// Otherwise, check the BOINC db for this email address
467
+require_boinc('boinc_db');
468
+$boinc_user = BoincUser::lookup_email_addr($lower_email_addr);
469
+if ($boinc_user) {
470
+  // If the user is in BOINC but not Drupal, bring them over...
471
+  boincuser_register_make_drupal_user($boinc_user);
472
+} else {
473
+  // If there is no existing BOINC user either, show an error
474
+  form_set_error('name', bts('No account exists for @email -- please create an account using a BOINC client -- !instructions',
475
+  array(
476
+      '@email' => $edit['name'],
477
+      '!instructions' => l(bts('Instructions', array(), NULL, 'boinc:forgot-password'), 'join')
478
+  ), NULL, 'boinc:forgot-password'));
479
+}
480
+}
481 481
 }
482 482
 
483 483
 /**
484 484
  * The definition of the authenticator login form.
485 485
  */
486 486
 function boincuser_authloginform() {
487
-  $headers = apache_request_headers();
488
-  $project_name = variable_get('site_name', 'Drupal-BOINC');
489
-  $project_domain = $headers['Host'];
490
-  $form['heading'] = array(
491
-    '#type' => 'markup',
492
-    '#value' => '<h3>' . bts("If you forgot your account's email address, or you can't receive email there:", array(), NULL, 'boinc:authenticator-login-page') . '</h3>'
493
-  );
494
-  $form['instructions'] = array(
495
-    '#type' => 'markup',
496
-    '#value' => '' .
497
-      '<p>' . bts("If you have run BOINC under the account, you can still access it. Here's how:", array(), NULL, 'boinc:authenticator-login-page') .
498
-      '  <ul>' .
499
-      '    <li>' . bts('Go to the BOINC data directory on your computer (see !boinc_wiki for help finding this).', array('!boinc_wiki' => l(bts('BOINC documentation', array(), NULL, 'boinc:authenticator-login-page'), 'http://boinc.berkeley.edu/wiki/BOINC_Data_directory')), NULL, 'boinc:authenticator-login-page') . '</li>' .
500
-      '    <li>' . bts('Find your account file for this project; it will have a name like %file (where the project URL is %url).', array('%file' => "account_{$project_domain}.xml", '%url' => "http://{$project_domain}"), NULL, 'boinc:authenticator-login-page') . '</li>' .
501
-      '    <li>' . bts("Open the file in a text editor like Notepad. You'll see something like:", array(), NULL, 'boinc:authenticator-login-page') .
502
-      '      <pre>' .
503
-      '&lt;account&gt;' . "\n" .
504
-      "  &lt;master_url&gt;http://{$project_domain}/&lt;/master_url&gt;" . "\n" .
505
-      '  &lt;authenticator&gt;8b8496fdd26df7dc0423ecd43c09a56b&lt;/authenticator&gt;' . "\n" .
506
-      "  &lt;project_name&gt;{$project_name}&lt;/project_name&gt;" . "\n" .
507
-      '  ...' . "\n" .
508
-      '&lt;/account&gt;' .
509
-      '      </pre>' .
510
-      '    </li>' .
511
-      '    <li>' . bts('Select and Copy the string between &lt;authenticator&gt; and &lt;/authenticator&gt; (%auth in the above example).', array('%auth' => '8b8496fdd26df7dc0423ecd43c09a56b'), NULL, 'boinc:authenticator-login-page') . '</li>' .
512
-      '    <li>' . bts('Paste the string into the field below, and click OK.', array(), NULL, 'boinc:authenticator-login-page') . '</li>' .
513
-      '    <li>' . bts('You will now be logged in to your account; update the email and password of your account.', array(), NULL, 'boinc:authenticator-login-page') . '</li>' .
514
-      '  </ul>' .
515
-      '</p>'
516
-  );
517
-  $form['authenticator'] = array(
518
-    '#title' => bts('Log in with authenticator', array(), NULL, 'boinc:authenticator-login-page'),
519
-    '#type' => 'textfield',
520
-    '#size' => 60,
521
-    '#maxlength' => 32,
522
-    '#required' => TRUE,
523
-    '#description' => null
524
-  );
525
-  
526
-  // Form control
527
-  $form['form control tabs prefix'] = array(
528
-    '#value' => '<ul class="form-control tab-list">',
529
-    '#weight' => 1001,
530
-  );
531
-  $form['submit'] = array(
532
-    '#prefix' => '<li class="first tab">',
533
-    '#type' => 'submit',
534
-    '#value' => bts('OK', array(), NULL, 'boinc:form-ok'),
535
-    '#suffix' => '</li>',
536
-    '#weight' => 1002,
537
-  );
538
-  $form['form control tabs'] = array(
539
-    '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'user/password') . '</li>',
540
-    '#weight' => 1003,
541
-  );
542
-  $form['form control tabs suffix'] = array(
543
-    '#value' => '</ul>',
544
-    '#weight' => 1004,
545
-  );
546
-  return $form;
487
+$headers = apache_request_headers();
488
+$project_name = variable_get('site_name', 'Drupal-BOINC');
489
+$project_domain = $headers['Host'];
490
+$form['heading'] = array(
491
+'#type' => 'markup',
492
+'#value' => '<h3>' . bts("If you forgot your account's email address, or you can't receive email there:", array(), NULL, 'boinc:authenticator-login-page') . '</h3>'
493
+);
494
+$form['instructions'] = array(
495
+'#type' => 'markup',
496
+'#value' => '' .
497
+  '<p>' . bts("If you have run BOINC under the account, you can still access it. Here's how:", array(), NULL, 'boinc:authenticator-login-page') .
498
+  '  <ul>' .
499
+  '    <li>' . bts('Go to the BOINC data directory on your computer (see !boinc_wiki for help finding this).', array('!boinc_wiki' => l(bts('BOINC documentation', array(), NULL, 'boinc:authenticator-login-page'), 'http://boinc.berkeley.edu/wiki/BOINC_Data_directory')), NULL, 'boinc:authenticator-login-page') . '</li>' .
500
+  '    <li>' . bts('Find your account file for this project; it will have a name like %file (where the project URL is %url).', array('%file' => "account_{$project_domain}.xml", '%url' => "http://{$project_domain}"), NULL, 'boinc:authenticator-login-page') . '</li>' .
501
+  '    <li>' . bts("Open the file in a text editor like Notepad. You'll see something like:", array(), NULL, 'boinc:authenticator-login-page') .
502
+  '      <pre>' .
503
+  '&lt;account&gt;' . "\n" .
504
+  "  &lt;master_url&gt;http://{$project_domain}/&lt;/master_url&gt;" . "\n" .
505
+  '  &lt;authenticator&gt;8b8496fdd26df7dc0423ecd43c09a56b&lt;/authenticator&gt;' . "\n" .
506
+  "  &lt;project_name&gt;{$project_name}&lt;/project_name&gt;" . "\n" .
507
+  '  ...' . "\n" .
508
+  '&lt;/account&gt;' .
509
+  '      </pre>' .
510
+  '    </li>' .
511
+  '    <li>' . bts('Select and Copy the string between &lt;authenticator&gt; and &lt;/authenticator&gt; (%auth in the above example).', array('%auth' => '8b8496fdd26df7dc0423ecd43c09a56b'), NULL, 'boinc:authenticator-login-page') . '</li>' .
512
+  '    <li>' . bts('Paste the string into the field below, and click OK.', array(), NULL, 'boinc:authenticator-login-page') . '</li>' .
513
+  '    <li>' . bts('You will now be logged in to your account; update the email and password of your account.', array(), NULL, 'boinc:authenticator-login-page') . '</li>' .
514
+  '  </ul>' .
515
+  '</p>'
516
+);
517
+$form['authenticator'] = array(
518
+'#title' => bts('Log in with authenticator', array(), NULL, 'boinc:authenticator-login-page'),
519
+'#type' => 'textfield',
520
+'#size' => 60,
521
+'#maxlength' => 32,
522
+'#required' => TRUE,
523
+'#description' => null
524
+);
525
+  
526
+// Form control
527
+$form['form control tabs prefix'] = array(
528
+'#value' => '<ul class="form-control tab-list">',
529
+'#weight' => 1001,
530
+);
531
+$form['submit'] = array(
532
+'#prefix' => '<li class="first tab">',
533
+'#type' => 'submit',
534
+'#value' => bts('OK', array(), NULL, 'boinc:form-ok'),
535
+'#suffix' => '</li>',
536
+'#weight' => 1002,
537
+);
538
+$form['form control tabs'] = array(
539
+'#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'user/password') . '</li>',
540
+'#weight' => 1003,
541
+);
542
+$form['form control tabs suffix'] = array(
543
+'#value' => '</ul>',
544
+'#weight' => 1004,
545
+);
546
+return $form;
547 547
 }
548 548
 
549 549
 /**
550 550
  * The authenticator login validation handler
551 551
  */
552 552
 function boincuser_authloginform_validate($form, &$form_state) {
553
-  $authenticator = $form_state['values']['authenticator'];
554
-  if (strlen($authenticator) != 32) {
555
-    // We notify the form API that this field has failed validation.
556
-    form_set_error('authenticator', bts('That authenticator is not valid.', array(), NULL, 'boinc:authenticator-login-page'));
557
-  } else {
558
-    require_boinc('boinc_db');
559
-    $boinc_user = BoincUser::lookup("authenticator='".addslashes($authenticator)."'");
560
-    if (!$boinc_user) form_set_error('authenticator', bts('There is no account with that authenticator.', array(), NULL, 'boinc:authenticator-login-page'));
561
-  }
553
+$authenticator = $form_state['values']['authenticator'];
554
+if (strlen($authenticator) != 32) {
555
+// We notify the form API that this field has failed validation.
556
+form_set_error('authenticator', bts('That authenticator is not valid.', array(), NULL, 'boinc:authenticator-login-page'));
557
+} else {
558
+require_boinc('boinc_db');
559
+$boinc_user = BoincUser::lookup("authenticator='".addslashes($authenticator)."'");
560
+if (!$boinc_user) form_set_error('authenticator', bts('There is no account with that authenticator.', array(), NULL, 'boinc:authenticator-login-page'));
561
+}
562 562
 }
563 563
 
564 564
 /**
565 565
  * The authenticator login submit handler
566 566
  */
567 567
 function boincuser_authloginform_submit($form, &$form_state) {
568
-  global $user;
569
-  $authenticator = $form_state['values']['authenticator'];
570
-  require_boinc('boinc_db');
571
-  $boinc_user = BoincUser::lookup("authenticator='".addslashes($authenticator)."'");
572
-  if (!$user = user_load(get_drupal_id($boinc_user->id))) drupal_set_message(t('An unresolved error occurred while logging into this account.'));
573
-  else $form_state['redirect'] = 'account/info/edit';
568
+global $user;
569
+$authenticator = $form_state['values']['authenticator'];
570
+require_boinc('boinc_db');
571
+$boinc_user = BoincUser::lookup("authenticator='".addslashes($authenticator)."'");
572
+if (!$user = user_load(get_drupal_id($boinc_user->id))) drupal_set_message(t('An unresolved error occurred while logging into this account.'));
573
+else $form_state['redirect'] = 'account/info/edit';
574 574
 }
575 575
 
576 576
 
@@ -578,44 +578,44 @@  discard block
 block discarded – undo
578 578
  * The definition of the moderator reject user profile form.
579 579
  */
580 580
 function boincuser_moderate_profile_reject_form(&$form_state, $uid) {
581
-  $form_state['storage']['reject_profile_uid'] = $uid;
582
-  $form['reason'] = array(
583
-    '#title' => bts('Reason for rejecting this profile', array(), NULL, 'boinc:moderate-user'),
584
-    '#type' => 'textarea',
585
-    '#description' => bts('This reason will be included in an email to the user. Please write a brief explanation of the problem and how to fix it.', array(), NULL, 'boinc:moderate-user'),
586
-    '#default_value' => '',
587
-  );
588
-  
589
-  // Form control
590
-  $form['form control tabs prefix'] = array(
591
-    '#value' => '<ul class="form-control tab-list">',
592
-    '#weight' => 1001,
593
-  );
594
-  $form['submit'] = array(
595
-    '#prefix' => '<li class="first tab">',
596
-    '#type' => 'submit',
597
-    '#value' => bts('Submit', array(), NULL, 'boinc:form-submit'),
598
-    '#suffix' => '</li>',
599
-    '#weight' => 1002,
600
-  );
601
-  $form['form control tabs'] = array(
602
-    '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/{$uid}") . '</li>',
603
-    '#weight' => 1003,
604
-  );
605
-  $form['form control tabs suffix'] = array(
606
-    '#value' => '</ul>',
607
-    '#weight' => 1004,
608
-  );
609
-  return $form;
581
+$form_state['storage']['reject_profile_uid'] = $uid;
582
+$form['reason'] = array(
583
+'#title' => bts('Reason for rejecting this profile', array(), NULL, 'boinc:moderate-user'),
584
+'#type' => 'textarea',
585
+'#description' => bts('This reason will be included in an email to the user. Please write a brief explanation of the problem and how to fix it.', array(), NULL, 'boinc:moderate-user'),
586
+'#default_value' => '',
587
+);
588
+  
589
+// Form control
590
+$form['form control tabs prefix'] = array(
591
+'#value' => '<ul class="form-control tab-list">',
592
+'#weight' => 1001,
593
+);
594
+$form['submit'] = array(
595
+'#prefix' => '<li class="first tab">',
596
+'#type' => 'submit',
597
+'#value' => bts('Submit', array(), NULL, 'boinc:form-submit'),
598
+'#suffix' => '</li>',
599
+'#weight' => 1002,
600
+);
601
+$form['form control tabs'] = array(
602
+'#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/{$uid}") . '</li>',
603
+'#weight' => 1003,
604
+);
605
+$form['form control tabs suffix'] = array(
606
+'#value' => '</ul>',
607
+'#weight' => 1004,
608
+);
609
+return $form;
610 610
 }
611 611
 
612 612
 /**
613 613
  * The moderator reject user profile submit handler
614 614
  */
615 615
 function boincuser_moderate_profile_reject_form_submit($form, &$form_state) {
616
-  $uid = $form_state['storage']['reject_profile_uid'];
617
-  $reason = $form_state['values']['reason'];
618
-  boincuser_moderate_profile_reject($uid, $reason);
616
+$uid = $form_state['storage']['reject_profile_uid'];
617
+$reason = $form_state['values']['reason'];
618
+boincuser_moderate_profile_reject($uid, $reason);
619 619
 }
620 620
 
621 621
 
@@ -623,52 +623,52 @@  discard block
 block discarded – undo
623 623
  * The definition of the ban user form.
624 624
  */
625 625
 function boincuser_moderate_user_ban_form(&$form_state, $uid) {
626
-  $form_state['storage']['ban_user_uid'] = $uid;
627
-  $form['reason'] = array(
628
-    '#title' => bts('Reason for banning this user', array(), NULL, 'boinc:moderate-user'),
629
-    '#type' => 'textarea',
630
-    '#description' => bts('This reason will be included in an email to the user. Please write a brief explanation of why the user is being banned.', array(), NULL, 'boinc:moderate-user'),
631
-    '#default_value' => '',
632
-  );
633
-  $form['duration'] = array(
634
-    '#title' => bts('Duration of the ban', array(), NULL, 'boinc:moderate-user'),
635
-    '#type' => 'textfield',
636
-    '#description' => bts('The number of days until the ban expires. Set to 0 to ban permanently.', array(), NULL, 'boinc:moderate-user'),
637
-    '#default_value' => '',
638
-  );
639
-  
640
-  // Form control
641
-  $form['form control tabs prefix'] = array(
642
-    '#value' => '<ul class="form-control tab-list">',
643
-    '#weight' => 1001,
644
-  );
645
-  $form['submit'] = array(
646
-    '#prefix' => '<li class="first tab">',
647
-    '#type' => 'submit',
648
-    '#value' => bts('Submit', array(), NULL, 'boinc:form-submit'),
649
-    '#suffix' => '</li>',
650
-    '#weight' => 1002,
651
-  );
652
-  $form['form control tabs'] = array(
653
-    '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/{$uid}") . '</li>',
654
-    '#weight' => 1003,
655
-  );
656
-  $form['form control tabs suffix'] = array(
657
-    '#value' => '</ul>',
658
-    '#weight' => 1004,
659
-  );
660
-  return $form;
626
+$form_state['storage']['ban_user_uid'] = $uid;
627
+$form['reason'] = array(
628
+'#title' => bts('Reason for banning this user', array(), NULL, 'boinc:moderate-user'),
629
+'#type' => 'textarea',
630
+'#description' => bts('This reason will be included in an email to the user. Please write a brief explanation of why the user is being banned.', array(), NULL, 'boinc:moderate-user'),
631
+'#default_value' => '',
632
+);
633
+$form['duration'] = array(
634
+'#title' => bts('Duration of the ban', array(), NULL, 'boinc:moderate-user'),
635
+'#type' => 'textfield',
636
+'#description' => bts('The number of days until the ban expires. Set to 0 to ban permanently.', array(), NULL, 'boinc:moderate-user'),
637
+'#default_value' => '',
638
+);
639
+  
640
+// Form control
641
+$form['form control tabs prefix'] = array(
642
+'#value' => '<ul class="form-control tab-list">',
643
+'#weight' => 1001,
644
+);
645
+$form['submit'] = array(
646
+'#prefix' => '<li class="first tab">',
647
+'#type' => 'submit',
648
+'#value' => bts('Submit', array(), NULL, 'boinc:form-submit'),
649
+'#suffix' => '</li>',
650
+'#weight' => 1002,
651
+);
652
+$form['form control tabs'] = array(
653
+'#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "account/{$uid}") . '</li>',
654
+'#weight' => 1003,
655
+);
656
+$form['form control tabs suffix'] = array(
657
+'#value' => '</ul>',
658
+'#weight' => 1004,
659
+);
660
+return $form;
661 661
 }
662 662
 
663 663
 /**
664 664
  * The ban user submit handler
665 665
  */
666 666
 function boincuser_moderate_user_ban_form_submit($form, &$form_state) {
667
-  $uid = $form_state['storage']['ban_user_uid'];
668
-  $reason = $form_state['values']['reason'];
669
-  $duration = $form_state['values']['duration'];
670
-  if ($duration) $duration = $duration * 24*60*60;
671
-  boincuser_moderate_user_ban($uid, $reason, $duration);
667
+$uid = $form_state['storage']['ban_user_uid'];
668
+$reason = $form_state['values']['reason'];
669
+$duration = $form_state['values']['duration'];
670
+if ($duration) $duration = $duration * 24*60*60;
671
+boincuser_moderate_user_ban($uid, $reason, $duration);
672 672
 }
673 673
 
674 674
 
@@ -676,10 +676,10 @@  discard block
 block discarded – undo
676 676
  * Hack to fix submission of the flag friend unfriend form
677 677
  */
678 678
 function boincuser_fix_unfriend_form_submit($form, &$form_state) {
679
-  // Leaving action as "unfriend" causes problems
680
-  if ($form_state['values']['action'] == 'unfriend') {
681
-    $form_state['values']['action'] = 'unflag';
682
-  }
679
+// Leaving action as "unfriend" causes problems
680
+if ($form_state['values']['action'] == 'unfriend') {
681
+$form_state['values']['action'] = 'unflag';
682
+}
683 683
 }
684 684
 
685 685
 /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
@@ -687,99 +687,99 @@  discard block
 block discarded – undo
687 687
  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  */
688 688
 
689 689
 function boincuser_termsofuse_form() {
690
-  global $user;
691
-
692
-  // If user has already signed terms of use, and got to this form in error, send them to site home.
693
-  if (boincuser_check_termsofuse($user)) {
694
-    drupal_goto();
695
-  }
696
-
697
-  drupal_set_message( bts('WARNING: You have not agreed to our terms of use. Please agree to the terms of use before continuing.', array(), NULL, 'boinc:termsofuse-form'), 'warning' );
698
-
699
-  $form = array();
700
-  drupal_add_js(drupal_get_path('module', 'boincuser') . '/boincuser.js');
701
-  $termsofuse = variable_get('boinc_weboptions_termsofuse', '');
702
-
703
-  // Fieldset to hold all of the form as a container
704
-  $form['termsofuse'] = array(
705
-    '#type'   => 'fieldset',
706
-    '#prefix' => '<div id="termsofuse-wrapper">', // This is our wrapper div.
707
-    '#suffix' => '</div>',
708
-    '#tree'   => TRUE,
709
-  );
690
+global $user;
710 691
 
711
-  $form['termsofuse']['title1'] = array(
712
-    '#weight' => -12,
713
-    '#value' => '<h2>' . bts( variable_get('boinc_weboptions_registrationtitle', 'Please read and acknowledge our terms of use'), array(), NULL, 'project:termsofuse-form' ) . '</h2>',
714
-    '#prefix' => '<div id="register-title1">',
715
-    '#suffix' => '</div>',
716
-  );
717
-
718
-  // Terms of use section
719
-  $form['termsofuse']['body'] = array(
720
-    '#weight' => -10,
721
-    '#value' => bts($termsofuse, array(), NULL, 'project:termsofuse-form'),
722
-    '#prefix' => '<div id="register-termsofuse">',
723
-    '#suffix' => '</div>',
724
-  );
725
-
726
-  $form['termsofuse']['agreeTOU'] = array(
727
-    '#type'   => 'checkbox',
728
-    '#title'  => bts(variable_get('boinc_weboptions_agreequestion', 'Do you agree with the above terms of use?'), array(), NULL, 'project:termsofuse-form'),
729
-    '#weight' => -8,
730
-    '#prefix' => '<div id="register-checkbox">',
731
-    '#suffix' => '</div>',
732
-  );
733
-
734
-  $form['termsofuse']['spacer'] = array(
735
-    '#prefix' => '<div class="clearfix" id="register-title2">',
736
-    '#value'  => '&nbsp;',
737
-    '#suffix' => '</div>',
738
-  );
692
+// If user has already signed terms of use, and got to this form in error, send them to site home.
693
+if (boincuser_check_termsofuse($user)) {
694
+drupal_goto();
695
+}
739 696
 
740
-  // Form Control
741
-  $form['submit'] = array(
742
-    '#prefix' => '<p><p><p><li class="first tab" id="register-submit">',
743
-    '#type' => 'submit',
744
-    '#value' => bts('Yes', array(), NULL, 'boinc:form-submit'),
745
-    '#suffix' => '</li>',
746
-  );
747
-  $form['form control tabs'] = array(
748
-    '#value' => '<li class="tab">' . l(bts('NO - LOGOUT', array(), NULL, 'boinc:form-cancel'), '/logout') . '</li>',
749
-  );
750
-  if (module_exists('boincuser_delete')) {
751
-    $deletelink = '/user/' . $user->uid . '/delete';
752
-    $form['deleteaccount'] = array(
753
-      '#value' => '<li class="tab">' . l(bts('NO - DELETE ACCOUNT', array(), NULL, 'boinc:form-delete-user'), $deletelink) . '</li>',
754
-    );
755
-  }
697
+drupal_set_message( bts('WARNING: You have not agreed to our terms of use. Please agree to the terms of use before continuing.', array(), NULL, 'boinc:termsofuse-form'), 'warning' );
698
+
699
+$form = array();
700
+drupal_add_js(drupal_get_path('module', 'boincuser') . '/boincuser.js');
701
+$termsofuse = variable_get('boinc_weboptions_termsofuse', '');
702
+
703
+// Fieldset to hold all of the form as a container
704
+$form['termsofuse'] = array(
705
+'#type'   => 'fieldset',
706
+'#prefix' => '<div id="termsofuse-wrapper">', // This is our wrapper div.
707
+'#suffix' => '</div>',
708
+'#tree'   => TRUE,
709
+);
710
+
711
+$form['termsofuse']['title1'] = array(
712
+'#weight' => -12,
713
+'#value' => '<h2>' . bts( variable_get('boinc_weboptions_registrationtitle', 'Please read and acknowledge our terms of use'), array(), NULL, 'project:termsofuse-form' ) . '</h2>',
714
+'#prefix' => '<div id="register-title1">',
715
+'#suffix' => '</div>',
716
+);
717
+
718
+// Terms of use section
719
+$form['termsofuse']['body'] = array(
720
+'#weight' => -10,
721
+'#value' => bts($termsofuse, array(), NULL, 'project:termsofuse-form'),
722
+'#prefix' => '<div id="register-termsofuse">',
723
+'#suffix' => '</div>',
724
+);
725
+
726
+$form['termsofuse']['agreeTOU'] = array(
727
+'#type'   => 'checkbox',
728
+'#title'  => bts(variable_get('boinc_weboptions_agreequestion', 'Do you agree with the above terms of use?'), array(), NULL, 'project:termsofuse-form'),
729
+'#weight' => -8,
730
+'#prefix' => '<div id="register-checkbox">',
731
+'#suffix' => '</div>',
732
+);
733
+
734
+$form['termsofuse']['spacer'] = array(
735
+'#prefix' => '<div class="clearfix" id="register-title2">',
736
+'#value'  => '&nbsp;',
737
+'#suffix' => '</div>',
738
+);
739
+
740
+// Form Control
741
+$form['submit'] = array(
742
+'#prefix' => '<p><p><p><li class="first tab" id="register-submit">',
743
+'#type' => 'submit',
744
+'#value' => bts('Yes', array(), NULL, 'boinc:form-submit'),
745
+'#suffix' => '</li>',
746
+);
747
+$form['form control tabs'] = array(
748
+'#value' => '<li class="tab">' . l(bts('NO - LOGOUT', array(), NULL, 'boinc:form-cancel'), '/logout') . '</li>',
749
+);
750
+if (module_exists('boincuser_delete')) {
751
+$deletelink = '/user/' . $user->uid . '/delete';
752
+$form['deleteaccount'] = array(
753
+  '#value' => '<li class="tab">' . l(bts('NO - DELETE ACCOUNT', array(), NULL, 'boinc:form-delete-user'), $deletelink) . '</li>',
754
+);
755
+}
756 756
 
757
-  // Set form redirect
758
-  $form['#redirect'] = $_REQUEST['destination'];
757
+// Set form redirect
758
+$form['#redirect'] = $_REQUEST['destination'];
759 759
 
760
-  // Add the current user's data into the form
761
-  $form['#account'] = $user;
760
+// Add the current user's data into the form
761
+$form['#account'] = $user;
762 762
 
763
-  return $form;
763
+return $form;
764 764
 }
765 765
 
766 766
 function boincuser_termsofuse_form_validate($form, &$form_state) {
767
-  // Check TOU agreement
768
-  if (!$form_state['values']['termsofuse']['agreeTOU']) {
769
-    form_set_error('termsofuse', bts('ERROR: You must acknowledge our terms of use by clicking the checkbox before registering for an account.', array(), NULL, 'boinc:termsofuse-form'));
770
-  }
767
+// Check TOU agreement
768
+if (!$form_state['values']['termsofuse']['agreeTOU']) {
769
+form_set_error('termsofuse', bts('ERROR: You must acknowledge our terms of use by clicking the checkbox before registering for an account.', array(), NULL, 'boinc:termsofuse-form'));
770
+}
771 771
 }
772 772
 
773 773
 function boincuser_termsofuse_form_submit($form, &$form_state) {
774
-  $user = $form['#account'];
775
-  if (!boincuser_consentto_termsofuse($user)) {
776
-    form_set_error('termsofuse', bts('There was an error in agreeing to the terms of use. Please contact the site administrators.', array(), NULL, 'boinc:termsofuse-form'));
777
-  }
774
+$user = $form['#account'];
775
+if (!boincuser_consentto_termsofuse($user)) {
776
+form_set_error('termsofuse', bts('There was an error in agreeing to the terms of use. Please contact the site administrators.', array(), NULL, 'boinc:termsofuse-form'));
777
+}
778 778
 
779
-  // Delete session messages
780
-  if ($_SESSION['messages']['warning']) {
781
-    unset($_SESSION['messages']['warning']);
782
-  }
779
+// Delete session messages
780
+if ($_SESSION['messages']['warning']) {
781
+unset($_SESSION['messages']['warning']);
782
+}
783 783
 }
784 784
 
785 785
 /**
@@ -788,88 +788,88 @@  discard block
 block discarded – undo
788 788
  * removed after used.
789 789
  */
790 790
 function boincuser_revertemail(&$form_state, $token) {
791
-  require_boinc('token');
792
-  require_boinc('util');
793
-
794
-  global $user;
795
-  $form = array();
796
-
797
-  // drupal JS for dynamic password validation
798
-  _user_password_dynamic_validation();
799
-
800
-  // check BOINC user exists
801
-  $account = user_load(array('uid' => $user->uid));
802
-  $uid = $user->uid;
803
-  $boincid = $account->boincuser_id;
804
-  // check $token is valid
805
-  if (!is_valid_token($boincid, $token, 'E')) {
806
-    drupal_set_message(bts('ERROR: You have supplied an incorrect (most likely expired) token. Please obtain a new token by !link your email address.',
807
-    array(
808
-      '!link' => l(bts('changing', array(), NULL, 'boinc:revert-email-change'), "/account/info/edit"),
809
-    ),
810
-    NULL, 'boinc:revert-email-change'), 'error');
811
-    drupal_goto();
812
-  }
813
-
814
-  // Attach account and token to this form.
815
-  $form['_account'] = array('#type' => 'value', '#value' => $account);
816
-  $form['_token'] = array('#type' => 'value', '#value' => $token);
817
-
818
-  // Instructions
819
-  $form['main']['instructions1'] = array(
820
-    '#value' => '<p>'.
821
-    bts('In order to change your email back to your previous email address, <strong>!prev_email</strong>, you must also change your password.',
822
-      array(
823
-        '!prev_email' => $account->boincuser_previous_email_addr,
824
-      ),
825
-      NULL, 'boinc:revert-email-change').
826
-    '</p>',
827
-  );
828
-
829
-  $form['main']['pass'] = array(
830
-    '#type' => 'password_confirm',
831
-    '#description' => 'Enter a new password in both fields',
832
-    '#size' => 17,
833
-  );
834
-
835
-  // Wrap action buttons for styling consistency
836
-  $form['buttons']['form control tabs prefix'] = array(
837
-      '#value' => '<ul class="form-control tab-list">',
838
-      '#weight' => 1001,
839
-  );
840
-  $form['buttons']['submit']['#type'] = 'submit';
841
-  $form['buttons']['submit']['#prefix'] = '<li class="first tab">';
842
-  $form['buttons']['submit']['#value'] = bts('Submit', array(), NULL, 'boinc:form-submit');
843
-  $form['buttons']['submit']['#suffix'] = '</li>';
844
-  $form['buttons']['submit']['#weight'] = 1002;
845
-  $form['buttons']['cancel'] = array(
846
-      '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'user/info/edit') . '</li>',
847
-      '#weight' => 1005,
848
-  );
849
-  $form['buttons']['form control tabs suffix'] = array(
850
-      '#value' => '</ul>',
851
-      '#weight' => 1010,
852
-  );
791
+require_boinc('token');
792
+require_boinc('util');
793
+
794
+global $user;
795
+$form = array();
796
+
797
+// drupal JS for dynamic password validation
798
+_user_password_dynamic_validation();
799
+
800
+// check BOINC user exists
801
+$account = user_load(array('uid' => $user->uid));
802
+$uid = $user->uid;
803
+$boincid = $account->boincuser_id;
804
+// check $token is valid
805
+if (!is_valid_token($boincid, $token, 'E')) {
806
+drupal_set_message(bts('ERROR: You have supplied an incorrect (most likely expired) token. Please obtain a new token by !link your email address.',
807
+array(
808
+  '!link' => l(bts('changing', array(), NULL, 'boinc:revert-email-change'), "/account/info/edit"),
809
+),
810
+NULL, 'boinc:revert-email-change'), 'error');
811
+drupal_goto();
812
+}
853 813
 
854
-  return $form;
814
+// Attach account and token to this form.
815
+$form['_account'] = array('#type' => 'value', '#value' => $account);
816
+$form['_token'] = array('#type' => 'value', '#value' => $token);
817
+
818
+// Instructions
819
+$form['main']['instructions1'] = array(
820
+'#value' => '<p>'.
821
+bts('In order to change your email back to your previous email address, <strong>!prev_email</strong>, you must also change your password.',
822
+  array(
823
+    '!prev_email' => $account->boincuser_previous_email_addr,
824
+  ),
825
+  NULL, 'boinc:revert-email-change').
826
+'</p>',
827
+);
828
+
829
+$form['main']['pass'] = array(
830
+'#type' => 'password_confirm',
831
+'#description' => 'Enter a new password in both fields',
832
+'#size' => 17,
833
+);
834
+
835
+// Wrap action buttons for styling consistency
836
+$form['buttons']['form control tabs prefix'] = array(
837
+  '#value' => '<ul class="form-control tab-list">',
838
+  '#weight' => 1001,
839
+);
840
+$form['buttons']['submit']['#type'] = 'submit';
841
+$form['buttons']['submit']['#prefix'] = '<li class="first tab">';
842
+$form['buttons']['submit']['#value'] = bts('Submit', array(), NULL, 'boinc:form-submit');
843
+$form['buttons']['submit']['#suffix'] = '</li>';
844
+$form['buttons']['submit']['#weight'] = 1002;
845
+$form['buttons']['cancel'] = array(
846
+  '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'user/info/edit') . '</li>',
847
+  '#weight' => 1005,
848
+);
849
+$form['buttons']['form control tabs suffix'] = array(
850
+  '#value' => '</ul>',
851
+  '#weight' => 1010,
852
+);
853
+
854
+return $form;
855 855
 }
856 856
 
857 857
 /**
858 858
  * Validation handler for revertemail form
859 859
  */
860 860
 function boincuser_revertemail_validate($form, &$form_state) {
861
-  // Load account and boincuser
862
-  $account = $form_state['values']['_account'];
863
-  $boinc_user = BoincUser::lookup_id_nocache($account->boincuser_id);
864
-
865
-  if (BoincUser::lookup_email_addr($boinc_user->previous_email_addr)) {
866
-    form_set_error('mail', bts('An account already exists for @email. Please contact admins for @project. Previous email address cannot be used because another account is using it as their email address.',
867
-      array(
868
-        '@email' => $boinc_user->previous_email_addr,
869
-        '@project' => variable_get('site_name', 'Drupal-BOINC'),
870
-      ),
871
-    NULL, 'boinc:add-new-user'));
872
-  }
861
+// Load account and boincuser
862
+$account = $form_state['values']['_account'];
863
+$boinc_user = BoincUser::lookup_id_nocache($account->boincuser_id);
864
+
865
+if (BoincUser::lookup_email_addr($boinc_user->previous_email_addr)) {
866
+form_set_error('mail', bts('An account already exists for @email. Please contact admins for @project. Previous email address cannot be used because another account is using it as their email address.',
867
+  array(
868
+    '@email' => $boinc_user->previous_email_addr,
869
+    '@project' => variable_get('site_name', 'Drupal-BOINC'),
870
+  ),
871
+NULL, 'boinc:add-new-user'));
872
+}
873 873
 
874 874
 }
875 875
 
@@ -877,25 +877,25 @@  discard block
 block discarded – undo
877 877
  * Submit handler for revertemail form
878 878
  */
879 879
 function boincuser_revertemail_submit($form, &$form_state) {
880
-  require_boinc('password_compat/password');
880
+require_boinc('password_compat/password');
881 881
 
882
-  // Load account and boincuser
883
-  $account = $form_state['values']['_account'];
884
-  $boinc_user = BoincUser::lookup_id_nocache($account->boincuser_id);
882
+// Load account and boincuser
883
+$account = $form_state['values']['_account'];
884
+$boinc_user = BoincUser::lookup_id_nocache($account->boincuser_id);
885 885
 
886
-  $pem = strtolower($boinc_user->previous_email_addr);
886
+$pem = strtolower($boinc_user->previous_email_addr);
887 887
 
888
-  // Set new password based on previous email address and entered
889
-  // password.
890
-  $new_passwd_hash = password_hash( md5($form_state['values']['pass'].$pem), PASSWORD_DEFAULT);
888
+// Set new password based on previous email address and entered
889
+// password.
890
+$new_passwd_hash = password_hash( md5($form_state['values']['pass'].$pem), PASSWORD_DEFAULT);
891 891
 
892
-  $boinc_user->update("email_addr='${pem}', previous_email_addr='', email_addr_change_time=0, passwd_hash='${new_passwd_hash}'");
892
+$boinc_user->update("email_addr='${pem}', previous_email_addr='', email_addr_change_time=0, passwd_hash='${new_passwd_hash}'");
893 893
 
894
-  // Set email in drupal database to previous email
895
-  user_save($account, array('mail' => $pem));
894
+// Set email in drupal database to previous email
895
+user_save($account, array('mail' => $pem));
896 896
 
897
-  // delete the token
898
-  $result = delete_token($account->boincuser_id, $form_state['values']['_token'], 'E');
897
+// delete the token
898
+$result = delete_token($account->boincuser_id, $form_state['values']['_token'], 'E');
899 899
 
900
-  drupal_goto('account');
900
+drupal_goto('account');
901 901
 }
Please login to merge, or discard this patch.