Passed
Push — master ( 90102b...16e7c5 )
by Christian
07:15
created
drupal/sites/default/boinc/modules/boincuser/includes/boincuser.helpers.inc 1 patch
Switch Indentation   +365 added lines, -365 removed lines patch added patch discarded remove patch
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  */
12 12
 
13 13
 if (!function_exists('user_load_by_mail')) {
14
-  /**
14
+/**
15 15
    * user_load_by_mail will be broken out of user_load
16 16
    */
17
-  function user_load_by_mail($mail) {
18
-    return user_load(array('mail' => $mail));
19
-  }
17
+function user_load_by_mail($mail) {
18
+return user_load(array('mail' => $mail));
19
+}
20 20
 }
21 21
  
22 22
 
@@ -28,14 +28,14 @@  discard block
 block discarded – undo
28 28
  * Get an image object from a given file and cck field
29 29
  */ 
30 30
 function get_cck_image_object($image_path, $field_name, $content_type, $ignore_resolution = FALSE) {
31
-  $field = content_fields($field_name, $content_type); 
32
-  $validators = array_merge(filefield_widget_upload_validators($field), imagefield_widget_upload_validators($field));
33
-  if ($ignore_resolution) {
34
-    unset($validators['filefield_validate_image_resolution']);
35
-  }
36
-  $target_path = filefield_widget_file_path($field);
37
-  // Create the image object
38
-  return field_file_save_file($image_path, $validators, $target_path, FILE_EXISTS_REPLACE);
31
+$field = content_fields($field_name, $content_type); 
32
+$validators = array_merge(filefield_widget_upload_validators($field), imagefield_widget_upload_validators($field));
33
+if ($ignore_resolution) {
34
+unset($validators['filefield_validate_image_resolution']);
35
+}
36
+$target_path = filefield_widget_file_path($field);
37
+// Create the image object
38
+return field_file_save_file($image_path, $validators, $target_path, FILE_EXISTS_REPLACE);
39 39
 }
40 40
 
41 41
 
@@ -47,73 +47,73 @@  discard block
 block discarded – undo
47 47
  * 
48 48
  */
