@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | }// switch |
72 | 72 | } else { |
73 | 73 | $form_state['storage']['wip'] = TRUE; |
74 | - if ( !in_array($prefs_preset, array('standard','maximum','green','minimum','custom')) ) { |
|
74 | + if (!in_array($prefs_preset, array('standard', 'maximum', 'green', 'minimum', 'custom'))) { |
|
75 | 75 | if ($established) { |
76 | 76 | $prefs_preset = 'custom'; |
77 | 77 | } else { |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | ); |
142 | 142 | $form['hour_options'] = array( |
143 | 143 | '#type' => 'value', |
144 | - '#value' => array('0:00','1:00','2:00','3:00','4:00', |
|
145 | - '5:00','6:00','7:00','8:00','9:00','10:00','11:00', |
|
146 | - '12:00','13:00','14:00','15:00','16:00','17:00', |
|
147 | - '18:00','19:00','20:00','21:00','22:00','23:00') |
|
144 | + '#value' => array('0:00', '1:00', '2:00', '3:00', '4:00', |
|
145 | + '5:00', '6:00', '7:00', '8:00', '9:00', '10:00', '11:00', |
|
146 | + '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', |
|
147 | + '18:00', '19:00', '20:00', '21:00', '22:00', '23:00') |
|
148 | 148 | ); |
149 | 149 | |
150 | 150 | // Identify preference sets that are established to distinguish what has been |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | '#description' => bts('Suspend computing when your computer is busy running other programs.', array(), NULL, 'boinc:account-preferences-computing'), |
282 | 282 | ); |
283 | 283 | $form['prefs']['advanced']['processor']['hour_label'] = array( |
284 | - '#value' => '<div class="form-item"><label>' . bts('Compute only between:', array(), NULL, 'boinc:account-preferences-computing') . '</label></div>' |
|
284 | + '#value' => '<div class="form-item"><label>'.bts('Compute only between:', array(), NULL, 'boinc:account-preferences-computing').'</label></div>' |
|
285 | 285 | ); |
286 | 286 | $form['prefs']['advanced']['processor']['start_hour'] = array( |
287 | 287 | '#type' => 'select', |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | '#default_value' => $default['start_hour'] |
290 | 290 | ); |
291 | 291 | $form['prefs']['advanced']['processor']['hour_delimiter'] = array( |
292 | - '#value' => '<span>' . bts('and', array(), NULL, 'boinc:account-preference') . '</span>' |
|
292 | + '#value' => '<span>'.bts('and', array(), NULL, 'boinc:account-preference').'</span>' |
|
293 | 293 | ); |
294 | 294 | $form['prefs']['advanced']['processor']['end_hour'] = array( |
295 | 295 | '#type' => 'select', |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | '#default_value' => $default['end_hour'] |
298 | 298 | ); |
299 | 299 | $form['prefs']['advanced']['processor']['hour_description'] = array( |
300 | - '#value' => '<div class="form-item slim"><div class="description">' . bts('Compute only during a particular period each day.', array(), NULL, 'boinc:account-preferences-computing') . '</div></div>' |
|
300 | + '#value' => '<div class="form-item slim"><div class="description">'.bts('Compute only during a particular period each day.', array(), NULL, 'boinc:account-preferences-computing').'</div></div>' |
|
301 | 301 | ); |
302 | 302 | $form['prefs']['advanced']['processor']['leave_apps_in_memory'] = array( |
303 | 303 | '#title' => bts('Leave non-GPU tasks in memory while suspended?', array(), NULL, 'boinc:account-preferences-computing'), |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | '#description' => bts('Limit the upload rate of file transfers.', array(), NULL, 'boinc:account-preferences-computing') |
455 | 455 | ); |
456 | 456 | $form['prefs']['advanced']['network']['hour_label'] = array( |
457 | - '#value' => '<div class="form-item"><label>' . bts('Transfer files only between', array(), NULL, 'boinc:account-preferences-computing') . '</label></div>' |
|
457 | + '#value' => '<div class="form-item"><label>'.bts('Transfer files only between', array(), NULL, 'boinc:account-preferences-computing').'</label></div>' |
|
458 | 458 | ); |
459 | 459 | $form['prefs']['advanced']['network']['net_start_hour'] = array( |
460 | 460 | '#type' => 'select', |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | '#default_value' => $default['net_start_hour'] |
463 | 463 | ); |
464 | 464 | $form['prefs']['advanced']['network']['hour_delimiter'] = array( |
465 | - '#value' => '<span>' . bts('and', array(), NULL, 'boinc:account-preference') . '</span>' |
|
465 | + '#value' => '<span>'.bts('and', array(), NULL, 'boinc:account-preference').'</span>' |
|
466 | 466 | ); |
467 | 467 | $form['prefs']['advanced']['network']['net_end_hour'] = array( |
468 | 468 | '#type' => 'select', |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | '#default_value' => $default['net_end_hour'] |
471 | 471 | ); |
472 | 472 | $form['prefs']['advanced']['network']['hour_description'] = array( |
473 | - '#value' => '<div class="form-item slim"><div class="description">' . bts('Transfer files only during a particular period each day.', array(), NULL, 'boinc:account-preferences-computing') . '</div></div>' |
|
473 | + '#value' => '<div class="form-item slim"><div class="description">'.bts('Transfer files only during a particular period each day.', array(), NULL, 'boinc:account-preferences-computing').'</div></div>' |
|
474 | 474 | ); |
475 | 475 | $form['prefs']['advanced']['network']['daily_xfer_limit_mb'] = array( |
476 | 476 | '#title' => bts('Limit usage to', array(), NULL, 'boinc:account-preferences-computing'), |
@@ -530,23 +530,23 @@ discard block |
||
530 | 530 | '#suffix' => '</li>' |
531 | 531 | ); |
532 | 532 | $form['prefs']['form control tabs'] = array( |
533 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), drupal_get_path_alias("account/prefs/computing/edit")) . '</li>' |
|
533 | + '#value' => '<li class="tab">'.l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), drupal_get_path_alias("account/prefs/computing/edit")).'</li>' |
|
534 | 534 | ); |
535 | 535 | if ($venue AND $venue != 'generic') { |
536 | 536 | global $base_path; |
537 | - $form['prefs']['form control tabs']['#value'] .= '<li class="tab">' . |
|
537 | + $form['prefs']['form control tabs']['#value'] .= '<li class="tab">'. |
|
538 | 538 | l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/computing/clear/{$venue}", |
539 | 539 | array( |
540 | - 'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/computing/combined')), |
|
540 | + 'query' => 'destination='.urlencode(drupal_get_path_alias('account/prefs/computing/combined')), |
|
541 | 541 | 'attributes' => array( |
542 | - 'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the @name preference set. Are you sure?', |
|
543 | - array('@name' => $venue), NULL, 'boinc:account-preferences') . '\')' |
|
542 | + 'onclick' => 'return confirm(\''.bts('This will remove all of your settings from the @name preference set. Are you sure?', |
|
543 | + array('@name' => $venue), NULL, 'boinc:account-preferences').'\')' |
|
544 | 544 | ) |
545 | 545 | ) |
546 | - ) . '</li>'; |
|
546 | + ).'</li>'; |
|
547 | 547 | } |
548 | 548 | $form['prefs']['view control'] = array( |
549 | - '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/computing/combined') . '</li>' |
|
549 | + '#value' => '<li class="first alt tab">'.l('('.bts('Show comparison view', array(), NULL, 'boinc:account-preferences').')', 'account/prefs/computing/combined').'</li>' |
|
550 | 550 | ); |
551 | 551 | $form['prefs']['form control tabs suffix'] = array( |
552 | 552 | '#value' => '</ul>' |
@@ -852,9 +852,9 @@ discard block |
||
852 | 852 | } |
853 | 853 | |
854 | 854 | $form['overview'] = array( |
855 | - '#value' => '<p>' . bts('Sometimes BOINC assigns separate identities to' |
|
855 | + '#value' => '<p>'.bts('Sometimes BOINC assigns separate identities to' |
|
856 | 856 | . ' the same computer by mistake. You can correct this by merging old' |
857 | - . ' identities with the newest one.', array(), NULL, 'boinc:account-host-merge') . '</p>' |
|
857 | + . ' identities with the newest one.', array(), NULL, 'boinc:account-host-merge').'</p>' |
|
858 | 858 | . '<p>' |
859 | 859 | . bts('Check the computers that are the same as @name' |
860 | 860 | . ' (created on @date at @time with computer ID @id)', |
@@ -864,7 +864,7 @@ discard block |
||
864 | 864 | '@time' => date('G:i:s T', $current_host->create_time), |
865 | 865 | '@id' => $current_host->id, |
866 | 866 | ), |
867 | - NULL, 'boinc:account-host-merge') . '</p>', |
|
867 | + NULL, 'boinc:account-host-merge').'</p>', |
|
868 | 868 | ); |
869 | 869 | |
870 | 870 | $options = array(); |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | '#suffix' => '</li>' |
899 | 899 | ); |
900 | 900 | $form['prefs']['form control tabs'] = array( |
901 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "host/{$host_id}") . '</li>' |
|
901 | + '#value' => '<li class="tab">'.l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "host/{$host_id}").'</li>' |
|
902 | 902 | ); |
903 | 903 | |
904 | 904 | return $form; |
@@ -943,7 +943,7 @@ discard block |
||
943 | 943 | if (count($merged) == 2) { |
944 | 944 | $oxford_comma = ''; |
945 | 945 | } |
946 | - $list = implode(', ', $list) . $oxford_comma . ' ' . $conjunction . ' ' . $last; |
|
946 | + $list = implode(', ', $list).$oxford_comma.' '.$conjunction.' '.$last; |
|
947 | 947 | } |
948 | 948 | else { |
949 | 949 | $list = $last; |
@@ -1192,23 +1192,23 @@ discard block |
||
1192 | 1192 | '#suffix' => '</li>' |
1193 | 1193 | ); |
1194 | 1194 | $form['prefs']['form control tabs'] = array( |
1195 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>' |
|
1195 | + '#value' => '<li class="tab">'.l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']).'</li>' |
|
1196 | 1196 | ); |
1197 | 1197 | if ($venue AND $venue != 'generic') { |
1198 | 1198 | global $base_path; |
1199 | - $form['prefs']['form control tabs']['#value'] .= '<li class="tab">' . |
|
1199 | + $form['prefs']['form control tabs']['#value'] .= '<li class="tab">'. |
|
1200 | 1200 | l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/project/clear/{$venue}", |
1201 | 1201 | array( |
1202 | - 'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/project/combined')), |
|
1202 | + 'query' => 'destination='.urlencode(drupal_get_path_alias('account/prefs/project/combined')), |
|
1203 | 1203 | 'attributes' => array( |
1204 | - 'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the @name preference set. Are you sure?', |
|
1205 | - array('@name' => $venue), NULL, 'boinc:account-preferences') . '\')' |
|
1204 | + 'onclick' => 'return confirm(\''.bts('This will remove all of your settings from the @name preference set. Are you sure?', |
|
1205 | + array('@name' => $venue), NULL, 'boinc:account-preferences').'\')' |
|
1206 | 1206 | ) |
1207 | 1207 | ) |
1208 | - ) . '</li>'; |
|
1208 | + ).'</li>'; |
|
1209 | 1209 | } |
1210 | 1210 | $form['prefs']['view control'] = array( |
1211 | - '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/project/combined') . '</li>' |
|
1211 | + '#value' => '<li class="first alt tab">'.l('('.bts('Show comparison view', array(), NULL, 'boinc:account-preferences').')', 'account/prefs/project/combined').'</li>' |
|
1212 | 1212 | ); |
1213 | 1213 | $form['prefs']['form control tabs suffix'] = array( |
1214 | 1214 | '#value' => '</ul>' |
@@ -1251,7 +1251,7 @@ discard block |
||
1251 | 1251 | |
1252 | 1252 | foreach ($xml['project_specific_preferences'] as $wrapped_element) { |
1253 | 1253 | $type = key($wrapped_element); |
1254 | - $element= reset($wrapped_element); |
|
1254 | + $element = reset($wrapped_element); |
|
1255 | 1255 | boincwork_generate_prefs_element($form, $type, $element, $prefs['project_specific']); |
1256 | 1256 | } |
1257 | 1257 | } |
@@ -1477,7 +1477,7 @@ discard block |
||
1477 | 1477 | $names = array(); |
1478 | 1478 | foreach ($languages as $langcode => $item) { |
1479 | 1479 | $name = t($item->name); |
1480 | - $names[check_plain($langcode)] = check_plain($name . ($item->native != $name ? ' ('. $item->native .')' : '')); |
|
1480 | + $names[check_plain($langcode)] = check_plain($name.($item->native != $name ? ' ('.$item->native.')' : '')); |
|
1481 | 1481 | } |
1482 | 1482 | $form['locale'] = array( |
1483 | 1483 | '#type' => 'fieldset', |
@@ -1502,20 +1502,20 @@ discard block |
||
1502 | 1502 | // Avatar options |
1503 | 1503 | $form['gravatar'] = array( |
1504 | 1504 | '#type' => 'item', |
1505 | - '#value' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, it will be used for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail), NULL, 'boinc:account-preferences-community'), |
|
1505 | + '#value' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, it will be used for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/'.$account->mail), NULL, 'boinc:account-preferences-community'), |
|
1506 | 1506 | '#description' => bts('Your Gravatar will not be shown if you upload a user picture.', array(), NULL, 'boinc:account-preferences-community'), |
1507 | 1507 | ); |
1508 | 1508 | if (user_access('disable own gravatar', $account)) { |
1509 | 1509 | $form['gravatar'] = array( |
1510 | 1510 | '#type' => 'checkbox', |
1511 | - '#title' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, use it for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail), NULL, 'boinc:account-preferences-community'), |
|
1511 | + '#title' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, use it for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/'.$account->mail), NULL, 'boinc:account-preferences-community'), |
|
1512 | 1512 | '#description' => bts('Gravatar will not be shown if an avatar is uploaded.', array(), NULL, 'boinc:account-preferences-community'), |
1513 | 1513 | '#default_value' => isset($account->gravatar) ? $account->gravatar : 0, |
1514 | 1514 | '#disabled' => !empty($account->picture), |
1515 | 1515 | ); |
1516 | 1516 | } |
1517 | 1517 | $form['gravatar']['#weight'] = 15; |
1518 | - $form['gravatar']['#prefix'] = '<fieldset class="collapsible"><legend><a href="#">' . bts('Avatar settings', array(), NULL, 'boinc:account-preferences-community') . '</a></legend>'; |
|
1518 | + $form['gravatar']['#prefix'] = '<fieldset class="collapsible"><legend><a href="#">'.bts('Avatar settings', array(), NULL, 'boinc:account-preferences-community').'</a></legend>'; |
|
1519 | 1519 | // Upload an avatar (pulled from profile_node_form): |
1520 | 1520 | if (!empty($profile_form['field_image'])) { |
1521 | 1521 | $form['field_image'] = $profile_form['field_image']; |
@@ -1550,7 +1550,7 @@ discard block |
||
1550 | 1550 | ); |
1551 | 1551 | // Can't have a typical Drupal form suffix on a select box? |
1552 | 1552 | $form['forums']['comments_per_page_suffix'] = array( |
1553 | - '#value' => '<span>' . bts('comments per page', array(), NULL, 'boinc:account-preferences-community') . '</span>' |
|
1553 | + '#value' => '<span>'.bts('comments per page', array(), NULL, 'boinc:account-preferences-community').'</span>' |
|
1554 | 1554 | ); |
1555 | 1555 | $form['forums']['comments_order'] = array( |
1556 | 1556 | '#type' => 'select', |
@@ -1603,7 +1603,7 @@ discard block |
||
1603 | 1603 | '#weight' => 1002, |
1604 | 1604 | ); |
1605 | 1605 | $form['form control tabs'] = array( |
1606 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
1606 | + '#value' => '<li class="tab">'.l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']).'</li>', |
|
1607 | 1607 | '#weight' => 1003, |
1608 | 1608 | ); |
1609 | 1609 | $form['form control tabs suffix'] = array( |
@@ -1689,10 +1689,10 @@ discard block |
||
1689 | 1689 | if ($user->language != $edit['language']) { |
1690 | 1690 | global $base_url; |
1691 | 1691 | if ($edit['language'] != language_default('language')) { |
1692 | - $form_state['redirect'] = $base_url . '/' . $edit['language'] . '/' . $_GET['q']; |
|
1692 | + $form_state['redirect'] = $base_url.'/'.$edit['language'].'/'.$_GET['q']; |
|
1693 | 1693 | } |
1694 | 1694 | else { |
1695 | - $form_state['redirect'] = $base_url . '/' . $_GET['q']; |
|
1695 | + $form_state['redirect'] = $base_url.'/'.$_GET['q']; |
|
1696 | 1696 | } |
1697 | 1697 | } |
1698 | 1698 | } |
@@ -1762,7 +1762,7 @@ discard block |
||
1762 | 1762 | // option that deals with privacy. |
1763 | 1763 | foreach ($privacy_consent_types as $ct) { |
1764 | 1764 | |
1765 | - $currstate = (check_user_consent($boincuser, $ct['shortname'])) ? 1 : 0 ; |
|
1765 | + $currstate = (check_user_consent($boincuser, $ct['shortname'])) ? 1 : 0; |
|
1766 | 1766 | // Set name to 'privacyconsent_SHORTNAME', which can be parsed |
1767 | 1767 | // later in the submit function. |
1768 | 1768 | $form['privacy']['privacyconsent_'.$ct['shortname']] = array( |
@@ -1801,7 +1801,7 @@ discard block |
||
1801 | 1801 | $form['ignoreblock']['delete'][$ignored_user['iuid']] = array( |
1802 | 1802 | '#value' => l( |
1803 | 1803 | bts('delete', array(), NULL, 'boinc:ignore-user-delete-button'), |
1804 | - 'account/prefs/privacy/ignore_user/remove/'. $ignored_user['iuid'], |
|
1804 | + 'account/prefs/privacy/ignore_user/remove/'.$ignored_user['iuid'], |
|
1805 | 1805 | array() |
1806 | 1806 | ), |
1807 | 1807 | ); |
@@ -1852,7 +1852,7 @@ discard block |
||
1852 | 1852 | '#suffix' => '</li>' |
1853 | 1853 | ); |
1854 | 1854 | $form['prefs']['form control tabs'] = array( |
1855 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>' |
|
1855 | + '#value' => '<li class="tab">'.l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']).'</li>' |
|
1856 | 1856 | ); |
1857 | 1857 | $form['prefs']['form control tabs suffix'] = array( |
1858 | 1858 | '#value' => '</ul>' |
@@ -1939,7 +1939,7 @@ discard block |
||
1939 | 1939 | $privacyconsent_prefs = array_intersect_key($form_state['values'], array_flip($result)); |
1940 | 1940 | foreach ($privacyconsent_prefs as $name => $newstate) { |
1941 | 1941 | $subname = explode('_', $name)[1]; |
1942 | - $currstate = (check_user_consent($boincuser, $subname)) ? 1 : 0 ; |
|
1942 | + $currstate = (check_user_consent($boincuser, $subname)) ? 1 : 0; |
|
1943 | 1943 | list($checkct, $ctid) = check_consent_type($subname); |
1944 | 1944 | if ($checkct && ($currstate != $newstate)) { |
1945 | 1945 | consent_to_a_policy($boincuser, $ctid, $newstate, 0, 'Webform', time()); |
@@ -2005,7 +2005,7 @@ discard block |
||
2005 | 2005 | function boincwork_selectapp_form_submit($form, &$form_state) { |
2006 | 2006 | $myargs = arg(); |
2007 | 2007 | array_pop($myargs); |
2008 | - $newpath = implode('/', $myargs ) . '/' . $form['selectapp']['#value']; |
|
2008 | + $newpath = implode('/', $myargs).'/'.$form['selectapp']['#value']; |
|
2009 | 2009 | $form_state['redirect'] = $newpath; |
2010 | 2010 | } |
2011 | 2011 |
@@ -15,16 +15,16 @@ discard block |
||
15 | 15 | * The structure of the general preferences form |
16 | 16 | */ |
17 | 17 | function boincwork_generalprefs_form(&$form_state, $venue, $prefs_preset = null, $advanced = FALSE) { |
18 | - $form = array(); |
|
19 | - $prefs = null; |
|
20 | - $established = TRUE; |
|
18 | + $form = array(); |
|
19 | + $prefs = null; |
|
20 | + $established = TRUE; |
|
21 | 21 | |
22 | - // Enable AHAH form support for dynamically updating content based on preset |
|
23 | - ahah_helper_register($form, $form_state); |
|
22 | + // Enable AHAH form support for dynamically updating content based on preset |
|
23 | + ahah_helper_register($form, $form_state); |
|
24 | 24 | |
25 | - if (!$prefs_preset) { |
|
25 | + if (!$prefs_preset) { |
|
26 | 26 | if (isset($form_state['storage']['prefs']['preset'])) { |
27 | - $prefs_preset = $form_state['storage']['prefs']['preset']; |
|
27 | + $prefs_preset = $form_state['storage']['prefs']['preset']; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | // Load preferences from BOINC account |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | // Take note if this is not an established preference set on the account |
34 | 34 | if (isset($prefs['@attributes']['cleared'])) { |
35 | - $established = FALSE; |
|
35 | + $established = FALSE; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | // Determine if a preset is selected or if these are custom settings |
@@ -47,45 +47,45 @@ discard block |
||
47 | 47 | $prefs_preset = $prefs['preset']['@value']; |
48 | 48 | } |
49 | 49 | }// if !$prefs_preset |
50 | - } |
|
51 | - // Extract mod_time tag if present, because it will be erased with |
|
52 | - // boincwork_get_preset_prefs() below. |
|
53 | - $mod_time = null; |
|
54 | - if (isset($prefs['mod_time']['@value'])) { |
|
55 | - $mod_time = $prefs['mod_time']['@value']; |
|
56 | - } |
|
57 | - |
|
58 | - if (isset($form_state['storage']['wip'])) { |
|
59 | - switch ($prefs_preset) { |
|
60 | - case 'standard': |
|
50 | + } |
|
51 | + // Extract mod_time tag if present, because it will be erased with |
|
52 | + // boincwork_get_preset_prefs() below. |
|
53 | + $mod_time = null; |
|
54 | + if (isset($prefs['mod_time']['@value'])) { |
|
55 | + $mod_time = $prefs['mod_time']['@value']; |
|
56 | + } |
|
57 | + |
|
58 | + if (isset($form_state['storage']['wip'])) { |
|
59 | + switch ($prefs_preset) { |
|
60 | + case 'standard': |
|
61 | 61 | case 'maximum': |
62 | 62 | case 'green': |
63 | 63 | case 'minimum': |
64 | 64 | $prefs = boincwork_get_preset_prefs($prefs_preset); |
65 | - break; |
|
66 | - case 'custom': |
|
65 | + break; |
|
66 | + case 'custom': |
|
67 | 67 | default: |
68 | 68 | // Just keeps prefs as they are |
69 | 69 | unset($prefs['preset']); |
70 | - break; |
|
71 | - }// switch |
|
72 | - } else { |
|
73 | - $form_state['storage']['wip'] = TRUE; |
|
74 | - if ( !in_array($prefs_preset, array('standard','maximum','green','minimum','custom')) ) { |
|
75 | - if ($established) { |
|
76 | - $prefs_preset = 'custom'; |
|
77 | - } else { |
|
78 | - $prefs_preset = 'standard'; |
|
79 | - $prefs = boincwork_get_preset_prefs($prefs_preset); |
|
80 | - }// if $established |
|
81 | - }// if $prefs_preset |
|
82 | - }// if WIP |
|
83 | - |
|
84 | - // This set of preferences is used in the form if no preferences |
|
85 | - // have been set above, in variable $prefs. |
|
86 | - require_boinc(array('db', 'prefs')); |
|
87 | - $disk_space_config = get_disk_space_config(); |
|
88 | - $default = array( |
|
70 | + break; |
|
71 | + }// switch |
|
72 | + } else { |
|
73 | + $form_state['storage']['wip'] = TRUE; |
|
74 | + if ( !in_array($prefs_preset, array('standard','maximum','green','minimum','custom')) ) { |
|
75 | + if ($established) { |
|
76 | + $prefs_preset = 'custom'; |
|
77 | + } else { |
|
78 | + $prefs_preset = 'standard'; |
|
79 | + $prefs = boincwork_get_preset_prefs($prefs_preset); |
|
80 | + }// if $established |
|
81 | + }// if $prefs_preset |
|
82 | + }// if WIP |
|
83 | + |
|
84 | + // This set of preferences is used in the form if no preferences |
|
85 | + // have been set above, in variable $prefs. |
|
86 | + require_boinc(array('db', 'prefs')); |
|
87 | + $disk_space_config = get_disk_space_config(); |
|
88 | + $default = array( |
|
89 | 89 | 'preset' => $prefs_preset, |
90 | 90 | // Processing... |
91 | 91 | 'run_on_batteries' => 0, |
@@ -120,385 +120,385 @@ discard block |
||
120 | 120 | 'daily_xfer_limit_mb' => 0, |
121 | 121 | 'daily_xfer_period_days' => 0, |
122 | 122 | 'dont_verify_images' => 0 |
123 | - ); |
|
124 | - foreach ($default as $name => $value) { |
|
123 | + ); |
|
124 | + foreach ($default as $name => $value) { |
|
125 | 125 | if (isset($prefs[$name])) { |
126 | - if (is_array($prefs[$name])) { |
|
126 | + if (is_array($prefs[$name])) { |
|
127 | 127 | if (isset($prefs[$name]['@value'])) { |
128 | - $default[$name] = $prefs[$name]['@value']; |
|
128 | + $default[$name] = $prefs[$name]['@value']; |
|
129 | + } |
|
129 | 130 | } |
130 | - } |
|
131 | - else { |
|
131 | + else { |
|
132 | 132 | $default[$name] = $prefs[$name]; |
133 | - } |
|
133 | + } |
|
134 | + } |
|
134 | 135 | } |
135 | - } |
|
136 | 136 | |
137 | - // Standard option sets |
|
138 | - $form['boolean_options'] = array( |
|
137 | + // Standard option sets |
|
138 | + $form['boolean_options'] = array( |
|
139 | 139 | '#type' => 'value', |
140 | 140 | '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')) |
141 | - ); |
|
142 | - $form['hour_options'] = array( |
|
141 | + ); |
|
142 | + $form['hour_options'] = array( |
|
143 | 143 | '#type' => 'value', |
144 | 144 | '#value' => array('0:00','1:00','2:00','3:00','4:00', |
145 | - '5:00','6:00','7:00','8:00','9:00','10:00','11:00', |
|
146 | - '12:00','13:00','14:00','15:00','16:00','17:00', |
|
147 | - '18:00','19:00','20:00','21:00','22:00','23:00') |
|
148 | - ); |
|
149 | - |
|
150 | - // Identify preference sets that are established to distinguish what has been |
|
151 | - // saved to the database from what is just showing default values |
|
152 | - $form['#established'] = $established; |
|
145 | + '5:00','6:00','7:00','8:00','9:00','10:00','11:00', |
|
146 | + '12:00','13:00','14:00','15:00','16:00','17:00', |
|
147 | + '18:00','19:00','20:00','21:00','22:00','23:00') |
|
148 | + ); |
|
149 | + |
|
150 | + // Identify preference sets that are established to distinguish what has been |
|
151 | + // saved to the database from what is just showing default values |
|
152 | + $form['#established'] = $established; |
|
153 | 153 | |
154 | - // Set up the preference container for AHAH |
|
155 | - $form['prefs'] = array( |
|
154 | + // Set up the preference container for AHAH |
|
155 | + $form['prefs'] = array( |
|
156 | 156 | '#title' => '', |
157 | 157 | '#type' => 'fieldset', |
158 | 158 | '#prefix' => '<div id="prefs-wrapper">', // This is our wrapper div. |
159 | 159 | '#attributes' => array('class' => 'ahah-container'), |
160 | 160 | '#suffix' => '</div>', |
161 | 161 | '#tree' => TRUE |
162 | - ); |
|
163 | - //$form['prefs']['debug'] = array('#value' => '<pre>' . print_r($form_state, true) . '</pre>'); |
|
162 | + ); |
|
163 | + //$form['prefs']['debug'] = array('#value' => '<pre>' . print_r($form_state, true) . '</pre>'); |
|
164 | 164 | |
165 | - // Hidden elements |
|
166 | - $form['prefs']['modified'] = array( |
|
165 | + // Hidden elements |
|
166 | + $form['prefs']['modified'] = array( |
|
167 | 167 | '#type' => 'hidden', |
168 | 168 | '#value' => $mod_time |
169 | - ); |
|
170 | - $form['prefs']['venue'] = array( |
|
169 | + ); |
|
170 | + $form['prefs']['venue'] = array( |
|
171 | 171 | '#type' => 'hidden', |
172 | 172 | '#value' => $venue |
173 | - ); |
|
173 | + ); |
|
174 | 174 | |
175 | - $form['prefs']['separator_top'] = array( |
|
175 | + $form['prefs']['separator_top'] = array( |
|
176 | 176 | '#value' => '<div class="separator"></div>' |
177 | - ); |
|
177 | + ); |
|
178 | 178 | |
179 | - // Simplified selectors |
|
180 | - $form['prefs']['preset'] = array( |
|
181 | - '#title' => bts('Presets', array(), NULL, 'boinc:account-preferences-preset:-1:for a user to choose a computing or project preference preset.'), |
|
179 | + // Simplified selectors |
|
180 | + $form['prefs']['preset'] = array( |
|
181 | + '#title' => bts('Presets', array(), NULL, 'boinc:account-preferences-preset:-1:for a user to choose a computing or project preference preset.'), |
|
182 | 182 | '#type' => 'radios', |
183 | 183 | '#description' => ' ', |
184 | 184 | '#options' => array( |
185 | - 'standard' => bts('Standard', array(), NULL, 'boinc:account-preferences-preset'), |
|
186 | - 'maximum' => bts('Maximum', array(), NULL, 'boinc:account-preferences-preset'), |
|
187 | - 'green' => bts('Green', array(), NULL, 'boinc:account-preferences-preset'), |
|
188 | - 'minimum' => bts('Minimum', array(), NULL, 'boinc:account-preferences-preset'), |
|
189 | - 'custom' => bts('Custom', array(), NULL, 'boinc:account-preferences-preset') |
|
185 | + 'standard' => bts('Standard', array(), NULL, 'boinc:account-preferences-preset'), |
|
186 | + 'maximum' => bts('Maximum', array(), NULL, 'boinc:account-preferences-preset'), |
|
187 | + 'green' => bts('Green', array(), NULL, 'boinc:account-preferences-preset'), |
|
188 | + 'minimum' => bts('Minimum', array(), NULL, 'boinc:account-preferences-preset'), |
|
189 | + 'custom' => bts('Custom', array(), NULL, 'boinc:account-preferences-preset') |
|
190 | 190 | ), |
191 | 191 | '#prefix' => '<div class="simple-form-controls">', |
192 | 192 | '#suffix' => '</div>', |
193 | 193 | '#default_value' => $default['preset'], |
194 | 194 | '#ahah' => array( |
195 | - 'event' => 'change', |
|
196 | - 'path' => ahah_helper_path(array('prefs')), |
|
197 | - 'wrapper' => 'prefs-wrapper' |
|
195 | + 'event' => 'change', |
|
196 | + 'path' => ahah_helper_path(array('prefs')), |
|
197 | + 'wrapper' => 'prefs-wrapper' |
|
198 | 198 | ) |
199 | - ); |
|
200 | - $form['prefs']['select preset'] = array( |
|
199 | + ); |
|
200 | + $form['prefs']['select preset'] = array( |
|
201 | 201 | '#type' => 'submit', |
202 | 202 | '#value' => bts('Update preset', array(), NULL, 'boinc:account-preferences-preset'), |
203 | 203 | '#submit' => array('ahah_helper_generic_submit'), |
204 | 204 | // The 'no-js' class only displays this button if javascript is disabled |
205 | 205 | '#attributes' => array('class' => 'no-js'), |
206 | - ); |
|
206 | + ); |
|
207 | 207 | |
208 | - // Advanced preferences |
|
209 | - $form['prefs']['advanced'] = array( |
|
208 | + // Advanced preferences |
|
209 | + $form['prefs']['advanced'] = array( |
|
210 | 210 | '#title' => bts('Advanced settings', array(), NULL, 'boinc:account-preferences-option'), |
211 | 211 | '#type' => 'fieldset', |
212 | 212 | '#description' => '', |
213 | 213 | '#collapsible' => TRUE, |
214 | 214 | '#collapsed' => !$advanced, |
215 | 215 | '#attributes' => array('class' => 'advanced-settings'), |
216 | - ); |
|
216 | + ); |
|
217 | 217 | |
218 | - // Processing preferences |
|
218 | + // Processing preferences |
|
219 | 219 | |
220 | - $form['prefs']['advanced']['anchor'] = array( |
|
220 | + $form['prefs']['advanced']['anchor'] = array( |
|
221 | 221 | '#value' => '<a name="advanced"></a>' |
222 | - ); |
|
222 | + ); |
|
223 | 223 | |
224 | - $form['prefs']['advanced']['separator_top'] = array( |
|
224 | + $form['prefs']['advanced']['separator_top'] = array( |
|
225 | 225 | '#value' => '<div class="separator"></div>' |
226 | - ); |
|
226 | + ); |
|
227 | 227 | |
228 | - $form['prefs']['advanced']['processor'] = array( |
|
228 | + $form['prefs']['advanced']['processor'] = array( |
|
229 | 229 | '#title' => bts('Processor usage', array(), NULL, 'boinc:account-preferences-computing'), |
230 | 230 | '#type' => 'fieldset', |
231 | 231 | '#description' => '', |
232 | 232 | '#collapsible' => FALSE, |
233 | 233 | '#collapsed' => FALSE |
234 | - ); |
|
235 | - $form['prefs']['advanced']['processor']['run_on_batteries'] = array( |
|
234 | + ); |
|
235 | + $form['prefs']['advanced']['processor']['run_on_batteries'] = array( |
|
236 | 236 | '#title' => bts('Suspend when computer is on battery?', array(), NULL, 'boinc:account-preferences-computing'), |
237 | 237 | '#type' => 'radios', |
238 | 238 | '#description' => bts('Suspends computing on portables when running on battery power.', array(), NULL, 'boinc:account-preferences-computing'), |
239 | 239 | '#options' => $form['boolean_options']['#value'], |
240 | 240 | '#attributes' => array('class' => 'fancy'), |
241 | 241 | '#default_value' => ($default['run_on_batteries']) ? 0 : 1 // intentional inversion of setting |
242 | - ); |
|
243 | - $form['prefs']['advanced']['processor']['run_if_user_active'] = array( |
|
242 | + ); |
|
243 | + $form['prefs']['advanced']['processor']['run_if_user_active'] = array( |
|
244 | 244 | '#title' => bts('Suspend when computer is in use?', array(), NULL, 'boinc:account-preferences-computing'), |
245 | 245 | '#type' => 'radios', |
246 | 246 | '#description' => bts("Suspends computing and file transfers when you're using the computer.", array(), NULL, 'boinc:account-preferences-computing'), |
247 | 247 | '#options' => $form['boolean_options']['#value'], |
248 | 248 | '#attributes' => array('class' => 'fancy'), |
249 | 249 | '#default_value' => ($default['run_if_user_active']) ? 0 : 1 // intentional inversion of setting |
250 | - ); |
|
251 | - $form['prefs']['advanced']['processor']['run_gpu_if_user_active'] = array( |
|
250 | + ); |
|
251 | + $form['prefs']['advanced']['processor']['run_gpu_if_user_active'] = array( |
|
252 | 252 | '#title' => bts('Suspend GPU computing when computer is in use?', array(), NULL, 'boinc:account-preferences-computing'), |
253 | 253 | '#type' => 'radios', |
254 | 254 | '#description' => bts("Suspends GPU computing when you're using the computer.", array(), NULL, 'boinc:account-preferences-computing'), |
255 | 255 | '#options' => $form['boolean_options']['#value'], |
256 | 256 | '#attributes' => array('class' => 'fancy'), |
257 | 257 | '#default_value' => ($default['run_gpu_if_user_active']) ? 0 : 1 // intentional inversion of setting |
258 | - ); |
|
259 | - $form['prefs']['advanced']['processor']['idle_time_to_run'] = array( |
|
260 | - '#title' => bts('"In use" means mouse/keyboard input in last', array(), NULL, 'boinc:account-preferences-computing'), |
|
258 | + ); |
|
259 | + $form['prefs']['advanced']['processor']['idle_time_to_run'] = array( |
|
260 | + '#title' => bts('"In use" means mouse/keyboard input in last', array(), NULL, 'boinc:account-preferences-computing'), |
|
261 | 261 | '#type' => 'textfield', |
262 | 262 | '#field_suffix' => bts('minutes', array(), NULL, 'boinc:unit-of-time'), |
263 | 263 | '#default_value' => $default['idle_time_to_run'], |
264 | 264 | '#size' => 1, |
265 | 265 | '#description' => bts('This determines when the computer is considered "in use".', array(), NULL, 'boinc:account-preferences-computing') |
266 | - ); |
|
267 | - $form['prefs']['advanced']['processor']['suspend_if_no_recent_input'] = array( |
|
266 | + ); |
|
267 | + $form['prefs']['advanced']['processor']['suspend_if_no_recent_input'] = array( |
|
268 | 268 | '#title' => bts('Suspend when no mouse/keyboard input in last', array(), NULL, 'boinc:account-preferences-computing'), |
269 | 269 | '#type' => 'textfield', |
270 | 270 | '#field_suffix' => bts('minutes', array(), NULL, 'boinc:unit-of-time'), |
271 | 271 | '#default_value' => $default['suspend_if_no_recent_input'], |
272 | 272 | '#size' => 1, |
273 | 273 | '#description' => bts('This allows some computers to enter low-power mode when not in use.', array(), NULL, 'boinc:account-preferences-computing') |
274 | - ); |
|
275 | - $form['prefs']['advanced']['processor']['suspend_cpu_usage'] = array( |
|
274 | + ); |
|
275 | + $form['prefs']['advanced']['processor']['suspend_cpu_usage'] = array( |
|
276 | 276 | '#title' => bts('Suspend when non-BOINC CPU usage is above', array(), NULL, 'boinc:account-preferences-computing'), |
277 | 277 | '#type' => 'textfield', |
278 | 278 | '#field_suffix' => '%', |
279 | 279 | '#default_value' => $default['suspend_cpu_usage'], |
280 | 280 | '#size' => 1, |
281 | 281 | '#description' => bts('Suspend computing when your computer is busy running other programs.', array(), NULL, 'boinc:account-preferences-computing'), |
282 | - ); |
|
283 | - $form['prefs']['advanced']['processor']['hour_label'] = array( |
|
282 | + ); |
|
283 | + $form['prefs']['advanced']['processor']['hour_label'] = array( |
|
284 | 284 | '#value' => '<div class="form-item"><label>' . bts('Compute only between:', array(), NULL, 'boinc:account-preferences-computing') . '</label></div>' |
285 | - ); |
|
286 | - $form['prefs']['advanced']['processor']['start_hour'] = array( |
|
285 | + ); |
|
286 | + $form['prefs']['advanced']['processor']['start_hour'] = array( |
|
287 | 287 | '#type' => 'select', |
288 | 288 | '#options' => $form['hour_options']['#value'], |
289 | 289 | '#default_value' => $default['start_hour'] |
290 | - ); |
|
291 | - $form['prefs']['advanced']['processor']['hour_delimiter'] = array( |
|
290 | + ); |
|
291 | + $form['prefs']['advanced']['processor']['hour_delimiter'] = array( |
|
292 | 292 | '#value' => '<span>' . bts('and', array(), NULL, 'boinc:account-preference') . '</span>' |
293 | - ); |
|
294 | - $form['prefs']['advanced']['processor']['end_hour'] = array( |
|
293 | + ); |
|
294 | + $form['prefs']['advanced']['processor']['end_hour'] = array( |
|
295 | 295 | '#type' => 'select', |
296 | 296 | '#options' => $form['hour_options']['#value'], |
297 | 297 | '#default_value' => $default['end_hour'] |
298 | - ); |
|
299 | - $form['prefs']['advanced']['processor']['hour_description'] = array( |
|
298 | + ); |
|
299 | + $form['prefs']['advanced']['processor']['hour_description'] = array( |
|
300 | 300 | '#value' => '<div class="form-item slim"><div class="description">' . bts('Compute only during a particular period each day.', array(), NULL, 'boinc:account-preferences-computing') . '</div></div>' |
301 | - ); |
|
302 | - $form['prefs']['advanced']['processor']['leave_apps_in_memory'] = array( |
|
301 | + ); |
|
302 | + $form['prefs']['advanced']['processor']['leave_apps_in_memory'] = array( |
|
303 | 303 | '#title' => bts('Leave non-GPU tasks in memory while suspended?', array(), NULL, 'boinc:account-preferences-computing'), |
304 | 304 | '#type' => 'radios', |
305 | 305 | '#options' => $form['boolean_options']['#value'], |
306 | 306 | '#attributes' => array('class' => 'fancy'), |
307 | 307 | '#default_value' => $default['leave_apps_in_memory'], |
308 | 308 | '#description' => bts('If "Yes", suspended tasks stay in memory, and resume with no work lost. If "No", suspended tasks are removed from memory, and resume from their last checkpoint.', array(), NULL, 'boinc:account-preferences-computing') |
309 | - ); |
|
310 | - $form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes'] = array( |
|
309 | + ); |
|
310 | + $form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes'] = array( |
|
311 | 311 | '#title' => bts('Switch between tasks every', array(), NULL, 'boinc:account-preferences-computing'), |
312 | 312 | '#type' => 'textfield', |
313 | 313 | '#field_suffix' => bts('minutes', array(), NULL, 'boinc:unit-of-time'), |
314 | 314 | '#default_value' => $default['cpu_scheduling_period_minutes'], |
315 | 315 | '#size' => 1, |
316 | 316 | '#description' => bts('If you run several projects, BOINC may switch between them this often.', array(), NULL, 'boinc:account-preferences-computing') |
317 | - ); |
|
318 | - $form['prefs']['advanced']['processor']['max_ncpus_pct'] = array( |
|
317 | + ); |
|
318 | + $form['prefs']['advanced']['processor']['max_ncpus_pct'] = array( |
|
319 | 319 | '#title' => bts('Use at most', array(), NULL, 'boinc:account-preferences-computing'), |
320 | 320 | '#type' => 'textfield', |
321 | 321 | '#field_suffix' => bts('% of the processors', array(), NULL, 'boinc:account-preferences-computing'), |
322 | 322 | '#default_value' => $default['max_ncpus_pct'], |
323 | 323 | '#size' => 1, |
324 | 324 | '#description' => bts('Keep some CPUs free for other applications. Example: 75% means use 6 cores on an 8-core CPU.', array(), NULL, 'boinc:account-preferences-computing'), |
325 | - ); |
|
326 | - $form['prefs']['advanced']['processor']['cpu_usage_limit'] = array( |
|
325 | + ); |
|
326 | + $form['prefs']['advanced']['processor']['cpu_usage_limit'] = array( |
|
327 | 327 | '#title' => bts('Use at most', array(), NULL, 'boinc:account-preferences-computing'), |
328 | 328 | '#type' => 'textfield', |
329 | 329 | '#field_suffix' => bts('% of the CPU time', array(), NULL, 'boinc:account-preferences-computing'), |
330 | 330 | '#default_value' => $default['cpu_usage_limit'], |
331 | 331 | '#size' => 1, |
332 | 332 | '#description' => bts('Suspend/resume computing every few seconds to reduce CPU temperature and energy usage. Example: 75% means compute for 3 seconds, wait for 1 second, and repeat.', array(), NULL, 'boinc:account-preferences-computing') |
333 | - ); |
|
333 | + ); |
|
334 | 334 | |
335 | - // Disk and memory preferences |
|
336 | - $form['prefs']['advanced']['storage'] = array( |
|
335 | + // Disk and memory preferences |
|
336 | + $form['prefs']['advanced']['storage'] = array( |
|
337 | 337 | '#title' => bts('Disk and memory usage', array(), NULL, 'boinc:account-preferences-computing'), |
338 | 338 | '#type' => 'fieldset', |
339 | 339 | '#description' => '', |
340 | 340 | '#collapsible' => FALSE, |
341 | 341 | '#collapsed' => FALSE |
342 | - ); |
|
343 | - $form['prefs']['advanced']['storage']['disk_max_used_gb'] = array( |
|
342 | + ); |
|
343 | + $form['prefs']['advanced']['storage']['disk_max_used_gb'] = array( |
|
344 | 344 | '#title' => bts('Disk: use no more than', array(), NULL, 'boinc:account-preferences-computing'), |
345 | 345 | '#type' => 'textfield', |
346 | 346 | '#field_suffix' => 'GB', |
347 | 347 | '#default_value' => $default['disk_max_used_gb'], |
348 | 348 | '#size' => 1, |
349 | 349 | '#description' => bts('Limit the total amount of disk space used by BOINC.', array(), NULL, 'boinc:account-preferences-computing'), |
350 | - ); |
|
351 | - $form['prefs']['advanced']['storage']['disk_min_free_gb'] = array( |
|
350 | + ); |
|
351 | + $form['prefs']['advanced']['storage']['disk_min_free_gb'] = array( |
|
352 | 352 | '#title' => bts('Disk: leave at least', array(), NULL, 'boinc:account-preferences-computing'), |
353 | 353 | '#type' => 'textfield', |
354 | 354 | '#field_suffix' => 'GB free', |
355 | 355 | '#default_value' => $default['disk_min_free_gb'], |
356 | 356 | '#size' => 1, |
357 | 357 | '#description' => bts('Limit disk usage to leave this much free space on the volume where BOINC stores data.', array(), NULL, 'boinc:account-preferences-computing'), |
358 | - ); |
|
359 | - $form['prefs']['advanced']['storage']['disk_max_used_pct'] = array( |
|
358 | + ); |
|
359 | + $form['prefs']['advanced']['storage']['disk_max_used_pct'] = array( |
|
360 | 360 | '#title' => bts('Disk: use no more than', array(), NULL, 'boinc:account-preferences-computing'), |
361 | 361 | '#type' => 'textfield', |
362 | 362 | '#field_suffix' => bts('% of total', array(), NULL, 'boinc:account-preferences-computing'), |
363 | 363 | '#default_value' => $default['disk_max_used_pct'], |
364 | 364 | '#size' => 1, |
365 | 365 | '#description' => bts('Limit the percentage of disk space used by BOINC on the volume where it stores data.', array(), NULL, 'boinc:account-preferences-computing') |
366 | - ); |
|
367 | - $form['prefs']['advanced']['storage']['disk_interval'] = array( |
|
366 | + ); |
|
367 | + $form['prefs']['advanced']['storage']['disk_interval'] = array( |
|
368 | 368 | '#title' => bts('Request tasks to checkpoint at most every', array(), NULL, 'boinc:account-preferences-computing'), |
369 | 369 | '#type' => 'textfield', |
370 | 370 | '#field_suffix' => bts('seconds', array(), NULL, 'boinc:unit-of-time'), |
371 | 371 | '#default_value' => $default['disk_interval'], |
372 | 372 | '#size' => 1, |
373 | 373 | '#description' => bts('This controls how often tasks save their state to disk, so that later they can be continued from that point.', array(), NULL, 'boinc:account-preferences-computing') |
374 | - ); |
|
375 | - $form['prefs']['advanced']['storage']['vm_max_used_pct'] = array( |
|
374 | + ); |
|
375 | + $form['prefs']['advanced']['storage']['vm_max_used_pct'] = array( |
|
376 | 376 | '#title' => bts('Page/swap file: use at most', array(), NULL, 'boinc:account-preferences-computing'), |
377 | 377 | '#type' => 'textfield', |
378 | 378 | '#field_suffix' => bts('% of total', array(), NULL, 'boinc:account-preferences-computing'), |
379 | 379 | '#default_value' => $default['vm_max_used_pct'], |
380 | 380 | '#size' => 1, |
381 | 381 | '#description' => bts('Limit the swap space (page file) used by BOINC.', array(), NULL, 'boinc:account-preferences-computing') |
382 | - ); |
|
383 | - $form['prefs']['advanced']['storage']['ram_max_used_busy_pct'] = array( |
|
382 | + ); |
|
383 | + $form['prefs']['advanced']['storage']['ram_max_used_busy_pct'] = array( |
|
384 | 384 | '#title' => bts('Memory: when computer is in use, use at most', array(), NULL, 'boinc:account-preferences-computing'), |
385 | 385 | '#type' => 'textfield', |
386 | 386 | '#field_suffix' => bts('% of total', array(), NULL, 'boinc:account-preferences-computing'), |
387 | 387 | '#default_value' => $default['ram_max_used_busy_pct'], |
388 | 388 | '#size' => 1, |
389 | 389 | '#description' => bts("Limit the memory used by BOINC when you're using the computer.", array(), NULL, 'boinc:account-preferences-computing') |
390 | - ); |
|
391 | - $form['prefs']['advanced']['storage']['ram_max_used_idle_pct'] = array( |
|
390 | + ); |
|
391 | + $form['prefs']['advanced']['storage']['ram_max_used_idle_pct'] = array( |
|
392 | 392 | '#title' => bts('Memory: when computer is not in use, use at most', array(), NULL, 'boinc:account-preferences-computing'), |
393 | 393 | '#type' => 'textfield', |
394 | 394 | '#field_suffix' => bts('% of total', array(), NULL, 'boinc:account-preferences-computing'), |
395 | 395 | '#default_value' => $default['ram_max_used_idle_pct'], |
396 | 396 | '#size' => 1, |
397 | 397 | '#description' => bts("Limit the memory used by BOINC when you're not using the computer.", array(), NULL, 'boinc:account-preferences-computing') |
398 | - ); |
|
398 | + ); |
|
399 | 399 | |
400 | - // Network preferences |
|
401 | - $form['prefs']['advanced']['network'] = array( |
|
400 | + // Network preferences |
|
401 | + $form['prefs']['advanced']['network'] = array( |
|
402 | 402 | '#title' => bts('Network usage', array(), NULL, 'boinc:account-preferences-computing'), |
403 | 403 | '#type' => 'fieldset', |
404 | 404 | '#description' => '', |
405 | 405 | '#collapsible' => FALSE, |
406 | 406 | '#collapsed' => FALSE |
407 | - ); |
|
408 | - $form['prefs']['advanced']['network']['work_buf_min_days'] = array( |
|
407 | + ); |
|
408 | + $form['prefs']['advanced']['network']['work_buf_min_days'] = array( |
|
409 | 409 | '#title' => bts('Store at least', array(), NULL, 'boinc:account-preferences-computing'), |
410 | 410 | '#type' => 'textfield', |
411 | 411 | '#field_suffix' => bts('days of work', array(), NULL, 'boinc:account-preferences-computing'), |
412 | 412 | '#default_value' => $default['work_buf_min_days'], |
413 | 413 | '#size' => 1, |
414 | 414 | '#description' => bts('Store at least enough tasks to keep the computer busy for this long.', array(), NULL, 'boinc:account-preferences-computing') |
415 | - ); |
|
416 | - $form['prefs']['advanced']['network']['work_buf_additional_days'] = array( |
|
415 | + ); |
|
416 | + $form['prefs']['advanced']['network']['work_buf_additional_days'] = array( |
|
417 | 417 | '#title' => bts('Store up to an additional', array(), NULL, 'boinc:account-preferences-computing'), |
418 | 418 | '#type' => 'textfield', |
419 | 419 | '#field_suffix' => bts('days', array(), NULL, 'boinc:unit-of-time'), |
420 | 420 | '#default_value' => $default['work_buf_additional_days'], |
421 | 421 | '#size' => 1, |
422 | 422 | '#description' => bts('Store additional tasks above the minimum level. Determines how much work is requested when contacting a project.', array(), NULL, 'boinc:account-preferences-computing') |
423 | - ); |
|
424 | - $form['prefs']['advanced']['network']['confirm_before_connecting'] = array( |
|
423 | + ); |
|
424 | + $form['prefs']['advanced']['network']['confirm_before_connecting'] = array( |
|
425 | 425 | '#title' => bts('Confirm before connecting to Internet?', array(), NULL, 'boinc:account-preferences-computing'), |
426 | 426 | '#type' => 'radios', |
427 | 427 | '#options' => $form['boolean_options']['#value'], |
428 | 428 | '#attributes' => array('class' => 'fancy'), |
429 | 429 | '#default_value' => $default['confirm_before_connecting'], |
430 | 430 | '#description' => bts('Useful only if you have a modem, ISDN or VPN connection.', array(), NULL, 'boinc:account-preferences-computing') |
431 | - ); |
|
432 | - $form['prefs']['advanced']['network']['hangup_if_dialed'] = array( |
|
431 | + ); |
|
432 | + $form['prefs']['advanced']['network']['hangup_if_dialed'] = array( |
|
433 | 433 | '#title' => bts('Disconnect when done?', array(), NULL, 'boinc:account-preferences-computing'), |
434 | 434 | '#type' => 'radios', |
435 | 435 | '#options' => $form['boolean_options']['#value'], |
436 | 436 | '#attributes' => array('class' => 'fancy'), |
437 | 437 | '#default_value' => $default['hangup_if_dialed'], |
438 | 438 | '#description' => bts('Useful only if you have a modem, ISDN or VPN connection.', array(), NULL, 'boinc:account-preferences-computing') |
439 | - ); |
|
440 | - $form['prefs']['advanced']['network']['max_bytes_sec_down'] = array( |
|
439 | + ); |
|
440 | + $form['prefs']['advanced']['network']['max_bytes_sec_down'] = array( |
|
441 | 441 | '#title' => bts('Limit download rate to', array(), NULL, 'boinc:account-preferences-computing'), |
442 | 442 | '#type' => 'textfield', |
443 | 443 | '#field_suffix' => 'Kbytes/sec', |
444 | 444 | '#default_value' => $default['max_bytes_sec_down']/1000, |
445 | 445 | '#size' => 1, |
446 | 446 | '#description' => bts('Limit the download rate of file transfers.', array(), NULL, 'boinc:account-preferences-computing') |
447 | - ); |
|
448 | - $form['prefs']['advanced']['network']['max_bytes_sec_up'] = array( |
|
447 | + ); |
|
448 | + $form['prefs']['advanced']['network']['max_bytes_sec_up'] = array( |
|
449 | 449 | '#title' => bts('Limit upload rate to', array(), NULL, 'boinc:account-preferences-computing'), |
450 | 450 | '#type' => 'textfield', |
451 | 451 | '#field_suffix' => 'Kbytes/sec', |
452 | 452 | '#default_value' => $default['max_bytes_sec_up']/1000, |
453 | 453 | '#size' => 1, |
454 | 454 | '#description' => bts('Limit the upload rate of file transfers.', array(), NULL, 'boinc:account-preferences-computing') |
455 | - ); |
|
456 | - $form['prefs']['advanced']['network']['hour_label'] = array( |
|
455 | + ); |
|
456 | + $form['prefs']['advanced']['network']['hour_label'] = array( |
|
457 | 457 | '#value' => '<div class="form-item"><label>' . bts('Transfer files only between', array(), NULL, 'boinc:account-preferences-computing') . '</label></div>' |
458 | - ); |
|
459 | - $form['prefs']['advanced']['network']['net_start_hour'] = array( |
|
458 | + ); |
|
459 | + $form['prefs']['advanced']['network']['net_start_hour'] = array( |
|
460 | 460 | '#type' => 'select', |
461 | 461 | '#options' => $form['hour_options']['#value'], |
462 | 462 | '#default_value' => $default['net_start_hour'] |
463 | - ); |
|
464 | - $form['prefs']['advanced']['network']['hour_delimiter'] = array( |
|
463 | + ); |
|
464 | + $form['prefs']['advanced']['network']['hour_delimiter'] = array( |
|
465 | 465 | '#value' => '<span>' . bts('and', array(), NULL, 'boinc:account-preference') . '</span>' |
466 | - ); |
|
467 | - $form['prefs']['advanced']['network']['net_end_hour'] = array( |
|
466 | + ); |
|
467 | + $form['prefs']['advanced']['network']['net_end_hour'] = array( |
|
468 | 468 | '#type' => 'select', |
469 | 469 | '#options' => $form['hour_options']['#value'], |
470 | 470 | '#default_value' => $default['net_end_hour'] |
471 | - ); |
|
472 | - $form['prefs']['advanced']['network']['hour_description'] = array( |
|
471 | + ); |
|
472 | + $form['prefs']['advanced']['network']['hour_description'] = array( |
|
473 | 473 | '#value' => '<div class="form-item slim"><div class="description">' . bts('Transfer files only during a particular period each day.', array(), NULL, 'boinc:account-preferences-computing') . '</div></div>' |
474 | - ); |
|
475 | - $form['prefs']['advanced']['network']['daily_xfer_limit_mb'] = array( |
|
474 | + ); |
|
475 | + $form['prefs']['advanced']['network']['daily_xfer_limit_mb'] = array( |
|
476 | 476 | '#title' => bts('Limit usage to', array(), NULL, 'boinc:account-preferences-computing'), |
477 | 477 | '#type' => 'textfield', |
478 | 478 | '#field_suffix' => 'Mbytes', |
479 | 479 | '#default_value' => $default['daily_xfer_limit_mb'], |
480 | 480 | '#size' => 1 |
481 | - ); |
|
482 | - $form['prefs']['advanced']['network']['daily_xfer_period_days'] = array( |
|
481 | + ); |
|
482 | + $form['prefs']['advanced']['network']['daily_xfer_period_days'] = array( |
|
483 | 483 | '#field_prefix' => 'every', |
484 | 484 | '#type' => 'textfield', |
485 | 485 | '#field_suffix' => bts('days', array(), NULL, 'boinc:unit-of-time'), |
486 | 486 | '#default_value' => $default['daily_xfer_period_days'], |
487 | 487 | '#size' => 1, |
488 | 488 | '#description' => bts('Example: BOINC should transfer at most 2000 MB of data every 30 days.', array(), NULL, 'boinc:account-preferences-computing'), |
489 | - ); |
|
490 | - $form['prefs']['advanced']['network']['dont_verify_images'] = array( |
|
489 | + ); |
|
490 | + $form['prefs']['advanced']['network']['dont_verify_images'] = array( |
|
491 | 491 | '#title' => bts('Skip data verification for image files?', array(), NULL, 'boinc:account-preferences-computing'), |
492 | 492 | '#type' => 'radios', |
493 | 493 | '#options' => $form['boolean_options']['#value'], |
494 | 494 | '#attributes' => array('class' => 'fancy'), |
495 | 495 | '#default_value' => $default['dont_verify_images'], |
496 | 496 | '#description' => bts('Only select "Yes" if your Internet provider modifies image files. Skipping verification reduces the security of BOINC.', array(), NULL, 'boinc:account-preferences-computing') |
497 | - ); |
|
497 | + ); |
|
498 | 498 | |
499 | - // The "fancy radios" are made via javascript on document load. In order for |
|
500 | - // these to work with AHAH, we need this crazy setTimeout() call. |
|
501 | - $form['prefs']['fancy-radios'] = array( |
|
499 | + // The "fancy radios" are made via javascript on document load. In order for |
|
500 | + // these to work with AHAH, we need this crazy setTimeout() call. |
|
501 | + $form['prefs']['fancy-radios'] = array( |
|
502 | 502 | '#value' => ' |
503 | 503 | <script> |
504 | 504 | setTimeout( |
@@ -509,177 +509,177 @@ discard block |
||
509 | 509 | 300 |
510 | 510 | ) |
511 | 511 | </script>' |
512 | - ); |
|
513 | - $form['prefs']['view advanced'] = array( |
|
512 | + ); |
|
513 | + $form['prefs']['view advanced'] = array( |
|
514 | 514 | '#type' => 'hidden', |
515 | 515 | '#value' => 1 |
516 | - ); |
|
516 | + ); |
|
517 | 517 | |
518 | - $form['prefs']['separator_bottom'] = array( |
|
518 | + $form['prefs']['separator_bottom'] = array( |
|
519 | 519 | '#value' => '<div class="separator buttons"></div>' |
520 | - ); |
|
520 | + ); |
|
521 | 521 | |
522 | - // Form control |
|
523 | - $form['prefs']['form control tabs prefix'] = array( |
|
522 | + // Form control |
|
523 | + $form['prefs']['form control tabs prefix'] = array( |
|
524 | 524 | '#value' => '<ul class="form-control tab-list">' |
525 | - ); |
|
526 | - $form['prefs']['submit'] = array( |
|
525 | + ); |
|
526 | + $form['prefs']['submit'] = array( |
|
527 | 527 | '#prefix' => '<li class="first tab">', |
528 | 528 | '#type' => 'submit', |
529 | 529 | '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'), |
530 | 530 | '#suffix' => '</li>' |
531 | - ); |
|
532 | - $form['prefs']['form control tabs'] = array( |
|
531 | + ); |
|
532 | + $form['prefs']['form control tabs'] = array( |
|
533 | 533 | '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), drupal_get_path_alias("account/prefs/computing/edit")) . '</li>' |
534 | - ); |
|
535 | - if ($venue AND $venue != 'generic') { |
|
534 | + ); |
|
535 | + if ($venue AND $venue != 'generic') { |
|
536 | 536 | global $base_path; |
537 | 537 | $form['prefs']['form control tabs']['#value'] .= '<li class="tab">' . |
538 | - l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/computing/clear/{$venue}", |
|
538 | + l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/computing/clear/{$venue}", |
|
539 | 539 | array( |
540 | - 'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/computing/combined')), |
|
541 | - 'attributes' => array( |
|
540 | + 'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/computing/combined')), |
|
541 | + 'attributes' => array( |
|
542 | 542 | 'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the @name preference set. Are you sure?', |
543 | - array('@name' => $venue), NULL, 'boinc:account-preferences') . '\')' |
|
544 | - ) |
|
543 | + array('@name' => $venue), NULL, 'boinc:account-preferences') . '\')' |
|
544 | + ) |
|
545 | 545 | ) |
546 | - ) . '</li>'; |
|
547 | - } |
|
548 | - $form['prefs']['view control'] = array( |
|
546 | + ) . '</li>'; |
|
547 | + } |
|
548 | + $form['prefs']['view control'] = array( |
|
549 | 549 | '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/computing/combined') . '</li>' |
550 | - ); |
|
551 | - $form['prefs']['form control tabs suffix'] = array( |
|
550 | + ); |
|
551 | + $form['prefs']['form control tabs suffix'] = array( |
|
552 | 552 | '#value' => '</ul>' |
553 | - ); |
|
554 | - $form['#submit'][] = 'boincwork_generalprefs_form_submit'; |
|
553 | + ); |
|
554 | + $form['#submit'][] = 'boincwork_generalprefs_form_submit'; |
|
555 | 555 | |
556 | - return $form; |
|
556 | + return $form; |
|
557 | 557 | } |
558 | 558 | |
559 | 559 | /** |
560 | - * Validate the general preferences form. |
|
561 | - */ |
|
560 | + * Validate the general preferences form. |
|
561 | + */ |
|
562 | 562 | function boincwork_generalprefs_form_validate($form, &$form_state) { |
563 | - require_boinc('util'); |
|
564 | - $values = $form_state['values']['prefs']['advanced']; |
|
565 | - |
|
566 | - //drupal_set_message('<pre>' . print_r($form_state['values'], true) . '</pre>'); |
|
567 | - // Verify all non-boolean user input values and notify form API of failures |
|
568 | - |
|
569 | - // Processing preferences |
|
570 | - if (!verify_numeric($values['processor']['idle_time_to_run'], 1, 9999)) form_set_error('idle_time_to_run', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['idle_time_to_run']['#title']} [x] {$form['prefs']['advanced']['processor']['idle_time_to_run']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
571 | - if (!verify_numeric($values['processor']['suspend_if_no_recent_input'], 0, 9999)) form_set_error('suspend_if_no_recent_input', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['suspend_if_no_recent_input']['#title']} [x] {$form['prefs']['advanced']['processor']['suspend_if_no_recent_input']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
572 | - if (!verify_numeric($values['processor']['suspend_cpu_usage'], 0, 100)) form_set_error('suspend_cpu_usage', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['suspend_cpu_usage']['#title']} [x] {$form['prefs']['advanced']['processor']['suspend_cpu_usage']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
573 | - if (!verify_numeric($values['processor']['start_hour'], 0, 23)) form_set_error('start_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['start_hour']['#title']} [x] {$form['prefs']['advanced']['processor']['start_hour']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
574 | - if (!verify_numeric($values['processor']['end_hour'], 0, 23)) form_set_error('end_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['end_hour']['#title']} [x] {$form['prefs']['advanced']['processor']['end_hour']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
575 | - if (!verify_numeric($values['processor']['cpu_scheduling_period_minutes'], 1, 9999)) form_set_error('cpu_scheduling_period_minutes', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes']['#title']} [x] {$form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
576 | - if (!verify_numeric($values['processor']['max_ncpus_pct'], 0, 100)) form_set_error('max_ncpus_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['max_ncpus_pct']['#title']} [x] {$form['prefs']['advanced']['processor']['max_ncpus_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
577 | - if (!verify_numeric($values['processor']['cpu_usage_limit'], 0, 100)) form_set_error('cpu_usage_limit', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['cpu_usage_limit']['#title']} [x] {$form['prefs']['advanced']['processor']['cpu_usage_limit']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
578 | - |
|
579 | - // Storage preferences |
|
580 | - if (!verify_numeric($values['storage']['disk_max_used_gb'], 0, 9999999)) form_set_error('disk_max_used_gb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_max_used_gb']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_max_used_gb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
581 | - if (!verify_numeric($values['storage']['disk_min_free_gb'], 0.001, 9999999)) form_set_error('disk_min_free_gb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_min_free_gb']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_min_free_gb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
582 | - if (!verify_numeric($values['storage']['disk_max_used_pct'], 0, 100)) form_set_error('disk_max_used_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_max_used_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_max_used_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
583 | - if (!verify_numeric($values['storage']['disk_interval'], 0, 9999999)) form_set_error('disk_interval', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_interval']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_interval']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
584 | - if (!verify_numeric($values['storage']['vm_max_used_pct'], 0, 100)) form_set_error('vm_max_used_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['vm_max_used_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['vm_max_used_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
585 | - if (!verify_numeric($values['storage']['ram_max_used_busy_pct'], 0, 100)) form_set_error('ram_max_used_busy_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['ram_max_used_busy_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['ram_max_used_busy_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
586 | - if (!verify_numeric($values['storage']['ram_max_used_idle_pct'], 0, 100)) form_set_error('ram_max_used_idle_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['ram_max_used_idle_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['ram_max_used_idle_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
587 | - |
|
588 | - // Network preferences |
|
589 | - if (!verify_numeric($values['network']['work_buf_min_days'], 0, 10)) form_set_error('work_buf_min_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['work_buf_min_days']['#title']} [x] {$form['prefs']['advanced']['network']['work_buf_min_days']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
590 | - if (!verify_numeric($values['network']['work_buf_additional_days'], 0, 10)) form_set_error('work_buf_additional_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['work_buf_additional_days']['#title']} [x] {$form['prefs']['advanced']['network']['work_buf_additional_days']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
591 | - if (!verify_numeric($values['network']['max_bytes_sec_down'], 0, 9999.999)) form_set_error('max_bytes_sec_down', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['max_bytes_sec_down']['#title']} [x] {$form['prefs']['advanced']['network']['max_bytes_sec_down']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
592 | - if (!verify_numeric($values['network']['max_bytes_sec_up'], 0, 9999.999)) form_set_error('max_bytes_sec_up', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['max_bytes_sec_up']['#title']} [x] {$form['prefs']['advanced']['network']['max_bytes_sec_up']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
593 | - if (!verify_numeric($values['network']['net_start_hour'], 0, 23)) form_set_error('net_start_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['net_start_hour']['#title']} [x] {$form['prefs']['advanced']['network']['net_start_hour']['#field_suffix']}"), NULL, 'boinc:account-prefrences-computing')); |
|
594 | - if (!verify_numeric($values['network']['net_end_hour'], 0, 23)) form_set_error('net_end_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['net_end_hour']['#title']} [x] {$form['prefs']['advanced']['network']['net_end_hour']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
595 | - if (!verify_numeric($values['network']['daily_xfer_limit_mb'], 0, 9999999)) form_set_error('daily_xfer_limit_mb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#title']} [x] {$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
596 | - if (!verify_numeric($values['network']['daily_xfer_period_days'], 0, 9999999)) form_set_error('daily_xfer_period_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#title']} [x] {$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
563 | + require_boinc('util'); |
|
564 | + $values = $form_state['values']['prefs']['advanced']; |
|
565 | + |
|
566 | + //drupal_set_message('<pre>' . print_r($form_state['values'], true) . '</pre>'); |
|
567 | + // Verify all non-boolean user input values and notify form API of failures |
|
568 | + |
|
569 | + // Processing preferences |
|
570 | + if (!verify_numeric($values['processor']['idle_time_to_run'], 1, 9999)) form_set_error('idle_time_to_run', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['idle_time_to_run']['#title']} [x] {$form['prefs']['advanced']['processor']['idle_time_to_run']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
571 | + if (!verify_numeric($values['processor']['suspend_if_no_recent_input'], 0, 9999)) form_set_error('suspend_if_no_recent_input', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['suspend_if_no_recent_input']['#title']} [x] {$form['prefs']['advanced']['processor']['suspend_if_no_recent_input']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
572 | + if (!verify_numeric($values['processor']['suspend_cpu_usage'], 0, 100)) form_set_error('suspend_cpu_usage', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['suspend_cpu_usage']['#title']} [x] {$form['prefs']['advanced']['processor']['suspend_cpu_usage']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
573 | + if (!verify_numeric($values['processor']['start_hour'], 0, 23)) form_set_error('start_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['start_hour']['#title']} [x] {$form['prefs']['advanced']['processor']['start_hour']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
574 | + if (!verify_numeric($values['processor']['end_hour'], 0, 23)) form_set_error('end_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['end_hour']['#title']} [x] {$form['prefs']['advanced']['processor']['end_hour']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
575 | + if (!verify_numeric($values['processor']['cpu_scheduling_period_minutes'], 1, 9999)) form_set_error('cpu_scheduling_period_minutes', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes']['#title']} [x] {$form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
576 | + if (!verify_numeric($values['processor']['max_ncpus_pct'], 0, 100)) form_set_error('max_ncpus_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['max_ncpus_pct']['#title']} [x] {$form['prefs']['advanced']['processor']['max_ncpus_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
577 | + if (!verify_numeric($values['processor']['cpu_usage_limit'], 0, 100)) form_set_error('cpu_usage_limit', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['cpu_usage_limit']['#title']} [x] {$form['prefs']['advanced']['processor']['cpu_usage_limit']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
578 | + |
|
579 | + // Storage preferences |
|
580 | + if (!verify_numeric($values['storage']['disk_max_used_gb'], 0, 9999999)) form_set_error('disk_max_used_gb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_max_used_gb']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_max_used_gb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
581 | + if (!verify_numeric($values['storage']['disk_min_free_gb'], 0.001, 9999999)) form_set_error('disk_min_free_gb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_min_free_gb']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_min_free_gb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
582 | + if (!verify_numeric($values['storage']['disk_max_used_pct'], 0, 100)) form_set_error('disk_max_used_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_max_used_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_max_used_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
583 | + if (!verify_numeric($values['storage']['disk_interval'], 0, 9999999)) form_set_error('disk_interval', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_interval']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_interval']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
584 | + if (!verify_numeric($values['storage']['vm_max_used_pct'], 0, 100)) form_set_error('vm_max_used_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['vm_max_used_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['vm_max_used_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
585 | + if (!verify_numeric($values['storage']['ram_max_used_busy_pct'], 0, 100)) form_set_error('ram_max_used_busy_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['ram_max_used_busy_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['ram_max_used_busy_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
586 | + if (!verify_numeric($values['storage']['ram_max_used_idle_pct'], 0, 100)) form_set_error('ram_max_used_idle_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['ram_max_used_idle_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['ram_max_used_idle_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
587 | + |
|
588 | + // Network preferences |
|
589 | + if (!verify_numeric($values['network']['work_buf_min_days'], 0, 10)) form_set_error('work_buf_min_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['work_buf_min_days']['#title']} [x] {$form['prefs']['advanced']['network']['work_buf_min_days']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
590 | + if (!verify_numeric($values['network']['work_buf_additional_days'], 0, 10)) form_set_error('work_buf_additional_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['work_buf_additional_days']['#title']} [x] {$form['prefs']['advanced']['network']['work_buf_additional_days']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
591 | + if (!verify_numeric($values['network']['max_bytes_sec_down'], 0, 9999.999)) form_set_error('max_bytes_sec_down', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['max_bytes_sec_down']['#title']} [x] {$form['prefs']['advanced']['network']['max_bytes_sec_down']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
592 | + if (!verify_numeric($values['network']['max_bytes_sec_up'], 0, 9999.999)) form_set_error('max_bytes_sec_up', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['max_bytes_sec_up']['#title']} [x] {$form['prefs']['advanced']['network']['max_bytes_sec_up']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
593 | + if (!verify_numeric($values['network']['net_start_hour'], 0, 23)) form_set_error('net_start_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['net_start_hour']['#title']} [x] {$form['prefs']['advanced']['network']['net_start_hour']['#field_suffix']}"), NULL, 'boinc:account-prefrences-computing')); |
|
594 | + if (!verify_numeric($values['network']['net_end_hour'], 0, 23)) form_set_error('net_end_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['net_end_hour']['#title']} [x] {$form['prefs']['advanced']['network']['net_end_hour']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
595 | + if (!verify_numeric($values['network']['daily_xfer_limit_mb'], 0, 9999999)) form_set_error('daily_xfer_limit_mb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#title']} [x] {$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
596 | + if (!verify_numeric($values['network']['daily_xfer_period_days'], 0, 9999999)) form_set_error('daily_xfer_period_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#title']} [x] {$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
597 | 597 | } |
598 | 598 | |
599 | 599 | /** |
600 | - * Handle post-validation submission of general preferences form. |
|
601 | - */ |
|
600 | + * Handle post-validation submission of general preferences form. |
|
601 | + */ |
|
602 | 602 | function boincwork_generalprefs_form_submit($form, &$form_state) { |
603 | - global $user; |
|
604 | - $account = user_load($user->uid); |
|
605 | - |
|
606 | - $values = $form_state['values']['prefs']['advanced']; |
|
607 | - $venue = $form_state['values']['prefs']['venue']; |
|
608 | - $preset = $form_state['values']['prefs']['preset']; |
|
609 | - |
|
610 | - // Load preferences from BOINC account |
|
611 | - $prefs = boincwork_load_prefs('general', $venue); |
|
612 | - |
|
613 | - // Processing preferences |
|
614 | - $prefs['run_on_batteries'] = ($values['processor']['run_on_batteries']) ? 0 : 1; |
|
615 | - $prefs['run_if_user_active'] = ($values['processor']['run_if_user_active']) ? 0 : 1; |
|
616 | - $prefs['run_gpu_if_user_active'] = ($values['processor']['run_gpu_if_user_active']) ? 0 : 1; |
|
617 | - $prefs['idle_time_to_run'] = $values['processor']['idle_time_to_run']; |
|
618 | - $prefs['suspend_if_no_recent_input'] = $values['processor']['suspend_if_no_recent_input']; |
|
619 | - $prefs['suspend_cpu_usage'] = $values['processor']['suspend_cpu_usage']; |
|
620 | - $prefs['start_hour'] = $values['processor']['start_hour']; |
|
621 | - $prefs['end_hour'] = $values['processor']['end_hour']; |
|
622 | - $prefs['leave_apps_in_memory'] = ($values['processor']['leave_apps_in_memory']) ? 1 : 0; |
|
623 | - $prefs['cpu_scheduling_period_minutes'] = $values['processor']['cpu_scheduling_period_minutes']; |
|
624 | - $prefs['max_ncpus_pct'] = $values['processor']['max_ncpus_pct']; |
|
625 | - $prefs['cpu_usage_limit'] = $values['processor']['cpu_usage_limit']; |
|
626 | - |
|
627 | - // Storage preferences |
|
628 | - $prefs['disk_max_used_gb'] = $values['storage']['disk_max_used_gb']; |
|
629 | - $prefs['disk_min_free_gb'] = $values['storage']['disk_min_free_gb']; |
|
630 | - $prefs['disk_max_used_pct'] = $values['storage']['disk_max_used_pct']; |
|
631 | - $prefs['disk_interval'] = $values['storage']['disk_interval']; |
|
632 | - $prefs['vm_max_used_pct'] = $values['storage']['vm_max_used_pct']; |
|
633 | - $prefs['ram_max_used_busy_pct'] = $values['storage']['ram_max_used_busy_pct']; |
|
634 | - $prefs['ram_max_used_idle_pct'] = $values['storage']['ram_max_used_idle_pct']; |
|
635 | - |
|
636 | - // Network preferences |
|
637 | - $prefs['work_buf_min_days'] = $values['network']['work_buf_min_days']; |
|
638 | - $prefs['work_buf_additional_days'] = $values['network']['work_buf_additional_days']; |
|
639 | - $prefs['confirm_before_connecting'] = ($values['network']['confirm_before_connecting']) ? 1 : 0; |
|
640 | - $prefs['hangup_if_dialed'] = ($values['network']['hangup_if_dialed']) ? 1 : 0; |
|
641 | - $prefs['max_bytes_sec_down'] = $values['network']['max_bytes_sec_down']*1000; |
|
642 | - $prefs['max_bytes_sec_up'] = $values['network']['max_bytes_sec_up']*1000; |
|
643 | - $prefs['net_start_hour'] = $values['network']['net_start_hour']; |
|
644 | - $prefs['net_end_hour'] = $values['network']['net_end_hour']; |
|
645 | - $prefs['daily_xfer_limit_mb'] = $values['network']['daily_xfer_limit_mb']; |
|
646 | - $prefs['daily_xfer_period_days'] = $values['network']['daily_xfer_period_days']; |
|
647 | - $prefs['dont_verify_images'] = ($values['network']['dont_verify_images']) ? 1 : 0; |
|
648 | - |
|
649 | - // transform old way to store the preset into new way |
|
650 | - // ideally this should already have happened in boincwork_generalprefs_form() |
|
651 | - if (isset($prefs['@attributes']['preset'])) { |
|
603 | + global $user; |
|
604 | + $account = user_load($user->uid); |
|
605 | + |
|
606 | + $values = $form_state['values']['prefs']['advanced']; |
|
607 | + $venue = $form_state['values']['prefs']['venue']; |
|
608 | + $preset = $form_state['values']['prefs']['preset']; |
|
609 | + |
|
610 | + // Load preferences from BOINC account |
|
611 | + $prefs = boincwork_load_prefs('general', $venue); |
|
612 | + |
|
613 | + // Processing preferences |
|
614 | + $prefs['run_on_batteries'] = ($values['processor']['run_on_batteries']) ? 0 : 1; |
|
615 | + $prefs['run_if_user_active'] = ($values['processor']['run_if_user_active']) ? 0 : 1; |
|
616 | + $prefs['run_gpu_if_user_active'] = ($values['processor']['run_gpu_if_user_active']) ? 0 : 1; |
|
617 | + $prefs['idle_time_to_run'] = $values['processor']['idle_time_to_run']; |
|
618 | + $prefs['suspend_if_no_recent_input'] = $values['processor']['suspend_if_no_recent_input']; |
|
619 | + $prefs['suspend_cpu_usage'] = $values['processor']['suspend_cpu_usage']; |
|
620 | + $prefs['start_hour'] = $values['processor']['start_hour']; |
|
621 | + $prefs['end_hour'] = $values['processor']['end_hour']; |
|
622 | + $prefs['leave_apps_in_memory'] = ($values['processor']['leave_apps_in_memory']) ? 1 : 0; |
|
623 | + $prefs['cpu_scheduling_period_minutes'] = $values['processor']['cpu_scheduling_period_minutes']; |
|
624 | + $prefs['max_ncpus_pct'] = $values['processor']['max_ncpus_pct']; |
|
625 | + $prefs['cpu_usage_limit'] = $values['processor']['cpu_usage_limit']; |
|
626 | + |
|
627 | + // Storage preferences |
|
628 | + $prefs['disk_max_used_gb'] = $values['storage']['disk_max_used_gb']; |
|
629 | + $prefs['disk_min_free_gb'] = $values['storage']['disk_min_free_gb']; |
|
630 | + $prefs['disk_max_used_pct'] = $values['storage']['disk_max_used_pct']; |
|
631 | + $prefs['disk_interval'] = $values['storage']['disk_interval']; |
|
632 | + $prefs['vm_max_used_pct'] = $values['storage']['vm_max_used_pct']; |
|
633 | + $prefs['ram_max_used_busy_pct'] = $values['storage']['ram_max_used_busy_pct']; |
|
634 | + $prefs['ram_max_used_idle_pct'] = $values['storage']['ram_max_used_idle_pct']; |
|
635 | + |
|
636 | + // Network preferences |
|
637 | + $prefs['work_buf_min_days'] = $values['network']['work_buf_min_days']; |
|
638 | + $prefs['work_buf_additional_days'] = $values['network']['work_buf_additional_days']; |
|
639 | + $prefs['confirm_before_connecting'] = ($values['network']['confirm_before_connecting']) ? 1 : 0; |
|
640 | + $prefs['hangup_if_dialed'] = ($values['network']['hangup_if_dialed']) ? 1 : 0; |
|
641 | + $prefs['max_bytes_sec_down'] = $values['network']['max_bytes_sec_down']*1000; |
|
642 | + $prefs['max_bytes_sec_up'] = $values['network']['max_bytes_sec_up']*1000; |
|
643 | + $prefs['net_start_hour'] = $values['network']['net_start_hour']; |
|
644 | + $prefs['net_end_hour'] = $values['network']['net_end_hour']; |
|
645 | + $prefs['daily_xfer_limit_mb'] = $values['network']['daily_xfer_limit_mb']; |
|
646 | + $prefs['daily_xfer_period_days'] = $values['network']['daily_xfer_period_days']; |
|
647 | + $prefs['dont_verify_images'] = ($values['network']['dont_verify_images']) ? 1 : 0; |
|
648 | + |
|
649 | + // transform old way to store the preset into new way |
|
650 | + // ideally this should already have happened in boincwork_generalprefs_form() |
|
651 | + if (isset($prefs['@attributes']['preset'])) { |
|
652 | 652 | $prefs['preset'] = $prefs['@attributes']['preset']; |
653 | 653 | unset($prefs['@attributes']['preset']); |
654 | - } |
|
655 | - // Save the preset selection (or lack thereof) |
|
656 | - if (!$preset OR $preset == 'custom') { |
|
654 | + } |
|
655 | + // Save the preset selection (or lack thereof) |
|
656 | + if (!$preset OR $preset == 'custom') { |
|
657 | 657 | $prefs['preset'] = 'custom'; |
658 | - } |
|
659 | - else { |
|
658 | + } |
|
659 | + else { |
|
660 | 660 | $prefs['preset'] = $preset; |
661 | - } |
|
661 | + } |
|
662 | 662 | |
663 | - // If this is a new preference set, be sure to unset the "cleared" attribute |
|
664 | - if (isset($prefs['@attributes']['cleared'])) { |
|
663 | + // If this is a new preference set, be sure to unset the "cleared" attribute |
|
664 | + if (isset($prefs['@attributes']['cleared'])) { |
|
665 | 665 | unset($prefs['@attributes']['cleared']); |
666 | - } |
|
666 | + } |
|
667 | 667 | |
668 | - // Update database |
|
669 | - $result = boincwork_save_prefs($prefs, 'general', $venue); |
|
668 | + // Update database |
|
669 | + $result = boincwork_save_prefs($prefs, 'general', $venue); |
|
670 | 670 | |
671 | - if (!$result) { |
|
671 | + if (!$result) { |
|
672 | 672 | watchdog('boincwork', 'Error updating global prefs for user @id: @message', array('@id' => $account->id, '@message' => mysqli_error()), WATCHDOG_ERROR); |
673 | 673 | drupal_set_message(t('Your changes could not be saved. Please contact support!'), 'error'); |
674 | - } |
|
675 | - elseif (!drupal_get_messages('status', FALSE)) { |
|
674 | + } |
|
675 | + elseif (!drupal_get_messages('status', FALSE)) { |
|
676 | 676 | // Show this message if the set wasn't created automatically (in which case |
677 | 677 | // there is a message tailored to that) { |
678 | 678 | drupal_set_message(t('Your preferences have been updated. |
679 | 679 | Client-related preferences will take effect when your computer |
680 | 680 | communicates with @project or you issue the "Update" |
681 | 681 | command from the BOINC client.', array('@project' => PROJECT))); |
682 | - } |
|
682 | + } |
|
683 | 683 | } |
684 | 684 | |
685 | 685 | |
@@ -691,88 +691,88 @@ discard block |
||
691 | 691 | * Find compatible hosts for merging |
692 | 692 | */ |
693 | 693 | function boincwork_host_get_compatible_hosts($host_id) { |
694 | - require_boinc('host'); |
|
695 | - global $user; |
|
696 | - $account = user_load($user->uid); |
|
697 | - $compatible_hosts = array(); |
|
698 | - $host_count = 0; |
|
699 | - db_set_active('boinc_ro'); |
|
700 | - $current_host = db_fetch_object(db_query(" |
|
694 | + require_boinc('host'); |
|
695 | + global $user; |
|
696 | + $account = user_load($user->uid); |
|
697 | + $compatible_hosts = array(); |
|
698 | + $host_count = 0; |
|
699 | + db_set_active('boinc_ro'); |
|
700 | + $current_host = db_fetch_object(db_query(" |
|
701 | 701 | SELECT id, domain_name, create_time, total_credit, rpc_time, os_name, |
702 | 702 | p_vendor, p_model |
703 | 703 | FROM {host} |
704 | 704 | WHERE userid = '%d' AND id = '%d'", |
705 | 705 | $account->boincuser_id, $host_id |
706 | - )); |
|
707 | - db_set_active('default'); |
|
708 | - $current_host->task_count = boincwork_host_get_task_count($current_host->id); |
|
709 | - $current_host->is_new = !$current_host->total_credit AND !$current_host->task_count; |
|
710 | - // Get the list of all other hosts owned by this user for comparison |
|
711 | - db_set_active('boinc_ro'); |
|
712 | - $all_other_hosts = db_query(" |
|
706 | + )); |
|
707 | + db_set_active('default'); |
|
708 | + $current_host->task_count = boincwork_host_get_task_count($current_host->id); |
|
709 | + $current_host->is_new = !$current_host->total_credit AND !$current_host->task_count; |
|
710 | + // Get the list of all other hosts owned by this user for comparison |
|
711 | + db_set_active('boinc_ro'); |
|
712 | + $all_other_hosts = db_query(" |
|
713 | 713 | SELECT id, domain_name, create_time, total_credit, rpc_time, os_name, |
714 | 714 | p_vendor, p_model |
715 | 715 | FROM {host} |
716 | 716 | WHERE userid = '%d' AND id <> '%d'", |
717 | 717 | $account->boincuser_id, $host_id |
718 | - ); |
|
719 | - db_set_active('default'); |
|
720 | - // Compare all hosts to see if any are plausible duplicates |
|
721 | - while ($other_host = db_fetch_object($all_other_hosts)) { |
|
718 | + ); |
|
719 | + db_set_active('default'); |
|
720 | + // Compare all hosts to see if any are plausible duplicates |
|
721 | + while ($other_host = db_fetch_object($all_other_hosts)) { |
|
722 | 722 | // First, disqualify if hosts were active at the same time |
723 | 723 | if (!$current_host->is_new) { |
724 | - $other_host->task_count = boincwork_host_get_task_count($other_host->id); |
|
725 | - $other_host->is_new = !$other_host->total_credit AND !$other_host->task_count; |
|
726 | - if (!$other_host->is_new) { |
|
724 | + $other_host->task_count = boincwork_host_get_task_count($other_host->id); |
|
725 | + $other_host->is_new = !$other_host->total_credit AND !$other_host->task_count; |
|
726 | + if (!$other_host->is_new) { |
|
727 | 727 | // If both hosts being compared are not new, see if times overlap |
728 | 728 | if (!times_disjoint($current_host, $other_host)) { |
729 | - // Hosts were active at the same time; can't be a duplicate |
|
730 | - continue; |
|
729 | + // Hosts were active at the same time; can't be a duplicate |
|
730 | + continue; |
|
731 | + } |
|
731 | 732 | } |
732 | - } |
|
733 | 733 | } |
734 | 734 | // Next, disqualify if hosts have different OS platforms |
735 | 735 | if (!os_compatible($current_host, $other_host)) { |
736 | - // Hosts have different OS platforms; not really a duplicate |
|
737 | - continue; |
|
736 | + // Hosts have different OS platforms; not really a duplicate |
|
737 | + continue; |
|
738 | 738 | } |
739 | 739 | // Finally, disqualify if hosts have different CPUs |
740 | 740 | if (!cpus_compatible($current_host, $other_host)) { |
741 | - // CPUs don't match; not a duplicate |
|
742 | - continue; |
|
741 | + // CPUs don't match; not a duplicate |
|
742 | + continue; |
|
743 | 743 | } |
744 | 744 | // If not disqualified, this host is available for merging |
745 | 745 | $hosts[] = $other_host; |
746 | 746 | $host_count++; |
747 | 747 | if ($host_count == 500) { |
748 | - // This is enough! |
|
749 | - break; |
|
748 | + // This is enough! |
|
749 | + break; |
|
750 | 750 | } |
751 | - } |
|
752 | - return $hosts; |
|
751 | + } |
|
752 | + return $hosts; |
|
753 | 753 | } |
754 | 754 | |
755 | 755 | /** |
756 | 756 | * Perform the database updates to merge the old host into the new host |
757 | 757 | */ |
758 | 758 | function boincwork_host_merge($old_host, $new_host, &$message = NULL) { |
759 | - // Decay the average credit of the two hosts |
|
760 | - require_boinc('credit'); |
|
761 | - $now = time(); |
|
762 | - update_average($now, 0, 0, $old_host->expavg_credit, $old_host->expavg_time); |
|
763 | - update_average($now, 0, 0, $new_host->expavg_credit, $new_host->expavg_time); |
|
764 | - |
|
765 | - // Update the database: |
|
766 | - // - add credit from old host to new host |
|
767 | - // - change results to refer to the new host |
|
768 | - // - put old host in "zombie" state (userid=0, rpc_seqno=[new_host_id]) |
|
769 | - |
|
770 | - $total_credit = $old_host->total_credit + $new_host->total_credit; |
|
771 | - $recent_credit = $old_host->expavg_credit + $new_host->expavg_credit; |
|
772 | - |
|
773 | - // Move credit from the old host to the new host |
|
774 | - db_set_active('boinc_rw'); |
|
775 | - $credit_updated = db_query(" |
|
759 | + // Decay the average credit of the two hosts |
|
760 | + require_boinc('credit'); |
|
761 | + $now = time(); |
|
762 | + update_average($now, 0, 0, $old_host->expavg_credit, $old_host->expavg_time); |
|
763 | + update_average($now, 0, 0, $new_host->expavg_credit, $new_host->expavg_time); |
|
764 | + |
|
765 | + // Update the database: |
|
766 | + // - add credit from old host to new host |
|
767 | + // - change results to refer to the new host |
|
768 | + // - put old host in "zombie" state (userid=0, rpc_seqno=[new_host_id]) |
|
769 | + |
|
770 | + $total_credit = $old_host->total_credit + $new_host->total_credit; |
|
771 | + $recent_credit = $old_host->expavg_credit + $new_host->expavg_credit; |
|
772 | + |
|
773 | + // Move credit from the old host to the new host |
|
774 | + db_set_active('boinc_rw'); |
|
775 | + $credit_updated = db_query(" |
|
776 | 776 | UPDATE {host} |
777 | 777 | SET |
778 | 778 | total_credit = '%d', |
@@ -780,34 +780,34 @@ discard block |
||
780 | 780 | expavg_time = '%d' |
781 | 781 | WHERE id = '%d'", |
782 | 782 | $total_credit, $recent_credit, $now, $new_host->id |
783 | - ); |
|
784 | - db_set_active('default'); |
|
785 | - if (!$credit_updated) { |
|
783 | + ); |
|
784 | + db_set_active('default'); |
|
785 | + if (!$credit_updated) { |
|
786 | 786 | if ($message !== NULL) { |
787 | - $message = bts('Could not update credit', array(), NULL, 'boinc:account-host-merge'); |
|
787 | + $message = bts('Could not update credit', array(), NULL, 'boinc:account-host-merge'); |
|
788 | 788 | } |
789 | 789 | return FALSE; |
790 | - } |
|
790 | + } |
|
791 | 791 | |
792 | - // Move results from the old host to the new host |
|
793 | - db_set_active('boinc_rw'); |
|
794 | - $results_updated = db_query(" |
|
792 | + // Move results from the old host to the new host |
|
793 | + db_set_active('boinc_rw'); |
|
794 | + $results_updated = db_query(" |
|
795 | 795 | UPDATE {result} |
796 | 796 | SET hostid = '%d' |
797 | 797 | WHERE hostid = '%d'", |
798 | 798 | $new_host->id, $old_host->id |
799 | - ); |
|
800 | - db_set_active('default'); |
|
801 | - if (!$results_updated) { |
|
799 | + ); |
|
800 | + db_set_active('default'); |
|
801 | + if (!$results_updated) { |
|
802 | 802 | if ($message !== NULL) { |
803 | - $message = bts('Could not update results', array(), NULL, 'boinc:account-host-merge'); |
|
803 | + $message = bts('Could not update results', array(), NULL, 'boinc:account-host-merge'); |
|
804 | 804 | } |
805 | 805 | return FALSE; |
806 | - } |
|
806 | + } |
|
807 | 807 | |
808 | - // Retire the old host |
|
809 | - db_set_active('boinc_rw'); |
|
810 | - $old_host_retired = db_query(" |
|
808 | + // Retire the old host |
|
809 | + db_set_active('boinc_rw'); |
|
810 | + $old_host_retired = db_query(" |
|
811 | 811 | UPDATE {host} |
812 | 812 | SET |
813 | 813 | total_credit = '0', |
@@ -816,16 +816,16 @@ discard block |
||
816 | 816 | rpc_seqno = '%d' |
817 | 817 | WHERE id = '%d'", |
818 | 818 | $new_host->id, $old_host->id |
819 | - ); |
|
820 | - db_set_active('default'); |
|
821 | - if (!$old_host_retired) { |
|
819 | + ); |
|
820 | + db_set_active('default'); |
|
821 | + if (!$old_host_retired) { |
|
822 | 822 | if ($message !== NULL) { |
823 | - $message = bts('Could not retire old computer', array(), NULL, 'boinc:account-host-merge'); |
|
823 | + $message = bts('Could not retire old computer', array(), NULL, 'boinc:account-host-merge'); |
|
824 | 824 | } |
825 | 825 | return FALSE; |
826 | - } |
|
826 | + } |
|
827 | 827 | |
828 | - return TRUE; |
|
828 | + return TRUE; |
|
829 | 829 | } |
830 | 830 | |
831 | 831 | /** |
@@ -833,75 +833,75 @@ discard block |
||
833 | 833 | */ |
834 | 834 | function boincwork_host_merge_form(&$form_state, $host_id) { |
835 | 835 | |
836 | - if (!boincwork_host_user_is_owner($host_id)) { |
|
836 | + if (!boincwork_host_user_is_owner($host_id)) { |
|
837 | 837 | drupal_goto("host/{$host_id}"); |
838 | - } |
|
838 | + } |
|
839 | 839 | |
840 | - $form = array(); |
|
841 | - $form_state['storage']['current_host_id'] = $host_id; |
|
842 | - $current_host = boincwork_host_get_info($host_id); |
|
840 | + $form = array(); |
|
841 | + $form_state['storage']['current_host_id'] = $host_id; |
|
842 | + $current_host = boincwork_host_get_info($host_id); |
|
843 | 843 | |
844 | - // Get hosts that could be merged with this one |
|
845 | - $hosts = boincwork_host_get_compatible_hosts($host_id); |
|
844 | + // Get hosts that could be merged with this one |
|
845 | + $hosts = boincwork_host_get_compatible_hosts($host_id); |
|
846 | 846 | |
847 | - if (!$hosts) { |
|
847 | + if (!$hosts) { |
|
848 | 848 | drupal_set_message(t('There are no computers eligible for merging with this |
849 | 849 | one'), 'warning' |
850 | 850 | ); |
851 | 851 | drupal_goto("host/{$host_id}"); |
852 | - } |
|
852 | + } |
|
853 | 853 | |
854 | - $form['overview'] = array( |
|
854 | + $form['overview'] = array( |
|
855 | 855 | '#value' => '<p>' . bts('Sometimes BOINC assigns separate identities to' |
856 | - . ' the same computer by mistake. You can correct this by merging old' |
|
857 | - . ' identities with the newest one.', array(), NULL, 'boinc:account-host-merge') . '</p>' |
|
858 | - . '<p>' |
|
859 | - . bts('Check the computers that are the same as @name' |
|
860 | - . ' (created on @date at @time with computer ID @id)', |
|
856 | + . ' the same computer by mistake. You can correct this by merging old' |
|
857 | + . ' identities with the newest one.', array(), NULL, 'boinc:account-host-merge') . '</p>' |
|
858 | + . '<p>' |
|
859 | + . bts('Check the computers that are the same as @name' |
|
860 | + . ' (created on @date at @time with computer ID @id)', |
|
861 | 861 | array( |
862 | - '@name' => $current_host->domain_name, |
|
863 | - '@date' => date('j M Y', $current_host->create_time), |
|
864 | - '@time' => date('G:i:s T', $current_host->create_time), |
|
865 | - '@id' => $current_host->id, |
|
862 | + '@name' => $current_host->domain_name, |
|
863 | + '@date' => date('j M Y', $current_host->create_time), |
|
864 | + '@time' => date('G:i:s T', $current_host->create_time), |
|
865 | + '@id' => $current_host->id, |
|
866 | 866 | ), |
867 | 867 | NULL, 'boinc:account-host-merge') . '</p>', |
868 | - ); |
|
868 | + ); |
|
869 | 869 | |
870 | - $options = array(); |
|
871 | - foreach ($hosts as $host) { |
|
870 | + $options = array(); |
|
871 | + foreach ($hosts as $host) { |
|
872 | 872 | $options[$host->id] = array( |
873 | - $host->domain_name, |
|
874 | - date('j M Y G:i:s T', $host->create_time), |
|
875 | - $host->id, |
|
873 | + $host->domain_name, |
|
874 | + date('j M Y G:i:s T', $host->create_time), |
|
875 | + $host->id, |
|
876 | 876 | ); |
877 | - } |
|
877 | + } |
|
878 | 878 | |
879 | - $form['merge'] = array( |
|
879 | + $form['merge'] = array( |
|
880 | 880 | '#title' => '', |
881 | 881 | '#type' => 'tableselect', |
882 | 882 | '#header' => array(bts('Name', array(), NULL, 'boinc:details:-1:name-of-the-host-or-task-or-workunit-etc-being-viewed-ignoreoverwrite'), bts('Created', array(), NULL, 'boinc:host-details'), bts('Computer ID', array(), NULL, 'boinc:host-list')), |
883 | 883 | '#options' => $options, |
884 | - ); |
|
884 | + ); |
|
885 | 885 | |
886 | - $form['prefs']['separator_bottom'] = array( |
|
887 | - // '#value' => '<div class="separator buttons"></div>' |
|
888 | - ); |
|
886 | + $form['prefs']['separator_bottom'] = array( |
|
887 | + // '#value' => '<div class="separator buttons"></div>' |
|
888 | + ); |
|
889 | 889 | |
890 | - // Form control |
|
891 | - $form['prefs']['form control tabs prefix'] = array( |
|
890 | + // Form control |
|
891 | + $form['prefs']['form control tabs prefix'] = array( |
|
892 | 892 | '#value' => '<ul class="form-control tab-list">' |
893 | - ); |
|
894 | - $form['prefs']['submit'] = array( |
|
893 | + ); |
|
894 | + $form['prefs']['submit'] = array( |
|
895 | 895 | '#prefix' => '<li class="first tab">', |
896 | 896 | '#type' => 'submit', |
897 | 897 | '#value' => bts('Merge', array(), NULL, 'boinc:form-merge'), |
898 | 898 | '#suffix' => '</li>' |
899 | - ); |
|
900 | - $form['prefs']['form control tabs'] = array( |
|
899 | + ); |
|
900 | + $form['prefs']['form control tabs'] = array( |
|
901 | 901 | '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "host/{$host_id}") . '</li>' |
902 | - ); |
|
902 | + ); |
|
903 | 903 | |
904 | - return $form; |
|
904 | + return $form; |
|
905 | 905 | } |
906 | 906 | |
907 | 907 | /** |
@@ -914,76 +914,76 @@ discard block |
||
914 | 914 | * Handle submission of the merge host form |
915 | 915 | */ |
916 | 916 | function boincwork_host_merge_form_submit($form, &$form_state) { |
917 | - $merged = array(); |
|
918 | - $errors = array(); |
|
919 | - $current_host_id = $form_state['storage']['current_host_id']; |
|
920 | - $current_host = boincwork_host_get_info($current_host_id); |
|
921 | - $selected_hosts = array_filter($form_state['values']['merge']); |
|
917 | + $merged = array(); |
|
918 | + $errors = array(); |
|
919 | + $current_host_id = $form_state['storage']['current_host_id']; |
|
920 | + $current_host = boincwork_host_get_info($current_host_id); |
|
921 | + $selected_hosts = array_filter($form_state['values']['merge']); |
|
922 | 922 | |
923 | - foreach ($selected_hosts as $host_id) { |
|
923 | + foreach ($selected_hosts as $host_id) { |
|
924 | 924 | // Attempt to merge each host, noting the results |
925 | 925 | $message = ''; |
926 | 926 | $old_host = boincwork_host_get_info($host_id); |
927 | 927 | if (boincwork_host_merge($old_host, $current_host, $message)) { |
928 | - $merged[$old_host->id] = $old_host->id; |
|
929 | - $current_host = boincwork_host_get_info($current_host_id); |
|
928 | + $merged[$old_host->id] = $old_host->id; |
|
929 | + $current_host = boincwork_host_get_info($current_host_id); |
|
930 | 930 | } |
931 | 931 | else { |
932 | - $errors[$old_host->id] = $message; |
|
932 | + $errors[$old_host->id] = $message; |
|
933 | + } |
|
933 | 934 | } |
934 | - } |
|
935 | 935 | |
936 | - if ($merged) { |
|
936 | + if ($merged) { |
|
937 | 937 | // Generate a natural language list of IDs that were merged |
938 | 938 | $oxford_comma = ','; |
939 | 939 | $conjunction = bts('and', array(), NULL, 'boinc:account-preference'); |
940 | 940 | $list = array_keys($merged); |
941 | 941 | $last = array_pop($list); |
942 | 942 | if ($list) { |
943 | - if (count($merged) == 2) { |
|
943 | + if (count($merged) == 2) { |
|
944 | 944 | $oxford_comma = ''; |
945 | - } |
|
946 | - $list = implode(', ', $list) . $oxford_comma . ' ' . $conjunction . ' ' . $last; |
|
945 | + } |
|
946 | + $list = implode(', ', $list) . $oxford_comma . ' ' . $conjunction . ' ' . $last; |
|
947 | 947 | } |
948 | 948 | else { |
949 | - $list = $last; |
|
949 | + $list = $last; |
|
950 | 950 | } |
951 | 951 | if (count($merged) == 1) { |
952 | - drupal_set_message(bts( |
|
952 | + drupal_set_message(bts( |
|
953 | 953 | 'Computer @old_id has been merged successfully into @id.', |
954 | 954 | array( |
955 | - '@old_id' => $list, |
|
956 | - '@id' => $current_host_id |
|
955 | + '@old_id' => $list, |
|
956 | + '@id' => $current_host_id |
|
957 | 957 | ), |
958 | 958 | NULL, 'boinc:account-host-merge')); |
959 | 959 | } |
960 | 960 | else { |
961 | - drupal_set_message(bts( |
|
961 | + drupal_set_message(bts( |
|
962 | 962 | 'Computers @old_ids have been merged successfully into @id.', |
963 | 963 | array( |
964 | - '@old_ids' => $list, |
|
965 | - '@id' => $current_host_id |
|
964 | + '@old_ids' => $list, |
|
965 | + '@id' => $current_host_id |
|
966 | 966 | ), |
967 | 967 | NULL, 'boinc:account-host-merge')); |
968 | 968 | } |
969 | - } |
|
969 | + } |
|
970 | 970 | |
971 | - if ($errors) { |
|
971 | + if ($errors) { |
|
972 | 972 | // Report any hosts that failed to merge |
973 | 973 | foreach ($errors as $id => $error) { |
974 | - drupal_set_message( |
|
974 | + drupal_set_message( |
|
975 | 975 | bts('Computer @old_id failed to merge: @message', |
976 | - array( |
|
976 | + array( |
|
977 | 977 | '@old_id' => $id, |
978 | 978 | '@message' => $error, |
979 | - ), |
|
980 | - NULL, 'boinc:account-host-merge'), |
|
979 | + ), |
|
980 | + NULL, 'boinc:account-host-merge'), |
|
981 | 981 | 'warning' |
982 | - ); |
|
982 | + ); |
|
983 | + } |
|
983 | 984 | } |
984 | - } |
|
985 | 985 | |
986 | - drupal_goto("host/{$current_host_id}"); |
|
986 | + drupal_goto("host/{$current_host_id}"); |
|
987 | 987 | } |
988 | 988 | |
989 | 989 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -995,44 +995,44 @@ discard block |
||
995 | 995 | */ |
996 | 996 | function boincwork_projectprefs_form(&$form_state, $venue) { |
997 | 997 | |
998 | - global $user; |
|
999 | - $account = user_load($user->uid); |
|
998 | + global $user; |
|
999 | + $account = user_load($user->uid); |
|
1000 | 1000 | |
1001 | - $established = TRUE; |
|
1001 | + $established = TRUE; |
|
1002 | 1002 | |
1003 | - // Get availability of special BOINC preferences |
|
1004 | - require_boinc(array('util')); |
|
1005 | - $app_types = get_app_types(); |
|
1003 | + // Get availability of special BOINC preferences |
|
1004 | + require_boinc(array('util')); |
|
1005 | + $app_types = get_app_types(); |
|
1006 | 1006 | |
1007 | - // Load any existing preferences from BOINC account |
|
1008 | - $prefs = boincwork_load_prefs('project', $venue); |
|
1007 | + // Load any existing preferences from BOINC account |
|
1008 | + $prefs = boincwork_load_prefs('project', $venue); |
|
1009 | 1009 | |
1010 | - // Take note if this is not an established preference set on the account |
|
1011 | - if (isset($prefs['@attributes']['cleared'])) { |
|
1010 | + // Take note if this is not an established preference set on the account |
|
1011 | + if (isset($prefs['@attributes']['cleared'])) { |
|
1012 | 1012 | $established = FALSE; |
1013 | - } |
|
1013 | + } |
|
1014 | 1014 | |
1015 | - // Extract modified tag if present |
|
1016 | - $modified = NULL; |
|
1017 | - if (isset($prefs['modified']['@value'])) { |
|
1015 | + // Extract modified tag if present |
|
1016 | + $modified = NULL; |
|
1017 | + if (isset($prefs['modified']['@value'])) { |
|
1018 | 1018 | $modified = $prefs['modified']['@value']; |
1019 | - } |
|
1019 | + } |
|
1020 | 1020 | |
1021 | - $venue_is_default = FALSE; |
|
1022 | - if ($account->boincuser_default_pref_set) { |
|
1021 | + $venue_is_default = FALSE; |
|
1022 | + if ($account->boincuser_default_pref_set) { |
|
1023 | 1023 | if ($account->boincuser_default_pref_set == $venue) { |
1024 | - $venue_is_default = TRUE; |
|
1024 | + $venue_is_default = TRUE; |
|
1025 | 1025 | } |
1026 | - } |
|
1027 | - elseif (!$venue OR $venue == 'generic') { |
|
1026 | + } |
|
1027 | + elseif (!$venue OR $venue == 'generic') { |
|
1028 | 1028 | $venue_is_default = TRUE; |
1029 | - } |
|
1030 | - else { |
|
1029 | + } |
|
1030 | + else { |
|
1031 | 1031 | $venue_is_default = FALSE; |
1032 | - } |
|
1032 | + } |
|
1033 | 1033 | |
1034 | - // Define form defaults |
|
1035 | - $default = array( |
|
1034 | + // Define form defaults |
|
1035 | + $default = array( |
|
1036 | 1036 | 'resource_share' => 100, |
1037 | 1037 | 'no_cpu' => 0, |
1038 | 1038 | 'no_cuda' => 0, |
@@ -1040,333 +1040,333 @@ discard block |
||
1040 | 1040 | 'no_intel_gpu' => 0, |
1041 | 1041 | 'default_venue' => $venue_is_default, |
1042 | 1042 | 'allow_beta_work' => $prefs['allow_beta_work'], |
1043 | - ); |
|
1044 | - foreach ($default as $name => $value) { |
|
1043 | + ); |
|
1044 | + foreach ($default as $name => $value) { |
|
1045 | 1045 | if (isset($prefs[$name])) { |
1046 | - if (is_array($prefs[$name])) { |
|
1046 | + if (is_array($prefs[$name])) { |
|
1047 | 1047 | if (isset($prefs[$name]['@value'])) { |
1048 | - $default[$name] = $prefs[$name]['@value']; |
|
1048 | + $default[$name] = $prefs[$name]['@value']; |
|
1049 | 1049 | } |
1050 | - } |
|
1051 | - else { |
|
1050 | + } |
|
1051 | + else { |
|
1052 | 1052 | $default[$name] = $prefs[$name]; |
1053 | - } |
|
1053 | + } |
|
1054 | + } |
|
1054 | 1055 | } |
1055 | - } |
|
1056 | 1056 | |
1057 | - // Standard option sets |
|
1058 | - $form['boolean_options'] = array( |
|
1057 | + // Standard option sets |
|
1058 | + $form['boolean_options'] = array( |
|
1059 | 1059 | '#type' => 'value', |
1060 | 1060 | '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')) |
1061 | - ); |
|
1061 | + ); |
|
1062 | 1062 | |
1063 | - // Identify preference sets that are established to distinguish what has been |
|
1064 | - // saved to the database from what is just showing default values |
|
1065 | - $form['#established'] = $established; |
|
1063 | + // Identify preference sets that are established to distinguish what has been |
|
1064 | + // saved to the database from what is just showing default values |
|
1065 | + $form['#established'] = $established; |
|
1066 | 1066 | |
1067 | - // Top level form options |
|
1068 | - $form['#tree'] = TRUE; |
|
1067 | + // Top level form options |
|
1068 | + $form['#tree'] = TRUE; |
|
1069 | 1069 | |
1070 | - // Hidden elements |
|
1071 | - $form['modified'] = array( |
|
1070 | + // Hidden elements |
|
1071 | + $form['modified'] = array( |
|
1072 | 1072 | '#type' => 'hidden', |
1073 | 1073 | '#value' => $modified, |
1074 | - ); |
|
1075 | - $form['venue'] = array( |
|
1074 | + ); |
|
1075 | + $form['venue'] = array( |
|
1076 | 1076 | '#type' => 'hidden', |
1077 | 1077 | '#value' => $venue, |
1078 | - ); |
|
1078 | + ); |
|
1079 | 1079 | |
1080 | - $form['separator_top'] = array( |
|
1080 | + $form['separator_top'] = array( |
|
1081 | 1081 | '#value' => '<div class="separator"></div>' |
1082 | - ); |
|
1082 | + ); |
|
1083 | 1083 | |
1084 | - // Common project preferences |
|
1085 | - $form['resource'] = array( |
|
1084 | + // Common project preferences |
|
1085 | + $form['resource'] = array( |
|
1086 | 1086 | '#title' => bts('Resource settings', array(), NULL, 'boinc:account-preferences-project'), |
1087 | 1087 | '#type' => 'fieldset', |
1088 | 1088 | '#description' => null, |
1089 | 1089 | '#collapsible' => TRUE, |
1090 | 1090 | '#collapsed' => FALSE |
1091 | - ); |
|
1092 | - $form['resource']['resource_share'] = array( |
|
1091 | + ); |
|
1092 | + $form['resource']['resource_share'] = array( |
|
1093 | 1093 | '#title' => bts('Resource share', array(), NULL, 'boinc:account-preferences-project'), |
1094 | 1094 | '#type' => 'textfield', |
1095 | 1095 | '#default_value' => $default['resource_share'], |
1096 | 1096 | '#size' => 5, |
1097 | 1097 | '#description' => bts("Determines the proportion of your computer's resources allocated to this project. Example: if you participate in two BOINC projects with resource shares of 100 and 200, the first will get 1/3 of your resources and the second will get 2/3.", array(), NULL, 'boinc:account-preferences-project') |
1098 | - ); |
|
1099 | - if ($app_types->count > 1) { |
|
1098 | + ); |
|
1099 | + if ($app_types->count > 1) { |
|
1100 | 1100 | if ($app_types->cpu) { |
1101 | - $form['resource']['no_cpu'] = array( |
|
1101 | + $form['resource']['no_cpu'] = array( |
|
1102 | 1102 | '#title' => bts('Use CPU', array(), NULL, 'boinc:account-preferences-project'), |
1103 | 1103 | '#type' => 'radios', |
1104 | 1104 | '#options' => $form['boolean_options']['#value'], |
1105 | 1105 | '#attributes' => array('class' => 'fancy'), |
1106 | 1106 | '#default_value' => $default['no_cpu'] ? 0 : 1, |
1107 | 1107 | '#description' => bts('Request CPU-only tasks from this project.', array(), NULL, 'boinc:account-preferences-project') |
1108 | - ); |
|
1108 | + ); |
|
1109 | 1109 | } |
1110 | 1110 | if ($app_types->cuda) { |
1111 | - $form['resource']['no_cuda'] = array( |
|
1111 | + $form['resource']['no_cuda'] = array( |
|
1112 | 1112 | '#title' => bts('Use NVIDIA GPU', array(), NULL, 'boinc:account-preferences-project'), |
1113 | 1113 | '#type' => 'radios', |
1114 | 1114 | '#options' => $form['boolean_options']['#value'], |
1115 | 1115 | '#attributes' => array('class' => 'fancy'), |
1116 | 1116 | '#default_value' => $default['no_cuda'] ? 0 : 1, |
1117 | 1117 | '#description' => bts('Request NVIDIA GPU tasks from this project.', array(), NULL, 'boinc:account-preferences-project') |
1118 | - ); |
|
1118 | + ); |
|
1119 | 1119 | } |
1120 | 1120 | if ($app_types->ati) { |
1121 | - $form['resource']['no_ati'] = array( |
|
1121 | + $form['resource']['no_ati'] = array( |
|
1122 | 1122 | '#title' => bts('Use AMD GPU', array(), NULL, 'boinc:account-preferences-project'), |
1123 | 1123 | '#type' => 'radios', |
1124 | 1124 | '#options' => $form['boolean_options']['#value'], |
1125 | 1125 | '#attributes' => array('class' => 'fancy'), |
1126 | 1126 | '#default_value' => $default['no_ati'] ? 0 : 1, |
1127 | 1127 | '#description' => bts('Request AMD GPU tasks from this project.', array(), NULL, 'boinc:account-preferences-project') |
1128 | - ); |
|
1128 | + ); |
|
1129 | 1129 | } |
1130 | 1130 | if ($app_types->intel_gpu) { |
1131 | - $form['resource']['no_intel_gpu'] = array( |
|
1131 | + $form['resource']['no_intel_gpu'] = array( |
|
1132 | 1132 | '#title' => bts('Use INTEL GPU', array(), NULL, 'boinc:account-preferences-project'), |
1133 | 1133 | '#type' => 'radios', |
1134 | 1134 | '#options' => $form['boolean_options']['#value'], |
1135 | 1135 | '#attributes' => array('class' => 'fancy'), |
1136 | 1136 | '#default_value' => $default['no_intel_gpu'] ? 0 : 1, |
1137 | 1137 | '#description' => bts('Request Intel GPU tasks from this project.', array(), NULL, 'boinc:account-preferences-project') |
1138 | - ); |
|
1138 | + ); |
|
1139 | + } |
|
1139 | 1140 | } |
1140 | - } |
|
1141 | 1141 | |
1142 | - if (variable_get('boinc_prefs_options_beta', FALSE)) { |
|
1142 | + if (variable_get('boinc_prefs_options_beta', FALSE)) { |
|
1143 | 1143 | $form['beta'] = array( |
1144 | - '#title' => bts('Beta settings', array(), NULL, 'boinc:account-preferences-project'), |
|
1145 | - '#type' => 'fieldset', |
|
1146 | - '#description' => null, |
|
1147 | - '#collapsible' => TRUE, |
|
1148 | - '#collapsed' => FALSE |
|
1144 | + '#title' => bts('Beta settings', array(), NULL, 'boinc:account-preferences-project'), |
|
1145 | + '#type' => 'fieldset', |
|
1146 | + '#description' => null, |
|
1147 | + '#collapsible' => TRUE, |
|
1148 | + '#collapsed' => FALSE |
|
1149 | 1149 | ); |
1150 | 1150 | $form['beta']['allow_beta_work'] = array( |
1151 | - '#title' => bts('Run test applications?', array(), NULL, 'boinc:account-preferences-project'), |
|
1152 | - '#type' => 'radios', |
|
1153 | - '#options' => $form['boolean_options']['#value'], |
|
1154 | - '#attributes' => array('class' => 'fancy'), |
|
1155 | - '#default_value' => ($default['allow_beta_work']) ? 1 : 0, |
|
1156 | - '#description' => bts('This helps us develop applications, but may cause jobs to fail on your computer', array(), NULL, 'boinc:account-preferences-project') |
|
1151 | + '#title' => bts('Run test applications?', array(), NULL, 'boinc:account-preferences-project'), |
|
1152 | + '#type' => 'radios', |
|
1153 | + '#options' => $form['boolean_options']['#value'], |
|
1154 | + '#attributes' => array('class' => 'fancy'), |
|
1155 | + '#default_value' => ($default['allow_beta_work']) ? 1 : 0, |
|
1156 | + '#description' => bts('This helps us develop applications, but may cause jobs to fail on your computer', array(), NULL, 'boinc:account-preferences-project') |
|
1157 | 1157 | ); |
1158 | - } |
|
1158 | + } |
|
1159 | 1159 | |
1160 | - // Add project specific prefs to the form |
|
1161 | - boincwork_add_project_specific_prefs($form, $prefs); |
|
1160 | + // Add project specific prefs to the form |
|
1161 | + boincwork_add_project_specific_prefs($form, $prefs); |
|
1162 | 1162 | |
1163 | - // Set whether to use this preference set by default for new computers |
|
1164 | - $form['default_set'] = array( |
|
1163 | + // Set whether to use this preference set by default for new computers |
|
1164 | + $form['default_set'] = array( |
|
1165 | 1165 | '#title' => bts('Default set', array(), NULL, 'boinc:account-preferences-project'), |
1166 | 1166 | '#type' => 'fieldset', |
1167 | 1167 | '#description' => null, |
1168 | 1168 | '#collapsible' => TRUE, |
1169 | 1169 | '#collapsed' => FALSE |
1170 | - ); |
|
1171 | - $form['default_set']['default_venue'] = array( |
|
1170 | + ); |
|
1171 | + $form['default_set']['default_venue'] = array( |
|
1172 | 1172 | '#title' => bts('Set used for new computers', array(), NULL, 'boinc:account-preferences-project'), |
1173 | 1173 | '#type' => 'radios', |
1174 | 1174 | '#options' => $form['boolean_options']['#value'], |
1175 | 1175 | '#attributes' => array('class' => 'fancy'), |
1176 | 1176 | '#default_value' => $default['default_venue'] ? 1 : 0, |
1177 | 1177 | '#description' => '' |
1178 | - ); |
|
1178 | + ); |
|
1179 | 1179 | |
1180 | - $form['prefs']['separator_bottom'] = array( |
|
1180 | + $form['prefs']['separator_bottom'] = array( |
|
1181 | 1181 | '#value' => '<div class="separator buttons"></div>' |
1182 | - ); |
|
1182 | + ); |
|
1183 | 1183 | |
1184 | - // Form control |
|
1185 | - $form['prefs']['form control tabs prefix'] = array( |
|
1184 | + // Form control |
|
1185 | + $form['prefs']['form control tabs prefix'] = array( |
|
1186 | 1186 | '#value' => '<ul class="form-control tab-list">' |
1187 | - ); |
|
1188 | - $form['prefs']['submit'] = array( |
|
1187 | + ); |
|
1188 | + $form['prefs']['submit'] = array( |
|
1189 | 1189 | '#prefix' => '<li class="first tab">', |
1190 | 1190 | '#type' => 'submit', |
1191 | 1191 | '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'), |
1192 | 1192 | '#suffix' => '</li>' |
1193 | - ); |
|
1194 | - $form['prefs']['form control tabs'] = array( |
|
1193 | + ); |
|
1194 | + $form['prefs']['form control tabs'] = array( |
|
1195 | 1195 | '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>' |
1196 | - ); |
|
1197 | - if ($venue AND $venue != 'generic') { |
|
1196 | + ); |
|
1197 | + if ($venue AND $venue != 'generic') { |
|
1198 | 1198 | global $base_path; |
1199 | 1199 | $form['prefs']['form control tabs']['#value'] .= '<li class="tab">' . |
1200 | - l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/project/clear/{$venue}", |
|
1200 | + l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/project/clear/{$venue}", |
|
1201 | 1201 | array( |
1202 | - 'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/project/combined')), |
|
1203 | - 'attributes' => array( |
|
1202 | + 'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/project/combined')), |
|
1203 | + 'attributes' => array( |
|
1204 | 1204 | 'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the @name preference set. Are you sure?', |
1205 | - array('@name' => $venue), NULL, 'boinc:account-preferences') . '\')' |
|
1206 | - ) |
|
1205 | + array('@name' => $venue), NULL, 'boinc:account-preferences') . '\')' |
|
1206 | + ) |
|
1207 | 1207 | ) |
1208 | - ) . '</li>'; |
|
1209 | - } |
|
1210 | - $form['prefs']['view control'] = array( |
|
1211 | - '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/project/combined') . '</li>' |
|
1212 | - ); |
|
1213 | - $form['prefs']['form control tabs suffix'] = array( |
|
1208 | + ) . '</li>'; |
|
1209 | + } |
|
1210 | + $form['prefs']['view control'] = array( |
|
1211 | + '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/project/combined') . '</li>' |
|
1212 | + ); |
|
1213 | + $form['prefs']['form control tabs suffix'] = array( |
|
1214 | 1214 | '#value' => '</ul>' |
1215 | - ); |
|
1215 | + ); |
|
1216 | 1216 | |
1217 | - return $form; |
|
1217 | + return $form; |
|
1218 | 1218 | } |
1219 | 1219 | |
1220 | 1220 | /** |
1221 | 1221 | * Add project specific preferences to the project preferences form |
1222 | 1222 | */ |
1223 | 1223 | function boincwork_add_project_specific_prefs(&$form, $prefs) { |
1224 | - // Load project specific preferences from XML config |
|
1225 | - $xml = boincwork_get_project_specific_config(); |
|
1224 | + // Load project specific preferences from XML config |
|
1225 | + $xml = boincwork_get_project_specific_config(); |
|
1226 | 1226 | |
1227 | - // Respect the order of the top level elements |
|
1228 | - $ordered_array = array(); |
|
1229 | - $unordered_array = array(); |
|
1230 | - foreach ($xml['project_specific_preferences'] as $type => $element) { |
|
1227 | + // Respect the order of the top level elements |
|
1228 | + $ordered_array = array(); |
|
1229 | + $unordered_array = array(); |
|
1230 | + foreach ($xml['project_specific_preferences'] as $type => $element) { |
|
1231 | 1231 | if (is_array($element) AND is_numeric(key($element))) { |
1232 | - foreach ($element as $ordered_element) { |
|
1232 | + foreach ($element as $ordered_element) { |
|
1233 | 1233 | if (isset($ordered_element['@position'])) { |
1234 | - $ordered_array[$ordered_element['@position']] = array($type => $ordered_element); |
|
1234 | + $ordered_array[$ordered_element['@position']] = array($type => $ordered_element); |
|
1235 | 1235 | } |
1236 | 1236 | else { |
1237 | - $unordered_array[] = array($type => $ordered_element); |
|
1237 | + $unordered_array[] = array($type => $ordered_element); |
|
1238 | + } |
|
1238 | 1239 | } |
1239 | - } |
|
1240 | 1240 | } |
1241 | 1241 | elseif (isset($element['@position'])) { |
1242 | - $ordered_array[$element['@position']] = array($type => $element); |
|
1242 | + $ordered_array[$element['@position']] = array($type => $element); |
|
1243 | 1243 | } |
1244 | 1244 | else { |
1245 | - $unordered_array[] = array($type => $element); |
|
1245 | + $unordered_array[] = array($type => $element); |
|
1246 | + } |
|
1246 | 1247 | } |
1247 | - } |
|
1248 | - ksort($ordered_array); |
|
1249 | - $primed_array = array_merge($ordered_array, $unordered_array); |
|
1250 | - $xml = array('project_specific_preferences' => $primed_array); |
|
1248 | + ksort($ordered_array); |
|
1249 | + $primed_array = array_merge($ordered_array, $unordered_array); |
|
1250 | + $xml = array('project_specific_preferences' => $primed_array); |
|
1251 | 1251 | |
1252 | - foreach ($xml['project_specific_preferences'] as $wrapped_element) { |
|
1252 | + foreach ($xml['project_specific_preferences'] as $wrapped_element) { |
|
1253 | 1253 | $type = key($wrapped_element); |
1254 | 1254 | $element= reset($wrapped_element); |
1255 | 1255 | boincwork_generate_prefs_element($form, $type, $element, $prefs['project_specific']); |
1256 | - } |
|
1256 | + } |
|
1257 | 1257 | } |
1258 | 1258 | |
1259 | 1259 | /** |
1260 | - * Validate the project preferences form. |
|
1261 | - */ |
|
1260 | + * Validate the project preferences form. |
|
1261 | + */ |
|
1262 | 1262 | function boincwork_projectprefs_form_validate($form, &$form_state) { |
1263 | 1263 | |
1264 | - // Verify all text user input values and notify form API of failures |
|
1265 | - $validation_rules = array( |
|
1264 | + // Verify all text user input values and notify form API of failures |
|
1265 | + $validation_rules = array( |
|
1266 | 1266 | 'resource' => array( |
1267 | - 'resource_share' => array( |
|
1267 | + 'resource_share' => array( |
|
1268 | 1268 | 'datatype' => 'integer', |
1269 | 1269 | 'min' => 0 |
1270 | - ), |
|
1270 | + ), |
|
1271 | 1271 | ), |
1272 | - ); |
|
1272 | + ); |
|
1273 | 1273 | |
1274 | - // Add validation rules for project specific settings |
|
1275 | - $validation_rules += boincwork_get_project_specific_config_validation_rules(); |
|
1274 | + // Add validation rules for project specific settings |
|
1275 | + $validation_rules += boincwork_get_project_specific_config_validation_rules(); |
|
1276 | 1276 | |
1277 | - // Perform validation |
|
1278 | - boincwork_validate_form($validation_rules, $form_state['values']); |
|
1277 | + // Perform validation |
|
1278 | + boincwork_validate_form($validation_rules, $form_state['values']); |
|
1279 | 1279 | |
1280 | - // Check for app validation |
|
1281 | - if (isset($validation_rules['apps'])) { |
|
1280 | + // Check for app validation |
|
1281 | + if (isset($validation_rules['apps'])) { |
|
1282 | 1282 | if (isset($validation_rules['apps']['minimum selected']) |
1283 | 1283 | AND $validation_rules['apps']['minimum selected'] > 0) { |
1284 | - $apps_selected = 0; |
|
1285 | - foreach ($validation_rules['apps']['list'] as $app) { |
|
1284 | + $apps_selected = 0; |
|
1285 | + foreach ($validation_rules['apps']['list'] as $app) { |
|
1286 | 1286 | if ($form_state['values']['applications'][$app]) $apps_selected++; |
1287 | - } |
|
1288 | - if ($apps_selected < $validation_rules['apps']['minimum selected']) { |
|
1287 | + } |
|
1288 | + if ($apps_selected < $validation_rules['apps']['minimum selected']) { |
|
1289 | 1289 | form_set_error( |
1290 | - 'applications', |
|
1291 | - bts('At least one application must be selected', array(), NULL, 'boinc:account-preferences-project') |
|
1290 | + 'applications', |
|
1291 | + bts('At least one application must be selected', array(), NULL, 'boinc:account-preferences-project') |
|
1292 | 1292 | ); |
1293 | - } |
|
1294 | - if ($apps_selected == count($validation_rules['apps']['list'])) { |
|
1293 | + } |
|
1294 | + if ($apps_selected == count($validation_rules['apps']['list'])) { |
|
1295 | 1295 | foreach ($validation_rules['apps']['list'] as $app) { |
1296 | - unset($form_state['values']['applications'][$app]); |
|
1296 | + unset($form_state['values']['applications'][$app]); |
|
1297 | 1297 | } |
1298 | 1298 | $form_state['storage']['all apps selected'] = TRUE; |
1299 | - } |
|
1299 | + } |
|
1300 | + } |
|
1300 | 1301 | } |
1301 | - } |
|
1302 | 1302 | } |
1303 | 1303 | |
1304 | 1304 | /** |
1305 | - * Handle post-validation submission of project preferences form. |
|
1306 | - */ |
|
1305 | + * Handle post-validation submission of project preferences form. |
|
1306 | + */ |
|
1307 | 1307 | function boincwork_projectprefs_form_submit($form, &$form_state) { |
1308 | - global $user; |
|
1309 | - global $site_name; |
|
1308 | + global $user; |
|
1309 | + global $site_name; |
|
1310 | 1310 | |
1311 | - require_boinc(array('util')); |
|
1312 | - $app_types = get_app_types(); |
|
1311 | + require_boinc(array('util')); |
|
1312 | + $app_types = get_app_types(); |
|
1313 | 1313 | |
1314 | - $account = user_load($user->uid); |
|
1315 | - $edit = $form_state['values']; |
|
1316 | - $venue = $edit['venue']; |
|
1314 | + $account = user_load($user->uid); |
|
1315 | + $edit = $form_state['values']; |
|
1316 | + $venue = $edit['venue']; |
|
1317 | 1317 | |
1318 | - // Load preferences from BOINC account |
|
1319 | - $prefs = boincwork_load_prefs('project', $venue); |
|
1318 | + // Load preferences from BOINC account |
|
1319 | + $prefs = boincwork_load_prefs('project', $venue); |
|
1320 | 1320 | |
1321 | - // Resource preferences |
|
1322 | - $prefs['resource_share'] = $edit['resource']['resource_share']; |
|
1323 | - if ($app_types->count > 1) { |
|
1321 | + // Resource preferences |
|
1322 | + $prefs['resource_share'] = $edit['resource']['resource_share']; |
|
1323 | + if ($app_types->count > 1) { |
|
1324 | 1324 | if ($app_types->cpu) $prefs['no_cpu'] = ($edit['resource']['no_cpu']) ? 0 : 1; |
1325 | 1325 | if ($app_types->cuda) $prefs['no_cuda'] = ($edit['resource']['no_cuda']) ? 0 : 1; |
1326 | 1326 | if ($app_types->ati) $prefs['no_ati'] = ($edit['resource']['no_ati']) ? 0 : 1; |
1327 | 1327 | if ($app_types->intel_gpu) $prefs['no_intel_gpu'] = ($edit['resource']['no_intel_gpu']) ? 0 : 1; |
1328 | - } |
|
1328 | + } |
|
1329 | 1329 | |
1330 | - // Beta preferences |
|
1331 | - if (variable_get('boinc_prefs_options_beta', FALSE)) { |
|
1330 | + // Beta preferences |
|
1331 | + if (variable_get('boinc_prefs_options_beta', FALSE)) { |
|
1332 | 1332 | $prefs['allow_beta_work'] = ($edit['beta']['allow_beta_work']) ? 1 : 0; |
1333 | - } |
|
1333 | + } |
|
1334 | 1334 | |
1335 | - // Load project specific preferences from XML config |
|
1336 | - $xml = boincwork_get_project_specific_config(); |
|
1337 | - $updated_prefs = array( |
|
1335 | + // Load project specific preferences from XML config |
|
1336 | + $xml = boincwork_get_project_specific_config(); |
|
1337 | + $updated_prefs = array( |
|
1338 | 1338 | 'project_specific' => boincwork_format_project_specific_prefs_data($edit) |
1339 | - ); |
|
1340 | - $prefs = $updated_prefs + $prefs; |
|
1339 | + ); |
|
1340 | + $prefs = $updated_prefs + $prefs; |
|
1341 | 1341 | |
1342 | - // Don't specify apps if all are selected |
|
1343 | - if (isset($form_state['storage']['all apps selected'])) { |
|
1342 | + // Don't specify apps if all are selected |
|
1343 | + if (isset($form_state['storage']['all apps selected'])) { |
|
1344 | 1344 | unset($prefs['project_specific']['app_id']); |
1345 | 1345 | unset($form_state['storage']['all apps selected']); |
1346 | - } |
|
1346 | + } |
|
1347 | 1347 | |
1348 | - // If this is a new preference set, be sure to unset the "cleared" attribute |
|
1349 | - if (isset($prefs['@attributes']['cleared'])) { |
|
1348 | + // If this is a new preference set, be sure to unset the "cleared" attribute |
|
1349 | + if (isset($prefs['@attributes']['cleared'])) { |
|
1350 | 1350 | unset($prefs['@attributes']['cleared']); |
1351 | - } |
|
1351 | + } |
|
1352 | 1352 | |
1353 | - // Save preferences back to the BOINC account |
|
1354 | - $result = boincwork_save_prefs($prefs, 'project', $venue); |
|
1353 | + // Save preferences back to the BOINC account |
|
1354 | + $result = boincwork_save_prefs($prefs, 'project', $venue); |
|
1355 | 1355 | |
1356 | - // Update the user's default preference set |
|
1357 | - if ($edit['default_set']['default_venue']) { |
|
1356 | + // Update the user's default preference set |
|
1357 | + if ($edit['default_set']['default_venue']) { |
|
1358 | 1358 | boincwork_set_default_venue($venue); |
1359 | - } |
|
1360 | - elseif ($venue == $account->boincuser_default_pref_set) { |
|
1359 | + } |
|
1360 | + elseif ($venue == $account->boincuser_default_pref_set) { |
|
1361 | 1361 | // User has cleared out the default venue setting |
1362 | 1362 | boincwork_set_default_venue(); |
1363 | - } |
|
1363 | + } |
|
1364 | 1364 | |
1365 | - if (!$result) { |
|
1365 | + if (!$result) { |
|
1366 | 1366 | watchdog('boincwork', 'Error updating project prefs for user @id: @message', array('@id' => $user->id, '@message' => mysqli_error()), WATCHDOG_ERROR); |
1367 | 1367 | drupal_set_message(t('Your changes could not be saved. Please contact support!'), 'error'); |
1368 | - } |
|
1369 | - elseif (!drupal_get_messages('status', FALSE)) { |
|
1368 | + } |
|
1369 | + elseif (!drupal_get_messages('status', FALSE)) { |
|
1370 | 1370 | // Show this message if the set wasn't created automatically (in which case |
1371 | 1371 | // there is a message tailored to that) |
1372 | 1372 | drupal_set_message(t('Your preferences have been updated. |
@@ -1374,53 +1374,53 @@ discard block |
||
1374 | 1374 | communicates with @project or you issue the "Update" |
1375 | 1375 | command from the BOINC client.', |
1376 | 1376 | array('@project' => $site_name))); |
1377 | - } |
|
1377 | + } |
|
1378 | 1378 | } |
1379 | 1379 | |
1380 | 1380 | /** |
1381 | 1381 | * The structure of the community preferences form |
1382 | 1382 | */ |
1383 | 1383 | function communityprefs_form(&$form_state) { |
1384 | - global $user; |
|
1385 | - $account = user_load($user->uid); |
|
1386 | - $form = array(); |
|
1387 | - |
|
1388 | - // Pull in some elements from the profile form |
|
1389 | - $profile_form_state = array(); |
|
1390 | - $profile = new stdClass(); |
|
1391 | - $profile->type = 'profile'; |
|
1392 | - $profile->language = ''; |
|
1393 | - if ($profile_nid = content_profile_profile_exists($profile, $account->uid)) { |
|
1384 | + global $user; |
|
1385 | + $account = user_load($user->uid); |
|
1386 | + $form = array(); |
|
1387 | + |
|
1388 | + // Pull in some elements from the profile form |
|
1389 | + $profile_form_state = array(); |
|
1390 | + $profile = new stdClass(); |
|
1391 | + $profile->type = 'profile'; |
|
1392 | + $profile->language = ''; |
|
1393 | + if ($profile_nid = content_profile_profile_exists($profile, $account->uid)) { |
|
1394 | 1394 | $profile_node = node_load($profile_nid); |
1395 | 1395 | $form_state['storage']['profile_node'] = $profile_node; |
1396 | 1396 | module_load_include('inc', 'node', 'node.pages'); |
1397 | 1397 | $profile_form = drupal_retrieve_form('profile_node_form', $profile_form_state, $profile_node); |
1398 | 1398 | drupal_prepare_form('profile_node_form', $profile_form, $profile_form_state); |
1399 | - } |
|
1399 | + } |
|
1400 | 1400 | |
1401 | - // Standard option sets |
|
1402 | - $form['boolean_options'] = array( |
|
1401 | + // Standard option sets |
|
1402 | + $form['boolean_options'] = array( |
|
1403 | 1403 | '#type' => 'value', |
1404 | 1404 | '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')) |
1405 | - ); |
|
1405 | + ); |
|
1406 | 1406 | |
1407 | - $default = array( |
|
1407 | + $default = array( |
|
1408 | 1408 | 'pm_send_notification' => '', // This is set already in pm_email_notify_user |
1409 | 1409 | 'friend_notification' => isset($account->friend_notification) ? $account->friend_notification : 0, |
1410 | 1410 | 'comments_per_page' => (isset($account->comments_per_page) AND $account->comments_per_page) ? $account->comments_per_page : variable_get('comment_default_per_page_forum', 50), |
1411 | 1411 | 'comments_order' => (isset($account->sort) AND $account->sort) ? $account->sort : variable_get('comment_default_order_forum', COMMENT_ORDER_OLDEST_FIRST), |
1412 | - ); |
|
1412 | + ); |
|
1413 | 1413 | |
1414 | - // General options |
|
1415 | - $form['general'] = array( |
|
1414 | + // General options |
|
1415 | + $form['general'] = array( |
|
1416 | 1416 | '#type' => 'fieldset', |
1417 | 1417 | '#title' => bts('General settings', array(), NULL, 'boinc:account-preferences-community'), |
1418 | 1418 | '#weight' => 0, |
1419 | 1419 | '#collapsible' => TRUE, |
1420 | 1420 | '#collapsed' => FALSE |
1421 | - ); |
|
1422 | - // Add the BOINC user name (non-unique, user editable) |
|
1423 | - $form['general']['boincuser_name'] = array( |
|
1421 | + ); |
|
1422 | + // Add the BOINC user name (non-unique, user editable) |
|
1423 | + $form['general']['boincuser_name'] = array( |
|
1424 | 1424 | '#type' => 'textfield', |
1425 | 1425 | '#title' => bts('Name', array(), NULL, 'boinc:user-or-team-name'), |
1426 | 1426 | '#default_value' => $account->boincuser_name, |
@@ -1428,252 +1428,252 @@ discard block |
||
1428 | 1428 | '#required' => TRUE, |
1429 | 1429 | '#description' => '', |
1430 | 1430 | '#size' => 40 |
1431 | - ); |
|
1432 | - // Time zone |
|
1433 | - if (variable_get('configurable_timezones', 1)) { |
|
1431 | + ); |
|
1432 | + // Time zone |
|
1433 | + if (variable_get('configurable_timezones', 1)) { |
|
1434 | 1434 | $zones = _system_zonelist(); |
1435 | 1435 | $form['general']['timezone'] = array( |
1436 | - '#type' => 'select', |
|
1437 | - '#title' => bts('Time zone', array(), NULL, 'boinc:account-preferences-community'), |
|
1438 | - '#default_value' => ($account->timezone !== NULL) ? $account->timezone : variable_get('date_default_timezone', 0), |
|
1439 | - '#options' => $zones, |
|
1440 | - '#description' => '', |
|
1436 | + '#type' => 'select', |
|
1437 | + '#title' => bts('Time zone', array(), NULL, 'boinc:account-preferences-community'), |
|
1438 | + '#default_value' => ($account->timezone !== NULL) ? $account->timezone : variable_get('date_default_timezone', 0), |
|
1439 | + '#options' => $zones, |
|
1440 | + '#description' => '', |
|
1441 | 1441 | ); |
1442 | - } |
|
1442 | + } |
|
1443 | 1443 | |
1444 | - // Notification options |
|
1445 | - $form['notifications'] = array( |
|
1444 | + // Notification options |
|
1445 | + $form['notifications'] = array( |
|
1446 | 1446 | '#type' => 'fieldset', |
1447 | 1447 | '#title' => bts('Notification settings', array(), NULL, 'boinc:account-preferences-community'), |
1448 | 1448 | '#weight' => 5, |
1449 | 1449 | '#collapsible' => TRUE, |
1450 | 1450 | '#collapsed' => FALSE |
1451 | - ); |
|
1452 | - // Pull in private message notification handling and tweak the form |
|
1453 | - $pm_notify = pm_email_notify_user('form', $edit, $account, 'account'); |
|
1454 | - $form['notifications']['pm_send_notifications'] = array_replace( |
|
1451 | + ); |
|
1452 | + // Pull in private message notification handling and tweak the form |
|
1453 | + $pm_notify = pm_email_notify_user('form', $edit, $account, 'account'); |
|
1454 | + $form['notifications']['pm_send_notifications'] = array_replace( |
|
1455 | 1455 | $pm_notify['enable_pm_mail']['pm_send_notifications'], |
1456 | 1456 | array( |
1457 | - '#type' => 'radios', |
|
1458 | - '#title' => bts('Receive email notification for private messages?', array(), NULL, 'boinc:account-preferences-community'), |
|
1459 | - '#description' => ' ', |
|
1460 | - '#options' => $form['boolean_options']['#value'], |
|
1461 | - '#attributes' => array('class' => 'fancy') |
|
1457 | + '#type' => 'radios', |
|
1458 | + '#title' => bts('Receive email notification for private messages?', array(), NULL, 'boinc:account-preferences-community'), |
|
1459 | + '#description' => ' ', |
|
1460 | + '#options' => $form['boolean_options']['#value'], |
|
1461 | + '#attributes' => array('class' => 'fancy') |
|
1462 | 1462 | ) |
1463 | - ); |
|
1464 | - $form['notifications']['friend_notification'] = array( |
|
1463 | + ); |
|
1464 | + $form['notifications']['friend_notification'] = array( |
|
1465 | 1465 | '#type' => 'radios', |
1466 | 1466 | '#title' => bts('Receive email notification for friend requests?', array(), NULL, 'boinc:account-preferences-community'), |
1467 | 1467 | '#description' => ' ', |
1468 | 1468 | '#options' => array(0 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), -1 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')), |
1469 | 1469 | '#attributes' => array('class' => 'fancy'), |
1470 | 1470 | '#default_value' => $default['friend_notification'] |
1471 | - ); |
|
1471 | + ); |
|
1472 | 1472 | |
1473 | - // Internationalization options |
|
1474 | - if (module_exists('internationalization')) { |
|
1473 | + // Internationalization options |
|
1474 | + if (module_exists('internationalization')) { |
|
1475 | 1475 | $languages = language_list('enabled'); |
1476 | 1476 | $languages = $languages[1]; |
1477 | 1477 | $names = array(); |
1478 | 1478 | foreach ($languages as $langcode => $item) { |
1479 | - $name = t($item->name); |
|
1480 | - $names[check_plain($langcode)] = check_plain($name . ($item->native != $name ? ' ('. $item->native .')' : '')); |
|
1479 | + $name = t($item->name); |
|
1480 | + $names[check_plain($langcode)] = check_plain($name . ($item->native != $name ? ' ('. $item->native .')' : '')); |
|
1481 | 1481 | } |
1482 | 1482 | $form['locale'] = array( |
1483 | - '#type' => 'fieldset', |
|
1484 | - '#title' => bts('Language settings', array(), NULL, 'boinc:account-preferences-community'), |
|
1485 | - '#weight' => 10, |
|
1486 | - '#collapsible' => TRUE, |
|
1487 | - '#collapsed' => FALSE, |
|
1483 | + '#type' => 'fieldset', |
|
1484 | + '#title' => bts('Language settings', array(), NULL, 'boinc:account-preferences-community'), |
|
1485 | + '#weight' => 10, |
|
1486 | + '#collapsible' => TRUE, |
|
1487 | + '#collapsed' => FALSE, |
|
1488 | 1488 | ); |
1489 | 1489 | |
1490 | 1490 | // Get language negotiation settings. |
1491 | 1491 | $mode = variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE); |
1492 | 1492 | $user_preferred_language = user_preferred_language($account); |
1493 | 1493 | $form['locale']['language'] = array( |
1494 | - '#type' => 'select', |
|
1495 | - '#title' => bts('Language', array(), NULL, 'boinc:account-preferences-community'), |
|
1496 | - '#default_value' => check_plain($user_preferred_language->language), |
|
1497 | - '#options' => $names, |
|
1498 | - '#description' => ($mode == LANGUAGE_NEGOTIATION_PATH) ? bts("This account's default language for e-mails and preferred language for site presentation.", array(), NULL, 'boinc:account-preferences-community') : bts("This account's default language for e-mails.", array(), NULL, 'boinc:account-preferences-community'), |
|
1494 | + '#type' => 'select', |
|
1495 | + '#title' => bts('Language', array(), NULL, 'boinc:account-preferences-community'), |
|
1496 | + '#default_value' => check_plain($user_preferred_language->language), |
|
1497 | + '#options' => $names, |
|
1498 | + '#description' => ($mode == LANGUAGE_NEGOTIATION_PATH) ? bts("This account's default language for e-mails and preferred language for site presentation.", array(), NULL, 'boinc:account-preferences-community') : bts("This account's default language for e-mails.", array(), NULL, 'boinc:account-preferences-community'), |
|
1499 | 1499 | ); |
1500 | - } |
|
1500 | + } |
|
1501 | 1501 | |
1502 | - // Avatar options |
|
1503 | - $form['gravatar'] = array( |
|
1502 | + // Avatar options |
|
1503 | + $form['gravatar'] = array( |
|
1504 | 1504 | '#type' => 'item', |
1505 | 1505 | '#value' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, it will be used for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail), NULL, 'boinc:account-preferences-community'), |
1506 | 1506 | '#description' => bts('Your Gravatar will not be shown if you upload a user picture.', array(), NULL, 'boinc:account-preferences-community'), |
1507 | - ); |
|
1508 | - if (user_access('disable own gravatar', $account)) { |
|
1507 | + ); |
|
1508 | + if (user_access('disable own gravatar', $account)) { |
|
1509 | 1509 | $form['gravatar'] = array( |
1510 | - '#type' => 'checkbox', |
|
1511 | - '#title' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, use it for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail), NULL, 'boinc:account-preferences-community'), |
|
1512 | - '#description' => bts('Gravatar will not be shown if an avatar is uploaded.', array(), NULL, 'boinc:account-preferences-community'), |
|
1513 | - '#default_value' => isset($account->gravatar) ? $account->gravatar : 0, |
|
1514 | - '#disabled' => !empty($account->picture), |
|
1515 | - ); |
|
1516 | - } |
|
1517 | - $form['gravatar']['#weight'] = 15; |
|
1518 | - $form['gravatar']['#prefix'] = '<fieldset class="collapsible"><legend><a href="#">' . bts('Avatar settings', array(), NULL, 'boinc:account-preferences-community') . '</a></legend>'; |
|
1519 | - // Upload an avatar (pulled from profile_node_form): |
|
1520 | - if (!empty($profile_form['field_image'])) { |
|
1510 | + '#type' => 'checkbox', |
|
1511 | + '#title' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, use it for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail), NULL, 'boinc:account-preferences-community'), |
|
1512 | + '#description' => bts('Gravatar will not be shown if an avatar is uploaded.', array(), NULL, 'boinc:account-preferences-community'), |
|
1513 | + '#default_value' => isset($account->gravatar) ? $account->gravatar : 0, |
|
1514 | + '#disabled' => !empty($account->picture), |
|
1515 | + ); |
|
1516 | + } |
|
1517 | + $form['gravatar']['#weight'] = 15; |
|
1518 | + $form['gravatar']['#prefix'] = '<fieldset class="collapsible"><legend><a href="#">' . bts('Avatar settings', array(), NULL, 'boinc:account-preferences-community') . '</a></legend>'; |
|
1519 | + // Upload an avatar (pulled from profile_node_form): |
|
1520 | + if (!empty($profile_form['field_image'])) { |
|
1521 | 1521 | $form['field_image'] = $profile_form['field_image']; |
1522 | - } |
|
1523 | - else { |
|
1522 | + } |
|
1523 | + else { |
|
1524 | 1524 | $form['field_image'] = array( |
1525 | - '#value' => '<div class="form-item">' |
|
1525 | + '#value' => '<div class="form-item">' |
|
1526 | 1526 | . '<label class="placeholder">' |
1527 | 1527 | . bts('This is not available until your profile is set up.', array(), NULL, 'boinc:account-preferences-community') |
1528 | 1528 | . '</label>' |
1529 | 1529 | . l(bts('Create a profile', array(), NULL, 'boinc:account-preferences-community'), 'account/profile/edit', array('attributes' => array('class' => 'form-link'))) |
1530 | 1530 | . '</div>', |
1531 | 1531 | ); |
1532 | - } |
|
1533 | - $form['field_image'][0]['#title'] = bts('Upload an avatar', array(), NULL, 'boinc:account-preferences-community'); |
|
1534 | - $form['field_image']['#weight'] = 20; |
|
1535 | - $form['field_image']['#suffix'] = '</fieldset>'; |
|
1532 | + } |
|
1533 | + $form['field_image'][0]['#title'] = bts('Upload an avatar', array(), NULL, 'boinc:account-preferences-community'); |
|
1534 | + $form['field_image']['#weight'] = 20; |
|
1535 | + $form['field_image']['#suffix'] = '</fieldset>'; |
|
1536 | 1536 | |
1537 | - // Forum options |
|
1538 | - $form['forums'] = array( |
|
1537 | + // Forum options |
|
1538 | + $form['forums'] = array( |
|
1539 | 1539 | '#type' => 'fieldset', |
1540 | 1540 | '#title' => bts('Forum settings', array(), NULL, 'boinc:account-preferences-community'), |
1541 | 1541 | '#weight' => 25, |
1542 | 1542 | '#collapsible' => TRUE, |
1543 | 1543 | '#collapsed' => FALSE |
1544 | - ); |
|
1545 | - $form['forums']['comments_per_page'] = array( |
|
1544 | + ); |
|
1545 | + $form['forums']['comments_per_page'] = array( |
|
1546 | 1546 | '#type' => 'select', |
1547 | 1547 | '#title' => bts('In discussion topics, show at most @comments_per_page', array('@comments_per_page' => ''), NULL, 'boinc:account-preferences-community'), |
1548 | 1548 | '#options' => array(10 => 10, 20 => 20, 30 => 30, 50 => 50, 100 => 100), |
1549 | 1549 | '#default_value' => $default['comments_per_page'] |
1550 | - ); |
|
1551 | - // Can't have a typical Drupal form suffix on a select box? |
|
1552 | - $form['forums']['comments_per_page_suffix'] = array( |
|
1550 | + ); |
|
1551 | + // Can't have a typical Drupal form suffix on a select box? |
|
1552 | + $form['forums']['comments_per_page_suffix'] = array( |
|
1553 | 1553 | '#value' => '<span>' . bts('comments per page', array(), NULL, 'boinc:account-preferences-community') . '</span>' |
1554 | - ); |
|
1555 | - $form['forums']['comments_order'] = array( |
|
1554 | + ); |
|
1555 | + $form['forums']['comments_order'] = array( |
|
1556 | 1556 | '#type' => 'select', |
1557 | 1557 | '#title' => bts('Sort comments in discussions', array(), NULL, 'boinc:account-preferences-community'), |
1558 | 1558 | '#options' => array(1 => bts('Newest post first', array(), NULL, 'boinc:account-preferences-community'), 2 => bts('Oldest post first', array(), NULL, 'boinc:account-preferences-community')), |
1559 | 1559 | '#default_value' => $default['comments_order'] |
1560 | - ); |
|
1561 | - // Signature (pulled from user_edit_form): |
|
1562 | - if (variable_get('user_signatures', 0) && module_exists('comment')) { |
|
1560 | + ); |
|
1561 | + // Signature (pulled from user_edit_form): |
|
1562 | + if (variable_get('user_signatures', 0) && module_exists('comment')) { |
|
1563 | 1563 | $form['forums']['signature'] = array( |
1564 | - '#type' => 'textarea', |
|
1565 | - '#title' => bts('Signature', array(), NULL, 'boinc:account-preferences-community'), |
|
1566 | - '#description' => bts('Your signature will be publicly displayed at the end of your comments.', array(), NULL, 'boinc:account-preferences-community'), |
|
1567 | - '#default_value' => $account->signature |
|
1568 | - ); |
|
1564 | + '#type' => 'textarea', |
|
1565 | + '#title' => bts('Signature', array(), NULL, 'boinc:account-preferences-community'), |
|
1566 | + '#description' => bts('Your signature will be publicly displayed at the end of your comments.', array(), NULL, 'boinc:account-preferences-community'), |
|
1567 | + '#default_value' => $account->signature |
|
1568 | + ); |
|
1569 | 1569 | // Prevent a "validation error" message when the user attempts to save with a default value they |
1570 | 1570 | // do not have access to. |
1571 | 1571 | if (!filter_access($account->signature_format) && empty($_POST)) { |
1572 | - drupal_set_message(t("The signature input format has been set to a format you don't have access to. It will be changed to a format you have access to when you save this page.")); |
|
1573 | - $edit['signature_format'] = FILTER_FORMAT_DEFAULT; |
|
1572 | + drupal_set_message(t("The signature input format has been set to a format you don't have access to. It will be changed to a format you have access to when you save this page.")); |
|
1573 | + $edit['signature_format'] = FILTER_FORMAT_DEFAULT; |
|
1574 | 1574 | } |
1575 | 1575 | $form['forums']['signature_format'] = filter_form($account->signature_format, NULL, array('signature_format')); |
1576 | 1576 | // Optionally hide signatures from comments |
1577 | 1577 | $form['forums']['hide_signatures'] = array( |
1578 | - '#type' => 'radios', |
|
1579 | - '#title' => bts('Hide signatures in forums', array(), NULL, 'boinc:account-preferences-community'), |
|
1580 | - '#description' => ' ', |
|
1581 | - '#options' => $form['boolean_options']['#value'], |
|
1582 | - '#attributes' => array('class' => 'fancy'), |
|
1583 | - '#default_value' => isset($account->hide_signatures) ? $account->hide_signatures : 0, |
|
1578 | + '#type' => 'radios', |
|
1579 | + '#title' => bts('Hide signatures in forums', array(), NULL, 'boinc:account-preferences-community'), |
|
1580 | + '#description' => ' ', |
|
1581 | + '#options' => $form['boolean_options']['#value'], |
|
1582 | + '#attributes' => array('class' => 'fancy'), |
|
1583 | + '#default_value' => isset($account->hide_signatures) ? $account->hide_signatures : 0, |
|
1584 | 1584 | ); |
1585 | - } |
|
1585 | + } |
|
1586 | 1586 | |
1587 | - //Bottom separator |
|
1588 | - $form['separator_bottom'] = array( |
|
1587 | + //Bottom separator |
|
1588 | + $form['separator_bottom'] = array( |
|
1589 | 1589 | '#value' => '<div class="separator buttons"></div>', |
1590 | 1590 | '#weight' => 999, |
1591 | - ); |
|
1591 | + ); |
|
1592 | 1592 | |
1593 | - // Form control |
|
1594 | - $form['form control tabs prefix'] = array( |
|
1593 | + // Form control |
|
1594 | + $form['form control tabs prefix'] = array( |
|
1595 | 1595 | '#value' => '<ul class="form-control tab-list">', |
1596 | 1596 | '#weight' => 1001, |
1597 | - ); |
|
1598 | - $form['submit'] = array( |
|
1597 | + ); |
|
1598 | + $form['submit'] = array( |
|
1599 | 1599 | '#prefix' => '<li class="first tab">', |
1600 | 1600 | '#type' => 'submit', |
1601 | 1601 | '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'), |
1602 | 1602 | '#suffix' => '</li>', |
1603 | 1603 | '#weight' => 1002, |
1604 | - ); |
|
1605 | - $form['form control tabs'] = array( |
|
1604 | + ); |
|
1605 | + $form['form control tabs'] = array( |
|
1606 | 1606 | '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
1607 | 1607 | '#weight' => 1003, |
1608 | - ); |
|
1609 | - $form['form control tabs suffix'] = array( |
|
1608 | + ); |
|
1609 | + $form['form control tabs suffix'] = array( |
|
1610 | 1610 | '#value' => '</ul>', |
1611 | 1611 | '#weight' => 1004, |
1612 | - ); |
|
1613 | - return $form; |
|
1612 | + ); |
|
1613 | + return $form; |
|
1614 | 1614 | } |
1615 | 1615 | |
1616 | 1616 | /** |
1617 | - * Handle validation submission of community preferences form. |
|
1618 | - */ |
|
1617 | + * Handle validation submission of community preferences form. |
|
1618 | + */ |
|
1619 | 1619 | function communityprefs_form_validate($form, &$form_state) { |
1620 | - // require_boinc(); |
|
1621 | - global $user; |
|
1622 | - $account = user_load($user->uid); |
|
1623 | - $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
1624 | - $edit = $form_state['values']; |
|
1620 | + // require_boinc(); |
|
1621 | + global $user; |
|
1622 | + $account = user_load($user->uid); |
|
1623 | + $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
1624 | + $edit = $form_state['values']; |
|
1625 | 1625 | |
1626 | - if ($edit['boincuser_name'] != $boinc_user->name) { |
|
1626 | + if ($edit['boincuser_name'] != $boinc_user->name) { |
|
1627 | 1627 | $blacklist1 = preg_split('/\r\n|\r|\n/', variable_get('boinc_weboptions_blacklisted_usernames', "admin\nadministrator\nmoderator")); |
1628 | 1628 | $blacklist2 = array(); |
1629 | 1629 | if (is_array($blacklist1)) { |
1630 | - $blacklist2 = array_map('strtolower', $blacklist1); |
|
1630 | + $blacklist2 = array_map('strtolower', $blacklist1); |
|
1631 | 1631 | } |
1632 | 1632 | if (in_array(strtolower($edit['boincuser_name']), $blacklist2)) { |
1633 | - form_set_error('boincuser_name', |
|
1633 | + form_set_error('boincuser_name', |
|
1634 | 1634 | bts('You may not use username @blname, as that name is not allowed. Please choose another name.', |
1635 | 1635 | array('@blname' => $edit['boincuser_name']), |
1636 | 1636 | NULL, 'boinc:account-preferences-community')); |
1637 | - return false; |
|
1637 | + return false; |
|
1638 | + } |
|
1638 | 1639 | } |
1639 | - } |
|
1640 | 1640 | |
1641 | - return true; |
|
1641 | + return true; |
|
1642 | 1642 | } |
1643 | 1643 | |
1644 | 1644 | /** |
1645 | - * Handle post-validation submission of community preferences form. |
|
1646 | - */ |
|
1645 | + * Handle post-validation submission of community preferences form. |
|
1646 | + */ |
|
1647 | 1647 | function communityprefs_form_submit($form, &$form_state) { |
1648 | - require_boinc('boinc_db'); |
|
1649 | - global $user; |
|
1650 | - $account = user_load($user->uid); |
|
1651 | - $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
1652 | - $edit = $form_state['values']; |
|
1653 | - $profile_node = $form_state['storage']['profile_node']; |
|
1654 | - |
|
1655 | - // Display name |
|
1656 | - if ($edit['boincuser_name'] != $boinc_user->name) { |
|
1648 | + require_boinc('boinc_db'); |
|
1649 | + global $user; |
|
1650 | + $account = user_load($user->uid); |
|
1651 | + $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
1652 | + $edit = $form_state['values']; |
|
1653 | + $profile_node = $form_state['storage']['profile_node']; |
|
1654 | + |
|
1655 | + // Display name |
|
1656 | + if ($edit['boincuser_name'] != $boinc_user->name) { |
|
1657 | 1657 | $boincuser_name = $edit['boincuser_name']; |
1658 | 1658 | $result = $boinc_user->update( |
1659 | 1659 | "name='{$boincuser_name}'" |
1660 | 1660 | ); |
1661 | - } |
|
1661 | + } |
|
1662 | 1662 | |
1663 | - // Private message settings |
|
1664 | - pm_email_notify_user('submit', $edit, $user); |
|
1663 | + // Private message settings |
|
1664 | + pm_email_notify_user('submit', $edit, $user); |
|
1665 | 1665 | |
1666 | - // Avatar settings - only set if profile_node exists. |
|
1667 | - if ($profile_node) { |
|
1666 | + // Avatar settings - only set if profile_node exists. |
|
1667 | + if ($profile_node) { |
|
1668 | 1668 | if (!$edit['field_image']) $edit['field_image'] = array(); |
1669 | 1669 | $profile_node->field_image = $edit['field_image']; |
1670 | 1670 | node_save($profile_node); |
1671 | 1671 | // Flush this from the node cache or changes won't show up immediately! |
1672 | 1672 | $profile_node = node_load($profile_node->nid, NULL, TRUE); |
1673 | - } |
|
1673 | + } |
|
1674 | 1674 | |
1675 | - // All other settings |
|
1676 | - $settings = array( |
|
1675 | + // All other settings |
|
1676 | + $settings = array( |
|
1677 | 1677 | 'signature' => $edit['signature'], |
1678 | 1678 | 'signature_format' => $edit['signature_format'], |
1679 | 1679 | 'timezone' => $edit['timezone'], |
@@ -1682,183 +1682,183 @@ discard block |
||
1682 | 1682 | 'hide_signatures' => $edit['hide_signatures'], |
1683 | 1683 | 'sort' => $edit['comments_order'], |
1684 | 1684 | 'gravatar' => $edit['gravatar'], |
1685 | - ); |
|
1686 | - if (module_exists('internationalization')) { |
|
1685 | + ); |
|
1686 | + if (module_exists('internationalization')) { |
|
1687 | 1687 | $settings['language'] = $edit['language']; |
1688 | 1688 | global $language; |
1689 | 1689 | if ($user->language != $edit['language']) { |
1690 | - global $base_url; |
|
1691 | - if ($edit['language'] != language_default('language')) { |
|
1690 | + global $base_url; |
|
1691 | + if ($edit['language'] != language_default('language')) { |
|
1692 | 1692 | $form_state['redirect'] = $base_url . '/' . $edit['language'] . '/' . $_GET['q']; |
1693 | - } |
|
1694 | - else { |
|
1693 | + } |
|
1694 | + else { |
|
1695 | 1695 | $form_state['redirect'] = $base_url . '/' . $_GET['q']; |
1696 | - } |
|
1696 | + } |
|
1697 | 1697 | } |
1698 | - } |
|
1699 | - user_save($user, $settings); |
|
1698 | + } |
|
1699 | + user_save($user, $settings); |
|
1700 | 1700 | |
1701 | - drupal_set_message(bts('Your community preferences have been updated.', array(), NULL, 'boinc:account-preferences-community')); |
|
1701 | + drupal_set_message(bts('Your community preferences have been updated.', array(), NULL, 'boinc:account-preferences-community')); |
|
1702 | 1702 | |
1703 | - // Form will not redirect if storage is set; not good if language changes |
|
1704 | - unset($form_state['storage']); |
|
1703 | + // Form will not redirect if storage is set; not good if language changes |
|
1704 | + unset($form_state['storage']); |
|
1705 | 1705 | } |
1706 | 1706 | |
1707 | 1707 | /** |
1708 | 1708 | * The structure of the privacy preferences form |
1709 | 1709 | */ |
1710 | 1710 | function boincwork_privacyprefs_form(&$form_state) { |
1711 | - require_boinc(array('user', 'prefs', 'util', 'consent')); |
|
1711 | + require_boinc(array('user', 'prefs', 'util', 'consent')); |
|
1712 | 1712 | |
1713 | - global $user; |
|
1714 | - $account = user_load($user->uid); |
|
1715 | - $boincuser = BoincUser::lookup_id($account->boincuser_id); |
|
1713 | + global $user; |
|
1714 | + $account = user_load($user->uid); |
|
1715 | + $boincuser = BoincUser::lookup_id($account->boincuser_id); |
|
1716 | 1716 | |
1717 | - // Load preferences from BOINC account |
|
1718 | - $prefs = boincwork_load_prefs('project'); |
|
1717 | + // Load preferences from BOINC account |
|
1718 | + $prefs = boincwork_load_prefs('project'); |
|
1719 | 1719 | |
1720 | - //if (!$prefs AND !$initialize_if_empty) return null; |
|
1720 | + //if (!$prefs AND !$initialize_if_empty) return null; |
|
1721 | 1721 | |
1722 | - $privacy_consent_types = boincwork_load_privacyconsenttypes(); |
|
1722 | + $privacy_consent_types = boincwork_load_privacyconsenttypes(); |
|
1723 | 1723 | |
1724 | - // Define form defaults |
|
1725 | - $default = array( |
|
1724 | + // Define form defaults |
|
1725 | + $default = array( |
|
1726 | 1726 | 'privacy' => array( |
1727 | - 'send_email' => ($boincuser->send_email) ? 1 : 0, |
|
1728 | - 'show_hosts' => ($boincuser->show_hosts) ? 1 : 0 |
|
1727 | + 'send_email' => ($boincuser->send_email) ? 1 : 0, |
|
1728 | + 'show_hosts' => ($boincuser->show_hosts) ? 1 : 0 |
|
1729 | 1729 | ) |
1730 | - ); |
|
1730 | + ); |
|
1731 | 1731 | |
1732 | - // Standard option sets |
|
1733 | - $form['boolean_options'] = array( |
|
1732 | + // Standard option sets |
|
1733 | + $form['boolean_options'] = array( |
|
1734 | 1734 | '#type' => 'value', |
1735 | 1735 | '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')) |
1736 | - ); |
|
1736 | + ); |
|
1737 | 1737 | |
1738 | - $form['privacy'] = array( |
|
1738 | + $form['privacy'] = array( |
|
1739 | 1739 | '#title' => bts('Privacy settings', array(), NULL, 'boinc:account-preferences-privacy'), |
1740 | 1740 | '#type' => 'fieldset', |
1741 | 1741 | '#description' => null, |
1742 | 1742 | '#collapsible' => TRUE, |
1743 | 1743 | '#collapsed' => FALSE |
1744 | - ); |
|
1745 | - $form['privacy']['send_email'] = array( |
|
1744 | + ); |
|
1745 | + $form['privacy']['send_email'] = array( |
|
1746 | 1746 | '#title' => bts('Is it OK for @project and your team (if any) to email you?', array('@project' => variable_get('site_name', 'Drupal-BOINC')), NULL, 'boinc:account-preferences-privacy'), |
1747 | 1747 | '#type' => 'radios', |
1748 | 1748 | '#options' => $form['boolean_options']['#value'], |
1749 | 1749 | '#attributes' => array('class' => 'fancy'), |
1750 | 1750 | '#default_value' => $default['privacy']['send_email'] |
1751 | - ); |
|
1752 | - $form['privacy']['show_hosts'] = array( |
|
1751 | + ); |
|
1752 | + $form['privacy']['show_hosts'] = array( |
|
1753 | 1753 | '#title' => bts('Should @project show your computers on its web site?', array('@project' => variable_get('site_name', 'Drupal-BOINC')), NULL, 'boinc:account-preferences-privacy'), |
1754 | 1754 | '#description' => bts('At times, you may be asked to enable this option in order to receive help from the forums. Advanced users may need to be able to inspect your computers\' information in order to help diagnose any problems.', array(), NULL, 'boinc:account-preferences-privacy'), |
1755 | 1755 | '#type' => 'radios', |
1756 | 1756 | '#options' => $form['boolean_options']['#value'], |
1757 | 1757 | '#attributes' => array('class' => 'fancy'), |
1758 | 1758 | '#default_value' => $default['privacy']['show_hosts'] |
1759 | - ); |
|
1759 | + ); |
|
1760 | 1760 | |
1761 | - // Loop over privacy consent types and create form question for each |
|
1762 | - // option that deals with privacy. |
|
1763 | - foreach ($privacy_consent_types as $ct) { |
|
1761 | + // Loop over privacy consent types and create form question for each |
|
1762 | + // option that deals with privacy. |
|
1763 | + foreach ($privacy_consent_types as $ct) { |
|
1764 | 1764 | |
1765 | 1765 | $currstate = (check_user_consent($boincuser, $ct['shortname'])) ? 1 : 0 ; |
1766 | 1766 | // Set name to 'privacyconsent_SHORTNAME', which can be parsed |
1767 | 1767 | // later in the submit function. |
1768 | 1768 | $form['privacy']['privacyconsent_'.$ct['shortname']] = array( |
1769 | - '#title' => bts($ct['description'], array(), NULL, 'boinc:account-preferences-privacy'), |
|
1770 | - '#type' => 'radios', |
|
1771 | - '#options' => $form['boolean_options']['#value'], |
|
1772 | - '#attributes' => array('class' => 'fancy'), |
|
1773 | - '#default_value' => $currstate, |
|
1769 | + '#title' => bts($ct['description'], array(), NULL, 'boinc:account-preferences-privacy'), |
|
1770 | + '#type' => 'radios', |
|
1771 | + '#options' => $form['boolean_options']['#value'], |
|
1772 | + '#attributes' => array('class' => 'fancy'), |
|
1773 | + '#default_value' => $currstate, |
|
1774 | 1774 | ); |
1775 | - } |
|
1775 | + } |
|
1776 | 1776 | |
1777 | - // Ignore and block users |
|
1778 | - if (module_exists('ignore_user')) { |
|
1777 | + // Ignore and block users |
|
1778 | + if (module_exists('ignore_user')) { |
|
1779 | 1779 | $form['ignoreblock'] = array( |
1780 | - '#title' => bts('Ignore Users', array(), NULL, 'boinc:account-preferences-privacy'), |
|
1781 | - '#type' => 'fieldset', |
|
1782 | - '#description' => bts('<p>You may ignore users in the forums and block users from sending you private messages.<p>', array(), NULL, 'boinc:ignore-user-help'), |
|
1783 | - '#collapsible' => TRUE, |
|
1784 | - '#collapsed' => FALSE |
|
1780 | + '#title' => bts('Ignore Users', array(), NULL, 'boinc:account-preferences-privacy'), |
|
1781 | + '#type' => 'fieldset', |
|
1782 | + '#description' => bts('<p>You may ignore users in the forums and block users from sending you private messages.<p>', array(), NULL, 'boinc:ignore-user-help'), |
|
1783 | + '#collapsible' => TRUE, |
|
1784 | + '#collapsed' => FALSE |
|
1785 | 1785 | ); |
1786 | 1786 | |
1787 | 1787 | // Table for ignored users |
1788 | 1788 | $form['ignoreblock']['current_ignore_section'] = array( |
1789 | - '#type' => 'item', |
|
1790 | - '#value' => bts('Current users on your Ignore List', array(), NULL, 'boinc:ignore-user-list'), |
|
1791 | - '#prefix' => '<h4>', |
|
1792 | - '#suffix' => '</h4>', |
|
1793 | - '#weight' => -20, |
|
1789 | + '#type' => 'item', |
|
1790 | + '#value' => bts('Current users on your Ignore List', array(), NULL, 'boinc:ignore-user-list'), |
|
1791 | + '#prefix' => '<h4>', |
|
1792 | + '#suffix' => '</h4>', |
|
1793 | + '#weight' => -20, |
|
1794 | 1794 | ); |
1795 | 1795 | |
1796 | 1796 | $ignored_users = _ignore_user_ignored_users(); |
1797 | 1797 | foreach ($ignored_users as $ignored_user) { |
1798 | - $form['ignoreblock']['username'][$ignored_user['iuid']] = array( |
|
1798 | + $form['ignoreblock']['username'][$ignored_user['iuid']] = array( |
|
1799 | 1799 | '#value' => $ignored_user['username'], |
1800 | - ); |
|
1801 | - $form['ignoreblock']['delete'][$ignored_user['iuid']] = array( |
|
1800 | + ); |
|
1801 | + $form['ignoreblock']['delete'][$ignored_user['iuid']] = array( |
|
1802 | 1802 | '#value' => l( |
1803 | - bts('delete', array(), NULL, 'boinc:ignore-user-delete-button'), |
|
1804 | - 'account/prefs/privacy/ignore_user/remove/'. $ignored_user['iuid'], |
|
1805 | - array() |
|
1803 | + bts('delete', array(), NULL, 'boinc:ignore-user-delete-button'), |
|
1804 | + 'account/prefs/privacy/ignore_user/remove/'. $ignored_user['iuid'], |
|
1805 | + array() |
|
1806 | 1806 | ), |
1807 | - ); |
|
1807 | + ); |
|
1808 | 1808 | } |
1809 | 1809 | $form['ignoreblock']['pager'] = array('#value' => theme('pager', NULL, 10, 0)); |
1810 | 1810 | |
1811 | 1811 | // Sub-form to add user to ignore list |
1812 | 1812 | $form['ignoreblock']['add_ignore_user_section'] = array( |
1813 | - '#type' => 'item', |
|
1814 | - '#value' => bts('Add user to Ignore List', array(), NULL, 'boinc:ignore-user-add'), |
|
1815 | - '#prefix' => '<h4>', |
|
1816 | - '#suffix' => '</h4>', |
|
1817 | - '#weight' => 10, |
|
1813 | + '#type' => 'item', |
|
1814 | + '#value' => bts('Add user to Ignore List', array(), NULL, 'boinc:ignore-user-add'), |
|
1815 | + '#prefix' => '<h4>', |
|
1816 | + '#suffix' => '</h4>', |
|
1817 | + '#weight' => 10, |
|
1818 | 1818 | ); |
1819 | 1819 | |
1820 | 1820 | $form['ignoreblock']['addusername_toignorelist'] = array( |
1821 | - '#type' => 'textfield', |
|
1822 | - '#title' => bts('Username', array(), NULL, 'boinc:ignore-user-searchbox'), |
|
1823 | - '#description' => bts('To lookup a username start typing in the search box. A list of usernames will appear as you type. The number appearing in the suffix is the BOINC id. You can find a user\'s BOINC id on their user profile page.', array(), NULL, 'boinc:ignore-user-searchbox-help'), |
|
1824 | - '#weight' => 11, |
|
1825 | - '#size' => 50, |
|
1826 | - '#autocomplete_path' => 'boincuser/autocomplete', |
|
1821 | + '#type' => 'textfield', |
|
1822 | + '#title' => bts('Username', array(), NULL, 'boinc:ignore-user-searchbox'), |
|
1823 | + '#description' => bts('To lookup a username start typing in the search box. A list of usernames will appear as you type. The number appearing in the suffix is the BOINC id. You can find a user\'s BOINC id on their user profile page.', array(), NULL, 'boinc:ignore-user-searchbox-help'), |
|
1824 | + '#weight' => 11, |
|
1825 | + '#size' => 50, |
|
1826 | + '#autocomplete_path' => 'boincuser/autocomplete', |
|
1827 | 1827 | ); |
1828 | 1828 | |
1829 | 1829 | $form['ignoreblock']['addusername_submit'] = array( |
1830 | - '#type' => 'submit', |
|
1831 | - '#value' => bts('Ignore user', array(), NULL, 'boinc:ignore-user-add'), |
|
1832 | - '#submit' => array('_boincwork_ignore_list_form_submit'), |
|
1833 | - '#weight' => 12, |
|
1834 | - '#attributes' => array('class' => 'add_ignore_user'), |
|
1830 | + '#type' => 'submit', |
|
1831 | + '#value' => bts('Ignore user', array(), NULL, 'boinc:ignore-user-add'), |
|
1832 | + '#submit' => array('_boincwork_ignore_list_form_submit'), |
|
1833 | + '#weight' => 12, |
|
1834 | + '#attributes' => array('class' => 'add_ignore_user'), |
|
1835 | 1835 | ); |
1836 | - }// endif module_exists |
|
1836 | + }// endif module_exists |
|
1837 | 1837 | |
1838 | - $form['prefs']['separator_bottom'] = array( |
|
1838 | + $form['prefs']['separator_bottom'] = array( |
|
1839 | 1839 | '#value' => '<div class="separator buttons"></div>' |
1840 | - ); |
|
1840 | + ); |
|
1841 | 1841 | |
1842 | - // Form control |
|
1843 | - $form['prefs']['form control tabs prefix'] = array( |
|
1842 | + // Form control |
|
1843 | + $form['prefs']['form control tabs prefix'] = array( |
|
1844 | 1844 | '#value' => '<ul class="form-control tab-list">' |
1845 | - ); |
|
1846 | - $form['prefs']['submit'] = array( |
|
1845 | + ); |
|
1846 | + $form['prefs']['submit'] = array( |
|
1847 | 1847 | '#prefix' => '<li class="first tab">', |
1848 | 1848 | '#type' => 'submit', |
1849 | 1849 | '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'), |
1850 | 1850 | '#validate' => array('boincwork_privacyprefs_form_validate'), |
1851 | 1851 | '#submit' => array('boincwork_privacyprefs_form_submit'), |
1852 | 1852 | '#suffix' => '</li>' |
1853 | - ); |
|
1854 | - $form['prefs']['form control tabs'] = array( |
|
1853 | + ); |
|
1854 | + $form['prefs']['form control tabs'] = array( |
|
1855 | 1855 | '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>' |
1856 | - ); |
|
1857 | - $form['prefs']['form control tabs suffix'] = array( |
|
1856 | + ); |
|
1857 | + $form['prefs']['form control tabs suffix'] = array( |
|
1858 | 1858 | '#value' => '</ul>' |
1859 | - ); |
|
1859 | + ); |
|
1860 | 1860 | |
1861 | - return $form; |
|
1861 | + return $form; |
|
1862 | 1862 | } |
1863 | 1863 | |
1864 | 1864 | /** |
@@ -1866,93 +1866,93 @@ discard block |
||
1866 | 1866 | */ |
1867 | 1867 | function theme_boincwork_privacyprefs_form($form) { |
1868 | 1868 | |
1869 | - $output = ''; |
|
1870 | - $output .= drupal_render($form['privacy']); |
|
1869 | + $output = ''; |
|
1870 | + $output .= drupal_render($form['privacy']); |
|
1871 | 1871 | |
1872 | - $header = array( |
|
1872 | + $header = array( |
|
1873 | 1873 | bts('Username', array(), NULL, 'boinc:ignore-user-list'), |
1874 | 1874 | bts('Operations', array(), NULL, 'boinc:ignore-user-list') |
1875 | - ); |
|
1875 | + ); |
|
1876 | 1876 | |
1877 | - $rows = array(); |
|
1878 | - if (isset($form['ignoreblock']['username']) && is_array($form['ignoreblock']['username'])) { |
|
1877 | + $rows = array(); |
|
1878 | + if (isset($form['ignoreblock']['username']) && is_array($form['ignoreblock']['username'])) { |
|
1879 | 1879 | foreach (element_children($form['ignoreblock']['username']) as $key) { |
1880 | - $row = array(); |
|
1881 | - $row[] = drupal_render($form['ignoreblock']['username'][$key]); |
|
1882 | - $row[] = drupal_render($form['ignoreblock']['delete'][$key]); |
|
1883 | - $rows[] = $row; |
|
1880 | + $row = array(); |
|
1881 | + $row[] = drupal_render($form['ignoreblock']['username'][$key]); |
|
1882 | + $row[] = drupal_render($form['ignoreblock']['delete'][$key]); |
|
1883 | + $rows[] = $row; |
|
1884 | + } |
|
1884 | 1885 | } |
1885 | - } |
|
1886 | - else { |
|
1886 | + else { |
|
1887 | 1887 | $rows[] = array( |
1888 | - array( |
|
1888 | + array( |
|
1889 | 1889 | 'data' => bts('You have not added any users to your Ignore List.', array(), NULL, 'boinc:ignore-user-list'), |
1890 | 1890 | 'colspan' => '2', |
1891 | - ) |
|
1891 | + ) |
|
1892 | 1892 | ); |
1893 | - } |
|
1893 | + } |
|
1894 | 1894 | |
1895 | - $attr = array('class' => 'ignore_user'); |
|
1896 | - $form['ignoreblock']['current_list']['ignored_users']['#value'] = theme('table', $header, $rows, $attr); |
|
1897 | - $output .= drupal_render($form['current_list']); |
|
1895 | + $attr = array('class' => 'ignore_user'); |
|
1896 | + $form['ignoreblock']['current_list']['ignored_users']['#value'] = theme('table', $header, $rows, $attr); |
|
1897 | + $output .= drupal_render($form['current_list']); |
|
1898 | 1898 | |
1899 | - if ($form['pager']['#value']) { |
|
1899 | + if ($form['pager']['#value']) { |
|
1900 | 1900 | $output .= drupal_render($form['pager']); |
1901 | - } |
|
1901 | + } |
|
1902 | 1902 | |
1903 | - $output .= drupal_render($form); |
|
1903 | + $output .= drupal_render($form); |
|
1904 | 1904 | |
1905 | - return $output; |
|
1905 | + return $output; |
|
1906 | 1906 | } |
1907 | 1907 | |
1908 | 1908 | /** |
1909 | - * Validate the privacy preferences form. |
|
1910 | - */ |
|
1909 | + * Validate the privacy preferences form. |
|
1910 | + */ |
|
1911 | 1911 | function boincwork_privacyprefs_form_validate($form, &$form_state) { |
1912 | - require_boinc('util'); |
|
1912 | + require_boinc('util'); |
|
1913 | 1913 | |
1914 | - // Verify all non-boolean user input values and notify form API of failures |
|
1915 | - // ... currently there are no non-boolean values! |
|
1914 | + // Verify all non-boolean user input values and notify form API of failures |
|
1915 | + // ... currently there are no non-boolean values! |
|
1916 | 1916 | } |
1917 | 1917 | |
1918 | 1918 | /** |
1919 | - * Handle post-validation submission of privacy preferences form. |
|
1920 | - */ |
|
1919 | + * Handle post-validation submission of privacy preferences form. |
|
1920 | + */ |
|
1921 | 1921 | function boincwork_privacyprefs_form_submit($form, &$form_state) { |
1922 | - require_boinc(array('user', 'prefs', 'consent')); |
|
1922 | + require_boinc(array('user', 'prefs', 'consent')); |
|
1923 | 1923 | |
1924 | - global $user; |
|
1925 | - $account = user_load($user->uid); |
|
1924 | + global $user; |
|
1925 | + $account = user_load($user->uid); |
|
1926 | 1926 | |
1927 | - // Load BOINC account |
|
1928 | - $boincuser = BoincUser::lookup_id($account->boincuser_id); |
|
1927 | + // Load BOINC account |
|
1928 | + $boincuser = BoincUser::lookup_id($account->boincuser_id); |
|
1929 | 1929 | |
1930 | - // Privacy preferences |
|
1931 | - $boincuser->send_email = ($form_state['values']['send_email']) ? true : false; |
|
1932 | - $boincuser->show_hosts = ($form_state['values']['show_hosts']) ? true : false; |
|
1930 | + // Privacy preferences |
|
1931 | + $boincuser->send_email = ($form_state['values']['send_email']) ? true : false; |
|
1932 | + $boincuser->show_hosts = ($form_state['values']['show_hosts']) ? true : false; |
|
1933 | 1933 | |
1934 | - // Privacy consent options, extract the 'privacyconsent_SHORTNAME' |
|
1935 | - // from values array, and loop over them; each is checked with |
|
1936 | - // check_consent_type(). Also check the current state of the option |
|
1937 | - // in the database. If the form value is a new state, then set it. |
|
1938 | - $result = preg_grep("/^privacyconsent/", array_keys($form_state['values'])); |
|
1939 | - $privacyconsent_prefs = array_intersect_key($form_state['values'], array_flip($result)); |
|
1940 | - foreach ($privacyconsent_prefs as $name => $newstate) { |
|
1934 | + // Privacy consent options, extract the 'privacyconsent_SHORTNAME' |
|
1935 | + // from values array, and loop over them; each is checked with |
|
1936 | + // check_consent_type(). Also check the current state of the option |
|
1937 | + // in the database. If the form value is a new state, then set it. |
|
1938 | + $result = preg_grep("/^privacyconsent/", array_keys($form_state['values'])); |
|
1939 | + $privacyconsent_prefs = array_intersect_key($form_state['values'], array_flip($result)); |
|
1940 | + foreach ($privacyconsent_prefs as $name => $newstate) { |
|
1941 | 1941 | $subname = explode('_', $name)[1]; |
1942 | 1942 | $currstate = (check_user_consent($boincuser, $subname)) ? 1 : 0 ; |
1943 | 1943 | list($checkct, $ctid) = check_consent_type($subname); |
1944 | 1944 | if ($checkct && ($currstate != $newstate)) { |
1945 | - consent_to_a_policy($boincuser, $ctid, $newstate, 0, 'Webform', time()); |
|
1945 | + consent_to_a_policy($boincuser, $ctid, $newstate, 0, 'Webform', time()); |
|
1946 | + } |
|
1946 | 1947 | } |
1947 | - } |
|
1948 | 1948 | |
1949 | - //project_prefs_update($boincuser, $main_prefs); |
|
1949 | + //project_prefs_update($boincuser, $main_prefs); |
|
1950 | 1950 | |
1951 | - db_set_active('boinc_rw'); |
|
1952 | - db_query("UPDATE user SET send_email = '{$boincuser->send_email}', show_hosts = '{$boincuser->show_hosts}' WHERE id = '{$boincuser->id}'"); |
|
1953 | - db_set_active('default'); |
|
1951 | + db_set_active('boinc_rw'); |
|
1952 | + db_query("UPDATE user SET send_email = '{$boincuser->send_email}', show_hosts = '{$boincuser->show_hosts}' WHERE id = '{$boincuser->id}'"); |
|
1953 | + db_set_active('default'); |
|
1954 | 1954 | |
1955 | - drupal_set_message(t('Your privacy preferences have been updated.')); |
|
1955 | + drupal_set_message(t('Your privacy preferences have been updated.')); |
|
1956 | 1956 | } |
1957 | 1957 | |
1958 | 1958 | /** |
@@ -1960,14 +1960,14 @@ discard block |
||
1960 | 1960 | * ignore list. |
1961 | 1961 | */ |
1962 | 1962 | function _boincwork_ignore_list_form_submit($form, $form_state) { |
1963 | - boincwork_ignore_user_add_user_username($form_state['values']['addusername_toignorelist']); |
|
1964 | - drupal_set_message( |
|
1963 | + boincwork_ignore_user_add_user_username($form_state['values']['addusername_toignorelist']); |
|
1964 | + drupal_set_message( |
|
1965 | 1965 | bts('@username has been added to your ignore list. See your !privacy_preferences for more details.', |
1966 | - array( |
|
1966 | + array( |
|
1967 | 1967 | '@username' => $form_state['values']['addusername_toignorelist'], |
1968 | 1968 | '!privacy_preferences' => l(bts('privacy preferences', array(), NULL, 'boinc:ignore-user-add'), 'account/prefs/privacy'), |
1969 | - ), |
|
1970 | - NULL, 'boinc:ignore-user-add'), |
|
1969 | + ), |
|
1970 | + NULL, 'boinc:ignore-user-add'), |
|
1971 | 1971 | 'status'); |
1972 | 1972 | } |
1973 | 1973 | |
@@ -1976,37 +1976,37 @@ discard block |
||
1976 | 1976 | */ |
1977 | 1977 | function boincwork_selectapp_form(&$form_state, $apps, $current_app) { |
1978 | 1978 | |
1979 | - $form['selectapp'] = array( |
|
1979 | + $form['selectapp'] = array( |
|
1980 | 1980 | '#type' => 'select', |
1981 | 1981 | '#attributes' => array( |
1982 | - 'class' => 'task-app-filter', |
|
1983 | - 'onchange' => 'this.form.submit();', |
|
1982 | + 'class' => 'task-app-filter', |
|
1983 | + 'onchange' => 'this.form.submit();', |
|
1984 | 1984 | ), |
1985 | 1985 | '#default_value' => $current_app, |
1986 | 1986 | '#options' => $apps, |
1987 | 1987 | '#post_render' => array('_boincwork_selectapp_form_callback'), |
1988 | - ); |
|
1988 | + ); |
|
1989 | 1989 | |
1990 | - // Class task-app-filter-submit for this form is used in |
|
1991 | - // theming. CSS sets 'display:none' if javascript is present. Thus |
|
1992 | - // only non-js users/browsers will see the Apply Filter button. |
|
1993 | - $form['submit'] = array( |
|
1990 | + // Class task-app-filter-submit for this form is used in |
|
1991 | + // theming. CSS sets 'display:none' if javascript is present. Thus |
|
1992 | + // only non-js users/browsers will see the Apply Filter button. |
|
1993 | + $form['submit'] = array( |
|
1994 | 1994 | '#type' => 'submit', |
1995 | 1995 | '#value' => bts('Apply Filter', array(), NULL, 'boinc:form-save'), |
1996 | 1996 | '#attributes' => array('class' => 'js-hide',), |
1997 | - ); |
|
1997 | + ); |
|
1998 | 1998 | |
1999 | - return $form; |
|
1999 | + return $form; |
|
2000 | 2000 | } |
2001 | 2001 | |
2002 | 2002 | /** |
2003 | 2003 | * Submit function for select appliacation form. |
2004 | 2004 | */ |
2005 | 2005 | function boincwork_selectapp_form_submit($form, &$form_state) { |
2006 | - $myargs = arg(); |
|
2007 | - array_pop($myargs); |
|
2008 | - $newpath = implode('/', $myargs ) . '/' . $form['selectapp']['#value']; |
|
2009 | - $form_state['redirect'] = $newpath; |
|
2006 | + $myargs = arg(); |
|
2007 | + array_pop($myargs); |
|
2008 | + $newpath = implode('/', $myargs ) . '/' . $form['selectapp']['#value']; |
|
2009 | + $form_state['redirect'] = $newpath; |
|
2010 | 2010 | } |
2011 | 2011 | |
2012 | 2012 | /** |
@@ -2016,7 +2016,7 @@ discard block |
||
2016 | 2016 | * 'title' for the Application drop down box. |
2017 | 2017 | */ |
2018 | 2018 | function _boincwork_selectapp_form_callback($theContent, $theElement) { |
2019 | - $disabled = '<option value="-1" disabled hidden'; |
|
2020 | - $newContent = preg_replace('/<option value="-1"/', $disabled, $theContent); |
|
2021 | - return $newContent; |
|
2019 | + $disabled = '<option value="-1" disabled hidden'; |
|
2020 | + $newContent = preg_replace('/<option value="-1"/', $disabled, $theContent); |
|
2021 | + return $newContent; |
|
2022 | 2022 | } |
@@ -127,8 +127,7 @@ discard block |
||
127 | 127 | if (isset($prefs[$name]['@value'])) { |
128 | 128 | $default[$name] = $prefs[$name]['@value']; |
129 | 129 | } |
130 | - } |
|
131 | - else { |
|
130 | + } else { |
|
132 | 131 | $default[$name] = $prefs[$name]; |
133 | 132 | } |
134 | 133 | } |
@@ -655,8 +654,7 @@ discard block |
||
655 | 654 | // Save the preset selection (or lack thereof) |
656 | 655 | if (!$preset OR $preset == 'custom') { |
657 | 656 | $prefs['preset'] = 'custom'; |
658 | - } |
|
659 | - else { |
|
657 | + } else { |
|
660 | 658 | $prefs['preset'] = $preset; |
661 | 659 | } |
662 | 660 | |
@@ -671,8 +669,7 @@ discard block |
||
671 | 669 | if (!$result) { |
672 | 670 | watchdog('boincwork', 'Error updating global prefs for user @id: @message', array('@id' => $account->id, '@message' => mysqli_error()), WATCHDOG_ERROR); |
673 | 671 | drupal_set_message(t('Your changes could not be saved. Please contact support!'), 'error'); |
674 | - } |
|
675 | - elseif (!drupal_get_messages('status', FALSE)) { |
|
672 | + } elseif (!drupal_get_messages('status', FALSE)) { |
|
676 | 673 | // Show this message if the set wasn't created automatically (in which case |
677 | 674 | // there is a message tailored to that) { |
678 | 675 | drupal_set_message(t('Your preferences have been updated. |
@@ -927,8 +924,7 @@ discard block |
||
927 | 924 | if (boincwork_host_merge($old_host, $current_host, $message)) { |
928 | 925 | $merged[$old_host->id] = $old_host->id; |
929 | 926 | $current_host = boincwork_host_get_info($current_host_id); |
930 | - } |
|
931 | - else { |
|
927 | + } else { |
|
932 | 928 | $errors[$old_host->id] = $message; |
933 | 929 | } |
934 | 930 | } |
@@ -944,8 +940,7 @@ discard block |
||
944 | 940 | $oxford_comma = ''; |
945 | 941 | } |
946 | 942 | $list = implode(', ', $list) . $oxford_comma . ' ' . $conjunction . ' ' . $last; |
947 | - } |
|
948 | - else { |
|
943 | + } else { |
|
949 | 944 | $list = $last; |
950 | 945 | } |
951 | 946 | if (count($merged) == 1) { |
@@ -956,8 +951,7 @@ discard block |
||
956 | 951 | '@id' => $current_host_id |
957 | 952 | ), |
958 | 953 | NULL, 'boinc:account-host-merge')); |
959 | - } |
|
960 | - else { |
|
954 | + } else { |
|
961 | 955 | drupal_set_message(bts( |
962 | 956 | 'Computers @old_ids have been merged successfully into @id.', |
963 | 957 | array( |
@@ -1023,11 +1017,9 @@ discard block |
||
1023 | 1017 | if ($account->boincuser_default_pref_set == $venue) { |
1024 | 1018 | $venue_is_default = TRUE; |
1025 | 1019 | } |
1026 | - } |
|
1027 | - elseif (!$venue OR $venue == 'generic') { |
|
1020 | + } elseif (!$venue OR $venue == 'generic') { |
|
1028 | 1021 | $venue_is_default = TRUE; |
1029 | - } |
|
1030 | - else { |
|
1022 | + } else { |
|
1031 | 1023 | $venue_is_default = FALSE; |
1032 | 1024 | } |
1033 | 1025 | |
@@ -1047,8 +1039,7 @@ discard block |
||
1047 | 1039 | if (isset($prefs[$name]['@value'])) { |
1048 | 1040 | $default[$name] = $prefs[$name]['@value']; |
1049 | 1041 | } |
1050 | - } |
|
1051 | - else { |
|
1042 | + } else { |
|
1052 | 1043 | $default[$name] = $prefs[$name]; |
1053 | 1044 | } |
1054 | 1045 | } |
@@ -1232,16 +1223,13 @@ discard block |
||
1232 | 1223 | foreach ($element as $ordered_element) { |
1233 | 1224 | if (isset($ordered_element['@position'])) { |
1234 | 1225 | $ordered_array[$ordered_element['@position']] = array($type => $ordered_element); |
1235 | - } |
|
1236 | - else { |
|
1226 | + } else { |
|
1237 | 1227 | $unordered_array[] = array($type => $ordered_element); |
1238 | 1228 | } |
1239 | 1229 | } |
1240 | - } |
|
1241 | - elseif (isset($element['@position'])) { |
|
1230 | + } elseif (isset($element['@position'])) { |
|
1242 | 1231 | $ordered_array[$element['@position']] = array($type => $element); |
1243 | - } |
|
1244 | - else { |
|
1232 | + } else { |
|
1245 | 1233 | $unordered_array[] = array($type => $element); |
1246 | 1234 | } |
1247 | 1235 | } |
@@ -1356,8 +1344,7 @@ discard block |
||
1356 | 1344 | // Update the user's default preference set |
1357 | 1345 | if ($edit['default_set']['default_venue']) { |
1358 | 1346 | boincwork_set_default_venue($venue); |
1359 | - } |
|
1360 | - elseif ($venue == $account->boincuser_default_pref_set) { |
|
1347 | + } elseif ($venue == $account->boincuser_default_pref_set) { |
|
1361 | 1348 | // User has cleared out the default venue setting |
1362 | 1349 | boincwork_set_default_venue(); |
1363 | 1350 | } |
@@ -1365,8 +1352,7 @@ discard block |
||
1365 | 1352 | if (!$result) { |
1366 | 1353 | watchdog('boincwork', 'Error updating project prefs for user @id: @message', array('@id' => $user->id, '@message' => mysqli_error()), WATCHDOG_ERROR); |
1367 | 1354 | drupal_set_message(t('Your changes could not be saved. Please contact support!'), 'error'); |
1368 | - } |
|
1369 | - elseif (!drupal_get_messages('status', FALSE)) { |
|
1355 | + } elseif (!drupal_get_messages('status', FALSE)) { |
|
1370 | 1356 | // Show this message if the set wasn't created automatically (in which case |
1371 | 1357 | // there is a message tailored to that) |
1372 | 1358 | drupal_set_message(t('Your preferences have been updated. |
@@ -1519,8 +1505,7 @@ discard block |
||
1519 | 1505 | // Upload an avatar (pulled from profile_node_form): |
1520 | 1506 | if (!empty($profile_form['field_image'])) { |
1521 | 1507 | $form['field_image'] = $profile_form['field_image']; |
1522 | - } |
|
1523 | - else { |
|
1508 | + } else { |
|
1524 | 1509 | $form['field_image'] = array( |
1525 | 1510 | '#value' => '<div class="form-item">' |
1526 | 1511 | . '<label class="placeholder">' |
@@ -1690,8 +1675,7 @@ discard block |
||
1690 | 1675 | global $base_url; |
1691 | 1676 | if ($edit['language'] != language_default('language')) { |
1692 | 1677 | $form_state['redirect'] = $base_url . '/' . $edit['language'] . '/' . $_GET['q']; |
1693 | - } |
|
1694 | - else { |
|
1678 | + } else { |
|
1695 | 1679 | $form_state['redirect'] = $base_url . '/' . $_GET['q']; |
1696 | 1680 | } |
1697 | 1681 | } |
@@ -1882,8 +1866,7 @@ discard block |
||
1882 | 1866 | $row[] = drupal_render($form['ignoreblock']['delete'][$key]); |
1883 | 1867 | $rows[] = $row; |
1884 | 1868 | } |
1885 | - } |
|
1886 | - else { |
|
1869 | + } else { |
|
1887 | 1870 | $rows[] = array( |
1888 | 1871 | array( |
1889 | 1872 | 'data' => bts('You have not added any users to your Ignore List.', array(), NULL, 'boinc:ignore-user-list'), |
@@ -14,10 +14,10 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * The structure of the general preferences form |
16 | 16 | */ |
17 | -function boincwork_generalprefs_form(&$form_state, $venue, $prefs_preset = null, $advanced = FALSE) { |
|
17 | +function boincwork_generalprefs_form(&$form_state, $venue, $prefs_preset = null, $advanced = false) { |
|
18 | 18 | $form = array(); |
19 | 19 | $prefs = null; |
20 | - $established = TRUE; |
|
20 | + $established = true; |
|
21 | 21 | |
22 | 22 | // Enable AHAH form support for dynamically updating content based on preset |
23 | 23 | ahah_helper_register($form, $form_state); |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | // Take note if this is not an established preference set on the account |
34 | 34 | if (isset($prefs['@attributes']['cleared'])) { |
35 | - $established = FALSE; |
|
35 | + $established = false; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | // Determine if a preset is selected or if these are custom settings |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | break; |
71 | 71 | }// switch |
72 | 72 | } else { |
73 | - $form_state['storage']['wip'] = TRUE; |
|
73 | + $form_state['storage']['wip'] = true; |
|
74 | 74 | if ( !in_array($prefs_preset, array('standard','maximum','green','minimum','custom')) ) { |
75 | 75 | if ($established) { |
76 | 76 | $prefs_preset = 'custom'; |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | // Standard option sets |
138 | 138 | $form['boolean_options'] = array( |
139 | 139 | '#type' => 'value', |
140 | - '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')) |
|
140 | + '#value' => array(1 => bts('yes', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')) |
|
141 | 141 | ); |
142 | 142 | $form['hour_options'] = array( |
143 | 143 | '#type' => 'value', |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | '#prefix' => '<div id="prefs-wrapper">', // This is our wrapper div. |
159 | 159 | '#attributes' => array('class' => 'ahah-container'), |
160 | 160 | '#suffix' => '</div>', |
161 | - '#tree' => TRUE |
|
161 | + '#tree' => true |
|
162 | 162 | ); |
163 | 163 | //$form['prefs']['debug'] = array('#value' => '<pre>' . print_r($form_state, true) . '</pre>'); |
164 | 164 | |
@@ -178,15 +178,15 @@ discard block |
||
178 | 178 | |
179 | 179 | // Simplified selectors |
180 | 180 | $form['prefs']['preset'] = array( |
181 | - '#title' => bts('Presets', array(), NULL, 'boinc:account-preferences-preset:-1:for a user to choose a computing or project preference preset.'), |
|
181 | + '#title' => bts('Presets', array(), null, 'boinc:account-preferences-preset:-1:for a user to choose a computing or project preference preset.'), |
|
182 | 182 | '#type' => 'radios', |
183 | 183 | '#description' => ' ', |
184 | 184 | '#options' => array( |
185 | - 'standard' => bts('Standard', array(), NULL, 'boinc:account-preferences-preset'), |
|
186 | - 'maximum' => bts('Maximum', array(), NULL, 'boinc:account-preferences-preset'), |
|
187 | - 'green' => bts('Green', array(), NULL, 'boinc:account-preferences-preset'), |
|
188 | - 'minimum' => bts('Minimum', array(), NULL, 'boinc:account-preferences-preset'), |
|
189 | - 'custom' => bts('Custom', array(), NULL, 'boinc:account-preferences-preset') |
|
185 | + 'standard' => bts('Standard', array(), null, 'boinc:account-preferences-preset'), |
|
186 | + 'maximum' => bts('Maximum', array(), null, 'boinc:account-preferences-preset'), |
|
187 | + 'green' => bts('Green', array(), null, 'boinc:account-preferences-preset'), |
|
188 | + 'minimum' => bts('Minimum', array(), null, 'boinc:account-preferences-preset'), |
|
189 | + 'custom' => bts('Custom', array(), null, 'boinc:account-preferences-preset') |
|
190 | 190 | ), |
191 | 191 | '#prefix' => '<div class="simple-form-controls">', |
192 | 192 | '#suffix' => '</div>', |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | ); |
200 | 200 | $form['prefs']['select preset'] = array( |
201 | 201 | '#type' => 'submit', |
202 | - '#value' => bts('Update preset', array(), NULL, 'boinc:account-preferences-preset'), |
|
202 | + '#value' => bts('Update preset', array(), null, 'boinc:account-preferences-preset'), |
|
203 | 203 | '#submit' => array('ahah_helper_generic_submit'), |
204 | 204 | // The 'no-js' class only displays this button if javascript is disabled |
205 | 205 | '#attributes' => array('class' => 'no-js'), |
@@ -207,10 +207,10 @@ discard block |
||
207 | 207 | |
208 | 208 | // Advanced preferences |
209 | 209 | $form['prefs']['advanced'] = array( |
210 | - '#title' => bts('Advanced settings', array(), NULL, 'boinc:account-preferences-option'), |
|
210 | + '#title' => bts('Advanced settings', array(), null, 'boinc:account-preferences-option'), |
|
211 | 211 | '#type' => 'fieldset', |
212 | 212 | '#description' => '', |
213 | - '#collapsible' => TRUE, |
|
213 | + '#collapsible' => true, |
|
214 | 214 | '#collapsed' => !$advanced, |
215 | 215 | '#attributes' => array('class' => 'advanced-settings'), |
216 | 216 | ); |
@@ -226,62 +226,62 @@ discard block |
||
226 | 226 | ); |
227 | 227 | |
228 | 228 | $form['prefs']['advanced']['processor'] = array( |
229 | - '#title' => bts('Processor usage', array(), NULL, 'boinc:account-preferences-computing'), |
|
229 | + '#title' => bts('Processor usage', array(), null, 'boinc:account-preferences-computing'), |
|
230 | 230 | '#type' => 'fieldset', |
231 | 231 | '#description' => '', |
232 | - '#collapsible' => FALSE, |
|
233 | - '#collapsed' => FALSE |
|
232 | + '#collapsible' => false, |
|
233 | + '#collapsed' => false |
|
234 | 234 | ); |
235 | 235 | $form['prefs']['advanced']['processor']['run_on_batteries'] = array( |
236 | - '#title' => bts('Suspend when computer is on battery?', array(), NULL, 'boinc:account-preferences-computing'), |
|
236 | + '#title' => bts('Suspend when computer is on battery?', array(), null, 'boinc:account-preferences-computing'), |
|
237 | 237 | '#type' => 'radios', |
238 | - '#description' => bts('Suspends computing on portables when running on battery power.', array(), NULL, 'boinc:account-preferences-computing'), |
|
238 | + '#description' => bts('Suspends computing on portables when running on battery power.', array(), null, 'boinc:account-preferences-computing'), |
|
239 | 239 | '#options' => $form['boolean_options']['#value'], |
240 | 240 | '#attributes' => array('class' => 'fancy'), |
241 | 241 | '#default_value' => ($default['run_on_batteries']) ? 0 : 1 // intentional inversion of setting |
242 | 242 | ); |
243 | 243 | $form['prefs']['advanced']['processor']['run_if_user_active'] = array( |
244 | - '#title' => bts('Suspend when computer is in use?', array(), NULL, 'boinc:account-preferences-computing'), |
|
244 | + '#title' => bts('Suspend when computer is in use?', array(), null, 'boinc:account-preferences-computing'), |
|
245 | 245 | '#type' => 'radios', |
246 | - '#description' => bts("Suspends computing and file transfers when you're using the computer.", array(), NULL, 'boinc:account-preferences-computing'), |
|
246 | + '#description' => bts("Suspends computing and file transfers when you're using the computer.", array(), null, 'boinc:account-preferences-computing'), |
|
247 | 247 | '#options' => $form['boolean_options']['#value'], |
248 | 248 | '#attributes' => array('class' => 'fancy'), |
249 | 249 | '#default_value' => ($default['run_if_user_active']) ? 0 : 1 // intentional inversion of setting |
250 | 250 | ); |
251 | 251 | $form['prefs']['advanced']['processor']['run_gpu_if_user_active'] = array( |
252 | - '#title' => bts('Suspend GPU computing when computer is in use?', array(), NULL, 'boinc:account-preferences-computing'), |
|
252 | + '#title' => bts('Suspend GPU computing when computer is in use?', array(), null, 'boinc:account-preferences-computing'), |
|
253 | 253 | '#type' => 'radios', |
254 | - '#description' => bts("Suspends GPU computing when you're using the computer.", array(), NULL, 'boinc:account-preferences-computing'), |
|
254 | + '#description' => bts("Suspends GPU computing when you're using the computer.", array(), null, 'boinc:account-preferences-computing'), |
|
255 | 255 | '#options' => $form['boolean_options']['#value'], |
256 | 256 | '#attributes' => array('class' => 'fancy'), |
257 | 257 | '#default_value' => ($default['run_gpu_if_user_active']) ? 0 : 1 // intentional inversion of setting |
258 | 258 | ); |
259 | 259 | $form['prefs']['advanced']['processor']['idle_time_to_run'] = array( |
260 | - '#title' => bts('"In use" means mouse/keyboard input in last', array(), NULL, 'boinc:account-preferences-computing'), |
|
260 | + '#title' => bts('"In use" means mouse/keyboard input in last', array(), null, 'boinc:account-preferences-computing'), |
|
261 | 261 | '#type' => 'textfield', |
262 | - '#field_suffix' => bts('minutes', array(), NULL, 'boinc:unit-of-time'), |
|
262 | + '#field_suffix' => bts('minutes', array(), null, 'boinc:unit-of-time'), |
|
263 | 263 | '#default_value' => $default['idle_time_to_run'], |
264 | 264 | '#size' => 1, |
265 | - '#description' => bts('This determines when the computer is considered "in use".', array(), NULL, 'boinc:account-preferences-computing') |
|
265 | + '#description' => bts('This determines when the computer is considered "in use".', array(), null, 'boinc:account-preferences-computing') |
|
266 | 266 | ); |
267 | 267 | $form['prefs']['advanced']['processor']['suspend_if_no_recent_input'] = array( |
268 | - '#title' => bts('Suspend when no mouse/keyboard input in last', array(), NULL, 'boinc:account-preferences-computing'), |
|
268 | + '#title' => bts('Suspend when no mouse/keyboard input in last', array(), null, 'boinc:account-preferences-computing'), |
|
269 | 269 | '#type' => 'textfield', |
270 | - '#field_suffix' => bts('minutes', array(), NULL, 'boinc:unit-of-time'), |
|
270 | + '#field_suffix' => bts('minutes', array(), null, 'boinc:unit-of-time'), |
|
271 | 271 | '#default_value' => $default['suspend_if_no_recent_input'], |
272 | 272 | '#size' => 1, |
273 | - '#description' => bts('This allows some computers to enter low-power mode when not in use.', array(), NULL, 'boinc:account-preferences-computing') |
|
273 | + '#description' => bts('This allows some computers to enter low-power mode when not in use.', array(), null, 'boinc:account-preferences-computing') |
|
274 | 274 | ); |
275 | 275 | $form['prefs']['advanced']['processor']['suspend_cpu_usage'] = array( |
276 | - '#title' => bts('Suspend when non-BOINC CPU usage is above', array(), NULL, 'boinc:account-preferences-computing'), |
|
276 | + '#title' => bts('Suspend when non-BOINC CPU usage is above', array(), null, 'boinc:account-preferences-computing'), |
|
277 | 277 | '#type' => 'textfield', |
278 | 278 | '#field_suffix' => '%', |
279 | 279 | '#default_value' => $default['suspend_cpu_usage'], |
280 | 280 | '#size' => 1, |
281 | - '#description' => bts('Suspend computing when your computer is busy running other programs.', array(), NULL, 'boinc:account-preferences-computing'), |
|
281 | + '#description' => bts('Suspend computing when your computer is busy running other programs.', array(), null, 'boinc:account-preferences-computing'), |
|
282 | 282 | ); |
283 | 283 | $form['prefs']['advanced']['processor']['hour_label'] = array( |
284 | - '#value' => '<div class="form-item"><label>' . bts('Compute only between:', array(), NULL, 'boinc:account-preferences-computing') . '</label></div>' |
|
284 | + '#value' => '<div class="form-item"><label>' . bts('Compute only between:', array(), null, 'boinc:account-preferences-computing') . '</label></div>' |
|
285 | 285 | ); |
286 | 286 | $form['prefs']['advanced']['processor']['start_hour'] = array( |
287 | 287 | '#type' => 'select', |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | '#default_value' => $default['start_hour'] |
290 | 290 | ); |
291 | 291 | $form['prefs']['advanced']['processor']['hour_delimiter'] = array( |
292 | - '#value' => '<span>' . bts('and', array(), NULL, 'boinc:account-preference') . '</span>' |
|
292 | + '#value' => '<span>' . bts('and', array(), null, 'boinc:account-preference') . '</span>' |
|
293 | 293 | ); |
294 | 294 | $form['prefs']['advanced']['processor']['end_hour'] = array( |
295 | 295 | '#type' => 'select', |
@@ -297,164 +297,164 @@ discard block |
||
297 | 297 | '#default_value' => $default['end_hour'] |
298 | 298 | ); |
299 | 299 | $form['prefs']['advanced']['processor']['hour_description'] = array( |
300 | - '#value' => '<div class="form-item slim"><div class="description">' . bts('Compute only during a particular period each day.', array(), NULL, 'boinc:account-preferences-computing') . '</div></div>' |
|
300 | + '#value' => '<div class="form-item slim"><div class="description">' . bts('Compute only during a particular period each day.', array(), null, 'boinc:account-preferences-computing') . '</div></div>' |
|
301 | 301 | ); |
302 | 302 | $form['prefs']['advanced']['processor']['leave_apps_in_memory'] = array( |
303 | - '#title' => bts('Leave non-GPU tasks in memory while suspended?', array(), NULL, 'boinc:account-preferences-computing'), |
|
303 | + '#title' => bts('Leave non-GPU tasks in memory while suspended?', array(), null, 'boinc:account-preferences-computing'), |
|
304 | 304 | '#type' => 'radios', |
305 | 305 | '#options' => $form['boolean_options']['#value'], |
306 | 306 | '#attributes' => array('class' => 'fancy'), |
307 | 307 | '#default_value' => $default['leave_apps_in_memory'], |
308 | - '#description' => bts('If "Yes", suspended tasks stay in memory, and resume with no work lost. If "No", suspended tasks are removed from memory, and resume from their last checkpoint.', array(), NULL, 'boinc:account-preferences-computing') |
|
308 | + '#description' => bts('If "Yes", suspended tasks stay in memory, and resume with no work lost. If "No", suspended tasks are removed from memory, and resume from their last checkpoint.', array(), null, 'boinc:account-preferences-computing') |
|
309 | 309 | ); |
310 | 310 | $form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes'] = array( |
311 | - '#title' => bts('Switch between tasks every', array(), NULL, 'boinc:account-preferences-computing'), |
|
311 | + '#title' => bts('Switch between tasks every', array(), null, 'boinc:account-preferences-computing'), |
|
312 | 312 | '#type' => 'textfield', |
313 | - '#field_suffix' => bts('minutes', array(), NULL, 'boinc:unit-of-time'), |
|
313 | + '#field_suffix' => bts('minutes', array(), null, 'boinc:unit-of-time'), |
|
314 | 314 | '#default_value' => $default['cpu_scheduling_period_minutes'], |
315 | 315 | '#size' => 1, |
316 | - '#description' => bts('If you run several projects, BOINC may switch between them this often.', array(), NULL, 'boinc:account-preferences-computing') |
|
316 | + '#description' => bts('If you run several projects, BOINC may switch between them this often.', array(), null, 'boinc:account-preferences-computing') |
|
317 | 317 | ); |
318 | 318 | $form['prefs']['advanced']['processor']['max_ncpus_pct'] = array( |
319 | - '#title' => bts('Use at most', array(), NULL, 'boinc:account-preferences-computing'), |
|
319 | + '#title' => bts('Use at most', array(), null, 'boinc:account-preferences-computing'), |
|
320 | 320 | '#type' => 'textfield', |
321 | - '#field_suffix' => bts('% of the processors', array(), NULL, 'boinc:account-preferences-computing'), |
|
321 | + '#field_suffix' => bts('% of the processors', array(), null, 'boinc:account-preferences-computing'), |
|
322 | 322 | '#default_value' => $default['max_ncpus_pct'], |
323 | 323 | '#size' => 1, |
324 | - '#description' => bts('Keep some CPUs free for other applications. Example: 75% means use 6 cores on an 8-core CPU.', array(), NULL, 'boinc:account-preferences-computing'), |
|
324 | + '#description' => bts('Keep some CPUs free for other applications. Example: 75% means use 6 cores on an 8-core CPU.', array(), null, 'boinc:account-preferences-computing'), |
|
325 | 325 | ); |
326 | 326 | $form['prefs']['advanced']['processor']['cpu_usage_limit'] = array( |
327 | - '#title' => bts('Use at most', array(), NULL, 'boinc:account-preferences-computing'), |
|
327 | + '#title' => bts('Use at most', array(), null, 'boinc:account-preferences-computing'), |
|
328 | 328 | '#type' => 'textfield', |
329 | - '#field_suffix' => bts('% of the CPU time', array(), NULL, 'boinc:account-preferences-computing'), |
|
329 | + '#field_suffix' => bts('% of the CPU time', array(), null, 'boinc:account-preferences-computing'), |
|
330 | 330 | '#default_value' => $default['cpu_usage_limit'], |
331 | 331 | '#size' => 1, |
332 | - '#description' => bts('Suspend/resume computing every few seconds to reduce CPU temperature and energy usage. Example: 75% means compute for 3 seconds, wait for 1 second, and repeat.', array(), NULL, 'boinc:account-preferences-computing') |
|
332 | + '#description' => bts('Suspend/resume computing every few seconds to reduce CPU temperature and energy usage. Example: 75% means compute for 3 seconds, wait for 1 second, and repeat.', array(), null, 'boinc:account-preferences-computing') |
|
333 | 333 | ); |
334 | 334 | |
335 | 335 | // Disk and memory preferences |
336 | 336 | $form['prefs']['advanced']['storage'] = array( |
337 | - '#title' => bts('Disk and memory usage', array(), NULL, 'boinc:account-preferences-computing'), |
|
337 | + '#title' => bts('Disk and memory usage', array(), null, 'boinc:account-preferences-computing'), |
|
338 | 338 | '#type' => 'fieldset', |
339 | 339 | '#description' => '', |
340 | - '#collapsible' => FALSE, |
|
341 | - '#collapsed' => FALSE |
|
340 | + '#collapsible' => false, |
|
341 | + '#collapsed' => false |
|
342 | 342 | ); |
343 | 343 | $form['prefs']['advanced']['storage']['disk_max_used_gb'] = array( |
344 | - '#title' => bts('Disk: use no more than', array(), NULL, 'boinc:account-preferences-computing'), |
|
344 | + '#title' => bts('Disk: use no more than', array(), null, 'boinc:account-preferences-computing'), |
|
345 | 345 | '#type' => 'textfield', |
346 | 346 | '#field_suffix' => 'GB', |
347 | 347 | '#default_value' => $default['disk_max_used_gb'], |
348 | 348 | '#size' => 1, |
349 | - '#description' => bts('Limit the total amount of disk space used by BOINC.', array(), NULL, 'boinc:account-preferences-computing'), |
|
349 | + '#description' => bts('Limit the total amount of disk space used by BOINC.', array(), null, 'boinc:account-preferences-computing'), |
|
350 | 350 | ); |
351 | 351 | $form['prefs']['advanced']['storage']['disk_min_free_gb'] = array( |
352 | - '#title' => bts('Disk: leave at least', array(), NULL, 'boinc:account-preferences-computing'), |
|
352 | + '#title' => bts('Disk: leave at least', array(), null, 'boinc:account-preferences-computing'), |
|
353 | 353 | '#type' => 'textfield', |
354 | 354 | '#field_suffix' => 'GB free', |
355 | 355 | '#default_value' => $default['disk_min_free_gb'], |
356 | 356 | '#size' => 1, |
357 | - '#description' => bts('Limit disk usage to leave this much free space on the volume where BOINC stores data.', array(), NULL, 'boinc:account-preferences-computing'), |
|
357 | + '#description' => bts('Limit disk usage to leave this much free space on the volume where BOINC stores data.', array(), null, 'boinc:account-preferences-computing'), |
|
358 | 358 | ); |
359 | 359 | $form['prefs']['advanced']['storage']['disk_max_used_pct'] = array( |
360 | - '#title' => bts('Disk: use no more than', array(), NULL, 'boinc:account-preferences-computing'), |
|
360 | + '#title' => bts('Disk: use no more than', array(), null, 'boinc:account-preferences-computing'), |
|
361 | 361 | '#type' => 'textfield', |
362 | - '#field_suffix' => bts('% of total', array(), NULL, 'boinc:account-preferences-computing'), |
|
362 | + '#field_suffix' => bts('% of total', array(), null, 'boinc:account-preferences-computing'), |
|
363 | 363 | '#default_value' => $default['disk_max_used_pct'], |
364 | 364 | '#size' => 1, |
365 | - '#description' => bts('Limit the percentage of disk space used by BOINC on the volume where it stores data.', array(), NULL, 'boinc:account-preferences-computing') |
|
365 | + '#description' => bts('Limit the percentage of disk space used by BOINC on the volume where it stores data.', array(), null, 'boinc:account-preferences-computing') |
|
366 | 366 | ); |
367 | 367 | $form['prefs']['advanced']['storage']['disk_interval'] = array( |
368 | - '#title' => bts('Request tasks to checkpoint at most every', array(), NULL, 'boinc:account-preferences-computing'), |
|
368 | + '#title' => bts('Request tasks to checkpoint at most every', array(), null, 'boinc:account-preferences-computing'), |
|
369 | 369 | '#type' => 'textfield', |
370 | - '#field_suffix' => bts('seconds', array(), NULL, 'boinc:unit-of-time'), |
|
370 | + '#field_suffix' => bts('seconds', array(), null, 'boinc:unit-of-time'), |
|
371 | 371 | '#default_value' => $default['disk_interval'], |
372 | 372 | '#size' => 1, |
373 | - '#description' => bts('This controls how often tasks save their state to disk, so that later they can be continued from that point.', array(), NULL, 'boinc:account-preferences-computing') |
|
373 | + '#description' => bts('This controls how often tasks save their state to disk, so that later they can be continued from that point.', array(), null, 'boinc:account-preferences-computing') |
|
374 | 374 | ); |
375 | 375 | $form['prefs']['advanced']['storage']['vm_max_used_pct'] = array( |
376 | - '#title' => bts('Page/swap file: use at most', array(), NULL, 'boinc:account-preferences-computing'), |
|
376 | + '#title' => bts('Page/swap file: use at most', array(), null, 'boinc:account-preferences-computing'), |
|
377 | 377 | '#type' => 'textfield', |
378 | - '#field_suffix' => bts('% of total', array(), NULL, 'boinc:account-preferences-computing'), |
|
378 | + '#field_suffix' => bts('% of total', array(), null, 'boinc:account-preferences-computing'), |
|
379 | 379 | '#default_value' => $default['vm_max_used_pct'], |
380 | 380 | '#size' => 1, |
381 | - '#description' => bts('Limit the swap space (page file) used by BOINC.', array(), NULL, 'boinc:account-preferences-computing') |
|
381 | + '#description' => bts('Limit the swap space (page file) used by BOINC.', array(), null, 'boinc:account-preferences-computing') |
|
382 | 382 | ); |
383 | 383 | $form['prefs']['advanced']['storage']['ram_max_used_busy_pct'] = array( |
384 | - '#title' => bts('Memory: when computer is in use, use at most', array(), NULL, 'boinc:account-preferences-computing'), |
|
384 | + '#title' => bts('Memory: when computer is in use, use at most', array(), null, 'boinc:account-preferences-computing'), |
|
385 | 385 | '#type' => 'textfield', |
386 | - '#field_suffix' => bts('% of total', array(), NULL, 'boinc:account-preferences-computing'), |
|
386 | + '#field_suffix' => bts('% of total', array(), null, 'boinc:account-preferences-computing'), |
|
387 | 387 | '#default_value' => $default['ram_max_used_busy_pct'], |
388 | 388 | '#size' => 1, |
389 | - '#description' => bts("Limit the memory used by BOINC when you're using the computer.", array(), NULL, 'boinc:account-preferences-computing') |
|
389 | + '#description' => bts("Limit the memory used by BOINC when you're using the computer.", array(), null, 'boinc:account-preferences-computing') |
|
390 | 390 | ); |
391 | 391 | $form['prefs']['advanced']['storage']['ram_max_used_idle_pct'] = array( |
392 | - '#title' => bts('Memory: when computer is not in use, use at most', array(), NULL, 'boinc:account-preferences-computing'), |
|
392 | + '#title' => bts('Memory: when computer is not in use, use at most', array(), null, 'boinc:account-preferences-computing'), |
|
393 | 393 | '#type' => 'textfield', |
394 | - '#field_suffix' => bts('% of total', array(), NULL, 'boinc:account-preferences-computing'), |
|
394 | + '#field_suffix' => bts('% of total', array(), null, 'boinc:account-preferences-computing'), |
|
395 | 395 | '#default_value' => $default['ram_max_used_idle_pct'], |
396 | 396 | '#size' => 1, |
397 | - '#description' => bts("Limit the memory used by BOINC when you're not using the computer.", array(), NULL, 'boinc:account-preferences-computing') |
|
397 | + '#description' => bts("Limit the memory used by BOINC when you're not using the computer.", array(), null, 'boinc:account-preferences-computing') |
|
398 | 398 | ); |
399 | 399 | |
400 | 400 | // Network preferences |
401 | 401 | $form['prefs']['advanced']['network'] = array( |
402 | - '#title' => bts('Network usage', array(), NULL, 'boinc:account-preferences-computing'), |
|
402 | + '#title' => bts('Network usage', array(), null, 'boinc:account-preferences-computing'), |
|
403 | 403 | '#type' => 'fieldset', |
404 | 404 | '#description' => '', |
405 | - '#collapsible' => FALSE, |
|
406 | - '#collapsed' => FALSE |
|
405 | + '#collapsible' => false, |
|
406 | + '#collapsed' => false |
|
407 | 407 | ); |
408 | 408 | $form['prefs']['advanced']['network']['work_buf_min_days'] = array( |
409 | - '#title' => bts('Store at least', array(), NULL, 'boinc:account-preferences-computing'), |
|
409 | + '#title' => bts('Store at least', array(), null, 'boinc:account-preferences-computing'), |
|
410 | 410 | '#type' => 'textfield', |
411 | - '#field_suffix' => bts('days of work', array(), NULL, 'boinc:account-preferences-computing'), |
|
411 | + '#field_suffix' => bts('days of work', array(), null, 'boinc:account-preferences-computing'), |
|
412 | 412 | '#default_value' => $default['work_buf_min_days'], |
413 | 413 | '#size' => 1, |
414 | - '#description' => bts('Store at least enough tasks to keep the computer busy for this long.', array(), NULL, 'boinc:account-preferences-computing') |
|
414 | + '#description' => bts('Store at least enough tasks to keep the computer busy for this long.', array(), null, 'boinc:account-preferences-computing') |
|
415 | 415 | ); |
416 | 416 | $form['prefs']['advanced']['network']['work_buf_additional_days'] = array( |
417 | - '#title' => bts('Store up to an additional', array(), NULL, 'boinc:account-preferences-computing'), |
|
417 | + '#title' => bts('Store up to an additional', array(), null, 'boinc:account-preferences-computing'), |
|
418 | 418 | '#type' => 'textfield', |
419 | - '#field_suffix' => bts('days', array(), NULL, 'boinc:unit-of-time'), |
|
419 | + '#field_suffix' => bts('days', array(), null, 'boinc:unit-of-time'), |
|
420 | 420 | '#default_value' => $default['work_buf_additional_days'], |
421 | 421 | '#size' => 1, |
422 | - '#description' => bts('Store additional tasks above the minimum level. Determines how much work is requested when contacting a project.', array(), NULL, 'boinc:account-preferences-computing') |
|
422 | + '#description' => bts('Store additional tasks above the minimum level. Determines how much work is requested when contacting a project.', array(), null, 'boinc:account-preferences-computing') |
|
423 | 423 | ); |
424 | 424 | $form['prefs']['advanced']['network']['confirm_before_connecting'] = array( |
425 | - '#title' => bts('Confirm before connecting to Internet?', array(), NULL, 'boinc:account-preferences-computing'), |
|
425 | + '#title' => bts('Confirm before connecting to Internet?', array(), null, 'boinc:account-preferences-computing'), |
|
426 | 426 | '#type' => 'radios', |
427 | 427 | '#options' => $form['boolean_options']['#value'], |
428 | 428 | '#attributes' => array('class' => 'fancy'), |
429 | 429 | '#default_value' => $default['confirm_before_connecting'], |
430 | - '#description' => bts('Useful only if you have a modem, ISDN or VPN connection.', array(), NULL, 'boinc:account-preferences-computing') |
|
430 | + '#description' => bts('Useful only if you have a modem, ISDN or VPN connection.', array(), null, 'boinc:account-preferences-computing') |
|
431 | 431 | ); |
432 | 432 | $form['prefs']['advanced']['network']['hangup_if_dialed'] = array( |
433 | - '#title' => bts('Disconnect when done?', array(), NULL, 'boinc:account-preferences-computing'), |
|
433 | + '#title' => bts('Disconnect when done?', array(), null, 'boinc:account-preferences-computing'), |
|
434 | 434 | '#type' => 'radios', |
435 | 435 | '#options' => $form['boolean_options']['#value'], |
436 | 436 | '#attributes' => array('class' => 'fancy'), |
437 | 437 | '#default_value' => $default['hangup_if_dialed'], |
438 | - '#description' => bts('Useful only if you have a modem, ISDN or VPN connection.', array(), NULL, 'boinc:account-preferences-computing') |
|
438 | + '#description' => bts('Useful only if you have a modem, ISDN or VPN connection.', array(), null, 'boinc:account-preferences-computing') |
|
439 | 439 | ); |
440 | 440 | $form['prefs']['advanced']['network']['max_bytes_sec_down'] = array( |
441 | - '#title' => bts('Limit download rate to', array(), NULL, 'boinc:account-preferences-computing'), |
|
441 | + '#title' => bts('Limit download rate to', array(), null, 'boinc:account-preferences-computing'), |
|
442 | 442 | '#type' => 'textfield', |
443 | 443 | '#field_suffix' => 'Kbytes/sec', |
444 | 444 | '#default_value' => $default['max_bytes_sec_down']/1000, |
445 | 445 | '#size' => 1, |
446 | - '#description' => bts('Limit the download rate of file transfers.', array(), NULL, 'boinc:account-preferences-computing') |
|
446 | + '#description' => bts('Limit the download rate of file transfers.', array(), null, 'boinc:account-preferences-computing') |
|
447 | 447 | ); |
448 | 448 | $form['prefs']['advanced']['network']['max_bytes_sec_up'] = array( |
449 | - '#title' => bts('Limit upload rate to', array(), NULL, 'boinc:account-preferences-computing'), |
|
449 | + '#title' => bts('Limit upload rate to', array(), null, 'boinc:account-preferences-computing'), |
|
450 | 450 | '#type' => 'textfield', |
451 | 451 | '#field_suffix' => 'Kbytes/sec', |
452 | 452 | '#default_value' => $default['max_bytes_sec_up']/1000, |
453 | 453 | '#size' => 1, |
454 | - '#description' => bts('Limit the upload rate of file transfers.', array(), NULL, 'boinc:account-preferences-computing') |
|
454 | + '#description' => bts('Limit the upload rate of file transfers.', array(), null, 'boinc:account-preferences-computing') |
|
455 | 455 | ); |
456 | 456 | $form['prefs']['advanced']['network']['hour_label'] = array( |
457 | - '#value' => '<div class="form-item"><label>' . bts('Transfer files only between', array(), NULL, 'boinc:account-preferences-computing') . '</label></div>' |
|
457 | + '#value' => '<div class="form-item"><label>' . bts('Transfer files only between', array(), null, 'boinc:account-preferences-computing') . '</label></div>' |
|
458 | 458 | ); |
459 | 459 | $form['prefs']['advanced']['network']['net_start_hour'] = array( |
460 | 460 | '#type' => 'select', |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | '#default_value' => $default['net_start_hour'] |
463 | 463 | ); |
464 | 464 | $form['prefs']['advanced']['network']['hour_delimiter'] = array( |
465 | - '#value' => '<span>' . bts('and', array(), NULL, 'boinc:account-preference') . '</span>' |
|
465 | + '#value' => '<span>' . bts('and', array(), null, 'boinc:account-preference') . '</span>' |
|
466 | 466 | ); |
467 | 467 | $form['prefs']['advanced']['network']['net_end_hour'] = array( |
468 | 468 | '#type' => 'select', |
@@ -470,10 +470,10 @@ discard block |
||
470 | 470 | '#default_value' => $default['net_end_hour'] |
471 | 471 | ); |
472 | 472 | $form['prefs']['advanced']['network']['hour_description'] = array( |
473 | - '#value' => '<div class="form-item slim"><div class="description">' . bts('Transfer files only during a particular period each day.', array(), NULL, 'boinc:account-preferences-computing') . '</div></div>' |
|
473 | + '#value' => '<div class="form-item slim"><div class="description">' . bts('Transfer files only during a particular period each day.', array(), null, 'boinc:account-preferences-computing') . '</div></div>' |
|
474 | 474 | ); |
475 | 475 | $form['prefs']['advanced']['network']['daily_xfer_limit_mb'] = array( |
476 | - '#title' => bts('Limit usage to', array(), NULL, 'boinc:account-preferences-computing'), |
|
476 | + '#title' => bts('Limit usage to', array(), null, 'boinc:account-preferences-computing'), |
|
477 | 477 | '#type' => 'textfield', |
478 | 478 | '#field_suffix' => 'Mbytes', |
479 | 479 | '#default_value' => $default['daily_xfer_limit_mb'], |
@@ -482,18 +482,18 @@ discard block |
||
482 | 482 | $form['prefs']['advanced']['network']['daily_xfer_period_days'] = array( |
483 | 483 | '#field_prefix' => 'every', |
484 | 484 | '#type' => 'textfield', |
485 | - '#field_suffix' => bts('days', array(), NULL, 'boinc:unit-of-time'), |
|
485 | + '#field_suffix' => bts('days', array(), null, 'boinc:unit-of-time'), |
|
486 | 486 | '#default_value' => $default['daily_xfer_period_days'], |
487 | 487 | '#size' => 1, |
488 | - '#description' => bts('Example: BOINC should transfer at most 2000 MB of data every 30 days.', array(), NULL, 'boinc:account-preferences-computing'), |
|
488 | + '#description' => bts('Example: BOINC should transfer at most 2000 MB of data every 30 days.', array(), null, 'boinc:account-preferences-computing'), |
|
489 | 489 | ); |
490 | 490 | $form['prefs']['advanced']['network']['dont_verify_images'] = array( |
491 | - '#title' => bts('Skip data verification for image files?', array(), NULL, 'boinc:account-preferences-computing'), |
|
491 | + '#title' => bts('Skip data verification for image files?', array(), null, 'boinc:account-preferences-computing'), |
|
492 | 492 | '#type' => 'radios', |
493 | 493 | '#options' => $form['boolean_options']['#value'], |
494 | 494 | '#attributes' => array('class' => 'fancy'), |
495 | 495 | '#default_value' => $default['dont_verify_images'], |
496 | - '#description' => bts('Only select "Yes" if your Internet provider modifies image files. Skipping verification reduces the security of BOINC.', array(), NULL, 'boinc:account-preferences-computing') |
|
496 | + '#description' => bts('Only select "Yes" if your Internet provider modifies image files. Skipping verification reduces the security of BOINC.', array(), null, 'boinc:account-preferences-computing') |
|
497 | 497 | ); |
498 | 498 | |
499 | 499 | // The "fancy radios" are made via javascript on document load. In order for |
@@ -526,27 +526,27 @@ discard block |
||
526 | 526 | $form['prefs']['submit'] = array( |
527 | 527 | '#prefix' => '<li class="first tab">', |
528 | 528 | '#type' => 'submit', |
529 | - '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'), |
|
529 | + '#value' => bts('Save changes', array(), null, 'boinc:form-save'), |
|
530 | 530 | '#suffix' => '</li>' |
531 | 531 | ); |
532 | 532 | $form['prefs']['form control tabs'] = array( |
533 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), drupal_get_path_alias("account/prefs/computing/edit")) . '</li>' |
|
533 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), null, 'boinc:form-cancel'), drupal_get_path_alias("account/prefs/computing/edit")) . '</li>' |
|
534 | 534 | ); |
535 | - if ($venue AND $venue != 'generic') { |
|
535 | + if ($venue and $venue != 'generic') { |
|
536 | 536 | global $base_path; |
537 | 537 | $form['prefs']['form control tabs']['#value'] .= '<li class="tab">' . |
538 | - l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/computing/clear/{$venue}", |
|
538 | + l(bts('Clear', array(), null, 'boinc:form-clear'), "account/prefs/computing/clear/{$venue}", |
|
539 | 539 | array( |
540 | 540 | 'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/computing/combined')), |
541 | 541 | 'attributes' => array( |
542 | 542 | 'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the @name preference set. Are you sure?', |
543 | - array('@name' => $venue), NULL, 'boinc:account-preferences') . '\')' |
|
543 | + array('@name' => $venue), null, 'boinc:account-preferences') . '\')' |
|
544 | 544 | ) |
545 | 545 | ) |
546 | 546 | ) . '</li>'; |
547 | 547 | } |
548 | 548 | $form['prefs']['view control'] = array( |
549 | - '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/computing/combined') . '</li>' |
|
549 | + '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), null, 'boinc:account-preferences') . ')', 'account/prefs/computing/combined') . '</li>' |
|
550 | 550 | ); |
551 | 551 | $form['prefs']['form control tabs suffix'] = array( |
552 | 552 | '#value' => '</ul>' |
@@ -567,33 +567,33 @@ discard block |
||
567 | 567 | // Verify all non-boolean user input values and notify form API of failures |
568 | 568 | |
569 | 569 | // Processing preferences |
570 | - if (!verify_numeric($values['processor']['idle_time_to_run'], 1, 9999)) form_set_error('idle_time_to_run', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['idle_time_to_run']['#title']} [x] {$form['prefs']['advanced']['processor']['idle_time_to_run']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
571 | - if (!verify_numeric($values['processor']['suspend_if_no_recent_input'], 0, 9999)) form_set_error('suspend_if_no_recent_input', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['suspend_if_no_recent_input']['#title']} [x] {$form['prefs']['advanced']['processor']['suspend_if_no_recent_input']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
572 | - if (!verify_numeric($values['processor']['suspend_cpu_usage'], 0, 100)) form_set_error('suspend_cpu_usage', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['suspend_cpu_usage']['#title']} [x] {$form['prefs']['advanced']['processor']['suspend_cpu_usage']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
573 | - if (!verify_numeric($values['processor']['start_hour'], 0, 23)) form_set_error('start_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['start_hour']['#title']} [x] {$form['prefs']['advanced']['processor']['start_hour']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
574 | - if (!verify_numeric($values['processor']['end_hour'], 0, 23)) form_set_error('end_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['end_hour']['#title']} [x] {$form['prefs']['advanced']['processor']['end_hour']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
575 | - if (!verify_numeric($values['processor']['cpu_scheduling_period_minutes'], 1, 9999)) form_set_error('cpu_scheduling_period_minutes', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes']['#title']} [x] {$form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
576 | - if (!verify_numeric($values['processor']['max_ncpus_pct'], 0, 100)) form_set_error('max_ncpus_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['max_ncpus_pct']['#title']} [x] {$form['prefs']['advanced']['processor']['max_ncpus_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
577 | - if (!verify_numeric($values['processor']['cpu_usage_limit'], 0, 100)) form_set_error('cpu_usage_limit', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['cpu_usage_limit']['#title']} [x] {$form['prefs']['advanced']['processor']['cpu_usage_limit']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
570 | + if (!verify_numeric($values['processor']['idle_time_to_run'], 1, 9999)) form_set_error('idle_time_to_run', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['idle_time_to_run']['#title']} [x] {$form['prefs']['advanced']['processor']['idle_time_to_run']['#field_suffix']}"), null, 'boinc:account-preferences-computing')); |
|
571 | + if (!verify_numeric($values['processor']['suspend_if_no_recent_input'], 0, 9999)) form_set_error('suspend_if_no_recent_input', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['suspend_if_no_recent_input']['#title']} [x] {$form['prefs']['advanced']['processor']['suspend_if_no_recent_input']['#field_suffix']}"), null, 'boinc:account-preferences-computing')); |
|
572 | + if (!verify_numeric($values['processor']['suspend_cpu_usage'], 0, 100)) form_set_error('suspend_cpu_usage', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['suspend_cpu_usage']['#title']} [x] {$form['prefs']['advanced']['processor']['suspend_cpu_usage']['#field_suffix']}"), null, 'boinc:account-preferences-computing')); |
|
573 | + if (!verify_numeric($values['processor']['start_hour'], 0, 23)) form_set_error('start_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['start_hour']['#title']} [x] {$form['prefs']['advanced']['processor']['start_hour']['#field_suffix']}"), null, 'boinc:account-preferences-computing')); |
|
574 | + if (!verify_numeric($values['processor']['end_hour'], 0, 23)) form_set_error('end_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['end_hour']['#title']} [x] {$form['prefs']['advanced']['processor']['end_hour']['#field_suffix']}"), null, 'boinc:account-preferences-computing')); |
|
575 | + if (!verify_numeric($values['processor']['cpu_scheduling_period_minutes'], 1, 9999)) form_set_error('cpu_scheduling_period_minutes', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes']['#title']} [x] {$form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes']['#field_suffix']}"), null, 'boinc:account-preferences-computing')); |
|
576 | + if (!verify_numeric($values['processor']['max_ncpus_pct'], 0, 100)) form_set_error('max_ncpus_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['max_ncpus_pct']['#title']} [x] {$form['prefs']['advanced']['processor']['max_ncpus_pct']['#field_suffix']}"), null, 'boinc:account-preferences-computing')); |
|
577 | + if (!verify_numeric($values['processor']['cpu_usage_limit'], 0, 100)) form_set_error('cpu_usage_limit', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['cpu_usage_limit']['#title']} [x] {$form['prefs']['advanced']['processor']['cpu_usage_limit']['#field_suffix']}"), null, 'boinc:account-preferences-computing')); |
|
578 | 578 | |
579 | 579 | // Storage preferences |
580 | - if (!verify_numeric($values['storage']['disk_max_used_gb'], 0, 9999999)) form_set_error('disk_max_used_gb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_max_used_gb']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_max_used_gb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
581 | - if (!verify_numeric($values['storage']['disk_min_free_gb'], 0.001, 9999999)) form_set_error('disk_min_free_gb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_min_free_gb']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_min_free_gb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
582 | - if (!verify_numeric($values['storage']['disk_max_used_pct'], 0, 100)) form_set_error('disk_max_used_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_max_used_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_max_used_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
583 | - if (!verify_numeric($values['storage']['disk_interval'], 0, 9999999)) form_set_error('disk_interval', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_interval']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_interval']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
584 | - if (!verify_numeric($values['storage']['vm_max_used_pct'], 0, 100)) form_set_error('vm_max_used_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['vm_max_used_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['vm_max_used_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
585 | - if (!verify_numeric($values['storage']['ram_max_used_busy_pct'], 0, 100)) form_set_error('ram_max_used_busy_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['ram_max_used_busy_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['ram_max_used_busy_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
586 | - if (!verify_numeric($values['storage']['ram_max_used_idle_pct'], 0, 100)) form_set_error('ram_max_used_idle_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['ram_max_used_idle_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['ram_max_used_idle_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
580 | + if (!verify_numeric($values['storage']['disk_max_used_gb'], 0, 9999999)) form_set_error('disk_max_used_gb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_max_used_gb']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_max_used_gb']['#field_suffix']}"), null, 'boinc:account-preferences-computing')); |
|
581 | + if (!verify_numeric($values['storage']['disk_min_free_gb'], 0.001, 9999999)) form_set_error('disk_min_free_gb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_min_free_gb']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_min_free_gb']['#field_suffix']}"), null, 'boinc:account-preferences-computing')); |
|
582 | + if (!verify_numeric($values['storage']['disk_max_used_pct'], 0, 100)) form_set_error('disk_max_used_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_max_used_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_max_used_pct']['#field_suffix']}"), null, 'boinc:account-preferences-computing')); |
|
583 | + if (!verify_numeric($values['storage']['disk_interval'], 0, 9999999)) form_set_error('disk_interval', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_interval']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_interval']['#field_suffix']}"), null, 'boinc:account-preferences-computing')); |
|
584 | + if (!verify_numeric($values['storage']['vm_max_used_pct'], 0, 100)) form_set_error('vm_max_used_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['vm_max_used_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['vm_max_used_pct']['#field_suffix']}"), null, 'boinc:account-preferences-computing')); |
|
585 | + if (!verify_numeric($values['storage']['ram_max_used_busy_pct'], 0, 100)) form_set_error('ram_max_used_busy_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['ram_max_used_busy_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['ram_max_used_busy_pct']['#field_suffix']}"), null, 'boinc:account-preferences-computing')); |
|
586 | + if (!verify_numeric($values['storage']['ram_max_used_idle_pct'], 0, 100)) form_set_error('ram_max_used_idle_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['ram_max_used_idle_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['ram_max_used_idle_pct']['#field_suffix']}"), null, 'boinc:account-preferences-computing')); |
|
587 | 587 | |
588 | 588 | // Network preferences |
589 | - if (!verify_numeric($values['network']['work_buf_min_days'], 0, 10)) form_set_error('work_buf_min_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['work_buf_min_days']['#title']} [x] {$form['prefs']['advanced']['network']['work_buf_min_days']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
590 | - if (!verify_numeric($values['network']['work_buf_additional_days'], 0, 10)) form_set_error('work_buf_additional_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['work_buf_additional_days']['#title']} [x] {$form['prefs']['advanced']['network']['work_buf_additional_days']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
591 | - if (!verify_numeric($values['network']['max_bytes_sec_down'], 0, 9999.999)) form_set_error('max_bytes_sec_down', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['max_bytes_sec_down']['#title']} [x] {$form['prefs']['advanced']['network']['max_bytes_sec_down']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
592 | - if (!verify_numeric($values['network']['max_bytes_sec_up'], 0, 9999.999)) form_set_error('max_bytes_sec_up', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['max_bytes_sec_up']['#title']} [x] {$form['prefs']['advanced']['network']['max_bytes_sec_up']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
593 | - if (!verify_numeric($values['network']['net_start_hour'], 0, 23)) form_set_error('net_start_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['net_start_hour']['#title']} [x] {$form['prefs']['advanced']['network']['net_start_hour']['#field_suffix']}"), NULL, 'boinc:account-prefrences-computing')); |
|
594 | - if (!verify_numeric($values['network']['net_end_hour'], 0, 23)) form_set_error('net_end_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['net_end_hour']['#title']} [x] {$form['prefs']['advanced']['network']['net_end_hour']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
595 | - if (!verify_numeric($values['network']['daily_xfer_limit_mb'], 0, 9999999)) form_set_error('daily_xfer_limit_mb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#title']} [x] {$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
596 | - if (!verify_numeric($values['network']['daily_xfer_period_days'], 0, 9999999)) form_set_error('daily_xfer_period_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#title']} [x] {$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing')); |
|
589 | + if (!verify_numeric($values['network']['work_buf_min_days'], 0, 10)) form_set_error('work_buf_min_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['work_buf_min_days']['#title']} [x] {$form['prefs']['advanced']['network']['work_buf_min_days']['#field_suffix']}"), null, 'boinc:account-preferences-computing')); |
|
590 | + if (!verify_numeric($values['network']['work_buf_additional_days'], 0, 10)) form_set_error('work_buf_additional_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['work_buf_additional_days']['#title']} [x] {$form['prefs']['advanced']['network']['work_buf_additional_days']['#field_suffix']}"), null, 'boinc:account-preferences-computing')); |
|
591 | + if (!verify_numeric($values['network']['max_bytes_sec_down'], 0, 9999.999)) form_set_error('max_bytes_sec_down', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['max_bytes_sec_down']['#title']} [x] {$form['prefs']['advanced']['network']['max_bytes_sec_down']['#field_suffix']}"), null, 'boinc:account-preferences-computing')); |
|
592 | + if (!verify_numeric($values['network']['max_bytes_sec_up'], 0, 9999.999)) form_set_error('max_bytes_sec_up', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['max_bytes_sec_up']['#title']} [x] {$form['prefs']['advanced']['network']['max_bytes_sec_up']['#field_suffix']}"), null, 'boinc:account-preferences-computing')); |
|
593 | + if (!verify_numeric($values['network']['net_start_hour'], 0, 23)) form_set_error('net_start_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['net_start_hour']['#title']} [x] {$form['prefs']['advanced']['network']['net_start_hour']['#field_suffix']}"), null, 'boinc:account-prefrences-computing')); |
|
594 | + if (!verify_numeric($values['network']['net_end_hour'], 0, 23)) form_set_error('net_end_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['net_end_hour']['#title']} [x] {$form['prefs']['advanced']['network']['net_end_hour']['#field_suffix']}"), null, 'boinc:account-preferences-computing')); |
|
595 | + if (!verify_numeric($values['network']['daily_xfer_limit_mb'], 0, 9999999)) form_set_error('daily_xfer_limit_mb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#title']} [x] {$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#field_suffix']}"), null, 'boinc:account-preferences-computing')); |
|
596 | + if (!verify_numeric($values['network']['daily_xfer_period_days'], 0, 9999999)) form_set_error('daily_xfer_period_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#title']} [x] {$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#field_suffix']}"), null, 'boinc:account-preferences-computing')); |
|
597 | 597 | } |
598 | 598 | |
599 | 599 | /** |
@@ -653,7 +653,7 @@ discard block |
||
653 | 653 | unset($prefs['@attributes']['preset']); |
654 | 654 | } |
655 | 655 | // Save the preset selection (or lack thereof) |
656 | - if (!$preset OR $preset == 'custom') { |
|
656 | + if (!$preset or $preset == 'custom') { |
|
657 | 657 | $prefs['preset'] = 'custom'; |
658 | 658 | } |
659 | 659 | else { |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | watchdog('boincwork', 'Error updating global prefs for user @id: @message', array('@id' => $account->id, '@message' => mysqli_error()), WATCHDOG_ERROR); |
673 | 673 | drupal_set_message(t('Your changes could not be saved. Please contact support!'), 'error'); |
674 | 674 | } |
675 | - elseif (!drupal_get_messages('status', FALSE)) { |
|
675 | + elseif (!drupal_get_messages('status', false)) { |
|
676 | 676 | // Show this message if the set wasn't created automatically (in which case |
677 | 677 | // there is a message tailored to that) { |
678 | 678 | drupal_set_message(t('Your preferences have been updated. |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | )); |
707 | 707 | db_set_active('default'); |
708 | 708 | $current_host->task_count = boincwork_host_get_task_count($current_host->id); |
709 | - $current_host->is_new = !$current_host->total_credit AND !$current_host->task_count; |
|
709 | + $current_host->is_new = !$current_host->total_credit and !$current_host->task_count; |
|
710 | 710 | // Get the list of all other hosts owned by this user for comparison |
711 | 711 | db_set_active('boinc_ro'); |
712 | 712 | $all_other_hosts = db_query(" |
@@ -722,7 +722,7 @@ discard block |
||
722 | 722 | // First, disqualify if hosts were active at the same time |
723 | 723 | if (!$current_host->is_new) { |
724 | 724 | $other_host->task_count = boincwork_host_get_task_count($other_host->id); |
725 | - $other_host->is_new = !$other_host->total_credit AND !$other_host->task_count; |
|
725 | + $other_host->is_new = !$other_host->total_credit and !$other_host->task_count; |
|
726 | 726 | if (!$other_host->is_new) { |
727 | 727 | // If both hosts being compared are not new, see if times overlap |
728 | 728 | if (!times_disjoint($current_host, $other_host)) { |
@@ -755,7 +755,7 @@ discard block |
||
755 | 755 | /** |
756 | 756 | * Perform the database updates to merge the old host into the new host |
757 | 757 | */ |
758 | -function boincwork_host_merge($old_host, $new_host, &$message = NULL) { |
|
758 | +function boincwork_host_merge($old_host, $new_host, &$message = null) { |
|
759 | 759 | // Decay the average credit of the two hosts |
760 | 760 | require_boinc('credit'); |
761 | 761 | $now = time(); |
@@ -783,10 +783,10 @@ discard block |
||
783 | 783 | ); |
784 | 784 | db_set_active('default'); |
785 | 785 | if (!$credit_updated) { |
786 | - if ($message !== NULL) { |
|
787 | - $message = bts('Could not update credit', array(), NULL, 'boinc:account-host-merge'); |
|
786 | + if ($message !== null) { |
|
787 | + $message = bts('Could not update credit', array(), null, 'boinc:account-host-merge'); |
|
788 | 788 | } |
789 | - return FALSE; |
|
789 | + return false; |
|
790 | 790 | } |
791 | 791 | |
792 | 792 | // Move results from the old host to the new host |
@@ -799,10 +799,10 @@ discard block |
||
799 | 799 | ); |
800 | 800 | db_set_active('default'); |
801 | 801 | if (!$results_updated) { |
802 | - if ($message !== NULL) { |
|
803 | - $message = bts('Could not update results', array(), NULL, 'boinc:account-host-merge'); |
|
802 | + if ($message !== null) { |
|
803 | + $message = bts('Could not update results', array(), null, 'boinc:account-host-merge'); |
|
804 | 804 | } |
805 | - return FALSE; |
|
805 | + return false; |
|
806 | 806 | } |
807 | 807 | |
808 | 808 | // Retire the old host |
@@ -819,13 +819,13 @@ discard block |
||
819 | 819 | ); |
820 | 820 | db_set_active('default'); |
821 | 821 | if (!$old_host_retired) { |
822 | - if ($message !== NULL) { |
|
823 | - $message = bts('Could not retire old computer', array(), NULL, 'boinc:account-host-merge'); |
|
822 | + if ($message !== null) { |
|
823 | + $message = bts('Could not retire old computer', array(), null, 'boinc:account-host-merge'); |
|
824 | 824 | } |
825 | - return FALSE; |
|
825 | + return false; |
|
826 | 826 | } |
827 | 827 | |
828 | - return TRUE; |
|
828 | + return true; |
|
829 | 829 | } |
830 | 830 | |
831 | 831 | /** |
@@ -854,7 +854,7 @@ discard block |
||
854 | 854 | $form['overview'] = array( |
855 | 855 | '#value' => '<p>' . bts('Sometimes BOINC assigns separate identities to' |
856 | 856 | . ' the same computer by mistake. You can correct this by merging old' |
857 | - . ' identities with the newest one.', array(), NULL, 'boinc:account-host-merge') . '</p>' |
|
857 | + . ' identities with the newest one.', array(), null, 'boinc:account-host-merge') . '</p>' |
|
858 | 858 | . '<p>' |
859 | 859 | . bts('Check the computers that are the same as @name' |
860 | 860 | . ' (created on @date at @time with computer ID @id)', |
@@ -864,7 +864,7 @@ discard block |
||
864 | 864 | '@time' => date('G:i:s T', $current_host->create_time), |
865 | 865 | '@id' => $current_host->id, |
866 | 866 | ), |
867 | - NULL, 'boinc:account-host-merge') . '</p>', |
|
867 | + null, 'boinc:account-host-merge') . '</p>', |
|
868 | 868 | ); |
869 | 869 | |
870 | 870 | $options = array(); |
@@ -879,7 +879,7 @@ discard block |
||
879 | 879 | $form['merge'] = array( |
880 | 880 | '#title' => '', |
881 | 881 | '#type' => 'tableselect', |
882 | - '#header' => array(bts('Name', array(), NULL, 'boinc:details:-1:name-of-the-host-or-task-or-workunit-etc-being-viewed-ignoreoverwrite'), bts('Created', array(), NULL, 'boinc:host-details'), bts('Computer ID', array(), NULL, 'boinc:host-list')), |
|
882 | + '#header' => array(bts('Name', array(), null, 'boinc:details:-1:name-of-the-host-or-task-or-workunit-etc-being-viewed-ignoreoverwrite'), bts('Created', array(), null, 'boinc:host-details'), bts('Computer ID', array(), null, 'boinc:host-list')), |
|
883 | 883 | '#options' => $options, |
884 | 884 | ); |
885 | 885 | |
@@ -894,11 +894,11 @@ discard block |
||
894 | 894 | $form['prefs']['submit'] = array( |
895 | 895 | '#prefix' => '<li class="first tab">', |
896 | 896 | '#type' => 'submit', |
897 | - '#value' => bts('Merge', array(), NULL, 'boinc:form-merge'), |
|
897 | + '#value' => bts('Merge', array(), null, 'boinc:form-merge'), |
|
898 | 898 | '#suffix' => '</li>' |
899 | 899 | ); |
900 | 900 | $form['prefs']['form control tabs'] = array( |
901 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "host/{$host_id}") . '</li>' |
|
901 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), null, 'boinc:form-cancel'), "host/{$host_id}") . '</li>' |
|
902 | 902 | ); |
903 | 903 | |
904 | 904 | return $form; |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | if ($merged) { |
937 | 937 | // Generate a natural language list of IDs that were merged |
938 | 938 | $oxford_comma = ','; |
939 | - $conjunction = bts('and', array(), NULL, 'boinc:account-preference'); |
|
939 | + $conjunction = bts('and', array(), null, 'boinc:account-preference'); |
|
940 | 940 | $list = array_keys($merged); |
941 | 941 | $last = array_pop($list); |
942 | 942 | if ($list) { |
@@ -955,7 +955,7 @@ discard block |
||
955 | 955 | '@old_id' => $list, |
956 | 956 | '@id' => $current_host_id |
957 | 957 | ), |
958 | - NULL, 'boinc:account-host-merge')); |
|
958 | + null, 'boinc:account-host-merge')); |
|
959 | 959 | } |
960 | 960 | else { |
961 | 961 | drupal_set_message(bts( |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | '@old_ids' => $list, |
965 | 965 | '@id' => $current_host_id |
966 | 966 | ), |
967 | - NULL, 'boinc:account-host-merge')); |
|
967 | + null, 'boinc:account-host-merge')); |
|
968 | 968 | } |
969 | 969 | } |
970 | 970 | |
@@ -977,7 +977,7 @@ discard block |
||
977 | 977 | '@old_id' => $id, |
978 | 978 | '@message' => $error, |
979 | 979 | ), |
980 | - NULL, 'boinc:account-host-merge'), |
|
980 | + null, 'boinc:account-host-merge'), |
|
981 | 981 | 'warning' |
982 | 982 | ); |
983 | 983 | } |
@@ -998,7 +998,7 @@ discard block |
||
998 | 998 | global $user; |
999 | 999 | $account = user_load($user->uid); |
1000 | 1000 | |
1001 | - $established = TRUE; |
|
1001 | + $established = true; |
|
1002 | 1002 | |
1003 | 1003 | // Get availability of special BOINC preferences |
1004 | 1004 | require_boinc(array('util')); |
@@ -1009,26 +1009,26 @@ discard block |
||
1009 | 1009 | |
1010 | 1010 | // Take note if this is not an established preference set on the account |
1011 | 1011 | if (isset($prefs['@attributes']['cleared'])) { |
1012 | - $established = FALSE; |
|
1012 | + $established = false; |
|
1013 | 1013 | } |
1014 | 1014 | |
1015 | 1015 | // Extract modified tag if present |
1016 | - $modified = NULL; |
|
1016 | + $modified = null; |
|
1017 | 1017 | if (isset($prefs['modified']['@value'])) { |
1018 | 1018 | $modified = $prefs['modified']['@value']; |
1019 | 1019 | } |
1020 | 1020 | |
1021 | - $venue_is_default = FALSE; |
|
1021 | + $venue_is_default = false; |
|
1022 | 1022 | if ($account->boincuser_default_pref_set) { |
1023 | 1023 | if ($account->boincuser_default_pref_set == $venue) { |
1024 | - $venue_is_default = TRUE; |
|
1024 | + $venue_is_default = true; |
|
1025 | 1025 | } |
1026 | 1026 | } |
1027 | - elseif (!$venue OR $venue == 'generic') { |
|
1028 | - $venue_is_default = TRUE; |
|
1027 | + elseif (!$venue or $venue == 'generic') { |
|
1028 | + $venue_is_default = true; |
|
1029 | 1029 | } |
1030 | 1030 | else { |
1031 | - $venue_is_default = FALSE; |
|
1031 | + $venue_is_default = false; |
|
1032 | 1032 | } |
1033 | 1033 | |
1034 | 1034 | // Define form defaults |
@@ -1057,7 +1057,7 @@ discard block |
||
1057 | 1057 | // Standard option sets |
1058 | 1058 | $form['boolean_options'] = array( |
1059 | 1059 | '#type' => 'value', |
1060 | - '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')) |
|
1060 | + '#value' => array(1 => bts('yes', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')) |
|
1061 | 1061 | ); |
1062 | 1062 | |
1063 | 1063 | // Identify preference sets that are established to distinguish what has been |
@@ -1065,7 +1065,7 @@ discard block |
||
1065 | 1065 | $form['#established'] = $established; |
1066 | 1066 | |
1067 | 1067 | // Top level form options |
1068 | - $form['#tree'] = TRUE; |
|
1068 | + $form['#tree'] = true; |
|
1069 | 1069 | |
1070 | 1070 | // Hidden elements |
1071 | 1071 | $form['modified'] = array( |
@@ -1083,77 +1083,77 @@ discard block |
||
1083 | 1083 | |
1084 | 1084 | // Common project preferences |
1085 | 1085 | $form['resource'] = array( |
1086 | - '#title' => bts('Resource settings', array(), NULL, 'boinc:account-preferences-project'), |
|
1086 | + '#title' => bts('Resource settings', array(), null, 'boinc:account-preferences-project'), |
|
1087 | 1087 | '#type' => 'fieldset', |
1088 | 1088 | '#description' => null, |
1089 | - '#collapsible' => TRUE, |
|
1090 | - '#collapsed' => FALSE |
|
1089 | + '#collapsible' => true, |
|
1090 | + '#collapsed' => false |
|
1091 | 1091 | ); |
1092 | 1092 | $form['resource']['resource_share'] = array( |
1093 | - '#title' => bts('Resource share', array(), NULL, 'boinc:account-preferences-project'), |
|
1093 | + '#title' => bts('Resource share', array(), null, 'boinc:account-preferences-project'), |
|
1094 | 1094 | '#type' => 'textfield', |
1095 | 1095 | '#default_value' => $default['resource_share'], |
1096 | 1096 | '#size' => 5, |
1097 | - '#description' => bts("Determines the proportion of your computer's resources allocated to this project. Example: if you participate in two BOINC projects with resource shares of 100 and 200, the first will get 1/3 of your resources and the second will get 2/3.", array(), NULL, 'boinc:account-preferences-project') |
|
1097 | + '#description' => bts("Determines the proportion of your computer's resources allocated to this project. Example: if you participate in two BOINC projects with resource shares of 100 and 200, the first will get 1/3 of your resources and the second will get 2/3.", array(), null, 'boinc:account-preferences-project') |
|
1098 | 1098 | ); |
1099 | 1099 | if ($app_types->count > 1) { |
1100 | 1100 | if ($app_types->cpu) { |
1101 | 1101 | $form['resource']['no_cpu'] = array( |
1102 | - '#title' => bts('Use CPU', array(), NULL, 'boinc:account-preferences-project'), |
|
1102 | + '#title' => bts('Use CPU', array(), null, 'boinc:account-preferences-project'), |
|
1103 | 1103 | '#type' => 'radios', |
1104 | 1104 | '#options' => $form['boolean_options']['#value'], |
1105 | 1105 | '#attributes' => array('class' => 'fancy'), |
1106 | 1106 | '#default_value' => $default['no_cpu'] ? 0 : 1, |
1107 | - '#description' => bts('Request CPU-only tasks from this project.', array(), NULL, 'boinc:account-preferences-project') |
|
1107 | + '#description' => bts('Request CPU-only tasks from this project.', array(), null, 'boinc:account-preferences-project') |
|
1108 | 1108 | ); |
1109 | 1109 | } |
1110 | 1110 | if ($app_types->cuda) { |
1111 | 1111 | $form['resource']['no_cuda'] = array( |
1112 | - '#title' => bts('Use NVIDIA GPU', array(), NULL, 'boinc:account-preferences-project'), |
|
1112 | + '#title' => bts('Use NVIDIA GPU', array(), null, 'boinc:account-preferences-project'), |
|
1113 | 1113 | '#type' => 'radios', |
1114 | 1114 | '#options' => $form['boolean_options']['#value'], |
1115 | 1115 | '#attributes' => array('class' => 'fancy'), |
1116 | 1116 | '#default_value' => $default['no_cuda'] ? 0 : 1, |
1117 | - '#description' => bts('Request NVIDIA GPU tasks from this project.', array(), NULL, 'boinc:account-preferences-project') |
|
1117 | + '#description' => bts('Request NVIDIA GPU tasks from this project.', array(), null, 'boinc:account-preferences-project') |
|
1118 | 1118 | ); |
1119 | 1119 | } |
1120 | 1120 | if ($app_types->ati) { |
1121 | 1121 | $form['resource']['no_ati'] = array( |
1122 | - '#title' => bts('Use AMD GPU', array(), NULL, 'boinc:account-preferences-project'), |
|
1122 | + '#title' => bts('Use AMD GPU', array(), null, 'boinc:account-preferences-project'), |
|
1123 | 1123 | '#type' => 'radios', |
1124 | 1124 | '#options' => $form['boolean_options']['#value'], |
1125 | 1125 | '#attributes' => array('class' => 'fancy'), |
1126 | 1126 | '#default_value' => $default['no_ati'] ? 0 : 1, |
1127 | - '#description' => bts('Request AMD GPU tasks from this project.', array(), NULL, 'boinc:account-preferences-project') |
|
1127 | + '#description' => bts('Request AMD GPU tasks from this project.', array(), null, 'boinc:account-preferences-project') |
|
1128 | 1128 | ); |
1129 | 1129 | } |
1130 | 1130 | if ($app_types->intel_gpu) { |
1131 | 1131 | $form['resource']['no_intel_gpu'] = array( |
1132 | - '#title' => bts('Use INTEL GPU', array(), NULL, 'boinc:account-preferences-project'), |
|
1132 | + '#title' => bts('Use INTEL GPU', array(), null, 'boinc:account-preferences-project'), |
|
1133 | 1133 | '#type' => 'radios', |
1134 | 1134 | '#options' => $form['boolean_options']['#value'], |
1135 | 1135 | '#attributes' => array('class' => 'fancy'), |
1136 | 1136 | '#default_value' => $default['no_intel_gpu'] ? 0 : 1, |
1137 | - '#description' => bts('Request Intel GPU tasks from this project.', array(), NULL, 'boinc:account-preferences-project') |
|
1137 | + '#description' => bts('Request Intel GPU tasks from this project.', array(), null, 'boinc:account-preferences-project') |
|
1138 | 1138 | ); |
1139 | 1139 | } |
1140 | 1140 | } |
1141 | 1141 | |
1142 | - if (variable_get('boinc_prefs_options_beta', FALSE)) { |
|
1142 | + if (variable_get('boinc_prefs_options_beta', false)) { |
|
1143 | 1143 | $form['beta'] = array( |
1144 | - '#title' => bts('Beta settings', array(), NULL, 'boinc:account-preferences-project'), |
|
1144 | + '#title' => bts('Beta settings', array(), null, 'boinc:account-preferences-project'), |
|
1145 | 1145 | '#type' => 'fieldset', |
1146 | 1146 | '#description' => null, |
1147 | - '#collapsible' => TRUE, |
|
1148 | - '#collapsed' => FALSE |
|
1147 | + '#collapsible' => true, |
|
1148 | + '#collapsed' => false |
|
1149 | 1149 | ); |
1150 | 1150 | $form['beta']['allow_beta_work'] = array( |
1151 | - '#title' => bts('Run test applications?', array(), NULL, 'boinc:account-preferences-project'), |
|
1151 | + '#title' => bts('Run test applications?', array(), null, 'boinc:account-preferences-project'), |
|
1152 | 1152 | '#type' => 'radios', |
1153 | 1153 | '#options' => $form['boolean_options']['#value'], |
1154 | 1154 | '#attributes' => array('class' => 'fancy'), |
1155 | 1155 | '#default_value' => ($default['allow_beta_work']) ? 1 : 0, |
1156 | - '#description' => bts('This helps us develop applications, but may cause jobs to fail on your computer', array(), NULL, 'boinc:account-preferences-project') |
|
1156 | + '#description' => bts('This helps us develop applications, but may cause jobs to fail on your computer', array(), null, 'boinc:account-preferences-project') |
|
1157 | 1157 | ); |
1158 | 1158 | } |
1159 | 1159 | |
@@ -1162,14 +1162,14 @@ discard block |
||
1162 | 1162 | |
1163 | 1163 | // Set whether to use this preference set by default for new computers |
1164 | 1164 | $form['default_set'] = array( |
1165 | - '#title' => bts('Default set', array(), NULL, 'boinc:account-preferences-project'), |
|
1165 | + '#title' => bts('Default set', array(), null, 'boinc:account-preferences-project'), |
|
1166 | 1166 | '#type' => 'fieldset', |
1167 | 1167 | '#description' => null, |
1168 | - '#collapsible' => TRUE, |
|
1169 | - '#collapsed' => FALSE |
|
1168 | + '#collapsible' => true, |
|
1169 | + '#collapsed' => false |
|
1170 | 1170 | ); |
1171 | 1171 | $form['default_set']['default_venue'] = array( |
1172 | - '#title' => bts('Set used for new computers', array(), NULL, 'boinc:account-preferences-project'), |
|
1172 | + '#title' => bts('Set used for new computers', array(), null, 'boinc:account-preferences-project'), |
|
1173 | 1173 | '#type' => 'radios', |
1174 | 1174 | '#options' => $form['boolean_options']['#value'], |
1175 | 1175 | '#attributes' => array('class' => 'fancy'), |
@@ -1188,27 +1188,27 @@ discard block |
||
1188 | 1188 | $form['prefs']['submit'] = array( |
1189 | 1189 | '#prefix' => '<li class="first tab">', |
1190 | 1190 | '#type' => 'submit', |
1191 | - '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'), |
|
1191 | + '#value' => bts('Save changes', array(), null, 'boinc:form-save'), |
|
1192 | 1192 | '#suffix' => '</li>' |
1193 | 1193 | ); |
1194 | 1194 | $form['prefs']['form control tabs'] = array( |
1195 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>' |
|
1195 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), null, 'boinc:form-cancel'), $_GET['q']) . '</li>' |
|
1196 | 1196 | ); |
1197 | - if ($venue AND $venue != 'generic') { |
|
1197 | + if ($venue and $venue != 'generic') { |
|
1198 | 1198 | global $base_path; |
1199 | 1199 | $form['prefs']['form control tabs']['#value'] .= '<li class="tab">' . |
1200 | - l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/project/clear/{$venue}", |
|
1200 | + l(bts('Clear', array(), null, 'boinc:form-clear'), "account/prefs/project/clear/{$venue}", |
|
1201 | 1201 | array( |
1202 | 1202 | 'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/project/combined')), |
1203 | 1203 | 'attributes' => array( |
1204 | 1204 | 'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the @name preference set. Are you sure?', |
1205 | - array('@name' => $venue), NULL, 'boinc:account-preferences') . '\')' |
|
1205 | + array('@name' => $venue), null, 'boinc:account-preferences') . '\')' |
|
1206 | 1206 | ) |
1207 | 1207 | ) |
1208 | 1208 | ) . '</li>'; |
1209 | 1209 | } |
1210 | 1210 | $form['prefs']['view control'] = array( |
1211 | - '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/project/combined') . '</li>' |
|
1211 | + '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), null, 'boinc:account-preferences') . ')', 'account/prefs/project/combined') . '</li>' |
|
1212 | 1212 | ); |
1213 | 1213 | $form['prefs']['form control tabs suffix'] = array( |
1214 | 1214 | '#value' => '</ul>' |
@@ -1228,7 +1228,7 @@ discard block |
||
1228 | 1228 | $ordered_array = array(); |
1229 | 1229 | $unordered_array = array(); |
1230 | 1230 | foreach ($xml['project_specific_preferences'] as $type => $element) { |
1231 | - if (is_array($element) AND is_numeric(key($element))) { |
|
1231 | + if (is_array($element) and is_numeric(key($element))) { |
|
1232 | 1232 | foreach ($element as $ordered_element) { |
1233 | 1233 | if (isset($ordered_element['@position'])) { |
1234 | 1234 | $ordered_array[$ordered_element['@position']] = array($type => $ordered_element); |
@@ -1280,7 +1280,7 @@ discard block |
||
1280 | 1280 | // Check for app validation |
1281 | 1281 | if (isset($validation_rules['apps'])) { |
1282 | 1282 | if (isset($validation_rules['apps']['minimum selected']) |
1283 | - AND $validation_rules['apps']['minimum selected'] > 0) { |
|
1283 | + and $validation_rules['apps']['minimum selected'] > 0) { |
|
1284 | 1284 | $apps_selected = 0; |
1285 | 1285 | foreach ($validation_rules['apps']['list'] as $app) { |
1286 | 1286 | if ($form_state['values']['applications'][$app]) $apps_selected++; |
@@ -1288,14 +1288,14 @@ discard block |
||
1288 | 1288 | if ($apps_selected < $validation_rules['apps']['minimum selected']) { |
1289 | 1289 | form_set_error( |
1290 | 1290 | 'applications', |
1291 | - bts('At least one application must be selected', array(), NULL, 'boinc:account-preferences-project') |
|
1291 | + bts('At least one application must be selected', array(), null, 'boinc:account-preferences-project') |
|
1292 | 1292 | ); |
1293 | 1293 | } |
1294 | 1294 | if ($apps_selected == count($validation_rules['apps']['list'])) { |
1295 | 1295 | foreach ($validation_rules['apps']['list'] as $app) { |
1296 | 1296 | unset($form_state['values']['applications'][$app]); |
1297 | 1297 | } |
1298 | - $form_state['storage']['all apps selected'] = TRUE; |
|
1298 | + $form_state['storage']['all apps selected'] = true; |
|
1299 | 1299 | } |
1300 | 1300 | } |
1301 | 1301 | } |
@@ -1328,7 +1328,7 @@ discard block |
||
1328 | 1328 | } |
1329 | 1329 | |
1330 | 1330 | // Beta preferences |
1331 | - if (variable_get('boinc_prefs_options_beta', FALSE)) { |
|
1331 | + if (variable_get('boinc_prefs_options_beta', false)) { |
|
1332 | 1332 | $prefs['allow_beta_work'] = ($edit['beta']['allow_beta_work']) ? 1 : 0; |
1333 | 1333 | } |
1334 | 1334 | |
@@ -1366,7 +1366,7 @@ discard block |
||
1366 | 1366 | watchdog('boincwork', 'Error updating project prefs for user @id: @message', array('@id' => $user->id, '@message' => mysqli_error()), WATCHDOG_ERROR); |
1367 | 1367 | drupal_set_message(t('Your changes could not be saved. Please contact support!'), 'error'); |
1368 | 1368 | } |
1369 | - elseif (!drupal_get_messages('status', FALSE)) { |
|
1369 | + elseif (!drupal_get_messages('status', false)) { |
|
1370 | 1370 | // Show this message if the set wasn't created automatically (in which case |
1371 | 1371 | // there is a message tailored to that) |
1372 | 1372 | drupal_set_message(t('Your preferences have been updated. |
@@ -1401,31 +1401,31 @@ discard block |
||
1401 | 1401 | // Standard option sets |
1402 | 1402 | $form['boolean_options'] = array( |
1403 | 1403 | '#type' => 'value', |
1404 | - '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')) |
|
1404 | + '#value' => array(1 => bts('yes', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')) |
|
1405 | 1405 | ); |
1406 | 1406 | |
1407 | 1407 | $default = array( |
1408 | 1408 | 'pm_send_notification' => '', // This is set already in pm_email_notify_user |
1409 | 1409 | 'friend_notification' => isset($account->friend_notification) ? $account->friend_notification : 0, |
1410 | - 'comments_per_page' => (isset($account->comments_per_page) AND $account->comments_per_page) ? $account->comments_per_page : variable_get('comment_default_per_page_forum', 50), |
|
1411 | - 'comments_order' => (isset($account->sort) AND $account->sort) ? $account->sort : variable_get('comment_default_order_forum', COMMENT_ORDER_OLDEST_FIRST), |
|
1410 | + 'comments_per_page' => (isset($account->comments_per_page) and $account->comments_per_page) ? $account->comments_per_page : variable_get('comment_default_per_page_forum', 50), |
|
1411 | + 'comments_order' => (isset($account->sort) and $account->sort) ? $account->sort : variable_get('comment_default_order_forum', COMMENT_ORDER_OLDEST_FIRST), |
|
1412 | 1412 | ); |
1413 | 1413 | |
1414 | 1414 | // General options |
1415 | 1415 | $form['general'] = array( |
1416 | 1416 | '#type' => 'fieldset', |
1417 | - '#title' => bts('General settings', array(), NULL, 'boinc:account-preferences-community'), |
|
1417 | + '#title' => bts('General settings', array(), null, 'boinc:account-preferences-community'), |
|
1418 | 1418 | '#weight' => 0, |
1419 | - '#collapsible' => TRUE, |
|
1420 | - '#collapsed' => FALSE |
|
1419 | + '#collapsible' => true, |
|
1420 | + '#collapsed' => false |
|
1421 | 1421 | ); |
1422 | 1422 | // Add the BOINC user name (non-unique, user editable) |
1423 | 1423 | $form['general']['boincuser_name'] = array( |
1424 | 1424 | '#type' => 'textfield', |
1425 | - '#title' => bts('Name', array(), NULL, 'boinc:user-or-team-name'), |
|
1425 | + '#title' => bts('Name', array(), null, 'boinc:user-or-team-name'), |
|
1426 | 1426 | '#default_value' => $account->boincuser_name, |
1427 | 1427 | '#maxlength' => USERNAME_MAX_LENGTH, |
1428 | - '#required' => TRUE, |
|
1428 | + '#required' => true, |
|
1429 | 1429 | '#description' => '', |
1430 | 1430 | '#size' => 40 |
1431 | 1431 | ); |
@@ -1434,8 +1434,8 @@ discard block |
||
1434 | 1434 | $zones = _system_zonelist(); |
1435 | 1435 | $form['general']['timezone'] = array( |
1436 | 1436 | '#type' => 'select', |
1437 | - '#title' => bts('Time zone', array(), NULL, 'boinc:account-preferences-community'), |
|
1438 | - '#default_value' => ($account->timezone !== NULL) ? $account->timezone : variable_get('date_default_timezone', 0), |
|
1437 | + '#title' => bts('Time zone', array(), null, 'boinc:account-preferences-community'), |
|
1438 | + '#default_value' => ($account->timezone !== null) ? $account->timezone : variable_get('date_default_timezone', 0), |
|
1439 | 1439 | '#options' => $zones, |
1440 | 1440 | '#description' => '', |
1441 | 1441 | ); |
@@ -1444,10 +1444,10 @@ discard block |
||
1444 | 1444 | // Notification options |
1445 | 1445 | $form['notifications'] = array( |
1446 | 1446 | '#type' => 'fieldset', |
1447 | - '#title' => bts('Notification settings', array(), NULL, 'boinc:account-preferences-community'), |
|
1447 | + '#title' => bts('Notification settings', array(), null, 'boinc:account-preferences-community'), |
|
1448 | 1448 | '#weight' => 5, |
1449 | - '#collapsible' => TRUE, |
|
1450 | - '#collapsed' => FALSE |
|
1449 | + '#collapsible' => true, |
|
1450 | + '#collapsed' => false |
|
1451 | 1451 | ); |
1452 | 1452 | // Pull in private message notification handling and tweak the form |
1453 | 1453 | $pm_notify = pm_email_notify_user('form', $edit, $account, 'account'); |
@@ -1455,7 +1455,7 @@ discard block |
||
1455 | 1455 | $pm_notify['enable_pm_mail']['pm_send_notifications'], |
1456 | 1456 | array( |
1457 | 1457 | '#type' => 'radios', |
1458 | - '#title' => bts('Receive email notification for private messages?', array(), NULL, 'boinc:account-preferences-community'), |
|
1458 | + '#title' => bts('Receive email notification for private messages?', array(), null, 'boinc:account-preferences-community'), |
|
1459 | 1459 | '#description' => ' ', |
1460 | 1460 | '#options' => $form['boolean_options']['#value'], |
1461 | 1461 | '#attributes' => array('class' => 'fancy') |
@@ -1463,9 +1463,9 @@ discard block |
||
1463 | 1463 | ); |
1464 | 1464 | $form['notifications']['friend_notification'] = array( |
1465 | 1465 | '#type' => 'radios', |
1466 | - '#title' => bts('Receive email notification for friend requests?', array(), NULL, 'boinc:account-preferences-community'), |
|
1466 | + '#title' => bts('Receive email notification for friend requests?', array(), null, 'boinc:account-preferences-community'), |
|
1467 | 1467 | '#description' => ' ', |
1468 | - '#options' => array(0 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), -1 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')), |
|
1468 | + '#options' => array(0 => bts('yes', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), -1 => bts('no', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')), |
|
1469 | 1469 | '#attributes' => array('class' => 'fancy'), |
1470 | 1470 | '#default_value' => $default['friend_notification'] |
1471 | 1471 | ); |
@@ -1481,10 +1481,10 @@ discard block |
||
1481 | 1481 | } |
1482 | 1482 | $form['locale'] = array( |
1483 | 1483 | '#type' => 'fieldset', |
1484 | - '#title' => bts('Language settings', array(), NULL, 'boinc:account-preferences-community'), |
|
1484 | + '#title' => bts('Language settings', array(), null, 'boinc:account-preferences-community'), |
|
1485 | 1485 | '#weight' => 10, |
1486 | - '#collapsible' => TRUE, |
|
1487 | - '#collapsed' => FALSE, |
|
1486 | + '#collapsible' => true, |
|
1487 | + '#collapsed' => false, |
|
1488 | 1488 | ); |
1489 | 1489 | |
1490 | 1490 | // Get language negotiation settings. |
@@ -1492,30 +1492,30 @@ discard block |
||
1492 | 1492 | $user_preferred_language = user_preferred_language($account); |
1493 | 1493 | $form['locale']['language'] = array( |
1494 | 1494 | '#type' => 'select', |
1495 | - '#title' => bts('Language', array(), NULL, 'boinc:account-preferences-community'), |
|
1495 | + '#title' => bts('Language', array(), null, 'boinc:account-preferences-community'), |
|
1496 | 1496 | '#default_value' => check_plain($user_preferred_language->language), |
1497 | 1497 | '#options' => $names, |
1498 | - '#description' => ($mode == LANGUAGE_NEGOTIATION_PATH) ? bts("This account's default language for e-mails and preferred language for site presentation.", array(), NULL, 'boinc:account-preferences-community') : bts("This account's default language for e-mails.", array(), NULL, 'boinc:account-preferences-community'), |
|
1498 | + '#description' => ($mode == LANGUAGE_NEGOTIATION_PATH) ? bts("This account's default language for e-mails and preferred language for site presentation.", array(), null, 'boinc:account-preferences-community') : bts("This account's default language for e-mails.", array(), null, 'boinc:account-preferences-community'), |
|
1499 | 1499 | ); |
1500 | 1500 | } |
1501 | 1501 | |
1502 | 1502 | // Avatar options |
1503 | 1503 | $form['gravatar'] = array( |
1504 | 1504 | '#type' => 'item', |
1505 | - '#value' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, it will be used for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail), NULL, 'boinc:account-preferences-community'), |
|
1506 | - '#description' => bts('Your Gravatar will not be shown if you upload a user picture.', array(), NULL, 'boinc:account-preferences-community'), |
|
1505 | + '#value' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, it will be used for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail), null, 'boinc:account-preferences-community'), |
|
1506 | + '#description' => bts('Your Gravatar will not be shown if you upload a user picture.', array(), null, 'boinc:account-preferences-community'), |
|
1507 | 1507 | ); |
1508 | 1508 | if (user_access('disable own gravatar', $account)) { |
1509 | 1509 | $form['gravatar'] = array( |
1510 | 1510 | '#type' => 'checkbox', |
1511 | - '#title' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, use it for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail), NULL, 'boinc:account-preferences-community'), |
|
1512 | - '#description' => bts('Gravatar will not be shown if an avatar is uploaded.', array(), NULL, 'boinc:account-preferences-community'), |
|
1511 | + '#title' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, use it for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail), null, 'boinc:account-preferences-community'), |
|
1512 | + '#description' => bts('Gravatar will not be shown if an avatar is uploaded.', array(), null, 'boinc:account-preferences-community'), |
|
1513 | 1513 | '#default_value' => isset($account->gravatar) ? $account->gravatar : 0, |
1514 | 1514 | '#disabled' => !empty($account->picture), |
1515 | 1515 | ); |
1516 | 1516 | } |
1517 | 1517 | $form['gravatar']['#weight'] = 15; |
1518 | - $form['gravatar']['#prefix'] = '<fieldset class="collapsible"><legend><a href="#">' . bts('Avatar settings', array(), NULL, 'boinc:account-preferences-community') . '</a></legend>'; |
|
1518 | + $form['gravatar']['#prefix'] = '<fieldset class="collapsible"><legend><a href="#">' . bts('Avatar settings', array(), null, 'boinc:account-preferences-community') . '</a></legend>'; |
|
1519 | 1519 | // Upload an avatar (pulled from profile_node_form): |
1520 | 1520 | if (!empty($profile_form['field_image'])) { |
1521 | 1521 | $form['field_image'] = $profile_form['field_image']; |
@@ -1524,46 +1524,46 @@ discard block |
||
1524 | 1524 | $form['field_image'] = array( |
1525 | 1525 | '#value' => '<div class="form-item">' |
1526 | 1526 | . '<label class="placeholder">' |
1527 | - . bts('This is not available until your profile is set up.', array(), NULL, 'boinc:account-preferences-community') |
|
1527 | + . bts('This is not available until your profile is set up.', array(), null, 'boinc:account-preferences-community') |
|
1528 | 1528 | . '</label>' |
1529 | - . l(bts('Create a profile', array(), NULL, 'boinc:account-preferences-community'), 'account/profile/edit', array('attributes' => array('class' => 'form-link'))) |
|
1529 | + . l(bts('Create a profile', array(), null, 'boinc:account-preferences-community'), 'account/profile/edit', array('attributes' => array('class' => 'form-link'))) |
|
1530 | 1530 | . '</div>', |
1531 | 1531 | ); |
1532 | 1532 | } |
1533 | - $form['field_image'][0]['#title'] = bts('Upload an avatar', array(), NULL, 'boinc:account-preferences-community'); |
|
1533 | + $form['field_image'][0]['#title'] = bts('Upload an avatar', array(), null, 'boinc:account-preferences-community'); |
|
1534 | 1534 | $form['field_image']['#weight'] = 20; |
1535 | 1535 | $form['field_image']['#suffix'] = '</fieldset>'; |
1536 | 1536 | |
1537 | 1537 | // Forum options |
1538 | 1538 | $form['forums'] = array( |
1539 | 1539 | '#type' => 'fieldset', |
1540 | - '#title' => bts('Forum settings', array(), NULL, 'boinc:account-preferences-community'), |
|
1540 | + '#title' => bts('Forum settings', array(), null, 'boinc:account-preferences-community'), |
|
1541 | 1541 | '#weight' => 25, |
1542 | - '#collapsible' => TRUE, |
|
1543 | - '#collapsed' => FALSE |
|
1542 | + '#collapsible' => true, |
|
1543 | + '#collapsed' => false |
|
1544 | 1544 | ); |
1545 | 1545 | $form['forums']['comments_per_page'] = array( |
1546 | 1546 | '#type' => 'select', |
1547 | - '#title' => bts('In discussion topics, show at most @comments_per_page', array('@comments_per_page' => ''), NULL, 'boinc:account-preferences-community'), |
|
1547 | + '#title' => bts('In discussion topics, show at most @comments_per_page', array('@comments_per_page' => ''), null, 'boinc:account-preferences-community'), |
|
1548 | 1548 | '#options' => array(10 => 10, 20 => 20, 30 => 30, 50 => 50, 100 => 100), |
1549 | 1549 | '#default_value' => $default['comments_per_page'] |
1550 | 1550 | ); |
1551 | 1551 | // Can't have a typical Drupal form suffix on a select box? |
1552 | 1552 | $form['forums']['comments_per_page_suffix'] = array( |
1553 | - '#value' => '<span>' . bts('comments per page', array(), NULL, 'boinc:account-preferences-community') . '</span>' |
|
1553 | + '#value' => '<span>' . bts('comments per page', array(), null, 'boinc:account-preferences-community') . '</span>' |
|
1554 | 1554 | ); |
1555 | 1555 | $form['forums']['comments_order'] = array( |
1556 | 1556 | '#type' => 'select', |
1557 | - '#title' => bts('Sort comments in discussions', array(), NULL, 'boinc:account-preferences-community'), |
|
1558 | - '#options' => array(1 => bts('Newest post first', array(), NULL, 'boinc:account-preferences-community'), 2 => bts('Oldest post first', array(), NULL, 'boinc:account-preferences-community')), |
|
1557 | + '#title' => bts('Sort comments in discussions', array(), null, 'boinc:account-preferences-community'), |
|
1558 | + '#options' => array(1 => bts('Newest post first', array(), null, 'boinc:account-preferences-community'), 2 => bts('Oldest post first', array(), null, 'boinc:account-preferences-community')), |
|
1559 | 1559 | '#default_value' => $default['comments_order'] |
1560 | 1560 | ); |
1561 | 1561 | // Signature (pulled from user_edit_form): |
1562 | 1562 | if (variable_get('user_signatures', 0) && module_exists('comment')) { |
1563 | 1563 | $form['forums']['signature'] = array( |
1564 | 1564 | '#type' => 'textarea', |
1565 | - '#title' => bts('Signature', array(), NULL, 'boinc:account-preferences-community'), |
|
1566 | - '#description' => bts('Your signature will be publicly displayed at the end of your comments.', array(), NULL, 'boinc:account-preferences-community'), |
|
1565 | + '#title' => bts('Signature', array(), null, 'boinc:account-preferences-community'), |
|
1566 | + '#description' => bts('Your signature will be publicly displayed at the end of your comments.', array(), null, 'boinc:account-preferences-community'), |
|
1567 | 1567 | '#default_value' => $account->signature |
1568 | 1568 | ); |
1569 | 1569 | // Prevent a "validation error" message when the user attempts to save with a default value they |
@@ -1572,11 +1572,11 @@ discard block |
||
1572 | 1572 | drupal_set_message(t("The signature input format has been set to a format you don't have access to. It will be changed to a format you have access to when you save this page.")); |
1573 | 1573 | $edit['signature_format'] = FILTER_FORMAT_DEFAULT; |
1574 | 1574 | } |
1575 | - $form['forums']['signature_format'] = filter_form($account->signature_format, NULL, array('signature_format')); |
|
1575 | + $form['forums']['signature_format'] = filter_form($account->signature_format, null, array('signature_format')); |
|
1576 | 1576 | // Optionally hide signatures from comments |
1577 | 1577 | $form['forums']['hide_signatures'] = array( |
1578 | 1578 | '#type' => 'radios', |
1579 | - '#title' => bts('Hide signatures in forums', array(), NULL, 'boinc:account-preferences-community'), |
|
1579 | + '#title' => bts('Hide signatures in forums', array(), null, 'boinc:account-preferences-community'), |
|
1580 | 1580 | '#description' => ' ', |
1581 | 1581 | '#options' => $form['boolean_options']['#value'], |
1582 | 1582 | '#attributes' => array('class' => 'fancy'), |
@@ -1598,12 +1598,12 @@ discard block |
||
1598 | 1598 | $form['submit'] = array( |
1599 | 1599 | '#prefix' => '<li class="first tab">', |
1600 | 1600 | '#type' => 'submit', |
1601 | - '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'), |
|
1601 | + '#value' => bts('Save changes', array(), null, 'boinc:form-save'), |
|
1602 | 1602 | '#suffix' => '</li>', |
1603 | 1603 | '#weight' => 1002, |
1604 | 1604 | ); |
1605 | 1605 | $form['form control tabs'] = array( |
1606 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
1606 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), null, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
1607 | 1607 | '#weight' => 1003, |
1608 | 1608 | ); |
1609 | 1609 | $form['form control tabs suffix'] = array( |
@@ -1633,7 +1633,7 @@ discard block |
||
1633 | 1633 | form_set_error('boincuser_name', |
1634 | 1634 | bts('You may not use username @blname, as that name is not allowed. Please choose another name.', |
1635 | 1635 | array('@blname' => $edit['boincuser_name']), |
1636 | - NULL, 'boinc:account-preferences-community')); |
|
1636 | + null, 'boinc:account-preferences-community')); |
|
1637 | 1637 | return false; |
1638 | 1638 | } |
1639 | 1639 | } |
@@ -1669,7 +1669,7 @@ discard block |
||
1669 | 1669 | $profile_node->field_image = $edit['field_image']; |
1670 | 1670 | node_save($profile_node); |
1671 | 1671 | // Flush this from the node cache or changes won't show up immediately! |
1672 | - $profile_node = node_load($profile_node->nid, NULL, TRUE); |
|
1672 | + $profile_node = node_load($profile_node->nid, null, true); |
|
1673 | 1673 | } |
1674 | 1674 | |
1675 | 1675 | // All other settings |
@@ -1698,7 +1698,7 @@ discard block |
||
1698 | 1698 | } |
1699 | 1699 | user_save($user, $settings); |
1700 | 1700 | |
1701 | - drupal_set_message(bts('Your community preferences have been updated.', array(), NULL, 'boinc:account-preferences-community')); |
|
1701 | + drupal_set_message(bts('Your community preferences have been updated.', array(), null, 'boinc:account-preferences-community')); |
|
1702 | 1702 | |
1703 | 1703 | // Form will not redirect if storage is set; not good if language changes |
1704 | 1704 | unset($form_state['storage']); |
@@ -1732,26 +1732,26 @@ discard block |
||
1732 | 1732 | // Standard option sets |
1733 | 1733 | $form['boolean_options'] = array( |
1734 | 1734 | '#type' => 'value', |
1735 | - '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')) |
|
1735 | + '#value' => array(1 => bts('yes', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')) |
|
1736 | 1736 | ); |
1737 | 1737 | |
1738 | 1738 | $form['privacy'] = array( |
1739 | - '#title' => bts('Privacy settings', array(), NULL, 'boinc:account-preferences-privacy'), |
|
1739 | + '#title' => bts('Privacy settings', array(), null, 'boinc:account-preferences-privacy'), |
|
1740 | 1740 | '#type' => 'fieldset', |
1741 | 1741 | '#description' => null, |
1742 | - '#collapsible' => TRUE, |
|
1743 | - '#collapsed' => FALSE |
|
1742 | + '#collapsible' => true, |
|
1743 | + '#collapsed' => false |
|
1744 | 1744 | ); |
1745 | 1745 | $form['privacy']['send_email'] = array( |
1746 | - '#title' => bts('Is it OK for @project and your team (if any) to email you?', array('@project' => variable_get('site_name', 'Drupal-BOINC')), NULL, 'boinc:account-preferences-privacy'), |
|
1746 | + '#title' => bts('Is it OK for @project and your team (if any) to email you?', array('@project' => variable_get('site_name', 'Drupal-BOINC')), null, 'boinc:account-preferences-privacy'), |
|
1747 | 1747 | '#type' => 'radios', |
1748 | 1748 | '#options' => $form['boolean_options']['#value'], |
1749 | 1749 | '#attributes' => array('class' => 'fancy'), |
1750 | 1750 | '#default_value' => $default['privacy']['send_email'] |
1751 | 1751 | ); |
1752 | 1752 | $form['privacy']['show_hosts'] = array( |
1753 | - '#title' => bts('Should @project show your computers on its web site?', array('@project' => variable_get('site_name', 'Drupal-BOINC')), NULL, 'boinc:account-preferences-privacy'), |
|
1754 | - '#description' => bts('At times, you may be asked to enable this option in order to receive help from the forums. Advanced users may need to be able to inspect your computers\' information in order to help diagnose any problems.', array(), NULL, 'boinc:account-preferences-privacy'), |
|
1753 | + '#title' => bts('Should @project show your computers on its web site?', array('@project' => variable_get('site_name', 'Drupal-BOINC')), null, 'boinc:account-preferences-privacy'), |
|
1754 | + '#description' => bts('At times, you may be asked to enable this option in order to receive help from the forums. Advanced users may need to be able to inspect your computers\' information in order to help diagnose any problems.', array(), null, 'boinc:account-preferences-privacy'), |
|
1755 | 1755 | '#type' => 'radios', |
1756 | 1756 | '#options' => $form['boolean_options']['#value'], |
1757 | 1757 | '#attributes' => array('class' => 'fancy'), |
@@ -1766,7 +1766,7 @@ discard block |
||
1766 | 1766 | // Set name to 'privacyconsent_SHORTNAME', which can be parsed |
1767 | 1767 | // later in the submit function. |
1768 | 1768 | $form['privacy']['privacyconsent_'.$ct['shortname']] = array( |
1769 | - '#title' => bts($ct['description'], array(), NULL, 'boinc:account-preferences-privacy'), |
|
1769 | + '#title' => bts($ct['description'], array(), null, 'boinc:account-preferences-privacy'), |
|
1770 | 1770 | '#type' => 'radios', |
1771 | 1771 | '#options' => $form['boolean_options']['#value'], |
1772 | 1772 | '#attributes' => array('class' => 'fancy'), |
@@ -1777,17 +1777,17 @@ discard block |
||
1777 | 1777 | // Ignore and block users |
1778 | 1778 | if (module_exists('ignore_user')) { |
1779 | 1779 | $form['ignoreblock'] = array( |
1780 | - '#title' => bts('Ignore Users', array(), NULL, 'boinc:account-preferences-privacy'), |
|
1780 | + '#title' => bts('Ignore Users', array(), null, 'boinc:account-preferences-privacy'), |
|
1781 | 1781 | '#type' => 'fieldset', |
1782 | - '#description' => bts('<p>You may ignore users in the forums and block users from sending you private messages.<p>', array(), NULL, 'boinc:ignore-user-help'), |
|
1783 | - '#collapsible' => TRUE, |
|
1784 | - '#collapsed' => FALSE |
|
1782 | + '#description' => bts('<p>You may ignore users in the forums and block users from sending you private messages.<p>', array(), null, 'boinc:ignore-user-help'), |
|
1783 | + '#collapsible' => true, |
|
1784 | + '#collapsed' => false |
|
1785 | 1785 | ); |
1786 | 1786 | |
1787 | 1787 | // Table for ignored users |
1788 | 1788 | $form['ignoreblock']['current_ignore_section'] = array( |
1789 | 1789 | '#type' => 'item', |
1790 | - '#value' => bts('Current users on your Ignore List', array(), NULL, 'boinc:ignore-user-list'), |
|
1790 | + '#value' => bts('Current users on your Ignore List', array(), null, 'boinc:ignore-user-list'), |
|
1791 | 1791 | '#prefix' => '<h4>', |
1792 | 1792 | '#suffix' => '</h4>', |
1793 | 1793 | '#weight' => -20, |
@@ -1800,18 +1800,18 @@ discard block |
||
1800 | 1800 | ); |
1801 | 1801 | $form['ignoreblock']['delete'][$ignored_user['iuid']] = array( |
1802 | 1802 | '#value' => l( |
1803 | - bts('delete', array(), NULL, 'boinc:ignore-user-delete-button'), |
|
1803 | + bts('delete', array(), null, 'boinc:ignore-user-delete-button'), |
|
1804 | 1804 | 'account/prefs/privacy/ignore_user/remove/'. $ignored_user['iuid'], |
1805 | 1805 | array() |
1806 | 1806 | ), |
1807 | 1807 | ); |
1808 | 1808 | } |
1809 | - $form['ignoreblock']['pager'] = array('#value' => theme('pager', NULL, 10, 0)); |
|
1809 | + $form['ignoreblock']['pager'] = array('#value' => theme('pager', null, 10, 0)); |
|
1810 | 1810 | |
1811 | 1811 | // Sub-form to add user to ignore list |
1812 | 1812 | $form['ignoreblock']['add_ignore_user_section'] = array( |
1813 | 1813 | '#type' => 'item', |
1814 | - '#value' => bts('Add user to Ignore List', array(), NULL, 'boinc:ignore-user-add'), |
|
1814 | + '#value' => bts('Add user to Ignore List', array(), null, 'boinc:ignore-user-add'), |
|
1815 | 1815 | '#prefix' => '<h4>', |
1816 | 1816 | '#suffix' => '</h4>', |
1817 | 1817 | '#weight' => 10, |
@@ -1819,8 +1819,8 @@ discard block |
||
1819 | 1819 | |
1820 | 1820 | $form['ignoreblock']['addusername_toignorelist'] = array( |
1821 | 1821 | '#type' => 'textfield', |
1822 | - '#title' => bts('Username', array(), NULL, 'boinc:ignore-user-searchbox'), |
|
1823 | - '#description' => bts('To lookup a username start typing in the search box. A list of usernames will appear as you type. The number appearing in the suffix is the BOINC id. You can find a user\'s BOINC id on their user profile page.', array(), NULL, 'boinc:ignore-user-searchbox-help'), |
|
1822 | + '#title' => bts('Username', array(), null, 'boinc:ignore-user-searchbox'), |
|
1823 | + '#description' => bts('To lookup a username start typing in the search box. A list of usernames will appear as you type. The number appearing in the suffix is the BOINC id. You can find a user\'s BOINC id on their user profile page.', array(), null, 'boinc:ignore-user-searchbox-help'), |
|
1824 | 1824 | '#weight' => 11, |
1825 | 1825 | '#size' => 50, |
1826 | 1826 | '#autocomplete_path' => 'boincuser/autocomplete', |
@@ -1828,7 +1828,7 @@ discard block |
||
1828 | 1828 | |
1829 | 1829 | $form['ignoreblock']['addusername_submit'] = array( |
1830 | 1830 | '#type' => 'submit', |
1831 | - '#value' => bts('Ignore user', array(), NULL, 'boinc:ignore-user-add'), |
|
1831 | + '#value' => bts('Ignore user', array(), null, 'boinc:ignore-user-add'), |
|
1832 | 1832 | '#submit' => array('_boincwork_ignore_list_form_submit'), |
1833 | 1833 | '#weight' => 12, |
1834 | 1834 | '#attributes' => array('class' => 'add_ignore_user'), |
@@ -1846,13 +1846,13 @@ discard block |
||
1846 | 1846 | $form['prefs']['submit'] = array( |
1847 | 1847 | '#prefix' => '<li class="first tab">', |
1848 | 1848 | '#type' => 'submit', |
1849 | - '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'), |
|
1849 | + '#value' => bts('Save changes', array(), null, 'boinc:form-save'), |
|
1850 | 1850 | '#validate' => array('boincwork_privacyprefs_form_validate'), |
1851 | 1851 | '#submit' => array('boincwork_privacyprefs_form_submit'), |
1852 | 1852 | '#suffix' => '</li>' |
1853 | 1853 | ); |
1854 | 1854 | $form['prefs']['form control tabs'] = array( |
1855 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>' |
|
1855 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), null, 'boinc:form-cancel'), $_GET['q']) . '</li>' |
|
1856 | 1856 | ); |
1857 | 1857 | $form['prefs']['form control tabs suffix'] = array( |
1858 | 1858 | '#value' => '</ul>' |
@@ -1870,8 +1870,8 @@ discard block |
||
1870 | 1870 | $output .= drupal_render($form['privacy']); |
1871 | 1871 | |
1872 | 1872 | $header = array( |
1873 | - bts('Username', array(), NULL, 'boinc:ignore-user-list'), |
|
1874 | - bts('Operations', array(), NULL, 'boinc:ignore-user-list') |
|
1873 | + bts('Username', array(), null, 'boinc:ignore-user-list'), |
|
1874 | + bts('Operations', array(), null, 'boinc:ignore-user-list') |
|
1875 | 1875 | ); |
1876 | 1876 | |
1877 | 1877 | $rows = array(); |
@@ -1886,7 +1886,7 @@ discard block |
||
1886 | 1886 | else { |
1887 | 1887 | $rows[] = array( |
1888 | 1888 | array( |
1889 | - 'data' => bts('You have not added any users to your Ignore List.', array(), NULL, 'boinc:ignore-user-list'), |
|
1889 | + 'data' => bts('You have not added any users to your Ignore List.', array(), null, 'boinc:ignore-user-list'), |
|
1890 | 1890 | 'colspan' => '2', |
1891 | 1891 | ) |
1892 | 1892 | ); |
@@ -1965,9 +1965,9 @@ discard block |
||
1965 | 1965 | bts('@username has been added to your ignore list. See your !privacy_preferences for more details.', |
1966 | 1966 | array( |
1967 | 1967 | '@username' => $form_state['values']['addusername_toignorelist'], |
1968 | - '!privacy_preferences' => l(bts('privacy preferences', array(), NULL, 'boinc:ignore-user-add'), 'account/prefs/privacy'), |
|
1968 | + '!privacy_preferences' => l(bts('privacy preferences', array(), null, 'boinc:ignore-user-add'), 'account/prefs/privacy'), |
|
1969 | 1969 | ), |
1970 | - NULL, 'boinc:ignore-user-add'), |
|
1970 | + null, 'boinc:ignore-user-add'), |
|
1971 | 1971 | 'status'); |
1972 | 1972 | } |
1973 | 1973 | |
@@ -1992,7 +1992,7 @@ discard block |
||
1992 | 1992 | // only non-js users/browsers will see the Apply Filter button. |
1993 | 1993 | $form['submit'] = array( |
1994 | 1994 | '#type' => 'submit', |
1995 | - '#value' => bts('Apply Filter', array(), NULL, 'boinc:form-save'), |
|
1995 | + '#value' => bts('Apply Filter', array(), null, 'boinc:form-save'), |
|
1996 | 1996 | '#attributes' => array('class' => 'js-hide',), |
1997 | 1997 | ); |
1998 | 1998 |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | "; |
47 | 47 | } |
48 | 48 | |
49 | -function xml_error($num, $msg=null, $file=null, $line=null) { |
|
49 | +function xml_error($num, $msg = null, $file = null, $line = null) { |
|
50 | 50 | global $xml_outer_tag; |
51 | 51 | if (!$msg) { |
52 | - switch($num) { |
|
52 | + switch ($num) { |
|
53 | 53 | case -112: $msg = "Invalid XML"; break; |
54 | 54 | case -136: $msg = "Not found"; break; |
55 | 55 | case -137: $msg = "Name or email address is not unique"; break; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | // If it's a single-tag element, and it's present, just return the tag |
96 | 96 | // |
97 | 97 | function parse_element($xml, $tag) { |
98 | - $closetag = "</" . substr($tag,1); |
|
98 | + $closetag = "</".substr($tag, 1); |
|
99 | 99 | $x = strstr($xml, $tag); |
100 | 100 | if ($x) { |
101 | 101 | if (strstr($tag, "/>")) return $tag; |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | |
112 | 112 | function parse_next_element($xml, $tag, &$cursor) { |
113 | 113 | $element = null; |
114 | - $closetag = "</" . substr($tag,1); |
|
115 | - $pos = substr($xml,$cursor); |
|
114 | + $closetag = "</".substr($tag, 1); |
|
115 | + $pos = substr($xml, $cursor); |
|
116 | 116 | $x = strstr($pos, $tag); |
117 | 117 | if ($x) { |
118 | 118 | if (strstr($tag, "/>")) return $tag; |
@@ -29,10 +29,10 @@ discard block |
||
29 | 29 | |
30 | 30 | $border = get_str("border", true); |
31 | 31 | |
32 | -if ($border=="no") { |
|
32 | +if ($border == "no") { |
|
33 | 33 | $border = 0; |
34 | 34 | } else { |
35 | - $border=8; |
|
35 | + $border = 8; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | $font = "\"Optima,Lucida Bright,Times New Roman\""; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | <tr><th align=left>Project</th><th align=left>Cobblestones</th><th align=left>Joined</th></tr> |
76 | 76 | "; |
77 | 77 | foreach ($user->projects as $p) { |
78 | - if ($p->total_credit<100) continue; |
|
78 | + if ($p->total_credit < 100) continue; |
|
79 | 79 | show_proj($p); |
80 | 80 | } |
81 | 81 | echo " |
@@ -40,7 +40,7 @@ |
||
40 | 40 | $n = (int)$argv[2]; |
41 | 41 | $db->do_query("delete from msg_to_host where handled = $n"); |
42 | 42 | } else { |
43 | - echo "echo "usage: purge_trickles.php [msg_from_host | msg_to_host]\n"; |
|
43 | + echo "echo "usage: purge_trickles.php [msg_from_host|msg_to_host]\n"; |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | ?> |
@@ -135,8 +135,7 @@ discard block |
||
135 | 135 | |
136 | 136 | if (!$name) { |
137 | 137 | form_set_error('name', bts('Team name is required.', array(), NULL, 'boinc:team-create/edit')); |
138 | - } |
|
139 | - else { |
|
138 | + } else { |
|
140 | 139 | require_boinc('boinc_db'); |
141 | 140 | if (BoincTeam::lookup_name($name)) { |
142 | 141 | form_set_error('name', bts('A team named "@name" already exists.', |
@@ -177,8 +176,7 @@ discard block |
||
177 | 176 | if ($boinc_team) { |
178 | 177 | $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
179 | 178 | user_join_team($boinc_team, $boinc_user); |
180 | - } |
|
181 | - else { |
|
179 | + } else { |
|
182 | 180 | drupal_set_message(t('Teams cannot be created at this time. Please |
183 | 181 | contact the @project administrators!', array('@project' => PROJECT))); |
184 | 182 | watchdog('BOINC team', 'BOINC teams cannot be created for an unknown |
@@ -212,8 +210,7 @@ discard block |
||
212 | 210 | if (module_exists('pathauto')) { |
213 | 211 | module_load_include('inc', 'pathauto', 'pathauto'); |
214 | 212 | $node['path'] = pathauto_cleanstring($values['name']); |
215 | - } |
|
216 | - else { |
|
213 | + } else { |
|
217 | 214 | drupal_set_message(t('Teams cannot be created at this time. Please |
218 | 215 | contact the @project administrators!', array('@project' => PROJECT))); |
219 | 216 | watchdog('BOINC team', 'BOINC teams require the Pathauto module. Teams |
@@ -381,8 +378,7 @@ discard block |
||
381 | 378 | $form['form control tabs'] = array( |
382 | 379 | '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), strstr($_GET['q'], '/edit', TRUE)) . '</li>' |
383 | 380 | ); |
384 | - } |
|
385 | - else { |
|
381 | + } else { |
|
386 | 382 | $form['description'] = array( |
387 | 383 | '#prefix' => '<div class="form-item"><label>' . bts('Description', array(), NULL, 'boinc:team-description') . ':</label></div><div class="form-item">', |
388 | 384 | '#value' => $default['description'], |
@@ -412,12 +408,10 @@ discard block |
||
412 | 408 | |
413 | 409 | if ($form_state['storage']['is_boinc_wide']) { |
414 | 410 | form_set_error('none', bts('This team is managed by the BOINC-wide teams system and cannot be updated here.', array(), NULL, 'boinc:team-create/edit')); |
415 | - } |
|
416 | - else { |
|
411 | + } else { |
|
417 | 412 | if (!$name) { |
418 | 413 | form_set_error('name', bts('Team name is required.', array(), NULL, 'boinc:team-create/edit')); |
419 | - } |
|
420 | - else { |
|
414 | + } else { |
|
421 | 415 | $team = node_load($form_state['storage']['team_id']); |
422 | 416 | if ($name != $team->title) { |
423 | 417 | // If changing the name ("title" in Drupal terms), check that the new name is available |
@@ -559,8 +553,7 @@ discard block |
||
559 | 553 | |
560 | 554 | if (!$values['username']) { |
561 | 555 | form_set_error('username', bts('BOINC username is required.', array(), NULL, 'boinc:team-add-admin')); |
562 | - } |
|
563 | - else { |
|
556 | + } else { |
|
564 | 557 | // Load user account associated with username |
565 | 558 | $account = boincuser_privatemsg_name_lookup($values['username']); |
566 | 559 | // Validate the account |
@@ -570,24 +563,21 @@ discard block |
||
570 | 563 | '@username' => $account->boincuser_name |
571 | 564 | ), |
572 | 565 | NULL, 'boinc:team-add-admin')); |
573 | - } |
|
574 | - elseif (boincteam_is_founder($team_id, $account->uid)) { |
|
566 | + } elseif (boincteam_is_founder($team_id, $account->uid)) { |
|
575 | 567 | form_set_error('username', bts('@user is the founder of @team! Team founder already have all admin privileges.', |
576 | 568 | array( |
577 | 569 | '@user' => $account->boincuser_name, |
578 | 570 | '@team' => $team->title, |
579 | 571 | ), |
580 | 572 | NULL, 'boinc:team-add-admin')); |
581 | - } |
|
582 | - elseif (boincteam_is_admin($team_id, $account->uid)) { |
|
573 | + } elseif (boincteam_is_admin($team_id, $account->uid)) { |
|
583 | 574 | form_set_error('username', bts('@user is already an admin of @team.', |
584 | 575 | array( |
585 | 576 | '@user' => $account->boincuser_name, |
586 | 577 | '@team' => $team->title, |
587 | 578 | ), |
588 | 579 | NULL, 'boinc:team-add-admin')); |
589 | - } |
|
590 | - else { |
|
580 | + } else { |
|
591 | 581 | $form_state['storage']['boincuser_id'] = $account->boincuser_id; |
592 | 582 | $form_state['storage']['boincuser_name'] = $account->boincuser_name; |
593 | 583 | } |
@@ -645,8 +635,7 @@ discard block |
||
645 | 635 | if (isset($form_state['values'])) { |
646 | 636 | $subject = $form_state['values']['subject']; |
647 | 637 | $body = $form_state['values']['body']; |
648 | - } |
|
649 | - else { |
|
638 | + } else { |
|
650 | 639 | $subject = ''; |
651 | 640 | $body = ''; |
652 | 641 | } |
@@ -22,22 +22,22 @@ discard block |
||
22 | 22 | 'website' => '', |
23 | 23 | 'type' => 0, |
24 | 24 | 'country' => 0, |
25 | - 'joinable' => TRUE, |
|
25 | + 'joinable' => true, |
|
26 | 26 | 'description' => '', |
27 | 27 | ); |
28 | 28 | |
29 | 29 | // Standard option sets |
30 | 30 | $form['boolean_options'] = array( |
31 | 31 | '#type' => 'value', |
32 | - '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')), |
|
32 | + '#value' => array(1 => bts('yes', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')), |
|
33 | 33 | ); |
34 | 34 | |
35 | 35 | // Vocabulary based option sets |
36 | 36 | $form['type_options'] = array( |
37 | 37 | '#type' => 'value', |
38 | - '#value' => array(0 => bts('Choose type', array(), NULL, 'boinc:form-choose')) |
|
38 | + '#value' => array(0 => bts('Choose type', array(), null, 'boinc:form-choose')) |
|
39 | 39 | ); |
40 | - $vocabs = taxonomy_get_vocabularies(NULL); |
|
40 | + $vocabs = taxonomy_get_vocabularies(null); |
|
41 | 41 | foreach ($vocabs as $vocab) { |
42 | 42 | switch ($vocab->name) { |
43 | 43 | case 'Teams': |
@@ -59,40 +59,40 @@ discard block |
||
59 | 59 | |
60 | 60 | // Form elements |
61 | 61 | $form['name'] = array( |
62 | - '#title' => bts('Team name', array(), NULL, 'boinc:team-create/edit'), |
|
62 | + '#title' => bts('Team name', array(), null, 'boinc:team-create/edit'), |
|
63 | 63 | '#type' => 'textfield', |
64 | 64 | '#default_value' => $default['name'], |
65 | 65 | '#size' => 34, |
66 | - '#description' => bts('Text only, no HTML tags', array(), NULL, 'boinc:team-form-help'), |
|
66 | + '#description' => bts('Text only, no HTML tags', array(), null, 'boinc:team-form-help'), |
|
67 | 67 | ); |
68 | 68 | $form['name_html'] = array( |
69 | - '#title' => bts('Team name -- HTML version (optional)', array(), NULL, 'boinc:team-create/edit'), |
|
69 | + '#title' => bts('Team name -- HTML version (optional)', array(), null, 'boinc:team-create/edit'), |
|
70 | 70 | '#type' => 'textfield', |
71 | 71 | '#default_value' => $default['name_html'], |
72 | 72 | '#size' => 34, |
73 | - '#description' => bts('You may use limited HTML tags', array(), NULL, 'boinc:team-form-help'), |
|
73 | + '#description' => bts('You may use limited HTML tags', array(), null, 'boinc:team-form-help'), |
|
74 | 74 | ); |
75 | 75 | $form['website'] = array( |
76 | - '#title' => bts('Team website (optional)', array(), NULL, 'boinc:team-create/edit'), |
|
76 | + '#title' => bts('Team website (optional)', array(), null, 'boinc:team-create/edit'), |
|
77 | 77 | '#type' => 'textfield', |
78 | 78 | '#default_value' => $default['website'], |
79 | 79 | '#size' => 34, |
80 | - '#description' => bts("Displayed on the team's page", array(), NULL, 'boinc:team-create/edit'), |
|
80 | + '#description' => bts("Displayed on the team's page", array(), null, 'boinc:team-create/edit'), |
|
81 | 81 | ); |
82 | 82 | $form['type'] = array( |
83 | - '#title' => bts('Type of team', array(), NULL, 'boinc:team-create/edit'), |
|
83 | + '#title' => bts('Type of team', array(), null, 'boinc:team-create/edit'), |
|
84 | 84 | '#type' => 'select', |
85 | 85 | '#options' => $form['type_options']['#value'], |
86 | 86 | '#default_value' => $default['type'], |
87 | 87 | ); |
88 | 88 | $form['country'] = array( |
89 | - '#title' => bts('Country', array(), NULL, 'boinc:country-of-origin'), |
|
89 | + '#title' => bts('Country', array(), null, 'boinc:country-of-origin'), |
|
90 | 90 | '#type' => 'select', |
91 | 91 | '#options' => $form['country_options']['#value'], |
92 | 92 | '#default_value' => $default['country'], |
93 | 93 | ); |
94 | 94 | $form['joinable'] = array( |
95 | - '#title' => bts('Accept new members?', array(), NULL, 'boinc:team-create/edit'), |
|
95 | + '#title' => bts('Accept new members?', array(), null, 'boinc:team-create/edit'), |
|
96 | 96 | '#type' => 'radios', |
97 | 97 | '#options' => $form['boolean_options']['#value'], |
98 | 98 | '#attributes' => array('class' => 'fancy'), |
@@ -100,11 +100,11 @@ discard block |
||
100 | 100 | '#size' => 34, |
101 | 101 | ); |
102 | 102 | $form['description'] = array( |
103 | - '#title' => bts('Description of team', array(), NULL, 'boinc:team-create/edit'), |
|
103 | + '#title' => bts('Description of team', array(), null, 'boinc:team-create/edit'), |
|
104 | 104 | '#type' => 'textarea', |
105 | 105 | '#default_value' => $default['description'], |
106 | 106 | '#size' => 5, |
107 | - '#description' => NULL, |
|
107 | + '#description' => null, |
|
108 | 108 | ); |
109 | 109 | $form['format'] = filter_form(); |
110 | 110 | |
@@ -115,11 +115,11 @@ discard block |
||
115 | 115 | $form['submit'] = array( |
116 | 116 | '#prefix' => '<li class="first tab">', |
117 | 117 | '#type' => 'submit', |
118 | - '#value' => bts('Save team', array(), NULL, 'boinc:team-form-save'), |
|
118 | + '#value' => bts('Save team', array(), null, 'boinc:team-form-save'), |
|
119 | 119 | '#suffix' => '</li>', |
120 | 120 | ); |
121 | 121 | $form['form control tabs'] = array( |
122 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>' |
|
122 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), null, 'boinc:form-cancel'), $_GET['q']) . '</li>' |
|
123 | 123 | ); |
124 | 124 | |
125 | 125 | return $form; |
@@ -134,18 +134,18 @@ discard block |
||
134 | 134 | $name = $values['name']; |
135 | 135 | |
136 | 136 | if (!$name) { |
137 | - form_set_error('name', bts('Team name is required.', array(), NULL, 'boinc:team-create/edit')); |
|
137 | + form_set_error('name', bts('Team name is required.', array(), null, 'boinc:team-create/edit')); |
|
138 | 138 | } |
139 | 139 | else { |
140 | 140 | require_boinc('boinc_db'); |
141 | 141 | if (BoincTeam::lookup_name($name)) { |
142 | 142 | form_set_error('name', bts('A team named "@name" already exists.', |
143 | - array('@name' => $name), NULL, 'boinc:team-create/edit')); |
|
143 | + array('@name' => $name), null, 'boinc:team-create/edit')); |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
147 | - if (!$values['type'] OR !isset($values['type_options'][$values['type']])) { |
|
148 | - form_set_error('type', bts('Please select a team type.', array(), NULL, 'boinc:team-create/edit')); |
|
147 | + if (!$values['type'] or !isset($values['type_options'][$values['type']])) { |
|
148 | + form_set_error('type', bts('Please select a team type.', array(), null, 'boinc:team-create/edit')); |
|
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | contact the @project administrators!', array('@project' => PROJECT))); |
184 | 184 | watchdog('BOINC team', 'BOINC teams cannot be created for an unknown |
185 | 185 | reason.', 'error'); |
186 | - return FALSE; |
|
186 | + return false; |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | // Create the team node in Drupal |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | $team = node_load($team_id); |
265 | 265 | $boincteam = boincteam_load(boincteam_lookup_id($team_id)); |
266 | 266 | |
267 | - $is_boinc_wide = ($boincteam->seti_id > 0) ? TRUE : FALSE; |
|
267 | + $is_boinc_wide = ($boincteam->seti_id > 0) ? true : false; |
|
268 | 268 | |
269 | 269 | $form_state['storage']['team_id'] = $team_id; |
270 | 270 | $form_state['storage']['is_boinc_wide'] = $is_boinc_wide; |
@@ -282,15 +282,15 @@ discard block |
||
282 | 282 | // Standard option sets |
283 | 283 | $form['boolean_options'] = array( |
284 | 284 | '#type' => 'value', |
285 | - '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')), |
|
285 | + '#value' => array(1 => bts('yes', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')), |
|
286 | 286 | ); |
287 | 287 | |
288 | 288 | // Vocabulary based option sets |
289 | 289 | $form['type_options'] = array( |
290 | 290 | '#type' => 'value', |
291 | - '#value' => array(0 => bts('Choose type', array(), NULL, 'boinc:form-choose')) |
|
291 | + '#value' => array(0 => bts('Choose type', array(), null, 'boinc:form-choose')) |
|
292 | 292 | ); |
293 | - $vocabs = taxonomy_get_vocabularies(NULL); |
|
293 | + $vocabs = taxonomy_get_vocabularies(null); |
|
294 | 294 | foreach ($vocabs as $vocab) { |
295 | 295 | switch ($vocab->name) { |
296 | 296 | case 'Teams': |
@@ -312,45 +312,45 @@ discard block |
||
312 | 312 | |
313 | 313 | // Form elements |
314 | 314 | $form['name'] = array( |
315 | - '#title' => bts('Team name', array(), NULL, 'boinc:team-create/edit'), |
|
315 | + '#title' => bts('Team name', array(), null, 'boinc:team-create/edit'), |
|
316 | 316 | '#type' => 'textfield', |
317 | 317 | '#default_value' => $default['name'], |
318 | 318 | '#size' => 34, |
319 | - '#description' => bts('Text only, no HTML tags', array(), NULL, 'boinc:team-form-help'), |
|
319 | + '#description' => bts('Text only, no HTML tags', array(), null, 'boinc:team-form-help'), |
|
320 | 320 | '#disabled' => $is_boinc_wide, |
321 | 321 | ); |
322 | 322 | $form['name_html'] = array( |
323 | - '#title' => bts('Team name -- HTML version (optional)', array(), NULL, 'boinc:team-create/edit'), |
|
323 | + '#title' => bts('Team name -- HTML version (optional)', array(), null, 'boinc:team-create/edit'), |
|
324 | 324 | '#type' => 'textfield', |
325 | 325 | '#default_value' => $default['name_html'], |
326 | 326 | '#size' => 34, |
327 | - '#description' => bts('You may use limited HTML tags', array(), NULL, 'boinc:team-form-help'), |
|
327 | + '#description' => bts('You may use limited HTML tags', array(), null, 'boinc:team-form-help'), |
|
328 | 328 | '#disabled' => $is_boinc_wide, |
329 | 329 | ); |
330 | 330 | $form['website'] = array( |
331 | - '#title' => bts('Team website (optional)', array(), NULL, 'boinc:team-create/edit'), |
|
331 | + '#title' => bts('Team website (optional)', array(), null, 'boinc:team-create/edit'), |
|
332 | 332 | '#type' => 'textfield', |
333 | 333 | '#default_value' => $default['website'], |
334 | 334 | '#size' => 34, |
335 | - '#description' => bts("Displayed on the team's page", array(), NULL, 'boinc:team-create/edit'), |
|
335 | + '#description' => bts("Displayed on the team's page", array(), null, 'boinc:team-create/edit'), |
|
336 | 336 | '#disabled' => $is_boinc_wide, |
337 | 337 | ); |
338 | 338 | $form['type'] = array( |
339 | - '#title' => bts('Type of team', array(), NULL, 'boinc:team-create/edit'), |
|
339 | + '#title' => bts('Type of team', array(), null, 'boinc:team-create/edit'), |
|
340 | 340 | '#type' => 'select', |
341 | 341 | '#options' => $form['type_options']['#value'], |
342 | 342 | '#default_value' => $default['type'], |
343 | 343 | '#disabled' => $is_boinc_wide, |
344 | 344 | ); |
345 | 345 | $form['country'] = array( |
346 | - '#title' => bts('Country', array(), NULL, 'boinc:country-of-origin'), |
|
346 | + '#title' => bts('Country', array(), null, 'boinc:country-of-origin'), |
|
347 | 347 | '#type' => 'select', |
348 | 348 | '#options' => $form['country_options']['#value'], |
349 | 349 | '#default_value' => $default['country'], |
350 | 350 | '#disabled' => $is_boinc_wide, |
351 | 351 | ); |
352 | 352 | $form['joinable'] = array( |
353 | - '#title' => bts('Accept new members?', array(), NULL, 'boinc:team-create/edit'), |
|
353 | + '#title' => bts('Accept new members?', array(), null, 'boinc:team-create/edit'), |
|
354 | 354 | '#type' => 'radios', |
355 | 355 | '#options' => $form['boolean_options']['#value'], |
356 | 356 | '#attributes' => array('class' => 'fancy'), |
@@ -360,11 +360,11 @@ discard block |
||
360 | 360 | ); |
361 | 361 | if (!$is_boinc_wide) { |
362 | 362 | $form['description'] = array( |
363 | - '#title' => bts('Description of team', array(), NULL, 'boinc:team-create/edit'), |
|
363 | + '#title' => bts('Description of team', array(), null, 'boinc:team-create/edit'), |
|
364 | 364 | '#type' => 'textarea', |
365 | 365 | '#default_value' => $default['description'], |
366 | 366 | '#size' => 5, |
367 | - '#description' => NULL, |
|
367 | + '#description' => null, |
|
368 | 368 | ); |
369 | 369 | $form['format'] = filter_form(); |
370 | 370 | |
@@ -375,25 +375,25 @@ discard block |
||
375 | 375 | $form['submit'] = array( |
376 | 376 | '#prefix' => '<li class="first tab">', |
377 | 377 | '#type' => 'submit', |
378 | - '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'), |
|
378 | + '#value' => bts('Save changes', array(), null, 'boinc:form-save'), |
|
379 | 379 | '#suffix' => '</li>', |
380 | 380 | ); |
381 | 381 | $form['form control tabs'] = array( |
382 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), strstr($_GET['q'], '/edit', TRUE)) . '</li>' |
|
382 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), null, 'boinc:form-cancel'), strstr($_GET['q'], '/edit', true)) . '</li>' |
|
383 | 383 | ); |
384 | 384 | } |
385 | 385 | else { |
386 | 386 | $form['description'] = array( |
387 | - '#prefix' => '<div class="form-item"><label>' . bts('Description', array(), NULL, 'boinc:team-description') . ':</label></div><div class="form-item">', |
|
387 | + '#prefix' => '<div class="form-item"><label>' . bts('Description', array(), null, 'boinc:team-description') . ':</label></div><div class="form-item">', |
|
388 | 388 | '#value' => $default['description'], |
389 | 389 | '#suffix' => '</div>', |
390 | 390 | ); |
391 | 391 | drupal_set_message( |
392 | 392 | bts('This is a BOINC-wide team. Changes can be made at the !site.', |
393 | - array('!site' => l(bts('BOINC-wide teams site', array(), NULL, 'boinc:link-to-BOINC-wide-teams-Website'), |
|
393 | + array('!site' => l(bts('BOINC-wide teams site', array(), null, 'boinc:link-to-BOINC-wide-teams-Website'), |
|
394 | 394 | 'http://boinc.berkeley.edu/teams/' |
395 | 395 | )), |
396 | - NULL, 'boinc:team-edit-warning-message'), |
|
396 | + null, 'boinc:team-edit-warning-message'), |
|
397 | 397 | 'warning'); |
398 | 398 | } |
399 | 399 | |
@@ -411,11 +411,11 @@ discard block |
||
411 | 411 | $name = $values['name']; |
412 | 412 | |
413 | 413 | if ($form_state['storage']['is_boinc_wide']) { |
414 | - form_set_error('none', bts('This team is managed by the BOINC-wide teams system and cannot be updated here.', array(), NULL, 'boinc:team-create/edit')); |
|
414 | + form_set_error('none', bts('This team is managed by the BOINC-wide teams system and cannot be updated here.', array(), null, 'boinc:team-create/edit')); |
|
415 | 415 | } |
416 | 416 | else { |
417 | 417 | if (!$name) { |
418 | - form_set_error('name', bts('Team name is required.', array(), NULL, 'boinc:team-create/edit')); |
|
418 | + form_set_error('name', bts('Team name is required.', array(), null, 'boinc:team-create/edit')); |
|
419 | 419 | } |
420 | 420 | else { |
421 | 421 | $team = node_load($form_state['storage']['team_id']); |
@@ -424,13 +424,13 @@ discard block |
||
424 | 424 | require_boinc('boinc_db'); |
425 | 425 | if (BoincTeam::lookup_name($name)) { |
426 | 426 | form_set_error('name', bts('A team named "@name" already exists.', |
427 | - array('@name' => $name), NULL, 'boinc:team-create/edit')); |
|
427 | + array('@name' => $name), null, 'boinc:team-create/edit')); |
|
428 | 428 | } |
429 | 429 | } |
430 | 430 | } |
431 | 431 | |
432 | - if (!$values['type'] OR !isset($values['type_options'][$values['type']])) { |
|
433 | - form_set_error('type', bts('Please select a team type.', array(), NULL, 'boinc:team-create/edit')); |
|
432 | + if (!$values['type'] or !isset($values['type_options'][$values['type']])) { |
|
433 | + form_set_error('type', bts('Please select a team type.', array(), null, 'boinc:team-create/edit')); |
|
434 | 434 | } |
435 | 435 | } |
436 | 436 | } |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | |
522 | 522 | // Form elements |
523 | 523 | $form['username'] = array( |
524 | - '#title' => bts('Enter BOINC username', array(), NULL, 'boinc:team--add-admin'), |
|
524 | + '#title' => bts('Enter BOINC username', array(), null, 'boinc:team--add-admin'), |
|
525 | 525 | '#description' => bts('The number appearing in the suffix is the BOINC id. You can find a user\'s BOINC id on their user profile page.'), |
526 | 526 | '#type' => 'textfield', |
527 | 527 | '#default_value' => $default['username'], |
@@ -536,11 +536,11 @@ discard block |
||
536 | 536 | $form['submit'] = array( |
537 | 537 | '#prefix' => '<li class="first tab">', |
538 | 538 | '#type' => 'submit', |
539 | - '#value' => bts('Add', array(), NULL, 'boinc:form-add'), |
|
539 | + '#value' => bts('Add', array(), null, 'boinc:form-add'), |
|
540 | 540 | '#suffix' => '</li>', |
541 | 541 | ); |
542 | 542 | $form['form control tabs'] = array( |
543 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), strstr($_GET['q'], '/edit', TRUE)) . '</li>' |
|
543 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), null, 'boinc:form-cancel'), strstr($_GET['q'], '/edit', true)) . '</li>' |
|
544 | 544 | ); |
545 | 545 | |
546 | 546 | //$form['#redirect'] = "community/teams/{$team_id}"; |
@@ -558,18 +558,18 @@ discard block |
||
558 | 558 | $team = node_load($team_id); |
559 | 559 | |
560 | 560 | if (!$values['username']) { |
561 | - form_set_error('username', bts('BOINC username is required.', array(), NULL, 'boinc:team-add-admin')); |
|
561 | + form_set_error('username', bts('BOINC username is required.', array(), null, 'boinc:team-add-admin')); |
|
562 | 562 | } |
563 | 563 | else { |
564 | 564 | // Load user account associated with username |
565 | 565 | $account = boincuser_privatemsg_name_lookup($values['username']); |
566 | 566 | // Validate the account |
567 | - if ((!$account) OR ($account->team != $team_id)) { |
|
567 | + if ((!$account) or ($account->team != $team_id)) { |
|
568 | 568 | form_set_error('username', bts('There is no user on your team with name @username.', |
569 | 569 | array( |
570 | 570 | '@username' => $account->boincuser_name |
571 | 571 | ), |
572 | - NULL, 'boinc:team-add-admin')); |
|
572 | + null, 'boinc:team-add-admin')); |
|
573 | 573 | } |
574 | 574 | elseif (boincteam_is_founder($team_id, $account->uid)) { |
575 | 575 | form_set_error('username', bts('@user is the founder of @team! Team founder already have all admin privileges.', |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | '@user' => $account->boincuser_name, |
578 | 578 | '@team' => $team->title, |
579 | 579 | ), |
580 | - NULL, 'boinc:team-add-admin')); |
|
580 | + null, 'boinc:team-add-admin')); |
|
581 | 581 | } |
582 | 582 | elseif (boincteam_is_admin($team_id, $account->uid)) { |
583 | 583 | form_set_error('username', bts('@user is already an admin of @team.', |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | '@user' => $account->boincuser_name, |
586 | 586 | '@team' => $team->title, |
587 | 587 | ), |
588 | - NULL, 'boinc:team-add-admin')); |
|
588 | + null, 'boinc:team-add-admin')); |
|
589 | 589 | } |
590 | 590 | else { |
591 | 591 | $form_state['storage']['boincuser_id'] = $account->boincuser_id; |
@@ -652,7 +652,7 @@ discard block |
||
652 | 652 | } |
653 | 653 | |
654 | 654 | // Title |
655 | - $mytitle = bts('Send E-mail To All Team Members', array(), NULL, 'boinc:team-message-form'); |
|
655 | + $mytitle = bts('Send E-mail To All Team Members', array(), null, 'boinc:team-message-form'); |
|
656 | 656 | drupal_set_title($mytitle); |
657 | 657 | |
658 | 658 | $form['emailteam']['header'] = array( |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | ); |
664 | 664 | |
665 | 665 | $form['emailteam']['instructions'] = array( |
666 | - '#value' => bts('This will send an email to all team members. If a team member has opt-ed out of notification e-mails, they will not receive your message. At the bottom of your message, there will be a link allowing team members to send you a Direct Message. This link is added automatically, you do not need to add it below in the Message box. Your email address will not be shown to the recipients.', array(), NULL, 'boinc:team-message-form'), |
|
666 | + '#value' => bts('This will send an email to all team members. If a team member has opt-ed out of notification e-mails, they will not receive your message. At the bottom of your message, there will be a link allowing team members to send you a Direct Message. This link is added automatically, you do not need to add it below in the Message box. Your email address will not be shown to the recipients.', array(), null, 'boinc:team-message-form'), |
|
667 | 667 | '#weight' => '-8', |
668 | 668 | '#prefix' => "<div id='sendmessageteammembers-instructions'>", |
669 | 669 | '#suffix' => "</div>", |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | // Subject |
673 | 673 | $form['emailteam']['subject'] = array( |
674 | 674 | '#type' => 'textfield', |
675 | - '#title' => bts('Subject', array(), NULL, 'boinc:team-message-form'), |
|
675 | + '#title' => bts('Subject', array(), null, 'boinc:team-message-form'), |
|
676 | 676 | '#size' => 50, |
677 | 677 | '#maxlength' => 255, |
678 | 678 | '#default_value' => $subject, |
@@ -682,17 +682,17 @@ discard block |
||
682 | 682 | // Body |
683 | 683 | $form['emailteam']['body'] = array( |
684 | 684 | '#type' => 'textarea', |
685 | - '#title' => bts('Message', array(), NULL, 'boinc:team-message-form'), |
|
685 | + '#title' => bts('Message', array(), null, 'boinc:team-message-form'), |
|
686 | 686 | '#rows' => 8, |
687 | 687 | '#weight' => 0, |
688 | 688 | '#default_value' => $body, |
689 | - '#resizable' => TRUE, |
|
689 | + '#resizable' => true, |
|
690 | 690 | ); |
691 | 691 | |
692 | 692 | // checkbox for 'sent to self' |
693 | 693 | $form['emailteam']['selfsend'] = array( |
694 | 694 | '#type' => 'checkbox', |
695 | - '#title' => bts('Check this box if you wish to be sent a copy of your message to your email address.', array(), NULL, 'boinc:team-message-form'), |
|
695 | + '#title' => bts('Check this box if you wish to be sent a copy of your message to your email address.', array(), null, 'boinc:team-message-form'), |
|
696 | 696 | '#weight' => 10, |
697 | 697 | '#prefix' => '<div class="clearfix" id="confirm-checkbox">', |
698 | 698 | '#suffix' => '</div>', |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | |
715 | 715 | $form['emailteam']['submit'] = array( |
716 | 716 | '#type' => 'submit', |
717 | - '#value' => bts('Send message', array(), NULL, 'boinc:form-submit'), |
|
717 | + '#value' => bts('Send message', array(), null, 'boinc:form-submit'), |
|
718 | 718 | '#submit' => array('boincteam_sendmessagetoteam_submit'), |
719 | 719 | '#validate' => array('boincteam_sendmessagetoteam_validate'), |
720 | 720 | '#weight' => 1001, |
@@ -722,7 +722,7 @@ discard block |
||
722 | 722 | '#suffix' => '</li>' |
723 | 723 | ); |
724 | 724 | |
725 | - $title = bts('Cancel', array(), NULL, 'boinc:form-cancel'); |
|
725 | + $title = bts('Cancel', array(), null, 'boinc:form-cancel'); |
|
726 | 726 | $url = "community/teams/{$team_id}"; |
727 | 727 | $form['emailteam']['cancel'] = array( |
728 | 728 | '#value' => l($title, $url, array('attributes' => array('id' => 'edit-cancel'))), |
@@ -763,7 +763,7 @@ discard block |
||
763 | 763 | // Avoid subjects which only consist of a space as these can not be clicked. |
764 | 764 | $message['subject'] = trim($message['subject']); |
765 | 765 | |
766 | - $trimed_body = trim(truncate_utf8(strip_tags($message['body']), 50, TRUE, TRUE)); |
|
766 | + $trimed_body = trim(truncate_utf8(strip_tags($message['body']), 50, true, true)); |
|
767 | 767 | if (empty($message['subject']) && !empty($trimed_body)) { |
768 | 768 | $message['subject'] = $trimed_body; |
769 | 769 | $form_state['values']['subject'] = $message['subject']; |
@@ -773,21 +773,21 @@ discard block |
||
773 | 773 | $message['subject'] = trim($message['subject']); |
774 | 774 | if (empty($message['subject'])) { |
775 | 775 | form_set_error('subject', |
776 | - bts('Not allowed to send a message without subject', array(), NULL, 'boinc:team-message-form') |
|
776 | + bts('Not allowed to send a message without subject', array(), null, 'boinc:team-message-form') |
|
777 | 777 | ); |
778 | 778 | } |
779 | 779 | |
780 | 780 | // Check body |
781 | - if ( ($message['body'] === NULL || $message['body'] === '') ) { |
|
781 | + if ( ($message['body'] === null || $message['body'] === '') ) { |
|
782 | 782 | form_set_error('body', |
783 | - bts('Not allowed to send an empty message.', array(), NULL, 'boinc:team-message-form') |
|
783 | + bts('Not allowed to send an empty message.', array(), null, 'boinc:team-message-form') |
|
784 | 784 | ); |
785 | 785 | } |
786 | 786 | |
787 | 787 | // Check team id |
788 | 788 | if (empty($message['_team_id'])) { |
789 | 789 | form_set_error('team_id', |
790 | - bts('Error, no team_id supplied.', array(), NULL, 'boinc:team-message-form') |
|
790 | + bts('Error, no team_id supplied.', array(), null, 'boinc:team-message-form') |
|
791 | 791 | ); |
792 | 792 | } |
793 | 793 |
@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | * The definition of the create team form |
15 | 15 | */ |
16 | 16 | function boincteam_create_form(&$form_state) { |
17 | - $form = array(); |
|
17 | + $form = array(); |
|
18 | 18 | |
19 | - $default = array( |
|
19 | + $default = array( |
|
20 | 20 | 'name' => '', |
21 | 21 | 'name_html' => '', |
22 | 22 | 'website' => '', |
@@ -24,105 +24,105 @@ discard block |
||
24 | 24 | 'country' => 0, |
25 | 25 | 'joinable' => TRUE, |
26 | 26 | 'description' => '', |
27 | - ); |
|
27 | + ); |
|
28 | 28 | |
29 | - // Standard option sets |
|
30 | - $form['boolean_options'] = array( |
|
29 | + // Standard option sets |
|
30 | + $form['boolean_options'] = array( |
|
31 | 31 | '#type' => 'value', |
32 | 32 | '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')), |
33 | - ); |
|
33 | + ); |
|
34 | 34 | |
35 | - // Vocabulary based option sets |
|
36 | - $form['type_options'] = array( |
|
35 | + // Vocabulary based option sets |
|
36 | + $form['type_options'] = array( |
|
37 | 37 | '#type' => 'value', |
38 | 38 | '#value' => array(0 => bts('Choose type', array(), NULL, 'boinc:form-choose')) |
39 | - ); |
|
40 | - $vocabs = taxonomy_get_vocabularies(NULL); |
|
41 | - foreach ($vocabs as $vocab) { |
|
39 | + ); |
|
40 | + $vocabs = taxonomy_get_vocabularies(NULL); |
|
41 | + foreach ($vocabs as $vocab) { |
|
42 | 42 | switch ($vocab->name) { |
43 | 43 | case 'Teams': |
44 | 44 | $team_types = taxonomy_get_tree($vocab->vid); |
45 | - if (module_exists('internationalization')) { |
|
45 | + if (module_exists('internationalization')) { |
|
46 | 46 | $team_types = i18ntaxonomy_localize_terms($team_types); |
47 | - } |
|
48 | - foreach ($team_types as $team_type) { |
|
47 | + } |
|
48 | + foreach ($team_types as $team_type) { |
|
49 | 49 | $form['type_options']['#value'][$team_type->tid] = $team_type->name; |
50 | - } |
|
51 | - break; |
|
50 | + } |
|
51 | + break; |
|
52 | 52 | default: |
53 | 53 | } |
54 | - } |
|
55 | - $form['country_options'] = array( |
|
54 | + } |
|
55 | + $form['country_options'] = array( |
|
56 | 56 | '#type' => 'value', |
57 | 57 | '#value' => boinccore_get_country_list(), |
58 | - ); |
|
58 | + ); |
|
59 | 59 | |
60 | - // Form elements |
|
61 | - $form['name'] = array( |
|
60 | + // Form elements |
|
61 | + $form['name'] = array( |
|
62 | 62 | '#title' => bts('Team name', array(), NULL, 'boinc:team-create/edit'), |
63 | 63 | '#type' => 'textfield', |
64 | 64 | '#default_value' => $default['name'], |
65 | 65 | '#size' => 34, |
66 | 66 | '#description' => bts('Text only, no HTML tags', array(), NULL, 'boinc:team-form-help'), |
67 | - ); |
|
68 | - $form['name_html'] = array( |
|
67 | + ); |
|
68 | + $form['name_html'] = array( |
|
69 | 69 | '#title' => bts('Team name -- HTML version (optional)', array(), NULL, 'boinc:team-create/edit'), |
70 | 70 | '#type' => 'textfield', |
71 | 71 | '#default_value' => $default['name_html'], |
72 | 72 | '#size' => 34, |
73 | 73 | '#description' => bts('You may use limited HTML tags', array(), NULL, 'boinc:team-form-help'), |
74 | - ); |
|
75 | - $form['website'] = array( |
|
74 | + ); |
|
75 | + $form['website'] = array( |
|
76 | 76 | '#title' => bts('Team website (optional)', array(), NULL, 'boinc:team-create/edit'), |
77 | 77 | '#type' => 'textfield', |
78 | 78 | '#default_value' => $default['website'], |
79 | 79 | '#size' => 34, |
80 | 80 | '#description' => bts("Displayed on the team's page", array(), NULL, 'boinc:team-create/edit'), |
81 | - ); |
|
82 | - $form['type'] = array( |
|
81 | + ); |
|
82 | + $form['type'] = array( |
|
83 | 83 | '#title' => bts('Type of team', array(), NULL, 'boinc:team-create/edit'), |
84 | 84 | '#type' => 'select', |
85 | 85 | '#options' => $form['type_options']['#value'], |
86 | 86 | '#default_value' => $default['type'], |
87 | - ); |
|
88 | - $form['country'] = array( |
|
87 | + ); |
|
88 | + $form['country'] = array( |
|
89 | 89 | '#title' => bts('Country', array(), NULL, 'boinc:country-of-origin'), |
90 | 90 | '#type' => 'select', |
91 | 91 | '#options' => $form['country_options']['#value'], |
92 | 92 | '#default_value' => $default['country'], |
93 | - ); |
|
94 | - $form['joinable'] = array( |
|
93 | + ); |
|
94 | + $form['joinable'] = array( |
|
95 | 95 | '#title' => bts('Accept new members?', array(), NULL, 'boinc:team-create/edit'), |
96 | 96 | '#type' => 'radios', |
97 | 97 | '#options' => $form['boolean_options']['#value'], |
98 | 98 | '#attributes' => array('class' => 'fancy'), |
99 | 99 | '#default_value' => $default['joinable'], |
100 | 100 | '#size' => 34, |
101 | - ); |
|
102 | - $form['description'] = array( |
|
101 | + ); |
|
102 | + $form['description'] = array( |
|
103 | 103 | '#title' => bts('Description of team', array(), NULL, 'boinc:team-create/edit'), |
104 | 104 | '#type' => 'textarea', |
105 | 105 | '#default_value' => $default['description'], |
106 | 106 | '#size' => 5, |
107 | 107 | '#description' => NULL, |
108 | - ); |
|
109 | - $form['format'] = filter_form(); |
|
108 | + ); |
|
109 | + $form['format'] = filter_form(); |
|
110 | 110 | |
111 | - // Form control |
|
112 | - $form['form control tabs prefix'] = array( |
|
111 | + // Form control |
|
112 | + $form['form control tabs prefix'] = array( |
|
113 | 113 | '#value' => '<ul class="form-control tab-list">' |
114 | - ); |
|
115 | - $form['submit'] = array( |
|
114 | + ); |
|
115 | + $form['submit'] = array( |
|
116 | 116 | '#prefix' => '<li class="first tab">', |
117 | 117 | '#type' => 'submit', |
118 | 118 | '#value' => bts('Save team', array(), NULL, 'boinc:team-form-save'), |
119 | 119 | '#suffix' => '</li>', |
120 | - ); |
|
121 | - $form['form control tabs'] = array( |
|
120 | + ); |
|
121 | + $form['form control tabs'] = array( |
|
122 | 122 | '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>' |
123 | - ); |
|
123 | + ); |
|
124 | 124 | |
125 | - return $form; |
|
125 | + return $form; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -130,41 +130,41 @@ discard block |
||
130 | 130 | */ |
131 | 131 | function boincteam_create_form_validate($form, &$form_state) { |
132 | 132 | |
133 | - $values = $form_state['values']; |
|
134 | - $name = $values['name']; |
|
133 | + $values = $form_state['values']; |
|
134 | + $name = $values['name']; |
|
135 | 135 | |
136 | - if (!$name) { |
|
136 | + if (!$name) { |
|
137 | 137 | form_set_error('name', bts('Team name is required.', array(), NULL, 'boinc:team-create/edit')); |
138 | - } |
|
139 | - else { |
|
138 | + } |
|
139 | + else { |
|
140 | 140 | require_boinc('boinc_db'); |
141 | 141 | if (BoincTeam::lookup_name($name)) { |
142 | - form_set_error('name', bts('A team named "@name" already exists.', |
|
142 | + form_set_error('name', bts('A team named "@name" already exists.', |
|
143 | 143 | array('@name' => $name), NULL, 'boinc:team-create/edit')); |
144 | 144 | } |
145 | - } |
|
145 | + } |
|
146 | 146 | |
147 | - if (!$values['type'] OR !isset($values['type_options'][$values['type']])) { |
|
147 | + if (!$values['type'] OR !isset($values['type_options'][$values['type']])) { |
|
148 | 148 | form_set_error('type', bts('Please select a team type.', array(), NULL, 'boinc:team-create/edit')); |
149 | - } |
|
149 | + } |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
153 | 153 | * The create team submit handler |
154 | 154 | */ |
155 | 155 | function boincteam_create_form_submit($form, &$form_state) { |
156 | - global $user; |
|
157 | - $account = user_load($user->uid); |
|
158 | - $values = $form_state['values']; |
|
159 | - //drupal_set_message('<pre>' . print_r($values,true) . '</pre>'); |
|
156 | + global $user; |
|
157 | + $account = user_load($user->uid); |
|
158 | + $values = $form_state['values']; |
|
159 | + //drupal_set_message('<pre>' . print_r($values,true) . '</pre>'); |
|
160 | 160 | |
161 | - $input_format = !empty($values['format']) ? $values['format'] : 4; |
|
162 | - $values['description'] = check_markup($values['description'], $input_format); |
|
161 | + $input_format = !empty($values['format']) ? $values['format'] : 4; |
|
162 | + $values['description'] = check_markup($values['description'], $input_format); |
|
163 | 163 | |
164 | - // Create the team in the BOINC db |
|
164 | + // Create the team in the BOINC db |
|
165 | 165 | |
166 | - require_boinc(array('user','team')); |
|
167 | - $boinc_team = make_team( |
|
166 | + require_boinc(array('user','team')); |
|
167 | + $boinc_team = make_team( |
|
168 | 168 | $account->boincuser_id, |
169 | 169 | $values['name'], |
170 | 170 | $values['website'], |
@@ -172,27 +172,27 @@ discard block |
||
172 | 172 | $values['name_html'], |
173 | 173 | $values['description'], |
174 | 174 | $values['country'] |
175 | - ); |
|
175 | + ); |
|
176 | 176 | |
177 | - if ($boinc_team) { |
|
177 | + if ($boinc_team) { |
|
178 | 178 | $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
179 | 179 | user_join_team($boinc_team, $boinc_user); |
180 | - } |
|
181 | - else { |
|
180 | + } |
|
181 | + else { |
|
182 | 182 | drupal_set_message(t('Teams cannot be created at this time. Please |
183 | 183 | contact the @project administrators!', array('@project' => PROJECT))); |
184 | 184 | watchdog('BOINC team', 'BOINC teams cannot be created for an unknown |
185 | 185 | reason.', 'error'); |
186 | 186 | return FALSE; |
187 | - } |
|
187 | + } |
|
188 | 188 | |
189 | - // Create the team node in Drupal |
|
189 | + // Create the team node in Drupal |
|
190 | 190 | |
191 | - $teaser = node_teaser($values['description']); |
|
192 | - $created_time = time(); |
|
193 | - $input_format = variable_get('filter_default_format', 1); |
|
191 | + $teaser = node_teaser($values['description']); |
|
192 | + $created_time = time(); |
|
193 | + $input_format = variable_get('filter_default_format', 1); |
|
194 | 194 | |
195 | - $node = array( |
|
195 | + $node = array( |
|
196 | 196 | 'type' => 'team', |
197 | 197 | 'title' => $values['name'], |
198 | 198 | 'body' => $values['description'], |
@@ -206,21 +206,21 @@ discard block |
||
206 | 206 | 'moderate' => 0, |
207 | 207 | 'sticky' => 0, |
208 | 208 | 'format' => $input_format |
209 | - ); |
|
209 | + ); |
|
210 | 210 | |
211 | - // Use pathauto function, if available, to clean up the path |
|
212 | - if (module_exists('pathauto')) { |
|
211 | + // Use pathauto function, if available, to clean up the path |
|
212 | + if (module_exists('pathauto')) { |
|
213 | 213 | module_load_include('inc', 'pathauto', 'pathauto'); |
214 | 214 | $node['path'] = pathauto_cleanstring($values['name']); |
215 | - } |
|
216 | - else { |
|
215 | + } |
|
216 | + else { |
|
217 | 217 | drupal_set_message(t('Teams cannot be created at this time. Please |
218 | 218 | contact the @project administrators!', array('@project' => PROJECT))); |
219 | 219 | watchdog('BOINC team', 'BOINC teams require the Pathauto module. Teams |
220 | 220 | cannot be created.', 'error'); |
221 | - } |
|
221 | + } |
|
222 | 222 | |
223 | - /* |
|
223 | + /* |
|
224 | 224 | // Add special organic group properties |
225 | 225 | $node['og_description'] = strip_tags($boincteam->description); |
226 | 226 | $node['og_selective'] = OG_OPEN; |
@@ -229,26 +229,26 @@ discard block |
||
229 | 229 | $node['og_private'] = 0; |
230 | 230 | */ |
231 | 231 | |
232 | - $node = (object) $node; // node_save requires an object form |
|
232 | + $node = (object) $node; // node_save requires an object form |
|
233 | 233 | |
234 | - /* |
|
234 | + /* |
|
235 | 235 | $node->field_description[]['value'] = $boincteam->description; |
236 | 236 | $node->field_url[]['value'] = $boincteam->url; |
237 | 237 | $node->field_country[]['value'] = $boincteam->country; |
238 | 238 | */ |
239 | 239 | |
240 | - $node->taxonomy[] = taxonomy_get_term($values['type']); |
|
240 | + $node->taxonomy[] = taxonomy_get_term($values['type']); |
|
241 | 241 | |
242 | - // Save the team node |
|
243 | - node_save($node); |
|
242 | + // Save the team node |
|
243 | + node_save($node); |
|
244 | 244 | |
245 | - // Save the team IDs to a BOINC <--> Drupal reference table. |
|
246 | - db_query('INSERT INTO {boincteam} (team_id, nid) VALUES (%d, %d)', $boinc_team->id, $node->nid); |
|
245 | + // Save the team IDs to a BOINC <--> Drupal reference table. |
|
246 | + db_query('INSERT INTO {boincteam} (team_id, nid) VALUES (%d, %d)', $boinc_team->id, $node->nid); |
|
247 | 247 | |
248 | - drupal_set_message(t('Team "@name" has been created.', |
|
248 | + drupal_set_message(t('Team "@name" has been created.', |
|
249 | 249 | array('@name' => $values['name']))); |
250 | 250 | |
251 | - $form_state['redirect'] = "community/teams/{$node->nid}"; |
|
251 | + $form_state['redirect'] = "community/teams/{$node->nid}"; |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -259,17 +259,17 @@ discard block |
||
259 | 259 | * The definition of the edit team form |
260 | 260 | */ |
261 | 261 | function boincteam_edit_form(&$form_state, $team_id) { |
262 | - $form = array(); |
|
262 | + $form = array(); |
|
263 | 263 | |
264 | - $team = node_load($team_id); |
|
265 | - $boincteam = boincteam_load(boincteam_lookup_id($team_id)); |
|
264 | + $team = node_load($team_id); |
|
265 | + $boincteam = boincteam_load(boincteam_lookup_id($team_id)); |
|
266 | 266 | |
267 | - $is_boinc_wide = ($boincteam->seti_id > 0) ? TRUE : FALSE; |
|
267 | + $is_boinc_wide = ($boincteam->seti_id > 0) ? TRUE : FALSE; |
|
268 | 268 | |
269 | - $form_state['storage']['team_id'] = $team_id; |
|
270 | - $form_state['storage']['is_boinc_wide'] = $is_boinc_wide; |
|
269 | + $form_state['storage']['team_id'] = $team_id; |
|
270 | + $form_state['storage']['is_boinc_wide'] = $is_boinc_wide; |
|
271 | 271 | |
272 | - $default = array( |
|
272 | + $default = array( |
|
273 | 273 | 'name' => $boincteam->name, |
274 | 274 | 'name_html' => $boincteam->name_html, |
275 | 275 | 'website' => $boincteam->url, |
@@ -277,79 +277,79 @@ discard block |
||
277 | 277 | 'country' => $boincteam->country, |
278 | 278 | 'joinable' => $boincteam->joinable, |
279 | 279 | 'description' => $boincteam->description, |
280 | - ); |
|
280 | + ); |
|
281 | 281 | |
282 | - // Standard option sets |
|
283 | - $form['boolean_options'] = array( |
|
282 | + // Standard option sets |
|
283 | + $form['boolean_options'] = array( |
|
284 | 284 | '#type' => 'value', |
285 | 285 | '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')), |
286 | - ); |
|
286 | + ); |
|
287 | 287 | |
288 | - // Vocabulary based option sets |
|
289 | - $form['type_options'] = array( |
|
288 | + // Vocabulary based option sets |
|
289 | + $form['type_options'] = array( |
|
290 | 290 | '#type' => 'value', |
291 | 291 | '#value' => array(0 => bts('Choose type', array(), NULL, 'boinc:form-choose')) |
292 | - ); |
|
293 | - $vocabs = taxonomy_get_vocabularies(NULL); |
|
294 | - foreach ($vocabs as $vocab) { |
|
292 | + ); |
|
293 | + $vocabs = taxonomy_get_vocabularies(NULL); |
|
294 | + foreach ($vocabs as $vocab) { |
|
295 | 295 | switch ($vocab->name) { |
296 | 296 | case 'Teams': |
297 | 297 | $team_types = taxonomy_get_tree($vocab->vid); |
298 | - if (module_exists('internationalization')) { |
|
298 | + if (module_exists('internationalization')) { |
|
299 | 299 | $team_types = i18ntaxonomy_localize_terms($team_types); |
300 | - } |
|
301 | - foreach ($team_types as $team_type) { |
|
300 | + } |
|
301 | + foreach ($team_types as $team_type) { |
|
302 | 302 | $form['type_options']['#value'][$team_type->tid] = $team_type->name; |
303 | - } |
|
304 | - break; |
|
303 | + } |
|
304 | + break; |
|
305 | 305 | default: |
306 | 306 | } |
307 | - } |
|
308 | - $form['country_options'] = array( |
|
307 | + } |
|
308 | + $form['country_options'] = array( |
|
309 | 309 | '#type' => 'value', |
310 | 310 | '#value' => boinccore_get_country_list(), |
311 | - ); |
|
311 | + ); |
|
312 | 312 | |
313 | - // Form elements |
|
314 | - $form['name'] = array( |
|
313 | + // Form elements |
|
314 | + $form['name'] = array( |
|
315 | 315 | '#title' => bts('Team name', array(), NULL, 'boinc:team-create/edit'), |
316 | 316 | '#type' => 'textfield', |
317 | 317 | '#default_value' => $default['name'], |
318 | 318 | '#size' => 34, |
319 | 319 | '#description' => bts('Text only, no HTML tags', array(), NULL, 'boinc:team-form-help'), |
320 | 320 | '#disabled' => $is_boinc_wide, |
321 | - ); |
|
322 | - $form['name_html'] = array( |
|
321 | + ); |
|
322 | + $form['name_html'] = array( |
|
323 | 323 | '#title' => bts('Team name -- HTML version (optional)', array(), NULL, 'boinc:team-create/edit'), |
324 | 324 | '#type' => 'textfield', |
325 | 325 | '#default_value' => $default['name_html'], |
326 | 326 | '#size' => 34, |
327 | 327 | '#description' => bts('You may use limited HTML tags', array(), NULL, 'boinc:team-form-help'), |
328 | 328 | '#disabled' => $is_boinc_wide, |
329 | - ); |
|
330 | - $form['website'] = array( |
|
329 | + ); |
|
330 | + $form['website'] = array( |
|
331 | 331 | '#title' => bts('Team website (optional)', array(), NULL, 'boinc:team-create/edit'), |
332 | 332 | '#type' => 'textfield', |
333 | 333 | '#default_value' => $default['website'], |
334 | 334 | '#size' => 34, |
335 | 335 | '#description' => bts("Displayed on the team's page", array(), NULL, 'boinc:team-create/edit'), |
336 | 336 | '#disabled' => $is_boinc_wide, |
337 | - ); |
|
338 | - $form['type'] = array( |
|
337 | + ); |
|
338 | + $form['type'] = array( |
|
339 | 339 | '#title' => bts('Type of team', array(), NULL, 'boinc:team-create/edit'), |
340 | 340 | '#type' => 'select', |
341 | 341 | '#options' => $form['type_options']['#value'], |
342 | 342 | '#default_value' => $default['type'], |
343 | 343 | '#disabled' => $is_boinc_wide, |
344 | - ); |
|
345 | - $form['country'] = array( |
|
344 | + ); |
|
345 | + $form['country'] = array( |
|
346 | 346 | '#title' => bts('Country', array(), NULL, 'boinc:country-of-origin'), |
347 | 347 | '#type' => 'select', |
348 | 348 | '#options' => $form['country_options']['#value'], |
349 | 349 | '#default_value' => $default['country'], |
350 | 350 | '#disabled' => $is_boinc_wide, |
351 | - ); |
|
352 | - $form['joinable'] = array( |
|
351 | + ); |
|
352 | + $form['joinable'] = array( |
|
353 | 353 | '#title' => bts('Accept new members?', array(), NULL, 'boinc:team-create/edit'), |
354 | 354 | '#type' => 'radios', |
355 | 355 | '#options' => $form['boolean_options']['#value'], |
@@ -357,49 +357,49 @@ discard block |
||
357 | 357 | '#default_value' => $default['joinable'], |
358 | 358 | '#size' => 34, |
359 | 359 | '#disabled' => $is_boinc_wide, |
360 | - ); |
|
361 | - if (!$is_boinc_wide) { |
|
360 | + ); |
|
361 | + if (!$is_boinc_wide) { |
|
362 | 362 | $form['description'] = array( |
363 | - '#title' => bts('Description of team', array(), NULL, 'boinc:team-create/edit'), |
|
364 | - '#type' => 'textarea', |
|
365 | - '#default_value' => $default['description'], |
|
366 | - '#size' => 5, |
|
367 | - '#description' => NULL, |
|
363 | + '#title' => bts('Description of team', array(), NULL, 'boinc:team-create/edit'), |
|
364 | + '#type' => 'textarea', |
|
365 | + '#default_value' => $default['description'], |
|
366 | + '#size' => 5, |
|
367 | + '#description' => NULL, |
|
368 | 368 | ); |
369 | 369 | $form['format'] = filter_form(); |
370 | 370 | |
371 | 371 | // Form control |
372 | 372 | $form['form control tabs prefix'] = array( |
373 | - '#value' => '<ul class="form-control tab-list">' |
|
373 | + '#value' => '<ul class="form-control tab-list">' |
|
374 | 374 | ); |
375 | 375 | $form['submit'] = array( |
376 | - '#prefix' => '<li class="first tab">', |
|
377 | - '#type' => 'submit', |
|
378 | - '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'), |
|
379 | - '#suffix' => '</li>', |
|
376 | + '#prefix' => '<li class="first tab">', |
|
377 | + '#type' => 'submit', |
|
378 | + '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'), |
|
379 | + '#suffix' => '</li>', |
|
380 | 380 | ); |
381 | 381 | $form['form control tabs'] = array( |
382 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), strstr($_GET['q'], '/edit', TRUE)) . '</li>' |
|
382 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), strstr($_GET['q'], '/edit', TRUE)) . '</li>' |
|
383 | 383 | ); |
384 | - } |
|
385 | - else { |
|
384 | + } |
|
385 | + else { |
|
386 | 386 | $form['description'] = array( |
387 | - '#prefix' => '<div class="form-item"><label>' . bts('Description', array(), NULL, 'boinc:team-description') . ':</label></div><div class="form-item">', |
|
388 | - '#value' => $default['description'], |
|
389 | - '#suffix' => '</div>', |
|
387 | + '#prefix' => '<div class="form-item"><label>' . bts('Description', array(), NULL, 'boinc:team-description') . ':</label></div><div class="form-item">', |
|
388 | + '#value' => $default['description'], |
|
389 | + '#suffix' => '</div>', |
|
390 | 390 | ); |
391 | 391 | drupal_set_message( |
392 | - bts('This is a BOINC-wide team. Changes can be made at the !site.', |
|
392 | + bts('This is a BOINC-wide team. Changes can be made at the !site.', |
|
393 | 393 | array('!site' => l(bts('BOINC-wide teams site', array(), NULL, 'boinc:link-to-BOINC-wide-teams-Website'), |
394 | - 'http://boinc.berkeley.edu/teams/' |
|
394 | + 'http://boinc.berkeley.edu/teams/' |
|
395 | 395 | )), |
396 | 396 | NULL, 'boinc:team-edit-warning-message'), |
397 | - 'warning'); |
|
398 | - } |
|
397 | + 'warning'); |
|
398 | + } |
|
399 | 399 | |
400 | - $form['#redirect'] = "community/teams/{$team_id}"; |
|
400 | + $form['#redirect'] = "community/teams/{$team_id}"; |
|
401 | 401 | |
402 | - return $form; |
|
402 | + return $form; |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | /** |
@@ -407,32 +407,32 @@ discard block |
||
407 | 407 | */ |
408 | 408 | function boincteam_edit_form_validate($form, &$form_state) { |
409 | 409 | |
410 | - $values = $form_state['values']; |
|
411 | - $name = $values['name']; |
|
410 | + $values = $form_state['values']; |
|
411 | + $name = $values['name']; |
|
412 | 412 | |
413 | - if ($form_state['storage']['is_boinc_wide']) { |
|
413 | + if ($form_state['storage']['is_boinc_wide']) { |
|
414 | 414 | form_set_error('none', bts('This team is managed by the BOINC-wide teams system and cannot be updated here.', array(), NULL, 'boinc:team-create/edit')); |
415 | - } |
|
416 | - else { |
|
415 | + } |
|
416 | + else { |
|
417 | 417 | if (!$name) { |
418 | - form_set_error('name', bts('Team name is required.', array(), NULL, 'boinc:team-create/edit')); |
|
418 | + form_set_error('name', bts('Team name is required.', array(), NULL, 'boinc:team-create/edit')); |
|
419 | 419 | } |
420 | 420 | else { |
421 | - $team = node_load($form_state['storage']['team_id']); |
|
422 | - if ($name != $team->title) { |
|
421 | + $team = node_load($form_state['storage']['team_id']); |
|
422 | + if ($name != $team->title) { |
|
423 | 423 | // If changing the name ("title" in Drupal terms), check that the new name is available |
424 | 424 | require_boinc('boinc_db'); |
425 | 425 | if (BoincTeam::lookup_name($name)) { |
426 | - form_set_error('name', bts('A team named "@name" already exists.', |
|
426 | + form_set_error('name', bts('A team named "@name" already exists.', |
|
427 | 427 | array('@name' => $name), NULL, 'boinc:team-create/edit')); |
428 | 428 | } |
429 | - } |
|
429 | + } |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | if (!$values['type'] OR !isset($values['type_options'][$values['type']])) { |
433 | - form_set_error('type', bts('Please select a team type.', array(), NULL, 'boinc:team-create/edit')); |
|
433 | + form_set_error('type', bts('Please select a team type.', array(), NULL, 'boinc:team-create/edit')); |
|
434 | + } |
|
434 | 435 | } |
435 | - } |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | /** |
@@ -440,18 +440,18 @@ discard block |
||
440 | 440 | */ |
441 | 441 | function boincteam_edit_form_submit($form, &$form_state) { |
442 | 442 | |
443 | - $team_id = $form_state['storage']['team_id']; |
|
444 | - $values = $form_state['values']; |
|
443 | + $team_id = $form_state['storage']['team_id']; |
|
444 | + $values = $form_state['values']; |
|
445 | 445 | |
446 | - $team = node_load($team_id); |
|
447 | - $boincteam_id = boincteam_lookup_id($team_id); |
|
446 | + $team = node_load($team_id); |
|
447 | + $boincteam_id = boincteam_lookup_id($team_id); |
|
448 | 448 | |
449 | - $input_format = !empty($values['format']) ? $values['format'] : 4; |
|
450 | - $values['description'] = check_markup($values['description'], $input_format); |
|
449 | + $input_format = !empty($values['format']) ? $values['format'] : 4; |
|
450 | + $values['description'] = check_markup($values['description'], $input_format); |
|
451 | 451 | |
452 | - // Update the team in the BOINC db |
|
453 | - db_set_active('boinc_rw'); |
|
454 | - db_query(" |
|
452 | + // Update the team in the BOINC db |
|
453 | + db_set_active('boinc_rw'); |
|
454 | + db_query(" |
|
455 | 455 | UPDATE {team} SET |
456 | 456 | name = '%s', |
457 | 457 | name_lc = '%s', |
@@ -471,32 +471,32 @@ discard block |
||
471 | 471 | $values['country'], |
472 | 472 | $values['joinable'], |
473 | 473 | $boincteam_id |
474 | - ); |
|
475 | - db_set_active('default'); |
|
474 | + ); |
|
475 | + db_set_active('default'); |
|
476 | 476 | |
477 | - // Update the team node in Drupal |
|
477 | + // Update the team node in Drupal |
|
478 | 478 | |
479 | - $team->title = $values['name']; |
|
480 | - $team->body = $values['description']; |
|
481 | - $team->teaser = node_teaser($values['description']); |
|
479 | + $team->title = $values['name']; |
|
480 | + $team->body = $values['description']; |
|
481 | + $team->teaser = node_teaser($values['description']); |
|
482 | 482 | |
483 | - /* |
|
483 | + /* |
|
484 | 484 | $node->field_description[]['value'] = $boincteam->description; |
485 | 485 | $node->field_url[]['value'] = $boincteam->url; |
486 | 486 | $node->field_country[]['value'] = $boincteam->country; |
487 | 487 | */ |
488 | 488 | |
489 | - // Replace any existing taxonomy with the new one |
|
490 | - $team->taxonomy = array(taxonomy_get_term($values['type'])); |
|
489 | + // Replace any existing taxonomy with the new one |
|
490 | + $team->taxonomy = array(taxonomy_get_term($values['type'])); |
|
491 | 491 | |
492 | - // Save the team node |
|
493 | - node_save($team); |
|
492 | + // Save the team node |
|
493 | + node_save($team); |
|
494 | 494 | |
495 | - drupal_set_message(t('Details for "@team" have been updated.', |
|
495 | + drupal_set_message(t('Details for "@team" have been updated.', |
|
496 | 496 | array('@team' => $values['name']))); |
497 | 497 | |
498 | - // The storage variable quietly kills redirection for some reason... unset it |
|
499 | - unset($form_state['storage']); |
|
498 | + // The storage variable quietly kills redirection for some reason... unset it |
|
499 | + unset($form_state['storage']); |
|
500 | 500 | } |
501 | 501 | |
502 | 502 | |
@@ -508,44 +508,44 @@ discard block |
||
508 | 508 | * The definition of the add team admin form |
509 | 509 | */ |
510 | 510 | function boincteam_add_admin_form(&$form_state, $team_id) { |
511 | - $form = array(); |
|
511 | + $form = array(); |
|
512 | 512 | |
513 | - $team = node_load($team_id); |
|
514 | - $boincteam = boincteam_load(boincteam_lookup_id($team_id)); |
|
513 | + $team = node_load($team_id); |
|
514 | + $boincteam = boincteam_load(boincteam_lookup_id($team_id)); |
|
515 | 515 | |
516 | - $form_state['storage']['team_id'] = $team_id; |
|
516 | + $form_state['storage']['team_id'] = $team_id; |
|
517 | 517 | |
518 | - $default = array( |
|
518 | + $default = array( |
|
519 | 519 | 'username' => '', |
520 | - ); |
|
520 | + ); |
|
521 | 521 | |
522 | - // Form elements |
|
523 | - $form['username'] = array( |
|
522 | + // Form elements |
|
523 | + $form['username'] = array( |
|
524 | 524 | '#title' => bts('Enter BOINC username', array(), NULL, 'boinc:team--add-admin'), |
525 | 525 | '#description' => bts('The number appearing in the suffix is the BOINC id. You can find a user\'s BOINC id on their user profile page.'), |
526 | 526 | '#type' => 'textfield', |
527 | 527 | '#default_value' => $default['username'], |
528 | 528 | '#size' => 34, |
529 | 529 | '#autocomplete_path' => "community/teams/${team_id}/user-name-autocomplete", |
530 | - ); |
|
530 | + ); |
|
531 | 531 | |
532 | - // Form control |
|
533 | - $form['form control tabs prefix'] = array( |
|
532 | + // Form control |
|
533 | + $form['form control tabs prefix'] = array( |
|
534 | 534 | '#value' => '<ul class="form-control tab-list">' |
535 | - ); |
|
536 | - $form['submit'] = array( |
|
535 | + ); |
|
536 | + $form['submit'] = array( |
|
537 | 537 | '#prefix' => '<li class="first tab">', |
538 | 538 | '#type' => 'submit', |
539 | 539 | '#value' => bts('Add', array(), NULL, 'boinc:form-add'), |
540 | 540 | '#suffix' => '</li>', |
541 | - ); |
|
542 | - $form['form control tabs'] = array( |
|
541 | + ); |
|
542 | + $form['form control tabs'] = array( |
|
543 | 543 | '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), strstr($_GET['q'], '/edit', TRUE)) . '</li>' |
544 | - ); |
|
544 | + ); |
|
545 | 545 | |
546 | - //$form['#redirect'] = "community/teams/{$team_id}"; |
|
546 | + //$form['#redirect'] = "community/teams/{$team_id}"; |
|
547 | 547 | |
548 | - return $form; |
|
548 | + return $form; |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | /** |
@@ -553,45 +553,45 @@ discard block |
||
553 | 553 | */ |
554 | 554 | function boincteam_add_admin_form_validate($form, &$form_state) { |
555 | 555 | |
556 | - $team_id = $form_state['storage']['team_id']; |
|
557 | - $values = $form_state['values']; |
|
558 | - $team = node_load($team_id); |
|
556 | + $team_id = $form_state['storage']['team_id']; |
|
557 | + $values = $form_state['values']; |
|
558 | + $team = node_load($team_id); |
|
559 | 559 | |
560 | - if (!$values['username']) { |
|
560 | + if (!$values['username']) { |
|
561 | 561 | form_set_error('username', bts('BOINC username is required.', array(), NULL, 'boinc:team-add-admin')); |
562 | - } |
|
563 | - else { |
|
562 | + } |
|
563 | + else { |
|
564 | 564 | // Load user account associated with username |
565 | 565 | $account = boincuser_privatemsg_name_lookup($values['username']); |
566 | 566 | // Validate the account |
567 | 567 | if ((!$account) OR ($account->team != $team_id)) { |
568 | - form_set_error('username', bts('There is no user on your team with name @username.', |
|
568 | + form_set_error('username', bts('There is no user on your team with name @username.', |
|
569 | 569 | array( |
570 | - '@username' => $account->boincuser_name |
|
570 | + '@username' => $account->boincuser_name |
|
571 | 571 | ), |
572 | - NULL, 'boinc:team-add-admin')); |
|
572 | + NULL, 'boinc:team-add-admin')); |
|
573 | 573 | } |
574 | 574 | elseif (boincteam_is_founder($team_id, $account->uid)) { |
575 | - form_set_error('username', bts('@user is the founder of @team! Team founder already have all admin privileges.', |
|
575 | + form_set_error('username', bts('@user is the founder of @team! Team founder already have all admin privileges.', |
|
576 | 576 | array( |
577 | - '@user' => $account->boincuser_name, |
|
578 | - '@team' => $team->title, |
|
577 | + '@user' => $account->boincuser_name, |
|
578 | + '@team' => $team->title, |
|
579 | 579 | ), |
580 | 580 | NULL, 'boinc:team-add-admin')); |
581 | 581 | } |
582 | 582 | elseif (boincteam_is_admin($team_id, $account->uid)) { |
583 | - form_set_error('username', bts('@user is already an admin of @team.', |
|
583 | + form_set_error('username', bts('@user is already an admin of @team.', |
|
584 | 584 | array( |
585 | - '@user' => $account->boincuser_name, |
|
586 | - '@team' => $team->title, |
|
585 | + '@user' => $account->boincuser_name, |
|
586 | + '@team' => $team->title, |
|
587 | 587 | ), |
588 | 588 | NULL, 'boinc:team-add-admin')); |
589 | 589 | } |
590 | 590 | else { |
591 | - $form_state['storage']['boincuser_id'] = $account->boincuser_id; |
|
592 | - $form_state['storage']['boincuser_name'] = $account->boincuser_name; |
|
591 | + $form_state['storage']['boincuser_id'] = $account->boincuser_id; |
|
592 | + $form_state['storage']['boincuser_name'] = $account->boincuser_name; |
|
593 | + } |
|
593 | 594 | } |
594 | - } |
|
595 | 595 | } |
596 | 596 | |
597 | 597 | /** |
@@ -599,17 +599,17 @@ discard block |
||
599 | 599 | */ |
600 | 600 | function boincteam_add_admin_form_submit($form, &$form_state) { |
601 | 601 | |
602 | - $team_id = $form_state['storage']['team_id']; |
|
603 | - $boincuser_id = $form_state['storage']['boincuser_id']; |
|
604 | - $user_name = $form_state['storage']['boincuser_name']; |
|
605 | - $values = $form_state['values']; |
|
602 | + $team_id = $form_state['storage']['team_id']; |
|
603 | + $boincuser_id = $form_state['storage']['boincuser_id']; |
|
604 | + $user_name = $form_state['storage']['boincuser_name']; |
|
605 | + $values = $form_state['values']; |
|
606 | 606 | |
607 | - $team = node_load($team_id); |
|
608 | - $boincteam_id = boincteam_lookup_id($team_id); |
|
607 | + $team = node_load($team_id); |
|
608 | + $boincteam_id = boincteam_lookup_id($team_id); |
|
609 | 609 | |
610 | - // Update the team in the BOINC db |
|
611 | - db_set_active('boinc_rw'); |
|
612 | - db_query(" |
|
610 | + // Update the team in the BOINC db |
|
611 | + db_set_active('boinc_rw'); |
|
612 | + db_query(" |
|
613 | 613 | INSERT INTO {team_admin} SET |
614 | 614 | teamid = '%d', |
615 | 615 | userid = '%d', |
@@ -617,17 +617,17 @@ discard block |
||
617 | 617 | $boincteam_id, |
618 | 618 | $boincuser_id, |
619 | 619 | time() |
620 | - ); |
|
621 | - db_set_active('default'); |
|
620 | + ); |
|
621 | + db_set_active('default'); |
|
622 | 622 | |
623 | - // Could assign a role in Drupal here, as needed |
|
623 | + // Could assign a role in Drupal here, as needed |
|
624 | 624 | |
625 | 625 | |
626 | - drupal_set_message(t('@user has been added as an admin.', |
|
626 | + drupal_set_message(t('@user has been added as an admin.', |
|
627 | 627 | array('@user' => $user_name))); |
628 | 628 | |
629 | - // The storage variable quietly kills redirection for some reason... unset it |
|
630 | - unset($form_state['storage']); |
|
629 | + // The storage variable quietly kills redirection for some reason... unset it |
|
630 | + unset($form_state['storage']); |
|
631 | 631 | } |
632 | 632 | |
633 | 633 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -639,80 +639,80 @@ discard block |
||
639 | 639 | * Send all team members an email message function |
640 | 640 | */ |
641 | 641 | function boincteam_sendmessagetoteam(&$form_state, $team_id) { |
642 | - global $user; |
|
643 | - $form = array(); |
|
642 | + global $user; |
|
643 | + $form = array(); |
|
644 | 644 | |
645 | - if (isset($form_state['values'])) { |
|
645 | + if (isset($form_state['values'])) { |
|
646 | 646 | $subject = $form_state['values']['subject']; |
647 | 647 | $body = $form_state['values']['body']; |
648 | - } |
|
649 | - else { |
|
648 | + } |
|
649 | + else { |
|
650 | 650 | $subject = ''; |
651 | 651 | $body = ''; |
652 | - } |
|
652 | + } |
|
653 | 653 | |
654 | - // Title |
|
655 | - $mytitle = bts('Send E-mail To All Team Members', array(), NULL, 'boinc:team-message-form'); |
|
656 | - drupal_set_title($mytitle); |
|
654 | + // Title |
|
655 | + $mytitle = bts('Send E-mail To All Team Members', array(), NULL, 'boinc:team-message-form'); |
|
656 | + drupal_set_title($mytitle); |
|
657 | 657 | |
658 | - $form['emailteam']['header'] = array( |
|
658 | + $form['emailteam']['header'] = array( |
|
659 | 659 | '#value' => '<h1>' . $mytitle . '</h1>', |
660 | 660 | '#weight' => '-10', |
661 | 661 | '#prefix' => "<div id='sendmessageteammembers-header'>", |
662 | 662 | '#suffix' => "</div>", |
663 | - ); |
|
663 | + ); |
|
664 | 664 | |
665 | - $form['emailteam']['instructions'] = array( |
|
665 | + $form['emailteam']['instructions'] = array( |
|
666 | 666 | '#value' => bts('This will send an email to all team members. If a team member has opt-ed out of notification e-mails, they will not receive your message. At the bottom of your message, there will be a link allowing team members to send you a Direct Message. This link is added automatically, you do not need to add it below in the Message box. Your email address will not be shown to the recipients.', array(), NULL, 'boinc:team-message-form'), |
667 | 667 | '#weight' => '-8', |
668 | 668 | '#prefix' => "<div id='sendmessageteammembers-instructions'>", |
669 | 669 | '#suffix' => "</div>", |
670 | - ); |
|
670 | + ); |
|
671 | 671 | |
672 | - // Subject |
|
673 | - $form['emailteam']['subject'] = array( |
|
672 | + // Subject |
|
673 | + $form['emailteam']['subject'] = array( |
|
674 | 674 | '#type' => 'textfield', |
675 | 675 | '#title' => bts('Subject', array(), NULL, 'boinc:team-message-form'), |
676 | 676 | '#size' => 50, |
677 | 677 | '#maxlength' => 255, |
678 | 678 | '#default_value' => $subject, |
679 | 679 | '#weight' => -5, |
680 | - ); |
|
680 | + ); |
|
681 | 681 | |
682 | - // Body |
|
683 | - $form['emailteam']['body'] = array( |
|
682 | + // Body |
|
683 | + $form['emailteam']['body'] = array( |
|
684 | 684 | '#type' => 'textarea', |
685 | 685 | '#title' => bts('Message', array(), NULL, 'boinc:team-message-form'), |
686 | 686 | '#rows' => 8, |
687 | 687 | '#weight' => 0, |
688 | 688 | '#default_value' => $body, |
689 | 689 | '#resizable' => TRUE, |
690 | - ); |
|
690 | + ); |
|
691 | 691 | |
692 | - // checkbox for 'sent to self' |
|
693 | - $form['emailteam']['selfsend'] = array( |
|
692 | + // checkbox for 'sent to self' |
|
693 | + $form['emailteam']['selfsend'] = array( |
|
694 | 694 | '#type' => 'checkbox', |
695 | 695 | '#title' => bts('Check this box if you wish to be sent a copy of your message to your email address.', array(), NULL, 'boinc:team-message-form'), |
696 | 696 | '#weight' => 10, |
697 | 697 | '#prefix' => '<div class="clearfix" id="confirm-checkbox">', |
698 | 698 | '#suffix' => '</div>', |
699 | - ); |
|
699 | + ); |
|
700 | 700 | |
701 | - // Add a captcha to form |
|
702 | - if (module_exists('captcha')) { |
|
701 | + // Add a captcha to form |
|
702 | + if (module_exists('captcha')) { |
|
703 | 703 | $form['register_captcha'] = array( |
704 | 704 | '#type' => 'captcha', |
705 | 705 | '#weight' => 1000, |
706 | 706 | ); |
707 | - } |
|
707 | + } |
|
708 | 708 | |
709 | - // form buttons |
|
710 | - $form['emailteam']['form control tabs prefix'] = array( |
|
709 | + // form buttons |
|
710 | + $form['emailteam']['form control tabs prefix'] = array( |
|
711 | 711 | '#value' => '<ul class="form-control tab-list">', |
712 | 712 | '#weight' => 1000, |
713 | - ); |
|
713 | + ); |
|
714 | 714 | |
715 | - $form['emailteam']['submit'] = array( |
|
715 | + $form['emailteam']['submit'] = array( |
|
716 | 716 | '#type' => 'submit', |
717 | 717 | '#value' => bts('Send message', array(), NULL, 'boinc:form-submit'), |
718 | 718 | '#submit' => array('boincteam_sendmessagetoteam_submit'), |
@@ -720,130 +720,130 @@ discard block |
||
720 | 720 | '#weight' => 1001, |
721 | 721 | '#prefix' => '<li class="first tab">', |
722 | 722 | '#suffix' => '</li>' |
723 | - ); |
|
723 | + ); |
|
724 | 724 | |
725 | - $title = bts('Cancel', array(), NULL, 'boinc:form-cancel'); |
|
726 | - $url = "community/teams/{$team_id}"; |
|
727 | - $form['emailteam']['cancel'] = array( |
|
725 | + $title = bts('Cancel', array(), NULL, 'boinc:form-cancel'); |
|
726 | + $url = "community/teams/{$team_id}"; |
|
727 | + $form['emailteam']['cancel'] = array( |
|
728 | 728 | '#value' => l($title, $url, array('attributes' => array('id' => 'edit-cancel'))), |
729 | 729 | '#weight' => 1005, |
730 | 730 | '#prefix' => '<li class="tab">', |
731 | 731 | '#suffix' => '</li>' |
732 | - ); |
|
732 | + ); |
|
733 | 733 | |
734 | - $form['emailteam']['form control tabs suffix'] = array( |
|
734 | + $form['emailteam']['form control tabs suffix'] = array( |
|
735 | 735 | '#value' => '</ul>', |
736 | 736 | '#weight' => 1010, |
737 | - ); |
|
737 | + ); |
|
738 | 738 | |
739 | - // Add team id information to form_state |
|
740 | - $form['_team_id'] = array( |
|
739 | + // Add team id information to form_state |
|
740 | + $form['_team_id'] = array( |
|
741 | 741 | '#type' => 'value', |
742 | 742 | '#value' => $team_id, |
743 | - ); |
|
743 | + ); |
|
744 | 744 | |
745 | - // Add sender user object to form_state |
|
746 | - $form['_senderuid'] = array( |
|
745 | + // Add sender user object to form_state |
|
746 | + $form['_senderuid'] = array( |
|
747 | 747 | '#type' => 'value', |
748 | 748 | '#value' => $user->uid, |
749 | - ); |
|
749 | + ); |
|
750 | 750 | |
751 | - // redirect after sending message |
|
752 | - $form['#redirect'] = "community/teams/{$team_id}"; |
|
751 | + // redirect after sending message |
|
752 | + $form['#redirect'] = "community/teams/{$team_id}"; |
|
753 | 753 | |
754 | - return $form; |
|
754 | + return $form; |
|
755 | 755 | } |
756 | 756 | |
757 | 757 | /** |
758 | 758 | * Send all team members validation handler |
759 | 759 | */ |
760 | 760 | function boincteam_sendmessagetoteam_validate($form, &$form_state) { |
761 | - $message = $form_state['values']; |
|
762 | - $message['timestamp'] = time(); |
|
763 | - // Avoid subjects which only consist of a space as these can not be clicked. |
|
764 | - $message['subject'] = trim($message['subject']); |
|
761 | + $message = $form_state['values']; |
|
762 | + $message['timestamp'] = time(); |
|
763 | + // Avoid subjects which only consist of a space as these can not be clicked. |
|
764 | + $message['subject'] = trim($message['subject']); |
|
765 | 765 | |
766 | - $trimed_body = trim(truncate_utf8(strip_tags($message['body']), 50, TRUE, TRUE)); |
|
767 | - if (empty($message['subject']) && !empty($trimed_body)) { |
|
766 | + $trimed_body = trim(truncate_utf8(strip_tags($message['body']), 50, TRUE, TRUE)); |
|
767 | + if (empty($message['subject']) && !empty($trimed_body)) { |
|
768 | 768 | $message['subject'] = $trimed_body; |
769 | 769 | $form_state['values']['subject'] = $message['subject']; |
770 | - } |
|
770 | + } |
|
771 | 771 | |
772 | - // Check subject line |
|
773 | - $message['subject'] = trim($message['subject']); |
|
774 | - if (empty($message['subject'])) { |
|
772 | + // Check subject line |
|
773 | + $message['subject'] = trim($message['subject']); |
|
774 | + if (empty($message['subject'])) { |
|
775 | 775 | form_set_error('subject', |
776 | - bts('Not allowed to send a message without subject', array(), NULL, 'boinc:team-message-form') |
|
776 | + bts('Not allowed to send a message without subject', array(), NULL, 'boinc:team-message-form') |
|
777 | 777 | ); |
778 | - } |
|
778 | + } |
|
779 | 779 | |
780 | - // Check body |
|
781 | - if ( ($message['body'] === NULL || $message['body'] === '') ) { |
|
780 | + // Check body |
|
781 | + if ( ($message['body'] === NULL || $message['body'] === '') ) { |
|
782 | 782 | form_set_error('body', |
783 | - bts('Not allowed to send an empty message.', array(), NULL, 'boinc:team-message-form') |
|
783 | + bts('Not allowed to send an empty message.', array(), NULL, 'boinc:team-message-form') |
|
784 | 784 | ); |
785 | - } |
|
785 | + } |
|
786 | 786 | |
787 | - // Check team id |
|
788 | - if (empty($message['_team_id'])) { |
|
787 | + // Check team id |
|
788 | + if (empty($message['_team_id'])) { |
|
789 | 789 | form_set_error('team_id', |
790 | - bts('Error, no team_id supplied.', array(), NULL, 'boinc:team-message-form') |
|
790 | + bts('Error, no team_id supplied.', array(), NULL, 'boinc:team-message-form') |
|
791 | 791 | ); |
792 | - } |
|
792 | + } |
|
793 | 793 | |
794 | - $form_state['validated_built_message'] = $message; |
|
794 | + $form_state['validated_built_message'] = $message; |
|
795 | 795 | } |
796 | 796 | |
797 | 797 | /** |
798 | 798 | * Send all team members submit handler |
799 | 799 | */ |
800 | 800 | function boincteam_sendmessagetoteam_submit($form, &$form_state) { |
801 | - module_load_include('inc', 'rules', 'modules/system.rules'); |
|
802 | - global $base_url; |
|
803 | - global $base_path; |
|
804 | - |
|
805 | - $suid = $form_state['values']['_senderuid']; |
|
806 | - $account = user_load(array('uid' => $suid )); |
|
807 | - $site_url = $base_url . $base_path . "messages/new/" . $suid; |
|
808 | - |
|
809 | - // Form is validated, now send to all team members. Lookup boinc |
|
810 | - // id of all team members, and then use user_load() to load user |
|
811 | - // object. Send message using email. |
|
812 | - // |
|
813 | - $boinc_id = boincteam_lookup_id($form_state['values']['_team_id']); |
|
814 | - // Email addresses, with those who have opt-ed out of notification |
|
815 | - // emails removed. |
|
816 | - $member_emails = _boincteam_emails($boinc_id); |
|
817 | - // Remove sender's email address, unless selfsend is true. |
|
818 | - if ( !$form_state['values']['selfsend'] ) { |
|
801 | + module_load_include('inc', 'rules', 'modules/system.rules'); |
|
802 | + global $base_url; |
|
803 | + global $base_path; |
|
804 | + |
|
805 | + $suid = $form_state['values']['_senderuid']; |
|
806 | + $account = user_load(array('uid' => $suid )); |
|
807 | + $site_url = $base_url . $base_path . "messages/new/" . $suid; |
|
808 | + |
|
809 | + // Form is validated, now send to all team members. Lookup boinc |
|
810 | + // id of all team members, and then use user_load() to load user |
|
811 | + // object. Send message using email. |
|
812 | + // |
|
813 | + $boinc_id = boincteam_lookup_id($form_state['values']['_team_id']); |
|
814 | + // Email addresses, with those who have opt-ed out of notification |
|
815 | + // emails removed. |
|
816 | + $member_emails = _boincteam_emails($boinc_id); |
|
817 | + // Remove sender's email address, unless selfsend is true. |
|
818 | + if ( !$form_state['values']['selfsend'] ) { |
|
819 | 819 | $pos = array_search($account->mail, $member_emails); |
820 | 820 | unset($member_emails[$pos]); |
821 | - } |
|
821 | + } |
|
822 | 822 | |
823 | - // Add link at bottom of body |
|
824 | - $mybody = $form_state['validated_built_message']['body']; |
|
825 | - $mybody .= "\n\n" |
|
826 | - . "To reply to the sender using a Direct Message (DM), please use this link:\n" |
|
827 | - . "${site_url}"; |
|
823 | + // Add link at bottom of body |
|
824 | + $mybody = $form_state['validated_built_message']['body']; |
|
825 | + $mybody .= "\n\n" |
|
826 | + . "To reply to the sender using a Direct Message (DM), please use this link:\n" |
|
827 | + . "${site_url}"; |
|
828 | 828 | |
829 | - $emailsettings = array( |
|
829 | + $emailsettings = array( |
|
830 | 830 | 'from' => '', |
831 | 831 | 'to' => "webmaster@{$base_url}", |
832 | 832 | 'boincteam_headers' => array( |
833 | - 'Bcc' => implode(',', $member_emails), |
|
833 | + 'Bcc' => implode(',', $member_emails), |
|
834 | 834 | ), |
835 | 835 | 'subject' => $form_state['validated_built_message']['subject'], |
836 | 836 | 'message' => $mybody, |
837 | - ); |
|
838 | - rules_action_mail($emailsettings); |
|
837 | + ); |
|
838 | + rules_action_mail($emailsettings); |
|
839 | 839 | |
840 | - $om = bts( |
|
840 | + $om = bts( |
|
841 | 841 | 'Sent your email message to !number team members.', |
842 | 842 | array( '!number' => count($member_emails) ), |
843 | 843 | 'NULL', |
844 | 844 | 'boinc:team-message-sent' |
845 | - ); |
|
846 | - drupal_set_message($om, 'info'); |
|
845 | + ); |
|
846 | + drupal_set_message($om, 'info'); |
|
847 | 847 | |
848 | - $form_state['redirect'] = "community/teams/{$form_state['values']['_team_id']}"; |
|
848 | + $form_state['redirect'] = "community/teams/{$form_state['values']['_team_id']}"; |
|
849 | 849 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | '#suffix' => '</li>', |
120 | 120 | ); |
121 | 121 | $form['form control tabs'] = array( |
122 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>' |
|
122 | + '#value' => '<li class="tab">'.l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']).'</li>' |
|
123 | 123 | ); |
124 | 124 | |
125 | 125 | return $form; |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | |
164 | 164 | // Create the team in the BOINC db |
165 | 165 | |
166 | - require_boinc(array('user','team')); |
|
166 | + require_boinc(array('user', 'team')); |
|
167 | 167 | $boinc_team = make_team( |
168 | 168 | $account->boincuser_id, |
169 | 169 | $values['name'], |
@@ -199,10 +199,10 @@ discard block |
||
199 | 199 | 'teaser' => $teaser, |
200 | 200 | 'uid' => $user->uid, |
201 | 201 | 'path' => null, |
202 | - 'status' => 1, // published or not - always publish |
|
202 | + 'status' => 1, // published or not - always publish |
|
203 | 203 | 'promote' => 0, |
204 | 204 | 'created' => $created_time, |
205 | - 'comment' => 0, // comments disabled |
|
205 | + 'comment' => 0, // comments disabled |
|
206 | 206 | 'moderate' => 0, |
207 | 207 | 'sticky' => 0, |
208 | 208 | 'format' => $input_format |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | $node['og_private'] = 0; |
230 | 230 | */ |
231 | 231 | |
232 | - $node = (object) $node; // node_save requires an object form |
|
232 | + $node = (object)$node; // node_save requires an object form |
|
233 | 233 | |
234 | 234 | /* |
235 | 235 | $node->field_description[]['value'] = $boincteam->description; |
@@ -379,12 +379,12 @@ discard block |
||
379 | 379 | '#suffix' => '</li>', |
380 | 380 | ); |
381 | 381 | $form['form control tabs'] = array( |
382 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), strstr($_GET['q'], '/edit', TRUE)) . '</li>' |
|
382 | + '#value' => '<li class="tab">'.l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), strstr($_GET['q'], '/edit', TRUE)).'</li>' |
|
383 | 383 | ); |
384 | 384 | } |
385 | 385 | else { |
386 | 386 | $form['description'] = array( |
387 | - '#prefix' => '<div class="form-item"><label>' . bts('Description', array(), NULL, 'boinc:team-description') . ':</label></div><div class="form-item">', |
|
387 | + '#prefix' => '<div class="form-item"><label>'.bts('Description', array(), NULL, 'boinc:team-description').':</label></div><div class="form-item">', |
|
388 | 388 | '#value' => $default['description'], |
389 | 389 | '#suffix' => '</div>', |
390 | 390 | ); |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | '#suffix' => '</li>', |
541 | 541 | ); |
542 | 542 | $form['form control tabs'] = array( |
543 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), strstr($_GET['q'], '/edit', TRUE)) . '</li>' |
|
543 | + '#value' => '<li class="tab">'.l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), strstr($_GET['q'], '/edit', TRUE)).'</li>' |
|
544 | 544 | ); |
545 | 545 | |
546 | 546 | //$form['#redirect'] = "community/teams/{$team_id}"; |
@@ -656,7 +656,7 @@ discard block |
||
656 | 656 | drupal_set_title($mytitle); |
657 | 657 | |
658 | 658 | $form['emailteam']['header'] = array( |
659 | - '#value' => '<h1>' . $mytitle . '</h1>', |
|
659 | + '#value' => '<h1>'.$mytitle.'</h1>', |
|
660 | 660 | '#weight' => '-10', |
661 | 661 | '#prefix' => "<div id='sendmessageteammembers-header'>", |
662 | 662 | '#suffix' => "</div>", |
@@ -778,7 +778,7 @@ discard block |
||
778 | 778 | } |
779 | 779 | |
780 | 780 | // Check body |
781 | - if ( ($message['body'] === NULL || $message['body'] === '') ) { |
|
781 | + if (($message['body'] === NULL || $message['body'] === '')) { |
|
782 | 782 | form_set_error('body', |
783 | 783 | bts('Not allowed to send an empty message.', array(), NULL, 'boinc:team-message-form') |
784 | 784 | ); |
@@ -803,8 +803,8 @@ discard block |
||
803 | 803 | global $base_path; |
804 | 804 | |
805 | 805 | $suid = $form_state['values']['_senderuid']; |
806 | - $account = user_load(array('uid' => $suid )); |
|
807 | - $site_url = $base_url . $base_path . "messages/new/" . $suid; |
|
806 | + $account = user_load(array('uid' => $suid)); |
|
807 | + $site_url = $base_url.$base_path."messages/new/".$suid; |
|
808 | 808 | |
809 | 809 | // Form is validated, now send to all team members. Lookup boinc |
810 | 810 | // id of all team members, and then use user_load() to load user |
@@ -815,7 +815,7 @@ discard block |
||
815 | 815 | // emails removed. |
816 | 816 | $member_emails = _boincteam_emails($boinc_id); |
817 | 817 | // Remove sender's email address, unless selfsend is true. |
818 | - if ( !$form_state['values']['selfsend'] ) { |
|
818 | + if (!$form_state['values']['selfsend']) { |
|
819 | 819 | $pos = array_search($account->mail, $member_emails); |
820 | 820 | unset($member_emails[$pos]); |
821 | 821 | } |
@@ -839,7 +839,7 @@ discard block |
||
839 | 839 | |
840 | 840 | $om = bts( |
841 | 841 | 'Sent your email message to !number team members.', |
842 | - array( '!number' => count($member_emails) ), |
|
842 | + array('!number' => count($member_emails)), |
|
843 | 843 | 'NULL', |
844 | 844 | 'boinc:team-message-sent' |
845 | 845 | ); |