@@ -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 | } |
@@ -42,8 +42,7 @@ |
||
42 | 42 | if (is_array($element)) { |
43 | 43 | show($element); |
44 | 44 | return drupal_render($element); |
45 | - } |
|
46 | - else { |
|
45 | + } else { |
|
47 | 46 | // Safe-guard for inappropriate use of render() on flat variables: return |
48 | 47 | // the variable as-is. |
49 | 48 | return $element; |
@@ -131,8 +131,7 @@ discard block |
||
131 | 131 | if ($comment->uid == 0 || strlen($comment->name) == 0) { |
132 | 132 | // @see user_validate_name(). !'0' === TRUE. |
133 | 133 | $comment_document->ss_name = '0'; |
134 | - } |
|
135 | - else { |
|
134 | + } else { |
|
136 | 135 | $comment_document->ss_name = $comment->name; |
137 | 136 | // We want the name to be searchable for keywords. |
138 | 137 | $comment_document->tos_name = $comment->name; |
@@ -318,8 +317,7 @@ discard block |
||
318 | 317 | $solr->deleteByQuery($query); |
319 | 318 | // Log the query used for deletion. |
320 | 319 | watchdog('Apache Solr', 'Deleted documents from index with query @query', array('@query' => $query), WATCHDOG_INFO); |
321 | - } |
|
322 | - catch (Exception $e) { |
|
320 | + } catch (Exception $e) { |
|
323 | 321 | watchdog('Apache Solr', nl2br(check_plain($e->getMessage())), NULL, WATCHDOG_ERROR); |
324 | 322 | return FALSE; |
325 | 323 | }// try |
@@ -376,8 +374,7 @@ discard block |
||
376 | 374 | $solr->deleteByQuery($query); |
377 | 375 | // Log the query used for deletion. |
378 | 376 | watchdog('Apache Solr', 'Deleted documents from index with query @query', array('@query' => $query), WATCHDOG_INFO); |
379 | - } |
|
380 | - catch (Exception $e) { |
|
377 | + } catch (Exception $e) { |
|
381 | 378 | watchdog('Apache Solr', nl2br(check_plain($e->getMessage())), NULL, WATCHDOG_ERROR); |
382 | 379 | return FALSE; |
383 | 380 | }// try |
@@ -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); |
|
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)) { |
|
87 | + } |
|
88 | + // Node information. |
|
89 | + $nid = $document->entity_id; |
|
90 | + $node = node_load($nid); |
|
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)) { |
|
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 | } |
@@ -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 | } |
@@ -220,8 +220,7 @@ discard block |
||
220 | 220 | if (!$values['boinc_translate_transifex_pass']) { |
221 | 221 | if (!variable_get('boinc_translate_transifex_pass', '')) { |
222 | 222 | form_set_error('boinc_translate_transifex_pass', t('Password is required.')); |
223 | - } |
|
224 | - else { |
|
223 | + } else { |
|
225 | 224 | unset($form_state['values']['boinc_translate_transifex_pass']); |
226 | 225 | } |
227 | 226 | } |
@@ -260,8 +259,7 @@ discard block |
||
260 | 259 | 'boinc_translate_transifex_pass', |
261 | 260 | t('Transifex authentication failed.') |
262 | 261 | ); |
263 | - } |
|
264 | - else { |
|
262 | + } else { |
|
265 | 263 | $authenticated = TRUE; |
266 | 264 | } |
267 | 265 | } |
@@ -278,14 +276,12 @@ discard block |
||
278 | 276 | ); |
279 | 277 | if ($project_name AND $project_resources) { |
280 | 278 | $transifex_resources[$project_name] = $project_resources; |
281 | - } |
|
282 | - elseif ($project_name AND !$project_resources) { |
|
279 | + } elseif ($project_name AND !$project_resources) { |
|
283 | 280 | drupal_set_message( |
284 | 281 | t('No project-specific resources were provided'), |
285 | 282 | 'warning' |
286 | 283 | ); |
287 | - } |
|
288 | - elseif ($project_resources AND !$project_name) { |
|
284 | + } elseif ($project_resources AND !$project_name) { |
|
289 | 285 | drupal_set_message( |
290 | 286 | t('No project-specific Transifex project name was provided'), |
291 | 287 | 'warning' |
@@ -7,85 +7,85 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | /** |
10 | - * The BOINC translation settings form allows configuration of BTS integration |
|
11 | - * (and other translation related settings) |
|
12 | - */ |
|
10 | + * The BOINC translation settings form allows configuration of BTS integration |
|
11 | + * (and other translation related settings) |
|
12 | + */ |
|
13 | 13 | function boinctranslate_admin_settings(&$form_state) { |
14 | - $form = array(); |
|
15 | - $initialized = FALSE; |
|
16 | - $import_enabled = FALSE; |
|
17 | - $default = array( |
|
14 | + $form = array(); |
|
15 | + $initialized = FALSE; |
|
16 | + $import_enabled = FALSE; |
|
17 | + $default = array( |
|
18 | 18 | 'transifex_user' => variable_get('boinc_translate_transifex_user', ''), |
19 | 19 | 'transifex_pass' => variable_get('boinc_translate_transifex_pass', ''), |
20 | 20 | 'transifex_boinc_name' => variable_get( |
21 | - 'boinc_translate_transifex_standard_name', 'boinc' |
|
21 | + 'boinc_translate_transifex_standard_name', 'boinc' |
|
22 | 22 | ), |
23 | 23 | 'transifex_boinc_resources' => variable_get( |
24 | - 'boinc_translate_transifex_standard_resources', |
|
25 | - "project-generic\nweb" |
|
24 | + 'boinc_translate_transifex_standard_resources', |
|
25 | + "project-generic\nweb" |
|
26 | 26 | ), |
27 | 27 | 'transifex_boinc_drupal_resource' => variable_get( |
28 | - 'boinc_translate_transifex_boinc_drupal_resource', |
|
29 | - 'drupal' |
|
28 | + 'boinc_translate_transifex_boinc_drupal_resource', |
|
29 | + 'drupal' |
|
30 | 30 | ), |
31 | 31 | 'transifex_project_name' => variable_get( |
32 | - 'boinc_translate_transifex_project_name', '' |
|
32 | + 'boinc_translate_transifex_project_name', '' |
|
33 | 33 | ), |
34 | 34 | 'transifex_project_resources' => variable_get( |
35 | - 'boinc_translate_transifex_project_resources', '' |
|
35 | + 'boinc_translate_transifex_project_resources', '' |
|
36 | 36 | ), |
37 | - ); |
|
37 | + ); |
|
38 | 38 | |
39 | - if ($default['transifex_user'] AND $default['transifex_pass']) { |
|
39 | + if ($default['transifex_user'] AND $default['transifex_pass']) { |
|
40 | 40 | if (trim($default['transifex_boinc_resources']) |
41 | 41 | OR trim($default['transifex_project_resources'])) { |
42 | - $import_enabled = TRUE; |
|
42 | + $import_enabled = TRUE; |
|
43 | 43 | } |
44 | 44 | if ($default['transifex_boinc_name'] |
45 | 45 | AND $default['transifex_project_name'] |
46 | 46 | AND trim($default['transifex_boinc_resources']) |
47 | 47 | AND trim($default['transifex_project_resources'])) { |
48 | - $initialized = TRUE; |
|
48 | + $initialized = TRUE; |
|
49 | + } |
|
49 | 50 | } |
50 | - } |
|
51 | 51 | |
52 | - // Define the form |
|
52 | + // Define the form |
|
53 | 53 | |
54 | - $form['transifex'] = array( |
|
54 | + $form['transifex'] = array( |
|
55 | 55 | '#title' => t('Transifex settings'), |
56 | 56 | '#type' => 'fieldset', |
57 | 57 | '#description' => '', |
58 | 58 | '#collapsible' => TRUE, |
59 | 59 | '#collapsed' => $initialized, |
60 | 60 | '#attributes' => array('class' => '') |
61 | - ); |
|
62 | - $form['transifex']['boinc_translate_transifex_user'] = array( |
|
61 | + ); |
|
62 | + $form['transifex']['boinc_translate_transifex_user'] = array( |
|
63 | 63 | '#type' => 'textfield', |
64 | 64 | '#title' => t('User name'), |
65 | 65 | '#default_value' => $default['transifex_user'], |
66 | - ); |
|
67 | - $form['transifex']['boinc_translate_transifex_pass'] = array( |
|
66 | + ); |
|
67 | + $form['transifex']['boinc_translate_transifex_pass'] = array( |
|
68 | 68 | '#type' => 'password', |
69 | 69 | '#title' => t('Password'), |
70 | 70 | '#attributes' => array( |
71 | - 'placeholder' => $default['transifex_pass'] ? '********' : '', |
|
71 | + 'placeholder' => $default['transifex_pass'] ? '********' : '', |
|
72 | 72 | ), |
73 | - ); |
|
74 | - $form['transifex']['boinc_translate_transifex_standard_name'] = array( |
|
73 | + ); |
|
74 | + $form['transifex']['boinc_translate_transifex_standard_name'] = array( |
|
75 | 75 | '#type' => 'textfield', |
76 | 76 | '#title' => t('BOINC Transifex project'), |
77 | 77 | '#default_value' => $default['transifex_boinc_name'], |
78 | 78 | '#description' => t('The portion of the Transifex URL that identifies BOINC.'), |
79 | - ); |
|
80 | - $form['transifex']['boinc_translate_transifex_boinc_drupal_resource'] = array( |
|
79 | + ); |
|
80 | + $form['transifex']['boinc_translate_transifex_boinc_drupal_resource'] = array( |
|
81 | 81 | '#type' => 'textfield', |
82 | 82 | '#title' => t('Official BOINC Drupal Resource'), |
83 | 83 | '#default_value' => $default['transifex_boinc_drupal_resource'], |
84 | 84 | '#description' => t('The portion of the Transifex URL that identifies |
85 | 85 | the standard BOINC Resource to use for translation of the public |
86 | 86 | content defined in the Drupal system.'), |
87 | - ); |
|
88 | - $form['transifex']['boinc_translate_transifex_standard_resources'] = array( |
|
87 | + ); |
|
88 | + $form['transifex']['boinc_translate_transifex_standard_resources'] = array( |
|
89 | 89 | '#type' => 'textarea', |
90 | 90 | '#title' => t('Additional BOINC Resources'), |
91 | 91 | '#default_value' => $default['transifex_boinc_resources'], |
@@ -96,14 +96,14 @@ discard block |
||
96 | 96 | by any matching translations found in Resources further down the list. |
97 | 97 | Note that strings from the Official BOINC Drupal Resource will override |
98 | 98 | any strings from these additional Resources.'), |
99 | - ); |
|
100 | - $form['transifex']['boinc_translate_transifex_project_name'] = array( |
|
99 | + ); |
|
100 | + $form['transifex']['boinc_translate_transifex_project_name'] = array( |
|
101 | 101 | '#type' => 'textfield', |
102 | 102 | '#title' => t('Project-specific Transifex project'), |
103 | 103 | '#default_value' => $default['transifex_project_name'], |
104 | 104 | '#description' => t('The portion of the Transifex URL that identifies this project.'), |
105 | - ); |
|
106 | - $form['transifex']['boinc_translate_transifex_project_resources'] = array( |
|
105 | + ); |
|
106 | + $form['transifex']['boinc_translate_transifex_project_resources'] = array( |
|
107 | 107 | '#type' => 'textarea', |
108 | 108 | '#title' => t('Project-specific Resources'), |
109 | 109 | '#default_value' => $default['transifex_project_resources'], |
@@ -116,241 +116,241 @@ discard block |
||
116 | 116 | NOTE: The first Resource listed here is considered the primary Resource |
117 | 117 | for project-specific translations and will be updated by the "Update |
118 | 118 | project-specific Resources" button below!'), |
119 | - ); |
|
120 | - $form['transifex']['buttons']['submit'] = array( |
|
119 | + ); |
|
120 | + $form['transifex']['buttons']['submit'] = array( |
|
121 | 121 | '#type' => 'submit', |
122 | 122 | '#value' => t('Save configuration'), |
123 | - ); |
|
123 | + ); |
|
124 | 124 | |
125 | - $form['tools'] = array( |
|
125 | + $form['tools'] = array( |
|
126 | 126 | '#title' => t('Tools'), |
127 | 127 | '#type' => 'fieldset', |
128 | 128 | '#description' => '', |
129 | 129 | '#collapsible' => TRUE, |
130 | 130 | '#collapsed' => FALSE, |
131 | 131 | '#attributes' => array('class' => '') |
132 | - ); |
|
133 | - $form['tools']['initialize_languages_text'] = array( |
|
132 | + ); |
|
133 | + $form['tools']['initialize_languages_text'] = array( |
|
134 | 134 | '#type' => 'item', |
135 | 135 | '#title' => t('Install official BOINC languages'), |
136 | 136 | '#value' => t('Installs all languages from the BOINC Transifex project. Also installs missing languages in Drupal. <br>Languages must be enabled manually in Administer > Site configuration > Languages.'), |
137 | - ); |
|
138 | - $form['tools']['initialize_languages'] = array( |
|
137 | + ); |
|
138 | + $form['tools']['initialize_languages'] = array( |
|
139 | 139 | '#type' => 'button', |
140 | 140 | '#value' => t('Install official BOINC languages'), |
141 | 141 | '#executes_submit_callback' => TRUE, |
142 | 142 | '#submit' => array('boinctranslate_admin_settings_initialize_languages'), |
143 | 143 | '#disabled' => !$initialized, |
144 | - ); |
|
145 | - $form['tools']['import_now_text'] = array( |
|
144 | + ); |
|
145 | + $form['tools']['import_now_text'] = array( |
|
146 | 146 | '#type' => 'item', |
147 | 147 | '#title' => t('Import all translations'), |
148 | 148 | '#value' => t('Imports from Tranifex all configured Resources into their respective text groups.'), |
149 | - ); |
|
150 | - $form['tools']['import_now'] = array( |
|
149 | + ); |
|
150 | + $form['tools']['import_now'] = array( |
|
151 | 151 | '#type' => 'button', |
152 | 152 | '#value' => t('Import all translations'), |
153 | 153 | '#executes_submit_callback' => TRUE, |
154 | 154 | '#submit' => array('boinctranslate_admin_settings_import_now'), |
155 | 155 | '#disabled' => !$import_enabled, |
156 | - ); |
|
157 | - $form['tools']['download_boinc_pot_text'] = array( |
|
156 | + ); |
|
157 | + $form['tools']['download_boinc_pot_text'] = array( |
|
158 | 158 | '#type' => 'item', |
159 | 159 | '#title' => t('Download official BOINC-Drupal .pot'), |
160 | 160 | '#value' => t('Downloads the generic BOINC-Drupal .pot file. This is the template file for the boinc text group.'), |
161 | - ); |
|
162 | - $form['tools']['download_boinc_pot'] = array( |
|
161 | + ); |
|
162 | + $form['tools']['download_boinc_pot'] = array( |
|
163 | 163 | '#type' => 'button', |
164 | 164 | '#value' => t('Download official BOINC-Drupal .pot'), |
165 | 165 | '#executes_submit_callback' => TRUE, |
166 | 166 | '#submit' => array('boinctranslate_admin_settings_download_boinc_pot'), |
167 | 167 | '#disabled' => !$import_enabled, |
168 | - ); |
|
169 | - $form['tools']['download_project_pot_text'] = array( |
|
168 | + ); |
|
169 | + $form['tools']['download_project_pot_text'] = array( |
|
170 | 170 | '#type' => 'item', |
171 | 171 | '#title' => t('Download project-specific .pot'), |
172 | 172 | '#value' => t('Downloads the project-specific .pot file. This is the template file for the project text group.'), |
173 | - ); |
|
174 | - $form['tools']['download_project_pot'] = array( |
|
173 | + ); |
|
174 | + $form['tools']['download_project_pot'] = array( |
|
175 | 175 | '#type' => 'button', |
176 | 176 | '#value' => t('Download project-specific .pot'), |
177 | 177 | '#executes_submit_callback' => TRUE, |
178 | 178 | '#submit' => array('boinctranslate_admin_settings_download_project_pot'), |
179 | 179 | '#disabled' => !$import_enabled, |
180 | - ); |
|
181 | - if (user_access('update official BOINC translations')) { |
|
180 | + ); |
|
181 | + if (user_access('update official BOINC translations')) { |
|
182 | 182 | $form['tools']['update_official_boinc_text'] = array( |
183 | - '#type' => 'item', |
|
184 | - '#title' => t('Update official BOINC translations'), |
|
185 | - '#value' => t('Updates the official BOINC-Drupal Resource (translatable strings templates) to the BOINC Transifex project, based on the consolidated imported translations.<br><b>WARNING: Do not use unless you have write-access to the BOINC Transifex project.</b>'), |
|
183 | + '#type' => 'item', |
|
184 | + '#title' => t('Update official BOINC translations'), |
|
185 | + '#value' => t('Updates the official BOINC-Drupal Resource (translatable strings templates) to the BOINC Transifex project, based on the consolidated imported translations.<br><b>WARNING: Do not use unless you have write-access to the BOINC Transifex project.</b>'), |
|
186 | 186 | ); |
187 | 187 | $form['tools']['update_official_boinc'] = array( |
188 | - '#type' => 'button', |
|
189 | - '#value' => t('Update official BOINC translations'), |
|
190 | - '#executes_submit_callback' => TRUE, |
|
191 | - '#submit' => array('boinctranslate_admin_settings_update_official_boinc'), |
|
192 | - '#disabled' => !$import_enabled, |
|
188 | + '#type' => 'button', |
|
189 | + '#value' => t('Update official BOINC translations'), |
|
190 | + '#executes_submit_callback' => TRUE, |
|
191 | + '#submit' => array('boinctranslate_admin_settings_update_official_boinc'), |
|
192 | + '#disabled' => !$import_enabled, |
|
193 | 193 | ); |
194 | - } |
|
195 | - $form['tools']['export_now_text'] = array( |
|
194 | + } |
|
195 | + $form['tools']['export_now_text'] = array( |
|
196 | 196 | '#type' => 'item', |
197 | 197 | '#title' => t('Update project-specific Resources'), |
198 | 198 | '#value' => t('Updates the configured Resources (translatable strings templates) to the project\'s Transifex project.<br><b>WARNING: Do not use unless you have write-access to your project\'s Transifex project.</b>'), |
199 | - ); |
|
200 | - $form['tools']['export_now'] = array( |
|
199 | + ); |
|
200 | + $form['tools']['export_now'] = array( |
|
201 | 201 | '#type' => 'button', |
202 | 202 | '#value' => t('Update project-specific Resources'), |
203 | 203 | '#executes_submit_callback' => TRUE, |
204 | 204 | '#submit' => array('boinctranslate_admin_settings_export_now'), |
205 | 205 | '#disabled' => !$import_enabled, |
206 | - ); |
|
206 | + ); |
|
207 | 207 | |
208 | - $form['#submit'][] = 'system_settings_form_submit'; |
|
209 | - $form['#theme'] = 'system_settings_form'; |
|
208 | + $form['#submit'][] = 'system_settings_form_submit'; |
|
209 | + $form['#theme'] = 'system_settings_form'; |
|
210 | 210 | |
211 | - return $form; |
|
211 | + return $form; |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | function boinctranslate_admin_settings_export_now() { |
215 | - drupal_goto('admin/boinc/translation/export'); |
|
215 | + drupal_goto('admin/boinc/translation/export'); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | function boinctranslate_admin_settings_import_now() { |
219 | - drupal_goto('admin/boinc/translation/import'); |
|
219 | + drupal_goto('admin/boinc/translation/import'); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | function boinctranslate_admin_settings_initialize_languages() { |
223 | - drupal_goto('admin/boinc/translation/initialize-languages'); |
|
223 | + drupal_goto('admin/boinc/translation/initialize-languages'); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | function boinctranslate_admin_settings_update_official_boinc() { |
227 | - drupal_goto('admin/boinc/translation/update-official-boinc'); |
|
227 | + drupal_goto('admin/boinc/translation/update-official-boinc'); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | function boinctranslate_admin_settings_download_boinc_pot() { |
231 | - drupal_goto('admin/boinc/translation/download-pot/boinc'); |
|
231 | + drupal_goto('admin/boinc/translation/download-pot/boinc'); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | function boinctranslate_admin_settings_download_project_pot() { |
235 | - drupal_goto('admin/boinc/translation/download-pot/project'); |
|
235 | + drupal_goto('admin/boinc/translation/download-pot/project'); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | |
239 | 239 | /** |
240 | - * Validate the BOINC translation settings form. |
|
241 | - */ |
|
240 | + * Validate the BOINC translation settings form. |
|
241 | + */ |
|
242 | 242 | function boinctranslate_admin_settings_validate($form, &$form_state) { |
243 | - $values = $form_state['values']; |
|
244 | - $errors = array(); |
|
245 | - $api_base_url = 'https://www.transifex.com/api/2'; |
|
243 | + $values = $form_state['values']; |
|
244 | + $errors = array(); |
|
245 | + $api_base_url = 'https://www.transifex.com/api/2'; |
|
246 | 246 | |
247 | - if (!$values['boinc_translate_transifex_user']) { |
|
247 | + if (!$values['boinc_translate_transifex_user']) { |
|
248 | 248 | form_set_error('boinc_translate_transifex_user', t('User name is required.')); |
249 | - } |
|
250 | - if (!$values['boinc_translate_transifex_pass']) { |
|
249 | + } |
|
250 | + if (!$values['boinc_translate_transifex_pass']) { |
|
251 | 251 | if (!variable_get('boinc_translate_transifex_pass', '')) { |
252 | - form_set_error('boinc_translate_transifex_pass', t('Password is required.')); |
|
252 | + form_set_error('boinc_translate_transifex_pass', t('Password is required.')); |
|
253 | 253 | } |
254 | 254 | else { |
255 | - unset($form_state['values']['boinc_translate_transifex_pass']); |
|
255 | + unset($form_state['values']['boinc_translate_transifex_pass']); |
|
256 | + } |
|
256 | 257 | } |
257 | - } |
|
258 | - if (!$values['boinc_translate_transifex_standard_name']) { |
|
258 | + if (!$values['boinc_translate_transifex_standard_name']) { |
|
259 | 259 | form_set_error('boinc_translate_transifex_standard_name', |
260 | - t('BOINC Transifex project name is required.') |
|
260 | + t('BOINC Transifex project name is required.') |
|
261 | 261 | ); |
262 | - } |
|
263 | - if (!$values['boinc_translate_transifex_standard_resources']) { |
|
262 | + } |
|
263 | + if (!$values['boinc_translate_transifex_standard_resources']) { |
|
264 | 264 | form_set_error('boinc_translate_transifex_standard_resources', |
265 | - t('At least one BOINC Transifex project Resource is required.') |
|
265 | + t('At least one BOINC Transifex project Resource is required.') |
|
266 | 266 | ); |
267 | - } |
|
268 | - if (!$values['boinc_translate_transifex_project_resources']) { |
|
267 | + } |
|
268 | + if (!$values['boinc_translate_transifex_project_resources']) { |
|
269 | 269 | form_set_error('boinc_translate_transifex_project_resources', |
270 | - t('At least one project-specific Transifex Resource is required.') |
|
270 | + t('At least one project-specific Transifex Resource is required.') |
|
271 | 271 | ); |
272 | - } |
|
272 | + } |
|
273 | 273 | |
274 | - $username = $values['boinc_translate_transifex_user']; |
|
275 | - $password = ($values['boinc_translate_transifex_pass']) ? $values['boinc_translate_transifex_pass'] : variable_get('boinc_translate_transifex_pass', ''); |
|
276 | - $boinc_name = $values['boinc_translate_transifex_standard_name']; |
|
277 | - $boinc_resources = boinctranslate_parse_resources( |
|
274 | + $username = $values['boinc_translate_transifex_user']; |
|
275 | + $password = ($values['boinc_translate_transifex_pass']) ? $values['boinc_translate_transifex_pass'] : variable_get('boinc_translate_transifex_pass', ''); |
|
276 | + $boinc_name = $values['boinc_translate_transifex_standard_name']; |
|
277 | + $boinc_resources = boinctranslate_parse_resources( |
|
278 | 278 | $values['boinc_translate_transifex_standard_resources'] |
279 | - ); |
|
279 | + ); |
|
280 | 280 | |
281 | - if ($username AND $password AND $boinc_name AND $boinc_resources) { |
|
281 | + if ($username AND $password AND $boinc_name AND $boinc_resources) { |
|
282 | 282 | // Test authentication |
283 | 283 | $authenticated = FALSE; |
284 | 284 | $path = "project/{$boinc_name}/resource/{$boinc_resources[0]}/translation/en"; |
285 | 285 | $response = boinctranslate_transifex_request($path, NULL, TRUE, FALSE, $username, $password); |
286 | 286 | |
287 | 287 | if ($response) { |
288 | - if ($response == '401 UNAUTHORIZED') { |
|
288 | + if ($response == '401 UNAUTHORIZED') { |
|
289 | 289 | form_set_error( |
290 | - 'boinc_translate_transifex_pass', |
|
291 | - t('Transifex authentication failed.') |
|
290 | + 'boinc_translate_transifex_pass', |
|
291 | + t('Transifex authentication failed.') |
|
292 | 292 | ); |
293 | - } |
|
294 | - else { |
|
293 | + } |
|
294 | + else { |
|
295 | 295 | $authenticated = TRUE; |
296 | - } |
|
296 | + } |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | if ($authenticated) { |
300 | - // Prepare list of resources to validate |
|
301 | - $transifex_resources = array( |
|
300 | + // Prepare list of resources to validate |
|
301 | + $transifex_resources = array( |
|
302 | 302 | 'boinc' => $boinc_resources, |
303 | - ); |
|
304 | - // Parse project-specific resources |
|
305 | - $project_name = trim($values['boinc_translate_transifex_project_name']); |
|
306 | - $project_resources = boinctranslate_parse_resources( |
|
303 | + ); |
|
304 | + // Parse project-specific resources |
|
305 | + $project_name = trim($values['boinc_translate_transifex_project_name']); |
|
306 | + $project_resources = boinctranslate_parse_resources( |
|
307 | 307 | $values['boinc_translate_transifex_project_resources'] |
308 | - ); |
|
309 | - if ($project_name AND $project_resources) { |
|
308 | + ); |
|
309 | + if ($project_name AND $project_resources) { |
|
310 | 310 | $transifex_resources[$project_name] = $project_resources; |
311 | - } |
|
312 | - elseif ($project_name AND !$project_resources) { |
|
311 | + } |
|
312 | + elseif ($project_name AND !$project_resources) { |
|
313 | 313 | drupal_set_message( |
314 | - t('No project-specific resources were provided'), |
|
315 | - 'warning' |
|
314 | + t('No project-specific resources were provided'), |
|
315 | + 'warning' |
|
316 | 316 | ); |
317 | - } |
|
318 | - elseif ($project_resources AND !$project_name) { |
|
317 | + } |
|
318 | + elseif ($project_resources AND !$project_name) { |
|
319 | 319 | drupal_set_message( |
320 | - t('No project-specific Transifex project name was provided'), |
|
321 | - 'warning' |
|
320 | + t('No project-specific Transifex project name was provided'), |
|
321 | + 'warning' |
|
322 | 322 | ); |
323 | - } |
|
323 | + } |
|
324 | 324 | |
325 | - // Try to access the given resources |
|
326 | - foreach ($transifex_resources as $project => $resources) { |
|
325 | + // Try to access the given resources |
|
326 | + foreach ($transifex_resources as $project => $resources) { |
|
327 | 327 | foreach ($resources as $resource) { |
328 | 328 | |
329 | - $path = "project/{$project}/resource/{$resource}/translation/en"; |
|
330 | - $response = boinctranslate_transifex_request($path); |
|
329 | + $path = "project/{$project}/resource/{$resource}/translation/en"; |
|
330 | + $response = boinctranslate_transifex_request($path); |
|
331 | 331 | |
332 | - if ($response == '404 NOT FOUND') { |
|
332 | + if ($response == '404 NOT FOUND') { |
|
333 | 333 | form_set_error( |
334 | - 'boinc_translate_transifex_' . ($project == $boinc_name ? 'standard' : 'project') . '_resources', |
|
335 | - t('Resource %name not found in %project.', |
|
334 | + 'boinc_translate_transifex_' . ($project == $boinc_name ? 'standard' : 'project') . '_resources', |
|
335 | + t('Resource %name not found in %project.', |
|
336 | 336 | array( |
337 | - '%name' => $resource, |
|
338 | - '%project' => $project, |
|
337 | + '%name' => $resource, |
|
338 | + '%project' => $project, |
|
339 | + ) |
|
339 | 340 | ) |
340 | - ) |
|
341 | 341 | ); |
342 | - } |
|
342 | + } |
|
343 | 343 | } |
344 | - } |
|
344 | + } |
|
345 | + } |
|
345 | 346 | } |
346 | - } |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | /** |
350 | - * Handle post-validation submission of BOINC translation settings form. |
|
351 | - */ |
|
350 | + * Handle post-validation submission of BOINC translation settings form. |
|
351 | + */ |
|
352 | 352 | function boinctranslate_admin_settings_submit($form, &$form_state) { |
353 | - drupal_set_message(t('BOINC translation settings have been updated.')); |
|
353 | + drupal_set_message(t('BOINC translation settings have been updated.')); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 |
@@ -157,13 +157,11 @@ discard block |
||
157 | 157 | if (!$values['boinc_root_dir']) { |
158 | 158 | form_set_error('boinc_root_dir', t('BOINC project root directory must be |
159 | 159 | defined!')); |
160 | - } |
|
161 | - elseif (!is_dir($values['boinc_root_dir'])) { |
|
160 | + } elseif (!is_dir($values['boinc_root_dir'])) { |
|
162 | 161 | form_set_error('boinc_root_dir', t('BOINC project root not found at %directory', |
163 | 162 | array('%directory' => $values['boinc_root_dir']) |
164 | 163 | )); |
165 | - } |
|
166 | - else { |
|
164 | + } else { |
|
167 | 165 | // By default, try to automatically set specific directories from the root |
168 | 166 | if (!$values['boinc_config_xml_dir']) { |
169 | 167 | $values['boinc_config_xml_dir'] = $values['boinc_root_dir']; |
@@ -285,8 +283,7 @@ discard block |
||
285 | 283 | if (!$values['boinc_scheduler_urls']) { |
286 | 284 | form_set_error('boinc_scheduler_urls', t('At least one scheduling server |
287 | 285 | URL must be specified.')); |
288 | - } |
|
289 | - else { |
|
286 | + } else { |
|
290 | 287 | $urls = explode("\r\n", $values['boinc_scheduler_urls']); |
291 | 288 | foreach ($urls as $key => $url) { |
292 | 289 | if (!$url) { |
@@ -28,13 +28,13 @@ discard block |
||
28 | 28 | }*/ |
29 | 29 | |
30 | 30 | /** |
31 | - * The BOINC environment form allows paths to be set to connect Drupal to an |
|
32 | - * existing BOINC web interface. |
|
33 | - */ |
|
31 | + * The BOINC environment form allows paths to be set to connect Drupal to an |
|
32 | + * existing BOINC web interface. |
|
33 | + */ |
|
34 | 34 | function boincuser_admin_environment(&$form_state) { |
35 | - global $base_url; |
|
36 | - $form = array(); |
|
37 | - $default = array( |
|
35 | + global $base_url; |
|
36 | + $form = array(); |
|
37 | + $default = array( |
|
38 | 38 | 'boinc_root_dir' => variable_get('boinc_root_dir', ''), |
39 | 39 | 'boinc_config_xml_dir' => variable_get('boinc_config_xml_dir', ''), |
40 | 40 | 'boinc_html_inc_dir' => variable_get('boinc_html_inc_dir', ''), |
@@ -47,303 +47,303 @@ discard block |
||
47 | 47 | 'boinc_admin_mailing_list_subject_tag' => variable_get('boinc_admin_mailing_list_subject_tag', ''), |
48 | 48 | 'boinc_debug_mode' => variable_get('boinc_debug_mode', 0), |
49 | 49 | 'boinc_project_config_keywords' => variable_get('boinc_project_config_keywords', ''), |
50 | - ); |
|
51 | - //drupal_set_message(print_r($default, true)); |
|
52 | - //drupal_set_message(print_r($form_state, true)); |
|
53 | - // Show overrides if the root dir is set and others have not been detected |
|
54 | - $show_overrides = FALSE; |
|
55 | - if ($default['boinc_root_dir']) { |
|
50 | + ); |
|
51 | + //drupal_set_message(print_r($default, true)); |
|
52 | + //drupal_set_message(print_r($form_state, true)); |
|
53 | + // Show overrides if the root dir is set and others have not been detected |
|
54 | + $show_overrides = FALSE; |
|
55 | + if ($default['boinc_root_dir']) { |
|
56 | 56 | foreach ($default as $key => $dir) { |
57 | - switch ($key) { |
|
58 | - case 'boinc_config_xml_dir': |
|
57 | + switch ($key) { |
|
58 | + case 'boinc_config_xml_dir': |
|
59 | 59 | case 'boinc_html_inc_dir': |
60 | 60 | case 'boinc_project_config_dir': |
61 | 61 | case 'boinc_user_image_dir': |
62 | 62 | // If any of these values are not set, show the overrides section |
63 | 63 | if (!$dir) { |
64 | - $default[$key] = $form_state['values'][$key]; |
|
65 | - $show_overrides = TRUE; |
|
66 | - break; |
|
64 | + $default[$key] = $form_state['values'][$key]; |
|
65 | + $show_overrides = TRUE; |
|
66 | + break; |
|
67 | 67 | } |
68 | 68 | break; |
69 | - default: |
|
69 | + default: |
|
70 | 70 | } |
71 | - if ($show_overrides) { |
|
71 | + if ($show_overrides) { |
|
72 | 72 | break; |
73 | - } |
|
73 | + } |
|
74 | + } |
|
74 | 75 | } |
75 | - } |
|
76 | - // Define the form |
|
77 | - $form['boinc_root_dir'] = array( |
|
76 | + // Define the form |
|
77 | + $form['boinc_root_dir'] = array( |
|
78 | 78 | '#type' => 'textfield', |
79 | 79 | '#title' => t('BOINC project root directory'), |
80 | 80 | '#default_value' => $default['boinc_root_dir'], |
81 | 81 | '#description' => t('The filesystem path to the BOINC project root. This |
82 | 82 | directory should contain config.xml as well as the html subdirectory, |
83 | 83 | which itself contains inc/, project/, and user_profile/.'), |
84 | - ); |
|
85 | - $form['overrides'] = array( |
|
84 | + ); |
|
85 | + $form['overrides'] = array( |
|
86 | 86 | '#title' => t('Overrides'), |
87 | 87 | '#type' => 'fieldset', |
88 | 88 | '#description' => '', |
89 | 89 | '#collapsible' => TRUE, |
90 | 90 | '#collapsed' => !$show_overrides, |
91 | 91 | '#attributes' => array('class' => 'advanced-settings') |
92 | - ); |
|
93 | - $form['overrides']['boinc_config_xml_dir'] = array( |
|
92 | + ); |
|
93 | + $form['overrides']['boinc_config_xml_dir'] = array( |
|
94 | 94 | '#type' => 'textfield', |
95 | 95 | '#title' => t('BOINC config.xml directory'), |
96 | 96 | '#default_value' => $default['boinc_config_xml_dir'], |
97 | 97 | '#description' => t('The filesystem path that contains config.xml'), |
98 | - ); |
|
99 | - $form['overrides']['boinc_html_inc_dir'] = array( |
|
98 | + ); |
|
99 | + $form['overrides']['boinc_html_inc_dir'] = array( |
|
100 | 100 | '#type' => 'textfield', |
101 | 101 | '#title' => t('BOINC web includes directory'), |
102 | 102 | '#default_value' => $default['boinc_html_inc_dir'], |
103 | 103 | '#description' => t('The filesystem path to the html/inc/ directory that |
104 | 104 | contains util.inc'), |
105 | - ); |
|
106 | - $form['overrides']['boinc_project_config_dir'] = array( |
|
105 | + ); |
|
106 | + $form['overrides']['boinc_project_config_dir'] = array( |
|
107 | 107 | '#type' => 'textfield', |
108 | 108 | '#title' => t('BOINC project config directory'), |
109 | 109 | '#default_value' => $default['boinc_project_config_dir'], |
110 | 110 | '#description' => t('The filesystem path to the project/ directory that |
111 | 111 | contains project.inc'), |
112 | - ); |
|
113 | - $form['overrides']['boinc_user_image_dir'] = array( |
|
112 | + ); |
|
113 | + $form['overrides']['boinc_user_image_dir'] = array( |
|
114 | 114 | '#type' => 'textfield', |
115 | 115 | '#title' => t('BOINC user profile image directory'), |
116 | 116 | '#default_value' => $default['boinc_user_image_dir'], |
117 | 117 | '#description' => t('The filesystem directory that contains user images'), |
118 | - ); |
|
119 | - $form['boinc_server_status_url'] = array( |
|
118 | + ); |
|
119 | + $form['boinc_server_status_url'] = array( |
|
120 | 120 | '#type' => 'textfield', |
121 | 121 | '#title' => t('BOINC server status page URL (optional)'), |
122 | 122 | '#default_value' => $default['boinc_server_status_url'], |
123 | 123 | '#description' => t('An absolute URL or path relative to the site base to the server status page (e.g. %full_url or just %relative_url).', |
124 | - array( |
|
124 | + array( |
|
125 | 125 | '%full_url' => $base_url . '/server_status.php', |
126 | 126 | '%relative_url' => 'server_status.php', |
127 | - ) |
|
127 | + ) |
|
128 | 128 | ), |
129 | - ); |
|
130 | - $form['boinc_app_list_url'] = array( |
|
129 | + ); |
|
130 | + $form['boinc_app_list_url'] = array( |
|
131 | 131 | '#type' => 'textfield', |
132 | 132 | '#title' => t('BOINC applications page URL (optional)'), |
133 | 133 | '#default_value' => $default['boinc_app_list_url'], |
134 | 134 | '#description' => t('An absolute URL or path relative to the site base to the applications page (e.g. %full_url or just %relative_url).', |
135 | - array( |
|
135 | + array( |
|
136 | 136 | '%full_url' => $base_url . '/apps.php', |
137 | 137 | '%relative_url' => 'apps.php', |
138 | - ) |
|
138 | + ) |
|
139 | 139 | ), |
140 | - ); |
|
141 | - $form['boinc_host_sched_logs_dir'] = array( |
|
140 | + ); |
|
141 | + $form['boinc_host_sched_logs_dir'] = array( |
|
142 | 142 | '#type' => 'textfield', |
143 | 143 | '#title' => t('BOINC host scheduler log directory (optional)'), |
144 | 144 | '#default_value' => $default['boinc_host_sched_logs_dir'], |
145 | 145 | '#description' => t('The filesystem directory that contains host scheduler logs'), |
146 | - ); |
|
147 | - $form['boinc_admin_mailing_list'] = array( |
|
146 | + ); |
|
147 | + $form['boinc_admin_mailing_list'] = array( |
|
148 | 148 | '#type' => 'textfield', |
149 | 149 | '#title' => t('Admin mailing list'), |
150 | 150 | '#default_value' => $default['boinc_admin_mailing_list'], |
151 | 151 | '#description' => t('Enter an email-address which will be used to contact admisistrators. If empty, the site email configured in Settings -> Site Information will be used.'), |
152 | - ); |
|
153 | - $form['boinc_admin_mailing_list_subject_tag'] = array( |
|
152 | + ); |
|
153 | + $form['boinc_admin_mailing_list_subject_tag'] = array( |
|
154 | 154 | '#type' => 'textfield', |
155 | 155 | '#title' => t('Admin mailing list - subject tag'), |
156 | 156 | '#default_value' => $default['boinc_admin_mailing_list_subject_tag'], |
157 | 157 | '#description' => t('Text which will appear at the beginning of the subject for any admin notification emails. If empty, no tag will be included. Examples: [drupal-error].'), |
158 | - ); |
|
159 | - $form['boinc_debug_mode'] = array( |
|
158 | + ); |
|
159 | + $form['boinc_debug_mode'] = array( |
|
160 | 160 | '#type' => 'checkbox', |
161 | 161 | '#title' => t('Show debug messages in system log'), |
162 | 162 | '#default_value' => $default['boinc_debug_mode'] |
163 | - ); |
|
164 | - $form['boinc_project_config_keywords'] = array( |
|
163 | + ); |
|
164 | + $form['boinc_project_config_keywords'] = array( |
|
165 | 165 | '#type' => 'textarea', |
166 | 166 | '#title' => t('Project/Job Keywords for get_project_config RPC'), |
167 | 167 | '#default_value' => $default['boinc_project_config_keywords'], |
168 | 168 | '#description' => t('XML from this text box will be appended to the XML output from the get_project_config RPC. There is no check for XML validity! See !link for more details. It is okay to leave this blank.', |
169 | 169 | array( |
170 | - '!link' => l('BOINC wiki page', 'https://boinc.berkeley.edu/trac/wiki/JobKeywords') |
|
170 | + '!link' => l('BOINC wiki page', 'https://boinc.berkeley.edu/trac/wiki/JobKeywords') |
|
171 | 171 | )), |
172 | - ); |
|
173 | - return system_settings_form($form); |
|
172 | + ); |
|
173 | + return system_settings_form($form); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
177 | - * Validate the BOINC environment form. |
|
178 | - */ |
|
177 | + * Validate the BOINC environment form. |
|
178 | + */ |
|
179 | 179 | function boincuser_admin_environment_validate($form, &$form_state) { |
180 | - $values = $form_state['values']; |
|
181 | - if (!$values['boinc_root_dir']) { |
|
180 | + $values = $form_state['values']; |
|
181 | + if (!$values['boinc_root_dir']) { |
|
182 | 182 | form_set_error('boinc_root_dir', t('BOINC project root directory must be |
183 | 183 | defined!')); |
184 | - } |
|
185 | - elseif (!is_dir($values['boinc_root_dir'])) { |
|
184 | + } |
|
185 | + elseif (!is_dir($values['boinc_root_dir'])) { |
|
186 | 186 | form_set_error('boinc_root_dir', t('BOINC project root not found at %directory', |
187 | - array('%directory' => $values['boinc_root_dir']) |
|
187 | + array('%directory' => $values['boinc_root_dir']) |
|
188 | 188 | )); |
189 | - } |
|
190 | - else { |
|
189 | + } |
|
190 | + else { |
|
191 | 191 | // By default, try to automatically set specific directories from the root |
192 | 192 | if (!$values['boinc_config_xml_dir']) { |
193 | - $values['boinc_config_xml_dir'] = $values['boinc_root_dir']; |
|
194 | - form_set_value($form['overrides']['boinc_config_xml_dir'], $values['boinc_config_xml_dir'], $form_state); |
|
193 | + $values['boinc_config_xml_dir'] = $values['boinc_root_dir']; |
|
194 | + form_set_value($form['overrides']['boinc_config_xml_dir'], $values['boinc_config_xml_dir'], $form_state); |
|
195 | 195 | } |
196 | 196 | if (!$values['boinc_html_inc_dir']) { |
197 | - $values['boinc_html_inc_dir'] = "{$values['boinc_root_dir']}/html/inc"; |
|
198 | - form_set_value($form['overrides']['boinc_html_inc_dir'], $values['boinc_html_inc_dir'], $form_state); |
|
197 | + $values['boinc_html_inc_dir'] = "{$values['boinc_root_dir']}/html/inc"; |
|
198 | + form_set_value($form['overrides']['boinc_html_inc_dir'], $values['boinc_html_inc_dir'], $form_state); |
|
199 | 199 | } |
200 | 200 | if (!$values['boinc_project_config_dir']) { |
201 | - $values['boinc_project_config_dir'] = "{$values['boinc_root_dir']}/html/project"; |
|
202 | - form_set_value($form['overrides']['boinc_project_config_dir'], $values['boinc_project_config_dir'], $form_state); |
|
201 | + $values['boinc_project_config_dir'] = "{$values['boinc_root_dir']}/html/project"; |
|
202 | + form_set_value($form['overrides']['boinc_project_config_dir'], $values['boinc_project_config_dir'], $form_state); |
|
203 | 203 | } |
204 | 204 | if (!$values['boinc_user_image_dir']) { |
205 | - $values['boinc_user_image_dir'] = "{$values['boinc_root_dir']}/html/user_profile/images"; |
|
206 | - form_set_value($form['overrides']['boinc_user_image_dir'], $values['boinc_user_image_dir'], $form_state); |
|
205 | + $values['boinc_user_image_dir'] = "{$values['boinc_root_dir']}/html/user_profile/images"; |
|
206 | + form_set_value($form['overrides']['boinc_user_image_dir'], $values['boinc_user_image_dir'], $form_state); |
|
207 | 207 | } |
208 | 208 | // Validate that required BOINC content is found |
209 | 209 | if (!is_readable("{$values['boinc_config_xml_dir']}/config.xml")) { |
210 | - form_set_error('boinc_config_xml_dir', t('@file not found in %directory', |
|
210 | + form_set_error('boinc_config_xml_dir', t('@file not found in %directory', |
|
211 | 211 | array( |
212 | - '@file' => 'config.xml', |
|
213 | - '%directory' => "{$values['boinc_config_xml_dir']}/" |
|
212 | + '@file' => 'config.xml', |
|
213 | + '%directory' => "{$values['boinc_config_xml_dir']}/" |
|
214 | 214 | ) |
215 | - )); |
|
215 | + )); |
|
216 | 216 | } |
217 | 217 | if (!is_readable("{$values['boinc_html_inc_dir']}/util.inc")) { |
218 | - form_set_error('boinc_html_inc_dir', t('@file not found in %directory', |
|
218 | + form_set_error('boinc_html_inc_dir', t('@file not found in %directory', |
|
219 | 219 | array( |
220 | - '@file' => 'util.inc', |
|
221 | - '%directory' => "{$values['boinc_html_inc_dir']}/" |
|
220 | + '@file' => 'util.inc', |
|
221 | + '%directory' => "{$values['boinc_html_inc_dir']}/" |
|
222 | 222 | ) |
223 | - )); |
|
223 | + )); |
|
224 | 224 | } |
225 | 225 | if (!is_readable("{$values['boinc_project_config_dir']}/project.inc")) { |
226 | - form_set_error('boinc_project_config_dir', t('@file not found in %directory', |
|
226 | + form_set_error('boinc_project_config_dir', t('@file not found in %directory', |
|
227 | 227 | array( |
228 | - '@file' => 'project.inc', |
|
229 | - '%directory' => "{$values['boinc_project_config_dir']}/" |
|
228 | + '@file' => 'project.inc', |
|
229 | + '%directory' => "{$values['boinc_project_config_dir']}/" |
|
230 | 230 | ) |
231 | - )); |
|
231 | + )); |
|
232 | 232 | } |
233 | 233 | if (!is_dir($values['boinc_user_image_dir'])) { |
234 | - form_set_error('boinc_user_image_dir', t('Profile image directory not found |
|
234 | + form_set_error('boinc_user_image_dir', t('Profile image directory not found |
|
235 | 235 | at %directory', array('%directory' => $values['boinc_user_image_dir']) |
236 | - )); |
|
236 | + )); |
|
237 | 237 | } |
238 | 238 | if ($values['boinc_host_sched_logs_dir'] |
239 | 239 | AND !is_dir($values['boinc_host_sched_logs_dir']) |
240 | - ) { |
|
241 | - form_set_error('boinc_host_sched_logs_dir', t('Host scheduler log |
|
240 | + ) { |
|
241 | + form_set_error('boinc_host_sched_logs_dir', t('Host scheduler log |
|
242 | 242 | directory not found at %directory', |
243 | 243 | array('%directory' => $values['boinc_host_sched_logs_dir']) |
244 | - )); |
|
244 | + )); |
|
245 | + } |
|
245 | 246 | } |
246 | - } |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
250 | - * Handle post-validation submission of BOINC environment form. |
|
251 | - */ |
|
250 | + * Handle post-validation submission of BOINC environment form. |
|
251 | + */ |
|
252 | 252 | function boincuser_admin_environment_submit($form, &$form_state) { |
253 | - unset($_SESSION['boinc_env']); |
|
254 | - drupal_set_message(t('BOINC environment settings have been updated.')); |
|
253 | + unset($_SESSION['boinc_env']); |
|
254 | + drupal_set_message(t('BOINC environment settings have been updated.')); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
258 | - * The BOINC scheduler form provides options for how scheduler tags are |
|
259 | - * inserted into the front page |
|
260 | - */ |
|
258 | + * The BOINC scheduler form provides options for how scheduler tags are |
|
259 | + * inserted into the front page |
|
260 | + */ |
|
261 | 261 | function boincuser_admin_scheduler(&$form_state) { |
262 | - $form = array(); |
|
263 | - $config_cgi_url = ''; |
|
264 | - if ($config_xml_dir = variable_get('boinc_config_xml_dir', '')) { |
|
262 | + $form = array(); |
|
263 | + $config_cgi_url = ''; |
|
264 | + if ($config_xml_dir = variable_get('boinc_config_xml_dir', '')) { |
|
265 | 265 | // Get the cgi_url option from the config file as the default scheduler URL |
266 | 266 | $xml = new DOMDocument(); |
267 | 267 | if ($xml->load("{$config_xml_dir}/config.xml")) { |
268 | - $config = xml_to_array($xml); |
|
269 | - if (isset($config['boinc']['config']['cgi_url']['@value'])) { |
|
268 | + $config = xml_to_array($xml); |
|
269 | + if (isset($config['boinc']['config']['cgi_url']['@value'])) { |
|
270 | 270 | $config_cgi_url = rtrim(trim($config['boinc']['config']['cgi_url']['@value']), '/'); |
271 | 271 | $config_cgi_url .= '/cgi'; |
272 | - } |
|
272 | + } |
|
273 | 273 | } |
274 | - } |
|
275 | - $default = array( |
|
274 | + } |
|
275 | + $default = array( |
|
276 | 276 | 'boinc_scheduler_urls' => variable_get('boinc_scheduler_urls', $config_cgi_url), |
277 | 277 | 'boinc_scheduler_tag_format_old' => variable_get('boinc_scheduler_tag_format_old', 1), |
278 | 278 | 'boinc_scheduler_tag_format_new' => variable_get('boinc_scheduler_tag_format_new', 1) |
279 | - ); |
|
279 | + ); |
|
280 | 280 | |
281 | - // Define the form |
|
282 | - $form['boinc_scheduler_urls'] = array( |
|
281 | + // Define the form |
|
282 | + $form['boinc_scheduler_urls'] = array( |
|
283 | 283 | '#type' => 'textarea', |
284 | 284 | '#title' => t('Scheduling server URLs'), |
285 | 285 | '#default_value' => $default['boinc_scheduler_urls'], |
286 | 286 | '#cols' => 60, |
287 | 287 | '#rows' => 5, |
288 | 288 | '#description' => t('If there are multiple URLs, please enter one per line.'), |
289 | - ); |
|
290 | - $form['boinc_scheduler_tag_format_old'] = array( |
|
289 | + ); |
|
290 | + $form['boinc_scheduler_tag_format_old'] = array( |
|
291 | 291 | '#type' => 'checkbox', |
292 | 292 | '#title' => t('Old format (@scheduler tag)', array('@scheduler' => '<scheduler>')), |
293 | 293 | '#default_value' => $default['boinc_scheduler_tag_format_old'] |
294 | - ); |
|
295 | - $form['boinc_scheduler_tag_format_new'] = array( |
|
294 | + ); |
|
295 | + $form['boinc_scheduler_tag_format_new'] = array( |
|
296 | 296 | '#type' => 'checkbox', |
297 | 297 | '#title' => t('New format (@link tag)', array('@link' => '<link>')), |
298 | 298 | '#default_value' => $default['boinc_scheduler_tag_format_new'] |
299 | - ); |
|
299 | + ); |
|
300 | 300 | |
301 | - return system_settings_form($form); |
|
301 | + return system_settings_form($form); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
305 | - * Validate the BOINC scheduler form. |
|
306 | - */ |
|
305 | + * Validate the BOINC scheduler form. |
|
306 | + */ |
|
307 | 307 | function boincuser_admin_scheduler_validate($form, &$form_state) { |
308 | - $values = $form_state['values']; |
|
309 | - if (!$values['boinc_scheduler_urls']) { |
|
308 | + $values = $form_state['values']; |
|
309 | + if (!$values['boinc_scheduler_urls']) { |
|
310 | 310 | form_set_error('boinc_scheduler_urls', t('At least one scheduling server |
311 | 311 | URL must be specified.')); |
312 | - } |
|
313 | - else { |
|
312 | + } |
|
313 | + else { |
|
314 | 314 | $urls = explode("\r\n", $values['boinc_scheduler_urls']); |
315 | 315 | foreach ($urls as $key => $url) { |
316 | - if (!$url) { |
|
316 | + if (!$url) { |
|
317 | 317 | unset($urls[$key]); |
318 | 318 | continue; |
319 | - } |
|
320 | - if (!filter_var($url, FILTER_VALIDATE_URL)) { |
|
319 | + } |
|
320 | + if (!filter_var($url, FILTER_VALIDATE_URL)) { |
|
321 | 321 | form_set_error('boinc_scheduler_urls', t('@url is not a valid URL |
322 | 322 | format.', array('@url' => $url))); |
323 | 323 | break; |
324 | - } |
|
324 | + } |
|
325 | 325 | } |
326 | 326 | $form_state['values']['boinc_scheduler_urls'] = implode("\r\n", $urls); |
327 | - } |
|
327 | + } |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | /** |
331 | - * Handle post-validation submission of BOINC scheduler form. |
|
332 | - */ |
|
331 | + * Handle post-validation submission of BOINC scheduler form. |
|
332 | + */ |
|
333 | 333 | function boincuser_admin_scheduler_submit($form, &$form_state) { |
334 | - drupal_set_message(t('BOINC scheduling server settings have been updated.')); |
|
334 | + drupal_set_message(t('BOINC scheduling server settings have been updated.')); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | |
338 | 338 | /** |
339 | - * Drupal-BOINC Web site related options. |
|
340 | - */ |
|
339 | + * Drupal-BOINC Web site related options. |
|
340 | + */ |
|
341 | 341 | function boincuser_admin_weboptions(&$form_state) { |
342 | - global $base_url; |
|
343 | - $form = array(); |
|
342 | + global $base_url; |
|
343 | + $form = array(); |
|
344 | 344 | |
345 | - //form defaults |
|
346 | - $default = array( |
|
345 | + //form defaults |
|
346 | + $default = array( |
|
347 | 347 | 'boinc_weboptions_enableaccountcreateRPC' => variable_get('boinc_weboptions_enableaccountcreateRPC', TRUE), |
348 | 348 | 'boinc_weboptions_registrationtitle' => variable_get('boinc_weboptions_registrationtitle', 'Please read and acknowledge our terms of use'), |
349 | 349 | 'boinc_weboptions_termsofuse' => variable_get('boinc_weboptions_termsofuse', ''), |
@@ -357,65 +357,65 @@ discard block |
||
357 | 357 | 'boinc_weboptions_rulespolicies' => variable_get('boinc_weboptions_rulespolicies', ''), |
358 | 358 | 'boinc_other_frontpage' => variable_get('boinc_other_frontpage', ''), |
359 | 359 | 'boinc_weboptions_blacklisted_usernames' => variable_get('boinc_weboptions_blacklisted_usernames', "admin\nadministrator\nmoderator"), |
360 | - ); |
|
360 | + ); |
|
361 | 361 | |
362 | - // Define the form |
|
363 | - $form['registrationtitle'] = array( |
|
362 | + // Define the form |
|
363 | + $form['registrationtitle'] = array( |
|
364 | 364 | '#value' => '<h3>BOINC Registration</h3>', |
365 | - ); |
|
365 | + ); |
|
366 | 366 | |
367 | - $form['boinc_weboptions_enableaccountcreateRPC'] = array( |
|
367 | + $form['boinc_weboptions_enableaccountcreateRPC'] = array( |
|
368 | 368 | '#type' => 'checkbox', |
369 | 369 | '#title' => t('Enable create_account.php RPC'), |
370 | 370 | '#default_value' => $default['boinc_weboptions_enableaccountcreateRPC'], |
371 | 371 | '#description' => t('If checked, users will be able to create an account remotely using the create_account.php RPC. This option is independent of the user regsitration option found in ') . l(t('User management -> User settings'), '/admin/user/settings') . '. If enabled, user <b>may not be able to see and agree to the terms-of-use</b> to your site\'s privacy and data retention policies!', |
372 | - ); |
|
372 | + ); |
|
373 | 373 | |
374 | - $form['boinc_weboptions_registrationtitle'] = array( |
|
374 | + $form['boinc_weboptions_registrationtitle'] = array( |
|
375 | 375 | '#type' => 'textfield', |
376 | 376 | '#title' => t('Title of regsistration page'), |
377 | 377 | '#description' => t('Title text presented above the terms of use text.'), |
378 | 378 | '#default_value' => $default['boinc_weboptions_registrationtitle'], |
379 | - ); |
|
379 | + ); |
|
380 | 380 | |
381 | - $form['boinc_weboptions_termsofuse'] = array( |
|
381 | + $form['boinc_weboptions_termsofuse'] = array( |
|
382 | 382 | '#type' => 'textarea', |
383 | 383 | '#title' => t('Terms of Use Message for User Registration Page'), |
384 | 384 | '#default_value' => $default['boinc_weboptions_termsofuse'], |
385 | 385 | '#cols' => 60, |
386 | 386 | '#rows' => 8, |
387 | 387 | '#description' => t('Text to be displayed on site\'s user registration page. Privacy policy and other data retention information goes here. If empty, there will be no terms of use message, and the title above and checkbox below will not be shown.'), |
388 | - ); |
|
388 | + ); |
|
389 | 389 | |
390 | - $form['boinc_weboptions_overrideboinctou'] = array( |
|
390 | + $form['boinc_weboptions_overrideboinctou'] = array( |
|
391 | 391 | '#type' => 'checkbox', |
392 | 392 | '#title' => t('Override BOINC terms of use.'), |
393 | 393 | '#default_value' => $default['boinc_weboptions_overrideboinctou'], |
394 | 394 | '#description' => t('Override the BOINC terms_of_use.txt file for get_profject_config.php RPC. If TRUE, the get_project_config.php RPC will use the above terms of use text entered above. Otherwise, the original terms_of_use.txt text file in the project directory is used. And you will need to be responsible for keeping both the text file and the above terms of use text up-to-date and in sync with each other.'), |
395 | - ); |
|
395 | + ); |
|
396 | 396 | |
397 | - $form['boinc_weboptions_agreequestion'] = array( |
|
397 | + $form['boinc_weboptions_agreequestion'] = array( |
|
398 | 398 | '#type' => 'textfield', |
399 | 399 | '#title' => t('Terms of use agreement question'), |
400 | 400 | '#description' => t('This text is presented to the user as the question next to the \'I agree\' checkbox.'), |
401 | 401 | '#default_value' => $default['boinc_weboptions_agreequestion'], |
402 | - ); |
|
402 | + ); |
|
403 | 403 | |
404 | - $form['boinc_weboptions_registrationtitle2'] = array( |
|
404 | + $form['boinc_weboptions_registrationtitle2'] = array( |
|
405 | 405 | '#type' => 'textfield', |
406 | 406 | '#title' => t('Instructions for username/email/password questions'), |
407 | 407 | '#description' => t('Title text presented below terms of use and above username/email/password textfields.'), |
408 | 408 | '#default_value' => $default['boinc_weboptions_registrationtitle2'], |
409 | - ); |
|
409 | + ); |
|
410 | 410 | |
411 | - $form['boinc_weboptions_existinguser_tou'] = array( |
|
411 | + $form['boinc_weboptions_existinguser_tou'] = array( |
|
412 | 412 | '#type' => 'checkbox', |
413 | 413 | '#title' => t('Are existing users forced to agree to the Terms of Use?'), |
414 | 414 | '#default_value' => $default['boinc_weboptions_existinguser_tou'], |
415 | 415 | '#description' => t('If TRUE, existing users are forced to agree to a terms of use (if present) when the login and the system has detected they have not agreed. Otherwise they may login as normal. This option has no affect on whether or not new users must agree to the terms of use.'), |
416 | - ); |
|
416 | + ); |
|
417 | 417 | |
418 | - $form['boinc_weboptions_pathstoignore'] = array( |
|
418 | + $form['boinc_weboptions_pathstoignore'] = array( |
|
419 | 419 | '#type' => 'textarea', |
420 | 420 | '#title' => t('Paths to ignore the Terms of Use page'), |
421 | 421 | '#default_value' => $default['boinc_weboptions_pathstoignore'], |
@@ -424,80 +424,80 @@ discard block |
||
424 | 424 | '#description' => t('A list of Drupal URLs/paths to ignore for Terms of Use (ToU). If the option above \'Are existing users forced to agree to the Terms of Use?\' is activated, then some paths need to be ignored when checking if a user has agreed to the ToU. A good example is the logout path, "logout", or else users will not be able to logout! |
425 | 425 | <p>There is a default list of paths that must be ignored or else the site will not function. They are not included in this box. Here you may provide additional paths to be ignored, for example the privacy policy page may be accessible so that users may read it before agreeing to the site\'s ToU. |
426 | 426 | <p>Paths should be entered one per line. All paths should be <em>lower-case</em> and should not include a leading \'/\'. Example: account/info/edit will allow the user to visit ' . $base_url . '/account/info/edit without first agreeing to the ToU. Regexp are allowed. Example: account/* will allow the user to visit any path starting with ' . $base_url . '/account/.'), |
427 | - ); |
|
427 | + ); |
|
428 | 428 | |
429 | - $form['pathtitle'] = array( |
|
429 | + $form['pathtitle'] = array( |
|
430 | 430 | '#value' => '<h3>Path Options</h3>', |
431 | - ); |
|
431 | + ); |
|
432 | 432 | |
433 | - $form['boinc_weboptions_accountfinish'] = array ( |
|
433 | + $form['boinc_weboptions_accountfinish'] = array ( |
|
434 | 434 | '#type' => 'textfield', |
435 | 435 | '#title' => t('Path to a custom account_finish.php page, should be a path to a node'), |
436 | 436 | '#description' => t('Provide a path to a node which will serve as your site\'s landing page for users create an account using the BOINC client manager. They will be directed to this page after the account is created. If blank, a default account_finish page will be used.<br>Examples: account_finish, content/welcome, node/123'), |
437 | 437 | '#default_value' => $default['boinc_weboptions_accountfinish'], |
438 | - ); |
|
439 | - $form['boinc_weboptions_moderationpage'] = array ( |
|
438 | + ); |
|
439 | + $form['boinc_weboptions_moderationpage'] = array ( |
|
440 | 440 | '#type' => 'textfield', |
441 | 441 | '#title' => t('Path to the site\'s content moderation info page, should be a path to a node'), |
442 | 442 | '#description' => t('Provide a path to a node which will serve as your site\'s page for account/content moderation information. This will be used on the default account_finish page. If blank, no link to a moderation page will be provided. If a path is provided to the custom account_finish.php page (above), this field will be ignored.<br>Examples: moderation, content/moderation, node/456'), |
443 | 443 | '#default_value' => $default['boinc_weboptions_moderationpage'], |
444 | - ); |
|
445 | - $form['boinc_weboptions_rulespolicies'] = array ( |
|
444 | + ); |
|
445 | + $form['boinc_weboptions_rulespolicies'] = array ( |
|
446 | 446 | '#type' => 'textfield', |
447 | 447 | '#title' => t('Path to the site\'s rule and policies page, should be a path to a node'), |
448 | 448 | '#description' => t('Provide a path to a node which will serve as your site\'s rules and policies page. This will be used on the Join page shown to new users. If blank, no link to a rules and policies page will be provided.<br>Examples: rules-and-policies, node/789'), |
449 | 449 | '#default_value' => $default['boinc_weboptions_rulespolicies'], |
450 | - ); |
|
451 | - $form['boinc_other_frontpage'] = array ( |
|
450 | + ); |
|
451 | + $form['boinc_other_frontpage'] = array ( |
|
452 | 452 | '#type' => 'textarea', |
453 | 453 | '#title' => bts('Message for site\'s Home Page', array(), NULL, 'boinc:admin-boinc-other-options'), |
454 | 454 | '#default_value' => $default['boinc_other_frontpage'], |
455 | 455 | '#cols' => 60, |
456 | 456 | '#rows' => 8, |
457 | 457 | '#description' => bts('Text to be displayed on the site\'s Home landing page.', array(), NULL, 'boinc:admin-boinc-other-options'), |
458 | - ); |
|
458 | + ); |
|
459 | 459 | |
460 | - $form['Othertitle'] = array( |
|
460 | + $form['Othertitle'] = array( |
|
461 | 461 | '#value' => '<h3>Other Options</h3>', |
462 | - ); |
|
462 | + ); |
|
463 | 463 | |
464 | - $form['boinc_weboptions_blacklisted_usernames'] = array ( |
|
464 | + $form['boinc_weboptions_blacklisted_usernames'] = array ( |
|
465 | 465 | '#type' => 'textarea', |
466 | 466 | '#title' => t('BOINC username blacklist'), |
467 | 467 | '#default_value' => $default['boinc_weboptions_blacklisted_usernames'], |
468 | 468 | '#cols' => 60, |
469 | 469 | '#rows' => 7, |
470 | 470 | '#description' => t('Username blacklist: List of names that users will not be able to choose as their BOINC username. This will only affect Web registration and when a user changes their name using the Web site. Names should be entered one per line.<p>All names should be <em>lower-case</em>. The comparison made is case-insensitive.<p>If you wish to <em>disable</em> this feature, remove all names from this textbox; the blacklist will be empty.'), |
471 | - ); |
|
471 | + ); |
|
472 | 472 | |
473 | - return system_settings_form($form); |
|
473 | + return system_settings_form($form); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | /** |
477 | - * Validate BOINC other form |
|
478 | - */ |
|
477 | + * Validate BOINC other form |
|
478 | + */ |
|
479 | 479 | function boincuser_admin_weboptions_validate($form, &$form_state) { |
480 | - $values = $form_state['values']; |
|
480 | + $values = $form_state['values']; |
|
481 | 481 | |
482 | - $accountfinish = $values['boinc_weboptions_accountfinish']; |
|
483 | - if ( ($accountfinish) AND (!drupal_lookup_path('source', $accountfinish)) ) { |
|
482 | + $accountfinish = $values['boinc_weboptions_accountfinish']; |
|
483 | + if ( ($accountfinish) AND (!drupal_lookup_path('source', $accountfinish)) ) { |
|
484 | 484 | form_set_error('boinc weboptions_accountfinish', t('Path to custom account finish page not found. Please provide a valid path, or leave blank to unset.')); |
485 | - } |
|
485 | + } |
|
486 | 486 | |
487 | - $moderationpage = $values['boinc_weboptions_moderationpage']; |
|
488 | - if ( ($moderationpage) AND (!drupal_lookup_path('source', $moderationpage)) ) { |
|
487 | + $moderationpage = $values['boinc_weboptions_moderationpage']; |
|
488 | + if ( ($moderationpage) AND (!drupal_lookup_path('source', $moderationpage)) ) { |
|
489 | 489 | form_set_error('boinc weboptions_moderationpage', t('Path to moderation page not found. Please provide a valid path, or leave blank to unset.')); |
490 | - } |
|
490 | + } |
|
491 | 491 | |
492 | - $rulespolicies = $values['boinc_weboptions_rulespolicies']; |
|
493 | - if ( ($rulespolicies) AND (!drupal_lookup_path('source', $rulespolicies)) ) { |
|
492 | + $rulespolicies = $values['boinc_weboptions_rulespolicies']; |
|
493 | + if ( ($rulespolicies) AND (!drupal_lookup_path('source', $rulespolicies)) ) { |
|
494 | 494 | form_set_error('boinc weboptions_rulespolicies', t('Path to rules and policies page not found. Please provide a valid path, or leave blank to unset.')); |
495 | - } |
|
495 | + } |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | /** |
499 | - * Submit BOINC other form |
|
500 | - */ |
|
499 | + * Submit BOINC other form |
|
500 | + */ |
|
501 | 501 | function boincuser_admin_weboptions_submit($form, &$form_state) { |
502 | - drupal_set_message( bts("Status: Drupa-BOINC Web site options have been updated", array(), NULL, 'boinc:admin-boinc-website-options') ); |
|
502 | + drupal_set_message( bts("Status: Drupa-BOINC Web site options have been updated", array(), NULL, 'boinc:admin-boinc-website-options') ); |
|
503 | 503 | } |