Passed
Push — master ( 8ae81c...db94a5 )
by Kevin
11:44 queued 03:12
created
html/user/submit_rpc_handler.php 1 patch
Switch Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1049,24 +1049,24 @@
 block discarded – undo
1049 1049
 log_write("----- Handling RPC; command ".$r->getName());
1050 1050
 
1051 1051
 switch ($r->getName()) {
1052
-    case 'abort_batch': handle_abort_batch($r); break;
1053
-    case 'abort_jobs': handle_abort_jobs($r); break;
1054
-    case 'create_batch': create_batch($r); break;
1055
-    case 'estimate_batch': estimate_batch($r); break;
1056
-    case 'get_templates': get_templates($r); break;
1057
-    case 'ping': ping($r); break;
1058
-    case 'query_batch': query_batch($r); break;
1059
-    case 'query_batch2': query_batch2($r); break;
1060
-    case 'query_batches': query_batches($r); break;
1061
-    case 'query_job': query_job($r); break;
1062
-    case 'query_completed_job': query_completed_job($r); break;
1063
-    case 'retire_batch': handle_retire_batch($r); break;
1064
-    case 'set_expire_time': handle_set_expire_time($r); break;
1065
-    case 'submit_batch': submit_batch($r); break;
1066
-    default:
1067
-        log_write("bad command");
1068
-        xml_error(-1, "bad command: ".$r->getName());
1069
-        break;
1052
+case 'abort_batch': handle_abort_batch($r); break;
1053
+case 'abort_jobs': handle_abort_jobs($r); break;
1054
+case 'create_batch': create_batch($r); break;
1055
+case 'estimate_batch': estimate_batch($r); break;
1056
+case 'get_templates': get_templates($r); break;
1057
+case 'ping': ping($r); break;
1058
+case 'query_batch': query_batch($r); break;
1059
+case 'query_batch2': query_batch2($r); break;
1060
+case 'query_batches': query_batches($r); break;
1061
+case 'query_job': query_job($r); break;
1062
+case 'query_completed_job': query_completed_job($r); break;
1063
+case 'retire_batch': handle_retire_batch($r); break;
1064
+case 'set_expire_time': handle_set_expire_time($r); break;
1065
+case 'submit_batch': submit_batch($r); break;
1066
+default:
1067
+    log_write("bad command");
1068
+    xml_error(-1, "bad command: ".$r->getName());
1069
+    break;
1070 1070
 }
1071 1071
 
1072 1072
 log_write("RPC done");
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boincwork/boincwork.admin.inc 1 patch
Switch Indentation   +199 added lines, -199 removed lines patch added patch discarded remove patch
@@ -10,20 +10,20 @@  discard block
 block discarded – undo
10 10
  * Allow configuration of general options for preference pages
11 11
  */
12 12
 function boincwork_admin_prefs_options_form(&$form_state) {
13
-  $form = array(); 
14
-  $form['beta'] = array(
15
-    '#type' => 'checkbox',
16
-    '#title' => t('Allow users to opt in to test beta applications'),
17
-    '#default_value' => variable_get('boinc_prefs_options_beta', 0),
18
-    '#required' => TRUE
19
-  );
20
-  $form['submit'] = array(
21
-    '#type' => 'submit',
22
-    '#value' => t('Submit')
23
-  );
24
-  // Add the official mechanical things and return
25
-  //drupal_prepare_form('boincwork_admin_prefs_upload_form', $form, $form_state);
26
-  return $form;
13
+$form = array(); 
14
+$form['beta'] = array(
15
+'#type' => 'checkbox',
16
+'#title' => t('Allow users to opt in to test beta applications'),
17
+'#default_value' => variable_get('boinc_prefs_options_beta', 0),
18
+'#required' => TRUE
19
+);
20
+$form['submit'] = array(
21
+'#type' => 'submit',
22
+'#value' => t('Submit')
23
+);
24
+// Add the official mechanical things and return
25
+//drupal_prepare_form('boincwork_admin_prefs_upload_form', $form, $form_state);
26
+return $form;
27 27
 } 
28 28
 
29 29
 /**
@@ -36,28 +36,28 @@  discard block
 block discarded – undo
36 36
   * Handle submission of preference general settings form.
37 37
   */
38 38
 function boincwork_admin_prefs_options_form_submit($form, &$form_state) {
39
-  variable_set('boinc_prefs_options_beta', $form_state['values']['beta']);
40
-  drupal_set_message('Preference options have been updated.');
39
+variable_set('boinc_prefs_options_beta', $form_state['values']['beta']);
40
+drupal_set_message('Preference options have been updated.');
41 41
 }
42 42
 
43 43
 /**
44 44
  * 
45 45
  */
