Completed
Pull Request — master (#1947)
by Christian
11:54
created
drupal/sites/default/boinc/modules/boincwork/includes/boincwork.helpers.inc 5 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -977,6 +977,7 @@  discard block
 block discarded – undo
977 977
 
978 978
 /**
979 979
  * Format a number to be displayed using a maximum number of digits
980
+ * @param double $number
980 981
  */ 
981 982
 function boincwork_format_stats($number, $max_digits = 4) {
982 983
   $suffix = array(
@@ -1187,6 +1188,9 @@  discard block
 block discarded – undo
1187 1188
   //  xml_to_array(): Convert an XML DOM object to array format
1188 1189
   //------------------------------------------------------------------------------------------------
1189 1190
   
1191
+  /**
1192
+   * @param DOMDocument $xml
1193
+   */
1190 1194
   function xml_to_array($xml) {
1191 1195
       $node = $xml->firstChild; //$xml->first_child();
1192 1196
       $result = '';
@@ -1269,6 +1273,7 @@  discard block
 block discarded – undo
1269 1273
 
1270 1274
 /**
1271 1275
   * Determine output for host list views when no hosts are found.
1276
+  * @param string $context
1272 1277
   */
1273 1278
 function boincwork_views_host_list_empty_text($context = NULL) {
1274 1279
   
@@ -1818,6 +1823,7 @@  discard block
 block discarded – undo
1818 1823
 
1819 1824
 /**
1820 1825
  * Function to delete a column from an array.
1826
+ * @param integer $offset
1821 1827
  */
1822 1828
 function delete_col(&$array, $offset) {
1823 1829
   return array_walk($array, function (&$v) use ($offset) {
Please login to merge, or discard this patch.
Indentation   +797 added lines, -797 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), NULL, 'boinc:account-preferences-project')
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', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')),
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), NULL, 'boinc:account-preferences-project')
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', array(), NULL, 'boinc:account-preferences'),
545
-      '#type' => 'fieldset',
546
-      '#description' => $title,
547
-      '#collapsible' => TRUE,
548
-      '#collapsed' => FALSE
544
+        '#title' => bts('Applications', array(), NULL, 'boinc:account-preferences'),
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:', array(), NULL, 'boinc:account-preferences-computing');
685
-          break;
685
+            break;
686 686
         case 'net_start_hour':
687 687
           $element['#title'] = bts('Transfer files only between:', array(), NULL, 'boinc:account-preferences-comuting');
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', array(), NULL, 'boinc:account-preferences'),
712
-      'elements' => $uncategorized,
711
+        'name' => bts('Other settings', array(), NULL, 'boinc:account-preferences'),
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', array(), NULL, 'boinc:account-preferences'),
719
-      'elements' => $uncategorized,
718
+        'name' => bts('Settings', array(), NULL, 'boinc:account-preferences'),
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), NULL, 'boinc:account-preferences'));
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), NULL, 'boinc:account-preferences'));
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), NULL, 'boinc:account-preferences'));
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', array(), NULL, 'boinc:host-list') . '</h2>';
1288
-      $output .=  '<p>' . bts('This user has no computers that have been'
1289
-      . ' active in the last 30 days.', array(), NULL, 'boinc:host-list') . '</p>';
1290
-      break;
1288
+        $output .=  '<p>' . bts('This user has no computers that have been'
1289
+        . ' active in the last 30 days.', array(), NULL, 'boinc:host-list') . '</p>';
1290
+        break;
1291 1291
       
1292 1292
     case 'preferences':
1293 1293
       $output .=  '<h2>' . bts('No computers', array(), NULL, 'boinc:host-list') . '</h2>';
1294
-      $output .=  '<p>' . bts('There are no computers assigned to this'
1295
-      . ' preference set.', array(), NULL, 'boinc:host-list') . '</p>';
1296
-      break;
1294
+        $output .=  '<p>' . bts('There are no computers assigned to this'
1295
+        . ' preference set.', array(), NULL, 'boinc:host-list') . '</p>';
1296
+        break;
1297 1297
     
1298 1298
     default:
1299 1299
       $output .=  '<h2>' . bts('Computers pending', array(), NULL, 'boinc:host-list') . '</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.', array(), NULL, 'boinc:host-list') . '</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.', array(), NULL, 'boinc:host-list') . '</p>';
1303 1303
     }
1304
-  }
1305
-  else {
1304
+    }
1305
+    else {
1306 1306
     $output .=  '<h2>' . bts('Computers hidden', array(), NULL, 'boinc:host-list') . '</h2>';
1307 1307
     $output .=  '<p>' . bts('This user has chosen not to show information'
1308 1308
     . ' about their computers.', array(), NULL, 'boinc:host-list') . '</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), NULL, 'boinc:task-list')
1323 1323
     . '</h2>';
1324 1324
     $output .=  '<p>' . bts('There are no tasks of this type on record', array(), NULL, 'boinc:task-list')
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', array(), NULL, 'boinc:form-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', array(), NULL, 'boinc:form-delete'), "host/{$host_id}/delete",
1342
+        $output .= '<li class="tab">';
1343
+        $output .= l(bts('Delete', array(), NULL, 'boinc:form-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),
1349
-              NULL, 'boinc:account-host-delete') . '\')'
1350
-          )
1347
+                . ' from your account forever. Are you sure this is OK?',
1348
+                array('@id' => $host_id),
1349
+                NULL, 'boinc:account-host-delete') . '\')'
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', array(), NULL, 'boinc:account-preferences-location'),
1434
-      "{$path}/home" => bts('Home', array(), NULL, 'boinc:account-preferences-location:-1:ignoreoverwrite'),
1435
-      "{$path}/work" => bts('Work', array(), NULL, 'boinc:account-preferences-location'),
1436
-      "{$path}/school" => bts('School', array(), NULL, 'boinc:account-preferences-location')
1433
+        "{$path}/generic" => bts('Generic', array(), NULL, 'boinc:account-preferences-location'),
1434
+        "{$path}/home" => bts('Home', array(), NULL, 'boinc:account-preferences-location:-1:ignoreoverwrite'),
1435
+        "{$path}/work" => bts('Work', array(), NULL, 'boinc:account-preferences-location'),
1436
+        "{$path}/school" => bts('School', array(), NULL, 'boinc:account-preferences-location')
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,34 +1441,34 @@  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
 }
1473 1473
 
1474 1474
 /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
@@ -1497,330 +1497,330 @@  discard block
 block discarded – undo
1497 1497
  *   for all applications.
1498 1498
  */
1499 1499
 function boincwork_tasktable($category = 0, $queryid = 1, $tselect = NULL, $app_id = 0) {
1500
-  // Check type parameter, if not (0,2) then return an error.
1501
-  if ( ($category!=0) AND ($category!=1) AND ($category!=2) ) {
1500
+    // Check type parameter, if not (0,2) then return an error.
1501
+    if ( ($category!=0) AND ($category!=1) AND ($category!=2) ) {
1502 1502
     watchdog('boincwork', 'task table called with invalid category = %category', array('%category' => $category), WATCHDOG_WARNING);
1503 1503
     return '';
1504
-  }
1504
+    }
1505 1505
 
1506
-  require_boinc( array('util', 'result') );
1506
+    require_boinc( array('util', 'result') );
1507 1507
 
1508
-  global $language;
1509
-  $locality=$language->language;
1510
-  $nf = new NumberFormatter($locality, NumberFormatter::DECIMAL);
1508
+    global $language;
1509
+    $locality=$language->language;
1510
+    $nf = new NumberFormatter($locality, NumberFormatter::DECIMAL);
1511 1511
 
1512
-  $output = '';
1512
+    $output = '';
1513 1513
 
1514
-  $state_hnames = array(
1514
+    $state_hnames = array(
1515 1515
     STATE_ALL => 'All',
1516 1516
     STATE_IN_PROGRESS => 'In progress',
1517 1517
     STATE_PENDING => 'Pending',
1518 1518
     STATE_VALID => 'Valid',
1519 1519
     STATE_INVALID => 'Invalid',
1520 1520
     STATE_ERROR => 'Error',
1521
-  );
1522
-  // Array (hash) to count total number of results/tasks, and their states.
1523
-  $taskstates = array(
1521
+    );
1522
+    // Array (hash) to count total number of results/tasks, and their states.
1523
+    $taskstates = array(
1524 1524
     STATE_ALL => 0,
1525 1525
     STATE_IN_PROGRESS => 0,
1526 1526
     STATE_PENDING => 0,
1527 1527
     STATE_VALID => 0,
1528 1528
     STATE_INVALID => 0,
1529 1529
     STATE_ERROR => 0,
1530
-  );
1531
-  // Array to hold pretty-print result data to be displayed in a table.
1532
-  $resultdata = array();
1533
-  // Arrays for applications. Form below uses $applications as parameter.
1534
-  $application_map = array();
1535
-  $application_select_count = array();
1536
-  $applications = array();
1530
+    );
1531
+    // Array to hold pretty-print result data to be displayed in a table.
1532
+    $resultdata = array();
1533
+    // Arrays for applications. Form below uses $applications as parameter.
1534
+    $application_map = array();
1535
+    $application_select_count = array();
1536
+    $applications = array();
1537 1537
 
1538
-  // BOINC DB queries for results, application names
1539
-  db_set_active('boinc');
1538
+    // BOINC DB queries for results, application names
1539
+    db_set_active('boinc');
1540 1540
 
1541
-  // Query to retreive all results, in order to calculate status for a
1542
-  // host with application names for each result.
1543
-  $sqlall = "SELECT user_friendly_name,"
1544
-      ."r.appid as appid,"
1545
-      ."r.server_state AS server_state,"
1546
-      ."r.outcome AS outcome,"
1547
-      ."r.client_state AS client_state,"
1548
-      ."r.validate_state AS validate_state,"
1549
-      ."r.exit_status AS exit_status "
1550
-      ."FROM {result} AS r "
1551
-      ."INNER JOIN {app} AS a "
1552
-      ."ON r.appid=a.id "
1553
-      ."WHERE deprecated=0 ";
1541
+    // Query to retreive all results, in order to calculate status for a
1542
+    // host with application names for each result.
1543
+    $sqlall = "SELECT user_friendly_name,"
1544
+        ."r.appid as appid,"
1545
+        ."r.server_state AS server_state,"
1546
+        ."r.outcome AS outcome,"
1547
+        ."r.client_state AS client_state,"
1548
+        ."r.validate_state AS validate_state,"
1549
+        ."r.exit_status AS exit_status "
1550
+        ."FROM {result} AS r "
1551
+        ."INNER JOIN {app} AS a "
1552
+        ."ON r.appid=a.id "
1553
+        ."WHERE deprecated=0 ";
1554 1554
 
1555
-  // Use userid, hostid, or workunitid
1556
-  if ($category==0) {
1555
+    // Use userid, hostid, or workunitid
1556
+    if ($category==0) {
1557 1557
     $sqlall .= "AND r.userid='%s' ";
1558
-  }
1559
-  elseif ($category==1) {
1558
+    }
1559
+    elseif ($category==1) {
1560 1560
     $sqlall .= "AND r.workunitid='%s' ";
1561
-  }
1562
-  elseif ($category==2) {
1561
+    }
1562
+    elseif ($category==2) {
1563 1563
     $sqlall .= "AND r.hostid='%s' ";
1564
-  }
1565
-  $sqlall .= "ORDER BY user_friendly_name";
1566
-  $dbres_all = db_query($sqlall, $queryid);
1567
-  db_set_active('default');
1564
+    }
1565
+    $sqlall .= "ORDER BY user_friendly_name";
1566
+    $dbres_all = db_query($sqlall, $queryid);
1567
+    db_set_active('default');
1568 1568
 
1569
-  // Loop 1 of DB results
1570
-  if ($dbres_all) {
1569
+    // Loop 1 of DB results
1570
+    if ($dbres_all) {
1571 1571
     while ($result = db_fetch_object($dbres_all)) {
1572
-      $mystate = state_num($result);
1573
-      if ( ($result->appid==$app_id) OR ($app_id==0) OR ($app_id==-1) ) {
1572
+        $mystate = state_num($result);
1573
+        if ( ($result->appid==$app_id) OR ($app_id==0) OR ($app_id==-1) ) {
1574 1574
         $taskstates[STATE_ALL]++;
1575 1575
         switch ($mystate) {
1576 1576
         case STATE_IN_PROGRESS:
1577 1577
           $taskstates[STATE_IN_PROGRESS]++;
1578
-          break;
1578
+            break;
1579 1579
         case STATE_PENDING:
1580 1580
           $taskstates[STATE_PENDING]++;
1581
-          break;
1581
+            break;
1582 1582
         case STATE_VALID:
1583 1583
           $taskstates[STATE_VALID]++;
1584
-          break;
1584
+            break;
1585 1585
         case STATE_INVALID:
1586 1586
           $taskstates[STATE_INVALID]++;
1587
-          break;
1587
+            break;
1588 1588
         case STATE_ERROR:
1589 1589
           $taskstates[STATE_ERROR]++;
1590
-          break;
1590
+            break;
1591 1591
         }
1592
-      }// if app_id
1592
+        }// if app_id
1593 1593
 
1594
-      //map holds a map between app ids and user friendly names for all applications.
1595
-      $application_map[$result->appid] = $result->user_friendly_name;
1596
-      if ( ($mystate == $tselect) OR ($tselect==STATE_ALL) ) {
1594
+        //map holds a map between app ids and user friendly names for all applications.
1595
+        $application_map[$result->appid] = $result->user_friendly_name;
1596
+        if ( ($mystate == $tselect) OR ($tselect==STATE_ALL) ) {
1597 1597
         //count of appids in the results.
1598 1598
         $application_select_count[$result->appid]++;
1599
-      }// if mystate
1599
+        }// if mystate
1600 1600
 
1601 1601
     }// while
1602
-  }
1603
-  else {
1604
-  }
1602
+    }
1603
+    else {
1604
+    }
1605 1605
   
1606
-  // Entry for all applications.
1607
-  $allcount = $application_select_count ? array_sum($application_select_count) : 0;
1608
-  $applications[-1] = bts('Application', array(), NULL, 'boinc:task-table');
1609
-  $applications[0] = bts('All applications', array(), NULL, 'boinc:task-table') . '(' . $allcount . ')';
1610
-  // Create application filter from application_map and application_select_count.
1611
-  foreach($application_map as $akey => $aname) {
1606
+    // Entry for all applications.
1607
+    $allcount = $application_select_count ? array_sum($application_select_count) : 0;
1608
+    $applications[-1] = bts('Application', array(), NULL, 'boinc:task-table');
1609
+    $applications[0] = bts('All applications', array(), NULL, 'boinc:task-table') . '(' . $allcount . ')';
1610
+    // Create application filter from application_map and application_select_count.
1611
+    foreach($application_map as $akey => $aname) {
1612 1612
     $acount = 0;
1613 1613
     if ( $application_select_count and array_key_exists($akey, $application_select_count) ) {
1614
-      $acount = $application_select_count[$akey];
1614
+        $acount = $application_select_count[$akey];
1615 1615
     }
1616 1616
     $applications[$akey] = $aname . ' ('. $acount . ')';
1617
-  }
1618
-  // Header array for (sub) results table.
1619
-  $resultheader = array(
1617
+    }
1618
+    // Header array for (sub) results table.
1619
+    $resultheader = array(
1620 1620
     array(
1621
-      'data' => bts('Task ID', array(), NULL, 'boinc:task-table'),
1622
-      'field' => 'id',
1621
+        'data' => bts('Task ID', array(), NULL, 'boinc:task-table'),
1622
+        'field' => 'id',
1623 1623
     ),
1624 1624
     array(
1625
-      'data' => bts('Workunit ID', array(), NULL, 'boinc:task-table'),
1626
-      'field' => 'workunitid',
1625
+        'data' => bts('Workunit ID', array(), NULL, 'boinc:task-table'),
1626
+        'field' => 'workunitid',
1627 1627
     ),
1628 1628
     array(
1629
-      'data' => bts('Computer', array(), NULL, 'boinc:task-table'),
1630
-      'field' => 'hostid',
1629
+        'data' => bts('Computer', array(), NULL, 'boinc:task-table'),
1630
+        'field' => 'hostid',
1631 1631
     ),
1632 1632
     array(
1633
-      'data' => bts('Sent', array(), NULL, 'boinc:task-table')
1633
+        'data' => bts('Sent', array(), NULL, 'boinc:task-table')
1634 1634
     ),
1635 1635
     array(
1636
-      'data' => bts('Time Reported or Deadline', array(), NULL, 'boinc:task-table')
1636
+        'data' => bts('Time Reported or Deadline', array(), NULL, 'boinc:task-table')
1637 1637
     ),
1638 1638
     array(
1639
-      'data' => bts('Status', array(), NULL, 'boinc:task-table')
1639
+        'data' => bts('Status', array(), NULL, 'boinc:task-table')
1640 1640
     ),
1641 1641
     array(
1642
-      'data' => bts('Run time', array(), NULL, 'boinc:task-table'),
1643
-      'field'=>'elapsed_time',
1642
+        'data' => bts('Run time', array(), NULL, 'boinc:task-table'),
1643
+        'field'=>'elapsed_time',
1644 1644
     ),
1645 1645
     array(
1646
-      'data' => bts('CPU time', array(), NULL, 'boinc:task-table'),
1647
-      'field'=>'cpu_time',
1646
+        'data' => bts('CPU time', array(), NULL, 'boinc:task-table'),
1647
+        'field'=>'cpu_time',
1648 1648
     ),
1649 1649
     array(
1650
-      'data' => bts('Claimed Credit', array(), NULL, 'boinc:task-table'),
1651
-      'field'=>'claimed_credit',
1650
+        'data' => bts('Claimed Credit', array(), NULL, 'boinc:task-table'),
1651
+        'field'=>'claimed_credit',
1652 1652
     ),
1653 1653
     array(
1654
-      'data' => bts('Granted Credit', array(), NULL, 'boinc:task-table'),
1655
-      'field'=>'granted_credit',
1654
+        'data' => bts('Granted Credit', array(), NULL, 'boinc:task-table'),
1655
+        'field'=>'granted_credit',
1656 1656
     ),
1657 1657
     // Application is a column, but won't be added until after tablesort_sql().
1658
-  );
1658
+    );
1659 1659
 
1660
-  // Query to retreive a subset of the total results for the results table.
1661
-  db_set_active('boinc');
1662
-  $sqlsub = "SELECT r.id AS id,"
1663
-      ."r.name AS name,"
1664
-      ."r.workunitid AS workunitid,"
1665
-      ."r.hostid as hostid,"
1666
-      ."r.sent_time AS sent_time,"
1667
-      ."r.received_time AS received_time,"
1668
-      ."r.report_deadline AS report_deadline,"
1669
-      ."r.server_state AS server_state,"
1670
-      ."r.outcome AS outcome,"
1671
-      ."r.client_state AS client_state,"
1672
-      ."r.validate_state AS validate_state,"
1673
-      ."r.exit_status AS exit_status,"
1674
-      ."r.elapsed_time AS elapsed_time,"
1675
-      ."r.cpu_time AS cpu_time,"
1676
-      ."r.claimed_credit AS claimed_credit,"
1677
-      ."r.granted_credit AS granted_credit,"
1678
-      ."r.appid AS appid,"
1679
-      ."r.app_version_id AS app_version_id,"
1680
-      ."a.user_friendly_name "
1681
-      ."FROM {result} AS r "
1682
-      ."INNER JOIN {app} AS a "
1683
-      ."ON r.appid=a.id "
1684
-      ."WHERE a.deprecated = 0 ";
1660
+    // Query to retreive a subset of the total results for the results table.
1661
+    db_set_active('boinc');
1662
+    $sqlsub = "SELECT r.id AS id,"
1663
+        ."r.name AS name,"
1664
+        ."r.workunitid AS workunitid,"
1665
+        ."r.hostid as hostid,"
1666
+        ."r.sent_time AS sent_time,"
1667
+        ."r.received_time AS received_time,"
1668
+        ."r.report_deadline AS report_deadline,"
1669
+        ."r.server_state AS server_state,"
1670
+        ."r.outcome AS outcome,"
1671
+        ."r.client_state AS client_state,"
1672
+        ."r.validate_state AS validate_state,"
1673
+        ."r.exit_status AS exit_status,"
1674
+        ."r.elapsed_time AS elapsed_time,"
1675
+        ."r.cpu_time AS cpu_time,"
1676
+        ."r.claimed_credit AS claimed_credit,"
1677
+        ."r.granted_credit AS granted_credit,"
1678
+        ."r.appid AS appid,"
1679
+        ."r.app_version_id AS app_version_id,"
1680
+        ."a.user_friendly_name "
1681
+        ."FROM {result} AS r "
1682
+        ."INNER JOIN {app} AS a "
1683
+        ."ON r.appid=a.id "
1684
+        ."WHERE a.deprecated = 0 ";
1685 1685
 
1686
-  // Use userid, hostid, or workunitid
1687
-  if ($category==0) {
1686
+    // Use userid, hostid, or workunitid
1687
+    if ($category==0) {
1688 1688
     $sqlsub .= "AND r.userid = '%s' ";
1689
-  }
1690
-  elseif ($category==1) {
1689
+    }
1690
+    elseif ($category==1) {
1691 1691
     $sqlsub .= "AND r.workunitid = '%s' ";
1692
-  }
1693
-  elseif ($category==2) {
1692
+    }
1693
+    elseif ($category==2) {
1694 1694
     $sqlsub .= "AND r.hostid = '%s' ";
1695
-  }
1695
+    }
1696 1696
 
1697
-  // Append additional where clauses based on task selection.
1698
-  switch ($tselect) {
1699
-  case STATE_IN_PROGRESS:
1697
+    // Append additional where clauses based on task selection.
1698
+    switch ($tselect) {
1699
+    case STATE_IN_PROGRESS:
1700 1700
     $sqlsub .= "AND r.server_state = 4 ";
1701 1701
     break;
1702
-  case STATE_PENDING:
1702
+    case STATE_PENDING:
1703 1703
     $sqlsub .= "AND (r.server_state = 5) AND (r.outcome = 1) AND (r.validate_state >= 0) AND (r.validate_state <= 0 OR r.validate_state >= 4) AND (r.validate_state <= 4) ";
1704 1704
     break;
1705
-  case STATE_VALID:
1705
+    case STATE_VALID:
1706 1706
     $sqlsub .= "AND (r.server_state = 5) AND (r.outcome = 1) AND (r.validate_state = 1) ";
1707 1707
     break;
1708
-  case STATE_INVALID:
1708
+    case STATE_INVALID:
1709 1709
     $sqlsub .= "AND (r.server_state = 5) AND ((r.outcome = 6) OR ((r.outcome = 1) AND ((r.validate_state = 2) OR (r.validate_state = 3) OR (r.validate_state = 5)))) ";
1710 1710
     break;
1711
-  case STATE_ERROR:
1711
+    case STATE_ERROR:
1712 1712
     $sqlsub .= "AND (r.server_state = 5) AND (r.outcome >= 3) AND (r.outcome <= 4 OR r.outcome >= 7) AND (r.outcome <= 7) ";
1713 1713
     break;
1714
-  }
1714
+    }
1715 1715
 
1716
-  if (is_numeric($app_id) AND $app_id>0 ) {
1716
+    if (is_numeric($app_id) AND $app_id>0 ) {
1717 1717
     $sqlsub .= " AND appid = '%s'";
1718 1718
     $dbres_sub = pager_query( $sqlsub . tablesort_sql($resultheader), 20, 0, NULL, $queryid, $app_id);
1719
-  }
1720
-  else {
1719
+    }
1720
+    else {
1721 1721
     $dbres_sub = pager_query( $sqlsub . tablesort_sql($resultheader), 20, 0, NULL, $queryid);
1722
-  }
1723
-  db_set_active('default');
1722
+    }
1723
+    db_set_active('default');
1724 1724
 
1725
-  // Loop 2 over DB results.
1726
-  if ($dbres_sub) {
1725
+    // Loop 2 over DB results.
1726
+    if ($dbres_sub) {
1727 1727
     while ($result = db_fetch_object($dbres_sub)) {
1728
-      // check if state matches selection
1729
-      if ( (state_num($result) == $tselect) OR ($tselect==STATE_ALL) ) {
1728
+        // check if state matches selection
1729
+        if ( (state_num($result) == $tselect) OR ($tselect==STATE_ALL) ) {
1730 1730
         // create pretty result row
1731 1731
         $prettyresult = array(
1732
-          array(
1732
+            array(
1733 1733
             'data' => l($result->name, "task/{$result->id}"),
1734 1734
             'class' => 'task-name',
1735
-          ),
1736
-          l($result->workunitid, "workunit/{$result->workunitid}"),
1737
-          l($result->hostid, "host/{$result->hostid}"),
1738
-          time_str($result->sent_time),
1739
-          boincwork_task_time_reported($result->received_time, $result->report_deadline),
1740
-          state_string($result),
1741
-          $nf->format($result->elapsed_time),
1742
-          $nf->format($result->result_cpu_time),
1743
-          $nf->format($result->claimed_credit),
1744
-          $nf->format($result->granted_credit),
1745
-          array(
1735
+            ),
1736
+            l($result->workunitid, "workunit/{$result->workunitid}"),
1737
+            l($result->hostid, "host/{$result->hostid}"),
1738
+            time_str($result->sent_time),
1739
+            boincwork_task_time_reported($result->received_time, $result->report_deadline),
1740
+            state_string($result),
1741
+            $nf->format($result->elapsed_time),
1742
+            $nf->format($result->result_cpu_time),
1743
+            $nf->format($result->claimed_credit),
1744
+            $nf->format($result->granted_credit),
1745
+            array(
1746 1746
             'data' => $result->user_friendly_name,
1747 1747
             'class' => 'task-app',
1748
-          )
1748
+            )
1749 1749
         );
1750 1750
         $resultdata[] = array_values($prettyresult);
1751
-      }
1751
+        }
1752 1752
     }// while
1753
-  }
1754
-  else {
1755
-  }
1756
-  // Begin result navigation
1753
+    }
1754
+    else {
1755
+    }
1756
+    // Begin result navigation
1757 1757
 
1758
-  // Set pathprefix based on type
1759
-  if ($category==0) {
1758
+    // Set pathprefix based on type
1759
+    if ($category==0) {
1760 1760
     $pathprefix = 'account/tasks';
1761
-  }
1762
-  elseif ($category==1) {
1761
+    }
1762
+    elseif ($category==1) {
1763 1763
     $pathprefix = 'workunit/' . $queryid . '/tasks';
1764
-  }
1765
-  elseif ($category==2) {
1764
+    }
1765
+    elseif ($category==2) {
1766 1766
     $pathprefix = 'host/' . $queryid . '/tasks';
1767
-  }
1768
-  // Need an "All" tab as well, maps to app_id of zero.
1769
-  $application_map[0] = bts('All', array(), NULL, 'boinc:task-table');
1770
-  $stitems = array();
1771
-  foreach ($taskstates as $state => $numstates) {
1767
+    }
1768
+    // Need an "All" tab as well, maps to app_id of zero.
1769
+    $application_map[0] = bts('All', array(), NULL, 'boinc:task-table');
1770
+    $stitems = array();
1771
+    foreach ($taskstates as $state => $numstates) {
1772 1772
     $mypath = $pathprefix . '/' . $state . '/' . $app_id;
1773 1773
     if ($state==STATE_ALL) {
1774
-      $ltext = '<span class="tab task-app-name">' . bts('All', array(), NULL, 'boinc:task-table') . '(' . $numstates . ')</span>';
1774
+        $ltext = '<span class="tab task-app-name">' . bts('All', array(), NULL, 'boinc:task-table') . '(' . $numstates . ')</span>';
1775 1775
     }
1776 1776
     else {
1777
-      $ltext = '<span class="tab">' . bts($state_hnames[$state], array(), NULL, 'boinc:task-table') . ' (' . $numstates . ')</span>';
1777
+        $ltext = '<span class="tab">' . bts($state_hnames[$state], array(), NULL, 'boinc:task-table') . ' (' . $numstates . ')</span>';
1778 1778
     }
1779 1779
     $myitem = array(
1780
-      'data' => l($ltext, $mypath, array('html' => TRUE) ),
1780
+        'data' => l($ltext, $mypath, array('html' => TRUE) ),
1781 1781
     );
1782 1782
     if ($state==$tselect) {
1783
-      $myitem['class'] = 'active';
1783
+        $myitem['class'] = 'active';
1784 1784
     }
1785 1785
     $stitems[] = $myitem;
1786
-  }
1787
-  // Add reset button
1788
-  $mypath = $pathprefix . '/0/0';
1789
-  $ltext = '<span class="tab">' . bts('Reset', array(), NULL, 'boinc:task-table') . '</span>';
1790
-  $stitems[] = array( 'data' => l($ltext, $mypath, array('html' => TRUE) ) );
1786
+    }
1787
+    // Add reset button
1788
+    $mypath = $pathprefix . '/0/0';
1789
+    $ltext = '<span class="tab">' . bts('Reset', array(), NULL, 'boinc:task-table') . '</span>';
1790
+    $stitems[] = array( 'data' => l($ltext, $mypath, array('html' => TRUE) ) );
1791 1791
 
1792
-  $output .= theme_item_list($stitems, $title = NULL, $type='ul'. $attributes=' class="tabs secondary clearfix"');
1792
+    $output .= theme_item_list($stitems, $title = NULL, $type='ul'. $attributes=' class="tabs secondary clearfix"');
1793 1793
 
1794
-  // Application select-drop down form
1795
-  // Hack to place Application form into header
1796
-  // App ID of zero maps to "-1" for drop-down box.
1797
-  if ($app_id==0) {
1794
+    // Application select-drop down form
1795
+    // Hack to place Application form into header
1796
+    // App ID of zero maps to "-1" for drop-down box.
1797
+    if ($app_id==0) {
1798 1798
     $app_id=-1;
1799
-  }
1800
-  $resultheader[] = drupal_get_form('boincwork_selectapp_form', $applications, $app_id);
1799
+    }
1800
+    $resultheader[] = drupal_get_form('boincwork_selectapp_form', $applications, $app_id);
1801 1801
 
1802
-  // Begin table of results
1803
-  if ( is_array($resultheader) AND is_array($resultdata) ) {
1802
+    // Begin table of results
1803
+    if ( is_array($resultheader) AND is_array($resultdata) ) {
1804 1804
 
1805 1805
     // Take advantage of the fact that $category is the same as the row/column we want to remove.
1806 1806
     if ( ($category==1) OR ($category==2) ) {
1807
-      unset($resultheader[$category]);
1808
-      delete_col($resultdata, $category);
1807
+        unset($resultheader[$category]);
1808
+        delete_col($resultdata, $category);
1809 1809
     }
1810 1810
 
1811 1811
     $output .= theme_table($resultheader, $resultdata);
1812 1812
     if (count($resultdata) > 0) {
1813
-      $output .= theme('pager');
1813
+        $output .= theme('pager');
1814 1814
     }
1815
-  }
1816
-  return $output;
1815
+    }
1816
+    return $output;
1817 1817
 }
1818 1818
 
1819 1819
 /**
1820 1820
  * Function to delete a column from an array.
1821 1821
  */
1822 1822
 function delete_col(&$array, $offset) {
1823
-  return array_walk($array, function (&$v) use ($offset) {
1824
-     array_splice($v, $offset, 1);
1825
-  });
1823
+    return array_walk($array, function (&$v) use ($offset) {
1824
+        array_splice($v, $offset, 1);
1825
+    });
1826 1826
 }
1827 1827
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
   
