Passed
Push — dpa_docker_wrapper12 ( e18bd7 )
by David
08:59
created
drupal/sites/default/settings.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -114,10 +114,10 @@  discard block
 block discarded – undo
114 114
  */
115 115
 require_once('dbconfig.php');
116 116
 if (!isset($dbserver) || empty($dbserver))
117
-  $dbserver='localhost';
117
+    $dbserver='localhost';
118 118
 $db_url = array(
119
-  'default' => "{$dbtype}://{$dbuser}:".urlencode($dbpass)."@{$dbserver}/{$dbname}",
120
-  'boinc_rw' => "{$boinc_rw_dbtype}://{$boinc_rw_dbuser}:".urlencode($boinc_rw_dbpass)."@{$boinc_rw_dbserver}/{$boinc_rw_dbname}"
119
+    'default' => "{$dbtype}://{$dbuser}:".urlencode($dbpass)."@{$dbserver}/{$dbname}",
120
+    'boinc_rw' => "{$boinc_rw_dbtype}://{$boinc_rw_dbuser}:".urlencode($boinc_rw_dbpass)."@{$boinc_rw_dbserver}/{$boinc_rw_dbname}"
121 121
 );
122 122
 $db_prefix = '';
123 123
 
@@ -125,10 +125,10 @@  discard block
 block discarded – undo
125 125
 // 'boinc_rw' entry as 'boinc_ro'.
126 126
 
127 127
 if (isset($boinc_ro_dbtype) && isset($boinc_ro_dbuser) && isset($boinc_ro_dbpass) && isset($boinc_ro_dbserver) && isset($boinc_ro_dbname)) {
128
-  $db_url['boinc_ro'] = "{$boinc_ro_dbtype}://{$boinc_ro_dbuser}:".urlencode($boinc_ro_dbpass)."@{$boinc_ro_dbserver}/{$boinc_ro_dbname}";
128
+    $db_url['boinc_ro'] = "{$boinc_ro_dbtype}://{$boinc_ro_dbuser}:".urlencode($boinc_ro_dbpass)."@{$boinc_ro_dbserver}/{$boinc_ro_dbname}";
129 129
 }
130 130
 else {
131
-  $db_url['boinc_ro'] = $db_url['boinc_rw'];
131
+    $db_url['boinc_ro'] = $db_url['boinc_rw'];
132 132
 }
133 133
 
134 134
 /**
@@ -216,5 +216,5 @@  discard block
 block discarded – undo
216 216
  */
217 217
 
218 218
 if (stream_resolve_include_path('settings.local.php')) {
219
-  include 'settings.local.php';
219
+    include 'settings.local.php';
220 220
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -126,8 +126,7 @@
 block discarded – undo
126 126
 
127 127
 if (isset($boinc_ro_dbtype) && isset($boinc_ro_dbuser) && isset($boinc_ro_dbpass) && isset($boinc_ro_dbserver) && isset($boinc_ro_dbname)) {
128 128
   $db_url['boinc_ro'] = "{$boinc_ro_dbtype}://{$boinc_ro_dbuser}:".urlencode($boinc_ro_dbpass)."@{$boinc_ro_dbserver}/{$boinc_ro_dbname}";
129
-}
130
-else {
129
+} else {
131 130
   $db_url['boinc_ro'] = $db_url['boinc_rw'];
132 131
 }
133 132
 
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
  */
115 115
 require_once('dbconfig.php');
116 116
 if (!isset($dbserver) || empty($dbserver))
117
-  $dbserver='localhost';
117
+  $dbserver = 'localhost';
118 118
 $db_url = array(
119 119
   'default' => "{$dbtype}://{$dbuser}:".urlencode($dbpass)."@{$dbserver}/{$dbname}",
120 120
   'boinc_rw' => "{$boinc_rw_dbtype}://{$boinc_rw_dbuser}:".urlencode($boinc_rw_dbpass)."@{$boinc_rw_dbserver}/{$boinc_rw_dbname}"
@@ -162,14 +162,14 @@  discard block
 block discarded – undo
162 162
  * settings are used there. Settings defined here should not be
163 163
  * duplicated there so as to avoid conflict issues.
164 164
  */
165
-ini_set('session.cache_expire',     200000);
166
-ini_set('session.cache_limiter',    'none');
167
-ini_set('session.cookie_lifetime',  2000000);
168
-ini_set('session.gc_maxlifetime',   200000);
169
-ini_set('session.save_handler',     'user');
165
+ini_set('session.cache_expire', 200000);
166
+ini_set('session.cache_limiter', 'none');
167
+ini_set('session.cookie_lifetime', 2000000);
168
+ini_set('session.gc_maxlifetime', 200000);
169
+ini_set('session.save_handler', 'user');
170 170
 ini_set('session.use_only_cookies', 1);
171
-ini_set('session.use_trans_sid',    0);
172
-ini_set('url_rewriter.tags',        '');
171
+ini_set('session.use_trans_sid', 0);
172
+ini_set('url_rewriter.tags', '');
173 173
 ini_set('memory_limit', '128M');
174 174
 ini_set('post_max_size', '8MB');
175 175
 ini_set('upload_max_filesize', '8MB');
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boincwork/includes/boincwork.helpers.inc 5 patches
Braces   +41 added lines, -72 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) {
@@ -875,8 +864,7 @@  discard block
 block discarded – undo
875 864
     db_set_active('boinc_rw');
876 865
     $result = db_query("UPDATE user SET project_prefs = '{$boincuser->project_prefs}' WHERE id = '{$boincuser->id}'");
877 866
     db_set_active('default');
878
-  }
879
-  else {
867
+  } else {
880 868
     $main_prefs = array('global_preferences' => $main_prefs);
881 869
     $boincuser->global_prefs = save_configuration($main_prefs);
882 870
     db_set_active('boinc_rw');
@@ -963,8 +951,7 @@  discard block
 block discarded – undo
963 951
         NULL, 'boinc:ignore-user-add'),
964 952
       'status');
965 953
     drupal_goto();
966
-  }
967
-  else {
954
+  } else {
968 955
     drupal_not_found();
969 956
   }// endif iuid
970 957
 }
@@ -1027,15 +1014,13 @@  discard block
 block discarded – undo
1027 1014
       // Process nested form elements
1028 1015
       $parents[] = $field;
1029 1016
       boincwork_validate_form($rules, $values[$field], $parents);
1030
-    }
1031
-    else {
1017
+    } else {
1032 1018
       if ($parents) {
1033 1019
         // form_set_error() identifies nested form elements with '][' as a
1034 1020
         // delimiter between each parent and child element
1035 1021
         $parents[] = $field;
1036 1022
         $form_field = implode('][', $parents);
1037
-      }
1038
-      else {
1023
+      } else {
1039 1024
         $form_field = $field;
1040 1025
       }
1041 1026
       if (isset($rules['datatype']) AND !boincwork_validate_datatype($values[$field], $rules['datatype'])) {
@@ -1118,8 +1103,7 @@  discard block
 block discarded – undo
1118 1103
   //  load_configuration(): Convert structured text/xml to array
1119 1104
   //------------------------------------------------------------------------------------------------
1120 1105
   
1121
-  function load_configuration($text)
1122
-  {
1106
+  function load_configuration($text) {
1123 1107
       if (preg_match('/^\<\?xml .*\?\>$/i', $text)) return null;
1124 1108
       if ($xml = text_to_xml($text)) return xml_to_array($xml);
1125 1109
       return false;
@@ -1129,8 +1113,7 @@  discard block
 block discarded – undo
1129 1113
   //  save_configuration(): Convert array to structured text/xml
1130 1114
   //------------------------------------------------------------------------------------------------
1131 1115
   
1132
-  function save_configuration($array)
1133
-  {
1116
+  function save_configuration($array) {
1134 1117
       if ($xml = array_to_xml($array)) return xml_to_text($xml, false, true);
1135 1118
       return false;
1136 1119
   }
@@ -1162,26 +1145,22 @@  discard block
 block discarded – undo
1162 1145
               $ordered_array[$item['@position']] = array(
1163 1146
                 $name => $item
1164 1147
               );
1165
-            }
1166
-            else {
1148
+            } else {
1167 1149
               $unordered_array[] = array(
1168 1150
                 $name => $item
1169 1151
               );
1170 1152
             }
1171 1153
           }
1172
-        }
1173
-        elseif (isset($value['@position'])) {
1154
+        } elseif (isset($value['@position'])) {
1174 1155
           $ordered_array[$value['@position']] = array(
1175 1156
             $name => $value
1176 1157
           );
1177
-        }
1178
-        else {
1158
+        } else {
1179 1159
           $unordered_array[] = array(
1180 1160
             $name => $value
1181 1161
           );
1182 1162
         }
1183
-      }
1184
-      else {
1163
+      } else {
1185 1164
         $unordered_array[] = array(
1186 1165
           $name => $value
1187 1166
         );
@@ -1267,8 +1246,7 @@  discard block
 block discarded – undo
1267 1246
   //  xml_to_text(): Convert an XML DOM object to string format
1268 1247
   //------------------------------------------------------------------------------------------------
1269 1248
   
1270
-  function xml_to_text($xml, $include_xml_declaration = true, $add_carriage_returns = false)
1271
-  {
1249
+  function xml_to_text($xml, $include_xml_declaration = true, $add_carriage_returns = false) {
1272 1250
       $xml->formatOutput = true;
1273 1251
       $text = $xml->saveXML();
1274 1252
       if (!$include_xml_declaration) {
@@ -1311,10 +1289,14 @@  discard block
 block discarded – undo
1311 1289
               $sibling = $node->nextSibling;
1312 1290
               
1313 1291
               // Determine if this node forms a set with siblings (share a node name)
1314
-              while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->nextSibling;
1292
+              while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) {
1293
+                  $sibling = $sibling->nextSibling;
1294
+              }
1315 1295
               if (!$sibling) {
1316 1296
                   $sibling = $node->previousSibling;
1317
-                  while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->previousSibling;
1297
+                  while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) {
1298
+                      $sibling = $sibling->previousSibling;
1299
+                  }
1318 1300
               }
1319 1301
               
1320 1302
               if ($sibling) {
@@ -1409,8 +1391,7 @@  discard block
 block discarded – undo
1409 1391
       . ' computers. Computers will be displayed when they have earned their'
1410 1392
       . ' first credits.', array(), NULL, 'boinc:host-list') . '</p>';
1411 1393
     }
1412
-  }
1413
-  else {
1394
+  } else {
1414 1395
     $output .=  '<h2>' . bts('Computers hidden', array(), NULL, 'boinc:host-list') . '</h2>';
1415 1396
     $output .=  '<p>' . bts('This user has chosen not to show information'
1416 1397
     . ' about their computers.', array(), NULL, 'boinc:host-list') . '</p>';
@@ -1570,8 +1551,7 @@  discard block
 block discarded – undo
1570 1551
     if (!$received_time) {
1571 1552
       if (time() < $deadline) {
1572 1553
         $output = '<span class="on-time">' . $output . '</span>';
1573
-      }
1574
-      else {
1554
+      } else {
1575 1555
         $output = '<span class="past-due">' . $output . '</span>';
1576 1556
       }
1577 1557
     }
@@ -1666,11 +1646,9 @@  discard block
 block discarded – undo
1666 1646
   // Use userid, hostid, or workunitid
1667 1647
   if ($category==0) {
1668 1648
     $sqlall .= " WHERE r.userid='%s' ";
1669
-  }
1670
-  elseif ($category==1) {
1649
+  } elseif ($category==1) {
1671 1650
     $sqlall .= " WHERE r.workunitid='%s' ";
1672
-  }
1673
-  elseif ($category==2) {
1651
+  } elseif ($category==2) {
1674 1652
     $sqlall .= " WHERE r.hostid='%s' ";
1675 1653
   }
1676 1654
   $sqlall .= " ORDER BY user_friendly_name";
@@ -1710,8 +1688,7 @@  discard block
 block discarded – undo
1710 1688
       }// if mystate
1711 1689
 
1712 1690
     }// while
1713
-  }
1714
-  else {
1691
+  } else {
1715 1692
   }
1716 1693
   
1717 1694
   // Entry for all applications.
@@ -1805,11 +1782,9 @@  discard block
 block discarded – undo
1805 1782
   // Use userid, hostid, or workunitid
1806 1783
   if ($category==0) {
1807 1784
     $sqlwhere[] = "r.userid = '%s'";
1808
-  }
1809
-  elseif ($category==1) {
1785
+  } elseif ($category==1) {
1810 1786
     $sqlwhere[] = "r.workunitid = '%s'";
1811
-  }
1812
-  elseif ($category==2) {
1787
+  } elseif ($category==2) {
1813 1788
     $sqlwhere[] = "r.hostid = '%s'";
1814 1789
   }
1815 1790
 
@@ -1837,8 +1812,7 @@  discard block
 block discarded – undo
1837 1812
     $sqlwhere[] = "r.appid = '%s'";
1838 1813
     if ($sqlwhere)  $sqlsub .= " WHERE " . implode(' AND ', $sqlwhere);
1839 1814
     $dbres_sub = pager_query( $sqlsub . tablesort_sql($resultheader), $tablerows, 0, NULL, $queryid, $app_id);
1840
-  }
1841
-  else {
1815
+  } else {
1842 1816
     if ($sqlwhere)  $sqlsub .= " WHERE " . implode(' AND ', $sqlwhere);
1843 1817
     $dbres_sub = pager_query( $sqlsub . tablesort_sql($resultheader), $tablerows, 0, NULL, $queryid);
1844 1818
   }
@@ -1873,19 +1847,16 @@  discard block
 block discarded – undo
1873 1847
         $resultdata[] = array_values($prettyresult);
1874 1848
       }
1875 1849
     }// while
1876
-  }
1877
-  else {
1850
+  } else {
1878 1851
   }
1879 1852
   // Begin result navigation
1880 1853
 
1881 1854
   // Set pathprefix based on type
1882 1855
   if ($category==0) {
1883 1856
     $pathprefix = 'account/tasks';
1884
-  }
1885
-  elseif ($category==1) {
1857
+  } elseif ($category==1) {
1886 1858
     $pathprefix = 'workunit/' . $queryid . '/tasks';
1887
-  }
1888
-  elseif ($category==2) {
1859
+  } elseif ($category==2) {
1889 1860
     $pathprefix = 'host/' . $queryid . '/tasks';
1890 1861
   }
1891 1862
   // Need an "All" tab as well, maps to app_id of zero.
@@ -1895,8 +1866,7 @@  discard block
 block discarded – undo
1895 1866
     $mypath = $pathprefix . '/' . $state . '/' . $app_id;
1896 1867
     if ($state==STATE_ALL) {
1897 1868
       $ltext = '<span class="tab task-app-name">' . bts('All', array(), NULL, 'boinc:task-table') . ' (' . $numstates . ')</span>';
1898
-    }
1899
-    else {
1869
+    } else {
1900 1870
       $ltext = '<span class="tab">' . bts($state_hnames[$state], array(), NULL, 'boinc:task-table') . ' (' . $numstates . ')</span>';
1901 1871
     }
