@@ -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 | } |
@@ -280,12 +280,12 @@ discard block |
||
280 | 280 | } |
281 | 281 | |
282 | 282 | switch ($op) { |
283 | - case 'delete': |
|
284 | - // Only call delete function on certain node types |
|
285 | - if (in_array( $node->type, $node_types)) { |
|
286 | - boinc_solr_comments_delete($node); |
|
287 | - } |
|
288 | - break; |
|
283 | + case 'delete': |
|
284 | + // Only call delete function on certain node types |
|
285 | + if (in_array( $node->type, $node_types)) { |
|
286 | + boinc_solr_comments_delete($node); |
|
287 | + } |
|
288 | + break; |
|
289 | 289 | } //switch |
290 | 290 | } |
291 | 291 | |
@@ -335,13 +335,13 @@ discard block |
||
335 | 335 | */ |
336 | 336 | function boinc_solr_comments_comment(&$a1, $op) { |
337 | 337 | switch ($op) { |
338 | - case 'view': |
|
339 | - case 'update': |
|
340 | - break; |
|
341 | - case 'delete': |
|
342 | - // $a1 should be a comment object |
|
343 | - boinc_solr_comments_deletecomment($a1); |
|
344 | - break; |
|
338 | + case 'view': |
|
339 | + case 'update': |
|
340 | + break; |
|
341 | + case 'delete': |
|
342 | + // $a1 should be a comment object |
|
343 | + boinc_solr_comments_deletecomment($a1); |
|
344 | + break; |
|
345 | 345 | }// switch |
346 | 346 | } |
347 | 347 |
@@ -14,19 +14,19 @@ discard block |
||
14 | 14 | * Implementation of hook_menu() |
15 | 15 | */ |
16 | 16 | function boinc_solr_comments_menu() { |
17 | - $items = array(); |
|
18 | - $base_path = 'admin/settings/apachesolr/indexcomments'; |
|
19 | - $items[$base_path] = array( |
|
20 | - 'title' => 'Index Comments', |
|
21 | - 'description' => 'Administer Indexing of Comments', |
|
22 | - 'page callback' => 'drupal_get_form', |
|
23 | - 'page arguments' => array('boinc_solr_comments_form'), |
|
24 | - 'access arguments' => array('administer search'), |
|
25 | - 'file' => 'boinc_solr_comments.admin.inc', |
|
26 | - 'weight' => '10', |
|
27 | - ); |
|
28 | - |
|
29 | - return $items; |
|
17 | + $items = array(); |
|
18 | + $base_path = 'admin/settings/apachesolr/indexcomments'; |
|
19 | + $items[$base_path] = array( |
|
20 | + 'title' => 'Index Comments', |
|
21 | + 'description' => 'Administer Indexing of Comments', |
|
22 | + 'page callback' => 'drupal_get_form', |
|
23 | + 'page arguments' => array('boinc_solr_comments_form'), |
|
24 | + 'access arguments' => array('administer search'), |
|
25 | + 'file' => 'boinc_solr_comments.admin.inc', |
|
26 | + 'weight' => '10', |
|
27 | + ); |
|
28 | + |
|
29 | + return $items; |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | |
@@ -58,11 +58,11 @@ discard block |
||
58 | 58 | * Environment ID for apache solr. |
59 | 59 | */ |
60 | 60 | function boinc_solr_comments_apachesolr_index_documents_alter(array &$documents, $entity, $entity_type, $env_id) { |
61 | - $comdocs = array(); |
|
61 | + $comdocs = array(); |
|
62 | 62 | |
63 | - // Array of node types that will have comments indexed. |
|
64 | - $node_types = variable_get('boinc_solr_comments_nodetypes', ''); |
|
65 | - if (empty($node_types)) { |
|
63 | + // Array of node types that will have comments indexed. |
|
64 | + $node_types = variable_get('boinc_solr_comments_nodetypes', ''); |
|
65 | + if (empty($node_types)) { |
|
66 | 66 | // If the variable has not been set, then by default index |
67 | 67 | // comments for all known node types. |
68 | 68 | $node_types = array( |
@@ -72,28 +72,28 @@ discard block |
||
72 | 72 | 'story' => 'story', |
73 | 73 | 'team_forum' => 'team_forum', |
74 | 74 | ); |
75 | - } |
|
75 | + } |
|
76 | 76 | |
77 | - // Loop over all documents and alter: |
|
78 | - foreach ($documents as $document) { |
|
77 | + // Loop over all documents and alter: |
|
78 | + foreach ($documents as $document) { |
|
79 | 79 | //dd($document, "index documents alter - document"); |
80 | 80 | |
81 | 81 | $to_process = ( array_key_exists($document->bundle, $node_types) AND $node_types[$document->bundle] ); |
82 | 82 | if ( $document->entity_type=='node' AND $to_process) { |
83 | 83 | |
84 | - // Remove ts_comments if present. |
|
85 | - if (isset($document->ts_comments)) { |
|
84 | + // Remove ts_comments if present. |
|
85 | + if (isset($document->ts_comments)) { |
|
86 | 86 | unset($document->ts_comments); |
87 | - } |
|
88 | - // Node information. |
|
89 | - $nid = $document->entity_id; |
|
90 | - $node = node_load($nid); |
|
87 | + } |
|
88 | + // Node information. |
|
89 | + $nid = $document->entity_id; |
|
90 | + $node = node_load($nid); |
|
91 | 91 | |
92 | - // Query database for comments of node. Only return comments |
|
93 | - // with status 0 (0 is published for comments). |
|
94 | - $sql = 'SELECT cid from {comments} WHERE nid = %d AND status = 0 ORDER by timestamp DESC'; |
|
95 | - $resource = db_query($sql, $nid); |
|
96 | - while ($row = db_fetch_array($resource)) { |
|
92 | + // Query database for comments of node. Only return comments |
|
93 | + // with status 0 (0 is published for comments). |
|
94 | + $sql = 'SELECT cid from {comments} WHERE nid = %d AND status = 0 ORDER by timestamp DESC'; |
|
95 | + $resource = db_query($sql, $nid); |
|
96 | + while ($row = db_fetch_array($resource)) { |
|
97 | 97 | // Load the comment from cid. |
98 | 98 | $comment = _comment_load($row['cid']); |
99 | 99 | |
@@ -116,10 +116,10 @@ discard block |
||
116 | 116 | // Comment object has no language |
117 | 117 | $comment_document->ss_language = 'und'; |
118 | 118 | if (function_exists('drupal_get_path_alias')) { |
119 | - $output = drupal_get_path_alias($comment_document->path, NULL); |
|
120 | - if ($output && $output != $document->path) { |
|
119 | + $output = drupal_get_path_alias($comment_document->path, NULL); |
|
120 | + if ($output && $output != $document->path) { |
|
121 | 121 | $comment_document->path_alias = $output; |
122 | - } |
|
122 | + } |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | // Code derived from apachesolr_index_node_solr_document |
@@ -129,13 +129,13 @@ discard block |
||
129 | 129 | |
130 | 130 | // Author information |
131 | 131 | if ($comment->uid == 0 || strlen($comment->name) == 0) { |
132 | - // @see user_validate_name(). !'0' === TRUE. |
|
133 | - $comment_document->ss_name = '0'; |
|
132 | + // @see user_validate_name(). !'0' === TRUE. |
|
133 | + $comment_document->ss_name = '0'; |
|
134 | 134 | } |
135 | 135 | else { |
136 | - $comment_document->ss_name = $comment->name; |
|
137 | - // We want the name to be searchable for keywords. |
|
138 | - $comment_document->tos_name = $comment->name; |
|
136 | + $comment_document->ss_name = $comment->name; |
|
137 | + // We want the name to be searchable for keywords. |
|
138 | + $comment_document->tos_name = $comment->name; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | // Index formatted username so it can be searched and sorted |
@@ -157,59 +157,59 @@ discard block |
||
157 | 157 | // Unset the following fields (if set) that don't make sense |
158 | 158 | // for a comment. |
159 | 159 | if (isset($comment_document->bs_sticky)) { |
160 | - unset($comment_document->bs_sticky); |
|
160 | + unset($comment_document->bs_sticky); |
|
161 | 161 | } |
162 | 162 | if (isset($comment_document->bs_promote)) { |
163 | - unset($comment_document->bs_promote); |
|
163 | + unset($comment_document->bs_promote); |
|
164 | 164 | } |
165 | 165 | if (isset($comment_document->is_tnid)) { |
166 | - unset($comment_document->is_tnid); |
|
166 | + unset($comment_document->is_tnid); |
|
167 | 167 | } |
168 | 168 | if (isset($comment_document->bs_translate)) { |
169 | - unset($comment_document->bs_translate); |
|
169 | + unset($comment_document->bs_translate); |
|
170 | 170 | } |
171 | 171 | if (isset($comment_document->ts_last_comment_timestamp)) { |
172 | - unset($comment_document->ts_last_comment_timestamp); |
|
172 | + unset($comment_document->ts_last_comment_timestamp); |
|
173 | 173 | } |
174 | 174 | if (isset($comment_document->ds_last_comment_or_change)) { |
175 | - unset($comment_document->ds_last_comment_or_change); |
|
175 | + unset($comment_document->ds_last_comment_or_change); |
|
176 | 176 | } |
177 | 177 | if (isset($comment_document->is_comment_count)) { |
178 | - unset($comment_document->is_comment_count); |
|
178 | + unset($comment_document->is_comment_count); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | // Loop over fields in document and copy relevant values into |
182 | 182 | // comment_document. |
183 | 183 | foreach ($document as $fieldName => $fieldValue) { |
184 | 184 | |
185 | - // Copy over fields [im_taxonomy_vid_1], [tid], [im_vid_1], |
|
186 | - // [im_vid_Forums], [tm_vid_1_names] |
|
187 | - if ( ( preg_match('/tid/', $fieldName) OR preg_match('/vid/', $fieldName) ) AND is_array($fieldValue) ) { |
|
185 | + // Copy over fields [im_taxonomy_vid_1], [tid], [im_vid_1], |
|
186 | + // [im_vid_Forums], [tm_vid_1_names] |
|
187 | + if ( ( preg_match('/tid/', $fieldName) OR preg_match('/vid/', $fieldName) ) AND is_array($fieldValue) ) { |
|
188 | 188 | foreach ($fieldValue as $subkey => $subvalue) { |
189 | - $comment_document->addField($fieldName, $subvalue); |
|
189 | + $comment_document->addField($fieldName, $subvalue); |
|
190 | 190 | } |
191 | - }// if preg_match |
|
191 | + }// if preg_match |
|
192 | 192 | |
193 | - // Set the access keys so this module will work with |
|
194 | - // apachesolr_access. |
|
195 | - if (module_exists('apachesolr_access')) { |
|
193 | + // Set the access keys so this module will work with |
|
194 | + // apachesolr_access. |
|
195 | + if (module_exists('apachesolr_access')) { |
|
196 | 196 | if (preg_match('/^access/', $fieldName) AND is_array($fieldValue)) { |
197 | - foreach ($fieldValue as $subkey => $subvalue) { |
|
197 | + foreach ($fieldValue as $subkey => $subvalue) { |
|
198 | 198 | $comment_document->addField($fieldName, $subvalue); |
199 | - } |
|
199 | + } |
|
200 | 200 | }// if preg_match |
201 | - }// if module_exist |
|
201 | + }// if module_exist |
|
202 | 202 | |
203 | 203 | }// foreach document |
204 | 204 | |
205 | 205 | $comdocs[] = $comment_document; |
206 | - }// while |
|
206 | + }// while |
|
207 | 207 | }// if entity_type=node |
208 | - }// documents |
|
208 | + }// documents |
|
209 | 209 | |
210 | - // Merge the comment documents with the input documents array. These |
|
211 | - // documents will now be added to the Solr search index. |
|
212 | - $documents = array_merge($documents, $comdocs); |
|
210 | + // Merge the comment documents with the input documents array. These |
|
211 | + // documents will now be added to the Solr search index. |
|
212 | + $documents = array_merge($documents, $comdocs); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -225,19 +225,19 @@ discard block |
||
225 | 225 | * The Solr query used for the search. |
226 | 226 | */ |
227 | 227 | function boinc_solr_comments_apachesolr_process_results(&$results, DrupalSolrQueryInterface $query) { |
228 | - //dpm($query->getSolrParams(), "process_results query getSolrParams"); |
|
229 | - foreach($results as $id => $result) { |
|
228 | + //dpm($query->getSolrParams(), "process_results query getSolrParams"); |
|
229 | + foreach($results as $id => $result) { |
|
230 | 230 | if ($result['entity_type']=='comment') { |
231 | 231 | $results[$id]['type'] = 'Comment'; |
232 | 232 | $results[$id]['date'] = $result['fields']['changed']; |
233 | 233 | if (isset($result['fields']['is_uid'])) { |
234 | - $uid = $result['fields']['is_uid']; |
|
235 | - $results[$id]['uid'] = $uid; |
|
236 | - $results[$id]['user'] = theme('username', user_load($uid)); |
|
234 | + $uid = $result['fields']['is_uid']; |
|
235 | + $results[$id]['uid'] = $uid; |
|
236 | + $results[$id]['user'] = theme('username', user_load($uid)); |
|
237 | 237 | } |
238 | 238 | } //if result entity_type == comment |
239 | - }// foreach $result |
|
240 | - //dpm($results, "process_results array_results"); |
|
239 | + }// foreach $result |
|
240 | + //dpm($results, "process_results array_results"); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | /** |
@@ -251,8 +251,8 @@ discard block |
||
251 | 251 | * The Solr query used for the search. |
252 | 252 | */ |
253 | 253 | function boinc_solr_comments_apachesolr_query_alter($query) { |
254 | - // Add custom field to query results |
|
255 | - $query->addParam('fl','tos_content_extra'); |
|
254 | + // Add custom field to query results |
|
255 | + $query->addParam('fl','tos_content_extra'); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -265,9 +265,9 @@ discard block |
||
265 | 265 | * |
266 | 266 | */ |
267 | 267 | function boinc_solr_comments_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { |
268 | - // Array of node types that will have comments indexed. |
|
269 | - $node_types = variable_get('boinc_solr_comments_nodetypes', ''); |
|
270 | - if (empty($node_types)) { |
|
268 | + // Array of node types that will have comments indexed. |
|
269 | + $node_types = variable_get('boinc_solr_comments_nodetypes', ''); |
|
270 | + if (empty($node_types)) { |
|
271 | 271 | // If the variable has not been set, then by default index |
272 | 272 | // comments for all known node types. |
273 | 273 | $node_types = array( |
@@ -277,16 +277,16 @@ discard block |
||
277 | 277 | 'story' => 'story', |
278 | 278 | 'team_forum' => 'team_forum', |
279 | 279 | ); |
280 | - } |
|
280 | + } |
|
281 | 281 | |
282 | - switch ($op) { |
|
282 | + switch ($op) { |
|
283 | 283 | case 'delete': |
284 | 284 | // Only call delete function on certain node types |
285 | 285 | if (in_array( $node->type, $node_types)) { |
286 | 286 | boinc_solr_comments_delete($node); |
287 | - } |
|
288 | - break; |
|
289 | - } //switch |
|
287 | + } |
|
288 | + break; |
|
289 | + } //switch |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | |
@@ -303,30 +303,30 @@ discard block |
||
303 | 303 | * Returns TRUE if the comment was deleted, otherwise return FALSE. |
304 | 304 | */ |
305 | 305 | function boinc_solr_comments_delete($node) { |
306 | - // Load the Solr environment. |
|
307 | - $env_id = apachesolr_default_environment(); |
|
308 | - // Check to see if Solr is read-only. |
|
309 | - if (apachesolr_environment_variable_get($env_id, 'apachesolr_read_only', APACHESOLR_READ_WRITE) == APACHESOLR_READ_ONLY) { |
|
306 | + // Load the Solr environment. |
|
307 | + $env_id = apachesolr_default_environment(); |
|
308 | + // Check to see if Solr is read-only. |
|
309 | + if (apachesolr_environment_variable_get($env_id, 'apachesolr_read_only', APACHESOLR_READ_WRITE) == APACHESOLR_READ_ONLY) { |
|
310 | 310 | return FALSE; |
311 | - } |
|
311 | + } |
|
312 | 312 | |
313 | - // Code derived from apachesolr_index_delete_entity_from_index |
|
314 | - try { |
|
313 | + // Code derived from apachesolr_index_delete_entity_from_index |
|
314 | + try { |
|
315 | 315 | $solr = apachesolr_get_solr($env_id); |
316 | 316 | // Custom query to find all comments with parent nid of the node bing deleted. |
317 | 317 | $query = "entity_type:comment AND tos_content_extra:" . $node->nid; |
318 | 318 | $solr->deleteByQuery($query); |
319 | 319 | // Log the query used for deletion. |
320 | 320 | watchdog('Apache Solr', 'Deleted documents from index with query @query', array('@query' => $query), WATCHDOG_INFO); |
321 | - } |
|
322 | - catch (Exception $e) { |
|
323 | - watchdog('Apache Solr', nl2br(check_plain($e->getMessage())), NULL, WATCHDOG_ERROR); |
|
324 | - return FALSE; |
|
325 | - }// try |
|
326 | - |
|
327 | - // all deletions sucessful |
|
328 | - apachesolr_set_last_index_updated($env_id, APACHESOLR_REQUEST_TIME); |
|
329 | - return TRUE; |
|
321 | + } |
|
322 | + catch (Exception $e) { |
|
323 | + watchdog('Apache Solr', nl2br(check_plain($e->getMessage())), NULL, WATCHDOG_ERROR); |
|
324 | + return FALSE; |
|
325 | + }// try |
|
326 | + |
|
327 | + // all deletions sucessful |
|
328 | + apachesolr_set_last_index_updated($env_id, APACHESOLR_REQUEST_TIME); |
|
329 | + return TRUE; |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | /** |
@@ -334,15 +334,15 @@ discard block |
||
334 | 334 | * |
335 | 335 | */ |
336 | 336 | function boinc_solr_comments_comment(&$a1, $op) { |
337 | - switch ($op) { |
|
337 | + switch ($op) { |
|
338 | 338 | case 'view': |
339 | 339 | case 'update': |
340 | 340 | break; |
341 | 341 | case 'delete': |
342 | 342 | // $a1 should be a comment object |
343 | 343 | boinc_solr_comments_deletecomment($a1); |
344 | - break; |
|
345 | - }// switch |
|
344 | + break; |
|
345 | + }// switch |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | /** |
@@ -358,16 +358,16 @@ discard block |
||
358 | 358 | * Returns TRUE if the comment was deleted, otherwise return FALSE. |
359 | 359 | */ |
360 | 360 | function boinc_solr_comments_deletecomment($comment) { |
361 | - // Load the Solr environment. |
|
362 | - $env_id = apachesolr_default_environment(); |
|
363 | - // Check to see if Solr is read-only. |
|
364 | - if (apachesolr_environment_variable_get($env_id, 'apachesolr_read_only', APACHESOLR_READ_WRITE) == APACHESOLR_READ_ONLY) { |
|
361 | + // Load the Solr environment. |
|
362 | + $env_id = apachesolr_default_environment(); |
|
363 | + // Check to see if Solr is read-only. |
|
364 | + if (apachesolr_environment_variable_get($env_id, 'apachesolr_read_only', APACHESOLR_READ_WRITE) == APACHESOLR_READ_ONLY) { |
|
365 | 365 | return FALSE; |
366 | - } |
|
367 | - //dd($comment->cid, "delete - nid begin"); |
|
366 | + } |
|
367 | + //dd($comment->cid, "delete - nid begin"); |
|
368 | 368 | |
369 | - // Code derived from apachesolr_index_delete_entity_from_index. |
|
370 | - try { |
|
369 | + // Code derived from apachesolr_index_delete_entity_from_index. |
|
370 | + try { |
|
371 | 371 | $solr = apachesolr_get_solr($env_id); |
372 | 372 | $entity_id = $comment->cid; |
373 | 373 | $entity_type = 'comment'; |
@@ -377,14 +377,14 @@ discard block |
||
377 | 377 | // Log the query used for deletion. |
378 | 378 | watchdog('Apache Solr', 'Deleted documents from index with query @query', array('@query' => $query), WATCHDOG_INFO); |
379 | 379 | } |
380 | - catch (Exception $e) { |
|
380 | + catch (Exception $e) { |
|
381 | 381 | watchdog('Apache Solr', nl2br(check_plain($e->getMessage())), NULL, WATCHDOG_ERROR); |
382 | 382 | return FALSE; |
383 | - }// try |
|
383 | + }// try |
|
384 | 384 | |
385 | - // deletion sucessful |
|
386 | - apachesolr_set_last_index_updated($env_id, APACHESOLR_REQUEST_TIME); |
|
387 | - return TRUE; |
|
385 | + // deletion sucessful |
|
386 | + apachesolr_set_last_index_updated($env_id, APACHESOLR_REQUEST_TIME); |
|
387 | + return TRUE; |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | */ |
400 | 400 | |
401 | 401 | function boinc_solr_comments_enable() { |
402 | - drupal_set_message( bts('Warning: Your content <a href="@url">must be re-indexed</a> before Apache Solr will search comments.', array('@url' => url('admin/settings/apachesolr/index')), NULL, 'boinc:admin-solr-index-comments-message'), 'warning'); |
|
402 | + drupal_set_message( bts('Warning: Your content <a href="@url">must be re-indexed</a> before Apache Solr will search comments.', array('@url' => url('admin/settings/apachesolr/index')), NULL, 'boinc:admin-solr-index-comments-message'), 'warning'); |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | /** |
@@ -410,12 +410,12 @@ discard block |
||
410 | 410 | * The comment to be published (unhidden). |
411 | 411 | */ |
412 | 412 | function boinc_solr_comments_publish($comment) { |
413 | - if ( ($comment->cid) AND ($comment->nid) ) { |
|
413 | + if ( ($comment->cid) AND ($comment->nid) ) { |
|
414 | 414 | $node = node_load($comment->nid); |
415 | 415 | // Tell Solr that the node has been updated, so the comment can be |
416 | 416 | // indexed. |
417 | 417 | apachesolr_entity_update($node, 'node'); |
418 | - } |
|
418 | + } |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | /** |
@@ -426,9 +426,9 @@ discard block |
||
426 | 426 | * The comment to be unpublished (hidden). |
427 | 427 | */ |
428 | 428 | function boinc_solr_comments_unpublish($comment) { |
429 | - if ( ($comment->cid) ) { |
|
429 | + if ( ($comment->cid) ) { |
|
430 | 430 | // Call the deletecomment function for hook comment. |
431 | 431 | boinc_solr_comments_deletecomment($comment); |
432 | - } |
|
432 | + } |
|
433 | 433 | } |
434 | 434 |
@@ -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 | } |
@@ -13,80 +13,80 @@ |
||
13 | 13 | */ |
14 | 14 | function boincteam_forum_views_data() { |
15 | 15 | |
16 | - // ----------------------------------------------------------------------------------------------- |
|
17 | - // Definition for team table |
|
18 | - // ----------------------------------------------------------------------------------------------- |
|
16 | + // ----------------------------------------------------------------------------------------------- |
|
17 | + // Definition for team table |
|
18 | + // ----------------------------------------------------------------------------------------------- |
|
19 | 19 | |
20 | - $data['boincteam_forum_node']['table']['group'] = t('BOINC'); |
|
20 | + $data['boincteam_forum_node']['table']['group'] = t('BOINC'); |
|
21 | 21 | |
22 | - $data['boincteam_forum_node']['table']['base'] = array( |
|
23 | - 'field' => 'nid', |
|
24 | - 'title' => t('BOINC team forum topic'), |
|
25 | - 'help' => t('Forum topics for a team'), |
|
26 | - ); |
|
22 | + $data['boincteam_forum_node']['table']['base'] = array( |
|
23 | + 'field' => 'nid', |
|
24 | + 'title' => t('BOINC team forum topic'), |
|
25 | + 'help' => t('Forum topics for a team'), |
|
26 | + ); |
|
27 | 27 | |
28 | - // Describe each of the individual fields in this table to Views. For |
|
29 | - // each field, you may define what field, sort, argument, and/or filter |
|
30 | - // handlers it supports. This will determine where in the Views interface you |
|
31 | - // may use the field. |
|
28 | + // Describe each of the individual fields in this table to Views. For |
|
29 | + // each field, you may define what field, sort, argument, and/or filter |
|
30 | + // handlers it supports. This will determine where in the Views interface you |
|
31 | + // may use the field. |
|
32 | 32 | |
33 | - // Primary keys allowed as arguments |
|
33 | + // Primary keys allowed as arguments |
|
34 | 34 | |
35 | - $data['boincteam_forum_node']['tfid'] = array( |
|
35 | + $data['boincteam_forum_node']['tfid'] = array( |
|
36 | 36 | 'title' => t('Team forum ID'), |
37 | 37 | 'help' => t('The ID of the team forum containing this topic.'), |
38 | 38 | 'field' => array( |
39 | - 'handler' => 'views_handler_field_numeric', |
|
40 | - 'click sortable' => TRUE |
|
39 | + 'handler' => 'views_handler_field_numeric', |
|
40 | + 'click sortable' => TRUE |
|
41 | 41 | ), |
42 | 42 | 'argument' => array( |
43 | - 'handler' => 'views_handler_argument_numeric', |
|
44 | - 'name field' => 'title', // the field to display in the summary. |
|
45 | - 'numeric' => TRUE, |
|
46 | - 'validate type' => 'id' |
|
43 | + 'handler' => 'views_handler_argument_numeric', |
|
44 | + 'name field' => 'title', // the field to display in the summary. |
|
45 | + 'numeric' => TRUE, |
|
46 | + 'validate type' => 'id' |
|
47 | 47 | ), |
48 | 48 | 'relationship' => array( |
49 | - 'base' => 'boincteam_forum', |
|
50 | - 'field' => 'tfid', |
|
51 | - 'handler' => 'views_handler_relationship', |
|
52 | - 'label' => t('Team Forum') |
|
49 | + 'base' => 'boincteam_forum', |
|
50 | + 'field' => 'tfid', |
|
51 | + 'handler' => 'views_handler_relationship', |
|
52 | + 'label' => t('Team Forum') |
|
53 | 53 | ), |
54 | 54 | 'filter' => array( |
55 | - 'handler' => 'views_handler_filter_numeric' |
|
55 | + 'handler' => 'views_handler_filter_numeric' |
|
56 | 56 | ), |
57 | 57 | 'sort' => array( |
58 | - 'handler' => 'views_handler_sort_numeric' |
|
58 | + 'handler' => 'views_handler_sort_numeric' |
|
59 | 59 | ) |
60 | - ); |
|
60 | + ); |
|
61 | 61 | |
62 | - // Foreign key fields |
|
62 | + // Foreign key fields |
|
63 | 63 | |
64 | - $data['boincteam_forum_node']['nid'] = array( |
|
64 | + $data['boincteam_forum_node']['nid'] = array( |
|
65 | 65 | 'title' => t('Team forum node'), |
66 | 66 | 'help' => t('The node containing the content of this team forum topic.'), |
67 | 67 | // This is a foreign key to the {node} table. When the view is configured |
68 | 68 | // with this relationship, all the fields for the related user node will be |
69 | 69 | // available. |
70 | 70 | 'relationship' => array( |
71 | - 'base' => 'node', |
|
72 | - 'field' => 'nid', |
|
73 | - 'handler' => 'views_handler_relationship', |
|
74 | - 'label' => t('Team Forum Topic Node') |
|
71 | + 'base' => 'node', |
|
72 | + 'field' => 'nid', |
|
73 | + 'handler' => 'views_handler_relationship', |
|
74 | + 'label' => t('Team Forum Topic Node') |
|
75 | 75 | ), |
76 | 76 | 'field' => array( |
77 | - 'handler' => 'views_handler_field_numeric', |
|
78 | - 'click sortable' => TRUE |
|
77 | + 'handler' => 'views_handler_field_numeric', |
|
78 | + 'click sortable' => TRUE |
|
79 | 79 | ), |
80 | 80 | 'filter' => array( |
81 | - 'handler' => 'views_handler_filter_numeric' |
|
81 | + 'handler' => 'views_handler_filter_numeric' |
|
82 | 82 | ), |
83 | 83 | 'sort' => array( |
84 | - 'handler' => 'views_handler_sort_numeric' |
|
84 | + 'handler' => 'views_handler_sort_numeric' |
|
85 | 85 | ) |
86 | - ); |
|
86 | + ); |
|
87 | 87 | |
88 | - // Descriptions of general fields (alphabetized) |
|
89 | - // ... |
|
88 | + // Descriptions of general fields (alphabetized) |
|
89 | + // ... |
|
90 | 90 | |
91 | - return $data; |
|
91 | + return $data; |
|
92 | 92 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -180,12 +180,12 @@ |
||
180 | 180 | */ |
181 | 181 | function boincwork_locale($op = 'groups', $group = NULL) { |
182 | 182 | switch ($op) { |
183 | - case 'groups': |
|
184 | - return array('project' => bts('Project')); |
|
185 | - case 'info': |
|
186 | - $info['project']['refresh callback'] = 'boincwork_locale_refresh'; |
|
187 | - $info['project']['format'] = FALSE; |
|
188 | - return $info; |
|
183 | + case 'groups': |
|
184 | + return array('project' => bts('Project')); |
|
185 | + case 'info': |
|
186 | + $info['project']['refresh callback'] = 'boincwork_locale_refresh'; |
|
187 | + $info['project']['format'] = FALSE; |
|
188 | + return $info; |
|
189 | 189 | } |
190 | 190 | } |
191 | 191 |
@@ -2,9 +2,9 @@ discard block |
||
2 | 2 | // $Id$ |
3 | 3 | |
4 | 4 | /** |
5 | - * @file |
|
6 | - * Enable BOINC features related to processing work and credit. |
|
7 | - */ |
|
5 | + * @file |
|
6 | + * Enable BOINC features related to processing work and credit. |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | |
10 | 10 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -20,70 +20,70 @@ discard block |
||
20 | 20 | * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
21 | 21 | |
22 | 22 | /** |
23 | - * Implementation of hook_menu(). |
|
24 | - */ |
|
23 | + * Implementation of hook_menu(). |
|
24 | + */ |
|
25 | 25 | function boincwork_menu() { |
26 | - require_boinc('util'); |
|
27 | - $items['account/prefs'] = array( |
|
26 | + require_boinc('util'); |
|
27 | + $items['account/prefs'] = array( |
|
28 | 28 | 'title' => 'Computing', |
29 | 29 | 'description' => '', |
30 | 30 | 'page callback' => 'generalprefs_page', |
31 | 31 | 'access callback' => 'user_is_logged_in', |
32 | 32 | 'type' => MENU_NORMAL_ITEM |
33 | - ); |
|
34 | - $items['account/prefs/computing'] = array( |
|
33 | + ); |
|
34 | + $items['account/prefs/computing'] = array( |
|
35 | 35 | 'title' => 'Computing', |
36 | 36 | 'page callback' => 'generalprefs_page', |
37 | 37 | 'access callback' => 'user_is_logged_in', |
38 | 38 | 'type' => MENU_DEFAULT_LOCAL_TASK, |
39 | 39 | 'weight' => 0 |
40 | - ); |
|
41 | - $items['account/prefs/project'] = array( |
|
40 | + ); |
|
41 | + $items['account/prefs/project'] = array( |
|
42 | 42 | 'title' => 'Project', |
43 | 43 | 'page callback' => 'projectprefs_page', |
44 | 44 | 'access callback' => 'user_is_logged_in', |
45 | 45 | 'type' => MENU_LOCAL_TASK, |
46 | 46 | 'weight' => 5 |
47 | - ); |
|
48 | - $items['account/prefs/community'] = array( |
|
47 | + ); |
|
48 | + $items['account/prefs/community'] = array( |
|
49 | 49 | 'title' => 'Community', |
50 | 50 | 'page callback' => 'communityprefs_page', |
51 | 51 | 'access callback' => 'user_is_logged_in', |
52 | 52 | 'type' => MENU_LOCAL_TASK, |
53 | 53 | 'weight' => 10 |
54 | - ); |
|
55 | - $items['account/prefs/privacy'] = array( |
|
54 | + ); |
|
55 | + $items['account/prefs/privacy'] = array( |
|
56 | 56 | 'title' => 'Privacy', |
57 | 57 | 'page callback' => 'privacyprefs_page', |
58 | 58 | 'access callback' => 'user_is_logged_in', |
59 | 59 | 'type' => MENU_LOCAL_TASK, |
60 | 60 | 'weight' => 15 |
61 | - ); |
|
62 | - if (module_exists('ignore_user')) { |
|
61 | + ); |
|
62 | + if (module_exists('ignore_user')) { |
|
63 | 63 | $items['account/prefs/privacy/ignore_user/add'] = array( |
64 | - 'title' => 'Add from ignore list', |
|
65 | - 'description' => 'Add user that you with to ignore to your ignore list.', |
|
66 | - 'page callback' => 'boincwork_ignore_user_add_user', |
|
67 | - 'access callback' => 'user_access', |
|
68 | - 'access arguments' => array('ignore user'), |
|
69 | - 'type' => MENU_CALLBACK, |
|
64 | + 'title' => 'Add from ignore list', |
|
65 | + 'description' => 'Add user that you with to ignore to your ignore list.', |
|
66 | + 'page callback' => 'boincwork_ignore_user_add_user', |
|
67 | + 'access callback' => 'user_access', |
|
68 | + 'access arguments' => array('ignore user'), |
|
69 | + 'type' => MENU_CALLBACK, |
|
70 | 70 | ); |
71 | 71 | $items['account/prefs/privacy/ignore_user/remove'] = array( |
72 | - 'title' => 'Remove from ignore list', |
|
73 | - 'description' => 'Remove user from your ignore list.', |
|
74 | - 'page callback' => 'boincwork_ignore_user_remove_user', |
|
75 | - 'access callback' => 'user_access', |
|
76 | - 'access arguments' => array('ignore user'), |
|
77 | - 'type' => MENU_CALLBACK, |
|
72 | + 'title' => 'Remove from ignore list', |
|
73 | + 'description' => 'Remove user from your ignore list.', |
|
74 | + 'page callback' => 'boincwork_ignore_user_remove_user', |
|
75 | + 'access callback' => 'user_access', |
|
76 | + 'access arguments' => array('ignore user'), |
|
77 | + 'type' => MENU_CALLBACK, |
|
78 | 78 | ); |
79 | - }// endif module_exists |
|
80 | - $items['account/certs'] = array( |
|
79 | + }// endif module_exists |
|
80 | + $items['account/certs'] = array( |
|
81 | 81 | 'title' =>'Account certificate', |
82 | 82 | 'page callback' => 'boincwork_certificates', |
83 | 83 | 'access arguments' => array('access content'), |
84 | 84 | 'type' => MENU_CALLBACK |
85 | - ); |
|
86 | - $items['admin/boinc/prefs/general'] = array( |
|
85 | + ); |
|
86 | + $items['admin/boinc/prefs/general'] = array( |
|
87 | 87 | 'title' => 'Preferences: General', |
88 | 88 | 'description' => 'Set options for BOINC preference set pages', |
89 | 89 | 'page callback' => 'drupal_get_form', |
@@ -91,16 +91,16 @@ discard block |
||
91 | 91 | 'access arguments' => array('administer site configuration'), |
92 | 92 | 'type' => MENU_NORMAL_ITEM, |
93 | 93 | 'file' => 'boincwork.admin.inc' |
94 | - ); |
|
95 | - $items['admin/boinc/prefs/presets'] = array( |
|
94 | + ); |
|
95 | + $items['admin/boinc/prefs/presets'] = array( |
|
96 | 96 | 'title' => 'Preferences: Presets', |
97 | 97 | 'description' => 'Set values for BOINC preference set presets.', |
98 | 98 | 'page callback' => 'boincwork_admin_prefs_presets_page', |
99 | 99 | 'access arguments' => array('administer site configuration'), |
100 | 100 | 'type' => MENU_NORMAL_ITEM, |
101 | 101 | 'file' => 'boincwork.admin.inc' |
102 | - ); |
|
103 | - $items['admin/boinc/prefs/upload'] = array( |
|
102 | + ); |
|
103 | + $items['admin/boinc/prefs/upload'] = array( |
|
104 | 104 | 'title' => 'Preferences: Project-specific XML upload', |
105 | 105 | 'description' => 'Upload XML configuration for project specific preferences.', |
106 | 106 | 'page callback' => 'drupal_get_form', |
@@ -108,153 +108,153 @@ discard block |
||
108 | 108 | 'access arguments' => array('administer site configuration'), |
109 | 109 | 'type' => MENU_NORMAL_ITEM, |
110 | 110 | 'file' => 'boincwork.admin.inc' |
111 | - ); |
|
112 | - $items['host/%/delete'] = array( |
|
111 | + ); |
|
112 | + $items['host/%/delete'] = array( |
|
113 | 113 | 'title' => 'Delete host', |
114 | 114 | 'page callback' => 'boincwork_host_delete', |
115 | 115 | 'page arguments' => array(1), |
116 | 116 | 'access callback' => 'user_is_logged_in', |
117 | 117 | 'type' => MENU_CALLBACK, |
118 | - ); |
|
119 | - $items['host/%/log'] = array( |
|
118 | + ); |
|
119 | + $items['host/%/log'] = array( |
|
120 | 120 | 'title' => 'Host log', |
121 | 121 | 'page callback' => 'boincwork_host_log', |
122 | 122 | 'page arguments' => array(1), |
123 | 123 | 'access callback' => 'user_is_logged_in', |
124 | 124 | 'type' => MENU_CALLBACK, |
125 | - ); |
|
126 | - $items['host/%/merge'] = array( |
|
125 | + ); |
|
126 | + $items['host/%/merge'] = array( |
|
127 | 127 | 'title' => 'Merge computer', |
128 | 128 | 'page callback' => 'drupal_get_form', |
129 | 129 | 'page arguments' => array('boincwork_host_merge_form', 1), |
130 | 130 | 'access callback' => 'user_is_logged_in', |
131 | 131 | 'type' => MENU_CALLBACK, |
132 | - ); |
|
133 | - $items['host/%/set-venue/%'] = array( |
|
132 | + ); |
|
133 | + $items['host/%/set-venue/%'] = array( |
|
134 | 134 | 'title' => 'Set host venue', |
135 | 135 | 'page callback' => 'boincwork_host_set_venue', |
136 | 136 | 'page arguments' => array(1,3), |
137 | 137 | 'access callback' => 'user_is_logged_in', |
138 | 138 | 'type' => MENU_CALLBACK, |
139 | - ); |
|
140 | - $items['user/%/mobile'] = array( |
|
139 | + ); |
|
140 | + $items['user/%/mobile'] = array( |
|
141 | 141 | 'title' => 'Mobile stats', |
142 | 142 | 'page callback' => 'boincwork_mobile_stats', |
143 | 143 | 'page arguments' => array(1), |
144 | 144 | 'access callback' => 'user_is_logged_in', |
145 | 145 | 'type' => MENU_CALLBACK |
146 | - ); |
|
147 | - $items['server_status.php'] = array( |
|
146 | + ); |
|
147 | + $items['server_status.php'] = array( |
|
148 | 148 | 'title' => 'Server status', |
149 | 149 | 'page callback' => 'boincwork_server_status', |
150 | 150 | 'access arguments' => array('access content'), |
151 | 151 | 'type' => MENU_CALLBACK |
152 | - ); |
|
153 | - $items['job_file.php'] = array( |
|
152 | + ); |
|
153 | + $items['job_file.php'] = array( |
|
154 | 154 | 'title' => 'Job file input', |
155 | 155 | 'page callback' => 'boincwork_job_file', |
156 | 156 | 'access arguments' => array('access content'), |
157 | 157 | 'type' => MENU_CALLBACK |
158 | - ); |
|
159 | - $items['get_output.php'] = array( |
|
158 | + ); |
|
159 | + $items['get_output.php'] = array( |
|
160 | 160 | 'title' => 'Get output file', |
161 | 161 | 'page callback' => 'boincwork_get_output', |
162 | 162 | 'access arguments' => array('access content'), |
163 | 163 | 'type' => MENU_CALLBACK |
164 | - ); |
|
165 | - $items['get_project_config.php'] = array( |
|
164 | + ); |
|
165 | + $items['get_project_config.php'] = array( |
|
166 | 166 | 'title' => 'Project config', |
167 | 167 | 'page callback' => 'boincwork_get_project_config', |
168 | 168 | 'access arguments' => array('access content'), |
169 | 169 | 'type' => MENU_CALLBACK |
170 | - ); |
|
171 | - $items['submit_rpc_handler.php'] = array( |
|
170 | + ); |
|
171 | + $items['submit_rpc_handler.php'] = array( |
|
172 | 172 | 'title' => 'Remote job submission', |
173 | 173 | 'page callback' => 'boincwork_submit_rpc_handler', |
174 | 174 | 'access arguments' => array('access content'), |
175 | 175 | 'type' => MENU_CALLBACK |
176 | - ); |
|
177 | - $items['userw.php'] = array( |
|
176 | + ); |
|
177 | + $items['userw.php'] = array( |
|
178 | 178 | 'title' => 'User WAP', |
179 | 179 | 'page callback' => 'boincwork_user_wap', |
180 | 180 | 'access arguments' => array('access content'), |
181 | 181 | 'type' => MENU_CALLBACK |
182 | - ); |
|
183 | - $items['account/tasks/%/%'] = array( |
|
182 | + ); |
|
183 | + $items['account/tasks/%/%'] = array( |
|
184 | 184 | 'title' => 'Account Tasks Table', |
185 | 185 | 'description' => '', |
186 | 186 | 'page callback' => 'boincwork_account_task_table', |
187 | 187 | 'page arguments' => array(2,3), |
188 | 188 | 'access arguments' => array('access content'), |
189 | 189 | 'type' => MENU_CALLBACK, |
190 | - ); |
|
191 | - $items['host/%/tasks/%/%'] = array( |
|
190 | + ); |
|
191 | + $items['host/%/tasks/%/%'] = array( |
|
192 | 192 | 'title' => 'Host Tasks Table', |
193 | 193 | 'description' => '', |
194 | 194 | 'page callback' => 'boincwork_host_task_table', |
195 | 195 | 'page arguments' => array(1,3,4), |
196 | 196 | 'access arguments' => array('access content'), |
197 | 197 | 'type' => MENU_CALLBACK, |
198 | - ); |
|
199 | - // Workunit task table disabled |
|
200 | - //$items['workunit/%/tasks/%/%'] = array( |
|
201 | - // 'title' => 'Workunit Tasks Table', |
|
202 | - // 'description' => '', |
|
203 | - // 'page callback' => 'boincwork_workunit_task_table', |
|
204 | - // 'page arguments' => array(1,3,4), |
|
205 | - // 'access arguments' => array('access content'), |
|
206 | - // 'type' => MENU_CALLBACK, |
|
207 | - //); |
|
208 | - return $items; |
|
198 | + ); |
|
199 | + // Workunit task table disabled |
|
200 | + //$items['workunit/%/tasks/%/%'] = array( |
|
201 | + // 'title' => 'Workunit Tasks Table', |
|
202 | + // 'description' => '', |
|
203 | + // 'page callback' => 'boincwork_workunit_task_table', |
|
204 | + // 'page arguments' => array(1,3,4), |
|
205 | + // 'access arguments' => array('access content'), |
|
206 | + // 'type' => MENU_CALLBACK, |
|
207 | + //); |
|
208 | + return $items; |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
212 | 212 | * Implementation of hook_theme(). |
213 | 213 | */ |
214 | 214 | function boincwork_theme() { |
215 | - return array( |
|
215 | + return array( |
|
216 | 216 | 'boincwork_privacyprefs_form' => array( |
217 | - 'arguments' => array('form'), |
|
217 | + 'arguments' => array('form'), |
|
218 | 218 | ), |
219 | - ); |
|
219 | + ); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
223 | 223 | * Implementation of hook_views_api(). |
224 | 224 | */ |
225 | 225 | function boincwork_views_api() { |
226 | - return array( |
|
226 | + return array( |
|
227 | 227 | 'api' => 2.0, |
228 | 228 | 'path' => drupal_get_path('module', 'boincwork') |
229 | - ); |
|
229 | + ); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
233 | 233 | * Implementation of hook_locale(). |
234 | 234 | */ |
235 | 235 | function boincwork_locale($op = 'groups', $group = NULL) { |
236 | - switch ($op) { |
|
236 | + switch ($op) { |
|
237 | 237 | case 'groups': |
238 | 238 | return array('project' => bts('Project')); |
239 | 239 | case 'info': |
240 | 240 | $info['project']['refresh callback'] = 'boincwork_locale_refresh'; |
241 | - $info['project']['format'] = FALSE; |
|
242 | - return $info; |
|
243 | - } |
|
241 | + $info['project']['format'] = FALSE; |
|
242 | + return $info; |
|
243 | + } |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
247 | 247 | * Refresh strings. |
248 | 248 | */ |
249 | 249 | function boincwork_locale_refresh() { |
250 | - // Mimic process of adding project specific prefs to the project preferences |
|
251 | - // form -- this parses the prefs XML and calls i18nstrings_update() |
|
252 | - $form = array(); |
|
253 | - $prefs = array( |
|
250 | + // Mimic process of adding project specific prefs to the project preferences |
|
251 | + // form -- this parses the prefs XML and calls i18nstrings_update() |
|
252 | + $form = array(); |
|
253 | + $prefs = array( |
|
254 | 254 | 'project_specific' => array(), |
255 | - ); |
|
256 | - boincwork_add_project_specific_prefs($form, $prefs); |
|
257 | - return TRUE; // Meaning it completed with no issues |
|
255 | + ); |
|
256 | + boincwork_add_project_specific_prefs($form, $prefs); |
|
257 | + return TRUE; // Meaning it completed with no issues |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | |
@@ -263,43 +263,43 @@ discard block |
||
263 | 263 | */ |
264 | 264 | |
265 | 265 | function boincwork_privatemsg_message_view_alter(&$vars) { |
266 | - global $user; |
|
266 | + global $user; |
|
267 | 267 | |
268 | - $author = $vars['message']['author']; |
|
269 | - if (!isset($vars['message']['thread_id'])) { |
|
268 | + $author = $vars['message']['author']; |
|
269 | + if (!isset($vars['message']['thread_id'])) { |
|
270 | 270 | // No thread id, this is probably only a preview |
271 | 271 | return; |
272 | - } |
|
273 | - $thread_id = $vars['message']['thread_id']; |
|
272 | + } |
|
273 | + $thread_id = $vars['message']['thread_id']; |
|
274 | 274 | |
275 | - if ($user->uid != $author->uid) { |
|
275 | + if ($user->uid != $author->uid) { |
|
276 | 276 | if ($vars['message']['is_blocked']) { |
277 | - $vars['message_actions']['unignore_user'] = array( |
|
277 | + $vars['message_actions']['unignore_user'] = array( |
|
278 | 278 | 'title' => bts('Stop Ignoring User', array(), NULL, 'boinc:ignore-user-remove'), |
279 | 279 | 'href' => 'account/prefs/privacy/ignore_user/remove/'. $author->uid, |
280 | 280 | 'query' => 'destination=messages/view/' . $thread_id, |
281 | - ); |
|
281 | + ); |
|
282 | 282 | } |
283 | 283 | else { |
284 | - $vars['message_actions']['ignore_user'] = array( |
|
284 | + $vars['message_actions']['ignore_user'] = array( |
|
285 | 285 | 'title' => bts('Ignore User', array(), NULL, 'boinc:ignore-user-add'), |
286 | 286 | 'href' => 'account/prefs/privacy/ignore_user/add/'. $author->uid, |
287 | 287 | 'query' => 'destination=messages/view/' . $thread_id, |
288 | - ); |
|
288 | + ); |
|
289 | + } |
|
289 | 290 | } |
290 | - } |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | /** |
294 | 294 | * Implementation of hook_cron() |
295 | 295 | */ |
296 | 296 | function boincwork_cron() { |
297 | - // Delete expired hosts in the BOINC database, host_delete table. |
|
298 | - require_boinc('boinc_db'); |
|
299 | - $num_deleted = BoincHostDeleted::delete_expired(); |
|
300 | - if ($num_deleted>0) { |
|
297 | + // Delete expired hosts in the BOINC database, host_delete table. |
|
298 | + require_boinc('boinc_db'); |
|
299 | + $num_deleted = BoincHostDeleted::delete_expired(); |
|
300 | + if ($num_deleted>0) { |
|
301 | 301 | watchdog('boincwork', "Deleted ${num_deleted} hosts from host_deleted table", WATCHDOG_NOTICE); |
302 | - } |
|
302 | + } |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -307,41 +307,41 @@ discard block |
||
307 | 307 | * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
308 | 308 | |
309 | 309 | /** |
310 | - * General preferences menu callback. |
|
311 | - * Called when user goes to edit preferences page |
|
312 | - */ |
|
310 | + * General preferences menu callback. |
|
311 | + * Called when user goes to edit preferences page |
|
312 | + */ |
|
313 | 313 | function generalprefs_page($action = null, $venue = null, $advanced = FALSE) { |
314 | 314 | |
315 | - // Keep the venue selected across preference pages |
|
316 | - boincwork_select_venue($venue); |
|
315 | + // Keep the venue selected across preference pages |
|
316 | + boincwork_select_venue($venue); |
|
317 | 317 | |
318 | - $pref_sets = array('generic', 'home', 'school', 'work'); |
|
319 | - $output = null; |
|
320 | - // Set the page title |
|
321 | - $title = 'Computing'; |
|
322 | - drupal_set_title($title); |
|
318 | + $pref_sets = array('generic', 'home', 'school', 'work'); |
|
319 | + $output = null; |
|
320 | + // Set the page title |
|
321 | + $title = 'Computing'; |
|
322 | + drupal_set_title($title); |
|
323 | 323 | |
324 | - switch ($action) { |
|
324 | + switch ($action) { |
|
325 | 325 | |
326 | - case 'clear': |
|
326 | + case 'clear': |
|
327 | 327 | // Remove settings from this preference set |
328 | 328 | if ($venue AND $venue != 'generic') { |
329 | - boincwork_save_prefs(NULL, 'general', $venue); |
|
330 | - drupal_set_message(t('Settings for the "@name" preference set have been |
|
329 | + boincwork_save_prefs(NULL, 'general', $venue); |
|
330 | + drupal_set_message(t('Settings for the "@name" preference set have been |
|
331 | 331 | cleared', array('@name' => ucfirst($venue)))); |
332 | - // Set the generic preference set as active |
|
333 | - $_SESSION['prefs venue'] = 'generic'; |
|
332 | + // Set the generic preference set as active |
|
333 | + $_SESSION['prefs venue'] = 'generic'; |
|
334 | 334 | } |
335 | 335 | drupal_goto(); |
336 | 336 | break; |
337 | 337 | |
338 | - case 'combined': |
|
338 | + case 'combined': |
|
339 | 339 | // Compare preference sets; tabular view |
340 | 340 | |
341 | 341 | foreach ($pref_sets as $pref_set) { |
342 | - $form_state = array(); |
|
343 | - $prefs[$pref_set] = drupal_retrieve_form('boincwork_generalprefs_form', $form_state, $pref_set); |
|
344 | - drupal_prepare_form('boincwork_generalprefs_form', $prefs[$pref_set], $form_state); |
|
342 | + $form_state = array(); |
|
343 | + $prefs[$pref_set] = drupal_retrieve_form('boincwork_generalprefs_form', $form_state, $pref_set); |
|
344 | + drupal_prepare_form('boincwork_generalprefs_form', $prefs[$pref_set], $form_state); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | $output .= '<p>' . bts('These apply to all BOINC projects in which you participate.', array(), NULL, 'boinc:account-preferences-computing') . '<br/>'; |
@@ -354,29 +354,29 @@ discard block |
||
354 | 354 | $prefs_table = boincwork_make_prefs_table($prefs['generic']['prefs']['advanced']); |
355 | 355 | |
356 | 356 | foreach ($prefs_table as $category => $section) { |
357 | - $output .= '<tr class="section-heading">'; |
|
358 | - $output .= "<td>{$section['name']}</td>"; |
|
359 | - foreach ($pref_sets as $pref_set) { |
|
357 | + $output .= '<tr class="section-heading">'; |
|
358 | + $output .= "<td>{$section['name']}</td>"; |
|
359 | + foreach ($pref_sets as $pref_set) { |
|
360 | 360 | $output .= '<td>' . $pref_set . '</td>'; |
361 | - } |
|
362 | - $output .= '</tr>'; |
|
363 | - foreach ($section['elements'] as $name => $setting) { |
|
361 | + } |
|
362 | + $output .= '</tr>'; |
|
363 | + foreach ($section['elements'] as $name => $setting) { |
|
364 | 364 | // Output the setting name and description, with an ugly exception |
365 | 365 | // made for preferences with special formatting |
366 | 366 | $special_map = array( |
367 | - 'start_hour' => 'end_hour', |
|
368 | - 'net_start_hour'=> 'net_end_hour', |
|
369 | - 'daily_xfer_limit_mb' => 'daily_xfer_period_days', |
|
367 | + 'start_hour' => 'end_hour', |
|
368 | + 'net_start_hour'=> 'net_end_hour', |
|
369 | + 'daily_xfer_limit_mb' => 'daily_xfer_period_days', |
|
370 | 370 | ); |
371 | 371 | $special_delimiter = array( |
372 | - 'start_hour' => bts('and', array(), NULL, 'boinc:account-preference'), |
|
373 | - 'net_start_hour'=> bts('and', array(), NULL, 'boinc:account-preference'), |
|
374 | - 'daily_xfer_limit_mb' => bts('every', array(), NULL, 'boinc:account-preference'), |
|
372 | + 'start_hour' => bts('and', array(), NULL, 'boinc:account-preference'), |
|
373 | + 'net_start_hour'=> bts('and', array(), NULL, 'boinc:account-preference'), |
|
374 | + 'daily_xfer_limit_mb' => bts('every', array(), NULL, 'boinc:account-preference'), |
|
375 | 375 | ); |
376 | 376 | $special = isset($special_map[$name]); |
377 | 377 | $very_special = in_array($name, $special_map); |
378 | 378 | if ($very_special) { |
379 | - continue; |
|
379 | + continue; |
|
380 | 380 | } |
381 | 381 | $output .= '<tr>'; |
382 | 382 | $output .= '<td>'; |
@@ -386,35 +386,35 @@ discard block |
||
386 | 386 | // Output values for each preference set, again with ugly hacks for |
387 | 387 | // time range preferences |
388 | 388 | foreach ($pref_sets as $pref_set) { |
389 | - if (($prefs[$pref_set]) AND |
|
389 | + if (($prefs[$pref_set]) AND |
|
390 | 390 | $prefs[$pref_set]['#established'] AND |
391 | 391 | isset($prefs[$pref_set]['prefs']['advanced'][$category])) { |
392 | 392 | $pref_setting = $prefs[$pref_set]['prefs']['advanced'][$category][$name]; |
393 | 393 | $value = isset($pref_setting['#options']) ? $pref_setting['#options'][$pref_setting['#default_value']] : $pref_setting['#default_value']; |
394 | 394 | if ($value == '') { |
395 | - $value = '---'; |
|
395 | + $value = '---'; |
|
396 | 396 | } |
397 | 397 | if (!isset($pref_setting['#field_suffix'])) { |
398 | - $pref_setting['#field_suffix'] = ''; |
|
398 | + $pref_setting['#field_suffix'] = ''; |
|
399 | 399 | } |
400 | 400 | if (!$special) { |
401 | - $output .= "<td>{$value} {$pref_setting['#field_suffix']}</td>"; |
|
401 | + $output .= "<td>{$value} {$pref_setting['#field_suffix']}</td>"; |
|
402 | 402 | } |
403 | 403 | else { |
404 | - // The "very special" case where we merge two prefs |
|
405 | - $second_pref = $special_map[$name]; |
|
406 | - $second_pref_setting = $prefs[$pref_set]['prefs']['advanced'][$category][$second_pref]; |
|
407 | - $second_value = isset($second_pref_setting['#options']) ? $second_pref_setting['#options'][$second_pref_setting['#default_value']] : $second_pref_setting['#default_value']; |
|
408 | - $output .= "<td>{$value} {$pref_setting['#field_suffix']} {$special_delimiter[$name]}" . |
|
404 | + // The "very special" case where we merge two prefs |
|
405 | + $second_pref = $special_map[$name]; |
|
406 | + $second_pref_setting = $prefs[$pref_set]['prefs']['advanced'][$category][$second_pref]; |
|
407 | + $second_value = isset($second_pref_setting['#options']) ? $second_pref_setting['#options'][$second_pref_setting['#default_value']] : $second_pref_setting['#default_value']; |
|
408 | + $output .= "<td>{$value} {$pref_setting['#field_suffix']} {$special_delimiter[$name]}" . |
|
409 | 409 | " {$second_value} {$second_pref_setting['#field_suffix']} </td>"; |
410 | 410 | } |
411 | - } |
|
412 | - else { |
|
411 | + } |
|
412 | + else { |
|
413 | 413 | $output .= '<td>---</td>'; |
414 | - } |
|
414 | + } |
|
415 | 415 | } |
416 | 416 | $output .= '</tr>'; |
417 | - } |
|
417 | + } |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | // Empty line above action links... :/ |
@@ -430,24 +430,24 @@ discard block |
||
430 | 430 | $output .= '<tr>'; |
431 | 431 | $output .= '<td></td>'; |
432 | 432 | foreach ($pref_sets as $pref_set) { |
433 | - $action_text = ($prefs[$pref_set]['#established']) ? bts('Edit', array(), NULL, 'boinc:form-edit') : bts('Add', array(), NULL, 'boinc:form-add'); |
|
434 | - $output .= '<td><ul class="tab-list"><li class="first tab">'; |
|
435 | - $output .= l($action_text, "account/prefs/computing/edit/{$pref_set}/1", |
|
433 | + $action_text = ($prefs[$pref_set]['#established']) ? bts('Edit', array(), NULL, 'boinc:form-edit') : bts('Add', array(), NULL, 'boinc:form-add'); |
|
434 | + $output .= '<td><ul class="tab-list"><li class="first tab">'; |
|
435 | + $output .= l($action_text, "account/prefs/computing/edit/{$pref_set}/1", |
|
436 | 436 | array('fragment' => "") |
437 | - ); |
|
438 | - // Show Clear links for established preference sets |
|
439 | - if ($pref_set != 'generic' AND $prefs[$pref_set]['#established']) { |
|
437 | + ); |
|
438 | + // Show Clear links for established preference sets |
|
439 | + if ($pref_set != 'generic' AND $prefs[$pref_set]['#established']) { |
|
440 | 440 | $output .= ' </li><li class="tab"> ' . l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/computing/clear/{$pref_set}", |
441 | - array( |
|
441 | + array( |
|
442 | 442 | 'query' => drupal_get_destination(), |
443 | 443 | 'attributes' => array( |
444 | - 'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the "@name" preference set. Are you sure?', |
|
444 | + 'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the "@name" preference set. Are you sure?', |
|
445 | 445 | array('@name' => ucfirst($pref_set)), NULL, 'boinc:account-computing-preferences') . '\')' |
446 | 446 | ) |
447 | - ) |
|
447 | + ) |
|
448 | 448 | ); |
449 | - } |
|
450 | - $output .= '</li></ul></td>'; |
|
449 | + } |
|
450 | + $output .= '</li></ul></td>'; |
|
451 | 451 | } |
452 | 452 | $output .= '</tr>'; |
453 | 453 | |
@@ -455,28 +455,28 @@ discard block |
||
455 | 455 | |
456 | 456 | break; |
457 | 457 | |
458 | - case 'edit': |
|
458 | + case 'edit': |
|
459 | 459 | default: |
460 | 460 | |
461 | 461 | // Return the HTML generated from the $form data structure. |
462 | 462 | if (function_exists('jump_quickly')) { |
463 | - $path = 'account/prefs/computing/edit'; |
|
464 | - $venues = array( |
|
463 | + $path = 'account/prefs/computing/edit'; |
|
464 | + $venues = array( |
|
465 | 465 | "{$path}/generic" => bts('Generic', array(), NULL, 'boinc:account-preferences-location'), |
466 | 466 | "{$path}/home" => bts('Home', array(), NULL, 'boinc:account-preferences-location:-1:ignoreoverwrite'), |
467 | 467 | "{$path}/school" => bts('School', array(), NULL, 'boinc:account-preferences-location'), |
468 | 468 | "{$path}/work" => bts('Work', array(), NULL, 'boinc:account-preferences-location') |
469 | - ); |
|
470 | - variable_set('jump_use_js_venues-Array', 1); |
|
471 | - drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js'); |
|
472 | - drupal_add_js(drupal_get_path('theme', 'boinc') . '/js/prefs.js', 'theme'); |
|
469 | + ); |
|
470 | + variable_set('jump_use_js_venues-Array', 1); |
|
471 | + drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js'); |
|
472 | + drupal_add_js(drupal_get_path('theme', 'boinc') . '/js/prefs.js', 'theme'); |
|
473 | 473 | |
474 | - $output .= '<div id="venue-selector" class="simple-form-controls">'; |
|
475 | - $output .= ' <div class="form-item venue">'; |
|
476 | - $output .= ' <label>Preference set:</label>'; |
|
477 | - $output .= jump_quickly($venues, 'venues', 1, "{$path}/{$venue}"); |
|
478 | - $output .= ' </div>'; |
|
479 | - $output .= '</div>'; |
|
474 | + $output .= '<div id="venue-selector" class="simple-form-controls">'; |
|
475 | + $output .= ' <div class="form-item venue">'; |
|
476 | + $output .= ' <label>Preference set:</label>'; |
|
477 | + $output .= jump_quickly($venues, 'venues', 1, "{$path}/{$venue}"); |
|
478 | + $output .= ' </div>'; |
|
479 | + $output .= '</div>'; |
|
480 | 480 | } |
481 | 481 | $output .= drupal_get_form('boincwork_generalprefs_form', $venue, NULL, $advanced); |
482 | 482 | |
@@ -487,54 +487,54 @@ discard block |
||
487 | 487 | drupal_prepare_form('boincwork_generalprefs_form', $current_set, $form_state); |
488 | 488 | |
489 | 489 | if (!$current_set['#established']) { |
490 | - drupal_set_message(bts( |
|
491 | - "No preferences found for set '@venue'. Click SAVE CHANGES below to save the following preferences to your account.", |
|
492 | - array( '@venue' => $venue, ), |
|
493 | - NULL, 'boinc:account-preferences'), 'status'); |
|
490 | + drupal_set_message(bts( |
|
491 | + "No preferences found for set '@venue'. Click SAVE CHANGES below to save the following preferences to your account.", |
|
492 | + array( '@venue' => $venue, ), |
|
493 | + NULL, 'boinc:account-preferences'), 'status'); |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | break; |
497 | - } |
|
497 | + } |
|
498 | 498 | |
499 | - return $output; |
|
499 | + return $output; |
|
500 | 500 | } |
501 | 501 | |
502 | 502 | /** |
503 | - * Project preferences menu callback |
|
504 | - * Called when user goes to edit project preferences page. |
|
505 | - */ |
|
503 | + * Project preferences menu callback |
|
504 | + * Called when user goes to edit project preferences page. |
|
505 | + */ |
|
506 | 506 | function projectprefs_page($action = null, $venue = null) { |
507 | 507 | |
508 | - // Keep the venue selected across preference pages |
|
509 | - boincwork_select_venue($venue); |
|
508 | + // Keep the venue selected across preference pages |
|
509 | + boincwork_select_venue($venue); |
|
510 | 510 | |
511 | - require_boinc(array('util', 'prefs')); |
|
512 | - global $project_has_beta; |
|
513 | - $pref_sets = array('generic', 'home', 'school', 'work'); |
|
514 | - $output = null; |
|
511 | + require_boinc(array('util', 'prefs')); |
|
512 | + global $project_has_beta; |
|
513 | + $pref_sets = array('generic', 'home', 'school', 'work'); |
|
514 | + $output = null; |
|
515 | 515 | |
516 | - $title = 'Project'; |
|
517 | - drupal_set_title($title); |
|
516 | + $title = 'Project'; |
|
517 | + drupal_set_title($title); |
|
518 | 518 | |
519 | - switch ($action) { |
|
519 | + switch ($action) { |
|
520 | 520 | |
521 | - case 'clear': |
|
521 | + case 'clear': |
|
522 | 522 | // Remove settings from this preference set |
523 | 523 | if ($venue AND $venue != 'generic') { |
524 | - boincwork_save_prefs(NULL, 'project', $venue); |
|
525 | - drupal_set_message(t('Settings for the "@name" preference set have been |
|
524 | + boincwork_save_prefs(NULL, 'project', $venue); |
|
525 | + drupal_set_message(t('Settings for the "@name" preference set have been |
|
526 | 526 | cleared', array('@name' => ucfirst($venue)))); |
527 | 527 | |
528 | - // Set the generic preference set as active |
|
529 | - $_SESSION['prefs venue'] = 'generic'; |
|
528 | + // Set the generic preference set as active |
|
529 | + $_SESSION['prefs venue'] = 'generic'; |
|
530 | 530 | |
531 | - // If the user has removed their default preference set, make it generic |
|
532 | - boincwork_set_default_venue(); |
|
531 | + // If the user has removed their default preference set, make it generic |
|
532 | + boincwork_set_default_venue(); |
|
533 | 533 | } |
534 | 534 | drupal_goto(); |
535 | 535 | break; |
536 | 536 | |
537 | - case 'combined': |
|
537 | + case 'combined': |
|
538 | 538 | |
539 | 539 | // Compare preference sets; tabular view |
540 | 540 | |
@@ -543,9 +543,9 @@ discard block |
||
543 | 543 | $boincuser = BoincUser::lookup_id($account->boincuser_id); |
544 | 544 | |
545 | 545 | foreach ($pref_sets as $pref_set) { |
546 | - $form_state = array(); |
|
547 | - $prefs[$pref_set] = drupal_retrieve_form('boincwork_projectprefs_form', $form_state, $pref_set); |
|
548 | - drupal_prepare_form('boincwork_projectprefs_form', $prefs[$pref_set], $form_state); |
|
546 | + $form_state = array(); |
|
547 | + $prefs[$pref_set] = drupal_retrieve_form('boincwork_projectprefs_form', $form_state, $pref_set); |
|
548 | + drupal_prepare_form('boincwork_projectprefs_form', $prefs[$pref_set], $form_state); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | $output .= '<p>' . bts('Preferences last modified: @mod_time', array('@mod_time' => pretty_time_str($prefs['generic']['modified']['#value'])), NULL, 'boinc:account-preferences') . '</p>'; |
@@ -556,20 +556,20 @@ discard block |
||
556 | 556 | $prefs_table = boincwork_make_prefs_table($prefs['generic']); |
557 | 557 | |
558 | 558 | foreach ($prefs_table as $category => $section) { |
559 | - $output .= '<tr class="section-heading">'; |
|
560 | - $output .= "<td>{$section['name']}</td>"; |
|
561 | - foreach ($pref_sets as $pref_set) { |
|
559 | + $output .= '<tr class="section-heading">'; |
|
560 | + $output .= "<td>{$section['name']}</td>"; |
|
561 | + foreach ($pref_sets as $pref_set) { |
|
562 | 562 | $output .= '<td>' . $pref_set . '</td>'; |
563 | - } |
|
564 | - $output .= '</tr>'; |
|
565 | - foreach ($section['elements'] as $name => $setting) { |
|
563 | + } |
|
564 | + $output .= '</tr>'; |
|
565 | + foreach ($section['elements'] as $name => $setting) { |
|
566 | 566 | $output .= '<tr>'; |
567 | 567 | $output .= '<td>'; |
568 | 568 | $output .= "<div class=\"title\">{$setting['name']}</div>"; |
569 | 569 | $output .= "<div class=\"description\">{$setting['description']}</div>"; |
570 | 570 | $output .= '</td>'; |
571 | 571 | foreach ($pref_sets as $pref_set) { |
572 | - if (($prefs[$pref_set]) AND |
|
572 | + if (($prefs[$pref_set]) AND |
|
573 | 573 | $prefs[$pref_set]['#established'] AND |
574 | 574 | isset($prefs[$pref_set][$category])) { |
575 | 575 | $pref_setting = $prefs[$pref_set][$category][$name]; |
@@ -577,10 +577,10 @@ discard block |
||
577 | 577 | if ($value == '') $value = '---'; |
578 | 578 | if (!isset($pref_setting['#field_suffix'])) $pref_setting['#field_suffix'] = ''; |
579 | 579 | $output .= "<td>{$value} {$pref_setting['#field_suffix']}</td>"; |
580 | - } else $output .= '<td>---</td>'; |
|
580 | + } else $output .= '<td>---</td>'; |
|
581 | 581 | } |
582 | 582 | $output .= '</tr>'; |
583 | - } |
|
583 | + } |
|
584 | 584 | } |
585 | 585 | |
586 | 586 | // Empty line above action links... :/ |
@@ -596,29 +596,29 @@ discard block |
||
596 | 596 | $output .= '<tr>'; |
597 | 597 | $output .= '<td></td>'; |
598 | 598 | foreach ($pref_sets as $pref_set) { |
599 | - $action_text = ($prefs[$pref_set]['#established']) ? bts('Edit', array(), NULL, 'boinc:form-edit') : bts('Add', array(), NULL, 'boinc:form-add'); |
|
600 | - $output .= '<td><ul class="tab-list"><li class="first tab">'; |
|
601 | - $output .= l($action_text, "account/prefs/project/edit/{$pref_set}"); |
|
602 | - // Show Clear links for established preference sets |
|
603 | - if ($pref_set != 'generic' AND $prefs[$pref_set]['#established']) { |
|
599 | + $action_text = ($prefs[$pref_set]['#established']) ? bts('Edit', array(), NULL, 'boinc:form-edit') : bts('Add', array(), NULL, 'boinc:form-add'); |
|
600 | + $output .= '<td><ul class="tab-list"><li class="first tab">'; |
|
601 | + $output .= l($action_text, "account/prefs/project/edit/{$pref_set}"); |
|
602 | + // Show Clear links for established preference sets |
|
603 | + if ($pref_set != 'generic' AND $prefs[$pref_set]['#established']) { |
|
604 | 604 | $output .= ' </li><li class="tab"> ' . l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/project/clear/{$pref_set}", |
605 | - array( |
|
605 | + array( |
|
606 | 606 | 'query' => drupal_get_destination(), |
607 | 607 | 'attributes' => array( |
608 | - 'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the "@name" preference set. Are you sure?', |
|
608 | + 'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the "@name" preference set. Are you sure?', |
|
609 | 609 | array('@name' => ucfirst($pref_set)), NULL, 'boinc:account-preferences-project') . '\')' |
610 | 610 | ) |
611 | - ) |
|
611 | + ) |
|
612 | 612 | ); |
613 | - } |
|
614 | - $output .= '</li></ul></td>'; |
|
613 | + } |
|
614 | + $output .= '</li></ul></td>'; |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | $output .= '</table>'; |
618 | 618 | |
619 | 619 | break; |
620 | 620 | |
621 | - case 'set-default': |
|
621 | + case 'set-default': |
|
622 | 622 | // Set this preference set as the one to use for any new hosts attached |
623 | 623 | // to the user account |
624 | 624 | boincwork_set_default_venue($venue); |
@@ -626,30 +626,30 @@ discard block |
||
626 | 626 | drupal_goto('account/prefs/project/combined'); |
627 | 627 | break; |
628 | 628 | |
629 | - case 'edit': |
|
629 | + case 'edit': |
|
630 | 630 | default: |
631 | 631 | |
632 | 632 | // Return the HTML generated from the $form data structure. |
633 | 633 | require_boinc('util'); |
634 | 634 | |
635 | 635 | if (function_exists('jump_quickly')) { |
636 | - $path = 'account/prefs/project/edit'; |
|
637 | - $venues = array( |
|
636 | + $path = 'account/prefs/project/edit'; |
|
637 | + $venues = array( |
|
638 | 638 | "{$path}/generic" => bts('Generic', array(), NULL, 'boinc:account-preferences-location'), |
639 | 639 | "{$path}/home" => bts('Home', array(), NULL, 'boinc:account-preferences-location:-1:ignoreoverwrite'), |
640 | 640 | "{$path}/school" => bts('School', array(), NULL, 'boinc:account-preferences-location'), |
641 | 641 | "{$path}/work" => bts('Work', array(), NULL, 'boinc:account-preferences-location') |
642 | - ); |
|
643 | - variable_set('jump_use_js_venues-Array', 1); |
|
644 | - drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js'); |
|
645 | - drupal_add_js(drupal_get_path('theme', 'boinc') . '/js/prefs.js', 'theme'); |
|
642 | + ); |
|
643 | + variable_set('jump_use_js_venues-Array', 1); |
|
644 | + drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js'); |
|
645 | + drupal_add_js(drupal_get_path('theme', 'boinc') . '/js/prefs.js', 'theme'); |
|
646 | 646 | |
647 | - $output .= '<div id="venue-selector" class="simple-form-controls">'; |
|
648 | - $output .= ' <div class="form-item venue">'; |
|
649 | - $output .= ' <label>Preference set:</label>'; |
|
650 | - $output .= jump_quickly($venues, 'venues', 1, "{$path}/{$venue}"); |
|
651 | - $output .= ' </div>'; |
|
652 | - $output .= '</div>'; |
|
647 | + $output .= '<div id="venue-selector" class="simple-form-controls">'; |
|
648 | + $output .= ' <div class="form-item venue">'; |
|
649 | + $output .= ' <label>Preference set:</label>'; |
|
650 | + $output .= jump_quickly($venues, 'venues', 1, "{$path}/{$venue}"); |
|
651 | + $output .= ' </div>'; |
|
652 | + $output .= '</div>'; |
|
653 | 653 | } |
654 | 654 | $output .= drupal_get_form('boincwork_projectprefs_form', $venue); |
655 | 655 | |
@@ -660,63 +660,63 @@ discard block |
||
660 | 660 | drupal_prepare_form('boincwork_projectprefs_form', $current_set, $form_state); |
661 | 661 | |
662 | 662 | if (!$current_set['#established']) { |
663 | - drupal_set_message(bts( |
|
664 | - "No preferences found for set '@venue'. Click SAVE CHANGES below to save the following preferences to your account.", |
|
665 | - array( '@venue' => $venue, ), |
|
666 | - NULL, 'boinc:account-preferences'), 'status'); |
|
663 | + drupal_set_message(bts( |
|
664 | + "No preferences found for set '@venue'. Click SAVE CHANGES below to save the following preferences to your account.", |
|
665 | + array( '@venue' => $venue, ), |
|
666 | + NULL, 'boinc:account-preferences'), 'status'); |
|
667 | 667 | } |
668 | 668 | |
669 | 669 | break; |
670 | 670 | |
671 | - } |
|
672 | - return $output; |
|
671 | + } |
|
672 | + return $output; |
|
673 | 673 | } |
674 | 674 | |
675 | 675 | /** |
676 | - * Community preferences menu callback |
|
677 | - * Called when user goes to edit community preferences page. |
|
678 | - */ |
|
676 | + * Community preferences menu callback |
|
677 | + * Called when user goes to edit community preferences page. |
|
678 | + */ |
|
679 | 679 | function communityprefs_page($action = null) { |
680 | 680 | |
681 | - require_boinc(array('util', 'prefs')); |
|
682 | - $output = null; |
|
681 | + require_boinc(array('util', 'prefs')); |
|
682 | + $output = null; |
|
683 | 683 | |
684 | - $title = 'Community'; |
|
685 | - drupal_set_title($title); |
|
684 | + $title = 'Community'; |
|
685 | + drupal_set_title($title); |
|
686 | 686 | |
687 | - //$output .= '<h2>Community preferences</h2>'; |
|
687 | + //$output .= '<h2>Community preferences</h2>'; |
|
688 | 688 | |
689 | - $output .= drupal_get_form('communityprefs_form'); |
|
689 | + $output .= drupal_get_form('communityprefs_form'); |
|
690 | 690 | |
691 | - return $output; |
|
691 | + return $output; |
|
692 | 692 | } |
693 | 693 | |
694 | 694 | /** |
695 | - * Privacy preferences menu callback |
|
696 | - * Called when user goes to edit privacy preferences page. |
|
697 | - */ |
|
695 | + * Privacy preferences menu callback |
|
696 | + * Called when user goes to edit privacy preferences page. |
|
697 | + */ |
|
698 | 698 | function privacyprefs_page($action = null) { |
699 | 699 | |
700 | - require_boinc(array('util', 'prefs')); |
|
701 | - $output = null; |
|
702 | - $title = 'Privacy'; |
|
703 | - drupal_set_title($title); |
|
700 | + require_boinc(array('util', 'prefs')); |
|
701 | + $output = null; |
|
702 | + $title = 'Privacy'; |
|
703 | + drupal_set_title($title); |
|
704 | 704 | |
705 | - switch ($action) { |
|
706 | - case 'view': |
|
705 | + switch ($action) { |
|
706 | + case 'view': |
|
707 | 707 | $form_state = array(); |
708 | 708 | $prefs = drupal_retrieve_form('boincwork_privacyprefs_form', $form_state); |
709 | 709 | drupal_prepare_form('boincwork_privacyprefs_form', $prefs, $form_state); |
710 | 710 | $output .= '<table>'; |
711 | 711 | |
712 | 712 | $sections = array( |
713 | - 'privacy' => $prefs['privacy'] |
|
713 | + 'privacy' => $prefs['privacy'] |
|
714 | 714 | ); |
715 | 715 | |
716 | 716 | foreach ($sections as $section) { |
717 | - $output .= '<tr class="section-heading">'; |
|
718 | - $output .= "<td>{$section['#title']}</td></tr>"; |
|
719 | - foreach ($section as $name => $setting) { |
|
717 | + $output .= '<tr class="section-heading">'; |
|
718 | + $output .= "<td>{$section['#title']}</td></tr>"; |
|
719 | + foreach ($section as $name => $setting) { |
|
720 | 720 | if ($name{0} == '#') continue; |
721 | 721 | $value = isset($setting['#default_value']) ? $setting['#default_value'] : ''; |
722 | 722 | if ($value AND isset($setting['#options'])) $value = $setting['#options'][$value]; |
@@ -728,7 +728,7 @@ discard block |
||
728 | 728 | $output .= "<td>{$setting['#title']}<br/>{$setting['#description']}</td>"; |
729 | 729 | $output .= "<td>{$value} {$setting['#field_suffix']}</td>"; |
730 | 730 | $output .= '</tr>'; |
731 | - } |
|
731 | + } |
|
732 | 732 | } |
733 | 733 | |
734 | 734 | // Edit preferences link |
@@ -741,33 +741,33 @@ discard block |
||
741 | 741 | |
742 | 742 | break; |
743 | 743 | |
744 | - case 'edit': |
|
744 | + case 'edit': |
|
745 | 745 | default: |
746 | 746 | require_boinc('util'); |
747 | 747 | // Return the HTML generated from the $form data structure. |
748 | 748 | $output .= drupal_get_form('boincwork_privacyprefs_form'); |
749 | 749 | break; |
750 | 750 | |
751 | - } |
|
751 | + } |
|
752 | 752 | |
753 | - return $output; |
|
753 | + return $output; |
|
754 | 754 | } |
755 | 755 | |
756 | 756 | /** |
757 | - * Certificates menu callback |
|
758 | - * Called when user goes to account certificate pages |
|
759 | - */ |
|
757 | + * Certificates menu callback |
|
758 | + * Called when user goes to account certificate pages |
|
759 | + */ |
|
760 | 760 | function boincwork_certificates($type = null, $border = null) { |
761 | - global $user; |
|
762 | - $drupuser = user_load($user->uid); |
|
763 | - // Load BOINC account and pre-authenticate with BOINC code |
|
764 | - require_boinc(array('util', 'cert')); |
|
765 | - $boincuser = BoincUser::lookup_id($drupuser->boincuser_id); |
|
766 | - //global $g_logged_in_user; |
|
767 | - //$g_logged_in_user = $boincuser; |
|
768 | - //print_r($boincuser); exit; |
|
769 | - switch ($type) { |
|
770 | - case 'all': |
|
761 | + global $user; |
|
762 | + $drupuser = user_load($user->uid); |
|
763 | + // Load BOINC account and pre-authenticate with BOINC code |
|
764 | + require_boinc(array('util', 'cert')); |
|
765 | + $boincuser = BoincUser::lookup_id($drupuser->boincuser_id); |
|
766 | + //global $g_logged_in_user; |
|
767 | + //$g_logged_in_user = $boincuser; |
|
768 | + //print_r($boincuser); exit; |
|
769 | + switch ($type) { |
|
770 | + case 'all': |
|
771 | 771 | //include_boinc('user/cert_all.php'); |
772 | 772 | require_boinc(array('util','cert','user')); |
773 | 773 | |
@@ -837,7 +837,7 @@ discard block |
||
837 | 837 | "; |
838 | 838 | break; |
839 | 839 | |
840 | - case 'account': |
|
840 | + case 'account': |
|
841 | 841 | default: |
842 | 842 | //include_boinc('user/cert1.php'); |
843 | 843 | require_boinc(array('util','cert')); |
@@ -913,7 +913,7 @@ discard block |
||
913 | 913 | echo " |
914 | 914 | </td><tr></table> |
915 | 915 | "; |
916 | - } |
|
916 | + } |
|
917 | 917 | } |
918 | 918 | |
919 | 919 | /** |
@@ -921,42 +921,42 @@ discard block |
||
921 | 921 | * Called when user selects to delete a host |
922 | 922 | */ |
923 | 923 | function boincwork_host_delete($host_id) { |
924 | - // Verify that host has no tasks |
|
925 | - if (boincwork_host_user_is_owner($host_id)) { |
|
924 | + // Verify that host has no tasks |
|
925 | + if (boincwork_host_user_is_owner($host_id)) { |
|
926 | 926 | if (!boincwork_host_get_task_count($host_id)) { |
927 | - // Delete the host record |
|
928 | - db_set_active('boinc_rw'); |
|
929 | - $host_deleted = db_query( |
|
927 | + // Delete the host record |
|
928 | + db_set_active('boinc_rw'); |
|
929 | + $host_deleted = db_query( |
|
930 | 930 | "DELETE FROM {host} WHERE id = '%d'", |
931 | 931 | $host_id |
932 | - ); |
|
933 | - db_set_active('default'); |
|
934 | - if ($host_deleted) { |
|
932 | + ); |
|
933 | + db_set_active('default'); |
|
934 | + if ($host_deleted) { |
|
935 | 935 | drupal_set_message(t('Host @id has been removed from your account.', |
936 | - array('@id' => $host_id))); |
|
936 | + array('@id' => $host_id))); |
|
937 | 937 | drupal_goto('account/computers'); |
938 | - } |
|
939 | - else { |
|
938 | + } |
|
939 | + else { |
|
940 | 940 | drupal_set_message(t('Host @id could not be deleted. Not sure why...', |
941 | - array('@id' => $host_id)), 'error' |
|
941 | + array('@id' => $host_id)), 'error' |
|
942 | 942 | ); |
943 | - } |
|
943 | + } |
|
944 | 944 | } |
945 | 945 | else { |
946 | - drupal_set_message(t('Host @id cannot be deleted because it still has |
|
946 | + drupal_set_message(t('Host @id cannot be deleted because it still has |
|
947 | 947 | tasks associated with it. These tasks should be processed within the |
948 | 948 | next few days, after which the host can be deleted.', |
949 | 949 | array('@id' => $host_id)), 'warning' |
950 | - ); |
|
950 | + ); |
|
951 | + } |
|
951 | 952 | } |
952 | - } |
|
953 | - else { |
|
953 | + else { |
|
954 | 954 | drupal_set_message(t('You are not the owner of host @id, so you cannot |
955 | 955 | delete it.', |
956 | - array('@id' => $host_id)), 'error' |
|
956 | + array('@id' => $host_id)), 'error' |
|
957 | 957 | ); |
958 | - } |
|
959 | - drupal_goto("host/{$host_id}"); |
|
958 | + } |
|
959 | + drupal_goto("host/{$host_id}"); |
|
960 | 960 | } |
961 | 961 | |
962 | 962 | /** |
@@ -964,55 +964,55 @@ discard block |
||
964 | 964 | * Called when user accesses the log for a host |
965 | 965 | */ |
966 | 966 | function boincwork_host_log($host_id = null) { |
967 | - $root_log_dir = variable_get('boinc_host_sched_logs_dir', ''); |
|
968 | - $log = ''; |
|
969 | - if ($root_log_dir AND $host_id) { |
|
967 | + $root_log_dir = variable_get('boinc_host_sched_logs_dir', ''); |
|
968 | + $log = ''; |
|
969 | + if ($root_log_dir AND $host_id) { |
|
970 | 970 | $subdir = substr($host_id, 0, -3) OR $subdir = 0; |
971 | 971 | $log = implode('/', array($root_log_dir, $subdir, $host_id)); |
972 | - } |
|
973 | - if ($log AND file_exists($log)) { |
|
972 | + } |
|
973 | + if ($log AND file_exists($log)) { |
|
974 | 974 | header('Content-type: text/plain'); |
975 | 975 | include($log); |
976 | - } |
|
976 | + } |
|
977 | 977 | } |
978 | 978 | |
979 | 979 | function boincwork_host_set_venue($host_id = NULL, $venue = NULL) { |
980 | - global $user; |
|
981 | - $account = user_load($user->uid); |
|
982 | - db_set_active('boinc_ro'); |
|
983 | - // Verify that this is my host |
|
984 | - $host_owner = db_result(db_query( |
|
980 | + global $user; |
|
981 | + $account = user_load($user->uid); |
|
982 | + db_set_active('boinc_ro'); |
|
983 | + // Verify that this is my host |
|
984 | + $host_owner = db_result(db_query( |
|
985 | 985 | "SELECT userid FROM {host} WHERE id = '%d'", |
986 | 986 | $host_id |
987 | - )); |
|
988 | - db_set_active('default'); |
|
989 | - if ($host_owner AND $host_owner == $account->boincuser_id) { |
|
987 | + )); |
|
988 | + db_set_active('default'); |
|
989 | + if ($host_owner AND $host_owner == $account->boincuser_id) { |
|
990 | 990 | db_set_active('boinc_rw'); |
991 | 991 | $updated = db_query( |
992 | - "UPDATE {host} SET venue = '%s' WHERE id = '%d'", |
|
993 | - $venue, $host_id |
|
992 | + "UPDATE {host} SET venue = '%s' WHERE id = '%d'", |
|
993 | + $venue, $host_id |
|
994 | 994 | ); |
995 | 995 | db_set_active('default'); |
996 | 996 | if ($updated) { |
997 | - drupal_set_message( |
|
997 | + drupal_set_message( |
|
998 | 998 | bts('The location for this host has been updated.', array(), NULL, 'boinc:account-host-details') |
999 | 999 | . bts('This will take effect next time the host contacts the project.', array(), NULL, 'boinc:account-host-details') |
1000 | - ); |
|
1000 | + ); |
|
1001 | 1001 | } |
1002 | 1002 | else { |
1003 | - drupal_set_message( |
|
1003 | + drupal_set_message( |
|
1004 | 1004 | bts('Unable to save changes to this host for some reason!', array(), NULL, 'boinc:account-host-details'), |
1005 | 1005 | 'error' |
1006 | - ); |
|
1006 | + ); |
|
1007 | 1007 | } |
1008 | - } |
|
1009 | - else { |
|
1008 | + } |
|
1009 | + else { |
|
1010 | 1010 | drupal_set_message( |
1011 | - bts('You are not allowed to make changes to this host.', array(), NULL, 'boinc:account-host-details'), |
|
1012 | - 'warning' |
|
1011 | + bts('You are not allowed to make changes to this host.', array(), NULL, 'boinc:account-host-details'), |
|
1012 | + 'warning' |
|
1013 | 1013 | ); |
1014 | - } |
|
1015 | - drupal_goto("host/{$host_id}"); |
|
1014 | + } |
|
1015 | + drupal_goto("host/{$host_id}"); |
|
1016 | 1016 | } |
1017 | 1017 | |
1018 | 1018 | /** |
@@ -1020,8 +1020,8 @@ discard block |
||
1020 | 1020 | * Called when user accesses cell phone stats |
1021 | 1021 | */ |
1022 | 1022 | function boincwork_mobile_stats($userid = null) { |
1023 | - $_GET['id'] = $userid; |
|
1024 | - include_boinc('user/userw.php'); |
|
1023 | + $_GET['id'] = $userid; |
|
1024 | + include_boinc('user/userw.php'); |
|
1025 | 1025 | } |
1026 | 1026 | |
1027 | 1027 | /** |
@@ -1029,7 +1029,7 @@ discard block |
||
1029 | 1029 | * Called to build the server status page |
1030 | 1030 | */ |
1031 | 1031 | function boincwork_server_status() { |
1032 | - include_boinc('user/server_status.php'); |
|
1032 | + include_boinc('user/server_status.php'); |
|
1033 | 1033 | } |
1034 | 1034 | |
1035 | 1035 | /** |
@@ -1037,7 +1037,7 @@ discard block |
||
1037 | 1037 | * RPC for managing job input files |
1038 | 1038 | */ |
1039 | 1039 | function boincwork_job_file() { |
1040 | - include_boinc('user/job_file.php'); |
|
1040 | + include_boinc('user/job_file.php'); |
|
1041 | 1041 | } |
1042 | 1042 | |
1043 | 1043 | /** |
@@ -1045,7 +1045,7 @@ discard block |
||
1045 | 1045 | * Get output file from remote job submission |
1046 | 1046 | */ |
1047 | 1047 | function boincwork_get_output() { |
1048 | - include_boinc('user/get_output.php'); |
|
1048 | + include_boinc('user/get_output.php'); |
|
1049 | 1049 | } |
1050 | 1050 | |
1051 | 1051 | /** |
@@ -1053,28 +1053,28 @@ discard block |
||
1053 | 1053 | * Get the project configuration XML; used by client software |
1054 | 1054 | */ |
1055 | 1055 | function boincwork_get_project_config() { |
1056 | - ob_start(); |
|
1057 | - include_boinc('user/get_project_config.php'); |
|
1058 | - $xml = ob_get_clean(); |
|
1059 | - $xml = load_configuration($xml); |
|
1060 | - |
|
1061 | - // obtain Drupal variables |
|
1062 | - $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
1063 | - $overrideboinctou = variable_get('boinc_weboptions_overrideboinctou', FALSE); |
|
1064 | - |
|
1065 | - // If terms of use string exists and override is true, set terms-of-use |
|
1066 | - // to Drupal varaible. |
|
1067 | - if ( (!empty($termsofuse) && ($overrideboinctou)) ) { |
|
1056 | + ob_start(); |
|
1057 | + include_boinc('user/get_project_config.php'); |
|
1058 | + $xml = ob_get_clean(); |
|
1059 | + $xml = load_configuration($xml); |
|
1060 | + |
|
1061 | + // obtain Drupal variables |
|
1062 | + $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
1063 | + $overrideboinctou = variable_get('boinc_weboptions_overrideboinctou', FALSE); |
|
1064 | + |
|
1065 | + // If terms of use string exists and override is true, set terms-of-use |
|
1066 | + // to Drupal varaible. |
|
1067 | + if ( (!empty($termsofuse) && ($overrideboinctou)) ) { |
|
1068 | 1068 | if (!empty($xml['project_config']['terms_of_use'])) { |
1069 | - // Remove any existing terms of use |
|
1070 | - unset($xml['project_config']['terms_of_use']); |
|
1069 | + // Remove any existing terms of use |
|
1070 | + unset($xml['project_config']['terms_of_use']); |
|
1071 | 1071 | } |
1072 | 1072 | |
1073 | 1073 | // Add terms of use from Drupal |
1074 | 1074 | $xml['project_config']['terms_of_use']['@value'] = $termsofuse; |
1075 | - } |
|
1075 | + } |
|
1076 | 1076 | |
1077 | - print save_configuration($xml); |
|
1077 | + print save_configuration($xml); |
|
1078 | 1078 | } |
1079 | 1079 | |
1080 | 1080 | |
@@ -1082,16 +1082,16 @@ discard block |
||
1082 | 1082 | * Page callback for the remote job submission RPC (submit_rpc_handler.php). |
1083 | 1083 | */ |
1084 | 1084 | function boincwork_submit_rpc_handler() { |
1085 | - include_boinc('user/submit_rpc_handler.php'); |
|
1085 | + include_boinc('user/submit_rpc_handler.php'); |
|
1086 | 1086 | } |
1087 | 1087 | |
1088 | 1088 | /** |
1089 | 1089 | * Page callback for user WAP (userw.php). |
1090 | 1090 | */ |
1091 | 1091 | function boincwork_user_wap() { |
1092 | - // Remove q from the GET request or BOINC will panic |
|
1093 | - unset($_GET['q']); |
|
1094 | - include_boinc('user/userw.php'); |
|
1092 | + // Remove q from the GET request or BOINC will panic |
|
1093 | + unset($_GET['q']); |
|
1094 | + include_boinc('user/userw.php'); |
|
1095 | 1095 | } |
1096 | 1096 | |
1097 | 1097 | |
@@ -1099,44 +1099,44 @@ discard block |
||
1099 | 1099 | * Page callback for user account task table |
1100 | 1100 | */ |
1101 | 1101 | function boincwork_account_task_table($tselect = NULL, $app_id = NULL) { |
1102 | - $title = bts('Tasks for your account', array(), NULL, 'boinc:account-task-table'); |
|
1103 | - drupal_set_title($title); |
|
1102 | + $title = bts('Tasks for your account', array(), NULL, 'boinc:account-task-table'); |
|
1103 | + drupal_set_title($title); |
|
1104 | 1104 | |
1105 | - global $user; |
|
1106 | - $account = user_load($user->uid); |
|
1107 | - return boincwork_tasktable(0, $account->boincuser_id, $tselect, $app_id); |
|
1105 | + global $user; |
|
1106 | + $account = user_load($user->uid); |
|
1107 | + return boincwork_tasktable(0, $account->boincuser_id, $tselect, $app_id); |
|
1108 | 1108 | } |
1109 | 1109 | |
1110 | 1110 | /** |
1111 | 1111 | * Page callback for host task table |
1112 | 1112 | */ |
1113 | 1113 | function boincwork_host_task_table($host_id = NULL, $tselect = NULL, $app_id = NULL) { |
1114 | - require_boinc( array('util', 'result') ); |
|
1114 | + require_boinc( array('util', 'result') ); |
|
1115 | 1115 | |
1116 | - $title = bts('Tasks for computer @host_id', array('@host_id' => $host_id), NULL, 'boinc:host-task-table'); |
|
1117 | - drupal_set_title($title); |
|
1116 | + $title = bts('Tasks for computer @host_id', array('@host_id' => $host_id), NULL, 'boinc:host-task-table'); |
|
1117 | + drupal_set_title($title); |
|
1118 | 1118 | |
1119 | - if (is_null($host_id)) { |
|
1119 | + if (is_null($host_id)) { |
|
1120 | 1120 | drupal_set_message(bts('ERROR: Invalid host ID', array(), NULL, 'boinc:host-task-table'), 'error'); |
1121 | 1121 | return ''; |
1122 | - } |
|
1122 | + } |
|
1123 | 1123 | |
1124 | - return boincwork_tasktable(2, $host_id, $tselect, $app_id); |
|
1124 | + return boincwork_tasktable(2, $host_id, $tselect, $app_id); |
|
1125 | 1125 | } |
1126 | 1126 | |
1127 | 1127 | /** |
1128 | 1128 | * Page callback for workunit task table |
1129 | 1129 | */ |
1130 | 1130 | function boincwork_workunit_task_table($workunit_id = NULL, $tselect = NULL, $app_id = NULL) { |
1131 | - $title = bts('Tasks for workunit @workunit_id', array('@workunit_id' => $workunit_id), NULL, 'boinc:workunit-task-table'); |
|
1132 | - drupal_set_title($title); |
|
1131 | + $title = bts('Tasks for workunit @workunit_id', array('@workunit_id' => $workunit_id), NULL, 'boinc:workunit-task-table'); |
|
1132 | + drupal_set_title($title); |
|
1133 | 1133 | |
1134 | - if (is_null($workunit_id)) { |
|
1134 | + if (is_null($workunit_id)) { |
|
1135 | 1135 | drupal_set_message(bts('ERROR: Invalid workunit ID', array(), NULL, 'boinc:workunit-task-table'), 'error'); |
1136 | 1136 | return ''; |
1137 | - } |
|
1137 | + } |
|
1138 | 1138 | |
1139 | - return boincwork_tasktable(1, $workunit_id, $tselect, $app_id); |
|
1139 | + return boincwork_tasktable(1, $workunit_id, $tselect, $app_id); |
|
1140 | 1140 | } |
1141 | 1141 | |
1142 | 1142 | /** |
@@ -1144,8 +1144,8 @@ discard block |
||
1144 | 1144 | * Take a node ID and render that node as a page |
1145 | 1145 | */ |
1146 | 1146 | function boincwork_view_page($nid) { |
1147 | - $node = node_load($nid); |
|
1148 | - return node_page_view($node); |
|
1147 | + $node = node_load($nid); |
|
1148 | + return node_page_view($node); |
|
1149 | 1149 | } |
1150 | 1150 | |
1151 | 1151 | |
@@ -1157,16 +1157,16 @@ discard block |
||
1157 | 1157 | * Determine which venue should be selected |
1158 | 1158 | */ |
1159 | 1159 | function boincwork_select_venue(&$venue) { |
1160 | - if (!$venue) { |
|
1160 | + if (!$venue) { |
|
1161 | 1161 | $active_venue = isset($_SESSION['prefs venue']) ? $_SESSION['prefs venue'] : NULL; |
1162 | 1162 | if ($active_venue) { |
1163 | - $venue = $active_venue; |
|
1164 | - //unset($_SESSION['prefs venue']); |
|
1163 | + $venue = $active_venue; |
|
1164 | + //unset($_SESSION['prefs venue']); |
|
1165 | + } |
|
1165 | 1166 | } |
1166 | - } |
|
1167 | - else { |
|
1167 | + else { |
|
1168 | 1168 | // Set the active venue to keep it selected between computing and project |
1169 | 1169 | // preference pages |
1170 | 1170 | $_SESSION['prefs venue'] = $venue; |
1171 | - } |
|
1171 | + } |
|
1172 | 1172 | } |