49 49
 function boincuser_check_credit_requirements() {
50
-  global $user;
51
-  if (!$user->uid) {
52
-    return FALSE;
53
-  }
54
-  $account = user_load($user->uid);
55
-  $min_credit_to_post = variable_get('boinc_comment_min_credit', 0);
56
-  $community_role = array_search('community member', user_roles(true));
57
-  $unrestricted_role = array_search('verified contributor', user_roles(true));
50
+global $user;
51
+if (!$user->uid) {
52
+return FALSE;
53
+}
54
+$account = user_load($user->uid);
55
+$min_credit_to_post = variable_get('boinc_comment_min_credit', 0);
56
+$community_role = array_search('community member', user_roles(true));
57
+$unrestricted_role = array_search('verified contributor', user_roles(true));
58 58
   
59
-  // Set user roles based on current penalty status...
60
-  if ($account->boincuser_penalty_expiration > time()) {
61
-    drupal_set_message(bts(
62
-      'You are banned from community participation until @date',
63
-      array('@date' => format_date($account->boincuser_penalty_expiration))
64
-    ), 'warning', FALSE);
65
-    if (isset($account->roles[$community_role])) {
66
-      // Remove from the community role, if not already
67
-      unset($account->roles[$community_role]);
68
-    }
69
-    if (isset($account->roles[$unrestricted_role])) {
70
-      // Likewise, revoke extra privileges
71
-      unset($account->roles[$unrestricted_role]);
72
-    }
59
+// Set user roles based on current penalty status...
60
+if ($account->boincuser_penalty_expiration > time()) {
61
+drupal_set_message(bts(
62
+  'You are banned from community participation until @date',
63
+  array('@date' => format_date($account->boincuser_penalty_expiration))
64
+), 'warning', FALSE);
65
+if (isset($account->roles[$community_role])) {
66
+  // Remove from the community role, if not already
67
+  unset($account->roles[$community_role]);
68
+}
69
+if (isset($account->roles[$unrestricted_role])) {
70
+  // Likewise, revoke extra privileges
71
+  unset($account->roles[$unrestricted_role]);
72
+}
73
+user_save($account, array('roles' => $account->roles));
74
+}
75
+else {
76
+if (!isset($account->roles[$community_role])) {
77
+  // The user should be a 'community member' role. If the user was
78
+  // previously banned, this will restore that role.
79
+  $account->roles[$community_role] = 'community member';
80
+  user_save($account, array('roles' => $account->roles));
81
+}
82
+
83
+// ... and total credit.
84
+if ($account->boincuser_total_credit >= $min_credit_to_post) {
85
+  if (!isset($account->roles[$unrestricted_role])) {
86
+    // This user is now above the credit threshold and is allowed full
87
+    // privileges
88
+    $account->roles[$unrestricted_role] = 'verified contributor';
73 89
     user_save($account, array('roles' => $account->roles));
74 90
   }
75
-  else {
76
-    if (!isset($account->roles[$community_role])) {
77
-      // The user should be a 'community member' role. If the user was
78
-      // previously banned, this will restore that role.
79
-      $account->roles[$community_role] = 'community member';
80
-      user_save($account, array('roles' => $account->roles));
81
-    }
82
-
83
-    // ... and total credit.
84
-    if ($account->boincuser_total_credit >= $min_credit_to_post) {
85
-      if (!isset($account->roles[$unrestricted_role])) {
86
-        // This user is now above the credit threshold and is allowed full
87
-        // privileges
88
-        $account->roles[$unrestricted_role] = 'verified contributor';
89
-        user_save($account, array('roles' => $account->roles));
90
-      }
91
-    }
92
-    else {
93
-      drupal_set_message(bts(
94
-        'You must earn @count more credits to be able to post comments on this site and create or modify your user profile.',
95
-        array('@count' => $min_credit_to_post - $account->boincuser_total_credit)
96
-      ), 'warning', FALSE);
97
-      if (isset($account->roles[$unrestricted_role])) {
98
-        // Either the threshold has been raised or credits have been revoked;
99
-        // this user no longer qualifies for full privileges
100
-        unset($account->roles[$unrestricted_role]);
101
-        user_save($account, array('roles' => $account->roles));
102
-      }
103
-    }
104
-
91
+}
92
+else {
93
+  drupal_set_message(bts(
94
+    'You must earn @count more credits to be able to post comments on this site and create or modify your user profile.',
95
+    array('@count' => $min_credit_to_post - $account->boincuser_total_credit)
96
+  ), 'warning', FALSE);
97
+  if (isset($account->roles[$unrestricted_role])) {
98
+    // Either the threshold has been raised or credits have been revoked;
99
+    // this user no longer qualifies for full privileges
100
+    unset($account->roles[$unrestricted_role]);
101
+    user_save($account, array('roles' => $account->roles));
105 102
   }
106 103
 }
107 104
 
105
+}
106
+}
107
+
108 108
 /**
109 109
  * Get the cid of the first comment the user has not seen on a given node
110 110
  */
111 111
 function boincuser_get_first_unread_comment_id($nid, $uid = NULL) {
112
-  if (!$uid) {
113
-    global $user;
114
-    $uid = $user->uid;
115
-  }
116
-  return db_result(db_query("
112
+if (!$uid) {
113
+global $user;
114
+$uid = $user->uid;
115
+}
116
+return db_result(db_query("
117 117
     SELECT c.cid
118 118
     FROM {node} n
119 119
     INNER JOIN {comments} c ON c.nid = n.nid
@@ -123,41 +123,41 @@  discard block
 block discarded – undo
123 123
     AND c.timestamp > h.timestamp
124 124
     ORDER BY c.timestamp ASC
125 125
     LIMIT 1",
126
-    $uid, $nid
127
-  ));
126
+$uid, $nid
127
+));
128 128
 }
129 129
 
130 130
 /**
131 131
  * Choose and set the user of the day
132 132
  */
133 133
 function boincuser_select_user_of_the_day() {
134
-  // First get a list of users with recent credit
135
-  db_set_active('boinc_rw');
136
-  $users_with_credit = db_query("
134
+// First get a list of users with recent credit
135
+db_set_active('boinc_rw');
136
+$users_with_credit = db_query("
137 137
     SELECT
138 138
       id
139 139
     FROM {user} u
140 140
     JOIN {profile} p ON p.userid = u.id
141 141
     WHERE expavg_credit > 1
142 142
     ORDER BY uotd_time ASC, RAND()"
143
-  );
144
-  db_set_active('default');
145
-  $active_users = array();
146
-  while ($user_with_credit = db_fetch_object($users_with_credit)) {
147
-    $active_users[] = $user_with_credit->id;
148
-  }
149
-  $active_users = implode(',', $active_users);
150
-  // Limit to users who have never been user of the day, if there are any
151
-  $never_been_picked = db_result(db_query("
143
+);
144
+db_set_active('default');
145
+$active_users = array();
146
+while ($user_with_credit = db_fetch_object($users_with_credit)) {
147
+$active_users[] = $user_with_credit->id;
148
+}
149
+$active_users = implode(',', $active_users);
150
+// Limit to users who have never been user of the day, if there are any
151
+$never_been_picked = db_result(db_query("
152 152
     SELECT COUNT(*)
153 153
     FROM {boincuser} bu
154 154
     WHERE bu.uotd_time = 0
155 155
     " . ($active_users ? " AND bu.boinc_id IN ({$active_users}) " : '')
156
-  ));
157
-  $new_uotd_uid = 0;
158
-  while (!$new_uotd_uid) {
159
-    // Select a user of the day randomly from the pool
160
-      $new_uotd_uid = db_result(db_query("
156
+));
157
+$new_uotd_uid = 0;
158
+while (!$new_uotd_uid) {
159
+// Select a user of the day randomly from the pool
160
+  $new_uotd_uid = db_result(db_query("
161 161
       SELECT
162 162
         n.uid
163 163
       FROM {node} n
@@ -169,33 +169,33 @@  discard block
 block discarded – undo
169 169
       " . ($active_users ? " AND bu.boinc_id IN ({$active_users}) " : '') . "
170 170
       ORDER BY RAND()
171 171
       LIMIT 1"
172
-    ));
173
-    if (!$new_uotd_uid) {
174
-      // Can't find a user with a profile; remove constraints on the pool
175
-      if ($never_been_picked) {
176
-        // Allow users who have been previously selected
177
-        $never_been_picked = FALSE;
178
-      }
179
-      elseif ($active_users) {
180
-        // Allow users who are not even active (getting desperate)
181
-        $active_users = FALSE;
182
-      }
183
-      else {
184
-        // Process failed...
185
-        return FALSE;
186
-      }
187
-    }
172
+));
173
+if (!$new_uotd_uid) {
174
+  // Can't find a user with a profile; remove constraints on the pool
175
+  if ($never_been_picked) {
176
+    // Allow users who have been previously selected
177
+    $never_been_picked = FALSE;
188 178
   }
189
-  $uotd = user_load($new_uotd_uid);
190
-  if ($uotd->uid) {
191
-    db_query("
179
+  elseif ($active_users) {
180
+    // Allow users who are not even active (getting desperate)
181
+    $active_users = FALSE;
182
+  }
183
+  else {
184
+    // Process failed...
185
+    return FALSE;
186
+  }
187
+}
188
+}
189
+$uotd = user_load($new_uotd_uid);
190
+if ($uotd->uid) {
191
+db_query("
192 192
       UPDATE {boincuser}
193 193
       SET uotd_time = '%d'
194 194
       WHERE uid = '%d'",
195
-      time(), $uotd->uid
196
-    );
197
-  }
198
-  return $uotd;
195
+  time(), $uotd->uid
196
+);
197
+}
198
+return $uotd;
199 199
 }
200 200
 
201 201
 
@@ -213,71 +213,71 @@  discard block
 block discarded – undo
213 213
  * new and prev email.
214 214
  */
215 215
 function _boincuser_send_emailchange($account, $new_email=NULL, $prev_email=NULL, $adminuser=FALSE) {
216
-  require_boinc('token');
217
-  module_load_include('inc', 'rules', 'modules/system.rules');
218
-
219
-  global $base_url;
220
-  $site_name = variable_get('site_name', 'Drupal-BOINC');
216
+require_boinc('token');
217
+module_load_include('inc', 'rules', 'modules/system.rules');
221 218
 
222
-  if (is_null($new_email)) {
223
-    $new_email = $account->mail;
224
-  }
225
-  if (is_null($prev_email)) {
226
-    $prev_email = $account->boincuser_previous_email_addr;
227
-  }
219
+global $base_url;
220
+$site_name = variable_get('site_name', 'Drupal-BOINC');
228 221
 
229
-  // @todo - set constant in drupal, or use BOINC contsants
230
-  $duration = TOKEN_DURATION_ONE_WEEK;
231
-  $changedate = date('F j, Y \a\t G:i T', time());
232
-  $newdate = date('F j, Y \a\t G:i T', $account->boincuser_email_addr_change_time + $duration);
233
-  $token = create_token($account->boincuser_id, TOKEN_TYPE_CHANGE_EMAIL, $duration);
234
-  if ($adminuser) {
235
-    $graf1 = "Your email address was changed from {$prev_email} to {$new_email} "
236
-      . "on {$changedate}. If you need to reverse this change, please look for "
237
-      . "an email send to the email address: {$prev_email}.\n";
238
-  }
239
-  else {
240
-    $graf1 = "Your email address was changed from {$prev_email} to {$new_email} "
241
-      . "on {$changedate}. You will not be able to change your email address "
242
-      . "until {$newdate}. If you need to reverse this change, please look for "
243
-      . "an email send to the email address: {$prev_email}.\n";
244
-  }
222
+if (is_null($new_email)) {
223
+$new_email = $account->mail;
224
+}
225
+if (is_null($prev_email)) {
226
+$prev_email = $account->boincuser_previous_email_addr;
227
+}
245 228
 
246
-  // Send email #1 to current address
247
-  $mysubject = "Notification of email change at {$site_name}";
248
-  $mymessage = ''
249
-      . "{$account->boincuser_name},\n"
250
-      . "\n"
251
-      . $graf1
252
-      . "\n"
253
-      . "Thanks, \n"
254
-      . "{$site_name} support team\n";
255
-
256
-  $settings = array(
257
-    'from' => '',
258
-    'to' => $new_email,
259
-    'subject' => $mysubject,
260
-    'message' => $mymessage,
261
-  );
262
-  rules_action_mail_to_user($account, $settings);
263
-
264
-  // Send email #2 to previous address.
265
-  $mymessage = ''
266
-      . "Your email address has been changed. If you did not intend to take this action, then please click this link to reverse this change, or copy-and-paste the link into your browser location bar. You will need to change your password as well.\n"
267
-      . "\n"
268
-      . "{$base_url}/user/{$account->uid}/recoveremail/{$token}\n"
269
-      . "\n"
270
-      . "Thanks, \n"
271
-      . "{$site_name} support team\n";
272
-
273
-  $settings = array(
274
-    'from' => '',
275
-    'to' => $prev_email,
276
-    'subject' => $mysubject,
277
-    'message' => $mymessage,
278
-  );
229
+// @todo - set constant in drupal, or use BOINC contsants
230
+$duration = TOKEN_DURATION_ONE_WEEK;
231
+$changedate = date('F j, Y \a\t G:i T', time());
232
+$newdate = date('F j, Y \a\t G:i T', $account->boincuser_email_addr_change_time + $duration);
233
+$token = create_token($account->boincuser_id, TOKEN_TYPE_CHANGE_EMAIL, $duration);
234
+if ($adminuser) {
235
+$graf1 = "Your email address was changed from {$prev_email} to {$new_email} "
236
+  . "on {$changedate}. If you need to reverse this change, please look for "
237
+  . "an email send to the email address: {$prev_email}.\n";
238
+}
239
+else {
240
+$graf1 = "Your email address was changed from {$prev_email} to {$new_email} "
241
+  . "on {$changedate}. You will not be able to change your email address "
242
+  . "until {$newdate}. If you need to reverse this change, please look for "
243
+  . "an email send to the email address: {$prev_email}.\n";
244
+}
279 245
 
280
-  rules_action_mail($settings);
246
+// Send email #1 to current address
247
+$mysubject = "Notification of email change at {$site_name}";
248
+$mymessage = ''
249
+  . "{$account->boincuser_name},\n"
250
+  . "\n"
251
+  . $graf1
252
+  . "\n"
253
+  . "Thanks, \n"
254
+  . "{$site_name} support team\n";
255
+
256
+$settings = array(
257
+'from' => '',
258
+'to' => $new_email,
259
+'subject' => $mysubject,
260
+'message' => $mymessage,
261
+);
262
+rules_action_mail_to_user($account, $settings);
263
+
264
+// Send email #2 to previous address.
265
+$mymessage = ''
266
+  . "Your email address has been changed. If you did not intend to take this action, then please click this link to reverse this change, or copy-and-paste the link into your browser location bar. You will need to change your password as well.\n"
267
+  . "\n"
268
+  . "{$base_url}/user/{$account->uid}/recoveremail/{$token}\n"
269
+  . "\n"
270
+  . "Thanks, \n"
271
+  . "{$site_name} support team\n";
272
+
273
+$settings = array(
274
+'from' => '',
275
+'to' => $prev_email,
276
+'subject' => $mysubject,
277
+'message' => $mymessage,
278
+);
279
+
280
+rules_action_mail($settings);
281 281
 }
282 282
 
283 283
 /**
@@ -287,32 +287,32 @@  discard block
 block discarded – undo
287 287
  *
288 288
  */
289 289
 function create_proper_drupalname($requested_name) {
290
-  if (!$requested_name) {
291
-    // If the name is empty, set it
292
-    $requested_name = 'anonymous';
293
-  }
294
-  $same_name_tally = 1;
295
-
296
-  // Remove extra spaces
297
-  $name2 = preg_replace("/ {2,}/", " ", trim($requested_name));
298
-  // Remove any non-valid characters
299
-  $cleaned_name = preg_replace('/[^a-zA-Z0-9_ \.-]/s', '_', $name2);
300
-  // Truncate name
301
-  $name_length = strlen($cleaned_name);
302
-  if ($name_length > 56) {
303
-    // Name is limited to 60 characters, but we want to leave space to add a
304
-    // tally if needed (for users with duplicate names); Limit to 56 chars and
305
-    // replace the middle of the string with "..." if too long
306
-    $cleaned_name = substr_replace($cleaned_name, '...', 28, ($name_length-56)+3);
307
-  }
290
+if (!$requested_name) {
291
+// If the name is empty, set it
292
+$requested_name = 'anonymous';
293
+}
294
+$same_name_tally = 1;
295
+
296
+// Remove extra spaces
297
+$name2 = preg_replace("/ {2,}/", " ", trim($requested_name));
298
+// Remove any non-valid characters
299
+$cleaned_name = preg_replace('/[^a-zA-Z0-9_ \.-]/s', '_', $name2);
300
+// Truncate name
301
+$name_length = strlen($cleaned_name);
302
+if ($name_length > 56) {
303
+// Name is limited to 60 characters, but we want to leave space to add a
304
+// tally if needed (for users with duplicate names); Limit to 56 chars and
305
+// replace the middle of the string with "..." if too long
306
+$cleaned_name = substr_replace($cleaned_name, '...', 28, ($name_length-56)+3);
307
+}
308 308
 
309
-  // Determine if there are duplicate names, if so append a number to end.
310
-  $unique_name = $cleaned_name;
311
-  while (db_result(db_query("SELECT uid FROM {users} WHERE name = '{$unique_name}' LIMIT 1"))) {
312
-    $same_name_tally++;
313
-    $unique_name = "{$cleaned_name}_{$same_name_tally}";
314
-  }
315
-  return $unique_name;
309
+// Determine if there are duplicate names, if so append a number to end.
310
+$unique_name = $cleaned_name;
311
+while (db_result(db_query("SELECT uid FROM {users} WHERE name = '{$unique_name}' LIMIT 1"))) {
312
+$same_name_tally++;
313
+$unique_name = "{$cleaned_name}_{$same_name_tally}";
314
+}
315
+return $unique_name;
316 316
 }
317 317
 
318 318
 
@@ -326,9 +326,9 @@  discard block
 block discarded – undo
326 326
  *
327 327
  */
328 328
 function boincuser_check_termsofuse($user) {
329
-  require_boinc('consent');
330
-  $boinc_user = boincuser_load($user->uid, TRUE);
331
-  return check_user_consent($boinc_user, CONSENT_TYPE_ENROLL);
329
+require_boinc('consent');
330
+$boinc_user = boincuser_load($user->uid, TRUE);
331
+return check_user_consent($boinc_user, CONSENT_TYPE_ENROLL);
332 332
 }
333 333
 
334 334
 /**
@@ -339,27 +339,27 @@  discard block
 block discarded – undo
339 339
  *
340 340
  */
341 341
 function boincuser_consentto_termsofuse($user) {
342
-  require_boinc('consent');
343
-  $boinc_user = boincuser_load($user->uid, TRUE);
344
-
345
-  list($checkct, $ctid) = check_consent_type(CONSENT_TYPE_ENROLL);
346
-  if ($checkct) {
347
-    $rc1 = consent_to_a_policy($boinc_user, $ctid, 1, 0, 'Webform', time());
348
-    if (!$rc1) {
349
-      drupal_set_message(
350
-        bts("ERROR: Database error when attempting to INSERT into table consent with ID=@id. Please contact site administrators.",
351
-        array('@id' => $boinc_user->id),
352
-        'NULL', 'boinc:consent-termsofuse'),
353
-      'error');
354
-    }
355
-    return $rc1;
356
-  }
357
-  else {
358
-    drupal_set_message(
359
-      bts('ERROR: Consent type for enrollment not found. Please contact site administrators.', array(), 'NULL', 'boinc:consent-termsofuse'),
360
-    'error');
361
-  }
362
-  return FALSE;
342
+require_boinc('consent');
343
+$boinc_user = boincuser_load($user->uid, TRUE);
344
+
345
+list($checkct, $ctid) = check_consent_type(CONSENT_TYPE_ENROLL);
346
+if ($checkct) {
347
+$rc1 = consent_to_a_policy($boinc_user, $ctid, 1, 0, 'Webform', time());
348
+if (!$rc1) {
349
+  drupal_set_message(
350
+    bts("ERROR: Database error when attempting to INSERT into table consent with ID=@id. Please contact site administrators.",
351
+    array('@id' => $boinc_user->id),
352
+    'NULL', 'boinc:consent-termsofuse'),
353
+  'error');
354
+}
355
+return $rc1;
356
+}
357
+else {
358
+drupal_set_message(
359
+  bts('ERROR: Consent type for enrollment not found. Please contact site administrators.', array(), 'NULL', 'boinc:consent-termsofuse'),
360
+'error');
361
+}
362
+return FALSE;
363 363
 }
364 364
 
365 365
 /**
@@ -368,16 +368,16 @@  discard block
 block discarded – undo
368 368
  */
369 369
 function _boincuser_ignore_paths($path, $paths_to_ignore) {
370 370
 
371
-  foreach ($paths_to_ignore as $pi) {
372
-    // @todo Currently this function uses {} as PHP regexp
373
-    // delimiters. Curly brace is not really allowed un URLs, but a
374
-    // more robust function would first check for these curly braces
375
-    // in the path_to_ignore patterms, just in case.
376
-    if (preg_match('{' . $pi . '}', $path)) {
377
-      return TRUE;
378
-    }
379
-  }
380
-  return FALSE;
371
+foreach ($paths_to_ignore as $pi) {
372
+// @todo Currently this function uses {} as PHP regexp
373
+// delimiters. Curly brace is not really allowed un URLs, but a
374
+// more robust function would first check for these curly braces
375
+// in the path_to_ignore patterms, just in case.
376
+if (preg_match('{' . $pi . '}', $path)) {
377
+  return TRUE;
378
+}
379
+}
380
+return FALSE;
381 381
 }
382 382
 
383 383
 /**
@@ -385,20 +385,20 @@  discard block
 block discarded – undo
385 385
  * Drupal's recover email path.
386 386
  */
387 387
 function _boincuser_redirect_recover_email() {
388
-  $params = array(
389
-    'boincid' => isset($_GET['id']) ? $_GET['id'] : '',
390
-    'token' => isset($_GET['token']) ? $_GET['token'] : ''
391
-  );
392
-
393
-  // If boincid or token is not present, then go to the home page.
394
-  if (empty($params['boincid']) or empty($params['token'])) {
395
-    $redirect = '';
396
-  }
397
-  else {
398
-    $uid = boincuser_lookup_uid($params['boincid']);
399
-    $redirect = "/user/${uid}/recoveremail/${params['token']}";
400
-  }
401
-  drupal_goto($redirect);
388
+$params = array(
389
+'boincid' => isset($_GET['id']) ? $_GET['id'] : '',
390
+'token' => isset($_GET['token']) ? $_GET['token'] : ''
391
+);
392
+
393
+// If boincid or token is not present, then go to the home page.
394
+if (empty($params['boincid']) or empty($params['token'])) {
395
+$redirect = '';
396
+}
397
+else {
398
+$uid = boincuser_lookup_uid($params['boincid']);
399
+$redirect = "/user/${uid}/recoveremail/${params['token']}";
400
+}
401
+drupal_goto($redirect);
402 402
 }
403 403
 
404 404
 /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
@@ -409,17 +409,17 @@  discard block
 block discarded – undo
409 409
  * Require BOINC library
410 410
  */
411 411
 function require_boinc($libraries) {
412
-  if ($include_dir = boinc_get_path('html_inc')) {
413
-    $working_dir = getcwd();
414
-    chdir($include_dir);
415
-    if (!is_array($libraries)) {
416
-      $libraries = array($libraries);
417
-    }
418
-    foreach ($libraries as $library) {
419
-      require_once("{$library}.inc");
420
-    }
421
-    chdir($working_dir);
422
-  }
412
+if ($include_dir = boinc_get_path('html_inc')) {
413
+$working_dir = getcwd();
414
+chdir($include_dir);
415
+if (!is_array($libraries)) {
416
+  $libraries = array($libraries);
417
+}
418
+foreach ($libraries as $library) {
419
+  require_once("{$library}.inc");
420
+}
421
+chdir($working_dir);
422
+}
423 423
 }
424 424
 
425 425
 /**
@@ -427,92 +427,92 @@  discard block
 block discarded – undo
427 427
  * The path from the BOINC html root must be included (e.g. user/file.php)
428 428
  */
429 429
 function include_boinc($file) {
430
-  if ($include_dir = boinc_get_path()) {
431
-    $include_dir .= '/html';
432
-    $workingDir = getcwd();
433
-    $path = dirname($file);
434
-    $file = basename($file);
435
-    chdir("{$include_dir}/{$path}");
436
-    include($file);
437
-    chdir($workingDir);
438
-  }
430
+if ($include_dir = boinc_get_path()) {
431
+$include_dir .= '/html';
432
+$workingDir = getcwd();
433
+$path = dirname($file);
434
+$file = basename($file);
435
+chdir("{$include_dir}/{$path}");
436
+include($file);
437
+chdir($workingDir);
438
+}
439 439
 }
440 440
 
441 441
 /**
442 442
  * Get the BOINC include path
443 443
  */
444 444
 function boinc_get_path($type = 'root') {
445
-  $dir = "boinc_{$type}_dir";
446
-  if ($include_dir = variable_get("boinc_{$type}_dir", '')) {
447
-    return $include_dir;
448
-  }
449
-  else {
450
-    // Don't show errors on blacklisted pages
451
-    $page_blacklist = array(
452
-      'admin/boinc/environment'
453
-    );
454
-    if (!in_array($_GET['q'], $page_blacklist)) {
455
-      watchdog('boincuser', 'The BOINC environment is not configured. Please
445
+$dir = "boinc_{$type}_dir";
446
+if ($include_dir = variable_get("boinc_{$type}_dir", '')) {
447
+return $include_dir;
448
+}
449
+else {
450
+// Don't show errors on blacklisted pages
451
+$page_blacklist = array(
452
+  'admin/boinc/environment'
453
+);
454
+if (!in_array($_GET['q'], $page_blacklist)) {
455
+  watchdog('boincuser', 'The BOINC environment is not configured. Please
456 456
           !configure_it', array('!configure_it' => l(t('configure it now'),
457
-            'admin/boinc/environment')), WATCHDOG_WARNING);
458
-      if (user_access('administer site configuration')) {
459
-        drupal_set_message(t('The BOINC environment is not configured. Please
457
+        'admin/boinc/environment')), WATCHDOG_WARNING);
458
+  if (user_access('administer site configuration')) {
459
+    drupal_set_message(t('The BOINC environment is not configured. Please
460 460
           !configure_it', array('!configure_it' => l(t('configure it now'),
461
-            'admin/boinc/environment'))), 'warning', FALSE);
462
-      }
463
-      else {
464
-        drupal_set_message(t('There is a problem with the site. Please contact
461
+        'admin/boinc/environment'))), 'warning', FALSE);
462
+  }
463
+  else {
464
+    drupal_set_message(t('There is a problem with the site. Please contact
465 465
           the system administrator.'), 'error', FALSE);
466
-      }
467
-      // Redirect home to display the error message and avoid fatal errors
468
-      // (unless on a blacklisted page)
469
-      $redirect_blacklist = array(
470
-        'admin/settings/performance',
471
-        'admin/boinc/environment',
472
-        'home',
473
-        ''
474
-      );
475
-      if (!in_array($_GET['q'], $redirect_blacklist)) {
476
-        drupal_goto('');
477
-      }
478
-    }
479
-    else {
480
-      // Clear the messages on the environment config page
481
-      drupal_get_messages();
482
-    }
483 466
   }
484
-  return FALSE;
467
+  // Redirect home to display the error message and avoid fatal errors
468
+  // (unless on a blacklisted page)
469
+  $redirect_blacklist = array(
470
+    'admin/settings/performance',
471
+    'admin/boinc/environment',
472
+    'home',
473
+    ''
474
+  );
475
+  if (!in_array($_GET['q'], $redirect_blacklist)) {
476
+    drupal_goto('');
477
+  }
478
+}
479
+else {
480
+  // Clear the messages on the environment config page
481
+  drupal_get_messages();
482
+}
483
+}
484
+return FALSE;
485 485
 }
