@@ -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 | - ); |
|
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 | 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; |
|
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,116 +691,116 @@ 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); |
|
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 | 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]) |
|
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 | 769 | |
770 | - $total_credit = $old_host->total_credit + $new_host->total_credit; |
|
771 | - $recent_credit = $old_host->expavg_credit + $new_host->expavg_credit; |
|
770 | + $total_credit = $old_host->total_credit + $new_host->total_credit; |
|
771 | + $recent_credit = $old_host->expavg_credit + $new_host->expavg_credit; |
|
772 | 772 | |
773 | - if ($new_host->rpc_seqno == $old_host->id) { |
|
773 | + if ($new_host->rpc_seqno == $old_host->id) { |
|
774 | 774 | rules_invoke_event('boincwork_circular_merge_error', $old_host->id, $new_host->id, variable_get('boinc_admin_mailing_list_subject_tag', '')); |
775 | 775 | watchdog('boincwork', |
776 | - 'Circular merge attempted, target host rpc_seqno is equal to old host\'s id: old host id=%old_host, target host id=%new_host', |
|
777 | - array( |
|
776 | + 'Circular merge attempted, target host rpc_seqno is equal to old host\'s id: old host id=%old_host, target host id=%new_host', |
|
777 | + array( |
|
778 | 778 | '%old_host' => $old_host->id, |
779 | 779 | '%new_host' => $new_host->id, |
780 | - ), |
|
781 | - WATCHDOG_WARNING |
|
780 | + ), |
|
781 | + WATCHDOG_WARNING |
|
782 | 782 | ); |
783 | 783 | $message = 'Could not merge due to a circular merge error. The site administrators have been contacted about this issue, and will investigate further.'; |
784 | 784 | return FALSE; |
785 | - } |
|
785 | + } |
|
786 | 786 | |
787 | - if ($new_host->userid==0) { |
|
787 | + if ($new_host->userid==0) { |
|
788 | 788 | rules_invoke_event('boincwork_zombie_merge_error', $old_host->id, $new_host->id, variable_get('boinc_admin_mailing_list_subject_tag', '')); |
789 | 789 | watchdog('boincwork', |
790 | - 'Zombie merge attempted, target host has userid=0: old host id=%old_host, target host id=%new_host', |
|
791 | - array( |
|
790 | + 'Zombie merge attempted, target host has userid=0: old host id=%old_host, target host id=%new_host', |
|
791 | + array( |
|
792 | 792 | '%old_host' => $old_host->id, |
793 | 793 | '%new_host' => $new_host->id, |
794 | - ), |
|
795 | - WATCHDOG_WARNING |
|
794 | + ), |
|
795 | + WATCHDOG_WARNING |
|
796 | 796 | ); |
797 | 797 | $message = 'Could not merge because the target host has userid=0. The site administrators have been contacted about this issue, and will investigate further.'; |
798 | 798 | return FALSE; |
799 | - } |
|
799 | + } |
|
800 | 800 | |
801 | - // Move credit from the old host to the new host |
|
802 | - db_set_active('boinc_rw'); |
|
803 | - $credit_updated = db_query(" |
|
801 | + // Move credit from the old host to the new host |
|
802 | + db_set_active('boinc_rw'); |
|
803 | + $credit_updated = db_query(" |
|
804 | 804 | UPDATE {host} |
805 | 805 | SET |
806 | 806 | total_credit = '%d', |
@@ -808,34 +808,34 @@ discard block |
||
808 | 808 | expavg_time = '%d' |
809 | 809 | WHERE id = '%d'", |
810 | 810 | $total_credit, $recent_credit, $now, $new_host->id |
811 | - ); |
|
812 | - db_set_active('default'); |
|
813 | - if (!$credit_updated) { |
|
811 | + ); |
|
812 | + db_set_active('default'); |
|
813 | + if (!$credit_updated) { |
|
814 | 814 | if ($message !== NULL) { |
815 | - $message = bts('Could not update credit', array(), NULL, 'boinc:account-host-merge'); |
|
815 | + $message = bts('Could not update credit', array(), NULL, 'boinc:account-host-merge'); |
|
816 | 816 | } |
817 | 817 | return FALSE; |
818 | - } |
|
818 | + } |
|
819 | 819 | |
820 | - // Move results from the old host to the new host |
|
821 | - db_set_active('boinc_rw'); |
|
822 | - $results_updated = db_query(" |
|
820 | + // Move results from the old host to the new host |
|
821 | + db_set_active('boinc_rw'); |
|
822 | + $results_updated = db_query(" |
|
823 | 823 | UPDATE {result} |
824 | 824 | SET hostid = '%d' |
825 | 825 | WHERE hostid = '%d'", |
826 | 826 | $new_host->id, $old_host->id |
827 | - ); |
|
828 | - db_set_active('default'); |
|
829 | - if (!$results_updated) { |
|
827 | + ); |
|
828 | + db_set_active('default'); |
|
829 | + if (!$results_updated) { |
|
830 | 830 | if ($message !== NULL) { |
831 | - $message = bts('Could not update results', array(), NULL, 'boinc:account-host-merge'); |
|
831 | + $message = bts('Could not update results', array(), NULL, 'boinc:account-host-merge'); |
|
832 | 832 | } |
833 | 833 | return FALSE; |
834 | - } |
|
834 | + } |
|
835 | 835 | |
836 | - // Retire the old host |
|
837 | - db_set_active('boinc_rw'); |
|
838 | - $old_host_retired = db_query(" |
|
836 | + // Retire the old host |
|
837 | + db_set_active('boinc_rw'); |
|
838 | + $old_host_retired = db_query(" |
|
839 | 839 | UPDATE {host} |
840 | 840 | SET |
841 | 841 | total_credit = '0', |
@@ -844,16 +844,16 @@ discard block |
||
844 | 844 | rpc_seqno = '%d' |
845 | 845 | WHERE id = '%d'", |
846 | 846 | $new_host->id, $old_host->id |
847 | - ); |
|
848 | - db_set_active('default'); |
|
849 | - if (!$old_host_retired) { |
|
847 | + ); |
|
848 | + db_set_active('default'); |
|
849 | + if (!$old_host_retired) { |
|
850 | 850 | if ($message !== NULL) { |
851 | - $message = bts('Could not retire old computer', array(), NULL, 'boinc:account-host-merge'); |
|
851 | + $message = bts('Could not retire old computer', array(), NULL, 'boinc:account-host-merge'); |
|
852 | 852 | } |
853 | 853 | return FALSE; |
854 | - } |
|
854 | + } |
|
855 | 855 | |
856 | - return TRUE; |
|
856 | + return TRUE; |
|
857 | 857 | } |
858 | 858 | |
859 | 859 | /** |
@@ -861,75 +861,75 @@ discard block |
||
861 | 861 | */ |
862 | 862 | function boincwork_host_merge_form(&$form_state, $host_id) { |
863 | 863 | |
864 | - if (!boincwork_host_user_is_owner($host_id)) { |
|
864 | + if (!boincwork_host_user_is_owner($host_id)) { |
|
865 | 865 | drupal_goto("host/{$host_id}"); |
866 | - } |
|
866 | + } |
|
867 | 867 | |
868 | - $form = array(); |
|
869 | - $form_state['storage']['current_host_id'] = $host_id; |
|
870 | - $current_host = boincwork_host_get_info($host_id); |
|
868 | + $form = array(); |
|
869 | + $form_state['storage']['current_host_id'] = $host_id; |
|
870 | + $current_host = boincwork_host_get_info($host_id); |
|
871 | 871 | |
872 | - // Get hosts that could be merged with this one |
|
873 | - $hosts = boincwork_host_get_compatible_hosts($host_id); |
|
872 | + // Get hosts that could be merged with this one |
|
873 | + $hosts = boincwork_host_get_compatible_hosts($host_id); |
|
874 | 874 | |
875 | - if (!$hosts) { |
|
875 | + if (!$hosts) { |
|
876 | 876 | drupal_set_message(t('There are no computers eligible for merging with this |
877 | 877 | one'), 'warning' |
878 | 878 | ); |
879 | 879 | drupal_goto("host/{$host_id}"); |
880 | - } |
|
880 | + } |
|
881 | 881 | |
882 | - $form['overview'] = array( |
|
882 | + $form['overview'] = array( |
|
883 | 883 | '#value' => '<p>' . bts('Sometimes BOINC assigns separate identities to' |
884 | - . ' the same computer by mistake. You can correct this by merging old' |
|
885 | - . ' identities with the newest one.', array(), NULL, 'boinc:account-host-merge') . '</p>' |
|
886 | - . '<p>' |
|
887 | - . bts('Check the computers that are the same as @name' |
|
888 | - . ' (created on @date at @time with computer ID @id)', |
|
884 | + . ' the same computer by mistake. You can correct this by merging old' |
|
885 | + . ' identities with the newest one.', array(), NULL, 'boinc:account-host-merge') . '</p>' |
|
886 | + . '<p>' |
|
887 | + . bts('Check the computers that are the same as @name' |
|
888 | + . ' (created on @date at @time with computer ID @id)', |
|
889 | 889 | array( |
890 | - '@name' => $current_host->domain_name, |
|
891 | - '@date' => date('j M Y', $current_host->create_time), |
|
892 | - '@time' => date('G:i:s T', $current_host->create_time), |
|
893 | - '@id' => $current_host->id, |
|
890 | + '@name' => $current_host->domain_name, |
|
891 | + '@date' => date('j M Y', $current_host->create_time), |
|
892 | + '@time' => date('G:i:s T', $current_host->create_time), |
|
893 | + '@id' => $current_host->id, |
|
894 | 894 | ), |
895 | 895 | NULL, 'boinc:account-host-merge') . '</p>', |
896 | - ); |
|
896 | + ); |
|
897 | 897 | |
898 | - $options = array(); |
|
899 | - foreach ($hosts as $host) { |
|
898 | + $options = array(); |
|
899 | + foreach ($hosts as $host) { |
|
900 | 900 | $options[$host->id] = array( |
901 | - $host->domain_name, |
|
902 | - date('j M Y G:i:s T', $host->create_time), |
|
903 | - $host->id, |
|
901 | + $host->domain_name, |
|
902 | + date('j M Y G:i:s T', $host->create_time), |
|
903 | + $host->id, |
|
904 | 904 | ); |
905 | - } |
|
905 | + } |
|
906 | 906 | |
907 | - $form['merge'] = array( |
|
907 | + $form['merge'] = array( |
|
908 | 908 | '#title' => '', |
909 | 909 | '#type' => 'tableselect', |
910 | 910 | '#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')), |
911 | 911 | '#options' => $options, |
912 | - ); |
|
912 | + ); |
|
913 | 913 | |
914 | - $form['prefs']['separator_bottom'] = array( |
|
915 | - // '#value' => '<div class="separator buttons"></div>' |
|
916 | - ); |
|
914 | + $form['prefs']['separator_bottom'] = array( |
|
915 | + // '#value' => '<div class="separator buttons"></div>' |
|
916 | + ); |
|
917 | 917 | |
918 | - // Form control |
|
919 | - $form['prefs']['form control tabs prefix'] = array( |
|
918 | + // Form control |
|
919 | + $form['prefs']['form control tabs prefix'] = array( |
|
920 | 920 | '#value' => '<ul class="form-control tab-list">' |
921 | - ); |
|
922 | - $form['prefs']['submit'] = array( |
|
921 | + ); |
|
922 | + $form['prefs']['submit'] = array( |
|
923 | 923 | '#prefix' => '<li class="first tab">', |
924 | 924 | '#type' => 'submit', |
925 | 925 | '#value' => bts('Merge', array(), NULL, 'boinc:form-merge'), |
926 | 926 | '#suffix' => '</li>' |
927 | - ); |
|
928 | - $form['prefs']['form control tabs'] = array( |
|
927 | + ); |
|
928 | + $form['prefs']['form control tabs'] = array( |
|
929 | 929 | '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "host/{$host_id}") . '</li>' |
930 | - ); |
|
930 | + ); |
|
931 | 931 | |
932 | - return $form; |
|
932 | + return $form; |
|
933 | 933 | } |
934 | 934 | |
935 | 935 | /** |
@@ -942,76 +942,76 @@ discard block |
||
942 | 942 | * Handle submission of the merge host form |
943 | 943 | */ |
944 | 944 | function boincwork_host_merge_form_submit($form, &$form_state) { |
945 | - $merged = array(); |
|
946 | - $errors = array(); |
|
947 | - $current_host_id = $form_state['storage']['current_host_id']; |
|
948 | - $current_host = boincwork_host_get_info($current_host_id); |
|
949 | - $selected_hosts = array_filter($form_state['values']['merge']); |
|
945 | + $merged = array(); |
|
946 | + $errors = array(); |
|
947 | + $current_host_id = $form_state['storage']['current_host_id']; |
|
948 | + $current_host = boincwork_host_get_info($current_host_id); |
|
949 | + $selected_hosts = array_filter($form_state['values']['merge']); |
|
950 | 950 | |
951 | - foreach ($selected_hosts as $host_id) { |
|
951 | + foreach ($selected_hosts as $host_id) { |
|
952 | 952 | // Attempt to merge each host, noting the results |
953 | 953 | $message = ''; |
954 | 954 | $old_host = boincwork_host_get_info($host_id); |
955 | 955 | if (boincwork_host_merge($old_host, $current_host, $message)) { |
956 | - $merged[$old_host->id] = $old_host->id; |
|
957 | - $current_host = boincwork_host_get_info($current_host_id); |
|
956 | + $merged[$old_host->id] = $old_host->id; |
|
957 | + $current_host = boincwork_host_get_info($current_host_id); |
|
958 | 958 | } |
959 | 959 | else { |
960 | - $errors[$old_host->id] = $message; |
|
960 | + $errors[$old_host->id] = $message; |
|
961 | + } |
|
961 | 962 | } |
962 | - } |
|
963 | 963 | |
964 | - if ($merged) { |
|
964 | + if ($merged) { |
|
965 | 965 | // Generate a natural language list of IDs that were merged |
966 | 966 | $oxford_comma = ','; |
967 | 967 | $conjunction = bts('and', array(), NULL, 'boinc:account-preference'); |
968 | 968 | $list = array_keys($merged); |
969 | 969 | $last = array_pop($list); |
970 | 970 | if ($list) { |
971 | - if (count($merged) == 2) { |
|
971 | + if (count($merged) == 2) { |
|
972 | 972 | $oxford_comma = ''; |
973 | - } |
|
974 | - $list = implode(', ', $list) . $oxford_comma . ' ' . $conjunction . ' ' . $last; |
|
973 | + } |
|
974 | + $list = implode(', ', $list) . $oxford_comma . ' ' . $conjunction . ' ' . $last; |
|
975 | 975 | } |
976 | 976 | else { |
977 | - $list = $last; |
|
977 | + $list = $last; |
|
978 | 978 | } |
979 | 979 | if (count($merged) == 1) { |
980 | - drupal_set_message(bts( |
|
980 | + drupal_set_message(bts( |
|
981 | 981 | 'Computer @old_id has been merged successfully into @id.', |
982 | 982 | array( |
983 | - '@old_id' => $list, |
|
984 | - '@id' => $current_host_id |
|
983 | + '@old_id' => $list, |
|
984 | + '@id' => $current_host_id |
|
985 | 985 | ), |
986 | 986 | NULL, 'boinc:account-host-merge')); |
987 | 987 | } |
988 | 988 | else { |
989 | - drupal_set_message(bts( |
|
989 | + drupal_set_message(bts( |
|
990 | 990 | 'Computers @old_ids have been merged successfully into @id.', |
991 | 991 | array( |
992 | - '@old_ids' => $list, |
|
993 | - '@id' => $current_host_id |
|
992 | + '@old_ids' => $list, |
|
993 | + '@id' => $current_host_id |
|
994 | 994 | ), |
995 | 995 | NULL, 'boinc:account-host-merge')); |
996 | 996 | } |
997 | - } |
|
997 | + } |
|
998 | 998 | |
999 | - if ($errors) { |
|
999 | + if ($errors) { |
|
1000 | 1000 | // Report any hosts that failed to merge |
1001 | 1001 | foreach ($errors as $id => $error) { |
1002 | - drupal_set_message( |
|
1002 | + drupal_set_message( |
|
1003 | 1003 | bts('Computer @old_id failed to merge: @message', |
1004 | - array( |
|
1004 | + array( |
|
1005 | 1005 | '@old_id' => $id, |
1006 | 1006 | '@message' => $error, |
1007 | - ), |
|
1008 | - NULL, 'boinc:account-host-merge'), |
|
1007 | + ), |
|
1008 | + NULL, 'boinc:account-host-merge'), |
|
1009 | 1009 | 'warning' |
1010 | - ); |
|
1010 | + ); |
|
1011 | + } |
|
1011 | 1012 | } |
1012 | - } |
|
1013 | 1013 | |
1014 | - drupal_goto("host/{$current_host_id}"); |
|
1014 | + drupal_goto("host/{$current_host_id}"); |
|
1015 | 1015 | } |
1016 | 1016 | |
1017 | 1017 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -1023,44 +1023,44 @@ discard block |
||
1023 | 1023 | */ |
1024 | 1024 | function boincwork_projectprefs_form(&$form_state, $venue) { |
1025 | 1025 | |
1026 | - global $user; |
|
1027 | - $account = user_load($user->uid); |
|
1026 | + global $user; |
|
1027 | + $account = user_load($user->uid); |
|
1028 | 1028 | |
1029 | - $established = TRUE; |
|
1029 | + $established = TRUE; |
|
1030 | 1030 | |
1031 | - // Get availability of special BOINC preferences |
|
1032 | - require_boinc(array('util')); |
|
1033 | - $app_types = get_app_types(); |
|
1031 | + // Get availability of special BOINC preferences |
|
1032 | + require_boinc(array('util')); |
|
1033 | + $app_types = get_app_types(); |
|
1034 | 1034 | |
1035 | - // Load any existing preferences from BOINC account |
|
1036 | - $prefs = boincwork_load_prefs('project', $venue); |
|
1035 | + // Load any existing preferences from BOINC account |
|
1036 | + $prefs = boincwork_load_prefs('project', $venue); |
|
1037 | 1037 | |
1038 | - // Take note if this is not an established preference set on the account |
|
1039 | - if (isset($prefs['@attributes']['cleared'])) { |
|
1038 | + // Take note if this is not an established preference set on the account |
|
1039 | + if (isset($prefs['@attributes']['cleared'])) { |
|
1040 | 1040 | $established = FALSE; |
1041 | - } |
|
1041 | + } |
|
1042 | 1042 | |
1043 | - // Extract modified tag if present |
|
1044 | - $modified = NULL; |
|
1045 | - if (isset($prefs['modified']['@value'])) { |
|
1043 | + // Extract modified tag if present |
|
1044 | + $modified = NULL; |
|
1045 | + if (isset($prefs['modified']['@value'])) { |
|
1046 | 1046 | $modified = $prefs['modified']['@value']; |
1047 | - } |
|
1047 | + } |
|
1048 | 1048 | |
1049 | - $venue_is_default = FALSE; |
|
1050 | - if ($account->boincuser_default_pref_set) { |
|
1049 | + $venue_is_default = FALSE; |
|
1050 | + if ($account->boincuser_default_pref_set) { |
|
1051 | 1051 | if ($account->boincuser_default_pref_set == $venue) { |
1052 | - $venue_is_default = TRUE; |
|
1052 | + $venue_is_default = TRUE; |
|
1053 | 1053 | } |
1054 | - } |
|
1055 | - elseif (!$venue OR $venue == 'generic') { |
|
1054 | + } |
|
1055 | + elseif (!$venue OR $venue == 'generic') { |
|
1056 | 1056 | $venue_is_default = TRUE; |
1057 | - } |
|
1058 | - else { |
|
1057 | + } |
|
1058 | + else { |
|
1059 | 1059 | $venue_is_default = FALSE; |
1060 | - } |
|
1060 | + } |
|
1061 | 1061 | |
1062 | - // Define form defaults |
|
1063 | - $default = array( |
|
1062 | + // Define form defaults |
|
1063 | + $default = array( |
|
1064 | 1064 | 'resource_share' => 100, |
1065 | 1065 | 'no_cpu' => 0, |
1066 | 1066 | 'no_cuda' => 0, |
@@ -1069,344 +1069,344 @@ discard block |
||
1069 | 1069 | 'no_apple_gpu' => 0, |
1070 | 1070 | 'default_venue' => $venue_is_default, |
1071 | 1071 | 'allow_beta_work' => $prefs['allow_beta_work'], |
1072 | - ); |
|
1073 | - foreach ($default as $name => $value) { |
|
1072 | + ); |
|
1073 | + foreach ($default as $name => $value) { |
|
1074 | 1074 | if (isset($prefs[$name])) { |
1075 | - if (is_array($prefs[$name])) { |
|
1075 | + if (is_array($prefs[$name])) { |
|
1076 | 1076 | if (isset($prefs[$name]['@value'])) { |
1077 | - $default[$name] = $prefs[$name]['@value']; |
|
1077 | + $default[$name] = $prefs[$name]['@value']; |
|
1078 | + } |
|
1078 | 1079 | } |
1079 | - } |
|
1080 | - else { |
|
1080 | + else { |
|
1081 | 1081 | $default[$name] = $prefs[$name]; |
1082 | - } |
|
1082 | + } |
|
1083 | + } |
|
1083 | 1084 | } |
1084 | - } |
|
1085 | 1085 | |
1086 | - // Standard option sets |
|
1087 | - $form['boolean_options'] = array( |
|
1086 | + // Standard option sets |
|
1087 | + $form['boolean_options'] = array( |
|
1088 | 1088 | '#type' => 'value', |
1089 | 1089 | '#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')) |
1090 | - ); |
|
1090 | + ); |
|
1091 | 1091 | |
1092 | - // Identify preference sets that are established to distinguish what has been |
|
1093 | - // saved to the database from what is just showing default values |
|
1094 | - $form['#established'] = $established; |
|
1092 | + // Identify preference sets that are established to distinguish what has been |
|
1093 | + // saved to the database from what is just showing default values |
|
1094 | + $form['#established'] = $established; |
|
1095 | 1095 | |
1096 | - // Top level form options |
|
1097 | - $form['#tree'] = TRUE; |
|
1096 | + // Top level form options |
|
1097 | + $form['#tree'] = TRUE; |
|
1098 | 1098 | |
1099 | - // Hidden elements |
|
1100 | - $form['modified'] = array( |
|
1099 | + // Hidden elements |
|
1100 | + $form['modified'] = array( |
|
1101 | 1101 | '#type' => 'hidden', |
1102 | 1102 | '#value' => $modified, |
1103 | - ); |
|
1104 | - $form['venue'] = array( |
|
1103 | + ); |
|
1104 | + $form['venue'] = array( |
|
1105 | 1105 | '#type' => 'hidden', |
1106 | 1106 | '#value' => $venue, |
1107 | - ); |
|
1107 | + ); |
|
1108 | 1108 | |
1109 | - $form['separator_top'] = array( |
|
1109 | + $form['separator_top'] = array( |
|
1110 | 1110 | '#value' => '<div class="separator"></div>' |
1111 | - ); |
|
1111 | + ); |
|
1112 | 1112 | |
1113 | - // Common project preferences |
|
1114 | - $form['resource'] = array( |
|
1113 | + // Common project preferences |
|
1114 | + $form['resource'] = array( |
|
1115 | 1115 | '#title' => bts('Resource settings', array(), NULL, 'boinc:account-preferences-project'), |
1116 | 1116 | '#type' => 'fieldset', |
1117 | 1117 | '#description' => null, |
1118 | 1118 | '#collapsible' => TRUE, |
1119 | 1119 | '#collapsed' => FALSE |
1120 | - ); |
|
1121 | - $form['resource']['resource_share'] = array( |
|
1120 | + ); |
|
1121 | + $form['resource']['resource_share'] = array( |
|
1122 | 1122 | '#title' => bts('Resource share', array(), NULL, 'boinc:account-preferences-project'), |
1123 | 1123 | '#type' => 'textfield', |
1124 | 1124 | '#default_value' => $default['resource_share'], |
1125 | 1125 | '#size' => 5, |
1126 | 1126 | '#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') |
1127 | - ); |
|
1128 | - if ($app_types->count > 1) { |
|
1127 | + ); |
|
1128 | + if ($app_types->count > 1) { |
|
1129 | 1129 | if ($app_types->cpu) { |
1130 | - $form['resource']['no_cpu'] = array( |
|
1130 | + $form['resource']['no_cpu'] = array( |
|
1131 | 1131 | '#title' => bts('Use CPU', array(), NULL, 'boinc:account-preferences-project'), |
1132 | 1132 | '#type' => 'radios', |
1133 | 1133 | '#options' => $form['boolean_options']['#value'], |
1134 | 1134 | '#attributes' => array('class' => 'fancy'), |
1135 | 1135 | '#default_value' => $default['no_cpu'] ? 0 : 1, |
1136 | 1136 | '#description' => bts('Request CPU-only tasks from this project.', array(), NULL, 'boinc:account-preferences-project') |
1137 | - ); |
|
1137 | + ); |
|
1138 | 1138 | } |
1139 | 1139 | if ($app_types->cuda) { |
1140 | - $form['resource']['no_cuda'] = array( |
|
1140 | + $form['resource']['no_cuda'] = array( |
|
1141 | 1141 | '#title' => bts('Use NVIDIA GPU', array(), NULL, 'boinc:account-preferences-project'), |
1142 | 1142 | '#type' => 'radios', |
1143 | 1143 | '#options' => $form['boolean_options']['#value'], |
1144 | 1144 | '#attributes' => array('class' => 'fancy'), |
1145 | 1145 | '#default_value' => $default['no_cuda'] ? 0 : 1, |
1146 | 1146 | '#description' => bts('Request NVIDIA GPU tasks from this project.', array(), NULL, 'boinc:account-preferences-project') |
1147 | - ); |
|
1147 | + ); |
|
1148 | 1148 | } |
1149 | 1149 | if ($app_types->ati) { |
1150 | - $form['resource']['no_ati'] = array( |
|
1150 | + $form['resource']['no_ati'] = array( |
|
1151 | 1151 | '#title' => bts('Use AMD GPU', 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['no_ati'] ? 0 : 1, |
1156 | 1156 | '#description' => bts('Request AMD GPU tasks from this project.', array(), NULL, 'boinc:account-preferences-project') |
1157 | - ); |
|
1157 | + ); |
|
1158 | 1158 | } |
1159 | 1159 | if ($app_types->intel_gpu) { |
1160 | - $form['resource']['no_intel_gpu'] = array( |
|
1160 | + $form['resource']['no_intel_gpu'] = array( |
|
1161 | 1161 | '#title' => bts('Use INTEL GPU', array(), NULL, 'boinc:account-preferences-project'), |
1162 | 1162 | '#type' => 'radios', |
1163 | 1163 | '#options' => $form['boolean_options']['#value'], |
1164 | 1164 | '#attributes' => array('class' => 'fancy'), |
1165 | 1165 | '#default_value' => $default['no_intel_gpu'] ? 0 : 1, |
1166 | 1166 | '#description' => bts('Request Intel GPU tasks from this project.', array(), NULL, 'boinc:account-preferences-project') |
1167 | - ); |
|
1167 | + ); |
|
1168 | 1168 | } |
1169 | 1169 | if ($app_types->apple_gpu) { |
1170 | - $form['resource']['no_apple_gpu'] = array( |
|
1170 | + $form['resource']['no_apple_gpu'] = array( |
|
1171 | 1171 | '#title' => bts('Use Apple GPU', array(), NULL, 'boinc:account-preferences-project'), |
1172 | 1172 | '#type' => 'radios', |
1173 | 1173 | '#options' => $form['boolean_options']['#value'], |
1174 | 1174 | '#attributes' => array('class' => 'fancy'), |
1175 | 1175 | '#default_value' => $default['no_apple_gpu'] ? 0 : 1, |
1176 | 1176 | '#description' => bts('Request Apple GPU tasks from this project.', array(), NULL, 'boinc:account-preferences-project') |
1177 | - ); |
|
1177 | + ); |
|
1178 | + } |
|
1178 | 1179 | } |
1179 | - } |
|
1180 | 1180 | |
1181 | - if (variable_get('boinc_prefs_options_beta', FALSE)) { |
|
1181 | + if (variable_get('boinc_prefs_options_beta', FALSE)) { |
|
1182 | 1182 | $form['beta'] = array( |
1183 | - '#title' => bts('Beta settings', array(), NULL, 'boinc:account-preferences-project'), |
|
1184 | - '#type' => 'fieldset', |
|
1185 | - '#description' => null, |
|
1186 | - '#collapsible' => TRUE, |
|
1187 | - '#collapsed' => FALSE |
|
1183 | + '#title' => bts('Beta settings', array(), NULL, 'boinc:account-preferences-project'), |
|
1184 | + '#type' => 'fieldset', |
|
1185 | + '#description' => null, |
|
1186 | + '#collapsible' => TRUE, |
|
1187 | + '#collapsed' => FALSE |
|
1188 | 1188 | ); |
1189 | 1189 | $form['beta']['allow_beta_work'] = array( |
1190 | - '#title' => bts('Run test applications?', array(), NULL, 'boinc:account-preferences-project'), |
|
1191 | - '#type' => 'radios', |
|
1192 | - '#options' => $form['boolean_options']['#value'], |
|
1193 | - '#attributes' => array('class' => 'fancy'), |
|
1194 | - '#default_value' => ($default['allow_beta_work']) ? 1 : 0, |
|
1195 | - '#description' => bts('This helps us develop applications, but may cause jobs to fail on your computer', array(), NULL, 'boinc:account-preferences-project') |
|
1190 | + '#title' => bts('Run test applications?', array(), NULL, 'boinc:account-preferences-project'), |
|
1191 | + '#type' => 'radios', |
|
1192 | + '#options' => $form['boolean_options']['#value'], |
|
1193 | + '#attributes' => array('class' => 'fancy'), |
|
1194 | + '#default_value' => ($default['allow_beta_work']) ? 1 : 0, |
|
1195 | + '#description' => bts('This helps us develop applications, but may cause jobs to fail on your computer', array(), NULL, 'boinc:account-preferences-project') |
|
1196 | 1196 | ); |
1197 | - } |
|
1197 | + } |
|
1198 | 1198 | |
1199 | - // Add project specific prefs to the form |
|
1200 | - boincwork_add_project_specific_prefs($form, $prefs); |
|
1199 | + // Add project specific prefs to the form |
|
1200 | + boincwork_add_project_specific_prefs($form, $prefs); |
|
1201 | 1201 | |
1202 | - // Set whether to use this preference set by default for new computers |
|
1203 | - $form['default_set'] = array( |
|
1202 | + // Set whether to use this preference set by default for new computers |
|
1203 | + $form['default_set'] = array( |
|
1204 | 1204 | '#title' => bts('Default set', array(), NULL, 'boinc:account-preferences-project'), |
1205 | 1205 | '#type' => 'fieldset', |
1206 | 1206 | '#description' => null, |
1207 | 1207 | '#collapsible' => TRUE, |
1208 | 1208 | '#collapsed' => FALSE |
1209 | - ); |
|
1210 | - $form['default_set']['default_venue'] = array( |
|
1209 | + ); |
|
1210 | + $form['default_set']['default_venue'] = array( |
|
1211 | 1211 | '#title' => bts('Set used for new computers', array(), NULL, 'boinc:account-preferences-project'), |
1212 | 1212 | '#type' => 'radios', |
1213 | 1213 | '#options' => $form['boolean_options']['#value'], |
1214 | 1214 | '#attributes' => array('class' => 'fancy'), |
1215 | 1215 | '#default_value' => $default['default_venue'] ? 1 : 0, |
1216 | 1216 | '#description' => '' |
1217 | - ); |
|
1217 | + ); |
|
1218 | 1218 | |
1219 | - $form['prefs']['separator_bottom'] = array( |
|
1219 | + $form['prefs']['separator_bottom'] = array( |
|
1220 | 1220 | '#value' => '<div class="separator buttons"></div>' |
1221 | - ); |
|
1221 | + ); |
|
1222 | 1222 | |
1223 | - // Form control |
|
1224 | - $form['prefs']['form control tabs prefix'] = array( |
|
1223 | + // Form control |
|
1224 | + $form['prefs']['form control tabs prefix'] = array( |
|
1225 | 1225 | '#value' => '<ul class="form-control tab-list">' |
1226 | - ); |
|
1227 | - $form['prefs']['submit'] = array( |
|
1226 | + ); |
|
1227 | + $form['prefs']['submit'] = array( |
|
1228 | 1228 | '#prefix' => '<li class="first tab">', |
1229 | 1229 | '#type' => 'submit', |
1230 | 1230 | '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'), |
1231 | 1231 | '#suffix' => '</li>' |
1232 | - ); |
|
1233 | - $form['prefs']['form control tabs'] = array( |
|
1232 | + ); |
|
1233 | + $form['prefs']['form control tabs'] = array( |
|
1234 | 1234 | '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>' |
1235 | - ); |
|
1236 | - if ($venue AND $venue != 'generic') { |
|
1235 | + ); |
|
1236 | + if ($venue AND $venue != 'generic') { |
|
1237 | 1237 | global $base_path; |
1238 | 1238 | $form['prefs']['form control tabs']['#value'] .= '<li class="tab">' . |
1239 | - l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/project/clear/{$venue}", |
|
1239 | + l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/project/clear/{$venue}", |
|
1240 | 1240 | array( |
1241 | - 'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/project/combined')), |
|
1242 | - 'attributes' => array( |
|
1241 | + 'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/project/combined')), |
|
1242 | + 'attributes' => array( |
|
1243 | 1243 | 'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the @name preference set. Are you sure?', |
1244 | - array('@name' => $venue), NULL, 'boinc:account-preferences') . '\')' |
|
1245 | - ) |
|
1244 | + array('@name' => $venue), NULL, 'boinc:account-preferences') . '\')' |
|
1245 | + ) |
|
1246 | 1246 | ) |
1247 | - ) . '</li>'; |
|
1248 | - } |
|
1249 | - $form['prefs']['view control'] = array( |
|
1250 | - '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/project/combined') . '</li>' |
|
1251 | - ); |
|
1252 | - $form['prefs']['form control tabs suffix'] = array( |
|
1247 | + ) . '</li>'; |
|
1248 | + } |
|
1249 | + $form['prefs']['view control'] = array( |
|
1250 | + '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/project/combined') . '</li>' |
|
1251 | + ); |
|
1252 | + $form['prefs']['form control tabs suffix'] = array( |
|
1253 | 1253 | '#value' => '</ul>' |
1254 | - ); |
|
1254 | + ); |
|
1255 | 1255 | |
1256 | - return $form; |
|
1256 | + return $form; |
|
1257 | 1257 | } |
1258 | 1258 | |
1259 | 1259 | /** |
1260 | 1260 | * Add project specific preferences to the project preferences form |
1261 | 1261 | */ |
1262 | 1262 | function boincwork_add_project_specific_prefs(&$form, $prefs) { |
1263 | - // Load project specific preferences from XML config |
|
1264 | - $xml = boincwork_get_project_specific_config(); |
|
1263 | + // Load project specific preferences from XML config |
|
1264 | + $xml = boincwork_get_project_specific_config(); |
|
1265 | 1265 | |
1266 | - // Respect the order of the top level elements |
|
1267 | - $ordered_array = array(); |
|
1268 | - $unordered_array = array(); |
|
1269 | - foreach ($xml['project_specific_preferences'] as $type => $element) { |
|
1266 | + // Respect the order of the top level elements |
|
1267 | + $ordered_array = array(); |
|
1268 | + $unordered_array = array(); |
|
1269 | + foreach ($xml['project_specific_preferences'] as $type => $element) { |
|
1270 | 1270 | if (is_array($element) AND is_numeric(key($element))) { |
1271 | - foreach ($element as $ordered_element) { |
|
1271 | + foreach ($element as $ordered_element) { |
|
1272 | 1272 | if (isset($ordered_element['@position'])) { |
1273 | - $ordered_array[$ordered_element['@position']] = array($type => $ordered_element); |
|
1273 | + $ordered_array[$ordered_element['@position']] = array($type => $ordered_element); |
|
1274 | 1274 | } |
1275 | 1275 | else { |
1276 | - $unordered_array[] = array($type => $ordered_element); |
|
1276 | + $unordered_array[] = array($type => $ordered_element); |
|
1277 | + } |
|
1277 | 1278 | } |
1278 | - } |
|
1279 | 1279 | } |
1280 | 1280 | elseif (isset($element['@position'])) { |
1281 | - $ordered_array[$element['@position']] = array($type => $element); |
|
1281 | + $ordered_array[$element['@position']] = array($type => $element); |
|
1282 | 1282 | } |
1283 | 1283 | else { |
1284 | - $unordered_array[] = array($type => $element); |
|
1284 | + $unordered_array[] = array($type => $element); |
|
1285 | 1285 | } |
1286 | - } |
|
1287 | - ksort($ordered_array); |
|
1288 | - $primed_array = array_merge($ordered_array, $unordered_array); |
|
1289 | - $xml = array('project_specific_preferences' => $primed_array); |
|
1286 | + } |
|
1287 | + ksort($ordered_array); |
|
1288 | + $primed_array = array_merge($ordered_array, $unordered_array); |
|
1289 | + $xml = array('project_specific_preferences' => $primed_array); |
|
1290 | 1290 | |
1291 | - foreach ($xml['project_specific_preferences'] as $wrapped_element) { |
|
1291 | + foreach ($xml['project_specific_preferences'] as $wrapped_element) { |
|
1292 | 1292 | $type = key($wrapped_element); |
1293 | 1293 | $element= reset($wrapped_element); |
1294 | 1294 | boincwork_generate_prefs_element($form, $type, $element, $prefs['project_specific']); |
1295 | - } |
|
1295 | + } |
|
1296 | 1296 | } |
1297 | 1297 | |
1298 | 1298 | /** |
1299 | - * Validate the project preferences form. |
|
1300 | - */ |
|
1299 | + * Validate the project preferences form. |
|
1300 | + */ |
|
1301 | 1301 | function boincwork_projectprefs_form_validate($form, &$form_state) { |
1302 | 1302 | |
1303 | - // Verify all text user input values and notify form API of failures |
|
1304 | - $validation_rules = array( |
|
1303 | + // Verify all text user input values and notify form API of failures |
|
1304 | + $validation_rules = array( |
|
1305 | 1305 | 'resource' => array( |
1306 | - 'resource_share' => array( |
|
1306 | + 'resource_share' => array( |
|
1307 | 1307 | 'datatype' => 'integer', |
1308 | 1308 | 'min' => 0 |
1309 | - ), |
|
1309 | + ), |
|
1310 | 1310 | ), |
1311 | - ); |
|
1311 | + ); |
|
1312 | 1312 | |
1313 | - // Add validation rules for project specific settings |
|
1314 | - $validation_rules += boincwork_get_project_specific_config_validation_rules(); |
|
1313 | + // Add validation rules for project specific settings |
|
1314 | + $validation_rules += boincwork_get_project_specific_config_validation_rules(); |
|
1315 | 1315 | |
1316 | - // Perform validation |
|
1317 | - boincwork_validate_form($validation_rules, $form_state['values']); |
|
1316 | + // Perform validation |
|
1317 | + boincwork_validate_form($validation_rules, $form_state['values']); |
|
1318 | 1318 | |
1319 | - // Check for app validation |
|
1320 | - if (isset($validation_rules['apps'])) { |
|
1319 | + // Check for app validation |
|
1320 | + if (isset($validation_rules['apps'])) { |
|
1321 | 1321 | if (isset($validation_rules['apps']['minimum selected']) |
1322 | 1322 | AND $validation_rules['apps']['minimum selected'] > 0) { |
1323 | - $apps_selected = 0; |
|
1324 | - foreach ($validation_rules['apps']['list'] as $app) { |
|
1323 | + $apps_selected = 0; |
|
1324 | + foreach ($validation_rules['apps']['list'] as $app) { |
|
1325 | 1325 | if ($form_state['values']['applications'][$app]) $apps_selected++; |
1326 | - } |
|
1327 | - if ($apps_selected < $validation_rules['apps']['minimum selected']) { |
|
1326 | + } |
|
1327 | + if ($apps_selected < $validation_rules['apps']['minimum selected']) { |
|
1328 | 1328 | form_set_error( |
1329 | - 'applications', |
|
1330 | - bts('At least one application must be selected', array(), NULL, 'boinc:account-preferences-project') |
|
1329 | + 'applications', |
|
1330 | + bts('At least one application must be selected', array(), NULL, 'boinc:account-preferences-project') |
|
1331 | 1331 | ); |
1332 | - } |
|
1333 | - if ($apps_selected == count($validation_rules['apps']['list'])) { |
|
1332 | + } |
|
1333 | + if ($apps_selected == count($validation_rules['apps']['list'])) { |
|
1334 | 1334 | foreach ($validation_rules['apps']['list'] as $app) { |
1335 | - unset($form_state['values']['applications'][$app]); |
|
1335 | + unset($form_state['values']['applications'][$app]); |
|
1336 | 1336 | } |
1337 | 1337 | $form_state['storage']['all apps selected'] = TRUE; |
1338 | - } |
|
1338 | + } |
|
1339 | + } |
|
1339 | 1340 | } |
1340 | - } |
|
1341 | 1341 | } |
1342 | 1342 | |
1343 | 1343 | /** |
1344 | - * Handle post-validation submission of project preferences form. |
|
1345 | - */ |
|
1344 | + * Handle post-validation submission of project preferences form. |
|
1345 | + */ |
|
1346 | 1346 | function boincwork_projectprefs_form_submit($form, &$form_state) { |
1347 | - global $user; |
|
1348 | - global $site_name; |
|
1347 | + global $user; |
|
1348 | + global $site_name; |
|
1349 | 1349 | |
1350 | - require_boinc(array('util')); |
|
1351 | - $app_types = get_app_types(); |
|
1350 | + require_boinc(array('util')); |
|
1351 | + $app_types = get_app_types(); |
|
1352 | 1352 | |
1353 | - $account = user_load($user->uid); |
|
1354 | - $edit = $form_state['values']; |
|
1355 | - $venue = $edit['venue']; |
|
1353 | + $account = user_load($user->uid); |
|
1354 | + $edit = $form_state['values']; |
|
1355 | + $venue = $edit['venue']; |
|
1356 | 1356 | |
1357 | - // Load preferences from BOINC account |
|
1358 | - $prefs = boincwork_load_prefs('project', $venue); |
|
1357 | + // Load preferences from BOINC account |
|
1358 | + $prefs = boincwork_load_prefs('project', $venue); |
|
1359 | 1359 | |
1360 | - // Resource preferences |
|
1361 | - $prefs['resource_share'] = $edit['resource']['resource_share']; |
|
1362 | - if ($app_types->count > 1) { |
|
1360 | + // Resource preferences |
|
1361 | + $prefs['resource_share'] = $edit['resource']['resource_share']; |
|
1362 | + if ($app_types->count > 1) { |
|
1363 | 1363 | if ($app_types->cpu) $prefs['no_cpu'] = ($edit['resource']['no_cpu']) ? 0 : 1; |
1364 | 1364 | if ($app_types->cuda) $prefs['no_cuda'] = ($edit['resource']['no_cuda']) ? 0 : 1; |
1365 | 1365 | if ($app_types->ati) $prefs['no_ati'] = ($edit['resource']['no_ati']) ? 0 : 1; |
1366 | 1366 | if ($app_types->intel_gpu) $prefs['no_intel_gpu'] = ($edit['resource']['no_intel_gpu']) ? 0 : 1; |
1367 | 1367 | if ($app_types->apple_gpu) $prefs['no_apple_gpu'] = ($edit['resource']['no_apple_gpu']) ? 0 : 1; |
1368 | - } |
|
1368 | + } |
|
1369 | 1369 | |
1370 | - // Beta preferences |
|
1371 | - if (variable_get('boinc_prefs_options_beta', FALSE)) { |
|
1370 | + // Beta preferences |
|
1371 | + if (variable_get('boinc_prefs_options_beta', FALSE)) { |
|
1372 | 1372 | $prefs['allow_beta_work'] = ($edit['beta']['allow_beta_work']) ? 1 : 0; |
1373 | - } |
|
1373 | + } |
|
1374 | 1374 | |
1375 | - // Load project specific preferences from XML config |
|
1376 | - $xml = boincwork_get_project_specific_config(); |
|
1377 | - $updated_prefs = array( |
|
1375 | + // Load project specific preferences from XML config |
|
1376 | + $xml = boincwork_get_project_specific_config(); |
|
1377 | + $updated_prefs = array( |
|
1378 | 1378 | 'project_specific' => boincwork_format_project_specific_prefs_data($edit) |
1379 | - ); |
|
1380 | - $prefs = $updated_prefs + $prefs; |
|
1379 | + ); |
|
1380 | + $prefs = $updated_prefs + $prefs; |
|
1381 | 1381 | |
1382 | - // Don't specify apps if all are selected |
|
1383 | - if (isset($form_state['storage']['all apps selected'])) { |
|
1382 | + // Don't specify apps if all are selected |
|
1383 | + if (isset($form_state['storage']['all apps selected'])) { |
|
1384 | 1384 | unset($prefs['project_specific']['app_id']); |
1385 | 1385 | unset($form_state['storage']['all apps selected']); |
1386 | - } |
|
1386 | + } |
|
1387 | 1387 | |
1388 | - // If this is a new preference set, be sure to unset the "cleared" attribute |
|
1389 | - if (isset($prefs['@attributes']['cleared'])) { |
|
1388 | + // If this is a new preference set, be sure to unset the "cleared" attribute |
|
1389 | + if (isset($prefs['@attributes']['cleared'])) { |
|
1390 | 1390 | unset($prefs['@attributes']['cleared']); |
1391 | - } |
|
1391 | + } |
|
1392 | 1392 | |
1393 | - // Save preferences back to the BOINC account |
|
1394 | - $result = boincwork_save_prefs($prefs, 'project', $venue); |
|
1393 | + // Save preferences back to the BOINC account |
|
1394 | + $result = boincwork_save_prefs($prefs, 'project', $venue); |
|
1395 | 1395 | |
1396 | - // Update the user's default preference set |
|
1397 | - if ($edit['default_set']['default_venue']) { |
|
1396 | + // Update the user's default preference set |
|
1397 | + if ($edit['default_set']['default_venue']) { |
|
1398 | 1398 | boincwork_set_default_venue($venue); |
1399 | - } |
|
1400 | - elseif ($venue == $account->boincuser_default_pref_set) { |
|
1399 | + } |
|
1400 | + elseif ($venue == $account->boincuser_default_pref_set) { |
|
1401 | 1401 | // User has cleared out the default venue setting |
1402 | 1402 | boincwork_set_default_venue(); |
1403 | - } |
|
1403 | + } |
|
1404 | 1404 | |
1405 | - if (!$result) { |
|
1405 | + if (!$result) { |
|
1406 | 1406 | watchdog('boincwork', 'Error updating project prefs for user @id: @message', array('@id' => $user->id, '@message' => mysqli_error()), WATCHDOG_ERROR); |
1407 | 1407 | drupal_set_message(t('Your changes could not be saved. Please contact support!'), 'error'); |
1408 | - } |
|
1409 | - elseif (!drupal_get_messages('status', FALSE)) { |
|
1408 | + } |
|
1409 | + elseif (!drupal_get_messages('status', FALSE)) { |
|
1410 | 1410 | // Show this message if the set wasn't created automatically (in which case |
1411 | 1411 | // there is a message tailored to that) |
1412 | 1412 | drupal_set_message(t('Your preferences have been updated. |
@@ -1414,53 +1414,53 @@ discard block |
||
1414 | 1414 | communicates with @project or you issue the "Update" |
1415 | 1415 | command from the BOINC client.', |
1416 | 1416 | array('@project' => $site_name))); |
1417 | - } |
|
1417 | + } |
|
1418 | 1418 | } |
1419 | 1419 | |
1420 | 1420 | /** |
1421 | 1421 | * The structure of the community preferences form |
1422 | 1422 | */ |
1423 | 1423 | function communityprefs_form(&$form_state) { |
1424 | - global $user; |
|
1425 | - $account = user_load($user->uid); |
|
1426 | - $form = array(); |
|
1427 | - |
|
1428 | - // Pull in some elements from the profile form |
|
1429 | - $profile_form_state = array(); |
|
1430 | - $profile = new stdClass(); |
|
1431 | - $profile->type = 'profile'; |
|
1432 | - $profile->language = ''; |
|
1433 | - if ($profile_nid = content_profile_profile_exists($profile, $account->uid)) { |
|
1424 | + global $user; |
|
1425 | + $account = user_load($user->uid); |
|
1426 | + $form = array(); |
|
1427 | + |
|
1428 | + // Pull in some elements from the profile form |
|
1429 | + $profile_form_state = array(); |
|
1430 | + $profile = new stdClass(); |
|
1431 | + $profile->type = 'profile'; |
|
1432 | + $profile->language = ''; |
|
1433 | + if ($profile_nid = content_profile_profile_exists($profile, $account->uid)) { |
|
1434 | 1434 | $profile_node = node_load($profile_nid); |
1435 | 1435 | $form_state['storage']['profile_node'] = $profile_node; |
1436 | 1436 | module_load_include('inc', 'node', 'node.pages'); |
1437 | 1437 | $profile_form = drupal_retrieve_form('profile_node_form', $profile_form_state, $profile_node); |
1438 | 1438 | drupal_prepare_form('profile_node_form', $profile_form, $profile_form_state); |
1439 | - } |
|
1439 | + } |
|
1440 | 1440 | |
1441 | - // Standard option sets |
|
1442 | - $form['boolean_options'] = array( |
|
1441 | + // Standard option sets |
|
1442 | + $form['boolean_options'] = array( |
|
1443 | 1443 | '#type' => 'value', |
1444 | 1444 | '#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')) |
1445 | - ); |
|
1445 | + ); |
|
1446 | 1446 | |
1447 | - $default = array( |
|
1447 | + $default = array( |
|
1448 | 1448 | 'pm_send_notification' => '', // This is set already in pm_email_notify_user |
1449 | 1449 | 'friend_notification' => isset($account->friend_notification) ? $account->friend_notification : 0, |
1450 | 1450 | '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), |
1451 | 1451 | 'comments_order' => (isset($account->sort) AND $account->sort) ? $account->sort : variable_get('comment_default_order_forum', COMMENT_ORDER_OLDEST_FIRST), |
1452 | - ); |
|
1452 | + ); |
|
1453 | 1453 | |
1454 | - // General options |
|
1455 | - $form['general'] = array( |
|
1454 | + // General options |
|
1455 | + $form['general'] = array( |
|
1456 | 1456 | '#type' => 'fieldset', |
1457 | 1457 | '#title' => bts('General settings', array(), NULL, 'boinc:account-preferences-community'), |
1458 | 1458 | '#weight' => 0, |
1459 | 1459 | '#collapsible' => TRUE, |
1460 | 1460 | '#collapsed' => FALSE |
1461 | - ); |
|
1462 | - // Add the BOINC user name (non-unique, user editable) |
|
1463 | - $form['general']['boincuser_name'] = array( |
|
1461 | + ); |
|
1462 | + // Add the BOINC user name (non-unique, user editable) |
|
1463 | + $form['general']['boincuser_name'] = array( |
|
1464 | 1464 | '#type' => 'textfield', |
1465 | 1465 | '#title' => bts('Name', array(), NULL, 'boinc:user-or-team-name'), |
1466 | 1466 | '#default_value' => $account->boincuser_name, |
@@ -1468,252 +1468,252 @@ discard block |
||
1468 | 1468 | '#required' => TRUE, |
1469 | 1469 | '#description' => '', |
1470 | 1470 | '#size' => 40 |
1471 | - ); |
|
1472 | - // Time zone |
|
1473 | - if (variable_get('configurable_timezones', 1)) { |
|
1471 | + ); |
|
1472 | + // Time zone |
|
1473 | + if (variable_get('configurable_timezones', 1)) { |
|
1474 | 1474 | $zones = _system_zonelist(); |
1475 | 1475 | $form['general']['timezone'] = array( |
1476 | - '#type' => 'select', |
|
1477 | - '#title' => bts('Time zone', array(), NULL, 'boinc:account-preferences-community'), |
|
1478 | - '#default_value' => ($account->timezone !== NULL) ? $account->timezone : variable_get('date_default_timezone', 0), |
|
1479 | - '#options' => $zones, |
|
1480 | - '#description' => '', |
|
1476 | + '#type' => 'select', |
|
1477 | + '#title' => bts('Time zone', array(), NULL, 'boinc:account-preferences-community'), |
|
1478 | + '#default_value' => ($account->timezone !== NULL) ? $account->timezone : variable_get('date_default_timezone', 0), |
|
1479 | + '#options' => $zones, |
|
1480 | + '#description' => '', |
|
1481 | 1481 | ); |
1482 | - } |
|
1482 | + } |
|
1483 | 1483 | |
1484 | - // Notification options |
|
1485 | - $form['notifications'] = array( |
|
1484 | + // Notification options |
|
1485 | + $form['notifications'] = array( |
|
1486 | 1486 | '#type' => 'fieldset', |
1487 | 1487 | '#title' => bts('Notification settings', array(), NULL, 'boinc:account-preferences-community'), |
1488 | 1488 | '#weight' => 5, |
1489 | 1489 | '#collapsible' => TRUE, |
1490 | 1490 | '#collapsed' => FALSE |
1491 | - ); |
|
1492 | - // Pull in private message notification handling and tweak the form |
|
1493 | - $pm_notify = pm_email_notify_user('form', $edit, $account, 'account'); |
|
1494 | - $form['notifications']['pm_send_notifications'] = array_replace( |
|
1491 | + ); |
|
1492 | + // Pull in private message notification handling and tweak the form |
|
1493 | + $pm_notify = pm_email_notify_user('form', $edit, $account, 'account'); |
|
1494 | + $form['notifications']['pm_send_notifications'] = array_replace( |
|
1495 | 1495 | $pm_notify['enable_pm_mail']['pm_send_notifications'], |
1496 | 1496 | array( |
1497 | - '#type' => 'radios', |
|
1498 | - '#title' => bts('Receive email notification for private messages?', array(), NULL, 'boinc:account-preferences-community'), |
|
1499 | - '#description' => ' ', |
|
1500 | - '#options' => $form['boolean_options']['#value'], |
|
1501 | - '#attributes' => array('class' => 'fancy') |
|
1497 | + '#type' => 'radios', |
|
1498 | + '#title' => bts('Receive email notification for private messages?', array(), NULL, 'boinc:account-preferences-community'), |
|
1499 | + '#description' => ' ', |
|
1500 | + '#options' => $form['boolean_options']['#value'], |
|
1501 | + '#attributes' => array('class' => 'fancy') |
|
1502 | 1502 | ) |
1503 | - ); |
|
1504 | - $form['notifications']['friend_notification'] = array( |
|
1503 | + ); |
|
1504 | + $form['notifications']['friend_notification'] = array( |
|
1505 | 1505 | '#type' => 'radios', |
1506 | 1506 | '#title' => bts('Receive email notification for friend requests?', array(), NULL, 'boinc:account-preferences-community'), |
1507 | 1507 | '#description' => ' ', |
1508 | 1508 | '#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')), |
1509 | 1509 | '#attributes' => array('class' => 'fancy'), |
1510 | 1510 | '#default_value' => $default['friend_notification'] |
1511 | - ); |
|
1511 | + ); |
|
1512 | 1512 | |
1513 | - // Internationalization options |
|
1514 | - if (module_exists('internationalization')) { |
|
1513 | + // Internationalization options |
|
1514 | + if (module_exists('internationalization')) { |
|
1515 | 1515 | $languages = language_list('enabled'); |
1516 | 1516 | $languages = $languages[1]; |
1517 | 1517 | $names = array(); |
1518 | 1518 | foreach ($languages as $langcode => $item) { |
1519 | - $name = t($item->name); |
|
1520 | - $names[check_plain($langcode)] = check_plain($name . ($item->native != $name ? ' ('. $item->native .')' : '')); |
|
1519 | + $name = t($item->name); |
|
1520 | + $names[check_plain($langcode)] = check_plain($name . ($item->native != $name ? ' ('. $item->native .')' : '')); |
|
1521 | 1521 | } |
1522 | 1522 | $form['locale'] = array( |
1523 | - '#type' => 'fieldset', |
|
1524 | - '#title' => bts('Language settings', array(), NULL, 'boinc:account-preferences-community'), |
|
1525 | - '#weight' => 10, |
|
1526 | - '#collapsible' => TRUE, |
|
1527 | - '#collapsed' => FALSE, |
|
1523 | + '#type' => 'fieldset', |
|
1524 | + '#title' => bts('Language settings', array(), NULL, 'boinc:account-preferences-community'), |
|
1525 | + '#weight' => 10, |
|
1526 | + '#collapsible' => TRUE, |
|
1527 | + '#collapsed' => FALSE, |
|
1528 | 1528 | ); |
1529 | 1529 | |
1530 | 1530 | // Get language negotiation settings. |
1531 | 1531 | $mode = variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE); |
1532 | 1532 | $user_preferred_language = user_preferred_language($account); |
1533 | 1533 | $form['locale']['language'] = array( |
1534 | - '#type' => 'select', |
|
1535 | - '#title' => bts('Language', array(), NULL, 'boinc:account-preferences-community'), |
|
1536 | - '#default_value' => check_plain($user_preferred_language->language), |
|
1537 | - '#options' => $names, |
|
1538 | - '#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'), |
|
1534 | + '#type' => 'select', |
|
1535 | + '#title' => bts('Language', array(), NULL, 'boinc:account-preferences-community'), |
|
1536 | + '#default_value' => check_plain($user_preferred_language->language), |
|
1537 | + '#options' => $names, |
|
1538 | + '#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'), |
|
1539 | 1539 | ); |
1540 | - } |
|
1540 | + } |
|
1541 | 1541 | |
1542 | - // Avatar options |
|
1543 | - $form['gravatar'] = array( |
|
1542 | + // Avatar options |
|
1543 | + $form['gravatar'] = array( |
|
1544 | 1544 | '#type' => 'item', |
1545 | 1545 | '#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'), |
1546 | 1546 | '#description' => bts('Your Gravatar will not be shown if you upload a user picture.', array(), NULL, 'boinc:account-preferences-community'), |
1547 | - ); |
|
1548 | - if (user_access('disable own gravatar', $account)) { |
|
1547 | + ); |
|
1548 | + if (user_access('disable own gravatar', $account)) { |
|
1549 | 1549 | $form['gravatar'] = array( |
1550 | - '#type' => 'checkbox', |
|
1551 | - '#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'), |
|
1552 | - '#description' => bts('Gravatar will not be shown if an avatar is uploaded.', array(), NULL, 'boinc:account-preferences-community'), |
|
1553 | - '#default_value' => isset($account->gravatar) ? $account->gravatar : 0, |
|
1554 | - '#disabled' => !empty($account->picture), |
|
1555 | - ); |
|
1556 | - } |
|
1557 | - $form['gravatar']['#weight'] = 15; |
|
1558 | - $form['gravatar']['#prefix'] = '<fieldset class="collapsible"><legend><a href="#">' . bts('Avatar settings', array(), NULL, 'boinc:account-preferences-community') . '</a></legend>'; |
|
1559 | - // Upload an avatar (pulled from profile_node_form): |
|
1560 | - if (!empty($profile_form['field_image'])) { |
|
1550 | + '#type' => 'checkbox', |
|
1551 | + '#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'), |
|
1552 | + '#description' => bts('Gravatar will not be shown if an avatar is uploaded.', array(), NULL, 'boinc:account-preferences-community'), |
|
1553 | + '#default_value' => isset($account->gravatar) ? $account->gravatar : 0, |
|
1554 | + '#disabled' => !empty($account->picture), |
|
1555 | + ); |
|
1556 | + } |
|
1557 | + $form['gravatar']['#weight'] = 15; |
|
1558 | + $form['gravatar']['#prefix'] = '<fieldset class="collapsible"><legend><a href="#">' . bts('Avatar settings', array(), NULL, 'boinc:account-preferences-community') . '</a></legend>'; |
|
1559 | + // Upload an avatar (pulled from profile_node_form): |
|
1560 | + if (!empty($profile_form['field_image'])) { |
|
1561 | 1561 | $form['field_image'] = $profile_form['field_image']; |
1562 | - } |
|
1563 | - else { |
|
1562 | + } |
|
1563 | + else { |
|
1564 | 1564 | $form['field_image'] = array( |
1565 | - '#value' => '<div class="form-item">' |
|
1565 | + '#value' => '<div class="form-item">' |
|
1566 | 1566 | . '<label class="placeholder">' |
1567 | 1567 | . bts('This is not available until your profile is set up.', array(), NULL, 'boinc:account-preferences-community') |
1568 | 1568 | . '</label>' |
1569 | 1569 | . l(bts('Create a profile', array(), NULL, 'boinc:account-preferences-community'), 'account/profile/edit', array('attributes' => array('class' => 'form-link'))) |
1570 | 1570 | . '</div>', |
1571 | 1571 | ); |
1572 | - } |
|
1573 | - $form['field_image'][0]['#title'] = bts('Upload an avatar', array(), NULL, 'boinc:account-preferences-community'); |
|
1574 | - $form['field_image']['#weight'] = 20; |
|
1575 | - $form['field_image']['#suffix'] = '</fieldset>'; |
|
1572 | + } |
|
1573 | + $form['field_image'][0]['#title'] = bts('Upload an avatar', array(), NULL, 'boinc:account-preferences-community'); |
|
1574 | + $form['field_image']['#weight'] = 20; |
|
1575 | + $form['field_image']['#suffix'] = '</fieldset>'; |
|
1576 | 1576 | |
1577 | - // Forum options |
|
1578 | - $form['forums'] = array( |
|
1577 | + // Forum options |
|
1578 | + $form['forums'] = array( |
|
1579 | 1579 | '#type' => 'fieldset', |
1580 | 1580 | '#title' => bts('Forum settings', array(), NULL, 'boinc:account-preferences-community'), |
1581 | 1581 | '#weight' => 25, |
1582 | 1582 | '#collapsible' => TRUE, |
1583 | 1583 | '#collapsed' => FALSE |
1584 | - ); |
|
1585 | - $form['forums']['comments_per_page'] = array( |
|
1584 | + ); |
|
1585 | + $form['forums']['comments_per_page'] = array( |
|
1586 | 1586 | '#type' => 'select', |
1587 | 1587 | '#title' => bts('In discussion topics, show at most @comments_per_page', array('@comments_per_page' => ''), NULL, 'boinc:account-preferences-community'), |
1588 | 1588 | '#options' => array(10 => 10, 20 => 20, 30 => 30, 50 => 50, 100 => 100), |
1589 | 1589 | '#default_value' => $default['comments_per_page'] |
1590 | - ); |
|
1591 | - // Can't have a typical Drupal form suffix on a select box? |
|
1592 | - $form['forums']['comments_per_page_suffix'] = array( |
|
1590 | + ); |
|
1591 | + // Can't have a typical Drupal form suffix on a select box? |
|
1592 | + $form['forums']['comments_per_page_suffix'] = array( |
|
1593 | 1593 | '#value' => '<span>' . bts('comments per page', array(), NULL, 'boinc:account-preferences-community') . '</span>' |
1594 | - ); |
|
1595 | - $form['forums']['comments_order'] = array( |
|
1594 | + ); |
|
1595 | + $form['forums']['comments_order'] = array( |
|
1596 | 1596 | '#type' => 'select', |
1597 | 1597 | '#title' => bts('Sort comments in discussions', array(), NULL, 'boinc:account-preferences-community'), |
1598 | 1598 | '#options' => array(1 => bts('Newest post first', array(), NULL, 'boinc:account-preferences-community'), 2 => bts('Oldest post first', array(), NULL, 'boinc:account-preferences-community')), |
1599 | 1599 | '#default_value' => $default['comments_order'] |
1600 | - ); |
|
1601 | - // Signature (pulled from user_edit_form): |
|
1602 | - if (variable_get('user_signatures', 0) && module_exists('comment')) { |
|
1600 | + ); |
|
1601 | + // Signature (pulled from user_edit_form): |
|
1602 | + if (variable_get('user_signatures', 0) && module_exists('comment')) { |
|
1603 | 1603 | $form['forums']['signature'] = array( |
1604 | - '#type' => 'textarea', |
|
1605 | - '#title' => bts('Signature', array(), NULL, 'boinc:account-preferences-community'), |
|
1606 | - '#description' => bts('Your signature will be publicly displayed at the end of your comments.', array(), NULL, 'boinc:account-preferences-community'), |
|
1607 | - '#default_value' => $account->signature |
|
1608 | - ); |
|
1604 | + '#type' => 'textarea', |
|
1605 | + '#title' => bts('Signature', array(), NULL, 'boinc:account-preferences-community'), |
|
1606 | + '#description' => bts('Your signature will be publicly displayed at the end of your comments.', array(), NULL, 'boinc:account-preferences-community'), |
|
1607 | + '#default_value' => $account->signature |
|
1608 | + ); |
|
1609 | 1609 | // Prevent a "validation error" message when the user attempts to save with a default value they |
1610 | 1610 | // do not have access to. |
1611 | 1611 | if (!filter_access($account->signature_format) && empty($_POST)) { |
1612 | - 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.")); |
|
1613 | - $edit['signature_format'] = FILTER_FORMAT_DEFAULT; |
|
1612 | + 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.")); |
|
1613 | + $edit['signature_format'] = FILTER_FORMAT_DEFAULT; |
|
1614 | 1614 | } |
1615 | 1615 | $form['forums']['signature_format'] = filter_form($account->signature_format, NULL, array('signature_format')); |
1616 | 1616 | // Optionally hide signatures from comments |
1617 | 1617 | $form['forums']['hide_signatures'] = array( |
1618 | - '#type' => 'radios', |
|
1619 | - '#title' => bts('Hide signatures in forums', array(), NULL, 'boinc:account-preferences-community'), |
|
1620 | - '#description' => ' ', |
|
1621 | - '#options' => $form['boolean_options']['#value'], |
|
1622 | - '#attributes' => array('class' => 'fancy'), |
|
1623 | - '#default_value' => isset($account->hide_signatures) ? $account->hide_signatures : 0, |
|
1618 | + '#type' => 'radios', |
|
1619 | + '#title' => bts('Hide signatures in forums', array(), NULL, 'boinc:account-preferences-community'), |
|
1620 | + '#description' => ' ', |
|
1621 | + '#options' => $form['boolean_options']['#value'], |
|
1622 | + '#attributes' => array('class' => 'fancy'), |
|
1623 | + '#default_value' => isset($account->hide_signatures) ? $account->hide_signatures : 0, |
|
1624 | 1624 | ); |
1625 | - } |
|
1625 | + } |
|
1626 | 1626 | |
1627 | - //Bottom separator |
|
1628 | - $form['separator_bottom'] = array( |
|
1627 | + //Bottom separator |
|
1628 | + $form['separator_bottom'] = array( |
|
1629 | 1629 | '#value' => '<div class="separator buttons"></div>', |
1630 | 1630 | '#weight' => 999, |
1631 | - ); |
|
1631 | + ); |
|
1632 | 1632 | |
1633 | - // Form control |
|
1634 | - $form['form control tabs prefix'] = array( |
|
1633 | + // Form control |
|
1634 | + $form['form control tabs prefix'] = array( |
|
1635 | 1635 | '#value' => '<ul class="form-control tab-list">', |
1636 | 1636 | '#weight' => 1001, |
1637 | - ); |
|
1638 | - $form['submit'] = array( |
|
1637 | + ); |
|
1638 | + $form['submit'] = array( |
|
1639 | 1639 | '#prefix' => '<li class="first tab">', |
1640 | 1640 | '#type' => 'submit', |
1641 | 1641 | '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'), |
1642 | 1642 | '#suffix' => '</li>', |
1643 | 1643 | '#weight' => 1002, |
1644 | - ); |
|
1645 | - $form['form control tabs'] = array( |
|
1644 | + ); |
|
1645 | + $form['form control tabs'] = array( |
|
1646 | 1646 | '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
1647 | 1647 | '#weight' => 1003, |
1648 | - ); |
|
1649 | - $form['form control tabs suffix'] = array( |
|
1648 | + ); |
|
1649 | + $form['form control tabs suffix'] = array( |
|
1650 | 1650 | '#value' => '</ul>', |
1651 | 1651 | '#weight' => 1004, |
1652 | - ); |
|
1653 | - return $form; |
|
1652 | + ); |
|
1653 | + return $form; |
|
1654 | 1654 | } |
1655 | 1655 | |
1656 | 1656 | /** |
1657 | - * Handle validation submission of community preferences form. |
|
1658 | - */ |
|
1657 | + * Handle validation submission of community preferences form. |
|
1658 | + */ |
|
1659 | 1659 | function communityprefs_form_validate($form, &$form_state) { |
1660 | - // require_boinc(); |
|
1661 | - global $user; |
|
1662 | - $account = user_load($user->uid); |
|
1663 | - $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
1664 | - $edit = $form_state['values']; |
|
1660 | + // require_boinc(); |
|
1661 | + global $user; |
|
1662 | + $account = user_load($user->uid); |
|
1663 | + $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
1664 | + $edit = $form_state['values']; |
|
1665 | 1665 | |
1666 | - if ($edit['boincuser_name'] != $boinc_user->name) { |
|
1666 | + if ($edit['boincuser_name'] != $boinc_user->name) { |
|
1667 | 1667 | $blacklist1 = preg_split('/\r\n|\r|\n/', variable_get('boinc_weboptions_blacklisted_usernames', "admin\nadministrator\nmoderator")); |
1668 | 1668 | $blacklist2 = array(); |
1669 | 1669 | if (is_array($blacklist1)) { |
1670 | - $blacklist2 = array_map('strtolower', $blacklist1); |
|
1670 | + $blacklist2 = array_map('strtolower', $blacklist1); |
|
1671 | 1671 | } |
1672 | 1672 | if (in_array(strtolower($edit['boincuser_name']), $blacklist2)) { |
1673 | - form_set_error('boincuser_name', |
|
1673 | + form_set_error('boincuser_name', |
|
1674 | 1674 | bts('You may not use username @blname, as that name is not allowed. Please choose another name.', |
1675 | 1675 | array('@blname' => $edit['boincuser_name']), |
1676 | 1676 | NULL, 'boinc:account-preferences-community')); |
1677 | - return false; |
|
1677 | + return false; |
|
1678 | + } |
|
1678 | 1679 | } |
1679 | - } |
|
1680 | 1680 | |
1681 | - return true; |
|
1681 | + return true; |
|
1682 | 1682 | } |
1683 | 1683 | |
1684 | 1684 | /** |
1685 | - * Handle post-validation submission of community preferences form. |
|
1686 | - */ |
|
1685 | + * Handle post-validation submission of community preferences form. |
|
1686 | + */ |
|
1687 | 1687 | function communityprefs_form_submit($form, &$form_state) { |
1688 | - require_boinc('boinc_db'); |
|
1689 | - global $user; |
|
1690 | - $account = user_load($user->uid); |
|
1691 | - $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
1692 | - $edit = $form_state['values']; |
|
1693 | - $profile_node = $form_state['storage']['profile_node']; |
|
1694 | - |
|
1695 | - // Display name |
|
1696 | - if ($edit['boincuser_name'] != $boinc_user->name) { |
|
1688 | + require_boinc('boinc_db'); |
|
1689 | + global $user; |
|
1690 | + $account = user_load($user->uid); |
|
1691 | + $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
1692 | + $edit = $form_state['values']; |
|
1693 | + $profile_node = $form_state['storage']['profile_node']; |
|
1694 | + |
|
1695 | + // Display name |
|
1696 | + if ($edit['boincuser_name'] != $boinc_user->name) { |
|
1697 | 1697 | $boincuser_name = $edit['boincuser_name']; |
1698 | 1698 | $result = $boinc_user->update( |
1699 | 1699 | "name='{$boincuser_name}'" |
1700 | 1700 | ); |
1701 | - } |
|
1701 | + } |
|
1702 | 1702 | |
1703 | - // Private message settings |
|
1704 | - pm_email_notify_user('submit', $edit, $user); |
|
1703 | + // Private message settings |
|
1704 | + pm_email_notify_user('submit', $edit, $user); |
|
1705 | 1705 | |
1706 | - // Avatar settings - only set if profile_node exists. |
|
1707 | - if ($profile_node) { |
|
1706 | + // Avatar settings - only set if profile_node exists. |
|
1707 | + if ($profile_node) { |
|
1708 | 1708 | if (!$edit['field_image']) $edit['field_image'] = array(); |
1709 | 1709 | $profile_node->field_image = $edit['field_image']; |
1710 | 1710 | node_save($profile_node); |
1711 | 1711 | // Flush this from the node cache or changes won't show up immediately! |
1712 | 1712 | $profile_node = node_load($profile_node->nid, NULL, TRUE); |
1713 | - } |
|
1713 | + } |
|
1714 | 1714 | |
1715 | - // All other settings |
|
1716 | - $settings = array( |
|
1715 | + // All other settings |
|
1716 | + $settings = array( |
|
1717 | 1717 | 'signature' => $edit['signature'], |
1718 | 1718 | 'signature_format' => $edit['signature_format'], |
1719 | 1719 | 'timezone' => $edit['timezone'], |
@@ -1722,197 +1722,197 @@ discard block |
||
1722 | 1722 | 'hide_signatures' => $edit['hide_signatures'], |
1723 | 1723 | 'sort' => $edit['comments_order'], |
1724 | 1724 | 'gravatar' => $edit['gravatar'], |
1725 | - ); |
|
1726 | - if (module_exists('internationalization')) { |
|
1725 | + ); |
|
1726 | + if (module_exists('internationalization')) { |
|
1727 | 1727 | $settings['language'] = $edit['language']; |
1728 | 1728 | global $language; |
1729 | 1729 | if ($user->language != $edit['language']) { |
1730 | - global $base_url; |
|
1731 | - if ($edit['language'] != language_default('language')) { |
|
1730 | + global $base_url; |
|
1731 | + if ($edit['language'] != language_default('language')) { |
|
1732 | 1732 | $form_state['redirect'] = $base_url . '/' . $edit['language'] . '/' . $_GET['q']; |
1733 | - } |
|
1734 | - else { |
|
1733 | + } |
|
1734 | + else { |
|
1735 | 1735 | $form_state['redirect'] = $base_url . '/' . $_GET['q']; |
1736 | - } |
|
1736 | + } |
|
1737 | + } |
|
1737 | 1738 | } |
1738 | - } |
|
1739 | - user_save($user, $settings); |
|
1739 | + user_save($user, $settings); |
|
1740 | 1740 | |
1741 | - drupal_set_message(bts('Your community preferences have been updated.', array(), NULL, 'boinc:account-preferences-community')); |
|
1741 | + drupal_set_message(bts('Your community preferences have been updated.', array(), NULL, 'boinc:account-preferences-community')); |
|
1742 | 1742 | |
1743 | - // Form will not redirect if storage is set; not good if language changes |
|
1744 | - unset($form_state['storage']); |
|
1743 | + // Form will not redirect if storage is set; not good if language changes |
|
1744 | + unset($form_state['storage']); |
|
1745 | 1745 | } |
1746 | 1746 | |
1747 | 1747 | /** |
1748 | 1748 | * The structure of the privacy preferences form |
1749 | 1749 | */ |
1750 | 1750 | function boincwork_privacyprefs_form(&$form_state) { |
1751 | - require_boinc(array('user', 'prefs', 'util', 'consent')); |
|
1751 | + require_boinc(array('user', 'prefs', 'util', 'consent')); |
|
1752 | 1752 | |
1753 | - global $user; |
|
1754 | - $account = user_load($user->uid); |
|
1755 | - $boincuser = BoincUser::lookup_id($account->boincuser_id); |
|
1753 | + global $user; |
|
1754 | + $account = user_load($user->uid); |
|
1755 | + $boincuser = BoincUser::lookup_id($account->boincuser_id); |
|
1756 | 1756 | |
1757 | - // Load preferences from BOINC account |
|
1758 | - $prefs = boincwork_load_prefs('project'); |
|
1757 | + // Load preferences from BOINC account |
|
1758 | + $prefs = boincwork_load_prefs('project'); |
|
1759 | 1759 | |
1760 | - //if (!$prefs AND !$initialize_if_empty) return null; |
|
1760 | + //if (!$prefs AND !$initialize_if_empty) return null; |
|
1761 | 1761 | |
1762 | - $privacy_consent_types = boincwork_load_privacyconsenttypes(); |
|
1762 | + $privacy_consent_types = boincwork_load_privacyconsenttypes(); |
|
1763 | 1763 | |
1764 | - // Define form defaults |
|
1765 | - $default = array( |
|
1764 | + // Define form defaults |
|
1765 | + $default = array( |
|
1766 | 1766 | 'privacy' => array( |
1767 | - 'send_email' => ($boincuser->send_email) ? 1 : 0, |
|
1768 | - 'show_hosts' => ($boincuser->show_hosts) ? 1 : 0 |
|
1767 | + 'send_email' => ($boincuser->send_email) ? 1 : 0, |
|
1768 | + 'show_hosts' => ($boincuser->show_hosts) ? 1 : 0 |
|
1769 | 1769 | ) |
1770 | - ); |
|
1770 | + ); |
|
1771 | 1771 | |
1772 | - // Standard option sets |
|
1773 | - $form['boolean_options'] = array( |
|
1772 | + // Standard option sets |
|
1773 | + $form['boolean_options'] = array( |
|
1774 | 1774 | '#type' => 'value', |
1775 | 1775 | '#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')) |
1776 | - ); |
|
1776 | + ); |
|
1777 | 1777 | |
1778 | - $form['privacy'] = array( |
|
1778 | + $form['privacy'] = array( |
|
1779 | 1779 | '#title' => bts('Privacy settings', array(), NULL, 'boinc:account-preferences-privacy'), |
1780 | 1780 | '#type' => 'fieldset', |
1781 | 1781 | '#description' => null, |
1782 | 1782 | '#collapsible' => TRUE, |
1783 | 1783 | '#collapsed' => FALSE |
1784 | - ); |
|
1785 | - $form['privacy']['send_email'] = array( |
|
1784 | + ); |
|
1785 | + $form['privacy']['send_email'] = array( |
|
1786 | 1786 | '#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'), |
1787 | 1787 | '#type' => 'radios', |
1788 | 1788 | '#options' => $form['boolean_options']['#value'], |
1789 | 1789 | '#attributes' => array('class' => 'fancy'), |
1790 | 1790 | '#default_value' => $default['privacy']['send_email'] |
1791 | - ); |
|
1792 | - $form['privacy']['show_hosts'] = array( |
|
1791 | + ); |
|
1792 | + $form['privacy']['show_hosts'] = array( |
|
1793 | 1793 | '#title' => bts('Should @project show your computers on its website?', array('@project' => variable_get('site_name', 'Drupal-BOINC')), NULL, 'boinc:account-preferences-privacy'), |
1794 | 1794 | '#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'), |
1795 | 1795 | '#type' => 'radios', |
1796 | 1796 | '#options' => $form['boolean_options']['#value'], |
1797 | 1797 | '#attributes' => array('class' => 'fancy'), |
1798 | 1798 | '#default_value' => $default['privacy']['show_hosts'] |
1799 | - ); |
|
1799 | + ); |
|
1800 | 1800 | |
1801 | - // Loop over privacy consent types and create form question for each |
|
1802 | - // option that deals with privacy. |
|
1803 | - foreach ($privacy_consent_types as $ct) { |
|
1801 | + // Loop over privacy consent types and create form question for each |
|
1802 | + // option that deals with privacy. |
|
1803 | + foreach ($privacy_consent_types as $ct) { |
|
1804 | 1804 | |
1805 | 1805 | $currstate = (check_user_consent($boincuser, $ct['shortname'])) ? 1 : 0 ; |
1806 | 1806 | // Set name to 'privacyconsent_SHORTNAME', which can be parsed |
1807 | 1807 | // later in the submit function. |
1808 | 1808 | $form['privacy']['privacyconsent_'.$ct['shortname']] = array( |
1809 | - '#title' => bts($ct['description'], array(), NULL, 'boinc:account-preferences-privacy'), |
|
1810 | - '#type' => 'radios', |
|
1811 | - '#options' => $form['boolean_options']['#value'], |
|
1812 | - '#attributes' => array('class' => 'fancy'), |
|
1813 | - '#default_value' => $currstate, |
|
1809 | + '#title' => bts($ct['description'], array(), NULL, 'boinc:account-preferences-privacy'), |
|
1810 | + '#type' => 'radios', |
|
1811 | + '#options' => $form['boolean_options']['#value'], |
|
1812 | + '#attributes' => array('class' => 'fancy'), |
|
1813 | + '#default_value' => $currstate, |
|
1814 | 1814 | ); |
1815 | 1815 | |
1816 | 1816 | // Add a description with link to the question 'Do you consent to |
1817 | 1817 | // exporting your data...'. |
1818 | 1818 | $mypatt = '/Do you consent to exporting your data/'; |
1819 | 1819 | if (preg_match($mypatt, $ct['description']) ) { |
1820 | - $form['privacy']['privacyconsent_'.$ct['shortname']]['#description'] = bts('See our !privacy_policy_link for the current list of statistics exports.', |
|
1821 | - array( |
|
1820 | + $form['privacy']['privacyconsent_'.$ct['shortname']]['#description'] = bts('See our !privacy_policy_link for the current list of statistics exports.', |
|
1821 | + array( |
|
1822 | 1822 | '!privacy_policy_link' => l( |
1823 | - bts('privacy policy', array(), NULL, 'boinc:account-preferences-privacy'), |
|
1824 | - '/privacy' |
|
1823 | + bts('privacy policy', array(), NULL, 'boinc:account-preferences-privacy'), |
|
1824 | + '/privacy' |
|
1825 | 1825 | ) |
1826 | - ), |
|
1827 | - NULL, 'boinc:account-preferences-privacy'); |
|
1826 | + ), |
|
1827 | + NULL, 'boinc:account-preferences-privacy'); |
|
1828 | + } |
|
1828 | 1829 | } |
1829 | - } |
|
1830 | 1830 | |
1831 | - // Ignore and block users |
|
1832 | - if (module_exists('ignore_user')) { |
|
1831 | + // Ignore and block users |
|
1832 | + if (module_exists('ignore_user')) { |
|
1833 | 1833 | $form['ignoreblock'] = array( |
1834 | - '#title' => bts('Ignore Users', array(), NULL, 'boinc:account-preferences-privacy'), |
|
1835 | - '#type' => 'fieldset', |
|
1836 | - '#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'), |
|
1837 | - '#collapsible' => TRUE, |
|
1838 | - '#collapsed' => FALSE |
|
1834 | + '#title' => bts('Ignore Users', array(), NULL, 'boinc:account-preferences-privacy'), |
|
1835 | + '#type' => 'fieldset', |
|
1836 | + '#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'), |
|
1837 | + '#collapsible' => TRUE, |
|
1838 | + '#collapsed' => FALSE |
|
1839 | 1839 | ); |
1840 | 1840 | |
1841 | 1841 | // Table for ignored users |
1842 | 1842 | $form['ignoreblock']['current_ignore_section'] = array( |
1843 | - '#type' => 'item', |
|
1844 | - '#value' => bts('Current users on your Ignore List', array(), NULL, 'boinc:ignore-user-list'), |
|
1845 | - '#prefix' => '<h4>', |
|
1846 | - '#suffix' => '</h4>', |
|
1847 | - '#weight' => -20, |
|
1843 | + '#type' => 'item', |
|
1844 | + '#value' => bts('Current users on your Ignore List', array(), NULL, 'boinc:ignore-user-list'), |
|
1845 | + '#prefix' => '<h4>', |
|
1846 | + '#suffix' => '</h4>', |
|
1847 | + '#weight' => -20, |
|
1848 | 1848 | ); |
1849 | 1849 | |
1850 | 1850 | $ignored_users = _ignore_user_ignored_users(); |
1851 | 1851 | foreach ($ignored_users as $ignored_user) { |
1852 | - $form['ignoreblock']['username'][$ignored_user['iuid']] = array( |
|
1852 | + $form['ignoreblock']['username'][$ignored_user['iuid']] = array( |
|
1853 | 1853 | '#value' => $ignored_user['username'], |
1854 | - ); |
|
1855 | - $form['ignoreblock']['delete'][$ignored_user['iuid']] = array( |
|
1854 | + ); |
|
1855 | + $form['ignoreblock']['delete'][$ignored_user['iuid']] = array( |
|
1856 | 1856 | '#value' => l( |
1857 | - bts('delete', array(), NULL, 'boinc:ignore-user-delete-button'), |
|
1858 | - 'account/prefs/privacy/ignore_user/remove/'. $ignored_user['iuid'], |
|
1859 | - array() |
|
1857 | + bts('delete', array(), NULL, 'boinc:ignore-user-delete-button'), |
|
1858 | + 'account/prefs/privacy/ignore_user/remove/'. $ignored_user['iuid'], |
|
1859 | + array() |
|
1860 | 1860 | ), |
1861 | - ); |
|
1861 | + ); |
|
1862 | 1862 | } |
1863 | 1863 | $form['ignoreblock']['pager'] = array('#value' => theme('pager', NULL, 10, 0)); |
1864 | 1864 | |
1865 | 1865 | // Sub-form to add user to ignore list |
1866 | 1866 | $form['ignoreblock']['add_ignore_user_section'] = array( |
1867 | - '#type' => 'item', |
|
1868 | - '#value' => bts('Add user to Ignore List', array(), NULL, 'boinc:ignore-user-add'), |
|
1869 | - '#prefix' => '<h4>', |
|
1870 | - '#suffix' => '</h4>', |
|
1871 | - '#weight' => 10, |
|
1867 | + '#type' => 'item', |
|
1868 | + '#value' => bts('Add user to Ignore List', array(), NULL, 'boinc:ignore-user-add'), |
|
1869 | + '#prefix' => '<h4>', |
|
1870 | + '#suffix' => '</h4>', |
|
1871 | + '#weight' => 10, |
|
1872 | 1872 | ); |
1873 | 1873 | |
1874 | 1874 | $form['ignoreblock']['addusername_toignorelist'] = array( |
1875 | - '#type' => 'textfield', |
|
1876 | - '#title' => bts('Username', array(), NULL, 'boinc:ignore-user-searchbox'), |
|
1877 | - '#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'), |
|
1878 | - '#weight' => 11, |
|
1879 | - '#size' => 50, |
|
1880 | - '#autocomplete_path' => 'boincuser/autocomplete', |
|
1875 | + '#type' => 'textfield', |
|
1876 | + '#title' => bts('Username', array(), NULL, 'boinc:ignore-user-searchbox'), |
|
1877 | + '#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'), |
|
1878 | + '#weight' => 11, |
|
1879 | + '#size' => 50, |
|
1880 | + '#autocomplete_path' => 'boincuser/autocomplete', |
|
1881 | 1881 | ); |
1882 | 1882 | |
1883 | 1883 | $form['ignoreblock']['addusername_submit'] = array( |
1884 | - '#type' => 'submit', |
|
1885 | - '#value' => bts('Ignore user', array(), NULL, 'boinc:ignore-user-add'), |
|
1886 | - '#submit' => array('_boincwork_ignore_list_form_submit'), |
|
1887 | - '#weight' => 12, |
|
1888 | - '#attributes' => array('class' => 'add_ignore_user'), |
|
1884 | + '#type' => 'submit', |
|
1885 | + '#value' => bts('Ignore user', array(), NULL, 'boinc:ignore-user-add'), |
|
1886 | + '#submit' => array('_boincwork_ignore_list_form_submit'), |
|
1887 | + '#weight' => 12, |
|
1888 | + '#attributes' => array('class' => 'add_ignore_user'), |
|
1889 | 1889 | ); |
1890 | - }// endif module_exists |
|
1890 | + }// endif module_exists |
|
1891 | 1891 | |
1892 | - $form['prefs']['separator_bottom'] = array( |
|
1892 | + $form['prefs']['separator_bottom'] = array( |
|
1893 | 1893 | '#value' => '<div class="separator buttons"></div>' |
1894 | - ); |
|
1894 | + ); |
|
1895 | 1895 | |
1896 | - // Form control |
|
1897 | - $form['prefs']['form control tabs prefix'] = array( |
|
1896 | + // Form control |
|
1897 | + $form['prefs']['form control tabs prefix'] = array( |
|
1898 | 1898 | '#value' => '<ul class="form-control tab-list">' |
1899 | - ); |
|
1900 | - $form['prefs']['submit'] = array( |
|
1899 | + ); |
|
1900 | + $form['prefs']['submit'] = array( |
|
1901 | 1901 | '#prefix' => '<li class="first tab">', |
1902 | 1902 | '#type' => 'submit', |
1903 | 1903 | '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'), |
1904 | 1904 | '#validate' => array('boincwork_privacyprefs_form_validate'), |
1905 | 1905 | '#submit' => array('boincwork_privacyprefs_form_submit'), |
1906 | 1906 | '#suffix' => '</li>' |
1907 | - ); |
|
1908 | - $form['prefs']['form control tabs'] = array( |
|
1907 | + ); |
|
1908 | + $form['prefs']['form control tabs'] = array( |
|
1909 | 1909 | '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>' |
1910 | - ); |
|
1911 | - $form['prefs']['form control tabs suffix'] = array( |
|
1910 | + ); |
|
1911 | + $form['prefs']['form control tabs suffix'] = array( |
|
1912 | 1912 | '#value' => '</ul>' |
1913 | - ); |
|
1913 | + ); |
|
1914 | 1914 | |
1915 | - return $form; |
|
1915 | + return $form; |
|
1916 | 1916 | } |
1917 | 1917 | |
1918 | 1918 | /** |
@@ -1920,93 +1920,93 @@ discard block |
||
1920 | 1920 | */ |
1921 | 1921 | function theme_boincwork_privacyprefs_form($form) { |
1922 | 1922 | |
1923 | - $output = ''; |
|
1924 | - $output .= drupal_render($form['privacy']); |
|
1923 | + $output = ''; |
|
1924 | + $output .= drupal_render($form['privacy']); |
|
1925 | 1925 | |
1926 | - $header = array( |
|
1926 | + $header = array( |
|
1927 | 1927 | bts('Username', array(), NULL, 'boinc:ignore-user-list'), |
1928 | 1928 | bts('Operations', array(), NULL, 'boinc:ignore-user-list') |
1929 | - ); |
|
1929 | + ); |
|
1930 | 1930 | |
1931 | - $rows = array(); |
|
1932 | - if (isset($form['ignoreblock']['username']) && is_array($form['ignoreblock']['username'])) { |
|
1931 | + $rows = array(); |
|
1932 | + if (isset($form['ignoreblock']['username']) && is_array($form['ignoreblock']['username'])) { |
|
1933 | 1933 | foreach (element_children($form['ignoreblock']['username']) as $key) { |
1934 | - $row = array(); |
|
1935 | - $row[] = drupal_render($form['ignoreblock']['username'][$key]); |
|
1936 | - $row[] = drupal_render($form['ignoreblock']['delete'][$key]); |
|
1937 | - $rows[] = $row; |
|
1934 | + $row = array(); |
|
1935 | + $row[] = drupal_render($form['ignoreblock']['username'][$key]); |
|
1936 | + $row[] = drupal_render($form['ignoreblock']['delete'][$key]); |
|
1937 | + $rows[] = $row; |
|
1938 | 1938 | } |
1939 | - } |
|
1940 | - else { |
|
1939 | + } |
|
1940 | + else { |
|
1941 | 1941 | $rows[] = array( |
1942 | - array( |
|
1942 | + array( |
|
1943 | 1943 | 'data' => bts('You have not added any users to your Ignore List.', array(), NULL, 'boinc:ignore-user-list'), |
1944 | 1944 | 'colspan' => '2', |
1945 | - ) |
|
1945 | + ) |
|
1946 | 1946 | ); |
1947 | - } |
|
1947 | + } |
|
1948 | 1948 | |
1949 | - $attr = array('class' => 'ignore_user'); |
|
1950 | - $form['ignoreblock']['current_list']['ignored_users']['#value'] = theme('table', $header, $rows, $attr); |
|
1951 | - $output .= drupal_render($form['current_list']); |
|
1949 | + $attr = array('class' => 'ignore_user'); |
|
1950 | + $form['ignoreblock']['current_list']['ignored_users']['#value'] = theme('table', $header, $rows, $attr); |
|
1951 | + $output .= drupal_render($form['current_list']); |
|
1952 | 1952 | |
1953 | - if ($form['pager']['#value']) { |
|
1953 | + if ($form['pager']['#value']) { |
|
1954 | 1954 | $output .= drupal_render($form['pager']); |
1955 | - } |
|
1955 | + } |
|
1956 | 1956 | |
1957 | - $output .= drupal_render($form); |
|
1957 | + $output .= drupal_render($form); |
|
1958 | 1958 | |
1959 | - return $output; |
|
1959 | + return $output; |
|
1960 | 1960 | } |
1961 | 1961 | |
1962 | 1962 | /** |
1963 | - * Validate the privacy preferences form. |
|
1964 | - */ |
|
1963 | + * Validate the privacy preferences form. |
|
1964 | + */ |
|
1965 | 1965 | function boincwork_privacyprefs_form_validate($form, &$form_state) { |
1966 | - require_boinc('util'); |
|
1966 | + require_boinc('util'); |
|
1967 | 1967 | |
1968 | - // Verify all non-boolean user input values and notify form API of failures |
|
1969 | - // ... currently there are no non-boolean values! |
|
1968 | + // Verify all non-boolean user input values and notify form API of failures |
|
1969 | + // ... currently there are no non-boolean values! |
|
1970 | 1970 | } |
1971 | 1971 | |
1972 | 1972 | /** |
1973 | - * Handle post-validation submission of privacy preferences form. |
|
1974 | - */ |
|
1973 | + * Handle post-validation submission of privacy preferences form. |
|
1974 | + */ |
|
1975 | 1975 | function boincwork_privacyprefs_form_submit($form, &$form_state) { |
1976 | - require_boinc(array('user', 'prefs', 'consent')); |
|
1976 | + require_boinc(array('user', 'prefs', 'consent')); |
|
1977 | 1977 | |
1978 | - global $user; |
|
1979 | - $account = user_load($user->uid); |
|
1978 | + global $user; |
|
1979 | + $account = user_load($user->uid); |
|
1980 | 1980 | |
1981 | - // Load BOINC account |
|
1982 | - $boincuser = BoincUser::lookup_id($account->boincuser_id); |
|
1981 | + // Load BOINC account |
|
1982 | + $boincuser = BoincUser::lookup_id($account->boincuser_id); |
|
1983 | 1983 | |
1984 | - // Privacy preferences |
|
1985 | - $boincuser->send_email = ($form_state['values']['send_email']) ? true : false; |
|
1986 | - $boincuser->show_hosts = ($form_state['values']['show_hosts']) ? true : false; |
|
1984 | + // Privacy preferences |
|
1985 | + $boincuser->send_email = ($form_state['values']['send_email']) ? true : false; |
|
1986 | + $boincuser->show_hosts = ($form_state['values']['show_hosts']) ? true : false; |
|
1987 | 1987 | |
1988 | - // Privacy consent options, extract the 'privacyconsent_SHORTNAME' |
|
1989 | - // from values array, and loop over them; each is checked with |
|
1990 | - // check_consent_type(). Also check the current state of the option |
|
1991 | - // in the database. If the form value is a new state, then set it. |
|
1992 | - $result = preg_grep("/^privacyconsent/", array_keys($form_state['values'])); |
|
1993 | - $privacyconsent_prefs = array_intersect_key($form_state['values'], array_flip($result)); |
|
1994 | - foreach ($privacyconsent_prefs as $name => $newstate) { |
|
1988 | + // Privacy consent options, extract the 'privacyconsent_SHORTNAME' |
|
1989 | + // from values array, and loop over them; each is checked with |
|
1990 | + // check_consent_type(). Also check the current state of the option |
|
1991 | + // in the database. If the form value is a new state, then set it. |
|
1992 | + $result = preg_grep("/^privacyconsent/", array_keys($form_state['values'])); |
|
1993 | + $privacyconsent_prefs = array_intersect_key($form_state['values'], array_flip($result)); |
|
1994 | + foreach ($privacyconsent_prefs as $name => $newstate) { |
|
1995 | 1995 | $subname = explode('_', $name)[1]; |
1996 | 1996 | $currstate = (check_user_consent($boincuser, $subname)) ? 1 : 0 ; |
1997 | 1997 | list($checkct, $ctid) = check_consent_type($subname); |
1998 | 1998 | if ($checkct && ($currstate != $newstate)) { |
1999 | - consent_to_a_policy($boincuser, $ctid, $newstate, 0, 'Webform', time()); |
|
1999 | + consent_to_a_policy($boincuser, $ctid, $newstate, 0, 'Webform', time()); |
|
2000 | + } |
|
2000 | 2001 | } |
2001 | - } |
|
2002 | 2002 | |
2003 | - //project_prefs_update($boincuser, $main_prefs); |
|
2003 | + //project_prefs_update($boincuser, $main_prefs); |
|
2004 | 2004 | |
2005 | - db_set_active('boinc_rw'); |
|
2006 | - db_query("UPDATE user SET send_email = '{$boincuser->send_email}', show_hosts = '{$boincuser->show_hosts}' WHERE id = '{$boincuser->id}'"); |
|
2007 | - db_set_active('default'); |
|
2005 | + db_set_active('boinc_rw'); |
|
2006 | + db_query("UPDATE user SET send_email = '{$boincuser->send_email}', show_hosts = '{$boincuser->show_hosts}' WHERE id = '{$boincuser->id}'"); |
|
2007 | + db_set_active('default'); |
|
2008 | 2008 | |
2009 | - drupal_set_message(t('Your privacy preferences have been updated.')); |
|
2009 | + drupal_set_message(t('Your privacy preferences have been updated.')); |
|
2010 | 2010 | } |
2011 | 2011 | |
2012 | 2012 | /** |
@@ -2014,14 +2014,14 @@ discard block |
||
2014 | 2014 | * ignore list. |
2015 | 2015 | */ |
2016 | 2016 | function _boincwork_ignore_list_form_submit($form, $form_state) { |
2017 | - boincwork_ignore_user_add_user_username($form_state['values']['addusername_toignorelist']); |
|
2018 | - drupal_set_message( |
|
2017 | + boincwork_ignore_user_add_user_username($form_state['values']['addusername_toignorelist']); |
|
2018 | + drupal_set_message( |
|
2019 | 2019 | bts('@username has been added to your ignore list. See your !privacy_preferences for more details.', |
2020 | - array( |
|
2020 | + array( |
|
2021 | 2021 | '@username' => $form_state['values']['addusername_toignorelist'], |
2022 | 2022 | '!privacy_preferences' => l(bts('privacy preferences', array(), NULL, 'boinc:ignore-user-add'), 'account/prefs/privacy'), |
2023 | - ), |
|
2024 | - NULL, 'boinc:ignore-user-add'), |
|
2023 | + ), |
|
2024 | + NULL, 'boinc:ignore-user-add'), |
|
2025 | 2025 | 'status'); |
2026 | 2026 | } |
2027 | 2027 | |
@@ -2030,37 +2030,37 @@ discard block |
||
2030 | 2030 | */ |
2031 | 2031 | function boincwork_selectapp_form(&$form_state, $apps, $current_app) { |
2032 | 2032 | |
2033 | - $form['selectapp'] = array( |
|
2033 | + $form['selectapp'] = array( |
|
2034 | 2034 | '#type' => 'select', |
2035 | 2035 | '#attributes' => array( |
2036 | - 'class' => 'task-app-filter', |
|
2037 | - 'onchange' => 'this.form.submit();', |
|
2036 | + 'class' => 'task-app-filter', |
|
2037 | + 'onchange' => 'this.form.submit();', |
|
2038 | 2038 | ), |
2039 | 2039 | '#default_value' => $current_app, |
2040 | 2040 | '#options' => $apps, |
2041 | 2041 | '#post_render' => array('_boincwork_selectapp_form_callback'), |
2042 | - ); |
|
2042 | + ); |
|
2043 | 2043 | |
2044 | - // Class task-app-filter-submit for this form is used in |
|
2045 | - // theming. CSS sets 'display:none' if javascript is present. Thus |
|
2046 | - // only non-js users/browsers will see the Apply Filter button. |
|
2047 | - $form['submit'] = array( |
|
2044 | + // Class task-app-filter-submit for this form is used in |
|
2045 | + // theming. CSS sets 'display:none' if javascript is present. Thus |
|
2046 | + // only non-js users/browsers will see the Apply Filter button. |
|
2047 | + $form['submit'] = array( |
|
2048 | 2048 | '#type' => 'submit', |
2049 | 2049 | '#value' => bts('Apply Filter', array(), NULL, 'boinc:form-save'), |
2050 | 2050 | '#attributes' => array('class' => 'js-hide',), |
2051 | - ); |
|
2051 | + ); |
|
2052 | 2052 | |
2053 | - return $form; |
|
2053 | + return $form; |
|
2054 | 2054 | } |
2055 | 2055 | |
2056 | 2056 | /** |
2057 | 2057 | * Submit function for select appliacation form. |
2058 | 2058 | */ |
2059 | 2059 | function boincwork_selectapp_form_submit($form, &$form_state) { |
2060 | - $myargs = arg(); |
|
2061 | - array_pop($myargs); |
|
2062 | - $newpath = implode('/', $myargs ) . '/' . $form['selectapp']['#value']; |
|
2063 | - $form_state['redirect'] = $newpath; |
|
2060 | + $myargs = arg(); |
|
2061 | + array_pop($myargs); |
|
2062 | + $newpath = implode('/', $myargs ) . '/' . $form['selectapp']['#value']; |
|
2063 | + $form_state['redirect'] = $newpath; |
|
2064 | 2064 | } |
2065 | 2065 | |
2066 | 2066 | /** |
@@ -2070,7 +2070,7 @@ discard block |
||
2070 | 2070 | * 'title' for the Application drop down box. |
2071 | 2071 | */ |
2072 | 2072 | function _boincwork_selectapp_form_callback($theContent, $theElement) { |
2073 | - $disabled = '<option value="-1" disabled hidden'; |
|
2074 | - $newContent = preg_replace('/<option value="-1"/', $disabled, $theContent); |
|
2075 | - return $newContent; |
|
2073 | + $disabled = '<option value="-1" disabled hidden'; |
|
2074 | + $newContent = preg_replace('/<option value="-1"/', $disabled, $theContent); |
|
2075 | + return $newContent; |
|
2076 | 2076 | } |
@@ -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(); |
@@ -781,7 +781,7 @@ discard block |
||
781 | 781 | WATCHDOG_WARNING |
782 | 782 | ); |
783 | 783 | $message = 'Could not merge due to a circular merge error. The site administrators have been contacted about this issue, and will investigate further.'; |
784 | - return FALSE; |
|
784 | + return false; |
|
785 | 785 | } |
786 | 786 | |
787 | 787 | if ($new_host->userid==0) { |
@@ -795,7 +795,7 @@ discard block |
||
795 | 795 | WATCHDOG_WARNING |
796 | 796 | ); |
797 | 797 | $message = 'Could not merge because the target host has userid=0. The site administrators have been contacted about this issue, and will investigate further.'; |
798 | - return FALSE; |
|
798 | + return false; |
|
799 | 799 | } |
800 | 800 | |
801 | 801 | // Move credit from the old host to the new host |
@@ -811,10 +811,10 @@ discard block |
||
811 | 811 | ); |
812 | 812 | db_set_active('default'); |
813 | 813 | if (!$credit_updated) { |
814 | - if ($message !== NULL) { |
|
815 | - $message = bts('Could not update credit', array(), NULL, 'boinc:account-host-merge'); |
|
814 | + if ($message !== null) { |
|
815 | + $message = bts('Could not update credit', array(), null, 'boinc:account-host-merge'); |
|
816 | 816 | } |
817 | - return FALSE; |
|
817 | + return false; |
|
818 | 818 | } |
819 | 819 | |
820 | 820 | // Move results from the old host to the new host |
@@ -827,10 +827,10 @@ discard block |
||
827 | 827 | ); |
828 | 828 | db_set_active('default'); |
829 | 829 | if (!$results_updated) { |
830 | - if ($message !== NULL) { |
|
831 | - $message = bts('Could not update results', array(), NULL, 'boinc:account-host-merge'); |
|
830 | + if ($message !== null) { |
|
831 | + $message = bts('Could not update results', array(), null, 'boinc:account-host-merge'); |
|
832 | 832 | } |
833 | - return FALSE; |
|
833 | + return false; |
|
834 | 834 | } |
835 | 835 | |
836 | 836 | // Retire the old host |
@@ -847,13 +847,13 @@ discard block |
||
847 | 847 | ); |
848 | 848 | db_set_active('default'); |
849 | 849 | if (!$old_host_retired) { |
850 | - if ($message !== NULL) { |
|
851 | - $message = bts('Could not retire old computer', array(), NULL, 'boinc:account-host-merge'); |
|
850 | + if ($message !== null) { |
|
851 | + $message = bts('Could not retire old computer', array(), null, 'boinc:account-host-merge'); |
|
852 | 852 | } |
853 | - return FALSE; |
|
853 | + return false; |
|
854 | 854 | } |
855 | 855 | |
856 | - return TRUE; |
|
856 | + return true; |
|
857 | 857 | } |
858 | 858 | |
859 | 859 | /** |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | $form['overview'] = array( |
883 | 883 | '#value' => '<p>' . bts('Sometimes BOINC assigns separate identities to' |
884 | 884 | . ' the same computer by mistake. You can correct this by merging old' |
885 | - . ' identities with the newest one.', array(), NULL, 'boinc:account-host-merge') . '</p>' |
|
885 | + . ' identities with the newest one.', array(), null, 'boinc:account-host-merge') . '</p>' |
|
886 | 886 | . '<p>' |
887 | 887 | . bts('Check the computers that are the same as @name' |
888 | 888 | . ' (created on @date at @time with computer ID @id)', |
@@ -892,7 +892,7 @@ discard block |
||
892 | 892 | '@time' => date('G:i:s T', $current_host->create_time), |
893 | 893 | '@id' => $current_host->id, |
894 | 894 | ), |
895 | - NULL, 'boinc:account-host-merge') . '</p>', |
|
895 | + null, 'boinc:account-host-merge') . '</p>', |
|
896 | 896 | ); |
897 | 897 | |
898 | 898 | $options = array(); |
@@ -907,7 +907,7 @@ discard block |
||
907 | 907 | $form['merge'] = array( |
908 | 908 | '#title' => '', |
909 | 909 | '#type' => 'tableselect', |
910 | - '#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')), |
|
910 | + '#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')), |
|
911 | 911 | '#options' => $options, |
912 | 912 | ); |
913 | 913 | |
@@ -922,11 +922,11 @@ discard block |
||
922 | 922 | $form['prefs']['submit'] = array( |
923 | 923 | '#prefix' => '<li class="first tab">', |
924 | 924 | '#type' => 'submit', |
925 | - '#value' => bts('Merge', array(), NULL, 'boinc:form-merge'), |
|
925 | + '#value' => bts('Merge', array(), null, 'boinc:form-merge'), |
|
926 | 926 | '#suffix' => '</li>' |
927 | 927 | ); |
928 | 928 | $form['prefs']['form control tabs'] = array( |
929 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "host/{$host_id}") . '</li>' |
|
929 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), null, 'boinc:form-cancel'), "host/{$host_id}") . '</li>' |
|
930 | 930 | ); |
931 | 931 | |
932 | 932 | return $form; |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | if ($merged) { |
965 | 965 | // Generate a natural language list of IDs that were merged |
966 | 966 | $oxford_comma = ','; |
967 | - $conjunction = bts('and', array(), NULL, 'boinc:account-preference'); |
|
967 | + $conjunction = bts('and', array(), null, 'boinc:account-preference'); |
|
968 | 968 | $list = array_keys($merged); |
969 | 969 | $last = array_pop($list); |
970 | 970 | if ($list) { |
@@ -983,7 +983,7 @@ discard block |
||
983 | 983 | '@old_id' => $list, |
984 | 984 | '@id' => $current_host_id |
985 | 985 | ), |
986 | - NULL, 'boinc:account-host-merge')); |
|
986 | + null, 'boinc:account-host-merge')); |
|
987 | 987 | } |
988 | 988 | else { |
989 | 989 | drupal_set_message(bts( |
@@ -992,7 +992,7 @@ discard block |
||
992 | 992 | '@old_ids' => $list, |
993 | 993 | '@id' => $current_host_id |
994 | 994 | ), |
995 | - NULL, 'boinc:account-host-merge')); |
|
995 | + null, 'boinc:account-host-merge')); |
|
996 | 996 | } |
997 | 997 | } |
998 | 998 | |
@@ -1005,7 +1005,7 @@ discard block |
||
1005 | 1005 | '@old_id' => $id, |
1006 | 1006 | '@message' => $error, |
1007 | 1007 | ), |
1008 | - NULL, 'boinc:account-host-merge'), |
|
1008 | + null, 'boinc:account-host-merge'), |
|
1009 | 1009 | 'warning' |
1010 | 1010 | ); |
1011 | 1011 | } |
@@ -1026,7 +1026,7 @@ discard block |
||
1026 | 1026 | global $user; |
1027 | 1027 | $account = user_load($user->uid); |
1028 | 1028 | |
1029 | - $established = TRUE; |
|
1029 | + $established = true; |
|
1030 | 1030 | |
1031 | 1031 | // Get availability of special BOINC preferences |
1032 | 1032 | require_boinc(array('util')); |
@@ -1037,26 +1037,26 @@ discard block |
||
1037 | 1037 | |
1038 | 1038 | // Take note if this is not an established preference set on the account |
1039 | 1039 | if (isset($prefs['@attributes']['cleared'])) { |
1040 | - $established = FALSE; |
|
1040 | + $established = false; |
|
1041 | 1041 | } |
1042 | 1042 | |
1043 | 1043 | // Extract modified tag if present |
1044 | - $modified = NULL; |
|
1044 | + $modified = null; |
|
1045 | 1045 | if (isset($prefs['modified']['@value'])) { |
1046 | 1046 | $modified = $prefs['modified']['@value']; |
1047 | 1047 | } |
1048 | 1048 | |
1049 | - $venue_is_default = FALSE; |
|
1049 | + $venue_is_default = false; |
|
1050 | 1050 | if ($account->boincuser_default_pref_set) { |
1051 | 1051 | if ($account->boincuser_default_pref_set == $venue) { |
1052 | - $venue_is_default = TRUE; |
|
1052 | + $venue_is_default = true; |
|
1053 | 1053 | } |
1054 | 1054 | } |
1055 | - elseif (!$venue OR $venue == 'generic') { |
|
1056 | - $venue_is_default = TRUE; |
|
1055 | + elseif (!$venue or $venue == 'generic') { |
|
1056 | + $venue_is_default = true; |
|
1057 | 1057 | } |
1058 | 1058 | else { |
1059 | - $venue_is_default = FALSE; |
|
1059 | + $venue_is_default = false; |
|
1060 | 1060 | } |
1061 | 1061 | |
1062 | 1062 | // Define form defaults |
@@ -1086,7 +1086,7 @@ discard block |
||
1086 | 1086 | // Standard option sets |
1087 | 1087 | $form['boolean_options'] = array( |
1088 | 1088 | '#type' => 'value', |
1089 | - '#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')) |
|
1089 | + '#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')) |
|
1090 | 1090 | ); |
1091 | 1091 | |
1092 | 1092 | // Identify preference sets that are established to distinguish what has been |
@@ -1094,7 +1094,7 @@ discard block |
||
1094 | 1094 | $form['#established'] = $established; |
1095 | 1095 | |
1096 | 1096 | // Top level form options |
1097 | - $form['#tree'] = TRUE; |
|
1097 | + $form['#tree'] = true; |
|
1098 | 1098 | |
1099 | 1099 | // Hidden elements |
1100 | 1100 | $form['modified'] = array( |
@@ -1112,87 +1112,87 @@ discard block |
||
1112 | 1112 | |
1113 | 1113 | // Common project preferences |
1114 | 1114 | $form['resource'] = array( |
1115 | - '#title' => bts('Resource settings', array(), NULL, 'boinc:account-preferences-project'), |
|
1115 | + '#title' => bts('Resource settings', array(), null, 'boinc:account-preferences-project'), |
|
1116 | 1116 | '#type' => 'fieldset', |
1117 | 1117 | '#description' => null, |
1118 | - '#collapsible' => TRUE, |
|
1119 | - '#collapsed' => FALSE |
|
1118 | + '#collapsible' => true, |
|
1119 | + '#collapsed' => false |
|
1120 | 1120 | ); |
1121 | 1121 | $form['resource']['resource_share'] = array( |
1122 | - '#title' => bts('Resource share', array(), NULL, 'boinc:account-preferences-project'), |
|
1122 | + '#title' => bts('Resource share', array(), null, 'boinc:account-preferences-project'), |
|
1123 | 1123 | '#type' => 'textfield', |
1124 | 1124 | '#default_value' => $default['resource_share'], |
1125 | 1125 | '#size' => 5, |
1126 | - '#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') |
|
1126 | + '#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') |
|
1127 | 1127 | ); |
1128 | 1128 | if ($app_types->count > 1) { |
1129 | 1129 | if ($app_types->cpu) { |
1130 | 1130 | $form['resource']['no_cpu'] = array( |
1131 | - '#title' => bts('Use CPU', array(), NULL, 'boinc:account-preferences-project'), |
|
1131 | + '#title' => bts('Use CPU', array(), null, 'boinc:account-preferences-project'), |
|
1132 | 1132 | '#type' => 'radios', |
1133 | 1133 | '#options' => $form['boolean_options']['#value'], |
1134 | 1134 | '#attributes' => array('class' => 'fancy'), |
1135 | 1135 | '#default_value' => $default['no_cpu'] ? 0 : 1, |
1136 | - '#description' => bts('Request CPU-only tasks from this project.', array(), NULL, 'boinc:account-preferences-project') |
|
1136 | + '#description' => bts('Request CPU-only tasks from this project.', array(), null, 'boinc:account-preferences-project') |
|
1137 | 1137 | ); |
1138 | 1138 | } |
1139 | 1139 | if ($app_types->cuda) { |
1140 | 1140 | $form['resource']['no_cuda'] = array( |
1141 | - '#title' => bts('Use NVIDIA GPU', array(), NULL, 'boinc:account-preferences-project'), |
|
1141 | + '#title' => bts('Use NVIDIA GPU', array(), null, 'boinc:account-preferences-project'), |
|
1142 | 1142 | '#type' => 'radios', |
1143 | 1143 | '#options' => $form['boolean_options']['#value'], |
1144 | 1144 | '#attributes' => array('class' => 'fancy'), |
1145 | 1145 | '#default_value' => $default['no_cuda'] ? 0 : 1, |
1146 | - '#description' => bts('Request NVIDIA GPU tasks from this project.', array(), NULL, 'boinc:account-preferences-project') |
|
1146 | + '#description' => bts('Request NVIDIA GPU tasks from this project.', array(), null, 'boinc:account-preferences-project') |
|
1147 | 1147 | ); |
1148 | 1148 | } |
1149 | 1149 | if ($app_types->ati) { |
1150 | 1150 | $form['resource']['no_ati'] = array( |
1151 | - '#title' => bts('Use AMD GPU', array(), NULL, 'boinc:account-preferences-project'), |
|
1151 | + '#title' => bts('Use AMD GPU', 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['no_ati'] ? 0 : 1, |
1156 | - '#description' => bts('Request AMD GPU tasks from this project.', array(), NULL, 'boinc:account-preferences-project') |
|
1156 | + '#description' => bts('Request AMD GPU tasks from this project.', array(), null, 'boinc:account-preferences-project') |
|
1157 | 1157 | ); |
1158 | 1158 | } |
1159 | 1159 | if ($app_types->intel_gpu) { |
1160 | 1160 | $form['resource']['no_intel_gpu'] = array( |
1161 | - '#title' => bts('Use INTEL GPU', array(), NULL, 'boinc:account-preferences-project'), |
|
1161 | + '#title' => bts('Use INTEL GPU', array(), null, 'boinc:account-preferences-project'), |
|
1162 | 1162 | '#type' => 'radios', |
1163 | 1163 | '#options' => $form['boolean_options']['#value'], |
1164 | 1164 | '#attributes' => array('class' => 'fancy'), |
1165 | 1165 | '#default_value' => $default['no_intel_gpu'] ? 0 : 1, |
1166 | - '#description' => bts('Request Intel GPU tasks from this project.', array(), NULL, 'boinc:account-preferences-project') |
|
1166 | + '#description' => bts('Request Intel GPU tasks from this project.', array(), null, 'boinc:account-preferences-project') |
|
1167 | 1167 | ); |
1168 | 1168 | } |
1169 | 1169 | if ($app_types->apple_gpu) { |
1170 | 1170 | $form['resource']['no_apple_gpu'] = array( |
1171 | - '#title' => bts('Use Apple GPU', array(), NULL, 'boinc:account-preferences-project'), |
|
1171 | + '#title' => bts('Use Apple GPU', array(), null, 'boinc:account-preferences-project'), |
|
1172 | 1172 | '#type' => 'radios', |
1173 | 1173 | '#options' => $form['boolean_options']['#value'], |
1174 | 1174 | '#attributes' => array('class' => 'fancy'), |
1175 | 1175 | '#default_value' => $default['no_apple_gpu'] ? 0 : 1, |
1176 | - '#description' => bts('Request Apple GPU tasks from this project.', array(), NULL, 'boinc:account-preferences-project') |
|
1176 | + '#description' => bts('Request Apple GPU tasks from this project.', array(), null, 'boinc:account-preferences-project') |
|
1177 | 1177 | ); |
1178 | 1178 | } |
1179 | 1179 | } |
1180 | 1180 | |
1181 | - if (variable_get('boinc_prefs_options_beta', FALSE)) { |
|
1181 | + if (variable_get('boinc_prefs_options_beta', false)) { |
|
1182 | 1182 | $form['beta'] = array( |
1183 | - '#title' => bts('Beta settings', array(), NULL, 'boinc:account-preferences-project'), |
|
1183 | + '#title' => bts('Beta settings', array(), null, 'boinc:account-preferences-project'), |
|
1184 | 1184 | '#type' => 'fieldset', |
1185 | 1185 | '#description' => null, |
1186 | - '#collapsible' => TRUE, |
|
1187 | - '#collapsed' => FALSE |
|
1186 | + '#collapsible' => true, |
|
1187 | + '#collapsed' => false |
|
1188 | 1188 | ); |
1189 | 1189 | $form['beta']['allow_beta_work'] = array( |
1190 | - '#title' => bts('Run test applications?', array(), NULL, 'boinc:account-preferences-project'), |
|
1190 | + '#title' => bts('Run test applications?', array(), null, 'boinc:account-preferences-project'), |
|
1191 | 1191 | '#type' => 'radios', |
1192 | 1192 | '#options' => $form['boolean_options']['#value'], |
1193 | 1193 | '#attributes' => array('class' => 'fancy'), |
1194 | 1194 | '#default_value' => ($default['allow_beta_work']) ? 1 : 0, |
1195 | - '#description' => bts('This helps us develop applications, but may cause jobs to fail on your computer', array(), NULL, 'boinc:account-preferences-project') |
|
1195 | + '#description' => bts('This helps us develop applications, but may cause jobs to fail on your computer', array(), null, 'boinc:account-preferences-project') |
|
1196 | 1196 | ); |
1197 | 1197 | } |
1198 | 1198 | |
@@ -1201,14 +1201,14 @@ discard block |
||
1201 | 1201 | |
1202 | 1202 | // Set whether to use this preference set by default for new computers |
1203 | 1203 | $form['default_set'] = array( |
1204 | - '#title' => bts('Default set', array(), NULL, 'boinc:account-preferences-project'), |
|
1204 | + '#title' => bts('Default set', array(), null, 'boinc:account-preferences-project'), |
|
1205 | 1205 | '#type' => 'fieldset', |
1206 | 1206 | '#description' => null, |
1207 | - '#collapsible' => TRUE, |
|
1208 | - '#collapsed' => FALSE |
|
1207 | + '#collapsible' => true, |
|
1208 | + '#collapsed' => false |
|
1209 | 1209 | ); |
1210 | 1210 | $form['default_set']['default_venue'] = array( |
1211 | - '#title' => bts('Set used for new computers', array(), NULL, 'boinc:account-preferences-project'), |
|
1211 | + '#title' => bts('Set used for new computers', array(), null, 'boinc:account-preferences-project'), |
|
1212 | 1212 | '#type' => 'radios', |
1213 | 1213 | '#options' => $form['boolean_options']['#value'], |
1214 | 1214 | '#attributes' => array('class' => 'fancy'), |
@@ -1227,27 +1227,27 @@ discard block |
||
1227 | 1227 | $form['prefs']['submit'] = array( |
1228 | 1228 | '#prefix' => '<li class="first tab">', |
1229 | 1229 | '#type' => 'submit', |
1230 | - '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'), |
|
1230 | + '#value' => bts('Save changes', array(), null, 'boinc:form-save'), |
|
1231 | 1231 | '#suffix' => '</li>' |
1232 | 1232 | ); |
1233 | 1233 | $form['prefs']['form control tabs'] = array( |
1234 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>' |
|
1234 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), null, 'boinc:form-cancel'), $_GET['q']) . '</li>' |
|
1235 | 1235 | ); |
1236 | - if ($venue AND $venue != 'generic') { |
|
1236 | + if ($venue and $venue != 'generic') { |
|
1237 | 1237 | global $base_path; |
1238 | 1238 | $form['prefs']['form control tabs']['#value'] .= '<li class="tab">' . |
1239 | - l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/project/clear/{$venue}", |
|
1239 | + l(bts('Clear', array(), null, 'boinc:form-clear'), "account/prefs/project/clear/{$venue}", |
|
1240 | 1240 | array( |
1241 | 1241 | 'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/project/combined')), |
1242 | 1242 | 'attributes' => array( |
1243 | 1243 | 'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the @name preference set. Are you sure?', |
1244 | - array('@name' => $venue), NULL, 'boinc:account-preferences') . '\')' |
|
1244 | + array('@name' => $venue), null, 'boinc:account-preferences') . '\')' |
|
1245 | 1245 | ) |
1246 | 1246 | ) |
1247 | 1247 | ) . '</li>'; |
1248 | 1248 | } |
1249 | 1249 | $form['prefs']['view control'] = array( |
1250 | - '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/project/combined') . '</li>' |
|
1250 | + '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), null, 'boinc:account-preferences') . ')', 'account/prefs/project/combined') . '</li>' |
|
1251 | 1251 | ); |
1252 | 1252 | $form['prefs']['form control tabs suffix'] = array( |
1253 | 1253 | '#value' => '</ul>' |
@@ -1267,7 +1267,7 @@ discard block |
||
1267 | 1267 | $ordered_array = array(); |
1268 | 1268 | $unordered_array = array(); |
1269 | 1269 | foreach ($xml['project_specific_preferences'] as $type => $element) { |
1270 | - if (is_array($element) AND is_numeric(key($element))) { |
|
1270 | + if (is_array($element) and is_numeric(key($element))) { |
|
1271 | 1271 | foreach ($element as $ordered_element) { |
1272 | 1272 | if (isset($ordered_element['@position'])) { |
1273 | 1273 | $ordered_array[$ordered_element['@position']] = array($type => $ordered_element); |
@@ -1319,7 +1319,7 @@ discard block |
||
1319 | 1319 | // Check for app validation |
1320 | 1320 | if (isset($validation_rules['apps'])) { |
1321 | 1321 | if (isset($validation_rules['apps']['minimum selected']) |
1322 | - AND $validation_rules['apps']['minimum selected'] > 0) { |
|
1322 | + and $validation_rules['apps']['minimum selected'] > 0) { |
|
1323 | 1323 | $apps_selected = 0; |
1324 | 1324 | foreach ($validation_rules['apps']['list'] as $app) { |
1325 | 1325 | if ($form_state['values']['applications'][$app]) $apps_selected++; |
@@ -1327,14 +1327,14 @@ discard block |
||
1327 | 1327 | if ($apps_selected < $validation_rules['apps']['minimum selected']) { |
1328 | 1328 | form_set_error( |
1329 | 1329 | 'applications', |
1330 | - bts('At least one application must be selected', array(), NULL, 'boinc:account-preferences-project') |
|
1330 | + bts('At least one application must be selected', array(), null, 'boinc:account-preferences-project') |
|
1331 | 1331 | ); |
1332 | 1332 | } |
1333 | 1333 | if ($apps_selected == count($validation_rules['apps']['list'])) { |
1334 | 1334 | foreach ($validation_rules['apps']['list'] as $app) { |
1335 | 1335 | unset($form_state['values']['applications'][$app]); |
1336 | 1336 | } |
1337 | - $form_state['storage']['all apps selected'] = TRUE; |
|
1337 | + $form_state['storage']['all apps selected'] = true; |
|
1338 | 1338 | } |
1339 | 1339 | } |
1340 | 1340 | } |
@@ -1368,7 +1368,7 @@ discard block |
||
1368 | 1368 | } |
1369 | 1369 | |
1370 | 1370 | // Beta preferences |
1371 | - if (variable_get('boinc_prefs_options_beta', FALSE)) { |
|
1371 | + if (variable_get('boinc_prefs_options_beta', false)) { |
|
1372 | 1372 | $prefs['allow_beta_work'] = ($edit['beta']['allow_beta_work']) ? 1 : 0; |
1373 | 1373 | } |
1374 | 1374 | |
@@ -1406,7 +1406,7 @@ discard block |
||
1406 | 1406 | watchdog('boincwork', 'Error updating project prefs for user @id: @message', array('@id' => $user->id, '@message' => mysqli_error()), WATCHDOG_ERROR); |
1407 | 1407 | drupal_set_message(t('Your changes could not be saved. Please contact support!'), 'error'); |
1408 | 1408 | } |
1409 | - elseif (!drupal_get_messages('status', FALSE)) { |
|
1409 | + elseif (!drupal_get_messages('status', false)) { |
|
1410 | 1410 | // Show this message if the set wasn't created automatically (in which case |
1411 | 1411 | // there is a message tailored to that) |
1412 | 1412 | drupal_set_message(t('Your preferences have been updated. |
@@ -1441,31 +1441,31 @@ discard block |
||
1441 | 1441 | // Standard option sets |
1442 | 1442 | $form['boolean_options'] = array( |
1443 | 1443 | '#type' => 'value', |
1444 | - '#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')) |
|
1444 | + '#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')) |
|
1445 | 1445 | ); |
1446 | 1446 | |
1447 | 1447 | $default = array( |
1448 | 1448 | 'pm_send_notification' => '', // This is set already in pm_email_notify_user |
1449 | 1449 | 'friend_notification' => isset($account->friend_notification) ? $account->friend_notification : 0, |
1450 | - '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), |
|
1451 | - 'comments_order' => (isset($account->sort) AND $account->sort) ? $account->sort : variable_get('comment_default_order_forum', COMMENT_ORDER_OLDEST_FIRST), |
|
1450 | + '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), |
|
1451 | + 'comments_order' => (isset($account->sort) and $account->sort) ? $account->sort : variable_get('comment_default_order_forum', COMMENT_ORDER_OLDEST_FIRST), |
|
1452 | 1452 | ); |
1453 | 1453 | |
1454 | 1454 | // General options |
1455 | 1455 | $form['general'] = array( |
1456 | 1456 | '#type' => 'fieldset', |
1457 | - '#title' => bts('General settings', array(), NULL, 'boinc:account-preferences-community'), |
|
1457 | + '#title' => bts('General settings', array(), null, 'boinc:account-preferences-community'), |
|
1458 | 1458 | '#weight' => 0, |
1459 | - '#collapsible' => TRUE, |
|
1460 | - '#collapsed' => FALSE |
|
1459 | + '#collapsible' => true, |
|
1460 | + '#collapsed' => false |
|
1461 | 1461 | ); |
1462 | 1462 | // Add the BOINC user name (non-unique, user editable) |
1463 | 1463 | $form['general']['boincuser_name'] = array( |
1464 | 1464 | '#type' => 'textfield', |
1465 | - '#title' => bts('Name', array(), NULL, 'boinc:user-or-team-name'), |
|
1465 | + '#title' => bts('Name', array(), null, 'boinc:user-or-team-name'), |
|
1466 | 1466 | '#default_value' => $account->boincuser_name, |
1467 | 1467 | '#maxlength' => USERNAME_MAX_LENGTH, |
1468 | - '#required' => TRUE, |
|
1468 | + '#required' => true, |
|
1469 | 1469 | '#description' => '', |
1470 | 1470 | '#size' => 40 |
1471 | 1471 | ); |
@@ -1474,8 +1474,8 @@ discard block |
||
1474 | 1474 | $zones = _system_zonelist(); |
1475 | 1475 | $form['general']['timezone'] = array( |
1476 | 1476 | '#type' => 'select', |
1477 | - '#title' => bts('Time zone', array(), NULL, 'boinc:account-preferences-community'), |
|
1478 | - '#default_value' => ($account->timezone !== NULL) ? $account->timezone : variable_get('date_default_timezone', 0), |
|
1477 | + '#title' => bts('Time zone', array(), null, 'boinc:account-preferences-community'), |
|
1478 | + '#default_value' => ($account->timezone !== null) ? $account->timezone : variable_get('date_default_timezone', 0), |
|
1479 | 1479 | '#options' => $zones, |
1480 | 1480 | '#description' => '', |
1481 | 1481 | ); |
@@ -1484,10 +1484,10 @@ discard block |
||
1484 | 1484 | // Notification options |
1485 | 1485 | $form['notifications'] = array( |
1486 | 1486 | '#type' => 'fieldset', |
1487 | - '#title' => bts('Notification settings', array(), NULL, 'boinc:account-preferences-community'), |
|
1487 | + '#title' => bts('Notification settings', array(), null, 'boinc:account-preferences-community'), |
|
1488 | 1488 | '#weight' => 5, |
1489 | - '#collapsible' => TRUE, |
|
1490 | - '#collapsed' => FALSE |
|
1489 | + '#collapsible' => true, |
|
1490 | + '#collapsed' => false |
|
1491 | 1491 | ); |
1492 | 1492 | // Pull in private message notification handling and tweak the form |
1493 | 1493 | $pm_notify = pm_email_notify_user('form', $edit, $account, 'account'); |
@@ -1495,7 +1495,7 @@ discard block |
||
1495 | 1495 | $pm_notify['enable_pm_mail']['pm_send_notifications'], |
1496 | 1496 | array( |
1497 | 1497 | '#type' => 'radios', |
1498 | - '#title' => bts('Receive email notification for private messages?', array(), NULL, 'boinc:account-preferences-community'), |
|
1498 | + '#title' => bts('Receive email notification for private messages?', array(), null, 'boinc:account-preferences-community'), |
|
1499 | 1499 | '#description' => ' ', |
1500 | 1500 | '#options' => $form['boolean_options']['#value'], |
1501 | 1501 | '#attributes' => array('class' => 'fancy') |
@@ -1503,9 +1503,9 @@ discard block |
||
1503 | 1503 | ); |
1504 | 1504 | $form['notifications']['friend_notification'] = array( |
1505 | 1505 | '#type' => 'radios', |
1506 | - '#title' => bts('Receive email notification for friend requests?', array(), NULL, 'boinc:account-preferences-community'), |
|
1506 | + '#title' => bts('Receive email notification for friend requests?', array(), null, 'boinc:account-preferences-community'), |
|
1507 | 1507 | '#description' => ' ', |
1508 | - '#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')), |
|
1508 | + '#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')), |
|
1509 | 1509 | '#attributes' => array('class' => 'fancy'), |
1510 | 1510 | '#default_value' => $default['friend_notification'] |
1511 | 1511 | ); |
@@ -1521,10 +1521,10 @@ discard block |
||
1521 | 1521 | } |
1522 | 1522 | $form['locale'] = array( |
1523 | 1523 | '#type' => 'fieldset', |
1524 | - '#title' => bts('Language settings', array(), NULL, 'boinc:account-preferences-community'), |
|
1524 | + '#title' => bts('Language settings', array(), null, 'boinc:account-preferences-community'), |
|
1525 | 1525 | '#weight' => 10, |
1526 | - '#collapsible' => TRUE, |
|
1527 | - '#collapsed' => FALSE, |
|
1526 | + '#collapsible' => true, |
|
1527 | + '#collapsed' => false, |
|
1528 | 1528 | ); |
1529 | 1529 | |
1530 | 1530 | // Get language negotiation settings. |
@@ -1532,30 +1532,30 @@ discard block |
||
1532 | 1532 | $user_preferred_language = user_preferred_language($account); |
1533 | 1533 | $form['locale']['language'] = array( |
1534 | 1534 | '#type' => 'select', |
1535 | - '#title' => bts('Language', array(), NULL, 'boinc:account-preferences-community'), |
|
1535 | + '#title' => bts('Language', array(), null, 'boinc:account-preferences-community'), |
|
1536 | 1536 | '#default_value' => check_plain($user_preferred_language->language), |
1537 | 1537 | '#options' => $names, |
1538 | - '#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'), |
|
1538 | + '#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'), |
|
1539 | 1539 | ); |
1540 | 1540 | } |
1541 | 1541 | |
1542 | 1542 | // Avatar options |
1543 | 1543 | $form['gravatar'] = array( |
1544 | 1544 | '#type' => 'item', |
1545 | - '#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'), |
|
1546 | - '#description' => bts('Your Gravatar will not be shown if you upload a user picture.', array(), NULL, 'boinc:account-preferences-community'), |
|
1545 | + '#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'), |
|
1546 | + '#description' => bts('Your Gravatar will not be shown if you upload a user picture.', array(), null, 'boinc:account-preferences-community'), |
|
1547 | 1547 | ); |
1548 | 1548 | if (user_access('disable own gravatar', $account)) { |
1549 | 1549 | $form['gravatar'] = array( |
1550 | 1550 | '#type' => 'checkbox', |
1551 | - '#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'), |
|
1552 | - '#description' => bts('Gravatar will not be shown if an avatar is uploaded.', array(), NULL, 'boinc:account-preferences-community'), |
|
1551 | + '#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'), |
|
1552 | + '#description' => bts('Gravatar will not be shown if an avatar is uploaded.', array(), null, 'boinc:account-preferences-community'), |
|
1553 | 1553 | '#default_value' => isset($account->gravatar) ? $account->gravatar : 0, |
1554 | 1554 | '#disabled' => !empty($account->picture), |
1555 | 1555 | ); |
1556 | 1556 | } |
1557 | 1557 | $form['gravatar']['#weight'] = 15; |
1558 | - $form['gravatar']['#prefix'] = '<fieldset class="collapsible"><legend><a href="#">' . bts('Avatar settings', array(), NULL, 'boinc:account-preferences-community') . '</a></legend>'; |
|
1558 | + $form['gravatar']['#prefix'] = '<fieldset class="collapsible"><legend><a href="#">' . bts('Avatar settings', array(), null, 'boinc:account-preferences-community') . '</a></legend>'; |
|
1559 | 1559 | // Upload an avatar (pulled from profile_node_form): |
1560 | 1560 | if (!empty($profile_form['field_image'])) { |
1561 | 1561 | $form['field_image'] = $profile_form['field_image']; |
@@ -1564,46 +1564,46 @@ discard block |
||
1564 | 1564 | $form['field_image'] = array( |
1565 | 1565 | '#value' => '<div class="form-item">' |
1566 | 1566 | . '<label class="placeholder">' |
1567 | - . bts('This is not available until your profile is set up.', array(), NULL, 'boinc:account-preferences-community') |
|
1567 | + . bts('This is not available until your profile is set up.', array(), null, 'boinc:account-preferences-community') |
|
1568 | 1568 | . '</label>' |
1569 | - . l(bts('Create a profile', array(), NULL, 'boinc:account-preferences-community'), 'account/profile/edit', array('attributes' => array('class' => 'form-link'))) |
|
1569 | + . l(bts('Create a profile', array(), null, 'boinc:account-preferences-community'), 'account/profile/edit', array('attributes' => array('class' => 'form-link'))) |
|
1570 | 1570 | . '</div>', |
1571 | 1571 | ); |
1572 | 1572 | } |
1573 | - $form['field_image'][0]['#title'] = bts('Upload an avatar', array(), NULL, 'boinc:account-preferences-community'); |
|
1573 | + $form['field_image'][0]['#title'] = bts('Upload an avatar', array(), null, 'boinc:account-preferences-community'); |
|
1574 | 1574 | $form['field_image']['#weight'] = 20; |
1575 | 1575 | $form['field_image']['#suffix'] = '</fieldset>'; |
1576 | 1576 | |
1577 | 1577 | // Forum options |
1578 | 1578 | $form['forums'] = array( |
1579 | 1579 | '#type' => 'fieldset', |
1580 | - '#title' => bts('Forum settings', array(), NULL, 'boinc:account-preferences-community'), |
|
1580 | + '#title' => bts('Forum settings', array(), null, 'boinc:account-preferences-community'), |
|
1581 | 1581 | '#weight' => 25, |
1582 | - '#collapsible' => TRUE, |
|
1583 | - '#collapsed' => FALSE |
|
1582 | + '#collapsible' => true, |
|
1583 | + '#collapsed' => false |
|
1584 | 1584 | ); |
1585 | 1585 | $form['forums']['comments_per_page'] = array( |
1586 | 1586 | '#type' => 'select', |
1587 | - '#title' => bts('In discussion topics, show at most @comments_per_page', array('@comments_per_page' => ''), NULL, 'boinc:account-preferences-community'), |
|
1587 | + '#title' => bts('In discussion topics, show at most @comments_per_page', array('@comments_per_page' => ''), null, 'boinc:account-preferences-community'), |
|
1588 | 1588 | '#options' => array(10 => 10, 20 => 20, 30 => 30, 50 => 50, 100 => 100), |
1589 | 1589 | '#default_value' => $default['comments_per_page'] |
1590 | 1590 | ); |
1591 | 1591 | // Can't have a typical Drupal form suffix on a select box? |
1592 | 1592 | $form['forums']['comments_per_page_suffix'] = array( |
1593 | - '#value' => '<span>' . bts('comments per page', array(), NULL, 'boinc:account-preferences-community') . '</span>' |
|
1593 | + '#value' => '<span>' . bts('comments per page', array(), null, 'boinc:account-preferences-community') . '</span>' |
|
1594 | 1594 | ); |
1595 | 1595 | $form['forums']['comments_order'] = array( |
1596 | 1596 | '#type' => 'select', |
1597 | - '#title' => bts('Sort comments in discussions', array(), NULL, 'boinc:account-preferences-community'), |
|
1598 | - '#options' => array(1 => bts('Newest post first', array(), NULL, 'boinc:account-preferences-community'), 2 => bts('Oldest post first', array(), NULL, 'boinc:account-preferences-community')), |
|
1597 | + '#title' => bts('Sort comments in discussions', array(), null, 'boinc:account-preferences-community'), |
|
1598 | + '#options' => array(1 => bts('Newest post first', array(), null, 'boinc:account-preferences-community'), 2 => bts('Oldest post first', array(), null, 'boinc:account-preferences-community')), |
|
1599 | 1599 | '#default_value' => $default['comments_order'] |
1600 | 1600 | ); |
1601 | 1601 | // Signature (pulled from user_edit_form): |
1602 | 1602 | if (variable_get('user_signatures', 0) && module_exists('comment')) { |
1603 | 1603 | $form['forums']['signature'] = array( |
1604 | 1604 | '#type' => 'textarea', |
1605 | - '#title' => bts('Signature', array(), NULL, 'boinc:account-preferences-community'), |
|
1606 | - '#description' => bts('Your signature will be publicly displayed at the end of your comments.', array(), NULL, 'boinc:account-preferences-community'), |
|
1605 | + '#title' => bts('Signature', array(), null, 'boinc:account-preferences-community'), |
|
1606 | + '#description' => bts('Your signature will be publicly displayed at the end of your comments.', array(), null, 'boinc:account-preferences-community'), |
|
1607 | 1607 | '#default_value' => $account->signature |
1608 | 1608 | ); |
1609 | 1609 | // Prevent a "validation error" message when the user attempts to save with a default value they |
@@ -1612,11 +1612,11 @@ discard block |
||
1612 | 1612 | 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.")); |
1613 | 1613 | $edit['signature_format'] = FILTER_FORMAT_DEFAULT; |
1614 | 1614 | } |
1615 | - $form['forums']['signature_format'] = filter_form($account->signature_format, NULL, array('signature_format')); |
|
1615 | + $form['forums']['signature_format'] = filter_form($account->signature_format, null, array('signature_format')); |
|
1616 | 1616 | // Optionally hide signatures from comments |
1617 | 1617 | $form['forums']['hide_signatures'] = array( |
1618 | 1618 | '#type' => 'radios', |
1619 | - '#title' => bts('Hide signatures in forums', array(), NULL, 'boinc:account-preferences-community'), |
|
1619 | + '#title' => bts('Hide signatures in forums', array(), null, 'boinc:account-preferences-community'), |
|
1620 | 1620 | '#description' => ' ', |
1621 | 1621 | '#options' => $form['boolean_options']['#value'], |
1622 | 1622 | '#attributes' => array('class' => 'fancy'), |
@@ -1638,12 +1638,12 @@ discard block |
||
1638 | 1638 | $form['submit'] = array( |
1639 | 1639 | '#prefix' => '<li class="first tab">', |
1640 | 1640 | '#type' => 'submit', |
1641 | - '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'), |
|
1641 | + '#value' => bts('Save changes', array(), null, 'boinc:form-save'), |
|
1642 | 1642 | '#suffix' => '</li>', |
1643 | 1643 | '#weight' => 1002, |
1644 | 1644 | ); |
1645 | 1645 | $form['form control tabs'] = array( |
1646 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
1646 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), null, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
1647 | 1647 | '#weight' => 1003, |
1648 | 1648 | ); |
1649 | 1649 | $form['form control tabs suffix'] = array( |
@@ -1673,7 +1673,7 @@ discard block |
||
1673 | 1673 | form_set_error('boincuser_name', |
1674 | 1674 | bts('You may not use username @blname, as that name is not allowed. Please choose another name.', |
1675 | 1675 | array('@blname' => $edit['boincuser_name']), |
1676 | - NULL, 'boinc:account-preferences-community')); |
|
1676 | + null, 'boinc:account-preferences-community')); |
|
1677 | 1677 | return false; |
1678 | 1678 | } |
1679 | 1679 | } |
@@ -1709,7 +1709,7 @@ discard block |
||
1709 | 1709 | $profile_node->field_image = $edit['field_image']; |
1710 | 1710 | node_save($profile_node); |
1711 | 1711 | // Flush this from the node cache or changes won't show up immediately! |
1712 | - $profile_node = node_load($profile_node->nid, NULL, TRUE); |
|
1712 | + $profile_node = node_load($profile_node->nid, null, true); |
|
1713 | 1713 | } |
1714 | 1714 | |
1715 | 1715 | // All other settings |
@@ -1738,7 +1738,7 @@ discard block |
||
1738 | 1738 | } |
1739 | 1739 | user_save($user, $settings); |
1740 | 1740 | |
1741 | - drupal_set_message(bts('Your community preferences have been updated.', array(), NULL, 'boinc:account-preferences-community')); |
|
1741 | + drupal_set_message(bts('Your community preferences have been updated.', array(), null, 'boinc:account-preferences-community')); |
|
1742 | 1742 | |
1743 | 1743 | // Form will not redirect if storage is set; not good if language changes |
1744 | 1744 | unset($form_state['storage']); |
@@ -1772,26 +1772,26 @@ discard block |
||
1772 | 1772 | // Standard option sets |
1773 | 1773 | $form['boolean_options'] = array( |
1774 | 1774 | '#type' => 'value', |
1775 | - '#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')) |
|
1775 | + '#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')) |
|
1776 | 1776 | ); |
1777 | 1777 | |
1778 | 1778 | $form['privacy'] = array( |
1779 | - '#title' => bts('Privacy settings', array(), NULL, 'boinc:account-preferences-privacy'), |
|
1779 | + '#title' => bts('Privacy settings', array(), null, 'boinc:account-preferences-privacy'), |
|
1780 | 1780 | '#type' => 'fieldset', |
1781 | 1781 | '#description' => null, |
1782 | - '#collapsible' => TRUE, |
|
1783 | - '#collapsed' => FALSE |
|
1782 | + '#collapsible' => true, |
|
1783 | + '#collapsed' => false |
|
1784 | 1784 | ); |
1785 | 1785 | $form['privacy']['send_email'] = array( |
1786 | - '#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'), |
|
1786 | + '#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'), |
|
1787 | 1787 | '#type' => 'radios', |
1788 | 1788 | '#options' => $form['boolean_options']['#value'], |
1789 | 1789 | '#attributes' => array('class' => 'fancy'), |
1790 | 1790 | '#default_value' => $default['privacy']['send_email'] |
1791 | 1791 | ); |
1792 | 1792 | $form['privacy']['show_hosts'] = array( |
1793 | - '#title' => bts('Should @project show your computers on its website?', array('@project' => variable_get('site_name', 'Drupal-BOINC')), NULL, 'boinc:account-preferences-privacy'), |
|
1794 | - '#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'), |
|
1793 | + '#title' => bts('Should @project show your computers on its website?', array('@project' => variable_get('site_name', 'Drupal-BOINC')), null, 'boinc:account-preferences-privacy'), |
|
1794 | + '#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'), |
|
1795 | 1795 | '#type' => 'radios', |
1796 | 1796 | '#options' => $form['boolean_options']['#value'], |
1797 | 1797 | '#attributes' => array('class' => 'fancy'), |
@@ -1806,7 +1806,7 @@ discard block |
||
1806 | 1806 | // Set name to 'privacyconsent_SHORTNAME', which can be parsed |
1807 | 1807 | // later in the submit function. |
1808 | 1808 | $form['privacy']['privacyconsent_'.$ct['shortname']] = array( |
1809 | - '#title' => bts($ct['description'], array(), NULL, 'boinc:account-preferences-privacy'), |
|
1809 | + '#title' => bts($ct['description'], array(), null, 'boinc:account-preferences-privacy'), |
|
1810 | 1810 | '#type' => 'radios', |
1811 | 1811 | '#options' => $form['boolean_options']['#value'], |
1812 | 1812 | '#attributes' => array('class' => 'fancy'), |
@@ -1820,28 +1820,28 @@ discard block |
||
1820 | 1820 | $form['privacy']['privacyconsent_'.$ct['shortname']]['#description'] = bts('See our !privacy_policy_link for the current list of statistics exports.', |
1821 | 1821 | array( |
1822 | 1822 | '!privacy_policy_link' => l( |
1823 | - bts('privacy policy', array(), NULL, 'boinc:account-preferences-privacy'), |
|
1823 | + bts('privacy policy', array(), null, 'boinc:account-preferences-privacy'), |
|
1824 | 1824 | '/privacy' |
1825 | 1825 | ) |
1826 | 1826 | ), |
1827 | - NULL, 'boinc:account-preferences-privacy'); |
|
1827 | + null, 'boinc:account-preferences-privacy'); |
|
1828 | 1828 | } |
1829 | 1829 | } |
1830 | 1830 | |
1831 | 1831 | // Ignore and block users |
1832 | 1832 | if (module_exists('ignore_user')) { |
1833 | 1833 | $form['ignoreblock'] = array( |
1834 | - '#title' => bts('Ignore Users', array(), NULL, 'boinc:account-preferences-privacy'), |
|
1834 | + '#title' => bts('Ignore Users', array(), null, 'boinc:account-preferences-privacy'), |
|
1835 | 1835 | '#type' => 'fieldset', |
1836 | - '#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'), |
|
1837 | - '#collapsible' => TRUE, |
|
1838 | - '#collapsed' => FALSE |
|
1836 | + '#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'), |
|
1837 | + '#collapsible' => true, |
|
1838 | + '#collapsed' => false |
|
1839 | 1839 | ); |
1840 | 1840 | |
1841 | 1841 | // Table for ignored users |
1842 | 1842 | $form['ignoreblock']['current_ignore_section'] = array( |
1843 | 1843 | '#type' => 'item', |
1844 | - '#value' => bts('Current users on your Ignore List', array(), NULL, 'boinc:ignore-user-list'), |
|
1844 | + '#value' => bts('Current users on your Ignore List', array(), null, 'boinc:ignore-user-list'), |
|
1845 | 1845 | '#prefix' => '<h4>', |
1846 | 1846 | '#suffix' => '</h4>', |
1847 | 1847 | '#weight' => -20, |
@@ -1854,18 +1854,18 @@ discard block |
||
1854 | 1854 | ); |
1855 | 1855 | $form['ignoreblock']['delete'][$ignored_user['iuid']] = array( |
1856 | 1856 | '#value' => l( |
1857 | - bts('delete', array(), NULL, 'boinc:ignore-user-delete-button'), |
|
1857 | + bts('delete', array(), null, 'boinc:ignore-user-delete-button'), |
|
1858 | 1858 | 'account/prefs/privacy/ignore_user/remove/'. $ignored_user['iuid'], |
1859 | 1859 | array() |
1860 | 1860 | ), |
1861 | 1861 | ); |
1862 | 1862 | } |
1863 | - $form['ignoreblock']['pager'] = array('#value' => theme('pager', NULL, 10, 0)); |
|
1863 | + $form['ignoreblock']['pager'] = array('#value' => theme('pager', null, 10, 0)); |
|
1864 | 1864 | |
1865 | 1865 | // Sub-form to add user to ignore list |
1866 | 1866 | $form['ignoreblock']['add_ignore_user_section'] = array( |
1867 | 1867 | '#type' => 'item', |
1868 | - '#value' => bts('Add user to Ignore List', array(), NULL, 'boinc:ignore-user-add'), |
|
1868 | + '#value' => bts('Add user to Ignore List', array(), null, 'boinc:ignore-user-add'), |
|
1869 | 1869 | '#prefix' => '<h4>', |
1870 | 1870 | '#suffix' => '</h4>', |
1871 | 1871 | '#weight' => 10, |
@@ -1873,8 +1873,8 @@ discard block |
||
1873 | 1873 | |
1874 | 1874 | $form['ignoreblock']['addusername_toignorelist'] = array( |
1875 | 1875 | '#type' => 'textfield', |
1876 | - '#title' => bts('Username', array(), NULL, 'boinc:ignore-user-searchbox'), |
|
1877 | - '#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'), |
|
1876 | + '#title' => bts('Username', array(), null, 'boinc:ignore-user-searchbox'), |
|
1877 | + '#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'), |
|
1878 | 1878 | '#weight' => 11, |
1879 | 1879 | '#size' => 50, |
1880 | 1880 | '#autocomplete_path' => 'boincuser/autocomplete', |
@@ -1882,7 +1882,7 @@ discard block |
||
1882 | 1882 | |
1883 | 1883 | $form['ignoreblock']['addusername_submit'] = array( |
1884 | 1884 | '#type' => 'submit', |
1885 | - '#value' => bts('Ignore user', array(), NULL, 'boinc:ignore-user-add'), |
|
1885 | + '#value' => bts('Ignore user', array(), null, 'boinc:ignore-user-add'), |
|
1886 | 1886 | '#submit' => array('_boincwork_ignore_list_form_submit'), |
1887 | 1887 | '#weight' => 12, |
1888 | 1888 | '#attributes' => array('class' => 'add_ignore_user'), |
@@ -1900,13 +1900,13 @@ discard block |
||
1900 | 1900 | $form['prefs']['submit'] = array( |
1901 | 1901 | '#prefix' => '<li class="first tab">', |
1902 | 1902 | '#type' => 'submit', |
1903 | - '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'), |
|
1903 | + '#value' => bts('Save changes', array(), null, 'boinc:form-save'), |
|
1904 | 1904 | '#validate' => array('boincwork_privacyprefs_form_validate'), |
1905 | 1905 | '#submit' => array('boincwork_privacyprefs_form_submit'), |
1906 | 1906 | '#suffix' => '</li>' |
1907 | 1907 | ); |
1908 | 1908 | $form['prefs']['form control tabs'] = array( |
1909 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>' |
|
1909 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), null, 'boinc:form-cancel'), $_GET['q']) . '</li>' |
|
1910 | 1910 | ); |
1911 | 1911 | $form['prefs']['form control tabs suffix'] = array( |
1912 | 1912 | '#value' => '</ul>' |
@@ -1924,8 +1924,8 @@ discard block |
||
1924 | 1924 | $output .= drupal_render($form['privacy']); |
1925 | 1925 | |
1926 | 1926 | $header = array( |
1927 | - bts('Username', array(), NULL, 'boinc:ignore-user-list'), |
|
1928 | - bts('Operations', array(), NULL, 'boinc:ignore-user-list') |
|
1927 | + bts('Username', array(), null, 'boinc:ignore-user-list'), |
|
1928 | + bts('Operations', array(), null, 'boinc:ignore-user-list') |
|
1929 | 1929 | ); |
1930 | 1930 | |
1931 | 1931 | $rows = array(); |
@@ -1940,7 +1940,7 @@ discard block |
||
1940 | 1940 | else { |
1941 | 1941 | $rows[] = array( |
1942 | 1942 | array( |
1943 | - 'data' => bts('You have not added any users to your Ignore List.', array(), NULL, 'boinc:ignore-user-list'), |
|
1943 | + 'data' => bts('You have not added any users to your Ignore List.', array(), null, 'boinc:ignore-user-list'), |
|
1944 | 1944 | 'colspan' => '2', |
1945 | 1945 | ) |
1946 | 1946 | ); |
@@ -2019,9 +2019,9 @@ discard block |
||
2019 | 2019 | bts('@username has been added to your ignore list. See your !privacy_preferences for more details.', |
2020 | 2020 | array( |
2021 | 2021 | '@username' => $form_state['values']['addusername_toignorelist'], |
2022 | - '!privacy_preferences' => l(bts('privacy preferences', array(), NULL, 'boinc:ignore-user-add'), 'account/prefs/privacy'), |
|
2022 | + '!privacy_preferences' => l(bts('privacy preferences', array(), null, 'boinc:ignore-user-add'), 'account/prefs/privacy'), |
|
2023 | 2023 | ), |
2024 | - NULL, 'boinc:ignore-user-add'), |
|
2024 | + null, 'boinc:ignore-user-add'), |
|
2025 | 2025 | 'status'); |
2026 | 2026 | } |
2027 | 2027 | |
@@ -2046,7 +2046,7 @@ discard block |
||
2046 | 2046 | // only non-js users/browsers will see the Apply Filter button. |
2047 | 2047 | $form['submit'] = array( |
2048 | 2048 | '#type' => 'submit', |
2049 | - '#value' => bts('Apply Filter', array(), NULL, 'boinc:form-save'), |
|
2049 | + '#value' => bts('Apply Filter', array(), null, 'boinc:form-save'), |
|
2050 | 2050 | '#attributes' => array('class' => 'js-hide',), |
2051 | 2051 | ); |
2052 | 2052 |