1902 1872
     $myitem = array(
@@ -1984,8 +1954,7 @@  discard block
 block discarded – undo
1984 1954
       // that is not handled by the above case statements.
1985 1955
       if ($appverid < 0) {
1986 1956
         return "Unknown Anonymous platform";
1987
-      }
1988
-      else {
1957
+      } else {
1989 1958
         $prettyv = sprintf("%d.%02d", $vernum/100, $vernum%100);
1990 1959
         $prettyc = ($plan_class) ? "($av->plan_class)" : '';
1991 1960
         return "v$prettyv $prettyc $plfm";
Please login to merge, or discard this patch.
Indentation   +865 added lines, -865 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', _boinctranslate_supertrim($title));
411 411
         $title = i18nstrings('project:prefs_xml', _boinctranslate_supertrim($title));
412
-      }
413
-      if ($description) {
412
+        }
413
+        if ($description) {
414 414
         i18nstrings_update('project:prefs_xml', _boinctranslate_supertrim($description));
415 415
         $description = i18nstrings('project:prefs_xml', _boinctranslate_supertrim($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', _boinctranslate_supertrim($title));
459 459
         $title = i18nstrings('project:prefs_xml', _boinctranslate_supertrim($title));
460
-      }
461
-      if ($description) {
460
+        }
461
+        if ($description) {
462 462
         i18nstrings_update('project:prefs_xml', _boinctranslate_supertrim($description));
463 463
         $description = i18nstrings('project:prefs_xml', _boinctranslate_supertrim($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', _boinctranslate_supertrim($title));
516 516
         $title = i18nstrings('project:prefs_xml', _boinctranslate_supertrim($title));
517
-      }
518
-      if ($description) {
517
+        }
518
+        if ($description) {
519 519
         i18nstrings_update('project:prefs_xml', _boinctranslate_supertrim($description));
520 520
         $description = i18nstrings('project:prefs_xml', _boinctranslate_supertrim($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', _boinctranslate_supertrim($title));
540 540
         $title = i18nstrings('project:prefs_xml', _boinctranslate_supertrim($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', _boinctranslate_supertrim($title));
600 600
         $title = i18nstrings('project:prefs_xml', _boinctranslate_supertrim($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', _boinctranslate_supertrim($title));
629 629
         $title = i18nstrings('project:prefs_xml', _boinctranslate_supertrim($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,104 +786,104 @@  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 == 'project') {
850
+    // Set modified time
851
+    if ($type == 'project') {
852 852
     if (!isset($main_prefs['modified'])) {
853
-      $main_prefs = array_merge(array('modified' => 0), $main_prefs);
853
+        $main_prefs = array_merge(array('modified' => 0), $main_prefs);
854 854
     }
855 855
     $main_prefs['modified'] = time();
856
-  } else {
856
+    } else {
857 857
     if (!isset($main_prefs['mod_time'])) {
858
-      $main_prefs = array_merge(array('mod_time' => 0), $main_prefs);
858
+        $main_prefs = array_merge(array('mod_time' => 0), $main_prefs);
859 859
     }
860 860
     $main_prefs['mod_time'] = time();
861 861
     // unset source information, the Client will fill this in again
862 862
     if (isset($main_prefs['source_project'])) {
863
-      unset($main_prefs['source_project']);
863
+        unset($main_prefs['source_project']);
864 864
     }
865 865
     if (isset($main_prefs['source_scheduler'])) {
866
-      unset($main_prefs['source_scheduler']);
866
+        unset($main_prefs['source_scheduler']);
867
+    }
867 868
     }
868
-  }
869 869
 
870
-  // Convert prefs back to XML and save to database
871
-  $result = null;
872
-  if ($type == 'project') {
870
+    // Convert prefs back to XML and save to database
871
+    $result = null;
872
+    if ($type == 'project') {
873 873
     $main_prefs = array('project_preferences' => $main_prefs);
874 874
     $boincuser->project_prefs = save_configuration($main_prefs);
875 875
     db_set_active('boinc_rw');
876 876
     $result = db_query("UPDATE user SET project_prefs = '{$boincuser->project_prefs}' WHERE id = '{$boincuser->id}'");
877 877
     db_set_active('default');
878
-  }
879
-  else {
878
+    }
879
+    else {
880 880
     $main_prefs = array('global_preferences' => $main_prefs);
881 881
     $boincuser->global_prefs = save_configuration($main_prefs);
882 882
     db_set_active('boinc_rw');
883 883
     $result = db_query("UPDATE user SET global_prefs = '{$boincuser->global_prefs}' WHERE id = '{$boincuser->id}'");
884 884
     db_set_active('default');
885
-  }
886
-  return $result;
885
+    }
886
+    return $result;
887 887
 }
888 888
 
889 889
 
@@ -900,9 +900,9 @@  discard block
 block discarded – undo
900 900
  *username. Called from privacy preference form.
901 901
  */
902 902
 function boincwork_ignore_user_add_user_username($name = NULL) {
903
-  global $user;
903
+    global $user;
904 904
 
905
-  if (isset($name)) {
905
+    if (isset($name)) {
906 906
     // Get the BOINC ID from the name string, and lookup the
907 907
     // corresponding drupal user.
908 908
     $boincname = substr($name, 0, strrpos($name, '_'));
@@ -911,84 +911,84 @@  discard block
 block discarded – undo
911 911
     $iuid = get_drupal_id($boincid);
912 912
 
913 913
     if ($user->uid == $iuid) {
914
-      drupal_set_message(bts('You can\'t add yourself to your own ignore list.', array(), NULL, 'boinc:ignore-user-error-message'), 'error');
915
-      drupal_goto('account/prefs/privacy');
914
+        drupal_set_message(bts('You can\'t add yourself to your own ignore list.', array(), NULL, 'boinc:ignore-user-error-message'), 'error');
915
+        drupal_goto('account/prefs/privacy');
916 916
     }
917 917
 
918 918
     if (is_numeric($iuid) && $iuid > 0) {
919
-      if (!db_result(db_query('SELECT COUNT(iuid) FROM {ignore_user} WHERE uid = %d AND iuid = %d', $user->uid, $iuid))) {
919
+        if (!db_result(db_query('SELECT COUNT(iuid) FROM {ignore_user} WHERE uid = %d AND iuid = %d', $user->uid, $iuid))) {
920 920
         db_query('INSERT INTO {ignore_user} (uid, iuid) VALUES (%d, %d)', $user->uid, $iuid);
921
-      }// endif db_result
921
+        }// endif db_result
922 922
 
923
-      if (module_exists('pm_block_user')) {
923
+        if (module_exists('pm_block_user')) {
924 924
         if (!db_result(db_query('SELECT COUNT(recipient) FROM {pm_block_user} WHERE author = %d AND recipient = %d', $iuid, $user->uid))) {
925
-          db_query('INSERT INTO {pm_block_user} (author, recipient) VALUES (%d, %d)', $iuid, $user->uid);
925
+            db_query('INSERT INTO {pm_block_user} (author, recipient) VALUES (%d, %d)', $iuid, $user->uid);
926 926
         }// endif db_result
927
-      }// endif module_exists('pm_block_user')
927
+        }// endif module_exists('pm_block_user')
928 928
 
929 929
     }// endif $iuid
930
-  }
930
+    }
931 931
 }
932 932
 
933 933
 /**
934 934
  * Add another user's UID to the current user's ignore list.
935 935
  */
936 936
 function boincwork_ignore_user_add_user($iuid = NULL) {
937
-  global $user;
937
+    global $user;
938 938
 
939
-  if ($user->uid == $iuid) {
939
+    if ($user->uid == $iuid) {
940 940
     drupal_set_message(bts('You can\'t add yourself to your own ignore list.', array(), NULL, 'boinc:ignore-user-error-message'), 'error');
941 941
     drupal_goto();
942
-  }
942
+    }
943 943
 
944
-  $otheraccount = user_load($iuid);
944
+    $otheraccount = user_load($iuid);
945 945
 
946
-  if (is_numeric($iuid) && $iuid > 0) {
946
+    if (is_numeric($iuid) && $iuid > 0) {
947 947
     if (!db_result(db_query('SELECT COUNT(iuid) FROM {ignore_user} WHERE uid = %d AND iuid = %d', $user->uid, $iuid))) {
948
-      db_query('INSERT INTO {ignore_user} (uid, iuid) VALUES (%d, %d)', $user->uid, $iuid);
948
+        db_query('INSERT INTO {ignore_user} (uid, iuid) VALUES (%d, %d)', $user->uid, $iuid);
949 949
     }// endif db_result
950 950
 
951 951
     if (module_exists('pm_block_user')) {
952
-      if (!db_result(db_query('SELECT COUNT(recipient) FROM {pm_block_user} WHERE author = %d AND recipient = %d', $iuid, $user->uid))) {
952
+        if (!db_result(db_query('SELECT COUNT(recipient) FROM {pm_block_user} WHERE author = %d AND recipient = %d', $iuid, $user->uid))) {
953 953
         db_query('INSERT INTO {pm_block_user} (author, recipient) VALUES (%d, %d)', $iuid, $user->uid);
954
-      }// endif db_result
954
+        }// endif db_result
955 955
     }// endif module_exists('pm_block_user')
956 956
 
957 957
     drupal_set_message(
958
-      bts('@username has been added to your ignore list. See your !privacy_preferences for more details.',
958
+        bts('@username has been added to your ignore list. See your !privacy_preferences for more details.',
959 959
         array(
960
-          '@username' => $otheraccount->boincuser_name,
961
-          '!privacy_preferences' => l(bts('privacy preferences', array(), NULL, 'boinc:ignore-user-add'), 'account/prefs/privacy'),
960
+            '@username' => $otheraccount->boincuser_name,
961
+            '!privacy_preferences' => l(bts('privacy preferences', array(), NULL, 'boinc:ignore-user-add'), 'account/prefs/privacy'),
962 962
         ),
963 963
         NULL, 'boinc:ignore-user-add'),
964
-      'status');
964
+        'status');
965 965
     drupal_goto();
966
-  }
967
-  else {
966
+    }
967
+    else {
968 968
     drupal_not_found();
969
-  }// endif iuid
969
+    }// endif iuid
970 970
 }
971 971
 
972 972
 /**
973 973
  * Remove user from user's ignore list.
974 974
  */
975 975
 function boincwork_ignore_user_remove_user($iuid = NULL) {
976
-  global $user;
977
-  $otheraccount = user_load($iuid);
976
+    global $user;
977
+    $otheraccount = user_load($iuid);
978 978
 
979
-  db_query('DELETE FROM {ignore_user} WHERE uid = %d AND iuid = %d', $user->uid, $iuid);
980
-  if (module_exists('pm_block_user')) {
979
+    db_query('DELETE FROM {ignore_user} WHERE uid = %d AND iuid = %d', $user->uid, $iuid);
980
+    if (module_exists('pm_block_user')) {
981 981
     db_query('DELETE FROM {pm_block_user} WHERE author = %d AND recipient = %d', $iuid, $user->uid);
982
-  }// endif module_exists
983
-  drupal_set_message(
982
+    }// endif module_exists
983
+    drupal_set_message(
984 984
     bts('@username has been removed from your ignore list. See your !privacy_preferences for more details.',
985
-      array(
985
+        array(
986 986
         '@username' => $otheraccount->boincuser_name,
987 987
         '!privacy_preferences' => l(bts('privacy preferences', array(), NULL, 'boinc:ignore-user-add'), 'account/prefs/privacy'),
988
-      ),
989
-      NULL, 'boinc:ignore-user-add'),
988
+        ),
989
+        NULL, 'boinc:ignore-user-add'),
990 990
     'status');
991
-  drupal_goto('account/prefs/privacy');
991
+    drupal_goto('account/prefs/privacy');
992 992
 }
993 993
 
994 994
 /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
@@ -1002,18 +1002,18 @@  discard block
 block discarded – undo
1002 1002
  */
1003 1003
 function boincwork_load_privacyconsenttypes() {
1004 1004
 
1005
-  db_set_active('boinc_rw');
1006
-  $db_result = db_query("SELECT id,shortname,description FROM consent_type WHERE enabled=1 AND privacypref=1 ORDER by project_specific ASC");
1007
-  db_set_active('drupal');
1005
+    db_set_active('boinc_rw');
1006
+    $db_result = db_query("SELECT id,shortname,description FROM consent_type WHERE enabled=1 AND privacypref=1 ORDER by project_specific ASC");
1007
+    db_set_active('drupal');
1008 1008
 
1009
-  if ($db_result) {
1009
+    if ($db_result) {
1010 1010
     $consent_types = array();
1011 1011
     while ($result = db_fetch_array($db_result)) {
1012
-      $consent_types[] = $result;
1012
+        $consent_types[] = $result;
1013 1013
     }
1014 1014
     return $consent_types;
1015
-  }
1016
-  return array();
1015
+    }
1016
+    return array();
1017 1017
 }
1018 1018
 
1019 1019
 /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
@@ -1025,94 +1025,94 @@  discard block
 block discarded – undo
1025 1025
  */
1026 1026
 function boincwork_set_default_venue($venue = '') {
1027 1027
 
1028
-  global $user;
1029
-  $account = user_load($user->uid);
1028
+    global $user;
1029
+    $account = user_load($user->uid);
1030 1030
 
1031
-  if ($venue == 'generic') {
1031
+    if ($venue == 'generic') {
1032 1032
     $venue = '';
1033
-  }
1033
+    }
1034 1034
 
1035
-  db_set_active('boinc_rw');
1036
-  db_query("
1035
+    db_set_active('boinc_rw');
1036
+    db_query("
1037 1037
     UPDATE user
1038 1038
     SET venue = '%s'
1039 1039
     WHERE id = %d",
1040 1040
     $venue, $account->boincuser_id
1041
-  );
1042
-  db_set_active('default');
1041
+    );
1042
+    db_set_active('default');
1043 1043
 }
1044 1044
 
1045 1045
 /**
1046 1046
  * Recursively validate submitted form values against a set of rules
1047 1047
  */
1048 1048
 function boincwork_validate_form($validation_rules, $values, $path = array()) {
1049
-  foreach ($validation_rules as $field => $rules) {
1049
+    foreach ($validation_rules as $field => $rules) {
1050 1050
     $parents = $path;
1051 1051
     if (is_array($values[$field])) {
1052
-      // Process nested form elements
1053
-      $parents[] = $field;
1054
-      boincwork_validate_form($rules, $values[$field], $parents);
1052
+        // Process nested form elements
1053
+        $parents[] = $field;
1054
+        boincwork_validate_form($rules, $values[$field], $parents);
1055 1055
     }
1056 1056
     else {
1057
-      if ($parents) {
1057
+        if ($parents) {
1058 1058
         // form_set_error() identifies nested form elements with '][' as a
1059 1059
         // delimiter between each parent and child element
1060 1060
         $parents[] = $field;
1061 1061
         $form_field = implode('][', $parents);
1062
-      }
1063
-      else {
1062
+        }
1063
+        else {
1064 1064
         $form_field = $field;
1065
-      }
1066
-      if (isset($rules['datatype']) AND !boincwork_validate_datatype($values[$field], $rules['datatype'])) {
1065
+        }
1066
+        if (isset($rules['datatype']) AND !boincwork_validate_datatype($values[$field], $rules['datatype'])) {
1067 1067
         form_set_error($form_field, bts('Invalid data type for @field', array('@field' => $field), NULL, 'boinc:account-preferences'));
1068
-      }
1069
-      if (isset($rules['min']) AND $values[$field] < $rules['min']) {
1068
+        }
1069
+        if (isset($rules['min']) AND $values[$field] < $rules['min']) {
1070 1070
         form_set_error($form_field, bts('Minimum value not met for @field', array('@field' => $field), NULL, 'boinc:account-preferences'));
1071
-      }
1072
-      if (isset($rules['max']) AND $values[$field] > $rules['max']) {
1071
+        }
1072
+        if (isset($rules['max']) AND $values[$field] > $rules['max']) {
1073 1073
         form_set_error($form_field, bts('Maximum value exceeded for @field', array('@field' => $field), NULL, 'boinc:account-preferences'));
1074
-      }
1074
+        }
1075
+    }
1075 1076
     }
1076
-  }
1077 1077
 }
1078 1078
 
1079 1079
 /**
1080 1080
  * Check that numeric data conforms to specifications
1081 1081
  */
1082 1082
 function boincwork_validate_datatype($data, $datatype = NULL) {
1083
-  switch ($datatype) {
1084
-  case 'float':
1083
+    switch ($datatype) {
1084
+    case 'float':
1085 1085
     if (!is_numeric($data)) {
1086
-      return FALSE;
1086
+        return FALSE;
1087 1087
     }
1088 1088
     $data += 0.0;
1089 1089
     if (!is_float($data)) {
1090
-      return FALSE;
1090
+        return FALSE;
1091 1091
     }
1092 1092
     break;
1093 1093
 
1094
-  case 'integer':
1094
+    case 'integer':
1095 1095
     if (!is_numeric($data)) {
1096
-      return FALSE;
1096
+        return FALSE;
1097 1097
     }
1098 1098
     $data += 0;
1099 1099
     if (!is_int($data)) {
1100
-      return FALSE;
1100
+        return FALSE;
1101 1101
     }
1102 1102
     break;
1103 1103
 
1104
-  case 'text':
1104
+    case 'text':
1105 1105
   default:
1106 1106
 
1107 1107
   }
1108
-  return TRUE;
1108
+    return TRUE;
1109 1109
 }
1110 1110
 
1111 1111
 /**
1112 1112
  * Format a number to be displayed using a maximum number of digits
1113 1113
  */
1114 1114
 function boincwork_format_stats($number, $max_digits = 4) {
1115
-  $suffix = array(
1115
+    $suffix = array(
1116 1116
     0 => '',
1117 1117
     1 => 'k',
1118 1118
     2 => 'M',
@@ -1122,94 +1122,94 @@  discard block
 block discarded – undo
1122 1122
     6 => 'E',
1123 1123
     7 => 'Z',
1124 1124
     8 => 'Y'
1125
-  );
1126
-  if (!is_numeric($number)) $number = 0;
1125
+    );
1126
+    if (!is_numeric($number)) $number = 0;
1127 1127
 
1128
-  $digits = floor(log($number, 10)) + 1;
1129
-  $magnitude = 0;
1130
-  $precision = 0;
1131
-  if ($digits > $max_digits) {
1128
+    $digits = floor(log($number, 10)) + 1;
1129
+    $magnitude = 0;
1130
+    $precision = 0;
1131
+    if ($digits > $max_digits) {
1132 1132
     $magnitude = floor(($digits - ($max_digits - 3)) / 3);
1133 1133
     $precision = $max_digits - ($digits - ($magnitude * 3) + 1);
1134 1134
     $number = round($number / pow(1000, $magnitude), $precision);
1135
-  }
1136
-  $number = number_format($number, $precision) . (($magnitude) ? "{$suffix[$magnitude]}" : '');
1135
+    }
1136
+    $number = number_format($number, $precision) . (($magnitude) ? "{$suffix[$magnitude]}" : '');
1137 1137
 
1138
-  return $number;
1138
+    return $number;
1139 1139
 }
1140 1140
 
1141
-  //------------------------------------------------------------------------------------------------
1142
-  //  load_configuration(): Convert structured text/xml to array
1143
-  //------------------------------------------------------------------------------------------------
1141
+    //------------------------------------------------------------------------------------------------
1142
+    //  load_configuration(): Convert structured text/xml to array
1143
+    //------------------------------------------------------------------------------------------------
1144 1144
 
1145
-  function load_configuration($text)
1146
-  {
1147
-      if (preg_match('/^\<\?xml .*\?\>$/i', $text)) return null;
1148
-      if ($xml = text_to_xml($text)) return xml_to_array($xml);
1149
-      return false;
1150
-  }
1145
+    function load_configuration($text)
1146
+    {
1147
+        if (preg_match('/^\<\?xml .*\?\>$/i', $text)) return null;
1148
+        if ($xml = text_to_xml($text)) return xml_to_array($xml);
1149
+        return false;
1150
+    }
1151 1151
 
1152
-  //------------------------------------------------------------------------------------------------
1153
-  //  save_configuration(): Convert array to structured text/xml
1154
-  //------------------------------------------------------------------------------------------------
1152
+    //------------------------------------------------------------------------------------------------
1153
+    //  save_configuration(): Convert array to structured text/xml
1154
+    //------------------------------------------------------------------------------------------------
1155 1155
 
1156
-  function save_configuration($array)
1157
-  {
1158
-      if ($xml = array_to_xml($array)) return xml_to_text($xml, false, true);
1159
-      return false;
1160
-  }
1156
+    function save_configuration($array)
1157
+    {
1158
+        if ($xml = array_to_xml($array)) return xml_to_text($xml, false, true);
1159
+        return false;
1160
+    }
1161 1161
 
1162
-  //------------------------------------------------------------------------------------------------
1163
-  //  array_to_xml(): Take a multidimensional array and convert it to a structured
1164
-  //  DOM XML object
1165
-  //------------------------------------------------------------------------------------------------
1162
+    //------------------------------------------------------------------------------------------------
1163
+    //  array_to_xml(): Take a multidimensional array and convert it to a structured
1164
+    //  DOM XML object
1165
+    //------------------------------------------------------------------------------------------------
1166 1166
 
1167
-  function array_to_xml($array, $dom = false, $parent_node = false) {
1167
+    function array_to_xml($array, $dom = false, $parent_node = false) {
1168 1168
     $is_root = false;
1169 1169
     if (!$dom) $dom = new DomDocument('1.0');
1170 1170
     if (!$parent_node) {
1171
-      $parent_node = $dom;
1172
-      $is_root = true;
1171
+        $parent_node = $dom;
1172
+        $is_root = true;
1173 1173
     }
1174 1174
     // Created an intermediate array to attempt to sort by @position
1175 1175
     $ordered_array = array();
1176 1176
     $unordered_array = array();
1177 1177
     foreach ($array as $name => $value) {
1178
-      if ($is_root) {
1178
+        if ($is_root) {
1179 1179
         $unordered_array[] = $array;
1180 1180
         break;
1181
-      }
1182
-      if (is_array($value)) {
1181
+        }
1182
+        if (is_array($value)) {
1183 1183
         if (is_numeric(key($value))) {
1184
-          foreach ($value as $item) {
1184
+            foreach ($value as $item) {
1185 1185
             if (is_array($item) AND isset($item['@position'])) {
1186
-              $ordered_array[$item['@position']] = array(
1186
+                $ordered_array[$item['@position']] = array(
1187 1187
                 $name => $item
1188
-              );
1188
+                );
1189 1189
             }
1190 1190
             else {
1191
-              $unordered_array[] = array(
1191
+                $unordered_array[] = array(
1192 1192
                 $name => $item
1193
-              );
1193
+                );
1194
+            }
1194 1195
             }
1195
-          }
1196 1196
         }
1197 1197
         elseif (isset($value['@position'])) {
1198
-          $ordered_array[$value['@position']] = array(
1198
+            $ordered_array[$value['@position']] = array(
1199 1199
             $name => $value
1200
-          );
1200
+            );
1201 1201
         }
1202 1202
         else {
1203
-          $unordered_array[] = array(
1203
+            $unordered_array[] = array(
1204 1204
             $name => $value
1205
-          );
1205
+            );
1206 1206
         }
1207
-      }
1208
-      else {
1207
+        }
1208
+        else {
1209 1209
         $unordered_array[] = array(
1210
-          $name => $value
1210
+            $name => $value
1211 1211
         );
1212
-      }
1212
+        }
1213 1213
     }
1214 1214
 
1215 1215
     // Now append items without explicit positions at the end
@@ -1217,39 +1217,39 @@  discard block
 block discarded – undo
1217 1217
 
1218 1218
     // Convert to XML...
1219 1219
     foreach ($primed_array as $item) {
1220
-      list($name, $value) = each($item);
1221
-      if (strcmp($name, '@attributes') == 0) {
1220
+        list($name, $value) = each($item);
1221
+        if (strcmp($name, '@attributes') == 0) {
1222 1222
         if (!is_array($value)) continue;
1223 1223
         foreach ($value as $attributeName => $attributeValue) {
1224
-          $parent_node->setAttribute($attributeName, $attributeValue);
1224
+            $parent_node->setAttribute($attributeName, $attributeValue);
1225 1225
         }
1226
-      } elseif (strcmp($name, '@value') == 0) {
1226
+        } elseif (strcmp($name, '@value') == 0) {
1227 1227
         if (isset($value)) $parent_node->nodeValue = $value;
1228
-      } elseif (strcmp($name, '@position') == 0) {
1228
+        } elseif (strcmp($name, '@position') == 0) {
1229 1229
         continue;
1230
-      } else {
1230
+        } else {
1231 1231
         if (is_numeric($name)) {
1232
-          $name = $parent_node->tagName;
1232
+            $name = $parent_node->tagName;
1233 1233
         }
1234 1234
         $current_item = $dom->createElement($name);
1235 1235
         if (is_array($value)) {
1236
-          if (is_numeric(key($value))) {
1236
+            if (is_numeric(key($value))) {
1237 1237
             $current_node = $parent_node->appendChild($current_item);
1238 1238
             $current_node = array_to_xml($value, $dom, $current_node);
1239 1239
             $child_count = $current_node->childNodes->length;
1240 1240
             for ($i = 0; $i < $child_count; $i++) {
1241
-              $parent_node->appendChild($current_node->childNodes->item(0));
1241
+                $parent_node->appendChild($current_node->childNodes->item(0));
1242 1242
             }
1243 1243
             $parent_node->removeChild($current_node);
1244
-          } else {
1244
+            } else {
1245 1245
             $current_node = $dom->appendChild($current_item);
1246 1246
             $parent_node->appendChild(array_to_xml($value, $dom, $current_node));
1247
-          }
1247
+            }
1248 1248
         } else {
1249
-          if (isset($value)) $current_item->nodeValue = $value;
1250
-          $parent_node->appendChild($current_item);
1249
+            if (isset($value)) $current_item->nodeValue = $value;
1250
+            $parent_node->appendChild($current_item);
1251
+        }
1251 1252
         }
1252
-      }
1253 1253
     }
1254 1254
     /*
1255 1255
     foreach ($array as $name => $value) {
@@ -1285,114 +1285,114 @@  discard block
 block discarded – undo
1285 1285
       }
1286 1286
     }*/
1287 1287
     return $parent_node;
1288
-  }
1288
+    }
1289 1289
 
1290
-  //------------------------------------------------------------------------------------------------
1291
-  //  xml_to_text(): Convert an XML DOM object to string format
1292
-  //------------------------------------------------------------------------------------------------
1290
+    //------------------------------------------------------------------------------------------------
1291
+    //  xml_to_text(): Convert an XML DOM object to string format
1292
+    //------------------------------------------------------------------------------------------------
1293 1293
 
1294
-  function xml_to_text($xml, $include_xml_declaration = true, $add_carriage_returns = false)
1295
-  {
1296
-      $xml->formatOutput = true;
1297
-      $text = $xml->saveXML();
1298
-      if (!$include_xml_declaration) {
1294
+    function xml_to_text($xml, $include_xml_declaration = true, $add_carriage_returns = false)
1295
+    {
1296
+        $xml->formatOutput = true;
1297
+        $text = $xml->saveXML();
1298
+        if (!$include_xml_declaration) {
1299 1299
         $text = preg_replace('/<\?xml version=.*\?>\s*/i', '', $text, 1);
1300
-      }
1301
-      if ($add_carriage_returns) {;
1300
+        }
1301
+        if ($add_carriage_returns) {;
1302 1302
         $text = preg_replace('/\n/i', "\r\n", $text);
1303
-      }
1304
-      return trim($text);
1305
-  }
1303
+        }
1304
+        return trim($text);
1305
+    }
1306 1306
 
1307
-  //------------------------------------------------------------------------------------------------
1308
-  //  text_to_xml(): Convert an XML DOM object to string format
1309
-  //------------------------------------------------------------------------------------------------
1307
+    //------------------------------------------------------------------------------------------------
1308
+    //  text_to_xml(): Convert an XML DOM object to string format
1309
+    //------------------------------------------------------------------------------------------------
1310 1310
 
1311
-  function text_to_xml($text) {
1311
+    function text_to_xml($text) {
1312 1312
     $xml = new DomDocument();
1313 1313
     if ( !($xml->loadXML($text)) ) return false;
1314 1314
     return $xml;
1315
-  }
1315
+    }
1316 1316
 
1317 1317
 
1318
-  //------------------------------------------------------------------------------------------------
1319
-  //  xml_to_array(): Convert an XML DOM object to array format
1320
-  //------------------------------------------------------------------------------------------------
1318
+    //------------------------------------------------------------------------------------------------
1319
+    //  xml_to_array(): Convert an XML DOM object to array format
1320
+    //------------------------------------------------------------------------------------------------
1321 1321
 
1322
-  function xml_to_array($xml) {
1323
-      $node = $xml->firstChild; //$xml->first_child();
1324
-      $result = '';
1325
-      $index = 1;
1326
-      $position = 0;
1327
-      while (!is_null($node)) {
1328
-          switch ($node->nodeType) {
1329
-          case XML_TEXT_NODE:
1322
+    function xml_to_array($xml) {
1323
+        $node = $xml->firstChild; //$xml->first_child();
1324
+        $result = '';
1325
+        $index = 1;
1326
+        $position = 0;
1327
+        while (!is_null($node)) {
1328
+            switch ($node->nodeType) {
1329
+            case XML_TEXT_NODE:
1330 1330
               if (trim($node->nodeValue)  != '') $result = $node->nodeValue;
1331
-              break;
1332
-          case XML_ELEMENT_NODE:
1331
+                break;
1332
+            case XML_ELEMENT_NODE:
1333 1333
               $node_name = $node->nodeName;
1334
-              $parent = $node->parentNode;
1335
-              $sibling = $node->nextSibling;
1336
-
1337
-              // Determine if this node forms a set with siblings (share a node name)
1338
-              while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->nextSibling;
1339
-              if (!$sibling) {
1340
-                  $sibling = $node->previousSibling;
1341
-                  while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->previousSibling;
1342
-              }
1343
-
1344
-              if ($sibling) {
1345
-                  $result[$node_name][$index] = '';
1346
-                  if ($node->childNodes) {
1347
-                      $result[$node_name][$index] = xml_to_array($node) ;
1348
-                  }
1349
-                  if ($node->hasAttributes()) {
1350
-                      $attributes = $node->attributes;
1351
-                      if ($result[$node_name][$index] !== '' AND !is_array($result[$node_name][$index])) {
1352
-                          $result[$node_name][$index] = array('@value' => $result[$node_name][$index]);
1353
-                      }
1354
-                      foreach ($attributes as $key => $attribute) {
1355
-                          $result[$node_name][$index]['@attributes'][$attribute->name] = $attribute->value;
1356
-                      }
1357
-                  }
1358
-                  // Retain the position of the element
1359
-                  if (!is_array($result[$node_name][$index])) {
1334
+                $parent = $node->parentNode;
1335
+                $sibling = $node->nextSibling;
1336
+
1337
+                // Determine if this node forms a set with siblings (share a node name)
1338
+                while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->nextSibling;
1339
+                if (!$sibling) {
1340
+                    $sibling = $node->previousSibling;
1341
+                    while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->previousSibling;
1342
+                }
1343
+
1344
+                if ($sibling) {
1345
+                    $result[$node_name][$index] = '';
1346
+                    if ($node->childNodes) {
1347
+                        $result[$node_name][$index] = xml_to_array($node) ;
1348
+                    }
1349
+                    if ($node->hasAttributes()) {
1350
+                        $attributes = $node->attributes;
1351
+                        if ($result[$node_name][$index] !== '' AND !is_array($result[$node_name][$index])) {
1352
+                            $result[$node_name][$index] = array('@value' => $result[$node_name][$index]);
1353
+                        }
1354
+                        foreach ($attributes as $key => $attribute) {
1355
+                            $result[$node_name][$index]['@attributes'][$attribute->name] = $attribute->value;
1356
+                        }
1357
+                    }
1358
+                    // Retain the position of the element
1359
+                    if (!is_array($result[$node_name][$index])) {
1360 1360
                     $result[$node_name][$index] = array(
1361
-                      '@value' => $result[$node_name][$index]
1361
+                        '@value' => $result[$node_name][$index]
1362 1362
                     );
1363
-                  }
1364
-                  $result[$node_name][$index]['@position'] = $position;
1365
-                  $position++;
1366
-                  $index++;
1367
-              } else {
1368
-                  $result[$node_name] = '';
1369
-                  if ($node->childNodes) {
1370
-                      $result[$node_name] = xml_to_array($node) ;
1371
-                  }
1372
-                  if ($node->hasAttributes()) {
1373
-                      $attributes = $node->attributes;
1374
-                      if ($result[$node_name] !== '' AND !is_array($result[$node_name])) {
1375
-                          $result[$node_name] = array('@value' => $result[$node_name]);
1376
-                      }
1377
-                      foreach($attributes as $key => $attribute) {
1378
-                          $result[$node_name]['@attributes'][$attribute->name] = $attribute->value;
1379
-                      }
1380
-                  }
1381
-                  // Retain the position of the element
1382
-                  if (!is_array($result[$node_name])) {
1363
+                    }
1364
+                    $result[$node_name][$index]['@position'] = $position;
1365
+                    $position++;
1366
+                    $index++;
1367
+                } else {
1368
+                    $result[$node_name] = '';
1369
+                    if ($node->childNodes) {
1370
+                        $result[$node_name] = xml_to_array($node) ;
1371
+                    }
1372
+                    if ($node->hasAttributes()) {
1373
+                        $attributes = $node->attributes;
1374
+                        if ($result[$node_name] !== '' AND !is_array($result[$node_name])) {
1375
+                            $result[$node_name] = array('@value' => $result[$node_name]);
1376
+                        }
1377
+                        foreach($attributes as $key => $attribute) {
1378
+                            $result[$node_name]['@attributes'][$attribute->name] = $attribute->value;
1379
+                        }
1380
+                    }
1381
+                    // Retain the position of the element
1382
+                    if (!is_array($result[$node_name])) {
1383 1383
                     $result[$node_name] = array(
1384
-                      '@value' => $result[$node_name]
1384
+                        '@value' => $result[$node_name]
1385 1385
                     );
1386
-                  }
1387
-                  $result[$node_name]['@position'] = $position;
1388
-                  $position++;
1389
-              }
1390
-              break;
1391
-          }
1392
-          $node = $node->nextSibling;
1393
-      }
1394
-      return $result;
1395
-  }
1386
+                    }
1387
+                    $result[$node_name]['@position'] = $position;
1388
+                    $position++;
1389
+                }
1390
+                break;
1391
+            }
1392
+            $node = $node->nextSibling;
1393
+        }
1394
+        return $result;
1395
+    }
1396 1396
 
1397 1397
 
1398 1398
 /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
@@ -1400,172 +1400,172 @@  discard block
 block discarded – undo
1400 1400
  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  */
1401 1401
 
1402 1402
 /**
1403
-  * Determine output for host list views when no hosts are found.
1404
-  */
1403
+ * Determine output for host list views when no hosts are found.
1404
+ */
1405 1405
 function boincwork_views_host_list_empty_text($context = NULL) {
1406 1406
 
1407
-  // Pull the BOINC user ID from the view arguments to get show_hosts
1408
-  // preference for that user
1409
-  require_boinc('boinc_db');
1410
-  $view = views_get_current_view();
1411
-  $account = user_load($view->args[0]);
1412
-  $boincuser = BoincUser::lookup_id($account->boincuser_id);
1407
+    // Pull the BOINC user ID from the view arguments to get show_hosts
1408
+    // preference for that user
1409
+    require_boinc('boinc_db');
1410
+    $view = views_get_current_view();
1411
+    $account = user_load($view->args[0]);
1412
+    $boincuser = BoincUser::lookup_id($account->boincuser_id);
1413 1413
 
1414
-  // Determine if hosts are associated at all or just hidden
1415
-  $output = '';
1416
-  if ($boincuser->show_hosts) {
1414
+    // Determine if hosts are associated at all or just hidden
1415
+    $output = '';
1416
+    if ($boincuser->show_hosts) {
1417 1417
     switch($context) {
1418 1418
     case 'active':
1419 1419
       $output .=  '<h2>' . bts('No active computers', array(), NULL, 'boinc:host-list') . '</h2>';
1420
-      $output .=  '<p>' . bts('This user has no computers that have been'
1421
-      . ' active in the last 30 days.', array(), NULL, 'boinc:host-list') . '</p>';
1422
-      break;
1420
+        $output .=  '<p>' . bts('This user has no computers that have been'
1421
+        . ' active in the last 30 days.', array(), NULL, 'boinc:host-list') . '</p>';
1422
+        break;
1423 1423
 
1424 1424
     case 'preferences':
1425 1425
       $output .=  '<h2>' . bts('No computers', array(), NULL, 'boinc:host-list') . '</h2>';
1426
-      $output .=  '<p>' . bts('There are no computers assigned to this'
1427
-      . ' preference set.', array(), NULL, 'boinc:host-list') . '</p>';
1428
-      break;
1426
+        $output .=  '<p>' . bts('There are no computers assigned to this'
1427
+        . ' preference set.', array(), NULL, 'boinc:host-list') . '</p>';
1428
+        break;
1429 1429
 
1430 1430
     default:
1431 1431
       $output .=  '<h2>' . bts('Computers pending', array(), NULL, 'boinc:host-list') . '</h2>';
1432
-      $output .=  '<p>' . bts('This user does not yet have any associated'
1433
-      . ' computers. Computers will be displayed when they have earned their'
1434
-      . ' first credits.', array(), NULL, 'boinc:host-list') . '</p>';
1432
+        $output .=  '<p>' . bts('This user does not yet have any associated'
1433
+        . ' computers. Computers will be displayed when they have earned their'
1434
+        . ' first credits.', array(), NULL, 'boinc:host-list') . '</p>';
1435 1435
     }
1436
-  }
1437
-  else {
1436
+    }
1437
+    else {
1438 1438
     $output .=  '<h2>' . bts('Computers hidden', array(), NULL, 'boinc:host-list') . '</h2>';
1439 1439
     $output .=  '<p>' . bts('This user has chosen not to show information'
1440 1440
     . ' about their computers.', array(), NULL, 'boinc:host-list') . '</p>';
1441
-  }
1442
-  return $output;
1441
+    }
1442
+    return $output;
1443 1443
 }
1444 1444
 
1445 1445
 /**
1446
-  * Determine output for task list views when no tasks are found.
1447
-  */
1446
+ * Determine output for task list views when no tasks are found.
1447
+ */
1448 1448
 function boincwork_views_task_list_empty_text($context = NULL) {
1449 1449
 
1450
-  //
1451
-  $output = '';
1452
-  switch($context) {
1453
-  default:
1450
+    //
1451
+    $output = '';
1452
+    switch($context) {
1453
+    default:
1454 1454
     $output .=  '<h2>' . bts('No @type tasks', array('@type' => $context), NULL, 'boinc:task-list')
1455 1455
     . '</h2>';
1456 1456
     $output .=  '<p>' . bts('There are no tasks of this type on record', array(), NULL, 'boinc:task-list')
1457 1457
     . '</p>';
1458
-  }
1459
-  return $output;
1458
+    }
1459
+    return $output;
1460 1460
 }
1461 1461
 
1462 1462
 /**
1463
-  * Output links to perform host actions
1464
-  */
1463
+ * Output links to perform host actions
1464
+ */
1465 1465
 function boincwork_host_action_links($host_id) {
1466
-  $output = '';
1467
-  if (boincwork_host_user_is_owner($host_id)) {
1466
+    $output = '';
1467
+    if (boincwork_host_user_is_owner($host_id)) {
1468 1468
     // Show merge hosts option
1469 1469
     $output = '<ul class="tab-list"><li class="first tab">';
1470 1470
     $output .= l(bts('Merge', array(), NULL, 'boinc:form-merge'), "host/{$host_id}/merge");
1471 1471
     $output .= '</li>';
1472 1472
     // If host has no tasks, allow the host to be deleted
1473 1473
     if (!boincwork_host_get_task_count($host_id)) {
1474
-      $output .= '<li class="tab">';
1475
-      $output .= l(bts('Delete', array(), NULL, 'boinc:form-delete'), "host/{$host_id}/delete",
1474
+        $output .= '<li class="tab">';
1475
+        $output .= l(bts('Delete', array(), NULL, 'boinc:form-delete'), "host/{$host_id}/delete",
1476 1476
         array(
1477
-          'attributes' => array(
1477
+            'attributes' => array(
1478 1478
             'onclick' => 'return confirm(\'' . bts('This will delete host @id'
1479
-              . ' from your account forever. Are you sure this is OK?',
1480
-              array('@id' => $host_id),
1481
-              NULL, 'boinc:account-host-delete') . '\')'
1482
-          )
1479
+                . ' from your account forever. Are you sure this is OK?',
1480
+                array('@id' => $host_id),
1481
+                NULL, 'boinc:account-host-delete') . '\')'
1482
+            )
1483 1483
         )
1484
-      );
1485
-      $output .= '</li>';
1484
+        );
1485
+        $output .= '</li>';
1486 1486
     }
1487 1487
     $output .= '</ul>';
1488
-  }
1489
-  return $output;
1488
+    }
1489
+    return $output;
1490 1490
 }
1491 1491
 
1492 1492
 /**
1493 1493
  * Get details for a given host
1494 1494
  */
1495 1495
 function boincwork_host_get_info($host_id) {
1496
-  db_set_active('boinc_ro');
1497
-  $host = db_fetch_object(db_query(
1496
+    db_set_active('boinc_ro');
1497
+    $host = db_fetch_object(db_query(
1498 1498
     "SELECT * FROM {host} WHERE id = '%d'",
1499 1499
     $host_id
1500
-  ));
1501
-  db_set_active('default');
1502
-  return $host;
1500
+    ));
1501
+    db_set_active('default');
1502
+    return $host;
1503 1503
 }
1504 1504
 
1505 1505
 /**
1506 1506
  * Get the number of tasks associated with a given host
1507 1507
  */
1508 1508
 function boincwork_host_get_task_count($host_id) {
1509
-  db_set_active('boinc_ro');
1510
-  $count = db_result(db_query(
1509
+    db_set_active('boinc_ro');
1510
+    $count = db_result(db_query(
1511 1511
     "SELECT COUNT(*) FROM {result} WHERE hostid = '%d'",
1512 1512
     $host_id
1513
-  ));
1514
-  db_set_active('default');
1515
-  return $count;
1513
+    ));
1514
+    db_set_active('default');
1515
+    return $count;
1516 1516
 }
1517 1517
 
1518 1518
 /**
1519 1519
  * Check whether a user is the owner of a host
1520 1520
  */
1521 1521
 function boincwork_host_user_is_owner($host_id, $uid = NULL) {
1522
-  if (!$uid) {
1522
+    if (!$uid) {
1523 1523
     global $user;
1524 1524
     $uid = $user->uid;
1525
-  }
1526
-  $account = user_load($uid);
1527
-  // Get host owner
1528
-  db_set_active('boinc_ro');
1529
-  $owner = db_result(db_query(
1525
+    }
1526
+    $account = user_load($uid);
1527
+    // Get host owner
1528
+    db_set_active('boinc_ro');
1529
+    $owner = db_result(db_query(
1530 1530
     "SELECT userid FROM {host} WHERE id = '%d'",
1531 1531
     $host_id
1532
-  ));
1533
-  db_set_active('default');
1534
-  return ($account->boincuser_id === $owner);
1532
+    ));
1533
+    db_set_active('default');
1534
+    return ($account->boincuser_id === $owner);
1535 1535
 }
1536 1536
 
1537 1537
 /**
1538
-  * Determine output for host last contact time
1539
-  */
1538
+ * Determine output for host last contact time
1539
+ */
1540 1540
 function boincwork_host_last_contact($timestamp, $host_id = NULL, $context = NULL) {
1541
-  $output = '---';
1542
-  $root_log_dir = variable_get('boinc_host_sched_logs_dir', '');
1543
-  $log = '';
1544
-  if ($timestamp) {
1541
+    $output = '---';
1542
+    $root_log_dir = variable_get('boinc_host_sched_logs_dir', '');
1543
+    $log = '';
1544
+    if ($timestamp) {
1545 1545
     $output = date('j M Y G:i:s T', $timestamp);
1546
-  }
1547
-  if ($root_log_dir AND $host_id) {
1546
+    }
1547
+    if ($root_log_dir AND $host_id) {
1548 1548
     $subdir = substr($host_id, 0, -3) OR $subdir = 0;
1549 1549
     $log = implode('/', array($root_log_dir, $subdir, $host_id));
1550
-  }
1551
-  if ($log AND file_exists($log)) {
1550
+    }
1551
+    if ($log AND file_exists($log)) {
1552 1552
     $output = l($output, "host/{$host_id}/log");
1553
-  }
1554
-  return $output;
1553
+    }
1554
+    return $output;
1555 1555
 }
1556 1556
 
1557 1557
 /**
1558 1558
  *
1559 1559
  */
1560 1560
 function boincwork_host_venue_selector($host_id) {
1561
-  $output = '';
1562
-  if (function_exists('jump_quickly')) {
1561
+    $output = '';
1562
+    if (function_exists('jump_quickly')) {
1563 1563
     $path = "host/{$host_id}/set-venue";
1564 1564
     $venues = array(
1565
-      "{$path}/generic" => bts('Generic', array(), NULL, 'boinc:account-preferences-location'),
1566
-      "{$path}/home" => bts('Home', array(), NULL, 'boinc:account-preferences-location:-1:ignoreoverwrite'),
1567
-      "{$path}/work" => bts('Work', array(), NULL, 'boinc:account-preferences-location'),
1568
-      "{$path}/school" => bts('School', array(), NULL, 'boinc:account-preferences-location')
1565
+        "{$path}/generic" => bts('Generic', array(), NULL, 'boinc:account-preferences-location'),
1566
+        "{$path}/home" => bts('Home', array(), NULL, 'boinc:account-preferences-location:-1:ignoreoverwrite'),
1567
+        "{$path}/work" => bts('Work', array(), NULL, 'boinc:account-preferences-location'),
1568
+        "{$path}/school" => bts('School', array(), NULL, 'boinc:account-preferences-location')
1569 1569
     );
1570 1570
     variable_set('jump_use_js_venues-Array', 1);
1571 1571
     drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js');
@@ -1573,34 +1573,34 @@  discard block
 block discarded – undo
1573 1573
     // Get current venue
1574 1574
     db_set_active('boinc_ro');
1575 1575
     $venue = db_result(db_query(
1576
-      "SELECT venue FROM {host} WHERE id = '%d'",
1577
-      $host_id
1576
+        "SELECT venue FROM {host} WHERE id = '%d'",
1577
+        $host_id
1578 1578
     ));
1579 1579
     db_set_active('default');
1580 1580
     $output .= jump_quickly($venues, 'venues', 1, "{$path}/{$venue}");
1581
-  }
1582
-  return $output;
1581
+    }
1582
+    return $output;
1583 1583
 }
1584 1584
 
1585 1585
 /**
1586
-  * Determine output for task reported time / deadline
1587
-  */
1586
+ * Determine output for task reported time / deadline
1587
+ */
1588 1588
 function boincwork_task_time_reported($received_time = NULL, $deadline = NULL, $context = NULL) {
1589
-  $output = '---';
1590
-  if ($received_time OR $deadline) {
1589
+    $output = '---';
1590
+    if ($received_time OR $deadline) {
1591 1591
     $timestamp = ($received_time) ? $received_time : $deadline;
1592 1592
     $output = date('j M Y G:i:s T', $timestamp);
1593 1593
     // Add a wrapper to deadline text
1594 1594
     if (!$received_time) {
1595
-      if (time() < $deadline) {
1595
+        if (time() < $deadline) {
1596 1596
         $output = '<span class="on-time">' . $output . '</span>';
1597
-      }
1598
-      else {
1597
+        }
1598
+        else {
1599 1599
         $output = '<span class="past-due">' . $output . '</span>';
1600
-      }
1600
+        }
1601 1601
     }
1602
-  }
1603
-  return $output;
1602
+    }
1603
+    return $output;
1604 1604
 }
1605 1605
 
1606 1606
 /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
@@ -1631,345 +1631,345 @@  discard block
 block discarded – undo
1631 1631
  *   Number of table row to display per page. Defaults to 20.
1632 1632
  */
1633 1633
 function boincwork_tasktable($category = 0, $queryid = 1, $tselect = NULL, $app_id = 0, $tablerows = 20) {
1634
-  // Check type parameter, if not (0,2) then return an error.
1635
-  if ( ($category!=0) AND ($category!=1) AND ($category!=2) ) {
1634
+    // Check type parameter, if not (0,2) then return an error.
1635
+    if ( ($category!=0) AND ($category!=1) AND ($category!=2) ) {
1636 1636
     watchdog('boincwork', 'task table called with invalid category = %category', array('%category' => $category), WATCHDOG_WARNING);
1637 1637
     return '';
1638
-  }
1638
+    }
1639 1639
 
1640
-  require_boinc( array('util', 'result') );
1640
+    require_boinc( array('util', 'result') );
1641 1641
 
1642
-  global $language;
1643
-  $locality=$language->language;
1644
-  $nf = new NumberFormatter($locality, NumberFormatter::DECIMAL);
1645
-  $nf->setAttribute(NumberFormatter::MIN_FRACTION_DIGITS, 0);
1646
-  $nf->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, 0);
1642
+    global $language;
1643
+    $locality=$language->language;
1644
+    $nf = new NumberFormatter($locality, NumberFormatter::DECIMAL);
1645
+    $nf->setAttribute(NumberFormatter::MIN_FRACTION_DIGITS, 0);
1646
+    $nf->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, 0);
1647 1647
 
1648
-  $output = '';
1648
+    $output = '';
1649 1649
 
1650
-  $state_hnames = array(
1650
+    $state_hnames = array(
1651 1651
     STATE_ALL => 'All',
1652 1652
     STATE_IN_PROGRESS => 'In progress',
1653 1653
     STATE_PENDING => 'Pending',
1654 1654
     STATE_VALID => 'Valid',
1655 1655
     STATE_INVALID => 'Invalid',
1656 1656
     STATE_ERROR => 'Error',
1657
-  );
1658
-  // Array (hash) to count total number of results/tasks, and their states.
1659
-  $taskstates = array(
1657
+    );
1658
+    // Array (hash) to count total number of results/tasks, and their states.
1659
+    $taskstates = array(
1660 1660
     STATE_ALL => 0,
1661 1661
     STATE_IN_PROGRESS => 0,
1662 1662
     STATE_PENDING => 0,
1663 1663
     STATE_VALID => 0,
1664 1664
     STATE_INVALID => 0,
1665 1665
     STATE_ERROR => 0,
1666
-  );
1667
-  // Array to hold pretty-print result data to be displayed in a table.
1668
-  $resultdata = array();
1669
-  // Arrays for applications. Form below uses $applications as parameter.
1670
-  $application_map = array();
1671
-  $application_select_count = array();
1672
-  $applications = array();
1673
-
1674
-  // BOINC DB queries for results, application names
1675
-  db_set_active('boinc_ro');
1676
-
1677
-  // Query to retreive all results, in order to calculate status for a
1678
-  // host with application names for each result.
1679
-  $sqlall = "SELECT user_friendly_name,"
1680
-      ."r.appid as appid,"
1681
-      ."r.server_state AS server_state,"
1682
-      ."r.outcome AS outcome,"
1683
-      ."r.client_state AS client_state,"
1684
-      ."r.validate_state AS validate_state,"
1685
-      ."r.exit_status AS exit_status "
1686
-      ."FROM {result} AS r "
1687
-      ."INNER JOIN {app} AS a "
1688
-      ."ON r.appid=a.id ";
1689
-
1690
-  // Use userid, hostid, or workunitid
1691
-  if ($category==0) {
1666
+    );
1667
+    // Array to hold pretty-print result data to be displayed in a table.
1668
+    $resultdata = array();
1669
+    // Arrays for applications. Form below uses $applications as parameter.
1670
+    $application_map = array();
1671
+    $application_select_count = array();
1672
+    $applications = array();
1673
+
1674
+    // BOINC DB queries for results, application names
1675
+    db_set_active('boinc_ro');
1676
+
1677
+    // Query to retreive all results, in order to calculate status for a
1678
+    // host with application names for each result.
1679
+    $sqlall = "SELECT user_friendly_name,"
1680
+        ."r.appid as appid,"
1681
+        ."r.server_state AS server_state,"
1682
+        ."r.outcome AS outcome,"
1683
+        ."r.client_state AS client_state,"
1684
+        ."r.validate_state AS validate_state,"
1685
+        ."r.exit_status AS exit_status "
1686
+        ."FROM {result} AS r "
1687
+        ."INNER JOIN {app} AS a "
1688
+        ."ON r.appid=a.id ";
1689
+
1690
+    // Use userid, hostid, or workunitid
1691
+    if ($category==0) {
1692 1692
     $sqlall .= " WHERE r.userid='%s' ";
1693
-  }
1694
-  elseif ($category==1) {
1693
+    }
1694
+    elseif ($category==1) {
1695 1695
     $sqlall .= " WHERE r.workunitid='%s' ";
1696
-  }
1697
-  elseif ($category==2) {
1696
+    }
1697
+    elseif ($category==2) {
1698 1698
     $sqlall .= " WHERE r.hostid='%s' ";
1699
-  }
1700
-  $sqlall .= " ORDER BY user_friendly_name";
1701
-  $dbres_all = db_query($sqlall, $queryid);
1702
-  db_set_active('default');
1699
+    }
1700
+    $sqlall .= " ORDER BY user_friendly_name";
1701
+    $dbres_all = db_query($sqlall, $queryid);
1702
+    db_set_active('default');
1703 1703
 
1704
-  // Loop 1 of DB results
1705
-  if ($dbres_all) {
1704
+    // Loop 1 of DB results
1705
+    if ($dbres_all) {
1706 1706
     while ($result = db_fetch_object($dbres_all)) {
1707
-      $mystate = state_num($result);
1708
-      if ( ($result->appid==$app_id) OR ($app_id==0) OR ($app_id==-1) ) {
1707
+        $mystate = state_num($result);
1708
+        if ( ($result->appid==$app_id) OR ($app_id==0) OR ($app_id==-1) ) {
1709 1709
         $taskstates[STATE_ALL]++;
1710 1710
         switch ($mystate) {
1711 1711
         case STATE_IN_PROGRESS:
1712 1712
           $taskstates[STATE_IN_PROGRESS]++;
1713
-          break;
1713
+            break;
1714 1714
         case STATE_PENDING:
1715 1715
           $taskstates[STATE_PENDING]++;
1716
-          break;
1716
+            break;
1717 1717
         case STATE_VALID:
1718 1718
           $taskstates[STATE_VALID]++;
1719
-          break;
1719
+            break;
1720 1720
         case STATE_INVALID:
1721 1721
           $taskstates[STATE_INVALID]++;
1722
-          break;
1722
+            break;
1723 1723
         case STATE_ERROR:
1724 1724
           $taskstates[STATE_ERROR]++;
1725
-          break;
1725
+            break;
1726 1726
         }
1727
-      }// if app_id
1727
+        }// if app_id
1728 1728
 
1729
-      //map holds a map between app ids and user friendly names for all applications.
1730
-      $application_map[$result->appid] = $result->user_friendly_name;
1731
-      if ( ($mystate == $tselect) OR ($tselect==STATE_ALL) ) {
1729
+        //map holds a map between app ids and user friendly names for all applications.
1730
+        $application_map[$result->appid] = $result->user_friendly_name;
1731
+        if ( ($mystate == $tselect) OR ($tselect==STATE_ALL) ) {
1732 1732
         //count of appids in the results.
1733 1733
         $application_select_count[$result->appid]++;
1734
-      }// if mystate
1734
+        }// if mystate
1735 1735
 
1736 1736
     }// while
1737
-  }
1738
-  else {
1739
-  }
1737
+    }
1738
+    else {
1739
+    }
1740 1740
 
1741
-  // Entry for all applications.
1742
-  $allcount = $application_select_count ? array_sum($application_select_count) : 0;
1743
-  $applications[-1] = bts('Application', array(), NULL, 'boinc:task-table');
1744
-  $applications[0] = bts('All applications', array(), NULL, 'boinc:task-table') . ' (' . $allcount . ')';
1745
-  // Create application filter from application_map and application_select_count.
1746
-  foreach($application_map as $akey => $aname) {
1741
+    // Entry for all applications.
1742
+    $allcount = $application_select_count ? array_sum($application_select_count) : 0;
1743
+    $applications[-1] = bts('Application', array(), NULL, 'boinc:task-table');
1744
+    $applications[0] = bts('All applications', array(), NULL, 'boinc:task-table') . ' (' . $allcount . ')';
1745
+    // Create application filter from application_map and application_select_count.
1746
+    foreach($application_map as $akey => $aname) {
1747 1747
     $acount = 0;
1748 1748
     if ( $application_select_count and array_key_exists($akey, $application_select_count) ) {
1749
-      $acount = $application_select_count[$akey];
1749
+        $acount = $application_select_count[$akey];
1750 1750
     }
1751 1751
     $applications[$akey] = $aname . ' ('. $acount . ')';
1752
-  }
1753
-  // Header array for (sub) results table.
1754
-  $resultheader = array(
1752
+    }
1753
+    // Header array for (sub) results table.
1754
+    $resultheader = array(
1755 1755
     array(
1756
-      'data' => bts('Task ID', array(), NULL, 'boinc:task-table'),
1757
-      'field' => 'id',
1756
+        'data' => bts('Task ID', array(), NULL, 'boinc:task-table'),
1757
+        'field' => 'id',
1758 1758
     ),
1759 1759
     array(
1760
-      'data' => bts('Workunit ID', array(), NULL, 'boinc:task-table'),
1761
-      'field' => 'workunitid',
1760
+        'data' => bts('Workunit ID', array(), NULL, 'boinc:task-table'),
1761
+        'field' => 'workunitid',
1762 1762
     ),
1763 1763
     array(
1764
-      'data' => bts('Computer', array(), NULL, 'boinc:task-table'),
1765
-      'field' => 'hostid',
1764
+        'data' => bts('Computer', array(), NULL, 'boinc:task-table'),
1765
+        'field' => 'hostid',
1766 1766
     ),
1767 1767
     array(
1768
-      'data' => bts('Sent', array(), NULL, 'boinc:task-table'),
1769
-      'field' => 'sent_time',
1768
+        'data' => bts('Sent', array(), NULL, 'boinc:task-table'),
1769
+        'field' => 'sent_time',
1770 1770
     ),
1771 1771
     array(
1772
-      'data' => bts('Time Reported or Deadline', array(), NULL, 'boinc:task-table')
1772
+        'data' => bts('Time Reported or Deadline', array(), NULL, 'boinc:task-table')
1773 1773
     ),
1774 1774
     array(
1775
-      'data' => bts('Status', array(), NULL, 'boinc:task-table')
1775
+        'data' => bts('Status', array(), NULL, 'boinc:task-table')
1776 1776
     ),
1777 1777
     array(
1778
-      'data' => bts('Run time', array(), NULL, 'boinc:task-table'),
1779
-      'field' => 'elapsed_time',
1778
+        'data' => bts('Run time', array(), NULL, 'boinc:task-table'),
1779
+        'field' => 'elapsed_time',
1780 1780
     ),
1781 1781
     array(
1782
-      'data' => bts('CPU time', array(), NULL, 'boinc:task-table'),
1783
-      'field' => 'cpu_time',
1782
+        'data' => bts('CPU time', array(), NULL, 'boinc:task-table'),
1783
+        'field' => 'cpu_time',
1784 1784
     ),
1785 1785
     array(
1786
-      'data' => bts('Granted Credit', array(), NULL, 'boinc:task-table'),
1787
-      'field' => 'granted_credit',
1786
+        'data' => bts('Granted Credit', array(), NULL, 'boinc:task-table'),
1787
+        'field' => 'granted_credit',
1788 1788
     ),
1789 1789
     // Application is a column, but won't be added until after tablesort_sql().
1790
-  );
1791
-
1792
-  // Query to retreive a subset of the total results for the results table.
1793
-  db_set_active('boinc_ro');
1794
-  $sqlsub = "SELECT r.id AS id,"
1795
-      ."r.name AS name,"
1796
-      ."r.workunitid AS workunitid,"
1797
-      ."r.hostid as hostid,"
1798
-      ."r.sent_time AS sent_time,"
1799
-      ."r.received_time AS received_time,"
1800
-      ."r.report_deadline AS report_deadline,"
1801
-      ."r.server_state AS server_state,"
1802
-      ."r.outcome AS outcome,"
1803
-      ."r.client_state AS client_state,"
1804
-      ."r.validate_state AS validate_state,"
1805
-      ."r.exit_status AS exit_status,"
1806
-      ."r.elapsed_time AS elapsed_time,"
1807
-      ."r.cpu_time AS cpu_time,"
1808
-      ."r.granted_credit AS granted_credit,"
1809
-      ."r.appid AS appid,"
1810
-      ."r.app_version_id AS app_version_id,"
1811
-      ."a.user_friendly_name,"
1812
-      ."av.version_num AS version_number,"
1813
-      ."av.plan_class AS plan_class,"
1814
-      ."pl.name AS platform "
1815
-      ."FROM {result} AS r "
1816
-      ."INNER JOIN {app} AS a "
1817
-      ."ON r.appid=a.id "
1818
-      ."LEFT JOIN {app_version} AS av "
1819
-      ."ON r.app_version_id=av.id "
1820
-      ."LEFT JOIN {platform} AS pl "
1821
-      ."ON av.platformid=pl.id ";
1822
-
1823
-  // Build an array for the WHERE clauses. The individual clauses are
1824
-  // placed into an array, and implode() is used to combine them into
1825
-  // a WHERE statement for the sql query. If no such clauses are added
1826
-  // to the array, then no WHERE statement will be included.
1827
-  $sqlwhere = array();
1828
-
1829
-  // Use userid, hostid, or workunitid
1830
-  if ($category==0) {
1790
+    );
1791
+
1792
+    // Query to retreive a subset of the total results for the results table.
1793
+    db_set_active('boinc_ro');
1794
+    $sqlsub = "SELECT r.id AS id,"
1795
+        ."r.name AS name,"
1796
+        ."r.workunitid AS workunitid,"
1797
+        ."r.hostid as hostid,"
1798
+        ."r.sent_time AS sent_time,"
1799
+        ."r.received_time AS received_time,"
1800
+        ."r.report_deadline AS report_deadline,"
1801
+        ."r.server_state AS server_state,"
1802
+        ."r.outcome AS outcome,"
1803
+        ."r.client_state AS client_state,"
1804
+        ."r.validate_state AS validate_state,"
1805
+        ."r.exit_status AS exit_status,"
1806
+        ."r.elapsed_time AS elapsed_time,"
1807
+        ."r.cpu_time AS cpu_time,"
1808
+        ."r.granted_credit AS granted_credit,"
1809
+        ."r.appid AS appid,"
1810
+        ."r.app_version_id AS app_version_id,"
1811
+        ."a.user_friendly_name,"
1812
+        ."av.version_num AS version_number,"
1813
+        ."av.plan_class AS plan_class,"
1814
+        ."pl.name AS platform "
1815
+        ."FROM {result} AS r "
1816
+        ."INNER JOIN {app} AS a "
1817
+        ."ON r.appid=a.id "
1818
+        ."LEFT JOIN {app_version} AS av "
1819
+        ."ON r.app_version_id=av.id "
1820
+        ."LEFT JOIN {platform} AS pl "
1821
+        ."ON av.platformid=pl.id ";
1822
+
1823
+    // Build an array for the WHERE clauses. The individual clauses are
1824
+    // placed into an array, and implode() is used to combine them into
1825
+    // a WHERE statement for the sql query. If no such clauses are added
1826
+    // to the array, then no WHERE statement will be included.
1827
+    $sqlwhere = array();
1828
+
1829
+    // Use userid, hostid, or workunitid
1830
+    if ($category==0) {
1831 1831
     $sqlwhere[] = "r.userid = '%s'";
1832
-  }
1833
-  elseif ($category==1) {
1832
+    }
1833
+    elseif ($category==1) {
1834 1834
     $sqlwhere[] = "r.workunitid = '%s'";
1835
-  }
1836
-  elseif ($category==2) {
1835
+    }
1836
+    elseif ($category==2) {
1837 1837
     $sqlwhere[] = "r.hostid = '%s'";
1838
-  }
1838
+    }
1839 1839
 
1840
-  // Append additional where clauses based on task selection.
1841
-  switch ($tselect) {
1842
-  case STATE_IN_PROGRESS:
1840
+    // Append additional where clauses based on task selection.
1841
+    switch ($tselect) {
1842
+    case STATE_IN_PROGRESS:
1843 1843
     $sqlwhere[] = "r.server_state = 4";
1844 1844
     break;
1845
-  case STATE_PENDING:
1845
+    case STATE_PENDING:
1846 1846
     $sqlwhere[] = "(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)";
1847 1847
     break;
1848
-  case STATE_VALID:
1848
+    case STATE_VALID:
1849 1849
     $sqlwhere[] = "(r.server_state = 5) AND (r.outcome = 1) AND (r.validate_state = 1)";
1850 1850
     break;
1851
-  case STATE_INVALID:
1851
+    case STATE_INVALID:
1852 1852
     $sqlwhere[] = "(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))))";
1853 1853
     break;
1854
-  case STATE_ERROR:
1854
+    case STATE_ERROR:
1855 1855
     $sqlwhere[] = "(r.server_state = 5) AND (r.outcome >= 3) AND (r.outcome <= 4 OR r.outcome >= 7) AND (r.outcome <= 7)";
1856 1856
     break;
1857
-  default:
1857
+    default:
1858 1858
   }
1859 1859
 
1860
-  if (is_numeric($app_id) AND $app_id>0 ) {
1860
+    if (is_numeric($app_id) AND $app_id>0 ) {
1861 1861
     $sqlwhere[] = "r.appid = '%s'";
1862 1862
     if ($sqlwhere)  $sqlsub .= " WHERE " . implode(' AND ', $sqlwhere);
1863 1863
     $dbres_sub = pager_query( $sqlsub . tablesort_sql($resultheader), $tablerows, 0, NULL, $queryid, $app_id);
1864
-  }
1865
-  else {
1864
+    }
1865
+    else {
1866 1866
     if ($sqlwhere)  $sqlsub .= " WHERE " . implode(' AND ', $sqlwhere);
1867 1867
     $dbres_sub = pager_query( $sqlsub . tablesort_sql($resultheader), $tablerows, 0, NULL, $queryid);
1868
-  }
1869
-  db_set_active('default');
1868
+    }
1869
+    db_set_active('default');
1870 1870
 
1871
-  // Loop 2 over DB results.
1872
-  if ($dbres_sub) {
1871
+    // Loop 2 over DB results.
1872
+    if ($dbres_sub) {
1873 1873
     while ($result = db_fetch_object($dbres_sub)) {
1874
-      // state_num() function changes $result object, clone $result
1875
-      // object for use in state_num()
1876
-      // check if state matches selection
1877
-      if ( (state_num(clone $result) == $tselect) OR ($tselect==STATE_ALL) ) {
1874
+        // state_num() function changes $result object, clone $result
1875
+        // object for use in state_num()
1876
+        // check if state matches selection
1877
+        if ( (state_num(clone $result) == $tselect) OR ($tselect==STATE_ALL) ) {
1878 1878
         // create pretty result row
1879 1879
         $prettyresult = array(
1880
-          array(
1880
+            array(
1881 1881
             'data' => l($result->name, "task/{$result->id}"),
1882 1882
             'class' => 'task-name',
1883
-          ),
1884
-          l($result->workunitid, "workunit/{$result->workunitid}"),
1885
-          l($result->hostid, "host/{$result->hostid}"),
1886
-          date('j M Y G:i:s T', $result->sent_time),
1887
-          boincwork_task_time_reported($result->received_time, $result->report_deadline),
1888
-          state_string($result),
1889
-          $nf->format($result->elapsed_time),
1890
-          $nf->format($result->cpu_time),
1891
-          $nf->format($result->granted_credit),
1892
-          array(
1883
+            ),
1884
+            l($result->workunitid, "workunit/{$result->workunitid}"),
1885
+            l($result->hostid, "host/{$result->hostid}"),
1886
+            date('j M Y G:i:s T', $result->sent_time),
1887
+            boincwork_task_time_reported($result->received_time, $result->report_deadline),
1888
+            state_string($result),
1889
+            $nf->format($result->elapsed_time),
1890
+            $nf->format($result->cpu_time),
1891
+            $nf->format($result->granted_credit),
1892
+            array(
1893 1893
             'data' => $result->user_friendly_name . " " . pretty_application_version($result->app_version_id,$result->version_number, $result->plan_class, $result->platform),
1894 1894
             'class' => 'task-app',
1895
-          ),
1895
+            ),
1896 1896
         );
1897 1897
         $resultdata[] = array_values($prettyresult);
1898
-      }
1898
+        }
1899 1899
     }// while
1900
-  }
1901
-  else {
1902
-  }
1903
-  // Begin result navigation
1900
+    }
1901
+    else {
1902
+    }
1903
+    // Begin result navigation
1904 1904
 
1905
-  // Set pathprefix based on type
1906
-  if ($category==0) {
1905
+    // Set pathprefix based on type
1906
+    if ($category==0) {
1907 1907
     $pathprefix = 'account/tasks';
1908
-  }
1909
-  elseif ($category==1) {
1908
+    }
1909
+    elseif ($category==1) {
1910 1910
     $pathprefix = 'workunit/' . $queryid . '/tasks';
1911
-  }
1912
-  elseif ($category==2) {
1911
+    }
1912
+    elseif ($category==2) {
1913 1913
     $pathprefix = 'host/' . $queryid . '/tasks';
1914
-  }
1915
-  // Need an "All" tab as well, maps to app_id of zero.
1916
-  $application_map[0] = bts('All', array(), NULL, 'boinc:task-table');
1917
-  $stitems = array();
1918
-  foreach ($taskstates as $state => $numstates) {
1914
+    }
1915
+    // Need an "All" tab as well, maps to app_id of zero.
1916
+    $application_map[0] = bts('All', array(), NULL, 'boinc:task-table');
1917
+    $stitems = array();
1918
+    foreach ($taskstates as $state => $numstates) {
1919 1919
     $mypath = $pathprefix . '/' . $state . '/' . $app_id;
1920 1920
     if ($state==STATE_ALL) {
1921
-      $ltext = '<span class="tab task-app-name">' . bts('All', array(), NULL, 'boinc:task-table') . ' (' . $numstates . ')</span>';
1921
+        $ltext = '<span class="tab task-app-name">' . bts('All', array(), NULL, 'boinc:task-table') . ' (' . $numstates . ')</span>';
1922 1922
     }
1923 1923
     else {
1924
-      $ltext = '<span class="tab">' . bts($state_hnames[$state], array(), NULL, 'boinc:task-table') . ' (' . $numstates . ')</span>';
1924
+        $ltext = '<span class="tab">' . bts($state_hnames[$state], array(), NULL, 'boinc:task-table') . ' (' . $numstates . ')</span>';
1925 1925
     }
1926 1926
     $myitem = array(
1927
-      'data' => l($ltext, $mypath, array('html' => TRUE) ),
1927
+        'data' => l($ltext, $mypath, array('html' => TRUE) ),
1928 1928
     );
1929 1929
     if ($state==$tselect) {
1930
-      $myitem['class'] = 'active';
1930
+        $myitem['class'] = 'active';
1931 1931
     }
1932 1932
     $stitems[] = $myitem;
1933
-  }
1934
-  // Add reset button
1935
-  $mypath = $pathprefix . '/0/0';
1936
-  $ltext = '<span class="tab">' . bts('Reset', array(), NULL, 'boinc:task-table') . '</span>';
1937
-  $stitems[] = array( 'data' => l($ltext, $mypath, array('html' => TRUE) ) );
1933
+    }
1934
+    // Add reset button
1935
+    $mypath = $pathprefix . '/0/0';
1936
+    $ltext = '<span class="tab">' . bts('Reset', array(), NULL, 'boinc:task-table') . '</span>';
1937
+    $stitems[] = array( 'data' => l($ltext, $mypath, array('html' => TRUE) ) );
1938 1938
 
1939
-  $output .= theme_item_list($stitems, NULL, 'ul' . ' class="tabs secondary clearfix"');
1939
+    $output .= theme_item_list($stitems, NULL, 'ul' . ' class="tabs secondary clearfix"');
1940 1940
 
1941
-  // Application select-drop down form
1942
-  // Hack to place Application form into header
1943
-  // App ID of zero maps to "-1" for drop-down box.
1944
-  if ($app_id==0) {
1941
+    // Application select-drop down form
1942
+    // Hack to place Application form into header
1943
+    // App ID of zero maps to "-1" for drop-down box.
1944
+    if ($app_id==0) {
1945 1945
     $app_id=-1;
1946
-  }
1947
-  $resultheader[] = drupal_get_form('boincwork_selectapp_form', $applications, $app_id);
1946
+    }
1947
+    $resultheader[] = drupal_get_form('boincwork_selectapp_form', $applications, $app_id);
1948 1948
 
1949
-  // Begin table of results
1950
-  if ( is_array($resultheader) AND is_array($resultdata) ) {
1949
+    // Begin table of results
1950
+    if ( is_array($resultheader) AND is_array($resultdata) ) {
1951 1951
 
1952 1952
     // Take advantage of the fact that $category is the same as the row/column we want to remove.
1953 1953
     if ( ($category==1) OR ($category==2) ) {
1954
-      unset($resultheader[$category]);
1955
-      delete_col($resultdata, $category);
1954
+        unset($resultheader[$category]);
1955
+        delete_col($resultdata, $category);
1956 1956
     }
1957 1957
 
1958 1958
     $output .= theme_table($resultheader, $resultdata);
1959 1959
     if (count($resultdata) > 0) {
1960
-      $output .= theme('pager');
1960
+        $output .= theme('pager');
1961 1961
     }
1962
-  }
1963
-  return $output;
1962
+    }
1963
+    return $output;
1964 1964
 }
1965 1965
 
1966 1966
 /**
1967 1967
  * Function to delete a column from an array.
1968 1968
  */
1969 1969
 function delete_col(&$array, $offset) {
1970
-  return array_walk($array, function (&$v) use ($offset) {
1971
-     array_splice($v, $offset, 1);
1972
-  });
1970
+    return array_walk($array, function (&$v) use ($offset) {
1971
+        array_splice($v, $offset, 1);
1972
+    });
1973 1973
 }
1974 1974
 
1975 1975
 /**
@@ -1989,7 +1989,7 @@  discard block
 block discarded – undo
1989 1989
  *  platform name, may be NULL
1990 1990
  */
1991 1991
 function pretty_application_version($appverid, $vernum, $plan_class, $plfm) {
1992
-  switch ($appverid) {
1992
+    switch ($appverid) {
1993 1993
     case ANON_PLATFORM_UNKNOWN:
1994 1994
       return "Anonymous platform";
1995 1995
     case ANON_PLATFORM_CPU:
@@ -2008,11 +2008,11 @@  discard block
 block discarded – undo
2008 2008
       // that is not handled by the above case statements.
2009 2009
       if ($appverid < 0) {
2010 2010
         return "Unknown Anonymous platform";
2011
-      }
2012
-      else {
2011
+        }
2012
+        else {
2013 2013
         $prettyv = sprintf("%d.%02d", $vernum/100, $vernum%100);
2014 2014
         $prettyc = ($plan_class) ? "($av->plan_class)" : '';
2015 2015
         return "v$prettyv $prettyc $plfm";
2016
-      }
2017
-  }
2016
+        }
2017
+    }
2018 2018
 }
Please login to merge, or discard this patch.
Spacing   +88 added lines, -88 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
 
@@ -1129,11 +1129,11 @@  discard block
 block discarded – undo
1129 1129
   $magnitude = 0;
1130 1130
   $precision = 0;
1131 1131
   if ($digits > $max_digits) {
1132
-    $magnitude = floor(($digits - ($max_digits - 3)) / 3);
1133
-    $precision = $max_digits - ($digits - ($magnitude * 3) + 1);
1134
-    $number = round($number / pow(1000, $magnitude), $precision);
1132
+    $magnitude = floor(($digits - ($max_digits - 3))/3);
1133
+    $precision = $max_digits - ($digits - ($magnitude*3) + 1);
1134
+    $number = round($number/pow(1000, $magnitude), $precision);
1135 1135
   }
1136
-  $number = number_format($number, $precision) . (($magnitude) ? "{$suffix[$magnitude]}" : '');
1136
+  $number = number_format($number, $precision).(($magnitude) ? "{$suffix[$magnitude]}" : '');
1137 1137
 
1138 1138
   return $number;
1139 1139
 }
@@ -1310,7 +1310,7 @@  discard block
 block discarded – undo
1310 1310
 
1311 1311
   function text_to_xml($text) {
1312 1312
     $xml = new DomDocument();
1313
-    if ( !($xml->loadXML($text)) ) return false;
1313
+    if (!($xml->loadXML($text))) return false;
1314 1314
     return $xml;
1315 1315
   }
1316 1316
 
@@ -1327,7 +1327,7 @@  discard block
 block discarded – undo
1327 1327
       while (!is_null($node)) {
1328 1328
           switch ($node->nodeType) {
1329 1329
           case XML_TEXT_NODE:
1330
-              if (trim($node->nodeValue)  != '') $result = $node->nodeValue;
1330
+              if (trim($node->nodeValue) != '') $result = $node->nodeValue;
1331 1331
               break;
1332 1332
           case XML_ELEMENT_NODE:
1333 1333
               $node_name = $node->nodeName;
@@ -1344,7 +1344,7 @@  discard block
 block discarded – undo
1344 1344
               if ($sibling) {
1345 1345
                   $result[$node_name][$index] = '';
1346 1346
                   if ($node->childNodes) {
1347
-                      $result[$node_name][$index] = xml_to_array($node) ;
1347
+                      $result[$node_name][$index] = xml_to_array($node);
1348 1348
                   }
1349 1349
                   if ($node->hasAttributes()) {
1350 1350
                       $attributes = $node->attributes;
@@ -1367,14 +1367,14 @@  discard block
 block discarded – undo
1367 1367
               } else {
1368 1368
                   $result[$node_name] = '';
1369 1369
                   if ($node->childNodes) {
1370
-                      $result[$node_name] = xml_to_array($node) ;
1370
+                      $result[$node_name] = xml_to_array($node);
1371 1371
                   }
1372 1372
                   if ($node->hasAttributes()) {
1373 1373
                       $attributes = $node->attributes;
1374 1374
                       if ($result[$node_name] !== '' AND !is_array($result[$node_name])) {
1375 1375
                           $result[$node_name] = array('@value' => $result[$node_name]);
1376 1376
                       }
1377
-                      foreach($attributes as $key => $attribute) {
1377
+                      foreach ($attributes as $key => $attribute) {
1378 1378
                           $result[$node_name]['@attributes'][$attribute->name] = $attribute->value;
1379 1379
                       }
1380 1380
                   }
@@ -1414,30 +1414,30 @@  discard block
 block discarded – undo
1414 1414
   // Determine if hosts are associated at all or just hidden
1415 1415
   $output = '';
1416 1416
   if ($boincuser->show_hosts) {
1417
-    switch($context) {
1417
+    switch ($context) {
1418 1418
     case 'active':
1419
-      $output .=  '<h2>' . bts('No active computers', array(), NULL, 'boinc:host-list') . '</h2>';
1420
-      $output .=  '<p>' . bts('This user has no computers that have been'
1421
-      . ' active in the last 30 days.', array(), NULL, 'boinc:host-list') . '</p>';
1419
+      $output .= '<h2>'.bts('No active computers', array(), NULL, 'boinc:host-list').'</h2>';
1420
+      $output .= '<p>'.bts('This user has no computers that have been'
1421
+      . ' active in the last 30 days.', array(), NULL, 'boinc:host-list').'</p>';
1422 1422
       break;
1423 1423
 
1424 1424
     case 'preferences':
1425
-      $output .=  '<h2>' . bts('No computers', array(), NULL, 'boinc:host-list') . '</h2>';
1426
-      $output .=  '<p>' . bts('There are no computers assigned to this'
1427
-      . ' preference set.', array(), NULL, 'boinc:host-list') . '</p>';
1425
+      $output .= '<h2>'.bts('No computers', array(), NULL, 'boinc:host-list').'</h2>';
1426
+      $output .= '<p>'.bts('There are no computers assigned to this'
1427
+      . ' preference set.', array(), NULL, 'boinc:host-list').'</p>';
1428 1428
       break;
1429 1429
 
1430 1430
     default:
1431
-      $output .=  '<h2>' . bts('Computers pending', array(), NULL, 'boinc:host-list') . '</h2>';
1432
-      $output .=  '<p>' . bts('This user does not yet have any associated'
1431
+      $output .= '<h2>'.bts('Computers pending', array(), NULL, 'boinc:host-list').'</h2>';
1432
+      $output .= '<p>'.bts('This user does not yet have any associated'
1433 1433
       . ' computers. Computers will be displayed when they have earned their'
1434
-      . ' first credits.', array(), NULL, 'boinc:host-list') . '</p>';
1434
+      . ' first credits.', array(), NULL, 'boinc:host-list').'</p>';
1435 1435
     }
1436 1436
   }
1437 1437
   else {
1438
-    $output .=  '<h2>' . bts('Computers hidden', array(), NULL, 'boinc:host-list') . '</h2>';
1439
-    $output .=  '<p>' . bts('This user has chosen not to show information'
1440
-    . ' about their computers.', array(), NULL, 'boinc:host-list') . '</p>';
1438
+    $output .= '<h2>'.bts('Computers hidden', array(), NULL, 'boinc:host-list').'</h2>';
1439
+    $output .= '<p>'.bts('This user has chosen not to show information'
1440
+    . ' about their computers.', array(), NULL, 'boinc:host-list').'</p>';
1441 1441
   }
1442 1442
   return $output;
1443 1443
 }
@@ -1449,11 +1449,11 @@  discard block
 block discarded – undo
1449 1449
 
1450 1450
   //
1451 1451
   $output = '';
1452
-  switch($context) {
1452
+  switch ($context) {
1453 1453
   default:
1454
-    $output .=  '<h2>' . bts('No @type tasks', array('@type' => $context), NULL, 'boinc:task-list')
1454
+    $output .= '<h2>'.bts('No @type tasks', array('@type' => $context), NULL, 'boinc:task-list')
1455 1455
     . '</h2>';
1456
-    $output .=  '<p>' . bts('There are no tasks of this type on record', array(), NULL, 'boinc:task-list')
1456
+    $output .= '<p>'.bts('There are no tasks of this type on record', array(), NULL, 'boinc:task-list')
1457 1457
     . '</p>';
1458 1458
   }
1459 1459
   return $output;
@@ -1475,10 +1475,10 @@  discard block
 block discarded – undo
1475 1475
       $output .= l(bts('Delete', array(), NULL, 'boinc:form-delete'), "host/{$host_id}/delete",
1476 1476
         array(
1477 1477
           'attributes' => array(
1478
-            'onclick' => 'return confirm(\'' . bts('This will delete host @id'
1478
+            'onclick' => 'return confirm(\''.bts('This will delete host @id'
1479 1479
               . ' from your account forever. Are you sure this is OK?',
1480 1480
               array('@id' => $host_id),
1481
-              NULL, 'boinc:account-host-delete') . '\')'
1481
+              NULL, 'boinc:account-host-delete').'\')'
1482 1482
           )
1483 1483
         )
1484 1484
       );
@@ -1568,8 +1568,8 @@  discard block
 block discarded – undo
1568 1568
       "{$path}/school" => bts('School', array(), NULL, 'boinc:account-preferences-location')
1569 1569
     );
1570 1570
     variable_set('jump_use_js_venues-Array', 1);
1571
-    drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js');
1572
-    drupal_add_js(drupal_get_path('theme', 'boinc') . '/js/prefs.js', 'theme');
1571
+    drupal_add_js(drupal_get_path('module', 'jump').'/jump.js');
1572
+    drupal_add_js(drupal_get_path('theme', 'boinc').'/js/prefs.js', 'theme');
1573 1573
     // Get current venue
1574 1574
     db_set_active('boinc_ro');
1575 1575
     $venue = db_result(db_query(
@@ -1593,10 +1593,10 @@  discard block
 block discarded – undo
1593 1593
     // Add a wrapper to deadline text
1594 1594
     if (!$received_time) {
1595 1595
       if (time() < $deadline) {
1596
-        $output = '<span class="on-time">' . $output . '</span>';
1596
+        $output = '<span class="on-time">'.$output.'</span>';
1597 1597
       }
1598 1598
       else {
1599
-        $output = '<span class="past-due">' . $output . '</span>';
1599
+        $output = '<span class="past-due">'.$output.'</span>';
1600 1600
       }
1601 1601
     }
1602 1602
   }
@@ -1632,15 +1632,15 @@  discard block
 block discarded – undo
1632 1632
  */
1633 1633
 function boincwork_tasktable($category = 0, $queryid = 1, $tselect = NULL, $app_id = 0, $tablerows = 20) {
1634 1634
   // Check type parameter, if not (0,2) then return an error.
1635
-  if ( ($category!=0) AND ($category!=1) AND ($category!=2) ) {
1635
+  if (($category != 0) AND ($category != 1) AND ($category != 2)) {
1636 1636
     watchdog('boincwork', 'task table called with invalid category = %category', array('%category' => $category), WATCHDOG_WARNING);
1637 1637
     return '';
1638 1638
   }
1639 1639
 
1640
-  require_boinc( array('util', 'result') );
1640
+  require_boinc(array('util', 'result'));
1641 1641
 
1642 1642
   global $language;
1643
-  $locality=$language->language;
1643
+  $locality = $language->language;
1644 1644
   $nf = new NumberFormatter($locality, NumberFormatter::DECIMAL);
1645 1645
   $nf->setAttribute(NumberFormatter::MIN_FRACTION_DIGITS, 0);
1646 1646
   $nf->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, 0);
@@ -1688,13 +1688,13 @@  discard block
 block discarded – undo
1688 1688
       ."ON r.appid=a.id ";
1689 1689
 
1690 1690
   // Use userid, hostid, or workunitid
1691
-  if ($category==0) {
1691
+  if ($category == 0) {
1692 1692
     $sqlall .= " WHERE r.userid='%s' ";
1693 1693
   }
1694
-  elseif ($category==1) {
1694
+  elseif ($category == 1) {
1695 1695
     $sqlall .= " WHERE r.workunitid='%s' ";
1696 1696
   }
1697
-  elseif ($category==2) {
1697
+  elseif ($category == 2) {
1698 1698
     $sqlall .= " WHERE r.hostid='%s' ";
1699 1699
   }
1700 1700
   $sqlall .= " ORDER BY user_friendly_name";
@@ -1705,7 +1705,7 @@  discard block
 block discarded – undo
1705 1705
   if ($dbres_all) {
1706 1706
     while ($result = db_fetch_object($dbres_all)) {
1707 1707
       $mystate = state_num($result);
1708
-      if ( ($result->appid==$app_id) OR ($app_id==0) OR ($app_id==-1) ) {
1708
+      if (($result->appid == $app_id) OR ($app_id == 0) OR ($app_id == -1)) {
1709 1709
         $taskstates[STATE_ALL]++;
1710 1710
         switch ($mystate) {
1711 1711
         case STATE_IN_PROGRESS:
@@ -1728,7 +1728,7 @@  discard block
 block discarded – undo
1728 1728
 
1729 1729
       //map holds a map between app ids and user friendly names for all applications.
1730 1730
       $application_map[$result->appid] = $result->user_friendly_name;
1731
-      if ( ($mystate == $tselect) OR ($tselect==STATE_ALL) ) {
1731
+      if (($mystate == $tselect) OR ($tselect == STATE_ALL)) {
1732 1732
         //count of appids in the results.
1733 1733
         $application_select_count[$result->appid]++;
1734 1734
       }// if mystate
@@ -1741,14 +1741,14 @@  discard block
 block discarded – undo
1741 1741
   // Entry for all applications.
1742 1742
   $allcount = $application_select_count ? array_sum($application_select_count) : 0;
1743 1743
   $applications[-1] = bts('Application', array(), NULL, 'boinc:task-table');
1744
-  $applications[0] = bts('All applications', array(), NULL, 'boinc:task-table') . ' (' . $allcount . ')';
1744
+  $applications[0] = bts('All applications', array(), NULL, 'boinc:task-table').' ('.$allcount.')';
1745 1745
   // Create application filter from application_map and application_select_count.
1746
-  foreach($application_map as $akey => $aname) {
1746
+  foreach ($application_map as $akey => $aname) {
1747 1747
     $acount = 0;
1748
-    if ( $application_select_count and array_key_exists($akey, $application_select_count) ) {
1748
+    if ($application_select_count and array_key_exists($akey, $application_select_count)) {
1749 1749
       $acount = $application_select_count[$akey];
1750 1750
     }
1751
-    $applications[$akey] = $aname . ' ('. $acount . ')';
1751
+    $applications[$akey] = $aname.' ('.$acount.')';
1752 1752
   }
1753 1753
   // Header array for (sub) results table.
1754 1754
   $resultheader = array(
@@ -1827,13 +1827,13 @@  discard block
 block discarded – undo
1827 1827
   $sqlwhere = array();
1828 1828
 
1829 1829
   // Use userid, hostid, or workunitid
1830
-  if ($category==0) {
1830
+  if ($category == 0) {
1831 1831
     $sqlwhere[] = "r.userid = '%s'";
1832 1832
   }
1833
-  elseif ($category==1) {
1833
+  elseif ($category == 1) {
1834 1834
     $sqlwhere[] = "r.workunitid = '%s'";
1835 1835
   }
1836
-  elseif ($category==2) {
1836
+  elseif ($category == 2) {
1837 1837
     $sqlwhere[] = "r.hostid = '%s'";
1838 1838
   }
1839 1839
 
@@ -1857,14 +1857,14 @@  discard block
 block discarded – undo
1857 1857
   default:
1858 1858
   }
1859 1859
 
1860
-  if (is_numeric($app_id) AND $app_id>0 ) {
1860
+  if (is_numeric($app_id) AND $app_id > 0) {
1861 1861
     $sqlwhere[] = "r.appid = '%s'";
1862
-    if ($sqlwhere)  $sqlsub .= " WHERE " . implode(' AND ', $sqlwhere);
1863
-    $dbres_sub = pager_query( $sqlsub . tablesort_sql($resultheader), $tablerows, 0, NULL, $queryid, $app_id);
1862
+    if ($sqlwhere)  $sqlsub .= " WHERE ".implode(' AND ', $sqlwhere);
1863
+    $dbres_sub = pager_query($sqlsub.tablesort_sql($resultheader), $tablerows, 0, NULL, $queryid, $app_id);
1864 1864
   }
1865 1865
   else {
1866
-    if ($sqlwhere)  $sqlsub .= " WHERE " . implode(' AND ', $sqlwhere);
1867
-    $dbres_sub = pager_query( $sqlsub . tablesort_sql($resultheader), $tablerows, 0, NULL, $queryid);
1866
+    if ($sqlwhere)  $sqlsub .= " WHERE ".implode(' AND ', $sqlwhere);
1867
+    $dbres_sub = pager_query($sqlsub.tablesort_sql($resultheader), $tablerows, 0, NULL, $queryid);
1868 1868
   }
1869 1869
   db_set_active('default');
1870 1870
 
@@ -1874,7 +1874,7 @@  discard block
 block discarded – undo
1874 1874
       // state_num() function changes $result object, clone $result
1875 1875
       // object for use in state_num()
1876 1876
       // check if state matches selection
1877
-      if ( (state_num(clone $result) == $tselect) OR ($tselect==STATE_ALL) ) {
1877
+      if ((state_num(clone $result) == $tselect) OR ($tselect == STATE_ALL)) {
1878 1878
         // create pretty result row
1879 1879
         $prettyresult = array(
1880 1880
           array(
@@ -1890,7 +1890,7 @@  discard block
 block discarded – undo
1890 1890
           $nf->format($result->cpu_time),
1891 1891
           $nf->format($result->granted_credit),
1892 1892
           array(
1893
-            'data' => $result->user_friendly_name . " " . pretty_application_version($result->app_version_id,$result->version_number, $result->plan_class, $result->platform),
1893
+            'data' => $result->user_friendly_name." ".pretty_application_version($result->app_version_id, $result->version_number, $result->plan_class, $result->platform),
1894 1894
             'class' => 'task-app',
1895 1895
           ),
1896 1896
         );
@@ -1903,54 +1903,54 @@  discard block
 block discarded – undo
1903 1903
   // Begin result navigation
1904 1904
 
1905 1905
   // Set pathprefix based on type
1906
-  if ($category==0) {
1906
+  if ($category == 0) {
1907 1907
     $pathprefix = 'account/tasks';
1908 1908
   }
1909
-  elseif ($category==1) {
1910
-    $pathprefix = 'workunit/' . $queryid . '/tasks';
1909
+  elseif ($category == 1) {
1910
+    $pathprefix = 'workunit/'.$queryid.'/tasks';
1911 1911
   }
1912
-  elseif ($category==2) {
1913
-    $pathprefix = 'host/' . $queryid . '/tasks';
1912
+  elseif ($category == 2) {
1913
+    $pathprefix = 'host/'.$queryid.'/tasks';
1914 1914
   }
1915 1915
   // Need an "All" tab as well, maps to app_id of zero.
1916 1916
   $application_map[0] = bts('All', array(), NULL, 'boinc:task-table');
1917 1917
   $stitems = array();
1918 1918
   foreach ($taskstates as $state => $numstates) {
1919
-    $mypath = $pathprefix . '/' . $state . '/' . $app_id;
1920
-    if ($state==STATE_ALL) {
1921
-      $ltext = '<span class="tab task-app-name">' . bts('All', array(), NULL, 'boinc:task-table') . ' (' . $numstates . ')</span>';
1919
+    $mypath = $pathprefix.'/'.$state.'/'.$app_id;
1920
+    if ($state == STATE_ALL) {
1921
+      $ltext = '<span class="tab task-app-name">'.bts('All', array(), NULL, 'boinc:task-table').' ('.$numstates.')</span>';
1922 1922
     }
1923 1923
     else {
1924
-      $ltext = '<span class="tab">' . bts($state_hnames[$state], array(), NULL, 'boinc:task-table') . ' (' . $numstates . ')</span>';
1924
+      $ltext = '<span class="tab">'.bts($state_hnames[$state], array(), NULL, 'boinc:task-table').' ('.$numstates.')</span>';
1925 1925
     }
1926 1926
     $myitem = array(
1927
-      'data' => l($ltext, $mypath, array('html' => TRUE) ),
1927
+      'data' => l($ltext, $mypath, array('html' => TRUE)),
1928 1928
     );
1929
-    if ($state==$tselect) {
1929
+    if ($state == $tselect) {
1930 1930
       $myitem['class'] = 'active';
1931 1931
     }
1932 1932
     $stitems[] = $myitem;
1933 1933
   }
1934 1934
   // Add reset button
1935
-  $mypath = $pathprefix . '/0/0';
1936
-  $ltext = '<span class="tab">' . bts('Reset', array(), NULL, 'boinc:task-table') . '</span>';
1937
-  $stitems[] = array( 'data' => l($ltext, $mypath, array('html' => TRUE) ) );
1935
+  $mypath = $pathprefix.'/0/0';
1936
+  $ltext = '<span class="tab">'.bts('Reset', array(), NULL, 'boinc:task-table').'</span>';
1937
+  $stitems[] = array('data' => l($ltext, $mypath, array('html' => TRUE)));
1938 1938
 
1939
-  $output .= theme_item_list($stitems, NULL, 'ul' . ' class="tabs secondary clearfix"');
1939
+  $output .= theme_item_list($stitems, NULL, 'ul'.' class="tabs secondary clearfix"');
1940 1940
 
1941 1941
   // Application select-drop down form
1942 1942
   // Hack to place Application form into header
1943 1943
   // App ID of zero maps to "-1" for drop-down box.
1944
-  if ($app_id==0) {
1945
-    $app_id=-1;
1944
+  if ($app_id == 0) {
1945
+    $app_id = -1;
1946 1946
   }
1947 1947
   $resultheader[] = drupal_get_form('boincwork_selectapp_form', $applications, $app_id);
1948 1948
 
1949 1949
   // Begin table of results
1950
-  if ( is_array($resultheader) AND is_array($resultdata) ) {
1950
+  if (is_array($resultheader) AND is_array($resultdata)) {
1951 1951
 
1952 1952
     // Take advantage of the fact that $category is the same as the row/column we want to remove.
1953
-    if ( ($category==1) OR ($category==2) ) {
1953
+    if (($category == 1) OR ($category == 2)) {
1954 1954
       unset($resultheader[$category]);
1955 1955
       delete_col($resultdata, $category);
1956 1956
     }
@@ -1967,7 +1967,7 @@  discard block
 block discarded – undo
1967 1967
  * Function to delete a column from an array.
1968 1968
  */
1969 1969
 function delete_col(&$array, $offset) {
1970
-  return array_walk($array, function (&$v) use ($offset) {
1970
+  return array_walk($array, function(&$v) use ($offset) {
1971 1971
      array_splice($v, $offset, 1);
1972 1972
   });
1973 1973
 }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +122 added lines, -122 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
           }
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
  *Add another user to the current user's ignore list using a BOINC
900 900
  *username. Called from privacy preference form.
901 901
  */
902
-function boincwork_ignore_user_add_user_username($name = NULL) {
902
+function boincwork_ignore_user_add_user_username($name = null) {
903 903
   global $user;
904 904
 
905 905
   if (isset($name)) {
@@ -911,7 +911,7 @@  discard block
 block discarded – undo
911 911
     $iuid = get_drupal_id($boincid);
912 912
 
913 913
     if ($user->uid == $iuid) {
914
-      drupal_set_message(bts('You can\'t add yourself to your own ignore list.', array(), NULL, 'boinc:ignore-user-error-message'), 'error');
914
+      drupal_set_message(bts('You can\'t add yourself to your own ignore list.', array(), null, 'boinc:ignore-user-error-message'), 'error');
915 915
       drupal_goto('account/prefs/privacy');
916 916
     }
917 917
 
@@ -933,11 +933,11 @@  discard block
 block discarded – undo
933 933
 /**
934 934
  * Add another user's UID to the current user's ignore list.
935 935
  */
936
-function boincwork_ignore_user_add_user($iuid = NULL) {
936
+function boincwork_ignore_user_add_user($iuid = null) {
937 937
   global $user;
938 938
 
939 939
   if ($user->uid == $iuid) {
940
-    drupal_set_message(bts('You can\'t add yourself to your own ignore list.', array(), NULL, 'boinc:ignore-user-error-message'), 'error');
940
+    drupal_set_message(bts('You can\'t add yourself to your own ignore list.', array(), null, 'boinc:ignore-user-error-message'), 'error');
941 941
     drupal_goto();
942 942
   }
943 943
 
@@ -958,9 +958,9 @@  discard block
 block discarded – undo
958 958
       bts('@username has been added to your ignore list. See your !privacy_preferences for more details.',
959 959
         array(
960 960
           '@username' => $otheraccount->boincuser_name,
961
-          '!privacy_preferences' => l(bts('privacy preferences', array(), NULL, 'boinc:ignore-user-add'), 'account/prefs/privacy'),
961
+          '!privacy_preferences' => l(bts('privacy preferences', array(), null, 'boinc:ignore-user-add'), 'account/prefs/privacy'),
962 962
         ),
963
-        NULL, 'boinc:ignore-user-add'),
963
+        null, 'boinc:ignore-user-add'),
964 964
       'status');
965 965
     drupal_goto();
966 966
   }
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
 /**
973 973
  * Remove user from user's ignore list.
974 974
  */
975
-function boincwork_ignore_user_remove_user($iuid = NULL) {
975
+function boincwork_ignore_user_remove_user($iuid = null) {
976 976
   global $user;
977 977
   $otheraccount = user_load($iuid);
978 978
 
@@ -984,9 +984,9 @@  discard block
 block discarded – undo
984 984
     bts('@username has been removed from your ignore list. See your !privacy_preferences for more details.',
985 985
       array(
986 986
         '@username' => $otheraccount->boincuser_name,
987
-        '!privacy_preferences' => l(bts('privacy preferences', array(), NULL, 'boinc:ignore-user-add'), 'account/prefs/privacy'),
987
+        '!privacy_preferences' => l(bts('privacy preferences', array(), null, 'boinc:ignore-user-add'), 'account/prefs/privacy'),
988 988
       ),
989
-      NULL, 'boinc:ignore-user-add'),
989
+      null, 'boinc:ignore-user-add'),
990 990
     'status');
991 991
   drupal_goto('account/prefs/privacy');
992 992
 }
@@ -1063,14 +1063,14 @@  discard block
 block discarded – undo
1063 1063
       else {
1064 1064
         $form_field = $field;
1065 1065
       }
1066
-      if (isset($rules['datatype']) AND !boincwork_validate_datatype($values[$field], $rules['datatype'])) {
1067
-        form_set_error($form_field, bts('Invalid data type for @field', array('@field' => $field), NULL, 'boinc:account-preferences'));
1066
+      if (isset($rules['datatype']) and !boincwork_validate_datatype($values[$field], $rules['datatype'])) {
1067
+        form_set_error($form_field, bts('Invalid data type for @field', array('@field' => $field), null, 'boinc:account-preferences'));
1068 1068
       }
1069
-      if (isset($rules['min']) AND $values[$field] < $rules['min']) {
1070
-        form_set_error($form_field, bts('Minimum value not met for @field', array('@field' => $field), NULL, 'boinc:account-preferences'));
1069
+      if (isset($rules['min']) and $values[$field] < $rules['min']) {
1070
+        form_set_error($form_field, bts('Minimum value not met for @field', array('@field' => $field), null, 'boinc:account-preferences'));
1071 1071
       }
1072
-      if (isset($rules['max']) AND $values[$field] > $rules['max']) {
1073
-        form_set_error($form_field, bts('Maximum value exceeded for @field', array('@field' => $field), NULL, 'boinc:account-preferences'));
1072
+      if (isset($rules['max']) and $values[$field] > $rules['max']) {
1073
+        form_set_error($form_field, bts('Maximum value exceeded for @field', array('@field' => $field), null, 'boinc:account-preferences'));
1074 1074
       }
1075 1075
     }
1076 1076
   }
@@ -1079,25 +1079,25 @@  discard block
 block discarded – undo
1079 1079
 /**
1080 1080
  * Check that numeric data conforms to specifications
1081 1081
  */
1082
-function boincwork_validate_datatype($data, $datatype = NULL) {
1082
+function boincwork_validate_datatype($data, $datatype = null) {
1083 1083
   switch ($datatype) {
1084 1084
   case 'float':
1085 1085
     if (!is_numeric($data)) {
1086
-      return FALSE;
1086
+      return false;
1087 1087
     }
1088 1088
     $data += 0.0;
1089 1089
     if (!is_float($data)) {
1090
-      return FALSE;
1090
+      return false;
1091 1091
     }
1092 1092
     break;
1093 1093
 
1094 1094
   case 'integer':
1095 1095
     if (!is_numeric($data)) {
1096
-      return FALSE;
1096
+      return false;
1097 1097
     }
1098 1098
     $data += 0;
1099 1099
     if (!is_int($data)) {
1100
-      return FALSE;
1100
+      return false;
1101 1101
     }
1102 1102
     break;
1103 1103
 
@@ -1105,7 +1105,7 @@  discard block
 block discarded – undo
1105 1105
   default:
1106 1106
 
1107 1107
   }
1108
-  return TRUE;
1108
+  return true;
1109 1109
 }
1110 1110
 
1111 1111
 /**
@@ -1182,7 +1182,7 @@  discard block
 block discarded – undo
1182 1182
       if (is_array($value)) {
1183 1183
         if (is_numeric(key($value))) {
1184 1184
           foreach ($value as $item) {
1185
-            if (is_array($item) AND isset($item['@position'])) {
1185
+            if (is_array($item) and isset($item['@position'])) {
1186 1186
               $ordered_array[$item['@position']] = array(
1187 1187
                 $name => $item
1188 1188
               );
@@ -1335,10 +1335,10 @@  discard block
 block discarded – undo
1335 1335
               $sibling = $node->nextSibling;
1336 1336
 
1337 1337
               // Determine if this node forms a set with siblings (share a node name)
1338
-              while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->nextSibling;
1338
+              while (($sibling) and (($sibling->nodeType != XML_ELEMENT_NODE) or ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->nextSibling;
1339 1339
               if (!$sibling) {
1340 1340
                   $sibling = $node->previousSibling;
1341
-                  while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->previousSibling;
1341
+                  while (($sibling) and (($sibling->nodeType != XML_ELEMENT_NODE) or ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->previousSibling;
1342 1342
               }
1343 1343
 
1344 1344
               if ($sibling) {
@@ -1348,7 +1348,7 @@  discard block
 block discarded – undo
1348 1348
                   }
1349 1349
                   if ($node->hasAttributes()) {
1350 1350
                       $attributes = $node->attributes;
1351
-                      if ($result[$node_name][$index] !== '' AND !is_array($result[$node_name][$index])) {
1351
+                      if ($result[$node_name][$index] !== '' and !is_array($result[$node_name][$index])) {
1352 1352
                           $result[$node_name][$index] = array('@value' => $result[$node_name][$index]);
1353 1353
                       }
1354 1354
                       foreach ($attributes as $key => $attribute) {
@@ -1371,7 +1371,7 @@  discard block
 block discarded – undo
1371 1371
                   }
1372 1372
                   if ($node->hasAttributes()) {
1373 1373
                       $attributes = $node->attributes;
1374
-                      if ($result[$node_name] !== '' AND !is_array($result[$node_name])) {
1374
+                      if ($result[$node_name] !== '' and !is_array($result[$node_name])) {
1375 1375
                           $result[$node_name] = array('@value' => $result[$node_name]);
1376 1376
                       }
1377 1377
                       foreach($attributes as $key => $attribute) {
@@ -1402,7 +1402,7 @@  discard block
 block discarded – undo
1402 1402
 /**
1403 1403
   * Determine output for host list views when no hosts are found.
1404 1404
   */
1405
-function boincwork_views_host_list_empty_text($context = NULL) {
1405
+function boincwork_views_host_list_empty_text($context = null) {
1406 1406
 
1407 1407
   // Pull the BOINC user ID from the view arguments to get show_hosts
1408 1408
   // preference for that user
@@ -1416,28 +1416,28 @@  discard block
 block discarded – undo
1416 1416
   if ($boincuser->show_hosts) {
1417 1417
     switch($context) {
1418 1418
     case 'active':
1419
-      $output .=  '<h2>' . bts('No active computers', array(), NULL, 'boinc:host-list') . '</h2>';
1419
+      $output .=  '<h2>' . bts('No active computers', array(), null, 'boinc:host-list') . '</h2>';
1420 1420
       $output .=  '<p>' . bts('This user has no computers that have been'
1421
-      . ' active in the last 30 days.', array(), NULL, 'boinc:host-list') . '</p>';
1421
+      . ' active in the last 30 days.', array(), null, 'boinc:host-list') . '</p>';
1422 1422
       break;
1423 1423
 
1424 1424
     case 'preferences':
1425
-      $output .=  '<h2>' . bts('No computers', array(), NULL, 'boinc:host-list') . '</h2>';
1425
+      $output .=  '<h2>' . bts('No computers', array(), null, 'boinc:host-list') . '</h2>';
1426 1426
       $output .=  '<p>' . bts('There are no computers assigned to this'
1427
-      . ' preference set.', array(), NULL, 'boinc:host-list') . '</p>';
1427
+      . ' preference set.', array(), null, 'boinc:host-list') . '</p>';
1428 1428
       break;
1429 1429
 
1430 1430
     default:
1431
-      $output .=  '<h2>' . bts('Computers pending', array(), NULL, 'boinc:host-list') . '</h2>';
1431
+      $output .=  '<h2>' . bts('Computers pending', array(), null, 'boinc:host-list') . '</h2>';
1432 1432
       $output .=  '<p>' . bts('This user does not yet have any associated'
1433 1433
       . ' computers. Computers will be displayed when they have earned their'
1434
-      . ' first credits.', array(), NULL, 'boinc:host-list') . '</p>';
1434
+      . ' first credits.', array(), null, 'boinc:host-list') . '</p>';
1435 1435
     }
1436 1436
   }
1437 1437
   else {
1438
-    $output .=  '<h2>' . bts('Computers hidden', array(), NULL, 'boinc:host-list') . '</h2>';
1438
+    $output .=  '<h2>' . bts('Computers hidden', array(), null, 'boinc:host-list') . '</h2>';
1439 1439
     $output .=  '<p>' . bts('This user has chosen not to show information'
1440
-    . ' about their computers.', array(), NULL, 'boinc:host-list') . '</p>';
1440
+    . ' about their computers.', array(), null, 'boinc:host-list') . '</p>';
1441 1441
   }
1442 1442
   return $output;
1443 1443
 }
@@ -1445,15 +1445,15 @@  discard block
 block discarded – undo
1445 1445
 /**
1446 1446
   * Determine output for task list views when no tasks are found.
1447 1447
   */
1448
-function boincwork_views_task_list_empty_text($context = NULL) {
1448
+function boincwork_views_task_list_empty_text($context = null) {
1449 1449
 
1450 1450
   //
1451 1451
   $output = '';
1452 1452
   switch($context) {
1453 1453
   default:
1454
-    $output .=  '<h2>' . bts('No @type tasks', array('@type' => $context), NULL, 'boinc:task-list')
1454
+    $output .=  '<h2>' . bts('No @type tasks', array('@type' => $context), null, 'boinc:task-list')
1455 1455
     . '</h2>';
1456
-    $output .=  '<p>' . bts('There are no tasks of this type on record', array(), NULL, 'boinc:task-list')
1456
+    $output .=  '<p>' . bts('There are no tasks of this type on record', array(), null, 'boinc:task-list')
1457 1457
     . '</p>';
1458 1458
   }
1459 1459
   return $output;
@@ -1467,18 +1467,18 @@  discard block
 block discarded – undo
1467 1467
   if (boincwork_host_user_is_owner($host_id)) {
1468 1468
     // Show merge hosts option
1469 1469
     $output = '<ul class="tab-list"><li class="first tab">';
1470
-    $output .= l(bts('Merge', array(), NULL, 'boinc:form-merge'), "host/{$host_id}/merge");
1470
+    $output .= l(bts('Merge', array(), null, 'boinc:form-merge'), "host/{$host_id}/merge");
1471 1471
     $output .= '</li>';
1472 1472
     // If host has no tasks, allow the host to be deleted
1473 1473
     if (!boincwork_host_get_task_count($host_id)) {
1474 1474
       $output .= '<li class="tab">';
1475
-      $output .= l(bts('Delete', array(), NULL, 'boinc:form-delete'), "host/{$host_id}/delete",
1475
+      $output .= l(bts('Delete', array(), null, 'boinc:form-delete'), "host/{$host_id}/delete",
1476 1476
         array(
1477 1477
           'attributes' => array(
1478 1478
             'onclick' => 'return confirm(\'' . bts('This will delete host @id'
1479 1479
               . ' from your account forever. Are you sure this is OK?',
1480 1480
               array('@id' => $host_id),
1481
-              NULL, 'boinc:account-host-delete') . '\')'
1481
+              null, 'boinc:account-host-delete') . '\')'
1482 1482
           )
1483 1483
         )
1484 1484
       );
@@ -1518,7 +1518,7 @@  discard block
 block discarded – undo
1518 1518
 /**
1519 1519
  * Check whether a user is the owner of a host
1520 1520
  */
1521
-function boincwork_host_user_is_owner($host_id, $uid = NULL) {
1521
+function boincwork_host_user_is_owner($host_id, $uid = null) {
1522 1522
   if (!$uid) {
1523 1523
     global $user;
1524 1524
     $uid = $user->uid;
@@ -1537,18 +1537,18 @@  discard block
 block discarded – undo
1537 1537
 /**
1538 1538
   * Determine output for host last contact time
1539 1539
   */
1540
-function boincwork_host_last_contact($timestamp, $host_id = NULL, $context = NULL) {
1540
+function boincwork_host_last_contact($timestamp, $host_id = null, $context = null) {
1541 1541
   $output = '---';
1542 1542
   $root_log_dir = variable_get('boinc_host_sched_logs_dir', '');
1543 1543
   $log = '';
1544 1544
   if ($timestamp) {
1545 1545
     $output = date('j M Y G:i:s T', $timestamp);
1546 1546
   }
1547
-  if ($root_log_dir AND $host_id) {
1548
-    $subdir = substr($host_id, 0, -3) OR $subdir = 0;
1547
+  if ($root_log_dir and $host_id) {
1548
+    $subdir = substr($host_id, 0, -3) or $subdir = 0;
1549 1549
     $log = implode('/', array($root_log_dir, $subdir, $host_id));
1550 1550
   }
1551
-  if ($log AND file_exists($log)) {
1551
+  if ($log and file_exists($log)) {
1552 1552
     $output = l($output, "host/{$host_id}/log");
1553 1553
   }
1554 1554
   return $output;
@@ -1562,10 +1562,10 @@  discard block
 block discarded – undo
1562 1562
   if (function_exists('jump_quickly')) {
1563 1563
     $path = "host/{$host_id}/set-venue";
1564 1564
     $venues = array(
1565
-      "{$path}/generic" => bts('Generic', array(), NULL, 'boinc:account-preferences-location'),
1566
-      "{$path}/home" => bts('Home', array(), NULL, 'boinc:account-preferences-location:-1:ignoreoverwrite'),
1567
-      "{$path}/work" => bts('Work', array(), NULL, 'boinc:account-preferences-location'),
1568
-      "{$path}/school" => bts('School', array(), NULL, 'boinc:account-preferences-location')
1565
+      "{$path}/generic" => bts('Generic', array(), null, 'boinc:account-preferences-location'),
1566
+      "{$path}/home" => bts('Home', array(), null, 'boinc:account-preferences-location:-1:ignoreoverwrite'),
1567
+      "{$path}/work" => bts('Work', array(), null, 'boinc:account-preferences-location'),
1568
+      "{$path}/school" => bts('School', array(), null, 'boinc:account-preferences-location')
1569 1569
     );
1570 1570
     variable_set('jump_use_js_venues-Array', 1);
1571 1571
     drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js');
@@ -1585,9 +1585,9 @@  discard block
 block discarded – undo
1585 1585
 /**
1586 1586
   * Determine output for task reported time / deadline
1587 1587
   */
1588
-function boincwork_task_time_reported($received_time = NULL, $deadline = NULL, $context = NULL) {
1588
+function boincwork_task_time_reported($received_time = null, $deadline = null, $context = null) {
1589 1589
   $output = '---';
1590
-  if ($received_time OR $deadline) {
1590
+  if ($received_time or $deadline) {
1591 1591
     $timestamp = ($received_time) ? $received_time : $deadline;
1592 1592
     $output = date('j M Y G:i:s T', $timestamp);
1593 1593
     // Add a wrapper to deadline text
@@ -1630,9 +1630,9 @@  discard block
 block discarded – undo
1630 1630
  * @param int $tablerows
1631 1631
  *   Number of table row to display per page. Defaults to 20.
1632 1632
  */
1633
-function boincwork_tasktable($category = 0, $queryid = 1, $tselect = NULL, $app_id = 0, $tablerows = 20) {
1633
+function boincwork_tasktable($category = 0, $queryid = 1, $tselect = null, $app_id = 0, $tablerows = 20) {
1634 1634
   // Check type parameter, if not (0,2) then return an error.
1635
-  if ( ($category!=0) AND ($category!=1) AND ($category!=2) ) {
1635
+  if ( ($category!=0) and ($category!=1) and ($category!=2) ) {
1636 1636
     watchdog('boincwork', 'task table called with invalid category = %category', array('%category' => $category), WATCHDOG_WARNING);
1637 1637
     return '';
1638 1638
   }
@@ -1705,7 +1705,7 @@  discard block
 block discarded – undo
1705 1705
   if ($dbres_all) {
1706 1706
     while ($result = db_fetch_object($dbres_all)) {
1707 1707
       $mystate = state_num($result);
1708
-      if ( ($result->appid==$app_id) OR ($app_id==0) OR ($app_id==-1) ) {
1708
+      if ( ($result->appid==$app_id) or ($app_id==0) or ($app_id==-1) ) {
1709 1709
         $taskstates[STATE_ALL]++;
1710 1710
         switch ($mystate) {
1711 1711
         case STATE_IN_PROGRESS:
@@ -1728,7 +1728,7 @@  discard block
 block discarded – undo
1728 1728
 
1729 1729
       //map holds a map between app ids and user friendly names for all applications.
1730 1730
       $application_map[$result->appid] = $result->user_friendly_name;
1731
-      if ( ($mystate == $tselect) OR ($tselect==STATE_ALL) ) {
1731
+      if ( ($mystate == $tselect) or ($tselect==STATE_ALL) ) {
1732 1732
         //count of appids in the results.
1733 1733
         $application_select_count[$result->appid]++;
1734 1734
       }// if mystate
@@ -1740,8 +1740,8 @@  discard block
 block discarded – undo
1740 1740
 
1741 1741
   // Entry for all applications.
1742 1742
   $allcount = $application_select_count ? array_sum($application_select_count) : 0;
1743
-  $applications[-1] = bts('Application', array(), NULL, 'boinc:task-table');
1744
-  $applications[0] = bts('All applications', array(), NULL, 'boinc:task-table') . ' (' . $allcount . ')';
1743
+  $applications[-1] = bts('Application', array(), null, 'boinc:task-table');
1744
+  $applications[0] = bts('All applications', array(), null, 'boinc:task-table') . ' (' . $allcount . ')';
1745 1745
   // Create application filter from application_map and application_select_count.
1746 1746
   foreach($application_map as $akey => $aname) {
1747 1747
     $acount = 0;
@@ -1753,37 +1753,37 @@  discard block
 block discarded – undo
1753 1753
   // Header array for (sub) results table.
1754 1754
   $resultheader = array(
1755 1755
     array(
1756
-      'data' => bts('Task ID', array(), NULL, 'boinc:task-table'),
1756
+      'data' => bts('Task ID', array(), null, 'boinc:task-table'),
1757 1757
       'field' => 'id',
1758 1758
     ),
1759 1759
     array(
1760
-      'data' => bts('Workunit ID', array(), NULL, 'boinc:task-table'),
1760
+      'data' => bts('Workunit ID', array(), null, 'boinc:task-table'),
1761 1761
       'field' => 'workunitid',
1762 1762
     ),
1763 1763
     array(
1764
-      'data' => bts('Computer', array(), NULL, 'boinc:task-table'),
1764
+      'data' => bts('Computer', array(), null, 'boinc:task-table'),
1765 1765
       'field' => 'hostid',
1766 1766
     ),
1767 1767
     array(
1768
-      'data' => bts('Sent', array(), NULL, 'boinc:task-table'),
1768
+      'data' => bts('Sent', array(), null, 'boinc:task-table'),
1769 1769
       'field' => 'sent_time',
1770 1770
     ),
1771 1771
     array(
1772
-      'data' => bts('Time Reported or Deadline', array(), NULL, 'boinc:task-table')
1772
+      'data' => bts('Time Reported or Deadline', array(), null, 'boinc:task-table')
1773 1773
     ),
1774 1774
     array(
1775
-      'data' => bts('Status', array(), NULL, 'boinc:task-table')
1775
+      'data' => bts('Status', array(), null, 'boinc:task-table')
1776 1776
     ),
1777 1777
     array(
1778
-      'data' => bts('Run time', array(), NULL, 'boinc:task-table'),
1778
+      'data' => bts('Run time', array(), null, 'boinc:task-table'),
1779 1779
       'field' => 'elapsed_time',
1780 1780
     ),
1781 1781
     array(
1782
-      'data' => bts('CPU time', array(), NULL, 'boinc:task-table'),
1782
+      'data' => bts('CPU time', array(), null, 'boinc:task-table'),
1783 1783
       'field' => 'cpu_time',
1784 1784
     ),
1785 1785
     array(
1786
-      'data' => bts('Granted Credit', array(), NULL, 'boinc:task-table'),
1786
+      'data' => bts('Granted Credit', array(), null, 'boinc:task-table'),
1787 1787
       'field' => 'granted_credit',
1788 1788
     ),
1789 1789
     // Application is a column, but won't be added until after tablesort_sql().
@@ -1857,14 +1857,14 @@  discard block
 block discarded – undo
1857 1857
   default:
1858 1858
   }
1859 1859
 
1860
-  if (is_numeric($app_id) AND $app_id>0 ) {
1860
+  if (is_numeric($app_id) and $app_id>0 ) {
1861 1861
     $sqlwhere[] = "r.appid = '%s'";
1862 1862
     if ($sqlwhere)  $sqlsub .= " WHERE " . implode(' AND ', $sqlwhere);
1863
-    $dbres_sub = pager_query( $sqlsub . tablesort_sql($resultheader), $tablerows, 0, NULL, $queryid, $app_id);
1863
+    $dbres_sub = pager_query( $sqlsub . tablesort_sql($resultheader), $tablerows, 0, null, $queryid, $app_id);
1864 1864
   }
1865 1865
   else {
1866 1866
     if ($sqlwhere)  $sqlsub .= " WHERE " . implode(' AND ', $sqlwhere);
1867
-    $dbres_sub = pager_query( $sqlsub . tablesort_sql($resultheader), $tablerows, 0, NULL, $queryid);
1867
+    $dbres_sub = pager_query( $sqlsub . tablesort_sql($resultheader), $tablerows, 0, null, $queryid);
1868 1868
   }
1869 1869
   db_set_active('default');
1870 1870
 
@@ -1874,7 +1874,7 @@  discard block
 block discarded – undo
1874 1874
       // state_num() function changes $result object, clone $result
1875 1875
       // object for use in state_num()
1876 1876
       // check if state matches selection
1877
-      if ( (state_num(clone $result) == $tselect) OR ($tselect==STATE_ALL) ) {
1877
+      if ( (state_num(clone $result) == $tselect) or ($tselect==STATE_ALL) ) {
1878 1878
         // create pretty result row
1879 1879
         $prettyresult = array(
1880 1880
           array(
@@ -1913,18 +1913,18 @@  discard block
 block discarded – undo
1913 1913
     $pathprefix = 'host/' . $queryid . '/tasks';
1914 1914
   }
1915 1915
   // Need an "All" tab as well, maps to app_id of zero.
1916
-  $application_map[0] = bts('All', array(), NULL, 'boinc:task-table');
1916
+  $application_map[0] = bts('All', array(), null, 'boinc:task-table');
1917 1917
   $stitems = array();
1918 1918
   foreach ($taskstates as $state => $numstates) {
1919 1919
     $mypath = $pathprefix . '/' . $state . '/' . $app_id;
1920 1920
     if ($state==STATE_ALL) {
1921
-      $ltext = '<span class="tab task-app-name">' . bts('All', array(), NULL, 'boinc:task-table') . ' (' . $numstates . ')</span>';
1921
+      $ltext = '<span class="tab task-app-name">' . bts('All', array(), null, 'boinc:task-table') . ' (' . $numstates . ')</span>';
1922 1922
     }
1923 1923
     else {
1924
-      $ltext = '<span class="tab">' . bts($state_hnames[$state], array(), NULL, 'boinc:task-table') . ' (' . $numstates . ')</span>';
1924
+      $ltext = '<span class="tab">' . bts($state_hnames[$state], array(), null, 'boinc:task-table') . ' (' . $numstates . ')</span>';
1925 1925
     }
1926 1926
     $myitem = array(
1927
-      'data' => l($ltext, $mypath, array('html' => TRUE) ),
1927
+      'data' => l($ltext, $mypath, array('html' => true) ),
1928 1928
     );
1929 1929
     if ($state==$tselect) {
1930 1930
       $myitem['class'] = 'active';
@@ -1933,10 +1933,10 @@  discard block
 block discarded – undo
1933 1933
   }
1934 1934
   // Add reset button
1935 1935
   $mypath = $pathprefix . '/0/0';
1936
-  $ltext = '<span class="tab">' . bts('Reset', array(), NULL, 'boinc:task-table') . '</span>';
1937
-  $stitems[] = array( 'data' => l($ltext, $mypath, array('html' => TRUE) ) );
1936
+  $ltext = '<span class="tab">' . bts('Reset', array(), null, 'boinc:task-table') . '</span>';
1937
+  $stitems[] = array( 'data' => l($ltext, $mypath, array('html' => true) ) );
1938 1938
 
1939
-  $output .= theme_item_list($stitems, NULL, 'ul' . ' class="tabs secondary clearfix"');
1939
+  $output .= theme_item_list($stitems, null, 'ul' . ' class="tabs secondary clearfix"');
1940 1940
 
1941 1941
   // Application select-drop down form
1942 1942
   // Hack to place Application form into header
@@ -1947,10 +1947,10 @@  discard block
 block discarded – undo
1947 1947
   $resultheader[] = drupal_get_form('boincwork_selectapp_form', $applications, $app_id);
1948 1948
 
1949 1949
   // Begin table of results
1950
-  if ( is_array($resultheader) AND is_array($resultdata) ) {
1950
+  if ( is_array($resultheader) and is_array($resultdata) ) {
1951 1951
 
1952 1952
     // Take advantage of the fact that $category is the same as the row/column we want to remove.
1953
-    if ( ($category==1) OR ($category==2) ) {
1953
+    if ( ($category==1) or ($category==2) ) {
1954 1954
       unset($resultheader[$category]);
1955 1955
       delete_col($resultdata, $category);
1956 1956
     }
Please login to merge, or discard this patch.
Switch Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -643,9 +643,9 @@  discard block
 block discarded – undo
643 643
     }
644 644
     break;
645 645
 
646
-    default:
647
-      // Don't generate form elements for things that aren't explicitly form
648
-      // elements (i.e. 'title', '@attributes' keys, and the like)
646
+  default:
647
+    // Don't generate form elements for things that aren't explicitly form
648
+    // elements (i.e. 'title', '@attributes' keys, and the like)
649 649
   }
650 650
 }
651 651
 
@@ -1990,31 +1990,31 @@  discard block
 block discarded – undo
1990 1990
  */
1991 1991
 function pretty_application_version($appverid, $vernum, $plan_class, $plfm) {
1992 1992
   switch ($appverid) {
1993
-    case ANON_PLATFORM_UNKNOWN:
1994
-      return "Anonymous platform";
1995
-    case ANON_PLATFORM_CPU:
1996
-      return "Anonymous platform CPU";
1997
-    case ANON_PLATFORM_NVIDIA:
1998
-      return "Anonymous platform NVIDIA GPU";
1999
-    case ANON_PLATFORM_ATI:
2000
-      return "Anonymous platform AMD GPU";
2001
-    case ANON_PLATFORM_INTEL_GPU:
2002
-      return "Anonymous platform Intel GPU";
2003
-    case ANON_PLATFORM_APPLE_GPU:
2004
-      return "Anonymous platform Apple GPU";
2005
-    case 0:
2006
-      return "---";
2007
-    default:
2008
-      // Handle the case where the appversid is still negative. This
2009
-      // may be cause BOINC has introduced a new anonymous platform
2010
-      // that is not handled by the above case statements.
2011
-      if ($appverid < 0) {
2012
-        return "Unknown Anonymous platform";
2013
-      }
2014
-      else {
2015
-        $prettyv = sprintf("%d.%02d", $vernum/100, $vernum%100);
2016
-        $prettyc = ($plan_class) ? "($av->plan_class)" : '';
2017
-        return "v$prettyv $prettyc $plfm";
2018
-      }
1993
+  case ANON_PLATFORM_UNKNOWN:
1994
+    return "Anonymous platform";
1995
+  case ANON_PLATFORM_CPU:
1996
+    return "Anonymous platform CPU";
1997
+  case ANON_PLATFORM_NVIDIA:
1998
+    return "Anonymous platform NVIDIA GPU";
1999
+  case ANON_PLATFORM_ATI:
2000
+    return "Anonymous platform AMD GPU";
2001
+  case ANON_PLATFORM_INTEL_GPU:
2002
+    return "Anonymous platform Intel GPU";
2003
+  case ANON_PLATFORM_APPLE_GPU:
2004
+    return "Anonymous platform Apple GPU";
2005
+  case 0:
2006
+    return "---";
2007
+  default:
2008
+    // Handle the case where the appversid is still negative. This
2009
+    // may be cause BOINC has introduced a new anonymous platform
2010
+    // that is not handled by the above case statements.
2011
+    if ($appverid < 0) {
2012
+      return "Unknown Anonymous platform";
2013
+    }
2014
+    else {
2015
+      $prettyv = sprintf("%d.%02d", $vernum/100, $vernum%100);
2016
+      $prettyc = ($plan_class) ? "($av->plan_class)" : '';
2017
+      return "v$prettyv $prettyc $plfm";
2018
+    }
2019 2019
   }
2020 2020
 }
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boincteam/boincteam.admin.inc 4 patches
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -105,8 +105,7 @@  discard block
 block discarded – undo
105 105
       $drupalnid = boincteam_lookup_nid($result->id);
106 106
       if ($drupalnid) {
107 107
         $tlink = l($result->name, '/community/teams/' . $drupalnid);
108
-      }
109
-      else {
108
+      } else {
110 109
         $tlink = '';
111 110
       }
112 111
       // only keys no values
@@ -181,8 +180,7 @@  discard block
 block discarded – undo
181 180
         drupal_render($form['link'][$key]),
182 181
       );
183 182
     }
184
-  }
185
-  else {
183
+  } else {
186 184
     $rows[] = array(array('data' => '<div class="error">No teams found</div>', 'colspan' => 5));
187 185
   }
188 186
   $output .= theme('table', $header, $rows);
@@ -230,8 +228,7 @@  discard block
 block discarded – undo
230 228
   if ($success) {
231 229
     $message = 'Info: Delete SPAM Teams utility- ' . count($results) . ' team(s) deleted.';
232 230
     drupal_set_message($message, 'info');
233
-  }
234
-  else {
231
+  } else {
235 232
     // An error occurred.
236 233
     // $operations contains the operations that remained unprocessed.
237 234
     $error_operation = reset($operations);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
   $form['help'] = array(
23 23
     '#type' => 'fieldset',
24 24
     '#title' => t('Help'),
25
-    '#collapsible' => TRUE,
25
+    '#collapsible' => true,
26 26
   );
27 27
 
28 28
   $form['help']['text'] = array(
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
     }
128 128
 
129 129
     $form['checkboxes'] = array('#type' => 'checkboxes', '#options' => $checkboxes);
130
-    $form['pager'] = array('#value' => theme('pager', NULL, $limit, 0));
130
+    $form['pager'] = array('#value' => theme('pager', null, $limit, 0));
131 131
 
132 132
     return $form;
133 133
   }
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
     // An error occurred.
236 236
     // $operations contains the operations that remained unprocessed.
237 237
     $error_operation = reset($operations);
238
-    $message = 'Error: An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE);
238
+    $message = 'Error: An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], true);
239 239
     drupal_set_message($message, 'error');
240 240
   }
241 241
 }
242 242
\ No newline at end of file
Please login to merge, or discard this patch.
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -17,15 +17,15 @@  discard block
 block discarded – undo
17 17
  * Utility Form to delete teams suspected of being spammers.
18 18
  */
19 19
 function boincteam_utility_delete(&$form_state) {
20
-  $form = array();
20
+    $form = array();
21 21
 
22
-  $form['help'] = array(
22
+    $form['help'] = array(
23 23
     '#type' => 'fieldset',
24 24
     '#title' => t('Help'),
25 25
     '#collapsible' => TRUE,
26
-  );
26
+    );
27 27
 
28
-  $form['help']['text'] = array(
28
+    $form['help']['text'] = array(
29 29
     '#type' => 'item',
30 30
     '#description' => t('This utility page will help in identifying BOINC teams created by SPAMMERs which can be deleted. The search will find BOINC teams that meet the following criteria.
31 31
 <ul>
@@ -38,19 +38,19 @@  discard block
 block discarded – undo
38 38
 <p> <i>How teams are deleted</i>: Select the teams to be deleted from the table below. Click "Delete Selected Teams" button to begin a batch operation to delete the teams. If you select teams, and then page through to another page of the table, your selections will be lost. I.e., only the teams select on the current page will be deleted.
39 39
 <p> The site must be offline/in maintenance mode before searching for and deleting teams. If not, the delete button below is disabled.
40 40
 '),
41
-  );
41
+    );
42 42
 
43
-  // This variable name has been changed for Drupal 7/8.
44
-  $maintenance_mode = variable_get('site_offline');
45
-  if (!$maintenance_mode) {
43
+    // This variable name has been changed for Drupal 7/8.
44
+    $maintenance_mode = variable_get('site_offline');
45
+    if (!$maintenance_mode) {
46 46
     drupal_set_message(t('WARNING: Site is online (not in maintenance mode)! Deleting teams is only allowed when site is offline. Change this setting in ') . l(t('Site maintenance'), '/admin/settings/site-maintenance'), 'warning');
47
-  }
47
+    }
48 48
 
49
-  $form['teamdelete'] = array(
49
+    $form['teamdelete'] = array(
50 50
     '#type' => 'fieldset',
51 51
     '#title' => t('Teams to delete'),
52
-  );
53
-  $form['teamdelete']['deleteall'] = array(
52
+    );
53
+    $form['teamdelete']['deleteall'] = array(
54 54
     '#type' => 'submit',
55 55
     '#disabled' => !($maintenance_mode),
56 56
     '#value' => t('Delete Selected Teams'),
@@ -58,101 +58,101 @@  discard block
 block discarded – undo
58 58
     '#attributes' => array(
59 59
         'onclick' => 'return confirm(\'' . t('You are about to delete the selected teams suspected of being SPAM. Do you want to continue?') . '\')',
60 60
     ),
61
-  );
62
-  $form['teamdelete']['results_table'] = array(
61
+    );
62
+    $form['teamdelete']['results_table'] = array(
63 63
     '#value' => drupal_get_form('boincteam_utility_team_table'),
64
-  );
64
+    );
65 65
 
66
-  return $form;
66
+    return $form;
67 67
 }
68 68
 
69 69
 function boincteam_utility_team_table() {
70 70
 
71
-  $limit=50;
72
-  $sql = "SELECT team.id AS id, team.name AS name, team.nusers AS nusers FROM {team} WHERE team.nusers<2 AND team.total_credit=0 AND team.seti_id=0 AND team.description REGEXP '<a href'";
71
+    $limit=50;
72
+    $sql = "SELECT team.id AS id, team.name AS name, team.nusers AS nusers FROM {team} WHERE team.nusers<2 AND team.total_credit=0 AND team.seti_id=0 AND team.description REGEXP '<a href'";
73 73
 
74
-  // @todo - add bts() or t()
75
-  $resultheader = array(
74
+    // @todo - add bts() or t()
75
+    $resultheader = array(
76 76
     array(
77
-      'data' => 'Team ID',
78
-      'field' => 'id',
79
-      'sort' => 'asc',
77
+        'data' => 'Team ID',
78
+        'field' => 'id',
79
+        'sort' => 'asc',
80 80
     ),
81 81
     array(
82
-      'data' => 'Team Name',
83
-      'field' => 'name',
82
+        'data' => 'Team Name',
83
+        'field' => 'name',
84 84
     ),
85 85
     array(
86
-      'data' => 'Num Users',
87
-      'field' => 'nusers',
86
+        'data' => 'Num Users',
87
+        'field' => 'nusers',
88 88
     ),
89 89
     array(
90
-      'data' => 'Link to Team',
91
-      'field' => 'link',
90
+        'data' => 'Link to Team',
91
+        'field' => 'link',
92 92
     ),
93
-  );
93
+    );
94 94
 
95
-  $tablesort = tablesort_sql($resultheader);
96
-  db_set_active('boinc_rw');
97
-  $db_res = pager_query($sql . $tablesort, $limit);
98
-  db_set_active('default');
95
+    $tablesort = tablesort_sql($resultheader);
96
+    db_set_active('boinc_rw');
97
+    $db_res = pager_query($sql . $tablesort, $limit);
98
+    db_set_active('default');
99 99
 
100
-  $form = array();
101
-  $form['options'] = array();
102
-  $checkboxes = array();
103
-  if ($db_res) {
100
+    $form = array();
101
+    $form['options'] = array();
102
+    $checkboxes = array();
103
+    if ($db_res) {
104 104
     while ($result = db_fetch_object($db_res)) {
105
-      $drupalnid = boincteam_lookup_nid($result->id);
106
-      if ($drupalnid) {
105
+        $drupalnid = boincteam_lookup_nid($result->id);
106
+        if ($drupalnid) {
107 107
         $tlink = l($result->name, '/community/teams/' . $drupalnid);
108
-      }
109
-      else {
108
+        }
109
+        else {
110 110
         $tlink = '';
111
-      }
112
-      // only keys no values
113
-      $checkboxes[$result->id] = '';
111
+        }
112
+        // only keys no values
113
+        $checkboxes[$result->id] = '';
114 114
 
115
-      $form['id'][$result->id] = array(
115
+        $form['id'][$result->id] = array(
116 116
         '#value' => $result->id,
117
-      );
118
-      $form['name'][$result->id] = array(
117
+        );
118
+        $form['name'][$result->id] = array(
119 119
         '#value' => $result->name,
120
-      );
121
-      $form['nusers'][$result->id] = array(
120
+        );
121
+        $form['nusers'][$result->id] = array(
122 122
         '#value' => $result->nusers,
123
-      );
124
-      $form['link'][$result->id] = array(
123
+        );
124
+        $form['link'][$result->id] = array(
125 125
         '#value' => $tlink,
126
-      );
126
+        );
127 127
     }
128 128
 
129 129
     $form['checkboxes'] = array('#type' => 'checkboxes', '#options' => $checkboxes);
130 130
     $form['pager'] = array('#value' => theme('pager', NULL, $limit, 0));
131 131
 
132 132
     return $form;
133
-  }
134
-  return "<p>No teams matched the criteria for a SPAM team.</p>";
133
+    }
134
+    return "<p>No teams matched the criteria for a SPAM team.</p>";
135 135
 }
136 136
 
137 137
 /**
138 138
  * Submit handler - also creates the batch job to delete the teams.
139 139
  */
140 140
 function boincteam_utility_delete_team($form, &$form_state) {
141
-  $checkedteamids = $form_state['clicked_button']['#post']['checkboxes'];
142
-  // Use batch to delete teams
143
-  $operations = array();
144
-  foreach ($checkedteamids as $id) {
141
+    $checkedteamids = $form_state['clicked_button']['#post']['checkboxes'];
142
+    // Use batch to delete teams
143
+    $operations = array();
144
+    foreach ($checkedteamids as $id) {
145 145
     $operations[] = array('boincteam_utility_batch_process', array($id));
146
-  }
147
-  $batch = array(
146
+    }
147
+    $batch = array(
148 148
     'title' => t('Processing BOINC Teams'),
149 149
     'operations' => $operations,
150 150
     'init_message' => t('Starting team deletion'),
151 151
     'finished' => 'boincteam_utility_batch_finished',
152 152
     'file' => drupal_get_path('module', 'boincteam') . '/boincteam.admin.inc',
153
-  );
154
-  batch_set($batch);
155
-  //batch_process('/admin/boinc/utility-team-delete');
153
+    );
154
+    batch_set($batch);
155
+    //batch_process('/admin/boinc/utility-team-delete');
156 156
 }
157 157
 
158 158
 /*
@@ -163,37 +163,37 @@  discard block
 block discarded – undo
163 163
  *     Input form (table)
164 164
  */
165 165
 function theme_boincteam_utility_team_table($form) {
166
-  //define table header
167
-  $header = array(
166
+    //define table header
167
+    $header = array(
168 168
     theme('table_select_header_cell'), //using that previously empty field
169 169
     array('data' => t('Team ID'), 'field' => 'id', 'sort' => 'asc'),
170 170
     array('data' => t('Name'), 'field' => 'name'),
171 171
     array('data' => t('Num Users'), 'field' => 'nusers'),
172 172
     array('data' => t('Link to Team'), 'field' => 'link'),
173
-  );
174
-  $rows = array();
175
-  $output = "";
176
-  if(!empty($form['checkboxes']['#options'])) {
173
+    );
174
+    $rows = array();
175
+    $output = "";
176
+    if(!empty($form['checkboxes']['#options'])) {
177 177
     foreach (element_children($form['id']) as $key) {
178
-      $rows[] = array(
178
+        $rows[] = array(
179 179
         drupal_render($form['checkboxes'][$key]),
180 180
         drupal_render($form['id'][$key]),
181 181
         drupal_render($form['name'][$key]),
182 182
         drupal_render($form['nusers'][$key]),
183 183
         drupal_render($form['link'][$key]),
184
-      );
184
+        );
185
+    }
185 186
     }
186
-  }
187
-  else {
187
+    else {
188 188
     $rows[] = array(array('data' => '<div class="error">No teams found</div>', 'colspan' => 5));
189
-  }
190
-  $output .= theme('table', $header, $rows);
191
-  if ($form['pager']['#value']) {
189
+    }
190
+    $output .= theme('table', $header, $rows);
191
+    if ($form['pager']['#value']) {
192 192
     $output .= drupal_render($form['pager']);
193
-  }
193
+    }
194 194
 
195
-  $output .= drupal_render($form);
196
-  return $output;
195
+    $output .= drupal_render($form);
196
+    return $output;
197 197
 }
198 198
 
199 199
 /**
@@ -202,26 +202,26 @@  discard block
 block discarded – undo
202 202
  * table. It also removes the team's drupal page (node) if found.
203 203
  */
204 204
 function boincteam_utility_batch_process($id, &$context) {
205
-  $boincteam = boincteam_load($id);
206
-  $drupalid = boincteam_lookup_nid($id);
205
+    $boincteam = boincteam_load($id);
206
+    $drupalid = boincteam_lookup_nid($id);
207 207
 
208
-  // Delete entry in team table
209
-  db_set_active('boinc_rw');
210
-  $sql1='DELETE FROM {team} WHERE id=%d';
211
-  $db_res = db_query($sql1, $id);
212
-  db_set_active('default');
208
+    // Delete entry in team table
209
+    db_set_active('boinc_rw');
210
+    $sql1='DELETE FROM {team} WHERE id=%d';
211
+    $db_res = db_query($sql1, $id);
212
+    db_set_active('default');
213 213
 
214
-  // Delete entry in boincteam table
215
-  $sql2='DELETE FROM {boincteam} WHERE id=%d';
216
-  $db_res = db_query($sql2, $id);
214
+    // Delete entry in boincteam table
215
+    $sql2='DELETE FROM {boincteam} WHERE id=%d';
216
+    $db_res = db_query($sql2, $id);
217 217
 
218
-  // Delete the drupal node (if present)
219
-  if ($drupalid) {
218
+    // Delete the drupal node (if present)
219
+    if ($drupalid) {
220 220
     node_delete($drupalid);
221
-  }
221
+    }
222 222
 
223
-  $context['results'][] = $id . ' : ' . check_plain($boincteam->name);
224
-  $context['message'] = t('Processing team @name', array('@name' => $boincteam->name));
223
+    $context['results'][] = $id . ' : ' . check_plain($boincteam->name);
224
+    $context['message'] = t('Processing team @name', array('@name' => $boincteam->name));
225 225
 }
226 226
 
227 227
 /**
@@ -229,15 +229,15 @@  discard block
 block discarded – undo
229 229
  * or failure.
230 230
  */
231 231
 function boincteam_utility_batch_finished($success, $results, $operations) {
232
-  if ($success) {
232
+    if ($success) {
233 233
     $message = 'Info: Delete SPAM Teams utility- ' . count($results) . ' team(s) deleted.';
234 234
     drupal_set_message($message, 'info');
235
-  }
236
-  else {
235
+    }
236
+    else {
237 237
     // An error occurred.
238 238
     // $operations contains the operations that remained unprocessed.
239 239
     $error_operation = reset($operations);
240 240
     $message = 'Error: An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE);
241 241
     drupal_set_message($message, 'error');
242
-  }
242
+    }
243 243
 }
244 244
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
   // This variable name has been changed for Drupal 7/8.
44 44
   $maintenance_mode = variable_get('site_offline');
45 45
   if (!$maintenance_mode) {
46
-    drupal_set_message(t('WARNING: Site is online (not in maintenance mode)! Deleting teams is only allowed when site is offline. Change this setting in ') . l(t('Site maintenance'), '/admin/settings/site-maintenance'), 'warning');
46
+    drupal_set_message(t('WARNING: Site is online (not in maintenance mode)! Deleting teams is only allowed when site is offline. Change this setting in ').l(t('Site maintenance'), '/admin/settings/site-maintenance'), 'warning');
47 47
   }
48 48
 
49 49
   $form['teamdelete'] = array(
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
     '#value' => t('Delete Selected Teams'),
57 57
     '#submit' => array('boincteam_utility_delete_team'),
58 58
     '#attributes' => array(
59
-        'onclick' => 'return confirm(\'' . t('You are about to delete the selected teams suspected of being SPAM. Do you want to continue?') . '\')',
59
+        'onclick' => 'return confirm(\''.t('You are about to delete the selected teams suspected of being SPAM. Do you want to continue?').'\')',
60 60
     ),
61 61
   );
62 62
   $form['teamdelete']['results_table'] = array(
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 
69 69
 function boincteam_utility_team_table() {
70 70
 
71
-  $limit=50;
71
+  $limit = 50;
72 72
   $sql = "SELECT team.id AS id, team.name AS name, team.nusers AS nusers FROM {team} WHERE team.nusers<2 AND team.total_credit=0 AND team.seti_id=0 AND team.description REGEXP '<a href'";
73 73
 
74 74
   // @todo - add bts() or t()
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 
95 95
   $tablesort = tablesort_sql($resultheader);
96 96
   db_set_active('boinc_rw');
97
-  $db_res = pager_query($sql . $tablesort, $limit);
97
+  $db_res = pager_query($sql.$tablesort, $limit);
98 98
   db_set_active('default');
99 99
 
100 100
   $form = array();
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
     while ($result = db_fetch_object($db_res)) {
105 105
       $drupalnid = boincteam_lookup_nid($result->id);
106 106
       if ($drupalnid) {
107
-        $tlink = l($result->name, '/community/teams/' . $drupalnid);
107
+        $tlink = l($result->name, '/community/teams/'.$drupalnid);
108 108
       }
109 109
       else {
110 110
         $tlink = '';
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
     'operations' => $operations,
150 150
     'init_message' => t('Starting team deletion'),
151 151
     'finished' => 'boincteam_utility_batch_finished',
152
-    'file' => drupal_get_path('module', 'boincteam') . '/boincteam.admin.inc',
152
+    'file' => drupal_get_path('module', 'boincteam').'/boincteam.admin.inc',
153 153
   );
154 154
   batch_set($batch);
155 155
   //batch_process('/admin/boinc/utility-team-delete');
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
   );
174 174
   $rows = array();
175 175
   $output = "";
176
-  if(!empty($form['checkboxes']['#options'])) {
176
+  if (!empty($form['checkboxes']['#options'])) {
177 177
     foreach (element_children($form['id']) as $key) {
178 178
       $rows[] = array(
179 179
         drupal_render($form['checkboxes'][$key]),
@@ -207,12 +207,12 @@  discard block
 block discarded – undo
207 207
 
208 208
   // Delete entry in team table
209 209
   db_set_active('boinc_rw');
210
-  $sql1='DELETE FROM {team} WHERE id=%d';
210
+  $sql1 = 'DELETE FROM {team} WHERE id=%d';
211 211
   $db_res = db_query($sql1, $id);
212 212
   db_set_active('default');
213 213
 
214 214
   // Delete entry in boincteam table
215
-  $sql2='DELETE FROM {boincteam} WHERE id=%d';
215
+  $sql2 = 'DELETE FROM {boincteam} WHERE id=%d';
216 216
   $db_res = db_query($sql2, $id);
217 217
 
218 218
   // Delete the drupal node (if present)
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
     node_delete($drupalid);
221 221
   }
222 222
 
223
-  $context['results'][] = $id . ' : ' . check_plain($boincteam->name);
223
+  $context['results'][] = $id.' : '.check_plain($boincteam->name);
224 224
   $context['message'] = t('Processing team @name', array('@name' => $boincteam->name));
225 225
 }
226 226
 
@@ -230,14 +230,14 @@  discard block
 block discarded – undo
230 230
  */
231 231
 function boincteam_utility_batch_finished($success, $results, $operations) {
232 232
   if ($success) {
233
-    $message = 'Info: Delete SPAM Teams utility- ' . count($results) . ' team(s) deleted.';
233
+    $message = 'Info: Delete SPAM Teams utility- '.count($results).' team(s) deleted.';
234 234
     drupal_set_message($message, 'info');
235 235
   }
236 236
   else {
237 237
     // An error occurred.
238 238
     // $operations contains the operations that remained unprocessed.
239 239
     $error_operation = reset($operations);
240
-    $message = 'Error: An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE);
240
+    $message = 'Error: An error occurred while processing '.$error_operation[0].' with arguments :'.print_r($error_operation[0], TRUE);
241 241
     drupal_set_message($message, 'error');
242 242
   }
243 243
 }
244 244
\ No newline at end of file
Please login to merge, or discard this patch.
html/inc/password_compat/password.inc 3 patches
Switch Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -50,47 +50,47 @@  discard block
 block discarded – undo
50 50
             }
51 51
             $resultLength = 0;
52 52
             switch ($algo) {
53
-                case PASSWORD_BCRYPT:
54
-                    $cost = PASSWORD_BCRYPT_DEFAULT_COST;
55
-                    if (isset($options['cost'])) {
56
-                        $cost = (int) $options['cost'];
57
-                        if ($cost < 4 || $cost > 31) {
58
-                            trigger_error(sprintf("password_hash(): Invalid bcrypt cost parameter specified: %d", $cost), E_USER_WARNING);
59
-                            return null;
60
-                        }
53
+            case PASSWORD_BCRYPT:
54
+                $cost = PASSWORD_BCRYPT_DEFAULT_COST;
55
+                if (isset($options['cost'])) {
56
+                    $cost = (int) $options['cost'];
57
+                    if ($cost < 4 || $cost > 31) {
58
+                        trigger_error(sprintf("password_hash(): Invalid bcrypt cost parameter specified: %d", $cost), E_USER_WARNING);
59
+                        return null;
61 60
                     }
62
-                    // The length of salt to generate
63
-                    $raw_salt_len = 16;
64
-                    // The length required in the final serialization
65
-                    $required_salt_len = 22;
66
-                    $hash_format = sprintf("$2y$%02d$", $cost);
67
-                    // The expected length of the final crypt() output
68
-                    $resultLength = 60;
69
-                    break;
70
-                default:
71
-                    trigger_error(sprintf("password_hash(): Unknown password hashing algorithm: %s", $algo), E_USER_WARNING);
72
-                    return null;
61
+                }
62
+                // The length of salt to generate
63
+                $raw_salt_len = 16;
64
+                // The length required in the final serialization
65
+                $required_salt_len = 22;
66
+                $hash_format = sprintf("$2y$%02d$", $cost);
67
+                // The expected length of the final crypt() output
68
+                $resultLength = 60;
69
+                break;
70
+            default:
71
+                trigger_error(sprintf("password_hash(): Unknown password hashing algorithm: %s", $algo), E_USER_WARNING);
72
+                return null;
73 73
             }
74 74
             $salt_req_encoding = false;
75 75
             if (isset($options['salt'])) {
76 76
                 switch (gettype($options['salt'])) {
77
-                    case 'NULL':
78
-                    case 'boolean':
79
-                    case 'integer':
80
-                    case 'double':
81
-                    case 'string':
77
+                case 'NULL':
78
+                case 'boolean':
79
+                case 'integer':
80
+                case 'double':
81
+                case 'string':
82
+                    $salt = (string) $options['salt'];
83
+                    break;
84
+                case 'object':
85
+                    if (method_exists($options['salt'], '__tostring')) {
82 86
                         $salt = (string) $options['salt'];
83 87
                         break;
84
-                    case 'object':
85
-                        if (method_exists($options['salt'], '__tostring')) {
86
-                            $salt = (string) $options['salt'];
87
-                            break;
88
-                        }
89
-                    case 'array':
90
-                    case 'resource':
91
-                    default:
92
-                        trigger_error('password_hash(): Non-string salt parameter supplied', E_USER_WARNING);
93
-                        return null;
88
+                    }
89
+                case 'array':
90
+                case 'resource':
91
+                default:
92
+                    trigger_error('password_hash(): Non-string salt parameter supplied', E_USER_WARNING);
93
+                    return null;
94 94
                 }
95 95
                 if (PasswordCompat\binary\_strlen($salt) < $required_salt_len) {
96 96
                     trigger_error(sprintf("password_hash(): Provided salt is too short: %d expecting %d", PasswordCompat\binary\_strlen($salt), $required_salt_len), E_USER_WARNING);
@@ -212,12 +212,12 @@  discard block
 block discarded – undo
212 212
                 return true;
213 213
             }
214 214
             switch ($algo) {
215
-                case PASSWORD_BCRYPT:
216
-                    $cost = isset($options['cost']) ? (int) $options['cost'] : PASSWORD_BCRYPT_DEFAULT_COST;
217
-                    if ($cost !== $info['options']['cost']) {
218
-                        return true;
219
-                    }
220
-                    break;
215
+            case PASSWORD_BCRYPT:
216
+                $cost = isset($options['cost']) ? (int) $options['cost'] : PASSWORD_BCRYPT_DEFAULT_COST;
217
+                if ($cost !== $info['options']['cost']) {
218
+                    return true;
219
+                }
220
+                break;
221 221
             }
222 222
             return false;
223 223
         }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
                 return null;
39 39
             }
40 40
             if (is_null($password) || is_int($password)) {
41
-                $password = (string) $password;
41
+                $password = (string)$password;
42 42
             }
43 43
             if (!is_string($password)) {
44 44
                 trigger_error("password_hash(): Password must be a string", E_USER_WARNING);
45 45
                 return null;
46 46
             }
47 47
             if (!is_int($algo)) {
48
-                trigger_error("password_hash() expects parameter 2 to be long, " . gettype($algo) . " given", E_USER_WARNING);
48
+                trigger_error("password_hash() expects parameter 2 to be long, ".gettype($algo)." given", E_USER_WARNING);
49 49
                 return null;
50 50
             }
51 51
             $resultLength = 0;
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
                 case PASSWORD_BCRYPT:
54 54
                     $cost = PASSWORD_BCRYPT_DEFAULT_COST;
55 55
                     if (isset($options['cost'])) {
56
-                        $cost = (int) $options['cost'];
56
+                        $cost = (int)$options['cost'];
57 57
                         if ($cost < 4 || $cost > 31) {
58 58
                             trigger_error(sprintf("password_hash(): Invalid bcrypt cost parameter specified: %d", $cost), E_USER_WARNING);
59 59
                             return null;
@@ -79,11 +79,11 @@  discard block
 block discarded – undo
79 79
                     case 'integer':
80 80
                     case 'double':
81 81
                     case 'string':
82
-                        $salt = (string) $options['salt'];
82
+                        $salt = (string)$options['salt'];
83 83
                         break;
84 84
                     case 'object':
85 85
                         if (method_exists($options['salt'], '__tostring')) {
86
-                            $salt = (string) $options['salt'];
86
+                            $salt = (string)$options['salt'];
87 87
                             break;
88 88
                         }
89 89
                     case 'array':
@@ -126,13 +126,13 @@  discard block
 block discarded – undo
126 126
                     if ($read >= $raw_salt_len) {
127 127
                         $buffer_valid = true;
128 128
                     }
129
-                    $buffer = str_pad($buffer, $raw_salt_len, "\0") ^ str_pad($local_buffer, $raw_salt_len, "\0");
129
+                    $buffer = str_pad($buffer, $raw_salt_len, "\0")^str_pad($local_buffer, $raw_salt_len, "\0");
130 130
                 }
131 131
                 if (!$buffer_valid || PasswordCompat\binary\_strlen($buffer) < $raw_salt_len) {
132 132
                     $buffer_length = PasswordCompat\binary\_strlen($buffer);
133 133
                     for ($i = 0; $i < $raw_salt_len; $i++) {
134 134
                         if ($i < $buffer_length) {
135
-                            $buffer[$i] = $buffer[$i] ^ chr(mt_rand(0, 255));
135
+                            $buffer[$i] = $buffer[$i]^chr(mt_rand(0, 255));
136 136
                         } else {
137 137
                             $buffer .= chr(mt_rand(0, 255));
138 138
                         }
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
             }
154 154
             $salt = PasswordCompat\binary\_substr($salt, 0, $required_salt_len);
155 155
 
156
-            $hash = $hash_format . $salt;
156
+            $hash = $hash_format.$salt;
157 157
 
158 158
             $ret = crypt($password, $hash);
159 159
 
@@ -208,12 +208,12 @@  discard block
 block discarded – undo
208 208
          */
209 209
         function password_needs_rehash($hash, $algo, array $options = array()) {
210 210
             $info = password_get_info($hash);
211
-            if ($info['algo'] !== (int) $algo) {
211
+            if ($info['algo'] !== (int)$algo) {
212 212
                 return true;
213 213
             }
214 214
             switch ($algo) {
215 215
                 case PASSWORD_BCRYPT:
216
-                    $cost = isset($options['cost']) ? (int) $options['cost'] : PASSWORD_BCRYPT_DEFAULT_COST;
216
+                    $cost = isset($options['cost']) ? (int)$options['cost'] : PASSWORD_BCRYPT_DEFAULT_COST;
217 217
                     if ($cost !== $info['options']['cost']) {
218 218
                         return true;
219 219
                     }
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 
243 243
             $status = 0;
244 244
             for ($i = 0; $i < PasswordCompat\binary\_strlen($ret); $i++) {
245
-                $status |= (ord($ret[$i]) ^ ord($hash[$i]));
245
+                $status |= (ord($ret[$i])^ord($hash[$i]));
246 246
             }
247 247
 
248 248
             return $status === 0;
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -299,7 +299,7 @@
 block discarded – undo
299 299
          * @return boolean the check result
300 300
          */
301 301
         function check() {
302
-            static $pass = NULL;
302
+            static $pass = null;
303 303
 
304 304
             if (is_null($pass)) {
305 305
                 if (function_exists('crypt')) {
Please login to merge, or discard this patch.
html/inc/random_compat/random_bytes_com_dotnet.inc 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,8 +38,7 @@
 block discarded – undo
38 38
      *
39 39
      * @return string
40 40
      */
41
-    function random_bytes($bytes)
42
-    {
41
+    function random_bytes($bytes) {
43 42
         try {
44 43
             $bytes = RandomCompat_intval($bytes);
45 44
         } catch (TypeError $ex) {
Please login to merge, or discard this patch.
html/inc/random_compat/random_bytes_libsodium_legacy.inc 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -70,10 +70,10 @@
 block discarded – undo
70 70
                 $n = ($bytes - $i) > 1073741824
71 71
                     ? 1073741824
72 72
                     : $bytes - $i;
73
-                $buf .= Sodium::randombytes_buf((int) $n);
73
+                $buf .= Sodium::randombytes_buf((int)$n);
74 74
             }
75 75
         } else {
76
-            $buf .= Sodium::randombytes_buf((int) $bytes);
76
+            $buf .= Sodium::randombytes_buf((int)$bytes);
77 77
         }
78 78
 
79 79
         if (is_string($buf)) {
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,8 +38,7 @@
 block discarded – undo
38 38
      *
39 39
      * @return string
40 40
      */
41
-    function random_bytes($bytes)
42
-    {
41
+    function random_bytes($bytes) {
43 42
         try {
44 43
             $bytes = RandomCompat_intval($bytes);
45 44
         } catch (TypeError $ex) {
Please login to merge, or discard this patch.
html/inc/random_compat/random_bytes_dev_urandom.inc 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,8 +44,7 @@
 block discarded – undo
44 44
      *
45 45
      * @return string
46 46
      */
47
-    function random_bytes($bytes)
48
-    {
47
+    function random_bytes($bytes) {
49 48
         static $fp = null;
50 49
         /**
51 50
          * This block should only be run once
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -141,7 +141,7 @@
 block discarded – undo
141 141
                 /**
142 142
                  * @var string|bool
143 143
                  */
144
-                $buf = $buf . $read;
144
+                $buf = $buf.$read;
145 145
             } while ($remaining > 0);
146 146
 
147 147
             /**
Please login to merge, or discard this patch.
html/inc/random_compat/random_int.inc 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
         }
79 79
 
80 80
         if ($max === $min) {
81
-            return (int) $min;
81
+            return (int)$min;
82 82
         }
83 83
 
84 84
         /**
@@ -124,12 +124,12 @@  discard block
 block discarded – undo
124 124
              * type juggling
125 125
              */
126 126
             while ($range > 0) {
127
-                if ($bits % 8 === 0) {
127
+                if ($bits%8 === 0) {
128 128
                     ++$bytes;
129 129
                 }
130 130
                 ++$bits;
131 131
                 $range >>= 1;
132
-                $mask = $mask << 1 | 1;
132
+                $mask = $mask << 1|1;
133 133
             }
134 134
             $valueShift = $min;
135 135
         }
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
              */
168 168
             $val &= 0;
169 169
             for ($i = 0; $i < $bytes; ++$i) {
170
-                $val |= ord($randomByteString[$i]) << ($i * 8);
170
+                $val |= ord($randomByteString[$i]) << ($i*8);
171 171
             }
172 172
 
173 173
             /**
@@ -185,6 +185,6 @@  discard block
 block discarded – undo
185 185
              */
186 186
         } while (!is_int($val) || $val > $max || $val < $min);
187 187
 
188
-        return (int) $val;
188
+        return (int)$val;
189 189
     }
190 190
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,8 +38,7 @@
 block discarded – undo
38 38
      *
39 39
      * @return int
40 40
      */
41
-    function random_int($min, $max)
42
-    {
41
+    function random_int($min, $max) {
43 42
         /**
44 43
          * Type and input logic checks
45 44
          *
Please login to merge, or discard this patch.
html/inc/random_compat/error_polyfill.inc 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -28,21 +28,18 @@
 block discarded – undo
28 28
 
29 29
 if (!class_exists('Error', false)) {
30 30
     // We can't really avoid making this extend Exception in PHP 5.
31
-    class Error extends Exception
32
-    {
31
+    class Error extends Exception {
33 32
         
34 33
     }
35 34
 }
36 35
 
37 36
 if (!class_exists('TypeError', false)) {
38 37
     if (is_subclass_of('Error', 'Exception')) {
39
-        class TypeError extends Error
40
-        {
38
+        class TypeError extends Error {
41 39
             
42 40
         }
43 41
     } else {
44
-        class TypeError extends Exception
45
-        {
42
+        class TypeError extends Exception {
46 43
             
47 44
         }
48 45
     }
Please login to merge, or discard this patch.