486 486
 
487 487
 /**
488 488
  * Get the configured scheduler tags
489 489
  */
490 490
 function boinc_get_scheduler_tags() {
491
-  // Don't generate messages for blacklisted pages
492
-  $page_blacklist = array(
493
-    'admin/boinc/environment',
494
-    'admin/boinc/scheduler'
495
-  );
496
-  if ($url_config = variable_get('boinc_scheduler_urls', '')) {
497
-    return explode("\r\n", $url_config);
498
-  }
499
-  elseif (!in_array($_GET['q'], $page_blacklist)) {
500
-    watchdog('boincuser', 'The BOINC scheduling server settings are not yet
491
+// Don't generate messages for blacklisted pages
492
+$page_blacklist = array(
493
+'admin/boinc/environment',
494
+'admin/boinc/scheduler'
495
+);
496
+if ($url_config = variable_get('boinc_scheduler_urls', '')) {
497
+return explode("\r\n", $url_config);
498
+}
499
+elseif (!in_array($_GET['q'], $page_blacklist)) {
500
+watchdog('boincuser', 'The BOINC scheduling server settings are not yet
501 501
         configured. Please !verify for the settings to become effective.',
502
-          array('!verify' => l(t('verify the default values') . ' <strong>' . 
503
-            t('and') . '</strong> ' . t('save the configuration'),
504
-            'admin/boinc/scheduler', array('html' => TRUE))
505
-          ), WATCHDOG_WARNING);
506
-    if (user_access('administer site configuration')) {
507
-      drupal_set_message(t('The BOINC scheduling server settings are not yet
502
+      array('!verify' => l(t('verify the default values') . ' <strong>' . 
503
+        t('and') . '</strong> ' . t('save the configuration'),
504
+        'admin/boinc/scheduler', array('html' => TRUE))
505
+      ), WATCHDOG_WARNING);
506
+if (user_access('administer site configuration')) {
507
+  drupal_set_message(t('The BOINC scheduling server settings are not yet
508 508
           configured. Please !verify for the settings to become effective',
509
-            array('!verify' => l(t('verify the default values') . ' <strong>' . 
510
-              t('and') . '</strong> ' . t('save the configuration'),
511
-              'admin/boinc/scheduler', array('html' => TRUE))
512
-            )), 'warning', FALSE);
513
-    }
514
-  }
515
-  return array();
509
+        array('!verify' => l(t('verify the default values') . ' <strong>' . 
510
+          t('and') . '</strong> ' . t('save the configuration'),
511
+          'admin/boinc/scheduler', array('html' => TRUE))
512
+        )), 'warning', FALSE);
513
+}
514
+}
515
+return array();
516 516
 }
