@@ -44,8 +44,7 @@ discard block |
||
44 | 44 | $nid = $existing_teams[$boinc_team->id]; |
45 | 45 | $success = boincteam_import($boinc_team, $nid); |
46 | 46 | } |
47 | - } |
|
48 | - else { |
|
47 | + } else { |
|
49 | 48 | // Import new teams created by RPC or ops/team_import.php |
50 | 49 | $success = boincteam_import($boinc_team); |
51 | 50 | } |
@@ -77,8 +76,7 @@ discard block |
||
77 | 76 | $node->body = $boincteam->description; |
78 | 77 | $node->teaser = $teaser; |
79 | 78 | $node->uid = boincuser_lookup_uid($boincteam->userid); |
80 | - } |
|
81 | - else { |
|
79 | + } else { |
|
82 | 80 | // Construct the team as a new node |
83 | 81 | $node = array( |
84 | 82 | 'type' => 'team', |
@@ -132,8 +130,7 @@ discard block |
||
132 | 130 | } |
133 | 131 | if ($boincid) { |
134 | 132 | return $ids; |
135 | - } |
|
136 | - else { |
|
133 | + } else { |
|
137 | 134 | return array_map('boincuser_lookup_uid', $ids); |
138 | 135 | } |
139 | 136 | } |
@@ -57,8 +57,7 @@ discard block |
||
57 | 57 | if (module_exists('pathauto')) { |
58 | 58 | module_load_include('inc', 'pathauto', 'pathauto'); |
59 | 59 | $node['path'] = pathauto_cleanstring($boincteam->name); |
60 | - } |
|
61 | - else { |
|
60 | + } else { |
|
62 | 61 | echo 'Pathauto module is required!'; |
63 | 62 | exit; |
64 | 63 | } |
@@ -77,7 +76,9 @@ discard block |
||
77 | 76 | // Determine team membership |
78 | 77 | db_set_active('boinc_rw'); |
79 | 78 | $boincteam_member_ids = array(); |
80 | - while ($boincuser = db_fetch_object($boincteam_members)) $boincteam_member_ids[] = $boincuser->id; |
|
79 | + while ($boincuser = db_fetch_object($boincteam_members)) { |
|
80 | + $boincteam_member_ids[] = $boincuser->id; |
|
81 | + } |
|
81 | 82 | db_set_active('default'); |
82 | 83 | if ($boincteam_member_ids) { |
83 | 84 | $team_members = db_query('SELECT uid FROM {boincuser} WHERE boinc_id IN(%s)', implode(',', $boincteam_member_ids)); |
@@ -126,8 +126,7 @@ |
||
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 |
@@ -332,8 +332,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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"; |
@@ -105,8 +105,7 @@ discard block |
||
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 |
||
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 |
||
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); |
@@ -38,8 +38,7 @@ |
||
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) { |
@@ -44,8 +44,7 @@ |
||
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 |
@@ -38,8 +38,7 @@ |
||
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 | * |
@@ -28,21 +28,18 @@ |
||
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 | } |