168 168
   if ($preset) {
169 169
     // Load preset from configuration
170
-    $preset_prefs = (array) $preset_prefs['general_preferences'];
170
+    $preset_prefs = (array)$preset_prefs['general_preferences'];
171 171
     if (isset($preset_prefs['preset'])) {
172 172
       if (!is_numeric(key($preset_prefs['preset']))) {
173 173
         $preset_prefs['preset'] = array($preset_prefs['preset']);
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 function boincwork_get_project_specific_config() {
189 189
   $raw_config_data = variable_get('boinc_project_specific_prefs_config', '');
190 190
   
191
-  $xsd = './' . drupal_get_path('module', 'boincwork') . '/includes/projectprefs.xsd';
191
+  $xsd = './'.drupal_get_path('module', 'boincwork').'/includes/projectprefs.xsd';
192 192
   libxml_use_internal_errors(true);
193 193
   
194 194
   $xml = new DomDocument();
@@ -196,8 +196,8 @@  discard block
 block discarded – undo
196 196
   if (!$xml->schemaValidate($xsd)) {
197 197
     $errors = libxml_get_errors();
198 198
     $lines = explode("\r", $raw_config_data);
199
-    drupal_set_message("{$errors[0]->message} at line {$errors[0]->line}" .
200
-      ': <br/>' . htmlentities($lines[$errors[0]->line - 1]), 'error');
199
+    drupal_set_message("{$errors[0]->message} at line {$errors[0]->line}".
200
+      ': <br/>'.htmlentities($lines[$errors[0]->line - 1]), 'error');
201 201
     return NULL;
202 202
   }
203 203
   
@@ -392,13 +392,13 @@  discard block
 block discarded – undo
392 392
       
393 393
       // Use appropriate datatype
394 394
       if (isset($element['@attributes']['datatype'])) {
395
-        switch($element['@attributes']['datatype']) {
395
+        switch ($element['@attributes']['datatype']) {
396 396
         case 'integer':
397
-          $value = (int) $value;
397
+          $value = (int)$value;
398 398
           break;
399 399
           
400 400
         case 'float':
401
-          $value = number_format((float) $value, 2);
401
+          $value = number_format((float)$value, 2);
402 402
           break;
403 403
         
404 404
         default:
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
         '#type' => 'textfield',
421 421
         '#default_value' => $value,
422 422
         '#size' => 5,
423
-        '#description' => $description . bts(' Default value: @default', array('@default' => $default), NULL, 'boinc:account-preferences-project')
423
+        '#description' => $description.bts(' Default value: @default', array('@default' => $default), NULL, 'boinc:account-preferences-project')
424 424
       );
425 425
     }
426 426
     break;
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
       $name = $element['@attributes']['name'];
485 485
       $default = null;
486 486
       $options = array();
487
-      foreach($element['items']['item'] as $item) {
487
+      foreach ($element['items']['item'] as $item) {
488 488
         if (is_array($item)) {
489 489
           $value = $item['@value'];
490 490
           if ($default === NULL AND
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
         '#options' => $options,
527 527
         '#attributes' => array('class' => 'fancy'),
528 528
         '#default_value' => $value,
529
-        '#description' => $description . bts(' Default value: @default', array('@default' =>$default), NULL, 'boinc:account-preferences-project')
529
+        '#description' => $description.bts(' Default value: @default', array('@default' =>$default), NULL, 'boinc:account-preferences-project')
530 530
       );
531 531
     }
532 532
     break;
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
     }
592 592
     foreach ($elements as $key => $element) {
593 593
       $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
594
-      $name = str_replace(' ','_',strtolower($title));
594
+      $name = str_replace(' ', '_', strtolower($title));
595 595
       $name = "group_{$name}";
596 596
       
597 597
       // Translate elements as appropriate
@@ -743,13 +743,13 @@  discard block
 block discarded – undo
743 743
   if ($type == 'project') {
744 744
     if ($boincuser->project_prefs) {
745 745
       $main_prefs = load_configuration($boincuser->project_prefs);
746
-      $main_prefs = (array) $main_prefs['project_preferences'];
746
+      $main_prefs = (array)$main_prefs['project_preferences'];
747 747
     }
748 748
   }
749 749
   else {
750 750
     if ($boincuser->global_prefs) {
751 751
       $main_prefs = load_configuration($boincuser->global_prefs);
752
-      $main_prefs = (array) $main_prefs['global_preferences'];
752
+      $main_prefs = (array)$main_prefs['global_preferences'];
753 753
     }
754 754
   }
755 755
   
@@ -801,13 +801,13 @@  discard block
 block discarded – undo
801 801
   if ($type == 'project') {
802 802
     if ($boincuser->project_prefs) {
803 803
       $main_prefs = load_configuration($boincuser->project_prefs);
804
-      $main_prefs = (array) $main_prefs['project_preferences'];
804
+      $main_prefs = (array)$main_prefs['project_preferences'];
805 805
     }
806 806
   }
807 807
   else {
808 808
     if ($boincuser->global_prefs) {
809 809
       $main_prefs = load_configuration($boincuser->global_prefs);
810
-      $main_prefs = (array) $main_prefs['global_preferences'];
810
+      $main_prefs = (array)$main_prefs['global_preferences'];
811 811
     }
812 812
   }
813 813
   
@@ -996,11 +996,11 @@  discard block
 block discarded – undo
996 996
   $magnitude = 0;
997 997
   $precision = 0;
998 998
   if ($digits > $max_digits) {
999
-    $magnitude = floor(($digits - ($max_digits - 3)) / 3);
1000
-    $precision = $max_digits - ($digits - ($magnitude * 3) + 1);
1001
-    $number = round($number / pow(1000, $magnitude), $precision);
999
+    $magnitude = floor(($digits - ($max_digits - 3))/3);
1000
+    $precision = $max_digits - ($digits - ($magnitude*3) + 1);
1001
+    $number = round($number/pow(1000, $magnitude), $precision);
1002 1002
   }
1003
-  $number = number_format($number, $precision) . (($magnitude) ? "{$suffix[$magnitude]}" : '');
1003
+  $number = number_format($number, $precision).(($magnitude) ? "{$suffix[$magnitude]}" : '');
1004 1004
   
1005 1005
   return $number;
1006 1006
 }
@@ -1178,7 +1178,7 @@  discard block
 block discarded – undo
1178 1178
   
1179 1179
   function text_to_xml($text) {
1180 1180
     $xml = new DomDocument();
1181
-    if ( !($xml->loadXML($text)) ) return false;
1181
+    if (!($xml->loadXML($text))) return false;
1182 1182
     return $xml;
1183 1183
   }
1184 1184
   
@@ -1195,7 +1195,7 @@  discard block
 block discarded – undo
1195 1195
       while (!is_null($node)) {
1196 1196
           switch ($node->nodeType) {
1197 1197
           case XML_TEXT_NODE:
1198
-              if (trim($node->nodeValue)  != '') $result = $node->nodeValue;
1198
+              if (trim($node->nodeValue) != '') $result = $node->nodeValue;
1199 1199
               break;
1200 1200
           case XML_ELEMENT_NODE:
1201 1201
               $node_name = $node->nodeName;
@@ -1212,7 +1212,7 @@  discard block
 block discarded – undo
1212 1212
               if ($sibling) {
1213 1213
                   $result[$node_name][$index] = '';
1214 1214
                   if ($node->childNodes) {
1215
-                      $result[$node_name][$index] = xml_to_array($node) ;
1215
+                      $result[$node_name][$index] = xml_to_array($node);
1216 1216
                   }
1217 1217
                   if ($node->hasAttributes()) {
1218 1218
                       $attributes = $node->attributes;
@@ -1235,14 +1235,14 @@  discard block
 block discarded – undo
1235 1235
               } else {
1236 1236
                   $result[$node_name] = '';
1237 1237
                   if ($node->childNodes) {
1238
-                      $result[$node_name] = xml_to_array($node) ;
1238
+                      $result[$node_name] = xml_to_array($node);
1239 1239
                   }
1240 1240
                   if ($node->hasAttributes()) {
1241 1241
                       $attributes = $node->attributes;
1242 1242
                       if ($result[$node_name] !== '' AND !is_array($result[$node_name])) {
1243 1243
                           $result[$node_name] = array('@value' => $result[$node_name]);
1244 1244
                       }
1245
-                      foreach($attributes as $key => $attribute) {
1245
+                      foreach ($attributes as $key => $attribute) {
1246 1246
                           $result[$node_name]['@attributes'][$attribute->name] = $attribute->value;
1247 1247
                       }
1248 1248
                   }
@@ -1282,30 +1282,30 @@  discard block
 block discarded – undo
1282 1282
   // Determine if hosts are associated at all or just hidden
1283 1283
   $output = '';
1284 1284
   if ($boincuser->show_hosts) {
1285
-    switch($context) {
1285
+    switch ($context) {
1286 1286
     case 'active':
1287
-      $output .=  '<h2>' . bts('No active computers', array(), NULL, 'boinc:host-list') . '</h2>';
1288
-      $output .=  '<p>' . bts('This user has no computers that have been'
1289
-      . ' active in the last 30 days.', array(), NULL, 'boinc:host-list') . '</p>';
1287
+      $output .= '<h2>'.bts('No active computers', array(), NULL, 'boinc:host-list').'</h2>';
1288
+      $output .= '<p>'.bts('This user has no computers that have been'
1289
+      . ' active in the last 30 days.', array(), NULL, 'boinc:host-list').'</p>';
1290 1290
       break;
1291 1291
       
1292 1292
     case 'preferences':
1293
-      $output .=  '<h2>' . bts('No computers', array(), NULL, 'boinc:host-list') . '</h2>';
1294
-      $output .=  '<p>' . bts('There are no computers assigned to this'
1295
-      . ' preference set.', array(), NULL, 'boinc:host-list') . '</p>';
1293
+      $output .= '<h2>'.bts('No computers', array(), NULL, 'boinc:host-list').'</h2>';
1294
+      $output .= '<p>'.bts('There are no computers assigned to this'
1295
+      . ' preference set.', array(), NULL, 'boinc:host-list').'</p>';
1296 1296
       break;
1297 1297
     
1298 1298
     default:
1299
-      $output .=  '<h2>' . bts('Computers pending', array(), NULL, 'boinc:host-list') . '</h2>';
1300
-      $output .=  '<p>' . bts('This user does not yet have any associated'
1299
+      $output .= '<h2>'.bts('Computers pending', array(), NULL, 'boinc:host-list').'</h2>';
1300
+      $output .= '<p>'.bts('This user does not yet have any associated'
1301 1301
       . ' computers. Computers will be displayed when they have earned their'
1302
-      . ' first credits.', array(), NULL, 'boinc:host-list') . '</p>';
1302
+      . ' first credits.', array(), NULL, 'boinc:host-list').'</p>';
1303 1303
     }
1304 1304
   }
1305 1305
   else {
1306
-    $output .=  '<h2>' . bts('Computers hidden', array(), NULL, 'boinc:host-list') . '</h2>';
1307
-    $output .=  '<p>' . bts('This user has chosen not to show information'
1308
-    . ' about their computers.', array(), NULL, 'boinc:host-list') . '</p>';
1306
+    $output .= '<h2>'.bts('Computers hidden', array(), NULL, 'boinc:host-list').'</h2>';
1307
+    $output .= '<p>'.bts('This user has chosen not to show information'
1308
+    . ' about their computers.', array(), NULL, 'boinc:host-list').'</p>';
1309 1309
   }
1310 1310
   return $output;
1311 1311
 }
@@ -1317,11 +1317,11 @@  discard block
 block discarded – undo
1317 1317
   
1318 1318
   // 
1319 1319
   $output = '';
1320
-  switch($context) {
1320
+  switch ($context) {
1321 1321
   default:
1322
-    $output .=  '<h2>' . bts('No @type tasks', array('@type' => $context), NULL, 'boinc:task-list')
1322
+    $output .= '<h2>'.bts('No @type tasks', array('@type' => $context), NULL, 'boinc:task-list')
1323 1323
     . '</h2>';
1324
-    $output .=  '<p>' . bts('There are no tasks of this type on record', array(), NULL, 'boinc:task-list')
1324
+    $output .= '<p>'.bts('There are no tasks of this type on record', array(), NULL, 'boinc:task-list')
1325 1325
     . '</p>';
1326 1326
   }
1327 1327
   return $output;
@@ -1343,10 +1343,10 @@  discard block
 block discarded – undo
1343 1343
       $output .= l(bts('Delete', array(), NULL, 'boinc:form-delete'), "host/{$host_id}/delete",
1344 1344
         array(
1345 1345
           'attributes' => array(
1346
-            'onclick' => 'return confirm(\'' . bts('This will delete host @id'
1346
+            'onclick' => 'return confirm(\''.bts('This will delete host @id'
1347 1347
               . ' from your account forever. Are you sure this is OK?',
1348 1348
               array('@id' => $host_id),
1349
-              NULL, 'boinc:account-host-delete') . '\')'
1349
+              NULL, 'boinc:account-host-delete').'\')'
1350 1350
           )
1351 1351
         )
1352 1352
       );
@@ -1410,7 +1410,7 @@  discard block
 block discarded – undo
1410 1410
   $root_log_dir = variable_get('boinc_host_sched_logs_dir', '');
1411 1411
   $log = '';
1412 1412
   if ($timestamp) {
1413
-    $output = gmdate('j M Y | G:i:s', $timestamp) . ' UTC';
1413
+    $output = gmdate('j M Y | G:i:s', $timestamp).' UTC';
1414 1414
   }
1415 1415
   if ($root_log_dir AND $host_id) {
1416 1416
     $subdir = substr($host_id, 0, -3) OR $subdir = 0;
@@ -1436,8 +1436,8 @@  discard block
 block discarded – undo
1436 1436
       "{$path}/school" => bts('School', array(), NULL, 'boinc:account-preferences-location')
1437 1437
     );
1438 1438
     variable_set('jump_use_js_venues-Array', 1);
1439
-    drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js');
1440
-    drupal_add_js(drupal_get_path('theme', 'boinc') . '/js/prefs.js', 'theme');
1439
+    drupal_add_js(drupal_get_path('module', 'jump').'/jump.js');
1440
+    drupal_add_js(drupal_get_path('theme', 'boinc').'/js/prefs.js', 'theme');
1441 1441
     // Get current venue
1442 1442
     db_set_active('boinc');
1443 1443
     $venue = db_result(db_query(
@@ -1457,14 +1457,14 @@  discard block
 block discarded – undo
1457 1457
   $output = '---';
1458 1458
   if ($received_time OR $deadline) {
1459 1459
     $timestamp = ($received_time) ? $received_time : $deadline;
1460
-    $output = gmdate('j M Y, G:i:s', $timestamp) . ' UTC';
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 1463
       if (time() < $deadline) {
1464
-        $output = '<span class="on-time">' . $output . '</span>';
1464
+        $output = '<span class="on-time">'.$output.'</span>';
1465 1465
       }
1466 1466
       else {
1467
-        $output = '<span class="past-due">' . $output . '</span>';
1467
+        $output = '<span class="past-due">'.$output.'</span>';
1468 1468
       }
1469 1469
     }
1470 1470
   }
@@ -1498,15 +1498,15 @@  discard block
 block discarded – undo
1498 1498
  */
1499 1499
 function boincwork_tasktable($category = 0, $queryid = 1, $tselect = NULL, $app_id = 0) {
1500 1500
   // Check type parameter, if not (0,2) then return an error.
1501
-  if ( ($category!=0) AND ($category!=1) AND ($category!=2) ) {
1501
+  if (($category != 0) AND ($category != 1) AND ($category != 2)) {
1502 1502
     watchdog('boincwork', 'task table called with invalid category = %category', array('%category' => $category), WATCHDOG_WARNING);
1503 1503
     return '';
1504 1504
   }
1505 1505
 
1506
-  require_boinc( array('util', 'result') );
1506
+  require_boinc(array('util', 'result'));
1507 1507
 
1508 1508
   global $language;
1509
-  $locality=$language->language;
1509
+  $locality = $language->language;
1510 1510
   $nf = new NumberFormatter($locality, NumberFormatter::DECIMAL);
1511 1511
 
1512 1512
   $output = '';
@@ -1553,13 +1553,13 @@  discard block
 block discarded – undo
1553 1553
       ."WHERE deprecated=0 ";
1554 1554
 
1555 1555
   // Use userid, hostid, or workunitid
1556
-  if ($category==0) {
1556
+  if ($category == 0) {
1557 1557
     $sqlall .= "AND r.userid='%s' ";
1558 1558
   }
1559
-  elseif ($category==1) {
1559
+  elseif ($category == 1) {
1560 1560
     $sqlall .= "AND r.workunitid='%s' ";
1561 1561
   }
1562
-  elseif ($category==2) {
1562
+  elseif ($category == 2) {
1563 1563
     $sqlall .= "AND r.hostid='%s' ";
1564 1564
   }
1565 1565
   $sqlall .= "ORDER BY user_friendly_name";
@@ -1570,7 +1570,7 @@  discard block
 block discarded – undo
1570 1570
   if ($dbres_all) {
1571 1571
     while ($result = db_fetch_object($dbres_all)) {
1572 1572
       $mystate = state_num($result);
1573
-      if ( ($result->appid==$app_id) OR ($app_id==0) OR ($app_id==-1) ) {
1573
+      if (($result->appid == $app_id) OR ($app_id == 0) OR ($app_id == -1)) {
1574 1574
         $taskstates[STATE_ALL]++;
1575 1575
         switch ($mystate) {
1576 1576
         case STATE_IN_PROGRESS:
@@ -1593,7 +1593,7 @@  discard block
 block discarded – undo
1593 1593
 
1594 1594
       //map holds a map between app ids and user friendly names for all applications.
1595 1595
       $application_map[$result->appid] = $result->user_friendly_name;
1596
-      if ( ($mystate == $tselect) OR ($tselect==STATE_ALL) ) {
1596
+      if (($mystate == $tselect) OR ($tselect == STATE_ALL)) {
1597 1597
         //count of appids in the results.
1598 1598
         $application_select_count[$result->appid]++;
1599 1599
       }// if mystate
@@ -1606,14 +1606,14 @@  discard block
 block discarded – undo
1606 1606
   // Entry for all applications.
1607 1607
   $allcount = $application_select_count ? array_sum($application_select_count) : 0;
1608 1608
   $applications[-1] = bts('Application', array(), NULL, 'boinc:task-table');
1609
-  $applications[0] = bts('All applications', array(), NULL, 'boinc:task-table') . '(' . $allcount . ')';
1609
+  $applications[0] = bts('All applications', array(), NULL, 'boinc:task-table').'('.$allcount.')';
1610 1610
   // Create application filter from application_map and application_select_count.
1611
-  foreach($application_map as $akey => $aname) {
1611
+  foreach ($application_map as $akey => $aname) {
1612 1612
     $acount = 0;
1613
-    if ( $application_select_count and array_key_exists($akey, $application_select_count) ) {
1613
+    if ($application_select_count and array_key_exists($akey, $application_select_count)) {
1614 1614
       $acount = $application_select_count[$akey];
1615 1615
     }
1616
-    $applications[$akey] = $aname . ' ('. $acount . ')';
1616
+    $applications[$akey] = $aname.' ('.$acount.')';
1617 1617
   }
1618 1618
   // Header array for (sub) results table.
1619 1619
   $resultheader = array(
@@ -1684,13 +1684,13 @@  discard block
 block discarded – undo
1684 1684
       ."WHERE a.deprecated = 0 ";
1685 1685
 
1686 1686
   // Use userid, hostid, or workunitid
1687
-  if ($category==0) {
1687
+  if ($category == 0) {
1688 1688
     $sqlsub .= "AND r.userid = '%s' ";
1689 1689
   }
1690
-  elseif ($category==1) {
1690
+  elseif ($category == 1) {
1691 1691
     $sqlsub .= "AND r.workunitid = '%s' ";
1692 1692
   }
1693
-  elseif ($category==2) {
1693
+  elseif ($category == 2) {
1694 1694
     $sqlsub .= "AND r.hostid = '%s' ";
1695 1695
   }
1696 1696
 
@@ -1713,12 +1713,12 @@  discard block
 block discarded – undo
1713 1713
     break;
1714 1714
   }
1715 1715
 
1716
-  if (is_numeric($app_id) AND $app_id>0 ) {
1716
+  if (is_numeric($app_id) AND $app_id > 0) {
1717 1717
     $sqlsub .= " AND appid = '%s'";
1718
-    $dbres_sub = pager_query( $sqlsub . tablesort_sql($resultheader), 20, 0, NULL, $queryid, $app_id);
1718
+    $dbres_sub = pager_query($sqlsub.tablesort_sql($resultheader), 20, 0, NULL, $queryid, $app_id);
1719 1719
   }
1720 1720
   else {
1721
-    $dbres_sub = pager_query( $sqlsub . tablesort_sql($resultheader), 20, 0, NULL, $queryid);
1721
+    $dbres_sub = pager_query($sqlsub.tablesort_sql($resultheader), 20, 0, NULL, $queryid);
1722 1722
   }
1723 1723
   db_set_active('default');
1724 1724
 
@@ -1726,7 +1726,7 @@  discard block
 block discarded – undo
1726 1726
   if ($dbres_sub) {
1727 1727
     while ($result = db_fetch_object($dbres_sub)) {
1728 1728
       // check if state matches selection
1729
-      if ( (state_num($result) == $tselect) OR ($tselect==STATE_ALL) ) {
1729
+      if ((state_num($result) == $tselect) OR ($tselect == STATE_ALL)) {
1730 1730
         // create pretty result row
1731 1731
         $prettyresult = array(
1732 1732
           array(
@@ -1756,54 +1756,54 @@  discard block
 block discarded – undo
1756 1756
   // Begin result navigation
1757 1757
 
1758 1758
   // Set pathprefix based on type
1759
-  if ($category==0) {
1759
+  if ($category == 0) {
1760 1760
     $pathprefix = 'account/tasks';
1761 1761
   }
1762
-  elseif ($category==1) {
1763
-    $pathprefix = 'workunit/' . $queryid . '/tasks';
1762
+  elseif ($category == 1) {
1763
+    $pathprefix = 'workunit/'.$queryid.'/tasks';
1764 1764
   }
1765
-  elseif ($category==2) {
1766
-    $pathprefix = 'host/' . $queryid . '/tasks';
1765
+  elseif ($category == 2) {
1766
+    $pathprefix = 'host/'.$queryid.'/tasks';
1767 1767
   }
1768 1768
   // Need an "All" tab as well, maps to app_id of zero.
1769 1769
   $application_map[0] = bts('All', array(), NULL, 'boinc:task-table');
1770 1770
   $stitems = array();
1771 1771
   foreach ($taskstates as $state => $numstates) {
1772
-    $mypath = $pathprefix . '/' . $state . '/' . $app_id;
1773
-    if ($state==STATE_ALL) {
1774
-      $ltext = '<span class="tab task-app-name">' . bts('All', array(), NULL, 'boinc:task-table') . '(' . $numstates . ')</span>';
1772
+    $mypath = $pathprefix.'/'.$state.'/'.$app_id;
1773
+    if ($state == STATE_ALL) {
1774
+      $ltext = '<span class="tab task-app-name">'.bts('All', array(), NULL, 'boinc:task-table').'('.$numstates.')</span>';
1775 1775
     }
1776 1776
     else {
1777
-      $ltext = '<span class="tab">' . bts($state_hnames[$state], array(), NULL, 'boinc:task-table') . ' (' . $numstates . ')</span>';
1777
+      $ltext = '<span class="tab">'.bts($state_hnames[$state], array(), NULL, 'boinc:task-table').' ('.$numstates.')</span>';
1778 1778
     }
1779 1779
     $myitem = array(
1780
-      'data' => l($ltext, $mypath, array('html' => TRUE) ),
1780
+      'data' => l($ltext, $mypath, array('html' => TRUE)),
1781 1781
     );
1782
-    if ($state==$tselect) {
1782
+    if ($state == $tselect) {
1783 1783
       $myitem['class'] = 'active';
1784 1784
     }
1785 1785
     $stitems[] = $myitem;
1786 1786
   }
1787 1787
   // Add reset button
1788
-  $mypath = $pathprefix . '/0/0';
1789
-  $ltext = '<span class="tab">' . bts('Reset', array(), NULL, 'boinc:task-table') . '</span>';
1790
-  $stitems[] = array( 'data' => l($ltext, $mypath, array('html' => TRUE) ) );
1788
+  $mypath = $pathprefix.'/0/0';
1789
+  $ltext = '<span class="tab">'.bts('Reset', array(), NULL, 'boinc:task-table').'</span>';
1790
+  $stitems[] = array('data' => l($ltext, $mypath, array('html' => TRUE)));
1791 1791
 
1792
-  $output .= theme_item_list($stitems, $title = NULL, $type='ul'. $attributes=' class="tabs secondary clearfix"');
1792
+  $output .= theme_item_list($stitems, $title = NULL, $type = 'ul'.$attributes = ' class="tabs secondary clearfix"');
1793 1793
 
1794 1794
   // Application select-drop down form
1795 1795
   // Hack to place Application form into header
1796 1796
   // App ID of zero maps to "-1" for drop-down box.
1797
-  if ($app_id==0) {
1798
-    $app_id=-1;
1797
+  if ($app_id == 0) {
1798
+    $app_id = -1;
1799 1799
   }
1800 1800
   $resultheader[] = drupal_get_form('boincwork_selectapp_form', $applications, $app_id);
1801 1801
 
1802 1802
   // Begin table of results
1803
-  if ( is_array($resultheader) AND is_array($resultdata) ) {
1803
+  if (is_array($resultheader) AND is_array($resultdata)) {
1804 1804
 
1805 1805
     // Take advantage of the fact that $category is the same as the row/column we want to remove.
1806
-    if ( ($category==1) OR ($category==2) ) {
1806
+    if (($category == 1) OR ($category == 2)) {
1807 1807
       unset($resultheader[$category]);
1808 1808
       delete_col($resultdata, $category);
1809 1809
     }
@@ -1820,7 +1820,7 @@  discard block
 block discarded – undo
1820 1820
  * Function to delete a column from an array.
1821 1821
  */
1822 1822
 function delete_col(&$array, $offset) {
1823
-  return array_walk($array, function (&$v) use ($offset) {
1823
+  return array_walk($array, function(&$v) use ($offset) {
1824 1824
      array_splice($v, $offset, 1);
1825 1825
   });
1826 1826
 }
1827 1827
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +39 added lines, -68 removed lines patch added patch discarded remove patch
@@ -332,8 +332,7 @@  discard block
 block discarded – undo
332 332
         $name = $element['@attributes']['name'];
333 333
         if (isset($element['@attributes']['entitytype']) AND $element['@attributes']['entitytype'] == 'attribute') {
334 334
           $defaults['@attributes'][$name] = $values[$name];
335
-        }
336
-        else {
335
+        } else {
337 336
           $defaults[$name] = $values[$name];
338 337
         }
339 338
       }
@@ -384,8 +383,7 @@  discard block
 block discarded – undo
384 383
       if (isset($user_pref[$name])) {
385 384
         if (is_array($user_pref[$name]) AND isset($user_pref[$name]['@value'])) {
386 385
           $value = $user_pref[$name]['@value'];
387
-        }
388
-        else {
386
+        } else {
389 387
           $value = $user_pref[$name];
390 388
         }
391 389
       }
@@ -447,8 +445,7 @@  discard block
 block discarded – undo
447 445
       if (isset($user_pref[$name])) {
448 446
         if (is_array($user_pref[$name]) AND isset($user_pref[$name]['@value'])) {
449 447
           $value = $user_pref[$name]['@value'];
450
-        }
451
-        else {
448
+        } else {
452 449
           $value = $user_pref[$name];
453 450
         }
454 451
       }
@@ -492,8 +489,7 @@  discard block
 block discarded – undo
492 489
               isset($item['@attributes']['selected'])) {
493 490
             $default = ($item['@attributes']['selected'] == 'true') ? $item['@value'] : null;
494 491
           }
495
-        }
496
-        else {
492
+        } else {
497 493
           $value = $item;
498 494
         }
499 495
         $options[$value] = $value;
@@ -696,8 +692,7 @@  discard block
 block discarded – undo
696 692
       );
697 693
       if ($top_level) {
698 694
         $uncategorized[$key] = $prefs_element;
699
-      }
700
-      else {
695
+      } else {
701 696
         $prefs_table[$key] = $prefs_element;
702 697
       }
703 698
       break;
@@ -711,8 +706,7 @@  discard block
 block discarded – undo
711 706
       'name' => bts('Other settings', array(), NULL, 'boinc:account-preferences'),
712 707
       'elements' => $uncategorized,
713 708
     );
714
-  }
715
-  elseif ($uncategorized) {
709
+  } elseif ($uncategorized) {
716 710
     // If nothing is categorized, output all prefs under a general "settings"
717 711
     $prefs_table['settings'] = array(
718 712
       'name' => bts('Settings', array(), NULL, 'boinc:account-preferences'),
@@ -745,8 +739,7 @@  discard block
 block discarded – undo
745 739
       $main_prefs = load_configuration($boincuser->project_prefs);
746 740
       $main_prefs = (array) $main_prefs['project_preferences'];
747 741
     }
748
-  }
749
-  else {
742
+  } else {
750 743
     if ($boincuser->global_prefs) {
751 744
       $main_prefs = load_configuration($boincuser->global_prefs);
752 745
       $main_prefs = (array) $main_prefs['global_preferences'];
@@ -762,8 +755,7 @@  discard block
 block discarded – undo
762 755
     if (count($main_prefs) < 3)
763 756
         $main_prefs['@attributes'] = array('cleared' => 1);
764 757
     return $main_prefs;
765
-  }
766
-  else {
758
+  } else {
767 759
     if (isset($main_prefs['venue'])) {
768 760
       if (!is_numeric(key($main_prefs['venue']))) {
769 761
         $main_prefs['venue'] = array($main_prefs['venue']);
@@ -803,8 +795,7 @@  discard block
 block discarded – undo
803 795
       $main_prefs = load_configuration($boincuser->project_prefs);
804 796
       $main_prefs = (array) $main_prefs['project_preferences'];
805 797
     }
806
-  }
807
-  else {
798
+  } else {
808 799
     if ($boincuser->global_prefs) {
809 800
       $main_prefs = load_configuration($boincuser->global_prefs);
810 801
       $main_prefs = (array) $main_prefs['global_preferences'];
@@ -817,8 +808,7 @@  discard block
 block discarded – undo
817 808
   if (!$venue OR $venue == 'generic') {
818 809
     //$main_prefs = $prefs;
819 810
     $main_prefs = $prefs + $main_prefs;
820
-  }
821
-  else {
811
+  } else {
822 812
     if (isset($main_prefs['venue'])) {
823 813
       if (!is_numeric(key($main_prefs['venue']))) {
824 814
         $main_prefs['venue'] = array($main_prefs['venue']);
@@ -827,8 +817,7 @@  discard block
 block discarded – undo
827 817
         if (isset($prefs_venue['@attributes']['name']) AND $prefs_venue['@attributes']['name'] == $venue) {
828 818
           if ($prefs) {
829 819
             $main_prefs['venue'][$key] = $prefs;
830
-          }
831
-          else {
820
+          } else {
832 821
             // If prefs is null, clear out this preference set
833 822
             unset($main_prefs['venue'][$key]);
834 823
             if (count($main_prefs['venue']) == 0) {
@@ -870,8 +859,7 @@  discard block
 block discarded – undo
870 859
     db_set_active('boinc');
871 860
     $result = db_query("UPDATE user SET project_prefs = '{$boincuser->project_prefs}' WHERE id = '{$boincuser->id}'");
872 861
     db_set_active('default');
873
-  }
874
-  else {
862
+  } else {
875 863
     $main_prefs = array('global_preferences' => $main_prefs);
876 864
     $boincuser->global_prefs = save_configuration($main_prefs);
877 865
     db_set_active('boinc');
@@ -919,15 +907,13 @@  discard block
 block discarded – undo
919 907
       // Process nested form elements
920 908
       $parents[] = $field;
921 909
       boincwork_validate_form($rules, $values[$field], $parents);
922
-    }
923
-    else {
910
+    } else {
924 911
       if ($parents) {
925 912
         // form_set_error() identifies nested form elements with '][' as a
926 913
         // delimiter between each parent and child element
927 914
         $parents[] = $field;
928 915
         $form_field = implode('][', $parents);
929
-      }
930
-      else {
916
+      } else {
931 917
         $form_field = $field;
932 918
       }
933 919
       if (isset($rules['datatype']) AND !boincwork_validate_datatype($values[$field], $rules['datatype'])) {
@@ -1010,8 +996,7 @@  discard block
 block discarded – undo
1010 996
   //  load_configuration(): Convert structured text/xml to array
1011 997
   //------------------------------------------------------------------------------------------------
1012 998
   
1013
-  function load_configuration($text)
1014
-  {
999
+  function load_configuration($text) {
1015 1000
       if (preg_match('/^\<\?xml .*\?\>$/i', $text)) return null;
1016 1001
       if ($xml = text_to_xml($text)) return xml_to_array($xml);
1017 1002
       return false;
@@ -1021,8 +1006,7 @@  discard block
 block discarded – undo
1021 1006
   //  save_configuration(): Convert array to structured text/xml
1022 1007
   //------------------------------------------------------------------------------------------------
1023 1008
   
1024
-  function save_configuration($array)
1025
-  {
1009
+  function save_configuration($array) {
1026 1010
       if ($xml = array_to_xml($array)) return xml_to_text($xml, false, true);
1027 1011
       return false;
1028 1012
   }
@@ -1054,26 +1038,22 @@  discard block
 block discarded – undo
1054 1038
               $ordered_array[$item['@position']] = array(
1055 1039
                 $name => $item
1056 1040
               );
1057
-            }
1058
-            else {
1041
+            } else {
1059 1042
               $unordered_array[] = array(
1060 1043
                 $name => $item
1061 1044
               );
1062 1045
             }
1063 1046
           }
1064
-        }
1065
-        elseif (isset($value['@position'])) {
1047
+        } elseif (isset($value['@position'])) {
1066 1048
           $ordered_array[$value['@position']] = array(
1067 1049
             $name => $value
1068 1050
           );
1069
-        }
1070
-        else {
1051
+        } else {
1071 1052
           $unordered_array[] = array(
1072 1053
             $name => $value
1073 1054
           );
1074 1055
         }
1075
-      }
1076
-      else {
1056
+      } else {
1077 1057
         $unordered_array[] = array(
1078 1058
           $name => $value
1079 1059
         );
@@ -1159,8 +1139,7 @@  discard block
 block discarded – undo
1159 1139
   //  xml_to_text(): Convert an XML DOM object to string format
1160 1140
   //------------------------------------------------------------------------------------------------
1161 1141
   
1162
-  function xml_to_text($xml, $include_xml_declaration = true, $add_carriage_returns = false)
1163
-  {
1142
+  function xml_to_text($xml, $include_xml_declaration = true, $add_carriage_returns = false) {
1164 1143
       $xml->formatOutput = true;
1165 1144
       $text = $xml->saveXML();
1166 1145
       if (!$include_xml_declaration) {
@@ -1203,10 +1182,14 @@  discard block
 block discarded – undo
1203 1182
               $sibling = $node->nextSibling;
1204 1183
               
1205 1184
               // 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;
1185
+              while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) {
1186
+                  $sibling = $sibling->nextSibling;
1187
+              }
1207 1188
               if (!$sibling) {
1208 1189
                   $sibling = $node->previousSibling;
1209
-                  while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->previousSibling;
1190
+                  while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) {
1191
+                      $sibling = $sibling->previousSibling;
1192
+                  }
1210 1193
               }
1211 1194
               
1212 1195
               if ($sibling) {
@@ -1301,8 +1284,7 @@  discard block
 block discarded – undo
1301 1284
       . ' computers. Computers will be displayed when they have earned their'
1302 1285
       . ' first credits.', array(), NULL, 'boinc:host-list') . '</p>';
1303 1286
     }
1304
-  }
1305
-  else {
1287
+  } else {
1306 1288
     $output .=  '<h2>' . bts('Computers hidden', array(), NULL, 'boinc:host-list') . '</h2>';
1307 1289
     $output .=  '<p>' . bts('This user has chosen not to show information'
1308 1290
     . ' about their computers.', array(), NULL, 'boinc:host-list') . '</p>';
@@ -1462,8 +1444,7 @@  discard block
 block discarded – undo
1462 1444
     if (!$received_time) {
1463 1445
       if (time() < $deadline) {
1464 1446
         $output = '<span class="on-time">' . $output . '</span>';
1465
-      }
1466
-      else {
1447
+      } else {
1467 1448
         $output = '<span class="past-due">' . $output . '</span>';
1468 1449
       }
1469 1450
     }
@@ -1555,11 +1536,9 @@  discard block
 block discarded – undo
1555 1536
   // Use userid, hostid, or workunitid
1556 1537
   if ($category==0) {
1557 1538
     $sqlall .= "AND r.userid='%s' ";
1558
-  }
1559
-  elseif ($category==1) {
1539
+  } elseif ($category==1) {
1560 1540
     $sqlall .= "AND r.workunitid='%s' ";
1561
-  }
1562
-  elseif ($category==2) {
1541
+  } elseif ($category==2) {
1563 1542
     $sqlall .= "AND r.hostid='%s' ";
1564 1543
   }
1565 1544
   $sqlall .= "ORDER BY user_friendly_name";
@@ -1599,8 +1578,7 @@  discard block
 block discarded – undo
1599 1578
       }// if mystate
1600 1579
 
1601 1580
     }// while
1602
-  }
1603
-  else {
1581
+  } else {
1604 1582
   }
1605 1583
   
1606 1584
   // Entry for all applications.
@@ -1686,11 +1664,9 @@  discard block
 block discarded – undo
1686 1664
   // Use userid, hostid, or workunitid
1687 1665
   if ($category==0) {
1688 1666
     $sqlsub .= "AND r.userid = '%s' ";
1689
-  }
1690
-  elseif ($category==1) {
1667
+  } elseif ($category==1) {
1691 1668
     $sqlsub .= "AND r.workunitid = '%s' ";
1692
-  }
1693
-  elseif ($category==2) {
1669
+  } elseif ($category==2) {
1694 1670
     $sqlsub .= "AND r.hostid = '%s' ";
1695 1671
   }
1696 1672
 
@@ -1716,8 +1692,7 @@  discard block
 block discarded – undo
1716 1692
   if (is_numeric($app_id) AND $app_id>0 ) {
1717 1693
     $sqlsub .= " AND appid = '%s'";
1718 1694
     $dbres_sub = pager_query( $sqlsub . tablesort_sql($resultheader), 20, 0, NULL, $queryid, $app_id);
1719
-  }
1720
-  else {
1695
+  } else {
1721 1696
     $dbres_sub = pager_query( $sqlsub . tablesort_sql($resultheader), 20, 0, NULL, $queryid);
1722 1697
   }
1723 1698
   db_set_active('default');
@@ -1750,19 +1725,16 @@  discard block
 block discarded – undo
1750 1725
         $resultdata[] = array_values($prettyresult);
1751 1726
       }
1752 1727
     }// while
1753
-  }
1754
-  else {
1728
+  } else {
1755 1729
   }
1756 1730
   // Begin result navigation
1757 1731
 
1758 1732
   // Set pathprefix based on type
1759 1733
   if ($category==0) {
1760 1734
     $pathprefix = 'account/tasks';
1761
-  }
1762
-  elseif ($category==1) {
1735
+  } elseif ($category==1) {
1763 1736
     $pathprefix = 'workunit/' . $queryid . '/tasks';
1764
-  }
1765
-  elseif ($category==2) {
1737
+  } elseif ($category==2) {
1766 1738
     $pathprefix = 'host/' . $queryid . '/tasks';
1767 1739
   }
1768 1740
   // Need an "All" tab as well, maps to app_id of zero.
@@ -1772,8 +1744,7 @@  discard block
 block discarded – undo
1772 1744
     $mypath = $pathprefix . '/' . $state . '/' . $app_id;
1773 1745
     if ($state==STATE_ALL) {
1774 1746
       $ltext = '<span class="tab task-app-name">' . bts('All', array(), NULL, 'boinc:task-table') . '(' . $numstates . ')</span>';
1775
-    }
1776
-    else {
1747
+    } else {
1777 1748
       $ltext = '<span class="tab">' . bts($state_hnames[$state], array(), NULL, 'boinc:task-table') . ' (' . $numstates . ')</span>';
1778 1749
     }
1779 1750
     $myitem = array(
Please login to merge, or discard this patch.
Upper-Lower-Casing   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
         $preset_prefs['preset'] = array($preset_prefs['preset']);
174 174
       }
175 175
       foreach ($preset_prefs['preset'] as $key => $prefs) {
176
-        if (isset($prefs['@attributes']['name']) AND $prefs['@attributes']['name'] == $preset) {
176
+        if (isset($prefs['@attributes']['name']) and $prefs['@attributes']['name'] == $preset) {
177 177
           return $preset_prefs['preset'][$key];
178 178
         }
179 179
       }
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
     $lines = explode("\r", $raw_config_data);
199 199
     drupal_set_message("{$errors[0]->message} at line {$errors[0]->line}" .
200 200
       ': <br/>' . htmlentities($lines[$errors[0]->line - 1]), 'error');
201
-    return NULL;
201
+    return null;
202 202
   }
203 203
   
204 204
   // Convert XML to array for validation
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
     $xml = $xml['project_specific_preferences'];
218 218
   }
219 219
   foreach ($xml as $type => $elements) {
220
-    if (is_array($elements) AND !is_numeric(key($elements))) {
220
+    if (is_array($elements) and !is_numeric(key($elements))) {
221 221
       $elements = array($elements);
222 222
     }
223 223
     switch ($type) {
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
   }
307 307
   foreach ($xml as $type => $elements) {
308 308
     $structure_data = array();
309
-    if (is_array($elements) AND !is_numeric(key($elements))) {
309
+    if (is_array($elements) and !is_numeric(key($elements))) {
310 310
       $elements = array($elements);
311 311
     }
312 312
     switch ($type) {
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
     case 'boolean':
331 331
       foreach ($elements as $element) {
332 332
         $name = $element['@attributes']['name'];
333
-        if (isset($element['@attributes']['entitytype']) AND $element['@attributes']['entitytype'] == 'attribute') {
333
+        if (isset($element['@attributes']['entitytype']) and $element['@attributes']['entitytype'] == 'attribute') {
334 334
           $defaults['@attributes'][$name] = $values[$name];
335 335
         }
336 336
         else {
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
         $user_pref = $user_prefs['@attributes'];
383 383
       }
384 384
       if (isset($user_pref[$name])) {
385
-        if (is_array($user_pref[$name]) AND isset($user_pref[$name]['@value'])) {
385
+        if (is_array($user_pref[$name]) and isset($user_pref[$name]['@value'])) {
386 386
           $value = $user_pref[$name]['@value'];
387 387
         }
388 388
         else {
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
         '#type' => 'textfield',
421 421
         '#default_value' => $value,
422 422
         '#size' => 5,
423
-        '#description' => $description . bts(' Default value: @default', array('@default' => $default), NULL, 'boinc:account-preferences-project')
423
+        '#description' => $description . bts(' Default value: @default', array('@default' => $default), null, 'boinc:account-preferences-project')
424 424
       );
425 425
     }
426 426
     break;
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
     foreach ($elements as $element) {
433 433
       $name = $element['@attributes']['name'];
434 434
       $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
435
-      $default = (isset($element['@attributes']['selected']) AND $element['@attributes']['selected'] == 'true') ? 1 : 0;
435
+      $default = (isset($element['@attributes']['selected']) and $element['@attributes']['selected'] == 'true') ? 1 : 0;
436 436
       $description = '';
437 437
       if (isset($element['description'])) {
438 438
         $description = is_array($element['description']) ? $element['description']['@value'] : $element['description'];
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
         $user_pref = $user_prefs['@attributes'];
446 446
       }
447 447
       if (isset($user_pref[$name])) {
448
-        if (is_array($user_pref[$name]) AND isset($user_pref[$name]['@value'])) {
448
+        if (is_array($user_pref[$name]) and isset($user_pref[$name]['@value'])) {
449 449
           $value = $user_pref[$name]['@value'];
450 450
         }
451 451
         else {
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
       $form[$name] = array(
467 467
         '#title' => $title,
468 468
         '#type' => 'radios',
469
-        '#options' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')),
469
+        '#options' => array(1 => bts('yes', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')),
470 470
         '#attributes' => array('class' => 'fancy'),
471 471
         '#default_value' => $value,
472 472
         '#description' => $description
@@ -487,8 +487,8 @@  discard block
 block discarded – undo
487 487
       foreach($element['items']['item'] as $item) {
488 488
         if (is_array($item)) {
489 489
           $value = $item['@value'];
490
-          if ($default === NULL AND
491
-              isset($item['@attributes']) AND
490
+          if ($default === null and
491
+              isset($item['@attributes']) and
492 492
               isset($item['@attributes']['selected'])) {
493 493
             $default = ($item['@attributes']['selected'] == 'true') ? $item['@value'] : null;
494 494
           }
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
         '#options' => $options,
527 527
         '#attributes' => array('class' => 'fancy'),
528 528
         '#default_value' => $value,
529
-        '#description' => $description . bts(' Default value: @default', array('@default' =>$default), NULL, 'boinc:account-preferences-project')
529
+        '#description' => $description . bts(' Default value: @default', array('@default' =>$default), null, 'boinc:account-preferences-project')
530 530
       );
531 531
     }
532 532
     break;
@@ -541,11 +541,11 @@  discard block
 block discarded – undo
541 541
       }
542 542
     
543 543
     $form['applications'] = array(
544
-      '#title' => bts('Applications', array(), NULL, 'boinc:account-preferences'),
544
+      '#title' => bts('Applications', array(), null, 'boinc:account-preferences'),
545 545
       '#type' => 'fieldset',
546 546
       '#description' => $title,
547
-      '#collapsible' => TRUE,
548
-      '#collapsed' => FALSE
547
+      '#collapsible' => true,
548
+      '#collapsed' => false
549 549
     );
550 550
     $applications = array();
551 551
     if (!is_array($user_prefs['app_id'])) {
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
     }
554 554
     foreach ($user_prefs['app_id'] as $app) {
555 555
       if (!$app) continue;
556
-      if (is_array($app) AND isset($app['@value'])) {
556
+      if (is_array($app) and isset($app['@value'])) {
557 557
         $app = $app['@value'];
558 558
       }
559 559
       $applications[] = $app;
@@ -561,18 +561,18 @@  discard block
 block discarded – undo
561 561
     foreach ($elements['app'] as $app) {
562 562
       $app_id = $app['@attributes']['id'];
563 563
       $app_name = $app['@value'];
564
-      $app_enabled = TRUE;
565
-      if (isset($app['@attributes']['enabled']) AND
564
+      $app_enabled = true;
565
+      if (isset($app['@attributes']['enabled']) and
566 566
           $app['@attributes']['enabled'] == 'false') {
567
-        $app_enabled = FALSE;
567
+        $app_enabled = false;
568 568
       }
569 569
       if ($applications) {
570 570
         $checked = in_array($app_id, $applications);
571 571
       } else {
572
-        $checked = TRUE;
573
-        if (isset($app['@attributes']['selected']) AND
572
+        $checked = true;
573
+        if (isset($app['@attributes']['selected']) and
574 574
             $app['@attributes']['selected'] == 'false') {
575
-          $checked = FALSE;
575
+          $checked = false;
576 576
         }
577 577
       }
578 578
       $form['applications']["app_{$app_id}"] = array(
@@ -603,10 +603,10 @@  discard block
 block discarded – undo
603 603
       $form[$name] = array(
604 604
           '#title' => $title,
605 605
           '#type' => 'fieldset',
606
-          '#tree' => FALSE,
606
+          '#tree' => false,
607 607
           //'#description' => t('Notes about this group of fields'),
608
-          '#collapsible' => TRUE,
609
-          '#collapsed' => FALSE
608
+          '#collapsible' => true,
609
+          '#collapsed' => false
610 610
       );
611 611
       // Recursively populate the compound element
612 612
       foreach ($element as $child_type => $child) {
@@ -633,8 +633,8 @@  discard block
 block discarded – undo
633 633
           '#title' => $title,
634 634
           '#type' => 'fieldset',
635 635
           //'#description' => t('Notes about this group of fields'),
636
-          '#collapsible' => TRUE,
637
-          '#collapsed' => FALSE
636
+          '#collapsible' => true,
637
+          '#collapsed' => false
638 638
       );
639 639
       // Recursively populate the compound element
640 640
       foreach ($element['attributes'] as $child_type => $child) {
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
  * Generate a tabular structure out of preferences for use in comparison
654 654
  * views of preference sets
655 655
  */
656
-function boincwork_make_prefs_table($prefs, $top_level = TRUE) {
656
+function boincwork_make_prefs_table($prefs, $top_level = true) {
657 657
 
658 658
   $prefs_table = array();
659 659
   $uncategorized = array();
@@ -662,15 +662,15 @@  discard block
 block discarded – undo
662 662
   foreach ($prefs as $key => $element) {
663 663
     
664 664
     // Determine which type of element this is and act accordingly
665
-    $element_type = NULL;
666
-    if (is_array($element) AND isset($element['#type'])) {
665
+    $element_type = null;
666
+    if (is_array($element) and isset($element['#type'])) {
667 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
-        'elements' => boincwork_make_prefs_table($element, FALSE),
673
+        'elements' => boincwork_make_prefs_table($element, false),
674 674
       );
675 675
       break;
676 676
     case 'textfield':
@@ -681,10 +681,10 @@  discard block
 block discarded – undo
681 681
       if (in_array($key, array('start_hour', 'net_start_hour'))) {
682 682
         switch ($key) {
683 683
         case 'start_hour':
684
-          $element['#title'] = bts('Compute only between:', array(), NULL, 'boinc:account-preferences-computing');
684
+          $element['#title'] = bts('Compute only between:', array(), null, 'boinc:account-preferences-computing');
685 685
           break;
686 686
         case 'net_start_hour':
687
-          $element['#title'] = bts('Transfer files only between:', array(), NULL, 'boinc:account-preferences-comuting');
687
+          $element['#title'] = bts('Transfer files only between:', array(), null, 'boinc:account-preferences-comuting');
688 688
           break;
689 689
         default:
690 690
         }
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
       $prefs_element = array(
693 693
         'name' => (isset($element['#title'])) ? $element['#title'] : '',
694 694
         'description' => (isset($element['#description'])) ? $element['#description'] : '',
695
-        'default_value' => (isset($element['#default_value'])) ? $element['#default_value'] : NULL,
695
+        'default_value' => (isset($element['#default_value'])) ? $element['#default_value'] : null,
696 696
       );
697 697
       if ($top_level) {
698 698
         $uncategorized[$key] = $prefs_element;
@@ -705,17 +705,17 @@  discard block
 block discarded – undo
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', array(), NULL, 'boinc:account-preferences'),
711
+      'name' => bts('Other settings', array(), null, 'boinc:account-preferences'),
712 712
       'elements' => $uncategorized,
713 713
     );
714 714
   }
715 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', array(), NULL, 'boinc:account-preferences'),
718
+      'name' => bts('Settings', array(), null, 'boinc:account-preferences'),
719 719
       'elements' => $uncategorized,
720 720
     );
721 721
   }
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
   }
755 755
   
756 756
   // Return general preferences or a subset based on venue
757
-  if (!$venue OR $venue == 'generic') {
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
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
         $main_prefs['venue'] = array($main_prefs['venue']);
770 770
       }
771 771
       foreach ($main_prefs['venue'] as $key => $prefs_venue) {
772
-        if (isset($prefs_venue['@attributes']['name']) AND $prefs_venue['@attributes']['name'] == $venue) {
772
+        if (isset($prefs_venue['@attributes']['name']) and $prefs_venue['@attributes']['name'] == $venue) {
773 773
           return $main_prefs['venue'][$key];
774 774
         }
775 775
       }
@@ -814,7 +814,7 @@  discard block
 block discarded – undo
814 814
   // Save all preferences or a subset based on venue
815 815
   //drupal_set_message('<pre>' . print_r($main_prefs, true) . '</pre>');
816 816
   $new_venue = true;
817
-  if (!$venue OR $venue == 'generic') {
817
+  if (!$venue or $venue == 'generic') {
818 818
     //$main_prefs = $prefs;
819 819
     $main_prefs = $prefs + $main_prefs;
820 820
   }
@@ -824,7 +824,7 @@  discard block
 block discarded – undo
824 824
         $main_prefs['venue'] = array($main_prefs['venue']);
825 825
       }
826 826
       foreach ($main_prefs['venue'] as $key => $prefs_venue) {
827
-        if (isset($prefs_venue['@attributes']['name']) AND $prefs_venue['@attributes']['name'] == $venue) {
827
+        if (isset($prefs_venue['@attributes']['name']) and $prefs_venue['@attributes']['name'] == $venue) {
828 828
           if ($prefs) {
829 829
             $main_prefs['venue'][$key] = $prefs;
830 830
           }
@@ -930,14 +930,14 @@  discard block
 block discarded – undo
930 930
       else {
931 931
         $form_field = $field;
932 932
       }
933
-      if (isset($rules['datatype']) AND !boincwork_validate_datatype($values[$field], $rules['datatype'])) {
934
-        form_set_error($form_field, bts('Invalid data type for @field', array('@field' => $field), NULL, 'boinc:account-preferences'));
933
+      if (isset($rules['datatype']) and !boincwork_validate_datatype($values[$field], $rules['datatype'])) {
934
+        form_set_error($form_field, bts('Invalid data type for @field', array('@field' => $field), null, 'boinc:account-preferences'));
935 935
       }
936
-      if (isset($rules['min']) AND $values[$field] < $rules['min']) {
937
-        form_set_error($form_field, bts('Minimum value not met for @field', array('@field' => $field), NULL, 'boinc:account-preferences'));
936
+      if (isset($rules['min']) and $values[$field] < $rules['min']) {
937
+        form_set_error($form_field, bts('Minimum value not met for @field', array('@field' => $field), null, 'boinc:account-preferences'));
938 938
       }
939
-      if (isset($rules['max']) AND $values[$field] > $rules['max']) {
940
-        form_set_error($form_field, bts('Maximum value exceeded for @field', array('@field' => $field), NULL, 'boinc:account-preferences'));
939
+      if (isset($rules['max']) and $values[$field] > $rules['max']) {
940
+        form_set_error($form_field, bts('Maximum value exceeded for @field', array('@field' => $field), null, 'boinc:account-preferences'));
941 941
       }
942 942
     }
943 943
   }
@@ -946,25 +946,25 @@  discard block
 block discarded – undo
946 946
 /**
947 947
  * Check that numeric data conforms to specifications
948 948
  */
949
-function boincwork_validate_datatype($data, $datatype = NULL) {
949
+function boincwork_validate_datatype($data, $datatype = null) {
950 950
   switch ($datatype) {
951 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 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
   
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
   default:
973 973
     
974 974
   }
975
-  return TRUE;
975
+  return true;
976 976
 }
977 977
 
978 978
 /**
@@ -1050,7 +1050,7 @@  discard block
 block discarded – undo
1050 1050
       if (is_array($value)) {
1051 1051
         if (is_numeric(key($value))) {
1052 1052
           foreach ($value as $item) {
1053
-            if (is_array($item) AND isset($item['@position'])) {
1053
+            if (is_array($item) and isset($item['@position'])) {
1054 1054
               $ordered_array[$item['@position']] = array(
1055 1055
                 $name => $item
1056 1056
               );
@@ -1203,10 +1203,10 @@  discard block
 block discarded – undo
1203 1203
               $sibling = $node->nextSibling;
1204 1204
               
1205 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;
1206
+              while (($sibling) and (($sibling->nodeType != XML_ELEMENT_NODE) or ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->nextSibling;
1207 1207
               if (!$sibling) {
1208 1208
                   $sibling = $node->previousSibling;
1209
-                  while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->previousSibling;
1209
+                  while (($sibling) and (($sibling->nodeType != XML_ELEMENT_NODE) or ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->previousSibling;
1210 1210
               }
1211 1211
               
1212 1212
               if ($sibling) {
@@ -1216,7 +1216,7 @@  discard block
 block discarded – undo
1216 1216
                   }
1217 1217
                   if ($node->hasAttributes()) {
1218 1218
                       $attributes = $node->attributes;
1219
-                      if ($result[$node_name][$index] !== '' AND !is_array($result[$node_name][$index])) {
1219
+                      if ($result[$node_name][$index] !== '' and !is_array($result[$node_name][$index])) {
1220 1220
                           $result[$node_name][$index] = array('@value' => $result[$node_name][$index]);
1221 1221
                       }
1222 1222
                       foreach ($attributes as $key => $attribute) {
@@ -1239,7 +1239,7 @@  discard block
 block discarded – undo
1239 1239
                   }
1240 1240
                   if ($node->hasAttributes()) {
1241 1241
                       $attributes = $node->attributes;
1242
-                      if ($result[$node_name] !== '' AND !is_array($result[$node_name])) {
1242
+                      if ($result[$node_name] !== '' and !is_array($result[$node_name])) {
1243 1243
                           $result[$node_name] = array('@value' => $result[$node_name]);
1244 1244
                       }
1245 1245
                       foreach($attributes as $key => $attribute) {
@@ -1270,7 +1270,7 @@  discard block
 block discarded – undo
1270 1270
 /**
1271 1271
   * Determine output for host list views when no hosts are found.
1272 1272
   */
1273
-function boincwork_views_host_list_empty_text($context = NULL) {
1273
+function boincwork_views_host_list_empty_text($context = null) {
1274 1274
   
1275 1275
   // Pull the BOINC user ID from the view arguments to get show_hosts 
1276 1276
   // preference for that user
@@ -1284,28 +1284,28 @@  discard block
 block discarded – undo
1284 1284
   if ($boincuser->show_hosts) {
1285 1285
     switch($context) {
1286 1286
     case 'active':
1287
-      $output .=  '<h2>' . bts('No active computers', array(), NULL, 'boinc:host-list') . '</h2>';
1287
+      $output .=  '<h2>' . bts('No active computers', array(), null, 'boinc:host-list') . '</h2>';
1288 1288
       $output .=  '<p>' . bts('This user has no computers that have been'
1289
-      . ' active in the last 30 days.', array(), NULL, 'boinc:host-list') . '</p>';
1289
+      . ' active in the last 30 days.', array(), null, 'boinc:host-list') . '</p>';
1290 1290
       break;
1291 1291
       
1292 1292
     case 'preferences':
1293
-      $output .=  '<h2>' . bts('No computers', array(), NULL, 'boinc:host-list') . '</h2>';
1293
+      $output .=  '<h2>' . bts('No computers', array(), null, 'boinc:host-list') . '</h2>';
1294 1294
       $output .=  '<p>' . bts('There are no computers assigned to this'
1295
-      . ' preference set.', array(), NULL, 'boinc:host-list') . '</p>';
1295
+      . ' preference set.', array(), null, 'boinc:host-list') . '</p>';
1296 1296
       break;
1297 1297
     
1298 1298
     default:
1299
-      $output .=  '<h2>' . bts('Computers pending', array(), NULL, 'boinc:host-list') . '</h2>';
1299
+      $output .=  '<h2>' . bts('Computers pending', array(), null, 'boinc:host-list') . '</h2>';
1300 1300
       $output .=  '<p>' . bts('This user does not yet have any associated'
1301 1301
       . ' computers. Computers will be displayed when they have earned their'
1302
-      . ' first credits.', array(), NULL, 'boinc:host-list') . '</p>';
1302
+      . ' first credits.', array(), null, 'boinc:host-list') . '</p>';
1303 1303
     }
1304 1304
   }
1305 1305
   else {
1306
-    $output .=  '<h2>' . bts('Computers hidden', array(), NULL, 'boinc:host-list') . '</h2>';
1306
+    $output .=  '<h2>' . bts('Computers hidden', array(), null, 'boinc:host-list') . '</h2>';
1307 1307
     $output .=  '<p>' . bts('This user has chosen not to show information'
1308
-    . ' about their computers.', array(), NULL, 'boinc:host-list') . '</p>';
1308
+    . ' about their computers.', array(), null, 'boinc:host-list') . '</p>';
1309 1309
   }
1310 1310
   return $output;
1311 1311
 }
@@ -1313,15 +1313,15 @@  discard block
 block discarded – undo
1313 1313
 /**
1314 1314
   * Determine output for task list views when no tasks are found.
1315 1315
   */
1316
-function boincwork_views_task_list_empty_text($context = NULL) {
1316
+function boincwork_views_task_list_empty_text($context = null) {
1317 1317
   
1318 1318
   // 
1319 1319
   $output = '';
1320 1320
   switch($context) {
1321 1321
   default:
1322
-    $output .=  '<h2>' . bts('No @type tasks', array('@type' => $context), NULL, 'boinc:task-list')
1322
+    $output .=  '<h2>' . bts('No @type tasks', array('@type' => $context), null, 'boinc:task-list')
1323 1323
     . '</h2>';
1324
-    $output .=  '<p>' . bts('There are no tasks of this type on record', array(), NULL, 'boinc:task-list')
1324
+    $output .=  '<p>' . bts('There are no tasks of this type on record', array(), null, 'boinc:task-list')
1325 1325
     . '</p>';
1326 1326
   }
1327 1327
   return $output;
@@ -1335,18 +1335,18 @@  discard block
 block discarded – undo
1335 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
-    $output .= l(bts('Merge', array(), NULL, 'boinc:form-merge'), "host/{$host_id}/merge");
1338
+    $output .= l(bts('Merge', array(), null, 'boinc:form-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 1342
       $output .= '<li class="tab">';
1343
-      $output .= l(bts('Delete', array(), NULL, 'boinc:form-delete'), "host/{$host_id}/delete",
1343
+      $output .= l(bts('Delete', array(), null, 'boinc:form-delete'), "host/{$host_id}/delete",
1344 1344
         array(
1345 1345
           'attributes' => array(
1346 1346
             'onclick' => 'return confirm(\'' . bts('This will delete host @id'
1347 1347
               . ' from your account forever. Are you sure this is OK?',
1348 1348
               array('@id' => $host_id),
1349
-              NULL, 'boinc:account-host-delete') . '\')'
1349
+              null, 'boinc:account-host-delete') . '\')'
1350 1350
           )
1351 1351
         )
1352 1352
       );
@@ -1386,7 +1386,7 @@  discard block
 block discarded – undo
1386 1386
 /**
1387 1387
  * Check whether a user is the owner of a host
1388 1388
  */
1389
-function boincwork_host_user_is_owner($host_id, $uid = NULL) {
1389
+function boincwork_host_user_is_owner($host_id, $uid = null) {
1390 1390
   if (!$uid) {
1391 1391
     global $user;
1392 1392
     $uid = $user->uid;
@@ -1405,18 +1405,18 @@  discard block
 block discarded – undo
1405 1405
 /**
1406 1406
   * Determine output for host last contact time
1407 1407
   */
1408
-function boincwork_host_last_contact($timestamp, $host_id = NULL, $context = NULL) {
1408
+function boincwork_host_last_contact($timestamp, $host_id = null, $context = null) {
1409 1409
   $output = '---';
1410 1410
   $root_log_dir = variable_get('boinc_host_sched_logs_dir', '');
1411 1411
   $log = '';
1412 1412
   if ($timestamp) {
1413 1413
     $output = gmdate('j M Y | G:i:s', $timestamp) . ' UTC';
1414 1414
   }
1415
-  if ($root_log_dir AND $host_id) {
1416
-    $subdir = substr($host_id, 0, -3) OR $subdir = 0;
1415
+  if ($root_log_dir and $host_id) {
1416
+    $subdir = substr($host_id, 0, -3) or $subdir = 0;
1417 1417
     $log = implode('/', array($root_log_dir, $subdir, $host_id));
1418 1418
   }
1419
-  if ($log AND file_exists($log)) {
1419
+  if ($log and file_exists($log)) {
1420 1420
     $output = l($output, "host/{$host_id}/log");
1421 1421
   }
1422 1422
   return $output;
@@ -1430,10 +1430,10 @@  discard block
 block discarded – undo
1430 1430
   if (function_exists('jump_quickly')) {
1431 1431
     $path = "host/{$host_id}/set-venue";
1432 1432
     $venues = array(
1433
-      "{$path}/generic" => bts('Generic', array(), NULL, 'boinc:account-preferences-location'),
1434
-      "{$path}/home" => bts('Home', array(), NULL, 'boinc:account-preferences-location:-1:ignoreoverwrite'),
1435
-      "{$path}/work" => bts('Work', array(), NULL, 'boinc:account-preferences-location'),
1436
-      "{$path}/school" => bts('School', array(), NULL, 'boinc:account-preferences-location')
1433
+      "{$path}/generic" => bts('Generic', array(), null, 'boinc:account-preferences-location'),
1434
+      "{$path}/home" => bts('Home', array(), null, 'boinc:account-preferences-location:-1:ignoreoverwrite'),
1435
+      "{$path}/work" => bts('Work', array(), null, 'boinc:account-preferences-location'),
1436
+      "{$path}/school" => bts('School', array(), null, 'boinc:account-preferences-location')
1437 1437
     );
1438 1438
     variable_set('jump_use_js_venues-Array', 1);
1439 1439
     drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js');
@@ -1453,9 +1453,9 @@  discard block
 block discarded – undo
1453 1453
 /**
1454 1454
   * Determine output for task reported time / deadline
1455 1455
   */
1456
-function boincwork_task_time_reported($received_time = NULL, $deadline = NULL, $context = NULL) {
1456
+function boincwork_task_time_reported($received_time = null, $deadline = null, $context = null) {
1457 1457
   $output = '---';
1458
-  if ($received_time OR $deadline) {
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
@@ -1496,9 +1496,9 @@  discard block
 block discarded – undo
1496 1496
  *   Application id of the application chosen by user. 0 and -1 are
1497 1497
  *   for all applications.
1498 1498
  */
1499
-function boincwork_tasktable($category = 0, $queryid = 1, $tselect = NULL, $app_id = 0) {
1499
+function boincwork_tasktable($category = 0, $queryid = 1, $tselect = null, $app_id = 0) {
1500 1500
   // Check type parameter, if not (0,2) then return an error.
1501
-  if ( ($category!=0) AND ($category!=1) AND ($category!=2) ) {
1501
+  if ( ($category!=0) and ($category!=1) and ($category!=2) ) {
1502 1502
     watchdog('boincwork', 'task table called with invalid category = %category', array('%category' => $category), WATCHDOG_WARNING);
1503 1503
     return '';
1504 1504
   }
@@ -1570,7 +1570,7 @@  discard block
 block discarded – undo
1570 1570
   if ($dbres_all) {
1571 1571
     while ($result = db_fetch_object($dbres_all)) {
1572 1572
       $mystate = state_num($result);
1573
-      if ( ($result->appid==$app_id) OR ($app_id==0) OR ($app_id==-1) ) {
1573
+      if ( ($result->appid==$app_id) or ($app_id==0) or ($app_id==-1) ) {
1574 1574
         $taskstates[STATE_ALL]++;
1575 1575
         switch ($mystate) {
1576 1576
         case STATE_IN_PROGRESS:
@@ -1593,7 +1593,7 @@  discard block
 block discarded – undo
1593 1593
 
1594 1594
       //map holds a map between app ids and user friendly names for all applications.
1595 1595
       $application_map[$result->appid] = $result->user_friendly_name;
1596
-      if ( ($mystate == $tselect) OR ($tselect==STATE_ALL) ) {
1596
+      if ( ($mystate == $tselect) or ($tselect==STATE_ALL) ) {
1597 1597
         //count of appids in the results.
1598 1598
         $application_select_count[$result->appid]++;
1599 1599
       }// if mystate
@@ -1605,8 +1605,8 @@  discard block
 block discarded – undo
1605 1605
   
1606 1606
   // Entry for all applications.
1607 1607
   $allcount = $application_select_count ? array_sum($application_select_count) : 0;
1608
-  $applications[-1] = bts('Application', array(), NULL, 'boinc:task-table');
1609
-  $applications[0] = bts('All applications', array(), NULL, 'boinc:task-table') . '(' . $allcount . ')';
1608
+  $applications[-1] = bts('Application', array(), null, 'boinc:task-table');
1609
+  $applications[0] = bts('All applications', array(), null, 'boinc:task-table') . '(' . $allcount . ')';
1610 1610
   // Create application filter from application_map and application_select_count.
1611 1611
   foreach($application_map as $akey => $aname) {
1612 1612
     $acount = 0;
@@ -1618,40 +1618,40 @@  discard block
 block discarded – undo
1618 1618
   // Header array for (sub) results table.
1619 1619
   $resultheader = array(
1620 1620
     array(
1621
-      'data' => bts('Task ID', array(), NULL, 'boinc:task-table'),
1621
+      'data' => bts('Task ID', array(), null, 'boinc:task-table'),
1622 1622
       'field' => 'id',
1623 1623
     ),
1624 1624
     array(
1625
-      'data' => bts('Workunit ID', array(), NULL, 'boinc:task-table'),
1625
+      'data' => bts('Workunit ID', array(), null, 'boinc:task-table'),
1626 1626
       'field' => 'workunitid',
1627 1627
     ),
1628 1628
     array(
1629
-      'data' => bts('Computer', array(), NULL, 'boinc:task-table'),
1629
+      'data' => bts('Computer', array(), null, 'boinc:task-table'),
1630 1630
       'field' => 'hostid',
1631 1631
     ),
1632 1632
     array(
1633
-      'data' => bts('Sent', array(), NULL, 'boinc:task-table')
1633
+      'data' => bts('Sent', array(), null, 'boinc:task-table')
1634 1634
     ),
1635 1635
     array(
1636
-      'data' => bts('Time Reported or Deadline', array(), NULL, 'boinc:task-table')
1636
+      'data' => bts('Time Reported or Deadline', array(), null, 'boinc:task-table')
1637 1637
     ),
1638 1638
     array(
1639
-      'data' => bts('Status', array(), NULL, 'boinc:task-table')
1639
+      'data' => bts('Status', array(), null, 'boinc:task-table')
1640 1640
     ),
1641 1641
     array(
1642
-      'data' => bts('Run time', array(), NULL, 'boinc:task-table'),
1642
+      'data' => bts('Run time', array(), null, 'boinc:task-table'),
1643 1643
       'field'=>'elapsed_time',
1644 1644
     ),
1645 1645
     array(
1646
-      'data' => bts('CPU time', array(), NULL, 'boinc:task-table'),
1646
+      'data' => bts('CPU time', array(), null, 'boinc:task-table'),
1647 1647
       'field'=>'cpu_time',
1648 1648
     ),
1649 1649
     array(
1650
-      'data' => bts('Claimed Credit', array(), NULL, 'boinc:task-table'),
1650
+      'data' => bts('Claimed Credit', array(), null, 'boinc:task-table'),
1651 1651
       'field'=>'claimed_credit',
1652 1652
     ),
1653 1653
     array(
1654
-      'data' => bts('Granted Credit', array(), NULL, 'boinc:task-table'),
1654
+      'data' => bts('Granted Credit', array(), null, 'boinc:task-table'),
1655 1655
       'field'=>'granted_credit',
1656 1656
     ),
1657 1657
     // Application is a column, but won't be added until after tablesort_sql().
@@ -1713,12 +1713,12 @@  discard block
 block discarded – undo
1713 1713
     break;
1714 1714
   }
1715 1715
 
1716
-  if (is_numeric($app_id) AND $app_id>0 ) {
1716
+  if (is_numeric($app_id) and $app_id>0 ) {
1717 1717
     $sqlsub .= " AND appid = '%s'";
1718
-    $dbres_sub = pager_query( $sqlsub . tablesort_sql($resultheader), 20, 0, NULL, $queryid, $app_id);
1718
+    $dbres_sub = pager_query( $sqlsub . tablesort_sql($resultheader), 20, 0, null, $queryid, $app_id);
1719 1719
   }
1720 1720
   else {
1721
-    $dbres_sub = pager_query( $sqlsub . tablesort_sql($resultheader), 20, 0, NULL, $queryid);
1721
+    $dbres_sub = pager_query( $sqlsub . tablesort_sql($resultheader), 20, 0, null, $queryid);
1722 1722
   }
1723 1723
   db_set_active('default');
1724 1724
 
@@ -1726,7 +1726,7 @@  discard block
 block discarded – undo
1726 1726
   if ($dbres_sub) {
1727 1727
     while ($result = db_fetch_object($dbres_sub)) {
1728 1728
       // check if state matches selection
1729
-      if ( (state_num($result) == $tselect) OR ($tselect==STATE_ALL) ) {
1729
+      if ( (state_num($result) == $tselect) or ($tselect==STATE_ALL) ) {
1730 1730
         // create pretty result row
1731 1731
         $prettyresult = array(
1732 1732
           array(
@@ -1766,18 +1766,18 @@  discard block
 block discarded – undo
1766 1766
     $pathprefix = 'host/' . $queryid . '/tasks';
1767 1767
   }
1768 1768
   // Need an "All" tab as well, maps to app_id of zero.
1769
-  $application_map[0] = bts('All', array(), NULL, 'boinc:task-table');
1769
+  $application_map[0] = bts('All', array(), null, 'boinc:task-table');
1770 1770
   $stitems = array();
1771 1771
   foreach ($taskstates as $state => $numstates) {
1772 1772
     $mypath = $pathprefix . '/' . $state . '/' . $app_id;
1773 1773
     if ($state==STATE_ALL) {
1774
-      $ltext = '<span class="tab task-app-name">' . bts('All', array(), NULL, 'boinc:task-table') . '(' . $numstates . ')</span>';
1774
+      $ltext = '<span class="tab task-app-name">' . bts('All', array(), null, 'boinc:task-table') . '(' . $numstates . ')</span>';
1775 1775
     }
1776 1776
     else {
1777
-      $ltext = '<span class="tab">' . bts($state_hnames[$state], array(), NULL, 'boinc:task-table') . ' (' . $numstates . ')</span>';
1777
+      $ltext = '<span class="tab">' . bts($state_hnames[$state], array(), null, 'boinc:task-table') . ' (' . $numstates . ')</span>';
1778 1778
     }
1779 1779
     $myitem = array(
1780
-      'data' => l($ltext, $mypath, array('html' => TRUE) ),
1780
+      'data' => l($ltext, $mypath, array('html' => true) ),
1781 1781
     );
1782 1782
     if ($state==$tselect) {
1783 1783
       $myitem['class'] = 'active';
@@ -1786,10 +1786,10 @@  discard block
 block discarded – undo
1786 1786
   }
1787 1787
   // Add reset button
1788 1788
   $mypath = $pathprefix . '/0/0';
1789
-  $ltext = '<span class="tab">' . bts('Reset', array(), NULL, 'boinc:task-table') . '</span>';
1790
-  $stitems[] = array( 'data' => l($ltext, $mypath, array('html' => TRUE) ) );
1789
+  $ltext = '<span class="tab">' . bts('Reset', array(), null, 'boinc:task-table') . '</span>';
1790
+  $stitems[] = array( 'data' => l($ltext, $mypath, array('html' => true) ) );
1791 1791
 
1792
-  $output .= theme_item_list($stitems, $title = NULL, $type='ul'. $attributes=' class="tabs secondary clearfix"');
1792
+  $output .= theme_item_list($stitems, $title = null, $type='ul'. $attributes=' class="tabs secondary clearfix"');
1793 1793
 
1794 1794
   // Application select-drop down form
1795 1795
   // Hack to place Application form into header
@@ -1800,10 +1800,10 @@  discard block
 block discarded – undo
1800 1800
   $resultheader[] = drupal_get_form('boincwork_selectapp_form', $applications, $app_id);
1801 1801
 
1802 1802
   // Begin table of results
1803
-  if ( is_array($resultheader) AND is_array($resultdata) ) {
1803
+  if ( is_array($resultheader) and is_array($resultdata) ) {
1804 1804
 
1805 1805
     // Take advantage of the fact that $category is the same as the row/column we want to remove.
1806
-    if ( ($category==1) OR ($category==2) ) {
1806
+    if ( ($category==1) or ($category==2) ) {
1807 1807
       unset($resultheader[$category]);
1808 1808
       delete_col($resultdata, $category);
1809 1809
     }
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boincwork/includes/boincwork.forms.inc 3 patches
Indentation   +860 added lines, -860 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', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes'))
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(
181
-      '#title' => bts('Presets', array(), NULL, 'boinc:account-preferences-preset:-1:for a user to choose a computing or project preference preset.'),
179
+    // Simplified selectors
180
+    $form['prefs']['preset'] = array(
181
+        '#title' => bts('Presets', array(), NULL, 'boinc:account-preferences-preset:-1:for a user to choose a computing or project preference preset.'),
182 182
     '#type' => 'radios',
183 183
     '#description' => ' ',
184 184
     '#options' => array(
185
-      'standard' => bts('Standard', array(), NULL, 'boinc:account-preferences-preset'),
186
-      'maximum' => bts('Maximum', array(), NULL, 'boinc:account-preferences-preset'),
187
-      'green' => bts('Green', array(), NULL, 'boinc:account-preferences-preset'),
188
-      'minimum' => bts('Minimum', array(), NULL, 'boinc:account-preferences-preset'),
189
-      'custom' => bts('Custom', array(), NULL, 'boinc:account-preferences-preset')
185
+        'standard' => bts('Standard', array(), NULL, 'boinc:account-preferences-preset'),
186
+        'maximum' => bts('Maximum', array(), NULL, 'boinc:account-preferences-preset'),
187
+        'green' => bts('Green', array(), NULL, 'boinc:account-preferences-preset'),
188
+        'minimum' => bts('Minimum', array(), NULL, 'boinc:account-preferences-preset'),
189
+        'custom' => bts('Custom', array(), NULL, 'boinc:account-preferences-preset')
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', array(), NULL, 'boinc:account-preferences-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', array(), NULL, 'boinc:account-preferences-option'),
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', array(), NULL, 'boinc:account-preferences-computing'),
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?', array(), NULL, 'boinc:account-preferences-computing'),
237 237
     '#type' => 'radios',
238 238
     '#description' => bts('Suspends computing on portables when running on battery power.', array(), NULL, 'boinc:account-preferences-computing'),
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?', array(), NULL, 'boinc:account-preferences-computing'),
245 245
     '#type' => 'radios',
246 246
     '#description' => bts("Suspends computing and file transfers when you're using the computer.", array(), NULL, 'boinc:account-preferences-computing'),
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?', array(), NULL, 'boinc:account-preferences-computing'),
253 253
     '#type' => 'radios',
254 254
     '#description' => bts("Suspends GPU computing when you're using the computer.", array(), NULL, 'boinc:account-preferences-computing'),
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(
260
-      '#title' => bts('"In use" means mouse/keyboard input in last', array(), NULL, 'boinc:account-preferences-computing'),
258
+    );
259
+    $form['prefs']['advanced']['processor']['idle_time_to_run'] = array(
260
+        '#title' => bts('"In use" means mouse/keyboard input in last', array(), NULL, 'boinc:account-preferences-computing'),
261 261
     '#type' => 'textfield',
262 262
     '#field_suffix' => bts('minutes', array(), NULL, 'boinc:unit-of-time'),
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".', array(), NULL, 'boinc:account-preferences-computing')
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', array(), NULL, 'boinc:account-preferences-computing'),
269 269
     '#type' => 'textfield',
270 270
     '#field_suffix' => bts('minutes', array(), NULL, 'boinc:unit-of-time'),
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.', array(), NULL, 'boinc:account-preferences-computing')
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', array(), NULL, 'boinc:account-preferences-computing'),
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.', array(), NULL, 'boinc:account-preferences-computing'),
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:', array(), NULL, 'boinc:account-preferences-computing') . '</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', array(), NULL, 'boinc:account-preference') . '</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.', array(), NULL, 'boinc:account-preferences-computing') . '</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?', array(), NULL, 'boinc:account-preferences-computing'),
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.', array(), NULL, 'boinc:account-preferences-computing')
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', array(), NULL, 'boinc:account-preferences-computing'),
312 312
     '#type' => 'textfield',
313 313
     '#field_suffix' => bts('minutes', array(), NULL, 'boinc:unit-of-time'),
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.', array(), NULL, 'boinc:account-preferences-computing')
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', array(), NULL, 'boinc:account-preferences-computing'),
320 320
     '#type' => 'textfield',
321 321
     '#field_suffix' => bts('% of the processors', array(), NULL, 'boinc:account-preferences-computing'),
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.', array(), NULL, 'boinc:account-preferences-computing'),
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', array(), NULL, 'boinc:account-preferences-computing'),
328 328
     '#type' => 'textfield',
329 329
     '#field_suffix' => bts('% of the CPU time', array(), NULL, 'boinc:account-preferences-computing'),
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.', array(), NULL, 'boinc:account-preferences-computing')
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', array(), NULL, 'boinc:account-preferences-computing'),
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', array(), NULL, 'boinc:account-preferences-computing'),
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.', array(), NULL, 'boinc:account-preferences-computing'),
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', array(), NULL, 'boinc:account-preferences-computing'),
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.', array(), NULL, 'boinc:account-preferences-computing'),
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', array(), NULL, 'boinc:account-preferences-computing'),
361 361
     '#type' => 'textfield',
362 362
     '#field_suffix' => bts('% of total', array(), NULL, 'boinc:account-preferences-computing'),
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.', array(), NULL, 'boinc:account-preferences-computing')
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', array(), NULL, 'boinc:account-preferences-computing'),
369 369
     '#type' => 'textfield',
370 370
     '#field_suffix' => bts('seconds', array(), NULL, 'boinc:unit-of-time'),
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.', array(), NULL, 'boinc:account-preferences-computing')
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', array(), NULL, 'boinc:account-preferences-computing'),
377 377
     '#type' => 'textfield',
378 378
     '#field_suffix' => bts('% of total', array(), NULL, 'boinc:account-preferences-computing'),
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.', array(), NULL, 'boinc:account-preferences-computing')
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', array(), NULL, 'boinc:account-preferences-computing'),
385 385
     '#type' => 'textfield',
386 386
     '#field_suffix' => bts('% of total', array(), NULL, 'boinc:account-preferences-computing'),
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.", array(), NULL, 'boinc:account-preferences-computing')
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', array(), NULL, 'boinc:account-preferences-computing'),
393 393
     '#type' => 'textfield',
394 394
     '#field_suffix' => bts('% of total', array(), NULL, 'boinc:account-preferences-computing'),
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.", array(), NULL, 'boinc:account-preferences-computing')
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', array(), NULL, 'boinc:account-preferences-computing'),
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', array(), NULL, 'boinc:account-preferences-computing'),
410 410
     '#type' => 'textfield',
411 411
     '#field_suffix' => bts('days of work', array(), NULL, 'boinc:account-preferences-computing'),
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.', array(), NULL, 'boinc:account-preferences-computing')
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', array(), NULL, 'boinc:account-preferences-computing'),
418 418
     '#type' => 'textfield',
419 419
     '#field_suffix' => bts('days', array(), NULL, 'boinc:unit-of-time'),
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.', array(), NULL, 'boinc:account-preferences-computing')
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?', array(), NULL, 'boinc:account-preferences-computing'),
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.', array(), NULL, 'boinc:account-preferences-computing')
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?', array(), NULL, 'boinc:account-preferences-computing'),
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.', array(), NULL, 'boinc:account-preferences-computing')
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', array(), NULL, 'boinc:account-preferences-computing'),
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.', array(), NULL, 'boinc:account-preferences-computing')
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', array(), NULL, 'boinc:account-preferences-computing'),
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.', array(), NULL, 'boinc:account-preferences-computing')
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', array(), NULL, 'boinc:account-preferences-computing') . '</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', array(), NULL, 'boinc:account-preference') . '</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.', array(), NULL, 'boinc:account-preferences-computing') . '</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', array(), NULL, 'boinc:account-preferences-computing'),
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', array(), NULL, 'boinc:unit-of-time'),
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.', array(), NULL, 'boinc:account-preferences-computing'),
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?', array(), NULL, 'boinc:account-preferences-computing'),
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.', array(), NULL, 'boinc:account-preferences-computing')
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', array(), NULL, 'boinc:form-save'),
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', array(), NULL, 'boinc:form-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', array(), NULL, 'boinc:form-clear'), "account/prefs/computing/clear/{$venue}",
538
+        l(bts('Clear', array(), NULL, 'boinc:form-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), array(), NULL, 'boinc:account-preferences') . '\')'
544
-          )
543
+                array('@name' => $venue), array(), NULL, 'boinc:account-preferences') . '\')'
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', array(), NULL, 'boinc:account-preferences') . ')', '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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-prefrences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-prefrences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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', array(), NULL, 'boinc:account-host-merge');
787
+        $message = bts('Could not update credit', array(), NULL, 'boinc:account-host-merge');
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', array(), NULL, 'boinc:account-host-merge');
803
+        $message = bts('Could not update results', array(), NULL, 'boinc:account-host-merge');
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', array(), NULL, 'boinc:account-host-merge');
823
+        $message = bts('Could not retire old computer', array(), NULL, 'boinc:account-host-merge');
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.', array(), NULL, 'boinc:account-host-merge') . '</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.', array(), NULL, 'boinc:account-host-merge') . '</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 867
         NULL, 'boinc:account-host-merge') . '</p>',
868
-  );
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', array(), NULL, 'boinc:details:-1:name-of-the-host-or-task-or-workunit-etc-being-viewed-ignoreoverwrite'), bts('Created', array(), NULL, 'boinc:host-details'), bts('Computer ID', array(), NULL, 'boinc:host-list')),
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', array(), NULL, 'boinc:form-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', array(), NULL, 'boinc:form-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', array(), NULL, 'boinc:account-preference');
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
         NULL, 'boinc:account-host-merge'));
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
         NULL, 'boinc:account-host-merge'));
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
-          ),
980
-          NULL, 'boinc:account-host-merge'),
979
+            ),
980
+            NULL, 'boinc:account-host-merge'),
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', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes'))
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', array(), NULL, 'boinc:account-preferences-project'),
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', array(), NULL, 'boinc:account-preferences-project'),
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.", array(), NULL, 'boinc:account-preferences-project')
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', array(), NULL, 'boinc:account-preferences-project'),
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.', array(), NULL, 'boinc:account-preferences-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', array(), NULL, 'boinc:account-preferences-project'),
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.', array(), NULL, 'boinc:account-preferences-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', array(), NULL, 'boinc:account-preferences-project'),
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.', array(), NULL, 'boinc:account-preferences-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', array(), NULL, 'boinc:account-preferences-project'),
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.', array(), NULL, 'boinc:account-preferences-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', array(), NULL, 'boinc:account-preferences-project'),
1135
-      '#type' => 'fieldset',
1136
-      '#description' => null,
1137
-      '#collapsible' => TRUE,
1138
-      '#collapsed' => FALSE
1134
+        '#title' => bts('Beta settings', array(), NULL, 'boinc:account-preferences-project'),
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?', array(), NULL, 'boinc:account-preferences-project'),
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', array(), NULL, 'boinc:account-preferences-project')
1141
+        '#title' => bts('Run test applications?', array(), NULL, 'boinc:account-preferences-project'),
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', array(), NULL, 'boinc:account-preferences-project')
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', array(), NULL, 'boinc:account-preferences-project'),
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', array(), NULL, 'boinc:account-preferences-project'),
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', array(), NULL, 'boinc:form-save'),
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', array(), NULL, 'boinc:form-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', array(), NULL, 'boinc:form-clear'), "account/prefs/project/clear/{$venue}",
1190
+        l(bts('Clear', array(), NULL, 'boinc:form-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), NULL, 'boinc:account-preferences') . '\')'
1196
-          )
1195
+                array('@name' => $venue), NULL, 'boinc:account-preferences') . '\')'
1196
+            )
1197 1197
         )
1198
-      ) . '</li>';
1199
-  }
1200
-  $form['prefs']['view control'] = array(
1201
-      '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/project/combined') . '</li>'
1202
-  );
1203
-  $form['prefs']['form control tabs suffix'] = array(
1198
+        ) . '</li>';
1199
+    }
1200
+    $form['prefs']['view control'] = array(
1201
+        '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/project/combined') . '</li>'
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', array(), NULL, 'boinc:account-preferences-project')
1280
+            'applications',
1281
+            bts('At least one application must be selected', array(), NULL, 'boinc:account-preferences-project')
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', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes'))
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', array(), NULL, 'boinc:account-preferences-community'),
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', array(), NULL, 'boinc:user-or-team-name'),
1416 1416
     '#default_value' => $account->boincuser_name,
@@ -1418,241 +1418,241 @@  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', array(), NULL, 'boinc:account-preferences-community'),
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', array(), NULL, 'boinc:account-preferences-community'),
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', array(), NULL, 'boinc:account-preferences-community'),
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?', array(), NULL, 'boinc:account-preferences-community'),
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?', array(), NULL, 'boinc:account-preferences-community'),
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?', array(), NULL, 'boinc:account-preferences-community'),
1457 1457
     '#description' => ' ',
1458 1458
     '#options' => array(0 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), -1 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')),
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', array(), NULL, 'boinc:account-preferences-community'),
1475
-      '#weight' => 10,
1476
-      '#collapsible' => TRUE,
1477
-      '#collapsed' => FALSE,
1473
+        '#type' => 'fieldset',
1474
+        '#title' => bts('Language settings', array(), NULL, 'boinc:account-preferences-community'),
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', array(), NULL, 'boinc:account-preferences-community'),
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.", array(), NULL, 'boinc:account-preferences-community') : bts("This account's default language for e-mails.", array(), NULL, 'boinc:account-preferences-community'),
1484
+        '#type' => 'select',
1485
+        '#title' => bts('Language', array(), NULL, 'boinc:account-preferences-community'),
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.", array(), NULL, 'boinc:account-preferences-community') : bts("This account's default language for e-mails.", array(), NULL, 'boinc:account-preferences-community'),
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), NULL, 'boinc:account-preferences-community'),
1496 1496
     '#description' => bts('Your Gravatar will not be shown if you upload a user picture.', array(), NULL, 'boinc:account-preferences-community'),
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), NULL, 'boinc:account-preferences-community'),
1502
-      '#description' => bts('Gravatar will not be shown if an avatar is uploaded.', array(), NULL, 'boinc:account-preferences-community'),
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', array(), NULL, 'boinc:account-preferences-community') . '</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), NULL, 'boinc:account-preferences-community'),
1502
+        '#description' => bts('Gravatar will not be shown if an avatar is uploaded.', array(), NULL, 'boinc:account-preferences-community'),
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', array(), NULL, 'boinc:account-preferences-community') . '</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.', array(), NULL, 'boinc:account-preferences-community')
1518 1518
         . '</label>'
1519 1519
         . l(bts('Create a profile', array(), NULL, 'boinc:account-preferences-community'), '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', array(), NULL, 'boinc:account-preferences-community');
1524
-  $form['field_image']['#weight'] = 20;
1525
-  $form['field_image']['#suffix'] = '</fieldset>';
1522
+    }
1523
+    $form['field_image'][0]['#title'] = bts('Upload an avatar', array(), NULL, 'boinc:account-preferences-community');
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', array(), NULL, 'boinc:account-preferences-community'),
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' => ''), NULL, 'boinc:account-preferences-community'),
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', array(), NULL, 'boinc:account-preferences-community') . '</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', array(), NULL, 'boinc:account-preferences-community'),
1548 1548
     '#options' => array(1 => bts('Newest post first', array(), NULL, 'boinc:account-preferences-community'), 2 => bts('Oldest post first', array(), NULL, 'boinc:account-preferences-community')),
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', array(), NULL, 'boinc:account-preferences-community'),
1556
-      '#description' => bts('Your signature will be publicly displayed at the end of your comments.', array(), NULL, 'boinc:account-preferences-community'),
1557
-      '#default_value' => $account->signature
1558
-      );
1554
+        '#type' => 'textarea',
1555
+        '#title' => bts('Signature', array(), NULL, 'boinc:account-preferences-community'),
1556
+        '#description' => bts('Your signature will be publicly displayed at the end of your comments.', array(), NULL, 'boinc:account-preferences-community'),
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', array(), NULL, 'boinc:account-preferences-community'),
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', array(), NULL, 'boinc:account-preferences-community'),
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:', array(), NULL, 'boinc:account-preferences-community')
1583
-	. '</label>'
1582
+    . bts('Ignore Users in forums:', array(), NULL, 'boinc:account-preferences-community')
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(
1585
+        array(
1586
+            '@ignore-user-list' => url('ignore_user/list'),
1587
+            array(
1588 1588
             'attributes' => array('class' => 'form-link')
1589
-          )
1590
-	    ),
1589
+            )
1590
+        ),
1591 1591
         NULL, 'boinc:account-preferences-community')
1592
-	. '</div>',
1592
+    . '</div>',
1593 1593
     );
1594
-  }//endif module_exists('ignore_user')
1594
+    }//endif module_exists('ignore_user')
1595 1595
 
1596
-  //Bottom separator
1597
-  $form['separator_bottom'] = array(
1596
+    //Bottom separator
1597
+    $form['separator_bottom'] = array(
1598 1598
     '#value' => '<div class="separator buttons"></div>',
1599 1599
     '#weight' => 999,
1600
-  );
1600
+    );
1601 1601
   
1602
-  // Form control
1603
-  $form['form control tabs prefix'] = array(
1602
+    // Form control
1603
+    $form['form control tabs prefix'] = array(
1604 1604
     '#value' => '<ul class="form-control tab-list">',
1605 1605
     '#weight' => 1001,
1606
-  );
1607
-  $form['submit'] = array(
1606
+    );
1607
+    $form['submit'] = array(
1608 1608
     '#prefix' => '<li class="first tab">',
1609 1609
     '#type' => 'submit',
1610 1610
     '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'),
1611 1611
     '#suffix' => '</li>',
1612 1612
     '#weight' => 1002,
1613
-  );
1614
-  $form['form control tabs'] = array(
1613
+    );
1614
+    $form['form control tabs'] = array(
1615 1615
     '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>',
1616 1616
     '#weight' => 1003,
1617
-  );
1618
-  $form['form control tabs suffix'] = array(
1617
+    );
1618
+    $form['form control tabs suffix'] = array(
1619 1619
     '#value' => '</ul>',
1620 1620
     '#weight' => 1004,
1621
-  );
1622
-  return $form;
1621
+    );
1622
+    return $form;
1623 1623
 }
1624 1624
 
1625 1625
 /**
1626
-  * Handle post-validation submission of community preferences form.
1627
-  */
1626
+ * Handle post-validation submission of community preferences form.
1627
+ */
1628 1628
 function communityprefs_form_submit($form, &$form_state) {
1629
-  require_boinc('boinc_db');
1630
-  global $user;
1631
-  $account = user_load($user->uid);
1632
-  $boinc_user = BoincUser::lookup_id($account->boincuser_id);
1633
-  $edit = $form_state['values'];
1634
-  $profile_node = $form_state['storage']['profile_node'];
1635
-  
1636
-  // Display name
1637
-  if ($edit['boincuser_name'] != $boinc_user->name) {
1629
+    require_boinc('boinc_db');
1630
+    global $user;
1631
+    $account = user_load($user->uid);
1632
+    $boinc_user = BoincUser::lookup_id($account->boincuser_id);
1633
+    $edit = $form_state['values'];
1634
+    $profile_node = $form_state['storage']['profile_node'];
1635
+  
1636
+    // Display name
1637
+    if ($edit['boincuser_name'] != $boinc_user->name) {
1638 1638
     $boincuser_name = $edit['boincuser_name'];
1639 1639
     $result = $boinc_user->update(
1640 1640
         "name='{$boincuser_name}'"
1641 1641
     );
1642
-  }
1642
+    }
1643 1643
   
1644
-  // Private message settings
1645
-  pm_email_notify_user('submit', $edit, $user);
1644
+    // Private message settings
1645
+    pm_email_notify_user('submit', $edit, $user);
1646 1646
   
1647
-  // Avatar settings
1648
-  if (!$edit['field_image']) $edit['field_image'] = array();
1649
-  $profile_node->field_image = $edit['field_image'];
1650
-  node_save($profile_node);
1651
-  // Flush this from the node cache or changes won't show up immediately!
1652
-  $profile_node = node_load($profile_node->nid, NULL, TRUE);
1647
+    // Avatar settings
1648
+    if (!$edit['field_image']) $edit['field_image'] = array();
1649
+    $profile_node->field_image = $edit['field_image'];
1650
+    node_save($profile_node);
1651
+    // Flush this from the node cache or changes won't show up immediately!
1652
+    $profile_node = node_load($profile_node->nid, NULL, TRUE);
1653 1653
   
1654
-  // All other settings
1655
-  $settings = array(
1654
+    // All other settings
1655
+    $settings = array(
1656 1656
     'signature' => $edit['signature'],
1657 1657
     'signature_format' => $edit['signature_format'],
1658 1658
     'timezone' => $edit['timezone'],
@@ -1661,136 +1661,136 @@  discard block
 block discarded – undo
1661 1661
     'hide_signatures' => $edit['hide_signatures'],
1662 1662
     'sort' => $edit['comments_order'],
1663 1663
     'gravatar' => $edit['gravatar'],
1664
-  );
1665
-  if (module_exists('internationalization')) {
1664
+    );
1665
+    if (module_exists('internationalization')) {
1666 1666
     $settings['language'] = $edit['language'];
1667 1667
     global $language;
1668 1668
     if ($user->language != $edit['language']) {
1669
-      global $base_url;
1670
-      if ($edit['language'] != language_default('language')) {
1669
+        global $base_url;
1670
+        if ($edit['language'] != language_default('language')) {
1671 1671
         $form_state['redirect'] = $base_url . '/' . $edit['language'] . '/' . $_GET['q'];
1672
-      }
1673
-      else {
1672
+        }
1673
+        else {
1674 1674
         $form_state['redirect'] = $base_url . '/' . $_GET['q'];
1675
-      }
1675
+        }
1676 1676
     }
1677
-  }
1678
-  user_save($user, $settings);
1677
+    }
1678
+    user_save($user, $settings);
1679 1679
   
1680
-  drupal_set_message(bts('Your community preferences have been updated.', array(), NULL, 'boinc:account-preferences-community'));
1680
+    drupal_set_message(bts('Your community preferences have been updated.', array(), NULL, 'boinc:account-preferences-community'));
1681 1681
   
1682
-  // Form will not redirect if storage is set; not good if language changes
1683
-  unset($form_state['storage']);
1682
+    // Form will not redirect if storage is set; not good if language changes
1683
+    unset($form_state['storage']);
1684 1684
 }
1685 1685
 
1686 1686
 /**
1687 1687
  * The structure of the privacy preferences form
1688 1688
  */
1689 1689
 function boincwork_privacyprefs_form(&$form_state) {
1690
-  require_boinc(array('user', 'prefs', 'util'));
1690
+    require_boinc(array('user', 'prefs', 'util'));
1691 1691
   
1692
-  global $user;
1693
-  $account = user_load($user->uid);
1694
-  $boincuser = BoincUser::lookup_id($account->boincuser_id);
1692
+    global $user;
1693
+    $account = user_load($user->uid);
1694
+    $boincuser = BoincUser::lookup_id($account->boincuser_id);
1695 1695
   
1696
-  // Load preferences from BOINC account
1697
-  $prefs = boincwork_load_prefs('project');
1696
+    // Load preferences from BOINC account
1697
+    $prefs = boincwork_load_prefs('project');
1698 1698
   
1699
-  //if (!$prefs AND !$initialize_if_empty) return null;
1699
+    //if (!$prefs AND !$initialize_if_empty) return null;
1700 1700
   
1701
-  // Define form defaults
1702
-  $default = array(
1701
+    // Define form defaults
1702
+    $default = array(
1703 1703
     'privacy' => array(
1704
-      'send_email' => ($boincuser->send_email) ? 1 : 0,
1705
-      'show_hosts' => ($boincuser->show_hosts) ? 1 : 0
1704
+        'send_email' => ($boincuser->send_email) ? 1 : 0,
1705
+        'show_hosts' => ($boincuser->show_hosts) ? 1 : 0
1706 1706
     )
1707
-  );
1707
+    );
1708 1708
   
1709
-  // Standard option sets
1710
-  $form['boolean_options'] = array(
1709
+    // Standard option sets
1710
+    $form['boolean_options'] = array(
1711 1711
     '#type' => 'value',
1712 1712
     '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes'))
1713
-  );
1713
+    );
1714 1714
   
1715
-  $form['privacy'] = array(
1715
+    $form['privacy'] = array(
1716 1716
     '#title' => bts('Privacy settings', array(), NULL, 'boinc:account-preferences-privacy'),
1717 1717
     '#type' => 'fieldset',
1718 1718
     '#description' => null,
1719 1719
     '#collapsible' => TRUE,
1720 1720
     '#collapsed' => FALSE
1721
-  );
1722
-  $form['privacy']['send_email'] = array(
1721
+    );
1722
+    $form['privacy']['send_email'] = array(
1723 1723
     '#title' => bts('Is it OK for @project and your team (if any) to email you?', array('@project' => variable_get('site_name', 'Drupal-BOINC')), NULL, 'boinc:account-preferences-privacy'),
1724 1724
     '#type' => 'radios',
1725 1725
     '#options' => $form['boolean_options']['#value'],
1726 1726
     '#attributes' => array('class' => 'fancy'),
1727 1727
     '#default_value' => $default['privacy']['send_email']
1728
-  );
1729
-  $form['privacy']['show_hosts'] = array(
1728
+    );
1729
+    $form['privacy']['show_hosts'] = array(
1730 1730
     '#title' => bts('Should @project show your computers on its web site?', array('@project' => variable_get('site_name', 'Drupal-BOINC')), NULL, 'boinc:account-preferences-privacy'),
1731 1731
     '#type' => 'radios',
1732 1732
     '#options' => $form['boolean_options']['#value'],
1733 1733
     '#attributes' => array('class' => 'fancy'),
1734 1734
     '#default_value' => $default['privacy']['show_hosts']
1735
-  );
1735
+    );
1736 1736
   
1737
-  $form['prefs']['separator_bottom'] = array(
1737
+    $form['prefs']['separator_bottom'] = array(
1738 1738
     '#value' => '<div class="separator buttons"></div>'
1739
-  );
1739
+    );
1740 1740
   
1741
-  // Form control
1742
-  $form['prefs']['form control tabs prefix'] = array(
1741
+    // Form control
1742
+    $form['prefs']['form control tabs prefix'] = array(
1743 1743
     '#value' => '<ul class="form-control tab-list">'
1744
-  );
1745
-  $form['prefs']['submit'] = array(
1744
+    );
1745
+    $form['prefs']['submit'] = array(
1746 1746
     '#prefix' => '<li class="first tab">',
1747 1747
     '#type' => 'submit',
1748 1748
     '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'),
1749 1749
     '#suffix' => '</li>'
1750
-  );
1751
-  $form['prefs']['form control tabs'] = array(
1750
+    );
1751
+    $form['prefs']['form control tabs'] = array(
1752 1752
     '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>'
1753
-  );
1754
-  $form['prefs']['form control tabs suffix'] = array(
1753
+    );
1754
+    $form['prefs']['form control tabs suffix'] = array(
1755 1755
     '#value' => '</ul>'
1756
-  );
1756
+    );
1757 1757
   
1758
-  return $form;
1758
+    return $form;
1759 1759
 }
1760 1760
 
1761 1761
 /**
1762
-  * Validate the privacy preferences form.
1763
-  */
1762
+ * Validate the privacy preferences form.
1763
+ */
1764 1764
 function boincwork_privacyprefs_form_validate($form, &$form_state) {
1765
-  require_boinc('util');
1765
+    require_boinc('util');
1766 1766
   
1767
-  // Verify all non-boolean user input values and notify form API of failures
1768
-  // ... currently there are no non-boolean values!
1767
+    // Verify all non-boolean user input values and notify form API of failures
1768
+    // ... currently there are no non-boolean values!
1769 1769
 }
1770 1770
 
1771 1771
 /**
1772
-  * Handle post-validation submission of privacy preferences form.
1773
-  */
1772
+ * Handle post-validation submission of privacy preferences form.
1773
+ */
1774 1774
 function boincwork_privacyprefs_form_submit($form, &$form_state) {
1775
-  require_boinc(array('user', 'prefs'));
1775
+    require_boinc(array('user', 'prefs'));
1776 1776
   
1777
-  global $user;
1778
-  $account = user_load($user->uid);
1777
+    global $user;
1778
+    $account = user_load($user->uid);
1779 1779
   
1780
-  // Load BOINC account
1781
-  $boincuser = BoincUser::lookup_id($account->boincuser_id);
1780
+    // Load BOINC account
1781
+    $boincuser = BoincUser::lookup_id($account->boincuser_id);
1782 1782
   
1783
-  // Privacy preferences
1784
-  $boincuser->send_email = ($form_state['values']['send_email']) ? true : false;
1785
-  $boincuser->show_hosts = ($form_state['values']['show_hosts']) ? true : false;
1783
+    // Privacy preferences
1784
+    $boincuser->send_email = ($form_state['values']['send_email']) ? true : false;
1785
+    $boincuser->show_hosts = ($form_state['values']['show_hosts']) ? true : false;
1786 1786
   
1787
-  //project_prefs_update($boincuser, $main_prefs);
1787
+    //project_prefs_update($boincuser, $main_prefs);
1788 1788
   
1789
-  db_set_active('boinc');
1790
-  db_query("UPDATE user SET send_email = '{$boincuser->send_email}', show_hosts = '{$boincuser->show_hosts}' WHERE id = '{$boincuser->id}'");
1791
-  db_set_active('default');
1789
+    db_set_active('boinc');
1790
+    db_query("UPDATE user SET send_email = '{$boincuser->send_email}', show_hosts = '{$boincuser->show_hosts}' WHERE id = '{$boincuser->id}'");
1791
+    db_set_active('default');
1792 1792
   
1793
-  drupal_set_message(t('Your privacy preferences have been updated.'));
1793
+    drupal_set_message(t('Your privacy preferences have been updated.'));
1794 1794
 }
1795 1795
 
1796 1796
 /**
@@ -1798,37 +1798,37 @@  discard block
 block discarded – undo
1798 1798
  */
1799 1799
 function boincwork_selectapp_form(&$form_state, $apps, $current_app) {
1800 1800
 
1801
-  $form['selectapp'] = array(
1801
+    $form['selectapp'] = array(
1802 1802
     '#type' => 'select',
1803 1803
     '#attributes' => array(
1804
-      'class' => 'task-app-filter',
1805
-      'onchange' => 'this.form.submit();',
1804
+        'class' => 'task-app-filter',
1805
+        'onchange' => 'this.form.submit();',
1806 1806
     ),
1807 1807
     '#default_value' => $current_app,
1808 1808
     '#options' => $apps,
1809 1809
     '#post_render' => array('_boincwork_selectapp_form_callback'),
1810
-  );
1810
+    );
1811 1811
 
1812
-  // Class task-app-filter-submit for this form is used in
1813
-  // theming. CSS sets 'display:none' if javascript is present. Thus
1814
-  // only non-js users/browsers will see the Apply Filter button.
1815
-  $form['submit'] = array(
1812
+    // Class task-app-filter-submit for this form is used in
1813
+    // theming. CSS sets 'display:none' if javascript is present. Thus
1814
+    // only non-js users/browsers will see the Apply Filter button.
1815
+    $form['submit'] = array(
1816 1816
     '#type' => 'submit',
1817 1817
     '#value' => bts('Apply Filter', array(), NULL, 'boinc:form-save'),
1818 1818
     '#attributes' => array('class' => 'js-hide',),
1819
-  );
1819
+    );
1820 1820
 
1821
-  return $form;
1821
+    return $form;
1822 1822
 }
1823 1823
 
1824 1824
 /**
1825 1825
  * Submit function for select appliacation form.
1826 1826
  */
1827 1827
 function boincwork_selectapp_form_submit($form, &$form_state) {
1828
-  $myargs = arg();
1829
-  array_pop($myargs);
1830
-  $newpath = implode('/', $myargs ) . '/' . $form['selectapp']['#value'];
1831
-  $form_state['redirect'] = $newpath;
1828
+    $myargs = arg();
1829
+    array_pop($myargs);
1830
+    $newpath = implode('/', $myargs ) . '/' . $form['selectapp']['#value'];
1831
+    $form_state['redirect'] = $newpath;
1832 1832
 }
1833 1833
 
1834 1834
 /**
@@ -1838,7 +1838,7 @@  discard block
 block discarded – undo
1838 1838
  * 'title' for the Application drop down box.
1839 1839
  */
1840 1840
 function _boincwork_selectapp_form_callback($theContent, $theElement) {
1841
-  $disabled = '<option value="-1" disabled hidden';
1842
-  $newContent = preg_replace('/<option value="-1"/', $disabled, $theContent);
1843
-  return $newContent;
1841
+    $disabled = '<option value="-1" disabled hidden';
1842
+    $newContent = preg_replace('/<option value="-1"/', $disabled, $theContent);
1843
+    return $newContent;
1844 1844
 }
1845 1845
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
       }// switch
72 72
   } else {
73 73
       $form_state['storage']['wip'] = TRUE;
74
-      if ( !in_array($prefs_preset, array('standard','maximum','green','minimum','custom')) ) {
74
+      if (!in_array($prefs_preset, array('standard', 'maximum', 'green', 'minimum', 'custom'))) {
75 75
           if ($established) {
76 76
               $prefs_preset = 'custom';
77 77
           } else {
@@ -141,10 +141,10 @@  discard block
 block discarded – undo
141 141
   );
142 142
   $form['hour_options'] = array(
143 143
     '#type' => 'value',
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')
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 148
   );
149 149
   
150 150
   // Identify preference sets that are established to distinguish what has been
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
     '#description' => bts('Suspend computing when your computer is busy running other programs.', array(), NULL, 'boinc:account-preferences-computing'),
282 282
   );
283 283
   $form['prefs']['advanced']['processor']['hour_label'] = array(
284
-    '#value' => '<div class="form-item"><label>' . bts('Compute only between:', array(), NULL, 'boinc:account-preferences-computing') . '</label></div>'
284
+    '#value' => '<div class="form-item"><label>'.bts('Compute only between:', array(), NULL, 'boinc:account-preferences-computing').'</label></div>'
285 285
   );
286 286
   $form['prefs']['advanced']['processor']['start_hour'] = array(
287 287
     '#type' => 'select',
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
     '#default_value' => $default['start_hour']
290 290
   );
291 291
   $form['prefs']['advanced']['processor']['hour_delimiter'] = array(
292
-    '#value' => '<span>' . bts('and', array(), NULL, 'boinc:account-preference') . '</span>'
292
+    '#value' => '<span>'.bts('and', array(), NULL, 'boinc:account-preference').'</span>'
293 293
   );
294 294
   $form['prefs']['advanced']['processor']['end_hour'] = array(
295 295
     '#type' => 'select',
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
     '#default_value' => $default['end_hour']
298 298
   );
299 299
   $form['prefs']['advanced']['processor']['hour_description'] = array(
300
-    '#value' => '<div class="form-item slim"><div class="description">' . bts('Compute only during a particular period each day.', array(), NULL, 'boinc:account-preferences-computing') . '</div></div>'
300
+    '#value' => '<div class="form-item slim"><div class="description">'.bts('Compute only during a particular period each day.', array(), NULL, 'boinc:account-preferences-computing').'</div></div>'
301 301
   );
302 302
   $form['prefs']['advanced']['processor']['leave_apps_in_memory'] = array(
303 303
     '#title' => bts('Leave non-GPU tasks in memory while suspended?', array(), NULL, 'boinc:account-preferences-computing'),
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
     '#description' => bts('Limit the upload rate of file transfers.', array(), NULL, 'boinc:account-preferences-computing')
455 455
   );
456 456
   $form['prefs']['advanced']['network']['hour_label'] = array(
457
-    '#value' => '<div class="form-item"><label>' . bts('Transfer files only between', array(), NULL, 'boinc:account-preferences-computing') . '</label></div>'
457
+    '#value' => '<div class="form-item"><label>'.bts('Transfer files only between', array(), NULL, 'boinc:account-preferences-computing').'</label></div>'
458 458
   );
459 459
   $form['prefs']['advanced']['network']['net_start_hour'] = array(
460 460
     '#type' => 'select',
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
     '#default_value' => $default['net_start_hour']
463 463
   );
464 464
   $form['prefs']['advanced']['network']['hour_delimiter'] = array(
465
-    '#value' => '<span>' . bts('and', array(), NULL, 'boinc:account-preference') . '</span>'
465
+    '#value' => '<span>'.bts('and', array(), NULL, 'boinc:account-preference').'</span>'
466 466
   );
467 467
   $form['prefs']['advanced']['network']['net_end_hour'] = array(
468 468
     '#type' => 'select',
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
     '#default_value' => $default['net_end_hour']
471 471
   );
472 472
   $form['prefs']['advanced']['network']['hour_description'] = array(
473
-    '#value' => '<div class="form-item slim"><div class="description">' . bts('Transfer files only during a particular period each day.', array(), NULL, 'boinc:account-preferences-computing') . '</div></div>'
473
+    '#value' => '<div class="form-item slim"><div class="description">'.bts('Transfer files only during a particular period each day.', array(), NULL, 'boinc:account-preferences-computing').'</div></div>'
474 474
   ); 
475 475
   $form['prefs']['advanced']['network']['daily_xfer_limit_mb'] = array(
476 476
     '#title' => bts('Limit usage to', array(), NULL, 'boinc:account-preferences-computing'),
@@ -530,23 +530,23 @@  discard block
 block discarded – undo
530 530
     '#suffix' => '</li>'
531 531
   );
532 532
   $form['prefs']['form control tabs'] = array(
533
-    '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), drupal_get_path_alias("account/prefs/computing/edit")) . '</li>'
533
+    '#value' => '<li class="tab">'.l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), drupal_get_path_alias("account/prefs/computing/edit")).'</li>'
534 534
   );
535 535
   if ($venue AND $venue != 'generic') {
536 536
     global $base_path;
537
-    $form['prefs']['form control tabs']['#value'] .= '<li class="tab">' . 
537
+    $form['prefs']['form control tabs']['#value'] .= '<li class="tab">'. 
538 538
       l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/computing/clear/{$venue}",
539 539
         array(
540
-          'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/computing/combined')),
540
+          'query' => 'destination='.urlencode(drupal_get_path_alias('account/prefs/computing/combined')),
541 541
           'attributes' => array(
542
-            'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the @name preference set. Are you sure?',
543
-              array('@name' => $venue), array(), NULL, 'boinc:account-preferences') . '\')'
542
+            'onclick' => 'return confirm(\''.bts('This will remove all of your settings from the @name preference set. Are you sure?',
543
+              array('@name' => $venue), array(), NULL, 'boinc:account-preferences').'\')'
544 544
           )
545 545
         )
546
-      ) . '</li>';
546
+      ).'</li>';
547 547
   }
548 548
   $form['prefs']['view control'] = array(
549
-    '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/computing/combined') . '</li>'
549
+    '#value' => '<li class="first alt tab">'.l('('.bts('Show comparison view', array(), NULL, 'boinc:account-preferences').')', 'account/prefs/computing/combined').'</li>'
550 550
   );
551 551
   $form['prefs']['form control tabs suffix'] = array(
552 552
     '#value' => '</ul>'
@@ -852,9 +852,9 @@  discard block
 block discarded – undo
852 852
   }
853 853
   
854 854
   $form['overview'] = array(
855
-    '#value' => '<p>' . bts('Sometimes BOINC assigns separate identities to'
855
+    '#value' => '<p>'.bts('Sometimes BOINC assigns separate identities to'
856 856
       . ' the same computer by mistake. You can correct this by merging old'
857
-      . ' identities with the newest one.', array(), NULL, 'boinc:account-host-merge') . '</p>'
857
+      . ' identities with the newest one.', array(), NULL, 'boinc:account-host-merge').'</p>'
858 858
       . '<p>'
859 859
       . bts('Check the computers that are the same as @name'
860 860
       . ' (created on @date at @time with computer ID @id)',
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
           '@time' => date('H:i:s T', $current_host->create_time),
865 865
           '@id' => $current_host->id,
866 866
         ),
867
-        NULL, 'boinc:account-host-merge') . '</p>',
867
+        NULL, 'boinc:account-host-merge').'</p>',
868 868
   );
869 869
   
870 870
   $options = array();
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
     '#suffix' => '</li>'
899 899
   );
900 900
   $form['prefs']['form control tabs'] = array(
901
-    '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "host/{$host_id}") . '</li>'
901
+    '#value' => '<li class="tab">'.l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "host/{$host_id}").'</li>'
902 902
   );
903 903
   
904 904
   return $form;
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
       if (count($merged) == 2) {
944 944
         $oxford_comma = '';
945 945
       }
946
-      $list = implode(', ', $list) . $oxford_comma . ' ' . $conjunction . ' ' . $last;
946
+      $list = implode(', ', $list).$oxford_comma.' '.$conjunction.' '.$last;
947 947
     }
948 948
     else {
949 949
       $list = $last;
@@ -1182,23 +1182,23 @@  discard block
 block discarded – undo
1182 1182
     '#suffix' => '</li>'
1183 1183
   );
1184 1184
   $form['prefs']['form control tabs'] = array(
1185
-    '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>'
1185
+    '#value' => '<li class="tab">'.l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']).'</li>'
1186 1186
   );
1187 1187
   if ($venue AND $venue != 'generic') {
1188 1188
     global $base_path;
1189
-    $form['prefs']['form control tabs']['#value'] .= '<li class="tab">' . 
1189
+    $form['prefs']['form control tabs']['#value'] .= '<li class="tab">'. 
1190 1190
       l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/project/clear/{$venue}",
1191 1191
         array(
1192
-          'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/project/combined')),
1192
+          'query' => 'destination='.urlencode(drupal_get_path_alias('account/prefs/project/combined')),
1193 1193
           'attributes' => array(
1194
-            'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the @name preference set. Are you sure?',
1195
-              array('@name' => $venue), NULL, 'boinc:account-preferences') . '\')'
1194
+            'onclick' => 'return confirm(\''.bts('This will remove all of your settings from the @name preference set. Are you sure?',
1195
+              array('@name' => $venue), NULL, 'boinc:account-preferences').'\')'
1196 1196
           )
1197 1197
         )
1198
-      ) . '</li>';
1198
+      ).'</li>';
1199 1199
   }
1200 1200
   $form['prefs']['view control'] = array(
1201
-      '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/project/combined') . '</li>'
1201
+      '#value' => '<li class="first alt tab">'.l('('.bts('Show comparison view', array(), NULL, 'boinc:account-preferences').')', 'account/prefs/project/combined').'</li>'
1202 1202
   );
1203 1203
   $form['prefs']['form control tabs suffix'] = array(
1204 1204
     '#value' => '</ul>'
@@ -1241,7 +1241,7 @@  discard block
 block discarded – undo
1241 1241
     
1242 1242
   foreach ($xml['project_specific_preferences'] as $wrapped_element) {
1243 1243
     $type = key($wrapped_element);
1244
-    $element= reset($wrapped_element);
1244
+    $element = reset($wrapped_element);
1245 1245
     boincwork_generate_prefs_element($form, $type, $element, $prefs['project_specific']);
1246 1246
   }
1247 1247
 }
@@ -1467,7 +1467,7 @@  discard block
 block discarded – undo
1467 1467
     $names = array();
1468 1468
     foreach ($languages as $langcode => $item) {
1469 1469
       $name = t($item->name);
1470
-      $names[check_plain($langcode)] = check_plain($name . ($item->native != $name ? ' ('. $item->native .')' : ''));
1470
+      $names[check_plain($langcode)] = check_plain($name.($item->native != $name ? ' ('.$item->native.')' : ''));
1471 1471
     }
1472 1472
     $form['locale'] = array(
1473 1473
       '#type' => 'fieldset',
@@ -1492,20 +1492,20 @@  discard block
 block discarded – undo
1492 1492
   // Avatar options
1493 1493
   $form['gravatar'] = array(
1494 1494
     '#type' => 'item',
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), NULL, 'boinc:account-preferences-community'),
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), NULL, 'boinc:account-preferences-community'),
1496 1496
     '#description' => bts('Your Gravatar will not be shown if you upload a user picture.', array(), NULL, 'boinc:account-preferences-community'),
1497 1497
   );
1498 1498
   if (user_access('disable own gravatar', $account)) {
1499 1499
     $form['gravatar'] = array(
1500 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), NULL, 'boinc:account-preferences-community'),
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), NULL, 'boinc:account-preferences-community'),
1502 1502
       '#description' => bts('Gravatar will not be shown if an avatar is uploaded.', array(), NULL, 'boinc:account-preferences-community'),
1503 1503
       '#default_value' => isset($account->gravatar) ? $account->gravatar : 0,
1504 1504
       '#disabled' => !empty($account->picture),
1505 1505
     );
1506 1506
   }
1507 1507
   $form['gravatar']['#weight'] = 15;
1508
-  $form['gravatar']['#prefix'] = '<fieldset class="collapsible"><legend><a href="#">' . bts('Avatar settings', array(), NULL, 'boinc:account-preferences-community') . '</a></legend>';
1508
+  $form['gravatar']['#prefix'] = '<fieldset class="collapsible"><legend><a href="#">'.bts('Avatar settings', array(), NULL, 'boinc:account-preferences-community').'</a></legend>';
1509 1509
   // Upload an avatar (pulled from profile_node_form):
1510 1510
   if (!empty($profile_form['field_image'])) {
1511 1511
     $form['field_image'] = $profile_form['field_image'];
@@ -1540,7 +1540,7 @@  discard block
 block discarded – undo
1540 1540
   );
1541 1541
   // Can't have a typical Drupal form suffix on a select box?
1542 1542
   $form['forums']['comments_per_page_suffix'] = array(
1543
-    '#value' => '<span>' . bts('comments per page', array(), NULL, 'boinc:account-preferences-community') . '</span>'
1543
+    '#value' => '<span>'.bts('comments per page', array(), NULL, 'boinc:account-preferences-community').'</span>'
1544 1544
   );
1545 1545
   $form['forums']['comments_order'] = array(
1546 1546
     '#type' => 'select',
@@ -1612,7 +1612,7 @@  discard block
 block discarded – undo
1612 1612
     '#weight' => 1002,
1613 1613
   );
1614 1614
   $form['form control tabs'] = array(
1615
-    '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>',
1615
+    '#value' => '<li class="tab">'.l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']).'</li>',
1616 1616
     '#weight' => 1003,
1617 1617
   );
1618 1618
   $form['form control tabs suffix'] = array(
@@ -1668,10 +1668,10 @@  discard block
 block discarded – undo
1668 1668
     if ($user->language != $edit['language']) {
1669 1669
       global $base_url;
1670 1670
       if ($edit['language'] != language_default('language')) {
1671
-        $form_state['redirect'] = $base_url . '/' . $edit['language'] . '/' . $_GET['q'];
1671
+        $form_state['redirect'] = $base_url.'/'.$edit['language'].'/'.$_GET['q'];
1672 1672
       }
1673 1673
       else {
1674
-        $form_state['redirect'] = $base_url . '/' . $_GET['q'];
1674
+        $form_state['redirect'] = $base_url.'/'.$_GET['q'];
1675 1675
       }
1676 1676
     }
1677 1677
   }
@@ -1749,7 +1749,7 @@  discard block
 block discarded – undo
1749 1749
     '#suffix' => '</li>'
1750 1750
   );
1751 1751
   $form['prefs']['form control tabs'] = array(
1752
-    '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>'
1752
+    '#value' => '<li class="tab">'.l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']).'</li>'
1753 1753
   );
1754 1754
   $form['prefs']['form control tabs suffix'] = array(
1755 1755
     '#value' => '</ul>'
@@ -1827,7 +1827,7 @@  discard block
 block discarded – undo
1827 1827
 function boincwork_selectapp_form_submit($form, &$form_state) {
1828 1828
   $myargs = arg();
1829 1829
   array_pop($myargs);
1830
-  $newpath = implode('/', $myargs ) . '/' . $form['selectapp']['#value'];
1830
+  $newpath = implode('/', $myargs).'/'.$form['selectapp']['#value'];
1831 1831
   $form_state['redirect'] = $newpath;
1832 1832
 }
1833 1833
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +245 added lines, -245 removed lines patch added patch discarded remove patch
@@ -14,10 +14,10 @@  discard block
 block discarded – undo
14 14
 /**
15 15
  * The structure of the general preferences form
16 16
  */
17
-function boincwork_generalprefs_form(&$form_state, $venue, $prefs_preset = null, $advanced = FALSE) {
17
+function boincwork_generalprefs_form(&$form_state, $venue, $prefs_preset = null, $advanced = false) {
18 18
   $form = array();
19 19
   $prefs = null;
20
-  $established = TRUE;
20
+  $established = true;
21 21
   
22 22
   // Enable AHAH form support for dynamically updating content based on preset
23 23
   ahah_helper_register($form, $form_state);
@@ -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
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
           break;
71 71
       }// switch
72 72
   } else {
73
-      $form_state['storage']['wip'] = TRUE;
73
+      $form_state['storage']['wip'] = true;
74 74
       if ( !in_array($prefs_preset, array('standard','maximum','green','minimum','custom')) ) {
75 75
           if ($established) {
76 76
               $prefs_preset = 'custom';
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
   // Standard option sets
138 138
   $form['boolean_options'] = array(
139 139
     '#type' => 'value',
140
-    '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes'))
140
+    '#value' => array(1 => bts('yes', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes'))
141 141
   );
142 142
   $form['hour_options'] = array(
143 143
     '#type' => 'value',
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
     '#prefix' => '<div id="prefs-wrapper">', // This is our wrapper div.
159 159
     '#attributes' => array('class' => 'ahah-container'),
160 160
     '#suffix' => '</div>',
161
-    '#tree'   => TRUE
161
+    '#tree'   => true
162 162
   );
163 163
   //$form['prefs']['debug'] = array('#value' => '<pre>' . print_r($form_state, true) . '</pre>');
164 164
   
@@ -178,15 +178,15 @@  discard block
 block discarded – undo
178 178
   
179 179
   // Simplified selectors
180 180
   $form['prefs']['preset'] = array(
181
-      '#title' => bts('Presets', array(), NULL, 'boinc:account-preferences-preset:-1:for a user to choose a computing or project preference preset.'),
181
+      '#title' => bts('Presets', array(), null, 'boinc:account-preferences-preset:-1:for a user to choose a computing or project preference preset.'),
182 182
     '#type' => 'radios',
183 183
     '#description' => ' ',
184 184
     '#options' => array(
185
-      'standard' => bts('Standard', array(), NULL, 'boinc:account-preferences-preset'),
186
-      'maximum' => bts('Maximum', array(), NULL, 'boinc:account-preferences-preset'),
187
-      'green' => bts('Green', array(), NULL, 'boinc:account-preferences-preset'),
188
-      'minimum' => bts('Minimum', array(), NULL, 'boinc:account-preferences-preset'),
189
-      'custom' => bts('Custom', array(), NULL, 'boinc:account-preferences-preset')
185
+      'standard' => bts('Standard', array(), null, 'boinc:account-preferences-preset'),
186
+      'maximum' => bts('Maximum', array(), null, 'boinc:account-preferences-preset'),
187
+      'green' => bts('Green', array(), null, 'boinc:account-preferences-preset'),
188
+      'minimum' => bts('Minimum', array(), null, 'boinc:account-preferences-preset'),
189
+      'custom' => bts('Custom', array(), null, 'boinc:account-preferences-preset')
190 190
     ),
191 191
     '#prefix' => '<div class="simple-form-controls">',
192 192
     '#suffix' => '</div>',
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
   );
200 200
   $form['prefs']['select preset'] = array(
201 201
     '#type'  => 'submit',
202
-    '#value' => bts('Update preset', array(), NULL, 'boinc:account-preferences-preset'),
202
+    '#value' => bts('Update preset', array(), null, 'boinc:account-preferences-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'),
@@ -207,10 +207,10 @@  discard block
 block discarded – undo
207 207
   
208 208
   // Advanced preferences
209 209
   $form['prefs']['advanced'] = array(
210
-    '#title' => bts('Advanced settings', array(), NULL, 'boinc:account-preferences-option'),
210
+    '#title' => bts('Advanced settings', array(), null, 'boinc:account-preferences-option'),
211 211
     '#type' => 'fieldset',
212 212
     '#description' => '',
213
-    '#collapsible' => TRUE,
213
+    '#collapsible' => true,
214 214
     '#collapsed' => !$advanced,
215 215
     '#attributes' => array('class' => 'advanced-settings'),
216 216
   );
@@ -226,62 +226,62 @@  discard block
 block discarded – undo
226 226
   );
227 227
   
228 228
   $form['prefs']['advanced']['processor'] = array(
229
-    '#title' => bts('Processor usage', array(), NULL, 'boinc:account-preferences-computing'),
229
+    '#title' => bts('Processor usage', array(), null, 'boinc:account-preferences-computing'),
230 230
     '#type' => 'fieldset',
231 231
     '#description' => '',
232
-    '#collapsible' => FALSE,
233
-    '#collapsed' => FALSE
232
+    '#collapsible' => false,
233
+    '#collapsed' => false
234 234
   );
235 235
   $form['prefs']['advanced']['processor']['run_on_batteries'] = array(
236
-    '#title' => bts('Suspend when computer is on battery?', array(), NULL, 'boinc:account-preferences-computing'),
236
+    '#title' => bts('Suspend when computer is on battery?', array(), null, 'boinc:account-preferences-computing'),
237 237
     '#type' => 'radios',
238
-    '#description' => bts('Suspends computing on portables when running on battery power.', array(), NULL, 'boinc:account-preferences-computing'),
238
+    '#description' => bts('Suspends computing on portables when running on battery power.', array(), null, 'boinc:account-preferences-computing'),
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 242
   );
243 243
   $form['prefs']['advanced']['processor']['run_if_user_active'] = array(
244
-    '#title' => bts('Suspend when computer is in use?', array(), NULL, 'boinc:account-preferences-computing'),
244
+    '#title' => bts('Suspend when computer is in use?', array(), null, 'boinc:account-preferences-computing'),
245 245
     '#type' => 'radios',
246
-    '#description' => bts("Suspends computing and file transfers when you're using the computer.", array(), NULL, 'boinc:account-preferences-computing'),
246
+    '#description' => bts("Suspends computing and file transfers when you're using the computer.", array(), null, 'boinc:account-preferences-computing'),
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 250
   );
251 251
   $form['prefs']['advanced']['processor']['run_gpu_if_user_active'] = array(
252
-    '#title' => bts('Suspend GPU computing when computer is in use?', array(), NULL, 'boinc:account-preferences-computing'),
252
+    '#title' => bts('Suspend GPU computing when computer is in use?', array(), null, 'boinc:account-preferences-computing'),
253 253
     '#type' => 'radios',
254
-    '#description' => bts("Suspends GPU computing when you're using the computer.", array(), NULL, 'boinc:account-preferences-computing'),
254
+    '#description' => bts("Suspends GPU computing when you're using the computer.", array(), null, 'boinc:account-preferences-computing'),
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 258
   );
259 259
   $form['prefs']['advanced']['processor']['idle_time_to_run'] = array(
260
-      '#title' => bts('"In use" means mouse/keyboard input in last', array(), NULL, 'boinc:account-preferences-computing'),
260
+      '#title' => bts('"In use" means mouse/keyboard input in last', array(), null, 'boinc:account-preferences-computing'),
261 261
     '#type' => 'textfield',
262
-    '#field_suffix' => bts('minutes', array(), NULL, 'boinc:unit-of-time'),
262
+    '#field_suffix' => bts('minutes', array(), null, 'boinc:unit-of-time'),
263 263
     '#default_value' => $default['idle_time_to_run'],
264 264
     '#size' => 1,
265
-    '#description' => bts('This determines when the computer is considered "in use".', array(), NULL, 'boinc:account-preferences-computing')
265
+    '#description' => bts('This determines when the computer is considered "in use".', array(), null, 'boinc:account-preferences-computing')
266 266
   );
267 267
   $form['prefs']['advanced']['processor']['suspend_if_no_recent_input'] = array(
268
-    '#title' => bts('Suspend when no mouse/keyboard input in last', array(), NULL, 'boinc:account-preferences-computing'),
268
+    '#title' => bts('Suspend when no mouse/keyboard input in last', array(), null, 'boinc:account-preferences-computing'),
269 269
     '#type' => 'textfield',
270
-    '#field_suffix' => bts('minutes', array(), NULL, 'boinc:unit-of-time'),
270
+    '#field_suffix' => bts('minutes', array(), null, 'boinc:unit-of-time'),
271 271
     '#default_value' => $default['suspend_if_no_recent_input'],
272 272
     '#size' => 1,
273
-    '#description' => bts('This allows some computers to enter low-power mode when not in use.', array(), NULL, 'boinc:account-preferences-computing')
273
+    '#description' => bts('This allows some computers to enter low-power mode when not in use.', array(), null, 'boinc:account-preferences-computing')
274 274
   );
275 275
   $form['prefs']['advanced']['processor']['suspend_cpu_usage'] = array(
276
-    '#title' => bts('Suspend when non-BOINC CPU usage is above', array(), NULL, 'boinc:account-preferences-computing'),
276
+    '#title' => bts('Suspend when non-BOINC CPU usage is above', array(), null, 'boinc:account-preferences-computing'),
277 277
     '#type' => 'textfield',
278 278
     '#field_suffix' => '%',
279 279
     '#default_value' => $default['suspend_cpu_usage'],
280 280
     '#size' => 1,
281
-    '#description' => bts('Suspend computing when your computer is busy running other programs.', array(), NULL, 'boinc:account-preferences-computing'),
281
+    '#description' => bts('Suspend computing when your computer is busy running other programs.', array(), null, 'boinc:account-preferences-computing'),
282 282
   );
283 283
   $form['prefs']['advanced']['processor']['hour_label'] = array(
284
-    '#value' => '<div class="form-item"><label>' . bts('Compute only between:', array(), NULL, 'boinc:account-preferences-computing') . '</label></div>'
284
+    '#value' => '<div class="form-item"><label>' . bts('Compute only between:', array(), null, 'boinc:account-preferences-computing') . '</label></div>'
285 285
   );
286 286
   $form['prefs']['advanced']['processor']['start_hour'] = array(
287 287
     '#type' => 'select',
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
     '#default_value' => $default['start_hour']
290 290
   );
291 291
   $form['prefs']['advanced']['processor']['hour_delimiter'] = array(
292
-    '#value' => '<span>' . bts('and', array(), NULL, 'boinc:account-preference') . '</span>'
292
+    '#value' => '<span>' . bts('and', array(), null, 'boinc:account-preference') . '</span>'
293 293
   );
294 294
   $form['prefs']['advanced']['processor']['end_hour'] = array(
295 295
     '#type' => 'select',
@@ -297,164 +297,164 @@  discard block
 block discarded – undo
297 297
     '#default_value' => $default['end_hour']
298 298
   );
299 299
   $form['prefs']['advanced']['processor']['hour_description'] = array(
300
-    '#value' => '<div class="form-item slim"><div class="description">' . bts('Compute only during a particular period each day.', array(), NULL, 'boinc:account-preferences-computing') . '</div></div>'
300
+    '#value' => '<div class="form-item slim"><div class="description">' . bts('Compute only during a particular period each day.', array(), null, 'boinc:account-preferences-computing') . '</div></div>'
301 301
   );
302 302
   $form['prefs']['advanced']['processor']['leave_apps_in_memory'] = array(
303
-    '#title' => bts('Leave non-GPU tasks in memory while suspended?', array(), NULL, 'boinc:account-preferences-computing'),
303
+    '#title' => bts('Leave non-GPU tasks in memory while suspended?', array(), null, 'boinc:account-preferences-computing'),
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
-    '#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.', array(), NULL, 'boinc:account-preferences-computing')
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.', array(), null, 'boinc:account-preferences-computing')
309 309
   );
310 310
   $form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes'] = array(
311
-    '#title' => bts('Switch between tasks every', array(), NULL, 'boinc:account-preferences-computing'),
311
+    '#title' => bts('Switch between tasks every', array(), null, 'boinc:account-preferences-computing'),
312 312
     '#type' => 'textfield',
313
-    '#field_suffix' => bts('minutes', array(), NULL, 'boinc:unit-of-time'),
313
+    '#field_suffix' => bts('minutes', array(), null, 'boinc:unit-of-time'),
314 314
     '#default_value' => $default['cpu_scheduling_period_minutes'],
315 315
     '#size' => 1,
316
-    '#description' => bts('If you run several projects, BOINC may switch between them this often.', array(), NULL, 'boinc:account-preferences-computing')
316
+    '#description' => bts('If you run several projects, BOINC may switch between them this often.', array(), null, 'boinc:account-preferences-computing')
317 317
   );
318 318
   $form['prefs']['advanced']['processor']['max_ncpus_pct'] = array(
319
-    '#title' => bts('Use at most', array(), NULL, 'boinc:account-preferences-computing'),
319
+    '#title' => bts('Use at most', array(), null, 'boinc:account-preferences-computing'),
320 320
     '#type' => 'textfield',
321
-    '#field_suffix' => bts('% of the processors', array(), NULL, 'boinc:account-preferences-computing'),
321
+    '#field_suffix' => bts('% of the processors', array(), null, 'boinc:account-preferences-computing'),
322 322
     '#default_value' => $default['max_ncpus_pct'],
323 323
     '#size' => 1,
324
-    '#description' => bts('Keep some CPUs free for other applications. Example: 75% means use 6 cores on an 8-core CPU.', array(), NULL, 'boinc:account-preferences-computing'),
324
+    '#description' => bts('Keep some CPUs free for other applications. Example: 75% means use 6 cores on an 8-core CPU.', array(), null, 'boinc:account-preferences-computing'),
325 325
   );
326 326
   $form['prefs']['advanced']['processor']['cpu_usage_limit'] = array(
327
-    '#title' => bts('Use at most', array(), NULL, 'boinc:account-preferences-computing'),
327
+    '#title' => bts('Use at most', array(), null, 'boinc:account-preferences-computing'),
328 328
     '#type' => 'textfield',
329
-    '#field_suffix' => bts('% of the CPU time', array(), NULL, 'boinc:account-preferences-computing'),
329
+    '#field_suffix' => bts('% of the CPU time', array(), null, 'boinc:account-preferences-computing'),
330 330
     '#default_value' => $default['cpu_usage_limit'],
331 331
     '#size' => 1,
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.', array(), NULL, 'boinc:account-preferences-computing')
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.', array(), null, 'boinc:account-preferences-computing')
333 333
   );
334 334
   
335 335
   // Disk and memory preferences
336 336
   $form['prefs']['advanced']['storage'] = array(
337
-    '#title' => bts('Disk and memory usage', array(), NULL, 'boinc:account-preferences-computing'),
337
+    '#title' => bts('Disk and memory usage', array(), null, 'boinc:account-preferences-computing'),
338 338
     '#type' => 'fieldset',
339 339
     '#description' => '',
340
-    '#collapsible' => FALSE,
341
-    '#collapsed' => FALSE
340
+    '#collapsible' => false,
341
+    '#collapsed' => false
342 342
   );
343 343
   $form['prefs']['advanced']['storage']['disk_max_used_gb'] = array(
344
-    '#title' => bts('Disk: use no more than', array(), NULL, 'boinc:account-preferences-computing'),
344
+    '#title' => bts('Disk: use no more than', array(), null, 'boinc:account-preferences-computing'),
345 345
     '#type' => 'textfield',
346 346
     '#field_suffix' => 'GB',
347 347
     '#default_value' => $default['disk_max_used_gb'],
348 348
     '#size' => 1,
349
-    '#description' => bts('Limit the total amount of disk space used by BOINC.', array(), NULL, 'boinc:account-preferences-computing'),
349
+    '#description' => bts('Limit the total amount of disk space used by BOINC.', array(), null, 'boinc:account-preferences-computing'),
350 350
   ); 
351 351
   $form['prefs']['advanced']['storage']['disk_min_free_gb'] = array(
352
-    '#title' => bts('Disk: leave at least', array(), NULL, 'boinc:account-preferences-computing'),
352
+    '#title' => bts('Disk: leave at least', array(), null, 'boinc:account-preferences-computing'),
353 353
     '#type' => 'textfield',
354 354
     '#field_suffix' => 'GB free',
355 355
     '#default_value' => $default['disk_min_free_gb'],
356 356
     '#size' => 1,
357
-    '#description' => bts('Limit disk usage to leave this much free space on the volume where BOINC stores data.', array(), NULL, 'boinc:account-preferences-computing'),
357
+    '#description' => bts('Limit disk usage to leave this much free space on the volume where BOINC stores data.', array(), null, 'boinc:account-preferences-computing'),
358 358
   );
359 359
   $form['prefs']['advanced']['storage']['disk_max_used_pct'] = array(
360
-    '#title' => bts('Disk: use no more than', array(), NULL, 'boinc:account-preferences-computing'),
360
+    '#title' => bts('Disk: use no more than', array(), null, 'boinc:account-preferences-computing'),
361 361
     '#type' => 'textfield',
362
-    '#field_suffix' => bts('% of total', array(), NULL, 'boinc:account-preferences-computing'),
362
+    '#field_suffix' => bts('% of total', array(), null, 'boinc:account-preferences-computing'),
363 363
     '#default_value' => $default['disk_max_used_pct'],
364 364
     '#size' => 1,
365
-    '#description' => bts('Limit the percentage of disk space used by BOINC on the volume where it stores data.', array(), NULL, 'boinc:account-preferences-computing')
365
+    '#description' => bts('Limit the percentage of disk space used by BOINC on the volume where it stores data.', array(), null, 'boinc:account-preferences-computing')
366 366
   ); 
367 367
   $form['prefs']['advanced']['storage']['disk_interval'] = array(
368
-    '#title' => bts('Request tasks to checkpoint at most every', array(), NULL, 'boinc:account-preferences-computing'),
368
+    '#title' => bts('Request tasks to checkpoint at most every', array(), null, 'boinc:account-preferences-computing'),
369 369
     '#type' => 'textfield',
370
-    '#field_suffix' => bts('seconds', array(), NULL, 'boinc:unit-of-time'),
370
+    '#field_suffix' => bts('seconds', array(), null, 'boinc:unit-of-time'),
371 371
     '#default_value' => $default['disk_interval'],
372 372
     '#size' => 1,
373
-    '#description' => bts('This controls how often tasks save their state to disk, so that later they can be continued from that point.', array(), NULL, 'boinc:account-preferences-computing')
373
+    '#description' => bts('This controls how often tasks save their state to disk, so that later they can be continued from that point.', array(), null, 'boinc:account-preferences-computing')
374 374
   );
375 375
   $form['prefs']['advanced']['storage']['vm_max_used_pct'] = array(
376
-    '#title' => bts('Page/swap file: use at most', array(), NULL, 'boinc:account-preferences-computing'),
376
+    '#title' => bts('Page/swap file: use at most', array(), null, 'boinc:account-preferences-computing'),
377 377
     '#type' => 'textfield',
378
-    '#field_suffix' => bts('% of total', array(), NULL, 'boinc:account-preferences-computing'),
378
+    '#field_suffix' => bts('% of total', array(), null, 'boinc:account-preferences-computing'),
379 379
     '#default_value' => $default['vm_max_used_pct'],
380 380
     '#size' => 1,
381
-    '#description' => bts('Limit the swap space (page file) used by BOINC.', array(), NULL, 'boinc:account-preferences-computing')
381
+    '#description' => bts('Limit the swap space (page file) used by BOINC.', array(), null, 'boinc:account-preferences-computing')
382 382
   );
383 383
   $form['prefs']['advanced']['storage']['ram_max_used_busy_pct'] = array(
384
-    '#title' => bts('Memory: when computer is in use, use at most', array(), NULL, 'boinc:account-preferences-computing'),
384
+    '#title' => bts('Memory: when computer is in use, use at most', array(), null, 'boinc:account-preferences-computing'),
385 385
     '#type' => 'textfield',
386
-    '#field_suffix' => bts('% of total', array(), NULL, 'boinc:account-preferences-computing'),
386
+    '#field_suffix' => bts('% of total', array(), null, 'boinc:account-preferences-computing'),
387 387
     '#default_value' => $default['ram_max_used_busy_pct'],
388 388
     '#size' => 1,
389
-    '#description' => bts("Limit the memory used by BOINC when you're using the computer.", array(), NULL, 'boinc:account-preferences-computing')
389
+    '#description' => bts("Limit the memory used by BOINC when you're using the computer.", array(), null, 'boinc:account-preferences-computing')
390 390
   );
391 391
   $form['prefs']['advanced']['storage']['ram_max_used_idle_pct'] = array(
392
-    '#title' => bts('Memory: when computer is not in use, use at most', array(), NULL, 'boinc:account-preferences-computing'),
392
+    '#title' => bts('Memory: when computer is not in use, use at most', array(), null, 'boinc:account-preferences-computing'),
393 393
     '#type' => 'textfield',
394
-    '#field_suffix' => bts('% of total', array(), NULL, 'boinc:account-preferences-computing'),
394
+    '#field_suffix' => bts('% of total', array(), null, 'boinc:account-preferences-computing'),
395 395
     '#default_value' => $default['ram_max_used_idle_pct'],
396 396
     '#size' => 1,
397
-    '#description' => bts("Limit the memory used by BOINC when you're not using the computer.", array(), NULL, 'boinc:account-preferences-computing')
397
+    '#description' => bts("Limit the memory used by BOINC when you're not using the computer.", array(), null, 'boinc:account-preferences-computing')
398 398
   );
399 399
   
400 400
   // Network preferences
401 401
   $form['prefs']['advanced']['network'] = array(
402
-    '#title' => bts('Network usage', array(), NULL, 'boinc:account-preferences-computing'),
402
+    '#title' => bts('Network usage', array(), null, 'boinc:account-preferences-computing'),
403 403
     '#type' => 'fieldset',
404 404
     '#description' => '',
405
-    '#collapsible' => FALSE,
406
-    '#collapsed' => FALSE
405
+    '#collapsible' => false,
406
+    '#collapsed' => false
407 407
   );
408 408
   $form['prefs']['advanced']['network']['work_buf_min_days'] = array(
409
-    '#title' => bts('Store at least', array(), NULL, 'boinc:account-preferences-computing'),
409
+    '#title' => bts('Store at least', array(), null, 'boinc:account-preferences-computing'),
410 410
     '#type' => 'textfield',
411
-    '#field_suffix' => bts('days of work', array(), NULL, 'boinc:account-preferences-computing'),
411
+    '#field_suffix' => bts('days of work', array(), null, 'boinc:account-preferences-computing'),
412 412
     '#default_value' => $default['work_buf_min_days'],
413 413
     '#size' => 1,
414
-    '#description' => bts('Store at least enough tasks to keep the computer busy for this long.', array(), NULL, 'boinc:account-preferences-computing')
414
+    '#description' => bts('Store at least enough tasks to keep the computer busy for this long.', array(), null, 'boinc:account-preferences-computing')
415 415
   ); 
416 416
   $form['prefs']['advanced']['network']['work_buf_additional_days'] = array(
417
-    '#title' => bts('Store up to an additional', array(), NULL, 'boinc:account-preferences-computing'),
417
+    '#title' => bts('Store up to an additional', array(), null, 'boinc:account-preferences-computing'),
418 418
     '#type' => 'textfield',
419
-    '#field_suffix' => bts('days', array(), NULL, 'boinc:unit-of-time'),
419
+    '#field_suffix' => bts('days', array(), null, 'boinc:unit-of-time'),
420 420
     '#default_value' => $default['work_buf_additional_days'],
421 421
     '#size' => 1,
422
-    '#description' => bts('Store additional tasks above the minimum level.  Determines how much work is requested when contacting a project.', array(), NULL, 'boinc:account-preferences-computing')
422
+    '#description' => bts('Store additional tasks above the minimum level.  Determines how much work is requested when contacting a project.', array(), null, 'boinc:account-preferences-computing')
423 423
   ); 
424 424
   $form['prefs']['advanced']['network']['confirm_before_connecting'] = array(
425
-    '#title' => bts('Confirm before connecting to Internet?', array(), NULL, 'boinc:account-preferences-computing'),
425
+    '#title' => bts('Confirm before connecting to Internet?', array(), null, 'boinc:account-preferences-computing'),
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
-    '#description' => bts('Useful only if you have a modem, ISDN or VPN connection.', array(), NULL, 'boinc:account-preferences-computing')
430
+    '#description' => bts('Useful only if you have a modem, ISDN or VPN connection.', array(), null, 'boinc:account-preferences-computing')
431 431
   ); 
432 432
   $form['prefs']['advanced']['network']['hangup_if_dialed'] = array(
433
-    '#title' => bts('Disconnect when done?', array(), NULL, 'boinc:account-preferences-computing'),
433
+    '#title' => bts('Disconnect when done?', array(), null, 'boinc:account-preferences-computing'),
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
-    '#description' => bts('Useful only if you have a modem, ISDN or VPN connection.', array(), NULL, 'boinc:account-preferences-computing')
438
+    '#description' => bts('Useful only if you have a modem, ISDN or VPN connection.', array(), null, 'boinc:account-preferences-computing')
439 439
   );
440 440
   $form['prefs']['advanced']['network']['max_bytes_sec_down'] = array(
441
-    '#title' => bts('Limit download rate to', array(), NULL, 'boinc:account-preferences-computing'),
441
+    '#title' => bts('Limit download rate to', array(), null, 'boinc:account-preferences-computing'),
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
-    '#description' => bts('Limit the download rate of file transfers.', array(), NULL, 'boinc:account-preferences-computing')
446
+    '#description' => bts('Limit the download rate of file transfers.', array(), null, 'boinc:account-preferences-computing')
447 447
   ); 
448 448
   $form['prefs']['advanced']['network']['max_bytes_sec_up'] = array(
449
-    '#title' => bts('Limit upload rate to', array(), NULL, 'boinc:account-preferences-computing'),
449
+    '#title' => bts('Limit upload rate to', array(), null, 'boinc:account-preferences-computing'),
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
-    '#description' => bts('Limit the upload rate of file transfers.', array(), NULL, 'boinc:account-preferences-computing')
454
+    '#description' => bts('Limit the upload rate of file transfers.', array(), null, 'boinc:account-preferences-computing')
455 455
   );
456 456
   $form['prefs']['advanced']['network']['hour_label'] = array(
457
-    '#value' => '<div class="form-item"><label>' . bts('Transfer files only between', array(), NULL, 'boinc:account-preferences-computing') . '</label></div>'
457
+    '#value' => '<div class="form-item"><label>' . bts('Transfer files only between', array(), null, 'boinc:account-preferences-computing') . '</label></div>'
458 458
   );
459 459
   $form['prefs']['advanced']['network']['net_start_hour'] = array(
460 460
     '#type' => 'select',
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
     '#default_value' => $default['net_start_hour']
463 463
   );
464 464
   $form['prefs']['advanced']['network']['hour_delimiter'] = array(
465
-    '#value' => '<span>' . bts('and', array(), NULL, 'boinc:account-preference') . '</span>'
465
+    '#value' => '<span>' . bts('and', array(), null, 'boinc:account-preference') . '</span>'
466 466
   );
467 467
   $form['prefs']['advanced']['network']['net_end_hour'] = array(
468 468
     '#type' => 'select',
@@ -470,10 +470,10 @@  discard block
 block discarded – undo
470 470
     '#default_value' => $default['net_end_hour']
471 471
   );
472 472
   $form['prefs']['advanced']['network']['hour_description'] = array(
473
-    '#value' => '<div class="form-item slim"><div class="description">' . bts('Transfer files only during a particular period each day.', array(), NULL, 'boinc:account-preferences-computing') . '</div></div>'
473
+    '#value' => '<div class="form-item slim"><div class="description">' . bts('Transfer files only during a particular period each day.', array(), null, 'boinc:account-preferences-computing') . '</div></div>'
474 474
   ); 
475 475
   $form['prefs']['advanced']['network']['daily_xfer_limit_mb'] = array(
476
-    '#title' => bts('Limit usage to', array(), NULL, 'boinc:account-preferences-computing'),
476
+    '#title' => bts('Limit usage to', array(), null, 'boinc:account-preferences-computing'),
477 477
     '#type' => 'textfield',
478 478
     '#field_suffix' => 'Mbytes',
479 479
     '#default_value' => $default['daily_xfer_limit_mb'],
@@ -482,18 +482,18 @@  discard block
 block discarded – undo
482 482
   $form['prefs']['advanced']['network']['daily_xfer_period_days'] = array(
483 483
     '#field_prefix' => 'every',
484 484
     '#type' => 'textfield',
485
-    '#field_suffix' => bts('days', array(), NULL, 'boinc:unit-of-time'),
485
+    '#field_suffix' => bts('days', array(), null, 'boinc:unit-of-time'),
486 486
     '#default_value' => $default['daily_xfer_period_days'],
487 487
     '#size' => 1,
488
-    '#description' => bts('Example: BOINC should transfer at most 2000 MB of data every 30 days.', array(), NULL, 'boinc:account-preferences-computing'),
488
+    '#description' => bts('Example: BOINC should transfer at most 2000 MB of data every 30 days.', array(), null, 'boinc:account-preferences-computing'),
489 489
   ); 
490 490
   $form['prefs']['advanced']['network']['dont_verify_images'] = array(
491
-    '#title' => bts('Skip data verification for image files?', array(), NULL, 'boinc:account-preferences-computing'),
491
+    '#title' => bts('Skip data verification for image files?', array(), null, 'boinc:account-preferences-computing'),
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
-    '#description' => bts('Only select "Yes" if your Internet provider modifies image files. Skipping verification reduces the security of BOINC.', array(), NULL, 'boinc:account-preferences-computing')
496
+    '#description' => bts('Only select "Yes" if your Internet provider modifies image files. Skipping verification reduces the security of BOINC.', array(), null, 'boinc:account-preferences-computing')
497 497
   );
498 498
   
499 499
   // The "fancy radios" are made via javascript on document load. In order for
@@ -526,27 +526,27 @@  discard block
 block discarded – undo
526 526
   $form['prefs']['submit'] = array(
527 527
     '#prefix' => '<li class="first tab">',
528 528
     '#type' => 'submit',
529
-    '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'),
529
+    '#value' => bts('Save changes', array(), null, 'boinc:form-save'),
530 530
     '#suffix' => '</li>'
531 531
   );
532 532
   $form['prefs']['form control tabs'] = array(
533
-    '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), drupal_get_path_alias("account/prefs/computing/edit")) . '</li>'
533
+    '#value' => '<li class="tab">' . l(bts('Cancel', array(), null, 'boinc:form-cancel'), drupal_get_path_alias("account/prefs/computing/edit")) . '</li>'
534 534
   );
535
-  if ($venue AND $venue != 'generic') {
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', array(), NULL, 'boinc:form-clear'), "account/prefs/computing/clear/{$venue}",
538
+      l(bts('Clear', array(), null, 'boinc:form-clear'), "account/prefs/computing/clear/{$venue}",
539 539
         array(
540 540
           'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/computing/combined')),
541 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), array(), NULL, 'boinc:account-preferences') . '\')'
543
+              array('@name' => $venue), array(), null, 'boinc:account-preferences') . '\')'
544 544
           )
545 545
         )
546 546
       ) . '</li>';
547 547
   }
548 548
   $form['prefs']['view control'] = array(
549
-    '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/computing/combined') . '</li>'
549
+    '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), null, 'boinc:account-preferences') . ')', 'account/prefs/computing/combined') . '</li>'
550 550
   );
551 551
   $form['prefs']['form control tabs suffix'] = array(
552 552
     '#value' => '</ul>'
@@ -567,33 +567,33 @@  discard block
 block discarded – undo
567 567
   // Verify all non-boolean user input values and notify form API of failures
568 568
   
569 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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), null, 'boinc:account-preferences-computing'));
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']}"), null, 'boinc:account-preferences-computing'));
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']}"), null, 'boinc:account-preferences-computing'));
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']}"), null, 'boinc:account-preferences-computing'));
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']}"), null, 'boinc:account-preferences-computing'));
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']}"), null, 'boinc:account-preferences-computing'));
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']}"), null, 'boinc:account-preferences-computing'));
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']}"), null, 'boinc:account-preferences-computing'));
578 578
 
579 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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), null, 'boinc:account-preferences-computing'));
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']}"), null, 'boinc:account-preferences-computing'));
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']}"), null, 'boinc:account-preferences-computing'));
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']}"), null, 'boinc:account-preferences-computing'));
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']}"), null, 'boinc:account-preferences-computing'));
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']}"), null, 'boinc:account-preferences-computing'));
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']}"), null, 'boinc:account-preferences-computing'));
587 587
 
588 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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-prefrences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), NULL, 'boinc:account-preferences-computing'));
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']}"), null, 'boinc:account-preferences-computing'));
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']}"), null, 'boinc:account-preferences-computing'));
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']}"), null, 'boinc:account-preferences-computing'));
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']}"), null, 'boinc:account-preferences-computing'));
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']}"), null, 'boinc:account-prefrences-computing'));
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']}"), null, 'boinc:account-preferences-computing'));
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']}"), null, 'boinc:account-preferences-computing'));
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']}"), null, 'boinc:account-preferences-computing'));
597 597
 }
598 598
 
599 599
 /**
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
     unset($prefs['@attributes']['preset']);
654 654
   }
655 655
   // Save the preset selection (or lack thereof)
656
-  if (!$preset OR $preset == 'custom') {
656
+  if (!$preset or $preset == 'custom') {
657 657
     $prefs['preset'] = 'custom';
658 658
   }
659 659
   else {
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
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 674
   }
675
-  elseif (!drupal_get_messages('status', FALSE)) {
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.
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
   ));
707 707
   db_set_active('default');
708 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;
709
+  $current_host->is_new = !$current_host->total_credit and !$current_host->task_count;
710 710
   // Get the list of all other hosts owned by this user for comparison
711 711
   db_set_active('boinc');
712 712
   $all_other_hosts = db_query("
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
     // First, disqualify if hosts were active at the same time
723 723
     if (!$current_host->is_new) {
724 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;
725
+      $other_host->is_new = !$other_host->total_credit and !$other_host->task_count;
726 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)) {
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
 /**
756 756
  * Perform the database updates to merge the old host into the new host
757 757
  */
758
-function boincwork_host_merge($old_host, $new_host, &$message = NULL) {
758
+function boincwork_host_merge($old_host, $new_host, &$message = null) {
759 759
   // Decay the average credit of the two hosts
760 760
   require_boinc('credit');
761 761
   $now = time();
@@ -783,10 +783,10 @@  discard block
 block discarded – undo
783 783
   );
784 784
   db_set_active('default');
785 785
   if (!$credit_updated) {
786
-    if ($message !== NULL) {
787
-      $message = bts('Could not update credit', array(), NULL, 'boinc:account-host-merge');
786
+    if ($message !== null) {
787
+      $message = bts('Could not update credit', array(), null, 'boinc:account-host-merge');
788 788
     }
789
-    return FALSE;
789
+    return false;
790 790
   }
791 791
   
792 792
   // Move results from the old host to the new host
@@ -799,10 +799,10 @@  discard block
 block discarded – undo
799 799
   );
800 800
   db_set_active('default');
801 801
   if (!$results_updated) {
802
-    if ($message !== NULL) {
803
-      $message = bts('Could not update results', array(), NULL, 'boinc:account-host-merge');
802
+    if ($message !== null) {
803
+      $message = bts('Could not update results', array(), null, 'boinc:account-host-merge');
804 804
     }
805
-    return FALSE;
805
+    return false;
806 806
   }
807 807
   
808 808
   // Retire the old host
@@ -819,13 +819,13 @@  discard block
 block discarded – undo
819 819
   );
820 820
   db_set_active('default');
821 821
   if (!$old_host_retired) {
822
-    if ($message !== NULL) {
823
-      $message = bts('Could not retire old computer', array(), NULL, 'boinc:account-host-merge');
822
+    if ($message !== null) {
823
+      $message = bts('Could not retire old computer', array(), null, 'boinc:account-host-merge');
824 824
     }
825
-    return FALSE;
825
+    return false;
826 826
   }
827 827
   
828
-  return TRUE;
828
+  return true;
829 829
 }
830 830
 
831 831
 /**
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
   $form['overview'] = array(
855 855
     '#value' => '<p>' . bts('Sometimes BOINC assigns separate identities to'
856 856
       . ' the same computer by mistake. You can correct this by merging old'
857
-      . ' identities with the newest one.', array(), NULL, 'boinc:account-host-merge') . '</p>'
857
+      . ' identities with the newest one.', array(), null, 'boinc:account-host-merge') . '</p>'
858 858
       . '<p>'
859 859
       . bts('Check the computers that are the same as @name'
860 860
       . ' (created on @date at @time with computer ID @id)',
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
           '@time' => date('H:i:s T', $current_host->create_time),
865 865
           '@id' => $current_host->id,
866 866
         ),
867
-        NULL, 'boinc:account-host-merge') . '</p>',
867
+        null, 'boinc:account-host-merge') . '</p>',
868 868
   );
869 869
   
870 870
   $options = array();
@@ -879,7 +879,7 @@  discard block
 block discarded – undo
879 879
   $form['merge'] = array(
880 880
     '#title' => '',
881 881
     '#type' => 'tableselect',
882
-    '#header' => array(bts('Name', array(), NULL, 'boinc:details:-1:name-of-the-host-or-task-or-workunit-etc-being-viewed-ignoreoverwrite'), bts('Created', array(), NULL, 'boinc:host-details'), bts('Computer ID', array(), NULL, 'boinc:host-list')),
882
+    '#header' => array(bts('Name', array(), null, 'boinc:details:-1:name-of-the-host-or-task-or-workunit-etc-being-viewed-ignoreoverwrite'), bts('Created', array(), null, 'boinc:host-details'), bts('Computer ID', array(), null, 'boinc:host-list')),
883 883
     '#options' => $options,
884 884
   );
885 885
   
@@ -894,11 +894,11 @@  discard block
 block discarded – undo
894 894
   $form['prefs']['submit'] = array(
895 895
     '#prefix' => '<li class="first tab">',
896 896
     '#type' => 'submit',
897
-    '#value' => bts('Merge', array(), NULL, 'boinc:form-merge'),
897
+    '#value' => bts('Merge', array(), null, 'boinc:form-merge'),
898 898
     '#suffix' => '</li>'
899 899
   );
900 900
   $form['prefs']['form control tabs'] = array(
901
-    '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "host/{$host_id}") . '</li>'
901
+    '#value' => '<li class="tab">' . l(bts('Cancel', array(), null, 'boinc:form-cancel'), "host/{$host_id}") . '</li>'
902 902
   );
903 903
   
904 904
   return $form;
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
   if ($merged) {
937 937
     // Generate a natural language list of IDs that were merged
938 938
     $oxford_comma = ',';
939
-    $conjunction = bts('and', array(), NULL, 'boinc:account-preference');
939
+    $conjunction = bts('and', array(), null, 'boinc:account-preference');
940 940
     $list = array_keys($merged);
941 941
     $last = array_pop($list);
942 942
     if ($list) {
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
           '@old_id' => $list,
956 956
           '@id' => $current_host_id
957 957
         ),
958
-        NULL, 'boinc:account-host-merge'));
958
+        null, 'boinc:account-host-merge'));
959 959
     }
960 960
     else {
961 961
       drupal_set_message(bts(
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
           '@old_ids' => $list,
965 965
           '@id' => $current_host_id
966 966
         ),
967
-        NULL, 'boinc:account-host-merge'));
967
+        null, 'boinc:account-host-merge'));
968 968
     }
969 969
   }
970 970
   
@@ -977,7 +977,7 @@  discard block
 block discarded – undo
977 977
             '@old_id' => $id,
978 978
             '@message' => $error,
979 979
           ),
980
-          NULL, 'boinc:account-host-merge'),
980
+          null, 'boinc:account-host-merge'),
981 981
         'warning'
982 982
       );
983 983
     }
@@ -998,7 +998,7 @@  discard block
 block discarded – undo
998 998
   global $user;
999 999
   $account = user_load($user->uid);
1000 1000
   
1001
-  $established = TRUE;
1001
+  $established = true;
1002 1002
   
1003 1003
   // Get availability of special BOINC preferences
1004 1004
   require_boinc(array('util'));
@@ -1009,20 +1009,20 @@  discard block
 block discarded – undo
1009 1009
   
1010 1010
   // Take note if this is not an established preference set on the account
1011 1011
   if (isset($prefs['@attributes']['cleared'])) {
1012
-    $established = FALSE;
1012
+    $established = false;
1013 1013
   }
1014 1014
   
1015
-  $venue_is_default = FALSE;
1015
+  $venue_is_default = false;
1016 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') {
1022
-    $venue_is_default = TRUE;
1021
+  elseif (!$venue or $venue == 'generic') {
1022
+    $venue_is_default = true;
1023 1023
   }
1024 1024
   else {
1025
-    $venue_is_default = FALSE;
1025
+    $venue_is_default = false;
1026 1026
   }
1027 1027
   
1028 1028
   // Define form defaults
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
   // Standard option sets
1052 1052
   $form['boolean_options'] = array(
1053 1053
     '#type' => 'value',
1054
-    '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes'))
1054
+    '#value' => array(1 => bts('yes', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes'))
1055 1055
   );
1056 1056
   
1057 1057
   // Identify preference sets that are established to distinguish what has been
@@ -1059,7 +1059,7 @@  discard block
 block discarded – undo
1059 1059
   $form['#established'] = $established;
1060 1060
   
1061 1061
   // Top level form options
1062
-  $form['#tree'] = TRUE;
1062
+  $form['#tree'] = true;
1063 1063
   
1064 1064
   // Hidden elements
1065 1065
   $form['venue'] = array(
@@ -1073,77 +1073,77 @@  discard block
 block discarded – undo
1073 1073
   
1074 1074
   // Common project preferences  
1075 1075
   $form['resource'] = array(
1076
-    '#title' => bts('Resource settings', array(), NULL, 'boinc:account-preferences-project'),
1076
+    '#title' => bts('Resource settings', array(), null, 'boinc:account-preferences-project'),
1077 1077
     '#type' => 'fieldset',
1078 1078
     '#description' => null,
1079
-    '#collapsible' => TRUE,
1080
-    '#collapsed' => FALSE
1079
+    '#collapsible' => true,
1080
+    '#collapsed' => false
1081 1081
   );
1082 1082
   $form['resource']['resource_share'] = array(
1083
-    '#title' => bts('Resource share', array(), NULL, 'boinc:account-preferences-project'),
1083
+    '#title' => bts('Resource share', array(), null, 'boinc:account-preferences-project'),
1084 1084
     '#type' => 'textfield',
1085 1085
     '#default_value' => $default['resource_share'],
1086 1086
     '#size' => 5,
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.", array(), NULL, 'boinc:account-preferences-project')
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.", array(), null, 'boinc:account-preferences-project')
1088 1088
   );
1089 1089
   if ($app_types->count > 1) {
1090 1090
     if ($app_types->cpu) {
1091 1091
       $form['resource']['no_cpu'] = array(
1092
-        '#title' => bts('Use CPU', array(), NULL, 'boinc:account-preferences-project'),
1092
+        '#title' => bts('Use CPU', array(), null, 'boinc:account-preferences-project'),
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
-        '#description' => bts('Request CPU-only tasks from this project.', array(), NULL, 'boinc:account-preferences-project')
1097
+        '#description' => bts('Request CPU-only tasks from this project.', array(), null, 'boinc:account-preferences-project')
1098 1098
       );
1099 1099
     }
1100 1100
     if ($app_types->cuda) {
1101 1101
       $form['resource']['no_cuda'] = array(
1102
-        '#title' => bts('Use NVIDIA GPU', array(), NULL, 'boinc:account-preferences-project'),
1102
+        '#title' => bts('Use NVIDIA GPU', array(), null, 'boinc:account-preferences-project'),
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
-        '#description' => bts('Request NVIDIA GPU tasks from this project.', array(), NULL, 'boinc:account-preferences-project')
1107
+        '#description' => bts('Request NVIDIA GPU tasks from this project.', array(), null, 'boinc:account-preferences-project')
1108 1108
       );
1109 1109
     }
1110 1110
     if ($app_types->ati) {
1111 1111
       $form['resource']['no_ati'] = array(
1112
-        '#title' => bts('Use ATI GPU', array(), NULL, 'boinc:account-preferences-project'),
1112
+        '#title' => bts('Use ATI GPU', array(), null, 'boinc:account-preferences-project'),
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
-        '#description' => bts('Request ATI GPU tasks from this project.', array(), NULL, 'boinc:account-preferences-project')
1117
+        '#description' => bts('Request ATI GPU tasks from this project.', array(), null, 'boinc:account-preferences-project')
1118 1118
       );
1119 1119
     }
1120 1120
     if ($app_types->intel_gpu) {
1121 1121
       $form['resource']['no_intel_gpu'] = array(
1122
-        '#title' => bts('Use INTEL GPU', array(), NULL, 'boinc:account-preferences-project'),
1122
+        '#title' => bts('Use INTEL GPU', array(), null, 'boinc:account-preferences-project'),
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
-        '#description' => bts('Request Intel GPU tasks from this project.', array(), NULL, 'boinc:account-preferences-project')
1127
+        '#description' => bts('Request Intel GPU tasks from this project.', array(), null, 'boinc:account-preferences-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', array(), NULL, 'boinc:account-preferences-project'),
1134
+      '#title' => bts('Beta settings', array(), null, 'boinc:account-preferences-project'),
1135 1135
       '#type' => 'fieldset',
1136 1136
       '#description' => null,
1137
-      '#collapsible' => TRUE,
1138
-      '#collapsed' => FALSE
1137
+      '#collapsible' => true,
1138
+      '#collapsed' => false
1139 1139
     );
1140 1140
     $form['beta']['allow_beta_work'] = array(
1141
-      '#title' => bts('Run test applications?', array(), NULL, 'boinc:account-preferences-project'),
1141
+      '#title' => bts('Run test applications?', array(), null, 'boinc:account-preferences-project'),
1142 1142
       '#type' => 'radios',
1143 1143
       '#options' => $form['boolean_options']['#value'],
1144 1144
       '#attributes' => array('class' => 'fancy'),
1145 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', array(), NULL, 'boinc:account-preferences-project')
1146
+      '#description' => bts('This helps us develop applications, but may cause jobs to fail on your computer', array(), null, 'boinc:account-preferences-project')
1147 1147
     );
1148 1148
   }
1149 1149
   
@@ -1152,14 +1152,14 @@  discard block
 block discarded – undo
1152 1152
   
1153 1153
   // Set whether to use this preference set by default for new computers
1154 1154
   $form['default_set'] = array(
1155
-    '#title' => bts('Default set', array(), NULL, 'boinc:account-preferences-project'),
1155
+    '#title' => bts('Default set', array(), null, 'boinc:account-preferences-project'),
1156 1156
     '#type' => 'fieldset',
1157 1157
     '#description' => null,
1158
-    '#collapsible' => TRUE,
1159
-    '#collapsed' => FALSE
1158
+    '#collapsible' => true,
1159
+    '#collapsed' => false
1160 1160
   );
1161 1161
   $form['default_set']['default_venue'] = array(
1162
-    '#title' => bts('Set used for new computers', array(), NULL, 'boinc:account-preferences-project'),
1162
+    '#title' => bts('Set used for new computers', array(), null, 'boinc:account-preferences-project'),
1163 1163
     '#type' => 'radios',
1164 1164
     '#options' => $form['boolean_options']['#value'],
1165 1165
     '#attributes' => array('class' => 'fancy'),
@@ -1178,27 +1178,27 @@  discard block
 block discarded – undo
1178 1178
   $form['prefs']['submit'] = array(
1179 1179
     '#prefix' => '<li class="first tab">',
1180 1180
     '#type' => 'submit',
1181
-    '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'),
1181
+    '#value' => bts('Save changes', array(), null, 'boinc:form-save'),
1182 1182
     '#suffix' => '</li>'
1183 1183
   );
1184 1184
   $form['prefs']['form control tabs'] = array(
1185
-    '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>'
1185
+    '#value' => '<li class="tab">' . l(bts('Cancel', array(), null, 'boinc:form-cancel'), $_GET['q']) . '</li>'
1186 1186
   );
1187
-  if ($venue AND $venue != 'generic') {
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', array(), NULL, 'boinc:form-clear'), "account/prefs/project/clear/{$venue}",
1190
+      l(bts('Clear', array(), null, 'boinc:form-clear'), "account/prefs/project/clear/{$venue}",
1191 1191
         array(
1192 1192
           'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/project/combined')),
1193 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), NULL, 'boinc:account-preferences') . '\')'
1195
+              array('@name' => $venue), null, 'boinc:account-preferences') . '\')'
1196 1196
           )
1197 1197
         )
1198 1198
       ) . '</li>';
1199 1199
   }
1200 1200
   $form['prefs']['view control'] = array(
1201
-      '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/project/combined') . '</li>'
1201
+      '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), null, 'boinc:account-preferences') . ')', 'account/prefs/project/combined') . '</li>'
1202 1202
   );
1203 1203
   $form['prefs']['form control tabs suffix'] = array(
1204 1204
     '#value' => '</ul>'
@@ -1218,7 +1218,7 @@  discard block
 block discarded – undo
1218 1218
   $ordered_array = array();
1219 1219
   $unordered_array = array();
1220 1220
   foreach ($xml['project_specific_preferences'] as $type => $element) {
1221
-    if (is_array($element) AND is_numeric(key($element))) {
1221
+    if (is_array($element) and is_numeric(key($element))) {
1222 1222
       foreach ($element as $ordered_element) {
1223 1223
         if (isset($ordered_element['@position'])) {
1224 1224
           $ordered_array[$ordered_element['@position']] = array($type => $ordered_element);
@@ -1270,7 +1270,7 @@  discard block
 block discarded – undo
1270 1270
   // Check for app validation
1271 1271
   if (isset($validation_rules['apps'])) {
1272 1272
     if (isset($validation_rules['apps']['minimum selected'])
1273
-        AND $validation_rules['apps']['minimum selected'] > 0) {
1273
+        and $validation_rules['apps']['minimum selected'] > 0) {
1274 1274
       $apps_selected = 0;
1275 1275
       foreach ($validation_rules['apps']['list'] as $app) {
1276 1276
         if ($form_state['values']['applications'][$app]) $apps_selected++;
@@ -1278,14 +1278,14 @@  discard block
 block discarded – undo
1278 1278
       if ($apps_selected < $validation_rules['apps']['minimum selected']) {
1279 1279
         form_set_error(
1280 1280
           'applications',
1281
-          bts('At least one application must be selected', array(), NULL, 'boinc:account-preferences-project')
1281
+          bts('At least one application must be selected', array(), null, 'boinc:account-preferences-project')
1282 1282
         );
1283 1283
       }
1284 1284
       if ($apps_selected == count($validation_rules['apps']['list'])) {
1285 1285
         foreach ($validation_rules['apps']['list'] as $app) {
1286 1286
           unset($form_state['values']['applications'][$app]);
1287 1287
         }
1288
-        $form_state['storage']['all apps selected'] = TRUE;
1288
+        $form_state['storage']['all apps selected'] = true;
1289 1289
       }
1290 1290
     }
1291 1291
   }
@@ -1318,7 +1318,7 @@  discard block
 block discarded – undo
1318 1318
   }
1319 1319
   
1320 1320
   // Beta preferences
1321
-  if (variable_get('boinc_prefs_options_beta', FALSE)) {
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
   
@@ -1356,7 +1356,7 @@  discard block
 block discarded – undo
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 1358
   }
1359
-  elseif (!drupal_get_messages('status', FALSE)) {
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.
@@ -1391,31 +1391,31 @@  discard block
 block discarded – undo
1391 1391
   // Standard option sets
1392 1392
   $form['boolean_options'] = array(
1393 1393
     '#type' => 'value',
1394
-    '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes'))
1394
+    '#value' => array(1 => bts('yes', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes'))
1395 1395
   );
1396 1396
   
1397 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
-    '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
-    'comments_order' => (isset($account->sort) AND $account->sort) ? $account->sort : variable_get('comment_default_order_forum', COMMENT_ORDER_OLDEST_FIRST),
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
+    '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 1404
   // General options
1405 1405
   $form['general'] = array(
1406 1406
     '#type' => 'fieldset',
1407
-    '#title' => bts('General settings', array(), NULL, 'boinc:account-preferences-community'),
1407
+    '#title' => bts('General settings', array(), null, 'boinc:account-preferences-community'),
1408 1408
     '#weight' => 0,
1409
-    '#collapsible' => TRUE,
1410
-    '#collapsed' => FALSE
1409
+    '#collapsible' => true,
1410
+    '#collapsed' => false
1411 1411
   );
1412 1412
   // Add the BOINC user name (non-unique, user editable)
1413 1413
   $form['general']['boincuser_name'] = array(
1414 1414
     '#type' => 'textfield',
1415
-    '#title' => bts('Name', array(), NULL, 'boinc:user-or-team-name'),
1415
+    '#title' => bts('Name', array(), null, 'boinc:user-or-team-name'),
1416 1416
     '#default_value' => $account->boincuser_name,
1417 1417
     '#maxlength' => USERNAME_MAX_LENGTH,
1418
-    '#required' => TRUE,
1418
+    '#required' => true,
1419 1419
     '#description' => '',
1420 1420
     '#size' => 40
1421 1421
   );
@@ -1424,8 +1424,8 @@  discard block
 block discarded – undo
1424 1424
     $zones = _system_zonelist();
1425 1425
     $form['general']['timezone'] = array(
1426 1426
       '#type' => 'select',
1427
-      '#title' => bts('Time zone', array(), NULL, 'boinc:account-preferences-community'),
1428
-      '#default_value' => ($account->timezone !== NULL) ? $account->timezone : variable_get('date_default_timezone', 0),
1427
+      '#title' => bts('Time zone', array(), null, 'boinc:account-preferences-community'),
1428
+      '#default_value' => ($account->timezone !== null) ? $account->timezone : variable_get('date_default_timezone', 0),
1429 1429
       '#options' => $zones,
1430 1430
       '#description' => '',
1431 1431
     );
@@ -1434,10 +1434,10 @@  discard block
 block discarded – undo
1434 1434
   // Notification options
1435 1435
   $form['notifications'] = array(
1436 1436
     '#type' => 'fieldset',
1437
-    '#title' => bts('Notification settings', array(), NULL, 'boinc:account-preferences-community'),
1437
+    '#title' => bts('Notification settings', array(), null, 'boinc:account-preferences-community'),
1438 1438
     '#weight' => 5,
1439
-    '#collapsible' => TRUE,
1440
-    '#collapsed' => FALSE
1439
+    '#collapsible' => true,
1440
+    '#collapsed' => false
1441 1441
   );
1442 1442
   // Pull in private message notification handling and tweak the form
1443 1443
   $pm_notify = pm_email_notify_user('form', $edit, $account, 'account');
@@ -1445,7 +1445,7 @@  discard block
 block discarded – undo
1445 1445
     $pm_notify['enable_pm_mail']['pm_send_notifications'],
1446 1446
     array(
1447 1447
       '#type' => 'radios',
1448
-      '#title' => bts('Receive email notification for private messages?', array(), NULL, 'boinc:account-preferences-community'),
1448
+      '#title' => bts('Receive email notification for private messages?', array(), null, 'boinc:account-preferences-community'),
1449 1449
       '#description' => ' ',
1450 1450
       '#options' => $form['boolean_options']['#value'],
1451 1451
       '#attributes' => array('class' => 'fancy')
@@ -1453,9 +1453,9 @@  discard block
 block discarded – undo
1453 1453
   );
1454 1454
   $form['notifications']['friend_notification'] = array(
1455 1455
     '#type' => 'radios',
1456
-    '#title' => bts('Receive email notification for friend requests?', array(), NULL, 'boinc:account-preferences-community'),
1456
+    '#title' => bts('Receive email notification for friend requests?', array(), null, 'boinc:account-preferences-community'),
1457 1457
     '#description' => ' ',
1458
-    '#options' => array(0 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), -1 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')),
1458
+    '#options' => array(0 => bts('yes', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), -1 => bts('no', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')),
1459 1459
     '#attributes' => array('class' => 'fancy'),
1460 1460
     '#default_value' => $default['friend_notification']
1461 1461
   );
@@ -1471,10 +1471,10 @@  discard block
 block discarded – undo
1471 1471
     }
1472 1472
     $form['locale'] = array(
1473 1473
       '#type' => 'fieldset',
1474
-      '#title' => bts('Language settings', array(), NULL, 'boinc:account-preferences-community'),
1474
+      '#title' => bts('Language settings', array(), null, 'boinc:account-preferences-community'),
1475 1475
       '#weight' => 10,
1476
-      '#collapsible' => TRUE,
1477
-      '#collapsed' => FALSE,
1476
+      '#collapsible' => true,
1477
+      '#collapsed' => false,
1478 1478
     );
1479 1479
 
1480 1480
     // Get language negotiation settings.
@@ -1482,30 +1482,30 @@  discard block
 block discarded – undo
1482 1482
     $user_preferred_language = user_preferred_language($account);
1483 1483
     $form['locale']['language'] = array(
1484 1484
       '#type' => 'select',
1485
-      '#title' => bts('Language', array(), NULL, 'boinc:account-preferences-community'),
1485
+      '#title' => bts('Language', array(), null, 'boinc:account-preferences-community'),
1486 1486
       '#default_value' => check_plain($user_preferred_language->language),
1487 1487
       '#options' => $names,
1488
-      '#description' => ($mode == LANGUAGE_NEGOTIATION_PATH) ? bts("This account's default language for e-mails and preferred language for site presentation.", array(), NULL, 'boinc:account-preferences-community') : bts("This account's default language for e-mails.", array(), NULL, 'boinc:account-preferences-community'),
1488
+      '#description' => ($mode == LANGUAGE_NEGOTIATION_PATH) ? bts("This account's default language for e-mails and preferred language for site presentation.", array(), null, 'boinc:account-preferences-community') : bts("This account's default language for e-mails.", array(), null, 'boinc:account-preferences-community'),
1489 1489
     );
1490 1490
   }
1491 1491
   
1492 1492
   // Avatar options
1493 1493
   $form['gravatar'] = array(
1494 1494
     '#type' => 'item',
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), NULL, 'boinc:account-preferences-community'),
1496
-    '#description' => bts('Your Gravatar will not be shown if you upload a user picture.', array(), NULL, 'boinc:account-preferences-community'),
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), null, 'boinc:account-preferences-community'),
1496
+    '#description' => bts('Your Gravatar will not be shown if you upload a user picture.', array(), null, 'boinc:account-preferences-community'),
1497 1497
   );
1498 1498
   if (user_access('disable own gravatar', $account)) {
1499 1499
     $form['gravatar'] = array(
1500 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), NULL, 'boinc:account-preferences-community'),
1502
-      '#description' => bts('Gravatar will not be shown if an avatar is uploaded.', array(), NULL, 'boinc:account-preferences-community'),
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), null, 'boinc:account-preferences-community'),
1502
+      '#description' => bts('Gravatar will not be shown if an avatar is uploaded.', array(), null, 'boinc:account-preferences-community'),
1503 1503
       '#default_value' => isset($account->gravatar) ? $account->gravatar : 0,
1504 1504
       '#disabled' => !empty($account->picture),
1505 1505
     );
1506 1506
   }
1507 1507
   $form['gravatar']['#weight'] = 15;
1508
-  $form['gravatar']['#prefix'] = '<fieldset class="collapsible"><legend><a href="#">' . bts('Avatar settings', array(), NULL, 'boinc:account-preferences-community') . '</a></legend>';
1508
+  $form['gravatar']['#prefix'] = '<fieldset class="collapsible"><legend><a href="#">' . bts('Avatar settings', array(), null, 'boinc:account-preferences-community') . '</a></legend>';
1509 1509
   // Upload an avatar (pulled from profile_node_form):
1510 1510
   if (!empty($profile_form['field_image'])) {
1511 1511
     $form['field_image'] = $profile_form['field_image'];
@@ -1514,46 +1514,46 @@  discard block
 block discarded – undo
1514 1514
     $form['field_image'] = array(
1515 1515
       '#value' => '<div class="form-item">'
1516 1516
         . '<label class="placeholder">'
1517
-        . bts('This is not available until your profile is set up.', array(), NULL, 'boinc:account-preferences-community')
1517
+        . bts('This is not available until your profile is set up.', array(), null, 'boinc:account-preferences-community')
1518 1518
         . '</label>'
1519
-        . l(bts('Create a profile', array(), NULL, 'boinc:account-preferences-community'), 'account/profile/edit', array('attributes' => array('class' => 'form-link')))
1519
+        . l(bts('Create a profile', array(), null, 'boinc:account-preferences-community'), 'account/profile/edit', array('attributes' => array('class' => 'form-link')))
1520 1520
         . '</div>',
1521 1521
     );
1522 1522
   }
1523
-  $form['field_image'][0]['#title'] = bts('Upload an avatar', array(), NULL, 'boinc:account-preferences-community');
1523
+  $form['field_image'][0]['#title'] = bts('Upload an avatar', array(), null, 'boinc:account-preferences-community');
1524 1524
   $form['field_image']['#weight'] = 20;
1525 1525
   $form['field_image']['#suffix'] = '</fieldset>';
1526 1526
   
1527 1527
   // Forum options
1528 1528
   $form['forums'] = array(
1529 1529
     '#type' => 'fieldset',
1530
-    '#title' => bts('Forum settings', array(), NULL, 'boinc:account-preferences-community'),
1530
+    '#title' => bts('Forum settings', array(), null, 'boinc:account-preferences-community'),
1531 1531
     '#weight' => 25,
1532
-    '#collapsible' => TRUE,
1533
-    '#collapsed' => FALSE
1532
+    '#collapsible' => true,
1533
+    '#collapsed' => false
1534 1534
   );
1535 1535
   $form['forums']['comments_per_page'] = array(
1536 1536
     '#type' => 'select',
1537
-    '#title' => bts('In discussion topics, show at most @comments_per_page', array('@comments_per_page' => ''), NULL, 'boinc:account-preferences-community'),
1537
+    '#title' => bts('In discussion topics, show at most @comments_per_page', array('@comments_per_page' => ''), null, 'boinc:account-preferences-community'),
1538 1538
     '#options' => array(10 => 10, 20 => 20, 30 => 30, 50 => 50, 100 => 100),
1539 1539
     '#default_value' => $default['comments_per_page']
1540 1540
   );
1541 1541
   // Can't have a typical Drupal form suffix on a select box?
1542 1542
   $form['forums']['comments_per_page_suffix'] = array(
1543
-    '#value' => '<span>' . bts('comments per page', array(), NULL, 'boinc:account-preferences-community') . '</span>'
1543
+    '#value' => '<span>' . bts('comments per page', array(), null, 'boinc:account-preferences-community') . '</span>'
1544 1544
   );
1545 1545
   $form['forums']['comments_order'] = array(
1546 1546
     '#type' => 'select',
1547
-    '#title' => bts('Sort comments in discussions', array(), NULL, 'boinc:account-preferences-community'),
1548
-    '#options' => array(1 => bts('Newest post first', array(), NULL, 'boinc:account-preferences-community'), 2 => bts('Oldest post first', array(), NULL, 'boinc:account-preferences-community')),
1547
+    '#title' => bts('Sort comments in discussions', array(), null, 'boinc:account-preferences-community'),
1548
+    '#options' => array(1 => bts('Newest post first', array(), null, 'boinc:account-preferences-community'), 2 => bts('Oldest post first', array(), null, 'boinc:account-preferences-community')),
1549 1549
     '#default_value' => $default['comments_order']
1550 1550
   );
1551 1551
   // Signature (pulled from user_edit_form):
1552 1552
   if (variable_get('user_signatures', 0) && module_exists('comment')) {
1553 1553
     $form['forums']['signature'] = array(
1554 1554
       '#type' => 'textarea',
1555
-      '#title' => bts('Signature', array(), NULL, 'boinc:account-preferences-community'),
1556
-      '#description' => bts('Your signature will be publicly displayed at the end of your comments.', array(), NULL, 'boinc:account-preferences-community'),
1555
+      '#title' => bts('Signature', array(), null, 'boinc:account-preferences-community'),
1556
+      '#description' => bts('Your signature will be publicly displayed at the end of your comments.', array(), null, 'boinc:account-preferences-community'),
1557 1557
       '#default_value' => $account->signature
1558 1558
       );
1559 1559
     // Prevent a "validation error" message when the user attempts to save with a default value they
@@ -1562,11 +1562,11 @@  discard block
 block discarded – undo
1562 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 1563
       $edit['signature_format'] = FILTER_FORMAT_DEFAULT;
1564 1564
     }
1565
-    $form['forums']['signature_format'] = filter_form($account->signature_format, NULL, array('signature_format'));
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 1568
       '#type' => 'radios',
1569
-      '#title' => bts('Hide signatures in forums', array(), NULL, 'boinc:account-preferences-community'),
1569
+      '#title' => bts('Hide signatures in forums', array(), null, 'boinc:account-preferences-community'),
1570 1570
       '#description' => ' ',
1571 1571
       '#options' => $form['boolean_options']['#value'],
1572 1572
       '#attributes' => array('class' => 'fancy'),
@@ -1579,7 +1579,7 @@  discard block
 block discarded – undo
1579 1579
     $form['forums']['ignored_users'] = array(
1580 1580
       '#value' => '<div class="form-item">'
1581 1581
         . '<label>'
1582
-	. bts('Ignore Users in forums:', array(), NULL, 'boinc:account-preferences-community')
1582
+	. bts('Ignore Users in forums:', array(), null, 'boinc:account-preferences-community')
1583 1583
 	. '</label>'
1584 1584
         . bts('<a href="@ignore-user-list">View/Edit</a> your ignored users list.',
1585 1585
 	    array(
@@ -1588,7 +1588,7 @@  discard block
 block discarded – undo
1588 1588
             'attributes' => array('class' => 'form-link')
1589 1589
           )
1590 1590
 	    ),
1591
-        NULL, 'boinc:account-preferences-community')
1591
+        null, 'boinc:account-preferences-community')
1592 1592
 	. '</div>',
1593 1593
     );
1594 1594
   }//endif module_exists('ignore_user')
@@ -1607,12 +1607,12 @@  discard block
 block discarded – undo
1607 1607
   $form['submit'] = array(
1608 1608
     '#prefix' => '<li class="first tab">',
1609 1609
     '#type' => 'submit',
1610
-    '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'),
1610
+    '#value' => bts('Save changes', array(), null, 'boinc:form-save'),
1611 1611
     '#suffix' => '</li>',
1612 1612
     '#weight' => 1002,
1613 1613
   );
1614 1614
   $form['form control tabs'] = array(
1615
-    '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>',
1615
+    '#value' => '<li class="tab">' . l(bts('Cancel', array(), null, 'boinc:form-cancel'), $_GET['q']) . '</li>',
1616 1616
     '#weight' => 1003,
1617 1617
   );
1618 1618
   $form['form control tabs suffix'] = array(
@@ -1649,7 +1649,7 @@  discard block
 block discarded – undo
1649 1649
   $profile_node->field_image = $edit['field_image'];
1650 1650
   node_save($profile_node);
1651 1651
   // Flush this from the node cache or changes won't show up immediately!
1652
-  $profile_node = node_load($profile_node->nid, NULL, TRUE);
1652
+  $profile_node = node_load($profile_node->nid, null, true);
1653 1653
   
1654 1654
   // All other settings
1655 1655
   $settings = array(
@@ -1677,7 +1677,7 @@  discard block
 block discarded – undo
1677 1677
   }
1678 1678
   user_save($user, $settings);
1679 1679
   
1680
-  drupal_set_message(bts('Your community preferences have been updated.', array(), NULL, 'boinc:account-preferences-community'));
1680
+  drupal_set_message(bts('Your community preferences have been updated.', array(), null, 'boinc:account-preferences-community'));
1681 1681
   
1682 1682
   // Form will not redirect if storage is set; not good if language changes
1683 1683
   unset($form_state['storage']);
@@ -1709,25 +1709,25 @@  discard block
 block discarded – undo
1709 1709
   // Standard option sets
1710 1710
   $form['boolean_options'] = array(
1711 1711
     '#type' => 'value',
1712
-    '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes'))
1712
+    '#value' => array(1 => bts('yes', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes'))
1713 1713
   );
1714 1714
   
1715 1715
   $form['privacy'] = array(
1716
-    '#title' => bts('Privacy settings', array(), NULL, 'boinc:account-preferences-privacy'),
1716
+    '#title' => bts('Privacy settings', array(), null, 'boinc:account-preferences-privacy'),
1717 1717
     '#type' => 'fieldset',
1718 1718
     '#description' => null,
1719
-    '#collapsible' => TRUE,
1720
-    '#collapsed' => FALSE
1719
+    '#collapsible' => true,
1720
+    '#collapsed' => false
1721 1721
   );
1722 1722
   $form['privacy']['send_email'] = array(
1723
-    '#title' => bts('Is it OK for @project and your team (if any) to email you?', array('@project' => variable_get('site_name', 'Drupal-BOINC')), NULL, 'boinc:account-preferences-privacy'),
1723
+    '#title' => bts('Is it OK for @project and your team (if any) to email you?', array('@project' => variable_get('site_name', 'Drupal-BOINC')), null, 'boinc:account-preferences-privacy'),
1724 1724
     '#type' => 'radios',
1725 1725
     '#options' => $form['boolean_options']['#value'],
1726 1726
     '#attributes' => array('class' => 'fancy'),
1727 1727
     '#default_value' => $default['privacy']['send_email']
1728 1728
   );
1729 1729
   $form['privacy']['show_hosts'] = array(
1730
-    '#title' => bts('Should @project show your computers on its web site?', array('@project' => variable_get('site_name', 'Drupal-BOINC')), NULL, 'boinc:account-preferences-privacy'),
1730
+    '#title' => bts('Should @project show your computers on its web site?', array('@project' => variable_get('site_name', 'Drupal-BOINC')), null, 'boinc:account-preferences-privacy'),
1731 1731
     '#type' => 'radios',
1732 1732
     '#options' => $form['boolean_options']['#value'],
1733 1733
     '#attributes' => array('class' => 'fancy'),
@@ -1745,11 +1745,11 @@  discard block
 block discarded – undo
1745 1745
   $form['prefs']['submit'] = array(
1746 1746
     '#prefix' => '<li class="first tab">',
1747 1747
     '#type' => 'submit',
1748
-    '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'),
1748
+    '#value' => bts('Save changes', array(), null, 'boinc:form-save'),
1749 1749
     '#suffix' => '</li>'
1750 1750
   );
1751 1751
   $form['prefs']['form control tabs'] = array(
1752
-    '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>'
1752
+    '#value' => '<li class="tab">' . l(bts('Cancel', array(), null, 'boinc:form-cancel'), $_GET['q']) . '</li>'
1753 1753
   );
1754 1754
   $form['prefs']['form control tabs suffix'] = array(
1755 1755
     '#value' => '</ul>'
@@ -1814,7 +1814,7 @@  discard block
 block discarded – undo
1814 1814
   // only non-js users/browsers will see the Apply Filter button.
1815 1815
   $form['submit'] = array(
1816 1816
     '#type' => 'submit',
1817
-    '#value' => bts('Apply Filter', array(), NULL, 'boinc:form-save'),
1817
+    '#value' => bts('Apply Filter', array(), null, 'boinc:form-save'),
1818 1818
     '#attributes' => array('class' => 'js-hide',),
1819 1819
   );
1820 1820
 
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boincwork/boincwork.module 3 patches
Indentation   +334 added lines, -334 removed lines patch added patch discarded remove patch
@@ -2,9 +2,9 @@  discard block
 block discarded – undo
2 2
 // $Id$
3 3
 
4 4
 /**
5
-  * @file
6
-  * Enable BOINC features related to processing work and credit.
7
-  */
5
+ * @file
6
+ * Enable BOINC features related to processing work and credit.
7
+ */
8 8
 
9 9
 
10 10
 /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
@@ -20,52 +20,52 @@  discard block
 block discarded – undo
20 20
  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  */
21 21
 
22 22
 /**
23
-  * Implementation of hook_menu().
24
-  */
23
+ * Implementation of hook_menu().
24
+ */
25 25
 function boincwork_menu() {
26
-  require_boinc('util');
27
-  $items['account/prefs'] = array(
26
+    require_boinc('util');
27
+    $items['account/prefs'] = array(
28 28
     'title' => 'Computing',
29 29
     'description' => '',
30 30
     'page callback' => 'generalprefs_page', 
31 31
     'access callback' => 'user_is_logged_in',
32 32
     'type' => MENU_NORMAL_ITEM
33
-  );
34
-  $items['account/prefs/computing'] = array(
33
+    );
34
+    $items['account/prefs/computing'] = array(
35 35
     'title' => 'Computing',
36 36
     'page callback' => 'generalprefs_page',
37 37
     'access callback' => 'user_is_logged_in',
38 38
     'type' => MENU_DEFAULT_LOCAL_TASK,
39 39
     'weight' => 0
40
-  );
41
-  $items['account/prefs/project'] = array(
40
+    );
41
+    $items['account/prefs/project'] = array(
42 42
     'title' => 'Project',
43 43
     'page callback' => 'projectprefs_page',
44 44
     'access callback' => 'user_is_logged_in',
45 45
     'type' => MENU_LOCAL_TASK,
46 46
     'weight' => 5
47
-  );
48
-  $items['account/prefs/community'] = array(
47
+    );
48
+    $items['account/prefs/community'] = array(
49 49
     'title' => 'Community',
50 50
     'page callback' => 'communityprefs_page',
51 51
     'access callback' => 'user_is_logged_in',
52 52
     'type' => MENU_LOCAL_TASK,
53 53
     'weight' => 10
54
-  );
55
-  $items['account/prefs/privacy'] = array(
54
+    );
55
+    $items['account/prefs/privacy'] = array(
56 56
     'title' => 'Privacy',
57 57
     'page callback' => 'privacyprefs_page',
58 58
     'access callback' => 'user_is_logged_in',
59 59
     'type' => MENU_LOCAL_TASK,
60 60
     'weight' => 15
61
-  );
62
-  $items['account/certs'] = array(
61
+    );
62
+    $items['account/certs'] = array(
63 63
     'title' =>'Account certificate',
64 64
     'page callback' => 'boincwork_certificates',
65 65
     'access arguments' => array('access content'),
66 66
     'type' => MENU_CALLBACK
67
-  );
68
-  $items['admin/boinc/prefs/general'] = array(
67
+    );
68
+    $items['admin/boinc/prefs/general'] = array(
69 69
     'title' => 'Preferences: General',
70 70
     'description' => 'Set options for BOINC preference set pages',
71 71
     'page callback' => 'drupal_get_form',
@@ -73,16 +73,16 @@  discard block
 block discarded – undo
73 73
     'access arguments' => array('administer site configuration'),
74 74
     'type' => MENU_NORMAL_ITEM,
75 75
     'file' => 'boincwork.admin.inc'
76
-  );
77
-  $items['admin/boinc/prefs/presets'] = array(
76
+    );
77
+    $items['admin/boinc/prefs/presets'] = array(
78 78
     'title' => 'Preferences: Presets',
79 79
     'description' => 'Set values for BOINC preference set presets.',
80 80
     'page callback' => 'boincwork_admin_prefs_presets_page',
81 81
     'access arguments' => array('administer site configuration'),
82 82
     'type' => MENU_NORMAL_ITEM,
83 83
     'file' => 'boincwork.admin.inc'
84
-  );
85
-  $items['admin/boinc/prefs/upload'] = array(
84
+    );
85
+    $items['admin/boinc/prefs/upload'] = array(
86 86
     'title' => 'Preferences: Project-specific XML upload',
87 87
     'description' => 'Upload XML configuration for project specific preferences.',
88 88
     'page callback' => 'drupal_get_form',
@@ -90,143 +90,143 @@  discard block
 block discarded – undo
90 90
     'access arguments' => array('administer site configuration'),
91 91
     'type' => MENU_NORMAL_ITEM,
92 92
     'file' => 'boincwork.admin.inc'
93
-  );
94
-  $items['host/%/delete'] = array(
93
+    );
94
+    $items['host/%/delete'] = array(
95 95
     'title' => 'Delete host',
96 96
     'page callback' => 'boincwork_host_delete',
97 97
     'page arguments' => array(1),
98 98
     'access callback' => 'user_is_logged_in',
99 99
     'type' => MENU_CALLBACK,
100
-  );
101
-  $items['host/%/log'] = array(
100
+    );
101
+    $items['host/%/log'] = array(
102 102
     'title' => 'Host log',
103 103
     'page callback' => 'boincwork_host_log',
104 104
     'page arguments' => array(1),
105 105
     'access callback' => 'user_is_logged_in',
106 106
     'type' => MENU_CALLBACK,
107
-  );
108
-  $items['host/%/merge'] = array(
107
+    );
108
+    $items['host/%/merge'] = array(
109 109
     'title' => 'Merge computer',
110 110
     'page callback' => 'drupal_get_form',
111 111
     'page arguments' => array('boincwork_host_merge_form', 1),
112 112
     'access callback' => 'user_is_logged_in',
113 113
     'type' => MENU_CALLBACK,
114
-  );
115
-  $items['host/%/set-venue/%'] = array(
114
+    );
115
+    $items['host/%/set-venue/%'] = array(
116 116
     'title' => 'Set host venue',
117 117
     'page callback' => 'boincwork_host_set_venue',
118 118
     'page arguments' => array(1,3),
119 119
     'access callback' => 'user_is_logged_in',
120 120
     'type' => MENU_CALLBACK,
121
-  );
122
-  $items['user/%/mobile'] = array(
121
+    );
122
+    $items['user/%/mobile'] = array(
123 123
     'title' => 'Mobile stats',
124 124
     'page callback' => 'boincwork_mobile_stats',
125 125
     'page arguments' => array(1),
126 126
     'access callback' => 'user_is_logged_in',
127 127
     'type' => MENU_CALLBACK
128
-  );
129
-  $items['server_status.php'] = array(
128
+    );
129
+    $items['server_status.php'] = array(
130 130
     'title' => 'Server status',
131 131
     'page callback' => 'boincwork_server_status',
132 132
     'access arguments' => array('access content'),
133 133
     'type' => MENU_CALLBACK
134
-  );
135
-  $items['job_file.php'] = array(
134
+    );
135
+    $items['job_file.php'] = array(
136 136
     'title' => 'Job file input',
137 137
     'page callback' => 'boincwork_job_file',
138 138
     'access arguments' => array('access content'),
139 139
     'type' => MENU_CALLBACK
140
-  );
141
-  $items['get_output.php'] = array(
140
+    );
141
+    $items['get_output.php'] = array(
142 142
     'title' => 'Get output file',
143 143
     'page callback' => 'boincwork_get_output',
144 144
     'access arguments' => array('access content'),
145 145
     'type' => MENU_CALLBACK
146
-  );
147
-  $items['get_project_config.php'] = array(
146
+    );
147
+    $items['get_project_config.php'] = array(
148 148
     'title' => 'Project config',
149 149
     'page callback' => 'boincwork_get_project_config',
150 150
     'access arguments' => array('access content'),
151 151
     'type' => MENU_CALLBACK
152
-  );
153
-  $items['submit_rpc_handler.php'] = array(
152
+    );
153
+    $items['submit_rpc_handler.php'] = array(
154 154
     'title' => 'Remote job submission',
155 155
     'page callback' => 'boincwork_submit_rpc_handler',
156 156
     'access arguments' => array('access content'),
157 157
     'type' => MENU_CALLBACK
158
-  );
159
-  $items['userw.php'] = array(
158
+    );
159
+    $items['userw.php'] = array(
160 160
     'title' => 'User WAP',
161 161
     'page callback' => 'boincwork_user_wap',
162 162
     'access arguments' => array('access content'),
163 163
     'type' => MENU_CALLBACK
164
-  );
165
-  // @todo - change URL of routes
166
-  $items['account/tasks/%/%'] = array(
164
+    );
165
+    // @todo - change URL of routes
166
+    $items['account/tasks/%/%'] = array(
167 167
     'title' => 'Account Tasks Table',
168 168
     'description' => '',
169 169
     'page callback' => 'boincwork_account_task_table',
170 170
     'page arguments' => array(2,3),
171 171
     'access arguments' => array('access content'),
172 172
     'type' => MENU_CALLBACK,
173
-  );
174
-  $items['host/%/tasks/%/%'] = array(
173
+    );
174
+    $items['host/%/tasks/%/%'] = array(
175 175
     'title' => 'Host Tasks Table',
176 176
     'description' => '',
177 177
     'page callback' => 'boincwork_host_task_table',
178 178
     'page arguments' => array(1,3,4),
179 179
     'access arguments' => array('access content'),
180 180
     'type' => MENU_CALLBACK,
181
-  );
182
-  // Workunit task table disabled
183
-  //$items['workunit/%/tasks/%/%'] = array(
184
-  //  'title' => 'Workunit Tasks Table',
185
-  //  'description' => '',
186
-  //  'page callback' => 'boincwork_workunit_task_table',
187
-  //  'page arguments' => array(1,3,4),
188
-  //  'access arguments' => array('access content'),
189
-  //  'type' => MENU_CALLBACK,
190
-  //);
191
-  return $items;
181
+    );
182
+    // Workunit task table disabled
183
+    //$items['workunit/%/tasks/%/%'] = array(
184
+    //  'title' => 'Workunit Tasks Table',
185
+    //  'description' => '',
186
+    //  'page callback' => 'boincwork_workunit_task_table',
187
+    //  'page arguments' => array(1,3,4),
188
+    //  'access arguments' => array('access content'),
189
+    //  'type' => MENU_CALLBACK,
190
+    //);
191
+    return $items;
192 192
 }
193 193
 
194 194
 /**
195 195
 * Implementation of hook_views_api().
196 196
 */
197 197
 function boincwork_views_api() {
198
-  return array(
198
+    return array(
199 199
     'api' => 2.0,
200 200
     'path' => drupal_get_path('module', 'boincwork')
201
-  );
201
+    );
202 202
 }
203 203
 
204 204
 /**
205 205
  * Implementation of hook_locale().
206 206
  */
207 207
 function boincwork_locale($op = 'groups', $group = NULL) {
208
-  switch ($op) {
208
+    switch ($op) {
209 209
     case 'groups':
210 210
       return array('project' => bts('Project'));
211 211
     case 'info':
212 212
       $info['project']['refresh callback'] = 'boincwork_locale_refresh';
213
-      $info['project']['format'] = FALSE;
214
-      return $info;
215
-  }
213
+        $info['project']['format'] = FALSE;
214
+        return $info;
215
+    }
216 216
 }
217 217
 
218 218
 /**
219 219
  * Refresh strings.
220 220
  */
221 221
 function boincwork_locale_refresh() {
222
-  // Mimic process of adding project specific prefs to the project preferences
223
-  // form -- this parses the prefs XML and calls i18nstrings_update()
224
-  $form = array();
225
-  $prefs = array(
222
+    // Mimic process of adding project specific prefs to the project preferences
223
+    // form -- this parses the prefs XML and calls i18nstrings_update()
224
+    $form = array();
225
+    $prefs = array(
226 226
     'project_specific' => array(),
227
-  );
228
-  boincwork_add_project_specific_prefs($form, $prefs);
229
-  return TRUE; // Meaning it completed with no issues
227
+    );
228
+    boincwork_add_project_specific_prefs($form, $prefs);
229
+    return TRUE; // Meaning it completed with no issues
230 230
 }
231 231
 
232 232
 
@@ -235,41 +235,41 @@  discard block
 block discarded – undo
235 235
  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  */
236 236
  
237 237
 /**
238
-  * General preferences menu callback.
239
-  * Called when user goes to edit preferences page
240
-  */
238
+ * General preferences menu callback.
239
+ * Called when user goes to edit preferences page
240
+ */
241 241
 function generalprefs_page($action = null, $venue = null, $advanced = FALSE) {
242 242
   
243
-  // Keep the venue selected across preference pages
244
-  boincwork_select_venue($venue);
243
+    // Keep the venue selected across preference pages
244
+    boincwork_select_venue($venue);
245 245
   
246
-  $pref_sets = array('generic', 'home', 'school', 'work');
247
-  $output = null;
248
-  // Set the page title
249
-  $title = 'Computing';
250
-  drupal_set_title($title);
246
+    $pref_sets = array('generic', 'home', 'school', 'work');
247
+    $output = null;
248
+    // Set the page title
249
+    $title = 'Computing';
250
+    drupal_set_title($title);
251 251
   
252
-  switch ($action) {
252
+    switch ($action) {
253 253
   
254
-  case 'clear':
254
+    case 'clear':
255 255
     // Remove settings from this preference set
256 256
     if ($venue AND $venue != 'generic') {
257
-      boincwork_save_prefs(NULL, 'general', $venue);
258
-      drupal_set_message(t('Settings for the "@name" preference set have been
257
+        boincwork_save_prefs(NULL, 'general', $venue);
258
+        drupal_set_message(t('Settings for the "@name" preference set have been
259 259
         cleared', array('@name' => ucfirst($venue))));
260
-      // Set the generic preference set as active
261
-      $_SESSION['prefs venue'] = 'generic';
260
+        // Set the generic preference set as active
261
+        $_SESSION['prefs venue'] = 'generic';
262 262
     }
263 263
     drupal_goto();
264 264
     break;
265 265
     
266
-  case 'combined':
266
+    case 'combined':
267 267
     // Compare preference sets; tabular view
268 268
     
269 269
     foreach ($pref_sets as $pref_set) {
270
-      $form_state = array();
271
-      $prefs[$pref_set] = drupal_retrieve_form('boincwork_generalprefs_form', $form_state, $pref_set);
272
-      drupal_prepare_form('boincwork_generalprefs_form', $prefs[$pref_set], $form_state);
270
+        $form_state = array();
271
+        $prefs[$pref_set] = drupal_retrieve_form('boincwork_generalprefs_form', $form_state, $pref_set);
272
+        drupal_prepare_form('boincwork_generalprefs_form', $prefs[$pref_set], $form_state);
273 273
     }
274 274
 
275 275
     $output .= '<p>' . bts('These apply to all BOINC projects in which you participate.', array(), NULL, 'boinc:account-preferences-computing') . '<br/>';
@@ -282,29 +282,29 @@  discard block
 block discarded – undo
282 282
     $prefs_table = boincwork_make_prefs_table($prefs['generic']['prefs']['advanced']);
283 283
     
284 284
     foreach ($prefs_table as $category => $section) {
285
-      $output .= '<tr class="section-heading">';
286
-      $output .= "<td>{$section['name']}</td>";
287
-      foreach ($pref_sets as $pref_set) {
285
+        $output .= '<tr class="section-heading">';
286
+        $output .= "<td>{$section['name']}</td>";
287
+        foreach ($pref_sets as $pref_set) {
288 288
         $output .= '<td>' . $pref_set . '</td>';
289
-      }
290
-      $output .= '</tr>';
291
-      foreach ($section['elements'] as $name => $setting) {
289
+        }
290
+        $output .= '</tr>';
291
+        foreach ($section['elements'] as $name => $setting) {
292 292
         // Output the setting name and description, with an ugly exception
293 293
         // made for preferences with special formatting
294 294
         $special_map = array(
295
-          'start_hour' => 'end_hour',
296
-          'net_start_hour'=> 'net_end_hour',
297
-          'daily_xfer_limit_mb' => 'daily_xfer_period_days',
295
+            'start_hour' => 'end_hour',
296
+            'net_start_hour'=> 'net_end_hour',
297
+            'daily_xfer_limit_mb' => 'daily_xfer_period_days',
298 298
         );
299 299
         $special_delimiter = array(
300
-          'start_hour' => bts('and', array(), NULL, 'boinc:account-preference'),
301
-          'net_start_hour'=> bts('and', array(), NULL, 'boinc:account-preference'),
302
-          'daily_xfer_limit_mb' => bts('every', array(), NULL, 'boinc:account-preference'),
300
+            'start_hour' => bts('and', array(), NULL, 'boinc:account-preference'),
301
+            'net_start_hour'=> bts('and', array(), NULL, 'boinc:account-preference'),
302
+            'daily_xfer_limit_mb' => bts('every', array(), NULL, 'boinc:account-preference'),
303 303
         );
304 304
         $special = isset($special_map[$name]);
305 305
         $very_special = in_array($name, $special_map);
306 306
         if ($very_special) {
307
-          continue;
307
+            continue;
308 308
         }
309 309
         $output .= '<tr>';
310 310
         $output .= '<td>';
@@ -314,35 +314,35 @@  discard block
 block discarded – undo
314 314
         // Output values for each preference set, again with ugly hacks for
315 315
         // time range preferences
316 316
         foreach ($pref_sets as $pref_set) {
317
-          if (($prefs[$pref_set]) AND 
317
+            if (($prefs[$pref_set]) AND 
318 318
               $prefs[$pref_set]['#established'] AND
319 319
               isset($prefs[$pref_set]['prefs']['advanced'][$category])) {
320 320
             $pref_setting = $prefs[$pref_set]['prefs']['advanced'][$category][$name];
321 321
             $value = isset($pref_setting['#options']) ? $pref_setting['#options'][$pref_setting['#default_value']] : $pref_setting['#default_value'];
322 322
             if ($value == '') {
323
-              $value = '---';
323
+                $value = '---';
324 324
             }
325 325
             if (!isset($pref_setting['#field_suffix'])) {
326
-              $pref_setting['#field_suffix'] = '';
326
+                $pref_setting['#field_suffix'] = '';
327 327
             }
328 328
             if (!$special) {
329
-              $output .= "<td>{$value} {$pref_setting['#field_suffix']}</td>";
329
+                $output .= "<td>{$value} {$pref_setting['#field_suffix']}</td>";
330 330
             }
331 331
             else {
332
-              // The "very special" case where we merge two prefs
333
-              $second_pref = $special_map[$name];
334
-              $second_pref_setting = $prefs[$pref_set]['prefs']['advanced'][$category][$second_pref];
335
-              $second_value = isset($second_pref_setting['#options']) ? $second_pref_setting['#options'][$second_pref_setting['#default_value']] : $second_pref_setting['#default_value'];
336
-              $output .= "<td>{$value} {$pref_setting['#field_suffix']} {$special_delimiter[$name]}" .
332
+                // The "very special" case where we merge two prefs
333
+                $second_pref = $special_map[$name];
334
+                $second_pref_setting = $prefs[$pref_set]['prefs']['advanced'][$category][$second_pref];
335
+                $second_value = isset($second_pref_setting['#options']) ? $second_pref_setting['#options'][$second_pref_setting['#default_value']] : $second_pref_setting['#default_value'];
336
+                $output .= "<td>{$value} {$pref_setting['#field_suffix']} {$special_delimiter[$name]}" .
337 337
                 " {$second_value} {$second_pref_setting['#field_suffix']} </td>";
338 338
             }
339
-          }
340
-          else  {
339
+            }
340
+            else  {
341 341
             $output .= '<td>---</td>';
342
-          }
342
+            }
343 343
         }
344 344
         $output .= '</tr>';
345
-      }
345
+        }
346 346
     }
347 347
     
348 348
     // Empty line above action links... :/
@@ -358,24 +358,24 @@  discard block
 block discarded – undo
358 358
     $output .= '<tr>';
359 359
     $output .= '<td></td>';
360 360
     foreach ($pref_sets as $pref_set) {
361
-      $action_text = ($prefs[$pref_set]['#established']) ? bts('Edit', array(), NULL, 'boinc:form-edit') : bts('Add', array(), NULL, 'boinc:form-add');
362
-      $output .= '<td><ul class="tab-list"><li class="first tab">';
363
-      $output .= l($action_text, "account/prefs/computing/edit/{$pref_set}/1",
361
+        $action_text = ($prefs[$pref_set]['#established']) ? bts('Edit', array(), NULL, 'boinc:form-edit') : bts('Add', array(), NULL, 'boinc:form-add');
362
+        $output .= '<td><ul class="tab-list"><li class="first tab">';
363
+        $output .= l($action_text, "account/prefs/computing/edit/{$pref_set}/1",
364 364
         array('fragment' => "")
365
-      );
366
-      // Show Clear links for established preference sets
367
-      if ($pref_set != 'generic' AND $prefs[$pref_set]['#established']) {
365
+        );
366
+        // Show Clear links for established preference sets
367
+        if ($pref_set != 'generic' AND $prefs[$pref_set]['#established']) {
368 368
         $output .= ' </li><li class="tab"> ' . l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/computing/clear/{$pref_set}",
369
-          array(
369
+            array(
370 370
             'query' => drupal_get_destination(),
371 371
             'attributes' => array(
372
-              'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the "@name" preference set. Are you sure?',
372
+                'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the "@name" preference set. Are you sure?',
373 373
                 array('@name' => ucfirst($pref_set)), array(), NULL, 'boinc:account-computing-preferences') . '\')'
374 374
             )
375
-          )
375
+            )
376 376
         );
377
-      }
378
-      $output .= '</li></ul></td>';
377
+        }
378
+        $output .= '</li></ul></td>';
379 379
     }
380 380
     $output .= '</tr>';
381 381
     
@@ -383,28 +383,28 @@  discard block
 block discarded – undo
383 383
     
384 384
     break;
385 385
     
386
-  case 'edit':
386
+    case 'edit':
387 387
   default:
388 388
   
389 389
     // Return the HTML generated from the $form data structure.
390 390
     if (function_exists('jump_quickly')) {
391
-      $path = 'account/prefs/computing/edit';
392
-      $venues = array(
391
+        $path = 'account/prefs/computing/edit';
392
+        $venues = array(
393 393
         "{$path}/generic" => bts('Generic', array(), NULL, 'boinc:account-preferences-location'),
394 394
         "{$path}/home" => bts('Home', array(), NULL, 'boinc:account-preferences-location:-1:ignoreoverwrite'),
395 395
         "{$path}/school" => bts('School', array(), NULL, 'boinc:account-preferences-location'),
396 396
         "{$path}/work" => bts('Work', array(), NULL, 'boinc:account-preferences-location')
397
-      );
398
-      variable_set('jump_use_js_venues-Array', 1);
399
-      drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js');
400
-      drupal_add_js(drupal_get_path('theme', 'boinc') . '/js/prefs.js', 'theme');
397
+        );
398
+        variable_set('jump_use_js_venues-Array', 1);
399
+        drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js');
400
+        drupal_add_js(drupal_get_path('theme', 'boinc') . '/js/prefs.js', 'theme');
401 401
       
402
-      $output .= '<div id="venue-selector" class="simple-form-controls">';
403
-      $output .= '  <div class="form-item venue">';
404
-      $output .= '    <label>Preference set:</label>';
405
-      $output .= jump_quickly($venues, 'venues', 1, "{$path}/{$venue}");
406
-      $output .= '  </div>';
407
-      $output .= '</div>';
402
+        $output .= '<div id="venue-selector" class="simple-form-controls">';
403
+        $output .= '  <div class="form-item venue">';
404
+        $output .= '    <label>Preference set:</label>';
405
+        $output .= jump_quickly($venues, 'venues', 1, "{$path}/{$venue}");
406
+        $output .= '  </div>';
407
+        $output .= '</div>';
408 408
     }
409 409
     $output .= drupal_get_form('boincwork_generalprefs_form', $venue, NULL, $advanced);
410 410
     
@@ -415,54 +415,54 @@  discard block
 block discarded – undo
415 415
     drupal_prepare_form('boincwork_generalprefs_form', $current_set, $form_state);
416 416
 
417 417
     if (!$current_set['#established']) {
418
-      drupal_set_message(bts(
419
-          "No preferences found for set '@venue'. Click SAVE CHANGES below to save the following preferences to your account.",
420
-          array( '@venue' => $venue, ),
421
-          NULL, 'boinc:account-preferences'), 'status');
418
+        drupal_set_message(bts(
419
+            "No preferences found for set '@venue'. Click SAVE CHANGES below to save the following preferences to your account.",
420
+            array( '@venue' => $venue, ),
421
+            NULL, 'boinc:account-preferences'), 'status');
422 422
     }
423 423
     
424 424
     break;
425
-  }
425
+    }
426 426
   
427
-  return $output;
427
+    return $output;
428 428
 }
429 429
 
430 430
 /**
431
-  * Project preferences menu callback
432
-  * Called when user goes to edit project preferences page.
433
-  */
431
+ * Project preferences menu callback
432
+ * Called when user goes to edit project preferences page.
433
+ */
434 434
 function projectprefs_page($action = null, $venue = null) {
435 435
   
436
-  // Keep the venue selected across preference pages
437
-  boincwork_select_venue($venue);
436
+    // Keep the venue selected across preference pages
437
+    boincwork_select_venue($venue);
438 438
   
439
-  require_boinc(array('util', 'prefs'));
440
-  global $project_has_beta;
441
-  $pref_sets = array('generic', 'home', 'school', 'work');
442
-  $output = null;
439
+    require_boinc(array('util', 'prefs'));
440
+    global $project_has_beta;
441
+    $pref_sets = array('generic', 'home', 'school', 'work');
442
+    $output = null;
443 443
   
444
-  $title = 'Project';
445
-  drupal_set_title($title);
444
+    $title = 'Project';
445
+    drupal_set_title($title);
446 446
   
447
-  switch ($action) {
447
+    switch ($action) {
448 448
   
449
-  case 'clear':
449
+    case 'clear':
450 450
     // Remove settings from this preference set
451 451
     if ($venue AND $venue != 'generic') {
452
-      boincwork_save_prefs(NULL, 'project', $venue);
453
-      drupal_set_message(t('Settings for the "@name" preference set have been
452
+        boincwork_save_prefs(NULL, 'project', $venue);
453
+        drupal_set_message(t('Settings for the "@name" preference set have been
454 454
         cleared', array('@name' => ucfirst($venue))));
455 455
       
456
-      // Set the generic preference set as active
457
-      $_SESSION['prefs venue'] = 'generic';
456
+        // Set the generic preference set as active
457
+        $_SESSION['prefs venue'] = 'generic';
458 458
       
459
-      // If the user has removed their default preference set, make it generic
460
-      boincwork_set_default_venue();
459
+        // If the user has removed their default preference set, make it generic
460
+        boincwork_set_default_venue();
461 461
     }
462 462
     drupal_goto();
463 463
     break;
464 464
     
465
-  case 'combined':
465
+    case 'combined':
466 466
   
467 467
     // Compare preference sets; tabular view
468 468
     
@@ -471,9 +471,9 @@  discard block
 block discarded – undo
471 471
     $boincuser = BoincUser::lookup_id($account->boincuser_id);
472 472
     
473 473
     foreach ($pref_sets as $pref_set) {
474
-      $form_state = array();
475
-      $prefs[$pref_set] = drupal_retrieve_form('boincwork_projectprefs_form', $form_state, $pref_set);
476
-      drupal_prepare_form('boincwork_projectprefs_form', $prefs[$pref_set], $form_state);
474
+        $form_state = array();
475
+        $prefs[$pref_set] = drupal_retrieve_form('boincwork_projectprefs_form', $form_state, $pref_set);
476
+        drupal_prepare_form('boincwork_projectprefs_form', $prefs[$pref_set], $form_state);
477 477
     }
478 478
     
479 479
     $output .= '<h2>' . bts('Combined preferences', array(), NULL, 'boinc:account-preferences') . ' ' . l('(' . bts('Switch View', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/project') . '</h2>';
@@ -483,20 +483,20 @@  discard block
 block discarded – undo
483 483
     $prefs_table = boincwork_make_prefs_table($prefs['generic']);
484 484
     
485 485
     foreach ($prefs_table as $category => $section) {
486
-      $output .= '<tr class="section-heading">';
487
-      $output .= "<td>{$section['name']}</td>";
488
-      foreach ($pref_sets as $pref_set) {
486
+        $output .= '<tr class="section-heading">';
487
+        $output .= "<td>{$section['name']}</td>";
488
+        foreach ($pref_sets as $pref_set) {
489 489
         $output .= '<td>' . $pref_set . '</td>';
490
-      }
491
-      $output .= '</tr>';
492
-      foreach ($section['elements'] as $name => $setting) {
490
+        }
491
+        $output .= '</tr>';
492
+        foreach ($section['elements'] as $name => $setting) {
493 493
         $output .= '<tr>';
494 494
         $output .= '<td>';
495 495
         $output .= "<div class=\"title\">{$setting['name']}</div>";
496 496
         $output .= "<div class=\"description\">{$setting['description']}</div>";
497 497
         $output .= '</td>';
498 498
         foreach ($pref_sets as $pref_set) {
499
-          if (($prefs[$pref_set]) AND
499
+            if (($prefs[$pref_set]) AND
500 500
               $prefs[$pref_set]['#established'] AND
501 501
               isset($prefs[$pref_set][$category])) {
502 502
             $pref_setting = $prefs[$pref_set][$category][$name];
@@ -504,10 +504,10 @@  discard block
 block discarded – undo
504 504
             if ($value == '') $value = '---';
505 505
             if (!isset($pref_setting['#field_suffix'])) $pref_setting['#field_suffix'] = '';
506 506
             $output .= "<td>{$value} {$pref_setting['#field_suffix']}</td>";
507
-          } else $output .= '<td>---</td>';
507
+            } else $output .= '<td>---</td>';
508 508
         }
509 509
         $output .= '</tr>';
510
-      }
510
+        }
511 511
     }
512 512
     
513 513
     // Empty line above action links... :/
@@ -523,29 +523,29 @@  discard block
 block discarded – undo
523 523
     $output .= '<tr>';
524 524
     $output .= '<td></td>';
525 525
     foreach ($pref_sets as $pref_set) {
526
-      $action_text = ($prefs[$pref_set]['#established']) ? bts('Edit', array(), NULL, 'boinc:form-edit') : bts('Add', array(), NULL, 'boinc:form-add');
527
-      $output .= '<td><ul class="tab-list"><li class="first tab">';
528
-      $output .= l($action_text, "account/prefs/project/edit/{$pref_set}");
529
-      // Show Clear links for established preference sets
530
-      if ($pref_set != 'generic' AND $prefs[$pref_set]['#established']) {
526
+        $action_text = ($prefs[$pref_set]['#established']) ? bts('Edit', array(), NULL, 'boinc:form-edit') : bts('Add', array(), NULL, 'boinc:form-add');
527
+        $output .= '<td><ul class="tab-list"><li class="first tab">';
528
+        $output .= l($action_text, "account/prefs/project/edit/{$pref_set}");
529
+        // Show Clear links for established preference sets
530
+        if ($pref_set != 'generic' AND $prefs[$pref_set]['#established']) {
531 531
         $output .= ' </li><li class="tab"> ' . l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/project/clear/{$pref_set}",
532
-          array(
532
+            array(
533 533
             'query' => drupal_get_destination(),
534 534
             'attributes' => array(
535
-              'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the "@name" preference set. Are you sure?',
535
+                'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the "@name" preference set. Are you sure?',
536 536
                 array('@name' => ucfirst($pref_set)), array(), NULL, 'boinc:account-preferences-project') . '\')'
537 537
             )
538
-          )
538
+            )
539 539
         );
540
-      }
541
-      $output .= '</li></ul></td>';
540
+        }
541
+        $output .= '</li></ul></td>';
542 542
     }
543 543
     
544 544
     $output .= '</table>';
545 545
     
546 546
     break;
547 547
     
548
-  case 'set-default':
548
+    case 'set-default':
549 549
     // Set this preference set as the one to use for any new hosts attached
550 550
     // to the user account
551 551
     boincwork_set_default_venue($venue);
@@ -553,30 +553,30 @@  discard block
 block discarded – undo
553 553
     drupal_goto('account/prefs/project/combined');
554 554
     break;
555 555
     
556
-  case 'edit':
556
+    case 'edit':
557 557
   default:
558 558
     
559 559
     // Return the HTML generated from the $form data structure.
560 560
     require_boinc('util');
561 561
     
562 562
     if (function_exists('jump_quickly')) {
563
-      $path = 'account/prefs/project/edit';
564
-      $venues = array(
563
+        $path = 'account/prefs/project/edit';
564
+        $venues = array(
565 565
         "{$path}/generic" => bts('Generic', array(), NULL, 'boinc:account-preferences-location'),
566 566
         "{$path}/home" => bts('Home', array(), NULL, 'boinc:account-preferences-location:-1:ignoreoverwrite'),
567 567
         "{$path}/school" => bts('School', array(), NULL, 'boinc:account-preferences-location'),
568 568
         "{$path}/work" => bts('Work', array(), NULL, 'boinc:account-preferences-location')
569
-      );
570
-      variable_set('jump_use_js_venues-Array', 1);
571
-      drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js');
572
-      drupal_add_js(drupal_get_path('theme', 'boinc') . '/js/prefs.js', 'theme');
569
+        );
570
+        variable_set('jump_use_js_venues-Array', 1);
571
+        drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js');
572
+        drupal_add_js(drupal_get_path('theme', 'boinc') . '/js/prefs.js', 'theme');
573 573
       
574
-      $output .= '<div id="venue-selector" class="simple-form-controls">';
575
-      $output .= '  <div class="form-item venue">';
576
-      $output .= '    <label>Preference set:</label>';
577
-      $output .= jump_quickly($venues, 'venues', 1, "{$path}/{$venue}");
578
-      $output .= '  </div>';
579
-      $output .= '</div>';
574
+        $output .= '<div id="venue-selector" class="simple-form-controls">';
575
+        $output .= '  <div class="form-item venue">';
576
+        $output .= '    <label>Preference set:</label>';
577
+        $output .= jump_quickly($venues, 'venues', 1, "{$path}/{$venue}");
578
+        $output .= '  </div>';
579
+        $output .= '</div>';
580 580
     }
581 581
     $output .= drupal_get_form('boincwork_projectprefs_form', $venue);
582 582
     
@@ -587,63 +587,63 @@  discard block
 block discarded – undo
587 587
     drupal_prepare_form('boincwork_projectprefs_form', $current_set, $form_state);
588 588
     
589 589
     if (!$current_set['#established']) {
590
-      drupal_set_message(bts(
591
-          "No preferences found for set '@venue'. Click SAVE CHANGES below to save the following preferences to your account.",
592
-          array( '@venue' => $venue, ),
593
-          NULL, 'boinc:account-preferences'), 'status');
590
+        drupal_set_message(bts(
591
+            "No preferences found for set '@venue'. Click SAVE CHANGES below to save the following preferences to your account.",
592
+            array( '@venue' => $venue, ),
593
+            NULL, 'boinc:account-preferences'), 'status');
594 594
     }
595 595
     
596 596
     break;
597 597
     
598
-  }
599
-  return $output;
598
+    }
599
+    return $output;
600 600
 }
601 601
 
602 602
 /**
603
-  * Community preferences menu callback
604
-  * Called when user goes to edit community preferences page.
605
-  */
603
+ * Community preferences menu callback
604
+ * Called when user goes to edit community preferences page.
605
+ */
606 606
 function communityprefs_page($action = null) {
607 607
   
608
-  require_boinc(array('util', 'prefs'));
609
-  $output = null;
608
+    require_boinc(array('util', 'prefs'));
609
+    $output = null;
610 610
   
611
-  $title = 'Community';
612
-  drupal_set_title($title);
611
+    $title = 'Community';
612
+    drupal_set_title($title);
613 613
   
614
-  //$output .= '<h2>Community preferences</h2>';
614
+    //$output .= '<h2>Community preferences</h2>';
615 615
   
616
-  $output .= drupal_get_form('communityprefs_form');
616
+    $output .= drupal_get_form('communityprefs_form');
617 617
   
618
-  return $output;
618
+    return $output;
619 619
 }
620 620
 
621 621
 /**
622
-  * Privacy preferences menu callback
623
-  * Called when user goes to edit privacy preferences page.
624
-  */
622
+ * Privacy preferences menu callback
623
+ * Called when user goes to edit privacy preferences page.
624
+ */
625 625
 function privacyprefs_page($action = null) {
626 626
   
627
-  require_boinc(array('util', 'prefs'));
628
-  $output = null;
629
-  $title = 'Privacy';
630
-  drupal_set_title($title);
627
+    require_boinc(array('util', 'prefs'));
628
+    $output = null;
629
+    $title = 'Privacy';
630
+    drupal_set_title($title);
631 631
   
632
-  switch ($action) {
633
-  case 'view':
632
+    switch ($action) {
633
+    case 'view':
634 634
     $form_state = array();
635 635
     $prefs = drupal_retrieve_form('boincwork_privacyprefs_form', $form_state);
636 636
     drupal_prepare_form('boincwork_privacyprefs_form', $prefs, $form_state);
637 637
     $output .= '<table>';
638 638
     
639 639
     $sections = array(
640
-      'privacy' => $prefs['privacy']
640
+        'privacy' => $prefs['privacy']
641 641
     );
642 642
     
643 643
     foreach ($sections as $section) {
644
-      $output .= '<tr class="section-heading">';
645
-      $output .= "<td>{$section['#title']}</td></tr>";
646
-      foreach ($section as $name => $setting) {
644
+        $output .= '<tr class="section-heading">';
645
+        $output .= "<td>{$section['#title']}</td></tr>";
646
+        foreach ($section as $name => $setting) {
647 647
         if ($name{0} == '#') continue;
648 648
         $value = isset($setting['#default_value']) ? $setting['#default_value'] : '';
649 649
         if ($value AND isset($setting['#options'])) $value = $setting['#options'][$value];
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
         $output .= "<td>{$setting['#title']}<br/>{$setting['#description']}</td>";
656 656
         $output .= "<td>{$value} {$setting['#field_suffix']}</td>";
657 657
         $output .= '</tr>';
658
-      }
658
+        }
659 659
     }
660 660
     
661 661
     // Edit preferences link
@@ -668,33 +668,33 @@  discard block
 block discarded – undo
668 668
     
669 669
     break;
670 670
     
671
-  case 'edit':
671
+    case 'edit':
672 672
   default:
673 673
     require_boinc('util');
674 674
     // Return the HTML generated from the $form data structure.
675 675
     $output .= drupal_get_form('boincwork_privacyprefs_form');
676 676
     break;
677 677
     
678
-  }
678
+    }
679 679
   
680
-  return $output;
680
+    return $output;
681 681
 }
682 682
 
683 683
 /**
684
-  * Certificates menu callback
685
-  * Called when user goes to account certificate pages
686
-  */
684
+ * Certificates menu callback
685
+ * Called when user goes to account certificate pages
686
+ */
687 687
 function boincwork_certificates($type = null, $border = null) {
688
-  global $user;
689
-  $drupuser = user_load($user->uid);
690
-  // Load BOINC account and pre-authenticate with BOINC code
691
-  require_boinc(array('util', 'cert'));
692
-  $boincuser = BoincUser::lookup_id($drupuser->boincuser_id);
693
-  //global $g_logged_in_user;
694
-  //$g_logged_in_user = $boincuser;
695
-  //print_r($boincuser); exit;
696
-  switch ($type) {
697
-  case 'all':
688
+    global $user;
689
+    $drupuser = user_load($user->uid);
690
+    // Load BOINC account and pre-authenticate with BOINC code
691
+    require_boinc(array('util', 'cert'));
692
+    $boincuser = BoincUser::lookup_id($drupuser->boincuser_id);
693
+    //global $g_logged_in_user;
694
+    //$g_logged_in_user = $boincuser;
695
+    //print_r($boincuser); exit;
696
+    switch ($type) {
697
+    case 'all':
698 698
     //include_boinc('user/cert_all.php');
699 699
     require_boinc(array('util','cert','user'));
700 700
 
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
     ";
765 765
     break;
766 766
     
767
-  case 'account':
767
+    case 'account':
768 768
   default:
769 769
     //include_boinc('user/cert1.php');
770 770
     require_boinc(array('util','cert'));
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
     echo "
841 841
     </td><tr></table>
842 842
     ";
843
-  }
843
+    }
844 844
 }
845 845
 
846 846
 /**
@@ -848,42 +848,42 @@  discard block
 block discarded – undo
848 848
  * Called when user selects to delete a host
849 849
  */
850 850
 function boincwork_host_delete($host_id) {
851
-  // Verify that host has no tasks
852
-  if (boincwork_host_user_is_owner($host_id)) {
851
+    // Verify that host has no tasks
852
+    if (boincwork_host_user_is_owner($host_id)) {
853 853
     if (!boincwork_host_get_task_count($host_id)) {
854
-      // Delete the host record
855
-      db_set_active('boinc');
856
-      $host_deleted = db_query(
854
+        // Delete the host record
855
+        db_set_active('boinc');
856
+        $host_deleted = db_query(
857 857
         "DELETE FROM {host} WHERE id = '%d'",
858 858
         $host_id
859
-      );
860
-      db_set_active('default');
861
-      if ($host_deleted) {
859
+        );
860
+        db_set_active('default');
861
+        if ($host_deleted) {
862 862
         drupal_set_message(t('Host @id has been removed from your account.',
863
-          array('@id' => $host_id)));
863
+            array('@id' => $host_id)));
864 864
         drupal_goto('account/computers');
865
-      }
866
-      else {
865
+        }
866
+        else {
867 867
         drupal_set_message(t('Host @id could not be deleted. Not sure why...',
868
-          array('@id' => $host_id)), 'error'
868
+            array('@id' => $host_id)), 'error'
869 869
         );
870
-      }
870
+        }
871 871
     }
872 872
     else {
873
-      drupal_set_message(t('Host @id cannot be deleted because it still has
873
+        drupal_set_message(t('Host @id cannot be deleted because it still has
874 874
         tasks associated with it. These tasks should be processed within the
875 875
         next few days, after which the host can be deleted.', 
876 876
         array('@id' => $host_id)), 'warning'
877
-      );
877
+        );
878 878
     }
879
-  }
880
-  else {
879
+    }
880
+    else {
881 881
     drupal_set_message(t('You are not the owner of host @id, so you cannot
882 882
       delete it.', 
883
-      array('@id' => $host_id)), 'error'
883
+        array('@id' => $host_id)), 'error'
884 884
     );
885
-  }
886
-  drupal_goto("host/{$host_id}");
885
+    }
886
+    drupal_goto("host/{$host_id}");
887 887
 }
888 888
 
889 889
 /**
@@ -891,53 +891,53 @@  discard block
 block discarded – undo
891 891
  * Called when user accesses the log for a host
892 892
  */
893 893
 function boincwork_host_log($host_id = null) {
894
-  $root_log_dir = variable_get('boinc_host_sched_logs_dir', '');
895
-  $log = '';
896
-  if ($root_log_dir AND $host_id) {
894
+    $root_log_dir = variable_get('boinc_host_sched_logs_dir', '');
895
+    $log = '';
896
+    if ($root_log_dir AND $host_id) {
897 897
     $subdir = substr($host_id, 0, -3) OR $subdir = 0;
898 898
     $log = implode('/', array($root_log_dir, $subdir, $host_id));
899
-  }
900
-  if ($log AND file_exists($log)) {
899
+    }
900
+    if ($log AND file_exists($log)) {
901 901
     header('Content-type: text/plain');
902 902
     include($log);
903
-  }
903
+    }
904 904
 }
905 905
 
906 906
 function boincwork_host_set_venue($host_id = NULL, $venue = NULL) {
907
-  global $user;
908
-  $account = user_load($user->uid);
909
-  db_set_active('boinc');
910
-  // Verify that this is my host
911
-  $host_owner = db_result(db_query(
907
+    global $user;
908
+    $account = user_load($user->uid);
909
+    db_set_active('boinc');
910
+    // Verify that this is my host
911
+    $host_owner = db_result(db_query(
912 912
     "SELECT userid FROM {host} WHERE id = '%d'",
913 913
     $host_id
914
-  ));
915
-  if ($host_owner AND $host_owner == $account->boincuser_id) {
914
+    ));
915
+    if ($host_owner AND $host_owner == $account->boincuser_id) {
916 916
     $updated = db_query(
917
-      "UPDATE {host} SET venue = '%s' WHERE id = '%d'",
918
-      $venue, $host_id
917
+        "UPDATE {host} SET venue = '%s' WHERE id = '%d'",
918
+        $venue, $host_id
919 919
     );
920 920
     if ($updated) {
921
-      drupal_set_message(
921
+        drupal_set_message(
922 922
         bts('The location for this host has been updated.', array(), NULL, 'boinc:account-host-details')
923 923
         . bts('This will take effect next time the host contacts the project.', array(), NULL, 'boinc:account-host-details')
924
-      );
924
+        );
925 925
     }
926 926
     else {
927
-      drupal_set_message(
927
+        drupal_set_message(
928 928
         bts('Unable to save changes to this host for some reason!', array(), NULL, 'boinc:account-host-details'),
929 929
         'error'
930
-      );
930
+        );
931
+    }
931 932
     }
932
-  }
933
-  else {
933
+    else {
934 934
     drupal_set_message(
935
-      bts('You are not allowed to make changes to this host.', array(), NULL, 'boinc:account-host-details'),
936
-      'warning'
935
+        bts('You are not allowed to make changes to this host.', array(), NULL, 'boinc:account-host-details'),
936
+        'warning'
937 937
     );
938
-  }
939
-  db_set_active('default');
940
-  drupal_goto("host/{$host_id}");
938
+    }
939
+    db_set_active('default');
940
+    drupal_goto("host/{$host_id}");
941 941
 }
942 942
 
943 943
 /**
@@ -945,8 +945,8 @@  discard block
 block discarded – undo
945 945
  * Called when user accesses cell phone stats
946 946
  */
947 947
 function boincwork_mobile_stats($userid = null) {
948
-  $_GET['id'] = $userid;
949
-  include_boinc('user/userw.php');
948
+    $_GET['id'] = $userid;
949
+    include_boinc('user/userw.php');
950 950
 }
951 951
 
952 952
 /**
@@ -954,7 +954,7 @@  discard block
 block discarded – undo
954 954
  * Called to build the server status page
955 955
  */
956 956
 function boincwork_server_status() {
957
-  include_boinc('user/server_status.php');
957
+    include_boinc('user/server_status.php');
958 958
 }
959 959
 
960 960
 /**
@@ -962,7 +962,7 @@  discard block
 block discarded – undo
962 962
  * RPC for managing job input files
963 963
  */
964 964
 function boincwork_job_file() {
965
-  include_boinc('user/job_file.php');
965
+    include_boinc('user/job_file.php');
966 966
 }
967 967
 
968 968
 /**
@@ -970,7 +970,7 @@  discard block
 block discarded – undo
970 970
  * Get output file from remote job submission
971 971
  */
972 972
 function boincwork_get_output() {
973
-  include_boinc('user/get_output.php');
973
+    include_boinc('user/get_output.php');
974 974
 }
975 975
 
976 976
 /**
@@ -978,23 +978,23 @@  discard block
 block discarded – undo
978 978
  * Get the project configuration XML; used by client software
979 979
  */
980 980
 function boincwork_get_project_config() {
981
-  include_boinc('user/get_project_config.php');
981
+    include_boinc('user/get_project_config.php');
982 982
 }
983 983
 
984 984
 /**
985 985
  * Page callback for the remote job submission RPC (submit_rpc_handler.php).
986 986
  */
987 987
 function boincwork_submit_rpc_handler() {
988
-  include_boinc('user/submit_rpc_handler.php');
988
+    include_boinc('user/submit_rpc_handler.php');
989 989
 }
990 990
 
991 991
 /**
992 992
  * Page callback for user WAP (userw.php).
993 993
  */
994 994
 function boincwork_user_wap() {
995
-  // Remove q from the GET request or BOINC will panic
996
-  unset($_GET['q']);
997
-  include_boinc('user/userw.php');
995
+    // Remove q from the GET request or BOINC will panic
996
+    unset($_GET['q']);
997
+    include_boinc('user/userw.php');
998 998
 }
999 999
 
1000 1000
 
@@ -1002,44 +1002,44 @@  discard block
 block discarded – undo
1002 1002
  * Page callback for user account task table
1003 1003
  */
1004 1004
 function boincwork_account_task_table($tselect = NULL, $app_id = NULL) {
1005
-  $title = bts('Tasks for your account', array(), NULL, 'boinc:account-task-table');
1006
-  drupal_set_title($title);
1005
+    $title = bts('Tasks for your account', array(), NULL, 'boinc:account-task-table');
1006
+    drupal_set_title($title);
1007 1007
 
1008
-  global $user;
1009
-  $account = user_load($user->uid);
1010
-  return boincwork_tasktable(0, $account->boincuser_id, $tselect, $app_id);
1008
+    global $user;
1009
+    $account = user_load($user->uid);
1010
+    return boincwork_tasktable(0, $account->boincuser_id, $tselect, $app_id);
1011 1011
 }
1012 1012
 
1013 1013
 /**
1014 1014
  * Page callback for host task table
1015 1015
  */
1016 1016
 function boincwork_host_task_table($host_id = NULL, $tselect = NULL, $app_id = NULL) {
1017
-  require_boinc( array('util', 'result') );
1017
+    require_boinc( array('util', 'result') );
1018 1018
 
1019
-  $title = bts('Tasks for computer @host_id', array('@host_id' => $host_id), NULL, 'boinc:host-task-table');
1020
-  drupal_set_title($title);
1019
+    $title = bts('Tasks for computer @host_id', array('@host_id' => $host_id), NULL, 'boinc:host-task-table');
1020
+    drupal_set_title($title);
1021 1021
 
1022
-  if (is_null($host_id)) {
1022
+    if (is_null($host_id)) {
1023 1023
     drupal_set_message(bts('ERROR: Invalid host ID', array(), NULL, 'boinc:host-task-table'), 'error');
1024 1024
     return '';
1025
-  }
1025
+    }
1026 1026
 
1027
-  return boincwork_tasktable(2, $host_id, $tselect, $app_id);
1027
+    return boincwork_tasktable(2, $host_id, $tselect, $app_id);
1028 1028
 }
1029 1029
 
1030 1030
 /**
1031 1031
  * Page callback for workunit task table
1032 1032
  */
1033 1033
 function boincwork_workunit_task_table($workunit_id = NULL, $tselect = NULL, $app_id = NULL) {
1034
-  $title = bts('Tasks for computer @workunit_id', array('@workunit_id' => $workunit_id), NULL, 'boinc:workunit-task-table');
1035
-  drupal_set_title($title);
1034
+    $title = bts('Tasks for computer @workunit_id', array('@workunit_id' => $workunit_id), NULL, 'boinc:workunit-task-table');
1035
+    drupal_set_title($title);
1036 1036
 
1037
-  if (is_null($workunit_id)) {
1037
+    if (is_null($workunit_id)) {
1038 1038
     drupal_set_message(bts('ERROR: Invalid workunit ID', array(), NULL, 'boinc:workunit-task-table'), 'error');
1039 1039
     return '';
1040
-  }
1040
+    }
1041 1041
   
1042
-  return boincwork_tasktable(1, $workunit_id, $tselect, $app_id);
1042
+    return boincwork_tasktable(1, $workunit_id, $tselect, $app_id);
1043 1043
 }
1044 1044
 
1045 1045
 /**
@@ -1047,8 +1047,8 @@  discard block
 block discarded – undo
1047 1047
  * Take a node ID and render that node as a page
1048 1048
  */
1049 1049
 function boincwork_view_page($nid) {
1050
-  $node = node_load($nid);
1051
-  return node_page_view($node);
1050
+    $node = node_load($nid);
1051
+    return node_page_view($node);
1052 1052
 }
1053 1053
 
1054 1054
 
@@ -1060,16 +1060,16 @@  discard block
 block discarded – undo
1060 1060
  * Determine which venue should be selected
1061 1061
  */
1062 1062
 function boincwork_select_venue(&$venue) {
1063
-  if (!$venue) {
1063
+    if (!$venue) {
1064 1064
     $active_venue = isset($_SESSION['prefs venue']) ? $_SESSION['prefs venue'] : NULL;
1065 1065
     if ($active_venue) {
1066
-      $venue = $active_venue;
1067
-      //unset($_SESSION['prefs venue']);
1066
+        $venue = $active_venue;
1067
+        //unset($_SESSION['prefs venue']);
1068
+    }
1068 1069
     }
1069
-  }
1070
-  else {
1070
+    else {
1071 1071
     // Set the active venue to keep it selected between computing and project
1072 1072
     // preference pages
1073 1073
     $_SESSION['prefs venue'] = $venue;
1074
-  }
1074
+    }
1075 1075
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
   $items['host/%/set-venue/%'] = array(
116 116
     'title' => 'Set host venue',
117 117
     'page callback' => 'boincwork_host_set_venue',
118
-    'page arguments' => array(1,3),
118
+    'page arguments' => array(1, 3),
119 119
     'access callback' => 'user_is_logged_in',
120 120
     'type' => MENU_CALLBACK,
121 121
   );
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
     'title' => 'Account Tasks Table',
168 168
     'description' => '',
169 169
     'page callback' => 'boincwork_account_task_table',
170
-    'page arguments' => array(2,3),
170
+    'page arguments' => array(2, 3),
171 171
     'access arguments' => array('access content'),
172 172
     'type' => MENU_CALLBACK,
173 173
   );
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
     'title' => 'Host Tasks Table',
176 176
     'description' => '',
177 177
     'page callback' => 'boincwork_host_task_table',
178
-    'page arguments' => array(1,3,4),
178
+    'page arguments' => array(1, 3, 4),
179 179
     'access arguments' => array('access content'),
180 180
     'type' => MENU_CALLBACK,
181 181
   );
@@ -272,10 +272,10 @@  discard block
 block discarded – undo
272 272
       drupal_prepare_form('boincwork_generalprefs_form', $prefs[$pref_set], $form_state);
273 273
     }
274 274
 
275
-    $output .= '<p>' . bts('These apply to all BOINC projects in which you participate.', array(), NULL, 'boinc:account-preferences-computing') . '<br/>';
276
-    $output .= bts('On computers attached to multiple projects, the most recently modified preferences will be used.', array(), NULL, 'boinc:account-preferences-computing') . '</p>';
277
-    $output .= '<p>' . bts('Preferences last modified: @mod_time', array('@mod_time' => pretty_time_str($prefs['generic']['prefs']['modified']['#value'])), NULL, 'boinc:account-preferences-computing') . '</p>';
278
-    $output .= '<h2>' . bts('Combined preferences', array(), NULL, 'boinc:account-preferences') . ' ' . l('(' . bts('Switch View', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/computing') . '</h2>';
275
+    $output .= '<p>'.bts('These apply to all BOINC projects in which you participate.', array(), NULL, 'boinc:account-preferences-computing').'<br/>';
276
+    $output .= bts('On computers attached to multiple projects, the most recently modified preferences will be used.', array(), NULL, 'boinc:account-preferences-computing').'</p>';
277
+    $output .= '<p>'.bts('Preferences last modified: @mod_time', array('@mod_time' => pretty_time_str($prefs['generic']['prefs']['modified']['#value'])), NULL, 'boinc:account-preferences-computing').'</p>';
278
+    $output .= '<h2>'.bts('Combined preferences', array(), NULL, 'boinc:account-preferences').' '.l('('.bts('Switch View', array(), NULL, 'boinc:account-preferences').')', 'account/prefs/computing').'</h2>';
279 279
     
280 280
     $output .= '<table class="preferences combined">';
281 281
     
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
       $output .= '<tr class="section-heading">';
286 286
       $output .= "<td>{$section['name']}</td>";
287 287
       foreach ($pref_sets as $pref_set) {
288
-        $output .= '<td>' . $pref_set . '</td>';
288
+        $output .= '<td>'.$pref_set.'</td>';
289 289
       }
290 290
       $output .= '</tr>';
291 291
       foreach ($section['elements'] as $name => $setting) {
@@ -333,11 +333,11 @@  discard block
 block discarded – undo
333 333
               $second_pref = $special_map[$name];
334 334
               $second_pref_setting = $prefs[$pref_set]['prefs']['advanced'][$category][$second_pref];
335 335
               $second_value = isset($second_pref_setting['#options']) ? $second_pref_setting['#options'][$second_pref_setting['#default_value']] : $second_pref_setting['#default_value'];
336
-              $output .= "<td>{$value} {$pref_setting['#field_suffix']} {$special_delimiter[$name]}" .
336
+              $output .= "<td>{$value} {$pref_setting['#field_suffix']} {$special_delimiter[$name]}".
337 337
                 " {$second_value} {$second_pref_setting['#field_suffix']} </td>";
338 338
             }
339 339
           }
340
-          else  {
340
+          else {
341 341
             $output .= '<td>---</td>';
342 342
           }
343 343
         }
@@ -365,12 +365,12 @@  discard block
 block discarded – undo
365 365
       );
366 366
       // Show Clear links for established preference sets
367 367
       if ($pref_set != 'generic' AND $prefs[$pref_set]['#established']) {
368
-        $output .= ' </li><li class="tab"> ' . l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/computing/clear/{$pref_set}",
368
+        $output .= ' </li><li class="tab"> '.l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/computing/clear/{$pref_set}",
369 369
           array(
370 370
             'query' => drupal_get_destination(),
371 371
             'attributes' => array(
372
-              'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the "@name" preference set. Are you sure?',
373
-                array('@name' => ucfirst($pref_set)), array(), NULL, 'boinc:account-computing-preferences') . '\')'
372
+              'onclick' => 'return confirm(\''.bts('This will remove all of your settings from the "@name" preference set. Are you sure?',
373
+                array('@name' => ucfirst($pref_set)), array(), NULL, 'boinc:account-computing-preferences').'\')'
374 374
             )
375 375
           )
376 376
         );
@@ -396,8 +396,8 @@  discard block
 block discarded – undo
396 396
         "{$path}/work" => bts('Work', array(), NULL, 'boinc:account-preferences-location')
397 397
       );
398 398
       variable_set('jump_use_js_venues-Array', 1);
399
-      drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js');
400
-      drupal_add_js(drupal_get_path('theme', 'boinc') . '/js/prefs.js', 'theme');
399
+      drupal_add_js(drupal_get_path('module', 'jump').'/jump.js');
400
+      drupal_add_js(drupal_get_path('theme', 'boinc').'/js/prefs.js', 'theme');
401 401
       
402 402
       $output .= '<div id="venue-selector" class="simple-form-controls">';
403 403
       $output .= '  <div class="form-item venue">';
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
     if (!$current_set['#established']) {
418 418
       drupal_set_message(bts(
419 419
           "No preferences found for set '@venue'. Click SAVE CHANGES below to save the following preferences to your account.",
420
-          array( '@venue' => $venue, ),
420
+          array('@venue' => $venue,),
421 421
           NULL, 'boinc:account-preferences'), 'status');
422 422
     }
423 423
     
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
       drupal_prepare_form('boincwork_projectprefs_form', $prefs[$pref_set], $form_state);
477 477
     }
478 478
     
479
-    $output .= '<h2>' . bts('Combined preferences', array(), NULL, 'boinc:account-preferences') . ' ' . l('(' . bts('Switch View', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/project') . '</h2>';
479
+    $output .= '<h2>'.bts('Combined preferences', array(), NULL, 'boinc:account-preferences').' '.l('('.bts('Switch View', array(), NULL, 'boinc:account-preferences').')', 'account/prefs/project').'</h2>';
480 480
     
481 481
     $output .= '<table class="preferences combined">';
482 482
     
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
       $output .= '<tr class="section-heading">';
487 487
       $output .= "<td>{$section['name']}</td>";
488 488
       foreach ($pref_sets as $pref_set) {
489
-        $output .= '<td>' . $pref_set . '</td>';
489
+        $output .= '<td>'.$pref_set.'</td>';
490 490
       }
491 491
       $output .= '</tr>';
492 492
       foreach ($section['elements'] as $name => $setting) {
@@ -528,12 +528,12 @@  discard block
 block discarded – undo
528 528
       $output .= l($action_text, "account/prefs/project/edit/{$pref_set}");
529 529
       // Show Clear links for established preference sets
530 530
       if ($pref_set != 'generic' AND $prefs[$pref_set]['#established']) {
531
-        $output .= ' </li><li class="tab"> ' . l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/project/clear/{$pref_set}",
531
+        $output .= ' </li><li class="tab"> '.l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/project/clear/{$pref_set}",
532 532
           array(
533 533
             'query' => drupal_get_destination(),
534 534
             'attributes' => array(
535
-              'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the "@name" preference set. Are you sure?',
536
-                array('@name' => ucfirst($pref_set)), array(), NULL, 'boinc:account-preferences-project') . '\')'
535
+              'onclick' => 'return confirm(\''.bts('This will remove all of your settings from the "@name" preference set. Are you sure?',
536
+                array('@name' => ucfirst($pref_set)), array(), NULL, 'boinc:account-preferences-project').'\')'
537 537
             )
538 538
           )
539 539
         );
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
     // Set this preference set as the one to use for any new hosts attached
550 550
     // to the user account
551 551
     boincwork_set_default_venue($venue);
552
-    drupal_set_message( bts('The primary preference set has been changed to "@set"', array('@set' => $venue), NULL, 'boinc:account-preferences-project') );
552
+    drupal_set_message(bts('The primary preference set has been changed to "@set"', array('@set' => $venue), NULL, 'boinc:account-preferences-project'));
553 553
     drupal_goto('account/prefs/project/combined');
554 554
     break;
555 555
     
@@ -568,8 +568,8 @@  discard block
 block discarded – undo
568 568
         "{$path}/work" => bts('Work', array(), NULL, 'boinc:account-preferences-location')
569 569
       );
570 570
       variable_set('jump_use_js_venues-Array', 1);
571
-      drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js');
572
-      drupal_add_js(drupal_get_path('theme', 'boinc') . '/js/prefs.js', 'theme');
571
+      drupal_add_js(drupal_get_path('module', 'jump').'/jump.js');
572
+      drupal_add_js(drupal_get_path('theme', 'boinc').'/js/prefs.js', 'theme');
573 573
       
574 574
       $output .= '<div id="venue-selector" class="simple-form-controls">';
575 575
       $output .= '  <div class="form-item venue">';
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
     if (!$current_set['#established']) {
590 590
       drupal_set_message(bts(
591 591
           "No preferences found for set '@venue'. Click SAVE CHANGES below to save the following preferences to your account.",
592
-          array( '@venue' => $venue, ),
592
+          array('@venue' => $venue,),
593 593
           NULL, 'boinc:account-preferences'), 'status');
594 594
     }
595 595
     
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
     // Edit preferences link
662 662
     $output .= '<tr>';
663 663
     $output .= '<td></td>';
664
-    $output .= '<td>' . l(bts('Edit privacy preferences', array('@project' => PROJECT), NULL, 'boinc:account-preferences-privacy'), "account/prefs/privacy/edit") . '</td>';
664
+    $output .= '<td>'.l(bts('Edit privacy preferences', array('@project' => PROJECT), NULL, 'boinc:account-preferences-privacy'), "account/prefs/privacy/edit").'</td>';
665 665
     $output .= '</tr>';
666 666
     
667 667
     $output .= '</table>';
@@ -696,15 +696,15 @@  discard block
 block discarded – undo
696 696
   switch ($type) {
697 697
   case 'all':
698 698
     //include_boinc('user/cert_all.php');
699
-    require_boinc(array('util','cert','user'));
699
+    require_boinc(array('util', 'cert', 'user'));
700 700
 
701 701
     $join = date('j F Y', $boincuser->create_time);
702 702
     $today = date('j F Y', time(0));
703 703
 
704
-    if ($border=="no") {
704
+    if ($border == "no") {
705 705
         $border = 0;
706 706
     } else {
707
-        $border=8;
707
+        $border = 8;
708 708
     }
709 709
 
710 710
     $title_font = "\"Optima,ZapfChancery\"";
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
         <tr><th align=left>Project</th><th align=left>Cobblestones</th><th align=left>Joined</th></tr>
749 749
     ";
750 750
     foreach ($boincuser->projects as $p) {
751
-        if ($p->total_credit<100) continue;
751
+        if ($p->total_credit < 100) continue;
752 752
         show_proj($p);
753 753
     }
754 754
     echo "
@@ -767,15 +767,15 @@  discard block
 block discarded – undo
767 767
   case 'account':
768 768
   default:
769 769
     //include_boinc('user/cert1.php');
770
-    require_boinc(array('util','cert'));
770
+    require_boinc(array('util', 'cert'));
771 771
 
772 772
     $join = date('j F Y', $boincuser->create_time);
773 773
     $today = date('j F Y', time(0));
774 774
 
775
-    if ($border=="no") {
775
+    if ($border == "no") {
776 776
         $border = 0;
777 777
     } else {
778
-        $border=8;
778
+        $border = 8;
779 779
     }
780 780
 
781 781
     $credit = credit_string($boincuser->total_credit, false);
@@ -1014,7 +1014,7 @@  discard block
 block discarded – undo
1014 1014
  * Page callback for host task table
1015 1015
  */
1016 1016
 function boincwork_host_task_table($host_id = NULL, $tselect = NULL, $app_id = NULL) {
1017
-  require_boinc( array('util', 'result') );
1017
+  require_boinc(array('util', 'result'));
1018 1018
 
1019 1019
   $title = bts('Tasks for computer @host_id', array('@host_id' => $host_id), NULL, 'boinc:host-task-table');
1020 1020
   drupal_set_title($title);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -204,13 +204,13 @@  discard block
 block discarded – undo
204 204
 /**
205 205
  * Implementation of hook_locale().
206 206
  */
207
-function boincwork_locale($op = 'groups', $group = NULL) {
207
+function boincwork_locale($op = 'groups', $group = null) {
208 208
   switch ($op) {
209 209
     case 'groups':
210 210
       return array('project' => bts('Project'));
211 211
     case 'info':
212 212
       $info['project']['refresh callback'] = 'boincwork_locale_refresh';
213
-      $info['project']['format'] = FALSE;
213
+      $info['project']['format'] = false;
214 214
       return $info;
215 215
   }
216 216
 }
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
     'project_specific' => array(),
227 227
   );
228 228
   boincwork_add_project_specific_prefs($form, $prefs);
229
-  return TRUE; // Meaning it completed with no issues
229
+  return true; // Meaning it completed with no issues
230 230
 }
231 231
 
232 232
 
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
   * General preferences menu callback.
239 239
   * Called when user goes to edit preferences page
240 240
   */
241
-function generalprefs_page($action = null, $venue = null, $advanced = FALSE) {
241
+function generalprefs_page($action = null, $venue = null, $advanced = false) {
242 242
   
243 243
   // Keep the venue selected across preference pages
244 244
   boincwork_select_venue($venue);
@@ -253,8 +253,8 @@  discard block
 block discarded – undo
253 253
   
254 254
   case 'clear':
255 255
     // Remove settings from this preference set
256
-    if ($venue AND $venue != 'generic') {
257
-      boincwork_save_prefs(NULL, 'general', $venue);
256
+    if ($venue and $venue != 'generic') {
257
+      boincwork_save_prefs(null, 'general', $venue);
258 258
       drupal_set_message(t('Settings for the "@name" preference set have been
259 259
         cleared', array('@name' => ucfirst($venue))));
260 260
       // Set the generic preference set as active
@@ -272,10 +272,10 @@  discard block
 block discarded – undo
272 272
       drupal_prepare_form('boincwork_generalprefs_form', $prefs[$pref_set], $form_state);
273 273
     }
274 274
 
275
-    $output .= '<p>' . bts('These apply to all BOINC projects in which you participate.', array(), NULL, 'boinc:account-preferences-computing') . '<br/>';
276
-    $output .= bts('On computers attached to multiple projects, the most recently modified preferences will be used.', array(), NULL, 'boinc:account-preferences-computing') . '</p>';
277
-    $output .= '<p>' . bts('Preferences last modified: @mod_time', array('@mod_time' => pretty_time_str($prefs['generic']['prefs']['modified']['#value'])), NULL, 'boinc:account-preferences-computing') . '</p>';
278
-    $output .= '<h2>' . bts('Combined preferences', array(), NULL, 'boinc:account-preferences') . ' ' . l('(' . bts('Switch View', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/computing') . '</h2>';
275
+    $output .= '<p>' . bts('These apply to all BOINC projects in which you participate.', array(), null, 'boinc:account-preferences-computing') . '<br/>';
276
+    $output .= bts('On computers attached to multiple projects, the most recently modified preferences will be used.', array(), null, 'boinc:account-preferences-computing') . '</p>';
277
+    $output .= '<p>' . bts('Preferences last modified: @mod_time', array('@mod_time' => pretty_time_str($prefs['generic']['prefs']['modified']['#value'])), null, 'boinc:account-preferences-computing') . '</p>';
278
+    $output .= '<h2>' . bts('Combined preferences', array(), null, 'boinc:account-preferences') . ' ' . l('(' . bts('Switch View', array(), null, 'boinc:account-preferences') . ')', 'account/prefs/computing') . '</h2>';
279 279
     
280 280
     $output .= '<table class="preferences combined">';
281 281
     
@@ -297,9 +297,9 @@  discard block
 block discarded – undo
297 297
           'daily_xfer_limit_mb' => 'daily_xfer_period_days',
298 298
         );
299 299
         $special_delimiter = array(
300
-          'start_hour' => bts('and', array(), NULL, 'boinc:account-preference'),
301
-          'net_start_hour'=> bts('and', array(), NULL, 'boinc:account-preference'),
302
-          'daily_xfer_limit_mb' => bts('every', array(), NULL, 'boinc:account-preference'),
300
+          'start_hour' => bts('and', array(), null, 'boinc:account-preference'),
301
+          'net_start_hour'=> bts('and', array(), null, 'boinc:account-preference'),
302
+          'daily_xfer_limit_mb' => bts('every', array(), null, 'boinc:account-preference'),
303 303
         );
304 304
         $special = isset($special_map[$name]);
305 305
         $very_special = in_array($name, $special_map);
@@ -314,8 +314,8 @@  discard block
 block discarded – undo
314 314
         // Output values for each preference set, again with ugly hacks for
315 315
         // time range preferences
316 316
         foreach ($pref_sets as $pref_set) {
317
-          if (($prefs[$pref_set]) AND 
318
-              $prefs[$pref_set]['#established'] AND
317
+          if (($prefs[$pref_set]) and 
318
+              $prefs[$pref_set]['#established'] and
319 319
               isset($prefs[$pref_set]['prefs']['advanced'][$category])) {
320 320
             $pref_setting = $prefs[$pref_set]['prefs']['advanced'][$category][$name];
321 321
             $value = isset($pref_setting['#options']) ? $pref_setting['#options'][$pref_setting['#default_value']] : $pref_setting['#default_value'];
@@ -358,19 +358,19 @@  discard block
 block discarded – undo
358 358
     $output .= '<tr>';
359 359
     $output .= '<td></td>';
360 360
     foreach ($pref_sets as $pref_set) {
361
-      $action_text = ($prefs[$pref_set]['#established']) ? bts('Edit', array(), NULL, 'boinc:form-edit') : bts('Add', array(), NULL, 'boinc:form-add');
361
+      $action_text = ($prefs[$pref_set]['#established']) ? bts('Edit', array(), null, 'boinc:form-edit') : bts('Add', array(), null, 'boinc:form-add');
362 362
       $output .= '<td><ul class="tab-list"><li class="first tab">';
363 363
       $output .= l($action_text, "account/prefs/computing/edit/{$pref_set}/1",
364 364
         array('fragment' => "")
365 365
       );
366 366
       // Show Clear links for established preference sets
367
-      if ($pref_set != 'generic' AND $prefs[$pref_set]['#established']) {
368
-        $output .= ' </li><li class="tab"> ' . l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/computing/clear/{$pref_set}",
367
+      if ($pref_set != 'generic' and $prefs[$pref_set]['#established']) {
368
+        $output .= ' </li><li class="tab"> ' . l(bts('Clear', array(), null, 'boinc:form-clear'), "account/prefs/computing/clear/{$pref_set}",
369 369
           array(
370 370
             'query' => drupal_get_destination(),
371 371
             'attributes' => array(
372 372
               'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the "@name" preference set. Are you sure?',
373
-                array('@name' => ucfirst($pref_set)), array(), NULL, 'boinc:account-computing-preferences') . '\')'
373
+                array('@name' => ucfirst($pref_set)), array(), null, 'boinc:account-computing-preferences') . '\')'
374 374
             )
375 375
           )
376 376
         );
@@ -390,10 +390,10 @@  discard block
 block discarded – undo
390 390
     if (function_exists('jump_quickly')) {
391 391
       $path = 'account/prefs/computing/edit';
392 392
       $venues = array(
393
-        "{$path}/generic" => bts('Generic', array(), NULL, 'boinc:account-preferences-location'),
394
-        "{$path}/home" => bts('Home', array(), NULL, 'boinc:account-preferences-location:-1:ignoreoverwrite'),
395
-        "{$path}/school" => bts('School', array(), NULL, 'boinc:account-preferences-location'),
396
-        "{$path}/work" => bts('Work', array(), NULL, 'boinc:account-preferences-location')
393
+        "{$path}/generic" => bts('Generic', array(), null, 'boinc:account-preferences-location'),
394
+        "{$path}/home" => bts('Home', array(), null, 'boinc:account-preferences-location:-1:ignoreoverwrite'),
395
+        "{$path}/school" => bts('School', array(), null, 'boinc:account-preferences-location'),
396
+        "{$path}/work" => bts('Work', array(), null, 'boinc:account-preferences-location')
397 397
       );
398 398
       variable_set('jump_use_js_venues-Array', 1);
399 399
       drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js');
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
       $output .= '  </div>';
407 407
       $output .= '</div>';
408 408
     }
409
-    $output .= drupal_get_form('boincwork_generalprefs_form', $venue, NULL, $advanced);
409
+    $output .= drupal_get_form('boincwork_generalprefs_form', $venue, null, $advanced);
410 410
     
411 411
     // If viewing the edit page for a preference set that doesn't
412 412
     // exist, inform the user that preferences are not set.
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
       drupal_set_message(bts(
419 419
           "No preferences found for set '@venue'. Click SAVE CHANGES below to save the following preferences to your account.",
420 420
           array( '@venue' => $venue, ),
421
-          NULL, 'boinc:account-preferences'), 'status');
421
+          null, 'boinc:account-preferences'), 'status');
422 422
     }
423 423
     
424 424
     break;
@@ -448,8 +448,8 @@  discard block
 block discarded – undo
448 448
   
449 449
   case 'clear':
450 450
     // Remove settings from this preference set
451
-    if ($venue AND $venue != 'generic') {
452
-      boincwork_save_prefs(NULL, 'project', $venue);
451
+    if ($venue and $venue != 'generic') {
452
+      boincwork_save_prefs(null, 'project', $venue);
453 453
       drupal_set_message(t('Settings for the "@name" preference set have been
454 454
         cleared', array('@name' => ucfirst($venue))));
455 455
       
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
       drupal_prepare_form('boincwork_projectprefs_form', $prefs[$pref_set], $form_state);
477 477
     }
478 478
     
479
-    $output .= '<h2>' . bts('Combined preferences', array(), NULL, 'boinc:account-preferences') . ' ' . l('(' . bts('Switch View', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/project') . '</h2>';
479
+    $output .= '<h2>' . bts('Combined preferences', array(), null, 'boinc:account-preferences') . ' ' . l('(' . bts('Switch View', array(), null, 'boinc:account-preferences') . ')', 'account/prefs/project') . '</h2>';
480 480
     
481 481
     $output .= '<table class="preferences combined">';
482 482
     
@@ -496,8 +496,8 @@  discard block
 block discarded – undo
496 496
         $output .= "<div class=\"description\">{$setting['description']}</div>";
497 497
         $output .= '</td>';
498 498
         foreach ($pref_sets as $pref_set) {
499
-          if (($prefs[$pref_set]) AND
500
-              $prefs[$pref_set]['#established'] AND
499
+          if (($prefs[$pref_set]) and
500
+              $prefs[$pref_set]['#established'] and
501 501
               isset($prefs[$pref_set][$category])) {
502 502
             $pref_setting = $prefs[$pref_set][$category][$name];
503 503
             $value = isset($pref_setting['#options']) ? $pref_setting['#options'][$pref_setting['#default_value']] : $pref_setting['#default_value'];
@@ -523,17 +523,17 @@  discard block
 block discarded – undo
523 523
     $output .= '<tr>';
524 524
     $output .= '<td></td>';
525 525
     foreach ($pref_sets as $pref_set) {
526
-      $action_text = ($prefs[$pref_set]['#established']) ? bts('Edit', array(), NULL, 'boinc:form-edit') : bts('Add', array(), NULL, 'boinc:form-add');
526
+      $action_text = ($prefs[$pref_set]['#established']) ? bts('Edit', array(), null, 'boinc:form-edit') : bts('Add', array(), null, 'boinc:form-add');
527 527
       $output .= '<td><ul class="tab-list"><li class="first tab">';
528 528
       $output .= l($action_text, "account/prefs/project/edit/{$pref_set}");
529 529
       // Show Clear links for established preference sets
530
-      if ($pref_set != 'generic' AND $prefs[$pref_set]['#established']) {
531
-        $output .= ' </li><li class="tab"> ' . l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/project/clear/{$pref_set}",
530
+      if ($pref_set != 'generic' and $prefs[$pref_set]['#established']) {
531
+        $output .= ' </li><li class="tab"> ' . l(bts('Clear', array(), null, 'boinc:form-clear'), "account/prefs/project/clear/{$pref_set}",
532 532
           array(
533 533
             'query' => drupal_get_destination(),
534 534
             'attributes' => array(
535 535
               'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the "@name" preference set. Are you sure?',
536
-                array('@name' => ucfirst($pref_set)), array(), NULL, 'boinc:account-preferences-project') . '\')'
536
+                array('@name' => ucfirst($pref_set)), array(), null, 'boinc:account-preferences-project') . '\')'
537 537
             )
538 538
           )
539 539
         );
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
     // Set this preference set as the one to use for any new hosts attached
550 550
     // to the user account
551 551
     boincwork_set_default_venue($venue);
552
-    drupal_set_message( bts('The primary preference set has been changed to "@set"', array('@set' => $venue), NULL, 'boinc:account-preferences-project') );
552
+    drupal_set_message( bts('The primary preference set has been changed to "@set"', array('@set' => $venue), null, 'boinc:account-preferences-project') );
553 553
     drupal_goto('account/prefs/project/combined');
554 554
     break;
555 555
     
@@ -562,10 +562,10 @@  discard block
 block discarded – undo
562 562
     if (function_exists('jump_quickly')) {
563 563
       $path = 'account/prefs/project/edit';
564 564
       $venues = array(
565
-        "{$path}/generic" => bts('Generic', array(), NULL, 'boinc:account-preferences-location'),
566
-        "{$path}/home" => bts('Home', array(), NULL, 'boinc:account-preferences-location:-1:ignoreoverwrite'),
567
-        "{$path}/school" => bts('School', array(), NULL, 'boinc:account-preferences-location'),
568
-        "{$path}/work" => bts('Work', array(), NULL, 'boinc:account-preferences-location')
565
+        "{$path}/generic" => bts('Generic', array(), null, 'boinc:account-preferences-location'),
566
+        "{$path}/home" => bts('Home', array(), null, 'boinc:account-preferences-location:-1:ignoreoverwrite'),
567
+        "{$path}/school" => bts('School', array(), null, 'boinc:account-preferences-location'),
568
+        "{$path}/work" => bts('Work', array(), null, 'boinc:account-preferences-location')
569 569
       );
570 570
       variable_set('jump_use_js_venues-Array', 1);
571 571
       drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js');
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
       drupal_set_message(bts(
591 591
           "No preferences found for set '@venue'. Click SAVE CHANGES below to save the following preferences to your account.",
592 592
           array( '@venue' => $venue, ),
593
-          NULL, 'boinc:account-preferences'), 'status');
593
+          null, 'boinc:account-preferences'), 'status');
594 594
     }
595 595
     
596 596
     break;
@@ -646,7 +646,7 @@  discard block
 block discarded – undo
646 646
       foreach ($section as $name => $setting) {
647 647
         if ($name{0} == '#') continue;
648 648
         $value = isset($setting['#default_value']) ? $setting['#default_value'] : '';
649
-        if ($value AND isset($setting['#options'])) $value = $setting['#options'][$value];
649
+        if ($value and isset($setting['#options'])) $value = $setting['#options'][$value];
650 650
         elseif ($value == '') $value = '---';
651 651
         if (!isset($setting['#title'])) $setting['#title'] = '';
652 652
         if (!isset($setting['#description'])) $setting['#description'] = '';
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
     // Edit preferences link
662 662
     $output .= '<tr>';
663 663
     $output .= '<td></td>';
664
-    $output .= '<td>' . l(bts('Edit privacy preferences', array('@project' => PROJECT), NULL, 'boinc:account-preferences-privacy'), "account/prefs/privacy/edit") . '</td>';
664
+    $output .= '<td>' . l(bts('Edit privacy preferences', array('@project' => PROJECT), null, 'boinc:account-preferences-privacy'), "account/prefs/privacy/edit") . '</td>';
665 665
     $output .= '</tr>';
666 666
     
667 667
     $output .= '</table>';
@@ -893,17 +893,17 @@  discard block
 block discarded – undo
893 893
 function boincwork_host_log($host_id = null) {
894 894
   $root_log_dir = variable_get('boinc_host_sched_logs_dir', '');
895 895
   $log = '';
896
-  if ($root_log_dir AND $host_id) {
897
-    $subdir = substr($host_id, 0, -3) OR $subdir = 0;
896
+  if ($root_log_dir and $host_id) {
897
+    $subdir = substr($host_id, 0, -3) or $subdir = 0;
898 898
     $log = implode('/', array($root_log_dir, $subdir, $host_id));
899 899
   }
900
-  if ($log AND file_exists($log)) {
900
+  if ($log and file_exists($log)) {
901 901
     header('Content-type: text/plain');
902 902
     include($log);
903 903
   }
904 904
 }
905 905
 
906
-function boincwork_host_set_venue($host_id = NULL, $venue = NULL) {
906
+function boincwork_host_set_venue($host_id = null, $venue = null) {
907 907
   global $user;
908 908
   $account = user_load($user->uid);
909 909
   db_set_active('boinc');
@@ -912,27 +912,27 @@  discard block
 block discarded – undo
912 912
     "SELECT userid FROM {host} WHERE id = '%d'",
913 913
     $host_id
914 914
   ));
915
-  if ($host_owner AND $host_owner == $account->boincuser_id) {
915
+  if ($host_owner and $host_owner == $account->boincuser_id) {
916 916
     $updated = db_query(
917 917
       "UPDATE {host} SET venue = '%s' WHERE id = '%d'",
918 918
       $venue, $host_id
919 919
     );
920 920
     if ($updated) {
921 921
       drupal_set_message(
922
-        bts('The location for this host has been updated.', array(), NULL, 'boinc:account-host-details')
923
-        . bts('This will take effect next time the host contacts the project.', array(), NULL, 'boinc:account-host-details')
922
+        bts('The location for this host has been updated.', array(), null, 'boinc:account-host-details')
923
+        . bts('This will take effect next time the host contacts the project.', array(), null, 'boinc:account-host-details')
924 924
       );
925 925
     }
926 926
     else {
927 927
       drupal_set_message(
928
-        bts('Unable to save changes to this host for some reason!', array(), NULL, 'boinc:account-host-details'),
928
+        bts('Unable to save changes to this host for some reason!', array(), null, 'boinc:account-host-details'),
929 929
         'error'
930 930
       );
931 931
     }
932 932
   }
933 933
   else {
934 934
     drupal_set_message(
935
-      bts('You are not allowed to make changes to this host.', array(), NULL, 'boinc:account-host-details'),
935
+      bts('You are not allowed to make changes to this host.', array(), null, 'boinc:account-host-details'),
936 936
       'warning'
937 937
     );
938 938
   }
@@ -1001,8 +1001,8 @@  discard block
 block discarded – undo
1001 1001
 /**
1002 1002
  * Page callback for user account task table
1003 1003
  */
1004
-function boincwork_account_task_table($tselect = NULL, $app_id = NULL) {
1005
-  $title = bts('Tasks for your account', array(), NULL, 'boinc:account-task-table');
1004
+function boincwork_account_task_table($tselect = null, $app_id = null) {
1005
+  $title = bts('Tasks for your account', array(), null, 'boinc:account-task-table');
1006 1006
   drupal_set_title($title);
1007 1007
 
1008 1008
   global $user;
@@ -1013,14 +1013,14 @@  discard block
 block discarded – undo
1013 1013
 /**
1014 1014
  * Page callback for host task table
1015 1015
  */
1016
-function boincwork_host_task_table($host_id = NULL, $tselect = NULL, $app_id = NULL) {
1016
+function boincwork_host_task_table($host_id = null, $tselect = null, $app_id = null) {
1017 1017
   require_boinc( array('util', 'result') );
1018 1018
 
1019
-  $title = bts('Tasks for computer @host_id', array('@host_id' => $host_id), NULL, 'boinc:host-task-table');
1019
+  $title = bts('Tasks for computer @host_id', array('@host_id' => $host_id), null, 'boinc:host-task-table');
1020 1020
   drupal_set_title($title);
1021 1021
 
1022 1022
   if (is_null($host_id)) {
1023
-    drupal_set_message(bts('ERROR: Invalid host ID', array(), NULL, 'boinc:host-task-table'), 'error');
1023
+    drupal_set_message(bts('ERROR: Invalid host ID', array(), null, 'boinc:host-task-table'), 'error');
1024 1024
     return '';
1025 1025
   }
1026 1026
 
@@ -1030,12 +1030,12 @@  discard block
 block discarded – undo
1030 1030
 /**
1031 1031
  * Page callback for workunit task table
1032 1032
  */
1033
-function boincwork_workunit_task_table($workunit_id = NULL, $tselect = NULL, $app_id = NULL) {
1034
-  $title = bts('Tasks for computer @workunit_id', array('@workunit_id' => $workunit_id), NULL, 'boinc:workunit-task-table');
1033
+function boincwork_workunit_task_table($workunit_id = null, $tselect = null, $app_id = null) {
1034
+  $title = bts('Tasks for computer @workunit_id', array('@workunit_id' => $workunit_id), null, 'boinc:workunit-task-table');
1035 1035
   drupal_set_title($title);
1036 1036
 
1037 1037
   if (is_null($workunit_id)) {
1038
-    drupal_set_message(bts('ERROR: Invalid workunit ID', array(), NULL, 'boinc:workunit-task-table'), 'error');
1038
+    drupal_set_message(bts('ERROR: Invalid workunit ID', array(), null, 'boinc:workunit-task-table'), 'error');
1039 1039
     return '';
1040 1040
   }
1041 1041
   
@@ -1061,7 +1061,7 @@  discard block
 block discarded – undo
1061 1061
  */
1062 1062
 function boincwork_select_venue(&$venue) {
1063 1063
   if (!$venue) {
1064
-    $active_venue = isset($_SESSION['prefs venue']) ? $_SESSION['prefs venue'] : NULL;
1064
+    $active_venue = isset($_SESSION['prefs venue']) ? $_SESSION['prefs venue'] : null;
1065 1065
     if ($active_venue) {
1066 1066
       $venue = $active_venue;
1067 1067
       //unset($_SESSION['prefs venue']);
Please login to merge, or discard this patch.