517 517
 
518 518
 /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
@@ -524,41 +524,41 @@  discard block
 block discarded – undo
524 524
  * Determine if a BOINC ID matches the logged in user
525 525
  */
526 526
 function is_current_boinc_user($boinc_id) {
527
-  global $user;
528
-  if (!$user->uid) {
529
-    return FALSE;
530
-  }
531
-  // boincuser_id is not stored in the global user, so load a new instance
532
-  $drupuser = user_load($user->uid);
533
-  return ($boinc_id == $drupuser->boincuser_id);
527
+global $user;
528
+if (!$user->uid) {
529
+return FALSE;
530
+}
531
+// boincuser_id is not stored in the global user, so load a new instance
532
+$drupuser = user_load($user->uid);
533
+return ($boinc_id == $drupuser->boincuser_id);
534 534
 }
535 535
 
536 536
 /**
537 537
  * Convert a BOINC ID to a Drupal ID
538 538
  */
539 539
 function boincuser_lookup_uid($boinc_id) {
540
-  $drupal_id = db_result(db_query("SELECT uid FROM {boincuser} WHERE boinc_id='%d'", $boinc_id));
541
-  return $drupal_id;
540
+$drupal_id = db_result(db_query("SELECT uid FROM {boincuser} WHERE boinc_id='%d'", $boinc_id));
541
+return $drupal_id;
542 542
 }