46 46
 function boincwork_admin_prefs_upload_form(&$form_state) {
47
-  $form = array(); 
48
-  $form['prefs_xml'] = array(
49
-    '#type' => 'textarea',
50
-    '#title' => t('Project specific preferences XML'),
51
-    '#default_value' => variable_get('boinc_project_specific_prefs_config', "<project_specific_preferences>\n\n</project_specific_preferences>"),
52
-    '#required' => TRUE
53
-  );
54
-  $form['submit'] = array(
55
-    '#type' => 'submit',
56
-    '#value' => t('Submit')
57
-  );
58
-  // Add the official mechanical things and return
59
-  //drupal_prepare_form('boincwork_admin_prefs_upload_form', $form, $form_state);
60
-  return $form;
47
+$form = array(); 
48
+$form['prefs_xml'] = array(
49
+'#type' => 'textarea',
50
+'#title' => t('Project specific preferences XML'),
51
+'#default_value' => variable_get('boinc_project_specific_prefs_config', "<project_specific_preferences>\n\n</project_specific_preferences>"),
52
+'#required' => TRUE
53
+);
54
+$form['submit'] = array(
55
+'#type' => 'submit',
56
+'#value' => t('Submit')
57
+);
58
+// Add the official mechanical things and return
59
+//drupal_prepare_form('boincwork_admin_prefs_upload_form', $form, $form_state);
60
+return $form;
61 61
 } 
62 62
 
63 63
 /**
@@ -65,25 +65,25 @@  discard block
 block discarded – undo
65 65
   */
66 66
 function boincwork_admin_prefs_upload_form_validate($form, &$form_state) {
67 67
   
68
-  $xsd = './' . drupal_get_path('module', 'boincwork') . '/includes/projectprefs.xsd';
69
-  libxml_use_internal_errors(true);
70
-  $xml = new DomDocument();
71
-  $xml->loadXML($form_state['values']['prefs_xml'], LIBXML_NOBLANKS);
72
-  if (!$xml->schemaValidate($xsd)) {
73
-    $errors = libxml_get_errors();
74
-    $lines = explode("\r", $form_state['values']['prefs_xml']);
75
-    drupal_set_message("{$errors[0]->message} at line {$errors[0]->line}" .
76
-      ': <br/>' . htmlentities($lines[$errors[0]->line - 1]), 'error');
77
-    form_set_error('upload', t('XML file failed validation'));
78
-  }
68
+$xsd = './' . drupal_get_path('module', 'boincwork') . '/includes/projectprefs.xsd';
69
+libxml_use_internal_errors(true);
70
+$xml = new DomDocument();
71
+$xml->loadXML($form_state['values']['prefs_xml'], LIBXML_NOBLANKS);
72
+if (!$xml->schemaValidate($xsd)) {
73
+$errors = libxml_get_errors();
74
+$lines = explode("\r", $form_state['values']['prefs_xml']);
75
+drupal_set_message("{$errors[0]->message} at line {$errors[0]->line}" .
76
+  ': <br/>' . htmlentities($lines[$errors[0]->line - 1]), 'error');
77
+form_set_error('upload', t('XML file failed validation'));
78
+}
79 79
 }
80 80
 
81 81
 /**
82 82
   * Handle submission of preference upload form.
83 83
   */
