@@ -9,45 +9,45 @@ discard block |
||
9 | 9 | * Implements hook_block() for Drupal 6 compatibility |
10 | 10 | */ |
11 | 11 | function node_comment_block_block($op = 'list', $delta = 0, $edit = array()) { |
12 | - switch ($op) { |
|
13 | - case 'view': |
|
12 | + switch ($op) { |
|
13 | + case 'view': |
|
14 | 14 | //$block = node_comment_block_block_view($delta); |
15 | 15 | $block = array(); |
16 | 16 | if ($delta == 'node_comments') { |
17 | - if (arg(0) == 'node' && is_numeric($nid = arg(1)) && !arg(2)) { |
|
17 | + if (arg(0) == 'node' && is_numeric($nid = arg(1)) && !arg(2)) { |
|
18 | 18 | $node = node_load($nid); |
19 | 19 | if ($node->comment !== 0) { |
20 | - $block['subject'] = NULL; // This should be NULL otherwise there will be duplicate h2 elements. |
|
21 | - $block['content'] = ''; |
|
22 | - if ($node->comment) { |
|
20 | + $block['subject'] = NULL; // This should be NULL otherwise there will be duplicate h2 elements. |
|
21 | + $block['content'] = ''; |
|
22 | + if ($node->comment) { |
|
23 | 23 | $block['content'] .= comment_render($node); |
24 | - } |
|
24 | + } |
|
25 | + } |
|
25 | 26 | } |
26 | - } |
|
27 | 27 | } |
28 | 28 | break; |
29 | - case 'list': |
|
29 | + case 'list': |
|
30 | 30 | $blocks = node_comment_block_block_info(); |
31 | 31 | return $blocks; |
32 | 32 | break; |
33 | - default: |
|
33 | + default: |
|
34 | 34 | } |
35 | - return $block; |
|
35 | + return $block; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
39 | 39 | * Port Drupal 7 render() function to Drupal 6 |
40 | 40 | */ |
41 | 41 | function render(&$element) { |
42 | - if (is_array($element)) { |
|
42 | + if (is_array($element)) { |
|
43 | 43 | show($element); |
44 | 44 | return drupal_render($element); |
45 | - } |
|
46 | - else { |
|
45 | + } |
|
46 | + else { |
|
47 | 47 | // Safe-guard for inappropriate use of render() on flat variables: return |
48 | 48 | // the variable as-is. |
49 | 49 | return $element; |
50 | - } |
|
50 | + } |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
@@ -56,50 +56,50 @@ discard block |
||
56 | 56 | * Implements hook_block_info(). |
57 | 57 | */ |
58 | 58 | function node_comment_block_block_info() { |
59 | - $blocks['node_comments'] = array( |
|
59 | + $blocks['node_comments'] = array( |
|
60 | 60 | 'info' => t('Node comments'), |
61 | - ); |
|
61 | + ); |
|
62 | 62 | |
63 | - return $blocks; |
|
63 | + return $blocks; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
67 | 67 | * Implements hook_block_view(). |
68 | 68 | */ |
69 | 69 | function node_comment_block_block_view($delta = '') { |
70 | - $block = array(); |
|
70 | + $block = array(); |
|
71 | 71 | |
72 | - if ($delta == 'node_comments') { |
|
72 | + if ($delta == 'node_comments') { |
|
73 | 73 | if (arg(0) == 'node' && is_numeric($nid = arg(1)) && !arg(2)) { |
74 | - $node = node_load($nid); |
|
74 | + $node = node_load($nid); |
|
75 | 75 | |
76 | - if ($node->comment !== 0) { |
|
76 | + if ($node->comment !== 0) { |
|
77 | 77 | $block['subject'] = NULL; // This should be NULL otherwise there will be duplicate h2 elements. |
78 | 78 | $block['content'] = ''; |
79 | 79 | |
80 | 80 | $node = node_view($node); |
81 | 81 | |
82 | 82 | if ($node['comments']) { |
83 | - $block['content'] .= render($node['comments']); |
|
83 | + $block['content'] .= render($node['comments']); |
|
84 | + } |
|
84 | 85 | } |
85 | - } |
|
86 | 86 | } |
87 | - } |
|
87 | + } |
|
88 | 88 | |
89 | - return $block; |
|
89 | + return $block; |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
93 | 93 | * Implements hook_preprocess_HOOK() for nodes. |
94 | 94 | */ |
95 | 95 | function node_comment_block_preprocess_node(&$variables) { |
96 | - $node = $variables['node']; |
|
97 | - // Only hide standard comments for news content |
|
98 | - if ($variables['type'] == 'news') { |
|
96 | + $node = $variables['node']; |
|
97 | + // Only hide standard comments for news content |
|
98 | + if ($variables['type'] == 'news') { |
|
99 | 99 | $variables['node']->comment = 0; |
100 | - } |
|
100 | + } |
|
101 | 101 | |
102 | - /* Drupal 7... |
|
102 | + /* Drupal 7... |
|
103 | 103 | if ($node->comment !== 0 && $variables['view_mode'] == 'full') { |
104 | 104 | if (isset($variables['content']['comments'])) { |
105 | 105 | unset($variables['content']['comments']); |
@@ -113,10 +113,10 @@ discard block |
||
113 | 113 | * Implements hook_form_FORM_ID_alter() for block_admin_configure. |
114 | 114 | */ |
115 | 115 | function node_comment_block_form_block_admin_configure_alter(&$form, &$form_state) { |
116 | - if (isset($form['delta'])) { |
|
116 | + if (isset($form['delta'])) { |
|
117 | 117 | if ($form['delta']['#value'] == 'node_comments') { |
118 | - $form['settings']['title']['#disabled'] = TRUE; |
|
119 | - $form['settings']['title']['#description'] = t('The title for this block cannot be overridden.'); |
|
118 | + $form['settings']['title']['#disabled'] = TRUE; |
|
119 | + $form['settings']['title']['#description'] = t('The title for this block cannot be overridden.'); |
|
120 | + } |
|
120 | 121 | } |
121 | - } |
|
122 | 122 | } |
@@ -33,7 +33,7 @@ |
||
33 | 33 | 'boinc_solr_comments_nodetypes' => variable_get('boinc_solr_comments_nodetypes', ''), |
34 | 34 | ); |
35 | 35 | if (empty($default['boinc_solr_comments_nodetypes'])) { |
36 | - $default['boinc_solr_comments_nodetypes'] = array('forum','team_forum','news','page','story'); |
|
36 | + $default['boinc_solr_comments_nodetypes'] = array('forum', 'team_forum', 'news', 'page', 'story'); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | // Define the form |
@@ -7,48 +7,48 @@ |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | function boinc_solr_comments_form(&$form_state) { |
10 | - $form = array(); |
|
10 | + $form = array(); |
|
11 | 11 | |
12 | - $form['config'] = array( |
|
12 | + $form['config'] = array( |
|
13 | 13 | '#type' => 'fieldset', |
14 | 14 | '#title' => t('Configuration'), |
15 | 15 | '#collapsible' => TRUE, |
16 | - ); |
|
16 | + ); |
|
17 | 17 | |
18 | - $options = array(); |
|
19 | - foreach (content_types() as $key => $info) { |
|
18 | + $options = array(); |
|
19 | + foreach (content_types() as $key => $info) { |
|
20 | 20 | // Exclude node types profile, team, and panel |
21 | 21 | switch ($key) { |
22 | - case 'profile': |
|
22 | + case 'profile': |
|
23 | 23 | case 'team': |
24 | 24 | case 'panel': |
25 | 25 | continue 2; |
26 | 26 | }// switch key |
27 | 27 | $options[$key] = $info['name']; |
28 | - } |
|
29 | - asort($options); |
|
28 | + } |
|
29 | + asort($options); |
|
30 | 30 | |
31 | - // Form defaults |
|
32 | - $default = array( |
|
31 | + // Form defaults |
|
32 | + $default = array( |
|
33 | 33 | 'boinc_solr_comments_nodetypes' => variable_get('boinc_solr_comments_nodetypes', ''), |
34 | - ); |
|
35 | - if (empty($default['boinc_solr_comments_nodetypes'])) { |
|
34 | + ); |
|
35 | + if (empty($default['boinc_solr_comments_nodetypes'])) { |
|
36 | 36 | $default['boinc_solr_comments_nodetypes'] = array('forum','team_forum','news','page','story'); |
37 | - } |
|
37 | + } |
|
38 | 38 | |
39 | - // Define the form |
|
40 | - $form['config']['nodes'] = array( |
|
39 | + // Define the form |
|
40 | + $form['config']['nodes'] = array( |
|
41 | 41 | '#type' => 'markup', |
42 | 42 | '#value' => bts('Select the content types where the comments are indexed by Apace Solr. Your content must be re-indexed after changing this configuration.', array(), NULL, 'boinc:admin-solr-search-comments-option'), |
43 | - ); |
|
43 | + ); |
|
44 | 44 | |
45 | - $form['config']['boinc_solr_comments_nodetypes'] = array( |
|
45 | + $form['config']['boinc_solr_comments_nodetypes'] = array( |
|
46 | 46 | '#type' => 'checkboxes', |
47 | 47 | '#title' => 'node', |
48 | 48 | '#options' => $options, |
49 | 49 | '#default_value' => $default['boinc_solr_comments_nodetypes'], |
50 | - ); |
|
50 | + ); |
|
51 | 51 | |
52 | - return system_settings_form($form); |
|
52 | + return system_settings_form($form); |
|
53 | 53 | } |
54 | 54 |
@@ -7,15 +7,15 @@ |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | class views_handler_argument_boincteam_id extends views_handler_argument_numeric { |
10 | - function construct() { |
|
10 | + function construct() { |
|
11 | 11 | parent::construct(); |
12 | - } |
|
12 | + } |
|
13 | 13 | |
14 | - function set_argument($arg) { |
|
14 | + function set_argument($arg) { |
|
15 | 15 | // When setting the ID argument, convert to BOINC ID |
16 | 16 | $id = is_numeric($arg) ? $arg : 0; |
17 | 17 | $boinc_id = db_result(db_query("SELECT team_id FROM {boincteam} WHERE nid = %d", $id)); |
18 | 18 | $this->argument = $boinc_id; |
19 | 19 | return $this->validate_arg($boinc_id); |
20 | - } |
|
20 | + } |
|
21 | 21 | } |
@@ -444,7 +444,7 @@ |
||
444 | 444 | function boincteam_views_handlers() { |
445 | 445 | return array( |
446 | 446 | 'info' => array( |
447 | - 'path' => drupal_get_path('module', 'boincteam') . '/views', |
|
447 | + 'path' => drupal_get_path('module', 'boincteam').'/views', |
|
448 | 448 | ), |
449 | 449 | 'handlers' => array( |
450 | 450 | 'views_handler_argument_boincteam_id' => array( |
@@ -13,103 +13,103 @@ discard block |
||
13 | 13 | */ |
14 | 14 | function boincteam_views_data() { |
15 | 15 | |
16 | - // ----------------------------------------------------------------------------------------------- |
|
17 | - // Definition for team table |
|
18 | - // ----------------------------------------------------------------------------------------------- |
|
16 | + // ----------------------------------------------------------------------------------------------- |
|
17 | + // Definition for team table |
|
18 | + // ----------------------------------------------------------------------------------------------- |
|
19 | 19 | |
20 | - $data['team']['table']['group'] = t('BOINC'); |
|
20 | + $data['team']['table']['group'] = t('BOINC'); |
|
21 | 21 | |
22 | - $data['team']['table']['base'] = array( |
|
23 | - 'field' => 'id', |
|
24 | - 'title' => t('BOINC team'), |
|
25 | - 'help' => t('BOINC data for a team'), |
|
26 | - 'database' => 'boinc_rw' |
|
27 | - ); |
|
22 | + $data['team']['table']['base'] = array( |
|
23 | + 'field' => 'id', |
|
24 | + 'title' => t('BOINC team'), |
|
25 | + 'help' => t('BOINC data for a team'), |
|
26 | + 'database' => 'boinc_rw' |
|
27 | + ); |
|
28 | 28 | |
29 | - // This table references the {user} table. |
|
30 | - // This join creates an 'implicit' relationship to the user table, so that when |
|
31 | - // "User" is the base table, the fields are automatically available. |
|
29 | + // This table references the {user} table. |
|
30 | + // This join creates an 'implicit' relationship to the user table, so that when |
|
31 | + // "User" is the base table, the fields are automatically available. |
|
32 | 32 | |
33 | - // Index this array by the table name to which this table refers. |
|
34 | - // 'left_field' is the primary key in the referenced table. |
|
35 | - // 'field' is the foreign key in this table. |
|
33 | + // Index this array by the table name to which this table refers. |
|
34 | + // 'left_field' is the primary key in the referenced table. |
|
35 | + // 'field' is the foreign key in this table. |
|
36 | 36 | |
37 | - $data['team']['table']['join'] = array( |
|
37 | + $data['team']['table']['join'] = array( |
|
38 | 38 | 'user' => array( |
39 | - 'left_field' => 'id', |
|
40 | - 'field' => 'userid', |
|
39 | + 'left_field' => 'id', |
|
40 | + 'field' => 'userid', |
|
41 | 41 | ), |
42 | - ); |
|
42 | + ); |
|
43 | 43 | |
44 | - // Describe each of the individual fields in this table to Views. For |
|
45 | - // each field, you may define what field, sort, argument, and/or filter |
|
46 | - // handlers it supports. This will determine where in the Views interface you |
|
47 | - // may use the field. |
|
44 | + // Describe each of the individual fields in this table to Views. For |
|
45 | + // each field, you may define what field, sort, argument, and/or filter |
|
46 | + // handlers it supports. This will determine where in the Views interface you |
|
47 | + // may use the field. |
|
48 | 48 | |
49 | - // Primary keys allowed as arguments |
|
49 | + // Primary keys allowed as arguments |
|
50 | 50 | |
51 | - $data['team']['id'] = array( |
|
51 | + $data['team']['id'] = array( |
|
52 | 52 | 'title' => bts('Team ID', array(), NULL, 'boinc:team-id'), |
53 | 53 | 'help' => t('The BOINC ID of the team.'), |
54 | 54 | 'field' => array( |
55 | - 'handler' => 'views_handler_field_numeric', |
|
56 | - 'click sortable' => TRUE |
|
55 | + 'handler' => 'views_handler_field_numeric', |
|
56 | + 'click sortable' => TRUE |
|
57 | 57 | ), |
58 | 58 | 'argument' => array( |
59 | - 'handler' => 'views_handler_argument_boincteam_id', // custom handler |
|
60 | - 'name field' => 'title', // the field to display in the summary. |
|
61 | - 'numeric' => TRUE, |
|
62 | - 'validate type' => 'id' |
|
59 | + 'handler' => 'views_handler_argument_boincteam_id', // custom handler |
|
60 | + 'name field' => 'title', // the field to display in the summary. |
|
61 | + 'numeric' => TRUE, |
|
62 | + 'validate type' => 'id' |
|
63 | 63 | ), |
64 | 64 | 'relationship' => array( |
65 | - 'base' => 'team_delta', |
|
66 | - 'field' => 'id', |
|
67 | - 'base field' => 'teamid', |
|
68 | - 'handler' => 'views_handler_relationship', |
|
69 | - 'label' => t('Team History') |
|
65 | + 'base' => 'team_delta', |
|
66 | + 'field' => 'id', |
|
67 | + 'base field' => 'teamid', |
|
68 | + 'handler' => 'views_handler_relationship', |
|
69 | + 'label' => t('Team History') |
|
70 | 70 | ), |
71 | 71 | 'filter' => array( |
72 | - 'handler' => 'views_handler_filter_numeric' |
|
72 | + 'handler' => 'views_handler_filter_numeric' |
|
73 | 73 | ), |
74 | 74 | 'sort' => array( |
75 | - 'handler' => 'views_handler_sort_numeric' |
|
75 | + 'handler' => 'views_handler_sort_numeric' |
|
76 | 76 | ) |
77 | - ); |
|
77 | + ); |
|
78 | 78 | |
79 | - // Foreign key fields |
|
79 | + // Foreign key fields |
|
80 | 80 | |
81 | - $data['team']['userid'] = array( |
|
81 | + $data['team']['userid'] = array( |
|
82 | 82 | 'title' => bts('Founder', array(), NULL, 'boinc:view-team-info'), |
83 | 83 | 'help' => t('The founder of this team.'), |
84 | 84 | // This is a foreign key to the {user} table. When the view is configured |
85 | 85 | // with this relationship, all the fields for the related user node will be |
86 | 86 | // available. |
87 | 87 | 'argument' => array( |
88 | - 'handler' => 'views_handler_argument_boincuser_id', |
|
89 | - 'name field' => 'title', |
|
90 | - 'numeric' => TRUE, |
|
91 | - 'validate type' => 'id' |
|
88 | + 'handler' => 'views_handler_argument_boincuser_id', |
|
89 | + 'name field' => 'title', |
|
90 | + 'numeric' => TRUE, |
|
91 | + 'validate type' => 'id' |
|
92 | 92 | ), |
93 | 93 | 'relationship' => array( |
94 | - 'base' => 'user', |
|
95 | - 'field' => 'userid', |
|
96 | - 'handler' => 'views_handler_relationship', |
|
97 | - 'label' => t('User') |
|
94 | + 'base' => 'user', |
|
95 | + 'field' => 'userid', |
|
96 | + 'handler' => 'views_handler_relationship', |
|
97 | + 'label' => t('User') |
|
98 | 98 | ), |
99 | 99 | 'field' => array( |
100 | - 'handler' => 'views_handler_field_numeric', |
|
101 | - 'click sortable' => TRUE |
|
100 | + 'handler' => 'views_handler_field_numeric', |
|
101 | + 'click sortable' => TRUE |
|
102 | 102 | ), |
103 | 103 | 'filter' => array( |
104 | - 'handler' => 'views_handler_filter_numeric' |
|
104 | + 'handler' => 'views_handler_filter_numeric' |
|
105 | 105 | ), |
106 | 106 | 'sort' => array( |
107 | - 'handler' => 'views_handler_sort_numeric' |
|
107 | + 'handler' => 'views_handler_sort_numeric' |
|
108 | 108 | ) |
109 | - ); |
|
109 | + ); |
|
110 | 110 | |
111 | - // Descriptions of general fields (alphabetized) |
|
112 | - /* |
|
111 | + // Descriptions of general fields (alphabetized) |
|
112 | + /* |
|
113 | 113 | $data['team']['create_time'] = array( |
114 | 114 | 'title' => bts('Team established', array(), NULL, 'boinc:date-team-established'), |
115 | 115 | 'help' => t('When the BOINC team was created.'), |
@@ -140,298 +140,298 @@ discard block |
||
140 | 140 | ); |
141 | 141 | */ |
142 | 142 | |
143 | - $data['team']['country'] = array( |
|
143 | + $data['team']['country'] = array( |
|
144 | 144 | 'title' => bts('Country', array(), NULL, 'boinc:country-of-origin'), |
145 | 145 | 'help' => t('The country of a team.'), |
146 | 146 | 'field' => array( |
147 | - 'handler' => 'views_handler_field', |
|
148 | - 'click sortable' => TRUE |
|
147 | + 'handler' => 'views_handler_field', |
|
148 | + 'click sortable' => TRUE |
|
149 | 149 | ), |
150 | 150 | 'filter' => array( |
151 | - 'handler' => 'views_handler_filter_string' |
|
151 | + 'handler' => 'views_handler_filter_string' |
|
152 | 152 | ), |
153 | 153 | 'sort' => array( |
154 | - 'handler' => 'views_handler_sort_string' |
|
154 | + 'handler' => 'views_handler_sort_string' |
|
155 | 155 | ) |
156 | - ); |
|
157 | - $data['team']['expavg_credit'] = array( |
|
156 | + ); |
|
157 | + $data['team']['expavg_credit'] = array( |
|
158 | 158 | 'title' => bts('Recent average credit', array(), NULL, 'boinc:user-or-team-RAC'), |
159 | 159 | 'help' => t('A decaying average of team credit per day.'), |
160 | 160 | 'field' => array( |
161 | - 'handler' => 'views_handler_field_numeric', |
|
162 | - 'click sortable' => TRUE, |
|
163 | - 'float' => TRUE |
|
161 | + 'handler' => 'views_handler_field_numeric', |
|
162 | + 'click sortable' => TRUE, |
|
163 | + 'float' => TRUE |
|
164 | 164 | ), |
165 | 165 | 'filter' => array( |
166 | - 'handler' => 'views_handler_filter_numeric' |
|
166 | + 'handler' => 'views_handler_filter_numeric' |
|
167 | 167 | ), |
168 | 168 | 'sort' => array( |
169 | - 'handler' => 'views_handler_sort_numeric' |
|
169 | + 'handler' => 'views_handler_sort_numeric' |
|
170 | 170 | ) |
171 | - ); |
|
172 | - $data['team']['name'] = array( |
|
171 | + ); |
|
172 | + $data['team']['name'] = array( |
|
173 | 173 | 'title' => bts('Name', array(), NULL, 'boinc:user-or-team-name'), |
174 | 174 | 'help' => t('The name of the team.'), |
175 | 175 | 'field' => array( |
176 | - 'handler' => 'views_handler_field', |
|
177 | - 'click sortable' => TRUE |
|
176 | + 'handler' => 'views_handler_field', |
|
177 | + 'click sortable' => TRUE |
|
178 | 178 | ), |
179 | 179 | 'filter' => array( |
180 | - 'handler' => 'views_handler_filter_string' |
|
180 | + 'handler' => 'views_handler_filter_string' |
|
181 | 181 | ), |
182 | 182 | 'sort' => array( |
183 | - 'handler' => 'views_handler_sort_string' |
|
183 | + 'handler' => 'views_handler_sort_string' |
|
184 | 184 | ) |
185 | - ); |
|
186 | - $data['team']['nusers'] = array( |
|
185 | + ); |
|
186 | + $data['team']['nusers'] = array( |
|
187 | 187 | 'title' => bts('Members', array(), NULL, 'boinc:team-members'), |
188 | 188 | 'help' => t('Count of team members.'), |
189 | 189 | 'field' => array( |
190 | - 'handler' => 'views_handler_field_numeric', |
|
191 | - 'click sortable' => TRUE |
|
190 | + 'handler' => 'views_handler_field_numeric', |
|
191 | + 'click sortable' => TRUE |
|
192 | 192 | ), |
193 | 193 | 'filter' => array( |
194 | - 'handler' => 'views_handler_filter_numeric' |
|
194 | + 'handler' => 'views_handler_filter_numeric' |
|
195 | 195 | ), |
196 | 196 | 'sort' => array( |
197 | - 'handler' => 'views_handler_sort_numeric' |
|
197 | + 'handler' => 'views_handler_sort_numeric' |
|
198 | 198 | ) |
199 | - ); |
|
200 | - $data['team']['total_credit'] = array( |
|
199 | + ); |
|
200 | + $data['team']['total_credit'] = array( |
|
201 | 201 | 'title' => bts('Total credit', array(), NULL, 'boinc:user-or-team-total-credits'), |
202 | 202 | 'help' => t('The total team accumulated BOINC credit.'), |
203 | 203 | 'field' => array( |
204 | - 'handler' => 'views_handler_field_numeric', |
|
205 | - 'click sortable' => TRUE, |
|
206 | - 'float' => TRUE |
|
204 | + 'handler' => 'views_handler_field_numeric', |
|
205 | + 'click sortable' => TRUE, |
|
206 | + 'float' => TRUE |
|
207 | 207 | ), |
208 | 208 | 'filter' => array( |
209 | - 'handler' => 'views_handler_filter_numeric' |
|
209 | + 'handler' => 'views_handler_filter_numeric' |
|
210 | 210 | ), |
211 | 211 | 'sort' => array( |
212 | - 'handler' => 'views_handler_sort_numeric' |
|
212 | + 'handler' => 'views_handler_sort_numeric' |
|
213 | 213 | ) |
214 | - ); |
|
214 | + ); |
|
215 | 215 | |
216 | - // ----------------------------------------------------------------------------------------------- |
|
217 | - // Definition for team_admin table |
|
218 | - // ----------------------------------------------------------------------------------------------- |
|
216 | + // ----------------------------------------------------------------------------------------------- |
|
217 | + // Definition for team_admin table |
|
218 | + // ----------------------------------------------------------------------------------------------- |
|
219 | 219 | |
220 | - $data['team_admin']['table']['group'] = t('BOINC'); |
|
220 | + $data['team_admin']['table']['group'] = t('BOINC'); |
|
221 | 221 | |
222 | - $data['team_admin']['table']['base'] = array( |
|
223 | - 'field' => 'id', |
|
224 | - 'title' => t('BOINC team admins'), |
|
225 | - 'help' => t('BOINC admins for a team'), |
|
226 | - 'database' => 'boinc_rw' |
|
227 | - ); |
|
222 | + $data['team_admin']['table']['base'] = array( |
|
223 | + 'field' => 'id', |
|
224 | + 'title' => t('BOINC team admins'), |
|
225 | + 'help' => t('BOINC admins for a team'), |
|
226 | + 'database' => 'boinc_rw' |
|
227 | + ); |
|
228 | 228 | |
229 | - // This table references the {team} table. |
|
230 | - // This join creates an 'implicit' relationship to the team table, so that when |
|
231 | - // "Team" is the base table, the fields are automatically available. |
|
229 | + // This table references the {team} table. |
|
230 | + // This join creates an 'implicit' relationship to the team table, so that when |
|
231 | + // "Team" is the base table, the fields are automatically available. |
|
232 | 232 | |
233 | - // Index this array by the table name to which this table refers. |
|
234 | - // 'left_field' is the primary key in the referenced table. |
|
235 | - // 'field' is the foreign key in this table. |
|
233 | + // Index this array by the table name to which this table refers. |
|
234 | + // 'left_field' is the primary key in the referenced table. |
|
235 | + // 'field' is the foreign key in this table. |
|
236 | 236 | |
237 | - $data['team_admin']['table']['join'] = array( |
|
237 | + $data['team_admin']['table']['join'] = array( |
|
238 | 238 | 'team' => array( |
239 | - 'left_field' => 'id', |
|
240 | - 'field' => 'teamid', |
|
239 | + 'left_field' => 'id', |
|
240 | + 'field' => 'teamid', |
|
241 | 241 | ), |
242 | - ); |
|
242 | + ); |
|
243 | 243 | |
244 | - // Describe each of the individual fields in this table to Views. For |
|
245 | - // each field, you may define what field, sort, argument, and/or filter |
|
246 | - // handlers it supports. This will determine where in the Views interface you |
|
247 | - // may use the field. |
|
244 | + // Describe each of the individual fields in this table to Views. For |
|
245 | + // each field, you may define what field, sort, argument, and/or filter |
|
246 | + // handlers it supports. This will determine where in the Views interface you |
|
247 | + // may use the field. |
|
248 | 248 | |
249 | - // Primary keys allowed as arguments |
|
249 | + // Primary keys allowed as arguments |
|
250 | 250 | |
251 | - $data['team_admin']['teamid'] = array( |
|
251 | + $data['team_admin']['teamid'] = array( |
|
252 | 252 | 'title' => bts('Team ID', array(), NULL, 'boinc:team-id'), |
253 | 253 | 'help' => t('The BOINC ID of the team on which this user is an admin.'), |
254 | 254 | 'field' => array( |
255 | - 'handler' => 'views_handler_field_numeric', |
|
256 | - 'click sortable' => TRUE |
|
255 | + 'handler' => 'views_handler_field_numeric', |
|
256 | + 'click sortable' => TRUE |
|
257 | 257 | ), |
258 | 258 | 'argument' => array( |
259 | - 'handler' => 'views_handler_argument_boincteam_id', // custom handler |
|
260 | - 'name field' => 'title', // the field to display in the summary. |
|
261 | - 'numeric' => TRUE, |
|
262 | - 'validate type' => 'id' |
|
259 | + 'handler' => 'views_handler_argument_boincteam_id', // custom handler |
|
260 | + 'name field' => 'title', // the field to display in the summary. |
|
261 | + 'numeric' => TRUE, |
|
262 | + 'validate type' => 'id' |
|
263 | 263 | ), |
264 | 264 | 'relationship' => array( |
265 | - 'base' => 'team', |
|
266 | - 'field' => 'teamid', |
|
267 | - 'handler' => 'views_handler_relationship', |
|
268 | - 'label' => t('Team') |
|
265 | + 'base' => 'team', |
|
266 | + 'field' => 'teamid', |
|
267 | + 'handler' => 'views_handler_relationship', |
|
268 | + 'label' => t('Team') |
|
269 | 269 | ), |
270 | 270 | 'filter' => array( |
271 | - 'handler' => 'views_handler_filter_numeric' |
|
271 | + 'handler' => 'views_handler_filter_numeric' |
|
272 | 272 | ), |
273 | 273 | 'sort' => array( |
274 | - 'handler' => 'views_handler_sort_numeric' |
|
274 | + 'handler' => 'views_handler_sort_numeric' |
|
275 | 275 | ) |
276 | - ); |
|
276 | + ); |
|
277 | 277 | |
278 | - // Foreign key fields |
|
278 | + // Foreign key fields |
|
279 | 279 | |
280 | - $data['team_admin']['userid'] = array( |
|
280 | + $data['team_admin']['userid'] = array( |
|
281 | 281 | 'title' => bts('User ID', array(), NULL, 'boinc:user-details'), |
282 | 282 | 'help' => t('The user that is a team admin.'), |
283 | 283 | // This is a foreign key to the {user} table. When the view is configured |
284 | 284 | // with this relationship, all the fields for the related user node will be |
285 | 285 | // available. |
286 | 286 | 'argument' => array( |
287 | - 'handler' => 'views_handler_argument_boincteam_id', |
|
288 | - 'name field' => 'title', |
|
289 | - 'numeric' => TRUE, |
|
290 | - 'validate type' => 'id' |
|
287 | + 'handler' => 'views_handler_argument_boincteam_id', |
|
288 | + 'name field' => 'title', |
|
289 | + 'numeric' => TRUE, |
|
290 | + 'validate type' => 'id' |
|
291 | 291 | ), |
292 | 292 | 'relationship' => array( |
293 | - 'base' => 'user', |
|
294 | - 'field' => 'userid', |
|
295 | - 'handler' => 'views_handler_relationship', |
|
296 | - 'label' => bts('User', array(), NULL, 'boinc:user-on-team') |
|
293 | + 'base' => 'user', |
|
294 | + 'field' => 'userid', |
|
295 | + 'handler' => 'views_handler_relationship', |
|
296 | + 'label' => bts('User', array(), NULL, 'boinc:user-on-team') |
|
297 | 297 | ), |
298 | 298 | 'field' => array( |
299 | - 'handler' => 'views_handler_field_numeric', |
|
300 | - 'click sortable' => TRUE |
|
299 | + 'handler' => 'views_handler_field_numeric', |
|
300 | + 'click sortable' => TRUE |
|
301 | 301 | ), |
302 | 302 | 'filter' => array( |
303 | - 'handler' => 'views_handler_filter_numeric' |
|
303 | + 'handler' => 'views_handler_filter_numeric' |
|
304 | 304 | ), |
305 | 305 | 'sort' => array( |
306 | - 'handler' => 'views_handler_sort_numeric' |
|
306 | + 'handler' => 'views_handler_sort_numeric' |
|
307 | 307 | ) |
308 | - ); |
|
308 | + ); |
|
309 | 309 | |
310 | - // Descriptions of general fields (alphabetized) |
|
310 | + // Descriptions of general fields (alphabetized) |
|
311 | 311 | |
312 | - $data['team_admin']['create_time'] = array( |
|
312 | + $data['team_admin']['create_time'] = array( |
|
313 | 313 | 'title' => bts('Admin since', array(), NULL, 'boinc:team-when-user-became-an-admin'), |
314 | 314 | 'help' => t('When the BOINC user became a team admin.'), |
315 | 315 | 'field' => array( |
316 | - 'handler' => 'views_handler_field_date', |
|
317 | - 'click sortable' => TRUE |
|
316 | + 'handler' => 'views_handler_field_date', |
|
317 | + 'click sortable' => TRUE |
|
318 | 318 | ), |
319 | 319 | 'filter' => array( |
320 | - 'handler' => 'views_handler_filter_date' |
|
320 | + 'handler' => 'views_handler_filter_date' |
|
321 | 321 | ), |
322 | 322 | 'sort' => array( |
323 | - 'handler' => 'views_handler_sort_date' |
|
323 | + 'handler' => 'views_handler_sort_date' |
|
324 | 324 | ) |
325 | - ); |
|
325 | + ); |
|
326 | 326 | |
327 | - // ----------------------------------------------------------------------------------------------- |
|
328 | - // Definition for team_delta table |
|
329 | - // ----------------------------------------------------------------------------------------------- |
|
327 | + // ----------------------------------------------------------------------------------------------- |
|
328 | + // Definition for team_delta table |
|
329 | + // ----------------------------------------------------------------------------------------------- |
|
330 | 330 | |
331 | - $data['team_delta']['table']['group'] = t('BOINC'); |
|
331 | + $data['team_delta']['table']['group'] = t('BOINC'); |
|
332 | 332 | |
333 | - // Describe each of the individual fields in this table to Views. For |
|
334 | - // each field, you may define what field, sort, argument, and/or filter |
|
335 | - // handlers it supports. This will determine where in the Views interface you |
|
336 | - // may use the field. |
|
333 | + // Describe each of the individual fields in this table to Views. For |
|
334 | + // each field, you may define what field, sort, argument, and/or filter |
|
335 | + // handlers it supports. This will determine where in the Views interface you |
|
336 | + // may use the field. |
|
337 | 337 | |
338 | - // Primary keys allowed as arguments |
|
338 | + // Primary keys allowed as arguments |
|
339 | 339 | |
340 | - $data['team_delta']['teamid'] = array( |
|
340 | + $data['team_delta']['teamid'] = array( |
|
341 | 341 | 'title' => bts('Team ID', array(), NULL, 'boinc:team-id'), |
342 | 342 | 'help' => t('The team ID for this team history event.'), |
343 | 343 | // This is a foreign key to the {team} table. When the view is configured |
344 | 344 | // with this relationship, all the fields for the related user node will be |
345 | 345 | // available. |
346 | 346 | 'argument' => array( |
347 | - 'handler' => 'views_handler_argument_boincteam_id', |
|
348 | - 'name field' => 'title', |
|
349 | - 'numeric' => TRUE, |
|
350 | - 'validate type' => 'id' |
|
347 | + 'handler' => 'views_handler_argument_boincteam_id', |
|
348 | + 'name field' => 'title', |
|
349 | + 'numeric' => TRUE, |
|
350 | + 'validate type' => 'id' |
|
351 | 351 | ), |
352 | 352 | 'field' => array( |
353 | - 'handler' => 'views_handler_field_numeric', |
|
354 | - 'click sortable' => TRUE |
|
353 | + 'handler' => 'views_handler_field_numeric', |
|
354 | + 'click sortable' => TRUE |
|
355 | 355 | ), |
356 | 356 | 'filter' => array( |
357 | - 'handler' => 'views_handler_filter_numeric' |
|
357 | + 'handler' => 'views_handler_filter_numeric' |
|
358 | 358 | ), |
359 | 359 | 'sort' => array( |
360 | - 'handler' => 'views_handler_sort_numeric' |
|
360 | + 'handler' => 'views_handler_sort_numeric' |
|
361 | 361 | ) |
362 | - ); |
|
362 | + ); |
|
363 | 363 | |
364 | - // Foreign key fields |
|
364 | + // Foreign key fields |
|
365 | 365 | |
366 | - $data['team_delta']['userid'] = array( |
|
366 | + $data['team_delta']['userid'] = array( |
|
367 | 367 | 'title' => bts('User ID', array(), NULL, 'boinc:user-details'), |
368 | 368 | 'help' => t('The user for this team history event.'), |
369 | 369 | 'relationship' => array( |
370 | - 'base' => 'user', |
|
371 | - 'field' => 'userid', |
|
372 | - 'handler' => 'views_handler_relationship', |
|
373 | - 'label' => t('User') |
|
370 | + 'base' => 'user', |
|
371 | + 'field' => 'userid', |
|
372 | + 'handler' => 'views_handler_relationship', |
|
373 | + 'label' => t('User') |
|
374 | 374 | ), |
375 | 375 | 'field' => array( |
376 | - 'handler' => 'views_handler_field_numeric', |
|
377 | - 'click sortable' => TRUE |
|
376 | + 'handler' => 'views_handler_field_numeric', |
|
377 | + 'click sortable' => TRUE |
|
378 | 378 | ), |
379 | 379 | 'filter' => array( |
380 | - 'handler' => 'views_handler_filter_numeric' |
|
380 | + 'handler' => 'views_handler_filter_numeric' |
|
381 | 381 | ), |
382 | 382 | 'sort' => array( |
383 | - 'handler' => 'views_handler_sort_numeric' |
|
383 | + 'handler' => 'views_handler_sort_numeric' |
|
384 | 384 | ) |
385 | - ); |
|
385 | + ); |
|
386 | 386 | |
387 | - // Descriptions of general fields (alphabetized) |
|
387 | + // Descriptions of general fields (alphabetized) |
|
388 | 388 | |
389 | - $data['team_delta']['joining'] = array( |
|
389 | + $data['team_delta']['joining'] = array( |
|
390 | 390 | 'title' => bts('User joined', array(), NULL, 'boinc:user-joined-or-leaving-team'), |
391 | 391 | 'help' => t('Whether the event is the user joining the team or leaving.'), |
392 | 392 | 'field' => array( |
393 | - 'handler' => 'views_handler_field_numeric', |
|
394 | - 'click sortable' => TRUE |
|
393 | + 'handler' => 'views_handler_field_numeric', |
|
394 | + 'click sortable' => TRUE |
|
395 | 395 | ), |
396 | 396 | 'filter' => array( |
397 | - 'handler' => 'views_handler_filter_numeric' |
|
397 | + 'handler' => 'views_handler_filter_numeric' |
|
398 | 398 | ), |
399 | 399 | 'sort' => array( |
400 | - 'handler' => 'views_handler_sort_numeric' |
|
400 | + 'handler' => 'views_handler_sort_numeric' |
|
401 | 401 | ) |
402 | - ); |
|
403 | - $data['team_delta']['timestamp'] = array( |
|
402 | + ); |
|
403 | + $data['team_delta']['timestamp'] = array( |
|
404 | 404 | 'title' => bts('Timestamp', array(), NULL, 'boinc:team-history-timestamp'), |
405 | 405 | 'help' => t('When the BOINC team history event took place.'), |
406 | 406 | 'field' => array( |
407 | - 'handler' => 'views_handler_field_date', |
|
408 | - 'click sortable' => TRUE |
|
407 | + 'handler' => 'views_handler_field_date', |
|
408 | + 'click sortable' => TRUE |
|
409 | 409 | ), |
410 | 410 | 'filter' => array( |
411 | - 'handler' => 'views_handler_filter_date' |
|
411 | + 'handler' => 'views_handler_filter_date' |
|
412 | 412 | ), |
413 | 413 | 'sort' => array( |
414 | - 'handler' => 'views_handler_sort_date' |
|
414 | + 'handler' => 'views_handler_sort_date' |
|
415 | 415 | ) |
416 | - ); |
|
417 | - $data['team_delta']['total_credit'] = array( |
|
416 | + ); |
|
417 | + $data['team_delta']['total_credit'] = array( |
|
418 | 418 | 'title' => bts('Total credit', array(), NULL, 'user-or-team-total-credits'), |
419 | 419 | 'help' => t('The total accumulated BOINC credit of the user when the |
420 | 420 | history event took place.'), |
421 | 421 | 'field' => array( |
422 | - 'handler' => 'views_handler_field_numeric', |
|
423 | - 'click sortable' => TRUE, |
|
424 | - 'float' => TRUE |
|
422 | + 'handler' => 'views_handler_field_numeric', |
|
423 | + 'click sortable' => TRUE, |
|
424 | + 'float' => TRUE |
|
425 | 425 | ), |
426 | 426 | 'filter' => array( |
427 | - 'handler' => 'views_handler_filter_numeric' |
|
427 | + 'handler' => 'views_handler_filter_numeric' |
|
428 | 428 | ), |
429 | 429 | 'sort' => array( |
430 | - 'handler' => 'views_handler_sort_numeric' |
|
430 | + 'handler' => 'views_handler_sort_numeric' |
|
431 | 431 | ) |
432 | - ); |
|
432 | + ); |
|
433 | 433 | |
434 | - return $data; |
|
434 | + return $data; |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | /* |
@@ -442,14 +442,14 @@ discard block |
||
442 | 442 | */ |
443 | 443 | |
444 | 444 | function boincteam_views_handlers() { |
445 | - return array( |
|
445 | + return array( |
|
446 | 446 | 'info' => array( |
447 | - 'path' => drupal_get_path('module', 'boincteam') . '/views', |
|
447 | + 'path' => drupal_get_path('module', 'boincteam') . '/views', |
|
448 | 448 | ), |
449 | 449 | 'handlers' => array( |
450 | - 'views_handler_argument_boincteam_id' => array( |
|
450 | + 'views_handler_argument_boincteam_id' => array( |
|
451 | 451 | 'parent' => 'views_handler_argument_numeric' |
452 | - ) |
|
452 | + ) |
|
453 | 453 | ) |
454 | - ); |
|
454 | + ); |
|
455 | 455 | } |
@@ -65,15 +65,15 @@ discard block |
||
65 | 65 | */ |
66 | 66 | function boincwork_admin_prefs_upload_form_validate($form, &$form_state) { |
67 | 67 | |
68 | - $xsd = './' . drupal_get_path('module', 'boincwork') . '/includes/projectprefs.xsd'; |
|
68 | + $xsd = './'.drupal_get_path('module', 'boincwork').'/includes/projectprefs.xsd'; |
|
69 | 69 | libxml_use_internal_errors(true); |
70 | 70 | $xml = new DomDocument(); |
71 | 71 | $xml->loadXML($form_state['values']['prefs_xml'], LIBXML_NOBLANKS); |
72 | 72 | if (!$xml->schemaValidate($xsd)) { |
73 | 73 | $errors = libxml_get_errors(); |
74 | 74 | $lines = explode("\r", $form_state['values']['prefs_xml']); |
75 | - drupal_set_message("{$errors[0]->message} at line {$errors[0]->line}" . |
|
76 | - ': <br/>' . htmlentities($lines[$errors[0]->line - 1]), 'error'); |
|
75 | + drupal_set_message("{$errors[0]->message} at line {$errors[0]->line}". |
|
76 | + ': <br/>'.htmlentities($lines[$errors[0]->line - 1]), 'error'); |
|
77 | 77 | form_set_error('upload', t('XML file failed validation')); |
78 | 78 | } |
79 | 79 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | "{$path}/minimum" => t('Minimum') |
102 | 102 | ); |
103 | 103 | variable_set('jump_use_js_presets-Array', 1); |
104 | - drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js'); |
|
104 | + drupal_add_js(drupal_get_path('module', 'jump').'/jump.js'); |
|
105 | 105 | $output .= '<div class="simple-form-controls"><div class="form-item venue">'; |
106 | 106 | $output .= '<label>Preset:</label>'; |
107 | 107 | $output .= jump_quickly($preset_options, 'presets'); |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | '#type' => 'submit', |
151 | 151 | '#value' => t('Save configuration') |
152 | 152 | ); |
153 | - $form['saveuseconfigxml'] = array ( |
|
153 | + $form['saveuseconfigxml'] = array( |
|
154 | 154 | '#type' => 'submit', |
155 | 155 | '#value' => t('Save configuration with disk usage settings from config.xml'), |
156 | 156 | '#validate' => array('boincwork_admin_prefs_preset_saveuseconfigxml'), |
@@ -175,33 +175,33 @@ discard block |
||
175 | 175 | // Verify all non-boolean user input values and notify form API of failures |
176 | 176 | |
177 | 177 | // Processing preferences |
178 | - if (!verify_numeric($values['processor']['idle_time_to_run'], 1, 9999)) form_set_error('idle_time_to_run', t('Invalid setting for') . " \"{$form['processor']['idle_time_to_run']['#title']} [x] {$form['processor']['idle_time_to_run']['#field_suffix']}\""); |
|
179 | - if (!verify_numeric($values['processor']['suspend_if_no_recent_input'], 0, 9999)) form_set_error('suspend_if_no_recent_input', t('Invalid setting for') . " \"{$form['processor']['suspend_if_no_recent_input']['#title']} [x] {$form['processor']['suspend_if_no_recent_input']['#field_suffix']}\""); |
|
180 | - if (!verify_numeric($values['processor']['suspend_cpu_usage'], 0, 100)) form_set_error('suspend_cpu_usage', t('Invalid setting for') . " \"{$form['processor']['suspend_cpu_usage']['#title']} [x] {$form['processor']['suspend_cpu_usage']['#field_suffix']}\""); |
|
181 | - if (!verify_numeric($values['processor']['start_hour'], 0, 23)) form_set_error('start_hour', t('Invalid setting for') . " \"{$form['processor']['start_hour']['#title']} [x] {$form['processor']['start_hour']['#field_suffix']}\""); |
|
182 | - if (!verify_numeric($values['processor']['end_hour'], 0, 23)) form_set_error('end_hour', t('Invalid setting for') . " \"{$form['processor']['end_hour']['#title']} [x] {$form['processor']['end_hour']['#field_suffix']}\""); |
|
183 | - if (!verify_numeric($values['processor']['cpu_scheduling_period_minutes'], 1, 9999)) form_set_error('cpu_scheduling_period_minutes', t('Invalid setting for') . " \"{$form['processor']['cpu_scheduling_period_minutes']['#title']} [x] {$form['processor']['cpu_scheduling_period_minutes']['#field_suffix']}\""); |
|
184 | - if (!verify_numeric($values['processor']['max_ncpus_pct'], 0, 100)) form_set_error('max_ncpus_pct', t('Invalid setting for') . " \"{$form['processor']['max_ncpus_pct']['#title']} [x] {$form['processor']['max_ncpus_pct']['#field_suffix']}\""); |
|
185 | - if (!verify_numeric($values['processor']['cpu_usage_limit'], 0, 100)) form_set_error('cpu_usage_limit', t('Invalid setting for') . " \"{$form['processor']['cpu_usage_limit']['#title']} [x] {$form['processor']['cpu_usage_limit']['#field_suffix']}\""); |
|
178 | + if (!verify_numeric($values['processor']['idle_time_to_run'], 1, 9999)) form_set_error('idle_time_to_run', t('Invalid setting for')." \"{$form['processor']['idle_time_to_run']['#title']} [x] {$form['processor']['idle_time_to_run']['#field_suffix']}\""); |
|
179 | + if (!verify_numeric($values['processor']['suspend_if_no_recent_input'], 0, 9999)) form_set_error('suspend_if_no_recent_input', t('Invalid setting for')." \"{$form['processor']['suspend_if_no_recent_input']['#title']} [x] {$form['processor']['suspend_if_no_recent_input']['#field_suffix']}\""); |
|
180 | + if (!verify_numeric($values['processor']['suspend_cpu_usage'], 0, 100)) form_set_error('suspend_cpu_usage', t('Invalid setting for')." \"{$form['processor']['suspend_cpu_usage']['#title']} [x] {$form['processor']['suspend_cpu_usage']['#field_suffix']}\""); |
|
181 | + if (!verify_numeric($values['processor']['start_hour'], 0, 23)) form_set_error('start_hour', t('Invalid setting for')." \"{$form['processor']['start_hour']['#title']} [x] {$form['processor']['start_hour']['#field_suffix']}\""); |
|
182 | + if (!verify_numeric($values['processor']['end_hour'], 0, 23)) form_set_error('end_hour', t('Invalid setting for')." \"{$form['processor']['end_hour']['#title']} [x] {$form['processor']['end_hour']['#field_suffix']}\""); |
|
183 | + if (!verify_numeric($values['processor']['cpu_scheduling_period_minutes'], 1, 9999)) form_set_error('cpu_scheduling_period_minutes', t('Invalid setting for')." \"{$form['processor']['cpu_scheduling_period_minutes']['#title']} [x] {$form['processor']['cpu_scheduling_period_minutes']['#field_suffix']}\""); |
|
184 | + if (!verify_numeric($values['processor']['max_ncpus_pct'], 0, 100)) form_set_error('max_ncpus_pct', t('Invalid setting for')." \"{$form['processor']['max_ncpus_pct']['#title']} [x] {$form['processor']['max_ncpus_pct']['#field_suffix']}\""); |
|
185 | + if (!verify_numeric($values['processor']['cpu_usage_limit'], 0, 100)) form_set_error('cpu_usage_limit', t('Invalid setting for')." \"{$form['processor']['cpu_usage_limit']['#title']} [x] {$form['processor']['cpu_usage_limit']['#field_suffix']}\""); |
|
186 | 186 | |
187 | 187 | // Storage preferences |
188 | - if (!verify_numeric($values['storage']['disk_max_used_gb'], 0, 9999999)) form_set_error('disk_max_used_gb', t('Invalid setting for') . " \"{$form['storage']['disk_max_used_gb']['#title']} [x] {$form['storage']['disk_max_used_gb']['#field_suffix']}\""); |
|
189 | - if (!verify_numeric($values['storage']['disk_min_free_gb'], 0.001, 9999999)) form_set_error('disk_min_free_gb', t('Invalid setting for') . " \"{$form['storage']['disk_min_free_gb']['#title']} [x] {$form['storage']['disk_min_free_gb']['#field_suffix']}\""); |
|
190 | - if (!verify_numeric($values['storage']['disk_max_used_pct'], 0, 100)) form_set_error('disk_max_used_pct', t('Invalid setting for') . " \"{$form['storage']['disk_max_used_pct']['#title']} [x] {$form['storage']['disk_max_used_pct']['#field_suffix']}\""); |
|
191 | - if (!verify_numeric($values['storage']['disk_interval'], 0, 9999999)) form_set_error('disk_interval', t('Invalid setting for') . " \"{$form['storage']['disk_interval']['#title']} [x] {$form['storage']['disk_interval']['#field_suffix']}\""); |
|
192 | - if (!verify_numeric($values['storage']['vm_max_used_pct'], 0, 100)) form_set_error('vm_max_used_pct', t('Invalid setting for') . " \"{$form['storage']['vm_max_used_pct']['#title']} [x] {$form['storage']['vm_max_used_pct']['#field_suffix']}\""); |
|
193 | - if (!verify_numeric($values['storage']['ram_max_used_busy_pct'], 0, 100)) form_set_error('ram_max_used_busy_pct', t('Invalid setting for') . " \"{$form['storage']['ram_max_used_busy_pct']['#title']} [x] {$form['storage']['ram_max_used_busy_pct']['#field_suffix']}\""); |
|
194 | - if (!verify_numeric($values['storage']['ram_max_used_idle_pct'], 0, 100)) form_set_error('ram_max_used_idle_pct', t('Invalid setting for') . " \"{$form['storage']['ram_max_used_idle_pct']['#title']} [x] {$form['storage']['ram_max_used_idle_pct']['#field_suffix']}\""); |
|
188 | + if (!verify_numeric($values['storage']['disk_max_used_gb'], 0, 9999999)) form_set_error('disk_max_used_gb', t('Invalid setting for')." \"{$form['storage']['disk_max_used_gb']['#title']} [x] {$form['storage']['disk_max_used_gb']['#field_suffix']}\""); |
|
189 | + if (!verify_numeric($values['storage']['disk_min_free_gb'], 0.001, 9999999)) form_set_error('disk_min_free_gb', t('Invalid setting for')." \"{$form['storage']['disk_min_free_gb']['#title']} [x] {$form['storage']['disk_min_free_gb']['#field_suffix']}\""); |
|
190 | + if (!verify_numeric($values['storage']['disk_max_used_pct'], 0, 100)) form_set_error('disk_max_used_pct', t('Invalid setting for')." \"{$form['storage']['disk_max_used_pct']['#title']} [x] {$form['storage']['disk_max_used_pct']['#field_suffix']}\""); |
|
191 | + if (!verify_numeric($values['storage']['disk_interval'], 0, 9999999)) form_set_error('disk_interval', t('Invalid setting for')." \"{$form['storage']['disk_interval']['#title']} [x] {$form['storage']['disk_interval']['#field_suffix']}\""); |
|
192 | + if (!verify_numeric($values['storage']['vm_max_used_pct'], 0, 100)) form_set_error('vm_max_used_pct', t('Invalid setting for')." \"{$form['storage']['vm_max_used_pct']['#title']} [x] {$form['storage']['vm_max_used_pct']['#field_suffix']}\""); |
|
193 | + if (!verify_numeric($values['storage']['ram_max_used_busy_pct'], 0, 100)) form_set_error('ram_max_used_busy_pct', t('Invalid setting for')." \"{$form['storage']['ram_max_used_busy_pct']['#title']} [x] {$form['storage']['ram_max_used_busy_pct']['#field_suffix']}\""); |
|
194 | + if (!verify_numeric($values['storage']['ram_max_used_idle_pct'], 0, 100)) form_set_error('ram_max_used_idle_pct', t('Invalid setting for')." \"{$form['storage']['ram_max_used_idle_pct']['#title']} [x] {$form['storage']['ram_max_used_idle_pct']['#field_suffix']}\""); |
|
195 | 195 | |
196 | 196 | // Network preferences |
197 | - if (!verify_numeric($values['network']['work_buf_min_days'], 0, 10)) form_set_error('work_buf_min_days', t('Invalid setting for') . " \"{$form['network']['work_buf_min_days']['#title']} [x] {$form['network']['work_buf_min_days']['#field_suffix']}\""); |
|
198 | - if (!verify_numeric($values['network']['work_buf_additional_days'], 0, 10)) form_set_error('work_buf_additional_days', t('Invalid setting for') . " \"{$form['network']['work_buf_additional_days']['#title']} [x] {$form['network']['work_buf_additional_days']['#field_suffix']}\""); |
|
199 | - if (!verify_numeric($values['network']['max_bytes_sec_down'], 0, 9999.999)) form_set_error('max_bytes_sec_down', t('Invalid setting for') . " \"{$form['network']['max_bytes_sec_down']['#title']} [x] {$form['network']['max_bytes_sec_down']['#field_suffix']}\""); |
|
200 | - if (!verify_numeric($values['network']['max_bytes_sec_up'], 0, 9999.999)) form_set_error('max_bytes_sec_up', t('Invalid setting for') . " \"{$form['network']['max_bytes_sec_up']['#title']} [x] {$form['network']['max_bytes_sec_up']['#field_suffix']}\""); |
|
201 | - if (!verify_numeric($values['network']['net_start_hour'], 0, 23)) form_set_error('net_start_hour', t('Invalid setting for') . " \"{$form['network']['net_start_hour']['#title']} [x] {$form['network']['net_start_hour']['#field_suffix']}\""); |
|
202 | - if (!verify_numeric($values['network']['net_end_hour'], 0, 23)) form_set_error('net_end_hour', t('Invalid setting for') . " \"{$form['network']['net_end_hour']['#title']} [x] {$form['network']['net_end_hour']['#field_suffix']}\""); |
|
203 | - if (!verify_numeric($values['network']['daily_xfer_limit_mb'], 0, 9999999)) form_set_error('daily_xfer_limit_mb', t('Invalid setting for') . " \"{$form['network']['daily_xfer_limit_mb']['#title']} [x] {$form['network']['daily_xfer_limit_mb']['#field_suffix']}\""); |
|
204 | - if (!verify_numeric($values['network']['daily_xfer_period_days'], 0, 9999999)) form_set_error('daily_xfer_period_days', t('Invalid setting for') . " \"{$form['network']['daily_xfer_limit_mb']['#title']} [x] {$form['network']['daily_xfer_limit_mb']['#field_suffix']}\""); |
|
197 | + if (!verify_numeric($values['network']['work_buf_min_days'], 0, 10)) form_set_error('work_buf_min_days', t('Invalid setting for')." \"{$form['network']['work_buf_min_days']['#title']} [x] {$form['network']['work_buf_min_days']['#field_suffix']}\""); |
|
198 | + if (!verify_numeric($values['network']['work_buf_additional_days'], 0, 10)) form_set_error('work_buf_additional_days', t('Invalid setting for')." \"{$form['network']['work_buf_additional_days']['#title']} [x] {$form['network']['work_buf_additional_days']['#field_suffix']}\""); |
|
199 | + if (!verify_numeric($values['network']['max_bytes_sec_down'], 0, 9999.999)) form_set_error('max_bytes_sec_down', t('Invalid setting for')." \"{$form['network']['max_bytes_sec_down']['#title']} [x] {$form['network']['max_bytes_sec_down']['#field_suffix']}\""); |
|
200 | + if (!verify_numeric($values['network']['max_bytes_sec_up'], 0, 9999.999)) form_set_error('max_bytes_sec_up', t('Invalid setting for')." \"{$form['network']['max_bytes_sec_up']['#title']} [x] {$form['network']['max_bytes_sec_up']['#field_suffix']}\""); |
|
201 | + if (!verify_numeric($values['network']['net_start_hour'], 0, 23)) form_set_error('net_start_hour', t('Invalid setting for')." \"{$form['network']['net_start_hour']['#title']} [x] {$form['network']['net_start_hour']['#field_suffix']}\""); |
|
202 | + if (!verify_numeric($values['network']['net_end_hour'], 0, 23)) form_set_error('net_end_hour', t('Invalid setting for')." \"{$form['network']['net_end_hour']['#title']} [x] {$form['network']['net_end_hour']['#field_suffix']}\""); |
|
203 | + if (!verify_numeric($values['network']['daily_xfer_limit_mb'], 0, 9999999)) form_set_error('daily_xfer_limit_mb', t('Invalid setting for')." \"{$form['network']['daily_xfer_limit_mb']['#title']} [x] {$form['network']['daily_xfer_limit_mb']['#field_suffix']}\""); |
|
204 | + if (!verify_numeric($values['network']['daily_xfer_period_days'], 0, 9999999)) form_set_error('daily_xfer_period_days', t('Invalid setting for')." \"{$form['network']['daily_xfer_limit_mb']['#title']} [x] {$form['network']['daily_xfer_limit_mb']['#field_suffix']}\""); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | // Processing preferences |
218 | 218 | $prefs['run_on_batteries'] = ($values['processor']['run_on_batteries']) ? 0 : 1; |
219 | 219 | $prefs['run_if_user_active'] = ($values['processor']['run_if_user_active']) ? 0 : 1; |
220 | - $prefs['run_gpu_if_user_active'] = ($values['processor']['run_gpu_if_user_active']) ? 0: 1; |
|
220 | + $prefs['run_gpu_if_user_active'] = ($values['processor']['run_gpu_if_user_active']) ? 0 : 1; |
|
221 | 221 | $prefs['idle_time_to_run'] = $values['processor']['idle_time_to_run']; |
222 | 222 | $prefs['suspend_if_no_recent_input'] = $values['processor']['suspend_if_no_recent_input']; |
223 | 223 | $prefs['suspend_cpu_usage'] = $values['processor']['suspend_cpu_usage']; |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | |
268 | 268 | // Get the full configuration |
269 | 269 | $all_presets = boincwork_get_preset_prefs(); |
270 | - $all_presets = (array) $all_presets['general_preferences']; |
|
270 | + $all_presets = (array)$all_presets['general_preferences']; |
|
271 | 271 | |
272 | 272 | // Check for sane config |
273 | 273 | if (isset($all_presets['preset'])) { |
@@ -10,80 +10,80 @@ discard block |
||
10 | 10 | * Allow configuration of general options for preference pages |
11 | 11 | */ |
12 | 12 | function boincwork_admin_prefs_options_form(&$form_state) { |
13 | - $form = array(); |
|
14 | - $form['beta'] = array( |
|
13 | + $form = array(); |
|
14 | + $form['beta'] = array( |
|
15 | 15 | '#type' => 'checkbox', |
16 | 16 | '#title' => t('Allow users to opt in to test beta applications'), |
17 | 17 | '#default_value' => variable_get('boinc_prefs_options_beta', 0), |
18 | 18 | '#required' => TRUE |
19 | - ); |
|
20 | - $form['submit'] = array( |
|
19 | + ); |
|
20 | + $form['submit'] = array( |
|
21 | 21 | '#type' => 'submit', |
22 | 22 | '#value' => t('Submit') |
23 | - ); |
|
24 | - // Add the official mechanical things and return |
|
25 | - //drupal_prepare_form('boincwork_admin_prefs_upload_form', $form, $form_state); |
|
26 | - return $form; |
|
23 | + ); |
|
24 | + // Add the official mechanical things and return |
|
25 | + //drupal_prepare_form('boincwork_admin_prefs_upload_form', $form, $form_state); |
|
26 | + return $form; |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
30 | - * Handle validation of preference general settings form. |
|
31 | - */ |
|
30 | + * Handle validation of preference general settings form. |
|
31 | + */ |
|
32 | 32 | function boincwork_admin_prefs_options_form_validate($form, &$form_state) { |
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
36 | - * Handle submission of preference general settings form. |
|
37 | - */ |
|
36 | + * Handle submission of preference general settings form. |
|
37 | + */ |
|
38 | 38 | function boincwork_admin_prefs_options_form_submit($form, &$form_state) { |
39 | - variable_set('boinc_prefs_options_beta', $form_state['values']['beta']); |
|
40 | - drupal_set_message('Preference options have been updated.'); |
|
39 | + variable_set('boinc_prefs_options_beta', $form_state['values']['beta']); |
|
40 | + drupal_set_message('Preference options have been updated.'); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
44 | 44 | * |
45 | 45 | */ |
46 | 46 | function boincwork_admin_prefs_upload_form(&$form_state) { |
47 | - $form = array(); |
|
48 | - $form['prefs_xml'] = array( |
|
47 | + $form = array(); |
|
48 | + $form['prefs_xml'] = array( |
|
49 | 49 | '#type' => 'textarea', |
50 | 50 | '#title' => t('Project specific preferences XML'), |
51 | 51 | '#default_value' => variable_get('boinc_project_specific_prefs_config', "<project_specific_preferences>\n\n</project_specific_preferences>"), |
52 | 52 | '#required' => TRUE |
53 | - ); |
|
54 | - $form['submit'] = array( |
|
53 | + ); |
|
54 | + $form['submit'] = array( |
|
55 | 55 | '#type' => 'submit', |
56 | 56 | '#value' => t('Submit') |
57 | - ); |
|
58 | - // Add the official mechanical things and return |
|
59 | - //drupal_prepare_form('boincwork_admin_prefs_upload_form', $form, $form_state); |
|
60 | - return $form; |
|
57 | + ); |
|
58 | + // Add the official mechanical things and return |
|
59 | + //drupal_prepare_form('boincwork_admin_prefs_upload_form', $form, $form_state); |
|
60 | + return $form; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
64 | - * Handle validation of preference upload form. |
|
65 | - */ |
|
64 | + * Handle validation of preference upload form. |
|
65 | + */ |
|
66 | 66 | function boincwork_admin_prefs_upload_form_validate($form, &$form_state) { |
67 | 67 | |
68 | - $xsd = './' . drupal_get_path('module', 'boincwork') . '/includes/projectprefs.xsd'; |
|
69 | - libxml_use_internal_errors(true); |
|
70 | - $xml = new DomDocument(); |
|
71 | - $xml->loadXML($form_state['values']['prefs_xml'], LIBXML_NOBLANKS); |
|
72 | - if (!$xml->schemaValidate($xsd)) { |
|
68 | + $xsd = './' . drupal_get_path('module', 'boincwork') . '/includes/projectprefs.xsd'; |
|
69 | + libxml_use_internal_errors(true); |
|
70 | + $xml = new DomDocument(); |
|
71 | + $xml->loadXML($form_state['values']['prefs_xml'], LIBXML_NOBLANKS); |
|
72 | + if (!$xml->schemaValidate($xsd)) { |
|
73 | 73 | $errors = libxml_get_errors(); |
74 | 74 | $lines = explode("\r", $form_state['values']['prefs_xml']); |
75 | 75 | drupal_set_message("{$errors[0]->message} at line {$errors[0]->line}" . |
76 | - ': <br/>' . htmlentities($lines[$errors[0]->line - 1]), 'error'); |
|
76 | + ': <br/>' . htmlentities($lines[$errors[0]->line - 1]), 'error'); |
|
77 | 77 | form_set_error('upload', t('XML file failed validation')); |
78 | - } |
|
78 | + } |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
82 | - * Handle submission of preference upload form. |
|
83 | - */ |
|
82 | + * Handle submission of preference upload form. |
|
83 | + */ |
|
84 | 84 | function boincwork_admin_prefs_upload_form_submit($form, &$form_state) { |
85 | - variable_set('boinc_project_specific_prefs_config', $form_state['values']['prefs_xml']); |
|
86 | - drupal_set_message('The XML has been validated and any changes to |
|
85 | + variable_set('boinc_project_specific_prefs_config', $form_state['values']['prefs_xml']); |
|
86 | + drupal_set_message('The XML has been validated and any changes to |
|
87 | 87 | preferences are now in place.'); |
88 | 88 | } |
89 | 89 | |
@@ -91,14 +91,14 @@ discard block |
||
91 | 91 | * |
92 | 92 | */ |
93 | 93 | function boincwork_admin_prefs_presets_page($preset = 'standard') { |
94 | - // Configure preference presets |
|
95 | - if (function_exists('jump_quickly')) { |
|
94 | + // Configure preference presets |
|
95 | + if (function_exists('jump_quickly')) { |
|
96 | 96 | $path = 'admin/boinc/prefs/presets'; |
97 | 97 | $preset_options = array( |
98 | - "{$path}/standard" => t('Standard'), |
|
99 | - "{$path}/maximum" => t('Maximum'), |
|
100 | - "{$path}/green" => t('Green'), |
|
101 | - "{$path}/minimum" => t('Minimum') |
|
98 | + "{$path}/standard" => t('Standard'), |
|
99 | + "{$path}/maximum" => t('Maximum'), |
|
100 | + "{$path}/green" => t('Green'), |
|
101 | + "{$path}/minimum" => t('Minimum') |
|
102 | 102 | ); |
103 | 103 | variable_set('jump_use_js_presets-Array', 1); |
104 | 104 | drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js'); |
@@ -106,15 +106,15 @@ discard block |
||
106 | 106 | $output .= '<label>Preset:</label>'; |
107 | 107 | $output .= jump_quickly($preset_options, 'presets'); |
108 | 108 | $output .= '</div></div>'; |
109 | - } |
|
110 | - $output .= drupal_get_form('boincwork_admin_prefs_presets_form', $preset); |
|
111 | - |
|
112 | - $output .= '<div>'; |
|
113 | - $output .= bts('Usage: \'Save configuration\' will save the above preferences into the drupal database. These will be the preset computing (global) preferences that will fill in the preferences form once a user loads the Account Preferences page.', array(), NULL, 'boinc:admin-boinc-preference-presets'); |
|
114 | - $output .= '<p>'; |
|
115 | - $output .= bts('\'Save configuration with disk usage settings from config.xml\' will save the above preferences into the drupal database, but also load disk usage settings from the BOINC project\'s config.xml file. These will overwrite any disk usage settings you have placed above. Caution: A user\'s personal preferences will not change if you load the disk usage settings from config.xml here into the drupal database. They must change their preference settings manually.', array(), NULL, 'boinc:admin-boinc-preference-presets'); |
|
116 | - $output .= '</div>'; |
|
117 | - return $output; |
|
109 | + } |
|
110 | + $output .= drupal_get_form('boincwork_admin_prefs_presets_form', $preset); |
|
111 | + |
|
112 | + $output .= '<div>'; |
|
113 | + $output .= bts('Usage: \'Save configuration\' will save the above preferences into the drupal database. These will be the preset computing (global) preferences that will fill in the preferences form once a user loads the Account Preferences page.', array(), NULL, 'boinc:admin-boinc-preference-presets'); |
|
114 | + $output .= '<p>'; |
|
115 | + $output .= bts('\'Save configuration with disk usage settings from config.xml\' will save the above preferences into the drupal database, but also load disk usage settings from the BOINC project\'s config.xml file. These will overwrite any disk usage settings you have placed above. Caution: A user\'s personal preferences will not change if you load the disk usage settings from config.xml here into the drupal database. They must change their preference settings manually.', array(), NULL, 'boinc:admin-boinc-preference-presets'); |
|
116 | + $output .= '</div>'; |
|
117 | + return $output; |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -122,141 +122,141 @@ discard block |
||
122 | 122 | */ |
123 | 123 | function boincwork_admin_prefs_presets_form(&$form_state, $preset = 'standard') { |
124 | 124 | |
125 | - // Check database for preset prefs |
|
126 | - if (!variable_get('boincwork_preset_prefs', null)) |
|
125 | + // Check database for preset prefs |
|
126 | + if (!variable_get('boincwork_preset_prefs', null)) |
|
127 | 127 | drupal_set_message(bts('No presets found in database, loading a default set of preferences for each preset. These will be saved to the database once you click \'Save configuration\'.', array(), NULL, 'boinc:admin-boinc-preference-presets'), 'status'); |
128 | 128 | |
129 | - // Load a copy of the general prefs form |
|
130 | - $form = boincwork_generalprefs_form($form_state, NULL, $preset); |
|
131 | - if ($key = array_search('boincwork_generalprefs_form_submit', $form['#submit'])) { |
|
129 | + // Load a copy of the general prefs form |
|
130 | + $form = boincwork_generalprefs_form($form_state, NULL, $preset); |
|
131 | + if ($key = array_search('boincwork_generalprefs_form_submit', $form['#submit'])) { |
|
132 | 132 | unset($form['#submit'][$key]); |
133 | - } |
|
134 | - $form['#submit'][] = 'boincwork_admin_prefs_presets_form_submit'; |
|
135 | - |
|
136 | - // Just keep the necessary items |
|
137 | - $form['processor'] = $form['prefs']['advanced']['processor']; |
|
138 | - $form['storage'] = $form['prefs']['advanced']['storage']; |
|
139 | - $form['network'] = $form['prefs']['advanced']['network']; |
|
140 | - unset($form['prefs']); |
|
141 | - |
|
142 | - // Tweak some things so it behaves a little better |
|
143 | - $form['#tree'] = TRUE; |
|
144 | - $form['processor']['#collapsible'] = TRUE; |
|
145 | - $form['storage']['#collapsible'] = TRUE; |
|
146 | - $form['network']['#collapsible'] = TRUE; |
|
147 | - |
|
148 | - // Add a submit button and a hidden field to pass the preset |
|
149 | - $form['submit'] = array( |
|
133 | + } |
|
134 | + $form['#submit'][] = 'boincwork_admin_prefs_presets_form_submit'; |
|
135 | + |
|
136 | + // Just keep the necessary items |
|
137 | + $form['processor'] = $form['prefs']['advanced']['processor']; |
|
138 | + $form['storage'] = $form['prefs']['advanced']['storage']; |
|
139 | + $form['network'] = $form['prefs']['advanced']['network']; |
|
140 | + unset($form['prefs']); |
|
141 | + |
|
142 | + // Tweak some things so it behaves a little better |
|
143 | + $form['#tree'] = TRUE; |
|
144 | + $form['processor']['#collapsible'] = TRUE; |
|
145 | + $form['storage']['#collapsible'] = TRUE; |
|
146 | + $form['network']['#collapsible'] = TRUE; |
|
147 | + |
|
148 | + // Add a submit button and a hidden field to pass the preset |
|
149 | + $form['submit'] = array( |
|
150 | 150 | '#type' => 'submit', |
151 | 151 | '#value' => t('Save configuration') |
152 | - ); |
|
153 | - $form['saveuseconfigxml'] = array ( |
|
154 | - '#type' => 'submit', |
|
155 | - '#value' => t('Save configuration with disk usage settings from config.xml'), |
|
156 | - '#validate' => array('boincwork_admin_prefs_preset_saveuseconfigxml'), |
|
157 | - ); |
|
158 | - $form['preset'] = array( |
|
152 | + ); |
|
153 | + $form['saveuseconfigxml'] = array ( |
|
154 | + '#type' => 'submit', |
|
155 | + '#value' => t('Save configuration with disk usage settings from config.xml'), |
|
156 | + '#validate' => array('boincwork_admin_prefs_preset_saveuseconfigxml'), |
|
157 | + ); |
|
158 | + $form['preset'] = array( |
|
159 | 159 | '#type' => 'hidden', |
160 | 160 | '#value' => $preset |
161 | - ); |
|
161 | + ); |
|
162 | 162 | |
163 | - // Add the official mechanical things and return |
|
164 | - drupal_prepare_form('boincwork_admin_prefs_presets_form', $form, $form_state); |
|
165 | - return $form; |
|
163 | + // Add the official mechanical things and return |
|
164 | + drupal_prepare_form('boincwork_admin_prefs_presets_form', $form, $form_state); |
|
165 | + return $form; |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
169 | - * Validate the preference presets form. |
|
170 | - */ |
|
169 | + * Validate the preference presets form. |
|
170 | + */ |
|
171 | 171 | function boincwork_admin_prefs_presets_form_validate($form, &$form_state) { |
172 | - require_boinc('util'); |
|
173 | - $values = $form_state['values']; |
|
174 | - |
|
175 | - // Verify all non-boolean user input values and notify form API of failures |
|
176 | - |
|
177 | - // Processing preferences |
|
178 | - if (!verify_numeric($values['processor']['idle_time_to_run'], 1, 9999)) form_set_error('idle_time_to_run', t('Invalid setting for') . " \"{$form['processor']['idle_time_to_run']['#title']} [x] {$form['processor']['idle_time_to_run']['#field_suffix']}\""); |
|
179 | - if (!verify_numeric($values['processor']['suspend_if_no_recent_input'], 0, 9999)) form_set_error('suspend_if_no_recent_input', t('Invalid setting for') . " \"{$form['processor']['suspend_if_no_recent_input']['#title']} [x] {$form['processor']['suspend_if_no_recent_input']['#field_suffix']}\""); |
|
180 | - if (!verify_numeric($values['processor']['suspend_cpu_usage'], 0, 100)) form_set_error('suspend_cpu_usage', t('Invalid setting for') . " \"{$form['processor']['suspend_cpu_usage']['#title']} [x] {$form['processor']['suspend_cpu_usage']['#field_suffix']}\""); |
|
181 | - if (!verify_numeric($values['processor']['start_hour'], 0, 23)) form_set_error('start_hour', t('Invalid setting for') . " \"{$form['processor']['start_hour']['#title']} [x] {$form['processor']['start_hour']['#field_suffix']}\""); |
|
182 | - if (!verify_numeric($values['processor']['end_hour'], 0, 23)) form_set_error('end_hour', t('Invalid setting for') . " \"{$form['processor']['end_hour']['#title']} [x] {$form['processor']['end_hour']['#field_suffix']}\""); |
|
183 | - if (!verify_numeric($values['processor']['cpu_scheduling_period_minutes'], 1, 9999)) form_set_error('cpu_scheduling_period_minutes', t('Invalid setting for') . " \"{$form['processor']['cpu_scheduling_period_minutes']['#title']} [x] {$form['processor']['cpu_scheduling_period_minutes']['#field_suffix']}\""); |
|
184 | - if (!verify_numeric($values['processor']['max_ncpus_pct'], 0, 100)) form_set_error('max_ncpus_pct', t('Invalid setting for') . " \"{$form['processor']['max_ncpus_pct']['#title']} [x] {$form['processor']['max_ncpus_pct']['#field_suffix']}\""); |
|
185 | - if (!verify_numeric($values['processor']['cpu_usage_limit'], 0, 100)) form_set_error('cpu_usage_limit', t('Invalid setting for') . " \"{$form['processor']['cpu_usage_limit']['#title']} [x] {$form['processor']['cpu_usage_limit']['#field_suffix']}\""); |
|
186 | - |
|
187 | - // Storage preferences |
|
188 | - if (!verify_numeric($values['storage']['disk_max_used_gb'], 0, 9999999)) form_set_error('disk_max_used_gb', t('Invalid setting for') . " \"{$form['storage']['disk_max_used_gb']['#title']} [x] {$form['storage']['disk_max_used_gb']['#field_suffix']}\""); |
|
189 | - if (!verify_numeric($values['storage']['disk_min_free_gb'], 0.001, 9999999)) form_set_error('disk_min_free_gb', t('Invalid setting for') . " \"{$form['storage']['disk_min_free_gb']['#title']} [x] {$form['storage']['disk_min_free_gb']['#field_suffix']}\""); |
|
190 | - if (!verify_numeric($values['storage']['disk_max_used_pct'], 0, 100)) form_set_error('disk_max_used_pct', t('Invalid setting for') . " \"{$form['storage']['disk_max_used_pct']['#title']} [x] {$form['storage']['disk_max_used_pct']['#field_suffix']}\""); |
|
191 | - if (!verify_numeric($values['storage']['disk_interval'], 0, 9999999)) form_set_error('disk_interval', t('Invalid setting for') . " \"{$form['storage']['disk_interval']['#title']} [x] {$form['storage']['disk_interval']['#field_suffix']}\""); |
|
192 | - if (!verify_numeric($values['storage']['vm_max_used_pct'], 0, 100)) form_set_error('vm_max_used_pct', t('Invalid setting for') . " \"{$form['storage']['vm_max_used_pct']['#title']} [x] {$form['storage']['vm_max_used_pct']['#field_suffix']}\""); |
|
193 | - if (!verify_numeric($values['storage']['ram_max_used_busy_pct'], 0, 100)) form_set_error('ram_max_used_busy_pct', t('Invalid setting for') . " \"{$form['storage']['ram_max_used_busy_pct']['#title']} [x] {$form['storage']['ram_max_used_busy_pct']['#field_suffix']}\""); |
|
194 | - if (!verify_numeric($values['storage']['ram_max_used_idle_pct'], 0, 100)) form_set_error('ram_max_used_idle_pct', t('Invalid setting for') . " \"{$form['storage']['ram_max_used_idle_pct']['#title']} [x] {$form['storage']['ram_max_used_idle_pct']['#field_suffix']}\""); |
|
195 | - |
|
196 | - // Network preferences |
|
197 | - if (!verify_numeric($values['network']['work_buf_min_days'], 0, 10)) form_set_error('work_buf_min_days', t('Invalid setting for') . " \"{$form['network']['work_buf_min_days']['#title']} [x] {$form['network']['work_buf_min_days']['#field_suffix']}\""); |
|
198 | - if (!verify_numeric($values['network']['work_buf_additional_days'], 0, 10)) form_set_error('work_buf_additional_days', t('Invalid setting for') . " \"{$form['network']['work_buf_additional_days']['#title']} [x] {$form['network']['work_buf_additional_days']['#field_suffix']}\""); |
|
199 | - if (!verify_numeric($values['network']['max_bytes_sec_down'], 0, 9999.999)) form_set_error('max_bytes_sec_down', t('Invalid setting for') . " \"{$form['network']['max_bytes_sec_down']['#title']} [x] {$form['network']['max_bytes_sec_down']['#field_suffix']}\""); |
|
200 | - if (!verify_numeric($values['network']['max_bytes_sec_up'], 0, 9999.999)) form_set_error('max_bytes_sec_up', t('Invalid setting for') . " \"{$form['network']['max_bytes_sec_up']['#title']} [x] {$form['network']['max_bytes_sec_up']['#field_suffix']}\""); |
|
201 | - if (!verify_numeric($values['network']['net_start_hour'], 0, 23)) form_set_error('net_start_hour', t('Invalid setting for') . " \"{$form['network']['net_start_hour']['#title']} [x] {$form['network']['net_start_hour']['#field_suffix']}\""); |
|
202 | - if (!verify_numeric($values['network']['net_end_hour'], 0, 23)) form_set_error('net_end_hour', t('Invalid setting for') . " \"{$form['network']['net_end_hour']['#title']} [x] {$form['network']['net_end_hour']['#field_suffix']}\""); |
|
203 | - if (!verify_numeric($values['network']['daily_xfer_limit_mb'], 0, 9999999)) form_set_error('daily_xfer_limit_mb', t('Invalid setting for') . " \"{$form['network']['daily_xfer_limit_mb']['#title']} [x] {$form['network']['daily_xfer_limit_mb']['#field_suffix']}\""); |
|
204 | - if (!verify_numeric($values['network']['daily_xfer_period_days'], 0, 9999999)) form_set_error('daily_xfer_period_days', t('Invalid setting for') . " \"{$form['network']['daily_xfer_limit_mb']['#title']} [x] {$form['network']['daily_xfer_limit_mb']['#field_suffix']}\""); |
|
172 | + require_boinc('util'); |
|
173 | + $values = $form_state['values']; |
|
174 | + |
|
175 | + // Verify all non-boolean user input values and notify form API of failures |
|
176 | + |
|
177 | + // Processing preferences |
|
178 | + if (!verify_numeric($values['processor']['idle_time_to_run'], 1, 9999)) form_set_error('idle_time_to_run', t('Invalid setting for') . " \"{$form['processor']['idle_time_to_run']['#title']} [x] {$form['processor']['idle_time_to_run']['#field_suffix']}\""); |
|
179 | + if (!verify_numeric($values['processor']['suspend_if_no_recent_input'], 0, 9999)) form_set_error('suspend_if_no_recent_input', t('Invalid setting for') . " \"{$form['processor']['suspend_if_no_recent_input']['#title']} [x] {$form['processor']['suspend_if_no_recent_input']['#field_suffix']}\""); |
|
180 | + if (!verify_numeric($values['processor']['suspend_cpu_usage'], 0, 100)) form_set_error('suspend_cpu_usage', t('Invalid setting for') . " \"{$form['processor']['suspend_cpu_usage']['#title']} [x] {$form['processor']['suspend_cpu_usage']['#field_suffix']}\""); |
|
181 | + if (!verify_numeric($values['processor']['start_hour'], 0, 23)) form_set_error('start_hour', t('Invalid setting for') . " \"{$form['processor']['start_hour']['#title']} [x] {$form['processor']['start_hour']['#field_suffix']}\""); |
|
182 | + if (!verify_numeric($values['processor']['end_hour'], 0, 23)) form_set_error('end_hour', t('Invalid setting for') . " \"{$form['processor']['end_hour']['#title']} [x] {$form['processor']['end_hour']['#field_suffix']}\""); |
|
183 | + if (!verify_numeric($values['processor']['cpu_scheduling_period_minutes'], 1, 9999)) form_set_error('cpu_scheduling_period_minutes', t('Invalid setting for') . " \"{$form['processor']['cpu_scheduling_period_minutes']['#title']} [x] {$form['processor']['cpu_scheduling_period_minutes']['#field_suffix']}\""); |
|
184 | + if (!verify_numeric($values['processor']['max_ncpus_pct'], 0, 100)) form_set_error('max_ncpus_pct', t('Invalid setting for') . " \"{$form['processor']['max_ncpus_pct']['#title']} [x] {$form['processor']['max_ncpus_pct']['#field_suffix']}\""); |
|
185 | + if (!verify_numeric($values['processor']['cpu_usage_limit'], 0, 100)) form_set_error('cpu_usage_limit', t('Invalid setting for') . " \"{$form['processor']['cpu_usage_limit']['#title']} [x] {$form['processor']['cpu_usage_limit']['#field_suffix']}\""); |
|
186 | + |
|
187 | + // Storage preferences |
|
188 | + if (!verify_numeric($values['storage']['disk_max_used_gb'], 0, 9999999)) form_set_error('disk_max_used_gb', t('Invalid setting for') . " \"{$form['storage']['disk_max_used_gb']['#title']} [x] {$form['storage']['disk_max_used_gb']['#field_suffix']}\""); |
|
189 | + if (!verify_numeric($values['storage']['disk_min_free_gb'], 0.001, 9999999)) form_set_error('disk_min_free_gb', t('Invalid setting for') . " \"{$form['storage']['disk_min_free_gb']['#title']} [x] {$form['storage']['disk_min_free_gb']['#field_suffix']}\""); |
|
190 | + if (!verify_numeric($values['storage']['disk_max_used_pct'], 0, 100)) form_set_error('disk_max_used_pct', t('Invalid setting for') . " \"{$form['storage']['disk_max_used_pct']['#title']} [x] {$form['storage']['disk_max_used_pct']['#field_suffix']}\""); |
|
191 | + if (!verify_numeric($values['storage']['disk_interval'], 0, 9999999)) form_set_error('disk_interval', t('Invalid setting for') . " \"{$form['storage']['disk_interval']['#title']} [x] {$form['storage']['disk_interval']['#field_suffix']}\""); |
|
192 | + if (!verify_numeric($values['storage']['vm_max_used_pct'], 0, 100)) form_set_error('vm_max_used_pct', t('Invalid setting for') . " \"{$form['storage']['vm_max_used_pct']['#title']} [x] {$form['storage']['vm_max_used_pct']['#field_suffix']}\""); |
|
193 | + if (!verify_numeric($values['storage']['ram_max_used_busy_pct'], 0, 100)) form_set_error('ram_max_used_busy_pct', t('Invalid setting for') . " \"{$form['storage']['ram_max_used_busy_pct']['#title']} [x] {$form['storage']['ram_max_used_busy_pct']['#field_suffix']}\""); |
|
194 | + if (!verify_numeric($values['storage']['ram_max_used_idle_pct'], 0, 100)) form_set_error('ram_max_used_idle_pct', t('Invalid setting for') . " \"{$form['storage']['ram_max_used_idle_pct']['#title']} [x] {$form['storage']['ram_max_used_idle_pct']['#field_suffix']}\""); |
|
195 | + |
|
196 | + // Network preferences |
|
197 | + if (!verify_numeric($values['network']['work_buf_min_days'], 0, 10)) form_set_error('work_buf_min_days', t('Invalid setting for') . " \"{$form['network']['work_buf_min_days']['#title']} [x] {$form['network']['work_buf_min_days']['#field_suffix']}\""); |
|
198 | + if (!verify_numeric($values['network']['work_buf_additional_days'], 0, 10)) form_set_error('work_buf_additional_days', t('Invalid setting for') . " \"{$form['network']['work_buf_additional_days']['#title']} [x] {$form['network']['work_buf_additional_days']['#field_suffix']}\""); |
|
199 | + if (!verify_numeric($values['network']['max_bytes_sec_down'], 0, 9999.999)) form_set_error('max_bytes_sec_down', t('Invalid setting for') . " \"{$form['network']['max_bytes_sec_down']['#title']} [x] {$form['network']['max_bytes_sec_down']['#field_suffix']}\""); |
|
200 | + if (!verify_numeric($values['network']['max_bytes_sec_up'], 0, 9999.999)) form_set_error('max_bytes_sec_up', t('Invalid setting for') . " \"{$form['network']['max_bytes_sec_up']['#title']} [x] {$form['network']['max_bytes_sec_up']['#field_suffix']}\""); |
|
201 | + if (!verify_numeric($values['network']['net_start_hour'], 0, 23)) form_set_error('net_start_hour', t('Invalid setting for') . " \"{$form['network']['net_start_hour']['#title']} [x] {$form['network']['net_start_hour']['#field_suffix']}\""); |
|
202 | + if (!verify_numeric($values['network']['net_end_hour'], 0, 23)) form_set_error('net_end_hour', t('Invalid setting for') . " \"{$form['network']['net_end_hour']['#title']} [x] {$form['network']['net_end_hour']['#field_suffix']}\""); |
|
203 | + if (!verify_numeric($values['network']['daily_xfer_limit_mb'], 0, 9999999)) form_set_error('daily_xfer_limit_mb', t('Invalid setting for') . " \"{$form['network']['daily_xfer_limit_mb']['#title']} [x] {$form['network']['daily_xfer_limit_mb']['#field_suffix']}\""); |
|
204 | + if (!verify_numeric($values['network']['daily_xfer_period_days'], 0, 9999999)) form_set_error('daily_xfer_period_days', t('Invalid setting for') . " \"{$form['network']['daily_xfer_limit_mb']['#title']} [x] {$form['network']['daily_xfer_limit_mb']['#field_suffix']}\""); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
208 | - * Handle post-validation submission of preference presets form. |
|
209 | - */ |
|
208 | + * Handle post-validation submission of preference presets form. |
|
209 | + */ |
|
210 | 210 | function boincwork_admin_prefs_presets_form_submit($form, &$form_state) { |
211 | - $values = $form_state['values']; |
|
212 | - $preset = $form_state['values']['preset']; |
|
213 | - |
|
214 | - // Load baseline settings from configuration |
|
215 | - $prefs = boincwork_get_preset_prefs($preset); |
|
216 | - |
|
217 | - // Processing preferences |
|
218 | - $prefs['run_on_batteries'] = ($values['processor']['run_on_batteries']) ? 0 : 1; |
|
219 | - $prefs['run_if_user_active'] = ($values['processor']['run_if_user_active']) ? 0 : 1; |
|
220 | - $prefs['run_gpu_if_user_active'] = ($values['processor']['run_gpu_if_user_active']) ? 0: 1; |
|
221 | - $prefs['idle_time_to_run'] = $values['processor']['idle_time_to_run']; |
|
222 | - $prefs['suspend_if_no_recent_input'] = $values['processor']['suspend_if_no_recent_input']; |
|
223 | - $prefs['suspend_cpu_usage'] = $values['processor']['suspend_cpu_usage']; |
|
224 | - $prefs['start_hour'] = $values['processor']['start_hour']; |
|
225 | - $prefs['end_hour'] = $values['processor']['end_hour']; |
|
226 | - $prefs['leave_apps_in_memory'] = ($values['processor']['leave_apps_in_memory']) ? 1 : 0; |
|
227 | - $prefs['cpu_scheduling_period_minutes'] = $values['processor']['cpu_scheduling_period_minutes']; |
|
228 | - $prefs['max_ncpus_pct'] = $values['processor']['max_ncpus_pct']; |
|
229 | - $prefs['cpu_usage_limit'] = $values['processor']['cpu_usage_limit']; |
|
230 | - |
|
231 | - // Storage preferences |
|
232 | - $prefs['disk_max_used_gb'] = $values['storage']['disk_max_used_gb']; |
|
233 | - $prefs['disk_min_free_gb'] = $values['storage']['disk_min_free_gb']; |
|
234 | - $prefs['disk_max_used_pct'] = $values['storage']['disk_max_used_pct']; |
|
235 | - $prefs['disk_interval'] = $values['storage']['disk_interval']; |
|
236 | - $prefs['vm_max_used_pct'] = $values['storage']['vm_max_used_pct']; |
|
237 | - $prefs['ram_max_used_busy_pct'] = $values['storage']['ram_max_used_busy_pct']; |
|
238 | - $prefs['ram_max_used_idle_pct'] = $values['storage']['ram_max_used_idle_pct']; |
|
239 | - |
|
240 | - // Network preferences |
|
241 | - $prefs['work_buf_min_days'] = $values['network']['work_buf_min_days']; |
|
242 | - $prefs['work_buf_additional_days'] = $values['network']['work_buf_additional_days']; |
|
243 | - $prefs['confirm_before_connecting'] = ($values['network']['confirm_before_connecting']) ? 1 : 0; |
|
244 | - $prefs['hangup_if_dialed'] = ($values['network']['hangup_if_dialed']) ? 1 : 0; |
|
245 | - $prefs['max_bytes_sec_down'] = $values['network']['max_bytes_sec_down']*1000; |
|
246 | - $prefs['max_bytes_sec_up'] = $values['network']['max_bytes_sec_up']*1000; |
|
247 | - $prefs['net_start_hour'] = $values['network']['net_start_hour']; |
|
248 | - $prefs['net_end_hour'] = $values['network']['net_end_hour']; |
|
249 | - $prefs['daily_xfer_limit_mb'] = $values['network']['daily_xfer_limit_mb']; |
|
250 | - $prefs['daily_xfer_period_days'] = $values['network']['daily_xfer_period_days']; |
|
251 | - $prefs['dont_verify_images'] = ($values['network']['dont_verify_images']) ? 1 : 0; |
|
252 | - |
|
253 | - //Remove @attributes to match new format (see boincwork.forms.inc |
|
254 | - //function boincwork_generalprefs_form) |
|
255 | - unset($prefs['@attributes']['preset']); |
|
256 | - |
|
257 | - // Update the configuration |
|
258 | - boincwork_save_preset_prefs($prefs, $preset); |
|
259 | - drupal_set_message(t('The "@name" preset has been updated.', |
|
211 | + $values = $form_state['values']; |
|
212 | + $preset = $form_state['values']['preset']; |
|
213 | + |
|
214 | + // Load baseline settings from configuration |
|
215 | + $prefs = boincwork_get_preset_prefs($preset); |
|
216 | + |
|
217 | + // Processing preferences |
|
218 | + $prefs['run_on_batteries'] = ($values['processor']['run_on_batteries']) ? 0 : 1; |
|
219 | + $prefs['run_if_user_active'] = ($values['processor']['run_if_user_active']) ? 0 : 1; |
|
220 | + $prefs['run_gpu_if_user_active'] = ($values['processor']['run_gpu_if_user_active']) ? 0: 1; |
|
221 | + $prefs['idle_time_to_run'] = $values['processor']['idle_time_to_run']; |
|
222 | + $prefs['suspend_if_no_recent_input'] = $values['processor']['suspend_if_no_recent_input']; |
|
223 | + $prefs['suspend_cpu_usage'] = $values['processor']['suspend_cpu_usage']; |
|
224 | + $prefs['start_hour'] = $values['processor']['start_hour']; |
|
225 | + $prefs['end_hour'] = $values['processor']['end_hour']; |
|
226 | + $prefs['leave_apps_in_memory'] = ($values['processor']['leave_apps_in_memory']) ? 1 : 0; |
|
227 | + $prefs['cpu_scheduling_period_minutes'] = $values['processor']['cpu_scheduling_period_minutes']; |
|
228 | + $prefs['max_ncpus_pct'] = $values['processor']['max_ncpus_pct']; |
|
229 | + $prefs['cpu_usage_limit'] = $values['processor']['cpu_usage_limit']; |
|
230 | + |
|
231 | + // Storage preferences |
|
232 | + $prefs['disk_max_used_gb'] = $values['storage']['disk_max_used_gb']; |
|
233 | + $prefs['disk_min_free_gb'] = $values['storage']['disk_min_free_gb']; |
|
234 | + $prefs['disk_max_used_pct'] = $values['storage']['disk_max_used_pct']; |
|
235 | + $prefs['disk_interval'] = $values['storage']['disk_interval']; |
|
236 | + $prefs['vm_max_used_pct'] = $values['storage']['vm_max_used_pct']; |
|
237 | + $prefs['ram_max_used_busy_pct'] = $values['storage']['ram_max_used_busy_pct']; |
|
238 | + $prefs['ram_max_used_idle_pct'] = $values['storage']['ram_max_used_idle_pct']; |
|
239 | + |
|
240 | + // Network preferences |
|
241 | + $prefs['work_buf_min_days'] = $values['network']['work_buf_min_days']; |
|
242 | + $prefs['work_buf_additional_days'] = $values['network']['work_buf_additional_days']; |
|
243 | + $prefs['confirm_before_connecting'] = ($values['network']['confirm_before_connecting']) ? 1 : 0; |
|
244 | + $prefs['hangup_if_dialed'] = ($values['network']['hangup_if_dialed']) ? 1 : 0; |
|
245 | + $prefs['max_bytes_sec_down'] = $values['network']['max_bytes_sec_down']*1000; |
|
246 | + $prefs['max_bytes_sec_up'] = $values['network']['max_bytes_sec_up']*1000; |
|
247 | + $prefs['net_start_hour'] = $values['network']['net_start_hour']; |
|
248 | + $prefs['net_end_hour'] = $values['network']['net_end_hour']; |
|
249 | + $prefs['daily_xfer_limit_mb'] = $values['network']['daily_xfer_limit_mb']; |
|
250 | + $prefs['daily_xfer_period_days'] = $values['network']['daily_xfer_period_days']; |
|
251 | + $prefs['dont_verify_images'] = ($values['network']['dont_verify_images']) ? 1 : 0; |
|
252 | + |
|
253 | + //Remove @attributes to match new format (see boincwork.forms.inc |
|
254 | + //function boincwork_generalprefs_form) |
|
255 | + unset($prefs['@attributes']['preset']); |
|
256 | + |
|
257 | + // Update the configuration |
|
258 | + boincwork_save_preset_prefs($prefs, $preset); |
|
259 | + drupal_set_message(t('The "@name" preset has been updated.', |
|
260 | 260 | array('@name' => $preset))); |
261 | 261 | } |
262 | 262 | |
@@ -265,26 +265,26 @@ discard block |
||
265 | 265 | */ |
266 | 266 | function boincwork_save_preset_prefs($updated_prefs, $preset = 'standard') { |
267 | 267 | |
268 | - // Get the full configuration |
|
269 | - $all_presets = boincwork_get_preset_prefs(); |
|
270 | - $all_presets = (array) $all_presets['general_preferences']; |
|
268 | + // Get the full configuration |
|
269 | + $all_presets = boincwork_get_preset_prefs(); |
|
270 | + $all_presets = (array) $all_presets['general_preferences']; |
|
271 | 271 | |
272 | - // Check for sane config |
|
273 | - if (isset($all_presets['preset'])) { |
|
272 | + // Check for sane config |
|
273 | + if (isset($all_presets['preset'])) { |
|
274 | 274 | if (!is_numeric(key($all_presets['preset']))) { |
275 | - $all_presets['preset'] = array($all_presets['preset']); |
|
275 | + $all_presets['preset'] = array($all_presets['preset']); |
|
276 | 276 | } |
277 | 277 | foreach ($all_presets['preset'] as $key => $old_preset) { |
278 | - // Find the preset being updated and... update it |
|
279 | - if (isset($old_preset['@attributes']['name']) AND $old_preset['@attributes']['name'] == $preset) { |
|
278 | + // Find the preset being updated and... update it |
|
279 | + if (isset($old_preset['@attributes']['name']) AND $old_preset['@attributes']['name'] == $preset) { |
|
280 | 280 | $all_presets['preset'][$key] = $updated_prefs + $old_preset; |
281 | - } |
|
281 | + } |
|
282 | + } |
|
282 | 283 | } |
283 | - } |
|
284 | 284 | |
285 | - // Convert prefs back to XML and save to database |
|
286 | - $all_presets = array('general_preferences' => $all_presets); |
|
287 | - variable_set('boincwork_preset_prefs', save_configuration($all_presets)); |
|
285 | + // Convert prefs back to XML and save to database |
|
286 | + $all_presets = array('general_preferences' => $all_presets); |
|
287 | + variable_set('boincwork_preset_prefs', save_configuration($all_presets)); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -7,15 +7,15 @@ |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | class views_handler_argument_boincuser_id extends views_handler_argument_numeric { |
10 | - function construct() { |
|
10 | + function construct() { |
|
11 | 11 | parent::construct(); |
12 | - } |
|
12 | + } |
|
13 | 13 | |
14 | - function set_argument($arg) { |
|
14 | + function set_argument($arg) { |
|
15 | 15 | // When setting the ID argument, convert to BOINC ID |
16 | 16 | $id = is_numeric($arg) ? $arg : 0; |
17 | 17 | $boinc_id = db_result(db_query("SELECT boinc_id FROM {boincuser} WHERE uid = %d", $id)); |
18 | 18 | $this->argument = $boinc_id; |
19 | 19 | return $this->validate_arg($boinc_id); |
20 | - } |
|
20 | + } |
|
21 | 21 | } |
@@ -6,15 +6,15 @@ |
||
6 | 6 | */ |
7 | 7 | |
8 | 8 | class views_handler_field_boincwork_host_app_et_avg extends views_handler_field { |
9 | - function construct() { |
|
9 | + function construct() { |
|
10 | 10 | parent::construct(); |
11 | - } |
|
11 | + } |
|
12 | 12 | |
13 | - function render($values) { |
|
13 | + function render($values) { |
|
14 | 14 | $gflops = 0; |
15 | 15 | if ($values->host_app_version_et_avg) { |
16 | - $gflops = 1e-9 / $values->host_app_version_et_avg; |
|
16 | + $gflops = 1e-9 / $values->host_app_version_et_avg; |
|
17 | 17 | } |
18 | 18 | return round($gflops, 2) . ' GFLOPS'; |
19 | - } |
|
19 | + } |
|
20 | 20 | } |
@@ -13,8 +13,8 @@ |
||
13 | 13 | function render($values) { |
14 | 14 | $gflops = 0; |
15 | 15 | if ($values->host_app_version_et_avg) { |
16 | - $gflops = 1e-9 / $values->host_app_version_et_avg; |
|
16 | + $gflops = 1e-9/$values->host_app_version_et_avg; |
|
17 | 17 | } |
18 | - return round($gflops, 2) . ' GFLOPS'; |
|
18 | + return round($gflops, 2).' GFLOPS'; |
|
19 | 19 | } |
20 | 20 | } |
@@ -6,12 +6,12 @@ |
||
6 | 6 | */ |
7 | 7 | |
8 | 8 | class views_handler_field_boincwork_host_app_turnaround_avg extends views_handler_field { |
9 | - function construct() { |
|
9 | + function construct() { |
|
10 | 10 | parent::construct(); |
11 | - } |
|
11 | + } |
|
12 | 12 | |
13 | - function render($values) { |
|
13 | + function render($values) { |
|
14 | 14 | $time_in_days = $values->host_app_version_turnaround_avg / (24*60*60); |
15 | 15 | return round($time_in_days, 2) . ' ' . t('days'); |
16 | - } |
|
16 | + } |
|
17 | 17 | } |
@@ -11,7 +11,7 @@ |
||
11 | 11 | } |
12 | 12 | |
13 | 13 | function render($values) { |
14 | - $time_in_days = $values->host_app_version_turnaround_avg / (24*60*60); |
|
15 | - return round($time_in_days, 2) . ' ' . t('days'); |
|
14 | + $time_in_days = $values->host_app_version_turnaround_avg/(24*60*60); |
|
15 | + return round($time_in_days, 2).' '.t('days'); |
|
16 | 16 | } |
17 | 17 | } |
@@ -6,11 +6,11 @@ |
||
6 | 6 | */ |
7 | 7 | |
8 | 8 | class views_handler_field_boincwork_app_version_number extends views_handler_field { |
9 | - function construct() { |
|
9 | + function construct() { |
|
10 | 10 | parent::construct(); |
11 | - } |
|
11 | + } |
|
12 | 12 | |
13 | - function render($values) { |
|
13 | + function render($values) { |
|
14 | 14 | return sprintf("%01.2f", $values->app_version_host_app_version_version_num / 100); |
15 | - } |
|
15 | + } |
|
16 | 16 | } |
@@ -11,6 +11,6 @@ |
||
11 | 11 | } |
12 | 12 | |
13 | 13 | function render($values) { |
14 | - return sprintf("%01.2f", $values->app_version_host_app_version_version_num / 100); |
|
14 | + return sprintf("%01.2f", $values->app_version_host_app_version_version_num/100); |
|
15 | 15 | } |
16 | 16 | } |