543 543
 function get_drupal_id($boinc_id) {
544
-  return boincuser_lookup_uid($boinc_id);
544
+return boincuser_lookup_uid($boinc_id);
545 545
 }
546 546
 
547 547
 /**
548 548
  * Get a BOINC user object
549 549
  */
550 550
 function boincuser_load($user_id = NULL, $is_drupal_id = FALSE) {
551
-  if (!$user_id) {
552
-    global $user;
553
-    $user_id = $user->uid;
554
-    $is_drupal_id = TRUE;
555
-  }
556
-  if ($is_drupal_id) {
557
-    $account = user_load($user_id);
558
-    $user_id = $account->boincuser_id;
559
-  }
560
-  require_boinc('boinc_db');
561
-  return BoincUser::lookup_id($user_id);
551
+if (!$user_id) {
552
+global $user;
553
+$user_id = $user->uid;
554
+$is_drupal_id = TRUE;
555
+}
556
+if ($is_drupal_id) {
557
+$account = user_load($user_id);
558
+$user_id = $account->boincuser_id;
559
+}
560
+require_boinc('boinc_db');
561
+return BoincUser::lookup_id($user_id);
562 562
 }
563 563
 
564 564
 /**
@@ -568,10 +568,10 @@  discard block
 block discarded – undo
568 568
  * page, delete button.
569 569
  */