84 84
 function boincwork_admin_prefs_upload_form_submit($form, &$form_state) {
85
-  variable_set('boinc_project_specific_prefs_config', $form_state['values']['prefs_xml']);
86
-  drupal_set_message('The XML has been validated and any changes to
85
+variable_set('boinc_project_specific_prefs_config', $form_state['values']['prefs_xml']);
86
+drupal_set_message('The XML has been validated and any changes to
87 87
       preferences are now in place.');
88 88
 }
89 89
 
@@ -91,30 +91,30 @@  discard block
 block discarded – undo
91 91
  * 
92 92
  */
93 93
 function boincwork_admin_prefs_presets_page($preset = 'standard') {
94
-  // Configure preference presets
95
-  if (function_exists('jump_quickly')) {
96
-    $path = 'admin/boinc/prefs/presets';
97
-    $preset_options = array(
98
-      "{$path}/standard" => t('Standard'),
99
-      "{$path}/maximum" => t('Maximum'),
100
-      "{$path}/green" => t('Green'),
101
-      "{$path}/minimum" => t('Minimum')
102
-    );
103
-    variable_set('jump_use_js_presets-Array', 1);
104
-    drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js');
105
-    $output .= '<div class="simple-form-controls"><div class="form-item venue">';
106
-    $output .= '<label>Preset:</label>';
107
-    $output .= jump_quickly($preset_options, 'presets');
108
-    $output .= '</div></div>';
109
-  }
110
-  $output .= drupal_get_form('boincwork_admin_prefs_presets_form', $preset);
94
+// Configure preference presets
95
+if (function_exists('jump_quickly')) {
96
+$path = 'admin/boinc/prefs/presets';
97
+$preset_options = array(
98
+  "{$path}/standard" => t('Standard'),
99
+  "{$path}/maximum" => t('Maximum'),
100
+  "{$path}/green" => t('Green'),
101
+  "{$path}/minimum" => t('Minimum')
102
+);
103
+variable_set('jump_use_js_presets-Array', 1);
104
+drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js');
105
+$output .= '<div class="simple-form-controls"><div class="form-item venue">';
106
+$output .= '<label>Preset:</label>';
107
+$output .= jump_quickly($preset_options, 'presets');
108
+$output .= '</div></div>';
109
+}
110
+$output .= drupal_get_form('boincwork_admin_prefs_presets_form', $preset);
111 111
 
112
-  $output .= '<div>';
113
-  $output .= bts('Usage: \'Save configuration\' will save the above preferences into the drupal database. These will be the preset computing (global) preferences that will fill in the preferences form once a user loads the Account Preferences page.', array(), NULL, 'boinc:admin-boinc-preference-presets');
114
-  $output .= '<p>';
115
-  $output .= bts('\'Save configuration with disk usage settings from config.xml\' will save the above preferences into the drupal database, but also load disk usage settings from the BOINC project\'s config.xml file. These will overwrite any disk usage settings you have placed above. Caution: A user\'s personal preferences will not change if you load the disk usage settings from config.xml here into the drupal database. They must change their preference settings manually.', array(), NULL, 'boinc:admin-boinc-preference-presets');
116
-  $output .= '</div>';
117
-  return $output;
112
+$output .= '<div>';
113
+$output .= bts('Usage: \'Save configuration\' will save the above preferences into the drupal database. These will be the preset computing (global) preferences that will fill in the preferences form once a user loads the Account Preferences page.', array(), NULL, 'boinc:admin-boinc-preference-presets');
114
+$output .= '<p>';
115
+$output .= bts('\'Save configuration with disk usage settings from config.xml\' will save the above preferences into the drupal database, but also load disk usage settings from the BOINC project\'s config.xml file. These will overwrite any disk usage settings you have placed above. Caution: A user\'s personal preferences will not change if you load the disk usage settings from config.xml here into the drupal database. They must change their preference settings manually.', array(), NULL, 'boinc:admin-boinc-preference-presets');
116
+$output .= '</div>';
117
+return $output;
118 118
 }
119 119
 
120 120
 /**
@@ -122,142 +122,142 @@  discard block
 block discarded – undo
122 122
  */
123 123
 function boincwork_admin_prefs_presets_form(&$form_state, $preset = 'standard') {
124 124
 
125
-  // Check database for preset prefs
126
-  if (!variable_get('boincwork_preset_prefs', null))
127
-    drupal_set_message(bts('No presets found in database, loading a default set of preferences for each preset. These will be saved to the database once you click \'Save configuration\'.', array(), NULL, 'boinc:admin-boinc-preference-presets'), 'status');
125
+// Check database for preset prefs
126
+if (!variable_get('boincwork_preset_prefs', null))
127
+drupal_set_message(bts('No presets found in database, loading a default set of preferences for each preset. These will be saved to the database once you click \'Save configuration\'.', array(), NULL, 'boinc:admin-boinc-preference-presets'), 'status');
128 128
 
129
-  // Load a copy of the general prefs form
130
-  $form = boincwork_generalprefs_form($form_state, NULL, $preset);
131
-  if ($key = array_search('boincwork_generalprefs_form_submit', $form['#submit'])) {
132
-    unset($form['#submit'][$key]);
133
-  }
134
-  $form['#submit'][] = 'boincwork_admin_prefs_presets_form_submit';
129
+// Load a copy of the general prefs form
130
+$form = boincwork_generalprefs_form($form_state, NULL, $preset);
131
+if ($key = array_search('boincwork_generalprefs_form_submit', $form['#submit'])) {
132
+unset($form['#submit'][$key]);
133
+}
134
+$form['#submit'][] = 'boincwork_admin_prefs_presets_form_submit';
135 135
   
136
-  // Just keep the necessary items
137
-  $form['processor'] = $form['prefs']['advanced']['processor'];
138
-  $form['storage'] = $form['prefs']['advanced']['storage'];
139
-  $form['network'] = $form['prefs']['advanced']['network'];
140
-  unset($form['prefs']);
136
+// Just keep the necessary items
137
+$form['processor'] = $form['prefs']['advanced']['processor'];
138
+$form['storage'] = $form['prefs']['advanced']['storage'];
139
+$form['network'] = $form['prefs']['advanced']['network'];
140
+unset($form['prefs']);
141 141
   
142
-  // Tweak some things so it behaves a little better
143
-  $form['#tree'] = TRUE;
144
-  $form['processor']['#collapsible'] = TRUE;
145
-  $form['storage']['#collapsible'] = TRUE;
146
-  $form['network']['#collapsible'] = TRUE;
142
+// Tweak some things so it behaves a little better
143
+$form['#tree'] = TRUE;
144
+$form['processor']['#collapsible'] = TRUE;
145
+$form['storage']['#collapsible'] = TRUE;
146
+$form['network']['#collapsible'] = TRUE;
147 147
   
148
-  // Add a submit button and a hidden field to pass the preset
149
-  $form['submit'] = array(
150
-    '#type' => 'submit',
151
-    '#value' => t('Save configuration')
152
-  );
153
-  $form['saveuseconfigxml'] = array (
154
-      '#type' => 'submit',
155
-      '#value' => t('Save configuration with disk usage settings from config.xml'),
156
-      '#validate' => array('boincwork_admin_prefs_preset_saveuseconfigxml'),
157
-  );
158
-  $form['preset'] = array(
159
-    '#type' => 'hidden',
160
-    '#value' => $preset
161
-  );
148
+// Add a submit button and a hidden field to pass the preset
149
+$form['submit'] = array(
150
+'#type' => 'submit',
151
+'#value' => t('Save configuration')
152
+);
153
+$form['saveuseconfigxml'] = array (
154
+  '#type' => 'submit',
155
+  '#value' => t('Save configuration with disk usage settings from config.xml'),
156
+  '#validate' => array('boincwork_admin_prefs_preset_saveuseconfigxml'),
157
+);
158
+$form['preset'] = array(
159
+'#type' => 'hidden',
160
+'#value' => $preset
161
+);
162 162
   
163
-  // Add the official mechanical things and return
164
-  drupal_prepare_form('boincwork_admin_prefs_presets_form', $form, $form_state);
165
-  return $form;
163
+// Add the official mechanical things and return
164
+drupal_prepare_form('boincwork_admin_prefs_presets_form', $form, $form_state);
165
+return $form;
166 166
 }
167 167
 
168 168
 /**
169 169
   * Validate the preference presets form.
170 170
   */
171 171
 function boincwork_admin_prefs_presets_form_validate($form, &$form_state) {
172
-  require_boinc('util');
173
-  $values = $form_state['values'];
172
+require_boinc('util');
173
+$values = $form_state['values'];
174 174
   
175
-  // Verify all non-boolean user input values and notify form API of failures
175
+// Verify all non-boolean user input values and notify form API of failures
176 176
   
177
-  // Processing preferences
178
-  if (!verify_numeric($values['processor']['idle_time_to_run'], 1, 9999)) form_set_error('idle_time_to_run', t('Invalid setting for') . " \"{$form['processor']['idle_time_to_run']['#title']} [x] {$form['processor']['idle_time_to_run']['#field_suffix']}\"");
179
-  if (!verify_numeric($values['processor']['suspend_if_no_recent_input'], 0, 9999)) form_set_error('suspend_if_no_recent_input', t('Invalid setting for') . " \"{$form['processor']['suspend_if_no_recent_input']['#title']} [x] {$form['processor']['suspend_if_no_recent_input']['#field_suffix']}\"");
180
-  if (!verify_numeric($values['processor']['suspend_cpu_usage'], 0, 100)) form_set_error('suspend_cpu_usage', t('Invalid setting for') . " \"{$form['processor']['suspend_cpu_usage']['#title']} [x] {$form['processor']['suspend_cpu_usage']['#field_suffix']}\"");
181
-  if (!verify_numeric($values['processor']['start_hour'], 0, 23)) form_set_error('start_hour', t('Invalid setting for') . " \"{$form['processor']['start_hour']['#title']} [x] {$form['processor']['start_hour']['#field_suffix']}\"");
182
-  if (!verify_numeric($values['processor']['end_hour'], 0, 23)) form_set_error('end_hour', t('Invalid setting for') . " \"{$form['processor']['end_hour']['#title']} [x] {$form['processor']['end_hour']['#field_suffix']}\"");
183
-  if (!verify_numeric($values['processor']['cpu_scheduling_period_minutes'], 1, 9999)) form_set_error('cpu_scheduling_period_minutes', t('Invalid setting for') . " \"{$form['processor']['cpu_scheduling_period_minutes']['#title']} [x] {$form['processor']['cpu_scheduling_period_minutes']['#field_suffix']}\"");
184
-  if (!verify_numeric($values['processor']['max_ncpus_pct'], 0, 100)) form_set_error('max_ncpus_pct', t('Invalid setting for') . " \"{$form['processor']['max_ncpus_pct']['#title']} [x] {$form['processor']['max_ncpus_pct']['#field_suffix']}\"");
185
-  if (!verify_numeric($values['processor']['cpu_usage_limit'], 0, 100)) form_set_error('cpu_usage_limit', t('Invalid setting for') . " \"{$form['processor']['cpu_usage_limit']['#title']} [x] {$form['processor']['cpu_usage_limit']['#field_suffix']}\"");
177
+// Processing preferences
178
+if (!verify_numeric($values['processor']['idle_time_to_run'], 1, 9999)) form_set_error('idle_time_to_run', t('Invalid setting for') . " \"{$form['processor']['idle_time_to_run']['#title']} [x] {$form['processor']['idle_time_to_run']['#field_suffix']}\"");
179
+if (!verify_numeric($values['processor']['suspend_if_no_recent_input'], 0, 9999)) form_set_error('suspend_if_no_recent_input', t('Invalid setting for') . " \"{$form['processor']['suspend_if_no_recent_input']['#title']} [x] {$form['processor']['suspend_if_no_recent_input']['#field_suffix']}\"");
180
+if (!verify_numeric($values['processor']['suspend_cpu_usage'], 0, 100)) form_set_error('suspend_cpu_usage', t('Invalid setting for') . " \"{$form['processor']['suspend_cpu_usage']['#title']} [x] {$form['processor']['suspend_cpu_usage']['#field_suffix']}\"");
181
+if (!verify_numeric($values['processor']['start_hour'], 0, 23)) form_set_error('start_hour', t('Invalid setting for') . " \"{$form['processor']['start_hour']['#title']} [x] {$form['processor']['start_hour']['#field_suffix']}\"");
182
+if (!verify_numeric($values['processor']['end_hour'], 0, 23)) form_set_error('end_hour', t('Invalid setting for') . " \"{$form['processor']['end_hour']['#title']} [x] {$form['processor']['end_hour']['#field_suffix']}\"");
183
+if (!verify_numeric($values['processor']['cpu_scheduling_period_minutes'], 1, 9999)) form_set_error('cpu_scheduling_period_minutes', t('Invalid setting for') . " \"{$form['processor']['cpu_scheduling_period_minutes']['#title']} [x] {$form['processor']['cpu_scheduling_period_minutes']['#field_suffix']}\"");
184
+if (!verify_numeric($values['processor']['max_ncpus_pct'], 0, 100)) form_set_error('max_ncpus_pct', t('Invalid setting for') . " \"{$form['processor']['max_ncpus_pct']['#title']} [x] {$form['processor']['max_ncpus_pct']['#field_suffix']}\"");
185
+if (!verify_numeric($values['processor']['cpu_usage_limit'], 0, 100)) form_set_error('cpu_usage_limit', t('Invalid setting for') . " \"{$form['processor']['cpu_usage_limit']['#title']} [x] {$form['processor']['cpu_usage_limit']['#field_suffix']}\"");
186 186
 
187
-  // Storage preferences
188
-  if (!verify_numeric($values['storage']['disk_max_used_gb'], 0, 9999999)) form_set_error('disk_max_used_gb', t('Invalid setting for') . " \"{$form['storage']['disk_max_used_gb']['#title']} [x] {$form['storage']['disk_max_used_gb']['#field_suffix']}\"");
189
-  if (!verify_numeric($values['storage']['disk_min_free_gb'], 0.001, 9999999)) form_set_error('disk_min_free_gb', t('Invalid setting for') . " \"{$form['storage']['disk_min_free_gb']['#title']} [x] {$form['storage']['disk_min_free_gb']['#field_suffix']}\"");
190
-  if (!verify_numeric($values['storage']['disk_max_used_pct'], 0, 100)) form_set_error('disk_max_used_pct', t('Invalid setting for') . " \"{$form['storage']['disk_max_used_pct']['#title']} [x] {$form['storage']['disk_max_used_pct']['#field_suffix']}\"");
191
-  if (!verify_numeric($values['storage']['disk_interval'], 0, 9999999)) form_set_error('disk_interval', t('Invalid setting for') . " \"{$form['storage']['disk_interval']['#title']} [x] {$form['storage']['disk_interval']['#field_suffix']}\"");
192
-  if (!verify_numeric($values['storage']['vm_max_used_pct'], 0, 100)) form_set_error('vm_max_used_pct', t('Invalid setting for') . " \"{$form['storage']['vm_max_used_pct']['#title']} [x] {$form['storage']['vm_max_used_pct']['#field_suffix']}\"");
193
-  if (!verify_numeric($values['storage']['ram_max_used_busy_pct'], 0, 100)) form_set_error('ram_max_used_busy_pct', t('Invalid setting for') . " \"{$form['storage']['ram_max_used_busy_pct']['#title']} [x] {$form['storage']['ram_max_used_busy_pct']['#field_suffix']}\"");
194
-  if (!verify_numeric($values['storage']['ram_max_used_idle_pct'], 0, 100)) form_set_error('ram_max_used_idle_pct', t('Invalid setting for') . " \"{$form['storage']['ram_max_used_idle_pct']['#title']} [x] {$form['storage']['ram_max_used_idle_pct']['#field_suffix']}\"");
187
+// Storage preferences
188
+if (!verify_numeric($values['storage']['disk_max_used_gb'], 0, 9999999)) form_set_error('disk_max_used_gb', t('Invalid setting for') . " \"{$form['storage']['disk_max_used_gb']['#title']} [x] {$form['storage']['disk_max_used_gb']['#field_suffix']}\"");
189
+if (!verify_numeric($values['storage']['disk_min_free_gb'], 0.001, 9999999)) form_set_error('disk_min_free_gb', t('Invalid setting for') . " \"{$form['storage']['disk_min_free_gb']['#title']} [x] {$form['storage']['disk_min_free_gb']['#field_suffix']}\"");
190
+if (!verify_numeric($values['storage']['disk_max_used_pct'], 0, 100)) form_set_error('disk_max_used_pct', t('Invalid setting for') . " \"{$form['storage']['disk_max_used_pct']['#title']} [x] {$form['storage']['disk_max_used_pct']['#field_suffix']}\"");
191
+if (!verify_numeric($values['storage']['disk_interval'], 0, 9999999)) form_set_error('disk_interval', t('Invalid setting for') . " \"{$form['storage']['disk_interval']['#title']} [x] {$form['storage']['disk_interval']['#field_suffix']}\"");
192
+if (!verify_numeric($values['storage']['vm_max_used_pct'], 0, 100)) form_set_error('vm_max_used_pct', t('Invalid setting for') . " \"{$form['storage']['vm_max_used_pct']['#title']} [x] {$form['storage']['vm_max_used_pct']['#field_suffix']}\"");
193
+if (!verify_numeric($values['storage']['ram_max_used_busy_pct'], 0, 100)) form_set_error('ram_max_used_busy_pct', t('Invalid setting for') . " \"{$form['storage']['ram_max_used_busy_pct']['#title']} [x] {$form['storage']['ram_max_used_busy_pct']['#field_suffix']}\"");
194
+if (!verify_numeric($values['storage']['ram_max_used_idle_pct'], 0, 100)) form_set_error('ram_max_used_idle_pct', t('Invalid setting for') . " \"{$form['storage']['ram_max_used_idle_pct']['#title']} [x] {$form['storage']['ram_max_used_idle_pct']['#field_suffix']}\"");
195 195
 
196
-  // Network preferences
197
-  if (!verify_numeric($values['network']['work_buf_min_days'], 0, 10)) form_set_error('work_buf_min_days', t('Invalid setting for') . " \"{$form['network']['work_buf_min_days']['#title']} [x] {$form['network']['work_buf_min_days']['#field_suffix']}\"");
198
-  if (!verify_numeric($values['network']['work_buf_additional_days'], 0, 10)) form_set_error('work_buf_additional_days', t('Invalid setting for') . " \"{$form['network']['work_buf_additional_days']['#title']} [x] {$form['network']['work_buf_additional_days']['#field_suffix']}\"");
199
-  if (!verify_numeric($values['network']['max_bytes_sec_down'], 0, 9999.999)) form_set_error('max_bytes_sec_down', t('Invalid setting for') . " \"{$form['network']['max_bytes_sec_down']['#title']} [x] {$form['network']['max_bytes_sec_down']['#field_suffix']}\"");
200
-  if (!verify_numeric($values['network']['max_bytes_sec_up'], 0, 9999.999)) form_set_error('max_bytes_sec_up', t('Invalid setting for') . " \"{$form['network']['max_bytes_sec_up']['#title']} [x] {$form['network']['max_bytes_sec_up']['#field_suffix']}\"");
201
-  if (!verify_numeric($values['network']['net_start_hour'], 0, 23)) form_set_error('net_start_hour', t('Invalid setting for') . " \"{$form['network']['net_start_hour']['#title']} [x] {$form['network']['net_start_hour']['#field_suffix']}\"");
202
-  if (!verify_numeric($values['network']['net_end_hour'], 0, 23)) form_set_error('net_end_hour', t('Invalid setting for') . " \"{$form['network']['net_end_hour']['#title']} [x] {$form['network']['net_end_hour']['#field_suffix']}\"");
203
-  if (!verify_numeric($values['network']['daily_xfer_limit_mb'], 0, 9999999)) form_set_error('daily_xfer_limit_mb', t('Invalid setting for') . " \"{$form['network']['daily_xfer_limit_mb']['#title']} [x] {$form['network']['daily_xfer_limit_mb']['#field_suffix']}\"");
204
-  if (!verify_numeric($values['network']['daily_xfer_period_days'], 0, 9999999)) form_set_error('daily_xfer_period_days', t('Invalid setting for') . " \"{$form['network']['daily_xfer_limit_mb']['#title']} [x] {$form['network']['daily_xfer_limit_mb']['#field_suffix']}\"");
196
+// Network preferences
197
+if (!verify_numeric($values['network']['work_buf_min_days'], 0, 10)) form_set_error('work_buf_min_days', t('Invalid setting for') . " \"{$form['network']['work_buf_min_days']['#title']} [x] {$form['network']['work_buf_min_days']['#field_suffix']}\"");
198
+if (!verify_numeric($values['network']['work_buf_additional_days'], 0, 10)) form_set_error('work_buf_additional_days', t('Invalid setting for') . " \"{$form['network']['work_buf_additional_days']['#title']} [x] {$form['network']['work_buf_additional_days']['#field_suffix']}\"");
199
+if (!verify_numeric($values['network']['max_bytes_sec_down'], 0, 9999.999)) form_set_error('max_bytes_sec_down', t('Invalid setting for') . " \"{$form['network']['max_bytes_sec_down']['#title']} [x] {$form['network']['max_bytes_sec_down']['#field_suffix']}\"");
200
+if (!verify_numeric($values['network']['max_bytes_sec_up'], 0, 9999.999)) form_set_error('max_bytes_sec_up', t('Invalid setting for') . " \"{$form['network']['max_bytes_sec_up']['#title']} [x] {$form['network']['max_bytes_sec_up']['#field_suffix']}\"");
201
+if (!verify_numeric($values['network']['net_start_hour'], 0, 23)) form_set_error('net_start_hour', t('Invalid setting for') . " \"{$form['network']['net_start_hour']['#title']} [x] {$form['network']['net_start_hour']['#field_suffix']}\"");
202
+if (!verify_numeric($values['network']['net_end_hour'], 0, 23)) form_set_error('net_end_hour', t('Invalid setting for') . " \"{$form['network']['net_end_hour']['#title']} [x] {$form['network']['net_end_hour']['#field_suffix']}\"");
203
+if (!verify_numeric($values['network']['daily_xfer_limit_mb'], 0, 9999999)) form_set_error('daily_xfer_limit_mb', t('Invalid setting for') . " \"{$form['network']['daily_xfer_limit_mb']['#title']} [x] {$form['network']['daily_xfer_limit_mb']['#field_suffix']}\"");
204
+if (!verify_numeric($values['network']['daily_xfer_period_days'], 0, 9999999)) form_set_error('daily_xfer_period_days', t('Invalid setting for') . " \"{$form['network']['daily_xfer_limit_mb']['#title']} [x] {$form['network']['daily_xfer_limit_mb']['#field_suffix']}\"");
205 205
 }
206 206
 
207 207
 /**
208 208
   * Handle post-validation submission of preference presets form.
209 209
   */
210 210
 function boincwork_admin_prefs_presets_form_submit($form, &$form_state) {
211
-  $values = $form_state['values'];
212
-  $preset = $form_state['values']['preset'];
211
+$values = $form_state['values'];
212
+$preset = $form_state['values']['preset'];
213 213
   
214
-  // Load baseline settings from configuration
215
-  $prefs = boincwork_get_preset_prefs($preset);
214
+// Load baseline settings from configuration
215
+$prefs = boincwork_get_preset_prefs($preset);
216 216
   
217
-  // Processing preferences
218
-  $prefs['run_on_batteries'] = ($values['processor']['run_on_batteries']) ? 0 : 1;
219
-  $prefs['run_if_user_active'] = ($values['processor']['run_if_user_active']) ? 0 : 1;
220
-  $prefs['run_gpu_if_user_active'] = ($values['processor']['run_gpu_if_user_active']) ? 0: 1;
221
-  $prefs['idle_time_to_run'] = $values['processor']['idle_time_to_run'];
222
-  $prefs['suspend_if_no_recent_input'] = $values['processor']['suspend_if_no_recent_input'];
223
-  $prefs['suspend_cpu_usage'] = $values['processor']['suspend_cpu_usage'];
224
-  $prefs['start_hour'] = $values['processor']['start_hour'];
225
-  $prefs['end_hour'] = $values['processor']['end_hour'];
226
-  $prefs['leave_apps_in_memory'] = ($values['processor']['leave_apps_in_memory']) ? 1 : 0;
227
-  $prefs['cpu_scheduling_period_minutes'] = $values['processor']['cpu_scheduling_period_minutes'];
228
-  $prefs['max_ncpus_pct'] = $values['processor']['max_ncpus_pct'];
229
-  $prefs['cpu_usage_limit'] = $values['processor']['cpu_usage_limit'];
217
+// Processing preferences
218
+$prefs['run_on_batteries'] = ($values['processor']['run_on_batteries']) ? 0 : 1;
219
+$prefs['run_if_user_active'] = ($values['processor']['run_if_user_active']) ? 0 : 1;
220
+$prefs['run_gpu_if_user_active'] = ($values['processor']['run_gpu_if_user_active']) ? 0: 1;
221
+$prefs['idle_time_to_run'] = $values['processor']['idle_time_to_run'];
222
+$prefs['suspend_if_no_recent_input'] = $values['processor']['suspend_if_no_recent_input'];
223
+$prefs['suspend_cpu_usage'] = $values['processor']['suspend_cpu_usage'];
224
+$prefs['start_hour'] = $values['processor']['start_hour'];
225
+$prefs['end_hour'] = $values['processor']['end_hour'];
226
+$prefs['leave_apps_in_memory'] = ($values['processor']['leave_apps_in_memory']) ? 1 : 0;
227
+$prefs['cpu_scheduling_period_minutes'] = $values['processor']['cpu_scheduling_period_minutes'];
228
+$prefs['max_ncpus_pct'] = $values['processor']['max_ncpus_pct'];
229
+$prefs['cpu_usage_limit'] = $values['processor']['cpu_usage_limit'];
230 230
   
231
-  // Storage preferences
232
-  $prefs['disk_max_used_gb'] = $values['storage']['disk_max_used_gb'];
233
-  $prefs['disk_min_free_gb'] = $values['storage']['disk_min_free_gb'];
234
-  $prefs['disk_max_used_pct'] = $values['storage']['disk_max_used_pct'];
235
-  $prefs['disk_interval'] = $values['storage']['disk_interval'];
236
-  $prefs['vm_max_used_pct'] = $values['storage']['vm_max_used_pct'];
237
-  $prefs['ram_max_used_busy_pct'] = $values['storage']['ram_max_used_busy_pct'];
238
-  $prefs['ram_max_used_idle_pct'] = $values['storage']['ram_max_used_idle_pct'];
231
+// Storage preferences
232
+$prefs['disk_max_used_gb'] = $values['storage']['disk_max_used_gb'];
233
+$prefs['disk_min_free_gb'] = $values['storage']['disk_min_free_gb'];
234
+$prefs['disk_max_used_pct'] = $values['storage']['disk_max_used_pct'];
235
+$prefs['disk_interval'] = $values['storage']['disk_interval'];
236
+$prefs['vm_max_used_pct'] = $values['storage']['vm_max_used_pct'];
237
+$prefs['ram_max_used_busy_pct'] = $values['storage']['ram_max_used_busy_pct'];
238
+$prefs['ram_max_used_idle_pct'] = $values['storage']['ram_max_used_idle_pct'];
239 239
   
240
-  // Network preferences
241
-  $prefs['work_buf_min_days'] = $values['network']['work_buf_min_days'];
242
-  $prefs['work_buf_additional_days'] = $values['network']['work_buf_additional_days'];
243
-  $prefs['confirm_before_connecting'] = ($values['network']['confirm_before_connecting']) ? 1 : 0;
244
-  $prefs['hangup_if_dialed'] = ($values['network']['hangup_if_dialed']) ? 1 : 0;
245
-  $prefs['max_bytes_sec_down'] = $values['network']['max_bytes_sec_down']*1000;
246
-  $prefs['max_bytes_sec_up'] = $values['network']['max_bytes_sec_up']*1000;
247
-  $prefs['net_start_hour'] = $values['network']['net_start_hour'];
248
-  $prefs['net_end_hour'] = $values['network']['net_end_hour'];
249
-  $prefs['daily_xfer_limit_mb'] = $values['network']['daily_xfer_limit_mb'];
250
-  $prefs['daily_xfer_period_days'] = $values['network']['daily_xfer_period_days'];
251
-  $prefs['dont_verify_images'] = ($values['network']['dont_verify_images']) ? 1 : 0;
240
+// Network preferences
241
+$prefs['work_buf_min_days'] = $values['network']['work_buf_min_days'];
242
+$prefs['work_buf_additional_days'] = $values['network']['work_buf_additional_days'];
243
+$prefs['confirm_before_connecting'] = ($values['network']['confirm_before_connecting']) ? 1 : 0;
244
+$prefs['hangup_if_dialed'] = ($values['network']['hangup_if_dialed']) ? 1 : 0;
245
+$prefs['max_bytes_sec_down'] = $values['network']['max_bytes_sec_down']*1000;
246
+$prefs['max_bytes_sec_up'] = $values['network']['max_bytes_sec_up']*1000;
247
+$prefs['net_start_hour'] = $values['network']['net_start_hour'];
248
+$prefs['net_end_hour'] = $values['network']['net_end_hour'];
249
+$prefs['daily_xfer_limit_mb'] = $values['network']['daily_xfer_limit_mb'];
250
+$prefs['daily_xfer_period_days'] = $values['network']['daily_xfer_period_days'];
251
+$prefs['dont_verify_images'] = ($values['network']['dont_verify_images']) ? 1 : 0;
252 252
   
253
-  //Remove @attributes to match new format (see boincwork.forms.inc
254
-  //function boincwork_generalprefs_form)
255
-  unset($prefs['@attributes']['preset']);
253
+//Remove @attributes to match new format (see boincwork.forms.inc
254
+//function boincwork_generalprefs_form)
255
+unset($prefs['@attributes']['preset']);
256 256
   
257
-  // Update the configuration
258
-  boincwork_save_preset_prefs($prefs, $preset);
259
-  drupal_set_message(t('The "@name" preset has been updated.',
260
-    array('@name' => $preset)));
257
+// Update the configuration
258
+boincwork_save_preset_prefs($prefs, $preset);
259
+drupal_set_message(t('The "@name" preset has been updated.',
260
+array('@name' => $preset)));
261 261
 }
262 262
 
263 263
 /**
@@ -265,26 +265,26 @@  discard block
 block discarded – undo
265 265
  */
266 266
 function boincwork_save_preset_prefs($updated_prefs, $preset = 'standard') {
267 267
   
268
-  // Get the full configuration
269
-  $all_presets = boincwork_get_preset_prefs();
270
-  $all_presets = (array) $all_presets['general_preferences'];
268
+// Get the full configuration
269
+$all_presets = boincwork_get_preset_prefs();
270
+$all_presets = (array) $all_presets['general_preferences'];
271 271
   
272
-  // Check for sane config
273
-  if (isset($all_presets['preset'])) {
274
-    if (!is_numeric(key($all_presets['preset']))) {
275
-      $all_presets['preset'] = array($all_presets['preset']);
276
-    }
277
-    foreach ($all_presets['preset'] as $key => $old_preset) {
278
-      // Find the preset being updated and... update it
279
-      if (isset($old_preset['@attributes']['name']) AND $old_preset['@attributes']['name'] == $preset) {
280
-        $all_presets['preset'][$key] = $updated_prefs + $old_preset;
281
-      }
282
-    }
272
+// Check for sane config
273
+if (isset($all_presets['preset'])) {
274
+if (!is_numeric(key($all_presets['preset']))) {
275
+  $all_presets['preset'] = array($all_presets['preset']);
276
+}
277
+foreach ($all_presets['preset'] as $key => $old_preset) {
278
+  // Find the preset being updated and... update it
279
+  if (isset($old_preset['@attributes']['name']) AND $old_preset['@attributes']['name'] == $preset) {
280
+    $all_presets['preset'][$key] = $updated_prefs + $old_preset;
283 281
   }
282
+}
283
+}
284 284
   
285
-  // Convert prefs back to XML and save to database
286
-  $all_presets = array('general_preferences' => $all_presets);
287
-  variable_set('boincwork_preset_prefs', save_configuration($all_presets));
285
+// Convert prefs back to XML and save to database
286
+$all_presets = array('general_preferences' => $all_presets);
287
+variable_set('boincwork_preset_prefs', save_configuration($all_presets));
288 288
 }
289 289
 
290 290
 /**
@@ -292,13 +292,13 @@  discard block
 block discarded – undo
292 292
  * overwrites whatever values are is in form.
293 293
  */
294 294
 function boincwork_admin_prefs_preset_saveuseconfigxml($form, &$form_state) {
295
-    require_boinc(array('db', 'prefs'));
296
-    $disk_space_config = get_disk_space_config();
295
+require_boinc(array('db', 'prefs'));
296
+$disk_space_config = get_disk_space_config();
297 297
 
298
-    $form_state['values']['storage']['disk_max_used_gb']  = $disk_space_config->disk_max_used_gb;
299
-    $form_state['values']['storage']['disk_min_free_gb']  = $disk_space_config->disk_min_free_gb;
300
-    $form_state['values']['storage']['disk_max_used_pct'] = $disk_space_config->disk_max_used_pct;
298
+$form_state['values']['storage']['disk_max_used_gb']  = $disk_space_config->disk_max_used_gb;
299
+$form_state['values']['storage']['disk_min_free_gb']  = $disk_space_config->disk_min_free_gb;
300
+$form_state['values']['storage']['disk_max_used_pct'] = $disk_space_config->disk_max_used_pct;
301 301
 
302
-    //Run the form validate function
303
-    boincwork_admin_prefs_presets_form_validate($form, $form_state);
302
+//Run the form validate function
303
+boincwork_admin_prefs_presets_form_validate($form, $form_state);
304 304
 }
305 305
\ No newline at end of file
Please login to merge, or discard this patch.