Completed
Pull Request — master (#1795)
by Christian
11:36
created
drupal/sites/default/boinc/modules/boincteam/boincteam.module 1 patch
Indentation   +566 added lines, -566 removed lines patch added patch discarded remove patch
@@ -26,113 +26,113 @@  discard block
 block discarded – undo
26 26
  * Implementation of hook_menu()
27 27
  */
28 28
 function boincteam_menu() {
29
-  $items = array();
30
-  $items['community/teams/%/assume-foundership'] = array(
29
+    $items = array();
30
+    $items['community/teams/%/assume-foundership'] = array(
31 31
     'page callback' => 'boincteam_assume_foundership',
32 32
     'page arguments' => array(2),
33 33
     'access callback' => 'boincteam_is_member',
34 34
     'access arguments' => array(2),
35 35
     'type' => MENU_CALLBACK
36
-  );
37
-  $items['community/teams/%/join'] = array(
36
+    );
37
+    $items['community/teams/%/join'] = array(
38 38
     'page callback' => 'boincteam_join',
39 39
     'page arguments' => array(2),
40 40
     'access arguments' => array('join boincteam'),
41 41
     'type' => MENU_CALLBACK
42
-  );
43
-  $items['community/teams/%/leave'] = array(
42
+    );
43
+    $items['community/teams/%/leave'] = array(
44 44
     'page callback' => 'boincteam_leave',
45 45
     'page arguments' => array(2),
46 46
     'access arguments' => array('join boincteam'),
47 47
     'type' => MENU_CALLBACK
48
-  );
49
-  $items['community/teams/%/delete'] = array(
48
+    );
49
+    $items['community/teams/%/delete'] = array(
50 50
     'page callback' => 'boincteam_delete',
51 51
     'page arguments' => array(2),
52 52
     'access callback' => 'boincteam_is_founder',
53 53
     'access arguments' => array(2),
54 54
     'type' => MENU_CALLBACK
55
-  );
56
-  $items['community/teams/%/deny-foundership-request'] = array(
55
+    );
56
+    $items['community/teams/%/deny-foundership-request'] = array(
57 57
     'page callback' => 'boincteam_deny_foundership_request',
58 58
     'page arguments' => array(2),
59 59
     'access callback' => 'boincteam_is_founder',
60 60
     'access arguments' => array(2),
61 61
     'type' => MENU_CALLBACK
62
-  );
63
-  $items['community/teams/%/edit/admins/remove/%'] = array(
62
+    );
63
+    $items['community/teams/%/edit/admins/remove/%'] = array(
64 64
     'page callback' => 'boincteam_remove_admin',
65 65
     'page arguments' => array(2,6),
66 66
     'access callback' => 'boincteam_is_founder',
67 67
     'access arguments' => array(2),
68 68
     'type' => MENU_CALLBACK
69
-  );
70
-  $items['community/teams/%/edit/founder/set/%'] = array(
69
+    );
70
+    $items['community/teams/%/edit/founder/set/%'] = array(
71 71
     'page callback' => 'boincteam_set_founder',
72 72
     'page arguments' => array(2,6),
73 73
     'access callback' => 'boincteam_is_founder',
74 74
     'access arguments' => array(2),
75 75
     'type' => MENU_CALLBACK
76
-  );
77
-  $items['community/teams/%/edit/members/remove/%'] = array(
76
+    );
77
+    $items['community/teams/%/edit/members/remove/%'] = array(
78 78
     'page callback' => 'boincteam_remove_member',
79 79
     'page arguments' => array(2,6),
80 80
     'access callback' => 'boincteam_is_founder',
81 81
     'access arguments' => array(2),
82 82
     'type' => MENU_CALLBACK
83
-  );
84
-  $items['community/teams/%/history/xml'] = array(
83
+    );
84
+    $items['community/teams/%/history/xml'] = array(
85 85
     'page callback' => 'boincteam_history_xml',
86 86
     'page arguments' => array(2),
87 87
     'access callback' => 'boincteam_is_admin',
88 88
     'access arguments' => array(2),
89 89
     'type' => MENU_CALLBACK
90
-  );
91
-  $items['community/teams/%/members/email'] = array(
90
+    );
91
+    $items['community/teams/%/members/email'] = array(
92 92
     'page callback' => 'boincteam_members_email_list',
93 93
     'page arguments' => array(2),
94 94
     'access callback' => 'boincteam_is_admin',
95 95
     'access arguments' => array(2),
96 96
     'type' => MENU_CALLBACK
97
-  );
98
-  $items['community/teams/%/request-foundership'] = array(
97
+    );
98
+    $items['community/teams/%/request-foundership'] = array(
99 99
     'page callback' => 'boincteam_request_foundership',
100 100
     'page arguments' => array(2),
101 101
     'access callback' => 'boincteam_is_member',
102 102
     'access arguments' => array(2),
103 103
     'type' => MENU_CALLBACK
104
-  );
104
+    );
105 105
    
106
-  return $items;
106
+    return $items;
107 107
 }
108 108
 
109 109
 /**
110 110
 * Implementation of hook_views_api().
111 111
 */
112 112
 function boincteam_views_api() {
113
-  return array(
113
+    return array(
114 114
     'api' => 2.0,
115 115
     'path' => drupal_get_path('module', 'boincteam')
116
-  );
116
+    );
117 117
 }
118 118
 
119 119
 /**
120 120
  * Implementation of hook_perm()
121 121
  */
122 122
 function boincteam_perm() {
123
-  return array('join boincteam', 'create boincteam', 'manage boincteam');
123
+    return array('join boincteam', 'create boincteam', 'manage boincteam');
124 124
 }
125 125
 
126 126
 /**
127 127
  * Implementation of hook_cron()
128 128
  */
129 129
 function boincteam_cron() {
130
-  // Sync teams from BOINC DB every day to catch BOINC-wide team updates
131
-  $last_sync = variable_get('boincteam_last_sync', 0);
132
-  if ($last_sync < time() - 24*60*60) {
130
+    // Sync teams from BOINC DB every day to catch BOINC-wide team updates
131
+    $last_sync = variable_get('boincteam_last_sync', 0);
132
+    if ($last_sync < time() - 24*60*60) {
133 133
     boincteam_sync();
134 134
     variable_set('boincteam_last_sync', time());
135
-  }
135
+    }
136 136
 }
137 137
 
138 138
 /**
@@ -152,49 +152,49 @@  discard block
 block discarded – undo
152 152
  * assume the role of founder
153 153
  */
154 154
 function boincteam_assume_foundership($team_id) {
155
-  global $user;
156
-  $account = user_load($user->uid);
157
-  $team = node_load($team_id);
158
-  $boincteam_id = boincteam_lookup_id($team_id);
159
-  $boincteam = boincteam_load($boincteam_id);
160
-  $boincuser_id = $account->boincuser_id;
155
+    global $user;
156
+    $account = user_load($user->uid);
157
+    $team = node_load($team_id);
158
+    $boincteam_id = boincteam_lookup_id($team_id);
159
+    $boincteam = boincteam_load($boincteam_id);
160
+    $boincuser_id = $account->boincuser_id;
161 161
   
162
-  if (boincteam_foundership_transfer_ok($boincteam)) {
162
+    if (boincteam_foundership_transfer_ok($boincteam)) {
163 163
     if ($boincuser_id == $boincteam->ping_user) {
164
-      db_set_active('boinc');
165
-      db_query("
164
+        db_set_active('boinc');
165
+        db_query("
166 166
         UPDATE {team}
167 167
         SET userid = '%d', ping_user = '0', ping_time = '0'
168 168
         WHERE id = '%d'",
169 169
         $boincuser_id, $boincteam_id
170
-      );
171
-      db_set_active('default');
172
-      drupal_set_message(t('You are now the founder of @team', array(
170
+        );
171
+        db_set_active('default');
172
+        drupal_set_message(t('You are now the founder of @team', array(
173 173
         '@team' => $team->title
174
-      )));
175
-      watchdog('boincteam', 'User @user assumed foundership of team @nid',
174
+        )));
175
+        watchdog('boincteam', 'User @user assumed foundership of team @nid',
176 176
         array(
177
-          '@current_user' => $account->uid,
178
-          '@nid' => $team_id
177
+            '@current_user' => $account->uid,
178
+            '@nid' => $team_id
179 179
         ), WATCHDOG_NOTICE
180
-      );
180
+        );
181 181
     }
182
-  }
183
-  else {
182
+    }
183
+    else {
184 184
     drupal_set_message(t('You are not allowed to assume foundership of this
185 185
       team.'
186 186
     ));
187
-  }
188
-  drupal_goto("community/teams/{$team_id}");
187
+    }
188
+    drupal_goto("community/teams/{$team_id}");
189 189
 }
190 190
 
191 191
 /**
192 192
  * Delete the team, if empty
193 193
  */
194 194
 function boincteam_delete($team_id) {
195
-  $team = node_load($team_id);
196
-  $boincteam = boincteam_load(boincteam_lookup_id($team_id), TRUE);
197
-  if ($boincteam->nusers == 1) {
195
+    $team = node_load($team_id);
196
+    $boincteam = boincteam_load(boincteam_lookup_id($team_id), TRUE);
197
+    if ($boincteam->nusers == 1) {
198 198
     require_boinc('team');
199 199
     $boincuser = boincuser_load();
200 200
     user_quit_team($boincuser);
@@ -203,35 +203,35 @@  discard block
 block discarded – undo
203 203
     $team->uid = 0;
204 204
     node_save($team);
205 205
     drupal_set_message(t('@team has been removed.',
206
-      array('@team' => $boincteam->name)));
206
+        array('@team' => $boincteam->name)));
207 207
     drupal_goto('community/teams');
208
-  }
209
-  else {
208
+    }
209
+    else {
210 210
     drupal_set_message(t('All members must be removed from @team before the
211 211
       team can be deleted.', array('@team' => $boincteam->name)), 'error');
212 212
     drupal_goto(strstr($_GET['q'], '/delete', TRUE));
213
-  }
213
+    }
214 214
 }
215 215
 
216 216
 /**
217 217
  * Deny a foundership transfer request
218 218
  */
219 219
 function boincteam_deny_foundership_request($team_id) {
220
-  $boincteam_id = boincteam_lookup_id($team_id);
221
-  // Remove the request from the BOINC database
222
-  db_set_active('boinc');
223
-  db_query("
220
+    $boincteam_id = boincteam_lookup_id($team_id);
221
+    // Remove the request from the BOINC database
222
+    db_set_active('boinc');
223
+    db_query("
224 224
     UPDATE {team}
225 225
     SET ping_user=0
226 226
     WHERE id = '%d'",
227 227
     $boincteam_id
228
-  );
229
-  db_set_active('default');
228
+    );
229
+    db_set_active('default');
230 230
   
231
-  drupal_set_message(t('The transfer request has been denied. No additional
231
+    drupal_set_message(t('The transfer request has been denied. No additional
232 232
     requests will be allowed until 90 days have passed since this request was
233 233
     made.'));
234
-  drupal_goto("community/teams/{$team_id}/edit/founder");
234
+    drupal_goto("community/teams/{$team_id}/edit/founder");
235 235
 }
236 236
   
237 237
 
@@ -239,62 +239,62 @@  discard block
 block discarded – undo
239 239
  * Get the join date of a user
240 240
  */
241 241
 function boincteam_get_member_join_date($boincteam_id, $boincuser_id = NULL) {
242
-  if (!$boincuser_id) {
242
+    if (!$boincuser_id) {
243 243
     global $user;
244 244
     $account = user_load($user->uid);
245 245
     $boincuser_id = $account->boincuser_id;
246
-  }
247
-  db_set_active('boinc');
248
-  $timestamp = db_result(db_query("
246
+    }
247
+    db_set_active('boinc');
248
+    $timestamp = db_result(db_query("
249 249
     SELECT timestamp FROM {team_delta} WHERE
250 250
     userid = %d AND teamid = %d AND joining = 1
251 251
     ORDER BY timestamp DESC LIMIT 1",
252 252
     $boincuser_id, $boincteam_id
253
-  ));
254
-  db_set_active('default');
255
-  return $timestamp;
253
+    ));
254
+    db_set_active('default');
255
+    return $timestamp;
256 256
 }
257 257
 
258 258
 /**
259 259
  * Get the team type for display
260 260
  */
261 261
 function boincteam_get_type($team_id) {
262
-  //$vid = boincteam_get_vocabulary_by_name('Teams'); $team->vid = $vid;
263
-  $team = node_load($team_id);
264
-  $terms = taxonomy_node_get_terms($team);
265
-  if ($terms) {
262
+    //$vid = boincteam_get_vocabulary_by_name('Teams'); $team->vid = $vid;
263
+    $team = node_load($team_id);
264
+    $terms = taxonomy_node_get_terms($team);
265
+    if ($terms) {
266 266
     $term = reset($terms);
267 267
     return $term->name;
268
-  } else {
268
+    } else {
269 269
     return null;
270
-  }
270
+    }
271 271
 }
272 272
 
273 273
 /**
274 274
  * Access a vocabulary of terms by name
275 275
  */ 
276 276
 function boincteam_get_vocabulary_by_name($name) {
277
-  $vocabs = taxonomy_get_vocabularies('team');
278
-  foreach ($vocabs as $vocab) {
277
+    $vocabs = taxonomy_get_vocabularies('team');
278
+    foreach ($vocabs as $vocab) {
279 279
     if ($vocab->name == $name) return $vocab->vid;
280
-  }
281
-  return null;
280
+    }
281
+    return null;
282 282
 }
283 283
 
284 284
 /**
285 285
  * Output the XML of the team history
286 286
  */
287 287
 function boincteam_history_xml($team_id) {
288
-  $team = node_load($team_id);
289
-  $boincteam_id = boincteam_lookup_id($team_id);
290
-  $team_history = array(
288
+    $team = node_load($team_id);
289
+    $boincteam_id = boincteam_lookup_id($team_id);
290
+    $team_history = array(
291 291
     'actions' => array(
292
-      'action' => array(),
292
+        'action' => array(),
293 293
     ),
294
-  );
294
+    );
295 295
   
296
-  db_set_active('boinc');
297
-  $result = db_query("
296
+    db_set_active('boinc');
297
+    $result = db_query("
298 298
     SELECT 
299 299
       td.userid AS id,
300 300
       u.name,
@@ -306,40 +306,40 @@  discard block
 block discarded – undo
306 306
     WHERE td.teamid = %d
307 307
     ORDER BY timestamp ASC",
308 308
     $boincteam_id
309
-  );
310
-  db_set_active('default');
309
+    );
310
+    db_set_active('default');
311 311
   
312
-  while ($record = db_fetch_array($result)) {
312
+    while ($record = db_fetch_array($result)) {
313 313
     $team_history['actions']['action'][] = $record;
314
-  }
314
+    }
315 315
   
316
-  header('Content-type: text/xml');
317
-  echo xml_to_text(array_to_xml($team_history));
316
+    header('Content-type: text/xml');
317
+    echo xml_to_text(array_to_xml($team_history));
318 318
 }
319 319
 
320 320
 /**
321 321
  * Convert a BOINC team ID to a Drupal team ID
322 322
  */
323 323
 function boincteam_lookup_nid($boinc_id) {
324
-  $drupal_id = db_result(db_query("SELECT nid FROM {boincteam} WHERE team_id='%d'", $boinc_id));
325
-  return $drupal_id;
324
+    $drupal_id = db_result(db_query("SELECT nid FROM {boincteam} WHERE team_id='%d'", $boinc_id));
325
+    return $drupal_id;
326 326
 }
327 327
 
328 328
 /**
329 329
  * Convert a Drupal team ID to a BOINC team ID
330 330
  */
331 331
 function boincteam_lookup_id($nid) {
332
-  $boinc_id = db_result(db_query("SELECT team_id FROM {boincteam} WHERE nid = '%d'", $nid));
333
-  return $boinc_id;
332
+    $boinc_id = db_result(db_query("SELECT team_id FROM {boincteam} WHERE nid = '%d'", $nid));
333
+    return $boinc_id;
334 334
 }
335 335
 
336 336
 /**
337 337
  * Get a BOINC team object
338 338
  */
339 339
 function boincteam_load($boincteam_id, $full_object = FALSE) {
340
-  require_boinc(array('team'));
341
-  $team = BoincTeam::lookup_id($boincteam_id);
342
-  if ($team AND $full_object) {
340
+    require_boinc(array('team'));
341
+    $team = BoincTeam::lookup_id($boincteam_id);
342
+    if ($team AND $full_object) {
343 343
     $team->nusers = BoincUser::count("teamid={$team->id}");
344 344
     $team->nusers_worked = BoincUser::count("teamid={$team->id} and total_credit>0");
345 345
     $team->nusers_active = BoincUser::count("teamid={$team->id} and expavg_credit>0.1");
@@ -347,340 +347,340 @@  discard block
 block discarded – undo
347 347
     $team->new_members = new_member_list($boincteam_id);
348 348
     $team->admins = admin_list($boincteam_id);
349 349
     $team->founder = BoincUser::lookup_id($team->userid);
350
-  }
351
-  return $team;
350
+    }
351
+    return $team;
352 352
 }
353 353
 
354 354
 /**
355 355
  * Check if a user is the team founder
356 356
  */
357 357
 function boincteam_is_founder($nid, $uid = NULL) {
358
-  if (!$uid) {
358
+    if (!$uid) {
359 359
     global $user;
360 360
     $uid = $user->uid;
361
-  }
362
-  if (!boincteam_is_member($nid, $uid)) {
361
+    }
362
+    if (!boincteam_is_member($nid, $uid)) {
363 363
     return FALSE;
364
-  }
365
-  $team_id = boincteam_lookup_id($nid);
366
-  require_boinc('team');
367
-  return is_team_founder(boincuser_load($uid, TRUE), boincteam_load($team_id));
364
+    }
365
+    $team_id = boincteam_lookup_id($nid);
366
+    require_boinc('team');
367
+    return is_team_founder(boincuser_load($uid, TRUE), boincteam_load($team_id));
368 368
 }
369 369
 
370 370
 /**
371 371
  * Check if a user is a team admin
372 372
  */
373 373
 function boincteam_is_admin($nid, $uid = NULL) {
374
-  if (!$uid) {
374
+    if (!$uid) {
375 375
     global $user;
376 376
     $uid = $user->uid;
377
-  }
378
-  if (!boincteam_is_member($nid, $uid)) {
377
+    }
378
+    if (!boincteam_is_member($nid, $uid)) {
379 379
     return FALSE;
380
-  }
381
-  $team_id = boincteam_lookup_id($nid);
382
-  require_boinc('team');
383
-  return is_team_admin(boincuser_load($uid, TRUE), boincteam_load($team_id));
380
+    }
381
+    $team_id = boincteam_lookup_id($nid);
382
+    require_boinc('team');
383
+    return is_team_admin(boincuser_load($uid, TRUE), boincteam_load($team_id));
384 384
 }
385 385
 
386 386
 /**
387 387
  * Check if a user is a team member
388 388
  */
389 389
 function boincteam_is_member($nid, $uid = NULL) {
390
-  if (!$uid) {
390
+    if (!$uid) {
391 391
     global $user;
392 392
     $uid = $user->uid;
393
-  }
394
-  $account = user_load($uid);
395
-  return ($account->team == $nid);
393
+    }
394
+    $account = user_load($uid);
395
+    return ($account->team == $nid);
396 396
 }
397 397
 
398 398
 /**
399 399
  * Display any persistent team messages
400 400
  */
401 401
 function boincteam_show_messages() {
402
-  global $user;
403
-  $uid = $user->uid;
404
-  $account = user_load($uid);
405
-  if ($account->team) {
402
+    global $user;
403
+    $uid = $user->uid;
404
+    $account = user_load($uid);
405
+    if ($account->team) {
406 406
     if (boincteam_is_founder($account->team, $account->uid)) {
407
-      // Set a notice of any pending foundership requests
408
-      $boincteam_id = boincteam_lookup_id($account->team);
409
-      $boincteam = boincteam_load($boincteam_id);
410
-      if ($boincteam->ping_user > 0) {
407
+        // Set a notice of any pending foundership requests
408
+        $boincteam_id = boincteam_lookup_id($account->team);
409
+        $boincteam = boincteam_load($boincteam_id);
410
+        if ($boincteam->ping_user > 0) {
411 411
         $foundership_url = "community/teams/{$account->team}/edit/founder";
412 412
         if (substr($_GET['q'], 0, strlen($foundership_url)) != $foundership_url) {
413
-          drupal_set_message(
413
+            drupal_set_message(
414 414
             bts(
415
-              'A foundership transfer request has been made for your team. Please !respond.',
416
-              array('!respond' => l(bts('respond to the request'), $foundership_url))
415
+                'A foundership transfer request has been made for your team. Please !respond.',
416
+                array('!respond' => l(bts('respond to the request'), $foundership_url))
417 417
             ),
418 418
             'warning', FALSE
419
-          );
419
+            );
420
+        }
420 421
         }
421
-      }
422 422
     }
423
-  }
423
+    }
424 424
 }
425 425
 
426 426
 /**
427 427
  * Add a user to a team
428 428
  */
429 429
 function boincteam_join($team_id) {
430
-  global $user;
431
-  $account = user_load($user->uid);
430
+    global $user;
431
+    $account = user_load($user->uid);
432 432
   
433
-  $boincteam_id = boincteam_lookup_id($team_id);
434
-  $boincteam = boincteam_load($boincteam_id);
435
-  if ($boincteam->joinable AND $account->team != $team_id) {
433
+    $boincteam_id = boincteam_lookup_id($team_id);
434
+    $boincteam = boincteam_load($boincteam_id);
435
+    if ($boincteam->joinable AND $account->team != $team_id) {
436 436
     require_boinc('team');
437 437
     $boincuser = boincuser_load();
438 438
     if (user_join_team($boincteam, $boincuser)) {
439
-      drupal_set_message(t('You are now a member of @team!',
439
+        drupal_set_message(t('You are now a member of @team!',
440 440
         array('@team' => $boincteam->name)));
441
-      watchdog('boincteam', 'added user @uid to team @nid',
441
+        watchdog('boincteam', 'added user @uid to team @nid',
442 442
         array('@uid' => $user->uid, '@nid' => $team_id), WATCHDOG_NOTICE);
443 443
     }
444 444
     else {
445
-      drupal_set_message(t('There was a problem joining @team, please try again
445
+        drupal_set_message(t('There was a problem joining @team, please try again
446 446
         later', array('@team' => $boincteam->name)));
447
-      watchdog('boincteam', 'error adding user @uid to team @nid',
447
+        watchdog('boincteam', 'error adding user @uid to team @nid',
448 448
         array('@uid' => $user->uid, '@nid' => $team_id), WATCHDOG_ERROR);
449 449
     }
450
-  }
451
-  drupal_goto("community/teams/{$team_id}");
450
+    }
451
+    drupal_goto("community/teams/{$team_id}");
452 452
 }
453 453
 
454 454
 /**
455 455
  * Leave a team
456 456
  */
457 457
 function boincteam_leave($team_id) {
458
-  global $user;
459
-  $account = user_load($user->uid);
458
+    global $user;
459
+    $account = user_load($user->uid);
460 460
   
461
-  $boincteam_id = boincteam_lookup_id($team_id);
462
-  $boincteam = boincteam_load($boincteam_id);
463
-  if ($account->team == $team_id) {
461
+    $boincteam_id = boincteam_lookup_id($team_id);
462
+    $boincteam = boincteam_load($boincteam_id);
463
+    if ($account->team == $team_id) {
464 464
     require_boinc('team');
465 465
     $boincuser = boincuser_load();
466 466
     user_quit_team($boincuser);
467 467
     drupal_set_message(t('You are no longer a member of @team.',
468
-      array('@team' => $boincteam->name)));
468
+        array('@team' => $boincteam->name)));
469 469
     watchdog('boincteam', 'removed user @uid from team @nid',
470
-      array('@uid' => $user->uid, '@nid' => $team_id), WATCHDOG_NOTICE);
471
-  }
472
-  else {
473
-      drupal_set_message(t('You are not a member of @team, so you cannot revoke
470
+        array('@uid' => $user->uid, '@nid' => $team_id), WATCHDOG_NOTICE);
471
+    }
472
+    else {
473
+        drupal_set_message(t('You are not a member of @team, so you cannot revoke
474 474
         your membership to it.', array('@team' => $boincteam->name)));
475
-  }
476
-  drupal_goto("community/teams/{$team_id}");
475
+    }
476
+    drupal_goto("community/teams/{$team_id}");
477 477
 }
478 478
 
479 479
 /**
480 480
  * Output a plain text list of member email addresses
481 481
  */
482 482
 function boincteam_members_email_list($team_id) {
483
-  $team = node_load($team_id);
484
-  $boincteam_id = boincteam_lookup_id($team_id);
485
-  $output = '';
483
+    $team = node_load($team_id);
484
+    $boincteam_id = boincteam_lookup_id($team_id);
485
+    $output = '';
486 486
   
487
-  db_set_active('boinc');
488
-  $result = db_query("
487
+    db_set_active('boinc');
488
+    $result = db_query("
489 489
     SELECT 
490 490
       u.name, u.email_addr
491 491
     FROM {user} u
492 492
     WHERE u.teamid = %d
493 493
     ORDER BY u.email_addr ASC",
494 494
     $boincteam_id
495
-  );
496
-  db_set_active('default');
495
+    );
496
+    db_set_active('default');
497 497
   
498
-  while ($member = db_fetch_object($result)) {
498
+    while ($member = db_fetch_object($result)) {
499 499
     $output .= "{$member->name} <{$member->email_addr}>\n";
500
-  }
500
+    }
501 501
   
502
-  header('Content-type: text/plain');
503
-  print $output;
502
+    header('Content-type: text/plain');
503
+    print $output;
504 504
 }
505 505
 
506 506
 /**
507 507
  * Remove team admin status from a user
508 508
  */
509 509
 function boincteam_remove_admin($team_id, $user_id) {
510
-  global $user;
511
-  $account = user_load($user_id);
512
-  $team = node_load($team_id);
513
-  $boincteam_id = boincteam_lookup_id($team_id);
514
-  $boincuser_id = $account->boincuser_id;
510
+    global $user;
511
+    $account = user_load($user_id);
512
+    $team = node_load($team_id);
513
+    $boincteam_id = boincteam_lookup_id($team_id);
514
+    $boincuser_id = $account->boincuser_id;
515 515
   
516
-  if (boincteam_is_admin($team_id, $account->uid)) {
516
+    if (boincteam_is_admin($team_id, $account->uid)) {
517 517
     // Update the team in the BOINC db
518 518
     db_set_active('boinc');
519 519
     db_query("
520 520
       DELETE FROM {team_admin} WHERE
521 521
         teamid = '%d' AND userid = '%d'",
522
-      $boincteam_id,
523
-      $boincuser_id
522
+        $boincteam_id,
523
+        $boincuser_id
524 524
     );
525 525
     db_set_active('default');
526 526
     drupal_set_message(t('@user is no longer an admin of @team.',
527
-      array(
527
+        array(
528 528
         '@user' => $account->boincuser_name,
529 529
         '@team' => $team->title
530
-      )
530
+        )
531 531
     ));
532 532
     watchdog('boincteam', 'User @current_user removed admin status for user
533 533
       @uid from team @nid',
534
-      array(
534
+        array(
535 535
         '@current_user' => $user->uid,
536 536
         '@uid' => $account->uid, 
537 537
         '@nid' => $team_id
538
-      ), WATCHDOG_NOTICE);
539
-  }
540
-  drupal_goto("community/teams/{$team_id}/edit/admins");
538
+        ), WATCHDOG_NOTICE);
539
+    }
540
+    drupal_goto("community/teams/{$team_id}/edit/admins");
541 541
 }
542 542
 
543 543
 /**
544 544
  * Remove a user from a team
545 545
  */
546 546
 function boincteam_remove_member($team_id, $user_id) {
547
-  global $user;
548
-  $account = user_load($user_id);
547
+    global $user;
548
+    $account = user_load($user_id);
549 549
   
550
-  $boincteam_id = boincteam_lookup_id($team_id);
551
-  $boincteam = boincteam_load($boincteam_id);
552
-  if ($account->team == $team_id) {
550
+    $boincteam_id = boincteam_lookup_id($team_id);
551
+    $boincteam = boincteam_load($boincteam_id);
552
+    if ($account->team == $team_id) {
553 553
     require_boinc('team');
554 554
     $boincuser = boincuser_load($user_id, TRUE);
555 555
     user_quit_team($boincuser);
556 556
     drupal_set_message(t('@user has been removed from @team.',
557
-      array(
557
+        array(
558 558
         '@user' => $account->boincuser_name,
559 559
         '@team' => $boincteam->name
560
-      )
560
+        )
561 561
     ));
562 562
     watchdog('boincteam', 'User @current_user removed user @uid from team @nid',
563
-      array(
563
+        array(
564 564
         '@current_user' => $user->uid,
565 565
         '@uid' => $account->uid, 
566 566
         '@nid' => $team_id
567
-      ), WATCHDOG_NOTICE);
568
-  }
569
-  else {
570
-      drupal_set_message(t('@user is not a member of @team, so you cannot
567
+        ), WATCHDOG_NOTICE);
568
+    }
569
+    else {
570
+        drupal_set_message(t('@user is not a member of @team, so you cannot
571 571
         revoke the membership.', array(
572
-          '@user' => $account->boincuser_name,
573
-          '@team' => $boincteam->name
572
+            '@user' => $account->boincuser_name,
573
+            '@team' => $boincteam->name
574 574
         )
575
-      ));
576
-  }
577
-  drupal_goto("community/teams/{$team_id}/edit/members");
575
+        ));
576
+    }
577
+    drupal_goto("community/teams/{$team_id}/edit/members");
578 578
 }
579 579
 
580 580
 /**
581 581
  * Request a foundership transfer
582 582
  */
583 583
 function boincteam_request_foundership($team_id) {
584
-  global $user;
585
-  $account = user_load($user->uid);
586
-  $team = node_load($team_id);
587
-  $boincteam_id = boincteam_lookup_id($team_id);
588
-  $boincteam = boincteam_load($boincteam_id);
589
-  $boincuser_id = $account->boincuser_id;
584
+    global $user;
585
+    $account = user_load($user->uid);
586
+    $team = node_load($team_id);
587
+    $boincteam_id = boincteam_lookup_id($team_id);
588
+    $boincteam = boincteam_load($boincteam_id);
589
+    $boincuser_id = $account->boincuser_id;
590 590
   
591
-  if (boincteam_is_founder($team_id, $account->uid)) {
591
+    if (boincteam_is_founder($team_id, $account->uid)) {
592 592
     // Shouldn't even be here...
593 593
     drupal_set_message(t('@user is already the team founder.',
594
-      array(
594
+        array(
595 595
         '@user' => $account->boincuser_name
596
-      )
596
+        )
597 597
     ), 'warning');
598
-  }
599
-  elseif (!boincteam_new_foundership_transfer_request_ok($team_id)) {
598
+    }
599
+    elseif (!boincteam_new_foundership_transfer_request_ok($team_id)) {
600 600
     // It hasn't been long enough since the last transfer request
601 601
     drupal_set_message(t('A foundership change was requested during the last 90
602 602
       days, so new requests are not allowed. Please try again later.'
603 603
     ), 'warning');
604
-  }
605
-  elseif (boincteam_is_member($team_id, $account->uid)) {
604
+    }
605
+    elseif (boincteam_is_member($team_id, $account->uid)) {
606 606
     // Log the transfer request
607 607
     db_set_active('boinc');
608 608
     db_query("
609 609
       UPDATE {team}
610 610
       SET ping_user = '%d', ping_time='%d'
611 611
       WHERE id = '%d'",
612
-      $boincuser_id, time(), $boincteam_id
612
+        $boincuser_id, time(), $boincteam_id
613 613
     );
614 614
     db_set_active('default');
615 615
     drupal_set_message(t('You have requested foundership of @team. The current
616 616
       founder has 60 days to respond to this request.',
617
-      array(
617
+        array(
618 618
         '@team' => $team->title
619
-      )
619
+        )
620 620
     ));
621 621
     watchdog('boincteam', 'User @user requested foundership of team @nid',
622
-      array(
622
+        array(
623 623
         '@current_user' => $account->uid,
624 624
         '@nid' => $team_id
625
-      ), WATCHDOG_NOTICE);
626
-  }
627
-  drupal_goto("community/teams/{$team_id}");
625
+        ), WATCHDOG_NOTICE);
626
+    }
627
+    drupal_goto("community/teams/{$team_id}");
628 628
 }
629 629
 
630 630
 /**
631 631
  * Transfer foundership to another team member
632 632
  */
633 633
 function boincteam_set_founder($team_id, $user_id) {
634
-  global $user;
635
-  $account = user_load($user_id);
636
-  $team = node_load($team_id);
637
-  $boincteam_id = boincteam_lookup_id($team_id);
638
-  $boincuser_id = $account->boincuser_id;
634
+    global $user;
635
+    $account = user_load($user_id);
636
+    $team = node_load($team_id);
637
+    $boincteam_id = boincteam_lookup_id($team_id);
638
+    $boincuser_id = $account->boincuser_id;
639 639
   
640
-  if (boincteam_is_member($team_id, $account->uid)) {
640
+    if (boincteam_is_member($team_id, $account->uid)) {
641 641
     // Update the team in the BOINC db
642 642
     db_set_active('boinc');
643 643
     db_query("
644 644
       UPDATE {team}
645 645
       SET userid = '%d', ping_user=0
646 646
       WHERE id = '%d'",
647
-      $boincuser_id, $boincteam_id
647
+        $boincuser_id, $boincteam_id
648 648
     );
649 649
     db_set_active('default');
650 650
     drupal_set_message(t('Foundership of @team has been transfered to @user.',
651
-      array(
651
+        array(
652 652
         '@user' => $account->boincuser_name,
653 653
         '@team' => $team->title
654
-      )
654
+        )
655 655
     ));
656 656
     watchdog('boincteam', 'User @current_user transferred foundership of team
657 657
       @nid to user @uid',
658
-      array(
658
+        array(
659 659
         '@current_user' => $user->uid,
660 660
         '@uid' => $account->uid, 
661 661
         '@nid' => $team_id
662
-      ), WATCHDOG_NOTICE);
663
-  }
664
-  drupal_goto("community/teams/{$team_id}");
662
+        ), WATCHDOG_NOTICE);
663
+    }
664
+    drupal_goto("community/teams/{$team_id}");
665 665
 }
666 666
 
667 667
 /**
668 668
  * See if a new foundership transfer request is allowed
669 669
  */
670 670
 function boincteam_new_foundership_transfer_request_ok($team_id) {
671
-  $boincteam_id = boincteam_lookup_id($team_id);
672
-  $boincteam = boincteam_load($boincteam_id);
673
-  $now = time();
674
-  if ($boincteam->ping_user <= 0) {
671
+    $boincteam_id = boincteam_lookup_id($team_id);
672
+    $boincteam = boincteam_load($boincteam_id);
673
+    $now = time();
674
+    if ($boincteam->ping_user <= 0) {
675 675
     if ($boincteam->ping_time < $now - 60 * (24*60*60)) {
676
-      return TRUE;
676
+        return TRUE;
677 677
     }
678 678
     return FALSE;
679
-  }
680
-  if ($boincteam->ping_time < $now - 90 * (24*60*60)) {
679
+    }
680
+    if ($boincteam->ping_time < $now - 90 * (24*60*60)) {
681 681
     return TRUE;
682
-  }
683
-  return FALSE;
682
+    }
683
+    return FALSE;
684 684
 }
685 685
 
686 686
 /** 
@@ -702,18 +702,18 @@  discard block
 block discarded – undo
702 702
  * Check if a user has an active foundership request with a team
703 703
  */
704 704
 function boincteam_user_requested_foundership($team_id, $user_id = NULL) {
705
-  if (!$user_id) {
705
+    if (!$user_id) {
706 706
     global $user;
707 707
     $user_id = $user->uid;
708
-  }
709
-  $account = user_load($user_id);
710
-  $boincteam_id = boincteam_lookup_id($team_id);
711
-  $boincteam = boincteam_load($boincteam_id);
708
+    }
709
+    $account = user_load($user_id);
710
+    $boincteam_id = boincteam_lookup_id($team_id);
711
+    $boincteam = boincteam_load($boincteam_id);
712 712
   
713
-  if ($boincteam->ping_user == $account->boincuser_id) {
713
+    if ($boincteam->ping_user == $account->boincuser_id) {
714 714
     // Be sure the request is still active
715 715
     return !boincteam_new_foundership_transfer_request_ok($team_id);
716
-  }
716
+    }
717 717
 }
718 718
 
719 719
 
@@ -725,124 +725,124 @@  discard block
 block discarded – undo
725 725
  * General info about team admins
726 726
  */                                         
727 727
 function boincteam_about_admins_panel() {
728
-  $output = '';
729
-  $output .= '<h2 class="pane-title">' . bts('About team admins') . '</h2>';
730
-  $output .= '<div>';
731
-  $output .= '<p>' . bts('Team admins can:') . '</p>';
732
-  $output .= '<ul>';
733
-  $output .= '  <li>' . bts('Edit team information') . '</li>';
734
-  $output .= '  <li>' . bts("View the team's join / quit history") . '</li>';
735
-  $output .= '  <li>' . bts('Moderate the team forum') . '</li>';
736
-  $output .= '  <li>' . bts('Remove members from the team') . '</li>';
737
-  $output .= '  <li>' . bts('Disband a team if it has no members') . '</li>';
738
-  $output .= '</ul>';
739
-  $output .= '</div>';
740
-  $output .= '<div>';
741
-  $output .= '<p>' . bts('Team admins cannot:') . '</p>';
742
-  $output .= '<ul>';
743
-  $output .= '  <li>' . bts('Change the team founder') . '</li>';
744
-  $output .= '  <li>' . bts('Remove members') . '</li>';
745
-  $output .= '  <li>' . bts('Add / Remove team admins') . '</li>';
746
-  $output .= '</ul>';
747
-  $output .= '</div>';
748
-  $output .= '<p>' . bts('If a team admin quits the team, they cease to be a'
728
+    $output = '';
729
+    $output .= '<h2 class="pane-title">' . bts('About team admins') . '</h2>';
730
+    $output .= '<div>';
731
+    $output .= '<p>' . bts('Team admins can:') . '</p>';
732
+    $output .= '<ul>';
733
+    $output .= '  <li>' . bts('Edit team information') . '</li>';
734
+    $output .= '  <li>' . bts("View the team's join / quit history") . '</li>';
735
+    $output .= '  <li>' . bts('Moderate the team forum') . '</li>';
736
+    $output .= '  <li>' . bts('Remove members from the team') . '</li>';
737
+    $output .= '  <li>' . bts('Disband a team if it has no members') . '</li>';
738
+    $output .= '</ul>';
739
+    $output .= '</div>';
740
+    $output .= '<div>';
741
+    $output .= '<p>' . bts('Team admins cannot:') . '</p>';
742
+    $output .= '<ul>';
743
+    $output .= '  <li>' . bts('Change the team founder') . '</li>';
744
+    $output .= '  <li>' . bts('Remove members') . '</li>';
745
+    $output .= '  <li>' . bts('Add / Remove team admins') . '</li>';
746
+    $output .= '</ul>';
747
+    $output .= '</div>';
748
+    $output .= '<p>' . bts('If a team admin quits the team, they cease to be a'
749 749
     . ' team admin. We recommend only selecting people you know and trust')
750 750
     . '</p>';
751
-  return $output;
751
+    return $output;
752 752
 }
753 753
 
754 754
 /**
755 755
  * General info about changing the team founder
756 756
  */                                         
757 757
 function boincteam_about_founder_panel() {
758
-  $output = '';
759
-  $output .= '<h2 class="pane-title">' . bts('Changing the team founder')
758
+    $output = '';
759
+    $output .= '<h2 class="pane-title">' . bts('Changing the team founder')
760 760
     . '</h2>';
761
-  $output .= '<div>';
762
-  $output .= '<p>' . bts('Notes about changes in foundership:') . '</p>';
763
-  $output .= '<ul>';
764
-  $output .= '  <li>' . bts('Any member of the team is eligible') . '</li>';
765
-  $output .= '  <li>' . bts('Current founder becomes a normal user') . '</li>';
766
-  $output .= '</ul>';
767
-  $output .= '</div>';
768
-  $output .= '<div>';
769
-  $output .= '<p>' . bts('Foundership can be requested by team members:')
761
+    $output .= '<div>';
762
+    $output .= '<p>' . bts('Notes about changes in foundership:') . '</p>';
763
+    $output .= '<ul>';
764
+    $output .= '  <li>' . bts('Any member of the team is eligible') . '</li>';
765
+    $output .= '  <li>' . bts('Current founder becomes a normal user') . '</li>';
766
+    $output .= '</ul>';
767
+    $output .= '</div>';
768
+    $output .= '<div>';
769
+    $output .= '<p>' . bts('Foundership can be requested by team members:')
770 770
     . '</p>';
771
-  $output .= '<ul>';
772
-  $output .= '  <li>' . bts('One request is allowed at a time') . '</li>';
773
-  $output .= '  <li>' . bts('It must be 60 days since any previous request')
771
+    $output .= '<ul>';
772
+    $output .= '  <li>' . bts('One request is allowed at a time') . '</li>';
773
+    $output .= '  <li>' . bts('It must be 60 days since any previous request')
774 774
     . '</li>';
775
-  $output .= '  <li>' . bts('Any active request must be older than 90 days')
775
+    $output .= '  <li>' . bts('Any active request must be older than 90 days')
776 776
     . '</li>';
777
-  $output .= '  <li>' . bts('Current founder has 60 days to respond to a'
777
+    $output .= '  <li>' . bts('Current founder has 60 days to respond to a'
778 778
     . ' request') . '</li>';
779
-  $output .= '</ul>';
780
-  $output .= '</div>';
781
-  return $output;
779
+    $output .= '</ul>';
780
+    $output .= '</div>';
781
+    return $output;
782 782
 }
783 783
 
784 784
 /**
785 785
  * Link to create a new team
786 786
  */
787 787
 function boincteam_create_team_link_panel() {
788
-  global $user;
789
-  $account = user_load($user->uid);
790
-  $unrestricted_role = array_search('verified contributor', user_roles(true));
791
-  $output = '';
792
-  $output .= '<h2 class="pane-title">' . bts('Create a new team') . '</h2>';
793
-  $output .= '<p>' . bts('If you cannot find a team that is right for you, you'
788
+    global $user;
789
+    $account = user_load($user->uid);
790
+    $unrestricted_role = array_search('verified contributor', user_roles(true));
791
+    $output = '';
792
+    $output .= '<h2 class="pane-title">' . bts('Create a new team') . '</h2>';
793
+    $output .= '<p>' . bts('If you cannot find a team that is right for you, you'
794 794
     . ' can create a team.') . '</p>';
795
-  $output .= '<ul class="tab-list">';
796
-  $output .= '  <li class="first last tab">';
797
-  if (isset($account->roles[$unrestricted_role])) {
795
+    $output .= '<ul class="tab-list">';
796
+    $output .= '  <li class="first last tab">';
797
+    if (isset($account->roles[$unrestricted_role])) {
798 798
     $output .= l(bts('Create new team'), 'community/teams/add');
799
-  } elseif ($account->uid <= 0) {
799
+    } elseif ($account->uid <= 0) {
800 800
     $output .= l(
801
-      bts('Login to create a new team'),
802
-      'user/login',
803
-      array('query' => drupal_get_destination())
801
+        bts('Login to create a new team'),
802
+        'user/login',
803
+        array('query' => drupal_get_destination())
804 804
     );
805
-  } else {
805
+    } else {
806 806
     $min_credit_needed = variable_get('boinc_comment_min_credit', 0);
807 807
     $credit_needed = $min_credit_needed - $account->boincuser_total_credit;
808 808
     $output .= '[';
809 809
     if ($credit_needed == 1) {
810
-      $output .= bts('You must earn 1 more credit!');
810
+        $output .= bts('You must earn 1 more credit!');
811 811
     }
812 812
     else {
813
-      $output .= bts('You must earn @count more credits!',
813
+        $output .= bts('You must earn @count more credits!',
814 814
         array('@count' => $credit_needed)
815
-      );
815
+        );
816 816
     }
817 817
     $output .= ']';
818
-  }
819
-  $output .= '  </li>';
820
-  $output .= '</ul>';
821
-  return $output;
818
+    }
819
+    $output .= '  </li>';
820
+    $output .= '</ul>';
821
+    return $output;
822 822
 }
823 823
 
824 824
 /**
825 825
  * Create team form
826 826
  */
827 827
 function boincteam_create_team_panel() {
828
-  $output = '';
829
-  $output .= '<h2 class="pane-title">' . bts('Create a team') . '</h2>';
830
-  $output .= drupal_get_form('boincteam_create_form');
828
+    $output = '';
829
+    $output .= '<h2 class="pane-title">' . bts('Create a team') . '</h2>';
830
+    $output .= drupal_get_form('boincteam_create_form');
831 831
   
832
-  return $output;
832
+    return $output;
833 833
 }
834 834
 
835 835
 /**
836 836
  * Link to user's team
837 837
  */
838 838
 function boincteam_dashboard_panel($uid = NULL) {
839
-  if (!$uid) {
839
+    if (!$uid) {
840 840
     global $user;
841 841
     $uid = $user->uid;
842
-  }
843
-  $output = '';
844
-  $account = user_load($uid);
845
-  if ($account->team) {
842
+    }
843
+    $output = '';
844
+    $account = user_load($uid);
845
+    if ($account->team) {
846 846
     $team = boincteam_load(boincteam_lookup_id($account->team));
847 847
     $output .= '<h2 class="pane-title">' . bts('Team') . '</h2>';
848 848
     $output .= '<div class="stats">';
@@ -861,244 +861,244 @@  discard block
 block discarded – undo
861 861
     $output .= '  <label>' . bts('Total credit') . ': </label>';
862 862
     $output .= '  <span>' . number_format($team->total_credit, 2) . '</span>';
863 863
     $output .= '</div>' . "\n";
864
-  }
865
-  return $output;
864
+    }
865
+    return $output;
866 866
 }
867 867
 
868 868
 /**
869 869
  * Edit team form
870 870
  */
871 871
 function boincteam_edit_team_panel($team_id) {
872
-  $team = node_load($team_id);
873
-  $output = '';
874
-  $output .= '<h2 class="pane-title">' . $team->title . '</h2>';
875
-  $output .= drupal_get_form('boincteam_edit_form', $team_id);
872
+    $team = node_load($team_id);
873
+    $output = '';
874
+    $output .= '<h2 class="pane-title">' . $team->title . '</h2>';
875
+    $output .= drupal_get_form('boincteam_edit_form', $team_id);
876 876
   
877
-  return $output;
877
+    return $output;
878 878
 }
879 879
 
880 880
 /**
881 881
  * Link to join a team
882 882
  */
883 883
 function boincteam_join_team_panel($team_id) {
884
-  $team = node_load($team_id);
885
-  $output = '';
886
-  $output .= '<h2 class="pane-title">' . bts('Join team') . '</h2>';
887
-  $output .= '<p>' . bts('Click here to become a member of @this_team',
884
+    $team = node_load($team_id);
885
+    $output = '';
886
+    $output .= '<h2 class="pane-title">' . bts('Join team') . '</h2>';
887
+    $output .= '<p>' . bts('Click here to become a member of @this_team',
888 888
     array('@this_team' =>$team->title)) . '</p>';
889
-  $output .= '<ul class="tab-list">';
890
-  $output .= '  <li class="first last tab">' . 
889
+    $output .= '<ul class="tab-list">';
890
+    $output .= '  <li class="first last tab">' . 
891 891
     l(bts('Join this team'), "community/teams/{$team_id}/join") . '</li>';
892
-  $output .= '</ul>';
893
-  return $output;
892
+    $output .= '</ul>';
893
+    return $output;
894 894
 }
895 895
 
896 896
 /**
897 897
  * Link to leave a team
898 898
  */
899 899
 function boincteam_leave_team_panel($team_id) {
900
-  $team = node_load($team_id);
901
-  $output = '';
902
-  $output .= '<h2 class="pane-title">' . bts('Leave team') . '</h2>';
903
-  $output .= '<p>' . bts('Click here to revoke your membership with'
900
+    $team = node_load($team_id);
901
+    $output = '';
902
+    $output .= '<h2 class="pane-title">' . bts('Leave team') . '</h2>';
903
+    $output .= '<p>' . bts('Click here to revoke your membership with'
904 904
     . ' @this_team', array('@this_team' =>$team->title)) . '</p>';
905
-  $output .= '<ul class="tab-list">';
906
-  $output .= '  <li class="first last tab">' . 
905
+    $output .= '<ul class="tab-list">';
906
+    $output .= '  <li class="first last tab">' . 
907 907
     l(bts('Leave this team'), "community/teams/{$team_id}/leave") . '</li>';
908
-  $output .= '</ul>';
909
-  return $output;
908
+    $output .= '</ul>';
909
+    return $output;
910 910
 }
911 911
 
912 912
 /**
913 913
  * General info about team admins
914 914
  */                                         
915 915
 function boincteam_manage_admins_panel_header($team_id) {
916
-  $output = '';
917
-  $output .= '<h4>' . bts('Add team admin') . '</h4>';
918
-  $output .= drupal_get_form('boincteam_add_admin_form', $team_id);
919
-  $output .= '<div class="clearfix"></div>';
920
-  $output .= '<h4>' . bts('Current team admins') . '</h4>';
916
+    $output = '';
917
+    $output .= '<h4>' . bts('Add team admin') . '</h4>';
918
+    $output .= drupal_get_form('boincteam_add_admin_form', $team_id);
919
+    $output .= '<div class="clearfix"></div>';
920
+    $output .= '<h4>' . bts('Current team admins') . '</h4>';
921 921
   
922
-  return $output;
922
+    return $output;
923 923
 }
924 924
 
925 925
 /**
926 926
  * Team management tools
927 927
  */
928 928
 function boincteam_management_panel($team_id) {
929
-  $is_founder = boincteam_is_founder($team_id);
930
-  $team = node_load($team_id);
931
-  $output = '';
932
-  $output .= '<h2 class="pane-title">' . bts('Manage team') . '</h2>';
929
+    $is_founder = boincteam_is_founder($team_id);
930
+    $team = node_load($team_id);
931
+    $output = '';
932
+    $output .= '<h2 class="pane-title">' . bts('Manage team') . '</h2>';
933 933
   
934
-  // Member list
935
-  $output .= '<div class="form-item">';
936
-  $output .= '  <label>' . bts('View member list') . '</label>';
937
-  $output .= '  <ul class="tab-list">';
938
-  $output .= '    <li class="first tab primary">' . 
934
+    // Member list
935
+    $output .= '<div class="form-item">';
936
+    $output .= '  <label>' . bts('View member list') . '</label>';
937
+    $output .= '  <ul class="tab-list">';
938
+    $output .= '    <li class="first tab primary">' . 
939 939
     l('HTML', "community/teams/{$team_id}/members") . '</li>';
940
-  $output .= '    <li class="last tab primary">' .
940
+    $output .= '    <li class="last tab primary">' .
941 941
     l('text', "community/teams/{$team_id}/members/email") . '</li>';
942
-  $output .= '  </ul>';
943
-  $output .= '  <div class="description">';
944
-  $output .=   bts('Member names and emails');
945
-  $output .= '  </div>';
946
-  $output .= '</div>'; 
942
+    $output .= '  </ul>';
943
+    $output .= '  <div class="description">';
944
+    $output .=   bts('Member names and emails');
945
+    $output .= '  </div>';
946
+    $output .= '</div>'; 
947 947
   
948
-  // Team history
949
-  $output .= '<div class="form-item">';
950
-  $output .= '  <label>' . bts('View change history') . '</label>';
951
-  $output .= '  <ul class="tab-list">';
952
-  $output .= '    <li class="first tab primary">' . 
948
+    // Team history
949
+    $output .= '<div class="form-item">';
950
+    $output .= '  <label>' . bts('View change history') . '</label>';
951
+    $output .= '  <ul class="tab-list">';
952
+    $output .= '    <li class="first tab primary">' . 
953 953
     l('HTML', "community/teams/{$team_id}/history") . '</li>';
954
-  $output .= '    <li class="last tab primary">' .
954
+    $output .= '    <li class="last tab primary">' .
955 955
     l('XML', "community/teams/{$team_id}/history/xml") . '</li>';
956
-  $output .= '  </ul>';
957
-  $output .= '  <div class="description">';
958
-  $output .=   bts('See member activity');
959
-  $output .= '  </div>';
960
-  $output .= '</div>';
956
+    $output .= '  </ul>';
957
+    $output .= '  <div class="description">';
958
+    $output .=   bts('See member activity');
959
+    $output .= '  </div>';
960
+    $output .= '</div>';
961 961
   
962
-  // Team forum
963
-  if (module_exists('boincteam_forum')) {
962
+    // Team forum
963
+    if (module_exists('boincteam_forum')) {
964 964
     if ($is_founder) {
965
-      // Determine whether to create a forum or edit the existing forum
966
-      // (multiple forums per team could be supported in the future)
967
-      $team_forum_link_path = 'add';
968
-      $team_forums = boincteam_forum_list();
969
-      if ($team_forums) {
965
+        // Determine whether to create a forum or edit the existing forum
966
+        // (multiple forums per team could be supported in the future)
967
+        $team_forum_link_path = 'add';
968
+        $team_forums = boincteam_forum_list();
969
+        if ($team_forums) {
970 970
         $team_forum = reset($team_forums);
971 971
         $team_forum_link_path = "{$team_forum->tfid}/edit";
972
-      }
973
-      $output .= '<div class="form-item">';
974
-      $output .= '  <ul class="tab-list action-list">';
975
-      $output .= '    <li class="first tab primary">' .   
972
+        }
973
+        $output .= '<div class="form-item">';
974
+        $output .= '  <ul class="tab-list action-list">';
975
+        $output .= '    <li class="first tab primary">' .   
976 976
         l(bts('Manage team message board'),
977
-          "community/teams/{$team_id}/forum/{$team_forum_link_path}"
977
+            "community/teams/{$team_id}/forum/{$team_forum_link_path}"
978 978
         );
979
-      $output .= '    </li>';
980
-      $output .= '  <div class="description">';
981
-      $output .=   bts('Create or manage message board');
982
-      $output .= '  </div>';
983
-      $output .= '</div>';
979
+        $output .= '    </li>';
980
+        $output .= '  <div class="description">';
981
+        $output .=   bts('Create or manage message board');
982
+        $output .= '  </div>';
983
+        $output .= '</div>';
984
+    }
984 985
     }
985
-  }
986 986
   
987
-  // Remove members
988
-  $output .= '<div class="form-item">';
989
-  $output .= '  <ul class="tab-list action-list">';
990
-  $output .= '    <li class="first tab primary">' . 
987
+    // Remove members
988
+    $output .= '<div class="form-item">';
989
+    $output .= '  <ul class="tab-list action-list">';
990
+    $output .= '    <li class="first tab primary">' . 
991 991
     l(bts('Remove members'), "community/teams/{$team_id}/edit/members") . '</li>';
992 992
   
993
-  if ($is_founder) {
993
+    if ($is_founder) {
994 994
     
995 995
     // Change founder
996 996
     $output .= '    <li class="tab primary">' . 
997
-      l(bts('Change founder'), "community/teams/{$team_id}/edit/founder") . '</li>';
997
+        l(bts('Change founder'), "community/teams/{$team_id}/edit/founder") . '</li>';
998 998
       
999
-      // Manage admins
999
+        // Manage admins
1000 1000
     $output .= '    <li class="tab primary">' . 
1001
-      l(bts('Manage team admins'), "community/teams/{$team_id}/edit/admins") . '</li>';
1002
-  }
1001
+        l(bts('Manage team admins'), "community/teams/{$team_id}/edit/admins") . '</li>';
1002
+    }
1003 1003
   
1004
-  // Edit team information
1005
-  $output .= '    <li class="tab primary">' . 
1004
+    // Edit team information
1005
+    $output .= '    <li class="tab primary">' . 
1006 1006
     l(bts('Edit team info'), "community/teams/{$team_id}/edit/info") . '</li>';
1007 1007
     
1008
-  if ($is_founder) {
1008
+    if ($is_founder) {
1009 1009
     
1010 1010
     // Delete the team
1011 1011
     $output .= '    <li class="last tab primary">' . 
1012
-      l(bts('Remove team'), "community/teams/{$team_id}/delete") . '</li>';
1013
-  }
1012
+        l(bts('Remove team'), "community/teams/{$team_id}/delete") . '</li>';
1013
+    }
1014 1014
   
1015
-  $output .= '  </ul>';
1016
-  $output .= '</div>';
1015
+    $output .= '  </ul>';
1016
+    $output .= '</div>';
1017 1017
   
1018
-  return $output;
1018
+    return $output;
1019 1019
 }
1020 1020
 
1021 1021
 /**
1022 1022
  * Link to user's team
1023 1023
  */
1024 1024
 function boincteam_member_link_panel() {
1025
-  global $user;
1026
-  $account = user_load($user->uid);
1027
-  $team = node_load($account->team);
1028
-  $output = '';
1029
-  $output .= '<h2 class="pane-title">' . bts('My team') . '</h2>';
1030
-  $output .= '<p>' . bts('You are a member of @team.', 
1025
+    global $user;
1026
+    $account = user_load($user->uid);
1027
+    $team = node_load($account->team);
1028
+    $output = '';
1029
+    $output .= '<h2 class="pane-title">' . bts('My team') . '</h2>';
1030
+    $output .= '<p>' . bts('You are a member of @team.', 
1031 1031
     array('@team' => $team->title)) . '</p>';
1032
-  $output .= '<ul class="tab-list">';
1033
-  $output .= '  <li class="first last tab">' . 
1032
+    $output .= '<ul class="tab-list">';
1033
+    $output .= '  <li class="first last tab">' . 
1034 1034
     l(bts('View my team'), "community/teams/{$account->team}") . '</li>';
1035
-  $output .= '</ul>';
1036
-  return $output;
1035
+    $output .= '</ul>';
1036
+    return $output;
1037 1037
 }
1038 1038
 
1039 1039
 /**
1040 1040
  * Link to request foundership transfer of a team
1041 1041
  */
1042 1042
 function boincteam_request_foundership_panel($team_id) {
1043
-  global $user;
1044
-  $account = user_load($user->uid);
1045
-  $team = node_load($team_id);
1046
-  $boincteam_id = boincteam_lookup_id($team_id);
1047
-  $boincteam = boincteam_load($boincteam_id);
1048
-  $boincuser_id = $account->boincuser_id;
1049
-  $output = '';
1050
-  $output .= '<h2 class="pane-title">' . bts('Request foundership') . '</h2>';
1043
+    global $user;
1044
+    $account = user_load($user->uid);
1045
+    $team = node_load($team_id);
1046
+    $boincteam_id = boincteam_lookup_id($team_id);
1047
+    $boincteam = boincteam_load($boincteam_id);
1048
+    $boincuser_id = $account->boincuser_id;
1049
+    $output = '';
1050
+    $output .= '<h2 class="pane-title">' . bts('Request foundership') . '</h2>';
1051 1051
   
1052
-  if (boincteam_user_requested_foundership($team_id)) {
1052
+    if (boincteam_user_requested_foundership($team_id)) {
1053 1053
     $deadline = boincteam_foundership_transfer_ok_time($boincteam);
1054 1054
     $days_to_deadline = ceil(($deadline - time()) / (24*60*60));
1055 1055
     $request_age = 60 - $days_to_deadline;
1056 1056
     $days_to_respond = 30 + $days_to_deadline;
1057 1057
     if (time() > $deadline) {
1058
-      $output .= '<p>';
1059
-      if ($request_age == 1) {
1058
+        $output .= '<p>';
1059
+        if ($request_age == 1) {
1060 1060
         $output .= bts('1 day has elapsed since your request and'
1061
-          . ' the founder has not responded.');
1062
-      }
1063
-      else {
1061
+            . ' the founder has not responded.');
1062
+        }
1063
+        else {
1064 1064
         $output .= bts('@count days have elapsed since your request and'
1065
-          . ' the founder has not responded.',
1066
-          array('@count' => $request_age)
1065
+            . ' the founder has not responded.',
1066
+            array('@count' => $request_age)
1067 1067
         );
1068
-      }
1069
-      $output .= ' ';
1070
-      if ($days_to_respond == 1) {
1068
+        }
1069
+        $output .= ' ';
1070
+        if ($days_to_respond == 1) {
1071 1071
         $output .= bts('You now have 1 day to assume foundership before'
1072
-          . ' another team member may submit a request.');
1073
-      }
1074
-      else {
1072
+            . ' another team member may submit a request.');
1073
+        }
1074
+        else {
1075 1075
         $output .= bts('You now have @count days to assume foundership before'
1076
-          . ' another team member may submit a request.',
1077
-          array('@count' => $days_to_respond)
1076
+            . ' another team member may submit a request.',
1077
+            array('@count' => $days_to_respond)
1078 1078
         );
1079
-      }
1080
-      $output .= '</p>';
1081
-      $output .= '<ul class="tab-list">';
1082
-      $output .= '  <li class="first last tab">' . 
1079
+        }
1080
+        $output .= '</p>';
1081
+        $output .= '<ul class="tab-list">';
1082
+        $output .= '  <li class="first last tab">' . 
1083 1083
         l(bts('Assume foundership'), "community/teams/{$team_id}/assume-foundership") . '</li>';
1084
-      $output .= '</ul>';
1084
+        $output .= '</ul>';
1085 1085
     }
1086 1086
     else {
1087
-      $output .= '<p>';
1088
-      if ($days_to_deadline == 1) {
1087
+        $output .= '<p>';
1088
+        if ($days_to_deadline == 1) {
1089 1089
         $output .= bts('The team founder has 1 day to respond to your'
1090
-          . ' transfer request.'
1090
+            . ' transfer request.'
1091 1091
         );
1092
-      }
1093
-      else {
1092
+        }
1093
+        else {
1094 1094
         $output .= bts('The team founder has @count days to respond to your'
1095
-          . ' transfer request.', array('@count' => $days_to_deadline)
1095
+            . ' transfer request.', array('@count' => $days_to_deadline)
1096 1096
         );
1097
-      }
1098
-      $output .= '</p>';
1097
+        }
1098
+        $output .= '</p>';
1099 1099
     }
1100
-  }
1101
-  elseif (!boincteam_new_foundership_transfer_request_ok($team_id)) {
1100
+    }
1101
+    elseif (!boincteam_new_foundership_transfer_request_ok($team_id)) {
1102 1102
     // If this user does not have a transfer request pending, but new requests
1103 1103
     // are not allowed, set the deadline to 90 days instead of 60 (as the user
1104 1104
     // who made the request has 30 additional days to assume foundership if 
@@ -1107,131 +1107,131 @@  discard block
 block discarded – undo
1107 1107
     $days_to_deadline = ceil(($deadline - time()) / (24*60*60)) + 30;
1108 1108
     $output .= '<p>';
1109 1109
     $output .= bts('A team foundership change was already requested recently.'
1110
-      . ' Only one request is allowed within a period of 90 days.'
1110
+        . ' Only one request is allowed within a period of 90 days.'
1111 1111
     );
1112 1112
     if ($days_to_deadline == 1) {
1113
-      $output .= ' (' . bts('1 day remaining') . ')';
1113
+        $output .= ' (' . bts('1 day remaining') . ')';
1114 1114
     }
1115 1115
     else {
1116
-      $output .= ' (' . bts('@count days remaining',
1116
+        $output .= ' (' . bts('@count days remaining',
1117 1117
         array('@count' => $days_to_deadline)
1118
-      ) . ')';
1118
+        ) . ')';
1119 1119
     }
1120 1120
     $output .= '</p>';
1121
-  }
1122
-  else {
1121
+    }
1122
+    else {
1123 1123
     $output .= '<p>' . bts('If the team founder is not active and you want to'
1124
-      . ' assume the role of founder, click below to request foundership of'
1125
-      . ' @this_team.',
1126
-      array('@this_team' =>$team->title)) . '</p>';
1124
+        . ' assume the role of founder, click below to request foundership of'
1125
+        . ' @this_team.',
1126
+        array('@this_team' =>$team->title)) . '</p>';
1127 1127
     $output .= '<ul class="tab-list">';
1128 1128
     $output .= '  <li class="first last tab">' . 
1129
-      l(bts('Initiate request'), "community/teams/{$team_id}/request-foundership") . '</li>';
1129
+        l(bts('Initiate request'), "community/teams/{$team_id}/request-foundership") . '</li>';
1130 1130
     $output .= '</ul>';
1131
-  }
1132
-  return $output;
1131
+    }
1132
+    return $output;
1133 1133
 }
1134 1134
 
1135 1135
 /**
1136 1136
  * Respond to foundership transfer requests for a team
1137 1137
  */
1138 1138
 function boincteam_request_foundership_response_panel($team_id) {
1139
-  global $user;
1140
-  $account = user_load($user->uid);
1141
-  $team = node_load($team_id);
1142
-  $boincteam_id = boincteam_lookup_id($team_id);
1143
-  $boincteam = boincteam_load($boincteam_id);
1144
-  $boincuser_id = $account->boincuser_id;
1145
-  $output = '';
1139
+    global $user;
1140
+    $account = user_load($user->uid);
1141
+    $team = node_load($team_id);
1142
+    $boincteam_id = boincteam_lookup_id($team_id);
1143
+    $boincteam = boincteam_load($boincteam_id);
1144
+    $boincuser_id = $account->boincuser_id;
1145
+    $output = '';
1146 1146
   
1147
-  if ($boincteam->ping_user) {
1147
+    if ($boincteam->ping_user) {
1148 1148
     if ($boincteam->ping_user < 0) {
1149
-      $member = user_load(boincuser_lookup_uid(-$boincteam->ping_user));
1150
-      $output .= '<h2 class="pane-title">' . bts('Obsolete transfer request')
1149
+        $member = user_load(boincuser_lookup_uid(-$boincteam->ping_user));
1150
+        $output .= '<h2 class="pane-title">' . bts('Obsolete transfer request')
1151 1151
         . '</h2>';
1152
-      $output .= '<p>' . bts('Team member @name requested team foundership on'
1152
+        $output .= '<p>' . bts('Team member @name requested team foundership on'
1153 1153
         . ' @date, but then left the team. This request is now canceled.',
1154 1154
         array(
1155
-          '@name' => $member->boincuser_name,
1156
-          '@date' => date('j M Y', $boincteam->ping_time),
1155
+            '@name' => $member->boincuser_name,
1156
+            '@date' => date('j M Y', $boincteam->ping_time),
1157 1157
         )
1158
-      ) . '</p>';
1159
-      // Automatically cancel the request
1160
-      db_set_active('boinc');
1161
-      db_query("
1158
+        ) . '</p>';
1159
+        // Automatically cancel the request
1160
+        db_set_active('boinc');
1161
+        db_query("
1162 1162
         UPDATE {team}
1163 1163
         SET ping_user=0
1164 1164
         WHERE id = '%d'",
1165 1165
         $boincteam_id
1166
-      );
1167
-      db_set_active('default');
1166
+        );
1167
+        db_set_active('default');
1168 1168
     }
1169 1169
     else {
1170
-      $member = user_load(boincuser_lookup_uid($boincteam->ping_user));
1171
-      $output .= '<h2 class="pane-title">' . bts('Respond to transfer request')
1170
+        $member = user_load(boincuser_lookup_uid($boincteam->ping_user));
1171
+        $output .= '<h2 class="pane-title">' . bts('Respond to transfer request')
1172 1172
         . '</h2>';
1173
-      $output .= '<p>' . bts('Team member @name has requested team foundership.'
1173
+        $output .= '<p>' . bts('Team member @name has requested team foundership.'
1174 1174
         . ' This may be because you left the team or have not had contact with'
1175 1175
         . ' the team for a long time.', array(
1176
-          '@name' => $member->boincuser_name,
1176
+            '@name' => $member->boincuser_name,
1177 1177
         )
1178
-      ) . '</p>';
1179
-      $output .= '<p>' . bts("If you don't decline the request by @date, @name"
1178
+        ) . '</p>';
1179
+        $output .= '<p>' . bts("If you don't decline the request by @date, @name"
1180 1180
         . ' will have the option of assuming team foundership. (note: To'
1181 1181
         . ' accept the request, assign foundership to @name using the form'
1182 1182
         . ' below)',
1183 1183
         array(
1184
-          '@name' => $member->boincuser_name,
1185
-          '@date' => date('j M Y', boincteam_foundership_transfer_ok_time($boincteam)),
1184
+            '@name' => $member->boincuser_name,
1185
+            '@date' => date('j M Y', boincteam_foundership_transfer_ok_time($boincteam)),
1186 1186
         )
1187
-      ) . '</p>';
1188
-      $output .= '<ul class="tab-list">';
1189
-      $output .= '  <li class="first last tab">' . 
1187
+        ) . '</p>';
1188
+        $output .= '<ul class="tab-list">';
1189
+        $output .= '  <li class="first last tab">' . 
1190 1190
         l(bts('Deny request'), "community/teams/{$team_id}/deny-foundership-request") . '</li>';
1191
-      $output .= '</ul>';
1191
+        $output .= '</ul>';
1192 1192
     }
1193
-  }
1194
-  return $output;
1193
+    }
1194
+    return $output;
1195 1195
 }
1196 1196
 
1197 1197
 function boincteam_search_panel() {
1198
-  $output = '';
1199
-  if (module_exists('global_search_teams_solr')) {
1198
+    $output = '';
1199
+    if (module_exists('global_search_teams_solr')) {
1200 1200
     $output .= '<h2 class="pane-title">' . bts('Search teams') . '</h2>';
1201 1201
     //$output .= '<p>' . bts('Render a search form here.') . '</p>';
1202 1202
     $output .= '<p>' . boincteam_search_view() . '</p>';
1203
-  }
1204
-  return $output;
1203
+    }
1204
+    return $output;
1205 1205
 }
1206 1206
 
1207 1207
 function boincteam_search_view($type = 'team') {
1208
-  // Get the team search form
1209
-  $search_page = apachesolr_search_page_load('team_search');
1210
-  module_load_include('inc', 'apachesolr_search', 'apachesolr_search.pages');
1211
-  return drupal_get_form('apachesolr_search_custom_page_search_form', $search_page);
1208
+    // Get the team search form
1209
+    $search_page = apachesolr_search_page_load('team_search');
1210
+    module_load_include('inc', 'apachesolr_search', 'apachesolr_search.pages');
1211
+    return drupal_get_form('apachesolr_search_custom_page_search_form', $search_page);
1212 1212
 }
1213 1213
 
1214 1214
 /**
1215 1215
  * General info about the concept of teams
1216 1216
  */                                         
1217 1217
 function boincteam_topic_overview_panel() {
1218
-  $site_name =  variable_get('site_name', bts('Project'));
1219
-  $output = '';
1220
-  $output .= '<h2 class="pane-title">' . bts('Teams') . '</h2>';
1221
-  $output .= '<div class="">';
1222
-  $output .= '<p>' . bts('@project participants may form teams. You may belong'
1218
+    $site_name =  variable_get('site_name', bts('Project'));
1219
+    $output = '';
1220
+    $output .= '<h2 class="pane-title">' . bts('Teams') . '</h2>';
1221
+    $output .= '<div class="">';
1222
+    $output .= '<p>' . bts('@project participants may form teams. You may belong'
1223 1223
     . ' to only one team. You can join or quit a team at any time. To join a'
1224 1224
     . ' team, visit its team page and click "Join this team". Each team has a'
1225 1225
     . ' founder who may:', array('@project' => $site_name)) . '</p>';
1226
-  $output .= '<ul>';
1227
-  $output .= '  <li>' . bts("access team members' email addresses") . '</li>';
1228
-  $output .= '  <li>' . bts("edit the team's name and description") . '</li>';
1229
-  $output .= '  <li>' . bts('add or remove team admins') . '</li>';
1230
-  $output .= '  <li>' . bts('remove members from the team') . '</li>';
1231
-  $output .= '  <li>' . bts('disband a team if it has no members') . '</li>';
1232
-  $output .= '</ul>';
1233
-  $output .= '</div>';
1234
-  return $output;
1226
+    $output .= '<ul>';
1227
+    $output .= '  <li>' . bts("access team members' email addresses") . '</li>';
1228
+    $output .= '  <li>' . bts("edit the team's name and description") . '</li>';
1229
+    $output .= '  <li>' . bts('add or remove team admins') . '</li>';
1230
+    $output .= '  <li>' . bts('remove members from the team') . '</li>';
1231
+    $output .= '  <li>' . bts('disband a team if it has no members') . '</li>';
1232
+    $output .= '</ul>';
1233
+    $output .= '</div>';
1234
+    return $output;
1235 1235
 }
1236 1236
 
1237 1237
 /**
@@ -1259,50 +1259,50 @@  discard block
 block discarded – undo
1259 1259
  * Link to view a team
1260 1260
  */
1261 1261
 function boincteam_view_team_panel($team_id) {
1262
-  $team = node_load($team_id);
1263
-  if ($team->type != "team") {
1262
+    $team = node_load($team_id);
1263
+    if ($team->type != "team") {
1264 1264
     return;
1265
-  }
1266
-  $boincteam = boincteam_load(boincteam_lookup_id($team_id), TRUE);
1267
-  $founder = user_load(get_drupal_id($boincteam->userid));
1268
-  $new_members = array();
1269
-  if ($boincteam->new_members) {
1265
+    }
1266
+    $boincteam = boincteam_load(boincteam_lookup_id($team_id), TRUE);
1267
+    $founder = user_load(get_drupal_id($boincteam->userid));
1268
+    $new_members = array();
1269
+    if ($boincteam->new_members) {
1270 1270
     foreach ($boincteam->new_members as $member) {
1271
-      $account = user_load(get_drupal_id($member->id));
1272
-      $new_members[] = l($account->boincuser_name, "account/{$account->uid}");
1271
+        $account = user_load(get_drupal_id($member->id));
1272
+        $new_members[] = l($account->boincuser_name, "account/{$account->uid}");
1273 1273
     }
1274
-  }
1275
-  $output = '';
1276
-  $output .= '<h2 class="pane-title">' . $boincteam->name . '</h2>';
1277
-  $output .= '<div>';
1278
-  $output .= '<div class="left-column">';
1279
-  $output .= '<ul class="stats">';
1280
-  $output .= '  <li>' . bts('Total credits') . ': ' . number_format($boincteam->total_credit, 2) . '</li>';
1281
-  $output .= '  <li>' . bts('Recent avg credits') . ': ' . number_format($boincteam->expavg_credit, 2) . '</li>';
1282
-  $output .= '  <li>' . bts('Country') . ': ' . $boincteam->country . '</li>';
1283
-  $output .= '  <li>' . bts('Type') . ': ' . boincteam_get_type($team_id) . '</li>';
1284
-  $output .= '</ul>';
1285
-  $output .= '</div>';
1286
-  $output .= '<div class="right-column">';
1287
-  $output .= '<ul class="stats">';
1288
-  $output .= '  <li>' . bts('Founder') . ': ' . l($founder->boincuser_name, "account/{$founder->uid}") . '</li>';
1289
-  $output .= '  <li>' . bts('New members in last day') . ': ' . implode('&middot;', $new_members) . '</li>';
1290
-  $output .= '  <li>' . bts('Total members') . ': ' . l($boincteam->nusers, "community/teams/{$team_id}/members") . '</li>';
1291
-  $output .= '  <li>' . bts('Active members') . ': ' . $boincteam->nusers_active . '</li>';
1292
-  $output .= '  <li>' . bts('Members with credit') . ': ' . $boincteam->nusers_worked . '</li>';
1293
-  $output .= '</ul>';
1294
-  $output .= '</div>';
1295
-  $output .= '</div>';
1296
-  $output .= '<div class="clearfix"></div>';
1297
-  if ($boincteam->url) {
1274
+    }
1275
+    $output = '';
1276
+    $output .= '<h2 class="pane-title">' . $boincteam->name . '</h2>';
1277
+    $output .= '<div>';
1278
+    $output .= '<div class="left-column">';
1279
+    $output .= '<ul class="stats">';
1280
+    $output .= '  <li>' . bts('Total credits') . ': ' . number_format($boincteam->total_credit, 2) . '</li>';
1281
+    $output .= '  <li>' . bts('Recent avg credits') . ': ' . number_format($boincteam->expavg_credit, 2) . '</li>';
1282
+    $output .= '  <li>' . bts('Country') . ': ' . $boincteam->country . '</li>';
1283
+    $output .= '  <li>' . bts('Type') . ': ' . boincteam_get_type($team_id) . '</li>';
1284
+    $output .= '</ul>';
1285
+    $output .= '</div>';
1286
+    $output .= '<div class="right-column">';
1287
+    $output .= '<ul class="stats">';
1288
+    $output .= '  <li>' . bts('Founder') . ': ' . l($founder->boincuser_name, "account/{$founder->uid}") . '</li>';
1289
+    $output .= '  <li>' . bts('New members in last day') . ': ' . implode('&middot;', $new_members) . '</li>';
1290
+    $output .= '  <li>' . bts('Total members') . ': ' . l($boincteam->nusers, "community/teams/{$team_id}/members") . '</li>';
1291
+    $output .= '  <li>' . bts('Active members') . ': ' . $boincteam->nusers_active . '</li>';
1292
+    $output .= '  <li>' . bts('Members with credit') . ': ' . $boincteam->nusers_worked . '</li>';
1293
+    $output .= '</ul>';
1294
+    $output .= '</div>';
1295
+    $output .= '</div>';
1296
+    $output .= '<div class="clearfix"></div>';
1297
+    if ($boincteam->url) {
1298 1298
     $output .= '<div class="stats">';
1299 1299
     $output .= bts('Web site') . ': ' . l("http://{$boincteam->url}", "http://{$boincteam->url}");
1300 1300
     $output .= '</div>';
1301
-  }
1302
-  if ($team->body) {
1301
+    }
1302
+    if ($team->body) {
1303 1303
     $output .= '<h3>' . bts('Description') . '</h3>';
1304 1304
     $output .= check_markup($team->body, $team->format);
1305 1305
     $output .= '</div>';
1306
-  }
1307
-  return $output;
1306
+    }
1307
+    return $output;
1308 1308
 }
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boincteam/boincteam.views.inc 1 patch
Indentation   +206 added lines, -206 removed lines patch added patch discarded remove patch
@@ -13,103 +13,103 @@  discard block
 block discarded – undo
13 13
  */
14 14
 function boincteam_views_data() {
15 15
   
16
-  // -----------------------------------------------------------------------------------------------
17
-  // Definition for team table
18
-  // -----------------------------------------------------------------------------------------------
16
+    // -----------------------------------------------------------------------------------------------
17
+    // Definition for team table
18
+    // -----------------------------------------------------------------------------------------------
19 19
   
20
-  $data['team']['table']['group'] = t('BOINC');
20
+    $data['team']['table']['group'] = t('BOINC');
21 21
   
22
-  $data['team']['table']['base'] = array(
23
-      'field' => 'id',
24
-      'title' => t('BOINC team'),
25
-      'help' => t('BOINC data for a team'),
26
-      'database' => 'boinc'
27
-  );
22
+    $data['team']['table']['base'] = array(
23
+        'field' => 'id',
24
+        'title' => t('BOINC team'),
25
+        'help' => t('BOINC data for a team'),
26
+        'database' => 'boinc'
27
+    );
28 28
   
29
-  // This table references the {user} table.
30
-  // This join creates an 'implicit' relationship to the user table, so that when
31
-  // "User" is the base table, the fields are automatically available.
29
+    // This table references the {user} table.
30
+    // This join creates an 'implicit' relationship to the user table, so that when
31
+    // "User" is the base table, the fields are automatically available.
32 32
   
33
-  // Index this array by the table name to which this table refers.
34
-  // 'left_field' is the primary key in the referenced table.
35
-  // 'field' is the foreign key in this table.
33
+    // Index this array by the table name to which this table refers.
34
+    // 'left_field' is the primary key in the referenced table.
35
+    // 'field' is the foreign key in this table.
36 36
   
37
-  $data['team']['table']['join'] = array(
37
+    $data['team']['table']['join'] = array(
38 38
     'user' => array(
39
-      'left_field' => 'id',
40
-      'field' => 'userid',
39
+        'left_field' => 'id',
40
+        'field' => 'userid',
41 41
     ),
42
-  );
42
+    );
43 43
 
44
-  // Describe each of the individual fields in this table to Views. For
45
-  // each field, you may define what field, sort, argument, and/or filter
46
-  // handlers it supports. This will determine where in the Views interface you
47
-  // may use the field.
44
+    // Describe each of the individual fields in this table to Views. For
45
+    // each field, you may define what field, sort, argument, and/or filter
46
+    // handlers it supports. This will determine where in the Views interface you
47
+    // may use the field.
48 48
   
49
-  // Primary keys allowed as arguments
49
+    // Primary keys allowed as arguments
50 50
   
51
-  $data['team']['id'] = array(
51
+    $data['team']['id'] = array(
52 52
     'title' => bts('Id'),
53 53
     'help' => t('The BOINC ID of the team.'),
54 54
     'field' => array(
55
-      'handler' => 'views_handler_field_numeric',
56
-      'click sortable' => TRUE
55
+        'handler' => 'views_handler_field_numeric',
56
+        'click sortable' => TRUE
57 57
     ),
58 58
     'argument' => array(
59
-      'handler' => 'views_handler_argument_boincteam_id', // custom handler
60
-      'name field' => 'title', // the field to display in the summary.
61
-      'numeric' => TRUE,
62
-      'validate type' => 'id'
59
+        'handler' => 'views_handler_argument_boincteam_id', // custom handler
60
+        'name field' => 'title', // the field to display in the summary.
61
+        'numeric' => TRUE,
62
+        'validate type' => 'id'
63 63
     ),
64 64
     'relationship' => array(
65
-      'base' => 'team_delta',
66
-      'field' => 'id',
67
-      'base field' => 'teamid',
68
-      'handler' => 'views_handler_relationship',
69
-      'label' => t('Team History')
65
+        'base' => 'team_delta',
66
+        'field' => 'id',
67
+        'base field' => 'teamid',
68
+        'handler' => 'views_handler_relationship',
69
+        'label' => t('Team History')
70 70
     ),
71 71
     'filter' => array(
72
-      'handler' => 'views_handler_filter_numeric'
72
+        'handler' => 'views_handler_filter_numeric'
73 73
     ),
74 74
     'sort' => array(
75
-      'handler' => 'views_handler_sort_numeric'
75
+        'handler' => 'views_handler_sort_numeric'
76 76
     )
77
-  );
77
+    );
78 78
   
79
-  // Foreign key fields
79
+    // Foreign key fields
80 80
   
81
-  $data['team']['userid'] = array(
81
+    $data['team']['userid'] = array(
82 82
     'title' => bts('Founder'),
83 83
     'help' => t('The founder of this team.'),
84 84
     // This is a foreign key to the {user} table. When the view is configured
85 85
     // with this relationship, all the fields for the related user node will be 
86 86
     // available.
87 87
     'argument' => array(
88
-      'handler' => 'views_handler_argument_boincuser_id',
89
-      'name field' => 'title',
90
-      'numeric' => TRUE,
91
-      'validate type' => 'id'
88
+        'handler' => 'views_handler_argument_boincuser_id',
89
+        'name field' => 'title',
90
+        'numeric' => TRUE,
91
+        'validate type' => 'id'
92 92
     ),
93 93
     'relationship' => array(
94
-      'base' => 'user',
95
-      'field' => 'userid',
96
-      'handler' => 'views_handler_relationship',
97
-      'label' => t('User')
94
+        'base' => 'user',
95
+        'field' => 'userid',
96
+        'handler' => 'views_handler_relationship',
97
+        'label' => t('User')
98 98
     ),
99 99
     'field' => array(
100
-      'handler' => 'views_handler_field_numeric',
101
-      'click sortable' => TRUE
100
+        'handler' => 'views_handler_field_numeric',
101
+        'click sortable' => TRUE
102 102
     ),
103 103
     'filter' => array(
104
-      'handler' => 'views_handler_filter_numeric'
104
+        'handler' => 'views_handler_filter_numeric'
105 105
     ),
106 106
     'sort' => array(
107
-      'handler' => 'views_handler_sort_numeric'
107
+        'handler' => 'views_handler_sort_numeric'
108 108
     )
109
-  );
109
+    );
110 110
   
111
-  // Descriptions of general fields (alphabetized)
112
-  /*
111
+    // Descriptions of general fields (alphabetized)
112
+    /*
113 113
   $data['team']['create_time'] = array(
114 114
     'title' => bts('Team established'),
115 115
     'help' => t('When the BOINC team was created.'),
@@ -140,298 +140,298 @@  discard block
 block discarded – undo
140 140
   );
141 141
   */
142 142
    
143
-  $data['team']['country'] = array(
143
+    $data['team']['country'] = array(
144 144
     'title' => bts('Country'),
145 145
     'help' => t('The country of a team.'),
146 146
     'field' => array(
147
-      'handler' => 'views_handler_field',
148
-      'click sortable' => TRUE
147
+        'handler' => 'views_handler_field',
148
+        'click sortable' => TRUE
149 149
     ),
150 150
     'filter' => array(
151
-      'handler' => 'views_handler_filter_string'
151
+        'handler' => 'views_handler_filter_string'
152 152
     ),
153 153
     'sort' => array(
154
-      'handler' => 'views_handler_sort_string'
154
+        'handler' => 'views_handler_sort_string'
155 155
     )
156
-  );
157
-  $data['team']['expavg_credit'] = array(
156
+    );
157
+    $data['team']['expavg_credit'] = array(
158 158
     'title' => bts('Recent average credit'),
159 159
     'help' => t('A decaying average of team credit per day.'),
160 160
     'field' => array(
161
-      'handler' => 'views_handler_field_numeric',
162
-      'click sortable' => TRUE,
163
-      'float' => TRUE
161
+        'handler' => 'views_handler_field_numeric',
162
+        'click sortable' => TRUE,
163
+        'float' => TRUE
164 164
     ),
165 165
     'filter' => array(
166
-      'handler' => 'views_handler_filter_numeric'
166
+        'handler' => 'views_handler_filter_numeric'
167 167
     ),
168 168
     'sort' => array(
169
-      'handler' => 'views_handler_sort_numeric'
169
+        'handler' => 'views_handler_sort_numeric'
170 170
     )
171
-  );
172
-  $data['team']['name'] = array(
171
+    );
172
+    $data['team']['name'] = array(
173 173
     'title' => bts('Name'),
174 174
     'help' => t('The name of the team.'),
175 175
     'field' => array(
176
-      'handler' => 'views_handler_field',
177
-      'click sortable' => TRUE
176
+        'handler' => 'views_handler_field',
177
+        'click sortable' => TRUE
178 178
     ),
179 179
     'filter' => array(
180
-      'handler' => 'views_handler_filter_string'
180
+        'handler' => 'views_handler_filter_string'
181 181
     ),
182 182
     'sort' => array(
183
-      'handler' => 'views_handler_sort_string'
183
+        'handler' => 'views_handler_sort_string'
184 184
     )
185
-  );
186
-  $data['team']['nusers'] = array(
185
+    );
186
+    $data['team']['nusers'] = array(
187 187
     'title' => bts('Members'),
188 188
     'help' => t('Count of team members.'),
189 189
     'field' => array(
190
-      'handler' => 'views_handler_field_numeric',
191
-      'click sortable' => TRUE
190
+        'handler' => 'views_handler_field_numeric',
191
+        'click sortable' => TRUE
192 192
     ),
193 193
     'filter' => array(
194
-      'handler' => 'views_handler_filter_numeric'
194
+        'handler' => 'views_handler_filter_numeric'
195 195
     ),
196 196
     'sort' => array(
197
-      'handler' => 'views_handler_sort_numeric'
197
+        'handler' => 'views_handler_sort_numeric'
198 198
     )
199
-  );
200
-  $data['team']['total_credit'] = array(
199
+    );
200
+    $data['team']['total_credit'] = array(
201 201
     'title' => bts('Total Credit'),
202 202
     'help' => t('The total team accumulated BOINC credit.'),
203 203
     'field' => array(
204
-      'handler' => 'views_handler_field_numeric',
205
-      'click sortable' => TRUE,
206
-      'float' => TRUE
204
+        'handler' => 'views_handler_field_numeric',
205
+        'click sortable' => TRUE,
206
+        'float' => TRUE
207 207
     ),
208 208
     'filter' => array(
209
-      'handler' => 'views_handler_filter_numeric'
209
+        'handler' => 'views_handler_filter_numeric'
210 210
     ),
211 211
     'sort' => array(
212
-      'handler' => 'views_handler_sort_numeric'
212
+        'handler' => 'views_handler_sort_numeric'
213 213
     )
214
-  );
214
+    );
215 215
   
216
-  // -----------------------------------------------------------------------------------------------
217
-  // Definition for team_admin table
218
-  // -----------------------------------------------------------------------------------------------
216
+    // -----------------------------------------------------------------------------------------------
217
+    // Definition for team_admin table
218
+    // -----------------------------------------------------------------------------------------------
219 219
   
220
-  $data['team_admin']['table']['group'] = t('BOINC');
220
+    $data['team_admin']['table']['group'] = t('BOINC');
221 221
   
222
-  $data['team_admin']['table']['base'] = array(
223
-      'field' => 'id',
224
-      'title' => t('BOINC team admins'),
225
-      'help' => t('BOINC admins for a team'),
226
-      'database' => 'boinc'
227
-  );
222
+    $data['team_admin']['table']['base'] = array(
223
+        'field' => 'id',
224
+        'title' => t('BOINC team admins'),
225
+        'help' => t('BOINC admins for a team'),
226
+        'database' => 'boinc'
227
+    );
228 228
   
229
-  // This table references the {team} table.
230
-  // This join creates an 'implicit' relationship to the team table, so that when
231
-  // "Team" is the base table, the fields are automatically available.
229
+    // This table references the {team} table.
230
+    // This join creates an 'implicit' relationship to the team table, so that when
231
+    // "Team" is the base table, the fields are automatically available.
232 232
   
233
-  // Index this array by the table name to which this table refers.
234
-  // 'left_field' is the primary key in the referenced table.
235
-  // 'field' is the foreign key in this table.
233
+    // Index this array by the table name to which this table refers.
234
+    // 'left_field' is the primary key in the referenced table.
235
+    // 'field' is the foreign key in this table.
236 236
   
237
-  $data['team_admin']['table']['join'] = array(
237
+    $data['team_admin']['table']['join'] = array(
238 238
     'team' => array(
239
-      'left_field' => 'id',
240
-      'field' => 'teamid',
239
+        'left_field' => 'id',
240
+        'field' => 'teamid',
241 241
     ),
242
-  );
242
+    );
243 243
 
244
-  // Describe each of the individual fields in this table to Views. For
245
-  // each field, you may define what field, sort, argument, and/or filter
246
-  // handlers it supports. This will determine where in the Views interface you
247
-  // may use the field.
244
+    // Describe each of the individual fields in this table to Views. For
245
+    // each field, you may define what field, sort, argument, and/or filter
246
+    // handlers it supports. This will determine where in the Views interface you
247
+    // may use the field.
248 248
   
249
-  // Primary keys allowed as arguments
249
+    // Primary keys allowed as arguments
250 250
   
251
-  $data['team_admin']['teamid'] = array(
251
+    $data['team_admin']['teamid'] = array(
252 252
     'title' => bts('Id'),
253 253
     'help' => t('The BOINC ID of the team on which this user is an admin.'),
254 254
     'field' => array(
255
-      'handler' => 'views_handler_field_numeric',
256
-      'click sortable' => TRUE
255
+        'handler' => 'views_handler_field_numeric',
256
+        'click sortable' => TRUE
257 257
     ),
258 258
     'argument' => array(
259
-      'handler' => 'views_handler_argument_boincteam_id', // custom handler
260
-      'name field' => 'title', // the field to display in the summary.
261
-      'numeric' => TRUE,
262
-      'validate type' => 'id'
259
+        'handler' => 'views_handler_argument_boincteam_id', // custom handler
260
+        'name field' => 'title', // the field to display in the summary.
261
+        'numeric' => TRUE,
262
+        'validate type' => 'id'
263 263
     ),
264 264
     'relationship' => array(
265
-      'base' => 'team',
266
-      'field' => 'teamid',
267
-      'handler' => 'views_handler_relationship',
268
-      'label' => t('Team')
265
+        'base' => 'team',
266
+        'field' => 'teamid',
267
+        'handler' => 'views_handler_relationship',
268
+        'label' => t('Team')
269 269
     ),
270 270
     'filter' => array(
271
-      'handler' => 'views_handler_filter_numeric'
271
+        'handler' => 'views_handler_filter_numeric'
272 272
     ),
273 273
     'sort' => array(
274
-      'handler' => 'views_handler_sort_numeric'
274
+        'handler' => 'views_handler_sort_numeric'
275 275
     )
276
-  );
276
+    );
277 277
   
278
-  // Foreign key fields
278
+    // Foreign key fields
279 279
   
280
-  $data['team_admin']['userid'] = array(
280
+    $data['team_admin']['userid'] = array(
281 281
     'title' => bts('User ID'),
282 282
     'help' => t('The user that is a team admin.'),
283 283
     // This is a foreign key to the {user} table. When the view is configured
284 284
     // with this relationship, all the fields for the related user node will be 
285 285
     // available.
286 286
     'argument' => array(
287
-      'handler' => 'views_handler_argument_boincteam_id',
288
-      'name field' => 'title',
289
-      'numeric' => TRUE,
290
-      'validate type' => 'id'
287
+        'handler' => 'views_handler_argument_boincteam_id',
288
+        'name field' => 'title',
289
+        'numeric' => TRUE,
290
+        'validate type' => 'id'
291 291
     ),
292 292
     'relationship' => array(
293
-      'base' => 'user',
294
-      'field' => 'userid',
295
-      'handler' => 'views_handler_relationship',
296
-      'label' => bts('User')
293
+        'base' => 'user',
294
+        'field' => 'userid',
295
+        'handler' => 'views_handler_relationship',
296
+        'label' => bts('User')
297 297
     ),
298 298
     'field' => array(
299
-      'handler' => 'views_handler_field_numeric',
300
-      'click sortable' => TRUE
299
+        'handler' => 'views_handler_field_numeric',
300
+        'click sortable' => TRUE
301 301
     ),
302 302
     'filter' => array(
303
-      'handler' => 'views_handler_filter_numeric'
303
+        'handler' => 'views_handler_filter_numeric'
304 304
     ),
305 305
     'sort' => array(
306
-      'handler' => 'views_handler_sort_numeric'
306
+        'handler' => 'views_handler_sort_numeric'
307 307
     )
308
-  );
308
+    );
309 309
   
310
-  // Descriptions of general fields (alphabetized)
310
+    // Descriptions of general fields (alphabetized)
311 311
   
312
-  $data['team_admin']['create_time'] = array(
312
+    $data['team_admin']['create_time'] = array(
313 313
     'title' => bts('Admin since'),
314 314
     'help' => t('When the BOINC user became a team admin.'),
315 315
     'field' => array(
316
-      'handler' => 'views_handler_field_date',
317
-      'click sortable' => TRUE
316
+        'handler' => 'views_handler_field_date',
317
+        'click sortable' => TRUE
318 318
     ),
319 319
     'filter' => array(
320
-      'handler' => 'views_handler_filter_date'
320
+        'handler' => 'views_handler_filter_date'
321 321
     ),
322 322
     'sort' => array(
323
-      'handler' => 'views_handler_sort_date'
323
+        'handler' => 'views_handler_sort_date'
324 324
     )
325
-  );
325
+    );
326 326
   
327
-  // -----------------------------------------------------------------------------------------------
328
-  // Definition for team_delta table
329
-  // -----------------------------------------------------------------------------------------------
327
+    // -----------------------------------------------------------------------------------------------
328
+    // Definition for team_delta table
329
+    // -----------------------------------------------------------------------------------------------
330 330
   
331
-  $data['team_delta']['table']['group'] = t('BOINC');
331
+    $data['team_delta']['table']['group'] = t('BOINC');
332 332
 
333
-  // Describe each of the individual fields in this table to Views. For
334
-  // each field, you may define what field, sort, argument, and/or filter
335
-  // handlers it supports. This will determine where in the Views interface you
336
-  // may use the field.
333
+    // Describe each of the individual fields in this table to Views. For
334
+    // each field, you may define what field, sort, argument, and/or filter
335
+    // handlers it supports. This will determine where in the Views interface you
336
+    // may use the field.
337 337
   
338
-  // Primary keys allowed as arguments
338
+    // Primary keys allowed as arguments
339 339
   
340
-  $data['team_delta']['teamid'] = array(
340
+    $data['team_delta']['teamid'] = array(
341 341
     'title' => bts('Team ID'),
342 342
     'help' => t('The team ID for this team history event.'),
343 343
     // This is a foreign key to the {team} table. When the view is configured
344 344
     // with this relationship, all the fields for the related user node will be 
345 345
     // available.
346 346
     'argument' => array(
347
-      'handler' => 'views_handler_argument_boincteam_id',
348
-      'name field' => 'title',
349
-      'numeric' => TRUE,
350
-      'validate type' => 'id'
347
+        'handler' => 'views_handler_argument_boincteam_id',
348
+        'name field' => 'title',
349
+        'numeric' => TRUE,
350
+        'validate type' => 'id'
351 351
     ),
352 352
     'field' => array(
353
-      'handler' => 'views_handler_field_numeric',
354
-      'click sortable' => TRUE
353
+        'handler' => 'views_handler_field_numeric',
354
+        'click sortable' => TRUE
355 355
     ),
356 356
     'filter' => array(
357
-      'handler' => 'views_handler_filter_numeric'
357
+        'handler' => 'views_handler_filter_numeric'
358 358
     ),
359 359
     'sort' => array(
360
-      'handler' => 'views_handler_sort_numeric'
360
+        'handler' => 'views_handler_sort_numeric'
361 361
     )
362
-  );
362
+    );
363 363
   
364
-  // Foreign key fields
364
+    // Foreign key fields
365 365
   
366
-  $data['team_delta']['userid'] = array(
366
+    $data['team_delta']['userid'] = array(
367 367
     'title' => bts('User ID'),
368 368
     'help' => t('The user for this team history event.'),
369 369
     'relationship' => array(
370
-      'base' => 'user',
371
-      'field' => 'userid',
372
-      'handler' => 'views_handler_relationship',
373
-      'label' => t('User')
370
+        'base' => 'user',
371
+        'field' => 'userid',
372
+        'handler' => 'views_handler_relationship',
373
+        'label' => t('User')
374 374
     ),
375 375
     'field' => array(
376
-      'handler' => 'views_handler_field_numeric',
377
-      'click sortable' => TRUE
376
+        'handler' => 'views_handler_field_numeric',
377
+        'click sortable' => TRUE
378 378
     ),
379 379
     'filter' => array(
380
-      'handler' => 'views_handler_filter_numeric'
380
+        'handler' => 'views_handler_filter_numeric'
381 381
     ),
382 382
     'sort' => array(
383
-      'handler' => 'views_handler_sort_numeric'
383
+        'handler' => 'views_handler_sort_numeric'
384 384
     )
385
-  );
385
+    );
386 386
   
387
-  // Descriptions of general fields (alphabetized)
387
+    // Descriptions of general fields (alphabetized)
388 388
   
389
-  $data['team_delta']['joining'] = array(
389
+    $data['team_delta']['joining'] = array(
390 390
     'title' => bts('User joined'),
391 391
     'help' => t('Whether the event is the user joining the team or leaving.'),
392 392
     'field' => array(
393
-      'handler' => 'views_handler_field_numeric',
394
-      'click sortable' => TRUE
393
+        'handler' => 'views_handler_field_numeric',
394
+        'click sortable' => TRUE
395 395
     ),
396 396
     'filter' => array(
397
-      'handler' => 'views_handler_filter_numeric'
397
+        'handler' => 'views_handler_filter_numeric'
398 398
     ),
399 399
     'sort' => array(
400
-      'handler' => 'views_handler_sort_numeric'
400
+        'handler' => 'views_handler_sort_numeric'
401 401
     )
402
-  );
403
-  $data['team_delta']['timestamp'] = array(
402
+    );
403
+    $data['team_delta']['timestamp'] = array(
404 404
     'title' => bts('Timestamp'),
405 405
     'help' => t('When the BOINC team history event took place.'),
406 406
     'field' => array(
407
-      'handler' => 'views_handler_field_date',
408
-      'click sortable' => TRUE
407
+        'handler' => 'views_handler_field_date',
408
+        'click sortable' => TRUE
409 409
     ),
410 410
     'filter' => array(
411
-      'handler' => 'views_handler_filter_date'
411
+        'handler' => 'views_handler_filter_date'
412 412
     ),
413 413
     'sort' => array(
414
-      'handler' => 'views_handler_sort_date'
414
+        'handler' => 'views_handler_sort_date'
415 415
     )
416
-  );
417
-  $data['team_delta']['total_credit'] = array(
416
+    );
417
+    $data['team_delta']['total_credit'] = array(
418 418
     'title' => bts('Total Credit'),
419 419
     'help' => t('The total accumulated BOINC credit of the user when the
420 420
       history event took place.'),
421 421
     'field' => array(
422
-      'handler' => 'views_handler_field_numeric',
423
-      'click sortable' => TRUE,
424
-      'float' => TRUE
422
+        'handler' => 'views_handler_field_numeric',
423
+        'click sortable' => TRUE,
424
+        'float' => TRUE
425 425
     ),
426 426
     'filter' => array(
427
-      'handler' => 'views_handler_filter_numeric'
427
+        'handler' => 'views_handler_filter_numeric'
428 428
     ),
429 429
     'sort' => array(
430
-      'handler' => 'views_handler_sort_numeric'
430
+        'handler' => 'views_handler_sort_numeric'
431 431
     )
432
-  ); 
432
+    ); 
433 433
   
434
-  return $data;
434
+    return $data;
435 435
 }
436 436
 
437 437
 /*
@@ -442,14 +442,14 @@  discard block
 block discarded – undo
442 442
  */
443 443
 
444 444
 function boincteam_views_handlers() {
445
-  return array(
445
+    return array(
446 446
     'info' => array(
447
-      'path' => drupal_get_path('module', 'boincteam') . '/views',
447
+        'path' => drupal_get_path('module', 'boincteam') . '/views',
448 448
     ),
449 449
     'handlers' => array(
450
-      'views_handler_argument_boincteam_id' => array(
450
+        'views_handler_argument_boincteam_id' => array(
451 451
         'parent' => 'views_handler_argument_numeric'
452
-      )
452
+        )
453 453
     )
454
-  );
454
+    );
455 455
 }
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boincwork/includes/boincwork.forms.inc 1 patch
Indentation   +843 added lines, -843 removed lines patch added patch discarded remove patch
@@ -15,16 +15,16 @@  discard block
 block discarded – undo
15 15
  * The structure of the general preferences form
16 16
  */
17 17
 function boincwork_generalprefs_form(&$form_state, $venue, $prefs_preset = null, $advanced = FALSE) {
18
-  $form = array();
19
-  $prefs = null;
20
-  $established = TRUE;
18
+    $form = array();
19
+    $prefs = null;
20
+    $established = TRUE;
21 21
   
22
-  // Enable AHAH form support for dynamically updating content based on preset
23
-  ahah_helper_register($form, $form_state);
22
+    // Enable AHAH form support for dynamically updating content based on preset
23
+    ahah_helper_register($form, $form_state);
24 24
   
25
-  if (!$prefs_preset) {
25
+    if (!$prefs_preset) {
26 26
     if (isset($form_state['storage']['prefs']['preset'])) {
27
-      $prefs_preset = $form_state['storage']['prefs']['preset'];
27
+        $prefs_preset = $form_state['storage']['prefs']['preset'];
28 28
     }
29 29
     
30 30
     // Load preferences from BOINC account
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     
33 33
     // Take note if this is not an established preference set on the account
34 34
     if (isset($prefs['@attributes']['cleared'])) {
35
-      $established = FALSE;
35
+        $established = FALSE;
36 36
     }
37 37
     
38 38
     // Determine if a preset is selected or if these are custom settings
@@ -47,45 +47,45 @@  discard block
 block discarded – undo
47 47
             $prefs_preset = $prefs['preset']['@value'];
48 48
         }
49 49
     }// if !$prefs_preset
50
-  }
51
-  // Extract mod_time tag if present, because it will be erased with
52
-  // boincwork_get_preset_prefs() below.
53
-  $mod_time = null;
54
-  if (isset($prefs['mod_time']['@value'])) {
55
-      $mod_time = $prefs['mod_time']['@value'];
56
-  }
50
+    }
51
+    // Extract mod_time tag if present, because it will be erased with
52
+    // boincwork_get_preset_prefs() below.
53
+    $mod_time = null;
54
+    if (isset($prefs['mod_time']['@value'])) {
55
+        $mod_time = $prefs['mod_time']['@value'];
56
+    }
57 57
 
58
-  if (isset($form_state['storage']['wip'])) {
59
-      switch ($prefs_preset) {
60
-      case 'standard':
58
+    if (isset($form_state['storage']['wip'])) {
59
+        switch ($prefs_preset) {
60
+        case 'standard':
61 61
       case 'maximum':
62 62
       case 'green':
63 63
       case 'minimum':
64 64
           $prefs = boincwork_get_preset_prefs($prefs_preset);
65
-          break;
66
-      case 'custom':
65
+            break;
66
+        case 'custom':
67 67
       default:
68 68
           // Just keeps prefs as they are
69 69
           unset($prefs['preset']);
70
-          break;
71
-      }// switch
72
-  } else {
73
-      $form_state['storage']['wip'] = TRUE;
74
-      if ( !in_array($prefs_preset, array('standard','maximum','green','minimum','custom')) ) {
75
-          if ($established) {
76
-              $prefs_preset = 'custom';
77
-          } else {
78
-              $prefs_preset = 'standard';
79
-              $prefs = boincwork_get_preset_prefs($prefs_preset);
80
-          }// if $established
81
-      }// if $prefs_preset
82
-  }// if WIP
83
-  
84
-  // This set of preferences is used in the form if no preferences
85
-  // have been set above, in variable $prefs.
86
-  require_boinc(array('db', 'prefs'));
87
-  $disk_space_config = get_disk_space_config();
88
-  $default = array(
70
+            break;
71
+        }// switch
72
+    } else {
73
+        $form_state['storage']['wip'] = TRUE;
74
+        if ( !in_array($prefs_preset, array('standard','maximum','green','minimum','custom')) ) {
75
+            if ($established) {
76
+                $prefs_preset = 'custom';
77
+            } else {
78
+                $prefs_preset = 'standard';
79
+                $prefs = boincwork_get_preset_prefs($prefs_preset);
80
+            }// if $established
81
+        }// if $prefs_preset
82
+    }// if WIP
83
+  
84
+    // This set of preferences is used in the form if no preferences
85
+    // have been set above, in variable $prefs.
86
+    require_boinc(array('db', 'prefs'));
87
+    $disk_space_config = get_disk_space_config();
88
+    $default = array(
89 89
     'preset' => $prefs_preset,
90 90
     // Processing...
91 91
     'run_on_batteries' => 0,
@@ -120,385 +120,385 @@  discard block
 block discarded – undo
120 120
     'daily_xfer_limit_mb' => 0,
121 121
     'daily_xfer_period_days' => 0,
122 122
     'dont_verify_images' => 0
123
-  );
124
-  foreach ($default as $name => $value) {
123
+    );
124
+    foreach ($default as $name => $value) {
125 125
     if (isset($prefs[$name])) {
126
-      if (is_array($prefs[$name])) {
126
+        if (is_array($prefs[$name])) {
127 127
         if (isset($prefs[$name]['@value'])) {
128
-          $default[$name] = $prefs[$name]['@value'];
128
+            $default[$name] = $prefs[$name]['@value'];
129 129
         }
130
-      }
131
-      else {
130
+        }
131
+        else {
132 132
         $default[$name] = $prefs[$name];
133
-      }
133
+        }
134
+    }
134 135
     }
135
-  }
136 136
 
137
-  // Standard option sets
138
-  $form['boolean_options'] = array(
137
+    // Standard option sets
138
+    $form['boolean_options'] = array(
139 139
     '#type' => 'value',
140 140
     '#value' => array(1 => bts('yes'), 0 => bts('no'))
141
-  );
142
-  $form['hour_options'] = array(
141
+    );
142
+    $form['hour_options'] = array(
143 143
     '#type' => 'value',
144 144
     '#value' => array('0:00','1:00','2:00','3:00','4:00', 
145
-     '5:00','6:00','7:00','8:00','9:00','10:00','11:00', 
146
-     '12:00','13:00','14:00','15:00','16:00','17:00',
147
-     '18:00','19:00','20:00','21:00','22:00','23:00')
148
-  );
149
-  
150
-  // Identify preference sets that are established to distinguish what has been
151
-  // saved to the database from what is just showing default values
152
-  $form['#established'] = $established;
145
+        '5:00','6:00','7:00','8:00','9:00','10:00','11:00', 
146
+        '12:00','13:00','14:00','15:00','16:00','17:00',
147
+        '18:00','19:00','20:00','21:00','22:00','23:00')
148
+    );
149
+  
150
+    // Identify preference sets that are established to distinguish what has been
151
+    // saved to the database from what is just showing default values
152
+    $form['#established'] = $established;
153 153
    
154
-  // Set up the preference container for AHAH
155
-  $form['prefs'] = array(
154
+    // Set up the preference container for AHAH
155
+    $form['prefs'] = array(
156 156
     '#title' => '',
157 157
     '#type' => 'fieldset',
158 158
     '#prefix' => '<div id="prefs-wrapper">', // This is our wrapper div.
159 159
     '#attributes' => array('class' => 'ahah-container'),
160 160
     '#suffix' => '</div>',
161 161
     '#tree'   => TRUE
162
-  );
163
-  //$form['prefs']['debug'] = array('#value' => '<pre>' . print_r($form_state, true) . '</pre>');
162
+    );
163
+    //$form['prefs']['debug'] = array('#value' => '<pre>' . print_r($form_state, true) . '</pre>');
164 164
   
165
-  // Hidden elements
166
-  $form['prefs']['modified'] = array(
165
+    // Hidden elements
166
+    $form['prefs']['modified'] = array(
167 167
     '#type' => 'hidden',
168 168
     '#value' => $mod_time
169
-  );
170
-  $form['prefs']['venue'] = array(
169
+    );
170
+    $form['prefs']['venue'] = array(
171 171
     '#type' => 'hidden',
172 172
     '#value' => $venue
173
-  );
173
+    );
174 174
   
175
-  $form['prefs']['separator_top'] = array(
175
+    $form['prefs']['separator_top'] = array(
176 176
     '#value' => '<div class="separator"></div>'
177
-  );
177
+    );
178 178
   
179
-  // Simplified selectors
180
-  $form['prefs']['preset'] = array(
179
+    // Simplified selectors
180
+    $form['prefs']['preset'] = array(
181 181
     '#title' => bts('Presets'),
182 182
     '#type' => 'radios',
183 183
     '#description' => ' ',
184 184
     '#options' => array(
185
-      'standard' => bts('Standard'),
186
-      'maximum' => bts('Maximum'),
187
-      'green' => bts('Green'),
188
-      'minimum' => bts('Minimum'),
189
-      'custom' => bts('Custom')
185
+        'standard' => bts('Standard'),
186
+        'maximum' => bts('Maximum'),
187
+        'green' => bts('Green'),
188
+        'minimum' => bts('Minimum'),
189
+        'custom' => bts('Custom')
190 190
     ),
191 191
     '#prefix' => '<div class="simple-form-controls">',
192 192
     '#suffix' => '</div>',
193 193
     '#default_value' => $default['preset'],
194 194
     '#ahah' => array(
195
-      'event' => 'change',
196
-      'path' => ahah_helper_path(array('prefs')),
197
-      'wrapper' => 'prefs-wrapper'
195
+        'event' => 'change',
196
+        'path' => ahah_helper_path(array('prefs')),
197
+        'wrapper' => 'prefs-wrapper'
198 198
     )
199
-  );
200
-  $form['prefs']['select preset'] = array(
199
+    );
200
+    $form['prefs']['select preset'] = array(
201 201
     '#type'  => 'submit',
202 202
     '#value' => bts('Update preset'),
203 203
     '#submit' => array('ahah_helper_generic_submit'),
204 204
     // The 'no-js' class only displays this button if javascript is disabled
205 205
     '#attributes' => array('class' => 'no-js'),
206
-  );
206
+    );
207 207
   
208
-  // Advanced preferences
209
-  $form['prefs']['advanced'] = array(
208
+    // Advanced preferences
209
+    $form['prefs']['advanced'] = array(
210 210
     '#title' => bts('Advanced settings'),
211 211
     '#type' => 'fieldset',
212 212
     '#description' => '',
213 213
     '#collapsible' => TRUE,
214 214
     '#collapsed' => !$advanced,
215 215
     '#attributes' => array('class' => 'advanced-settings'),
216
-  );
216
+    );
217 217
   
218
-  // Processing preferences
218
+    // Processing preferences
219 219
   
220
-  $form['prefs']['advanced']['anchor'] = array(
220
+    $form['prefs']['advanced']['anchor'] = array(
221 221
     '#value' => '<a name="advanced"></a>'
222
-  );
222
+    );
223 223
   
224
-  $form['prefs']['advanced']['separator_top'] = array(
224
+    $form['prefs']['advanced']['separator_top'] = array(
225 225
     '#value' => '<div class="separator"></div>'
226
-  );
226
+    );
227 227
   
228
-  $form['prefs']['advanced']['processor'] = array(
228
+    $form['prefs']['advanced']['processor'] = array(
229 229
     '#title' => bts('Processor usage'),
230 230
     '#type' => 'fieldset',
231 231
     '#description' => '',
232 232
     '#collapsible' => FALSE,
233 233
     '#collapsed' => FALSE
234
-  );
235
-  $form['prefs']['advanced']['processor']['run_on_batteries'] = array(
234
+    );
235
+    $form['prefs']['advanced']['processor']['run_on_batteries'] = array(
236 236
     '#title' => bts('Suspend when computer is on battery?'),
237 237
     '#type' => 'radios',
238 238
     '#description' => bts('Suspends computing on portables when running on battery power.'),
239 239
     '#options' => $form['boolean_options']['#value'],
240 240
     '#attributes' => array('class' => 'fancy'),
241 241
     '#default_value' => ($default['run_on_batteries']) ? 0 : 1 // intentional inversion of setting
242
-  );
243
-  $form['prefs']['advanced']['processor']['run_if_user_active'] = array(
242
+    );
243
+    $form['prefs']['advanced']['processor']['run_if_user_active'] = array(
244 244
     '#title' => bts('Suspend when computer is in use?'),
245 245
     '#type' => 'radios',
246 246
     '#description' => bts("Suspends computing and file transfers when you're using the computer."),
247 247
     '#options' => $form['boolean_options']['#value'],
248 248
     '#attributes' => array('class' => 'fancy'),
249 249
     '#default_value' => ($default['run_if_user_active']) ? 0 : 1 // intentional inversion of setting
250
-  );
251
-  $form['prefs']['advanced']['processor']['run_gpu_if_user_active'] = array(
250
+    );
251
+    $form['prefs']['advanced']['processor']['run_gpu_if_user_active'] = array(
252 252
     '#title' => bts('Suspend GPU computing when computer is in use?'),
253 253
     '#type' => 'radios',
254 254
     '#description' => bts("Suspends GPU computing when you're using the computer."),
255 255
     '#options' => $form['boolean_options']['#value'],
256 256
     '#attributes' => array('class' => 'fancy'),
257 257
     '#default_value' => ($default['run_gpu_if_user_active']) ? 0 : 1 // intentional inversion of setting
258
-  );
259
-  $form['prefs']['advanced']['processor']['idle_time_to_run'] = array(
258
+    );
259
+    $form['prefs']['advanced']['processor']['idle_time_to_run'] = array(
260 260
     '#title' => bts('"In use" means mouse/keyboard input in last'),
261 261
     '#type' => 'textfield',
262 262
     '#field_suffix' => bts('minutes'),
263 263
     '#default_value' => $default['idle_time_to_run'],
264 264
     '#size' => 1,
265 265
     '#description' => bts('This determines when the computer is considered "in use".')
266
-  );
267
-  $form['prefs']['advanced']['processor']['suspend_if_no_recent_input'] = array(
266
+    );
267
+    $form['prefs']['advanced']['processor']['suspend_if_no_recent_input'] = array(
268 268
     '#title' => bts('Suspend when no mouse/keyboard input in last'),
269 269
     '#type' => 'textfield',
270 270
     '#field_suffix' => bts('minutes'),
271 271
     '#default_value' => $default['suspend_if_no_recent_input'],
272 272
     '#size' => 1,
273 273
     '#description' => bts('This allows some computers to enter low-power mode when not in use.')
274
-  );
275
-  $form['prefs']['advanced']['processor']['suspend_cpu_usage'] = array(
274
+    );
275
+    $form['prefs']['advanced']['processor']['suspend_cpu_usage'] = array(
276 276
     '#title' => bts('Suspend when non-BOINC CPU usage is above'),
277 277
     '#type' => 'textfield',
278 278
     '#field_suffix' => '%',
279 279
     '#default_value' => $default['suspend_cpu_usage'],
280 280
     '#size' => 1,
281 281
     '#description' => bts('Suspend computing when your computer is busy running other programs.'),
282
-  );
283
-  $form['prefs']['advanced']['processor']['hour_label'] = array(
282
+    );
283
+    $form['prefs']['advanced']['processor']['hour_label'] = array(
284 284
     '#value' => '<div class="form-item"><label>' . bts('Compute only between:') . '</label></div>'
285
-  );
286
-  $form['prefs']['advanced']['processor']['start_hour'] = array(
285
+    );
286
+    $form['prefs']['advanced']['processor']['start_hour'] = array(
287 287
     '#type' => 'select',
288 288
     '#options' => $form['hour_options']['#value'],
289 289
     '#default_value' => $default['start_hour']
290
-  );
291
-  $form['prefs']['advanced']['processor']['hour_delimiter'] = array(
290
+    );
291
+    $form['prefs']['advanced']['processor']['hour_delimiter'] = array(
292 292
     '#value' => '<span>' . bts('and') . '</span>'
293
-  );
294
-  $form['prefs']['advanced']['processor']['end_hour'] = array(
293
+    );
294
+    $form['prefs']['advanced']['processor']['end_hour'] = array(
295 295
     '#type' => 'select',
296 296
     '#options' => $form['hour_options']['#value'],
297 297
     '#default_value' => $default['end_hour']
298
-  );
299
-  $form['prefs']['advanced']['processor']['hour_description'] = array(
298
+    );
299
+    $form['prefs']['advanced']['processor']['hour_description'] = array(
300 300
     '#value' => '<div class="form-item slim"><div class="description">' . bts('Compute only during a particular period each day.') . '</div></div>'
301
-  );
302
-  $form['prefs']['advanced']['processor']['leave_apps_in_memory'] = array(
301
+    );
302
+    $form['prefs']['advanced']['processor']['leave_apps_in_memory'] = array(
303 303
     '#title' => bts('Leave non-GPU tasks in memory while suspended?'),
304 304
     '#type' => 'radios',
305 305
     '#options' => $form['boolean_options']['#value'],
306 306
     '#attributes' => array('class' => 'fancy'),
307 307
     '#default_value' => $default['leave_apps_in_memory'],
308 308
     '#description' => bts('If "Yes", suspended tasks stay in memory, and resume with no work lost. If "No", suspended tasks are removed from memory, and resume from their last checkpoint.')
309
-  );
310
-  $form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes'] = array(
309
+    );
310
+    $form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes'] = array(
311 311
     '#title' => bts('Switch between tasks every'),
312 312
     '#type' => 'textfield',
313 313
     '#field_suffix' => bts('minutes'),
314 314
     '#default_value' => $default['cpu_scheduling_period_minutes'],
315 315
     '#size' => 1,
316 316
     '#description' => bts('If you run several projects, BOINC may switch between them this often.')
317
-  );
318
-  $form['prefs']['advanced']['processor']['max_ncpus_pct'] = array(
317
+    );
318
+    $form['prefs']['advanced']['processor']['max_ncpus_pct'] = array(
319 319
     '#title' => bts('Use at most'),
320 320
     '#type' => 'textfield',
321 321
     '#field_suffix' => bts('% of the processors'),
322 322
     '#default_value' => $default['max_ncpus_pct'],
323 323
     '#size' => 1,
324 324
     '#description' => bts('Keep some CPUs free for other applications. Example: 75% means use 6 cores on an 8-core CPU.'),
325
-  );
326
-  $form['prefs']['advanced']['processor']['cpu_usage_limit'] = array(
325
+    );
326
+    $form['prefs']['advanced']['processor']['cpu_usage_limit'] = array(
327 327
     '#title' => bts('Use at most'),
328 328
     '#type' => 'textfield',
329 329
     '#field_suffix' => bts('% of the CPU time'),
330 330
     '#default_value' => $default['cpu_usage_limit'],
331 331
     '#size' => 1,
332 332
     '#description' => bts('Suspend/resume computing every few seconds to reduce CPU temperature and energy usage. Example: 75% means compute for 3 seconds, wait for 1 second, and repeat.')
333
-  );
333
+    );
334 334
   
335
-  // Disk and memory preferences
336
-  $form['prefs']['advanced']['storage'] = array(
335
+    // Disk and memory preferences
336
+    $form['prefs']['advanced']['storage'] = array(
337 337
     '#title' => bts('Disk and memory usage'),
338 338
     '#type' => 'fieldset',
339 339
     '#description' => '',
340 340
     '#collapsible' => FALSE,
341 341
     '#collapsed' => FALSE
342
-  );
343
-  $form['prefs']['advanced']['storage']['disk_max_used_gb'] = array(
342
+    );
343
+    $form['prefs']['advanced']['storage']['disk_max_used_gb'] = array(
344 344
     '#title' => bts('Disk: use no more than'),
345 345
     '#type' => 'textfield',
346 346
     '#field_suffix' => 'GB',
347 347
     '#default_value' => $default['disk_max_used_gb'],
348 348
     '#size' => 1,
349 349
     '#description' => bts('Limit the total amount of disk space used by BOINC.'),
350
-  ); 
351
-  $form['prefs']['advanced']['storage']['disk_min_free_gb'] = array(
350
+    ); 
351
+    $form['prefs']['advanced']['storage']['disk_min_free_gb'] = array(
352 352
     '#title' => bts('Disk: leave at least'),
353 353
     '#type' => 'textfield',
354 354
     '#field_suffix' => 'GB free',
355 355
     '#default_value' => $default['disk_min_free_gb'],
356 356
     '#size' => 1,
357 357
     '#description' => bts('Limit disk usage to leave this much free space on the volume where BOINC stores data.'),
358
-  );
359
-  $form['prefs']['advanced']['storage']['disk_max_used_pct'] = array(
358
+    );
359
+    $form['prefs']['advanced']['storage']['disk_max_used_pct'] = array(
360 360
     '#title' => bts('Disk: use no more than'),
361 361
     '#type' => 'textfield',
362 362
     '#field_suffix' => bts('% of total'),
363 363
     '#default_value' => $default['disk_max_used_pct'],
364 364
     '#size' => 1,
365 365
     '#description' => bts('Limit the percentage of disk space used by BOINC on the volume where it stores data.')
366
-  ); 
367
-  $form['prefs']['advanced']['storage']['disk_interval'] = array(
366
+    ); 
367
+    $form['prefs']['advanced']['storage']['disk_interval'] = array(
368 368
     '#title' => bts('Request tasks to checkpoint at most every'),
369 369
     '#type' => 'textfield',
370 370
     '#field_suffix' => bts('seconds'),
371 371
     '#default_value' => $default['disk_interval'],
372 372
     '#size' => 1,
373 373
     '#description' => bts('This controls how often tasks save their state to disk, so that later they can be continued from that point.')
374
-  );
375
-  $form['prefs']['advanced']['storage']['vm_max_used_pct'] = array(
374
+    );
375
+    $form['prefs']['advanced']['storage']['vm_max_used_pct'] = array(
376 376
     '#title' => bts('Page/swap file: use at most'),
377 377
     '#type' => 'textfield',
378 378
     '#field_suffix' => bts('% of total'),
379 379
     '#default_value' => $default['vm_max_used_pct'],
380 380
     '#size' => 1,
381 381
     '#description' => bts('Limit the swap space (page file) used by BOINC.')
382
-  );
383
-  $form['prefs']['advanced']['storage']['ram_max_used_busy_pct'] = array(
382
+    );
383
+    $form['prefs']['advanced']['storage']['ram_max_used_busy_pct'] = array(
384 384
     '#title' => bts('Memory: when computer is in use, use at most'),
385 385
     '#type' => 'textfield',
386 386
     '#field_suffix' => bts('% of total'),
387 387
     '#default_value' => $default['ram_max_used_busy_pct'],
388 388
     '#size' => 1,
389 389
     '#description' => bts("Limit the memory used by BOINC when you're using the computer.")
390
-  );
391
-  $form['prefs']['advanced']['storage']['ram_max_used_idle_pct'] = array(
390
+    );
391
+    $form['prefs']['advanced']['storage']['ram_max_used_idle_pct'] = array(
392 392
     '#title' => bts('Memory: when computer is not in use, use at most'),
393 393
     '#type' => 'textfield',
394 394
     '#field_suffix' => bts('% of total'),
395 395
     '#default_value' => $default['ram_max_used_idle_pct'],
396 396
     '#size' => 1,
397 397
     '#description' => bts("Limit the memory used by BOINC when you're not using the computer.")
398
-  );
398
+    );
399 399
   
400
-  // Network preferences
401
-  $form['prefs']['advanced']['network'] = array(
400
+    // Network preferences
401
+    $form['prefs']['advanced']['network'] = array(
402 402
     '#title' => bts('Network usage'),
403 403
     '#type' => 'fieldset',
404 404
     '#description' => '',
405 405
     '#collapsible' => FALSE,
406 406
     '#collapsed' => FALSE
407
-  );
408
-  $form['prefs']['advanced']['network']['work_buf_min_days'] = array(
407
+    );
408
+    $form['prefs']['advanced']['network']['work_buf_min_days'] = array(
409 409
     '#title' => bts('Store at least'),
410 410
     '#type' => 'textfield',
411 411
     '#field_suffix' => bts('days of work'),
412 412
     '#default_value' => $default['work_buf_min_days'],
413 413
     '#size' => 1,
414 414
     '#description' => bts('Store at least enough tasks to keep the computer busy for this long.')
415
-  ); 
416
-  $form['prefs']['advanced']['network']['work_buf_additional_days'] = array(
415
+    ); 
416
+    $form['prefs']['advanced']['network']['work_buf_additional_days'] = array(
417 417
     '#title' => bts('Store up to an additional'),
418 418
     '#type' => 'textfield',
419 419
     '#field_suffix' => bts('days'),
420 420
     '#default_value' => $default['work_buf_additional_days'],
421 421
     '#size' => 1,
422 422
     '#description' => bts('Store additional tasks above the minimum level.  Determines how much work is requested when contacting a project.')
423
-  ); 
424
-  $form['prefs']['advanced']['network']['confirm_before_connecting'] = array(
423
+    ); 
424
+    $form['prefs']['advanced']['network']['confirm_before_connecting'] = array(
425 425
     '#title' => bts('Confirm before connecting to Internet?'),
426 426
     '#type' => 'radios',
427 427
     '#options' => $form['boolean_options']['#value'],
428 428
     '#attributes' => array('class' => 'fancy'),
429 429
     '#default_value' => $default['confirm_before_connecting'],
430 430
     '#description' => bts('Useful only if you have a modem, ISDN or VPN connection.')
431
-  ); 
432
-  $form['prefs']['advanced']['network']['hangup_if_dialed'] = array(
431
+    ); 
432
+    $form['prefs']['advanced']['network']['hangup_if_dialed'] = array(
433 433
     '#title' => bts('Disconnect when done?'),
434 434
     '#type' => 'radios',
435 435
     '#options' => $form['boolean_options']['#value'],
436 436
     '#attributes' => array('class' => 'fancy'),
437 437
     '#default_value' => $default['hangup_if_dialed'],
438 438
     '#description' => bts('Useful only if you have a modem, ISDN or VPN connection.')
439
-  );
440
-  $form['prefs']['advanced']['network']['max_bytes_sec_down'] = array(
439
+    );
440
+    $form['prefs']['advanced']['network']['max_bytes_sec_down'] = array(
441 441
     '#title' => bts('Limit download rate to'),
442 442
     '#type' => 'textfield',
443 443
     '#field_suffix' => 'Kbytes/sec',
444 444
     '#default_value' => $default['max_bytes_sec_down']/1000,
445 445
     '#size' => 1,
446 446
     '#description' => bts('Limit the download rate of file transfers.')
447
-  ); 
448
-  $form['prefs']['advanced']['network']['max_bytes_sec_up'] = array(
447
+    ); 
448
+    $form['prefs']['advanced']['network']['max_bytes_sec_up'] = array(
449 449
     '#title' => bts('Limit upload rate to'),
450 450
     '#type' => 'textfield',
451 451
     '#field_suffix' => 'Kbytes/sec',
452 452
     '#default_value' => $default['max_bytes_sec_up']/1000,
453 453
     '#size' => 1,
454 454
     '#description' => bts('Limit the upload rate of file transfers.')
455
-  );
456
-  $form['prefs']['advanced']['network']['hour_label'] = array(
455
+    );
456
+    $form['prefs']['advanced']['network']['hour_label'] = array(
457 457
     '#value' => '<div class="form-item"><label>' . bts('Transfer files only between') . '</label></div>'
458
-  );
459
-  $form['prefs']['advanced']['network']['net_start_hour'] = array(
458
+    );
459
+    $form['prefs']['advanced']['network']['net_start_hour'] = array(
460 460
     '#type' => 'select',
461 461
     '#options' => $form['hour_options']['#value'],
462 462
     '#default_value' => $default['net_start_hour']
463
-  );
464
-  $form['prefs']['advanced']['network']['hour_delimiter'] = array(
463
+    );
464
+    $form['prefs']['advanced']['network']['hour_delimiter'] = array(
465 465
     '#value' => '<span>' . bts('and') . '</span>'
466
-  );
467
-  $form['prefs']['advanced']['network']['net_end_hour'] = array(
466
+    );
467
+    $form['prefs']['advanced']['network']['net_end_hour'] = array(
468 468
     '#type' => 'select',
469 469
     '#options' => $form['hour_options']['#value'],
470 470
     '#default_value' => $default['net_end_hour']
471
-  );
472
-  $form['prefs']['advanced']['network']['hour_description'] = array(
471
+    );
472
+    $form['prefs']['advanced']['network']['hour_description'] = array(
473 473
     '#value' => '<div class="form-item slim"><div class="description">' . bts('Transfer files only during a particular period each day.') . '</div></div>'
474
-  ); 
475
-  $form['prefs']['advanced']['network']['daily_xfer_limit_mb'] = array(
474
+    ); 
475
+    $form['prefs']['advanced']['network']['daily_xfer_limit_mb'] = array(
476 476
     '#title' => bts('Limit usage to'),
477 477
     '#type' => 'textfield',
478 478
     '#field_suffix' => 'Mbytes',
479 479
     '#default_value' => $default['daily_xfer_limit_mb'],
480 480
     '#size' => 1
481
-  ); 
482
-  $form['prefs']['advanced']['network']['daily_xfer_period_days'] = array(
481
+    ); 
482
+    $form['prefs']['advanced']['network']['daily_xfer_period_days'] = array(
483 483
     '#field_prefix' => 'every',
484 484
     '#type' => 'textfield',
485 485
     '#field_suffix' => bts('days'),
486 486
     '#default_value' => $default['daily_xfer_period_days'],
487 487
     '#size' => 1,
488 488
     '#description' => bts('Example: BOINC should transfer at most 2000 MB of data every 30 days.'),
489
-  ); 
490
-  $form['prefs']['advanced']['network']['dont_verify_images'] = array(
489
+    ); 
490
+    $form['prefs']['advanced']['network']['dont_verify_images'] = array(
491 491
     '#title' => bts('Skip data verification for image files?'),
492 492
     '#type' => 'radios',
493 493
     '#options' => $form['boolean_options']['#value'],
494 494
     '#attributes' => array('class' => 'fancy'),
495 495
     '#default_value' => $default['dont_verify_images'],
496 496
     '#description' => bts('Only select "Yes" if your Internet provider modifies image files. Skipping verification reduces the security of BOINC.')
497
-  );
497
+    );
498 498
   
499
-  // The "fancy radios" are made via javascript on document load. In order for
500
-  // these to work with AHAH, we need this crazy setTimeout() call.
501
-  $form['prefs']['fancy-radios'] = array(
499
+    // The "fancy radios" are made via javascript on document load. In order for
500
+    // these to work with AHAH, we need this crazy setTimeout() call.
501
+    $form['prefs']['fancy-radios'] = array(
502 502
     '#value' => '
503 503
       <script>
504 504
         setTimeout(
@@ -509,177 +509,177 @@  discard block
 block discarded – undo
509 509
           300
510 510
         )
511 511
       </script>'
512
-  );
513
-  $form['prefs']['view advanced'] = array(
512
+    );
513
+    $form['prefs']['view advanced'] = array(
514 514
     '#type' => 'hidden',
515 515
     '#value' => 1
516
-  );
516
+    );
517 517
   
518
-  $form['prefs']['separator_bottom'] = array(
518
+    $form['prefs']['separator_bottom'] = array(
519 519
     '#value' => '<div class="separator buttons"></div>'
520
-  );
520
+    );
521 521
   
522
-  // Form control
523
-  $form['prefs']['form control tabs prefix'] = array(
522
+    // Form control
523
+    $form['prefs']['form control tabs prefix'] = array(
524 524
     '#value' => '<ul class="form-control tab-list">'
525
-  );
526
-  $form['prefs']['submit'] = array(
525
+    );
526
+    $form['prefs']['submit'] = array(
527 527
     '#prefix' => '<li class="first tab">',
528 528
     '#type' => 'submit',
529 529
     '#value' => bts('Save changes'),
530 530
     '#suffix' => '</li>'
531
-  );
532
-  $form['prefs']['form control tabs'] = array(
531
+    );
532
+    $form['prefs']['form control tabs'] = array(
533 533
     '#value' => '<li class="tab">' . l(bts('Cancel'), drupal_get_path_alias("account/prefs/computing/edit")) . '</li>'
534
-  );
535
-  if ($venue AND $venue != 'generic') {
534
+    );
535
+    if ($venue AND $venue != 'generic') {
536 536
     global $base_path;
537 537
     $form['prefs']['form control tabs']['#value'] .= '<li class="tab">' . 
538
-      l(bts('Clear'), "account/prefs/computing/clear/{$venue}",
538
+        l(bts('Clear'), "account/prefs/computing/clear/{$venue}",
539 539
         array(
540
-          'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/computing/combined')),
541
-          'attributes' => array(
540
+            'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/computing/combined')),
541
+            'attributes' => array(
542 542
             'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the @name preference set. Are you sure?',
543
-              array('@name' => $venue)) . '\')'
544
-          )
543
+                array('@name' => $venue)) . '\')'
544
+            )
545 545
         )
546
-      ) . '</li>';
547
-  }
548
-  $form['prefs']['view control'] = array(
546
+        ) . '</li>';
547
+    }
548
+    $form['prefs']['view control'] = array(
549 549
     '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view') . ')', 'account/prefs/computing/combined') . '</li>'
550
-  );
551
-  $form['prefs']['form control tabs suffix'] = array(
550
+    );
551
+    $form['prefs']['form control tabs suffix'] = array(
552 552
     '#value' => '</ul>'
553
-  );
554
-  $form['#submit'][] = 'boincwork_generalprefs_form_submit';
553
+    );
554
+    $form['#submit'][] = 'boincwork_generalprefs_form_submit';
555 555
   
556
-  return $form;
556
+    return $form;
557 557
 }
558 558
 
559 559
 /**
560
-  * Validate the general preferences form.
561
-  */
560
+ * Validate the general preferences form.
561
+ */
562 562
 function boincwork_generalprefs_form_validate($form, &$form_state) {
563
-  require_boinc('util');
564
-  $values = $form_state['values']['prefs']['advanced'];
565
-  
566
-  //drupal_set_message('<pre>' . print_r($form_state['values'], true) . '</pre>');
567
-  // Verify all non-boolean user input values and notify form API of failures
568
-  
569
-  // Processing preferences
570
-  if (!verify_numeric($values['processor']['idle_time_to_run'], 1, 9999)) form_set_error('idle_time_to_run', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['idle_time_to_run']['#title']} [x] {$form['prefs']['advanced']['processor']['idle_time_to_run']['#field_suffix']}")));
571
-  if (!verify_numeric($values['processor']['suspend_if_no_recent_input'], 0, 9999)) form_set_error('suspend_if_no_recent_input', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['suspend_if_no_recent_input']['#title']} [x] {$form['prefs']['advanced']['processor']['suspend_if_no_recent_input']['#field_suffix']}")));
572
-  if (!verify_numeric($values['processor']['suspend_cpu_usage'], 0, 100)) form_set_error('suspend_cpu_usage', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['suspend_cpu_usage']['#title']} [x] {$form['prefs']['advanced']['processor']['suspend_cpu_usage']['#field_suffix']}")));
573
-  if (!verify_numeric($values['processor']['start_hour'], 0, 23)) form_set_error('start_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['start_hour']['#title']} [x] {$form['prefs']['advanced']['processor']['start_hour']['#field_suffix']}")));
574
-  if (!verify_numeric($values['processor']['end_hour'], 0, 23)) form_set_error('end_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['end_hour']['#title']} [x] {$form['prefs']['advanced']['processor']['end_hour']['#field_suffix']}")));
575
-  if (!verify_numeric($values['processor']['cpu_scheduling_period_minutes'], 1, 9999)) form_set_error('cpu_scheduling_period_minutes', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes']['#title']} [x] {$form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes']['#field_suffix']}")));
576
-  if (!verify_numeric($values['processor']['max_ncpus_pct'], 0, 100)) form_set_error('max_ncpus_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['max_ncpus_pct']['#title']} [x] {$form['prefs']['advanced']['processor']['max_ncpus_pct']['#field_suffix']}")));
577
-  if (!verify_numeric($values['processor']['cpu_usage_limit'], 0, 100)) form_set_error('cpu_usage_limit', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['cpu_usage_limit']['#title']} [x] {$form['prefs']['advanced']['processor']['cpu_usage_limit']['#field_suffix']}")));
563
+    require_boinc('util');
564
+    $values = $form_state['values']['prefs']['advanced'];
565
+  
566
+    //drupal_set_message('<pre>' . print_r($form_state['values'], true) . '</pre>');
567
+    // Verify all non-boolean user input values and notify form API of failures
568
+  
569
+    // Processing preferences
570
+    if (!verify_numeric($values['processor']['idle_time_to_run'], 1, 9999)) form_set_error('idle_time_to_run', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['idle_time_to_run']['#title']} [x] {$form['prefs']['advanced']['processor']['idle_time_to_run']['#field_suffix']}")));
571
+    if (!verify_numeric($values['processor']['suspend_if_no_recent_input'], 0, 9999)) form_set_error('suspend_if_no_recent_input', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['suspend_if_no_recent_input']['#title']} [x] {$form['prefs']['advanced']['processor']['suspend_if_no_recent_input']['#field_suffix']}")));
572
+    if (!verify_numeric($values['processor']['suspend_cpu_usage'], 0, 100)) form_set_error('suspend_cpu_usage', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['suspend_cpu_usage']['#title']} [x] {$form['prefs']['advanced']['processor']['suspend_cpu_usage']['#field_suffix']}")));
573
+    if (!verify_numeric($values['processor']['start_hour'], 0, 23)) form_set_error('start_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['start_hour']['#title']} [x] {$form['prefs']['advanced']['processor']['start_hour']['#field_suffix']}")));
574
+    if (!verify_numeric($values['processor']['end_hour'], 0, 23)) form_set_error('end_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['end_hour']['#title']} [x] {$form['prefs']['advanced']['processor']['end_hour']['#field_suffix']}")));
575
+    if (!verify_numeric($values['processor']['cpu_scheduling_period_minutes'], 1, 9999)) form_set_error('cpu_scheduling_period_minutes', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes']['#title']} [x] {$form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes']['#field_suffix']}")));
576
+    if (!verify_numeric($values['processor']['max_ncpus_pct'], 0, 100)) form_set_error('max_ncpus_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['max_ncpus_pct']['#title']} [x] {$form['prefs']['advanced']['processor']['max_ncpus_pct']['#field_suffix']}")));
577
+    if (!verify_numeric($values['processor']['cpu_usage_limit'], 0, 100)) form_set_error('cpu_usage_limit', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['cpu_usage_limit']['#title']} [x] {$form['prefs']['advanced']['processor']['cpu_usage_limit']['#field_suffix']}")));
578 578
 
579
-  // Storage preferences
580
-  if (!verify_numeric($values['storage']['disk_max_used_gb'], 0, 9999999)) form_set_error('disk_max_used_gb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_max_used_gb']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_max_used_gb']['#field_suffix']}")));
581
-  if (!verify_numeric($values['storage']['disk_min_free_gb'], 0.001, 9999999)) form_set_error('disk_min_free_gb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_min_free_gb']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_min_free_gb']['#field_suffix']}")));
582
-  if (!verify_numeric($values['storage']['disk_max_used_pct'], 0, 100)) form_set_error('disk_max_used_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_max_used_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_max_used_pct']['#field_suffix']}")));
583
-  if (!verify_numeric($values['storage']['disk_interval'], 0, 9999999)) form_set_error('disk_interval', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_interval']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_interval']['#field_suffix']}")));
584
-  if (!verify_numeric($values['storage']['vm_max_used_pct'], 0, 100)) form_set_error('vm_max_used_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['vm_max_used_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['vm_max_used_pct']['#field_suffix']}")));
585
-  if (!verify_numeric($values['storage']['ram_max_used_busy_pct'], 0, 100)) form_set_error('ram_max_used_busy_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['ram_max_used_busy_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['ram_max_used_busy_pct']['#field_suffix']}")));
586
-  if (!verify_numeric($values['storage']['ram_max_used_idle_pct'], 0, 100)) form_set_error('ram_max_used_idle_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['ram_max_used_idle_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['ram_max_used_idle_pct']['#field_suffix']}")));
579
+    // Storage preferences
580
+    if (!verify_numeric($values['storage']['disk_max_used_gb'], 0, 9999999)) form_set_error('disk_max_used_gb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_max_used_gb']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_max_used_gb']['#field_suffix']}")));
581
+    if (!verify_numeric($values['storage']['disk_min_free_gb'], 0.001, 9999999)) form_set_error('disk_min_free_gb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_min_free_gb']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_min_free_gb']['#field_suffix']}")));
582
+    if (!verify_numeric($values['storage']['disk_max_used_pct'], 0, 100)) form_set_error('disk_max_used_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_max_used_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_max_used_pct']['#field_suffix']}")));
583
+    if (!verify_numeric($values['storage']['disk_interval'], 0, 9999999)) form_set_error('disk_interval', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_interval']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_interval']['#field_suffix']}")));
584
+    if (!verify_numeric($values['storage']['vm_max_used_pct'], 0, 100)) form_set_error('vm_max_used_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['vm_max_used_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['vm_max_used_pct']['#field_suffix']}")));
585
+    if (!verify_numeric($values['storage']['ram_max_used_busy_pct'], 0, 100)) form_set_error('ram_max_used_busy_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['ram_max_used_busy_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['ram_max_used_busy_pct']['#field_suffix']}")));
586
+    if (!verify_numeric($values['storage']['ram_max_used_idle_pct'], 0, 100)) form_set_error('ram_max_used_idle_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['ram_max_used_idle_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['ram_max_used_idle_pct']['#field_suffix']}")));
587 587
 
588
-  // Network preferences
589
-  if (!verify_numeric($values['network']['work_buf_min_days'], 0, 10)) form_set_error('work_buf_min_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['work_buf_min_days']['#title']} [x] {$form['prefs']['advanced']['network']['work_buf_min_days']['#field_suffix']}")));
590
-  if (!verify_numeric($values['network']['work_buf_additional_days'], 0, 10)) form_set_error('work_buf_additional_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['work_buf_additional_days']['#title']} [x] {$form['prefs']['advanced']['network']['work_buf_additional_days']['#field_suffix']}")));
591
-  if (!verify_numeric($values['network']['max_bytes_sec_down'], 0, 9999.999)) form_set_error('max_bytes_sec_down', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['max_bytes_sec_down']['#title']} [x] {$form['prefs']['advanced']['network']['max_bytes_sec_down']['#field_suffix']}")));
592
-  if (!verify_numeric($values['network']['max_bytes_sec_up'], 0, 9999.999)) form_set_error('max_bytes_sec_up', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['max_bytes_sec_up']['#title']} [x] {$form['prefs']['advanced']['network']['max_bytes_sec_up']['#field_suffix']}")));
593
-  if (!verify_numeric($values['network']['net_start_hour'], 0, 23)) form_set_error('net_start_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['net_start_hour']['#title']} [x] {$form['prefs']['advanced']['network']['net_start_hour']['#field_suffix']}")));
594
-  if (!verify_numeric($values['network']['net_end_hour'], 0, 23)) form_set_error('net_end_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['net_end_hour']['#title']} [x] {$form['prefs']['advanced']['network']['net_end_hour']['#field_suffix']}")));
595
-  if (!verify_numeric($values['network']['daily_xfer_limit_mb'], 0, 9999999)) form_set_error('daily_xfer_limit_mb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#title']} [x] {$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#field_suffix']}")));
596
-  if (!verify_numeric($values['network']['daily_xfer_period_days'], 0, 9999999)) form_set_error('daily_xfer_period_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#title']} [x] {$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#field_suffix']}")));
588
+    // Network preferences
589
+    if (!verify_numeric($values['network']['work_buf_min_days'], 0, 10)) form_set_error('work_buf_min_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['work_buf_min_days']['#title']} [x] {$form['prefs']['advanced']['network']['work_buf_min_days']['#field_suffix']}")));
590
+    if (!verify_numeric($values['network']['work_buf_additional_days'], 0, 10)) form_set_error('work_buf_additional_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['work_buf_additional_days']['#title']} [x] {$form['prefs']['advanced']['network']['work_buf_additional_days']['#field_suffix']}")));
591
+    if (!verify_numeric($values['network']['max_bytes_sec_down'], 0, 9999.999)) form_set_error('max_bytes_sec_down', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['max_bytes_sec_down']['#title']} [x] {$form['prefs']['advanced']['network']['max_bytes_sec_down']['#field_suffix']}")));
592
+    if (!verify_numeric($values['network']['max_bytes_sec_up'], 0, 9999.999)) form_set_error('max_bytes_sec_up', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['max_bytes_sec_up']['#title']} [x] {$form['prefs']['advanced']['network']['max_bytes_sec_up']['#field_suffix']}")));
593
+    if (!verify_numeric($values['network']['net_start_hour'], 0, 23)) form_set_error('net_start_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['net_start_hour']['#title']} [x] {$form['prefs']['advanced']['network']['net_start_hour']['#field_suffix']}")));
594
+    if (!verify_numeric($values['network']['net_end_hour'], 0, 23)) form_set_error('net_end_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['net_end_hour']['#title']} [x] {$form['prefs']['advanced']['network']['net_end_hour']['#field_suffix']}")));
595
+    if (!verify_numeric($values['network']['daily_xfer_limit_mb'], 0, 9999999)) form_set_error('daily_xfer_limit_mb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#title']} [x] {$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#field_suffix']}")));
596
+    if (!verify_numeric($values['network']['daily_xfer_period_days'], 0, 9999999)) form_set_error('daily_xfer_period_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#title']} [x] {$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#field_suffix']}")));
597 597
 }
598 598
 
599 599
 /**
600
-  * Handle post-validation submission of general preferences form.
601
-  */
600
+ * Handle post-validation submission of general preferences form.
601
+ */
602 602
 function boincwork_generalprefs_form_submit($form, &$form_state) {
603
-  global $user;
604
-  $account = user_load($user->uid);
605
-  
606
-  $values = $form_state['values']['prefs']['advanced'];
607
-  $venue = $form_state['values']['prefs']['venue'];
608
-  $preset = $form_state['values']['prefs']['preset'];
609
-  
610
-  // Load preferences from BOINC account
611
-  $prefs = boincwork_load_prefs('general', $venue);
612
-  
613
-  // Processing preferences
614
-  $prefs['run_on_batteries'] = ($values['processor']['run_on_batteries']) ? 0 : 1;
615
-  $prefs['run_if_user_active'] = ($values['processor']['run_if_user_active']) ? 0 : 1;
616
-  $prefs['run_gpu_if_user_active'] = ($values['processor']['run_gpu_if_user_active']) ? 0 : 1;
617
-  $prefs['idle_time_to_run'] = $values['processor']['idle_time_to_run'];
618
-  $prefs['suspend_if_no_recent_input'] = $values['processor']['suspend_if_no_recent_input'];
619
-  $prefs['suspend_cpu_usage'] = $values['processor']['suspend_cpu_usage'];
620
-  $prefs['start_hour'] = $values['processor']['start_hour'];
621
-  $prefs['end_hour'] = $values['processor']['end_hour'];
622
-  $prefs['leave_apps_in_memory'] = ($values['processor']['leave_apps_in_memory']) ? 1 : 0;
623
-  $prefs['cpu_scheduling_period_minutes'] = $values['processor']['cpu_scheduling_period_minutes'];
624
-  $prefs['max_ncpus_pct'] = $values['processor']['max_ncpus_pct'];
625
-  $prefs['cpu_usage_limit'] = $values['processor']['cpu_usage_limit'];
626
-  
627
-  // Storage preferences
628
-  $prefs['disk_max_used_gb'] = $values['storage']['disk_max_used_gb'];
629
-  $prefs['disk_min_free_gb'] = $values['storage']['disk_min_free_gb'];
630
-  $prefs['disk_max_used_pct'] = $values['storage']['disk_max_used_pct'];
631
-  $prefs['disk_interval'] = $values['storage']['disk_interval'];
632
-  $prefs['vm_max_used_pct'] = $values['storage']['vm_max_used_pct'];
633
-  $prefs['ram_max_used_busy_pct'] = $values['storage']['ram_max_used_busy_pct'];
634
-  $prefs['ram_max_used_idle_pct'] = $values['storage']['ram_max_used_idle_pct'];
635
-  
636
-  // Network preferences
637
-  $prefs['work_buf_min_days'] = $values['network']['work_buf_min_days'];
638
-  $prefs['work_buf_additional_days'] = $values['network']['work_buf_additional_days'];
639
-  $prefs['confirm_before_connecting'] = ($values['network']['confirm_before_connecting']) ? 1 : 0;
640
-  $prefs['hangup_if_dialed'] = ($values['network']['hangup_if_dialed']) ? 1 : 0;
641
-  $prefs['max_bytes_sec_down'] = $values['network']['max_bytes_sec_down']*1000;
642
-  $prefs['max_bytes_sec_up'] = $values['network']['max_bytes_sec_up']*1000;
643
-  $prefs['net_start_hour'] = $values['network']['net_start_hour'];
644
-  $prefs['net_end_hour'] = $values['network']['net_end_hour'];
645
-  $prefs['daily_xfer_limit_mb'] = $values['network']['daily_xfer_limit_mb'];
646
-  $prefs['daily_xfer_period_days'] = $values['network']['daily_xfer_period_days'];
647
-  $prefs['dont_verify_images'] = ($values['network']['dont_verify_images']) ? 1 : 0;
603
+    global $user;
604
+    $account = user_load($user->uid);
605
+  
606
+    $values = $form_state['values']['prefs']['advanced'];
607
+    $venue = $form_state['values']['prefs']['venue'];
608
+    $preset = $form_state['values']['prefs']['preset'];
609
+  
610
+    // Load preferences from BOINC account
611
+    $prefs = boincwork_load_prefs('general', $venue);
612
+  
613
+    // Processing preferences
614
+    $prefs['run_on_batteries'] = ($values['processor']['run_on_batteries']) ? 0 : 1;
615
+    $prefs['run_if_user_active'] = ($values['processor']['run_if_user_active']) ? 0 : 1;
616
+    $prefs['run_gpu_if_user_active'] = ($values['processor']['run_gpu_if_user_active']) ? 0 : 1;
617
+    $prefs['idle_time_to_run'] = $values['processor']['idle_time_to_run'];
618
+    $prefs['suspend_if_no_recent_input'] = $values['processor']['suspend_if_no_recent_input'];
619
+    $prefs['suspend_cpu_usage'] = $values['processor']['suspend_cpu_usage'];
620
+    $prefs['start_hour'] = $values['processor']['start_hour'];
621
+    $prefs['end_hour'] = $values['processor']['end_hour'];
622
+    $prefs['leave_apps_in_memory'] = ($values['processor']['leave_apps_in_memory']) ? 1 : 0;
623
+    $prefs['cpu_scheduling_period_minutes'] = $values['processor']['cpu_scheduling_period_minutes'];
624
+    $prefs['max_ncpus_pct'] = $values['processor']['max_ncpus_pct'];
625
+    $prefs['cpu_usage_limit'] = $values['processor']['cpu_usage_limit'];
626
+  
627
+    // Storage preferences
628
+    $prefs['disk_max_used_gb'] = $values['storage']['disk_max_used_gb'];
629
+    $prefs['disk_min_free_gb'] = $values['storage']['disk_min_free_gb'];
630
+    $prefs['disk_max_used_pct'] = $values['storage']['disk_max_used_pct'];
631
+    $prefs['disk_interval'] = $values['storage']['disk_interval'];
632
+    $prefs['vm_max_used_pct'] = $values['storage']['vm_max_used_pct'];
633
+    $prefs['ram_max_used_busy_pct'] = $values['storage']['ram_max_used_busy_pct'];
634
+    $prefs['ram_max_used_idle_pct'] = $values['storage']['ram_max_used_idle_pct'];
635
+  
636
+    // Network preferences
637
+    $prefs['work_buf_min_days'] = $values['network']['work_buf_min_days'];
638
+    $prefs['work_buf_additional_days'] = $values['network']['work_buf_additional_days'];
639
+    $prefs['confirm_before_connecting'] = ($values['network']['confirm_before_connecting']) ? 1 : 0;
640
+    $prefs['hangup_if_dialed'] = ($values['network']['hangup_if_dialed']) ? 1 : 0;
641
+    $prefs['max_bytes_sec_down'] = $values['network']['max_bytes_sec_down']*1000;
642
+    $prefs['max_bytes_sec_up'] = $values['network']['max_bytes_sec_up']*1000;
643
+    $prefs['net_start_hour'] = $values['network']['net_start_hour'];
644
+    $prefs['net_end_hour'] = $values['network']['net_end_hour'];
645
+    $prefs['daily_xfer_limit_mb'] = $values['network']['daily_xfer_limit_mb'];
646
+    $prefs['daily_xfer_period_days'] = $values['network']['daily_xfer_period_days'];
647
+    $prefs['dont_verify_images'] = ($values['network']['dont_verify_images']) ? 1 : 0;
648 648
 
649
-  // transform old way to store the preset into new way
650
-  // ideally this should already have happened in boincwork_generalprefs_form()
651
-  if (isset($prefs['@attributes']['preset'])) {
649
+    // transform old way to store the preset into new way
650
+    // ideally this should already have happened in boincwork_generalprefs_form()
651
+    if (isset($prefs['@attributes']['preset'])) {
652 652
     $prefs['preset'] = $prefs['@attributes']['preset'];
653 653
     unset($prefs['@attributes']['preset']);
654
-  }
655
-  // Save the preset selection (or lack thereof)
656
-  if (!$preset OR $preset == 'custom') {
654
+    }
655
+    // Save the preset selection (or lack thereof)
656
+    if (!$preset OR $preset == 'custom') {
657 657
     $prefs['preset'] = 'custom';
658
-  }
659
-  else {
658
+    }
659
+    else {
660 660
     $prefs['preset'] = $preset;
661
-  }
661
+    }
662 662
   
663
-  // If this is a new preference set, be sure to unset the "cleared" attribute
664
-  if (isset($prefs['@attributes']['cleared'])) {
663
+    // If this is a new preference set, be sure to unset the "cleared" attribute
664
+    if (isset($prefs['@attributes']['cleared'])) {
665 665
     unset($prefs['@attributes']['cleared']);
666
-  }
666
+    }
667 667
   
668
-  // Update database
669
-  $result = boincwork_save_prefs($prefs, 'general', $venue);
668
+    // Update database
669
+    $result = boincwork_save_prefs($prefs, 'general', $venue);
670 670
   
671
-  if (!$result) {
671
+    if (!$result) {
672 672
     watchdog('boincwork', 'Error updating global prefs for user @id: @message', array('@id' => $account->id, '@message' => mysql_error()), WATCHDOG_ERROR);
673 673
     drupal_set_message(t('Your changes could not be saved. Please contact support!'), 'error');
674
-  }
675
-  elseif (!drupal_get_messages('status', FALSE)) {
674
+    }
675
+    elseif (!drupal_get_messages('status', FALSE)) {
676 676
     // Show this message if the set wasn't created automatically (in which case
677 677
     // there is a message tailored to that) {
678 678
     drupal_set_message(t('Your preferences have been updated.
679 679
       Client-related preferences will take effect when your computer 
680 680
       communicates with @project or you issue the "Update"
681 681
       command from the BOINC client.', array('@project' => PROJECT)));
682
-  }
682
+    }
683 683
 }
684 684
 
685 685
 
@@ -691,88 +691,88 @@  discard block
 block discarded – undo
691 691
  * Find compatible hosts for merging
692 692
  */
693 693
 function boincwork_host_get_compatible_hosts($host_id) {
694
-  require_boinc('host');
695
-  global $user;
696
-  $account = user_load($user->uid);
697
-  $compatible_hosts = array();
698
-  $host_count = 0;
699
-  db_set_active('boinc');
700
-  $current_host = db_fetch_object(db_query("
694
+    require_boinc('host');
695
+    global $user;
696
+    $account = user_load($user->uid);
697
+    $compatible_hosts = array();
698
+    $host_count = 0;
699
+    db_set_active('boinc');
700
+    $current_host = db_fetch_object(db_query("
701 701
     SELECT id, domain_name, create_time, total_credit, rpc_time, os_name,
702 702
       p_vendor, p_model
703 703
     FROM {host}
704 704
     WHERE userid = '%d' AND id = '%d'",
705 705
     $account->boincuser_id, $host_id
706
-  ));
707
-  db_set_active('default');
708
-  $current_host->task_count = boincwork_host_get_task_count($current_host->id);
709
-  $current_host->is_new = !$current_host->total_credit AND !$current_host->task_count;
710
-  // Get the list of all other hosts owned by this user for comparison
711
-  db_set_active('boinc');
712
-  $all_other_hosts = db_query("
706
+    ));
707
+    db_set_active('default');
708
+    $current_host->task_count = boincwork_host_get_task_count($current_host->id);
709
+    $current_host->is_new = !$current_host->total_credit AND !$current_host->task_count;
710
+    // Get the list of all other hosts owned by this user for comparison
711
+    db_set_active('boinc');
712
+    $all_other_hosts = db_query("
713 713
     SELECT id, domain_name, create_time, total_credit, rpc_time, os_name,
714 714
       p_vendor, p_model
715 715
     FROM {host}
716 716
     WHERE userid = '%d' AND id <> '%d'",
717 717
     $account->boincuser_id, $host_id
718
-  );
719
-  db_set_active('default');
720
-  // Compare all hosts to see if any are plausible duplicates
721
-  while ($other_host = db_fetch_object($all_other_hosts)) {
718
+    );
719
+    db_set_active('default');
720
+    // Compare all hosts to see if any are plausible duplicates
721
+    while ($other_host = db_fetch_object($all_other_hosts)) {
722 722
     // First, disqualify if hosts were active at the same time
723 723
     if (!$current_host->is_new) {
724
-      $other_host->task_count = boincwork_host_get_task_count($other_host->id);
725
-      $other_host->is_new = !$other_host->total_credit AND !$other_host->task_count;
726
-      if (!$other_host->is_new) {
724
+        $other_host->task_count = boincwork_host_get_task_count($other_host->id);
725
+        $other_host->is_new = !$other_host->total_credit AND !$other_host->task_count;
726
+        if (!$other_host->is_new) {
727 727
         // If both hosts being compared are not new, see if times overlap
728 728
         if (!times_disjoint($current_host, $other_host)) {
729
-          // Hosts were active at the same time; can't be a duplicate
730
-          continue;
729
+            // Hosts were active at the same time; can't be a duplicate
730
+            continue;
731
+        }
731 732
         }
732
-      }
733 733
     }
734 734
     // Next, disqualify if hosts have different OS platforms
735 735
     if (!os_compatible($current_host, $other_host)) {
736
-      // Hosts have different OS platforms; not really a duplicate
737
-      continue;
736
+        // Hosts have different OS platforms; not really a duplicate
737
+        continue;
738 738
     }
739 739
     // Finally, disqualify if hosts have different CPUs
740 740
     if (!cpus_compatible($current_host, $other_host)) {
741
-      // CPUs don't match; not a duplicate
742
-      continue;
741
+        // CPUs don't match; not a duplicate
742
+        continue;
743 743
     }
744 744
     // If not disqualified, this host is available for merging
745 745
     $hosts[] = $other_host;
746 746
     $host_count++;
747 747
     if ($host_count == 500) {
748
-      // This is enough!
749
-      break;
748
+        // This is enough!
749
+        break;
750 750
     }
751
-  }
752
-  return $hosts;
751
+    }
752
+    return $hosts;
753 753
 }
754 754
 
755 755
 /**
756 756
  * Perform the database updates to merge the old host into the new host
757 757
  */
758 758
 function boincwork_host_merge($old_host, $new_host, &$message = NULL) {
759
-  // Decay the average credit of the two hosts
760
-  require_boinc('credit');
761
-  $now = time();
762
-  update_average($now, 0, 0, $old_host->expavg_credit, $old_host->expavg_time);
763
-  update_average($now, 0, 0, $new_host->expavg_credit, $new_host->expavg_time);
764
-  
765
-  // Update the database:
766
-  // - add credit from old host to new host
767
-  // - change results to refer to the new host
768
-  // - put old host in "zombie" state (userid=0, rpc_seqno=[new_host_id])
769
-  
770
-  $total_credit = $old_host->total_credit + $new_host->total_credit;
771
-  $recent_credit = $old_host->expavg_credit + $new_host->expavg_credit;
772
-  
773
-  // Move credit from the old host to the new host
774
-  db_set_active('boinc');
775
-  $credit_updated = db_query("
759
+    // Decay the average credit of the two hosts
760
+    require_boinc('credit');
761
+    $now = time();
762
+    update_average($now, 0, 0, $old_host->expavg_credit, $old_host->expavg_time);
763
+    update_average($now, 0, 0, $new_host->expavg_credit, $new_host->expavg_time);
764
+  
765
+    // Update the database:
766
+    // - add credit from old host to new host
767
+    // - change results to refer to the new host
768
+    // - put old host in "zombie" state (userid=0, rpc_seqno=[new_host_id])
769
+  
770
+    $total_credit = $old_host->total_credit + $new_host->total_credit;
771
+    $recent_credit = $old_host->expavg_credit + $new_host->expavg_credit;
772
+  
773
+    // Move credit from the old host to the new host
774
+    db_set_active('boinc');
775
+    $credit_updated = db_query("
776 776
     UPDATE {host}
777 777
     SET
778 778
       total_credit = '%d',
@@ -780,34 +780,34 @@  discard block
 block discarded – undo
780 780
       expavg_time = '%d'
781 781
     WHERE id = '%d'",
782 782
     $total_credit, $recent_credit, $now, $new_host->id
783
-  );
784
-  db_set_active('default');
785
-  if (!$credit_updated) {
783
+    );
784
+    db_set_active('default');
785
+    if (!$credit_updated) {
786 786
     if ($message !== NULL) {
787
-      $message = bts('Could not update credit');
787
+        $message = bts('Could not update credit');
788 788
     }
789 789
     return FALSE;
790
-  }
790
+    }
791 791
   
792
-  // Move results from the old host to the new host
793
-  db_set_active('boinc');
794
-  $results_updated = db_query("
792
+    // Move results from the old host to the new host
793
+    db_set_active('boinc');
794
+    $results_updated = db_query("
795 795
     UPDATE {result}
796 796
     SET hostid = '%d'
797 797
     WHERE hostid = '%d'",
798 798
     $new_host->id, $old_host->id
799
-  );
800
-  db_set_active('default');
801
-  if (!$results_updated) {
799
+    );
800
+    db_set_active('default');
801
+    if (!$results_updated) {
802 802
     if ($message !== NULL) {
803
-      $message = bts('Could not update results');
803
+        $message = bts('Could not update results');
804 804
     }
805 805
     return FALSE;
806
-  }
806
+    }
807 807
   
808
-  // Retire the old host
809
-  db_set_active('boinc');
810
-  $old_host_retired = db_query("
808
+    // Retire the old host
809
+    db_set_active('boinc');
810
+    $old_host_retired = db_query("
811 811
     UPDATE {host}
812 812
     SET
813 813
       total_credit = '0',
@@ -816,16 +816,16 @@  discard block
 block discarded – undo
816 816
       rpc_seqno = '%d'
817 817
     WHERE id = '%d'",
818 818
     $new_host->id, $old_host->id
819
-  );
820
-  db_set_active('default');
821
-  if (!$old_host_retired) {
819
+    );
820
+    db_set_active('default');
821
+    if (!$old_host_retired) {
822 822
     if ($message !== NULL) {
823
-      $message = bts('Could not retire old computer');
823
+        $message = bts('Could not retire old computer');
824 824
     }
825 825
     return FALSE;
826
-  }
826
+    }
827 827
   
828
-  return TRUE;
828
+    return TRUE;
829 829
 }
830 830
 
831 831
 /**
@@ -833,75 +833,75 @@  discard block
 block discarded – undo
833 833
  */
834 834
 function boincwork_host_merge_form(&$form_state, $host_id) {
835 835
 
836
-  if (!boincwork_host_user_is_owner($host_id)) {
836
+    if (!boincwork_host_user_is_owner($host_id)) {
837 837
     drupal_goto("host/{$host_id}");
838
-  }
838
+    }
839 839
   
840
-  $form = array();
841
-  $form_state['storage']['current_host_id'] = $host_id;
842
-  $current_host = boincwork_host_get_info($host_id);
840
+    $form = array();
841
+    $form_state['storage']['current_host_id'] = $host_id;
842
+    $current_host = boincwork_host_get_info($host_id);
843 843
   
844
-  // Get hosts that could be merged with this one
845
-  $hosts = boincwork_host_get_compatible_hosts($host_id);
844
+    // Get hosts that could be merged with this one
845
+    $hosts = boincwork_host_get_compatible_hosts($host_id);
846 846
   
847
-  if (!$hosts) {
847
+    if (!$hosts) {
848 848
     drupal_set_message(t('There are no computers eligible for merging with this
849 849
       one'), 'warning'
850 850
     );
851 851
     drupal_goto("host/{$host_id}");
852
-  }
852
+    }
853 853
   
854
-  $form['overview'] = array(
854
+    $form['overview'] = array(
855 855
     '#value' => '<p>' . bts('Sometimes BOINC assigns separate identities to'
856
-      . ' the same computer by mistake. You can correct this by merging old'
857
-      . ' identities with the newest one.') . '</p>'
858
-      . '<p>'
859
-      . bts('Check the computers that are the same as @name'
860
-      . ' (created on @date at @time with computer ID @id)',
856
+        . ' the same computer by mistake. You can correct this by merging old'
857
+        . ' identities with the newest one.') . '</p>'
858
+        . '<p>'
859
+        . bts('Check the computers that are the same as @name'
860
+        . ' (created on @date at @time with computer ID @id)',
861 861
         array(
862
-          '@name' => $current_host->domain_name,
863
-          '@date' => date('j M Y', $current_host->create_time),
864
-          '@time' => date('H:i:s T', $current_host->create_time),
865
-          '@id' => $current_host->id,
862
+            '@name' => $current_host->domain_name,
863
+            '@date' => date('j M Y', $current_host->create_time),
864
+            '@time' => date('H:i:s T', $current_host->create_time),
865
+            '@id' => $current_host->id,
866 866
         )
867
-      ) . '</p>',
868
-  );
867
+        ) . '</p>',
868
+    );
869 869
   
870
-  $options = array();
871
-  foreach ($hosts as $host) {
870
+    $options = array();
871
+    foreach ($hosts as $host) {
872 872
     $options[$host->id] = array(
873
-      $host->domain_name,
874
-      date('j M Y H:i:s T', $host->create_time),
875
-      $host->id,
873
+        $host->domain_name,
874
+        date('j M Y H:i:s T', $host->create_time),
875
+        $host->id,
876 876
     );
877
-  }
877
+    }
878 878
   
879
-  $form['merge'] = array(
879
+    $form['merge'] = array(
880 880
     '#title' => '',
881 881
     '#type' => 'tableselect',
882 882
     '#header' => array(bts('Name'), bts('Created'), bts('Computer ID')),
883 883
     '#options' => $options,
884
-  );
884
+    );
885 885
   
886
-  $form['prefs']['separator_bottom'] = array(
887
-  //  '#value' => '<div class="separator buttons"></div>'
888
-  );
886
+    $form['prefs']['separator_bottom'] = array(
887
+    //  '#value' => '<div class="separator buttons"></div>'
888
+    );
889 889
   
890
-  // Form control
891
-  $form['prefs']['form control tabs prefix'] = array(
890
+    // Form control
891
+    $form['prefs']['form control tabs prefix'] = array(
892 892
     '#value' => '<ul class="form-control tab-list">'
893
-  );
894
-  $form['prefs']['submit'] = array(
893
+    );
894
+    $form['prefs']['submit'] = array(
895 895
     '#prefix' => '<li class="first tab">',
896 896
     '#type' => 'submit',
897 897
     '#value' => bts('Merge'),
898 898
     '#suffix' => '</li>'
899
-  );
900
-  $form['prefs']['form control tabs'] = array(
899
+    );
900
+    $form['prefs']['form control tabs'] = array(
901 901
     '#value' => '<li class="tab">' . l(bts('Cancel'), "host/{$host_id}") . '</li>'
902
-  );
902
+    );
903 903
   
904
-  return $form;
904
+    return $form;
905 905
 }
906 906
 
907 907
 /**
@@ -914,76 +914,76 @@  discard block
 block discarded – undo
914 914
  * Handle submission of the merge host form
915 915
  */
916 916
 function boincwork_host_merge_form_submit($form, &$form_state) {
917
-  $merged = array();
918
-  $errors = array();
919
-  $current_host_id = $form_state['storage']['current_host_id'];
920
-  $current_host = boincwork_host_get_info($current_host_id);
921
-  $selected_hosts = array_filter($form_state['values']['merge']);
917
+    $merged = array();
918
+    $errors = array();
919
+    $current_host_id = $form_state['storage']['current_host_id'];
920
+    $current_host = boincwork_host_get_info($current_host_id);
921
+    $selected_hosts = array_filter($form_state['values']['merge']);
922 922
   
923
-  foreach ($selected_hosts as $host_id) {
923
+    foreach ($selected_hosts as $host_id) {
924 924
     // Attempt to merge each host, noting the results
925 925
     $message = '';
926 926
     $old_host = boincwork_host_get_info($host_id);
927 927
     if (boincwork_host_merge($old_host, $current_host, $message)) {
928
-      $merged[$old_host->id] = $old_host->id;
929
-      $current_host = boincwork_host_get_info($current_host_id);
928
+        $merged[$old_host->id] = $old_host->id;
929
+        $current_host = boincwork_host_get_info($current_host_id);
930 930
     }
931 931
     else {
932
-      $errors[$old_host->id] = $message;
932
+        $errors[$old_host->id] = $message;
933
+    }
933 934
     }
934
-  }
935 935
   
936
-  if ($merged) {
936
+    if ($merged) {
937 937
     // Generate a natural language list of IDs that were merged
938 938
     $oxford_comma = ',';
939 939
     $conjunction = bts('and');
940 940
     $list = array_keys($merged);
941 941
     $last = array_pop($list);
942 942
     if ($list) {
943
-      if (count($merged) == 2) {
943
+        if (count($merged) == 2) {
944 944
         $oxford_comma = '';
945
-      }
946
-      $list = implode(', ', $list) . $oxford_comma . ' ' . $conjunction . ' ' . $last;
945
+        }
946
+        $list = implode(', ', $list) . $oxford_comma . ' ' . $conjunction . ' ' . $last;
947 947
     }
948 948
     else {
949
-      $list = $last;
949
+        $list = $last;
950 950
     }
951 951
     if (count($merged) == 1) {
952
-      drupal_set_message(bts(
952
+        drupal_set_message(bts(
953 953
         'Computer @old_id has been merged successfully into @id.',
954 954
         array(
955
-          '@old_id' => $list,
956
-          '@id' => $current_host_id
955
+            '@old_id' => $list,
956
+            '@id' => $current_host_id
957 957
         )
958
-      ));
958
+        ));
959 959
     }
960 960
     else {
961
-      drupal_set_message(bts(
961
+        drupal_set_message(bts(
962 962
         'Computers @old_ids have been merged successfully into @id.',
963 963
         array(
964
-          '@old_ids' => $list,
965
-          '@id' => $current_host_id
964
+            '@old_ids' => $list,
965
+            '@id' => $current_host_id
966 966
         )
967
-      ));
967
+        ));
968
+    }
968 969
     }
969
-  }
970 970
   
971
-  if ($errors) {
971
+    if ($errors) {
972 972
     // Report any hosts that failed to merge
973 973
     foreach ($errors as $id => $error) {
974
-      drupal_set_message(
974
+        drupal_set_message(
975 975
         bts('Computer @old_id failed to merge: @message',
976
-          array(
976
+            array(
977 977
             '@old_id' => $id,
978 978
             '@message' => $error,
979
-          )
979
+            )
980 980
         ),
981 981
         'warning'
982
-      );
982
+        );
983
+    }
983 984
     }
984
-  }
985 985
   
986
-  drupal_goto("host/{$current_host_id}");
986
+    drupal_goto("host/{$current_host_id}");
987 987
 }
988 988
 
989 989
 /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
@@ -995,38 +995,38 @@  discard block
 block discarded – undo
995 995
  */
996 996
 function boincwork_projectprefs_form(&$form_state, $venue) {
997 997
   
998
-  global $user;
999
-  $account = user_load($user->uid);
998
+    global $user;
999
+    $account = user_load($user->uid);
1000 1000
   
1001
-  $established = TRUE;
1001
+    $established = TRUE;
1002 1002
   
1003
-  // Get availability of special BOINC preferences
1004
-  require_boinc(array('util'));
1005
-  $app_types = get_app_types();
1003
+    // Get availability of special BOINC preferences
1004
+    require_boinc(array('util'));
1005
+    $app_types = get_app_types();
1006 1006
   
1007
-  // Load any existing preferences from BOINC account
1008
-  $prefs = boincwork_load_prefs('project', $venue);
1007
+    // Load any existing preferences from BOINC account
1008
+    $prefs = boincwork_load_prefs('project', $venue);
1009 1009
   
1010
-  // Take note if this is not an established preference set on the account
1011
-  if (isset($prefs['@attributes']['cleared'])) {
1010
+    // Take note if this is not an established preference set on the account
1011
+    if (isset($prefs['@attributes']['cleared'])) {
1012 1012
     $established = FALSE;
1013
-  }
1013
+    }
1014 1014
   
1015
-  $venue_is_default = FALSE;
1016
-  if ($account->boincuser_default_pref_set) {
1015
+    $venue_is_default = FALSE;
1016
+    if ($account->boincuser_default_pref_set) {
1017 1017
     if ($account->boincuser_default_pref_set == $venue) {
1018
-      $venue_is_default = TRUE;
1018
+        $venue_is_default = TRUE;
1019
+    }
1019 1020
     }
1020
-  }
1021
-  elseif (!$venue OR $venue == 'generic') {
1021
+    elseif (!$venue OR $venue == 'generic') {
1022 1022
     $venue_is_default = TRUE;
1023
-  }
1024
-  else {
1023
+    }
1024
+    else {
1025 1025
     $venue_is_default = FALSE;
1026
-  }
1026
+    }
1027 1027
   
1028
-  // Define form defaults
1029
-  $default = array(
1028
+    // Define form defaults
1029
+    $default = array(
1030 1030
     'resource_share' => 100,
1031 1031
     'no_cpu' => 0,
1032 1032
     'no_cuda' => 0,
@@ -1034,329 +1034,329 @@  discard block
 block discarded – undo
1034 1034
     'no_intel_gpu' => 0,
1035 1035
     'default_venue' => $venue_is_default,
1036 1036
     'allow_beta_work' => $prefs['allow_beta_work'],
1037
-  );
1038
-  foreach ($default as $name => $value) {
1037
+    );
1038
+    foreach ($default as $name => $value) {
1039 1039
     if (isset($prefs[$name])) {
1040
-      if (is_array($prefs[$name])) {
1040
+        if (is_array($prefs[$name])) {
1041 1041
         if (isset($prefs[$name]['@value'])) {
1042
-          $default[$name] = $prefs[$name]['@value'];
1042
+            $default[$name] = $prefs[$name]['@value'];
1043 1043
         }
1044
-      }
1045
-      else {
1044
+        }
1045
+        else {
1046 1046
         $default[$name] = $prefs[$name];
1047
-      }
1047
+        }
1048
+    }
1048 1049
     }
1049
-  }
1050 1050
   
1051
-  // Standard option sets
1052
-  $form['boolean_options'] = array(
1051
+    // Standard option sets
1052
+    $form['boolean_options'] = array(
1053 1053
     '#type' => 'value',
1054 1054
     '#value' => array(1 => bts('yes'), 0 => bts('no'))
1055
-  );
1055
+    );
1056 1056
   
1057
-  // Identify preference sets that are established to distinguish what has been
1058
-  // saved to the database from what is just showing default values
1059
-  $form['#established'] = $established;
1057
+    // Identify preference sets that are established to distinguish what has been
1058
+    // saved to the database from what is just showing default values
1059
+    $form['#established'] = $established;
1060 1060
   
1061
-  // Top level form options
1062
-  $form['#tree'] = TRUE;
1061
+    // Top level form options
1062
+    $form['#tree'] = TRUE;
1063 1063
   
1064
-  // Hidden elements
1065
-  $form['venue'] = array(
1064
+    // Hidden elements
1065
+    $form['venue'] = array(
1066 1066
     '#type' => 'hidden',
1067 1067
     '#value' => $venue
1068
-  );
1068
+    );
1069 1069
   
1070
-  $form['separator_top'] = array(
1070
+    $form['separator_top'] = array(
1071 1071
     '#value' => '<div class="separator"></div>'
1072
-  );
1072
+    );
1073 1073
   
1074
-  // Common project preferences  
1075
-  $form['resource'] = array(
1074
+    // Common project preferences  
1075
+    $form['resource'] = array(
1076 1076
     '#title' => bts('Resource settings'),
1077 1077
     '#type' => 'fieldset',
1078 1078
     '#description' => null,
1079 1079
     '#collapsible' => TRUE,
1080 1080
     '#collapsed' => FALSE
1081
-  );
1082
-  $form['resource']['resource_share'] = array(
1081
+    );
1082
+    $form['resource']['resource_share'] = array(
1083 1083
     '#title' => bts('Resource share'),
1084 1084
     '#type' => 'textfield',
1085 1085
     '#default_value' => $default['resource_share'],
1086 1086
     '#size' => 5,
1087 1087
     '#description' => bts("Determines the proportion of your computer's resources allocated to this project. Example: if you participate in two BOINC projects with resource shares of 100 and 200, the first will get 1/3 of your resources and the second will get 2/3.")
1088
-  );
1089
-  if ($app_types->count > 1) {
1088
+    );
1089
+    if ($app_types->count > 1) {
1090 1090
     if ($app_types->cpu) {
1091
-      $form['resource']['no_cpu'] = array(
1091
+        $form['resource']['no_cpu'] = array(
1092 1092
         '#title' => bts('Use CPU'),
1093 1093
         '#type' => 'radios',
1094 1094
         '#options' => $form['boolean_options']['#value'],
1095 1095
         '#attributes' => array('class' => 'fancy'),
1096 1096
         '#default_value' => $default['no_cpu'] ? 0 : 1,
1097 1097
         '#description' => bts('Request CPU-only tasks from this project.')
1098
-      );
1098
+        );
1099 1099
     }
1100 1100
     if ($app_types->cuda) {
1101
-      $form['resource']['no_cuda'] = array(
1101
+        $form['resource']['no_cuda'] = array(
1102 1102
         '#title' => bts('Use NVIDIA GPU'),
1103 1103
         '#type' => 'radios',
1104 1104
         '#options' => $form['boolean_options']['#value'],
1105 1105
         '#attributes' => array('class' => 'fancy'),
1106 1106
         '#default_value' => $default['no_cuda'] ? 0 : 1,
1107 1107
         '#description' => bts('Request NVIDIA GPU tasks from this project.')
1108
-      );
1108
+        );
1109 1109
     }
1110 1110
     if ($app_types->ati) {
1111
-      $form['resource']['no_ati'] = array(
1111
+        $form['resource']['no_ati'] = array(
1112 1112
         '#title' => bts('Use ATI GPU'),
1113 1113
         '#type' => 'radios',
1114 1114
         '#options' => $form['boolean_options']['#value'],
1115 1115
         '#attributes' => array('class' => 'fancy'),
1116 1116
         '#default_value' => $default['no_ati'] ? 0 : 1,
1117 1117
         '#description' => bts('Request ATI GPU tasks from this project.')
1118
-      );
1118
+        );
1119 1119
     }
1120 1120
     if ($app_types->intel_gpu) {
1121
-      $form['resource']['no_intel_gpu'] = array(
1121
+        $form['resource']['no_intel_gpu'] = array(
1122 1122
         '#title' => bts('Use INTEL GPU'),
1123 1123
         '#type' => 'radios',
1124 1124
         '#options' => $form['boolean_options']['#value'],
1125 1125
         '#attributes' => array('class' => 'fancy'),
1126 1126
         '#default_value' => $default['no_intel_gpu'] ? 0 : 1,
1127 1127
         '#description' => bts('Request Intel GPU tasks from this project.')
1128
-      );
1128
+        );
1129
+    }
1129 1130
     }
1130
-  }
1131 1131
   
1132
-  if (variable_get('boinc_prefs_options_beta', FALSE)) {
1132
+    if (variable_get('boinc_prefs_options_beta', FALSE)) {
1133 1133
     $form['beta'] = array(
1134
-      '#title' => bts('Beta settings'),
1135
-      '#type' => 'fieldset',
1136
-      '#description' => null,
1137
-      '#collapsible' => TRUE,
1138
-      '#collapsed' => FALSE
1134
+        '#title' => bts('Beta settings'),
1135
+        '#type' => 'fieldset',
1136
+        '#description' => null,
1137
+        '#collapsible' => TRUE,
1138
+        '#collapsed' => FALSE
1139 1139
     );
1140 1140
     $form['beta']['allow_beta_work'] = array(
1141
-      '#title' => bts('Run test applications?'),
1142
-      '#type' => 'radios',
1143
-      '#options' => $form['boolean_options']['#value'],
1144
-      '#attributes' => array('class' => 'fancy'),
1145
-      '#default_value' => ($default['allow_beta_work']) ? 1 : 0,
1146
-      '#description' => bts('This helps us develop applications, but may cause jobs to fail on your computer')
1141
+        '#title' => bts('Run test applications?'),
1142
+        '#type' => 'radios',
1143
+        '#options' => $form['boolean_options']['#value'],
1144
+        '#attributes' => array('class' => 'fancy'),
1145
+        '#default_value' => ($default['allow_beta_work']) ? 1 : 0,
1146
+        '#description' => bts('This helps us develop applications, but may cause jobs to fail on your computer')
1147 1147
     );
1148
-  }
1148
+    }
1149 1149
   
1150
-  // Add project specific prefs to the form
1151
-  boincwork_add_project_specific_prefs($form, $prefs);
1150
+    // Add project specific prefs to the form
1151
+    boincwork_add_project_specific_prefs($form, $prefs);
1152 1152
   
1153
-  // Set whether to use this preference set by default for new computers
1154
-  $form['default_set'] = array(
1153
+    // Set whether to use this preference set by default for new computers
1154
+    $form['default_set'] = array(
1155 1155
     '#title' => bts('Default set'),
1156 1156
     '#type' => 'fieldset',
1157 1157
     '#description' => null,
1158 1158
     '#collapsible' => TRUE,
1159 1159
     '#collapsed' => FALSE
1160
-  );
1161
-  $form['default_set']['default_venue'] = array(
1160
+    );
1161
+    $form['default_set']['default_venue'] = array(
1162 1162
     '#title' => bts('Set used for new computers'),
1163 1163
     '#type' => 'radios',
1164 1164
     '#options' => $form['boolean_options']['#value'],
1165 1165
     '#attributes' => array('class' => 'fancy'),
1166 1166
     '#default_value' => $default['default_venue'] ? 1 : 0,
1167 1167
     '#description' => ''
1168
-  );
1168
+    );
1169 1169
   
1170
-  $form['prefs']['separator_bottom'] = array(
1170
+    $form['prefs']['separator_bottom'] = array(
1171 1171
     '#value' => '<div class="separator buttons"></div>'
1172
-  );
1172
+    );
1173 1173
   
1174
-  // Form control
1175
-  $form['prefs']['form control tabs prefix'] = array(
1174
+    // Form control
1175
+    $form['prefs']['form control tabs prefix'] = array(
1176 1176
     '#value' => '<ul class="form-control tab-list">'
1177
-  );
1178
-  $form['prefs']['submit'] = array(
1177
+    );
1178
+    $form['prefs']['submit'] = array(
1179 1179
     '#prefix' => '<li class="first tab">',
1180 1180
     '#type' => 'submit',
1181 1181
     '#value' => bts('Save changes'),
1182 1182
     '#suffix' => '</li>'
1183
-  );
1184
-  $form['prefs']['form control tabs'] = array(
1183
+    );
1184
+    $form['prefs']['form control tabs'] = array(
1185 1185
     '#value' => '<li class="tab">' . l(bts('Cancel'), $_GET['q']) . '</li>'
1186
-  );
1187
-  if ($venue AND $venue != 'generic') {
1186
+    );
1187
+    if ($venue AND $venue != 'generic') {
1188 1188
     global $base_path;
1189 1189
     $form['prefs']['form control tabs']['#value'] .= '<li class="tab">' . 
1190
-      l(bts('Clear'), "account/prefs/project/clear/{$venue}",
1190
+        l(bts('Clear'), "account/prefs/project/clear/{$venue}",
1191 1191
         array(
1192
-          'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/project/combined')),
1193
-          'attributes' => array(
1192
+            'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/project/combined')),
1193
+            'attributes' => array(
1194 1194
             'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the @name preference set. Are you sure?',
1195
-              array('@name' => $venue)) . '\')'
1196
-          )
1195
+                array('@name' => $venue)) . '\')'
1196
+            )
1197 1197
         )
1198
-      ) . '</li>';
1199
-  }
1200
-  $form['prefs']['view control'] = array(
1198
+        ) . '</li>';
1199
+    }
1200
+    $form['prefs']['view control'] = array(
1201 1201
     '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view') . ')', 'account/prefs/project/combined') . '</li>'
1202
-  );
1203
-  $form['prefs']['form control tabs suffix'] = array(
1202
+    );
1203
+    $form['prefs']['form control tabs suffix'] = array(
1204 1204
     '#value' => '</ul>'
1205
-  );
1205
+    );
1206 1206
   
1207
-  return $form;
1207
+    return $form;
1208 1208
 }
1209 1209
 
1210 1210
 /**
1211 1211
  * Add project specific preferences to the project preferences form
1212 1212
  */
1213 1213
 function boincwork_add_project_specific_prefs(&$form, $prefs) {
1214
-  // Load project specific preferences from XML config
1215
-  $xml = boincwork_get_project_specific_config();
1214
+    // Load project specific preferences from XML config
1215
+    $xml = boincwork_get_project_specific_config();
1216 1216
   
1217
-  // Respect the order of the top level elements
1218
-  $ordered_array = array();
1219
-  $unordered_array = array();
1220
-  foreach ($xml['project_specific_preferences'] as $type => $element) {
1217
+    // Respect the order of the top level elements
1218
+    $ordered_array = array();
1219
+    $unordered_array = array();
1220
+    foreach ($xml['project_specific_preferences'] as $type => $element) {
1221 1221
     if (is_array($element) AND is_numeric(key($element))) {
1222
-      foreach ($element as $ordered_element) {
1222
+        foreach ($element as $ordered_element) {
1223 1223
         if (isset($ordered_element['@position'])) {
1224
-          $ordered_array[$ordered_element['@position']] = array($type => $ordered_element);
1224
+            $ordered_array[$ordered_element['@position']] = array($type => $ordered_element);
1225 1225
         }
1226 1226
         else {
1227
-          $unordered_array[] = array($type => $ordered_element);
1227
+            $unordered_array[] = array($type => $ordered_element);
1228
+        }
1228 1229
         }
1229
-      }
1230 1230
     }
1231 1231
     elseif (isset($element['@position'])) {
1232
-      $ordered_array[$element['@position']] = array($type => $element);
1232
+        $ordered_array[$element['@position']] = array($type => $element);
1233 1233
     }
1234 1234
     else {
1235
-      $unordered_array[] = array($type => $element);
1235
+        $unordered_array[] = array($type => $element);
1236
+    }
1236 1237
     }
1237
-  }
1238
-  ksort($ordered_array);
1239
-  $primed_array = array_merge($ordered_array, $unordered_array);
1240
-  $xml = array('project_specific_preferences' => $primed_array);
1238
+    ksort($ordered_array);
1239
+    $primed_array = array_merge($ordered_array, $unordered_array);
1240
+    $xml = array('project_specific_preferences' => $primed_array);
1241 1241
     
1242
-  foreach ($xml['project_specific_preferences'] as $wrapped_element) {
1242
+    foreach ($xml['project_specific_preferences'] as $wrapped_element) {
1243 1243
     $type = key($wrapped_element);
1244 1244
     $element= reset($wrapped_element);
1245 1245
     boincwork_generate_prefs_element($form, $type, $element, $prefs['project_specific']);
1246
-  }
1246
+    }
1247 1247
 }
1248 1248
 
1249 1249
 /**
1250
-  * Validate the project preferences form.
1251
-  */
1250
+ * Validate the project preferences form.
1251
+ */
1252 1252
 function boincwork_projectprefs_form_validate($form, &$form_state) {
1253 1253
   
1254
-  // Verify all text user input values and notify form API of failures
1255
-  $validation_rules = array(
1254
+    // Verify all text user input values and notify form API of failures
1255
+    $validation_rules = array(
1256 1256
     'resource' => array(
1257
-      'resource_share' => array(
1257
+        'resource_share' => array(
1258 1258
         'datatype' => 'integer',
1259 1259
         'min' => 0
1260
-      ),
1260
+        ),
1261 1261
     ),
1262
-  );
1262
+    );
1263 1263
   
1264
-  // Add validation rules for project specific settings
1265
-  $validation_rules += boincwork_get_project_specific_config_validation_rules();
1264
+    // Add validation rules for project specific settings
1265
+    $validation_rules += boincwork_get_project_specific_config_validation_rules();
1266 1266
   
1267
-  // Perform validation
1268
-  boincwork_validate_form($validation_rules, $form_state['values']);
1267
+    // Perform validation
1268
+    boincwork_validate_form($validation_rules, $form_state['values']);
1269 1269
   
1270
-  // Check for app validation
1271
-  if (isset($validation_rules['apps'])) {
1270
+    // Check for app validation
1271
+    if (isset($validation_rules['apps'])) {
1272 1272
     if (isset($validation_rules['apps']['minimum selected'])
1273 1273
         AND $validation_rules['apps']['minimum selected'] > 0) {
1274
-      $apps_selected = 0;
1275
-      foreach ($validation_rules['apps']['list'] as $app) {
1274
+        $apps_selected = 0;
1275
+        foreach ($validation_rules['apps']['list'] as $app) {
1276 1276
         if ($form_state['values']['applications'][$app]) $apps_selected++;
1277
-      }
1278
-      if ($apps_selected < $validation_rules['apps']['minimum selected']) {
1277
+        }
1278
+        if ($apps_selected < $validation_rules['apps']['minimum selected']) {
1279 1279
         form_set_error(
1280
-          'applications',
1281
-          bts('At least one application must be selected')
1280
+            'applications',
1281
+            bts('At least one application must be selected')
1282 1282
         );
1283
-      }
1284
-      if ($apps_selected == count($validation_rules['apps']['list'])) {
1283
+        }
1284
+        if ($apps_selected == count($validation_rules['apps']['list'])) {
1285 1285
         foreach ($validation_rules['apps']['list'] as $app) {
1286
-          unset($form_state['values']['applications'][$app]);
1286
+            unset($form_state['values']['applications'][$app]);
1287 1287
         }
1288 1288
         $form_state['storage']['all apps selected'] = TRUE;
1289
-      }
1289
+        }
1290
+    }
1290 1291
     }
1291
-  }
1292 1292
 }
1293 1293
 
1294 1294
 /**
1295
-  * Handle post-validation submission of project preferences form.
1296
-  */
1295
+ * Handle post-validation submission of project preferences form.
1296
+ */
1297 1297
 function boincwork_projectprefs_form_submit($form, &$form_state) {
1298
-  global $user;
1299
-  global $site_name;
1298
+    global $user;
1299
+    global $site_name;
1300 1300
   
1301
-  require_boinc(array('util'));
1302
-  $app_types = get_app_types();
1301
+    require_boinc(array('util'));
1302
+    $app_types = get_app_types();
1303 1303
   
1304
-  $account = user_load($user->uid);
1305
-  $edit = $form_state['values'];
1306
-  $venue = $edit['venue'];
1304
+    $account = user_load($user->uid);
1305
+    $edit = $form_state['values'];
1306
+    $venue = $edit['venue'];
1307 1307
   
1308
-  // Load preferences from BOINC account
1309
-  $prefs = boincwork_load_prefs('project', $venue);
1308
+    // Load preferences from BOINC account
1309
+    $prefs = boincwork_load_prefs('project', $venue);
1310 1310
   
1311
-  // Resource preferences
1312
-  $prefs['resource_share'] = $edit['resource']['resource_share'];
1313
-  if ($app_types->count > 1) {
1311
+    // Resource preferences
1312
+    $prefs['resource_share'] = $edit['resource']['resource_share'];
1313
+    if ($app_types->count > 1) {
1314 1314
     if ($app_types->cpu) $prefs['no_cpu'] = ($edit['resource']['no_cpu']) ? 0 : 1;
1315 1315
     if ($app_types->cuda) $prefs['no_cuda'] = ($edit['resource']['no_cuda']) ? 0 : 1;
1316 1316
     if ($app_types->ati) $prefs['no_ati'] = ($edit['resource']['no_ati']) ? 0 : 1;
1317 1317
     if ($app_types->intel_gpu) $prefs['no_intel_gpu'] = ($edit['resource']['no_intel_gpu']) ? 0 : 1;
1318
-  }
1318
+    }
1319 1319
   
1320
-  // Beta preferences
1321
-  if (variable_get('boinc_prefs_options_beta', FALSE)) {
1320
+    // Beta preferences
1321
+    if (variable_get('boinc_prefs_options_beta', FALSE)) {
1322 1322
     $prefs['allow_beta_work'] = ($edit['beta']['allow_beta_work']) ? 1 : 0;
1323
-  }
1323
+    }
1324 1324
   
1325
-  // Load project specific preferences from XML config
1326
-  $xml = boincwork_get_project_specific_config();
1327
-  $updated_prefs = array(
1325
+    // Load project specific preferences from XML config
1326
+    $xml = boincwork_get_project_specific_config();
1327
+    $updated_prefs = array(
1328 1328
     'project_specific' => boincwork_format_project_specific_prefs_data($edit)
1329
-  );
1330
-  $prefs = $updated_prefs + $prefs;
1329
+    );
1330
+    $prefs = $updated_prefs + $prefs;
1331 1331
   
1332
-  // Don't specify apps if all are selected
1333
-  if (isset($form_state['storage']['all apps selected'])) {
1332
+    // Don't specify apps if all are selected
1333
+    if (isset($form_state['storage']['all apps selected'])) {
1334 1334
     unset($prefs['project_specific']['app_id']);
1335 1335
     unset($form_state['storage']['all apps selected']);
1336
-  }
1336
+    }
1337 1337
   
1338
-  // If this is a new preference set, be sure to unset the "cleared" attribute
1339
-  if (isset($prefs['@attributes']['cleared'])) {
1338
+    // If this is a new preference set, be sure to unset the "cleared" attribute
1339
+    if (isset($prefs['@attributes']['cleared'])) {
1340 1340
     unset($prefs['@attributes']['cleared']);
1341
-  }
1341
+    }
1342 1342
   
1343
-  // Save preferences back to the BOINC account
1344
-  $result = boincwork_save_prefs($prefs, 'project', $venue);
1343
+    // Save preferences back to the BOINC account
1344
+    $result = boincwork_save_prefs($prefs, 'project', $venue);
1345 1345
   
1346
-  // Update the user's default preference set
1347
-  if ($edit['default_set']['default_venue']) {
1346
+    // Update the user's default preference set
1347
+    if ($edit['default_set']['default_venue']) {
1348 1348
     boincwork_set_default_venue($venue);
1349
-  }
1350
-  elseif ($venue == $account->boincuser_default_pref_set) {
1349
+    }
1350
+    elseif ($venue == $account->boincuser_default_pref_set) {
1351 1351
     // User has cleared out the default venue setting
1352 1352
     boincwork_set_default_venue();
1353
-  }
1353
+    }
1354 1354
   
1355
-  if (!$result) {
1355
+    if (!$result) {
1356 1356
     watchdog('boincwork', 'Error updating project prefs for user @id: @message', array('@id' => $user->id, '@message' => mysql_error()), WATCHDOG_ERROR);
1357 1357
     drupal_set_message(t('Your changes could not be saved. Please contact support!'), 'error');
1358
-  }
1359
-  elseif (!drupal_get_messages('status', FALSE)) {
1358
+    }
1359
+    elseif (!drupal_get_messages('status', FALSE)) {
1360 1360
     // Show this message if the set wasn't created automatically (in which case
1361 1361
     // there is a message tailored to that)
1362 1362
     drupal_set_message(t('Your preferences have been updated.
@@ -1364,53 +1364,53 @@  discard block
 block discarded – undo
1364 1364
         communicates with @project or you issue the "Update"
1365 1365
         command from the BOINC client.', 
1366 1366
         array('@project' => $site_name)));
1367
-  }
1367
+    }
1368 1368
 }
1369 1369
 
1370 1370
 /**
1371 1371
  * The structure of the community preferences form
1372 1372
  */
1373 1373
 function communityprefs_form(&$form_state) {
1374
-  global $user;
1375
-  $account = user_load($user->uid);
1376
-  $form = array();
1377
-  
1378
-  // Pull in some elements from the profile form
1379
-  $profile_form_state = array();
1380
-  $profile = new stdClass();
1381
-  $profile->type = 'profile';
1382
-  $profile->language = '';
1383
-  if ($profile_nid = content_profile_profile_exists($profile, $account->uid)) {
1374
+    global $user;
1375
+    $account = user_load($user->uid);
1376
+    $form = array();
1377
+  
1378
+    // Pull in some elements from the profile form
1379
+    $profile_form_state = array();
1380
+    $profile = new stdClass();
1381
+    $profile->type = 'profile';
1382
+    $profile->language = '';
1383
+    if ($profile_nid = content_profile_profile_exists($profile, $account->uid)) {
1384 1384
     $profile_node = node_load($profile_nid);
1385 1385
     $form_state['storage']['profile_node'] = $profile_node;
1386 1386
     module_load_include('inc', 'node', 'node.pages');    
1387 1387
     $profile_form = drupal_retrieve_form('profile_node_form', $profile_form_state, $profile_node);
1388 1388
     drupal_prepare_form('profile_node_form', $profile_form, $profile_form_state);
1389
-  }
1389
+    }
1390 1390
   
1391
-  // Standard option sets
1392
-  $form['boolean_options'] = array(
1391
+    // Standard option sets
1392
+    $form['boolean_options'] = array(
1393 1393
     '#type' => 'value',
1394 1394
     '#value' => array(1 => bts('yes'), 0 => bts('no'))
1395
-  );
1395
+    );
1396 1396
   
1397
-  $default = array(
1397
+    $default = array(
1398 1398
     'pm_send_notification' => '', // This is set already in pm_email_notify_user
1399 1399
     'friend_notification' => isset($account->friend_notification) ? $account->friend_notification : 0,
1400 1400
     'comments_per_page' => (isset($account->comments_per_page) AND $account->comments_per_page) ? $account->comments_per_page : variable_get('comment_default_per_page_forum', 50),
1401 1401
     'comments_order' => (isset($account->sort) AND $account->sort) ? $account->sort : variable_get('comment_default_order_forum', COMMENT_ORDER_OLDEST_FIRST),
1402
-  );
1402
+    );
1403 1403
   
1404
-  // General options
1405
-  $form['general'] = array(
1404
+    // General options
1405
+    $form['general'] = array(
1406 1406
     '#type' => 'fieldset',
1407 1407
     '#title' => bts('General settings'),
1408 1408
     '#weight' => 0,
1409 1409
     '#collapsible' => TRUE,
1410 1410
     '#collapsed' => FALSE
1411
-  );
1412
-  // Add the BOINC user name (non-unique, user editable)
1413
-  $form['general']['boincuser_name'] = array(
1411
+    );
1412
+    // Add the BOINC user name (non-unique, user editable)
1413
+    $form['general']['boincuser_name'] = array(
1414 1414
     '#type' => 'textfield',
1415 1415
     '#title' => bts('Name'),
1416 1416
     '#default_value' => $account->boincuser_name,
@@ -1418,239 +1418,239 @@  discard block
 block discarded – undo
1418 1418
     '#required' => TRUE,
1419 1419
     '#description' => '',
1420 1420
     '#size' => 40
1421
-  );
1422
-  // Time zone
1423
-  if (variable_get('configurable_timezones', 1)) {
1421
+    );
1422
+    // Time zone
1423
+    if (variable_get('configurable_timezones', 1)) {
1424 1424
     $zones = _system_zonelist();
1425 1425
     $form['general']['timezone'] = array(
1426
-      '#type' => 'select',
1427
-      '#title' => bts('Time zone'),
1428
-      '#default_value' => ($account->timezone !== NULL) ? $account->timezone : variable_get('date_default_timezone', 0),
1429
-      '#options' => $zones,
1430
-      '#description' => '',
1426
+        '#type' => 'select',
1427
+        '#title' => bts('Time zone'),
1428
+        '#default_value' => ($account->timezone !== NULL) ? $account->timezone : variable_get('date_default_timezone', 0),
1429
+        '#options' => $zones,
1430
+        '#description' => '',
1431 1431
     );
1432
-  }
1432
+    }
1433 1433
   
1434
-  // Notification options
1435
-  $form['notifications'] = array(
1434
+    // Notification options
1435
+    $form['notifications'] = array(
1436 1436
     '#type' => 'fieldset',
1437 1437
     '#title' => bts('Notification settings'),
1438 1438
     '#weight' => 5,
1439 1439
     '#collapsible' => TRUE,
1440 1440
     '#collapsed' => FALSE
1441
-  );
1442
-  // Pull in private message notification handling and tweak the form
1443
-  $pm_notify = pm_email_notify_user('form', $edit, $account, 'account');
1444
-  $form['notifications']['pm_send_notifications'] = array_replace(
1441
+    );
1442
+    // Pull in private message notification handling and tweak the form
1443
+    $pm_notify = pm_email_notify_user('form', $edit, $account, 'account');
1444
+    $form['notifications']['pm_send_notifications'] = array_replace(
1445 1445
     $pm_notify['enable_pm_mail']['pm_send_notifications'],
1446 1446
     array(
1447
-      '#type' => 'radios',
1448
-      '#title' => bts('Receive email notification for private messages?'),
1449
-      '#description' => ' ',
1450
-      '#options' => $form['boolean_options']['#value'],
1451
-      '#attributes' => array('class' => 'fancy')
1447
+        '#type' => 'radios',
1448
+        '#title' => bts('Receive email notification for private messages?'),
1449
+        '#description' => ' ',
1450
+        '#options' => $form['boolean_options']['#value'],
1451
+        '#attributes' => array('class' => 'fancy')
1452 1452
     )
1453
-  );
1454
-  $form['notifications']['friend_notification'] = array(
1453
+    );
1454
+    $form['notifications']['friend_notification'] = array(
1455 1455
     '#type' => 'radios',
1456 1456
     '#title' => bts('Receive email notification for friend requests?'),
1457 1457
     '#description' => ' ',
1458 1458
     '#options' => array(0 => bts('yes'), -1 => bts('no')),
1459 1459
     '#attributes' => array('class' => 'fancy'),
1460 1460
     '#default_value' => $default['friend_notification']
1461
-  );
1461
+    );
1462 1462
   
1463
-  // Internationalization options
1464
-  if (module_exists('internationalization')) {
1463
+    // Internationalization options
1464
+    if (module_exists('internationalization')) {
1465 1465
     $languages = language_list('enabled');
1466 1466
     $languages = $languages[1];
1467 1467
     $names = array();
1468 1468
     foreach ($languages as $langcode => $item) {
1469
-      $name = t($item->name);
1470
-      $names[check_plain($langcode)] = check_plain($name . ($item->native != $name ? ' ('. $item->native .')' : ''));
1469
+        $name = t($item->name);
1470
+        $names[check_plain($langcode)] = check_plain($name . ($item->native != $name ? ' ('. $item->native .')' : ''));
1471 1471
     }
1472 1472
     $form['locale'] = array(
1473
-      '#type' => 'fieldset',
1474
-      '#title' => bts('Language settings'),
1475
-      '#weight' => 10,
1476
-      '#collapsible' => TRUE,
1477
-      '#collapsed' => FALSE,
1473
+        '#type' => 'fieldset',
1474
+        '#title' => bts('Language settings'),
1475
+        '#weight' => 10,
1476
+        '#collapsible' => TRUE,
1477
+        '#collapsed' => FALSE,
1478 1478
     );
1479 1479
 
1480 1480
     // Get language negotiation settings.
1481 1481
     $mode = variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE);
1482 1482
     $user_preferred_language = user_preferred_language($account);
1483 1483
     $form['locale']['language'] = array(
1484
-      '#type' => 'select',
1485
-      '#title' => bts('Language'),
1486
-      '#default_value' => check_plain($user_preferred_language->language),
1487
-      '#options' => $names,
1488
-      '#description' => ($mode == LANGUAGE_NEGOTIATION_PATH) ? bts("This account's default language for e-mails and preferred language for site presentation.") : bts("This account's default language for e-mails."),
1484
+        '#type' => 'select',
1485
+        '#title' => bts('Language'),
1486
+        '#default_value' => check_plain($user_preferred_language->language),
1487
+        '#options' => $names,
1488
+        '#description' => ($mode == LANGUAGE_NEGOTIATION_PATH) ? bts("This account's default language for e-mails and preferred language for site presentation.") : bts("This account's default language for e-mails."),
1489 1489
     );
1490
-  }
1490
+    }
1491 1491
   
1492
-  // Avatar options
1493
-  $form['gravatar'] = array(
1492
+    // Avatar options
1493
+    $form['gravatar'] = array(
1494 1494
     '#type' => 'item',
1495 1495
     '#value' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, it will be used for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail)),
1496 1496
     '#description' => bts('Your Gravatar will not be shown if you upload a user picture.'),
1497
-  );
1498
-  if (user_access('disable own gravatar', $account)) {
1497
+    );
1498
+    if (user_access('disable own gravatar', $account)) {
1499 1499
     $form['gravatar'] = array(
1500
-      '#type' => 'checkbox',
1501
-      '#title' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, use it for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail)),
1502
-      '#description' => bts('Gravatar will not be shown if an avatar is uploaded.'),
1503
-      '#default_value' => isset($account->gravatar) ? $account->gravatar : 0,
1504
-      '#disabled' => !empty($account->picture),
1505
-    );
1506
-  }
1507
-  $form['gravatar']['#weight'] = 15;
1508
-  $form['gravatar']['#prefix'] = '<fieldset class="collapsible"><legend><a href="#">' . bts('Avatar settings') . '</a></legend>';
1509
-  // Upload an avatar (pulled from profile_node_form):
1510
-  if (!empty($profile_form['field_image'])) {
1500
+        '#type' => 'checkbox',
1501
+        '#title' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, use it for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail)),
1502
+        '#description' => bts('Gravatar will not be shown if an avatar is uploaded.'),
1503
+        '#default_value' => isset($account->gravatar) ? $account->gravatar : 0,
1504
+        '#disabled' => !empty($account->picture),
1505
+    );
1506
+    }
1507
+    $form['gravatar']['#weight'] = 15;
1508
+    $form['gravatar']['#prefix'] = '<fieldset class="collapsible"><legend><a href="#">' . bts('Avatar settings') . '</a></legend>';
1509
+    // Upload an avatar (pulled from profile_node_form):
1510
+    if (!empty($profile_form['field_image'])) {
1511 1511
     $form['field_image'] = $profile_form['field_image'];
1512
-  }
1513
-  else {
1512
+    }
1513
+    else {
1514 1514
     $form['field_image'] = array(
1515
-      '#value' => '<div class="form-item">'
1515
+        '#value' => '<div class="form-item">'
1516 1516
         . '<label class="placeholder">'
1517 1517
         . bts('This is not available until your profile is set up.')
1518 1518
         . '</label>'
1519 1519
         . l(bts('Create a profile'), 'account/profile/edit', array('attributes' => array('class' => 'form-link')))
1520 1520
         . '</div>',
1521 1521
     );
1522
-  }
1523
-  $form['field_image'][0]['#title'] = bts('Upload an avatar');
1524
-  $form['field_image']['#weight'] = 20;
1525
-  $form['field_image']['#suffix'] = '</fieldset>';
1522
+    }
1523
+    $form['field_image'][0]['#title'] = bts('Upload an avatar');
1524
+    $form['field_image']['#weight'] = 20;
1525
+    $form['field_image']['#suffix'] = '</fieldset>';
1526 1526
   
1527
-  // Forum options
1528
-  $form['forums'] = array(
1527
+    // Forum options
1528
+    $form['forums'] = array(
1529 1529
     '#type' => 'fieldset',
1530 1530
     '#title' => bts('Forum settings'),
1531 1531
     '#weight' => 25,
1532 1532
     '#collapsible' => TRUE,
1533 1533
     '#collapsed' => FALSE
1534
-  );
1535
-  $form['forums']['comments_per_page'] = array(
1534
+    );
1535
+    $form['forums']['comments_per_page'] = array(
1536 1536
     '#type' => 'select',
1537 1537
     '#title' => bts('In discussion topics, show at most @comments_per_page', array('@comments_per_page' => '')),
1538 1538
     '#options' => array(10 => 10, 20 => 20, 30 => 30, 50 => 50, 100 => 100),
1539 1539
     '#default_value' => $default['comments_per_page']
1540
-  );
1541
-  // Can't have a typical Drupal form suffix on a select box?
1542
-  $form['forums']['comments_per_page_suffix'] = array(
1540
+    );
1541
+    // Can't have a typical Drupal form suffix on a select box?
1542
+    $form['forums']['comments_per_page_suffix'] = array(
1543 1543
     '#value' => '<span>' . bts('comments per page') . '</span>'
1544
-  );
1545
-  $form['forums']['comments_order'] = array(
1544
+    );
1545
+    $form['forums']['comments_order'] = array(
1546 1546
     '#type' => 'select',
1547 1547
     '#title' => bts('Sort comments in discussions'),
1548 1548
     '#options' => array(1 => bts('Newest post first'), 2 => bts('Oldest post first')),
1549 1549
     '#default_value' => $default['comments_order']
1550
-  );
1551
-  // Signature (pulled from user_edit_form):
1552
-  if (variable_get('user_signatures', 0) && module_exists('comment')) {
1550
+    );
1551
+    // Signature (pulled from user_edit_form):
1552
+    if (variable_get('user_signatures', 0) && module_exists('comment')) {
1553 1553
     $form['forums']['signature'] = array(
1554
-      '#type' => 'textarea',
1555
-      '#title' => bts('Signature'),
1556
-      '#description' => bts('Your signature will be publicly displayed at the end of your comments.'),
1557
-      '#default_value' => $account->signature
1558
-      );
1554
+        '#type' => 'textarea',
1555
+        '#title' => bts('Signature'),
1556
+        '#description' => bts('Your signature will be publicly displayed at the end of your comments.'),
1557
+        '#default_value' => $account->signature
1558
+        );
1559 1559
     // Prevent a "validation error" message when the user attempts to save with a default value they
1560 1560
     // do not have access to.
1561 1561
     if (!filter_access($account->signature_format) && empty($_POST)) {
1562
-      drupal_set_message(t("The signature input format has been set to a format you don't have access to. It will be changed to a format you have access to when you save this page."));
1563
-      $edit['signature_format'] = FILTER_FORMAT_DEFAULT;
1562
+        drupal_set_message(t("The signature input format has been set to a format you don't have access to. It will be changed to a format you have access to when you save this page."));
1563
+        $edit['signature_format'] = FILTER_FORMAT_DEFAULT;
1564 1564
     }
1565 1565
     $form['forums']['signature_format'] = filter_form($account->signature_format, NULL, array('signature_format'));
1566 1566
     // Optionally hide signatures from comments
1567 1567
     $form['forums']['hide_signatures'] = array(
1568
-      '#type' => 'radios',
1569
-      '#title' => bts('Hide signatures in forums'),
1570
-      '#description' => ' ',
1571
-      '#options' => $form['boolean_options']['#value'],
1572
-      '#attributes' => array('class' => 'fancy'),
1573
-      '#default_value' => isset($account->hide_signatures) ? $account->hide_signatures : 0,
1574
-    );
1575
-  }
1568
+        '#type' => 'radios',
1569
+        '#title' => bts('Hide signatures in forums'),
1570
+        '#description' => ' ',
1571
+        '#options' => $form['boolean_options']['#value'],
1572
+        '#attributes' => array('class' => 'fancy'),
1573
+        '#default_value' => isset($account->hide_signatures) ? $account->hide_signatures : 0,
1574
+    );
1575
+    }
1576 1576
 
1577
-  //Ignored users list
1578
-  if (module_exists('ignore_user')) {
1577
+    //Ignored users list
1578
+    if (module_exists('ignore_user')) {
1579 1579
     $form['forums']['ignored_users'] = array(
1580
-      '#value' => '<div class="form-item">'
1580
+        '#value' => '<div class="form-item">'
1581 1581
         . '<label>'
1582
-	. bts('Ignore Users in forums:')
1583
-	. '</label>'
1582
+    . bts('Ignore Users in forums:')
1583
+    . '</label>'
1584 1584
         . bts('<a href="@ignore-user-list">View/Edit</a> your ignored users list.',
1585
-	  array(
1586
-	    '@ignore-user-list' => url('ignore_user/list'),
1587
-	    array('attributes' => array('class' => 'form-link'))
1588
-	  )
1589
-	)
1590
-	. '</div>',
1591
-    );
1592
-  }//endif module_exists('ignore_user')
1585
+        array(
1586
+        '@ignore-user-list' => url('ignore_user/list'),
1587
+        array('attributes' => array('class' => 'form-link'))
1588
+        )
1589
+    )
1590
+    . '</div>',
1591
+    );
1592
+    }//endif module_exists('ignore_user')
1593 1593
 
1594
-  //Bottom separator
1595
-  $form['separator_bottom'] = array(
1594
+    //Bottom separator
1595
+    $form['separator_bottom'] = array(
1596 1596
     '#value' => '<div class="separator buttons"></div>',
1597 1597
     '#weight' => 999,
1598
-  );
1598
+    );
1599 1599
   
1600
-  // Form control
1601
-  $form['form control tabs prefix'] = array(
1600
+    // Form control
1601
+    $form['form control tabs prefix'] = array(
1602 1602
     '#value' => '<ul class="form-control tab-list">',
1603 1603
     '#weight' => 1001,
1604
-  );
1605
-  $form['submit'] = array(
1604
+    );
1605
+    $form['submit'] = array(
1606 1606
     '#prefix' => '<li class="first tab">',
1607 1607
     '#type' => 'submit',
1608 1608
     '#value' => bts('Save changes'),
1609 1609
     '#suffix' => '</li>',
1610 1610
     '#weight' => 1002,
1611
-  );
1612
-  $form['form control tabs'] = array(
1611
+    );
1612
+    $form['form control tabs'] = array(
1613 1613
     '#value' => '<li class="tab">' . l(bts('Cancel'), $_GET['q']) . '</li>',
1614 1614
     '#weight' => 1003,
1615
-  );
1616
-  $form['form control tabs suffix'] = array(
1615
+    );
1616
+    $form['form control tabs suffix'] = array(
1617 1617
     '#value' => '</ul>',
1618 1618
     '#weight' => 1004,
1619
-  );
1620
-  return $form;
1619
+    );
1620
+    return $form;
1621 1621
 }
1622 1622
 
1623 1623
 /**
1624
-  * Handle post-validation submission of community preferences form.
1625
-  */
1624
+ * Handle post-validation submission of community preferences form.
1625
+ */
1626 1626
 function communityprefs_form_submit($form, &$form_state) {
1627
-  require_boinc('boinc_db');
1628
-  global $user;
1629
-  $account = user_load($user->uid);
1630
-  $boinc_user = BoincUser::lookup_id($account->boincuser_id);
1631
-  $edit = $form_state['values'];
1632
-  $profile_node = $form_state['storage']['profile_node'];
1633
-  
1634
-  // Display name
1635
-  if ($edit['boincuser_name'] != $boinc_user->name) {
1627
+    require_boinc('boinc_db');
1628
+    global $user;
1629
+    $account = user_load($user->uid);
1630
+    $boinc_user = BoincUser::lookup_id($account->boincuser_id);
1631
+    $edit = $form_state['values'];
1632
+    $profile_node = $form_state['storage']['profile_node'];
1633
+  
1634
+    // Display name
1635
+    if ($edit['boincuser_name'] != $boinc_user->name) {
1636 1636
     $boincuser_name = $edit['boincuser_name'];
1637 1637
     $result = $boinc_user->update(
1638 1638
         "name='{$boincuser_name}'"
1639 1639
     );
1640
-  }
1640
+    }
1641 1641
   
1642
-  // Private message settings
1643
-  pm_email_notify_user('submit', $edit, $user);
1642
+    // Private message settings
1643
+    pm_email_notify_user('submit', $edit, $user);
1644 1644
   
1645
-  // Avatar settings
1646
-  if (!$edit['field_image']) $edit['field_image'] = array();
1647
-  $profile_node->field_image = $edit['field_image'];
1648
-  node_save($profile_node);
1649
-  // Flush this from the node cache or changes won't show up immediately!
1650
-  $profile_node = node_load($profile_node->nid, NULL, TRUE);
1645
+    // Avatar settings
1646
+    if (!$edit['field_image']) $edit['field_image'] = array();
1647
+    $profile_node->field_image = $edit['field_image'];
1648
+    node_save($profile_node);
1649
+    // Flush this from the node cache or changes won't show up immediately!
1650
+    $profile_node = node_load($profile_node->nid, NULL, TRUE);
1651 1651
   
1652
-  // All other settings
1653
-  $settings = array(
1652
+    // All other settings
1653
+    $settings = array(
1654 1654
     'signature' => $edit['signature'],
1655 1655
     'signature_format' => $edit['signature_format'],
1656 1656
     'timezone' => $edit['timezone'],
@@ -1659,134 +1659,134 @@  discard block
 block discarded – undo
1659 1659
     'hide_signatures' => $edit['hide_signatures'],
1660 1660
     'sort' => $edit['comments_order'],
1661 1661
     'gravatar' => $edit['gravatar'],
1662
-  );
1663
-  if (module_exists('internationalization')) {
1662
+    );
1663
+    if (module_exists('internationalization')) {
1664 1664
     $settings['language'] = $edit['language'];
1665 1665
     global $language;
1666 1666
     if ($user->language != $edit['language']) {
1667
-      global $base_url;
1668
-      if ($edit['language'] != language_default('language')) {
1667
+        global $base_url;
1668
+        if ($edit['language'] != language_default('language')) {
1669 1669
         $form_state['redirect'] = $base_url . '/' . $edit['language'] . '/' . $_GET['q'];
1670
-      }
1671
-      else {
1670
+        }
1671
+        else {
1672 1672
         $form_state['redirect'] = $base_url . '/' . $_GET['q'];
1673
-      }
1673
+        }
1674
+    }
1674 1675
     }
1675
-  }
1676
-  user_save($user, $settings);
1676
+    user_save($user, $settings);
1677 1677
   
1678
-  drupal_set_message(bts('Your community preferences have been updated.'));
1678
+    drupal_set_message(bts('Your community preferences have been updated.'));
1679 1679
   
1680
-  // Form will not redirect if storage is set; not good if language changes
1681
-  unset($form_state['storage']);
1680
+    // Form will not redirect if storage is set; not good if language changes
1681
+    unset($form_state['storage']);
1682 1682
 }
1683 1683
 
1684 1684
 /**
1685 1685
  * The structure of the privacy preferences form
1686 1686
  */
1687 1687
 function boincwork_privacyprefs_form(&$form_state) {
1688
-  require_boinc(array('user', 'prefs', 'util'));
1688
+    require_boinc(array('user', 'prefs', 'util'));
1689 1689
   
1690
-  global $user;
1691
-  $account = user_load($user->uid);
1692
-  $boincuser = BoincUser::lookup_id($account->boincuser_id);
1690
+    global $user;
1691
+    $account = user_load($user->uid);
1692
+    $boincuser = BoincUser::lookup_id($account->boincuser_id);
1693 1693
   
1694
-  // Load preferences from BOINC account
1695
-  $prefs = boincwork_load_prefs('project');
1694
+    // Load preferences from BOINC account
1695
+    $prefs = boincwork_load_prefs('project');
1696 1696
   
1697
-  //if (!$prefs AND !$initialize_if_empty) return null;
1697
+    //if (!$prefs AND !$initialize_if_empty) return null;
1698 1698
   
1699
-  // Define form defaults
1700
-  $default = array(
1699
+    // Define form defaults
1700
+    $default = array(
1701 1701
     'privacy' => array(
1702
-      'send_email' => ($boincuser->send_email) ? 1 : 0,
1703
-      'show_hosts' => ($boincuser->show_hosts) ? 1 : 0
1702
+        'send_email' => ($boincuser->send_email) ? 1 : 0,
1703
+        'show_hosts' => ($boincuser->show_hosts) ? 1 : 0
1704 1704
     )
1705
-  );
1705
+    );
1706 1706
   
1707
-  // Standard option sets
1708
-  $form['boolean_options'] = array(
1707
+    // Standard option sets
1708
+    $form['boolean_options'] = array(
1709 1709
     '#type' => 'value',
1710 1710
     '#value' => array(1 => bts('yes'), 0 => bts('no'))
1711
-  );
1711
+    );
1712 1712
   
1713
-  $form['privacy'] = array(
1713
+    $form['privacy'] = array(
1714 1714
     '#title' => bts('Privacy settings'),
1715 1715
     '#type' => 'fieldset',
1716 1716
     '#description' => null,
1717 1717
     '#collapsible' => TRUE,
1718 1718
     '#collapsed' => FALSE
1719
-  );
1720
-  $form['privacy']['send_email'] = array(
1719
+    );
1720
+    $form['privacy']['send_email'] = array(
1721 1721
     '#title' => bts('Is it OK for @project and your team (if any) to email you?', array('@project' => variable_get('site_name', 'BOINC'))),
1722 1722
     '#type' => 'radios',
1723 1723
     '#options' => $form['boolean_options']['#value'],
1724 1724
     '#attributes' => array('class' => 'fancy'),
1725 1725
     '#default_value' => $default['privacy']['send_email']
1726
-  );
1727
-  $form['privacy']['show_hosts'] = array(
1726
+    );
1727
+    $form['privacy']['show_hosts'] = array(
1728 1728
     '#title' => bts('Should @project show your computers on its web site?', array('@project' => variable_get('site_name', 'BOINC'))),
1729 1729
     '#type' => 'radios',
1730 1730
     '#options' => $form['boolean_options']['#value'],
1731 1731
     '#attributes' => array('class' => 'fancy'),
1732 1732
     '#default_value' => $default['privacy']['show_hosts']
1733
-  );
1733
+    );
1734 1734
   
1735
-  $form['prefs']['separator_bottom'] = array(
1735
+    $form['prefs']['separator_bottom'] = array(
1736 1736
     '#value' => '<div class="separator buttons"></div>'
1737
-  );
1737
+    );
1738 1738
   
1739
-  // Form control
1740
-  $form['prefs']['form control tabs prefix'] = array(
1739
+    // Form control
1740
+    $form['prefs']['form control tabs prefix'] = array(
1741 1741
     '#value' => '<ul class="form-control tab-list">'
1742
-  );
1743
-  $form['prefs']['submit'] = array(
1742
+    );
1743
+    $form['prefs']['submit'] = array(
1744 1744
     '#prefix' => '<li class="first tab">',
1745 1745
     '#type' => 'submit',
1746 1746
     '#value' => bts('Save changes'),
1747 1747
     '#suffix' => '</li>'
1748
-  );
1749
-  $form['prefs']['form control tabs'] = array(
1748
+    );
1749
+    $form['prefs']['form control tabs'] = array(
1750 1750
     '#value' => '<li class="tab">' . l(bts('Cancel'), $_GET['q']) . '</li>'
1751
-  );
1752
-  $form['prefs']['form control tabs suffix'] = array(
1751
+    );
1752
+    $form['prefs']['form control tabs suffix'] = array(
1753 1753
     '#value' => '</ul>'
1754
-  );
1754
+    );
1755 1755
   
1756
-  return $form;
1756
+    return $form;
1757 1757
 }
1758 1758
 
1759 1759
 /**
1760
-  * Validate the privacy preferences form.
1761
-  */
1760
+ * Validate the privacy preferences form.
1761
+ */
1762 1762
 function boincwork_privacyprefs_form_validate($form, &$form_state) {
1763
-  require_boinc('util');
1763
+    require_boinc('util');
1764 1764
   
1765
-  // Verify all non-boolean user input values and notify form API of failures
1766
-  // ... currently there are no non-boolean values!
1765
+    // Verify all non-boolean user input values and notify form API of failures
1766
+    // ... currently there are no non-boolean values!
1767 1767
 }
1768 1768
 
1769 1769
 /**
1770
-  * Handle post-validation submission of privacy preferences form.
1771
-  */
1770
+ * Handle post-validation submission of privacy preferences form.
1771
+ */
1772 1772
 function boincwork_privacyprefs_form_submit($form, &$form_state) {
1773
-  require_boinc(array('user', 'prefs'));
1773
+    require_boinc(array('user', 'prefs'));
1774 1774
   
1775
-  global $user;
1776
-  $account = user_load($user->uid);
1775
+    global $user;
1776
+    $account = user_load($user->uid);
1777 1777
   
1778
-  // Load BOINC account
1779
-  $boincuser = BoincUser::lookup_id($account->boincuser_id);
1778
+    // Load BOINC account
1779
+    $boincuser = BoincUser::lookup_id($account->boincuser_id);
1780 1780
   
1781
-  // Privacy preferences
1782
-  $boincuser->send_email = ($form_state['values']['send_email']) ? true : false;
1783
-  $boincuser->show_hosts = ($form_state['values']['show_hosts']) ? true : false;
1781
+    // Privacy preferences
1782
+    $boincuser->send_email = ($form_state['values']['send_email']) ? true : false;
1783
+    $boincuser->show_hosts = ($form_state['values']['show_hosts']) ? true : false;
1784 1784
   
1785
-  //project_prefs_update($boincuser, $main_prefs);
1785
+    //project_prefs_update($boincuser, $main_prefs);
1786 1786
   
1787
-  db_set_active('boinc');
1788
-  db_query("UPDATE user SET send_email = '{$boincuser->send_email}', show_hosts = '{$boincuser->show_hosts}' WHERE id = '{$boincuser->id}'");
1789
-  db_set_active('default');
1787
+    db_set_active('boinc');
1788
+    db_query("UPDATE user SET send_email = '{$boincuser->send_email}', show_hosts = '{$boincuser->show_hosts}' WHERE id = '{$boincuser->id}'");
1789
+    db_set_active('default');
1790 1790
   
1791
-  drupal_set_message(t('Your privacy preferences have been updated.'));
1791
+    drupal_set_message(t('Your privacy preferences have been updated.'));
1792 1792
 }
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boincwork/includes/boincwork.helpers.inc 1 patch
Indentation   +603 added lines, -603 removed lines patch added patch discarded remove patch
@@ -11,19 +11,19 @@  discard block
 block discarded – undo
11 11
  * that was selected
12 12
  */
13 13
 function boincwork_ahah_helper_venue_submit($form, &$form_state) {
14
-  $form_state['storage']['prefs']['preset'] = null;
15
-  ahah_helper_generic_submit($form, $form_state);
14
+    $form_state['storage']['prefs']['preset'] = null;
15
+    ahah_helper_generic_submit($form, $form_state);
16 16
 }
17 17
 
18 18
 /**
19 19
  * Get a predetermined set of preferences
20 20
  */
21 21
 function boincwork_get_preset_prefs($preset = null) {
22
-  $saved_state = variable_get('boincwork_preset_prefs', null);
22
+    $saved_state = variable_get('boincwork_preset_prefs', null);
23 23
   
24
-  // If not configured yet, use these values as for inital
25
-  // computing/general preferences.
26
-  if (!$saved_state) {
24
+    // If not configured yet, use these values as for inital
25
+    // computing/general preferences.
26
+    if (!$saved_state) {
27 27
     // Get BOINC project disk space configurations from config.xml to
28 28
     // fill in initial preference values.
29 29
     require_boinc(array('db', 'prefs'));
@@ -160,88 +160,88 @@  discard block
 block discarded – undo
160 160
           <dont_verify_images>0</dont_verify_images>
161 161
         </preset>
162 162
       </general_preferences>';
163
-  }
163
+    }
164 164
   
165
-  // Convert XML data to array format
166
-  $preset_prefs = load_configuration($saved_state);
165
+    // Convert XML data to array format
166
+    $preset_prefs = load_configuration($saved_state);
167 167
   
168
-  if ($preset) {
168
+    if ($preset) {
169 169
     // Load preset from configuration
170 170
     $preset_prefs = (array) $preset_prefs['general_preferences'];
171 171
     if (isset($preset_prefs['preset'])) {
172
-      if (!is_numeric(key($preset_prefs['preset']))) {
172
+        if (!is_numeric(key($preset_prefs['preset']))) {
173 173
         $preset_prefs['preset'] = array($preset_prefs['preset']);
174
-      }
175
-      foreach ($preset_prefs['preset'] as $key => $prefs) {
174
+        }
175
+        foreach ($preset_prefs['preset'] as $key => $prefs) {
176 176
         if (isset($prefs['@attributes']['name']) AND $prefs['@attributes']['name'] == $preset) {
177
-          return $preset_prefs['preset'][$key];
177
+            return $preset_prefs['preset'][$key];
178
+        }
178 179
         }
179
-      }
180 180
     }
181
-  }
182
-  return $preset_prefs;
181
+    }
182
+    return $preset_prefs;
183 183
 }
184 184
 
185 185
 /**
186 186
  * Load (and validate) the project specific configuration XML
187 187
  */
188 188
 function boincwork_get_project_specific_config() {
189
-  $raw_config_data = variable_get('boinc_project_specific_prefs_config', '');
189
+    $raw_config_data = variable_get('boinc_project_specific_prefs_config', '');
190 190
   
191
-  $xsd = './' . drupal_get_path('module', 'boincwork') . '/includes/projectprefs.xsd';
192
-  libxml_use_internal_errors(true);
191
+    $xsd = './' . drupal_get_path('module', 'boincwork') . '/includes/projectprefs.xsd';
192
+    libxml_use_internal_errors(true);
193 193
   
194
-  $xml = new DomDocument();
195
-  $xml->loadXML($raw_config_data, LIBXML_NOBLANKS);
196
-  if (!$xml->schemaValidate($xsd)) {
194
+    $xml = new DomDocument();
195
+    $xml->loadXML($raw_config_data, LIBXML_NOBLANKS);
196
+    if (!$xml->schemaValidate($xsd)) {
197 197
     $errors = libxml_get_errors();
198 198
     $lines = explode("\r", $raw_config_data);
199 199
     drupal_set_message("{$errors[0]->message} at line {$errors[0]->line}" .
200
-      ': <br/>' . htmlentities($lines[$errors[0]->line - 1]), 'error');
200
+        ': <br/>' . htmlentities($lines[$errors[0]->line - 1]), 'error');
201 201
     return NULL;
202
-  }
202
+    }
203 203
   
204
-  // Convert XML to array for validation
205
-  $xml = load_configuration($raw_config_data);
206
-  return $xml;
204
+    // Convert XML to array for validation
205
+    $xml = load_configuration($raw_config_data);
206
+    return $xml;
207 207
 }
208 208
 
209 209
 /**
210 210
  * Get rules by which to validate project specific data
211 211
  */
212 212
 function boincwork_get_project_specific_config_validation_rules($xml = array()) {
213
-  $rules = array();
214
-  if (!$xml) {
213
+    $rules = array();
214
+    if (!$xml) {
215 215
     // Read the config XML
216 216
     $xml = boincwork_get_project_specific_config();
217 217
     $xml = $xml['project_specific_preferences'];
218
-  }
219
-  foreach ($xml as $type => $elements) {
218
+    }
219
+    foreach ($xml as $type => $elements) {
220 220
     if (is_array($elements) AND !is_numeric(key($elements))) {
221
-      $elements = array($elements);
221
+        $elements = array($elements);
222 222
     }
223 223
     switch ($type) {
224 224
     case 'compound':
225 225
       foreach ($elements as $element) {
226 226
         $name = $element['@attributes']['name'];
227 227
         $rules[$name] = boincwork_get_project_specific_config_validation_rules($element['attributes']);
228
-      }
229
-      break;
228
+        }
229
+        break;
230 230
       
231 231
     case 'text':
232 232
       foreach ($elements as $element) {
233 233
         $name = $element['@attributes']['name'];
234 234
         $rules[$name] = array(
235
-          'datatype' => $element['@attributes']['datatype']
235
+            'datatype' => $element['@attributes']['datatype']
236 236
         );
237 237
         if (isset($element['@attributes']['min'])) {
238
-          $rules[$name]['min'] = $element['@attributes']['min'];
238
+            $rules[$name]['min'] = $element['@attributes']['min'];
239 239
         }
240 240
         if (isset($element['@attributes']['max'])) {
241
-          $rules[$name]['max'] = $element['@attributes']['max'];
241
+            $rules[$name]['max'] = $element['@attributes']['max'];
242 242
         }
243
-      }
244
-      break;
243
+        }
244
+        break;
245 245
     /*
246 246
     case 'radio':
247 247
     case 'dropdown':
@@ -265,24 +265,24 @@  discard block
 block discarded – undo
265 265
       $rules['apps'] = array(
266 266
         'minimum selected' => 1,
267 267
         'list' => array()
268
-      );
269
-      foreach ($elements as $element) {
268
+        );
269
+        foreach ($elements as $element) {
270 270
         foreach ($element['app'] as $app) {
271
-          $name = "app_{$app['@attributes']['id']}";
272
-          $rules['apps']['list'][] = $name;
273
-          //$rules[$name] = array(
274
-          //  'options' => $options
275
-          //);
271
+            $name = "app_{$app['@attributes']['id']}";
272
+            $rules['apps']['list'][] = $name;
273
+            //$rules[$name] = array(
274
+            //  'options' => $options
275
+            //);
276 276
         }
277
-      }
278
-      break;
277
+        }
278
+        break;
279 279
       
280 280
     case 'group':
281 281
       foreach ($elements as $element) {
282 282
         $name = $element['@attributes']['name'];
283 283
         $rules += boincwork_get_project_specific_config_validation_rules($element);
284
-      }
285
-      break;
284
+        }
285
+        break;
286 286
     /*
287 287
     case 'boolean':
288 288
       // Shouldn't need to validate boolean...
@@ -290,39 +290,39 @@  discard block
 block discarded – undo
290 290
       */
291 291
     default:
292 292
     }
293
-  }
294
-  return $rules;
293
+    }
294
+    return $rules;
295 295
 }
296 296
 
297 297
 /**
298 298
  * Define how project specific settings should be saved
299 299
  */
300 300
 function boincwork_format_project_specific_prefs_data($values, $xml = array()) {
301
-  $defaults = array();
302
-  if (!$xml) {
301
+    $defaults = array();
302
+    if (!$xml) {
303 303
     // Read the config XML
304 304
     $xml = boincwork_get_project_specific_config();
305 305
     $xml = $xml['project_specific_preferences'];
306
-  }
307
-  foreach ($xml as $type => $elements) {
306
+    }
307
+    foreach ($xml as $type => $elements) {
308 308
     $structure_data = array();
309 309
     if (is_array($elements) AND !is_numeric(key($elements))) {
310
-      $elements = array($elements);
310
+        $elements = array($elements);
311 311
     }
312 312
     switch ($type) {
313 313
     case 'compound':
314 314
       foreach ($elements as $element) {
315 315
         $name = $element['@attributes']['name'];
316 316
         $default[$name]['@attributes'] = boincwork_format_project_specific_prefs_data($values[$name], $element['attributes']);
317
-      }
318
-      $defaults += $default;
319
-      break;
317
+        }
318
+        $defaults += $default;
319
+        break;
320 320
       
321 321
     case 'group':
322 322
       foreach ($elements as $element) {
323 323
         $defaults += boincwork_format_project_specific_prefs_data($values, $element);
324
-      }
325
-      break;
324
+        }
325
+        break;
326 326
       
327 327
     case 'text':
328 328
     case 'radio':
@@ -331,315 +331,315 @@  discard block
 block discarded – undo
331 331
       foreach ($elements as $element) {
332 332
         $name = $element['@attributes']['name'];
333 333
         if (isset($element['@attributes']['entitytype']) AND $element['@attributes']['entitytype'] == 'attribute') {
334
-          $defaults['@attributes'][$name] = $values[$name];
334
+            $defaults['@attributes'][$name] = $values[$name];
335 335
         }
336 336
         else {
337
-          $defaults[$name] = $values[$name];
337
+            $defaults[$name] = $values[$name];
338 338
         }
339
-      }
340
-      break;
339
+        }
340
+        break;
341 341
     
342 342
     case 'apps':
343 343
       foreach ($elements as $element) {
344 344
         $defaults['app_id'] = array();
345 345
         foreach ($element['app'] as $app) {
346
-          $app_id = $app['@attributes']['id'];
347
-          if ($values['applications']["app_{$app_id}"]) {
346
+            $app_id = $app['@attributes']['id'];
347
+            if ($values['applications']["app_{$app_id}"]) {
348 348
             $defaults['app_id'][] = $app_id;
349
-          }
349
+            }
350 350
         }
351
-      }
352
-      break;
351
+        }
352
+        break;
353 353
       
354 354
     default:
355 355
     }
356
-  }
357
-  return $defaults;
356
+    }
357
+    return $defaults;
358 358
 }
359 359
 
360 360
 /**
361 361
  * Add an element to the form based on its definition
362 362
  */
363 363
 function boincwork_generate_prefs_element(&$form, $type, $elements, $user_prefs = null) {
364
-  switch ($type) {
365
-  case 'text':
364
+    switch ($type) {
365
+    case 'text':
366 366
     if (!is_numeric(key($elements))) {
367
-      $elements = array($elements);
367
+        $elements = array($elements);
368 368
     }
369 369
     foreach ($elements as $element) {
370
-      $name = $element['@attributes']['name'];
371
-      $default = $element['@attributes']['default'];
372
-      $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
373
-      $description = '';
374
-      if (isset($element['description'])) {
370
+        $name = $element['@attributes']['name'];
371
+        $default = $element['@attributes']['default'];
372
+        $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
373
+        $description = '';
374
+        if (isset($element['description'])) {
375 375
         $description = is_array($element['description']) ? $element['description']['@value'] : $element['description'];
376
-      }
376
+        }
377 377
       
378
-      $value = $default;
379
-      $user_pref = $user_prefs;
380
-      $entitytype = isset($element['@attributes']['entitytype']) ? $element['@attributes']['entitytype'] : 'element';
381
-      if ($entitytype == 'attribute') {
378
+        $value = $default;
379
+        $user_pref = $user_prefs;
380
+        $entitytype = isset($element['@attributes']['entitytype']) ? $element['@attributes']['entitytype'] : 'element';
381
+        if ($entitytype == 'attribute') {
382 382
         $user_pref = $user_prefs['@attributes'];
383
-      }
384
-      if (isset($user_pref[$name])) {
383
+        }
384
+        if (isset($user_pref[$name])) {
385 385
         if (is_array($user_pref[$name]) AND isset($user_pref[$name]['@value'])) {
386
-          $value = $user_pref[$name]['@value'];
386
+            $value = $user_pref[$name]['@value'];
387 387
         }
388 388
         else {
389
-          $value = $user_pref[$name];
389
+            $value = $user_pref[$name];
390
+        }
390 391
         }
391
-      }
392 392
       
393
-      // Use appropriate datatype
394
-      if (isset($element['@attributes']['datatype'])) {
393
+        // Use appropriate datatype
394
+        if (isset($element['@attributes']['datatype'])) {
395 395
         switch($element['@attributes']['datatype']) {
396 396
         case 'integer':
397 397
           $value = (int) $value;
398
-          break;
398
+            break;
399 399
           
400 400
         case 'float':
401 401
           $value = number_format((float) $value, 2);
402
-          break;
402
+            break;
403 403
         
404 404
         default:
405 405
         }
406
-      }
406
+        }
407 407
       
408
-      // Translate elements as appropriate
409
-      if ($title) {
408
+        // Translate elements as appropriate
409
+        if ($title) {
410 410
         i18nstrings_update('project:prefs_xml', $title);
411 411
         $title = i18nstrings('project:prefs_xml', $title);
412
-      }
413
-      if ($description) {
412
+        }
413
+        if ($description) {
414 414
         i18nstrings_update('project:prefs_xml', $description);
415 415
         $description = i18nstrings('project:prefs_xml', $description);
416
-      }
416
+        }
417 417
       
418
-      $form[$name] = array(
418
+        $form[$name] = array(
419 419
         '#title' => $title,
420 420
         '#type' => 'textfield',
421 421
         '#default_value' => $value,
422 422
         '#size' => 5,
423 423
         '#description' => $description . bts(' Default value: @default', array('@default' => $default))
424
-      );
424
+        );
425 425
     }
426 426
     break;
427 427
     
428
-  case 'boolean':
428
+    case 'boolean':
429 429
     if (!is_numeric(key($elements))) {
430
-      $elements = array($elements);
430
+        $elements = array($elements);
431 431
     }
432 432
     foreach ($elements as $element) {
433
-      $name = $element['@attributes']['name'];
434
-      $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
435
-      $default = (isset($element['@attributes']['selected']) AND $element['@attributes']['selected'] == 'true') ? 1 : 0;
436
-      $description = '';
437
-      if (isset($element['description'])) {
433
+        $name = $element['@attributes']['name'];
434
+        $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
435
+        $default = (isset($element['@attributes']['selected']) AND $element['@attributes']['selected'] == 'true') ? 1 : 0;
436
+        $description = '';
437
+        if (isset($element['description'])) {
438 438
         $description = is_array($element['description']) ? $element['description']['@value'] : $element['description'];
439
-      }
439
+        }
440 440
       
441
-      $value = $default;
442
-      $user_pref = $user_prefs;
443
-      $entitytype = isset($element['@attributes']['entitytype']) ? $element['@attributes']['entitytype'] : 'element';
444
-      if ($entitytype == 'attribute') {
441
+        $value = $default;
442
+        $user_pref = $user_prefs;
443
+        $entitytype = isset($element['@attributes']['entitytype']) ? $element['@attributes']['entitytype'] : 'element';
444
+        if ($entitytype == 'attribute') {
445 445
         $user_pref = $user_prefs['@attributes'];
446
-      }
447
-      if (isset($user_pref[$name])) {
446
+        }
447
+        if (isset($user_pref[$name])) {
448 448
         if (is_array($user_pref[$name]) AND isset($user_pref[$name]['@value'])) {
449
-          $value = $user_pref[$name]['@value'];
449
+            $value = $user_pref[$name]['@value'];
450 450
         }
451 451
         else {
452
-          $value = $user_pref[$name];
452
+            $value = $user_pref[$name];
453
+        }
453 454
         }
454
-      }
455 455
       
456
-      // Translate elements as appropriate
457
-      if ($title) {
456
+        // Translate elements as appropriate
457
+        if ($title) {
458 458
         i18nstrings_update('project:prefs_xml', $title);
459 459
         $title = i18nstrings('project:prefs_xml', $title);
460
-      }
461
-      if ($description) {
460
+        }
461
+        if ($description) {
462 462
         i18nstrings_update('project:prefs_xml', $description);
463 463
         $description = i18nstrings('project:prefs_xml', $description);
464
-      }
464
+        }
465 465
       
466
-      $form[$name] = array(
466
+        $form[$name] = array(
467 467
         '#title' => $title,
468 468
         '#type' => 'radios',
469 469
         '#options' => array(1 => bts('yes'), 0 => bts('no')),
470 470
         '#attributes' => array('class' => 'fancy'),
471 471
         '#default_value' => $value,
472 472
         '#description' => $description
473
-      );
473
+        );
474 474
     }
475 475
     break;
476 476
     
477
-  case 'radio':
477
+    case 'radio':
478 478
   case 'dropdown':
479 479
     
480 480
     if (!is_numeric(key($elements))) {
481
-      $elements = array($elements);
481
+        $elements = array($elements);
482 482
     }
483 483
     foreach ($elements as $element) {
484
-      $name = $element['@attributes']['name'];
485
-      $default = null;
486
-      $options = array();
487
-      foreach($element['items']['item'] as $item) {
484
+        $name = $element['@attributes']['name'];
485
+        $default = null;
486
+        $options = array();
487
+        foreach($element['items']['item'] as $item) {
488 488
         if (is_array($item)) {
489
-          $value = $item['@value'];
490
-          if ($default === NULL AND
489
+            $value = $item['@value'];
490
+            if ($default === NULL AND
491 491
               isset($item['@attributes']) AND
492 492
               isset($item['@attributes']['selected'])) {
493 493
             $default = ($item['@attributes']['selected'] == 'true') ? $item['@value'] : null;
494
-          }
494
+            }
495 495
         }
496 496
         else {
497
-          $value = $item;
497
+            $value = $item;
498 498
         }
499 499
         $options[$value] = $value;
500
-      }
501
-      $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
502
-      $description = '';
503
-      if (isset($element['description'])) {
500
+        }
501
+        $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
502
+        $description = '';
503
+        if (isset($element['description'])) {
504 504
         $description = is_array($element['description']) ? $element['description']['@value'] : $element['description'];
505
-      }
506
-      $user_pref = $user_prefs;
507
-      $entitytype = isset($element['@attributes']['entitytype']) ? $element['@attributes']['entitytype'] : 'element';
508
-      if ($entitytype == 'attribute') {
505
+        }
506
+        $user_pref = $user_prefs;
507
+        $entitytype = isset($element['@attributes']['entitytype']) ? $element['@attributes']['entitytype'] : 'element';
508
+        if ($entitytype == 'attribute') {
509 509
         $user_pref = $user_prefs['@attributes'];
510
-      }
511
-      $value = isset($user_pref[$name]) ? $user_pref[$name] : $default;
510
+        }
511
+        $value = isset($user_pref[$name]) ? $user_pref[$name] : $default;
512 512
       
513
-      // Translate elements as appropriate
514
-      if ($title) {
513
+        // Translate elements as appropriate
514
+        if ($title) {
515 515
         i18nstrings_update('project:prefs_xml', $title);
516 516
         $title = i18nstrings('project:prefs_xml', $title);
517
-      }
518
-      if ($description) {
517
+        }
518
+        if ($description) {
519 519
         i18nstrings_update('project:prefs_xml', $description);
520 520
         $description = i18nstrings('project:prefs_xml', $description);
521
-      }
521
+        }
522 522
       
523
-      $form[$name] = array(
523
+        $form[$name] = array(
524 524
         '#title' => $title,
525 525
         '#type' => ($type == 'radio') ? 'radios' : 'select',
526 526
         '#options' => $options,
527 527
         '#attributes' => array('class' => 'fancy'),
528 528
         '#default_value' => $value,
529 529
         '#description' => $description . bts(' Default value: @default', array('@default' =>$default))
530
-      );
530
+        );
531 531
     }
532 532
     break;
533 533
     
534
-  case 'apps':
534
+    case 'apps':
535 535
     $title = is_array($elements['title']) ? $elements['title']['@value'] : $elements['title'];
536 536
     
537
-      // Translate elements as appropriate
538
-      if ($title) {
537
+        // Translate elements as appropriate
538
+        if ($title) {
539 539
         i18nstrings_update('project:prefs_xml', $title);
540 540
         $title = i18nstrings('project:prefs_xml', $title);
541
-      }
541
+        }
542 542
     
543 543
     $form['applications'] = array(
544
-      '#title' => bts('Applications'),
545
-      '#type' => 'fieldset',
546
-      '#description' => $title,
547
-      '#collapsible' => TRUE,
548
-      '#collapsed' => FALSE
544
+        '#title' => bts('Applications'),
545
+        '#type' => 'fieldset',
546
+        '#description' => $title,
547
+        '#collapsible' => TRUE,
548
+        '#collapsed' => FALSE
549 549
     );
550 550
     $applications = array();
551 551
     if (!is_array($user_prefs['app_id'])) {
552
-      $user_prefs['app_id'] = array($user_prefs['app_id']);
552
+        $user_prefs['app_id'] = array($user_prefs['app_id']);
553 553
     }
554 554
     foreach ($user_prefs['app_id'] as $app) {
555
-      if (!$app) continue;
556
-      if (is_array($app) AND isset($app['@value'])) {
555
+        if (!$app) continue;
556
+        if (is_array($app) AND isset($app['@value'])) {
557 557
         $app = $app['@value'];
558
-      }
559
-      $applications[] = $app;
558
+        }
559
+        $applications[] = $app;
560 560
     }
561 561
     foreach ($elements['app'] as $app) {
562
-      $app_id = $app['@attributes']['id'];
563
-      $app_name = $app['@value'];
564
-      $app_enabled = TRUE;
565
-      if (isset($app['@attributes']['enabled']) AND
562
+        $app_id = $app['@attributes']['id'];
563
+        $app_name = $app['@value'];
564
+        $app_enabled = TRUE;
565
+        if (isset($app['@attributes']['enabled']) AND
566 566
           $app['@attributes']['enabled'] == 'false') {
567 567
         $app_enabled = FALSE;
568
-      }
569
-      if ($applications) {
568
+        }
569
+        if ($applications) {
570 570
         $checked = in_array($app_id, $applications);
571
-      } else {
571
+        } else {
572 572
         $checked = TRUE;
573 573
         if (isset($app['@attributes']['selected']) AND
574 574
             $app['@attributes']['selected'] == 'false') {
575
-          $checked = FALSE;
575
+            $checked = FALSE;
576 576
         }
577
-      }
578
-      $form['applications']["app_{$app_id}"] = array(
577
+        }
578
+        $form['applications']["app_{$app_id}"] = array(
579 579
         '#title' => $app_name,
580 580
         '#type' => 'checkbox',
581 581
         '#default_value' => ($checked) ? 'x' : false,
582 582
         '#disabled' => !$app_enabled
583
-      );
583
+        );
584 584
     }
585 585
     
586 586
     break;
587 587
     
588
-  case 'group':
588
+    case 'group':
589 589
     if (!is_numeric(key($elements))) {
590
-      $elements = array($elements);
590
+        $elements = array($elements);
591 591
     }
592 592
     foreach ($elements as $key => $element) {
593
-      $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
594
-      $name = str_replace(' ','_',strtolower($title));
595
-      $name = "group_{$name}";
593
+        $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
594
+        $name = str_replace(' ','_',strtolower($title));
595
+        $name = "group_{$name}";
596 596
       
597
-      // Translate elements as appropriate
598
-      if ($title) {
597
+        // Translate elements as appropriate
598
+        if ($title) {
599 599
         i18nstrings_update('project:prefs_xml', $title);
600 600
         $title = i18nstrings('project:prefs_xml', $title);
601
-      }
601
+        }
602 602
       
603
-      $form[$name] = array(
604
-          '#title' => $title,
605
-          '#type' => 'fieldset',
606
-          '#tree' => FALSE,
607
-          //'#description' => t('Notes about this group of fields'),
608
-          '#collapsible' => TRUE,
609
-          '#collapsed' => FALSE
610
-      );
611
-      // Recursively populate the compound element
612
-      foreach ($element as $child_type => $child) {
603
+        $form[$name] = array(
604
+            '#title' => $title,
605
+            '#type' => 'fieldset',
606
+            '#tree' => FALSE,
607
+            //'#description' => t('Notes about this group of fields'),
608
+            '#collapsible' => TRUE,
609
+            '#collapsed' => FALSE
610
+        );
611
+        // Recursively populate the compound element
612
+        foreach ($element as $child_type => $child) {
613 613
         boincwork_generate_prefs_element($form[$name], $child_type, $child, $user_prefs);
614
-      }
614
+        }
615 615
     }
616 616
     break;
617 617
     
618
-  case 'compound':
618
+    case 'compound':
619 619
     if (!is_numeric(key($elements))) {
620
-      $elements = array($elements);
620
+        $elements = array($elements);
621 621
     }
622 622
     foreach ($elements as $element) {
623
-      $name = $element['@attributes']['name'];
624
-      $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
623
+        $name = $element['@attributes']['name'];
624
+        $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
625 625
       
626
-      // Translate elements as appropriate
627
-      if ($title) {
626
+        // Translate elements as appropriate
627
+        if ($title) {
628 628
         i18nstrings_update('project:prefs_xml', $title);
629 629
         $title = i18nstrings('project:prefs_xml', $title);
630
-      }
630
+        }
631 631
       
632
-      $form[$name] = array(
633
-          '#title' => $title,
634
-          '#type' => 'fieldset',
635
-          //'#description' => t('Notes about this group of fields'),
636
-          '#collapsible' => TRUE,
637
-          '#collapsed' => FALSE
638
-      );
639
-      // Recursively populate the compound element
640
-      foreach ($element['attributes'] as $child_type => $child) {
632
+        $form[$name] = array(
633
+            '#title' => $title,
634
+            '#type' => 'fieldset',
635
+            //'#description' => t('Notes about this group of fields'),
636
+            '#collapsible' => TRUE,
637
+            '#collapsed' => FALSE
638
+        );
639
+        // Recursively populate the compound element
640
+        foreach ($element['attributes'] as $child_type => $child) {
641 641
         boincwork_generate_prefs_element($form[$name], $child_type, $child, $user_prefs[$name]['@attributes']);
642
-      }
642
+        }
643 643
     }
644 644
     break;
645 645
     
@@ -655,24 +655,24 @@  discard block
 block discarded – undo
655 655
  */
656 656
 function boincwork_make_prefs_table($prefs, $top_level = TRUE) {
657 657
 
658
-  $prefs_table = array();
659
-  $uncategorized = array();
658
+    $prefs_table = array();
659
+    $uncategorized = array();
660 660
   
661
-  // Parse the project preferences form
662
-  foreach ($prefs as $key => $element) {
661
+    // Parse the project preferences form
662
+    foreach ($prefs as $key => $element) {
663 663
     
664 664
     // Determine which type of element this is and act accordingly
665 665
     $element_type = NULL;
666 666
     if (is_array($element) AND isset($element['#type'])) {
667
-      $element_type = $element['#type'];
667
+        $element_type = $element['#type'];
668 668
     }
669 669
     switch ($element_type) {
670 670
     case 'fieldset':
671 671
       $prefs_table[$key] = array(
672 672
         'name' => $element['#title'],
673 673
         'elements' => boincwork_make_prefs_table($element, FALSE),
674
-      );
675
-      break;
674
+        );
675
+        break;
676 676
     case 'textfield':
677 677
     case 'radios':
678 678
     case 'checkbox':
@@ -682,45 +682,45 @@  discard block
 block discarded – undo
682 682
         switch ($key) {
683 683
         case 'start_hour':
684 684
           $element['#title'] = bts('Compute only between:');
685
-          break;
685
+            break;
686 686
         case 'net_start_hour':
687 687
           $element['#title'] = bts('Transfer files only between:');
688
-          break;
688
+            break;
689 689
         default:
690 690
         }
691
-      }
692
-      $prefs_element = array(
691
+        }
692
+        $prefs_element = array(
693 693
         'name' => (isset($element['#title'])) ? $element['#title'] : '',
694 694
         'description' => (isset($element['#description'])) ? $element['#description'] : '',
695 695
         'default_value' => (isset($element['#default_value'])) ? $element['#default_value'] : NULL,
696
-      );
697
-      if ($top_level) {
696
+        );
697
+        if ($top_level) {
698 698
         $uncategorized[$key] = $prefs_element;
699
-      }
700
-      else {
699
+        }
700
+        else {
701 701
         $prefs_table[$key] = $prefs_element;
702
-      }
703
-      break;
702
+        }
703
+        break;
704 704
     default:
705 705
     }
706
-  }
706
+    }
707 707
   
708
-  if ($prefs_table AND $uncategorized) {
708
+    if ($prefs_table AND $uncategorized) {
709 709
     // Throw any settings that don't fit elsewhere into "other"
710 710
     $prefs_table['other'] = array(
711
-      'name' => bts('Other settings'),
712
-      'elements' => $uncategorized,
711
+        'name' => bts('Other settings'),
712
+        'elements' => $uncategorized,
713 713
     );
714
-  }
715
-  elseif ($uncategorized) {
714
+    }
715
+    elseif ($uncategorized) {
716 716
     // If nothing is categorized, output all prefs under a general "settings"
717 717
     $prefs_table['settings'] = array(
718
-      'name' => bts('Settings'),
719
-      'elements' => $uncategorized,
718
+        'name' => bts('Settings'),
719
+        'elements' => $uncategorized,
720 720
     );
721
-  }
721
+    }
722 722
   
723
-  return $prefs_table;
723
+    return $prefs_table;
724 724
 }
725 725
  
726 726
 /**
@@ -728,33 +728,33 @@  discard block
 block discarded – undo
728 728
  */
729 729
 function boincwork_load_prefs($type = 'general', $venue = null, $account = null) {
730 730
   
731
-  require_boinc(array('user'));
731
+    require_boinc(array('user'));
732 732
   
733
-  // Load the BOINC user object
734
-  if (!$account) {
733
+    // Load the BOINC user object
734
+    if (!$account) {
735 735
     global $user;
736 736
     $account = $user;
737
-  }
738
-  $account = user_load($account->uid);
739
-  $boincuser = BoincUser::lookup_id($account->boincuser_id);
737
+    }
738
+    $account = user_load($account->uid);
739
+    $boincuser = BoincUser::lookup_id($account->boincuser_id);
740 740
   
741
-  // Load the desired preferences for the user
742
-  $main_prefs = array();
743
-  if ($type == 'project') {
741
+    // Load the desired preferences for the user
742
+    $main_prefs = array();
743
+    if ($type == 'project') {
744 744
     if ($boincuser->project_prefs) {
745
-      $main_prefs = load_configuration($boincuser->project_prefs);
746
-      $main_prefs = (array) $main_prefs['project_preferences'];
745
+        $main_prefs = load_configuration($boincuser->project_prefs);
746
+        $main_prefs = (array) $main_prefs['project_preferences'];
747 747
     }
748
-  }
749
-  else {
748
+    }
749
+    else {
750 750
     if ($boincuser->global_prefs) {
751
-      $main_prefs = load_configuration($boincuser->global_prefs);
752
-      $main_prefs = (array) $main_prefs['global_preferences'];
751
+        $main_prefs = load_configuration($boincuser->global_prefs);
752
+        $main_prefs = (array) $main_prefs['global_preferences'];
753
+    }
753 754
     }
754
-  }
755 755
   
756
-  // Return general preferences or a subset based on venue
757
-  if (!$venue OR $venue == 'generic') {
756
+    // Return general preferences or a subset based on venue
757
+    if (!$venue OR $venue == 'generic') {
758 758
     unset($main_prefs['venue']);
759 759
     // Use the length of the $main_prefs array as a condition as to
760 760
     // whether the preferences have already been set. This is
@@ -762,23 +762,23 @@  discard block
 block discarded – undo
762 762
     if (count($main_prefs) < 3)
763 763
         $main_prefs['@attributes'] = array('cleared' => 1);
764 764
     return $main_prefs;
765
-  }
766
-  else {
765
+    }
766
+    else {
767 767
     if (isset($main_prefs['venue'])) {
768
-      if (!is_numeric(key($main_prefs['venue']))) {
768
+        if (!is_numeric(key($main_prefs['venue']))) {
769 769
         $main_prefs['venue'] = array($main_prefs['venue']);
770
-      }
771
-      foreach ($main_prefs['venue'] as $key => $prefs_venue) {
770
+        }
771
+        foreach ($main_prefs['venue'] as $key => $prefs_venue) {
772 772
         if (isset($prefs_venue['@attributes']['name']) AND $prefs_venue['@attributes']['name'] == $venue) {
773
-          return $main_prefs['venue'][$key];
773
+            return $main_prefs['venue'][$key];
774
+        }
774 775
         }
775
-      }
776 776
     }
777
-  }
777
+    }
778 778
 
779
-  return array(
779
+    return array(
780 780
     '@attributes' => array('name' => $venue, 'cleared' => 1)
781
-  );
781
+    );
782 782
 }
783 783
 
784 784
 /**
@@ -786,99 +786,99 @@  discard block
 block discarded – undo
786 786
  */
787 787
 function boincwork_save_prefs($prefs, $type = 'general', $venue = null, $account = null) {
788 788
   
789
-  require_boinc(array('user'));
789
+    require_boinc(array('user'));
790 790
   
791
-  // Load existing project prefs from the BOINC user object
792
-  if (!$account) {
791
+    // Load existing project prefs from the BOINC user object
792
+    if (!$account) {
793 793
     global $user;
794 794
     $account = $user;
795
-  }
796
-  $account = user_load($account->uid);
797
-  $boincuser = BoincUser::lookup_id($account->boincuser_id);
795
+    }
796
+    $account = user_load($account->uid);
797
+    $boincuser = BoincUser::lookup_id($account->boincuser_id);
798 798
   
799
-  // Load the specified preferences for the user
800
-  $main_prefs = array();
801
-  if ($type == 'project') {
799
+    // Load the specified preferences for the user
800
+    $main_prefs = array();
801
+    if ($type == 'project') {
802 802
     if ($boincuser->project_prefs) {
803
-      $main_prefs = load_configuration($boincuser->project_prefs);
804
-      $main_prefs = (array) $main_prefs['project_preferences'];
803
+        $main_prefs = load_configuration($boincuser->project_prefs);
804
+        $main_prefs = (array) $main_prefs['project_preferences'];
805 805
     }
806
-  }
807
-  else {
806
+    }
807
+    else {
808 808
     if ($boincuser->global_prefs) {
809
-      $main_prefs = load_configuration($boincuser->global_prefs);
810
-      $main_prefs = (array) $main_prefs['global_preferences'];
809
+        $main_prefs = load_configuration($boincuser->global_prefs);
810
+        $main_prefs = (array) $main_prefs['global_preferences'];
811
+    }
811 812
     }
812
-  }
813 813
   
814
-  // Save all preferences or a subset based on venue
815
-  //drupal_set_message('<pre>' . print_r($main_prefs, true) . '</pre>');
816
-  $new_venue = true;
817
-  if (!$venue OR $venue == 'generic') {
814
+    // Save all preferences or a subset based on venue
815
+    //drupal_set_message('<pre>' . print_r($main_prefs, true) . '</pre>');
816
+    $new_venue = true;
817
+    if (!$venue OR $venue == 'generic') {
818 818
     //$main_prefs = $prefs;
819 819
     $main_prefs = $prefs + $main_prefs;
820
-  }
821
-  else {
820
+    }
821
+    else {
822 822
     if (isset($main_prefs['venue'])) {
823
-      if (!is_numeric(key($main_prefs['venue']))) {
823
+        if (!is_numeric(key($main_prefs['venue']))) {
824 824
         $main_prefs['venue'] = array($main_prefs['venue']);
825
-      }
826
-      foreach ($main_prefs['venue'] as $key => $prefs_venue) {
825
+        }
826
+        foreach ($main_prefs['venue'] as $key => $prefs_venue) {
827 827
         if (isset($prefs_venue['@attributes']['name']) AND $prefs_venue['@attributes']['name'] == $venue) {
828
-          if ($prefs) {
828
+            if ($prefs) {
829 829
             $main_prefs['venue'][$key] = $prefs;
830
-          }
831
-          else {
830
+            }
831
+            else {
832 832
             // If prefs is null, clear out this preference set
833 833
             unset($main_prefs['venue'][$key]);
834 834
             if (count($main_prefs['venue']) == 0) {
835
-              // If that was the only preference set configured, unset the
836
-              // venue tag altogether
837
-              unset($main_prefs['venue']);
835
+                // If that was the only preference set configured, unset the
836
+                // venue tag altogether
837
+                unset($main_prefs['venue']);
838 838
             }
839
-          }
840
-          $new_venue = false;
841
-          break;
839
+            }
840
+            $new_venue = false;
841
+            break;
842
+        }
842 843
         }
843
-      }
844 844
     }
845 845
     if ($new_venue) {
846
-      $main_prefs['venue'][] = $prefs;
846
+        $main_prefs['venue'][] = $prefs;
847
+    }
847 848
     }
848
-  }
849 849
   
850
-  // Set modified time
851
-  if ($type == 'general') {
850
+    // Set modified time
851
+    if ($type == 'general') {
852 852
     if (!isset($main_prefs['mod_time'])) {
853
-      $main_prefs = array_merge(array('mod_time' => 0), $main_prefs);
853
+        $main_prefs = array_merge(array('mod_time' => 0), $main_prefs);
854 854
     }
855 855
     $main_prefs['mod_time'] = time();
856 856
     // unset source information, the Client will fill this in again
857 857
     if (isset($main_prefs['source_project'])) {
858
-      unset($main_prefs['source_project']);
858
+        unset($main_prefs['source_project']);
859 859
     }
860 860
     if (isset($main_prefs['source_scheduler'])) {
861
-      unset($main_prefs['source_scheduler']);
861
+        unset($main_prefs['source_scheduler']);
862
+    }
862 863
     }
863
-  }
864 864
   
865
-  // Convert prefs back to XML and save to database
866
-  $result = null;
867
-  if ($type == 'project') {
865
+    // Convert prefs back to XML and save to database
866
+    $result = null;
867
+    if ($type == 'project') {
868 868
     $main_prefs = array('project_preferences' => $main_prefs);
869 869
     $boincuser->project_prefs = save_configuration($main_prefs);
870 870
     db_set_active('boinc');
871 871
     $result = db_query("UPDATE user SET project_prefs = '{$boincuser->project_prefs}' WHERE id = '{$boincuser->id}'");
872 872
     db_set_active('default');
873
-  }
874
-  else {
873
+    }
874
+    else {
875 875
     $main_prefs = array('global_preferences' => $main_prefs);
876 876
     $boincuser->global_prefs = save_configuration($main_prefs);
877 877
     db_set_active('boinc');
878 878
     $result = db_query("UPDATE user SET global_prefs = '{$boincuser->global_prefs}' WHERE id = '{$boincuser->id}'");
879 879
     db_set_active('default');
880
-  }
881
-  return $result;
880
+    }
881
+    return $result;
882 882
 }
883 883
 
884 884
 
@@ -892,94 +892,94 @@  discard block
 block discarded – undo
892 892
  */ 
893 893
 function boincwork_set_default_venue($venue = '') {
894 894
   
895
-  global $user;
896
-  $account = user_load($user->uid);
895
+    global $user;
896
+    $account = user_load($user->uid);
897 897
   
898
-  if ($venue == 'generic') {
898
+    if ($venue == 'generic') {
899 899
     $venue = '';
900
-  }
900
+    }
901 901
   
902
-  db_set_active('boinc');
903
-  db_query("
902
+    db_set_active('boinc');
903
+    db_query("
904 904
     UPDATE user
905 905
     SET venue = '%s'
906 906
     WHERE id = %d",
907 907
     $venue, $account->boincuser_id
908
-  );
909
-  db_set_active('default');
908
+    );
909
+    db_set_active('default');
910 910
 }
911 911
 
912 912
 /**
913 913
  * Recursively validate submitted form values against a set of rules
914 914
  */ 
915 915
 function boincwork_validate_form($validation_rules, $values, $path = array()) {
916
-  foreach ($validation_rules as $field => $rules) {
916
+    foreach ($validation_rules as $field => $rules) {
917 917
     $parents = $path;
918 918
     if (is_array($values[$field])) {
919
-      // Process nested form elements
920
-      $parents[] = $field;
921
-      boincwork_validate_form($rules, $values[$field], $parents);
919
+        // Process nested form elements
920
+        $parents[] = $field;
921
+        boincwork_validate_form($rules, $values[$field], $parents);
922 922
     }
923 923
     else {
924
-      if ($parents) {
924
+        if ($parents) {
925 925
         // form_set_error() identifies nested form elements with '][' as a
926 926
         // delimiter between each parent and child element
927 927
         $parents[] = $field;
928 928
         $form_field = implode('][', $parents);
929
-      }
930
-      else {
929
+        }
930
+        else {
931 931
         $form_field = $field;
932
-      }
933
-      if (isset($rules['datatype']) AND !boincwork_validate_datatype($values[$field], $rules['datatype'])) {
932
+        }
933
+        if (isset($rules['datatype']) AND !boincwork_validate_datatype($values[$field], $rules['datatype'])) {
934 934
         form_set_error($form_field, bts('Invalid data type for @field', array('@field' => $field)));
935
-      }
936
-      if (isset($rules['min']) AND $values[$field] < $rules['min']) {
935
+        }
936
+        if (isset($rules['min']) AND $values[$field] < $rules['min']) {
937 937
         form_set_error($form_field, bts('Minimum value not met for @field', array('@field' => $field)));
938
-      }
939
-      if (isset($rules['max']) AND $values[$field] > $rules['max']) {
938
+        }
939
+        if (isset($rules['max']) AND $values[$field] > $rules['max']) {
940 940
         form_set_error($form_field, bts('Maximum value exceeded for @field', array('@field' => $field)));
941
-      }
941
+        }
942
+    }
942 943
     }
943
-  }
944 944
 }
945 945
 
946 946
 /**
947 947
  * Check that numeric data conforms to specifications
948 948
  */
949 949
 function boincwork_validate_datatype($data, $datatype = NULL) {
950
-  switch ($datatype) {
951
-  case 'float':
950
+    switch ($datatype) {
951
+    case 'float':
952 952
     if (!is_numeric($data)) {
953
-      return FALSE;
953
+        return FALSE;
954 954
     }
955 955
     $data += 0;
956 956
     if (!is_float($data)) {
957
-      return FALSE;
957
+        return FALSE;
958 958
     }
959 959
     break;
960 960
     
961
-  case 'integer':
961
+    case 'integer':
962 962
     if (!is_numeric($data)) {
963
-      return FALSE;
963
+        return FALSE;
964 964
     }
965 965
     $data += 0;
966 966
     if (!is_int($data)) {
967
-      return FALSE;
967
+        return FALSE;
968 968
     }
969 969
     break;
970 970
   
971
-  case 'text':
971
+    case 'text':
972 972
   default:
973 973
     
974 974
   }
975
-  return TRUE;
975
+    return TRUE;
976 976
 }
977 977
 
978 978
 /**
979 979
  * Format a number to be displayed using a maximum number of digits
980 980
  */ 
981 981
 function boincwork_format_stats($number, $max_digits = 4) {
982
-  $suffix = array(
982
+    $suffix = array(
983 983
     0 => '',
984 984
     1 => 'k',
985 985
     2 => 'M',
@@ -989,95 +989,95 @@  discard block
 block discarded – undo
989 989
     6 => 'E',
990 990
     7 => 'Z',
991 991
     8 => 'Y'
992
-  );
993
-  if (!is_numeric($number)) $number = 0;
992
+    );
993
+    if (!is_numeric($number)) $number = 0;
994 994
   
995
-  $digits = floor(log($number, 10)) + 1;
996
-  $magnitude = 0;
997
-  $precision = 0;
998
-  if ($digits > $max_digits) {
995
+    $digits = floor(log($number, 10)) + 1;
996
+    $magnitude = 0;
997
+    $precision = 0;
998
+    if ($digits > $max_digits) {
999 999
     $magnitude = floor(($digits - ($max_digits - 3)) / 3);
1000 1000
     $precision = $max_digits - ($digits - ($magnitude * 3) + 1);
1001 1001
     $number = round($number / pow(1000, $magnitude), $precision);
1002
-  }
1003
-  $number = number_format($number, $precision) . (($magnitude) ? "{$suffix[$magnitude]}" : '');
1002
+    }
1003
+    $number = number_format($number, $precision) . (($magnitude) ? "{$suffix[$magnitude]}" : '');
1004 1004
   
1005
-  return $number;
1005
+    return $number;
1006 1006
 }
1007 1007
 
1008 1008
 
1009
-  //------------------------------------------------------------------------------------------------
1010
-  //  load_configuration(): Convert structured text/xml to array
1011
-  //------------------------------------------------------------------------------------------------
1009
+    //------------------------------------------------------------------------------------------------
1010
+    //  load_configuration(): Convert structured text/xml to array
1011
+    //------------------------------------------------------------------------------------------------
1012 1012
   
1013
-  function load_configuration($text)
1014
-  {
1015
-      if (preg_match('/^\<\?xml .*\?\>$/i', $text)) return null;
1016
-      if ($xml = text_to_xml($text)) return xml_to_array($xml);
1017
-      return false;
1018
-  }
1013
+    function load_configuration($text)
1014
+    {
1015
+        if (preg_match('/^\<\?xml .*\?\>$/i', $text)) return null;
1016
+        if ($xml = text_to_xml($text)) return xml_to_array($xml);
1017
+        return false;
1018
+    }
1019 1019
   
1020
-  //------------------------------------------------------------------------------------------------
1021
-  //  save_configuration(): Convert array to structured text/xml
1022
-  //------------------------------------------------------------------------------------------------
1020
+    //------------------------------------------------------------------------------------------------
1021
+    //  save_configuration(): Convert array to structured text/xml
1022
+    //------------------------------------------------------------------------------------------------
1023 1023
   
1024
-  function save_configuration($array)
1025
-  {
1026
-      if ($xml = array_to_xml($array)) return xml_to_text($xml, false, true);
1027
-      return false;
1028
-  }
1024
+    function save_configuration($array)
1025
+    {
1026
+        if ($xml = array_to_xml($array)) return xml_to_text($xml, false, true);
1027
+        return false;
1028
+    }
1029 1029
   
1030
-  //------------------------------------------------------------------------------------------------
1031
-  //  array_to_xml(): Take a multidimensional array and convert it to a structured
1032
-  //  DOM XML object
1033
-  //------------------------------------------------------------------------------------------------
1030
+    //------------------------------------------------------------------------------------------------
1031
+    //  array_to_xml(): Take a multidimensional array and convert it to a structured
1032
+    //  DOM XML object
1033
+    //------------------------------------------------------------------------------------------------
1034 1034
   
1035
-  function array_to_xml($array, $dom = false, $parent_node = false) {
1035
+    function array_to_xml($array, $dom = false, $parent_node = false) {
1036 1036
     $is_root = false;
1037 1037
     if (!$dom) $dom = new DomDocument('1.0');
1038 1038
     if (!$parent_node) {
1039
-      $parent_node = $dom;
1040
-      $is_root = true;
1039
+        $parent_node = $dom;
1040
+        $is_root = true;
1041 1041
     }
1042 1042
     // Created an intermediate array to attempt to sort by @position
1043 1043
     $ordered_array = array();
1044 1044
     $unordered_array = array();
1045 1045
     foreach ($array as $name => $value) {
1046
-      if ($is_root) {
1046
+        if ($is_root) {
1047 1047
         $unordered_array[] = $array;
1048 1048
         break;
1049
-      }
1050
-      if (is_array($value)) {
1049
+        }
1050
+        if (is_array($value)) {
1051 1051
         if (is_numeric(key($value))) {
1052
-          foreach ($value as $item) {
1052
+            foreach ($value as $item) {
1053 1053
             if (is_array($item) AND isset($item['@position'])) {
1054
-              $ordered_array[$item['@position']] = array(
1054
+                $ordered_array[$item['@position']] = array(
1055 1055
                 $name => $item
1056
-              );
1056
+                );
1057 1057
             }
1058 1058
             else {
1059
-              $unordered_array[] = array(
1059
+                $unordered_array[] = array(
1060 1060
                 $name => $item
1061
-              );
1061
+                );
1062
+            }
1062 1063
             }
1063
-          }
1064 1064
         }
1065 1065
         elseif (isset($value['@position'])) {
1066
-          $ordered_array[$value['@position']] = array(
1066
+            $ordered_array[$value['@position']] = array(
1067 1067
             $name => $value
1068
-          );
1068
+            );
1069 1069
         }
1070 1070
         else {
1071
-          $unordered_array[] = array(
1071
+            $unordered_array[] = array(
1072 1072
             $name => $value
1073
-          );
1073
+            );
1074 1074
         }
1075
-      }
1076
-      else {
1075
+        }
1076
+        else {
1077 1077
         $unordered_array[] = array(
1078
-          $name => $value
1078
+            $name => $value
1079 1079
         );
1080
-      }
1080
+        }
1081 1081
     }
1082 1082
     
1083 1083
     // Now append items without explicit positions at the end
@@ -1085,39 +1085,39 @@  discard block
 block discarded – undo
1085 1085
     
1086 1086
     // Convert to XML...
1087 1087
     foreach ($primed_array as $item) {
1088
-      list($name, $value) = each($item);
1089
-      if (strcmp($name, '@attributes') == 0) {
1088
+        list($name, $value) = each($item);
1089
+        if (strcmp($name, '@attributes') == 0) {
1090 1090
         if (!is_array($value)) continue;
1091 1091
         foreach ($value as $attributeName => $attributeValue) {
1092
-          $parent_node->setAttribute($attributeName, $attributeValue);
1092
+            $parent_node->setAttribute($attributeName, $attributeValue);
1093 1093
         }
1094
-      } elseif (strcmp($name, '@value') == 0) {
1094
+        } elseif (strcmp($name, '@value') == 0) {
1095 1095
         if (isset($value)) $parent_node->nodeValue = $value;
1096
-      } elseif (strcmp($name, '@position') == 0) {
1096
+        } elseif (strcmp($name, '@position') == 0) {
1097 1097
         continue;
1098
-      } else {
1098
+        } else {
1099 1099
         if (is_numeric($name)) {
1100
-          $name = $parent_node->tagName;
1100
+            $name = $parent_node->tagName;
1101 1101
         }
1102 1102
         $current_item = $dom->createElement($name);
1103 1103
         if (is_array($value)) {
1104
-          if (is_numeric(key($value))) {
1104
+            if (is_numeric(key($value))) {
1105 1105
             $current_node = $parent_node->appendChild($current_item);
1106 1106
             $current_node = array_to_xml($value, $dom, $current_node);
1107 1107
             $child_count = $current_node->childNodes->length;
1108 1108
             for ($i = 0; $i < $child_count; $i++) {
1109
-              $parent_node->appendChild($current_node->childNodes->item(0));
1109
+                $parent_node->appendChild($current_node->childNodes->item(0));
1110 1110
             }
1111 1111
             $parent_node->removeChild($current_node);
1112
-          } else {
1112
+            } else {
1113 1113
             $current_node = $dom->appendChild($current_item);
1114 1114
             $parent_node->appendChild(array_to_xml($value, $dom, $current_node));
1115
-          }
1115
+            }
1116 1116
         } else {
1117
-          if (isset($value)) $current_item->nodeValue = $value;
1118
-          $parent_node->appendChild($current_item);
1117
+            if (isset($value)) $current_item->nodeValue = $value;
1118
+            $parent_node->appendChild($current_item);
1119
+        }
1119 1120
         }
1120
-      }
1121 1121
     }
1122 1122
     /*
1123 1123
     foreach ($array as $name => $value) {
@@ -1153,114 +1153,114 @@  discard block
 block discarded – undo
1153 1153
       }
1154 1154
     }*/
1155 1155
     return $parent_node;
1156
-  }
1156
+    }
1157 1157
   
1158
-  //------------------------------------------------------------------------------------------------
1159
-  //  xml_to_text(): Convert an XML DOM object to string format
1160
-  //------------------------------------------------------------------------------------------------
1158
+    //------------------------------------------------------------------------------------------------
1159
+    //  xml_to_text(): Convert an XML DOM object to string format
1160
+    //------------------------------------------------------------------------------------------------
1161 1161
   
1162
-  function xml_to_text($xml, $include_xml_declaration = true, $add_carriage_returns = false)
1163
-  {
1164
-      $xml->formatOutput = true;
1165
-      $text = $xml->saveXML();
1166
-      if (!$include_xml_declaration) {
1162
+    function xml_to_text($xml, $include_xml_declaration = true, $add_carriage_returns = false)
1163
+    {
1164
+        $xml->formatOutput = true;
1165
+        $text = $xml->saveXML();
1166
+        if (!$include_xml_declaration) {
1167 1167
         $text = preg_replace('/<\?xml version=.*\?>\s*/i', '', $text, 1);
1168
-      }
1169
-      if ($add_carriage_returns) {;
1168
+        }
1169
+        if ($add_carriage_returns) {;
1170 1170
         $text = preg_replace('/\n/i', "\r\n", $text);
1171
-      }
1172
-      return trim($text);
1173
-  }
1171
+        }
1172
+        return trim($text);
1173
+    }
1174 1174
   
1175
-  //------------------------------------------------------------------------------------------------
1176
-  //  text_to_xml(): Convert an XML DOM object to string format
1177
-  //------------------------------------------------------------------------------------------------
1175
+    //------------------------------------------------------------------------------------------------
1176
+    //  text_to_xml(): Convert an XML DOM object to string format
1177
+    //------------------------------------------------------------------------------------------------
1178 1178
   
1179
-  function text_to_xml($text) {
1179
+    function text_to_xml($text) {
1180 1180
     $xml = new DomDocument();
1181 1181
     if ( !($xml->loadXML($text)) ) return false;
1182 1182
     return $xml;
1183
-  }
1183
+    }
1184 1184
   
1185 1185
   
1186
-  //------------------------------------------------------------------------------------------------
1187
-  //  xml_to_array(): Convert an XML DOM object to array format
1188
-  //------------------------------------------------------------------------------------------------
1186
+    //------------------------------------------------------------------------------------------------
1187
+    //  xml_to_array(): Convert an XML DOM object to array format
1188
+    //------------------------------------------------------------------------------------------------
1189 1189
   
1190
-  function xml_to_array($xml) {
1191
-      $node = $xml->firstChild; //$xml->first_child();
1192
-      $result = '';
1193
-      $index = 1;
1194
-      $position = 0;
1195
-      while (!is_null($node)) {
1196
-          switch ($node->nodeType) {
1197
-          case XML_TEXT_NODE:
1190
+    function xml_to_array($xml) {
1191
+        $node = $xml->firstChild; //$xml->first_child();
1192
+        $result = '';
1193
+        $index = 1;
1194
+        $position = 0;
1195
+        while (!is_null($node)) {
1196
+            switch ($node->nodeType) {
1197
+            case XML_TEXT_NODE:
1198 1198
               if (trim($node->nodeValue)  != '') $result = $node->nodeValue;
1199
-              break;
1200
-          case XML_ELEMENT_NODE:
1199
+                break;
1200
+            case XML_ELEMENT_NODE:
1201 1201
               $node_name = $node->nodeName;
1202
-              $parent = $node->parentNode;
1203
-              $sibling = $node->nextSibling;
1202
+                $parent = $node->parentNode;
1203
+                $sibling = $node->nextSibling;
1204 1204
               
1205
-              // Determine if this node forms a set with siblings (share a node name)
1206
-              while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->nextSibling;
1207
-              if (!$sibling) {
1208
-                  $sibling = $node->previousSibling;
1209
-                  while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->previousSibling;
1210
-              }
1205
+                // Determine if this node forms a set with siblings (share a node name)
1206
+                while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->nextSibling;
1207
+                if (!$sibling) {
1208
+                    $sibling = $node->previousSibling;
1209
+                    while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->previousSibling;
1210
+                }
1211 1211
               
1212
-              if ($sibling) {
1213
-                  $result[$node_name][$index] = '';
1214
-                  if ($node->childNodes) {
1215
-                      $result[$node_name][$index] = xml_to_array($node) ;
1216
-                  }
1217
-                  if ($node->hasAttributes()) {
1218
-                      $attributes = $node->attributes;
1219
-                      if ($result[$node_name][$index] !== '' AND !is_array($result[$node_name][$index])) {
1220
-                          $result[$node_name][$index] = array('@value' => $result[$node_name][$index]);
1221
-                      }
1222
-                      foreach ($attributes as $key => $attribute) {
1223
-                          $result[$node_name][$index]['@attributes'][$attribute->name] = $attribute->value;
1224
-                      }
1225
-                  }
1226
-                  // Retain the position of the element
1227
-                  if (!is_array($result[$node_name][$index])) {
1212
+                if ($sibling) {
1213
+                    $result[$node_name][$index] = '';
1214
+                    if ($node->childNodes) {
1215
+                        $result[$node_name][$index] = xml_to_array($node) ;
1216
+                    }
1217
+                    if ($node->hasAttributes()) {
1218
+                        $attributes = $node->attributes;
1219
+                        if ($result[$node_name][$index] !== '' AND !is_array($result[$node_name][$index])) {
1220
+                            $result[$node_name][$index] = array('@value' => $result[$node_name][$index]);
1221
+                        }
1222
+                        foreach ($attributes as $key => $attribute) {
1223
+                            $result[$node_name][$index]['@attributes'][$attribute->name] = $attribute->value;
1224
+                        }
1225
+                    }
1226
+                    // Retain the position of the element
1227
+                    if (!is_array($result[$node_name][$index])) {
1228 1228
                     $result[$node_name][$index] = array(
1229
-                      '@value' => $result[$node_name][$index]
1229
+                        '@value' => $result[$node_name][$index]
1230 1230
                     );
1231
-                  }
1232
-                  $result[$node_name][$index]['@position'] = $position;
1233
-                  $position++;
1234
-                  $index++;
1235
-              } else {
1236
-                  $result[$node_name] = '';
1237
-                  if ($node->childNodes) {
1238
-                      $result[$node_name] = xml_to_array($node) ;
1239
-                  }
1240
-                  if ($node->hasAttributes()) {
1241
-                      $attributes = $node->attributes;
1242
-                      if ($result[$node_name] !== '' AND !is_array($result[$node_name])) {
1243
-                          $result[$node_name] = array('@value' => $result[$node_name]);
1244
-                      }
1245
-                      foreach($attributes as $key => $attribute) {
1246
-                          $result[$node_name]['@attributes'][$attribute->name] = $attribute->value;
1247
-                      }
1248
-                  }
1249
-                  // Retain the position of the element
1250
-                  if (!is_array($result[$node_name])) {
1231
+                    }
1232
+                    $result[$node_name][$index]['@position'] = $position;
1233
+                    $position++;
1234
+                    $index++;
1235
+                } else {
1236
+                    $result[$node_name] = '';
1237
+                    if ($node->childNodes) {
1238
+                        $result[$node_name] = xml_to_array($node) ;
1239
+                    }
1240
+                    if ($node->hasAttributes()) {
1241
+                        $attributes = $node->attributes;
1242
+                        if ($result[$node_name] !== '' AND !is_array($result[$node_name])) {
1243
+                            $result[$node_name] = array('@value' => $result[$node_name]);
1244
+                        }
1245
+                        foreach($attributes as $key => $attribute) {
1246
+                            $result[$node_name]['@attributes'][$attribute->name] = $attribute->value;
1247
+                        }
1248
+                    }
1249
+                    // Retain the position of the element
1250
+                    if (!is_array($result[$node_name])) {
1251 1251
                     $result[$node_name] = array(
1252
-                      '@value' => $result[$node_name]
1252
+                        '@value' => $result[$node_name]
1253 1253
                     );
1254
-                  }
1255
-                  $result[$node_name]['@position'] = $position;
1256
-                  $position++;
1257
-              }
1258
-              break;
1259
-          }
1260
-          $node = $node->nextSibling;
1261
-      }
1262
-      return $result;
1263
-  }
1254
+                    }
1255
+                    $result[$node_name]['@position'] = $position;
1256
+                    $position++;
1257
+                }
1258
+                break;
1259
+            }
1260
+            $node = $node->nextSibling;
1261
+        }
1262
+        return $result;
1263
+    }
1264 1264
   
1265 1265
 
1266 1266
 /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
@@ -1268,172 +1268,172 @@  discard block
 block discarded – undo
1268 1268
  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  */
1269 1269
 
1270 1270
 /**
1271
-  * Determine output for host list views when no hosts are found.
1272
-  */
1271
+ * Determine output for host list views when no hosts are found.
1272
+ */
1273 1273
 function boincwork_views_host_list_empty_text($context = NULL) {
1274 1274
   
1275
-  // Pull the BOINC user ID from the view arguments to get show_hosts 
1276
-  // preference for that user
1277
-  require_boinc('boinc_db');
1278
-  $view = views_get_current_view();
1279
-  $account = user_load($view->args[0]);
1280
-  $boincuser = BoincUser::lookup_id($account->boincuser_id);
1275
+    // Pull the BOINC user ID from the view arguments to get show_hosts 
1276
+    // preference for that user
1277
+    require_boinc('boinc_db');
1278
+    $view = views_get_current_view();
1279
+    $account = user_load($view->args[0]);
1280
+    $boincuser = BoincUser::lookup_id($account->boincuser_id);
1281 1281
   
1282
-  // Determine if hosts are associated at all or just hidden
1283
-  $output = '';
1284
-  if ($boincuser->show_hosts) {
1282
+    // Determine if hosts are associated at all or just hidden
1283
+    $output = '';
1284
+    if ($boincuser->show_hosts) {
1285 1285
     switch($context) {
1286 1286
     case 'active':
1287 1287
       $output .=  '<h2>' . bts('No active computers') . '</h2>';
1288
-      $output .=  '<p>' . bts('This user has no computers that have been'
1289
-      . ' active in the last 30 days.') . '</p>';
1290
-      break;
1288
+        $output .=  '<p>' . bts('This user has no computers that have been'
1289
+        . ' active in the last 30 days.') . '</p>';
1290
+        break;
1291 1291
       
1292 1292
     case 'preferences':
1293 1293
       $output .=  '<h2>' . bts('No computers') . '</h2>';
1294
-      $output .=  '<p>' . bts('There are no computers assigned to this'
1295
-      . ' preference set.') . '</p>';
1296
-      break;
1294
+        $output .=  '<p>' . bts('There are no computers assigned to this'
1295
+        . ' preference set.') . '</p>';
1296
+        break;
1297 1297
     
1298 1298
     default:
1299 1299
       $output .=  '<h2>' . bts('Computers pending') . '</h2>';
1300
-      $output .=  '<p>' . bts('This user does not yet have any associated'
1301
-      . ' computers. Computers will be displayed when they have earned their'
1302
-      . ' first credits.') . '</p>';
1300
+        $output .=  '<p>' . bts('This user does not yet have any associated'
1301
+        . ' computers. Computers will be displayed when they have earned their'
1302
+        . ' first credits.') . '</p>';
1303 1303
     }
1304
-  }
1305
-  else {
1304
+    }
1305
+    else {
1306 1306
     $output .=  '<h2>' . bts('Computers hidden') . '</h2>';
1307 1307
     $output .=  '<p>' . bts('This user has chosen not to show information'
1308 1308
     . ' about their computers.') . '</p>';
1309
-  }
1310
-  return $output;
1309
+    }
1310
+    return $output;
1311 1311
 }
1312 1312
 
1313 1313
 /**
1314
-  * Determine output for task list views when no tasks are found.
1315
-  */
1314
+ * Determine output for task list views when no tasks are found.
1315
+ */
1316 1316
 function boincwork_views_task_list_empty_text($context = NULL) {
1317 1317
   
1318
-  // 
1319
-  $output = '';
1320
-  switch($context) {
1321
-  default:
1318
+    // 
1319
+    $output = '';
1320
+    switch($context) {
1321
+    default:
1322 1322
     $output .=  '<h2>' . bts('No @type tasks', array('@type' => $context))
1323 1323
     . '</h2>';
1324 1324
     $output .=  '<p>' . bts('There are no tasks of this type on record')
1325 1325
     . '</p>';
1326
-  }
1327
-  return $output;
1326
+    }
1327
+    return $output;
1328 1328
 }
1329 1329
 
1330 1330
 /**
1331
-  * Output links to perform host actions
1332
-  */
1331
+ * Output links to perform host actions
1332
+ */
1333 1333
 function boincwork_host_action_links($host_id) {
1334
-  $output = '';
1335
-  if (boincwork_host_user_is_owner($host_id)) {
1334
+    $output = '';
1335
+    if (boincwork_host_user_is_owner($host_id)) {
1336 1336
     // Show merge hosts option
1337 1337
     $output = '<ul class="tab-list"><li class="first tab">';
1338 1338
     $output .= l(bts('Merge'), "host/{$host_id}/merge");
1339 1339
     $output .= '</li>';
1340 1340
     // If host has no tasks, allow the host to be deleted
1341 1341
     if (!boincwork_host_get_task_count($host_id)) {
1342
-      $output .= '<li class="tab">';
1343
-      $output .= l(bts('Delete'), "host/{$host_id}/delete",
1342
+        $output .= '<li class="tab">';
1343
+        $output .= l(bts('Delete'), "host/{$host_id}/delete",
1344 1344
         array(
1345
-          'attributes' => array(
1345
+            'attributes' => array(
1346 1346
             'onclick' => 'return confirm(\'' . bts('This will delete host @id'
1347
-              . ' from your account forever. Are you sure this is OK?',
1348
-              array('@id' => $host_id)
1347
+                . ' from your account forever. Are you sure this is OK?',
1348
+                array('@id' => $host_id)
1349 1349
             ) . '\')'
1350
-          )
1350
+            )
1351 1351
         )
1352
-      );
1353
-      $output .= '</li>';
1352
+        );
1353
+        $output .= '</li>';
1354 1354
     }
1355 1355
     $output .= '</ul>';
1356
-  }
1357
-  return $output;
1356
+    }
1357
+    return $output;
1358 1358
 }
1359 1359
 
1360 1360
 /**
1361 1361
  * Get details for a given host
1362 1362
  */
1363 1363
 function boincwork_host_get_info($host_id) {
1364
-  db_set_active('boinc');
1365
-  $host = db_fetch_object(db_query(
1364
+    db_set_active('boinc');
1365
+    $host = db_fetch_object(db_query(
1366 1366
     "SELECT * FROM {host} WHERE id = '%d'",
1367 1367
     $host_id
1368
-  ));
1369
-  db_set_active('default');
1370
-  return $host;
1368
+    ));
1369
+    db_set_active('default');
1370
+    return $host;
1371 1371
 }
1372 1372
 
1373 1373
 /**
1374 1374
  * Get the number of tasks associated with a given host
1375 1375
  */
1376 1376
 function boincwork_host_get_task_count($host_id) {
1377
-  db_set_active('boinc');
1378
-  $count = db_result(db_query(
1377
+    db_set_active('boinc');
1378
+    $count = db_result(db_query(
1379 1379
     "SELECT COUNT(*) FROM {result} WHERE hostid = '%d'",
1380 1380
     $host_id
1381
-  ));
1382
-  db_set_active('default');
1383
-  return $count;
1381
+    ));
1382
+    db_set_active('default');
1383
+    return $count;
1384 1384
 }
1385 1385
 
1386 1386
 /**
1387 1387
  * Check whether a user is the owner of a host
1388 1388
  */
1389 1389
 function boincwork_host_user_is_owner($host_id, $uid = NULL) {
1390
-  if (!$uid) {
1390
+    if (!$uid) {
1391 1391
     global $user;
1392 1392
     $uid = $user->uid;
1393
-  }
1394
-  $account = user_load($uid);
1395
-  // Get host owner
1396
-  db_set_active('boinc');
1397
-  $owner = db_result(db_query(
1393
+    }
1394
+    $account = user_load($uid);
1395
+    // Get host owner
1396
+    db_set_active('boinc');
1397
+    $owner = db_result(db_query(
1398 1398
     "SELECT userid FROM {host} WHERE id = '%d'",
1399 1399
     $host_id
1400
-  ));
1401
-  db_set_active('default');
1402
-  return ($account->boincuser_id === $owner);
1400
+    ));
1401
+    db_set_active('default');
1402
+    return ($account->boincuser_id === $owner);
1403 1403
 }
1404 1404
 
1405 1405
 /**
1406
-  * Determine output for host last contact time
1407
-  */
1406
+ * Determine output for host last contact time
1407
+ */
1408 1408
 function boincwork_host_last_contact($timestamp, $host_id = NULL, $context = NULL) {
1409
-  $output = '---';
1410
-  $root_log_dir = variable_get('boinc_host_sched_logs_dir', '');
1411
-  $log = '';
1412
-  if ($timestamp) {
1409
+    $output = '---';
1410
+    $root_log_dir = variable_get('boinc_host_sched_logs_dir', '');
1411
+    $log = '';
1412
+    if ($timestamp) {
1413 1413
     $output = gmdate('j M Y | G:i:s', $timestamp) . ' UTC';
1414
-  }
1415
-  if ($root_log_dir AND $host_id) {
1414
+    }
1415
+    if ($root_log_dir AND $host_id) {
1416 1416
     $subdir = substr($host_id, 0, -3) OR $subdir = 0;
1417 1417
     $log = implode('/', array($root_log_dir, $subdir, $host_id));
1418
-  }
1419
-  if ($log AND file_exists($log)) {
1418
+    }
1419
+    if ($log AND file_exists($log)) {
1420 1420
     $output = l($output, "host/{$host_id}/log");
1421
-  }
1422
-  return $output;
1421
+    }
1422
+    return $output;
1423 1423
 }
1424 1424
 
1425 1425
 /**
1426 1426
  * 
1427 1427
  */
1428 1428
 function boincwork_host_venue_selector($host_id) {
1429
-  $output = '';
1430
-  if (function_exists('jump_quickly')) {
1429
+    $output = '';
1430
+    if (function_exists('jump_quickly')) {
1431 1431
     $path = "host/{$host_id}/set-venue";
1432 1432
     $venues = array(
1433
-      "{$path}/generic" => bts('Generic'),
1434
-      "{$path}/home" => bts('Home'),
1435
-      "{$path}/work" => bts('Work'),
1436
-      "{$path}/school" => bts('School')
1433
+        "{$path}/generic" => bts('Generic'),
1434
+        "{$path}/home" => bts('Home'),
1435
+        "{$path}/work" => bts('Work'),
1436
+        "{$path}/school" => bts('School')
1437 1437
     );
1438 1438
     variable_set('jump_use_js_venues-Array', 1);
1439 1439
     drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js');
@@ -1441,32 +1441,32 @@  discard block
 block discarded – undo
1441 1441
     // Get current venue
1442 1442
     db_set_active('boinc');
1443 1443
     $venue = db_result(db_query(
1444
-      "SELECT venue FROM {host} WHERE id = '%d'",
1445
-      $host_id
1444
+        "SELECT venue FROM {host} WHERE id = '%d'",
1445
+        $host_id
1446 1446
     ));
1447 1447
     db_set_active('default');
1448 1448
     $output .= jump_quickly($venues, 'venues', 1, "{$path}/{$venue}");
1449
-  }
1450
-  return $output;
1449
+    }
1450
+    return $output;
1451 1451
 }
1452 1452
 
1453 1453
 /**
1454
-  * Determine output for task reported time / deadline
1455
-  */
1454
+ * Determine output for task reported time / deadline
1455
+ */
1456 1456
 function boincwork_task_time_reported($received_time = NULL, $deadline = NULL, $context = NULL) {
1457
-  $output = '---';
1458
-  if ($received_time OR $deadline) {
1457
+    $output = '---';
1458
+    if ($received_time OR $deadline) {
1459 1459
     $timestamp = ($received_time) ? $received_time : $deadline;
1460 1460
     $output = gmdate('j M Y, G:i:s', $timestamp) . ' UTC';
1461 1461
     // Add a wrapper to deadline text
1462 1462
     if (!$received_time) {
1463
-      if (time() < $deadline) {
1463
+        if (time() < $deadline) {
1464 1464
         $output = '<span class="on-time">' . $output . '</span>';
1465
-      }
1466
-      else {
1465
+        }
1466
+        else {
1467 1467
         $output = '<span class="past-due">' . $output . '</span>';
1468
-      }
1468
+        }
1469 1469
     }
1470
-  }
1471
-  return $output;
1470
+    }
1471
+    return $output;
1472 1472
 }
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boincwork/boincwork.admin.inc 1 patch
Indentation   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -10,80 +10,80 @@  discard block
 block discarded – undo
10 10
  * Allow configuration of general options for preference pages
11 11
  */
12 12
 function boincwork_admin_prefs_options_form(&$form_state) {
13
-  $form = array(); 
14
-  $form['beta'] = array(
13
+    $form = array(); 
14
+    $form['beta'] = array(
15 15
     '#type' => 'checkbox',
16 16
     '#title' => t('Allow users to opt in to test beta applications'),
17 17
     '#default_value' => variable_get('boinc_prefs_options_beta', 0),
18 18
     '#required' => TRUE
19
-  );
20
-  $form['submit'] = array(
19
+    );
20
+    $form['submit'] = array(
21 21
     '#type' => 'submit',
22 22
     '#value' => t('Submit')
23
-  );
24
-  // Add the official mechanical things and return
25
-  //drupal_prepare_form('boincwork_admin_prefs_upload_form', $form, $form_state);
26
-  return $form;
23
+    );
24
+    // Add the official mechanical things and return
25
+    //drupal_prepare_form('boincwork_admin_prefs_upload_form', $form, $form_state);
26
+    return $form;
27 27
 } 
28 28
 
29 29
 /**
30
-  * Handle validation of preference general settings form.
31
-  */
30
+ * Handle validation of preference general settings form.
31
+ */
32 32
 function boincwork_admin_prefs_options_form_validate($form, &$form_state) {
33 33
 }
34 34
 
35 35
 /**
36
-  * Handle submission of preference general settings form.
37
-  */
36
+ * Handle submission of preference general settings form.
37
+ */
38 38
 function boincwork_admin_prefs_options_form_submit($form, &$form_state) {
39
-  variable_set('boinc_prefs_options_beta', $form_state['values']['beta']);
40
-  drupal_set_message('Preference options have been updated.');
39
+    variable_set('boinc_prefs_options_beta', $form_state['values']['beta']);
40
+    drupal_set_message('Preference options have been updated.');
41 41
 }
42 42
 
43 43
 /**
44 44
  * 
45 45
  */
46 46
 function boincwork_admin_prefs_upload_form(&$form_state) {
47
-  $form = array(); 
48
-  $form['prefs_xml'] = array(
47
+    $form = array(); 
48
+    $form['prefs_xml'] = array(
49 49
     '#type' => 'textarea',
50 50
     '#title' => t('Project specific preferences XML'),
51 51
     '#default_value' => variable_get('boinc_project_specific_prefs_config', "<project_specific_preferences>\n\n</project_specific_preferences>"),
52 52
     '#required' => TRUE
53
-  );
54
-  $form['submit'] = array(
53
+    );
54
+    $form['submit'] = array(
55 55
     '#type' => 'submit',
56 56
     '#value' => t('Submit')
57
-  );
58
-  // Add the official mechanical things and return
59
-  //drupal_prepare_form('boincwork_admin_prefs_upload_form', $form, $form_state);
60
-  return $form;
57
+    );
58
+    // Add the official mechanical things and return
59
+    //drupal_prepare_form('boincwork_admin_prefs_upload_form', $form, $form_state);
60
+    return $form;
61 61
 } 
62 62
 
63 63
 /**
64
-  * Handle validation of preference upload form.
65
-  */
64
+ * Handle validation of preference upload form.
65
+ */
66 66
 function boincwork_admin_prefs_upload_form_validate($form, &$form_state) {
67 67
   
68
-  $xsd = './' . drupal_get_path('module', 'boincwork') . '/includes/projectprefs.xsd';
69
-  libxml_use_internal_errors(true);
70
-  $xml = new DomDocument();
71
-  $xml->loadXML($form_state['values']['prefs_xml'], LIBXML_NOBLANKS);
72
-  if (!$xml->schemaValidate($xsd)) {
68
+    $xsd = './' . drupal_get_path('module', 'boincwork') . '/includes/projectprefs.xsd';
69
+    libxml_use_internal_errors(true);
70
+    $xml = new DomDocument();
71
+    $xml->loadXML($form_state['values']['prefs_xml'], LIBXML_NOBLANKS);
72
+    if (!$xml->schemaValidate($xsd)) {
73 73
     $errors = libxml_get_errors();
74 74
     $lines = explode("\r", $form_state['values']['prefs_xml']);
75 75
     drupal_set_message("{$errors[0]->message} at line {$errors[0]->line}" .
76
-      ': <br/>' . htmlentities($lines[$errors[0]->line - 1]), 'error');
76
+        ': <br/>' . htmlentities($lines[$errors[0]->line - 1]), 'error');
77 77
     form_set_error('upload', t('XML file failed validation'));
78
-  }
78
+    }
79 79
 }
80 80
 
81 81
 /**
82
-  * Handle submission of preference upload form.
83
-  */
82
+ * Handle submission of preference upload form.
83
+ */
84 84
 function boincwork_admin_prefs_upload_form_submit($form, &$form_state) {
85
-  variable_set('boinc_project_specific_prefs_config', $form_state['values']['prefs_xml']);
86
-  drupal_set_message('The XML has been validated and any changes to
85
+    variable_set('boinc_project_specific_prefs_config', $form_state['values']['prefs_xml']);
86
+    drupal_set_message('The XML has been validated and any changes to
87 87
       preferences are now in place.');
88 88
 }
89 89
 
@@ -91,14 +91,14 @@  discard block
 block discarded – undo
91 91
  * 
92 92
  */
93 93
 function boincwork_admin_prefs_presets_page($preset = 'standard') {
94
-  // Configure preference presets
95
-  if (function_exists('jump_quickly')) {
94
+    // Configure preference presets
95
+    if (function_exists('jump_quickly')) {
96 96
     $path = 'admin/boinc/prefs/presets';
97 97
     $preset_options = array(
98
-      "{$path}/standard" => t('Standard'),
99
-      "{$path}/maximum" => t('Maximum'),
100
-      "{$path}/green" => t('Green'),
101
-      "{$path}/minimum" => t('Minimum')
98
+        "{$path}/standard" => t('Standard'),
99
+        "{$path}/maximum" => t('Maximum'),
100
+        "{$path}/green" => t('Green'),
101
+        "{$path}/minimum" => t('Minimum')
102 102
     );
103 103
     variable_set('jump_use_js_presets-Array', 1);
104 104
     drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js');
@@ -106,15 +106,15 @@  discard block
 block discarded – undo
106 106
     $output .= '<label>Preset:</label>';
107 107
     $output .= jump_quickly($preset_options, 'presets');
108 108
     $output .= '</div></div>';
109
-  }
110
-  $output .= drupal_get_form('boincwork_admin_prefs_presets_form', $preset);
109
+    }
110
+    $output .= drupal_get_form('boincwork_admin_prefs_presets_form', $preset);
111 111
 
112
-  $output .= '<div>';
113
-  $output .= bts('Usage: \'Save configuration\' will save the above preferences into the drupal database. These will be the preset computing (global) preferences that will fill in the preferences form once a user loads the Account Preferences page.');
114
-  $output .= '<p>';
115
-  $output .= bts('\'Save configuration with disk usage settings from config.xml\' will save the above preferences into the drupal database, but also load disk usage settings from the BOINC project\'s config.xml file. These will overwrite any disk usage settings you have placed above. Caution: A user\'s personal preferences will not change if you load the disk usage settings from config.xml here into the drupal database. They must change their preference settings manually.');
116
-  $output .= '</div>';
117
-  return $output;
112
+    $output .= '<div>';
113
+    $output .= bts('Usage: \'Save configuration\' will save the above preferences into the drupal database. These will be the preset computing (global) preferences that will fill in the preferences form once a user loads the Account Preferences page.');
114
+    $output .= '<p>';
115
+    $output .= bts('\'Save configuration with disk usage settings from config.xml\' will save the above preferences into the drupal database, but also load disk usage settings from the BOINC project\'s config.xml file. These will overwrite any disk usage settings you have placed above. Caution: A user\'s personal preferences will not change if you load the disk usage settings from config.xml here into the drupal database. They must change their preference settings manually.');
116
+    $output .= '</div>';
117
+    return $output;
118 118
 }
119 119
 
120 120
 /**
@@ -122,141 +122,141 @@  discard block
 block discarded – undo
122 122
  */
123 123
 function boincwork_admin_prefs_presets_form(&$form_state, $preset = 'standard') {
124 124
 
125
-  // Check database for preset prefs
126
-  if (!variable_get('boincwork_preset_prefs', null))
125
+    // Check database for preset prefs
126
+    if (!variable_get('boincwork_preset_prefs', null))
127 127
     drupal_set_message(bts('No presets found in database, loading a default set of preferences for each preset. These will be saved to the database once you click \'Save configuration\'.'), 'status');
128 128
 
129
-  // Load a copy of the general prefs form
130
-  $form = boincwork_generalprefs_form($form_state, NULL, $preset);
131
-  if ($key = array_search('boincwork_generalprefs_form_submit', $form['#submit'])) {
129
+    // Load a copy of the general prefs form
130
+    $form = boincwork_generalprefs_form($form_state, NULL, $preset);
131
+    if ($key = array_search('boincwork_generalprefs_form_submit', $form['#submit'])) {
132 132
     unset($form['#submit'][$key]);
133
-  }
134
-  $form['#submit'][] = 'boincwork_admin_prefs_presets_form_submit';
133
+    }
134
+    $form['#submit'][] = 'boincwork_admin_prefs_presets_form_submit';
135 135
   
136
-  // Just keep the necessary items
137
-  $form['processor'] = $form['prefs']['advanced']['processor'];
138
-  $form['storage'] = $form['prefs']['advanced']['storage'];
139
-  $form['network'] = $form['prefs']['advanced']['network'];
140
-  unset($form['prefs']);
136
+    // Just keep the necessary items
137
+    $form['processor'] = $form['prefs']['advanced']['processor'];
138
+    $form['storage'] = $form['prefs']['advanced']['storage'];
139
+    $form['network'] = $form['prefs']['advanced']['network'];
140
+    unset($form['prefs']);
141 141
   
142
-  // Tweak some things so it behaves a little better
143
-  $form['#tree'] = TRUE;
144
-  $form['processor']['#collapsible'] = TRUE;
145
-  $form['storage']['#collapsible'] = TRUE;
146
-  $form['network']['#collapsible'] = TRUE;
142
+    // Tweak some things so it behaves a little better
143
+    $form['#tree'] = TRUE;
144
+    $form['processor']['#collapsible'] = TRUE;
145
+    $form['storage']['#collapsible'] = TRUE;
146
+    $form['network']['#collapsible'] = TRUE;
147 147
   
148
-  // Add a submit button and a hidden field to pass the preset
149
-  $form['submit'] = array(
148
+    // Add a submit button and a hidden field to pass the preset
149
+    $form['submit'] = array(
150 150
     '#type' => 'submit',
151 151
     '#value' => t('Save configuration')
152
-  );
153
-  $form['saveuseconfigxml'] = array (
154
-      '#type' => 'submit',
155
-      '#value' => t('Save configuration with disk usage settings from config.xml'),
156
-      '#validate' => array('boincwork_admin_prefs_preset_saveuseconfigxml'),
157
-  );
158
-  $form['preset'] = array(
152
+    );
153
+    $form['saveuseconfigxml'] = array (
154
+        '#type' => 'submit',
155
+        '#value' => t('Save configuration with disk usage settings from config.xml'),
156
+        '#validate' => array('boincwork_admin_prefs_preset_saveuseconfigxml'),
157
+    );
158
+    $form['preset'] = array(
159 159
     '#type' => 'hidden',
160 160
     '#value' => $preset
161
-  );
161
+    );
162 162
   
163
-  // Add the official mechanical things and return
164
-  drupal_prepare_form('boincwork_admin_prefs_presets_form', $form, $form_state);
165
-  return $form;
163
+    // Add the official mechanical things and return
164
+    drupal_prepare_form('boincwork_admin_prefs_presets_form', $form, $form_state);
165
+    return $form;
166 166
 }
167 167
 
168 168
 /**
169
-  * Validate the preference presets form.
170
-  */
169
+ * Validate the preference presets form.
170
+ */
171 171
 function boincwork_admin_prefs_presets_form_validate($form, &$form_state) {
172
-  require_boinc('util');
173
-  $values = $form_state['values'];
172
+    require_boinc('util');
173
+    $values = $form_state['values'];
174 174
   
175
-  // Verify all non-boolean user input values and notify form API of failures
175
+    // Verify all non-boolean user input values and notify form API of failures
176 176
   
177
-  // Processing preferences
178
-  if (!verify_numeric($values['processor']['idle_time_to_run'], 1, 9999)) form_set_error('idle_time_to_run', t('Invalid setting for') . " \"{$form['processor']['idle_time_to_run']['#title']} [x] {$form['processor']['idle_time_to_run']['#field_suffix']}\"");
179
-  if (!verify_numeric($values['processor']['suspend_if_no_recent_input'], 0, 9999)) form_set_error('suspend_if_no_recent_input', t('Invalid setting for') . " \"{$form['processor']['suspend_if_no_recent_input']['#title']} [x] {$form['processor']['suspend_if_no_recent_input']['#field_suffix']}\"");
180
-  if (!verify_numeric($values['processor']['suspend_cpu_usage'], 0, 100)) form_set_error('suspend_cpu_usage', t('Invalid setting for') . " \"{$form['processor']['suspend_cpu_usage']['#title']} [x] {$form['processor']['suspend_cpu_usage']['#field_suffix']}\"");
181
-  if (!verify_numeric($values['processor']['start_hour'], 0, 23)) form_set_error('start_hour', t('Invalid setting for') . " \"{$form['processor']['start_hour']['#title']} [x] {$form['processor']['start_hour']['#field_suffix']}\"");
182
-  if (!verify_numeric($values['processor']['end_hour'], 0, 23)) form_set_error('end_hour', t('Invalid setting for') . " \"{$form['processor']['end_hour']['#title']} [x] {$form['processor']['end_hour']['#field_suffix']}\"");
183
-  if (!verify_numeric($values['processor']['cpu_scheduling_period_minutes'], 1, 9999)) form_set_error('cpu_scheduling_period_minutes', t('Invalid setting for') . " \"{$form['processor']['cpu_scheduling_period_minutes']['#title']} [x] {$form['processor']['cpu_scheduling_period_minutes']['#field_suffix']}\"");
184
-  if (!verify_numeric($values['processor']['max_ncpus_pct'], 0, 100)) form_set_error('max_ncpus_pct', t('Invalid setting for') . " \"{$form['processor']['max_ncpus_pct']['#title']} [x] {$form['processor']['max_ncpus_pct']['#field_suffix']}\"");
185
-  if (!verify_numeric($values['processor']['cpu_usage_limit'], 0, 100)) form_set_error('cpu_usage_limit', t('Invalid setting for') . " \"{$form['processor']['cpu_usage_limit']['#title']} [x] {$form['processor']['cpu_usage_limit']['#field_suffix']}\"");
177
+    // Processing preferences
178
+    if (!verify_numeric($values['processor']['idle_time_to_run'], 1, 9999)) form_set_error('idle_time_to_run', t('Invalid setting for') . " \"{$form['processor']['idle_time_to_run']['#title']} [x] {$form['processor']['idle_time_to_run']['#field_suffix']}\"");
179
+    if (!verify_numeric($values['processor']['suspend_if_no_recent_input'], 0, 9999)) form_set_error('suspend_if_no_recent_input', t('Invalid setting for') . " \"{$form['processor']['suspend_if_no_recent_input']['#title']} [x] {$form['processor']['suspend_if_no_recent_input']['#field_suffix']}\"");
180
+    if (!verify_numeric($values['processor']['suspend_cpu_usage'], 0, 100)) form_set_error('suspend_cpu_usage', t('Invalid setting for') . " \"{$form['processor']['suspend_cpu_usage']['#title']} [x] {$form['processor']['suspend_cpu_usage']['#field_suffix']}\"");
181
+    if (!verify_numeric($values['processor']['start_hour'], 0, 23)) form_set_error('start_hour', t('Invalid setting for') . " \"{$form['processor']['start_hour']['#title']} [x] {$form['processor']['start_hour']['#field_suffix']}\"");
182
+    if (!verify_numeric($values['processor']['end_hour'], 0, 23)) form_set_error('end_hour', t('Invalid setting for') . " \"{$form['processor']['end_hour']['#title']} [x] {$form['processor']['end_hour']['#field_suffix']}\"");
183
+    if (!verify_numeric($values['processor']['cpu_scheduling_period_minutes'], 1, 9999)) form_set_error('cpu_scheduling_period_minutes', t('Invalid setting for') . " \"{$form['processor']['cpu_scheduling_period_minutes']['#title']} [x] {$form['processor']['cpu_scheduling_period_minutes']['#field_suffix']}\"");
184
+    if (!verify_numeric($values['processor']['max_ncpus_pct'], 0, 100)) form_set_error('max_ncpus_pct', t('Invalid setting for') . " \"{$form['processor']['max_ncpus_pct']['#title']} [x] {$form['processor']['max_ncpus_pct']['#field_suffix']}\"");
185
+    if (!verify_numeric($values['processor']['cpu_usage_limit'], 0, 100)) form_set_error('cpu_usage_limit', t('Invalid setting for') . " \"{$form['processor']['cpu_usage_limit']['#title']} [x] {$form['processor']['cpu_usage_limit']['#field_suffix']}\"");
186 186
 
187
-  // Storage preferences
188
-  if (!verify_numeric($values['storage']['disk_max_used_gb'], 0, 9999999)) form_set_error('disk_max_used_gb', t('Invalid setting for') . " \"{$form['storage']['disk_max_used_gb']['#title']} [x] {$form['storage']['disk_max_used_gb']['#field_suffix']}\"");
189
-  if (!verify_numeric($values['storage']['disk_min_free_gb'], 0.001, 9999999)) form_set_error('disk_min_free_gb', t('Invalid setting for') . " \"{$form['storage']['disk_min_free_gb']['#title']} [x] {$form['storage']['disk_min_free_gb']['#field_suffix']}\"");
190
-  if (!verify_numeric($values['storage']['disk_max_used_pct'], 0, 100)) form_set_error('disk_max_used_pct', t('Invalid setting for') . " \"{$form['storage']['disk_max_used_pct']['#title']} [x] {$form['storage']['disk_max_used_pct']['#field_suffix']}\"");
191
-  if (!verify_numeric($values['storage']['disk_interval'], 0, 9999999)) form_set_error('disk_interval', t('Invalid setting for') . " \"{$form['storage']['disk_interval']['#title']} [x] {$form['storage']['disk_interval']['#field_suffix']}\"");
192
-  if (!verify_numeric($values['storage']['vm_max_used_pct'], 0, 100)) form_set_error('vm_max_used_pct', t('Invalid setting for') . " \"{$form['storage']['vm_max_used_pct']['#title']} [x] {$form['storage']['vm_max_used_pct']['#field_suffix']}\"");
193
-  if (!verify_numeric($values['storage']['ram_max_used_busy_pct'], 0, 100)) form_set_error('ram_max_used_busy_pct', t('Invalid setting for') . " \"{$form['storage']['ram_max_used_busy_pct']['#title']} [x] {$form['storage']['ram_max_used_busy_pct']['#field_suffix']}\"");
194
-  if (!verify_numeric($values['storage']['ram_max_used_idle_pct'], 0, 100)) form_set_error('ram_max_used_idle_pct', t('Invalid setting for') . " \"{$form['storage']['ram_max_used_idle_pct']['#title']} [x] {$form['storage']['ram_max_used_idle_pct']['#field_suffix']}\"");
187
+    // Storage preferences
188
+    if (!verify_numeric($values['storage']['disk_max_used_gb'], 0, 9999999)) form_set_error('disk_max_used_gb', t('Invalid setting for') . " \"{$form['storage']['disk_max_used_gb']['#title']} [x] {$form['storage']['disk_max_used_gb']['#field_suffix']}\"");
189
+    if (!verify_numeric($values['storage']['disk_min_free_gb'], 0.001, 9999999)) form_set_error('disk_min_free_gb', t('Invalid setting for') . " \"{$form['storage']['disk_min_free_gb']['#title']} [x] {$form['storage']['disk_min_free_gb']['#field_suffix']}\"");
190
+    if (!verify_numeric($values['storage']['disk_max_used_pct'], 0, 100)) form_set_error('disk_max_used_pct', t('Invalid setting for') . " \"{$form['storage']['disk_max_used_pct']['#title']} [x] {$form['storage']['disk_max_used_pct']['#field_suffix']}\"");
191
+    if (!verify_numeric($values['storage']['disk_interval'], 0, 9999999)) form_set_error('disk_interval', t('Invalid setting for') . " \"{$form['storage']['disk_interval']['#title']} [x] {$form['storage']['disk_interval']['#field_suffix']}\"");
192
+    if (!verify_numeric($values['storage']['vm_max_used_pct'], 0, 100)) form_set_error('vm_max_used_pct', t('Invalid setting for') . " \"{$form['storage']['vm_max_used_pct']['#title']} [x] {$form['storage']['vm_max_used_pct']['#field_suffix']}\"");
193
+    if (!verify_numeric($values['storage']['ram_max_used_busy_pct'], 0, 100)) form_set_error('ram_max_used_busy_pct', t('Invalid setting for') . " \"{$form['storage']['ram_max_used_busy_pct']['#title']} [x] {$form['storage']['ram_max_used_busy_pct']['#field_suffix']}\"");
194
+    if (!verify_numeric($values['storage']['ram_max_used_idle_pct'], 0, 100)) form_set_error('ram_max_used_idle_pct', t('Invalid setting for') . " \"{$form['storage']['ram_max_used_idle_pct']['#title']} [x] {$form['storage']['ram_max_used_idle_pct']['#field_suffix']}\"");
195 195
 
196
-  // Network preferences
197
-  if (!verify_numeric($values['network']['work_buf_min_days'], 0, 10)) form_set_error('work_buf_min_days', t('Invalid setting for') . " \"{$form['network']['work_buf_min_days']['#title']} [x] {$form['network']['work_buf_min_days']['#field_suffix']}\"");
198
-  if (!verify_numeric($values['network']['work_buf_additional_days'], 0, 10)) form_set_error('work_buf_additional_days', t('Invalid setting for') . " \"{$form['network']['work_buf_additional_days']['#title']} [x] {$form['network']['work_buf_additional_days']['#field_suffix']}\"");
199
-  if (!verify_numeric($values['network']['max_bytes_sec_down'], 0, 9999.999)) form_set_error('max_bytes_sec_down', t('Invalid setting for') . " \"{$form['network']['max_bytes_sec_down']['#title']} [x] {$form['network']['max_bytes_sec_down']['#field_suffix']}\"");
200
-  if (!verify_numeric($values['network']['max_bytes_sec_up'], 0, 9999.999)) form_set_error('max_bytes_sec_up', t('Invalid setting for') . " \"{$form['network']['max_bytes_sec_up']['#title']} [x] {$form['network']['max_bytes_sec_up']['#field_suffix']}\"");
201
-  if (!verify_numeric($values['network']['net_start_hour'], 0, 23)) form_set_error('net_start_hour', t('Invalid setting for') . " \"{$form['network']['net_start_hour']['#title']} [x] {$form['network']['net_start_hour']['#field_suffix']}\"");
202
-  if (!verify_numeric($values['network']['net_end_hour'], 0, 23)) form_set_error('net_end_hour', t('Invalid setting for') . " \"{$form['network']['net_end_hour']['#title']} [x] {$form['network']['net_end_hour']['#field_suffix']}\"");
203
-  if (!verify_numeric($values['network']['daily_xfer_limit_mb'], 0, 9999999)) form_set_error('daily_xfer_limit_mb', t('Invalid setting for') . " \"{$form['network']['daily_xfer_limit_mb']['#title']} [x] {$form['network']['daily_xfer_limit_mb']['#field_suffix']}\"");
204
-  if (!verify_numeric($values['network']['daily_xfer_period_days'], 0, 9999999)) form_set_error('daily_xfer_period_days', t('Invalid setting for') . " \"{$form['network']['daily_xfer_limit_mb']['#title']} [x] {$form['network']['daily_xfer_limit_mb']['#field_suffix']}\"");
196
+    // Network preferences
197
+    if (!verify_numeric($values['network']['work_buf_min_days'], 0, 10)) form_set_error('work_buf_min_days', t('Invalid setting for') . " \"{$form['network']['work_buf_min_days']['#title']} [x] {$form['network']['work_buf_min_days']['#field_suffix']}\"");
198
+    if (!verify_numeric($values['network']['work_buf_additional_days'], 0, 10)) form_set_error('work_buf_additional_days', t('Invalid setting for') . " \"{$form['network']['work_buf_additional_days']['#title']} [x] {$form['network']['work_buf_additional_days']['#field_suffix']}\"");
199
+    if (!verify_numeric($values['network']['max_bytes_sec_down'], 0, 9999.999)) form_set_error('max_bytes_sec_down', t('Invalid setting for') . " \"{$form['network']['max_bytes_sec_down']['#title']} [x] {$form['network']['max_bytes_sec_down']['#field_suffix']}\"");
200
+    if (!verify_numeric($values['network']['max_bytes_sec_up'], 0, 9999.999)) form_set_error('max_bytes_sec_up', t('Invalid setting for') . " \"{$form['network']['max_bytes_sec_up']['#title']} [x] {$form['network']['max_bytes_sec_up']['#field_suffix']}\"");
201
+    if (!verify_numeric($values['network']['net_start_hour'], 0, 23)) form_set_error('net_start_hour', t('Invalid setting for') . " \"{$form['network']['net_start_hour']['#title']} [x] {$form['network']['net_start_hour']['#field_suffix']}\"");
202
+    if (!verify_numeric($values['network']['net_end_hour'], 0, 23)) form_set_error('net_end_hour', t('Invalid setting for') . " \"{$form['network']['net_end_hour']['#title']} [x] {$form['network']['net_end_hour']['#field_suffix']}\"");
203
+    if (!verify_numeric($values['network']['daily_xfer_limit_mb'], 0, 9999999)) form_set_error('daily_xfer_limit_mb', t('Invalid setting for') . " \"{$form['network']['daily_xfer_limit_mb']['#title']} [x] {$form['network']['daily_xfer_limit_mb']['#field_suffix']}\"");
204
+    if (!verify_numeric($values['network']['daily_xfer_period_days'], 0, 9999999)) form_set_error('daily_xfer_period_days', t('Invalid setting for') . " \"{$form['network']['daily_xfer_limit_mb']['#title']} [x] {$form['network']['daily_xfer_limit_mb']['#field_suffix']}\"");
205 205
 }
206 206
 
207 207
 /**
208
-  * Handle post-validation submission of preference presets form.
209
-  */
208
+ * Handle post-validation submission of preference presets form.
209
+ */
210 210
 function boincwork_admin_prefs_presets_form_submit($form, &$form_state) {
211
-  $values = $form_state['values'];
212
-  $preset = $form_state['values']['preset'];
211
+    $values = $form_state['values'];
212
+    $preset = $form_state['values']['preset'];
213 213
   
214
-  // Load baseline settings from configuration
215
-  $prefs = boincwork_get_preset_prefs($preset);
214
+    // Load baseline settings from configuration
215
+    $prefs = boincwork_get_preset_prefs($preset);
216 216
   
217
-  // Processing preferences
218
-  $prefs['run_on_batteries'] = ($values['processor']['run_on_batteries']) ? 0 : 1;
219
-  $prefs['run_if_user_active'] = ($values['processor']['run_if_user_active']) ? 0 : 1;
220
-  $prefs['run_gpu_if_user_active'] = ($values['processor']['run_gpu_if_user_active']) ? 0: 1;
221
-  $prefs['idle_time_to_run'] = $values['processor']['idle_time_to_run'];
222
-  $prefs['suspend_if_no_recent_input'] = $values['processor']['suspend_if_no_recent_input'];
223
-  $prefs['suspend_cpu_usage'] = $values['processor']['suspend_cpu_usage'];
224
-  $prefs['start_hour'] = $values['processor']['start_hour'];
225
-  $prefs['end_hour'] = $values['processor']['end_hour'];
226
-  $prefs['leave_apps_in_memory'] = ($values['processor']['leave_apps_in_memory']) ? 1 : 0;
227
-  $prefs['cpu_scheduling_period_minutes'] = $values['processor']['cpu_scheduling_period_minutes'];
228
-  $prefs['max_ncpus_pct'] = $values['processor']['max_ncpus_pct'];
229
-  $prefs['cpu_usage_limit'] = $values['processor']['cpu_usage_limit'];
217
+    // Processing preferences
218
+    $prefs['run_on_batteries'] = ($values['processor']['run_on_batteries']) ? 0 : 1;
219
+    $prefs['run_if_user_active'] = ($values['processor']['run_if_user_active']) ? 0 : 1;
220
+    $prefs['run_gpu_if_user_active'] = ($values['processor']['run_gpu_if_user_active']) ? 0: 1;
221
+    $prefs['idle_time_to_run'] = $values['processor']['idle_time_to_run'];
222
+    $prefs['suspend_if_no_recent_input'] = $values['processor']['suspend_if_no_recent_input'];
223
+    $prefs['suspend_cpu_usage'] = $values['processor']['suspend_cpu_usage'];
224
+    $prefs['start_hour'] = $values['processor']['start_hour'];
225
+    $prefs['end_hour'] = $values['processor']['end_hour'];
226
+    $prefs['leave_apps_in_memory'] = ($values['processor']['leave_apps_in_memory']) ? 1 : 0;
227
+    $prefs['cpu_scheduling_period_minutes'] = $values['processor']['cpu_scheduling_period_minutes'];
228
+    $prefs['max_ncpus_pct'] = $values['processor']['max_ncpus_pct'];
229
+    $prefs['cpu_usage_limit'] = $values['processor']['cpu_usage_limit'];
230 230
   
231
-  // Storage preferences
232
-  $prefs['disk_max_used_gb'] = $values['storage']['disk_max_used_gb'];
233
-  $prefs['disk_min_free_gb'] = $values['storage']['disk_min_free_gb'];
234
-  $prefs['disk_max_used_pct'] = $values['storage']['disk_max_used_pct'];
235
-  $prefs['disk_interval'] = $values['storage']['disk_interval'];
236
-  $prefs['vm_max_used_pct'] = $values['storage']['vm_max_used_pct'];
237
-  $prefs['ram_max_used_busy_pct'] = $values['storage']['ram_max_used_busy_pct'];
238
-  $prefs['ram_max_used_idle_pct'] = $values['storage']['ram_max_used_idle_pct'];
231
+    // Storage preferences
232
+    $prefs['disk_max_used_gb'] = $values['storage']['disk_max_used_gb'];
233
+    $prefs['disk_min_free_gb'] = $values['storage']['disk_min_free_gb'];
234
+    $prefs['disk_max_used_pct'] = $values['storage']['disk_max_used_pct'];
235
+    $prefs['disk_interval'] = $values['storage']['disk_interval'];
236
+    $prefs['vm_max_used_pct'] = $values['storage']['vm_max_used_pct'];
237
+    $prefs['ram_max_used_busy_pct'] = $values['storage']['ram_max_used_busy_pct'];
238
+    $prefs['ram_max_used_idle_pct'] = $values['storage']['ram_max_used_idle_pct'];
239 239
   
240
-  // Network preferences
241
-  $prefs['work_buf_min_days'] = $values['network']['work_buf_min_days'];
242
-  $prefs['work_buf_additional_days'] = $values['network']['work_buf_additional_days'];
243
-  $prefs['confirm_before_connecting'] = ($values['network']['confirm_before_connecting']) ? 1 : 0;
244
-  $prefs['hangup_if_dialed'] = ($values['network']['hangup_if_dialed']) ? 1 : 0;
245
-  $prefs['max_bytes_sec_down'] = $values['network']['max_bytes_sec_down']*1000;
246
-  $prefs['max_bytes_sec_up'] = $values['network']['max_bytes_sec_up']*1000;
247
-  $prefs['net_start_hour'] = $values['network']['net_start_hour'];
248
-  $prefs['net_end_hour'] = $values['network']['net_end_hour'];
249
-  $prefs['daily_xfer_limit_mb'] = $values['network']['daily_xfer_limit_mb'];
250
-  $prefs['daily_xfer_period_days'] = $values['network']['daily_xfer_period_days'];
251
-  $prefs['dont_verify_images'] = ($values['network']['dont_verify_images']) ? 1 : 0;
240
+    // Network preferences
241
+    $prefs['work_buf_min_days'] = $values['network']['work_buf_min_days'];
242
+    $prefs['work_buf_additional_days'] = $values['network']['work_buf_additional_days'];
243
+    $prefs['confirm_before_connecting'] = ($values['network']['confirm_before_connecting']) ? 1 : 0;
244
+    $prefs['hangup_if_dialed'] = ($values['network']['hangup_if_dialed']) ? 1 : 0;
245
+    $prefs['max_bytes_sec_down'] = $values['network']['max_bytes_sec_down']*1000;
246
+    $prefs['max_bytes_sec_up'] = $values['network']['max_bytes_sec_up']*1000;
247
+    $prefs['net_start_hour'] = $values['network']['net_start_hour'];
248
+    $prefs['net_end_hour'] = $values['network']['net_end_hour'];
249
+    $prefs['daily_xfer_limit_mb'] = $values['network']['daily_xfer_limit_mb'];
250
+    $prefs['daily_xfer_period_days'] = $values['network']['daily_xfer_period_days'];
251
+    $prefs['dont_verify_images'] = ($values['network']['dont_verify_images']) ? 1 : 0;
252 252
   
253
-  //Remove @attributes to match new format (see boincwork.forms.inc
254
-  //function boincwork_generalprefs_form)
255
-  unset($prefs['@attributes']['preset']);
253
+    //Remove @attributes to match new format (see boincwork.forms.inc
254
+    //function boincwork_generalprefs_form)
255
+    unset($prefs['@attributes']['preset']);
256 256
   
257
-  // Update the configuration
258
-  boincwork_save_preset_prefs($prefs, $preset);
259
-  drupal_set_message(t('The "@name" preset has been updated.',
257
+    // Update the configuration
258
+    boincwork_save_preset_prefs($prefs, $preset);
259
+    drupal_set_message(t('The "@name" preset has been updated.',
260 260
     array('@name' => $preset)));
261 261
 }
262 262
 
@@ -265,26 +265,26 @@  discard block
 block discarded – undo
265 265
  */
266 266
 function boincwork_save_preset_prefs($updated_prefs, $preset = 'standard') {
267 267
   
268
-  // Get the full configuration
269
-  $all_presets = boincwork_get_preset_prefs();
270
-  $all_presets = (array) $all_presets['general_preferences'];
268
+    // Get the full configuration
269
+    $all_presets = boincwork_get_preset_prefs();
270
+    $all_presets = (array) $all_presets['general_preferences'];
271 271
   
272
-  // Check for sane config
273
-  if (isset($all_presets['preset'])) {
272
+    // Check for sane config
273
+    if (isset($all_presets['preset'])) {
274 274
     if (!is_numeric(key($all_presets['preset']))) {
275
-      $all_presets['preset'] = array($all_presets['preset']);
275
+        $all_presets['preset'] = array($all_presets['preset']);
276 276
     }
277 277
     foreach ($all_presets['preset'] as $key => $old_preset) {
278
-      // Find the preset being updated and... update it
279
-      if (isset($old_preset['@attributes']['name']) AND $old_preset['@attributes']['name'] == $preset) {
278
+        // Find the preset being updated and... update it
279
+        if (isset($old_preset['@attributes']['name']) AND $old_preset['@attributes']['name'] == $preset) {
280 280
         $all_presets['preset'][$key] = $updated_prefs + $old_preset;
281
-      }
281
+        }
282
+    }
282 283
     }
283
-  }
284 284
   
285
-  // Convert prefs back to XML and save to database
286
-  $all_presets = array('general_preferences' => $all_presets);
287
-  variable_set('boincwork_preset_prefs', save_configuration($all_presets));
285
+    // Convert prefs back to XML and save to database
286
+    $all_presets = array('general_preferences' => $all_presets);
287
+    variable_set('boincwork_preset_prefs', save_configuration($all_presets));
288 288
 }
289 289
 
290 290
 /**
Please login to merge, or discard this patch.
boinc/modules/boincwork/views/views_handler_argument_boincuser_id.inc 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@
 block discarded – undo
7 7
  */
8 8
 
9 9
 class views_handler_argument_boincuser_id extends views_handler_argument_numeric {
10
-  function construct() {
10
+    function construct() {
11 11
     parent::construct();
12
-  }
12
+    }
13 13
 
14
-  function set_argument($arg) {
14
+    function set_argument($arg) {
15 15
     // When setting the ID argument, convert to BOINC ID
16 16
     $id = is_numeric($arg) ? $arg : 0;
17 17
     $boinc_id = db_result(db_query("SELECT boinc_id FROM {boincuser} WHERE uid = %d", $id));
18 18
     $this->argument = $boinc_id;
19 19
     return $this->validate_arg($boinc_id);
20
-  }
20
+    }
21 21
 }
Please login to merge, or discard this patch.
modules/boincwork/views/views_handler_field_boincwork_host_app_et_avg.inc 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -6,15 +6,15 @@
 block discarded – undo
6 6
  */
7 7
 
8 8
 class views_handler_field_boincwork_host_app_et_avg extends views_handler_field {
9
-  function construct() {
9
+    function construct() {
10 10
     parent::construct();
11
-  }
11
+    }
12 12
 
13
-  function render($values) {
13
+    function render($values) {
14 14
     $gflops = 0;
15 15
     if ($values->host_app_version_et_avg) {
16
-      $gflops = 1e-9 / $values->host_app_version_et_avg;
16
+        $gflops = 1e-9 / $values->host_app_version_et_avg;
17 17
     }
18 18
     return round($gflops, 2) . ' GFLOPS';
19
-  }
19
+    }
20 20
 }
Please login to merge, or discard this patch.
boincwork/views/views_handler_field_boincwork_host_app_turnaround_avg.inc 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -6,12 +6,12 @@
 block discarded – undo
6 6
  */
7 7
 
8 8
 class views_handler_field_boincwork_host_app_turnaround_avg extends views_handler_field {
9
-  function construct() {
9
+    function construct() {
10 10
     parent::construct();
11
-  }
11
+    }
12 12
 
13
-  function render($values) {
13
+    function render($values) {
14 14
     $time_in_days = $values->host_app_version_turnaround_avg / (24*60*60);
15 15
     return round($time_in_days, 2) . ' ' . t('days');
16
-  }
16
+    }
17 17
 }
Please login to merge, or discard this patch.
boincwork/views/views_handler_field_boincwork_app_version_number.inc 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -6,11 +6,11 @@
 block discarded – undo
6 6
  */
7 7
 
8 8
 class views_handler_field_boincwork_app_version_number extends views_handler_field {
9
-  function construct() {
9
+    function construct() {
10 10
     parent::construct();
11
-  }
11
+    }
12 12
 
13
-  function render($values) {
13
+    function render($values) {
14 14
     return sprintf("%01.2f", $values->app_version_host_app_version_version_num / 100);
15
-  }
15
+    }
16 16
 }
Please login to merge, or discard this patch.