570 570
 function _boincuser_node_profile_delete_submit($form, &$form_state) {
571
-  $node = $form['#node'];
572
-  $deleteurl = 'node/'. $node->nid .'/delete';
573
-  $afterq = 'destination=account';
574
-  drupal_goto($deleteurl, $afterq);
571
+$node = $form['#node'];
572
+$deleteurl = 'node/'. $node->nid .'/delete';
573
+$afterq = 'destination=account';
574
+drupal_goto($deleteurl, $afterq);
575 575
 }
576 576
 
577 577
 /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
@@ -582,8 +582,8 @@  discard block
 block discarded – undo
582 582
  * Wrapper for boinc_version() function
583 583
  */
584 584
 function get_boinc_version($x) {
585
-  require_boinc('host');
586
-  return function_exists('boinc_version') ? boinc_version($x) : 'err!';
585
+require_boinc('host');
586
+return function_exists('boinc_version') ? boinc_version($x) : 'err!';
587 587
 }
588 588
   
589 589
 
@@ -595,12 +595,12 @@  discard block
 block discarded – undo
595 595
   * Generate the friend block header
596 596
   */
597 597
 function boincuser_views_friends_block_header($context = null) {
598
-  // Get the friend count for the user being viewed
599
-  $view = views_get_current_view();
600
-  $account_id = $view->args[0];
601
-  $friend_count = flag_friend_get_friend_count($account_id);
602
-  return '<h2 class="pane-title">' . bts('Friends (@count)', 
603
-    array('@count' => $friend_count)) . '</h2>';
598
+// Get the friend count for the user being viewed
599
+$view = views_get_current_view();
600
+$account_id = $view->args[0];
601
+$friend_count = flag_friend_get_friend_count($account_id);
602
+return '<h2 class="pane-title">' . bts('Friends (@count)', 
603
+array('@count' => $friend_count)) . '</h2>';
604 604
 }
605 605
 
606 606
 /**
@@ -608,13 +608,13 @@  discard block
 block discarded – undo
608 608
  * database.
609 609
  */
610 610
 function _boincuser_user_name_autocomplete($string) {
611
-  $matches = array();
612
-  db_set_active('boinc_ro');
613
-  $result = db_query_range("SELECT id,name FROM {user} WHERE name LIKE '%s%'", $string, 0, 10);
614
-  db_set_active('default');
615
-  while ($user = db_fetch_object($result)) {
616
-      $matches[$user->name . '_' . $user->id] = htmlentities($user->name) . " (" . $user->id . ')';
617
-  }
611
+$matches = array();
612
+db_set_active('boinc_ro');
613
+$result = db_query_range("SELECT id,name FROM {user} WHERE name LIKE '%s%'", $string, 0, 10);
614
+db_set_active('default');
615
+while ($user = db_fetch_object($result)) {
616
+  $matches[$user->name . '_' . $user->id] = htmlentities($user->name) . " (" . $user->id . ')';
617
+}
618 618
 
619
-  drupal_json((object)$matches);
619
+drupal_json((object)$matches);
620 620
 }
Please login to merge, or discard this patch.
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.