@@ -29,22 +29,22 @@ discard block |
||
29 | 29 | * with defined URL paths |
30 | 30 | */ |
31 | 31 | function boinccore_menu() { |
32 | - $items['node_control'] = array( |
|
32 | + $items['node_control'] = array( |
|
33 | 33 | 'page callback' => 'boinccore_node_control', |
34 | 34 | 'access arguments' => array('access content'), |
35 | 35 | 'type' => MENU_CALLBACK |
36 | - ); |
|
37 | - $items['comment_control'] = array( |
|
36 | + ); |
|
37 | + $items['comment_control'] = array( |
|
38 | 38 | 'page callback' => 'boinccore_comment_control', |
39 | 39 | 'access arguments' => array('administer comments'), |
40 | 40 | 'type' => MENU_CALLBACK |
41 | - ); |
|
42 | - $items['goto'] = array( |
|
41 | + ); |
|
42 | + $items['goto'] = array( |
|
43 | 43 | 'page callback' => 'boinccore_url_pagination_handler', |
44 | 44 | 'access arguments' => array('access content'), |
45 | 45 | 'type' => MENU_CALLBACK |
46 | - ); |
|
47 | - $items['admin/boinc/community'] = array( |
|
46 | + ); |
|
47 | + $items['admin/boinc/community'] = array( |
|
48 | 48 | 'title' => 'Community', |
49 | 49 | 'description' => 'Global settings for community interaction.', |
50 | 50 | 'page callback' => 'drupal_get_form', |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | 'access arguments' => array('administer site configuration'), |
53 | 53 | 'type' => MENU_NORMAL_ITEM, |
54 | 54 | 'file' => 'boinccore.admin.inc' |
55 | - ); |
|
56 | - $items['admin/boinc/standard-content-generator'] = array( |
|
55 | + ); |
|
56 | + $items['admin/boinc/standard-content-generator'] = array( |
|
57 | 57 | 'title' => 'Standard page generator', |
58 | 58 | 'description' => 'Regenerate standard site content (e.g. Help and About Us |
59 | 59 | pages).', |
@@ -62,172 +62,172 @@ discard block |
||
62 | 62 | 'access arguments' => array('administer site configuration'), |
63 | 63 | 'type' => MENU_NORMAL_ITEM, |
64 | 64 | 'file' => 'boinccore.admin.inc' |
65 | - ); |
|
65 | + ); |
|
66 | 66 | |
67 | - // BOINC RPC wrappers |
|
68 | - $items['lookup_account.php'] = array( |
|
67 | + // BOINC RPC wrappers |
|
68 | + $items['lookup_account.php'] = array( |
|
69 | 69 | 'title' => 'Look up account RPC', |
70 | 70 | 'description' => 'RPC for getting the authenticator for a user account.', |
71 | 71 | 'page callback' => 'boinccore_lookup_account', |
72 | 72 | 'access callback' => TRUE, |
73 | 73 | 'type' => MENU_CALLBACK |
74 | - ); |
|
75 | - $items['am_get_info.php'] = array( |
|
74 | + ); |
|
75 | + $items['am_get_info.php'] = array( |
|
76 | 76 | 'title' => 'Account manager get info RPC', |
77 | 77 | 'description' => 'RPC for getting assorted details of a user account.', |
78 | 78 | 'page callback' => 'boinccore_am_get_info', |
79 | 79 | 'access callback' => TRUE, |
80 | 80 | 'type' => MENU_CALLBACK |
81 | - ); |
|
82 | - $items['am_set_info.php'] = array( |
|
81 | + ); |
|
82 | + $items['am_set_info.php'] = array( |
|
83 | 83 | 'title' => 'Account manager set info RPC', |
84 | 84 | 'description' => 'RPC for updating assorted details of a user account.', |
85 | 85 | 'page callback' => 'boinccore_am_set_info', |
86 | 86 | 'access callback' => TRUE, |
87 | 87 | 'type' => MENU_CALLBACK |
88 | - ); |
|
89 | - $items['am_set_host_info.php'] = array( |
|
88 | + ); |
|
89 | + $items['am_set_host_info.php'] = array( |
|
90 | 90 | 'title' => 'Account manager set host info RPC', |
91 | 91 | 'description' => 'RPC for updating the venue for a given host.', |
92 | 92 | 'page callback' => 'boinccore_am_set_host_info', |
93 | 93 | 'access callback' => TRUE, |
94 | 94 | 'type' => MENU_CALLBACK |
95 | - ); |
|
96 | - $items['show_user.php'] = array( |
|
95 | + ); |
|
96 | + $items['show_user.php'] = array( |
|
97 | 97 | 'title' => 'Show user RPC', |
98 | 98 | 'description' => 'RPC for getting assorted details of a user account.', |
99 | 99 | 'page callback' => 'boinccore_show_user', |
100 | 100 | 'access callback' => TRUE, |
101 | 101 | 'type' => MENU_CALLBACK |
102 | - ); |
|
103 | - $items['pending.php'] = array( |
|
102 | + ); |
|
103 | + $items['pending.php'] = array( |
|
104 | 104 | 'title' => 'Pending credit RPC', |
105 | 105 | 'description' => 'RPC for getting pending credit for a given account.', |
106 | 106 | 'page callback' => 'boinccore_pending_credit', |
107 | 107 | 'access callback' => TRUE, |
108 | 108 | 'type' => MENU_CALLBACK |
109 | - ); |
|
110 | - $items['create_team.php'] = array( |
|
109 | + ); |
|
110 | + $items['create_team.php'] = array( |
|
111 | 111 | 'title' => 'Create team RPC', |
112 | 112 | 'description' => 'RPC for creating a new team.', |
113 | 113 | 'page callback' => 'boinccore_create_team', |
114 | 114 | 'access callback' => TRUE, |
115 | 115 | 'type' => MENU_CALLBACK |
116 | - ); |
|
117 | - $items['team_lookup.php'] = array( |
|
116 | + ); |
|
117 | + $items['team_lookup.php'] = array( |
|
118 | 118 | 'title' => 'Team lookup RPC', |
119 | 119 | 'description' => 'RPC for getting info on a team or matching teams.', |
120 | 120 | 'page callback' => 'boinccore_team_lookup', |
121 | 121 | 'access callback' => TRUE, |
122 | 122 | 'type' => MENU_CALLBACK |
123 | - ); |
|
124 | - $items['team_email_list.php'] = array( |
|
123 | + ); |
|
124 | + $items['team_email_list.php'] = array( |
|
125 | 125 | 'title' => 'Get team member list RPC', |
126 | 126 | 'description' => 'RPC for getting a list of members of a given team.', |
127 | 127 | 'page callback' => 'boinccore_team_email_list', |
128 | 128 | 'access callback' => TRUE, |
129 | 129 | 'type' => MENU_CALLBACK |
130 | - ); |
|
131 | - $items['edit_forum_preferences_action.php'] = array( |
|
130 | + ); |
|
131 | + $items['edit_forum_preferences_action.php'] = array( |
|
132 | 132 | 'title' => 'Forum preferences RPC', |
133 | 133 | 'description' => 'RPC for setting forum preferences for a given user.', |
134 | 134 | 'page callback' => 'boinccore_edit_forum_preferences', |
135 | 135 | 'access callback' => TRUE, |
136 | 136 | 'type' => MENU_CALLBACK |
137 | - ); |
|
138 | - $items['forum_get_data.php'] = array( |
|
137 | + ); |
|
138 | + $items['forum_get_data.php'] = array( |
|
139 | 139 | 'title' => 'Forum get data RPC', |
140 | 140 | 'description' => 'RPC for getting recent forum activity for a given user.', |
141 | 141 | 'page callback' => 'boinccore_forum_get_data', |
142 | 142 | 'access callback' => TRUE, |
143 | 143 | 'type' => MENU_CALLBACK |
144 | - ); |
|
145 | - $items['apps.php'] = array( |
|
144 | + ); |
|
145 | + $items['apps.php'] = array( |
|
146 | 146 | 'title' => 'Apps RPC', |
147 | 147 | 'description' => 'RPC for getting the applications in the system.', |
148 | 148 | 'page callback' => 'boinccore_apps', |
149 | 149 | 'access callback' => TRUE, |
150 | 150 | 'type' => MENU_CALLBACK |
151 | - ); |
|
151 | + ); |
|
152 | 152 | |
153 | - return $items; |
|
153 | + return $items; |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
157 | 157 | * Implementation of hook_menu_alter() |
158 | 158 | */ |
159 | 159 | function boinccore_menu_alter(&$items) { |
160 | - // If using Solr search and not core Drupal search, disable core search! |
|
161 | - if (module_exists('global_search_solr') AND !module_exists('global_search')) { |
|
160 | + // If using Solr search and not core Drupal search, disable core search! |
|
161 | + if (module_exists('global_search_solr') AND !module_exists('global_search')) { |
|
162 | 162 | // Add permission to user search. |
163 | 163 | $check = array( |
164 | - 'search/node/%menu_tail', |
|
165 | - 'search/user/%menu_tail', |
|
166 | - 'user/autocomplete' |
|
164 | + 'search/node/%menu_tail', |
|
165 | + 'search/user/%menu_tail', |
|
166 | + 'user/autocomplete' |
|
167 | 167 | ); |
168 | 168 | foreach ($check as $path) { |
169 | - if (isset($items[$path])) { |
|
169 | + if (isset($items[$path])) { |
|
170 | 170 | $items[$path]['access callback'] = FALSE; |
171 | - } |
|
171 | + } |
|
172 | 172 | } |
173 | - } |
|
174 | - // If using content profile module (for user profiles) setup special |
|
175 | - // delete page. |
|
176 | - if (module_exists('content_profile')) { |
|
173 | + } |
|
174 | + // If using content profile module (for user profiles) setup special |
|
175 | + // delete page. |
|
176 | + if (module_exists('content_profile')) { |
|
177 | 177 | $items['node/%node/delete'] = array( |
178 | - 'title' => 'Delete', |
|
179 | - 'page callback' => 'drupal_get_form', |
|
180 | - 'page arguments' => array('boinccore_delete_confirm', 1), |
|
181 | - 'access callback' => 'node_access', |
|
182 | - 'access arguments' => array('delete', 1), |
|
183 | - 'module' => 'boinccore', |
|
184 | - 'file' => 'includes/boinccore.forms.inc', |
|
185 | - 'weight' => 1, |
|
186 | - 'type' => MENU_CALLBACK, |
|
178 | + 'title' => 'Delete', |
|
179 | + 'page callback' => 'drupal_get_form', |
|
180 | + 'page arguments' => array('boinccore_delete_confirm', 1), |
|
181 | + 'access callback' => 'node_access', |
|
182 | + 'access arguments' => array('delete', 1), |
|
183 | + 'module' => 'boinccore', |
|
184 | + 'file' => 'includes/boinccore.forms.inc', |
|
185 | + 'weight' => 1, |
|
186 | + 'type' => MENU_CALLBACK, |
|
187 | 187 | ); |
188 | - } |
|
188 | + } |
|
189 | 189 | |
190 | - // 'Remove' menu paths for ignore_user and privatemsg |
|
191 | - // (pm_block_user) module which we have 'overridden' with |
|
192 | - // boincwork's own functions. |
|
193 | - if (module_exists('ignore_user')) { |
|
190 | + // 'Remove' menu paths for ignore_user and privatemsg |
|
191 | + // (pm_block_user) module which we have 'overridden' with |
|
192 | + // boincwork's own functions. |
|
193 | + if (module_exists('ignore_user')) { |
|
194 | 194 | $check = array( |
195 | - 'ignore_user/add', |
|
196 | - 'ignore_user/remove', |
|
195 | + 'ignore_user/add', |
|
196 | + 'ignore_user/remove', |
|
197 | 197 | ); |
198 | 198 | foreach ($check as $path) { |
199 | - if (isset($items[$path])) { |
|
199 | + if (isset($items[$path])) { |
|
200 | 200 | $items[$path]['access callback'] = FALSE; |
201 | - } |
|
201 | + } |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | // Redirect user to privacy prefs page. |
205 | 205 | $path1 = 'ignore_user/list'; |
206 | 206 | if (isset($items[$path1])) { |
207 | - $items[$path1]['page callback'] = 'drupal_goto'; |
|
208 | - $items[$path1]['page arguments'] = array('account/prefs/privacy'); |
|
207 | + $items[$path1]['page callback'] = 'drupal_goto'; |
|
208 | + $items[$path1]['page arguments'] = array('account/prefs/privacy'); |
|
209 | + } |
|
209 | 210 | } |
210 | - } |
|
211 | 211 | |
212 | - if (module_exists('pm_block_user')) { |
|
212 | + if (module_exists('pm_block_user')) { |
|
213 | 213 | $check = array( |
214 | - 'messages/block/%user', |
|
214 | + 'messages/block/%user', |
|
215 | 215 | ); |
216 | 216 | foreach ($check as $path) { |
217 | - if (isset($items[$path])) { |
|
217 | + if (isset($items[$path])) { |
|
218 | 218 | $items[$path]['access callback'] = FALSE; |
219 | - } |
|
219 | + } |
|
220 | + } |
|
220 | 221 | } |
221 | - } |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | /** |
225 | 225 | * Implementation of hook_enable() |
226 | 226 | */ |
227 | 227 | function boinccore_enable() { |
228 | - // Automatically try to establish standard site content when this module is |
|
229 | - // enabled (e.g. Help and About Us pages) |
|
230 | - boinccore_admin_default_content_generate(); |
|
228 | + // Automatically try to establish standard site content when this module is |
|
229 | + // enabled (e.g. Help and About Us pages) |
|
230 | + boinccore_admin_default_content_generate(); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -240,14 +240,14 @@ discard block |
||
240 | 240 | * See: https://www.drupal.org/node/339958#comment-3012662 |
241 | 241 | */ |
242 | 242 | function boinccore_boot() { |
243 | - global $user, $language; |
|
244 | - $cache = variable_get('cache', CACHE_DISABLED); |
|
245 | - $language_negotiation = variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE); |
|
246 | - |
|
247 | - // If we have an anonymous user, page cache is enabled, the URL has no prefix |
|
248 | - // and browser language negotiation is set, we perform a redirect to the |
|
249 | - // prefixed URL. |
|
250 | - if (empty($user->uid) && $cache != CACHE_DISABLED && $language_negotiation == LANGUAGE_NEGOTIATION_PATH) { |
|
243 | + global $user, $language; |
|
244 | + $cache = variable_get('cache', CACHE_DISABLED); |
|
245 | + $language_negotiation = variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE); |
|
246 | + |
|
247 | + // If we have an anonymous user, page cache is enabled, the URL has no prefix |
|
248 | + // and browser language negotiation is set, we perform a redirect to the |
|
249 | + // prefixed URL. |
|
250 | + if (empty($user->uid) && $cache != CACHE_DISABLED && $language_negotiation == LANGUAGE_NEGOTIATION_PATH) { |
|
251 | 251 | $args = isset($_GET['q']) ? explode('/', $_GET['q']) : array(); |
252 | 252 | $prefix = array_shift($args); |
253 | 253 | |
@@ -259,24 +259,24 @@ discard block |
||
259 | 259 | // so call this backported Drupal 7 language negotation function, which |
260 | 260 | // does both case insensitive and longest prefix matching |
261 | 261 | if (function_exists('locale_language_from_browser')) { |
262 | - $language = locale_language_from_browser(); |
|
262 | + $language = locale_language_from_browser(); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | if (!empty($language->prefix) && $prefix != $language->prefix) { |
266 | - // We need full path support to perform the redirect. |
|
267 | - drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH); |
|
268 | - |
|
269 | - require_once './includes/common.inc'; |
|
270 | - $url = url($_GET['q'], array('query' => drupal_query_string_encode($_GET, array('q')))); |
|
271 | - $code = variable_get('locale_redirect_http_code', 302); |
|
272 | - |
|
273 | - // Since we are in a hook_boot() implementation cache mode is normal, so |
|
274 | - // we can safely call hook_exit(). |
|
275 | - bootstrap_invoke_all('exit'); |
|
276 | - header("Location: $url", TRUE, $code); |
|
277 | - exit; |
|
266 | + // We need full path support to perform the redirect. |
|
267 | + drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH); |
|
268 | + |
|
269 | + require_once './includes/common.inc'; |
|
270 | + $url = url($_GET['q'], array('query' => drupal_query_string_encode($_GET, array('q')))); |
|
271 | + $code = variable_get('locale_redirect_http_code', 302); |
|
272 | + |
|
273 | + // Since we are in a hook_boot() implementation cache mode is normal, so |
|
274 | + // we can safely call hook_exit(). |
|
275 | + bootstrap_invoke_all('exit'); |
|
276 | + header("Location: $url", TRUE, $code); |
|
277 | + exit; |
|
278 | + } |
|
278 | 279 | } |
279 | - } |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | |
@@ -289,9 +289,9 @@ discard block |
||
289 | 289 | * |
290 | 290 | * Obsolete in Drupal 7... |
291 | 291 | */ |
292 | - function locale_language_from_browser() { |
|
292 | + function locale_language_from_browser() { |
|
293 | 293 | if (empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
294 | - return FALSE; |
|
294 | + return FALSE; |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | $languages = language_list('enabled'); |
@@ -306,14 +306,14 @@ discard block |
||
306 | 306 | // Samples: "hu, en-us;q=0.66, en;q=0.33", "hu,en-us;q=0.5" |
307 | 307 | $browser_langcodes = array(); |
308 | 308 | if (preg_match_all('@(?<=[, ]|^)([a-zA-Z-]+|\*)(?:;q=([0-9.]+))?(?:$|\s*,\s*)@', trim($_SERVER['HTTP_ACCEPT_LANGUAGE']), $matches, PREG_SET_ORDER)) { |
309 | - foreach ($matches as $match) { |
|
309 | + foreach ($matches as $match) { |
|
310 | 310 | // We can safely use strtolower() here, tags are ASCII. |
311 | 311 | // RFC2616 mandates that the decimal part is no more than three digits, |
312 | 312 | // so we multiply the qvalue by 1000 to avoid floating point comparisons. |
313 | 313 | $langcode = strtolower($match[1]); |
314 | 314 | $qvalue = isset($match[2]) ? (float) $match[2] : 1; |
315 | 315 | $browser_langcodes[$langcode] = (int) ($qvalue * 1000); |
316 | - } |
|
316 | + } |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | // We should take pristine values from the HTTP headers, but Internet Explorer |
@@ -325,10 +325,10 @@ discard block |
||
325 | 325 | // http://blogs.msdn.com/b/ie/archive/2006/10/17/accept-language-header-for-internet-explorer-7.aspx |
326 | 326 | asort($browser_langcodes); |
327 | 327 | foreach ($browser_langcodes as $langcode => $qvalue) { |
328 | - $generic_tag = strtok($langcode, '-'); |
|
329 | - if (!isset($browser_langcodes[$generic_tag])) { |
|
328 | + $generic_tag = strtok($langcode, '-'); |
|
329 | + if (!isset($browser_langcodes[$generic_tag])) { |
|
330 | 330 | $browser_langcodes[$generic_tag] = $qvalue; |
331 | - } |
|
331 | + } |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | // Find the enabled language with the greatest qvalue, following the rules |
@@ -337,156 +337,156 @@ discard block |
||
337 | 337 | $best_match_language = FALSE; |
338 | 338 | $max_qvalue = 0; |
339 | 339 | foreach ($languages as $langcode => $language) { |
340 | - // Language tags are case insensitive (RFC2616, sec 3.10). |
|
341 | - $langcode = strtolower($langcode); |
|
340 | + // Language tags are case insensitive (RFC2616, sec 3.10). |
|
341 | + $langcode = strtolower($langcode); |
|
342 | 342 | |
343 | - // If nothing matches below, the default qvalue is the one of the wildcard |
|
344 | - // language, if set, or is 0 (which will never match). |
|
345 | - $qvalue = isset($browser_langcodes['*']) ? $browser_langcodes['*'] : 0; |
|
343 | + // If nothing matches below, the default qvalue is the one of the wildcard |
|
344 | + // language, if set, or is 0 (which will never match). |
|
345 | + $qvalue = isset($browser_langcodes['*']) ? $browser_langcodes['*'] : 0; |
|
346 | 346 | |
347 | - // Find the longest possible prefix of the browser-supplied language |
|
348 | - // ('the language-range') that matches this site language ('the language tag'). |
|
349 | - $prefix = $langcode; |
|
350 | - do { |
|
347 | + // Find the longest possible prefix of the browser-supplied language |
|
348 | + // ('the language-range') that matches this site language ('the language tag'). |
|
349 | + $prefix = $langcode; |
|
350 | + do { |
|
351 | 351 | if (isset($browser_langcodes[$prefix])) { |
352 | - $qvalue = $browser_langcodes[$prefix]; |
|
353 | - break; |
|
352 | + $qvalue = $browser_langcodes[$prefix]; |
|
353 | + break; |
|
354 | 354 | } |
355 | - } |
|
356 | - while ($prefix = substr($prefix, 0, strrpos($prefix, '-'))); |
|
355 | + } |
|
356 | + while ($prefix = substr($prefix, 0, strrpos($prefix, '-'))); |
|
357 | 357 | |
358 | - // Find the best match. |
|
359 | - if ($qvalue > $max_qvalue) { |
|
358 | + // Find the best match. |
|
359 | + if ($qvalue > $max_qvalue) { |
|
360 | 360 | $best_match_language = $language; |
361 | 361 | $max_qvalue = $qvalue; |
362 | - } |
|
362 | + } |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | return $best_match_language; |
366 | - } |
|
366 | + } |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | /** |
370 | 370 | * Implementation of hook_cron() |
371 | 371 | */ |
372 | 372 | function boinccore_cron() { |
373 | - // Notify moderators if there is site content that requires moderator action |
|
374 | - $items_in_queue = boincuser_moderation_queue_count('cron'); |
|
375 | - $last_notification = variable_get('boinccore_last_content_moderation_reminder', 0); |
|
376 | - if ($items_in_queue AND $last_notification < time() - 24*60*60) { |
|
373 | + // Notify moderators if there is site content that requires moderator action |
|
374 | + $items_in_queue = boincuser_moderation_queue_count('cron'); |
|
375 | + $last_notification = variable_get('boinccore_last_content_moderation_reminder', 0); |
|
376 | + if ($items_in_queue AND $last_notification < time() - 24*60*60) { |
|
377 | 377 | global $base_url; |
378 | 378 | global $base_path; |
379 | 379 | $site_name = variable_get('site_name', 'Drupal-BOINC'); |
380 | 380 | $site_url = $base_url . $base_path; |
381 | 381 | $settings = array( |
382 | - 'from' => '', |
|
383 | - 'subject' => "Content at {$site_name} is awaiting moderation", |
|
384 | - 'message' => '' |
|
385 | - . "Please visit the moderation queue page to review content that " |
|
386 | - . "requires moderator action: \n" |
|
387 | - . "\n" |
|
388 | - . "{$site_url}moderate", |
|
382 | + 'from' => '', |
|
383 | + 'subject' => "Content at {$site_name} is awaiting moderation", |
|
384 | + 'message' => '' |
|
385 | + . "Please visit the moderation queue page to review content that " |
|
386 | + . "requires moderator action: \n" |
|
387 | + . "\n" |
|
388 | + . "{$site_url}moderate", |
|
389 | 389 | ); |
390 | 390 | boinccore_rules_action_mail_to_moderators($settings); |
391 | 391 | variable_set('boinccore_last_content_moderation_reminder', time()); |
392 | - } |
|
392 | + } |
|
393 | 393 | |
394 | - // Delete expired tokens in BOINC DB |
|
395 | - _boinccore_delete_expired_tokens(); |
|
394 | + // Delete expired tokens in BOINC DB |
|
395 | + _boinccore_delete_expired_tokens(); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | /** |
399 | 399 | * Implementation of hook_rules_action_info(). |
400 | 400 | */ |
401 | 401 | function boinccore_rules_action_info() { |
402 | - return array( |
|
402 | + return array( |
|
403 | 403 | 'boinccore_rules_action_mail_to_moderators' => array( |
404 | - 'label' => t('Notify moderators via email'), |
|
405 | - 'module' => 'BOINC core', |
|
406 | - 'eval input' => array('subject', 'message', 'from'), |
|
404 | + 'label' => t('Notify moderators via email'), |
|
405 | + 'module' => 'BOINC core', |
|
406 | + 'eval input' => array('subject', 'message', 'from'), |
|
407 | 407 | ), |
408 | 408 | 'boinccore_rules_action_mark_content_for_moderation' => array( |
409 | - 'label' => t('Mark content for moderation'), |
|
410 | - 'arguments' => array( |
|
409 | + 'label' => t('Mark content for moderation'), |
|
410 | + 'arguments' => array( |
|
411 | 411 | 'node' => array('type' => 'node', 'label' => t('Content')), |
412 | - ), |
|
413 | - 'module' => 'BOINC core', |
|
412 | + ), |
|
413 | + 'module' => 'BOINC core', |
|
414 | 414 | ), |
415 | 415 | 'boinccore_rules_action_mail_to_admins' => array( |
416 | - 'label' => t('Notify admins via email'), |
|
417 | - 'module' => 'BOINC core', |
|
418 | - 'eval input' => array('subject', 'message', 'from'), |
|
416 | + 'label' => t('Notify admins via email'), |
|
417 | + 'module' => 'BOINC core', |
|
418 | + 'eval input' => array('subject', 'message', 'from'), |
|
419 | 419 | ), |
420 | - ); |
|
420 | + ); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | /** |
424 | 424 | * Implementation of hook_form_alter() |
425 | 425 | */ |
426 | 426 | function boinccore_form_alter(&$form, $form_state, $form_id) { |
427 | - global $user; |
|
428 | - $account = user_load($user->uid); |
|
429 | - switch ($form_id) { |
|
430 | - // Comment form |
|
431 | - case 'comment_form': |
|
427 | + global $user; |
|
428 | + $account = user_load($user->uid); |
|
429 | + switch ($form_id) { |
|
430 | + // Comment form |
|
431 | + case 'comment_form': |
|
432 | 432 | $user_image = boincuser_get_user_profile_image($user->uid); |
433 | 433 | $user_info = '<div class="user">'; |
434 | 434 | if ($user_image) { |
435 | - $user_info .= ' <div class="picture">'; |
|
436 | - if (is_array($user_image) AND $user_image['image']['filepath']) { |
|
435 | + $user_info .= ' <div class="picture">'; |
|
436 | + if (is_array($user_image) AND $user_image['image']['filepath']) { |
|
437 | 437 | $user_info .= theme('imagefield_image', $user_image['image'], $user_image['alt'], $user_image['alt'], array(), false); |
438 | - } |
|
439 | - elseif (is_string($user_image)) { |
|
438 | + } |
|
439 | + elseif (is_string($user_image)) { |
|
440 | 440 | $user_info .= '<img src="' . $user_image . '"/>'; |
441 | - } |
|
442 | - $user_info .= ' </div>'; |
|
441 | + } |
|
442 | + $user_info .= ' </div>'; |
|
443 | 443 | } |
444 | 444 | $user_info .= ' <div class="name">' . theme('username', $account) . '</div>'; |
445 | 445 | if ($account->uid) { |
446 | - //$user_info .= ' <div class="join-date">Joined: ' . date('j M y', $account->created) . '</div>'; |
|
447 | - //$user_info .= ' <div class="post-count">Posts: ' . $account->post_count . '</div>'; |
|
448 | - //$user_info .= ' <div class="credit">Credit: ' . $account->boincuser_total_credit . '</div>'; |
|
449 | - //$user_info .= ' <div class="rac">RAC: ' . $account->boincuser_expavg_credit . '</div>'; |
|
446 | + //$user_info .= ' <div class="join-date">Joined: ' . date('j M y', $account->created) . '</div>'; |
|
447 | + //$user_info .= ' <div class="post-count">Posts: ' . $account->post_count . '</div>'; |
|
448 | + //$user_info .= ' <div class="credit">Credit: ' . $account->boincuser_total_credit . '</div>'; |
|
449 | + //$user_info .= ' <div class="rac">RAC: ' . $account->boincuser_expavg_credit . '</div>'; |
|
450 | 450 | } |
451 | 451 | $user_info .= '</div>'; |
452 | 452 | array_unshift($form, array( |
453 | - 'user_info' => array( |
|
453 | + 'user_info' => array( |
|
454 | 454 | '#value' => $user_info, |
455 | - ), |
|
456 | - 'comment_form_prefix' => array( |
|
455 | + ), |
|
456 | + 'comment_form_prefix' => array( |
|
457 | 457 | '#value' => '<div class="form-body">', |
458 | - ), |
|
458 | + ), |
|
459 | 459 | )); |
460 | 460 | $form['comment_form_suffix'] = array( |
461 | - '#value' => '</div>', |
|
461 | + '#value' => '</div>', |
|
462 | 462 | ); |
463 | 463 | |
464 | 464 | module_load_include('inc', 'bbcode', 'bbcode-help'); |
465 | 465 | $form['bbcode_help'] = array( |
466 | - '#title' => bts('BBcode help', array(), NULL, 'boinc:help-with-user-input-with-BBCode'), |
|
467 | - '#type' => 'fieldset', |
|
468 | - '#attributes' => array( |
|
466 | + '#title' => bts('BBcode help', array(), NULL, 'boinc:help-with-user-input-with-BBCode'), |
|
467 | + '#type' => 'fieldset', |
|
468 | + '#attributes' => array( |
|
469 | 469 | 'class' => 'bbcode_help', |
470 | - ), |
|
471 | - '#collapsible' => TRUE, |
|
472 | - '#collapsed' => TRUE, |
|
473 | - 'content' => array( |
|
470 | + ), |
|
471 | + '#collapsible' => TRUE, |
|
472 | + '#collapsed' => TRUE, |
|
473 | + 'content' => array( |
|
474 | 474 | '#value' => _bbcode_filter_tip(), |
475 | - ), |
|
475 | + ), |
|
476 | 476 | ); |
477 | 477 | |
478 | 478 | // If a specific comment is being referenced, go back to it on cancel |
479 | 479 | if ($comment_ref = $form['pid']['#value']) { |
480 | - $cancel_url = "goto/comment/{$comment_ref}"; |
|
480 | + $cancel_url = "goto/comment/{$comment_ref}"; |
|
481 | 481 | } |
482 | 482 | else { |
483 | - $cancel_url = "node/{$form['nid']['#value']}"; |
|
483 | + $cancel_url = "node/{$form['nid']['#value']}"; |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | // Wrap action buttons for styling consistency |
487 | 487 | $form['buttons']['form control tabs prefix'] = array( |
488 | - '#value' => '<ul class="form-control tab-list">', |
|
489 | - '#weight' => 1001, |
|
488 | + '#value' => '<ul class="form-control tab-list">', |
|
489 | + '#weight' => 1001, |
|
490 | 490 | ); |
491 | 491 | $form['buttons']['submit'] = $form['submit']; |
492 | 492 | unset($form['submit']); |
@@ -505,12 +505,12 @@ discard block |
||
505 | 505 | $form['buttons']['preview']['#suffix'] = '</li>'; |
506 | 506 | $form['buttons']['preview']['#weight'] = 1003; |
507 | 507 | $form['buttons']['cancel'] = array( |
508 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $cancel_url) . '</li>', |
|
509 | - '#weight' => 1004, |
|
508 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $cancel_url) . '</li>', |
|
509 | + '#weight' => 1004, |
|
510 | 510 | ); |
511 | 511 | $form['buttons']['form control tabs suffix'] = array( |
512 | - '#value' => '</ul>', |
|
513 | - '#weight' => 1010, |
|
512 | + '#value' => '</ul>', |
|
513 | + '#weight' => 1010, |
|
514 | 514 | ); |
515 | 515 | |
516 | 516 | // Remove redundant name field |
@@ -526,38 +526,38 @@ discard block |
||
526 | 526 | $community_role = array_search('community member', user_roles(true)); |
527 | 527 | $unrestricted_role = array_search('verified contributor', user_roles(true)); |
528 | 528 | if ( (isset($account->roles[$community_role])) and (!isset($account->roles[$unrestricted_role])) ) { |
529 | - if ($node->type == 'forum') { |
|
529 | + if ($node->type == 'forum') { |
|
530 | 530 | if (module_exists('captcha')) { |
531 | - $form['comment_captcha'] = array( |
|
531 | + $form['comment_captcha'] = array( |
|
532 | 532 | '#type' => 'captcha', |
533 | 533 | '#weight' => 1000, |
534 | - ); |
|
534 | + ); |
|
535 | 535 | } |
536 | - } |
|
537 | - else { |
|
536 | + } |
|
537 | + else { |
|
538 | 538 | $form = NULL; |
539 | 539 | $form['from'] = array( |
540 | - '#type' => 'item', |
|
541 | - '#value' => 'You do not have permission to post comments in this forum.', |
|
540 | + '#type' => 'item', |
|
541 | + '#value' => 'You do not have permission to post comments in this forum.', |
|
542 | 542 | ); |
543 | - } |
|
543 | + } |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | break; |
547 | 547 | |
548 | - // Forum node form |
|
549 | - case 'forum_node_form': |
|
548 | + // Forum node form |
|
549 | + case 'forum_node_form': |
|
550 | 550 | case 'team_forum_node_form': |
551 | 551 | $forum_id = key($form['#node']->taxonomy); |
552 | 552 | $form['buttons']['separator_bottom'] = array( |
553 | - '#value' => '<div class="separator buttons"></div>', |
|
554 | - '#weight' => 999, |
|
553 | + '#value' => '<div class="separator buttons"></div>', |
|
554 | + '#weight' => 999, |
|
555 | 555 | ); |
556 | 556 | |
557 | 557 | // Wrap action buttons for styling consistency |
558 | 558 | $form['buttons']['form control tabs prefix'] = array( |
559 | - '#value' => '<ul class="form-control tab-list">', |
|
560 | - '#weight' => 1001, |
|
559 | + '#value' => '<ul class="form-control tab-list">', |
|
560 | + '#weight' => 1001, |
|
561 | 561 | ); |
562 | 562 | $form['buttons']['submit']['#prefix'] = '<li class="first tab">'; |
563 | 563 | $form['buttons']['submit']['#value'] = bts('Post topic', array(), NULL, 'boinc:post-forum-comment'); |
@@ -570,28 +570,28 @@ discard block |
||
570 | 570 | $form['buttons']['preview_changes']['#suffix'] = '</li>'; |
571 | 571 | $form['buttons']['preview_changes']['#weight'] = 1004; |
572 | 572 | $form['buttons']['cancel'] = array( |
573 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "community/forum/{$forum_id}") . '</li>', |
|
574 | - '#weight' => 1005, |
|
573 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "community/forum/{$forum_id}") . '</li>', |
|
574 | + '#weight' => 1005, |
|
575 | 575 | ); |
576 | 576 | $form['buttons']['form control tabs suffix'] = array( |
577 | - '#value' => '</ul>', |
|
578 | - '#weight' => 1010, |
|
577 | + '#value' => '</ul>', |
|
578 | + '#weight' => 1010, |
|
579 | 579 | ); |
580 | 580 | |
581 | 581 | // Add captcha for role='community member' |
582 | 582 | $community_role = array_search('community member', user_roles(true)); |
583 | 583 | $unrestricted_role = array_search('verified contributor', user_roles(true)); |
584 | 584 | if ( (isset($account->roles[$community_role])) and (!isset($account->roles[$unrestricted_role])) ) { |
585 | - if (module_exists('captcha')) { |
|
585 | + if (module_exists('captcha')) { |
|
586 | 586 | $form['comment_captcha'] = array( |
587 | - '#type' => 'captcha', |
|
588 | - '#weight' => 1000, |
|
587 | + '#type' => 'captcha', |
|
588 | + '#weight' => 1000, |
|
589 | 589 | ); |
590 | - } |
|
590 | + } |
|
591 | 591 | } |
592 | 592 | |
593 | 593 | break; |
594 | - case 'boinccore_delete_confirm': |
|
594 | + case 'boinccore_delete_confirm': |
|
595 | 595 | // Wrap action buttons for styling consistency |
596 | 596 | $form['actions']['#prefix'] = '<ul class="form-control tab-list">'; |
597 | 597 | $form['actions']['#suffix'] = '</ul>'; |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | $form['actions']['cancel']['#prefix'] = '<li class="tab">'; |
602 | 602 | $form['actions']['cancel']['#suffix'] = '</li>'; |
603 | 603 | break; |
604 | - default: |
|
604 | + default: |
|
605 | 605 | } |
606 | 606 | } |
607 | 607 | |
@@ -609,61 +609,61 @@ discard block |
||
609 | 609 | * Implementation of hook_link_alter() |
610 | 610 | */ |
611 | 611 | function boinccore_link_alter(&$links, $node, $comment = NULL) { |
612 | - //echo '<pre>' . print_r($links, true) . '</pre>'; |
|
613 | - foreach ($links as $module => $link) { |
|
612 | + //echo '<pre>' . print_r($links, true) . '</pre>'; |
|
613 | + foreach ($links as $module => $link) { |
|
614 | 614 | // Remove the ignore user link |
615 | 615 | if (strstr($module, 'ignore_user')) { |
616 | - unset($links[$module]); |
|
616 | + unset($links[$module]); |
|
617 | 617 | } |
618 | - } |
|
619 | - // Node first, then comment: to be consistent with boinccore_link() function |
|
620 | - if (!($comment)) { |
|
618 | + } |
|
619 | + // Node first, then comment: to be consistent with boinccore_link() function |
|
620 | + if (!($comment)) { |
|
621 | 621 | // modify the comment_add link |
622 | 622 | if (isset($links['comment_add'])) { |
623 | - $links['comment_add']['title'] = bts('reply', array(), NULL, 'boinc:forum-reply-to-comment'); |
|
624 | - $links['comment_add']['attributes'] = array( |
|
625 | - 'title' => bts('Reply to this comment', array(), NULL, 'boinc:forum-reply-to-comment') |
|
626 | - ); |
|
623 | + $links['comment_add']['title'] = bts('reply', array(), NULL, 'boinc:forum-reply-to-comment'); |
|
624 | + $links['comment_add']['attributes'] = array( |
|
625 | + 'title' => bts('Reply to this comment', array(), NULL, 'boinc:forum-reply-to-comment') |
|
626 | + ); |
|
627 | 627 | } |
628 | 628 | // modify quote link |
629 | 629 | if (isset($links['quote'])) { |
630 | - $links['quote']['attributes'] = array( |
|
631 | - 'title' => bts('Reply to this topic with a quote', array(), NULL, 'boinc:forum-reply-to-comment') |
|
632 | - ); |
|
630 | + $links['quote']['attributes'] = array( |
|
631 | + 'title' => bts('Reply to this topic with a quote', array(), NULL, 'boinc:forum-reply-to-comment') |
|
632 | + ); |
|
633 | 633 | } |
634 | - } |
|
635 | - else { |
|
634 | + } |
|
635 | + else { |
|
636 | 636 | // Standard EDIT, DELETE, and REPLY links are created by Drupal, but we want to alter them |
637 | 637 | if (isset($links['comment_delete'])) { |
638 | - $links['comment_delete']['attributes'] = array( |
|
639 | - 'title' => bts('Delete this comment', array(), NULL, 'boinc:forum-delete-comment') |
|
640 | - ); |
|
638 | + $links['comment_delete']['attributes'] = array( |
|
639 | + 'title' => bts('Delete this comment', array(), NULL, 'boinc:forum-delete-comment') |
|
640 | + ); |
|
641 | 641 | } |
642 | 642 | if (isset($links['comment_edit'])) { |
643 | - $links['comment_edit']['attributes'] = array( |
|
644 | - 'title' => bts('Edit this comment', array(), NULL, 'boinc:forum-edit-comment') |
|
645 | - ); |
|
643 | + $links['comment_edit']['attributes'] = array( |
|
644 | + 'title' => bts('Edit this comment', array(), NULL, 'boinc:forum-edit-comment') |
|
645 | + ); |
|
646 | 646 | } |
647 | 647 | if (isset($links['comment_reply'])) { |
648 | - $links['comment_reply']['attributes'] = array( |
|
649 | - 'title' => bts('Reply to this comment', array(), NULL, 'boinc:forum-reply-to-comment') |
|
650 | - ); |
|
648 | + $links['comment_reply']['attributes'] = array( |
|
649 | + 'title' => bts('Reply to this comment', array(), NULL, 'boinc:forum-reply-to-comment') |
|
650 | + ); |
|
651 | 651 | } |
652 | - }// if !$comment |
|
652 | + }// if !$comment |
|
653 | 653 | } |
654 | 654 | |
655 | 655 | /** |
656 | 656 | * Implementation of hook_locale(). |
657 | 657 | */ |
658 | 658 | function boinccore_locale($op = 'groups', $group = NULL) { |
659 | - switch ($op) { |
|
659 | + switch ($op) { |
|
660 | 660 | case 'groups': |
661 | 661 | return array('boinc' => 'BOINC'); |
662 | 662 | case 'info': |
663 | 663 | //$info['boinc']['refresh callback'] = 'boinccore_locale_refresh'; |
664 | 664 | $info['boinc']['format'] = FALSE; |
665 | - return $info; |
|
666 | - } |
|
665 | + return $info; |
|
666 | + } |
|
667 | 667 | } |
668 | 668 | |
669 | 669 | |
@@ -671,71 +671,71 @@ discard block |
||
671 | 671 | * Implementation of hook_link() |
672 | 672 | */ |
673 | 673 | function boinccore_link($type, $object, $teaser = FALSE) { |
674 | - // Add custom links with this hook |
|
674 | + // Add custom links with this hook |
|
675 | 675 | |
676 | - if ($type=='node') { |
|
676 | + if ($type=='node') { |
|
677 | 677 | if ( ($object->type=='forum') OR ($object->type=='team_forum') ) { |
678 | - // Add topic moderator controls |
|
679 | - if (user_access('edit any forum topic')) { |
|
678 | + // Add topic moderator controls |
|
679 | + if (user_access('edit any forum topic')) { |
|
680 | 680 | $node_control = "node_control/{$object->nid}"; |
681 | 681 | if ($object->sticky) { |
682 | - $links['make_unsticky'] = array( |
|
683 | - 'title' => bts('Make unsticky', array(), NULL, 'boinc:forum-unsticky-comment'), |
|
684 | - 'href' => "{$node_control}/unsticky", |
|
685 | - 'attributes' => array( |
|
686 | - 'title' => bts('Remove sticky status from this topic', array(), NULL, 'boinc:forum-unsticky-comment') |
|
687 | - ) |
|
688 | - ); |
|
682 | + $links['make_unsticky'] = array( |
|
683 | + 'title' => bts('Make unsticky', array(), NULL, 'boinc:forum-unsticky-comment'), |
|
684 | + 'href' => "{$node_control}/unsticky", |
|
685 | + 'attributes' => array( |
|
686 | + 'title' => bts('Remove sticky status from this topic', array(), NULL, 'boinc:forum-unsticky-comment') |
|
687 | + ) |
|
688 | + ); |
|
689 | 689 | } |
690 | 690 | else { |
691 | - $links['make_sticky'] = array( |
|
692 | - 'title' => bts('Make sticky', array(), NULL, 'boinc:forum-sticky-comment'), |
|
693 | - 'href' => "{$node_control}/sticky", |
|
694 | - 'attributes' => array( |
|
695 | - 'title' => bts('Make this topic sticky', array(), NULL, 'boinc:forum-sticky-comment') |
|
696 | - ) |
|
697 | - ); |
|
691 | + $links['make_sticky'] = array( |
|
692 | + 'title' => bts('Make sticky', array(), NULL, 'boinc:forum-sticky-comment'), |
|
693 | + 'href' => "{$node_control}/sticky", |
|
694 | + 'attributes' => array( |
|
695 | + 'title' => bts('Make this topic sticky', array(), NULL, 'boinc:forum-sticky-comment') |
|
696 | + ) |
|
697 | + ); |
|
698 | 698 | } |
699 | 699 | if ($object->comment == COMMENT_NODE_READ_WRITE) { |
700 | - $links['lock'] = array( |
|
701 | - 'title' => bts('Lock', array(), NULL, 'boinc:forum-lock-comment'), |
|
702 | - 'href' => "{$node_control}/lock", |
|
703 | - 'attributes' => array( |
|
704 | - 'title' => bts('Lock this thread for comments', array(), NULL, 'boinc:forum-lock-comment') |
|
705 | - ) |
|
706 | - ); |
|
700 | + $links['lock'] = array( |
|
701 | + 'title' => bts('Lock', array(), NULL, 'boinc:forum-lock-comment'), |
|
702 | + 'href' => "{$node_control}/lock", |
|
703 | + 'attributes' => array( |
|
704 | + 'title' => bts('Lock this thread for comments', array(), NULL, 'boinc:forum-lock-comment') |
|
705 | + ) |
|
706 | + ); |
|
707 | 707 | } |
708 | 708 | else { |
709 | - $links['unlock'] = array( |
|
710 | - 'title' => bts('Unlock', array(), NULL, 'boinc:forum-unlock-comment'), |
|
711 | - 'href' => "{$node_control}/unlock", |
|
712 | - 'attributes' => array( |
|
713 | - 'title' => bts('Unlock this thread for comments', array(), NULL, 'boinc:forum-unlock-comment') |
|
714 | - ) |
|
715 | - ); |
|
709 | + $links['unlock'] = array( |
|
710 | + 'title' => bts('Unlock', array(), NULL, 'boinc:forum-unlock-comment'), |
|
711 | + 'href' => "{$node_control}/unlock", |
|
712 | + 'attributes' => array( |
|
713 | + 'title' => bts('Unlock this thread for comments', array(), NULL, 'boinc:forum-unlock-comment') |
|
714 | + ) |
|
715 | + ); |
|
716 | 716 | } |
717 | 717 | if ($object->status) { |
718 | - $links['hide'] = array( |
|
719 | - 'title' => bts('Hide', array(), NULL, 'boinc:forum-hide-comment'), |
|
720 | - 'href' => "{$node_control}/hide", |
|
721 | - 'attributes' => array( |
|
722 | - 'title' => bts('Hide this topic', array(), NULL, 'boinc:forum-hide-comment') |
|
723 | - ) |
|
724 | - ); |
|
718 | + $links['hide'] = array( |
|
719 | + 'title' => bts('Hide', array(), NULL, 'boinc:forum-hide-comment'), |
|
720 | + 'href' => "{$node_control}/hide", |
|
721 | + 'attributes' => array( |
|
722 | + 'title' => bts('Hide this topic', array(), NULL, 'boinc:forum-hide-comment') |
|
723 | + ) |
|
724 | + ); |
|
725 | 725 | } |
726 | 726 | else { |
727 | - $links['unhide'] = array( |
|
728 | - 'title' => bts('Unhide', array(), NULL, 'boinc:forum-unhide-comment'), |
|
729 | - 'href' => "{$node_control}/unhide", |
|
730 | - 'attributes' => array( |
|
731 | - 'title' => bts('Unhide this topic', array(), NULL, 'boinc:forum-unhide-comment') |
|
732 | - ) |
|
733 | - ); |
|
727 | + $links['unhide'] = array( |
|
728 | + 'title' => bts('Unhide', array(), NULL, 'boinc:forum-unhide-comment'), |
|
729 | + 'href' => "{$node_control}/unhide", |
|
730 | + 'attributes' => array( |
|
731 | + 'title' => bts('Unhide this topic', array(), NULL, 'boinc:forum-unhide-comment') |
|
732 | + ) |
|
733 | + ); |
|
734 | 734 | } |
735 | - }// if user_access('edit any forum topic') |
|
735 | + }// if user_access('edit any forum topic') |
|
736 | 736 | } |
737 | - } |
|
738 | - else if ($type=='comment') { |
|
737 | + } |
|
738 | + else if ($type=='comment') { |
|
739 | 739 | $node = node_load($object->nid); |
740 | 740 | $nid = $object->nid; |
741 | 741 | $cid = $object->cid; |
@@ -755,10 +755,10 @@ discard block |
||
755 | 755 | // HIDE and COVERT comment |
756 | 756 | // The following are moderator only links |
757 | 757 | if (user_access('administer comments')) { |
758 | - $comment_control = "comment_control/{$cid}"; |
|
759 | - // Add link to convert comment into a new topic |
|
760 | - $reply_count = db_result(db_query(' SELECT COUNT(*) FROM comments WHERE pid = %d', $cid )); |
|
761 | - if ($reply_count == 0) { |
|
758 | + $comment_control = "comment_control/{$cid}"; |
|
759 | + // Add link to convert comment into a new topic |
|
760 | + $reply_count = db_result(db_query(' SELECT COUNT(*) FROM comments WHERE pid = %d', $cid )); |
|
761 | + if ($reply_count == 0) { |
|
762 | 762 | $links['convert'] = array( |
763 | 763 | 'title' => bts('Convert', array(), NULL, 'boinc:forum-convert-comment-to-topic'), |
764 | 764 | 'href' => "{$comment_control}/convert", |
@@ -766,9 +766,9 @@ discard block |
||
766 | 766 | 'title' => bts('Convert this comment to a new topic', array(), NULL, 'boinc:forum-convert-comment-to-topic') |
767 | 767 | ) |
768 | 768 | ); |
769 | - } |
|
770 | - // Add hide link |
|
771 | - if ($object->status == 0) { |
|
769 | + } |
|
770 | + // Add hide link |
|
771 | + if ($object->status == 0) { |
|
772 | 772 | $links['hide'] = array( |
773 | 773 | 'title' => bts('Hide', array(), NULL, 'boinc:forum-hide-comment'), |
774 | 774 | 'href' => "{$comment_control}/hide", |
@@ -776,8 +776,8 @@ discard block |
||
776 | 776 | 'title' => bts('Hide this comment', array(), NULL, 'boinc:forum-hide-comment') |
777 | 777 | ) |
778 | 778 | ); |
779 | - } |
|
780 | - else { |
|
779 | + } |
|
780 | + else { |
|
781 | 781 | $links['unhide'] = array( |
782 | 782 | 'title' => bts('Unhide', array(), NULL, 'boinc:forum-unhide-comment'), |
783 | 783 | 'href' => "{$comment_control}/unhide", |
@@ -785,27 +785,27 @@ discard block |
||
785 | 785 | 'title' => bts('Unhide this comment', array(), NULL, 'boinc:forum-unhide-comment') |
786 | 786 | ) |
787 | 787 | ); |
788 | - } |
|
788 | + } |
|
789 | 789 | }// if user_access('administer comments') |
790 | - }//if $type |
|
790 | + }//if $type |
|
791 | 791 | |
792 | - return $links; |
|
792 | + return $links; |
|
793 | 793 | } |
794 | 794 | |
795 | 795 | /** |
796 | 796 | * Implementation of hook_mail_alter() |
797 | 797 | */ |
798 | 798 | function boinccore_mail_alter(&$message) { |
799 | - /* This code alters the headers for all emails sent by the Drupal Web site to use |
|
799 | + /* This code alters the headers for all emails sent by the Drupal Web site to use |
|
800 | 800 | 'Quote-Printable' as the encoding, both altering the header and modifies the body to the |
801 | 801 | new encoding. |
802 | 802 | */ |
803 | - $message['headers']['Content-Transfer-Encoding'] = 'Quoted-Printable'; |
|
804 | - if (is_array($message['body'])) { |
|
803 | + $message['headers']['Content-Transfer-Encoding'] = 'Quoted-Printable'; |
|
804 | + if (is_array($message['body'])) { |
|
805 | 805 | $message['body'] = array_map( "quoted_printable_encode", $message['body'] ); |
806 | - } else { |
|
806 | + } else { |
|
807 | 807 | $message['body'] = quoted_printable_encode($message['body']); |
808 | - } |
|
808 | + } |
|
809 | 809 | } |
810 | 810 | |
811 | 811 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -818,45 +818,45 @@ discard block |
||
818 | 818 | * link rather than through the node form. |
819 | 819 | */ |
820 | 820 | function boinccore_node_control($nid = NULL, $action = NULL) { |
821 | - if ((!$nid OR !$node = node_load($nid)) OR |
|
821 | + if ((!$nid OR !$node = node_load($nid)) OR |
|
822 | 822 | ($node->type == 'forum' AND !user_access('edit any forum topic')) OR |
823 | 823 | ($node->type != 'forum' AND !user_access('administer nodes'))) { |
824 | 824 | // What are you even doing here... |
825 | 825 | return FALSE; |
826 | - } |
|
827 | - switch ($action) { |
|
828 | - case 'unhide': |
|
826 | + } |
|
827 | + switch ($action) { |
|
828 | + case 'unhide': |
|
829 | 829 | node_publish_action($node); |
830 | 830 | break; |
831 | - case 'hide': |
|
831 | + case 'hide': |
|
832 | 832 | node_unpublish_action($node); |
833 | 833 | break; |
834 | - case 'sticky': |
|
834 | + case 'sticky': |
|
835 | 835 | node_make_sticky_action($node); |
836 | 836 | break; |
837 | - case 'unsticky': |
|
837 | + case 'unsticky': |
|
838 | 838 | node_make_unsticky_action($node); |
839 | 839 | break; |
840 | - case 'lock': |
|
840 | + case 'lock': |
|
841 | 841 | $node->comment = 1; |
842 | 842 | watchdog('action', 'Locked comments on @type %title.', array( |
843 | - '@type' => node_get_types('name', $node), '%title' => $node->title)); |
|
843 | + '@type' => node_get_types('name', $node), '%title' => $node->title)); |
|
844 | 844 | break; |
845 | - case 'unlock': |
|
845 | + case 'unlock': |
|
846 | 846 | $node->comment = 2; |
847 | 847 | watchdog('action', 'Unlocked comments on @type %title.', array( |
848 | - '@type' => node_get_types('name', $node), '%title' => $node->title)); |
|
848 | + '@type' => node_get_types('name', $node), '%title' => $node->title)); |
|
849 | 849 | break; |
850 | - default: |
|
850 | + default: |
|
851 | 851 | } |
852 | - node_save($node); |
|
853 | - // If hiding a forum topic (node) and not an administrator, go to |
|
854 | - // the forum page. Otherwise the user will reach an access-denied |
|
855 | - // page. |
|
856 | - if (($action=="hide") and (!user_access('administer forums'))) { |
|
852 | + node_save($node); |
|
853 | + // If hiding a forum topic (node) and not an administrator, go to |
|
854 | + // the forum page. Otherwise the user will reach an access-denied |
|
855 | + // page. |
|
856 | + if (($action=="hide") and (!user_access('administer forums'))) { |
|
857 | 857 | drupal_goto("community/forum/{$node->tid}"); |
858 | - } |
|
859 | - drupal_goto("node/{$nid}"); |
|
858 | + } |
|
859 | + drupal_goto("node/{$nid}"); |
|
860 | 860 | } |
861 | 861 | |
862 | 862 | /** |
@@ -865,28 +865,28 @@ discard block |
||
865 | 865 | * through the comment edit form. |
866 | 866 | */ |
867 | 867 | function boinccore_comment_control($cid = NULL, $action = NULL) { |
868 | - if (!$cid OR !$comment = _comment_load($cid)) { |
|
868 | + if (!$cid OR !$comment = _comment_load($cid)) { |
|
869 | 869 | // What are you even doing here... |
870 | 870 | return FALSE; |
871 | - } |
|
872 | - $return_path = "node/{$comment->nid}"; |
|
873 | - $return_anchor = "comment-{$cid}"; |
|
874 | - switch ($action) { |
|
875 | - case 'unhide': |
|
871 | + } |
|
872 | + $return_path = "node/{$comment->nid}"; |
|
873 | + $return_anchor = "comment-{$cid}"; |
|
874 | + switch ($action) { |
|
875 | + case 'unhide': |
|
876 | 876 | comment_publish_action($comment); |
877 | 877 | rules_invoke_event('boinccore_comment_unhidden', $comment); |
878 | 878 | if (module_exists("boinc_solr_comments")) { |
879 | - boinc_solr_comments_publish($comment); |
|
879 | + boinc_solr_comments_publish($comment); |
|
880 | 880 | } |
881 | 881 | break; |
882 | - case 'hide': |
|
882 | + case 'hide': |
|
883 | 883 | comment_unpublish_action($comment); |
884 | 884 | rules_invoke_event('comment_unpublish', $comment); |
885 | 885 | if (module_exists("boinc_solr_comments")) { |
886 | - boinc_solr_comments_unpublish($comment); |
|
886 | + boinc_solr_comments_unpublish($comment); |
|
887 | 887 | } |
888 | 888 | break; |
889 | - case 'convert': |
|
889 | + case 'convert': |
|
890 | 890 | $node = new stdClass(); |
891 | 891 | $node->name = $comment->subject; |
892 | 892 | $node->title = $node->name; |
@@ -906,7 +906,7 @@ discard block |
||
906 | 906 | $node->tid = $parent_node->tid; |
907 | 907 | |
908 | 908 | if (filter_access($comment->format)) { |
909 | - $node->format = $comment->format; |
|
909 | + $node->format = $comment->format; |
|
910 | 910 | } |
911 | 911 | |
912 | 912 | // Save the new node |
@@ -922,9 +922,9 @@ discard block |
||
922 | 922 | $return_path = "node/{$node->nid}"; |
923 | 923 | $return_anchor = NULL; |
924 | 924 | break; |
925 | - default: |
|
925 | + default: |
|
926 | 926 | } |
927 | - drupal_goto($return_path, NULL, $return_anchor); |
|
927 | + drupal_goto($return_path, NULL, $return_anchor); |
|
928 | 928 | } |
929 | 929 | |
930 | 930 | /** |
@@ -932,7 +932,7 @@ discard block |
||
932 | 932 | * Get the authenticator for a given account |
933 | 933 | */ |
934 | 934 | function boinccore_lookup_account() { |
935 | - include_boinc('user/lookup_account.php'); |
|
935 | + include_boinc('user/lookup_account.php'); |
|
936 | 936 | } |
937 | 937 | |
938 | 938 | /** |
@@ -940,29 +940,29 @@ discard block |
||
940 | 940 | * Get assorted details for a given account |
941 | 941 | */ |
942 | 942 | function boinccore_am_get_info() { |
943 | - // Remove q from the GET request or BOINC will panic |
|
944 | - unset($_GET['q']); |
|
945 | - // Capture the XML output of the RPC so we can override things |
|
946 | - ob_start(); |
|
947 | - include_boinc('user/am_get_info.php'); |
|
948 | - $xml = ob_get_clean(); |
|
949 | - $xml = load_configuration($xml); |
|
950 | - // See if the account has an approved profile in Drupal |
|
951 | - $uid = !empty($xml['am_get_info_reply']['id']) ? boincuser_lookup_uid($xml['am_get_info_reply']['id']) : 0; |
|
952 | - if ($uid) { |
|
943 | + // Remove q from the GET request or BOINC will panic |
|
944 | + unset($_GET['q']); |
|
945 | + // Capture the XML output of the RPC so we can override things |
|
946 | + ob_start(); |
|
947 | + include_boinc('user/am_get_info.php'); |
|
948 | + $xml = ob_get_clean(); |
|
949 | + $xml = load_configuration($xml); |
|
950 | + // See if the account has an approved profile in Drupal |
|
951 | + $uid = !empty($xml['am_get_info_reply']['id']) ? boincuser_lookup_uid($xml['am_get_info_reply']['id']) : 0; |
|
952 | + if ($uid) { |
|
953 | 953 | $content_profile = content_profile_load('profile', $uid); |
954 | 954 | $profile_is_approved = ($content_profile->status AND !$content_profile->moderate); |
955 | 955 | $country = check_plain($content_profile->field_country[0]['value']); |
956 | 956 | $website = ''; |
957 | 957 | if ($profile_is_approved) { |
958 | - $website = check_plain($content_profile->field_url[0]['value']); |
|
958 | + $website = check_plain($content_profile->field_url[0]['value']); |
|
959 | 959 | } |
960 | 960 | // Override BOINC values with Drupal values as needed |
961 | 961 | $xml['am_get_info_reply']['has_profile']['@value'] = ($profile_is_approved) ? 1 : 0; |
962 | 962 | $xml['am_get_info_reply']['country']['@value'] = $country; |
963 | 963 | $xml['am_get_info_reply']['url']['@value'] = $website; |
964 | - } |
|
965 | - print save_configuration($xml); |
|
964 | + } |
|
965 | + print save_configuration($xml); |
|
966 | 966 | } |
967 | 967 | |
968 | 968 | /** |
@@ -970,75 +970,75 @@ discard block |
||
970 | 970 | * Update assorted details for a given account |
971 | 971 | */ |
972 | 972 | function boinccore_am_set_info() { |
973 | - // Remove q from the GET request or BOINC will panic |
|
974 | - unset($_GET['q']); |
|
975 | - // Validate the XML prefs (in case BOINC does not) |
|
976 | - $global_prefs = !empty($_POST['global_prefs']) ? $_POST['global_prefs'] : (!empty($_GET['global_prefs']) ? $_GET['global_prefs'] : NULL); |
|
977 | - $project_prefs = !empty($_POST['project_prefs']) ? $_POST['project_prefs'] : (!empty($_GET['project_prefs']) ? $_GET['project_prefs'] : NULL); |
|
978 | - libxml_use_internal_errors(true); |
|
979 | - $xml = new DomDocument(); |
|
980 | - if ($global_prefs) { |
|
973 | + // Remove q from the GET request or BOINC will panic |
|
974 | + unset($_GET['q']); |
|
975 | + // Validate the XML prefs (in case BOINC does not) |
|
976 | + $global_prefs = !empty($_POST['global_prefs']) ? $_POST['global_prefs'] : (!empty($_GET['global_prefs']) ? $_GET['global_prefs'] : NULL); |
|
977 | + $project_prefs = !empty($_POST['project_prefs']) ? $_POST['project_prefs'] : (!empty($_GET['project_prefs']) ? $_GET['project_prefs'] : NULL); |
|
978 | + libxml_use_internal_errors(true); |
|
979 | + $xml = new DomDocument(); |
|
980 | + if ($global_prefs) { |
|
981 | 981 | $xml->loadXML($global_prefs, LIBXML_NOBLANKS); |
982 | 982 | if ($errors = libxml_get_errors($xml)) { |
983 | - $lines = explode("\r", $global_prefs); |
|
984 | - watchdog('am_set_info', "XML validation error in global_prefs: {$errors[0]->message} at line {$errors[0]->line}" . |
|
983 | + $lines = explode("\r", $global_prefs); |
|
984 | + watchdog('am_set_info', "XML validation error in global_prefs: {$errors[0]->message} at line {$errors[0]->line}" . |
|
985 | 985 | ': <br/>' . htmlentities($lines[$errors[0]->line - 1]), array(), WATCHDOG_ERROR); |
986 | 986 | } |
987 | - } |
|
988 | - elseif ($project_prefs) { |
|
987 | + } |
|
988 | + elseif ($project_prefs) { |
|
989 | 989 | $xml->loadXML($project_prefs, LIBXML_NOBLANKS); |
990 | 990 | if ($errors = libxml_get_errors($xml)) { |
991 | - $lines = explode("\r", $project_prefs); |
|
992 | - watchdog('am_set_info', "XML validation error in project_prefs: {$errors[0]->message} at line {$errors[0]->line}" . |
|
991 | + $lines = explode("\r", $project_prefs); |
|
992 | + watchdog('am_set_info', "XML validation error in project_prefs: {$errors[0]->message} at line {$errors[0]->line}" . |
|
993 | 993 | ': <br/>' . htmlentities($lines[$errors[0]->line - 1]), array(), WATCHDOG_ERROR); |
994 | 994 | } |
995 | - } |
|
996 | - if (!$errors) { |
|
995 | + } |
|
996 | + if (!$errors) { |
|
997 | 997 | // Capture the XML output of the RPC so we can override things |
998 | 998 | ob_start(); |
999 | 999 | include_boinc('user/am_set_info.php'); |
1000 | 1000 | $xml = ob_get_clean(); |
1001 | 1001 | $xml = load_configuration($xml); |
1002 | 1002 | if (isset($xml['am_set_info_reply']['success'])) { |
1003 | - // Find the account in Drupal |
|
1004 | - $boinc_auth = !empty($_POST['account_key']) ? $_POST['account_key'] : $_GET['account_key']; |
|
1005 | - db_set_active('boinc_rw'); |
|
1006 | - $boinc_id = db_result(db_query(" |
|
1003 | + // Find the account in Drupal |
|
1004 | + $boinc_auth = !empty($_POST['account_key']) ? $_POST['account_key'] : $_GET['account_key']; |
|
1005 | + db_set_active('boinc_rw'); |
|
1006 | + $boinc_id = db_result(db_query(" |
|
1007 | 1007 | SELECT id |
1008 | 1008 | FROM {user} |
1009 | 1009 | WHERE authenticator = '%s'", |
1010 | 1010 | $boinc_auth |
1011 | - )); |
|
1012 | - db_set_active('default'); |
|
1013 | - $uid = boincuser_lookup_uid($boinc_id); |
|
1011 | + )); |
|
1012 | + db_set_active('default'); |
|
1013 | + $uid = boincuser_lookup_uid($boinc_id); |
|
1014 | 1014 | |
1015 | - // Apply any relevant updates to the Drupal account, also |
|
1016 | - $country = !empty($_POST['country']) ? $_POST['country'] : (!empty($_GET['country']) ? $_GET['country'] : NULL); |
|
1017 | - $url = !empty($_POST['url']) ? $_POST['url'] : (!empty($_GET['url']) ? $_GET['url'] : NULL); |
|
1018 | - $email_addr = !empty($_POST['email_addr']) ? $_POST['email_addr'] : (!empty($_GET['email_addr']) ? $_GET['email_addr'] : NULL); |
|
1015 | + // Apply any relevant updates to the Drupal account, also |
|
1016 | + $country = !empty($_POST['country']) ? $_POST['country'] : (!empty($_GET['country']) ? $_GET['country'] : NULL); |
|
1017 | + $url = !empty($_POST['url']) ? $_POST['url'] : (!empty($_GET['url']) ? $_GET['url'] : NULL); |
|
1018 | + $email_addr = !empty($_POST['email_addr']) ? $_POST['email_addr'] : (!empty($_GET['email_addr']) ? $_GET['email_addr'] : NULL); |
|
1019 | 1019 | |
1020 | - if ($email_addr) { |
|
1020 | + if ($email_addr) { |
|
1021 | 1021 | $account = user_load($uid); |
1022 | 1022 | user_save($account, array('mail' => $email_addr)); |
1023 | - } |
|
1024 | - if ($country OR $url) { |
|
1023 | + } |
|
1024 | + if ($country OR $url) { |
|
1025 | 1025 | $content_profile = content_profile_load('profile', $uid); |
1026 | 1026 | if ($country) $content_profile->field_country[0]['value'] = $country; |
1027 | 1027 | if ($url) $content_profile->field_url[0]['value'] = $url; |
1028 | 1028 | node_save($content_profile); |
1029 | - } |
|
1029 | + } |
|
1030 | 1030 | } |
1031 | - } |
|
1032 | - else { |
|
1031 | + } |
|
1032 | + else { |
|
1033 | 1033 | $xml = array( |
1034 | - 'error' => array( |
|
1034 | + 'error' => array( |
|
1035 | 1035 | 'error_num' => -112, |
1036 | 1036 | 'error_msg' => "{$errors[0]->message} at line {$errors[0]->line}" . |
1037 | 1037 | ': <br/>' . htmlentities($lines[$errors[0]->line - 1]) |
1038 | - ), |
|
1038 | + ), |
|
1039 | 1039 | ); |
1040 | - } |
|
1041 | - print save_configuration($xml); |
|
1040 | + } |
|
1041 | + print save_configuration($xml); |
|
1042 | 1042 | } |
1043 | 1043 | |
1044 | 1044 | /** |
@@ -1046,17 +1046,17 @@ discard block |
||
1046 | 1046 | * Update the venue for the given host |
1047 | 1047 | */ |
1048 | 1048 | function boinccore_am_set_host_info() { |
1049 | - // Remove q from the GET request or BOINC will panic |
|
1050 | - unset($_GET['q']); |
|
1051 | - // Capture the XML output of the RPC so we can override things |
|
1052 | - ob_start(); |
|
1053 | - include_boinc('user/am_set_host_info.php'); |
|
1054 | - $xml = ob_get_clean(); |
|
1055 | - $xml = load_configuration($xml); |
|
1056 | - if (isset($xml['am_set_host_info_reply']['success'])) { |
|
1049 | + // Remove q from the GET request or BOINC will panic |
|
1050 | + unset($_GET['q']); |
|
1051 | + // Capture the XML output of the RPC so we can override things |
|
1052 | + ob_start(); |
|
1053 | + include_boinc('user/am_set_host_info.php'); |
|
1054 | + $xml = ob_get_clean(); |
|
1055 | + $xml = load_configuration($xml); |
|
1056 | + if (isset($xml['am_set_host_info_reply']['success'])) { |
|
1057 | 1057 | // Override anything that needs overriding |
1058 | - } |
|
1059 | - print save_configuration($xml); |
|
1058 | + } |
|
1059 | + print save_configuration($xml); |
|
1060 | 1060 | } |
1061 | 1061 | |
1062 | 1062 | /** |
@@ -1064,29 +1064,29 @@ discard block |
||
1064 | 1064 | * Get assorted details for a given account |
1065 | 1065 | */ |
1066 | 1066 | function boinccore_show_user() { |
1067 | - // Remove q from the GET request or BOINC will panic |
|
1068 | - unset($_GET['q']); |
|
1069 | - // Capture the XML output of the RPC so we can override things |
|
1070 | - ob_start(); |
|
1071 | - include_boinc('user/show_user.php'); |
|
1072 | - $xml = ob_get_clean(); |
|
1073 | - $xml = load_configuration($xml); |
|
1074 | - // See if the account has an approved profile in Drupal |
|
1075 | - $uid = !empty($xml['user']['id']) ? boincuser_lookup_uid($xml['user']['id']) : 0; |
|
1076 | - if ($uid) { |
|
1067 | + // Remove q from the GET request or BOINC will panic |
|
1068 | + unset($_GET['q']); |
|
1069 | + // Capture the XML output of the RPC so we can override things |
|
1070 | + ob_start(); |
|
1071 | + include_boinc('user/show_user.php'); |
|
1072 | + $xml = ob_get_clean(); |
|
1073 | + $xml = load_configuration($xml); |
|
1074 | + // See if the account has an approved profile in Drupal |
|
1075 | + $uid = !empty($xml['user']['id']) ? boincuser_lookup_uid($xml['user']['id']) : 0; |
|
1076 | + if ($uid) { |
|
1077 | 1077 | $content_profile = content_profile_load('profile', $uid); |
1078 | 1078 | $profile_is_approved = ($content_profile->status AND !$content_profile->moderate); |
1079 | 1079 | $country = check_plain($content_profile->field_country[0]['value']); |
1080 | 1080 | $website = ''; |
1081 | 1081 | if ($profile_is_approved) { |
1082 | - $website = check_plain($content_profile->field_url[0]['value']); |
|
1082 | + $website = check_plain($content_profile->field_url[0]['value']); |
|
1083 | 1083 | } |
1084 | 1084 | // Override BOINC values with Drupal values as needed |
1085 | 1085 | $xml['user']['has_profile']['@value'] = ($profile_is_approved) ? 1 : 0; |
1086 | 1086 | $xml['user']['country']['@value'] = $country; |
1087 | 1087 | $xml['user']['url']['@value'] = $website; |
1088 | - } |
|
1089 | - print save_configuration($xml); |
|
1088 | + } |
|
1089 | + print save_configuration($xml); |
|
1090 | 1090 | } |
1091 | 1091 | |
1092 | 1092 | /** |
@@ -1094,9 +1094,9 @@ discard block |
||
1094 | 1094 | * Get pending credit information for a given account |
1095 | 1095 | */ |
1096 | 1096 | function boinccore_pending_credit() { |
1097 | - // Remove q from the GET request or BOINC will panic |
|
1098 | - unset($_GET['q']); |
|
1099 | - include_boinc('user/pending.php'); |
|
1097 | + // Remove q from the GET request or BOINC will panic |
|
1098 | + unset($_GET['q']); |
|
1099 | + include_boinc('user/pending.php'); |
|
1100 | 1100 | } |
1101 | 1101 | |
1102 | 1102 | /** |
@@ -1105,7 +1105,7 @@ discard block |
||
1105 | 1105 | */ |
1106 | 1106 | function boinccore_create_team() { |
1107 | 1107 | |
1108 | - if (module_exists('boincteam')) { |
|
1108 | + if (module_exists('boincteam')) { |
|
1109 | 1109 | module_load_include('module', 'boincteam', 'boincteam'); |
1110 | 1110 | |
1111 | 1111 | $input_format = !empty($values['format']) ? $values['format'] : 4; |
@@ -1118,9 +1118,9 @@ discard block |
||
1118 | 1118 | $xml = load_configuration($xml); |
1119 | 1119 | |
1120 | 1120 | if (isset($xml['create_team_reply']['success'])) { |
1121 | - $boincteam_id = isset($xml['create_team_reply']['team_id']['@value']) ? $xml['create_team_reply']['team_id']['@value'] : 0; |
|
1121 | + $boincteam_id = isset($xml['create_team_reply']['team_id']['@value']) ? $xml['create_team_reply']['team_id']['@value'] : 0; |
|
1122 | 1122 | |
1123 | - if ($boincteam_id) { |
|
1123 | + if ($boincteam_id) { |
|
1124 | 1124 | |
1125 | 1125 | $boincteam = boincteam_load($boincteam_id); |
1126 | 1126 | $team_owner_uid = boincuser_lookup_uid($boincteam->userid); |
@@ -1128,92 +1128,92 @@ discard block |
||
1128 | 1128 | // Create the team node in Drupal |
1129 | 1129 | |
1130 | 1130 | $values = array( |
1131 | - 'name' => isset($_GET['name']) ? $_GET['name'] : '', |
|
1132 | - 'description' => isset($_GET['description']) ? $_GET['description'] : '', |
|
1133 | - 'type' => isset($_GET['type']) ? $_GET['type'] : '', |
|
1131 | + 'name' => isset($_GET['name']) ? $_GET['name'] : '', |
|
1132 | + 'description' => isset($_GET['description']) ? $_GET['description'] : '', |
|
1133 | + 'type' => isset($_GET['type']) ? $_GET['type'] : '', |
|
1134 | 1134 | ); |
1135 | 1135 | $teaser = node_teaser($values['description']); |
1136 | 1136 | $created_time = time(); |
1137 | 1137 | |
1138 | 1138 | $node = array( |
1139 | - 'type' => 'team', |
|
1140 | - 'title' => $values['name'], |
|
1141 | - 'body' => $values['description'], |
|
1142 | - 'teaser' => $teaser, |
|
1143 | - 'uid' => $team_owner_uid, |
|
1144 | - 'path' => null, |
|
1145 | - 'status' => 1, // published or not - always publish |
|
1146 | - 'promote' => 0, |
|
1147 | - 'created' => $created_time, |
|
1148 | - 'comment' => 0, // comments disabled |
|
1149 | - 'moderate' => 0, |
|
1150 | - 'sticky' => 0, |
|
1151 | - 'format' => $input_format |
|
1139 | + 'type' => 'team', |
|
1140 | + 'title' => $values['name'], |
|
1141 | + 'body' => $values['description'], |
|
1142 | + 'teaser' => $teaser, |
|
1143 | + 'uid' => $team_owner_uid, |
|
1144 | + 'path' => null, |
|
1145 | + 'status' => 1, // published or not - always publish |
|
1146 | + 'promote' => 0, |
|
1147 | + 'created' => $created_time, |
|
1148 | + 'comment' => 0, // comments disabled |
|
1149 | + 'moderate' => 0, |
|
1150 | + 'sticky' => 0, |
|
1151 | + 'format' => $input_format |
|
1152 | 1152 | ); |
1153 | 1153 | |
1154 | 1154 | // Use pathauto function, if available, to clean up the path |
1155 | 1155 | if (module_exists('pathauto')) { |
1156 | - module_load_include('inc', 'pathauto', 'pathauto'); |
|
1157 | - $node['path'] = pathauto_cleanstring($values['name']); |
|
1156 | + module_load_include('inc', 'pathauto', 'pathauto'); |
|
1157 | + $node['path'] = pathauto_cleanstring($values['name']); |
|
1158 | 1158 | |
1159 | - $node = (object) $node; // node_save requires an object form |
|
1160 | - $team_categories = taxonomy_get_term_by_name($values['type']); |
|
1161 | - $node->taxonomy[] = $team_categories[0]; |
|
1159 | + $node = (object) $node; // node_save requires an object form |
|
1160 | + $team_categories = taxonomy_get_term_by_name($values['type']); |
|
1161 | + $node->taxonomy[] = $team_categories[0]; |
|
1162 | 1162 | |
1163 | - // Save the team node |
|
1164 | - node_save($node); |
|
1165 | - // Save the team IDs to a BOINC <--> Drupal reference table. |
|
1166 | - db_query('INSERT INTO {boincteam} (team_id, nid) VALUES (%d, %d)', $boincteam_id, $node->nid); |
|
1163 | + // Save the team node |
|
1164 | + node_save($node); |
|
1165 | + // Save the team IDs to a BOINC <--> Drupal reference table. |
|
1166 | + db_query('INSERT INTO {boincteam} (team_id, nid) VALUES (%d, %d)', $boincteam_id, $node->nid); |
|
1167 | 1167 | } |
1168 | 1168 | else { |
1169 | - $xml['create_team_reply']['warning'] = t( |
|
1169 | + $xml['create_team_reply']['warning'] = t( |
|
1170 | 1170 | 'There was a problem integrating this team into Drupal. Please |
1171 | 1171 | contact @project administrators!', array('@project' => PROJECT) |
1172 | - ); |
|
1173 | - watchdog( |
|
1172 | + ); |
|
1173 | + watchdog( |
|
1174 | 1174 | 'BOINC team', |
1175 | 1175 | 'BOINC teams require the Pathauto module. Team cannot be created in |
1176 | 1176 | Drupal via create_team.php RPC.', |
1177 | 1177 | array(), |
1178 | 1178 | WATCHDOG_ERROR |
1179 | - ); |
|
1180 | - // Delete from the BOINC DB if we can't sync with Drupal |
|
1181 | - $boincteam::delete(); |
|
1179 | + ); |
|
1180 | + // Delete from the BOINC DB if we can't sync with Drupal |
|
1181 | + $boincteam::delete(); |
|
1182 | 1182 | } |
1183 | - } |
|
1184 | - else { |
|
1183 | + } |
|
1184 | + else { |
|
1185 | 1185 | $xml['create_team_reply']['warning'] = t( |
1186 | - 'There was a problem integrating this team into Drupal. Please |
|
1186 | + 'There was a problem integrating this team into Drupal. Please |
|
1187 | 1187 | contact @project administrators!', array('@project' => PROJECT) |
1188 | 1188 | ); |
1189 | 1189 | watchdog( |
1190 | - 'BOINC team', |
|
1191 | - 'Team cannot be created in Drupal via create_team.php RPC because no |
|
1190 | + 'BOINC team', |
|
1191 | + 'Team cannot be created in Drupal via create_team.php RPC because no |
|
1192 | 1192 | BOINC team ID was returned in the XML.', |
1193 | - array(), |
|
1194 | - WATCHDOG_ERROR |
|
1193 | + array(), |
|
1194 | + WATCHDOG_ERROR |
|
1195 | 1195 | ); |
1196 | - } |
|
1196 | + } |
|
1197 | 1197 | } |
1198 | - } |
|
1199 | - else { |
|
1198 | + } |
|
1199 | + else { |
|
1200 | 1200 | $xml = array( |
1201 | - 'error' => array( |
|
1201 | + 'error' => array( |
|
1202 | 1202 | 'error_num' => -1, |
1203 | 1203 | 'error_msg' => t( |
1204 | - 'Teams are not enabled for this project' |
|
1204 | + 'Teams are not enabled for this project' |
|
1205 | + ), |
|
1205 | 1206 | ), |
1206 | - ), |
|
1207 | 1207 | ); |
1208 | 1208 | watchdog( |
1209 | - 'BOINC team', |
|
1210 | - 'Team cannot be created in Drupal via create_team.php RPC because the |
|
1209 | + 'BOINC team', |
|
1210 | + 'Team cannot be created in Drupal via create_team.php RPC because the |
|
1211 | 1211 | BOINC team module is not enabled.', |
1212 | - array(), |
|
1213 | - WATCHDOG_ERROR |
|
1212 | + array(), |
|
1213 | + WATCHDOG_ERROR |
|
1214 | 1214 | ); |
1215 | - } |
|
1216 | - print save_configuration($xml); |
|
1215 | + } |
|
1216 | + print save_configuration($xml); |
|
1217 | 1217 | } |
1218 | 1218 | |
1219 | 1219 | /** |
@@ -1221,9 +1221,9 @@ discard block |
||
1221 | 1221 | * Get info on a team by ID or a list of teams that match a given name |
1222 | 1222 | */ |
1223 | 1223 | function boinccore_team_lookup() { |
1224 | - // Remove q from the GET request or BOINC will panic |
|
1225 | - unset($_GET['q']); |
|
1226 | - include_boinc('user/team_lookup.php'); |
|
1224 | + // Remove q from the GET request or BOINC will panic |
|
1225 | + unset($_GET['q']); |
|
1226 | + include_boinc('user/team_lookup.php'); |
|
1227 | 1227 | } |
1228 | 1228 | |
1229 | 1229 | /** |
@@ -1231,72 +1231,72 @@ discard block |
||
1231 | 1231 | * Get members of a given team |
1232 | 1232 | */ |
1233 | 1233 | function boinccore_team_email_list() { |
1234 | - // See if the account has an approved profile in Drupal |
|
1235 | - $boincteam_id = !empty($_POST['teamid']) ? $_POST['teamid'] : $_GET['teamid']; |
|
1236 | - $credit_only = !empty($_POST['creditonly']) ? $_POST['creditonly'] : $_GET['creditonly']; |
|
1237 | - $show_xml = !empty($_POST['xml']) ? $_POST['xml'] : $_GET['xml']; |
|
1238 | - if (!$show_xml) { |
|
1239 | - // creditonly does not affect non xml output in BOINC |
|
1240 | - $credit_only = FALSE; |
|
1241 | - } |
|
1242 | - $xml = array(); |
|
1234 | + // See if the account has an approved profile in Drupal |
|
1235 | + $boincteam_id = !empty($_POST['teamid']) ? $_POST['teamid'] : $_GET['teamid']; |
|
1236 | + $credit_only = !empty($_POST['creditonly']) ? $_POST['creditonly'] : $_GET['creditonly']; |
|
1237 | + $show_xml = !empty($_POST['xml']) ? $_POST['xml'] : $_GET['xml']; |
|
1238 | + if (!$show_xml) { |
|
1239 | + // creditonly does not affect non xml output in BOINC |
|
1240 | + $credit_only = FALSE; |
|
1241 | + } |
|
1242 | + $xml = array(); |
|
1243 | 1243 | |
1244 | - if ($boincteam_id && is_numeric($boincteam_id)) { |
|
1244 | + if ($boincteam_id && is_numeric($boincteam_id)) { |
|
1245 | 1245 | if ($credit_only) { |
1246 | - db_set_active('boinc_rw'); |
|
1247 | - $result = db_query(" |
|
1246 | + db_set_active('boinc_rw'); |
|
1247 | + $result = db_query(" |
|
1248 | 1248 | SELECT |
1249 | 1249 | u.id, u.name, u.cross_project_id, u.email_addr, u.total_credit, u.expavg_credit, u.expavg_time |
1250 | 1250 | FROM {user} u |
1251 | 1251 | WHERE u.teamid = %d and u.total_credit > 0", |
1252 | 1252 | $boincteam_id |
1253 | - ); |
|
1254 | - db_set_active('default'); |
|
1253 | + ); |
|
1254 | + db_set_active('default'); |
|
1255 | 1255 | |
1256 | - $xml = array('users' => array()); |
|
1257 | - while ($member = db_fetch_object($result)) { |
|
1256 | + $xml = array('users' => array()); |
|
1257 | + while ($member = db_fetch_object($result)) { |
|
1258 | 1258 | $team_member = array( |
1259 | - 'id' => $member->id, |
|
1260 | - 'cpid' => md5($member->cross_project_id.$member->email_addr), |
|
1261 | - 'name' => htmlspecialchars($member->name), |
|
1262 | - 'total_credit' => round($member->total_credit), |
|
1263 | - 'expavg_credit' => round($member->expavg_credit), |
|
1264 | - 'expavg_time' => round($member->expavg_time), |
|
1259 | + 'id' => $member->id, |
|
1260 | + 'cpid' => md5($member->cross_project_id.$member->email_addr), |
|
1261 | + 'name' => htmlspecialchars($member->name), |
|
1262 | + 'total_credit' => round($member->total_credit), |
|
1263 | + 'expavg_credit' => round($member->expavg_credit), |
|
1264 | + 'expavg_time' => round($member->expavg_time), |
|
1265 | 1265 | ); |
1266 | 1266 | $xml['users']['user'][] = $team_member; |
1267 | - } |
|
1267 | + } |
|
1268 | 1268 | } |
1269 | 1269 | else { |
1270 | - // Query BOINC database user table |
|
1271 | - db_set_active('boinc_rw'); |
|
1272 | - $result = db_query(" |
|
1270 | + // Query BOINC database user table |
|
1271 | + db_set_active('boinc_rw'); |
|
1272 | + $result = db_query(" |
|
1273 | 1273 | SELECT |
1274 | 1274 | u.id, u.name, u.cross_project_id, u.create_time, u.email_addr, u.total_credit, u.expavg_credit, u.expavg_time |
1275 | 1275 | FROM {user} u |
1276 | 1276 | WHERE u.teamid = %d ORDER BY u.email_addr ASC", |
1277 | 1277 | $boincteam_id |
1278 | - ); |
|
1279 | - db_set_active('default'); |
|
1278 | + ); |
|
1279 | + db_set_active('default'); |
|
1280 | 1280 | |
1281 | - // Extract information from BOINC database for team members. |
|
1282 | - $team_members = array(); |
|
1283 | - while ($member = db_fetch_object($result)) { |
|
1281 | + // Extract information from BOINC database for team members. |
|
1282 | + $team_members = array(); |
|
1283 | + while ($member = db_fetch_object($result)) { |
|
1284 | 1284 | $team_members[$member->id] = array( |
1285 | - 'id' => $member->id, |
|
1286 | - 'cpid' => md5($member->cross_project_id.$member->email_addr), |
|
1287 | - 'create_time' => $member->create_time, |
|
1288 | - 'name' => htmlspecialchars($member->name), |
|
1289 | - 'country' => NULL, |
|
1290 | - 'total_credit' => round($member->total_credit), |
|
1291 | - 'expavg_credit' => round($member->expavg_credit), |
|
1292 | - 'expavg_time' => round($member->expavg_time), |
|
1293 | - 'url' => NULL, |
|
1294 | - 'has_profile' => 0, |
|
1285 | + 'id' => $member->id, |
|
1286 | + 'cpid' => md5($member->cross_project_id.$member->email_addr), |
|
1287 | + 'create_time' => $member->create_time, |
|
1288 | + 'name' => htmlspecialchars($member->name), |
|
1289 | + 'country' => NULL, |
|
1290 | + 'total_credit' => round($member->total_credit), |
|
1291 | + 'expavg_credit' => round($member->expavg_credit), |
|
1292 | + 'expavg_time' => round($member->expavg_time), |
|
1293 | + 'url' => NULL, |
|
1294 | + 'has_profile' => 0, |
|
1295 | 1295 | ); |
1296 | - } |
|
1296 | + } |
|
1297 | 1297 | |
1298 | - // Query Drupal database, multiple tables |
|
1299 | - $sql1 = " |
|
1298 | + // Query Drupal database, multiple tables |
|
1299 | + $sql1 = " |
|
1300 | 1300 | SELECT |
1301 | 1301 | bu.boinc_id, du.uid, du.name, n.nid, n.type, n.field_country_value, n.field_url_value |
1302 | 1302 | FROM {boincuser} AS bu |
@@ -1307,28 +1307,28 @@ discard block |
||
1307 | 1307 | INNER JOIN {content_type_profile} AS p ON node.nid=p.nid |
1308 | 1308 | WHERE node.type='profile' ) n ON du.uid=n.uid |
1309 | 1309 | WHERE bu.boinc_id IN (%s)"; |
1310 | - $member_id_list = implode(',', array_keys($team_members)); |
|
1311 | - if (!$member_id_list) { |
|
1310 | + $member_id_list = implode(',', array_keys($team_members)); |
|
1311 | + if (!$member_id_list) { |
|
1312 | 1312 | $member_id_list = '-1'; |
1313 | - } |
|
1314 | - $result = db_query($sql1, $member_id_list); |
|
1315 | - while ($member = db_fetch_object($result)) { |
|
1313 | + } |
|
1314 | + $result = db_query($sql1, $member_id_list); |
|
1315 | + while ($member = db_fetch_object($result)) { |
|
1316 | 1316 | $team_members[$member->boinc_id]['country'] = $member->field_country_value; |
1317 | 1317 | $team_members[$member->boinc_id]['url'] = $member->field_url_value; |
1318 | 1318 | $team_members[$member->boinc_id]['has_profile'] = isset($member->nid) ? 1: 0; |
1319 | 1319 | $xml['users']['user'][] = $team_members[$member->boinc_id]; |
1320 | - } |
|
1320 | + } |
|
1321 | 1321 | } // end if credit_only |
1322 | - } |
|
1323 | - else { |
|
1322 | + } |
|
1323 | + else { |
|
1324 | 1324 | $xml = array( |
1325 | - 'error' => array( |
|
1325 | + 'error' => array( |
|
1326 | 1326 | 'error_num' => -136, |
1327 | 1327 | 'error_msg' => 'Not found', |
1328 | - ), |
|
1328 | + ), |
|
1329 | 1329 | ); |
1330 | - } // end if boincteam_id |
|
1331 | - print xml_to_text(array_to_xml($xml), TRUE, TRUE); |
|
1330 | + } // end if boincteam_id |
|
1331 | + print xml_to_text(array_to_xml($xml), TRUE, TRUE); |
|
1332 | 1332 | } |
1333 | 1333 | |
1334 | 1334 | /** |
@@ -1336,114 +1336,114 @@ discard block |
||
1336 | 1336 | * Edit the forum preferences for a given user |
1337 | 1337 | */ |
1338 | 1338 | function boinccore_edit_forum_preferences() { |
1339 | - // Do not pass through to BOINC in this case as BOINC forums are no longer |
|
1340 | - // relevant -- use Drupal data only |
|
1339 | + // Do not pass through to BOINC in this case as BOINC forums are no longer |
|
1340 | + // relevant -- use Drupal data only |
|
1341 | 1341 | |
1342 | - $account_key = !empty($_POST['account_key']) ? $_POST['account_key'] : (!empty($_GET['account_key']) ? $_GET['account_key'] : NULL); |
|
1342 | + $account_key = !empty($_POST['account_key']) ? $_POST['account_key'] : (!empty($_GET['account_key']) ? $_GET['account_key'] : NULL); |
|
1343 | 1343 | |
1344 | - require_boinc('boinc_db'); |
|
1345 | - $boincuser = BoincUser::lookup_auth($account_key); |
|
1346 | - if ($boincuser) { |
|
1344 | + require_boinc('boinc_db'); |
|
1345 | + $boincuser = BoincUser::lookup_auth($account_key); |
|
1346 | + if ($boincuser) { |
|
1347 | 1347 | $uid = boincuser_lookup_uid($boincuser->id); |
1348 | 1348 | if ($uid AND $account = user_load($uid)) { |
1349 | - // Currently supported preferences |
|
1350 | - $avatar_url = isset($_POST['avatar_url']) ? $_POST['avatar_url'] : (isset($_GET['avatar_url']) ? $_GET['avatar_url'] : NULL); |
|
1351 | - $hide_signatures = isset($_POST['forum_hide_signatures']) ? $_POST['forum_hide_signatures'] : (isset($_GET['forum_hide_signatures']) ? $_GET['forum_hide_signatures'] : NULL); |
|
1352 | - $signature = isset($_POST['signature']) ? $_POST['signature'] : (isset($_GET['signature']) ? $_GET['signature'] : NULL); |
|
1353 | - $post_order = isset($_POST['thread_sort']) ? $_POST['thread_sort'] : (isset($_GET['thread_sort']) ? $_GET['thread_sort'] : NULL); |
|
1354 | - // Update preferences as needed |
|
1355 | - if ($avatar_url) { |
|
1349 | + // Currently supported preferences |
|
1350 | + $avatar_url = isset($_POST['avatar_url']) ? $_POST['avatar_url'] : (isset($_GET['avatar_url']) ? $_GET['avatar_url'] : NULL); |
|
1351 | + $hide_signatures = isset($_POST['forum_hide_signatures']) ? $_POST['forum_hide_signatures'] : (isset($_GET['forum_hide_signatures']) ? $_GET['forum_hide_signatures'] : NULL); |
|
1352 | + $signature = isset($_POST['signature']) ? $_POST['signature'] : (isset($_GET['signature']) ? $_GET['signature'] : NULL); |
|
1353 | + $post_order = isset($_POST['thread_sort']) ? $_POST['thread_sort'] : (isset($_GET['thread_sort']) ? $_GET['thread_sort'] : NULL); |
|
1354 | + // Update preferences as needed |
|
1355 | + if ($avatar_url) { |
|
1356 | 1356 | $avatar_image = file_get_contents($avatar_url); |
1357 | 1357 | if ($avatar_image) { |
1358 | - $image_dir = 'profiles'; |
|
1359 | - $image_path = "{$image_dir}/{$boincuser->id}_avatar.jpg"; |
|
1360 | - $file = file_save_data($avatar_image, $image_path, FILE_EXISTS_REPLACE); |
|
1361 | - if ($file) { |
|
1358 | + $image_dir = 'profiles'; |
|
1359 | + $image_path = "{$image_dir}/{$boincuser->id}_avatar.jpg"; |
|
1360 | + $file = file_save_data($avatar_image, $image_path, FILE_EXISTS_REPLACE); |
|
1361 | + if ($file) { |
|
1362 | 1362 | $profile = new stdClass(); |
1363 | 1363 | $profile->type = 'profile'; |
1364 | 1364 | $profile->language = NULL; |
1365 | 1365 | if ($profile_nid = content_profile_profile_exists($profile, $account->uid)) { |
1366 | - $profile_node = node_load($profile_nid); |
|
1367 | - if ($profile_node) { |
|
1366 | + $profile_node = node_load($profile_nid); |
|
1367 | + if ($profile_node) { |
|
1368 | 1368 | $avatar_image = get_cck_image_object(file_directory_path() . '/' . $image_path, 'field_image', 'profile', TRUE); |
1369 | 1369 | if ($avatar_image) { |
1370 | - $profile_node->field_image[0] = $avatar_image; |
|
1371 | - node_save($profile_node); |
|
1370 | + $profile_node->field_image[0] = $avatar_image; |
|
1371 | + node_save($profile_node); |
|
1372 | 1372 | } |
1373 | 1373 | else { |
1374 | - $error = 'Error saving avatar to profile'; |
|
1374 | + $error = 'Error saving avatar to profile'; |
|
1375 | + } |
|
1375 | 1376 | } |
1376 | - } |
|
1377 | - else { |
|
1377 | + else { |
|
1378 | 1378 | $error = 'Unable to load user profile'; |
1379 | - } |
|
1379 | + } |
|
1380 | 1380 | } |
1381 | 1381 | else { |
1382 | - $error = 'User has no profile, so avatar could not be added'; |
|
1382 | + $error = 'User has no profile, so avatar could not be added'; |
|
1383 | 1383 | } |
1384 | - } |
|
1385 | - else { |
|
1384 | + } |
|
1385 | + else { |
|
1386 | 1386 | $error = 'Unable to save remote image'; |
1387 | - } |
|
1387 | + } |
|
1388 | 1388 | } |
1389 | 1389 | else { |
1390 | - $error = 'Could not find avatar image at URL'; |
|
1390 | + $error = 'Could not find avatar image at URL'; |
|
1391 | 1391 | } |
1392 | - } |
|
1393 | - if ($hide_signatures !== NULL) { |
|
1392 | + } |
|
1393 | + if ($hide_signatures !== NULL) { |
|
1394 | 1394 | user_save($account, array('hide_signatures' => ($hide_signatures ? 1 : 0))); |
1395 | - } |
|
1396 | - if ($signature !== NULL) { |
|
1395 | + } |
|
1396 | + if ($signature !== NULL) { |
|
1397 | 1397 | $signature = check_markup($signature); |
1398 | 1398 | user_save($account, array('signature' => $signature)); |
1399 | - } |
|
1400 | - if ($post_order) { |
|
1399 | + } |
|
1400 | + if ($post_order) { |
|
1401 | 1401 | require_boinc('forum'); |
1402 | 1402 | $post_order_map = array( |
1403 | - CREATE_TIME_OLD => 2, |
|
1404 | - CREATE_TIME_NEW => 1, |
|
1403 | + CREATE_TIME_OLD => 2, |
|
1404 | + CREATE_TIME_NEW => 1, |
|
1405 | 1405 | ); |
1406 | 1406 | $drupal_post_order = isset($post_order_map[$post_order]) ? $post_order_map[$post_order] : 2; |
1407 | 1407 | user_save($account, array('sort' => $drupal_post_order)); |
1408 | - } |
|
1409 | - if (!$error) { |
|
1408 | + } |
|
1409 | + if (!$error) { |
|
1410 | 1410 | // Success |
1411 | 1411 | $xml = array( |
1412 | - 'edit_forum_preferences' => array( |
|
1412 | + 'edit_forum_preferences' => array( |
|
1413 | 1413 | 'success' => NULL, |
1414 | - ), |
|
1414 | + ), |
|
1415 | 1415 | ); |
1416 | - } |
|
1417 | - else { |
|
1416 | + } |
|
1417 | + else { |
|
1418 | 1418 | // Failure |
1419 | 1419 | $xml = array( |
1420 | - 'error' => array( |
|
1420 | + 'error' => array( |
|
1421 | 1421 | 'error_num' => -1, |
1422 | 1422 | 'error_msg' => $error, |
1423 | - ), |
|
1423 | + ), |
|
1424 | 1424 | ); |
1425 | - } |
|
1425 | + } |
|
1426 | 1426 | } |
1427 | 1427 | else { |
1428 | - // Drupal user not found |
|
1429 | - $xml = array( |
|
1428 | + // Drupal user not found |
|
1429 | + $xml = array( |
|
1430 | 1430 | 'error' => array( |
1431 | - 'error_num' => -1, |
|
1432 | - 'error_msg' => 'Unknown error', |
|
1431 | + 'error_num' => -1, |
|
1432 | + 'error_msg' => 'Unknown error', |
|
1433 | 1433 | ), |
1434 | - ); |
|
1434 | + ); |
|
1435 | 1435 | } |
1436 | - } |
|
1437 | - else { |
|
1436 | + } |
|
1437 | + else { |
|
1438 | 1438 | // BOINC user not found |
1439 | 1439 | $xml = array( |
1440 | - 'error' => array( |
|
1440 | + 'error' => array( |
|
1441 | 1441 | 'error_num' => -136, |
1442 | 1442 | 'error_msg' => 'Not found', |
1443 | - ), |
|
1443 | + ), |
|
1444 | 1444 | ); |
1445 | - } |
|
1446 | - print xml_to_text(array_to_xml($xml), TRUE, TRUE); |
|
1445 | + } |
|
1446 | + print xml_to_text(array_to_xml($xml), TRUE, TRUE); |
|
1447 | 1447 | } |
1448 | 1448 | |
1449 | 1449 | /** |
@@ -1451,14 +1451,14 @@ discard block |
||
1451 | 1451 | * Get the last comments OR threads made by a given user |
1452 | 1452 | */ |
1453 | 1453 | function boinccore_forum_get_data() { |
1454 | - // Do not pass through to BOINC in this case as BOINC forums are no longer |
|
1455 | - // relevant -- use Drupal data only |
|
1454 | + // Do not pass through to BOINC in this case as BOINC forums are no longer |
|
1455 | + // relevant -- use Drupal data only |
|
1456 | 1456 | |
1457 | - $xml = array(); |
|
1458 | - $boinc_id = !empty($_POST['userid']) ? $_POST['userid'] : (!empty($_GET['userid']) ? $_GET['userid'] : NULL); |
|
1459 | - $uid = boincuser_lookup_uid($boinc_id); |
|
1457 | + $xml = array(); |
|
1458 | + $boinc_id = !empty($_POST['userid']) ? $_POST['userid'] : (!empty($_GET['userid']) ? $_GET['userid'] : NULL); |
|
1459 | + $uid = boincuser_lookup_uid($boinc_id); |
|
1460 | 1460 | |
1461 | - if ($uid) { |
|
1461 | + if ($uid) { |
|
1462 | 1462 | $method = !empty($_POST['method']) ? $_POST['method'] : (!empty($_GET['method']) ? $_GET['method'] : NULL); |
1463 | 1463 | $count = !empty($_POST['count']) ? $_POST['count'] : (!empty($_GET['count']) ? $_GET['count'] : NULL); |
1464 | 1464 | if (!$count) $count = 10; |
@@ -1466,7 +1466,7 @@ discard block |
||
1466 | 1466 | switch ($method) { |
1467 | 1467 | case 'user_posts': |
1468 | 1468 | $content_length = !empty($_POST['content_length']) ? $_POST['content_length'] : (!empty($_GET['content_length']) ? $_GET['content_length'] : NULL); |
1469 | - $posts = db_query(" |
|
1469 | + $posts = db_query(" |
|
1470 | 1470 | SELECT |
1471 | 1471 | c.cid, |
1472 | 1472 | n.nid, |
@@ -1480,26 +1480,26 @@ discard block |
||
1480 | 1480 | ORDER BY timestamp DESC |
1481 | 1481 | LIMIT %d", |
1482 | 1482 | $uid, (int) $count |
1483 | - ); |
|
1484 | - $xml = array( |
|
1483 | + ); |
|
1484 | + $xml = array( |
|
1485 | 1485 | 'rpc_response' => array( |
1486 | - 'count' => 0, |
|
1487 | - 'posts' => array(), |
|
1486 | + 'count' => 0, |
|
1487 | + 'posts' => array(), |
|
1488 | 1488 | ), |
1489 | - ); |
|
1490 | - $post_count = 0; |
|
1491 | - while ($post = db_fetch_object($posts)) { |
|
1489 | + ); |
|
1490 | + $post_count = 0; |
|
1491 | + while ($post = db_fetch_object($posts)) { |
|
1492 | 1492 | $xml['rpc_response']['posts']['post'][] = array( |
1493 | - 'id' => $post->cid, |
|
1494 | - 'threadid' => $post->nid, |
|
1495 | - 'threadtitle' => $post->title, |
|
1496 | - 'timestamp' => $post->timestamp, |
|
1497 | - 'content' => ($content_length ? substr($post->comment, 0, $content_length) : $post->comment), |
|
1493 | + 'id' => $post->cid, |
|
1494 | + 'threadid' => $post->nid, |
|
1495 | + 'threadtitle' => $post->title, |
|
1496 | + 'timestamp' => $post->timestamp, |
|
1497 | + 'content' => ($content_length ? substr($post->comment, 0, $content_length) : $post->comment), |
|
1498 | 1498 | ); |
1499 | 1499 | $post_count++; |
1500 | - } |
|
1501 | - $xml['rpc_response']['count'] = $post_count; |
|
1502 | - break; |
|
1500 | + } |
|
1501 | + $xml['rpc_response']['count'] = $post_count; |
|
1502 | + break; |
|
1503 | 1503 | |
1504 | 1504 | case 'user_threads': |
1505 | 1505 | $threads = db_query(" |
@@ -1523,45 +1523,45 @@ discard block |
||
1523 | 1523 | ORDER BY changed DESC |
1524 | 1524 | LIMIT %d", |
1525 | 1525 | $uid, (int) $count |
1526 | - ); |
|
1527 | - $xml = array( |
|
1526 | + ); |
|
1527 | + $xml = array( |
|
1528 | 1528 | 'rpc_response' => array( |
1529 | - 'count' => 0, |
|
1530 | - 'threads' => array(), |
|
1529 | + 'count' => 0, |
|
1530 | + 'threads' => array(), |
|
1531 | 1531 | ), |
1532 | - ); |
|
1533 | - $thread_count = 0; |
|
1534 | - while ($thread = db_fetch_object($threads)) { |
|
1532 | + ); |
|
1533 | + $thread_count = 0; |
|
1534 | + while ($thread = db_fetch_object($threads)) { |
|
1535 | 1535 | $xml['rpc_response']['threads']['thread'][] = array( |
1536 | - 'id' => $thread->nid, |
|
1537 | - 'forumid' => $thread->tid, |
|
1538 | - 'replies' => $thread->replies, |
|
1539 | - 'views' => $thread->views, |
|
1540 | - 'timestamp' => $thread->changed, |
|
1541 | - 'title' => $thread->title, |
|
1536 | + 'id' => $thread->nid, |
|
1537 | + 'forumid' => $thread->tid, |
|
1538 | + 'replies' => $thread->replies, |
|
1539 | + 'views' => $thread->views, |
|
1540 | + 'timestamp' => $thread->changed, |
|
1541 | + 'title' => $thread->title, |
|
1542 | 1542 | ); |
1543 | 1543 | $thread_count++; |
1544 | - } |
|
1545 | - $xml['rpc_response']['count'] = $thread_count; |
|
1546 | - break; |
|
1544 | + } |
|
1545 | + $xml['rpc_response']['count'] = $thread_count; |
|
1546 | + break; |
|
1547 | 1547 | default: |
1548 | 1548 | $xml = array( |
1549 | 1549 | 'error' => array( |
1550 | - 'error_num' => -1, |
|
1551 | - 'error_msg' => 'Unknown error', |
|
1550 | + 'error_num' => -1, |
|
1551 | + 'error_msg' => 'Unknown error', |
|
1552 | 1552 | ), |
1553 | - ); |
|
1553 | + ); |
|
1554 | 1554 | } |
1555 | - } |
|
1556 | - else { |
|
1555 | + } |
|
1556 | + else { |
|
1557 | 1557 | $xml = array( |
1558 | - 'error' => array( |
|
1558 | + 'error' => array( |
|
1559 | 1559 | 'error_num' => -136, |
1560 | 1560 | 'error_msg' => 'Not found', |
1561 | - ), |
|
1561 | + ), |
|
1562 | 1562 | ); |
1563 | - } |
|
1564 | - print xml_to_text(array_to_xml($xml), TRUE, TRUE); |
|
1563 | + } |
|
1564 | + print xml_to_text(array_to_xml($xml), TRUE, TRUE); |
|
1565 | 1565 | } |
1566 | 1566 | |
1567 | 1567 | /** |
@@ -1569,9 +1569,9 @@ discard block |
||
1569 | 1569 | * Get information on applications in the system |
1570 | 1570 | */ |
1571 | 1571 | function boinccore_apps() { |
1572 | - // Remove q from the GET request or BOINC will panic |
|
1573 | - unset($_GET['q']); |
|
1574 | - include_boinc('user/apps.php'); |
|
1572 | + // Remove q from the GET request or BOINC will panic |
|
1573 | + unset($_GET['q']); |
|
1574 | + include_boinc('user/apps.php'); |
|
1575 | 1575 | } |
1576 | 1576 | |
1577 | 1577 | /** |
@@ -1581,147 +1581,147 @@ discard block |
||
1581 | 1581 | * controller function, which can compute the page based on the user's settings |
1582 | 1582 | */ |
1583 | 1583 | function boinccore_url_pagination_handler($type, $object_id = NULL) { |
1584 | - global $user; |
|
1585 | - $path = NULL; |
|
1586 | - $params = array(); |
|
1587 | - switch ($type) { |
|
1588 | - case 'boinc-forum': |
|
1584 | + global $user; |
|
1585 | + $path = NULL; |
|
1586 | + $params = array(); |
|
1587 | + switch ($type) { |
|
1588 | + case 'boinc-forum': |
|
1589 | 1589 | // Redirect requests to a BOINC forum to the Drupal forum |
1590 | 1590 | $forum_id = db_result(db_query(' |
1591 | 1591 | SELECT tid |
1592 | 1592 | FROM {boincimport_temp_forum} |
1593 | 1593 | WHERE forum_id = %d', |
1594 | - $object_id |
|
1594 | + $object_id |
|
1595 | 1595 | )); |
1596 | 1596 | if ($forum_id) { |
1597 | - drupal_goto("community/forum/{$forum_id}"); |
|
1597 | + drupal_goto("community/forum/{$forum_id}"); |
|
1598 | 1598 | } |
1599 | 1599 | break; |
1600 | - case 'boinc-forum-index': |
|
1600 | + case 'boinc-forum-index': |
|
1601 | 1601 | // Redirect requests to the top level BOINC forum to Drupal forums |
1602 | 1602 | drupal_goto("community/forum"); |
1603 | 1603 | break; |
1604 | - case 'boinc-forum-post': |
|
1604 | + case 'boinc-forum-post': |
|
1605 | 1605 | // Redirect requests to a BOINC forum post to the Drupal comment |
1606 | 1606 | $cid = db_result(db_query(' |
1607 | 1607 | SELECT cid |
1608 | 1608 | FROM {boincimport_temp_post} |
1609 | 1609 | WHERE post_id = %d', |
1610 | - $object_id |
|
1610 | + $object_id |
|
1611 | 1611 | )); |
1612 | 1612 | if ($cid) { |
1613 | - drupal_goto("goto/comment/{$cid}"); |
|
1613 | + drupal_goto("goto/comment/{$cid}"); |
|
1614 | 1614 | } |
1615 | 1615 | break; |
1616 | - case 'boinc-forum-topic': |
|
1616 | + case 'boinc-forum-topic': |
|
1617 | 1617 | // Redirect requests to a BOINC forum topic to the Drupal node |
1618 | 1618 | $nid = db_result(db_query(' |
1619 | 1619 | SELECT nid |
1620 | 1620 | FROM {boincimport_temp_topic} |
1621 | 1621 | WHERE topic_id = %d', |
1622 | - $object_id |
|
1622 | + $object_id |
|
1623 | 1623 | )); |
1624 | 1624 | if ($nid) { |
1625 | - drupal_goto("node/{$nid}"); |
|
1625 | + drupal_goto("node/{$nid}"); |
|
1626 | 1626 | } |
1627 | 1627 | break; |
1628 | - case 'boinc-host': |
|
1628 | + case 'boinc-host': |
|
1629 | 1629 | // Redirect requests to BOINC host details to the host page in Drupal |
1630 | 1630 | drupal_goto("host/{$object_id}"); |
1631 | 1631 | break; |
1632 | - case 'boinc-hosts-user': |
|
1632 | + case 'boinc-hosts-user': |
|
1633 | 1633 | // Redirect requests to a BOINC user host list to the host list in Drupal |
1634 | 1634 | $uid = boincuser_lookup_uid($object_id); |
1635 | 1635 | if ($uid) { |
1636 | - drupal_goto("account/{$uid}/computers"); |
|
1636 | + drupal_goto("account/{$uid}/computers"); |
|
1637 | 1637 | } |
1638 | 1638 | break; |
1639 | - case 'boinc-result': |
|
1639 | + case 'boinc-result': |
|
1640 | 1640 | // Redirect requests to BOINC task details to the task page in Drupal |
1641 | 1641 | drupal_goto("task/{$object_id}"); |
1642 | - case 'boinc-results-host': |
|
1642 | + case 'boinc-results-host': |
|
1643 | 1643 | // Redirect requests to BOINC tasks by host to the host task page in Drupal |
1644 | 1644 | drupal_goto("host/{$object_id}/tasks"); |
1645 | 1645 | break; |
1646 | - case 'boinc-results-user': |
|
1646 | + case 'boinc-results-user': |
|
1647 | 1647 | // Redirect requests to a BOINC user's tasks to the Drupal account tasks |
1648 | 1648 | drupal_goto("account/tasks"); |
1649 | 1649 | break; |
1650 | - case 'boinc-user': |
|
1650 | + case 'boinc-user': |
|
1651 | 1651 | // Redirect requests to a BOINC user ID to the Drupal profile |
1652 | 1652 | $uid = boincuser_lookup_uid($object_id); |
1653 | 1653 | if ($uid) { |
1654 | - drupal_goto("account/{$uid}"); |
|
1654 | + drupal_goto("account/{$uid}"); |
|
1655 | 1655 | } |
1656 | 1656 | break; |
1657 | - case 'boinc-workunit': |
|
1657 | + case 'boinc-workunit': |
|
1658 | 1658 | // Redirect requests to BOINC workunits to the workunit page in Drupal |
1659 | 1659 | drupal_goto("workunit/{$object_id}"); |
1660 | 1660 | break; |
1661 | - case 'comment': |
|
1661 | + case 'comment': |
|
1662 | 1662 | $object = _comment_load($object_id); |
1663 | 1663 | if ($object) { |
1664 | - $path = "node/{$object->nid}"; |
|
1665 | - // Get the sort order |
|
1666 | - $gt_lt = '<'; |
|
1667 | - $comment_order = (isset($user->sort)) ? $user->sort : variable_get('comment_default_order_forum', 2); |
|
1668 | - if ($comment_order == COMMENT_ORDER_NEWEST_FIRST) { |
|
1664 | + $path = "node/{$object->nid}"; |
|
1665 | + // Get the sort order |
|
1666 | + $gt_lt = '<'; |
|
1667 | + $comment_order = (isset($user->sort)) ? $user->sort : variable_get('comment_default_order_forum', 2); |
|
1668 | + if ($comment_order == COMMENT_ORDER_NEWEST_FIRST) { |
|
1669 | 1669 | $gt_lt = '>'; |
1670 | - } |
|
1671 | - // don't filter hidden comments for admins/mods |
|
1672 | - $include_hidden = ''; |
|
1673 | - if (in_array('administrator', array_values($user->roles)) || |
|
1670 | + } |
|
1671 | + // don't filter hidden comments for admins/mods |
|
1672 | + $include_hidden = ''; |
|
1673 | + if (in_array('administrator', array_values($user->roles)) || |
|
1674 | 1674 | in_array('moderator', array_values($user->roles))) { |
1675 | 1675 | $include_hidden = 'OR status = 1'; |
1676 | - } |
|
1677 | - // See how many comments there are before (or after) this comment... |
|
1678 | - $comment_offset = db_result(db_query(' |
|
1676 | + } |
|
1677 | + // See how many comments there are before (or after) this comment... |
|
1678 | + $comment_offset = db_result(db_query(' |
|
1679 | 1679 | SELECT COUNT(*) FROM {comments} |
1680 | 1680 | WHERE nid = %d AND (status = 0 %s) AND timestamp %s %d', |
1681 | 1681 | $object->nid, $include_hidden, $gt_lt, $object->timestamp)); |
1682 | - if ($comment_offset) { |
|
1682 | + if ($comment_offset) { |
|
1683 | 1683 | // Get the number of comments per page |
1684 | 1684 | if ($user->comments_per_page) { |
1685 | - $comments_per_page = $user->comments_per_page; |
|
1685 | + $comments_per_page = $user->comments_per_page; |
|
1686 | 1686 | } |
1687 | 1687 | else { |
1688 | - $node = node_load($object->nid); |
|
1689 | - $comments_per_page = variable_get( |
|
1688 | + $node = node_load($object->nid); |
|
1689 | + $comments_per_page = variable_get( |
|
1690 | 1690 | "comment_default_per_page_{$node->type}", 50 |
1691 | - ); |
|
1691 | + ); |
|
1692 | 1692 | } |
1693 | 1693 | // Determine which page to display in order to show the given comment |
1694 | 1694 | $page = floor($comment_offset / $comments_per_page); |
1695 | 1695 | if ($page) { |
1696 | - $params = array('page' => $page); |
|
1696 | + $params = array('page' => $page); |
|
1697 | + } |
|
1697 | 1698 | } |
1698 | - } |
|
1699 | 1699 | } |
1700 | 1700 | if ($path) { |
1701 | - drupal_goto($path, $params, "comment-{$object->cid}"); |
|
1701 | + drupal_goto($path, $params, "comment-{$object->cid}"); |
|
1702 | 1702 | } |
1703 | 1703 | break; |
1704 | - case 'friend-requests': |
|
1704 | + case 'friend-requests': |
|
1705 | 1705 | // Check for a login, then redirect to the user's friend requests page |
1706 | 1706 | if ($user->uid) { |
1707 | - drupal_goto("account/{$user->uid}/friends/pending"); |
|
1707 | + drupal_goto("account/{$user->uid}/friends/pending"); |
|
1708 | 1708 | } |
1709 | 1709 | else { |
1710 | - drupal_goto('user/login', array( |
|
1710 | + drupal_goto('user/login', array( |
|
1711 | 1711 | 'destination' => 'goto/friend-requests' |
1712 | - )); |
|
1712 | + )); |
|
1713 | 1713 | } |
1714 | 1714 | break; |
1715 | - default: |
|
1715 | + default: |
|
1716 | 1716 | } |
1717 | - drupal_not_found(); |
|
1717 | + drupal_not_found(); |
|
1718 | 1718 | } |
1719 | 1719 | |
1720 | 1720 | /* |
1721 | 1721 | * Fetch an array of all countries |
1722 | 1722 | */ |
1723 | 1723 | function boinccore_get_country_list() { |
1724 | - return array( |
|
1724 | + return array( |
|
1725 | 1725 | 'None' => 'None', |
1726 | 1726 | 'International' => 'International', |
1727 | 1727 | 'Afghanistan' => 'Afghanistan', |
@@ -1955,7 +1955,7 @@ discard block |
||
1955 | 1955 | 'Yemen' => 'Yemen', |
1956 | 1956 | 'Zambia' => 'Zambia', |
1957 | 1957 | 'Zimbabwe' => 'Zimbabwe', |
1958 | - ); |
|
1958 | + ); |
|
1959 | 1959 | } |
1960 | 1960 | |
1961 | 1961 | |
@@ -1967,46 +1967,46 @@ discard block |
||
1967 | 1967 | * Action: Mark node for moderation |
1968 | 1968 | */ |
1969 | 1969 | function boinccore_rules_action_mark_content_for_moderation($node) { |
1970 | - $node->moderate = 1; |
|
1971 | - return array('node' => $node); |
|
1970 | + $node->moderate = 1; |
|
1971 | + return array('node' => $node); |
|
1972 | 1972 | } |
1973 | 1973 | |
1974 | 1974 | /** |
1975 | 1975 | * Action: Send mail to moderators. |
1976 | 1976 | */ |
1977 | 1977 | function boinccore_rules_action_mail_to_moderators($settings) { |
1978 | - module_load_include('inc', 'rules', 'modules/system.rules'); |
|
1979 | - $mailing_list = variable_get('boinc_moderator_mailing_list', ''); |
|
1980 | - $force_individual_notifications = variable_get('boinc_moderator_force_individual_notifications', 0); |
|
1978 | + module_load_include('inc', 'rules', 'modules/system.rules'); |
|
1979 | + $mailing_list = variable_get('boinc_moderator_mailing_list', ''); |
|
1980 | + $force_individual_notifications = variable_get('boinc_moderator_force_individual_notifications', 0); |
|
1981 | 1981 | |
1982 | - if (!$mailing_list OR $force_individual_notifications) { |
|
1982 | + if (!$mailing_list OR $force_individual_notifications) { |
|
1983 | 1983 | // Send individual emails to all moderators |
1984 | 1984 | $roles = user_roles(); |
1985 | 1985 | $moderator_rid = array_search('moderator', $roles); |
1986 | 1986 | if ($moderator_rid !== FALSE) { |
1987 | - $settings['recipients'] = array($moderator_rid); |
|
1988 | - rules_action_mail_to_users_of_role($settings); |
|
1987 | + $settings['recipients'] = array($moderator_rid); |
|
1988 | + rules_action_mail_to_users_of_role($settings); |
|
1989 | 1989 | } |
1990 | 1990 | else { |
1991 | - watchdog( |
|
1991 | + watchdog( |
|
1992 | 1992 | 'boinccore', |
1993 | 1993 | 'Unable to identify members of the moderator role to send moderator notifications!', |
1994 | 1994 | array(), |
1995 | 1995 | WATCHDOG_ERROR |
1996 | - ); |
|
1996 | + ); |
|
1997 | 1997 | } |
1998 | - } |
|
1999 | - if ($mailing_list) { |
|
1998 | + } |
|
1999 | + if ($mailing_list) { |
|
2000 | 2000 | $settings['to'] = $mailing_list; |
2001 | 2001 | rules_action_mail($settings); |
2002 | - } |
|
2002 | + } |
|
2003 | 2003 | } |
2004 | 2004 | /** |
2005 | 2005 | * Action "Send mail to moderators" configuration form |
2006 | 2006 | */ |
2007 | 2007 | function boinccore_rules_action_mail_to_moderators_form($settings = array(), &$form) { |
2008 | - // Select only non-anonymous user roles because anonymous users won't have emails. |
|
2009 | - rules_action_mail_to_user_form($settings, $form); |
|
2008 | + // Select only non-anonymous user roles because anonymous users won't have emails. |
|
2009 | + rules_action_mail_to_user_form($settings, $form); |
|
2010 | 2010 | } |
2011 | 2011 | |
2012 | 2012 | |
@@ -2014,27 +2014,27 @@ discard block |
||
2014 | 2014 | * Action: Send mail to admins. |
2015 | 2015 | */ |
2016 | 2016 | function boinccore_rules_action_mail_to_admins($settings) { |
2017 | - module_load_include('inc', 'rules', 'modules/system.rules'); |
|
2018 | - $mailing_list = variable_get('boinc_admin_mailing_list', ''); |
|
2019 | - if (empty($mailing_list)) { |
|
2017 | + module_load_include('inc', 'rules', 'modules/system.rules'); |
|
2018 | + $mailing_list = variable_get('boinc_admin_mailing_list', ''); |
|
2019 | + if (empty($mailing_list)) { |
|
2020 | 2020 | $mailing_list = variable_get('site_mail', ''); |
2021 | 2021 | if (empty($mailing_list)) { |
2022 | - watchdog('boinccore', |
|
2022 | + watchdog('boinccore', |
|
2023 | 2023 | 'Attempting to email administrators, but there is no admin email list or site email to send to.', array(), |
2024 | 2024 | WATCHDOG_ERROR |
2025 | - ); |
|
2026 | - return FALSE; |
|
2025 | + ); |
|
2026 | + return FALSE; |
|
2027 | 2027 | } |
2028 | - } |
|
2029 | - $settings['to'] = $mailing_list; |
|
2030 | - rules_action_mail($settings); |
|
2028 | + } |
|
2029 | + $settings['to'] = $mailing_list; |
|
2030 | + rules_action_mail($settings); |
|
2031 | 2031 | } |
2032 | 2032 | |
2033 | 2033 | /** |
2034 | 2034 | * Action "Send mail to admins" configuration form |
2035 | 2035 | */ |
2036 | 2036 | function boinccore_rules_action_mail_to_admins_form($settings = array(), &$form) { |
2037 | - rules_action_mail_to_user_form($settings, $form); |
|
2037 | + rules_action_mail_to_user_form($settings, $form); |
|
2038 | 2038 | } |
2039 | 2039 | |
2040 | 2040 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -2045,33 +2045,33 @@ discard block |
||
2045 | 2045 | * BOINC wrapper for string translation |
2046 | 2046 | */ |
2047 | 2047 | function bts($string, $args = array(), $langcode = NULL, $context = 'boinc: ', $update = TRUE) { |
2048 | - if (function_exists('i18nstrings_ts')) { |
|
2048 | + if (function_exists('i18nstrings_ts')) { |
|
2049 | 2049 | $string = i18nstrings_ts($context, $string, $langcode, $update); |
2050 | - } |
|
2051 | - if (empty($args)) { |
|
2050 | + } |
|
2051 | + if (empty($args)) { |
|
2052 | 2052 | return $string; |
2053 | - } |
|
2054 | - else { |
|
2053 | + } |
|
2054 | + else { |
|
2055 | 2055 | // Transform arguments before inserting them. |
2056 | 2056 | foreach ($args as $key => $value) { |
2057 | - switch ($key [0]) { |
|
2057 | + switch ($key [0]) { |
|
2058 | 2058 | case '@': |
2059 | 2059 | // Escaped only. |
2060 | 2060 | $args [$key] = check_plain($value); |
2061 | - break; |
|
2061 | + break; |
|
2062 | 2062 | |
2063 | 2063 | case '%': |
2064 | 2064 | default: |
2065 | 2065 | // Escaped and placeholder. |
2066 | 2066 | $args [$key] = theme('placeholder', $value); |
2067 | - break; |
|
2067 | + break; |
|
2068 | 2068 | |
2069 | 2069 | case '!': |
2070 | 2070 | // Pass-through. |
2071 | 2071 | } |
2072 | 2072 | } |
2073 | 2073 | return strtr($string, $args); |
2074 | - } |
|
2074 | + } |
|
2075 | 2075 | } |
2076 | 2076 | |
2077 | 2077 | |
@@ -2083,9 +2083,9 @@ discard block |
||
2083 | 2083 | * Overview of moderation queues |
2084 | 2084 | */ |
2085 | 2085 | function boinccore_moderation_overview_panel() { |
2086 | - $output = '<h2 class="pane-title">' . bts('Moderation', array(), NULL, 'boinc:moderate-profiles') . '</h2>'; |
|
2087 | - $output .= '<ul class="tab-list action-list">'; |
|
2088 | - if (module_exists('user_profiles')) { |
|
2086 | + $output = '<h2 class="pane-title">' . bts('Moderation', array(), NULL, 'boinc:moderate-profiles') . '</h2>'; |
|
2087 | + $output .= '<ul class="tab-list action-list">'; |
|
2088 | + if (module_exists('user_profiles')) { |
|
2089 | 2089 | $profile_count = db_result(db_query(" |
2090 | 2090 | SELECT COUNT(DISTINCT(n.nid)) |
2091 | 2091 | FROM {node} n |
@@ -2097,9 +2097,9 @@ discard block |
||
2097 | 2097 | $output .= '<span class="item-count">' . $profile_count . '</span>'; |
2098 | 2098 | $output .= '</div>'; |
2099 | 2099 | $output .= '</li>'; |
2100 | - } |
|
2101 | - $output .= '</ul>'; |
|
2102 | - return $output; |
|
2100 | + } |
|
2101 | + $output .= '</ul>'; |
|
2102 | + return $output; |
|
2103 | 2103 | } |
2104 | 2104 | |
2105 | 2105 | |
@@ -2109,10 +2109,10 @@ discard block |
||
2109 | 2109 | * |
2110 | 2110 | */ |
2111 | 2111 | function _boinccore_delete_expired_tokens() { |
2112 | - require_boinc('boinc_db'); |
|
2112 | + require_boinc('boinc_db'); |
|
2113 | 2113 | |
2114 | - $num_deleted = BoincToken::delete_expired(); |
|
2115 | - if ($num_deleted>0) { |
|
2114 | + $num_deleted = BoincToken::delete_expired(); |
|
2115 | + if ($num_deleted>0) { |
|
2116 | 2116 | watchdog('boinccore', "Deleted ${num_deleted} tokens from table token", WATCHDOG_NOTICE); |
2117 | - } |
|
2117 | + } |
|
2118 | 2118 | } |
@@ -2,9 +2,9 @@ discard block |
||
2 | 2 | // $Id$ |
3 | 3 | |
4 | 4 | /** |
5 | - * @file |
|
6 | - * Enable BOINC charting features for statistics |
|
7 | - */ |
|
5 | + * @file |
|
6 | + * Enable BOINC charting features for statistics |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | |
10 | 10 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
19 | 19 | |
20 | 20 | /** |
21 | - * Implementation of hook_menu(). |
|
22 | - */ |
|
21 | + * Implementation of hook_menu(). |
|
22 | + */ |
|
23 | 23 | function boincstats_menu() { |
24 | - $items['admin/boinc/stats'] = array( |
|
24 | + $items['admin/boinc/stats'] = array( |
|
25 | 25 | 'title' => 'Environment: Statistics setup', |
26 | 26 | 'description' => 'Configure the stats system for generating charts and |
27 | 27 | providing cross project data.', |
@@ -30,18 +30,18 @@ discard block |
||
30 | 30 | 'access arguments' => array('administer site configuration'), |
31 | 31 | 'type' => MENU_NORMAL_ITEM, |
32 | 32 | 'file' => 'boincstats.admin.inc' |
33 | - ); |
|
34 | - $items['charts/user'] = array( |
|
33 | + ); |
|
34 | + $items['charts/user'] = array( |
|
35 | 35 | 'page callback' => 'boincstats_get_user_stats_chart', |
36 | 36 | 'access arguments' => array('access content'), |
37 | 37 | 'type' => MENU_CALLBACK |
38 | - ); |
|
39 | - $items['charts/project'] = array( |
|
38 | + ); |
|
39 | + $items['charts/project'] = array( |
|
40 | 40 | 'page callback' => 'boincstats_get_project_stats_chart', |
41 | 41 | 'access arguments' => array('access content'), |
42 | 42 | 'type' => MENU_CALLBACK |
43 | - ); |
|
44 | - return $items; |
|
43 | + ); |
|
44 | + return $items; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | |
@@ -50,31 +50,31 @@ discard block |
||
50 | 50 | * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
51 | 51 | |
52 | 52 | /** |
53 | - * User stats chart menu callback |
|
54 | - * Called to generate the daily credit status chart for a user (dashboard) |
|
55 | - */ |
|
53 | + * User stats chart menu callback |
|
54 | + * Called to generate the daily credit status chart for a user (dashboard) |
|
55 | + */ |
|
56 | 56 | function boincstats_get_user_stats_chart($cpid = null, $chart_size = 'medium') { |
57 | 57 | |
58 | - // pChart library inclusions |
|
59 | - module_load_include('php', 'boincstats', 'includes/pchart/class/pData.class'); |
|
60 | - module_load_include('php', 'boincstats', 'includes/pchart/class/pDraw.class'); |
|
61 | - module_load_include('php', 'boincstats', 'includes/pchart/class/pImage.class'); |
|
62 | - module_load_include('php', 'boincstats', 'includes/pchart/class/pCache.class'); |
|
58 | + // pChart library inclusions |
|
59 | + module_load_include('php', 'boincstats', 'includes/pchart/class/pData.class'); |
|
60 | + module_load_include('php', 'boincstats', 'includes/pchart/class/pDraw.class'); |
|
61 | + module_load_include('php', 'boincstats', 'includes/pchart/class/pImage.class'); |
|
62 | + module_load_include('php', 'boincstats', 'includes/pchart/class/pCache.class'); |
|
63 | 63 | |
64 | - init_theme(); |
|
65 | - global $theme_key; |
|
66 | - $cache_name = "{$theme_key}_"; |
|
64 | + init_theme(); |
|
65 | + global $theme_key; |
|
66 | + $cache_name = "{$theme_key}_"; |
|
67 | 67 | |
68 | - $dataset_size = 0; |
|
69 | - $chart_height = 0; |
|
70 | - $chart_width = 0; |
|
71 | - $draw_x_lines = FALSE; |
|
72 | - $label_x_axis = FALSE; |
|
68 | + $dataset_size = 0; |
|
69 | + $chart_height = 0; |
|
70 | + $chart_width = 0; |
|
71 | + $draw_x_lines = FALSE; |
|
72 | + $label_x_axis = FALSE; |
|
73 | 73 | |
74 | - $stats_xml = NULL; |
|
74 | + $stats_xml = NULL; |
|
75 | 75 | |
76 | - switch($chart_size) { |
|
77 | - case 'small': |
|
76 | + switch($chart_size) { |
|
77 | + case 'small': |
|
78 | 78 | $cache_name .= "{$cpid}_small"; |
79 | 79 | $dataset_size = 30; |
80 | 80 | $chart_height = 80; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $draw_x_lines = FALSE; |
84 | 84 | $label_x_axis = FALSE; |
85 | 85 | break; |
86 | - case 'medium': |
|
86 | + case 'medium': |
|
87 | 87 | default: |
88 | 88 | $cache_name .= $cpid; |
89 | 89 | $dataset_size = 60; |
@@ -91,32 +91,32 @@ discard block |
||
91 | 91 | $chart_width = 589; |
92 | 92 | $draw_x_lines = TRUE; |
93 | 93 | $label_x_axis = TRUE; |
94 | - } |
|
94 | + } |
|
95 | 95 | |
96 | - // Sanity check for cache directory |
|
97 | - if (!boincstats_check_cache_dir()) { |
|
96 | + // Sanity check for cache directory |
|
97 | + if (!boincstats_check_cache_dir()) { |
|
98 | 98 | return; |
99 | - } |
|
99 | + } |
|
100 | 100 | |
101 | - // Initialize the cache object and flush stale images |
|
102 | - $myCache = new pCache(array('CacheFolder' => realpath('.') . '/' . conf_path() . '/files/cache')); |
|
103 | - $myCache->removeOlderThan(60*60*24); |
|
101 | + // Initialize the cache object and flush stale images |
|
102 | + $myCache = new pCache(array('CacheFolder' => realpath('.') . '/' . conf_path() . '/files/cache')); |
|
103 | + $myCache->removeOlderThan(60*60*24); |
|
104 | 104 | |
105 | - if ($myCache->isInCache($cache_name)) { |
|
105 | + if ($myCache->isInCache($cache_name)) { |
|
106 | 106 | $myCache->strokeFromCache($cache_name); |
107 | - } |
|
108 | - else { |
|
107 | + } |
|
108 | + else { |
|
109 | 109 | // Initialize dataset |
110 | 110 | $dataset = array(); |
111 | 111 | $stats_xml = boincstats_get_project_stats('daily', $cpid); |
112 | 112 | if ($stats_xml) { |
113 | - // Get the last 60 days of stats for the chart |
|
114 | - for ($j = 30; $j < 90; $j++) { |
|
113 | + // Get the last 60 days of stats for the chart |
|
114 | + for ($j = 30; $j < 90; $j++) { |
|
115 | 115 | $dataset[] = (int) $stats_xml->records->record[$j]; |
116 | - } |
|
116 | + } |
|
117 | 117 | } |
118 | 118 | else { |
119 | - for ($i = 0; $i <= $dataset_size; $i++) $dataset[] = 0; |
|
119 | + for ($i = 0; $i <= $dataset_size; $i++) $dataset[] = 0; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | // Get color configuration |
@@ -145,39 +145,39 @@ discard block |
||
145 | 145 | // Define the chart area |
146 | 146 | $myPicture->setGraphArea(0, 3, $chart_width, $chart_height); |
147 | 147 | if ($backdrop_color) { |
148 | - $myPicture->drawFilledRectangle(0, 0, $chart_width, $chart_height, $backdrop_color); |
|
148 | + $myPicture->drawFilledRectangle(0, 0, $chart_width, $chart_height, $backdrop_color); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | // Draw the scale |
152 | 152 | $scaleSettings = array( |
153 | - 'Mode' => SCALE_MODE_START0, |
|
154 | - 'DrawYLines' => false, |
|
155 | - 'DrawXLines' => $draw_x_lines, |
|
156 | - 'GridTicks' => 2, |
|
157 | - 'LabelSkip' => 9, |
|
158 | - 'SkippedAxisAlpha' => 0, |
|
159 | - 'SkippedInnerTickWidth' => 0, |
|
160 | - 'SkippedOuterTickWidth' => 0, |
|
161 | - 'AxisAlpha' => 0, |
|
162 | - 'InnerTickWidth' => 0, |
|
163 | - 'OuterTickWidth' => 0, |
|
164 | - 'XMargin' => 1, |
|
165 | - 'YMargin' => 0, |
|
166 | - 'Floating' => TRUE, |
|
167 | - 'GridR' => 200, |
|
168 | - 'GridG' => 200, |
|
169 | - 'GridB' => 200, |
|
170 | - 'DrawSubTicks' => false, |
|
171 | - 'CycleBackground' => false |
|
153 | + 'Mode' => SCALE_MODE_START0, |
|
154 | + 'DrawYLines' => false, |
|
155 | + 'DrawXLines' => $draw_x_lines, |
|
156 | + 'GridTicks' => 2, |
|
157 | + 'LabelSkip' => 9, |
|
158 | + 'SkippedAxisAlpha' => 0, |
|
159 | + 'SkippedInnerTickWidth' => 0, |
|
160 | + 'SkippedOuterTickWidth' => 0, |
|
161 | + 'AxisAlpha' => 0, |
|
162 | + 'InnerTickWidth' => 0, |
|
163 | + 'OuterTickWidth' => 0, |
|
164 | + 'XMargin' => 1, |
|
165 | + 'YMargin' => 0, |
|
166 | + 'Floating' => TRUE, |
|
167 | + 'GridR' => 200, |
|
168 | + 'GridG' => 200, |
|
169 | + 'GridB' => 200, |
|
170 | + 'DrawSubTicks' => false, |
|
171 | + 'CycleBackground' => false |
|
172 | 172 | ); |
173 | 173 | $myPicture->setFontProperties(array('FontSize' => 10)); |
174 | 174 | $myPicture->drawScale($scaleSettings); |
175 | 175 | |
176 | 176 | if ($label_x_axis) { |
177 | - for ($i = 5; $i >= 0; $i--) { |
|
177 | + for ($i = 5; $i >= 0; $i--) { |
|
178 | 178 | $label = ($i) ? -10*$i : 'Today'; |
179 | 179 | $myPicture->drawText(589-587*($i/6)-5, 2, $label, array('Align' => TEXT_ALIGN_TOPRIGHT)); |
180 | - } |
|
180 | + } |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | // Draw the area chart |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | // Render the picture (choose the best way) |
190 | 190 | //$myPicture->autoOutput('pictures/example.drawAreaChart.simple.png'); |
191 | 191 | $myPicture->stroke(); |
192 | - } |
|
192 | + } |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -197,48 +197,48 @@ discard block |
||
197 | 197 | * Called to generate the daily credit status chart for the whole project |
198 | 198 | */ |
199 | 199 | function boincstats_get_project_stats_chart() { |
200 | - // pChart library inclusions |
|
201 | - module_load_include('php', 'boincstats', 'includes/pchart/class/pData.class'); |
|
202 | - module_load_include('php', 'boincstats', 'includes/pchart/class/pDraw.class'); |
|
203 | - module_load_include('php', 'boincstats', 'includes/pchart/class/pImage.class'); |
|
204 | - module_load_include('php', 'boincstats', 'includes/pchart/class/pCache.class'); |
|
200 | + // pChart library inclusions |
|
201 | + module_load_include('php', 'boincstats', 'includes/pchart/class/pData.class'); |
|
202 | + module_load_include('php', 'boincstats', 'includes/pchart/class/pDraw.class'); |
|
203 | + module_load_include('php', 'boincstats', 'includes/pchart/class/pImage.class'); |
|
204 | + module_load_include('php', 'boincstats', 'includes/pchart/class/pCache.class'); |
|
205 | 205 | |
206 | - init_theme(); |
|
207 | - global $theme_key; |
|
208 | - $cache_name = "{$theme_key}_project_chart"; |
|
206 | + init_theme(); |
|
207 | + global $theme_key; |
|
208 | + $cache_name = "{$theme_key}_project_chart"; |
|
209 | 209 | |
210 | - $color_keys = array('R', 'G', 'B'); |
|
210 | + $color_keys = array('R', 'G', 'B'); |
|
211 | 211 | |
212 | - // Get color configuration |
|
213 | - $palette_color_hex = theme_get_setting('boinc_stats_chart_color'); |
|
214 | - $palette_color = array_combine($color_keys, sscanf($palette_color_hex, "#%02x%02x%02x")); |
|
215 | - $backdrop_color_hex = theme_get_setting('boinc_stats_chart_bcolor'); |
|
216 | - $backdrop_color = array_combine($color_keys, sscanf($backdrop_color_hex, "#%02x%02x%02x")); |
|
212 | + // Get color configuration |
|
213 | + $palette_color_hex = theme_get_setting('boinc_stats_chart_color'); |
|
214 | + $palette_color = array_combine($color_keys, sscanf($palette_color_hex, "#%02x%02x%02x")); |
|
215 | + $backdrop_color_hex = theme_get_setting('boinc_stats_chart_bcolor'); |
|
216 | + $backdrop_color = array_combine($color_keys, sscanf($backdrop_color_hex, "#%02x%02x%02x")); |
|
217 | 217 | |
218 | - // Sanity check for cache directory |
|
219 | - if (!boincstats_check_cache_dir()) { |
|
218 | + // Sanity check for cache directory |
|
219 | + if (!boincstats_check_cache_dir()) { |
|
220 | 220 | return; |
221 | - } |
|
221 | + } |
|
222 | 222 | |
223 | - // Initialize the cache object and flush stale images |
|
224 | - $myCache = new pCache(array('CacheFolder' => realpath('.') . '/' . conf_path() . '/files/cache')); |
|
225 | - $myCache->removeOlderThan(60*60*24); |
|
223 | + // Initialize the cache object and flush stale images |
|
224 | + $myCache = new pCache(array('CacheFolder' => realpath('.') . '/' . conf_path() . '/files/cache')); |
|
225 | + $myCache->removeOlderThan(60*60*24); |
|
226 | 226 | |
227 | - if ($myCache->isInCache($cache_name)) { |
|
227 | + if ($myCache->isInCache($cache_name)) { |
|
228 | 228 | $myCache->strokeFromCache($cache_name); |
229 | - } |
|
230 | - else { |
|
229 | + } |
|
230 | + else { |
|
231 | 231 | // Initialize dataset |
232 | 232 | $dataset = array(); |
233 | 233 | $stats_xml = boincstats_get_project_stats('daily'); |
234 | 234 | if ($stats_xml) { |
235 | - // Get the last 60 days of stats for the chart |
|
236 | - for ($j = 30; $j < 90; $j++) { |
|
235 | + // Get the last 60 days of stats for the chart |
|
236 | + for ($j = 30; $j < 90; $j++) { |
|
237 | 237 | $dataset[] = (int) $stats_xml->records->record[$j]; |
238 | - } |
|
238 | + } |
|
239 | 239 | } |
240 | 240 | else { |
241 | - for ($i = 0; $i <= 30; $i++) $dataset[] = 0; |
|
241 | + for ($i = 0; $i <= 30; $i++) $dataset[] = 0; |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | // Create and populate the pData object |
@@ -263,25 +263,25 @@ discard block |
||
263 | 263 | |
264 | 264 | // Draw the scale |
265 | 265 | $scaleSettings = array( |
266 | - 'Mode' => SCALE_MODE_START0, |
|
267 | - 'DrawYLines' => false, |
|
268 | - 'DrawXLines' => false, |
|
269 | - 'GridTicks' => 2, |
|
270 | - 'LabelSkip' => 9, |
|
271 | - 'SkippedAxisAlpha' => 0, |
|
272 | - 'SkippedInnerTickWidth' => 0, |
|
273 | - 'SkippedOuterTickWidth' => 0, |
|
274 | - 'AxisAlpha' => 0, |
|
275 | - 'InnerTickWidth' => 0, |
|
276 | - 'OuterTickWidth' => 0, |
|
277 | - 'XMargin' => 1, |
|
278 | - 'YMargin' => 0, |
|
279 | - 'Floating' => TRUE, |
|
280 | - 'GridR' => 200, |
|
281 | - 'GridG' => 200, |
|
282 | - 'GridB' => 200, |
|
283 | - 'DrawSubTicks' => false, |
|
284 | - 'CycleBackground' => false |
|
266 | + 'Mode' => SCALE_MODE_START0, |
|
267 | + 'DrawYLines' => false, |
|
268 | + 'DrawXLines' => false, |
|
269 | + 'GridTicks' => 2, |
|
270 | + 'LabelSkip' => 9, |
|
271 | + 'SkippedAxisAlpha' => 0, |
|
272 | + 'SkippedInnerTickWidth' => 0, |
|
273 | + 'SkippedOuterTickWidth' => 0, |
|
274 | + 'AxisAlpha' => 0, |
|
275 | + 'InnerTickWidth' => 0, |
|
276 | + 'OuterTickWidth' => 0, |
|
277 | + 'XMargin' => 1, |
|
278 | + 'YMargin' => 0, |
|
279 | + 'Floating' => TRUE, |
|
280 | + 'GridR' => 200, |
|
281 | + 'GridG' => 200, |
|
282 | + 'GridB' => 200, |
|
283 | + 'DrawSubTicks' => false, |
|
284 | + 'CycleBackground' => false |
|
285 | 285 | ); |
286 | 286 | $myPicture->setFontProperties(array('FontSize' => 10)); |
287 | 287 | $myPicture->drawScale($scaleSettings); |
@@ -300,41 +300,41 @@ discard block |
||
300 | 300 | // Render the picture (choose the best way) |
301 | 301 | //$myPicture->autoOutput('pictures/example.drawAreaChart.simple.png'); |
302 | 302 | $myPicture->stroke(); |
303 | - } |
|
303 | + } |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | /* |
307 | 307 | * |
308 | 308 | */ |
309 | 309 | function boincstats_check_cache_dir($cache_path = 'files/cache') { |
310 | - $cache_dir = realpath('.') . '/' . conf_path() . '/' . $cache_path; |
|
311 | - if (!is_writeable($cache_dir)) { |
|
310 | + $cache_dir = realpath('.') . '/' . conf_path() . '/' . $cache_path; |
|
311 | + if (!is_writeable($cache_dir)) { |
|
312 | 312 | if (!is_dir($cache_dir)) { |
313 | - if (!is_writeable(dirname($cache_dir))) { |
|
313 | + if (!is_writeable(dirname($cache_dir))) { |
|
314 | 314 | // If the parent "files" dir isn't even writeable... |
315 | 315 | watchdog('boincstats', '@parent_dir directory is not writeable. This |
316 | 316 | directory must be writeable by the web server.', |
317 | - array('@parent_dir' => dirname($cache_dir)), WATCHDOG_ERROR); |
|
317 | + array('@parent_dir' => dirname($cache_dir)), WATCHDOG_ERROR); |
|
318 | 318 | return FALSE; |
319 | - } |
|
320 | - else { |
|
319 | + } |
|
320 | + else { |
|
321 | 321 | // Create the cache dir |
322 | 322 | if (!mkdir($cache_dir, 0775)) { |
323 | - watchdog('boincstats', 'Failed to create @cache_dir directory. Check |
|
323 | + watchdog('boincstats', 'Failed to create @cache_dir directory. Check |
|
324 | 324 | filesystem permissions...?', |
325 | 325 | array('@cache_dir' => $cache_dir), WATCHDOG_ERROR); |
326 | - return FALSE; |
|
326 | + return FALSE; |
|
327 | + } |
|
327 | 328 | } |
328 | - } |
|
329 | 329 | } |
330 | 330 | else { |
331 | - watchdog('boincstats', 'Cache directory at @cache_dir is not writeable. |
|
331 | + watchdog('boincstats', 'Cache directory at @cache_dir is not writeable. |
|
332 | 332 | Please allow webserver write access.', |
333 | 333 | array('@cache_dir' => $cache_dir), WATCHDOG_ERROR); |
334 | - return FALSE; |
|
334 | + return FALSE; |
|
335 | 335 | } |
336 | - } |
|
337 | - return TRUE; |
|
336 | + } |
|
337 | + return TRUE; |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | /* |
@@ -342,87 +342,87 @@ discard block |
||
342 | 342 | */ |
343 | 343 | function boincstats_get_project_stats($type = 'total', $cpid = NULL) { |
344 | 344 | |
345 | - // Determine the stats environment |
|
346 | - boincstats_check_configuration(); |
|
347 | - $stats_server = variable_get('boinc_stats_server', ''); |
|
348 | - $stats_rpc = variable_get('boinc_stats_project_credit_history_rpc', ''); |
|
349 | - $project_id = variable_get('boinc_stats_remote_project_id', ''); |
|
345 | + // Determine the stats environment |
|
346 | + boincstats_check_configuration(); |
|
347 | + $stats_server = variable_get('boinc_stats_server', ''); |
|
348 | + $stats_rpc = variable_get('boinc_stats_project_credit_history_rpc', ''); |
|
349 | + $project_id = variable_get('boinc_stats_remote_project_id', ''); |
|
350 | 350 | |
351 | - $get = array( |
|
351 | + $get = array( |
|
352 | 352 | 'id' => $project_id |
353 | - ); |
|
354 | - switch ($type) { |
|
355 | - case 'daily': |
|
353 | + ); |
|
354 | + switch ($type) { |
|
355 | + case 'daily': |
|
356 | 356 | $get['daily'] = NULL; |
357 | 357 | break; |
358 | - case 'total': |
|
358 | + case 'total': |
|
359 | 359 | default: |
360 | 360 | } |
361 | 361 | |
362 | - if ($cpid) { |
|
362 | + if ($cpid) { |
|
363 | 363 | // If a user CPID has been provided, limit scope to that user |
364 | 364 | $stats_rpc = variable_get('boinc_stats_user_credit_history_rpc', ''); |
365 | 365 | $get['cpid'] = $cpid; |
366 | - } |
|
366 | + } |
|
367 | 367 | |
368 | - // Construct query string |
|
369 | - $args = array(); |
|
370 | - foreach ($get as $arg => $value) { |
|
368 | + // Construct query string |
|
369 | + $args = array(); |
|
370 | + foreach ($get as $arg => $value) { |
|
371 | 371 | if ($value !== NULL) { |
372 | - $args[] = "{$arg}=" . rawurlencode($value); |
|
372 | + $args[] = "{$arg}=" . rawurlencode($value); |
|
373 | 373 | } |
374 | 374 | else { |
375 | - $args[] = $arg; |
|
375 | + $args[] = $arg; |
|
376 | 376 | } |
377 | - } |
|
378 | - $query = '?' . implode('&', $args); |
|
377 | + } |
|
378 | + $query = '?' . implode('&', $args); |
|
379 | 379 | |
380 | - // Load XML from RPC |
|
381 | - $stats_xml = NULL; |
|
382 | - $target_url = "http://{$stats_server}/{$stats_rpc}{$query}"; |
|
383 | - $result = drupal_http_request($target_url); |
|
384 | - if (in_array($result->code, array(200, 304)) || in_array($result->redirect_code, array(200, 304))) { |
|
380 | + // Load XML from RPC |
|
381 | + $stats_xml = NULL; |
|
382 | + $target_url = "http://{$stats_server}/{$stats_rpc}{$query}"; |
|
383 | + $result = drupal_http_request($target_url); |
|
384 | + if (in_array($result->code, array(200, 304)) || in_array($result->redirect_code, array(200, 304))) { |
|
385 | 385 | $stats_xml = simplexml_load_string($result->data); |
386 | - } |
|
387 | - watchdog('boincstats', $target_url); |
|
388 | - return $stats_xml; |
|
386 | + } |
|
387 | + watchdog('boincstats', $target_url); |
|
388 | + return $stats_xml; |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | /* |
392 | 392 | * |
393 | 393 | */ |
394 | 394 | function boincstats_get_project_total_credit() { |
395 | - $stats_xml = boincstats_get_project_stats(); |
|
396 | - $last_record = end($stats_xml->records->record); |
|
397 | - return ($last_record) ? (int) $last_record : 0; |
|
395 | + $stats_xml = boincstats_get_project_stats(); |
|
396 | + $last_record = end($stats_xml->records->record); |
|
397 | + return ($last_record) ? (int) $last_record : 0; |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | /* |
401 | 401 | * |
402 | 402 | */ |
403 | 403 | function boincstats_get_project_avg_credit() { |
404 | - $stats_xml = boincstats_get_project_stats(); |
|
405 | - return (isset($stats_xml->recent_avg)) ? $stats_xml->recent_avg : 0; |
|
404 | + $stats_xml = boincstats_get_project_stats(); |
|
405 | + return (isset($stats_xml->recent_avg)) ? $stats_xml->recent_avg : 0; |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | /* |
409 | 409 | * |
410 | 410 | */ |
411 | 411 | function boincstats_credit_to_ghours($credit) { |
412 | - return $credit / (100 * 365); |
|
412 | + return $credit / (100 * 365); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | /* |
416 | 416 | * |
417 | 417 | */ |
418 | 418 | function boincstats_credit_to_flops($credit, $prefix = 0) { |
419 | - $factor = array( |
|
419 | + $factor = array( |
|
420 | 420 | '0' => 0, |
421 | 421 | 'g' => 3, |
422 | 422 | 't' => 6, |
423 | 423 | 'p' => 9 |
424 | - ); |
|
425 | - return $credit / (pow(10, (int) $factor[$prefix]) / 10); |
|
424 | + ); |
|
425 | + return $credit / (pow(10, (int) $factor[$prefix]) / 10); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | |
@@ -431,22 +431,22 @@ discard block |
||
431 | 431 | * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
432 | 432 | |
433 | 433 | function boincstats_get_project_stats_overview($type = 'basic') { |
434 | - global $base_path; |
|
435 | - $output = ''; |
|
436 | - switch ($type) { |
|
437 | - case 'basic': |
|
434 | + global $base_path; |
|
435 | + $output = ''; |
|
436 | + switch ($type) { |
|
437 | + case 'basic': |
|
438 | 438 | $output .= '<div class="overlay"><span>(' . bts('Credits per day', array(), NULL, 'boinc:front-page') . ')</span></div>' . "\n"; |
439 | 439 | $output .= '<div class="chart"><img src="' . $base_path . 'charts/project" /></div>' . "\n"; |
440 | 440 | break; |
441 | - case 'detailed': |
|
441 | + case 'detailed': |
|
442 | 442 | $output .= '<div class="stats"><label>' . bts('Total G-hours', array(), NULL, 'boinc:front-page') . ': </label><span>' . number_format(boincstats_credit_to_ghours(boincstats_get_project_total_credit())) . '</span></div>' . "\n"; |
443 | 443 | $output .= '<div class="stats"><label>' . bts('Avg TFlops', array(), NULL, 'boinc:front-page') . ': </label><span>' . number_format(boincstats_credit_to_flops(boincstats_get_project_avg_credit(), 't')) . '</span></div>' . "\n"; |
444 | 444 | //$output .= '<div class="stats"><a href="#">' . bts('Pending credits', array(), NULL, 'boinc:front-page') . '</a></div>' . "\n"; |
445 | 445 | $output .= '<div class="chart"><img src="' . $base_path . 'charts/project" /></div>' . "\n"; |
446 | 446 | break; |
447 | - default: |
|
447 | + default: |
|
448 | 448 | } |
449 | - return $output; |
|
449 | + return $output; |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | |
@@ -458,19 +458,19 @@ discard block |
||
458 | 458 | * Check that the stats system is configured, report if it isn't |
459 | 459 | */ |
460 | 460 | function boincstats_check_configuration() { |
461 | - $project_id = variable_get('boinc_stats_remote_project_id', ''); |
|
462 | - if (!$project_id) { |
|
461 | + $project_id = variable_get('boinc_stats_remote_project_id', ''); |
|
462 | + if (!$project_id) { |
|
463 | 463 | watchdog('boincstats', 'The BOINC stats system is not configured. Please |
464 | 464 | !configure_it', array('!configure_it' => l(t('configure it now'), |
465 | - 'admin/boinc/stats')), WATCHDOG_ERROR); |
|
465 | + 'admin/boinc/stats')), WATCHDOG_ERROR); |
|
466 | 466 | if (user_access('administer site configuration')) { |
467 | - drupal_set_message(t('The BOINC stats system is not configured. Please |
|
467 | + drupal_set_message(t('The BOINC stats system is not configured. Please |
|
468 | 468 | !configure_it', array('!configure_it' => l(t('configure it now'), |
469 | - 'admin/boinc/stats'))), 'error', FALSE); |
|
469 | + 'admin/boinc/stats'))), 'error', FALSE); |
|
470 | 470 | } |
471 | 471 | else { |
472 | - drupal_set_message(t('There is a problem with the site. Please contact |
|
472 | + drupal_set_message(t('There is a problem with the site. Please contact |
|
473 | 473 | the system administrator.'), 'error', FALSE); |
474 | 474 | } |
475 | - } |
|
475 | + } |
|
476 | 476 | } |
@@ -27,44 +27,44 @@ discard block |
||
27 | 27 | * with defined URL paths |
28 | 28 | */ |
29 | 29 | function boincuser_menu() { |
30 | - $items['account/posts'] = array( |
|
30 | + $items['account/posts'] = array( |
|
31 | 31 | 'title' => 'Recent posts', |
32 | 32 | 'description' => '', |
33 | 33 | 'page callback' => 'boincuser_goto_recent_posts', |
34 | 34 | 'access callback' => 'user_is_logged_in', |
35 | 35 | 'type' => MENU_CALLBACK, |
36 | - ); |
|
37 | - $items['account/profile'] = array( |
|
36 | + ); |
|
37 | + $items['account/profile'] = array( |
|
38 | 38 | 'title' => '', |
39 | 39 | 'description' => '', |
40 | 40 | 'page callback' => 'boincuser_view_profile', |
41 | 41 | 'access callback' => 'user_is_logged_in', |
42 | 42 | 'type' => MENU_NORMAL_ITEM |
43 | - ); |
|
44 | - $items['account/profile/view'] = array( |
|
43 | + ); |
|
44 | + $items['account/profile/view'] = array( |
|
45 | 45 | 'title' => 'View', |
46 | 46 | 'description' => 'Show a user profile', |
47 | 47 | 'page callback' => 'boincuser_view_profile', |
48 | 48 | 'access callback' => 'user_is_logged_in', |
49 | 49 | 'type' => MENU_DEFAULT_LOCAL_TASK, |
50 | 50 | 'weight' => 0 |
51 | - ); |
|
52 | - $items['account/profile/edit'] = array( |
|
51 | + ); |
|
52 | + $items['account/profile/edit'] = array( |
|
53 | 53 | 'title' => 'Edit', |
54 | 54 | 'description' => 'Edit a user profile', |
55 | 55 | 'page callback' => 'boincuser_edit_profile', |
56 | 56 | 'access arguments' => array('edit own profile content'), |
57 | 57 | 'type' => MENU_LOCAL_TASK, |
58 | 58 | 'weight' => 5 |
59 | - ); |
|
60 | - $items['account/team'] = array( |
|
59 | + ); |
|
60 | + $items['account/team'] = array( |
|
61 | 61 | 'title' => 'User team', |
62 | 62 | 'description' => '', |
63 | 63 | 'page callback' => 'boincuser_goto_team', |
64 | 64 | 'access callback' => 'user_is_logged_in', |
65 | 65 | 'type' => MENU_CALLBACK, |
66 | - ); |
|
67 | - $items['moderate/profile/%user/approve'] = array( |
|
66 | + ); |
|
67 | + $items['moderate/profile/%user/approve'] = array( |
|
68 | 68 | 'title' => 'Profile approval', |
69 | 69 | 'description' => 'Approve profile content', |
70 | 70 | 'page callback' => 'boincuser_moderate_profile_approve', |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | 'access arguments' => array('edit any profile content'), |
73 | 73 | 'type' => MENU_CALLBACK, |
74 | 74 | 'weight' => 5 |
75 | - ); |
|
76 | - $items['moderate/profile/%user/edit'] = array( |
|
75 | + ); |
|
76 | + $items['moderate/profile/%user/edit'] = array( |
|
77 | 77 | 'title' => 'Profile editor', |
78 | 78 | 'description' => 'Edit a user profile', |
79 | 79 | 'page callback' => 'boincuser_edit_profile', |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | 'access arguments' => array('edit any profile content'), |
82 | 82 | 'type' => MENU_CALLBACK, |
83 | 83 | 'weight' => 5 |
84 | - ); |
|
85 | - $items['moderate/profile/%/reject'] = array( |
|
84 | + ); |
|
85 | + $items['moderate/profile/%/reject'] = array( |
|
86 | 86 | 'title' => bts('Reject profile', array(), NULL, 'boinc:moderate-user'), |
87 | 87 | 'description' => 'Reject profile content', |
88 | 88 | 'page callback' => 'drupal_get_form', |
@@ -90,60 +90,60 @@ discard block |
||
90 | 90 | 'access arguments' => array('edit any profile content'), |
91 | 91 | 'type' => MENU_CALLBACK, |
92 | 92 | 'weight' => 5 |
93 | - ); |
|
94 | - $items['moderate/user/%/ban'] = array( |
|
93 | + ); |
|
94 | + $items['moderate/user/%/ban'] = array( |
|
95 | 95 | 'title' => bts('Ban user', array(), NULL, 'boinc:moderate-ban-user'), |
96 | 96 | 'description' => 'Ban a user from using community features', |
97 | 97 | 'page callback' => 'drupal_get_form', |
98 | 98 | 'page arguments' => array('boincuser_moderate_user_ban_form', 2), |
99 | 99 | 'access callback' => 'boincuser_moderate_community_access', |
100 | 100 | 'type' => MENU_CALLBACK, |
101 | - ); |
|
102 | - $items['join'] = array( |
|
101 | + ); |
|
102 | + $items['join'] = array( |
|
103 | 103 | 'title' => '', |
104 | 104 | 'description' => '', |
105 | 105 | 'page callback' => 'join_page', |
106 | 106 | 'access arguments' => array('access content'), |
107 | 107 | 'type' => MENU_NORMAL_ITEM |
108 | - ); |
|
109 | - $items['join/new'] = array( |
|
108 | + ); |
|
109 | + $items['join/new'] = array( |
|
110 | 110 | 'title' => bts("I'm new"), |
111 | 111 | 'page callback' => 'join_page', |
112 | 112 | 'page arguments' => array(1), |
113 | 113 | 'access arguments' => array('access content'), |
114 | 114 | 'type' => MENU_DEFAULT_LOCAL_TASK, |
115 | 115 | 'weight' => 0 |
116 | - ); |
|
117 | - $items['join/boinc'] = array( |
|
116 | + ); |
|
117 | + $items['join/boinc'] = array( |
|
118 | 118 | 'title' => bts("I'm a BOINC user"), |
119 | 119 | 'page callback' => 'join_page', |
120 | 120 | 'page arguments' => array(1), |
121 | 121 | 'access arguments' => array('access content'), |
122 | 122 | 'type' => MENU_LOCAL_TASK, |
123 | 123 | 'weight' => 5 |
124 | - ); |
|
125 | - $items['user/login/auth'] = array( |
|
124 | + ); |
|
125 | + $items['user/login/auth'] = array( |
|
126 | 126 | 'title' => bts('Authenticator login', array(), NULL, 'boinc:authenticator-login-page'), |
127 | 127 | 'description' => 'Log in using a user authenticator', |
128 | 128 | 'page callback' => 'drupal_get_form', |
129 | 129 | 'page arguments' => array('boincuser_authloginform'), |
130 | 130 | 'access arguments' => array('access content'), |
131 | 131 | 'type' => MENU_CALLBACK, |
132 | - ); |
|
133 | - $items['user/termsofuse'] = array( |
|
132 | + ); |
|
133 | + $items['user/termsofuse'] = array( |
|
134 | 134 | 'title' => bts('Terms of Use', array(), NULL, 'boinc:termsofuse-form'), |
135 | 135 | 'description' => 'A site\'s term of use.', |
136 | 136 | 'page callback' => 'drupal_get_form', |
137 | 137 | 'page arguments' => array('boincuser_termsofuse_form'), |
138 | 138 | 'access callback' => 'user_is_logged_in', |
139 | 139 | 'type' => MENU_CALLBACK, |
140 | - ); |
|
141 | - $items['user_control'] = array( |
|
140 | + ); |
|
141 | + $items['user_control'] = array( |
|
142 | 142 | 'page callback' => 'boincuser_control', |
143 | 143 | 'access arguments' => array('access user profiles'), |
144 | 144 | 'type' => MENU_CALLBACK |
145 | - ); |
|
146 | - $items['admin/boinc'] = array( |
|
145 | + ); |
|
146 | + $items['admin/boinc'] = array( |
|
147 | 147 | 'title' => 'BOINC configuration', |
148 | 148 | 'position' => 'right', |
149 | 149 | 'weight' => -8, |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | 'access arguments' => array('administer site configuration'), |
152 | 152 | 'file' => 'system.admin.inc', |
153 | 153 | 'file path' => drupal_get_path('module', 'system'), |
154 | - ); |
|
155 | - $items['admin/boinc/environment'] = array( |
|
154 | + ); |
|
155 | + $items['admin/boinc/environment'] = array( |
|
156 | 156 | 'title' => 'Environment: General', |
157 | 157 | 'description' => 'Set paths to BOINC functions and any other necessary |
158 | 158 | variables that establish a BOINC environment.', |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | 'access arguments' => array('administer site configuration'), |
162 | 162 | 'type' => MENU_NORMAL_ITEM, |
163 | 163 | 'file' => 'boincuser.admin.inc' |
164 | - ); |
|
165 | - $items['admin/boinc/scheduler'] = array( |
|
164 | + ); |
|
165 | + $items['admin/boinc/scheduler'] = array( |
|
166 | 166 | 'title' => 'Environment: Scheduling server URLs', |
167 | 167 | 'description' => 'Set BOINC scheduler options.', |
168 | 168 | 'page callback' => 'drupal_get_form', |
@@ -170,8 +170,8 @@ discard block |
||
170 | 170 | 'access arguments' => array('administer site configuration'), |
171 | 171 | 'type' => MENU_NORMAL_ITEM, |
172 | 172 | 'file' => 'boincuser.admin.inc' |
173 | - ); |
|
174 | - $items['admin/boinc/weboptions'] = array( |
|
173 | + ); |
|
174 | + $items['admin/boinc/weboptions'] = array( |
|
175 | 175 | 'title' => 'Environment: Website Options', |
176 | 176 | 'description' => 'Set options configuring this Drupal-BOINC Web site.', |
177 | 177 | 'page callback' => 'drupal_get_form', |
@@ -179,117 +179,117 @@ discard block |
||
179 | 179 | 'access arguments' => array('administer site configuration'), |
180 | 180 | 'type' => MENU_NORMAL_ITEM, |
181 | 181 | 'file' => 'boincuser.admin.inc' |
182 | - ); |
|
182 | + ); |
|
183 | 183 | |
184 | - $items['create_account.php'] = array( |
|
184 | + $items['create_account.php'] = array( |
|
185 | 185 | 'title' => 'Create Account RPC', |
186 | 186 | 'description' => 'RPC for creating user accounts.', |
187 | 187 | 'page callback' => 'boincuser_create_account', |
188 | 188 | 'access callback' => TRUE, |
189 | 189 | 'type' => MENU_CALLBACK |
190 | - ); |
|
191 | - $items['account_finish.php'] = array( |
|
190 | + ); |
|
191 | + $items['account_finish.php'] = array( |
|
192 | 192 | 'title' => 'Welcome to ' . variable_get('site_name', 'Drupal-BOINC'), |
193 | 193 | 'description' => 'RPC for after a user has created an account.', |
194 | 194 | 'page callback' => 'boincuser_account_finish', |
195 | 195 | 'access callback' => TRUE, |
196 | 196 | 'type' => MENU_CALLBACK, |
197 | - ); |
|
198 | - $items['boincuser/autocomplete'] = array( |
|
197 | + ); |
|
198 | + $items['boincuser/autocomplete'] = array( |
|
199 | 199 | 'page callback' => '_boincuser_user_name_autocomplete', |
200 | 200 | 'access callback' => TRUE, |
201 | 201 | 'type' => MENU_CALLBACK, |
202 | - ); |
|
203 | - $items['user/%user/recoveremail/%'] = array( |
|
202 | + ); |
|
203 | + $items['user/%user/recoveremail/%'] = array( |
|
204 | 204 | 'title' => t('Recover previous email'), |
205 | 205 | 'description' => t('Form to revert email to previous address.'), |
206 | 206 | 'page callback' => 'drupal_get_form', |
207 | 207 | 'page arguments' => array('boincuser_revertemail', 3), |
208 | 208 | 'access callback' => 'user_is_logged_in', |
209 | 209 | 'type' => MENU_CALLBACK, |
210 | - ); |
|
211 | - $items['recover_email.php'] = array( |
|
210 | + ); |
|
211 | + $items['recover_email.php'] = array( |
|
212 | 212 | 'title' => t('Recover previous email'), |
213 | 213 | 'description' => t('redirect'), |
214 | 214 | 'page callback' => '_boincuser_redirect_recover_email', |
215 | 215 | 'access callback' => TRUE, |
216 | 216 | 'type' => MENU_CALLBACK, |
217 | - ); |
|
218 | - return $items; |
|
217 | + ); |
|
218 | + return $items; |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
222 | 222 | * Implementation of hook_init() |
223 | 223 | */ |
224 | 224 | function boincuser_init() { |
225 | - global $user; |
|
226 | - // Skip this check for charts, which are loaded separately |
|
227 | - // (may get duplicate or unexpected messages otherwise) |
|
228 | - if (substr($_GET['q'], 0, 7) == 'charts/') { |
|
225 | + global $user; |
|
226 | + // Skip this check for charts, which are loaded separately |
|
227 | + // (may get duplicate or unexpected messages otherwise) |
|
228 | + if (substr($_GET['q'], 0, 7) == 'charts/') { |
|
229 | 229 | return; |
230 | - } |
|
230 | + } |
|
231 | 231 | |
232 | - // If admin user, do some basic site functionality checks |
|
233 | - if (user_access('administer site configuration')) { |
|
232 | + // If admin user, do some basic site functionality checks |
|
233 | + if (user_access('administer site configuration')) { |
|
234 | 234 | // Ensure we have a configured BOINC environment |
235 | 235 | boinc_get_path(); |
236 | 236 | boinc_get_scheduler_tags(); |
237 | - } |
|
237 | + } |
|
238 | 238 | |
239 | - // Check credits for the verified contributor role |
|
240 | - boincuser_check_credit_requirements(); |
|
239 | + // Check credits for the verified contributor role |
|
240 | + boincuser_check_credit_requirements(); |
|
241 | 241 | |
242 | - if (module_exists('boincteam')) { |
|
242 | + if (module_exists('boincteam')) { |
|
243 | 243 | // Display any persistent team messages |
244 | 244 | boincteam_show_messages(); |
245 | - } |
|
245 | + } |
|
246 | 246 | |
247 | - // Check if user has agreed to the terms of use. If not, send the |
|
248 | - // user to the terms-of-use form. This is only makes sense if the |
|
249 | - // termsofuse is enabled, by having text in the termsofuse variable. |
|
250 | - $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE); |
|
251 | - $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
252 | - if ( (!empty($termsofuse)) and ($user->uid) ) { |
|
247 | + // Check if user has agreed to the terms of use. If not, send the |
|
248 | + // user to the terms-of-use form. This is only makes sense if the |
|
249 | + // termsofuse is enabled, by having text in the termsofuse variable. |
|
250 | + $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE); |
|
251 | + $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
252 | + if ( (!empty($termsofuse)) and ($user->uid) ) { |
|
253 | 253 | if ( !boincuser_check_termsofuse($user) and ($existinguser_tou) ) { |
254 | 254 | |
255 | - // Admins are exempt, otherwise the admin may not be able to |
|
256 | - // access the site! |
|
257 | - $administrator_role = array_search('administrator', user_roles(true)); |
|
258 | - if (!isset($user->roles[$administrator_role])) { |
|
255 | + // Admins are exempt, otherwise the admin may not be able to |
|
256 | + // access the site! |
|
257 | + $administrator_role = array_search('administrator', user_roles(true)); |
|
258 | + if (!isset($user->roles[$administrator_role])) { |
|
259 | 259 | $path = drupal_get_path_alias($_GET['q']); |
260 | 260 | |
261 | 261 | // Any paths that should NOT be redirected go here. |
262 | 262 | // The site will not function correctly if these are not exempt! |
263 | 263 | $paths0 = array( |
264 | - 'user/termsofuse', |
|
265 | - 'logout', |
|
266 | - 'account/info/edit', |
|
267 | - 'user/' . $user->uid . '/edit', |
|
268 | - 'user/' . $user->uid . '/recoveremail/*', |
|
269 | - 'recover_email.php', |
|
264 | + 'user/termsofuse', |
|
265 | + 'logout', |
|
266 | + 'account/info/edit', |
|
267 | + 'user/' . $user->uid . '/edit', |
|
268 | + 'user/' . $user->uid . '/recoveremail/*', |
|
269 | + 'recover_email.php', |
|
270 | 270 | ); |
271 | 271 | if (module_exists('boincuser_delete')) { |
272 | - $paths0[] = 'user/' . $user->uid . '/delete'; |
|
273 | - $paths0[] = 'user/' . $user->uid . '/deleteconfirm/*'; |
|
274 | - $paths0[] = 'user/' . $user->uid . '/odeleteconfirm/*'; |
|
272 | + $paths0[] = 'user/' . $user->uid . '/delete'; |
|
273 | + $paths0[] = 'user/' . $user->uid . '/deleteconfirm/*'; |
|
274 | + $paths0[] = 'user/' . $user->uid . '/odeleteconfirm/*'; |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | // Paths added by the admin |
278 | 278 | $paths1 = preg_split('/\r\n|\r|\n/', variable_get('boinc_weboptions_pathstoignore', "moderation\ncontent/moderation\nprivacy")); |
279 | 279 | $paths2 = array(); |
280 | 280 | if (is_array($paths1)) { |
281 | - $paths2 = array_map('strtolower', $paths1); |
|
281 | + $paths2 = array_map('strtolower', $paths1); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | // paths to ignore |
285 | 285 | $paths_to_ignore = array_unique( array_merge($paths0, $paths2) ); |
286 | 286 | |
287 | 287 | if (!_boincuser_ignore_paths($path, $paths_to_ignore)) { |
288 | - drupal_goto('user/termsofuse'); |
|
288 | + drupal_goto('user/termsofuse'); |
|
289 | + } |
|
289 | 290 | } |
290 | - } |
|
291 | 291 | } |
292 | - } |
|
292 | + } |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | /** |
@@ -297,13 +297,13 @@ discard block |
||
297 | 297 | * Drupal user operations |
298 | 298 | */ |
299 | 299 | function boincuser_user($op, &$edit, &$account, $category = NULL) { |
300 | - require_boinc('boinc_db'); |
|
301 | - require_boinc('user'); |
|
302 | - require_boinc('xml'); |
|
300 | + require_boinc('boinc_db'); |
|
301 | + require_boinc('user'); |
|
302 | + require_boinc('xml'); |
|
303 | 303 | |
304 | - require_boinc('password_compat/password'); |
|
305 | - // Handle BOINC integration for users with UID > 1 (skip anonymous and admin) |
|
306 | - if (isset($account->uid) && ($account->uid > 1)) { |
|
304 | + require_boinc('password_compat/password'); |
|
305 | + // Handle BOINC integration for users with UID > 1 (skip anonymous and admin) |
|
306 | + if (isset($account->uid) && ($account->uid > 1)) { |
|
307 | 307 | switch($op) { |
308 | 308 | case 'load': |
309 | 309 | // User loading; insert BOINC data into the user object |
@@ -311,11 +311,11 @@ discard block |
||
311 | 311 | SELECT boinc_id, penalty_expiration |
312 | 312 | FROM {boincuser} WHERE uid = %d", |
313 | 313 | $account->uid |
314 | - )); |
|
315 | - $account->boincuser_id = $drupal_user->boinc_id; |
|
316 | - $account->boincuser_penalty_expiration = $drupal_user->penalty_expiration; |
|
317 | - db_set_active('boinc_rw'); |
|
318 | - $boinc_user = db_fetch_object(db_query(" |
|
314 | + )); |
|
315 | + $account->boincuser_id = $drupal_user->boinc_id; |
|
316 | + $account->boincuser_penalty_expiration = $drupal_user->penalty_expiration; |
|
317 | + db_set_active('boinc_rw'); |
|
318 | + $boinc_user = db_fetch_object(db_query(" |
|
319 | 319 | SELECT |
320 | 320 | name, |
321 | 321 | authenticator, |
@@ -331,29 +331,29 @@ discard block |
||
331 | 331 | FROM {user} |
332 | 332 | WHERE id = %d", |
333 | 333 | $account->boincuser_id |
334 | - )); |
|
335 | - $account->boincuser_name = $boinc_user->name; |
|
336 | - $account->boincuser_account_key = $boinc_user->authenticator; |
|
337 | - $account->boincuser_weak_auth = md5($boinc_user->authenticator . $boinc_user->passwd_hash); |
|
338 | - $account->boincuser_total_credit = round($boinc_user->total_credit); |
|
339 | - $account->boincuser_expavg_credit = round($boinc_user->expavg_credit); |
|
340 | - $account->boincuser_expavg_time = round($boinc_user->expavg_time); |
|
341 | - $account->boincuser_cpid = md5($boinc_user->cross_project_id . $account->mail); |
|
342 | - $account->boincuser_default_pref_set = $boinc_user->venue; |
|
343 | - $account->boincteam_id = $boinc_user->teamid; |
|
344 | - $account->boincuser_previous_email_addr = $boinc_user->previous_email_addr; |
|
345 | - $account->boincuser_email_addr_change_time = $boinc_user->email_addr_change_time; |
|
346 | - db_set_active('default'); |
|
347 | - // Set Drupal team ID |
|
348 | - $account->team = NULL; |
|
349 | - if ($account->boincteam_id) { |
|
334 | + )); |
|
335 | + $account->boincuser_name = $boinc_user->name; |
|
336 | + $account->boincuser_account_key = $boinc_user->authenticator; |
|
337 | + $account->boincuser_weak_auth = md5($boinc_user->authenticator . $boinc_user->passwd_hash); |
|
338 | + $account->boincuser_total_credit = round($boinc_user->total_credit); |
|
339 | + $account->boincuser_expavg_credit = round($boinc_user->expavg_credit); |
|
340 | + $account->boincuser_expavg_time = round($boinc_user->expavg_time); |
|
341 | + $account->boincuser_cpid = md5($boinc_user->cross_project_id . $account->mail); |
|
342 | + $account->boincuser_default_pref_set = $boinc_user->venue; |
|
343 | + $account->boincteam_id = $boinc_user->teamid; |
|
344 | + $account->boincuser_previous_email_addr = $boinc_user->previous_email_addr; |
|
345 | + $account->boincuser_email_addr_change_time = $boinc_user->email_addr_change_time; |
|
346 | + db_set_active('default'); |
|
347 | + // Set Drupal team ID |
|
348 | + $account->team = NULL; |
|
349 | + if ($account->boincteam_id) { |
|
350 | 350 | $account->team = db_result(db_query(" |
351 | 351 | SELECT nid FROM {boincteam} WHERE team_id = %d", |
352 | - $account->boincteam_id |
|
352 | + $account->boincteam_id |
|
353 | 353 | )); |
354 | - } |
|
355 | - // Set post count |
|
356 | - $account->post_count = db_result(db_query(" |
|
354 | + } |
|
355 | + // Set post count |
|
356 | + $account->post_count = db_result(db_query(" |
|
357 | 357 | SELECT COUNT(*) + |
358 | 358 | ( |
359 | 359 | SELECT COUNT(*) FROM {node} |
@@ -366,8 +366,8 @@ discard block |
||
366 | 366 | WHERE comments.uid = '%d' |
367 | 367 | AND node.status = 1", |
368 | 368 | $account->uid, $account->uid |
369 | - )); |
|
370 | - break; |
|
369 | + )); |
|
370 | + break; |
|
371 | 371 | |
372 | 372 | case 'view': |
373 | 373 | // SAMPLE: Add BOINC data to the user profile |
@@ -393,74 +393,74 @@ discard block |
||
393 | 393 | case 'user_account': |
394 | 394 | // Validate data before updating user account info |
395 | 395 | boincuser_account_validate($edit, $account); |
396 | - break; |
|
396 | + break; |
|
397 | 397 | |
398 | 398 | default: |
399 | 399 | |
400 | 400 | } |
401 | 401 | // We don't want to save validation source, so remove it |
402 | 402 | $edit['validation_source'] = null; |
403 | - } |
|
404 | - break; |
|
403 | + } |
|
404 | + break; |
|
405 | 405 | |
406 | 406 | case 'insert': |
407 | 407 | // New user being added to the system |
408 | 408 | $imported = $_SESSION['importedUser']; |
409 | - unset($_SESSION['importedUser']); |
|
409 | + unset($_SESSION['importedUser']); |
|
410 | 410 | |
411 | - watchdog( |
|
411 | + watchdog( |
|
412 | 412 | 'boincuser', |
413 | 413 | 'Creating user account for %email_addr', |
414 | 414 | array('%email_addr' => $edit['mail']), |
415 | 415 | WATCHDOG_NOTICE |
416 | - ); |
|
416 | + ); |
|
417 | 417 | |
418 | - // The create_acount RPC will call this block of code when |
|
419 | - // user_save() is used. If user is registering using the Web |
|
420 | - // registration form, create a BOINC user and relationships. |
|
421 | - // Create a BOINC account unless importing from BOINC. |
|
422 | - if (!$imported) { |
|
418 | + // The create_acount RPC will call this block of code when |
|
419 | + // user_save() is used. If user is registering using the Web |
|
420 | + // registration form, create a BOINC user and relationships. |
|
421 | + // Create a BOINC account unless importing from BOINC. |
|
422 | + if (!$imported) { |
|
423 | 423 | |
424 | 424 | // set email address lower-case |
425 | 425 | $lower_email_addr = strtolower($edit['mail']); |
426 | 426 | |
427 | 427 | if ($edit['boincuser_name']) { |
428 | - $myname = $edit['boincuser_name']; |
|
428 | + $myname = $edit['boincuser_name']; |
|
429 | 429 | } |
430 | 430 | else if ($edit['name']) { |
431 | - $myname = $edit['name']; |
|
431 | + $myname = $edit['name']; |
|
432 | 432 | } |
433 | 433 | else { |
434 | - $myname = 'noname'; |
|
434 | + $myname = 'noname'; |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | $user_params = array( |
438 | - 'email_addr' => $lower_email_addr, |
|
439 | - 'name' => $myname, |
|
438 | + 'email_addr' => $lower_email_addr, |
|
439 | + 'name' => $myname, |
|
440 | 440 | ); |
441 | 441 | |
442 | 442 | // If the 'pass' variable is already a hash, then don't hash it again. |
443 | 443 | if ($edit['boinchash_flag']) { |
444 | - $user_params['passwd_hash'] = $edit['pass']; |
|
444 | + $user_params['passwd_hash'] = $edit['pass']; |
|
445 | 445 | } |
446 | 446 | else { |
447 | - // The passwd_hash here is only the md5() hash. This is |
|
448 | - // because BOINC make_user(), called later, will run |
|
449 | - // password_hash() on this md5 hash. |
|
450 | - $user_params['passwd_hash'] = md5($edit['pass'].$lower_email_addr); |
|
447 | + // The passwd_hash here is only the md5() hash. This is |
|
448 | + // because BOINC make_user(), called later, will run |
|
449 | + // password_hash() on this md5 hash. |
|
450 | + $user_params['passwd_hash'] = md5($edit['pass'].$lower_email_addr); |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | $boinc_user = boincuser_register_make_user($user_params); |
454 | 454 | if (!$boinc_user) { |
455 | - // Account exists with this email addr |
|
456 | - form_set_error('email', bts('Error creating BOINC account.', array(), NULL, 'boinc:add-new-user')); |
|
457 | - return; |
|
455 | + // Account exists with this email addr |
|
456 | + form_set_error('email', bts('Error creating BOINC account.', array(), NULL, 'boinc:add-new-user')); |
|
457 | + return; |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | // Add user to community role by default (not banned) |
461 | 461 | $unrestricted_role = array_search('community member', user_roles(true)); |
462 | 462 | $edit['roles'] = array( |
463 | - $unrestricted_role => '' |
|
463 | + $unrestricted_role => '' |
|
464 | 464 | ); |
465 | 465 | |
466 | 466 | // Disable show_hosts flag, set to TRUE by default |
@@ -471,14 +471,14 @@ discard block |
||
471 | 471 | // Cross reference Drupal account with BOINC |
472 | 472 | $reference = db_query("INSERT INTO {boincuser} SET uid='%d', boinc_id='%d'", $account->uid, $boinc_user->id); |
473 | 473 | if (!$reference) { |
474 | - drupal_set_message(t('Error connecting BOINC account.'), 'error'); |
|
475 | - return; |
|
474 | + drupal_set_message(t('Error connecting BOINC account.'), 'error'); |
|
475 | + return; |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | // if terms of use exist, the user must agree. |
479 | 479 | $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
480 | 480 | if (!empty($termsofuse)) { |
481 | - $reference2 = boincuser_consentto_termsofuse($account); |
|
481 | + $reference2 = boincuser_consentto_termsofuse($account); |
|
482 | 482 | } |
483 | 483 | |
484 | 484 | // Don't save custom fields to the Drupal user object |
@@ -486,10 +486,10 @@ discard block |
||
486 | 486 | $edit['boinchash_flag'] = null; |
487 | 487 | // Set email address to lower case in Drupal users table |
488 | 488 | if ($account) { |
489 | - user_save($account, array('mail' => $lower_email_addr)); |
|
489 | + user_save($account, array('mail' => $lower_email_addr)); |
|
490 | 490 | } |
491 | - } |
|
492 | - break; |
|
491 | + } |
|
492 | + break; |
|
493 | 493 | |
494 | 494 | case 'update': |
495 | 495 | if (isset($edit['update_source'])) { |
@@ -500,8 +500,8 @@ discard block |
||
500 | 500 | // Ensure that BOINC data is altered |
501 | 501 | |
502 | 502 | $changing_email = ($edit['mail'] AND $edit['mail'] != $boinc_user->email_addr) ? true : false; |
503 | - $changing_pass = ($edit['pass']) ? true : false; |
|
504 | - if ($changing_email OR $changing_pass) { |
|
503 | + $changing_pass = ($edit['pass']) ? true : false; |
|
504 | + if ($changing_email OR $changing_pass) { |
|
505 | 505 | // set email address to lower-case |
506 | 506 | $lower_email_addr = strtolower($edit['mail']); |
507 | 507 | |
@@ -510,47 +510,47 @@ discard block |
||
510 | 510 | $passwd_hash = password_hash( md5($passwd.$lower_email_addr), PASSWORD_DEFAULT ); |
511 | 511 | // Algorithm for changing email and/or password |
512 | 512 | if ($changing_email) { |
513 | - // locally store current email to set as previous email |
|
514 | - $prev_email = $account->mail; |
|
515 | - $mytime = (user_access('administer users')) ? $boinc_user->email_addr_change_time : time(); |
|
516 | - $querypart = "email_addr='{$lower_email_addr}', passwd_hash='{$passwd_hash}', previous_email_addr = '{$prev_email}', email_addr_change_time = $mytime"; |
|
513 | + // locally store current email to set as previous email |
|
514 | + $prev_email = $account->mail; |
|
515 | + $mytime = (user_access('administer users')) ? $boinc_user->email_addr_change_time : time(); |
|
516 | + $querypart = "email_addr='{$lower_email_addr}', passwd_hash='{$passwd_hash}', previous_email_addr = '{$prev_email}', email_addr_change_time = $mytime"; |
|
517 | 517 | } |
518 | 518 | else { |
519 | - $querypart = "email_addr='{$lower_email_addr}', passwd_hash='{$passwd_hash}'"; |
|
519 | + $querypart = "email_addr='{$lower_email_addr}', passwd_hash='{$passwd_hash}'"; |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | // Update user account information |
523 | 523 | $result = $boinc_user->update($querypart); |
524 | 524 | |
525 | 525 | if ($changing_email) { |
526 | - // reload account |
|
527 | - $account = user_load($account->uid); |
|
528 | - _boincuser_send_emailchange($account, $lower_email_addr, $prev_email, user_access('administer users')); |
|
526 | + // reload account |
|
527 | + $account = user_load($account->uid); |
|
528 | + _boincuser_send_emailchange($account, $lower_email_addr, $prev_email, user_access('administer users')); |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | // Change email to edit to lower-case version, this sets |
532 | 532 | // email in Drupal database to the lower-case email |
533 | 533 | // address. |
534 | 534 | $edit['mail'] = strtolower($lower_email_addr); |
535 | - } |
|
535 | + } |
|
536 | 536 | |
537 | - // Change boinc username |
|
538 | - if ($edit['boincuser_name'] and ($edit['boincuser_name'] != $boinc_user->name)) { |
|
537 | + // Change boinc username |
|
538 | + if ($edit['boincuser_name'] and ($edit['boincuser_name'] != $boinc_user->name)) { |
|
539 | 539 | $boincuser_name = $edit['boincuser_name']; |
540 | 540 | $result = $boinc_user->update( |
541 | 541 | "name='{$boincuser_name}'" |
542 | 542 | ); |
543 | - } |
|
543 | + } |
|
544 | 544 | |
545 | - break; |
|
545 | + break; |
|
546 | 546 | case 'user_profile': |
547 | 547 | if ($edit['boincuser_name'] != $boinc_user->name) { |
548 | 548 | $boincuser_name = $edit['boincuser_name']; |
549 | 549 | $result = $boinc_user->update( |
550 | 550 | "name='{$boincuser_name}'" |
551 | 551 | ); |
552 | - } |
|
553 | - break; |
|
552 | + } |
|
553 | + break; |
|
554 | 554 | default: |
555 | 555 | } |
556 | 556 | // We don't want to save update source or duplicate custom fields, so |
@@ -558,23 +558,23 @@ discard block |
||
558 | 558 | $edit['update_source'] = null; |
559 | 559 | $edit['boincuser_name'] = null; |
560 | 560 | $edit['current_pass'] = null; |
561 | - } |
|
562 | - break; |
|
561 | + } |
|
562 | + break; |
|
563 | 563 | |
564 | 564 | case 'login': |
565 | 565 | // Function is forward compatible to Drupal 7 |
566 | 566 | boincuser_user_login($edit, $account); |
567 | - break; |
|
567 | + break; |
|
568 | 568 | |
569 | 569 | case 'delete': |
570 | 570 | // Function is forward compatible to Drupal 7 |
571 | 571 | boincuser_user_delete($account); |
572 | - break; |
|
572 | + break; |
|
573 | 573 | |
574 | 574 | default: |
575 | 575 | |
576 | 576 | } |
577 | - } |
|
577 | + } |
|
578 | 578 | } |
579 | 579 | |
580 | 580 | /** |
@@ -583,39 +583,39 @@ discard block |
||
583 | 583 | *(forward compatible to Drupal 7). |
584 | 584 | */ |
585 | 585 | function boincuser_user_login(&$edit, $account) { |
586 | - $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE); |
|
587 | - $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
588 | - |
|
589 | - // Use the same code as boincuser_form_alter(), for case |
|
590 | - // 'user_profile_form', if the refering page is the user password |
|
591 | - // reset form, then do not check for terms of use. |
|
592 | - $reset_pass = (strpos($_SERVER['HTTP_REFERER'], "/user/reset/$account->uid") === FALSE) ? 0 : 1; |
|
593 | - if ($reset_pass) { |
|
586 | + $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE); |
|
587 | + $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
588 | + |
|
589 | + // Use the same code as boincuser_form_alter(), for case |
|
590 | + // 'user_profile_form', if the refering page is the user password |
|
591 | + // reset form, then do not check for terms of use. |
|
592 | + $reset_pass = (strpos($_SERVER['HTTP_REFERER'], "/user/reset/$account->uid") === FALSE) ? 0 : 1; |
|
593 | + if ($reset_pass) { |
|
594 | 594 | return; |
595 | - } |
|
595 | + } |
|
596 | 596 | |
597 | - // Check if user has agreed to terms of use. |
|
598 | - if ( (!empty($termsofuse)) and ($account->uid) and |
|
597 | + // Check if user has agreed to terms of use. |
|
598 | + if ( (!empty($termsofuse)) and ($account->uid) and |
|
599 | 599 | (!boincuser_check_termsofuse($account)) and ($existinguser_tou) ) { |
600 | 600 | |
601 | 601 | // Admins are exempted. |
602 | 602 | $administrator_role = array_search('administrator', user_roles(true)); |
603 | 603 | if (!isset($account->roles[$administrator_role])) { |
604 | 604 | |
605 | - // Find and save the current destination and use as an parameter |
|
606 | - // to send the user back to here he/she came from. |
|
607 | - $np = ltrim('user/termsofuse', '/'); |
|
608 | - $path_for_destination = rawurlencode($np); |
|
605 | + // Find and save the current destination and use as an parameter |
|
606 | + // to send the user back to here he/she came from. |
|
607 | + $np = ltrim('user/termsofuse', '/'); |
|
608 | + $path_for_destination = rawurlencode($np); |
|
609 | 609 | |
610 | - $query_for_destination = ''; |
|
611 | - $prevdest = $_REQUEST['destination']; |
|
612 | - if ($prevdest) { |
|
610 | + $query_for_destination = ''; |
|
611 | + $prevdest = $_REQUEST['destination']; |
|
612 | + if ($prevdest) { |
|
613 | 613 | $query_for_destination = '?destination=' . $prevdest; |
614 | - } |
|
615 | - $_REQUEST['destination'] = $path_for_destination . $query_for_destination; |
|
614 | + } |
|
615 | + $_REQUEST['destination'] = $path_for_destination . $query_for_destination; |
|
616 | 616 | |
617 | 617 | } |
618 | - } |
|
618 | + } |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | /** |
@@ -624,16 +624,16 @@ discard block |
||
624 | 624 | */ |
625 | 625 | function boincuser_user_delete($account) { |
626 | 626 | |
627 | - $boincid = $account->boincuser_id; |
|
628 | - // bug in comment module, remove user name from comments. Find all |
|
629 | - // comments with uid=0 and clear the field 'name'. |
|
630 | - $qrc1 = db_query("UPDATE {comments} SET comments.name='' WHERE comments.uid=0"); |
|
627 | + $boincid = $account->boincuser_id; |
|
628 | + // bug in comment module, remove user name from comments. Find all |
|
629 | + // comments with uid=0 and clear the field 'name'. |
|
630 | + $qrc1 = db_query("UPDATE {comments} SET comments.name='' WHERE comments.uid=0"); |
|
631 | 631 | |
632 | - // Delete entry in drupal boincuser table. |
|
633 | - $qrc2 = db_query("DELETE FROM {boincuser} WHERE uid=%d", $account->uid); |
|
634 | - if (!$qrc2) { |
|
632 | + // Delete entry in drupal boincuser table. |
|
633 | + $qrc2 = db_query("DELETE FROM {boincuser} WHERE uid=%d", $account->uid); |
|
634 | + if (!$qrc2) { |
|
635 | 635 | watchdog('user', 'Error deleting user account, boincuser table UID: %uid.', array('%uid' => $account->uid), WATCHDOG_ERROR); |
636 | - } |
|
636 | + } |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | |
@@ -642,13 +642,13 @@ discard block |
||
642 | 642 | * Obsolete in Drupal 7... |
643 | 643 | */ |
644 | 644 | function boincuser_nodeapi(&$node, $op, $a3 = null, $a4 = null) { |
645 | - // In Drupal 7, these operation cases will all exist as their own hooks, |
|
646 | - // so let's approximate that here so that this function can simply be removed |
|
647 | - // upon migration to 7 |
|
648 | - switch($op) { |
|
649 | - case 'update': |
|
645 | + // In Drupal 7, these operation cases will all exist as their own hooks, |
|
646 | + // so let's approximate that here so that this function can simply be removed |
|
647 | + // upon migration to 7 |
|
648 | + switch($op) { |
|
649 | + case 'update': |
|
650 | 650 | boincuser_node_update($node); |
651 | - } |
|
651 | + } |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | /** |
@@ -656,8 +656,8 @@ discard block |
||
656 | 656 | * is updated (forward compatible to Drupal 7) |
657 | 657 | */ |
658 | 658 | function boincuser_node_update($node) { |
659 | - switch($node->type) { |
|
660 | - case 'profile': |
|
659 | + switch($node->type) { |
|
660 | + case 'profile': |
|
661 | 661 | // Update the BOINC database directly |
662 | 662 | $account = user_load($node->uid); |
663 | 663 | // Save user account data |
@@ -669,11 +669,11 @@ discard block |
||
669 | 669 | UPDATE user |
670 | 670 | SET country = '%s', postal_code = '%s', url = '%s', has_profile = 1 |
671 | 671 | WHERE id = %d", |
672 | - $country, $postal_code, $url, $account->boincuser_id |
|
672 | + $country, $postal_code, $url, $account->boincuser_id |
|
673 | 673 | ); |
674 | 674 | db_set_active('default'); |
675 | 675 | if (!$account_updated) { |
676 | - drupal_set_message(t('Error saving BOINC account info.'), 'error'); |
|
676 | + drupal_set_message(t('Error saving BOINC account info.'), 'error'); |
|
677 | 677 | } |
678 | 678 | // Save profile data |
679 | 679 | $response1 = $node->field_background[0]['value']; |
@@ -684,16 +684,16 @@ discard block |
||
684 | 684 | SET userid = %d, response1 = '%s', response2 = '%s' |
685 | 685 | ON DUPLICATE KEY UPDATE |
686 | 686 | response1 = '%s', response2 = '%s'", |
687 | - $account->boincuser_id, $response1, $response2, |
|
688 | - $response1, $response2 |
|
687 | + $account->boincuser_id, $response1, $response2, |
|
688 | + $response1, $response2 |
|
689 | 689 | ); |
690 | 690 | db_set_active('default'); |
691 | 691 | if (!$profile_updated) { |
692 | - drupal_set_message(t('Error saving BOINC profile.'), 'error'); |
|
692 | + drupal_set_message(t('Error saving BOINC profile.'), 'error'); |
|
693 | 693 | } |
694 | 694 | break; |
695 | 695 | |
696 | - default: |
|
696 | + default: |
|
697 | 697 | |
698 | 698 | } |
699 | 699 | } |
@@ -702,21 +702,21 @@ discard block |
||
702 | 702 | * Implementation of hook_views_api() |
703 | 703 | */ |
704 | 704 | function boincuser_views_api() { |
705 | - return array( |
|
705 | + return array( |
|
706 | 706 | 'api' => 2.0, |
707 | 707 | 'path' => drupal_get_path('module', 'boincuser') |
708 | - ); |
|
708 | + ); |
|
709 | 709 | } |
710 | 710 | |
711 | 711 | /** |
712 | 712 | * Implementation of hook_form_alter() |
713 | 713 | */ |
714 | 714 | function boincuser_form_alter(&$form, $form_state, $form_id) { |
715 | - require_boinc('token'); |
|
715 | + require_boinc('token'); |
|
716 | 716 | |
717 | - global $user; |
|
718 | - switch ($form_id) { |
|
719 | - case 'flag_confirm': |
|
717 | + global $user; |
|
718 | + switch ($form_id) { |
|
719 | + case 'flag_confirm': |
|
720 | 720 | // The URL seems to be the only way to put any kind of context to this |
721 | 721 | // request! |
722 | 722 | $action = arg(2); |
@@ -725,25 +725,25 @@ discard block |
||
725 | 725 | |
726 | 726 | // Wrap action buttons for styling consistency |
727 | 727 | $form['form control tabs prefix'] = array( |
728 | - '#value' => '<ul class="form-control tab-list">', |
|
729 | - '#weight' => 1001, |
|
728 | + '#value' => '<ul class="form-control tab-list">', |
|
729 | + '#weight' => 1001, |
|
730 | 730 | ); |
731 | 731 | |
732 | 732 | switch ($flag_type) { |
733 | 733 | case 'friend': |
734 | 734 | $friend_id = $form['content_id']['#value']; |
735 | - $flag = flag_get_flag('friend'); |
|
736 | - $friend_status = flag_friend_determine_friend_status($flag, $friend_id, $user->uid); |
|
735 | + $flag = flag_get_flag('friend'); |
|
736 | + $friend_status = flag_friend_determine_friend_status($flag, $friend_id, $user->uid); |
|
737 | 737 | |
738 | - // General friend form overrides |
|
739 | - $form['flag_friend_submit']['#prefix'] = '<li class="first tab">'; |
|
740 | - $form['flag_friend_submit']['#value'] = bts('Send request', array(), NULL, 'boinc:friends-page'); |
|
741 | - $form['flag_friend_submit']['#type'] = 'submit'; |
|
742 | - $form['flag_friend_submit']['#suffix'] = '</li>'; |
|
743 | - $form['flag_friend_submit']['#weight'] = 1002; |
|
738 | + // General friend form overrides |
|
739 | + $form['flag_friend_submit']['#prefix'] = '<li class="first tab">'; |
|
740 | + $form['flag_friend_submit']['#value'] = bts('Send request', array(), NULL, 'boinc:friends-page'); |
|
741 | + $form['flag_friend_submit']['#type'] = 'submit'; |
|
742 | + $form['flag_friend_submit']['#suffix'] = '</li>'; |
|
743 | + $form['flag_friend_submit']['#weight'] = 1002; |
|
744 | 744 | |
745 | - switch ($friend_status) { |
|
746 | - case FLAG_FRIEND_BOTH: |
|
745 | + switch ($friend_status) { |
|
746 | + case FLAG_FRIEND_BOTH: |
|
747 | 747 | case FLAG_FRIEND_FLAGGED: |
748 | 748 | unset($form['actions']); |
749 | 749 | $form['flag_friend_submit']['#value'] = bts('Remove friend', array(), NULL, 'boinc:friends-remove'); |
@@ -752,53 +752,53 @@ discard block |
||
752 | 752 | $form['#submit'][] = 'boincuser_fix_unfriend_form_submit'; |
753 | 753 | $form['#submit'][] = $final_handler; |
754 | 754 | break; |
755 | - case FLAG_FRIEND_PENDING: |
|
755 | + case FLAG_FRIEND_PENDING: |
|
756 | 756 | unset($form['actions']); |
757 | 757 | $form['flag_friend_submit']['#value'] = bts('Remove request', array(), NULL, 'boinc:friends-page'); |
758 | 758 | break; |
759 | - case FLAG_FRIEND_APPROVAL: |
|
759 | + case FLAG_FRIEND_APPROVAL: |
|
760 | 760 | if ($action == 'flag') { |
761 | - $form['flag_friend_submit']['#value'] = bts('Approve request', array(), NULL, 'boinc:friends-page'); |
|
761 | + $form['flag_friend_submit']['#value'] = bts('Approve request', array(), NULL, 'boinc:friends-page'); |
|
762 | 762 | } |
763 | 763 | elseif ($action == 'unflag') { |
764 | - unset($form['actions']); |
|
765 | - $form['flag_friend_submit']['#value'] = bts('Deny request', array(), NULL, 'boinc:friends-page'); |
|
764 | + unset($form['actions']); |
|
765 | + $form['flag_friend_submit']['#value'] = bts('Deny request', array(), NULL, 'boinc:friends-page'); |
|
766 | 766 | } |
767 | 767 | break; |
768 | - case FLAG_FRIEND_UNFLAGGED: |
|
768 | + case FLAG_FRIEND_UNFLAGGED: |
|
769 | 769 | default: |
770 | 770 | $user_links[] = array( |
771 | - 'title' => bts('Add as friend', array(), NULL, 'boinc:friends-add'), |
|
772 | - 'href' => "flag/confirm/flag/friend/{$account->uid}" |
|
771 | + 'title' => bts('Add as friend', array(), NULL, 'boinc:friends-add'), |
|
772 | + 'href' => "flag/confirm/flag/friend/{$account->uid}" |
|
773 | 773 | ); |
774 | - } |
|
775 | - break; |
|
774 | + } |
|
775 | + break; |
|
776 | 776 | |
777 | 777 | default: |
778 | 778 | } |
779 | 779 | |
780 | 780 | $form['cancel'] = array( |
781 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $cancel_dest) . '</li>', |
|
782 | - '#weight' => 1004, |
|
781 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $cancel_dest) . '</li>', |
|
782 | + '#weight' => 1004, |
|
783 | 783 | ); |
784 | 784 | $form['form control tabs suffix'] = array( |
785 | - '#value' => '</ul>', |
|
786 | - '#weight' => 1010, |
|
785 | + '#value' => '</ul>', |
|
786 | + '#weight' => 1010, |
|
787 | 787 | ); |
788 | 788 | |
789 | 789 | break; |
790 | 790 | |
791 | - // General node edit form |
|
792 | - case 'news_node_form': |
|
791 | + // General node edit form |
|
792 | + case 'news_node_form': |
|
793 | 793 | $form['separator_bottom'] = array( |
794 | - '#value' => '<div class="separator buttons"></div>', |
|
795 | - '#weight' => 999, |
|
794 | + '#value' => '<div class="separator buttons"></div>', |
|
795 | + '#weight' => 999, |
|
796 | 796 | ); |
797 | 797 | |
798 | 798 | // Wrap action buttons for styling consistency |
799 | 799 | $form['buttons']['form control tabs prefix'] = array( |
800 | - '#value' => '<ul class="form-control tab-list">', |
|
801 | - '#weight' => 1001, |
|
800 | + '#value' => '<ul class="form-control tab-list">', |
|
801 | + '#weight' => 1001, |
|
802 | 802 | ); |
803 | 803 | $form['buttons']['submit']['#prefix'] = '<li class="first tab">'; |
804 | 804 | $form['buttons']['submit']['#value'] = bts('Save changes', array(), NULL, 'boinc:form-save'); |
@@ -811,15 +811,15 @@ discard block |
||
811 | 811 | $form['buttons']['preview_changes']['#suffix'] = '</li>'; |
812 | 812 | $form['buttons']['preview_changes']['#weight'] = 1004; |
813 | 813 | $form['buttons']['cancel'] = array( |
814 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "node/{$form['nid']['#value']}") . '</li>', |
|
815 | - '#weight' => 1005, |
|
814 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "node/{$form['nid']['#value']}") . '</li>', |
|
815 | + '#weight' => 1005, |
|
816 | 816 | ); |
817 | 817 | $form['buttons']['delete']['#prefix'] = '<li class="tab">'; |
818 | 818 | $form['buttons']['delete']['#suffix'] = '</li>'; |
819 | 819 | $form['buttons']['delete']['#weight'] = 1006; |
820 | 820 | $form['buttons']['form control tabs suffix'] = array( |
821 | - '#value' => '</ul>', |
|
822 | - '#weight' => 1010, |
|
821 | + '#value' => '</ul>', |
|
822 | + '#weight' => 1010, |
|
823 | 823 | ); |
824 | 824 | |
825 | 825 | // Preview is ugly, unset until it works |
@@ -827,16 +827,16 @@ discard block |
||
827 | 827 | |
828 | 828 | break; |
829 | 829 | |
830 | - case 'node_delete_confirm': |
|
830 | + case 'node_delete_confirm': |
|
831 | 831 | $form['separator_bottom'] = array( |
832 | - '#value' => '<div class="separator buttons"></div>', |
|
833 | - '#weight' => 999, |
|
832 | + '#value' => '<div class="separator buttons"></div>', |
|
833 | + '#weight' => 999, |
|
834 | 834 | ); |
835 | 835 | |
836 | 836 | // Wrap action buttons for styling consistency |
837 | 837 | $form['actions']['form control tabs prefix'] = array( |
838 | - '#value' => '<ul class="form-control tab-list">', |
|
839 | - '#weight' => 1001, |
|
838 | + '#value' => '<ul class="form-control tab-list">', |
|
839 | + '#weight' => 1001, |
|
840 | 840 | ); |
841 | 841 | $form['actions']['submit']['#prefix'] = '<li class="first tab">'; |
842 | 842 | $form['actions']['submit']['#value'] = bts('Delete', array(), NULL, 'boinc:form-delete'); |
@@ -844,23 +844,23 @@ discard block |
||
844 | 844 | $form['actions']['submit']['#weight'] = 1002; |
845 | 845 | $form['actions']['cancel'] = array( |
846 | 846 | '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "node/{$form['nid']['#value']}") . '</li>', |
847 | - '#weight' => 1005, |
|
847 | + '#weight' => 1005, |
|
848 | 848 | ); |
849 | 849 | $form['actions']['form control tabs suffix'] = array( |
850 | - '#value' => '</ul>', |
|
851 | - '#weight' => 1010, |
|
850 | + '#value' => '</ul>', |
|
851 | + '#weight' => 1010, |
|
852 | 852 | ); |
853 | 853 | $form['#redirect'] = 'account/profile'; |
854 | 854 | break; |
855 | 855 | |
856 | - case 'privatemsg_new': |
|
856 | + case 'privatemsg_new': |
|
857 | 857 | |
858 | 858 | $form['privatemsg']['body']['#title'] = ''; |
859 | 859 | |
860 | 860 | // Wrap action buttons for styling consistency |
861 | 861 | $form['privatemsg']['form control tabs prefix'] = array( |
862 | - '#value' => '<ul class="form-control tab-list">', |
|
863 | - '#weight' => 1001, |
|
862 | + '#value' => '<ul class="form-control tab-list">', |
|
863 | + '#weight' => 1001, |
|
864 | 864 | ); |
865 | 865 | $form['privatemsg']['submit']['#prefix'] = '<li class="first tab">'; |
866 | 866 | $form['privatemsg']['submit']['#value'] = bts('Send message', array(), NULL, 'boinc:private-message'); |
@@ -870,26 +870,26 @@ discard block |
||
870 | 870 | $form['privatemsg']['preview']['#suffix'] = '</li>'; |
871 | 871 | $form['privatemsg']['preview']['#weight'] = 1003; |
872 | 872 | $form['privatemsg']['cancel'] = array( |
873 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
874 | - '#weight' => 1004, |
|
873 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
874 | + '#weight' => 1004, |
|
875 | 875 | ); |
876 | 876 | $form['privatemsg']['form control tabs suffix'] = array( |
877 | - '#value' => '</ul>', |
|
878 | - '#weight' => 1010, |
|
877 | + '#value' => '</ul>', |
|
878 | + '#weight' => 1010, |
|
879 | 879 | ); |
880 | 880 | |
881 | 881 | unset($form['privatemsg']['recipient_display']); |
882 | 882 | |
883 | 883 | break; |
884 | 884 | |
885 | - // Login form |
|
886 | - case 'user_login': |
|
885 | + // Login form |
|
886 | + case 'user_login': |
|
887 | 887 | case 'user_login_block': |
888 | 888 | drupal_set_title(bts('Login', array(), NULL, 'boinc:menu-link')); |
889 | 889 | // Replace name with email in login form |
890 | 890 | unset($form['name']); |
891 | 891 | array_unshift($form, array( |
892 | - 'email' => array( |
|
892 | + 'email' => array( |
|
893 | 893 | '#type' => 'textfield', |
894 | 894 | '#title' => bts('Email address', array(), NULL, 'boinc:email-address-to-login'), |
895 | 895 | '#size' => ($form_id == 'user_login_block') ? 15 : 60, |
@@ -897,18 +897,18 @@ discard block |
||
897 | 897 | '#required' => TRUE, |
898 | 898 | '#attributes' => array('tabindex' => '1'), |
899 | 899 | '#description' => bts('Enter your @s email address.', array('@s' => variable_get('site_name', 'Drupal-BOINC')), NULL, 'boinc:standard-login-page') |
900 | - ), |
|
901 | - 'validation_source' => array( |
|
900 | + ), |
|
901 | + 'validation_source' => array( |
|
902 | 902 | '#type' => 'hidden', |
903 | 903 | '#value' => 'user_login' |
904 | - ) |
|
904 | + ) |
|
905 | 905 | )); |
906 | 906 | $form['#redirect'] = 'home'; |
907 | 907 | |
908 | 908 | // Wrap action buttons for styling consistency |
909 | 909 | $form['buttons']['form control tabs prefix'] = array( |
910 | - '#value' => '<ul class="form-control tab-list">', |
|
911 | - '#weight' => 1001, |
|
910 | + '#value' => '<ul class="form-control tab-list">', |
|
911 | + '#weight' => 1001, |
|
912 | 912 | ); |
913 | 913 | $form['buttons']['submit'] = $form['submit']; |
914 | 914 | $form['buttons']['submit']['#prefix'] = '<li class="first tab">'; |
@@ -916,8 +916,8 @@ discard block |
||
916 | 916 | $form['buttons']['submit']['#suffix'] = '</li>'; |
917 | 917 | $form['buttons']['submit']['#weight'] = 1002; |
918 | 918 | $form['buttons']['form control tabs suffix'] = array( |
919 | - '#value' => '</ul>', |
|
920 | - '#weight' => 1010, |
|
919 | + '#value' => '</ul>', |
|
920 | + '#weight' => 1010, |
|
921 | 921 | ); |
922 | 922 | unset($form['submit']); |
923 | 923 | |
@@ -926,23 +926,23 @@ discard block |
||
926 | 926 | isset($form['buttons']['submit']['#attributes']) ? array_push($form['buttons']['submit']['#attributes'], array('tabindex' => '3')) : $form['buttons']['submit']['#attributes'] = array('tabindex' => '3'); |
927 | 927 | // If the user login form is being submitted, use BOINC validation handler. |
928 | 928 | if (isset($form_state['post']['email']) and isset($form_state['post']['pass'])) { |
929 | - // Find the local validation function's entry so we can replace it. |
|
930 | - $array_key = array_search('user_login_authenticate_validate', $form['#validate']); |
|
931 | - if ($array_key === FALSE) { |
|
929 | + // Find the local validation function's entry so we can replace it. |
|
930 | + $array_key = array_search('user_login_authenticate_validate', $form['#validate']); |
|
931 | + if ($array_key === FALSE) { |
|
932 | 932 | // Could not find it. Some other module must have run form_alter(). |
933 | 933 | // We will simply add our validation just before the final validator. |
934 | 934 | $final_validator = array_pop($form['#validate']); |
935 | 935 | $form['#validate'][] = 'boincuser_login_validate'; |
936 | 936 | $form['#validate'][] = $final_validator; |
937 | - } else { |
|
937 | + } else { |
|
938 | 938 | // Replace the local validation function with BOINC validation |
939 | 939 | $form['#validate'][$array_key] = 'boincuser_login_validate'; |
940 | - } |
|
940 | + } |
|
941 | 941 | } |
942 | 942 | break; |
943 | 943 | |
944 | - // User credentials form |
|
945 | - case 'user_profile_form': |
|
944 | + // User credentials form |
|
945 | + case 'user_profile_form': |
|
946 | 946 | |
947 | 947 | // Use the displaly name as the title, not the username |
948 | 948 | $account = user_load($form['#uid']); |
@@ -950,28 +950,28 @@ discard block |
||
950 | 950 | |
951 | 951 | // Message for admins |
952 | 952 | if (user_access('administer users')) { |
953 | - drupal_set_message( |
|
953 | + drupal_set_message( |
|
954 | 954 | bts('WARNING: You are editing the information for user. Please note: you may change a user\'s password by itself. But to change the user\'s email address you must change both the email address and the password simultaneously.') |
955 | - , 'warning'); |
|
955 | + , 'warning'); |
|
956 | 956 | } |
957 | 957 | |
958 | 958 | // Set special message if user has not agreed to TOU |
959 | 959 | $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE); |
960 | 960 | $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
961 | 961 | if ( (!boincuser_check_termsofuse($account)) and ($existinguser_tou) and (!empty($termsofuse)) and (!user_access('administer users')) ) { |
962 | - drupal_set_message( |
|
962 | + drupal_set_message( |
|
963 | 963 | bts('INFO: You have not agreed to the terms of use for @project. You may use this form to change your email address and/or password. Please note: you may not delete your account within seven (7) days of changing your email address.', |
964 | 964 | array( |
965 | - '@project' => variable_get('site_name','Drupal-BOINC'), |
|
965 | + '@project' => variable_get('site_name','Drupal-BOINC'), |
|
966 | 966 | ), NULL, 'boinc:account-credentials-change') |
967 | - , 'info'); |
|
967 | + , 'info'); |
|
968 | 968 | } |
969 | 969 | |
970 | 970 | // A bit hackish... but don't require the user to enter his password if |
971 | 971 | // coming from the password reset function |
972 | 972 | $reset_pass = (strpos($_SERVER['HTTP_REFERER'], "/user/reset/{$form['#uid']}") === FALSE) ? 0 : 1; |
973 | 973 | if ($reset_pass) { |
974 | - $_SESSION['reset_pass'] = 1; |
|
974 | + $_SESSION['reset_pass'] = 1; |
|
975 | 975 | } |
976 | 976 | |
977 | 977 | // Adjust form elements already present |
@@ -983,8 +983,8 @@ discard block |
||
983 | 983 | $form['account']['pass']['#size'] = 17; |
984 | 984 | |
985 | 985 | if (user_access('administer users')) { |
986 | - // Add BOINC username (aka displayname) |
|
987 | - $form['account']['boincuser_name'] = array( |
|
986 | + // Add BOINC username (aka displayname) |
|
987 | + $form['account']['boincuser_name'] = array( |
|
988 | 988 | '#type' => 'textfield', |
989 | 989 | '#title' => bts('BOINC Username', array(), NULL, 'boinc:user-or-team-name'), |
990 | 990 | '#default_value' => $account->boincuser_name, |
@@ -992,68 +992,68 @@ discard block |
||
992 | 992 | '#required' => TRUE, |
993 | 993 | '#description' => bts('This is the BOINC (external) username. This is the same setting as found in Account -> Preferences -> Community.', array(), NULL, 'boinc:username-change'), |
994 | 994 | '#size' => 40, |
995 | - ); |
|
995 | + ); |
|
996 | 996 | } |
997 | 997 | |
998 | 998 | // If email address was changed less than 7 days (7 * 86400 s) |
999 | 999 | // ago, it cannot be changed again. |
1000 | 1000 | $duration = TOKEN_DURATION_ONE_WEEK; |
1001 | 1001 | if (($account->boincuser_email_addr_change_time + $duration) > time() and (!user_access('administer users'))) { |
1002 | - $form['account']['mail']['#required'] = FALSE; |
|
1003 | - $form['account']['mailhelp'] = array( |
|
1002 | + $form['account']['mail']['#required'] = FALSE; |
|
1003 | + $form['account']['mailhelp'] = array( |
|
1004 | 1004 | '#value' => bts("You email address was changed within the past seven (7) days. Please look for an email to !prev_email if you need to revert this change. You may change your email address on !time.", |
1005 | - array( |
|
1005 | + array( |
|
1006 | 1006 | '!prev_email' => $account->boincuser_previous_email_addr, |
1007 | 1007 | '!time' => date('F j, Y \a\t G:i T', $account->boincuser_email_addr_change_time + $duration), |
1008 | - ), NULL, 'boinc:account-credentials-change'), |
|
1009 | - ); |
|
1008 | + ), NULL, 'boinc:account-credentials-change'), |
|
1009 | + ); |
|
1010 | 1010 | } |
1011 | 1011 | |
1012 | 1012 | if (!$reset_pass AND ($user->uid == $account->uid OR !user_access('administer users'))) { |
1013 | - // Add a password authenticator, required to change email or pw |
|
1014 | - $form['account']['current_pass'] = array( |
|
1013 | + // Add a password authenticator, required to change email or pw |
|
1014 | + $form['account']['current_pass'] = array( |
|
1015 | 1015 | '#type' => 'password', |
1016 | 1016 | '#title' => bts('Enter your password to save changes', array(), NULL, 'boinc:account-credentials-change'), |
1017 | 1017 | '#description' => bts('Enter your current password if changing your email |
1018 | 1018 | address or password.', array(), NULL, 'boinc:account-credentials-change'), |
1019 | 1019 | '#size' => 17, |
1020 | 1020 | '#attributes' => array( |
1021 | - 'autocomplete' => 'off', |
|
1021 | + 'autocomplete' => 'off', |
|
1022 | 1022 | ), |
1023 | - ); |
|
1023 | + ); |
|
1024 | 1024 | } |
1025 | 1025 | |
1026 | 1026 | // Add account keys, CPID, etc |
1027 | 1027 | $form['account']['boincuser_id'] = array( |
1028 | - '#value' => ' |
|
1028 | + '#value' => ' |
|
1029 | 1029 | <div class="form-item"> |
1030 | 1030 | <label>' . bts('BOINC user ID', array(), NULL, 'boinc:account-credentials-change') . '</label> |
1031 | 1031 | <span>' . $account->boincuser_id . '</span> |
1032 | 1032 | </div>', |
1033 | 1033 | ); |
1034 | 1034 | $form['account']['user_id'] = array( |
1035 | - '#value' => ' |
|
1035 | + '#value' => ' |
|
1036 | 1036 | <div class="form-item"> |
1037 | 1037 | <label>' . bts('Drupal user ID', array(), NULL, 'boinc:account-credentials-change') . '</label> |
1038 | 1038 | <span>' . $account->uid . '</span> |
1039 | 1039 | </div>', |
1040 | 1040 | ); |
1041 | 1041 | $form['account']['account_key'] = array( |
1042 | - '#value' => ' |
|
1042 | + '#value' => ' |
|
1043 | 1043 | <div class="form-item"> |
1044 | 1044 | <label>' . bts('Account key', array(), NULL, 'boinc:account-credentials-change') . '</label> |
1045 | 1045 | <span>' . $account->boincuser_account_key . '</span> |
1046 | 1046 | </div>', |
1047 | 1047 | ); |
1048 | 1048 | $form['account']['weak_account_key'] = array( |
1049 | - '#value' => ' |
|
1049 | + '#value' => ' |
|
1050 | 1050 | <div class="form-item"> |
1051 | 1051 | <label>' . bts('Weak account key', array(), NULL, 'boinc:account-credentials-change') . '</label> |
1052 | 1052 | <span>' . "{$account->boincuser_id}_{$account->boincuser_weak_auth}" . '</span> |
1053 | 1053 | </div>', |
1054 | 1054 | ); |
1055 | 1055 | $form['account']['cpid'] = array( |
1056 | - '#value' => ' |
|
1056 | + '#value' => ' |
|
1057 | 1057 | <div class="form-item"> |
1058 | 1058 | <label>' . bts('Cross-project ID', array(), NULL, 'boinc:account-credentials-change') . '</label> |
1059 | 1059 | <span>' . $account->boincuser_cpid . '</span> |
@@ -1061,30 +1061,30 @@ discard block |
||
1061 | 1061 | ); |
1062 | 1062 | |
1063 | 1063 | $form['account']['separator_bottom'] = array( |
1064 | - '#value' => '<div class="separator buttons"></div>' |
|
1064 | + '#value' => '<div class="separator buttons"></div>' |
|
1065 | 1065 | ); |
1066 | 1066 | |
1067 | 1067 | // Wrap action buttons for styling consistency |
1068 | 1068 | $form['form control tabs prefix'] = array( |
1069 | - '#value' => '<ul class="form-control tab-list">', |
|
1070 | - '#weight' => 1001, |
|
1069 | + '#value' => '<ul class="form-control tab-list">', |
|
1070 | + '#weight' => 1001, |
|
1071 | 1071 | ); |
1072 | 1072 | $form['submit']['#prefix'] = '<li class="first tab">'; |
1073 | 1073 | $form['submit']['#value'] = bts('Save changes', array(), NULL, 'boinc:form-save'); |
1074 | 1074 | $form['submit']['#suffix'] = '</li>'; |
1075 | 1075 | $form['submit']['#weight'] = 1002; |
1076 | 1076 | $form['cancel'] = array( |
1077 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
1078 | - '#weight' => 1003, |
|
1077 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
1078 | + '#weight' => 1003, |
|
1079 | 1079 | ); |
1080 | 1080 | if (isset($form['delete']) AND is_array($form['delete'])) { |
1081 | - $form['delete']['#prefix'] = '<li class="first alt tab">'; |
|
1082 | - $form['delete']['#suffix'] = '</li>'; |
|
1083 | - $form['delete']['#weight'] = 1004; |
|
1081 | + $form['delete']['#prefix'] = '<li class="first alt tab">'; |
|
1082 | + $form['delete']['#suffix'] = '</li>'; |
|
1083 | + $form['delete']['#weight'] = 1004; |
|
1084 | 1084 | } |
1085 | 1085 | $form['form control tabs suffix'] = array( |
1086 | - '#value' => '</ul>', |
|
1087 | - '#weight' => 1010, |
|
1086 | + '#value' => '</ul>', |
|
1087 | + '#weight' => 1010, |
|
1088 | 1088 | ); |
1089 | 1089 | |
1090 | 1090 | // Rearrange form elements |
@@ -1104,7 +1104,7 @@ discard block |
||
1104 | 1104 | // Remove redundant / unnecessary form elements |
1105 | 1105 | unset($form['theme_select']); |
1106 | 1106 | if (!module_exists('boincuser_delete')) { |
1107 | - unset($form['delete']); |
|
1107 | + unset($form['delete']); |
|
1108 | 1108 | } |
1109 | 1109 | |
1110 | 1110 | // These are on the Community preferences form (boincwork module) |
@@ -1120,18 +1120,18 @@ discard block |
||
1120 | 1120 | |
1121 | 1121 | // Internal fields to indicate where these user changes are taking place |
1122 | 1122 | array_unshift($form, array( |
1123 | - 'validation_source' => array( |
|
1123 | + 'validation_source' => array( |
|
1124 | 1124 | '#type' => 'hidden', |
1125 | 1125 | '#value' => 'user_account' |
1126 | - ), |
|
1127 | - 'update_source' => array( |
|
1126 | + ), |
|
1127 | + 'update_source' => array( |
|
1128 | 1128 | '#type' => 'hidden', |
1129 | 1129 | '#value' => 'user_account' |
1130 | - ) |
|
1130 | + ) |
|
1131 | 1131 | )); |
1132 | 1132 | break; |
1133 | 1133 | |
1134 | - case 'profile_node_form': |
|
1134 | + case 'profile_node_form': |
|
1135 | 1135 | |
1136 | 1136 | // Use the display name as the title, not the username |
1137 | 1137 | $account = user_load($form['uid']['#value']); |
@@ -1142,22 +1142,22 @@ discard block |
||
1142 | 1142 | $form['title']['#access'] = FALSE; |
1143 | 1143 | |
1144 | 1144 | $form['separator_bottom'] = array( |
1145 | - '#value' => '<div class="separator buttons"></div>', |
|
1146 | - '#weight' => 999, |
|
1145 | + '#value' => '<div class="separator buttons"></div>', |
|
1146 | + '#weight' => 999, |
|
1147 | 1147 | ); |
1148 | 1148 | |
1149 | 1149 | if (module_exists('captcha')) { |
1150 | - // Add an optional captcha |
|
1151 | - $form['profile_captcha'] = array( |
|
1150 | + // Add an optional captcha |
|
1151 | + $form['profile_captcha'] = array( |
|
1152 | 1152 | '#type' => 'captcha', |
1153 | 1153 | '#weight' => 1000, |
1154 | - ); |
|
1154 | + ); |
|
1155 | 1155 | } |
1156 | 1156 | |
1157 | 1157 | // Wrap action buttons for styling consistency |
1158 | 1158 | $form['buttons']['form control tabs prefix'] = array( |
1159 | - '#value' => '<ul class="form-control tab-list">', |
|
1160 | - '#weight' => 1001, |
|
1159 | + '#value' => '<ul class="form-control tab-list">', |
|
1160 | + '#weight' => 1001, |
|
1161 | 1161 | ); |
1162 | 1162 | $form['buttons']['submit']['#prefix'] = '<li class="first tab">'; |
1163 | 1163 | $form['buttons']['submit']['#value'] = bts('Save changes', array(), NULL, 'boinc:form-save'); |
@@ -1170,8 +1170,8 @@ discard block |
||
1170 | 1170 | $form['buttons']['preview_changes']['#suffix'] = '</li>'; |
1171 | 1171 | $form['buttons']['preview_changes']['#weight'] = 1004; |
1172 | 1172 | $form['buttons']['cancel'] = array( |
1173 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
1174 | - '#weight' => 1005, |
|
1173 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
1174 | + '#weight' => 1005, |
|
1175 | 1175 | ); |
1176 | 1176 | $form['buttons']['delete']['#prefix'] = '<li class="tab">'; |
1177 | 1177 | $form['buttons']['delete']['#suffix'] = '</li>'; |
@@ -1179,8 +1179,8 @@ discard block |
||
1179 | 1179 | $form['buttons']['delete']['#weight'] = 1006; |
1180 | 1180 | $form['buttons']['delete']['#submit'] = array('_boincuser_node_profile_delete_submit'); |
1181 | 1181 | $form['buttons']['form control tabs suffix'] = array( |
1182 | - '#value' => '</ul>', |
|
1183 | - '#weight' => 1010, |
|
1182 | + '#value' => '</ul>', |
|
1183 | + '#weight' => 1010, |
|
1184 | 1184 | ); |
1185 | 1185 | |
1186 | 1186 | $form['#after_build'][] = 'boincuser_profile_node_form_after_build'; |
@@ -1193,33 +1193,33 @@ discard block |
||
1193 | 1193 | |
1194 | 1194 | // Internal fields to indicate where these user changes are taking place |
1195 | 1195 | array_unshift($form, array( |
1196 | - 'validation_source' => array( |
|
1196 | + 'validation_source' => array( |
|
1197 | 1197 | '#type' => 'hidden', |
1198 | 1198 | '#value' => 'user_profile' |
1199 | - ), |
|
1200 | - 'update_source' => array( |
|
1199 | + ), |
|
1200 | + 'update_source' => array( |
|
1201 | 1201 | '#type' => 'hidden', |
1202 | 1202 | '#value' => 'user_profile' |
1203 | - ) |
|
1203 | + ) |
|
1204 | 1204 | )); |
1205 | 1205 | break; |
1206 | 1206 | |
1207 | - // Registration form |
|
1208 | - case 'user_register': |
|
1207 | + // Registration form |
|
1208 | + case 'user_register': |
|
1209 | 1209 | array_unshift($form, array( |
1210 | - 'boincuser_name' => array( |
|
1210 | + 'boincuser_name' => array( |
|
1211 | 1211 | '#type' => 'textfield', |
1212 | 1212 | '#title' => bts('Name', array(), NULL, 'boinc:user-or-team-name'), |
1213 | 1213 | '#default_value' => $edit['boincuser_name'], |
1214 | 1214 | '#maxlength' => USERNAME_MAX_LENGTH, |
1215 | 1215 | '#description' => bts('Spaces are allowed; punctuation is not allowed except for periods, hyphens, and underscores.', array(), NULL, 'boinc:user-register'), |
1216 | 1216 | '#required' => TRUE |
1217 | - ), |
|
1217 | + ), |
|
1218 | 1218 | )); |
1219 | 1219 | // Set name temporarily to dummy value to beat validation |
1220 | 1220 | $form['name'] = array( |
1221 | - '#type' => 'hidden', |
|
1222 | - '#value' => rand() . '.' . time() |
|
1221 | + '#type' => 'hidden', |
|
1222 | + '#value' => rand() . '.' . time() |
|
1223 | 1223 | ); |
1224 | 1224 | |
1225 | 1225 | // Add JS for submit button disabling |
@@ -1229,50 +1229,50 @@ discard block |
||
1229 | 1229 | $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
1230 | 1230 | if (!empty($termsofuse)) { |
1231 | 1231 | |
1232 | - $form['termsofuse'] = array( |
|
1232 | + $form['termsofuse'] = array( |
|
1233 | 1233 | '#type' => 'fieldset', |
1234 | 1234 | '#prefix' => '<div id="termsofuse-wrapper">', // This is our wrapper div. |
1235 | 1235 | '#suffix' => '</div>', |
1236 | 1236 | '#tree' => TRUE, |
1237 | 1237 | '#weight' => -15, |
1238 | - ); |
|
1238 | + ); |
|
1239 | 1239 | |
1240 | - $form['termsofuse']['title1'] = array( |
|
1240 | + $form['termsofuse']['title1'] = array( |
|
1241 | 1241 | '#weight' => -12, |
1242 | 1242 | '#value' => '<h2>' . bts(variable_get('boinc_weboptions_registrationtitle', 'Please read and acknowledge our terms of use'), array(), NULL, 'project:user-register' ) . '</h2>', |
1243 | 1243 | '#prefix' => '<div id="register-title1">', |
1244 | 1244 | '#suffix' => '</div>', |
1245 | - ); |
|
1245 | + ); |
|
1246 | 1246 | |
1247 | - $form['termsofuse']['body'] = array( |
|
1247 | + $form['termsofuse']['body'] = array( |
|
1248 | 1248 | '#weight' => -10, |
1249 | 1249 | '#value' => bts($termsofuse, array(), NULL, 'project:user-register'), |
1250 | 1250 | '#prefix' => '<div id="register-termsofuse">', |
1251 | 1251 | '#suffix' => '</div>', |
1252 | - ); |
|
1252 | + ); |
|
1253 | 1253 | |
1254 | - $form['termsofuse']['agreeTOU'] = array( |
|
1254 | + $form['termsofuse']['agreeTOU'] = array( |
|
1255 | 1255 | '#type' => 'checkbox', |
1256 | 1256 | '#title' => bts(variable_get('boinc_weboptions_agreequestion', 'Do you agree with the above terms of use?'), array(), NULL, 'project:user-register'), |
1257 | 1257 | '#weight' => -8, |
1258 | 1258 | '#prefix' => '<div id="register-checkbox">', |
1259 | 1259 | '#suffix' => '</div>', |
1260 | - ); |
|
1260 | + ); |
|
1261 | 1261 | } |
1262 | 1262 | |
1263 | 1263 | $form['title2'] = array( |
1264 | - '#weight' => -6, |
|
1265 | - '#value' => '<h2>' . bts(variable_get('boinc_weboptions_registrationtitle2', 'Fill in your name, email, and choose a secure passphrase.'), array(), NULL, 'project:user-register') . '</h2>', |
|
1266 | - '#prefix' => '<div id="register-title2">', |
|
1267 | - '#suffix' => '</div>', |
|
1264 | + '#weight' => -6, |
|
1265 | + '#value' => '<h2>' . bts(variable_get('boinc_weboptions_registrationtitle2', 'Fill in your name, email, and choose a secure passphrase.'), array(), NULL, 'project:user-register') . '</h2>', |
|
1266 | + '#prefix' => '<div id="register-title2">', |
|
1267 | + '#suffix' => '</div>', |
|
1268 | 1268 | ); |
1269 | 1269 | |
1270 | 1270 | if (module_exists('captcha')) { |
1271 | - // Add an optional captcha |
|
1272 | - $form['register_captcha'] = array( |
|
1271 | + // Add an optional captcha |
|
1272 | + $form['register_captcha'] = array( |
|
1273 | 1273 | '#type' => 'captcha', |
1274 | 1274 | '#weight' => 1000, |
1275 | - ); |
|
1275 | + ); |
|
1276 | 1276 | } |
1277 | 1277 | |
1278 | 1278 | $form['#validate'][] = 'boincuser_register_validate'; |
@@ -1280,45 +1280,45 @@ discard block |
||
1280 | 1280 | $form['submit']['#weight'] = 1001; |
1281 | 1281 | break; |
1282 | 1282 | |
1283 | - // Request new password form |
|
1284 | - case 'user_pass': |
|
1283 | + // Request new password form |
|
1284 | + case 'user_pass': |
|
1285 | 1285 | drupal_set_title(bts('Forgot password', array(), NULL, 'boinc:forgot-password')); |
1286 | 1286 | // Replace name/email text box with email only; retain "name" label |
1287 | 1287 | // for compatibility with standard Drupal submit function |
1288 | 1288 | unset($form['name']); |
1289 | 1289 | array_unshift($form, array( |
1290 | - 'name' => array( |
|
1290 | + 'name' => array( |
|
1291 | 1291 | '#type' => 'textfield', |
1292 | 1292 | '#title' => bts('Email address', array(), NULL, 'boinc:email-address-to-login'), |
1293 | 1293 | '#size' => 60, |
1294 | 1294 | '#maxlength' => EMAIL_MAX_LENGTH, |
1295 | 1295 | '#required' => TRUE, |
1296 | 1296 | '#description' => bts( |
1297 | - 'Enter your email address to receive instructions for resetting your password (or use the !authenticator_login).', |
|
1298 | - array( |
|
1297 | + 'Enter your email address to receive instructions for resetting your password (or use the !authenticator_login).', |
|
1298 | + array( |
|
1299 | 1299 | '!authenticator_login' => l( |
1300 | - bts('authenticator-based login', array(), NULL, 'boinc:forgot-password'), |
|
1301 | - 'user/login/auth' |
|
1300 | + bts('authenticator-based login', array(), NULL, 'boinc:forgot-password'), |
|
1301 | + 'user/login/auth' |
|
1302 | + ) |
|
1302 | 1303 | ) |
1303 | - ) |
|
1304 | 1304 | , NULL, 'boinc:forgot-password'), |
1305 | - ), |
|
1305 | + ), |
|
1306 | 1306 | )); |
1307 | 1307 | |
1308 | 1308 | if (module_exists('captcha')) { |
1309 | - // Add an optional captcha |
|
1310 | - $form['register_captcha'] = array( |
|
1309 | + // Add an optional captcha |
|
1310 | + $form['register_captcha'] = array( |
|
1311 | 1311 | '#type' => 'captcha', |
1312 | 1312 | '#weight' => 0, |
1313 | 1313 | '#prefix' => '<div id="captcha-password-reset">', |
1314 | 1314 | '#suffix' => '</div>' |
1315 | - ); |
|
1315 | + ); |
|
1316 | 1316 | } |
1317 | 1317 | |
1318 | 1318 | // Wrap action buttons for styling consistency |
1319 | 1319 | $form['buttons']['form control tabs prefix'] = array( |
1320 | - '#value' => '<ul class="form-control tab-list">', |
|
1321 | - '#weight' => 1001, |
|
1320 | + '#value' => '<ul class="form-control tab-list">', |
|
1321 | + '#weight' => 1001, |
|
1322 | 1322 | ); |
1323 | 1323 | $form['buttons']['submit'] = $form['submit']; |
1324 | 1324 | $form['buttons']['submit']['#prefix'] = '<li class="first tab">'; |
@@ -1326,26 +1326,26 @@ discard block |
||
1326 | 1326 | $form['buttons']['submit']['#suffix'] = '</li>'; |
1327 | 1327 | $form['buttons']['submit']['#weight'] = 1002; |
1328 | 1328 | $form['buttons']['cancel'] = array( |
1329 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'user/login') . '</li>', |
|
1330 | - '#weight' => 1005, |
|
1329 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'user/login') . '</li>', |
|
1330 | + '#weight' => 1005, |
|
1331 | 1331 | ); |
1332 | 1332 | $form['buttons']['form control tabs suffix'] = array( |
1333 | - '#value' => '</ul>', |
|
1334 | - '#weight' => 1010, |
|
1333 | + '#value' => '</ul>', |
|
1334 | + '#weight' => 1010, |
|
1335 | 1335 | ); |
1336 | 1336 | unset($form['submit']); |
1337 | 1337 | |
1338 | 1338 | // If the form is being submitted, use BOINC validation handler. |
1339 | 1339 | if (isset($form_state['post']['name'])) { |
1340 | - // Prepend the BOINC validation function to local validation |
|
1341 | - array_unshift($form['#validate'], 'boincuser_request_pass_validate'); |
|
1340 | + // Prepend the BOINC validation function to local validation |
|
1341 | + array_unshift($form['#validate'], 'boincuser_request_pass_validate'); |
|
1342 | 1342 | } |
1343 | 1343 | break; |
1344 | 1344 | |
1345 | - case 'views_exposed_form': |
|
1345 | + case 'views_exposed_form': |
|
1346 | 1346 | $form['submit']['#value'] = bts('Search', array(), NULL, 'boinc:search-user'); |
1347 | 1347 | break; |
1348 | - } |
|
1348 | + } |
|
1349 | 1349 | } |
1350 | 1350 | |
1351 | 1351 | /** |
@@ -1353,10 +1353,10 @@ discard block |
||
1353 | 1353 | * built; this is called from boincuser_form_alter() |
1354 | 1354 | */ |
1355 | 1355 | function boincuser_profile_node_form_after_build($form, &$form_state) { |
1356 | - // Move to community prefs form |
|
1357 | - $form_state['storage']['avatar'] = $form['field_image']; |
|
1358 | - unset($form['field_image']); |
|
1359 | - return $form; |
|
1356 | + // Move to community prefs form |
|
1357 | + $form_state['storage']['avatar'] = $form['field_image']; |
|
1358 | + unset($form['field_image']); |
|
1359 | + return $form; |
|
1360 | 1360 | } |
1361 | 1361 | |
1362 | 1362 | /** |
@@ -1364,8 +1364,8 @@ discard block |
||
1364 | 1364 | * @see http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hook_elements/6 |
1365 | 1365 | */ |
1366 | 1366 | function boincuser_elements() { |
1367 | - $type['password_confirm']['#process'][] = 'boincuser_process_password_confirm'; |
|
1368 | - return $type; |
|
1367 | + $type['password_confirm']['#process'][] = 'boincuser_process_password_confirm'; |
|
1368 | + return $type; |
|
1369 | 1369 | } |
1370 | 1370 | |
1371 | 1371 | /** |
@@ -1373,11 +1373,11 @@ discard block |
||
1373 | 1373 | * profile form |
1374 | 1374 | */ |
1375 | 1375 | function boincuser_process_password_confirm($element) { |
1376 | - // Check if parent element is "account". |
|
1377 | - if ($element['#array_parents'][0] == 'account') { |
|
1376 | + // Check if parent element is "account". |
|
1377 | + if ($element['#array_parents'][0] == 'account') { |
|
1378 | 1378 | $element['pass1']['#title'] = bts('Change password', array(), NULL, 'boinc:forgot-password'); |
1379 | - } |
|
1380 | - return $element; |
|
1379 | + } |
|
1380 | + return $element; |
|
1381 | 1381 | } |
1382 | 1382 | |
1383 | 1383 | /** |
@@ -1385,42 +1385,42 @@ discard block |
||
1385 | 1385 | * Register theme functions for use in this module. |
1386 | 1386 | */ |
1387 | 1387 | function boincuser_theme($existing, $type, $theme, $path) { |
1388 | - return array( |
|
1388 | + return array( |
|
1389 | 1389 | 'boincuser_user_pass' => array( |
1390 | - 'arguments' => array() |
|
1390 | + 'arguments' => array() |
|
1391 | 1391 | ) |
1392 | - ); |
|
1392 | + ); |
|
1393 | 1393 | } |
1394 | 1394 | |
1395 | 1395 | /** |
1396 | 1396 | * Implementation of hook_token_values |
1397 | 1397 | */ |
1398 | 1398 | function boincuser_token_values($type, $object = NULL, $options = array()) { |
1399 | - if ($type == 'user') { |
|
1399 | + if ($type == 'user') { |
|
1400 | 1400 | $account = user_load($object->uid); |
1401 | 1401 | $tokens['display-name'] = $account->boincuser_name; |
1402 | 1402 | return $tokens; |
1403 | - } |
|
1403 | + } |
|
1404 | 1404 | } |
1405 | 1405 | |
1406 | 1406 | /** |
1407 | 1407 | * Implementation of hook_token_list |
1408 | 1408 | */ |
1409 | 1409 | function boincuser_token_list($type = 'all') { |
1410 | - if ($type == 'user' || $type == 'all') { |
|
1410 | + if ($type == 'user' || $type == 'all') { |
|
1411 | 1411 | $tokens['user']['display-name'] = t("The user's name that should be displayed"); |
1412 | 1412 | return $tokens; |
1413 | - } |
|
1413 | + } |
|
1414 | 1414 | } |
1415 | 1415 | |
1416 | 1416 | /** |
1417 | 1417 | * Implementation of hook_views_pre_execute() |
1418 | 1418 | */ |
1419 | 1419 | function boincuser_views_pre_execute(&$view) { |
1420 | - if ($view->args) { |
|
1420 | + if ($view->args) { |
|
1421 | 1421 | $account_id = $view->args[0]; |
1422 | - } |
|
1423 | - if ($view->name=="user_activity") { |
|
1422 | + } |
|
1423 | + if ($view->name=="user_activity") { |
|
1424 | 1424 | // Run the following custom query for the user_activity view |
1425 | 1425 | $view->build_info['query']= " |
1426 | 1426 | SELECT node_revisions.vid AS vid, |
@@ -1452,25 +1452,25 @@ discard block |
||
1452 | 1452 | |
1453 | 1453 | // count_query determines the pager. Do this so the right item count is returned. |
1454 | 1454 | $view->build_info['count_query'] = $view->build_info['query']; |
1455 | - } |
|
1455 | + } |
|
1456 | 1456 | } |
1457 | 1457 | |
1458 | 1458 | /** |
1459 | 1459 | * Implementation of hook_cron() |
1460 | 1460 | */ |
1461 | 1461 | function boincuser_cron() { |
1462 | - // Delete expired users in the BOINC database, user_delete table. |
|
1463 | - require_boinc('boinc_db'); |
|
1464 | - $num_deleted = BoincUserDeleted::delete_expired(); |
|
1465 | - if ($num_deleted>0) { |
|
1462 | + // Delete expired users in the BOINC database, user_delete table. |
|
1463 | + require_boinc('boinc_db'); |
|
1464 | + $num_deleted = BoincUserDeleted::delete_expired(); |
|
1465 | + if ($num_deleted>0) { |
|
1466 | 1466 | watchdog('boincuser', "Deleted ${num_deleted} users from user_deleted table", WATCHDOG_NOTICE); |
1467 | - } |
|
1467 | + } |
|
1468 | 1468 | |
1469 | - // Delete expired tokens from token table |
|
1470 | - $tokens_deleted = BoincToken::delete_expired(); |
|
1471 | - if ($tokens_deleted>0) { |
|
1469 | + // Delete expired tokens from token table |
|
1470 | + $tokens_deleted = BoincToken::delete_expired(); |
|
1471 | + if ($tokens_deleted>0) { |
|
1472 | 1472 | watchdog('boincuser', "Deleted ${tokens_deleted} tokens from token table", WATCHDOG_NOTICE); |
1473 | - } |
|
1473 | + } |
|
1474 | 1474 | } |
1475 | 1475 | |
1476 | 1476 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -1481,17 +1481,17 @@ discard block |
||
1481 | 1481 | * Page callback shortcut to recent posts for the logged in user |
1482 | 1482 | */ |
1483 | 1483 | function boincuser_goto_recent_posts() { |
1484 | - global $user; |
|
1485 | - drupal_goto("account/{$user->uid}/posts"); |
|
1484 | + global $user; |
|
1485 | + drupal_goto("account/{$user->uid}/posts"); |
|
1486 | 1486 | } |
1487 | 1487 | |
1488 | 1488 | /** |
1489 | 1489 | * Page callback shortcut to the team of the logged in user |
1490 | 1490 | */ |
1491 | 1491 | function boincuser_goto_team() { |
1492 | - global $user; |
|
1493 | - $account = user_load($user->uid); |
|
1494 | - drupal_goto("community/teams/{$account->team}"); |
|
1492 | + global $user; |
|
1493 | + $account = user_load($user->uid); |
|
1494 | + drupal_goto("community/teams/{$account->team}"); |
|
1495 | 1495 | } |
1496 | 1496 | |
1497 | 1497 | /** |
@@ -1500,93 +1500,93 @@ discard block |
||
1500 | 1500 | * user profile pages, so use a wrapper for display |
1501 | 1501 | */ |
1502 | 1502 | function boincuser_view_profile($account = null) { |
1503 | - // Create the user profile page |
|
1504 | - if (!$account) { |
|
1503 | + // Create the user profile page |
|
1504 | + if (!$account) { |
|
1505 | 1505 | global $user; |
1506 | 1506 | $account = $user; |
1507 | - } |
|
1507 | + } |
|
1508 | 1508 | |
1509 | - $min_credit_to_post = variable_get('boinc_comment_min_credit', 0); |
|
1510 | - $verified_contributor = array_search('verified contributor', user_roles(true)); |
|
1511 | - if (!isset($account->roles[$verified_contributor])) { |
|
1509 | + $min_credit_to_post = variable_get('boinc_comment_min_credit', 0); |
|
1510 | + $verified_contributor = array_search('verified contributor', user_roles(true)); |
|
1511 | + if (!isset($account->roles[$verified_contributor])) { |
|
1512 | 1512 | drupal_set_message(bts( |
1513 | 1513 | 'You may only create or modify your user profile after earning @count credits.', |
1514 | 1514 | array('@count' => $min_credit_to_post), NULL, 'boinc:view-profile' |
1515 | 1515 | ), 'warning', FALSE); |
1516 | - } |
|
1516 | + } |
|
1517 | 1517 | |
1518 | - // For now, just call the user module profile view function |
|
1519 | - user_build_content($account); |
|
1520 | - return theme('user_profile', $account); |
|
1518 | + // For now, just call the user module profile view function |
|
1519 | + user_build_content($account); |
|
1520 | + return theme('user_profile', $account); |
|
1521 | 1521 | } |
1522 | 1522 | |
1523 | 1523 | /** |
1524 | 1524 | * Page callback for editing a user profile |
1525 | 1525 | */ |
1526 | 1526 | function boincuser_edit_profile($account = null) { |
1527 | - // Create the user profile form |
|
1528 | - if (!$account) { |
|
1527 | + // Create the user profile form |
|
1528 | + if (!$account) { |
|
1529 | 1529 | global $user; |
1530 | 1530 | $account = $user; |
1531 | - } |
|
1532 | - // Render the form |
|
1533 | - module_load_include('pages.inc', 'node', 'node'); |
|
1534 | - return content_profile_page_edit('profile', $account); |
|
1531 | + } |
|
1532 | + // Render the form |
|
1533 | + module_load_include('pages.inc', 'node', 'node'); |
|
1534 | + return content_profile_page_edit('profile', $account); |
|
1535 | 1535 | } |
1536 | 1536 | |
1537 | 1537 | /** |
1538 | - * Join page menu callback. |
|
1539 | - * Display instructions on joining for new or existing BOINC users |
|
1540 | - */ |
|
1538 | + * Join page menu callback. |
|
1539 | + * Display instructions on joining for new or existing BOINC users |
|
1540 | + */ |
|
1541 | 1541 | function join_page($type = null) { |
1542 | - global $base_url; |
|
1543 | - /* The paths/links to the rules-and-policies page is hardcoded |
|
1542 | + global $base_url; |
|
1543 | + /* The paths/links to the rules-and-policies page is hardcoded |
|
1544 | 1544 | * here. An improvement would be admin settings for the Join Page |
1545 | 1545 | * where this path could be set. |
1546 | 1546 | */ |
1547 | - $ruleslinkA = 'rules-and-policies'; |
|
1548 | - $ruleslinkB = 'content/rules-and-policies'; |
|
1549 | - $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
1550 | - $registration_enabled = variable_get('user_register', 0); |
|
1551 | - $output = '<div class="join">'; |
|
1552 | - switch ($type) { |
|
1553 | - case 'boinc': |
|
1547 | + $ruleslinkA = 'rules-and-policies'; |
|
1548 | + $ruleslinkB = 'content/rules-and-policies'; |
|
1549 | + $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
1550 | + $registration_enabled = variable_get('user_register', 0); |
|
1551 | + $output = '<div class="join">'; |
|
1552 | + switch ($type) { |
|
1553 | + case 'boinc': |
|
1554 | 1554 | $output .= '<ol>'; |
1555 | 1555 | if ($registration_enabled) { |
1556 | - $output .= '<li>' . bts('First !create_an_account here at @sitename.', |
|
1557 | - array( |
|
1556 | + $output .= '<li>' . bts('First !create_an_account here at @sitename.', |
|
1557 | + array( |
|
1558 | 1558 | '!create_an_account' => l(bts('create an account', array(), NULL, 'boinc:join-page'), 'user/registration'), |
1559 | 1559 | '@sitename' => $site_name, |
1560 | - ), NULL, 'boinc:join-page') . '</li>'; |
|
1560 | + ), NULL, 'boinc:join-page') . '</li>'; |
|
1561 | 1561 | } |
1562 | 1562 | $output .= ' <li>' . bts("Install BOINC on this device if not already present.", array(), NULL, 'boinc:join-page') . '</li>'; |
1563 | 1563 | $output .= ' <li>' . bts("Select <i>Tools / Add Project</i>. Choose @sitename from the list, or enter @siteurl.", |
1564 | 1564 | array( |
1565 | - '@sitename' => $site_name, |
|
1566 | - '@siteurl' => $base_url, |
|
1565 | + '@sitename' => $site_name, |
|
1566 | + '@siteurl' => $base_url, |
|
1567 | 1567 | ), NULL, 'boinc:join-page') . '</li>'; |
1568 | 1568 | if ($registration_enabled) { |
1569 | - $output .= '<li>' . bts("If you're running a command-line or pre-5.0 version of BOINC, use <b>!boinccmd</b> to add the project.", |
|
1569 | + $output .= '<li>' . bts("If you're running a command-line or pre-5.0 version of BOINC, use <b>!boinccmd</b> to add the project.", |
|
1570 | 1570 | array( |
1571 | - '!boinccmd' => l('boinccmd --project_attach', 'http://boinc.berkeley.edu/wiki/Boinccmd_tool'), |
|
1571 | + '!boinccmd' => l('boinccmd --project_attach', 'http://boinc.berkeley.edu/wiki/Boinccmd_tool'), |
|
1572 | 1572 | ), NULL, 'boinc:join-page') . '</li>'; |
1573 | 1573 | } |
1574 | 1574 | else { |
1575 | - $output .= '<li>' . bts("If you're running a command-line version of BOINC, |
|
1575 | + $output .= '<li>' . bts("If you're running a command-line version of BOINC, |
|
1576 | 1576 | please follow the <b>!instructionslink</b> to first <i>create an account</i>, and then <i>attach</i> to this project. Use the same project URL as above.", |
1577 | 1577 | array( |
1578 | - '!instructionslink' => l('instructions', 'http://boinc.berkeley.edu/wiki/Boinccmd_tool'), |
|
1578 | + '!instructionslink' => l('instructions', 'http://boinc.berkeley.edu/wiki/Boinccmd_tool'), |
|
1579 | 1579 | ), NULL, 'boinc:join-page') . '</li>'; |
1580 | 1580 | } |
1581 | 1581 | $output .= '<li>' . bts("If you're running a pre-5.0 version of BOINC, please |
1582 | 1582 | upgrade to a more recent version of BOINC to create an account |
1583 | 1583 | at @this_project.", |
1584 | - array( |
|
1584 | + array( |
|
1585 | 1585 | '@this_project' => $site_name, |
1586 | - ), NULL, 'boinc:join-page') . '</li>'; |
|
1586 | + ), NULL, 'boinc:join-page') . '</li>'; |
|
1587 | 1587 | $output .= '</ol>'; |
1588 | 1588 | break; |
1589 | - case 'new': |
|
1589 | + case 'new': |
|
1590 | 1590 | default: |
1591 | 1591 | // Determine if there is a link to rules-and-policies |
1592 | 1592 | //$ruleslink=''; |
@@ -1601,16 +1601,16 @@ discard block |
||
1601 | 1601 | // Join page output |
1602 | 1602 | $output .= '<ol>'; |
1603 | 1603 | if ($registration_enabled) { |
1604 | - $output .= '<li>' . bts('First !create_an_account here at @sitename.', |
|
1605 | - array( |
|
1604 | + $output .= '<li>' . bts('First !create_an_account here at @sitename.', |
|
1605 | + array( |
|
1606 | 1606 | '!create_an_account' => l(bts('create an account', array(), NULL, 'boinc:join-page'), 'user/registration'), |
1607 | 1607 | '@sitename' => $site_name, |
1608 | - ), NULL, 'boinc:join-page') . '</li>'; |
|
1608 | + ), NULL, 'boinc:join-page') . '</li>'; |
|
1609 | 1609 | } |
1610 | 1610 | else if ( menu_valid_path(array('link_path' => $ruleslink)) ) { |
1611 | - $output .= ' <li>' . bts("Read our !rules_and_policies.", array( |
|
1611 | + $output .= ' <li>' . bts("Read our !rules_and_policies.", array( |
|
1612 | 1612 | '!rules_and_policies' => l(bts('Rules and Policies', array(), NULL, 'boinc:join-page'), $ruleslink), |
1613 | - ), NULL, 'boinc:join-page') . '</li>'; |
|
1613 | + ), NULL, 'boinc:join-page') . '</li>'; |
|
1614 | 1614 | } |
1615 | 1615 | $output .= ' <li>' . bts('Download the BOINC desktop software.', array(), NULL, 'boinc:join-page'); |
1616 | 1616 | $output .= ' <p>'; |
@@ -1620,73 +1620,73 @@ discard block |
||
1620 | 1620 | $output .= ' </li>'; |
1621 | 1621 | $output .= ' <li>' . bts('Run the installer.', array(), NULL, 'boinc:join-page') . '</li>'; |
1622 | 1622 | $output .= ' <li>' . bts('Choose @sitename from the list, or enter @siteurl.', array( |
1623 | - '@sitename' => $site_name, |
|
1624 | - '@siteurl' => $base_url, |
|
1623 | + '@sitename' => $site_name, |
|
1624 | + '@siteurl' => $base_url, |
|
1625 | 1625 | ), NULL, 'boinc:join-page') . '</li>'; |
1626 | 1626 | $output .= '</ol>'; |
1627 | - } |
|
1628 | - $output .= '</div>'; |
|
1629 | - return $output; |
|
1627 | + } |
|
1628 | + $output .= '</div>'; |
|
1629 | + return $output; |
|
1630 | 1630 | } |
1631 | 1631 | |
1632 | 1632 | /** |
1633 | - * Home page content for embedding in Panels page |
|
1634 | - */ |
|
1633 | + * Home page content for embedding in Panels page |
|
1634 | + */ |
|
1635 | 1635 | function boincuser_home_page() { |
1636 | - global $user; |
|
1637 | - $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
1638 | - // get the front page message from database; this is set in the admin interface under BOINC Other |
|
1639 | - $site_message = variable_get('boinc_other_frontpage',''); |
|
1636 | + global $user; |
|
1637 | + $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
1638 | + // get the front page message from database; this is set in the admin interface under BOINC Other |
|
1639 | + $site_message = variable_get('boinc_other_frontpage',''); |
|
1640 | 1640 | |
1641 | - // Determine the user of the day |
|
1642 | - $current_uotd = db_fetch_object(db_query(" |
|
1641 | + // Determine the user of the day |
|
1642 | + $current_uotd = db_fetch_object(db_query(" |
|
1643 | 1643 | SELECT |
1644 | 1644 | uid, |
1645 | 1645 | uotd_time |
1646 | 1646 | FROM {boincuser} |
1647 | 1647 | ORDER BY uotd_time DESC |
1648 | 1648 | LIMIT 1" |
1649 | - )); |
|
1650 | - if ($current_uotd->uotd_time < strtotime('today midnight')) { |
|
1649 | + )); |
|
1650 | + if ($current_uotd->uotd_time < strtotime('today midnight')) { |
|
1651 | 1651 | $uotd = boincuser_select_user_of_the_day(); |
1652 | - } |
|
1653 | - else { |
|
1652 | + } |
|
1653 | + else { |
|
1654 | 1654 | $uotd = user_load($current_uotd->uid); |
1655 | - } |
|
1656 | - $uotd_image = boincuser_get_user_profile_image($uotd->uid, FALSE); |
|
1657 | - $output = '<h2 class="pane-title">'; |
|
1658 | - $output .= ($user->uid) ? bts('Welcome back!', array(), NULL, 'boinc:front-page') : ($site_name ? bts('What is @this_project?', array('@this_project' => $site_name)) : bts('Welcome!', array(), NULL, 'boinc:front-page')); |
|
1659 | - $output .= '</h2>'; |
|
1660 | - $output .= '<div class="boinc-overview balance-height-front">'; |
|
1661 | - $output .= ' <div>' . bts($site_message, array(), NULL, "project:front page") . ' ' . l(bts('Learn more', array(), NULL, 'boinc:front-page'), 'about') . '</div>'; |
|
1662 | - if ($user->uid) { |
|
1655 | + } |
|
1656 | + $uotd_image = boincuser_get_user_profile_image($uotd->uid, FALSE); |
|
1657 | + $output = '<h2 class="pane-title">'; |
|
1658 | + $output .= ($user->uid) ? bts('Welcome back!', array(), NULL, 'boinc:front-page') : ($site_name ? bts('What is @this_project?', array('@this_project' => $site_name)) : bts('Welcome!', array(), NULL, 'boinc:front-page')); |
|
1659 | + $output .= '</h2>'; |
|
1660 | + $output .= '<div class="boinc-overview balance-height-front">'; |
|
1661 | + $output .= ' <div>' . bts($site_message, array(), NULL, "project:front page") . ' ' . l(bts('Learn more', array(), NULL, 'boinc:front-page'), 'about') . '</div>'; |
|
1662 | + if ($user->uid) { |
|
1663 | 1663 | $output .= ' <div>' . l(bts('View account', array(), NULL, 'boinc:front-page'), 'dashboard', array('attributes' => array('class' => 'join button'))) . '</div>'; |
1664 | - } |
|
1665 | - else { |
|
1664 | + } |
|
1665 | + else { |
|
1666 | 1666 | $output .= ' <div>' . l(bts('Join now', array(), NULL, 'boinc:front-page'), 'join', array('attributes' => array('class' => 'join button'))) . '</div>'; |
1667 | - } |
|
1668 | - $output .= '</div>'; |
|
1669 | - $output .= '<div class="boinc-overview-details">'; |
|
1670 | - $output .= ' <div class="detail-container">'; |
|
1671 | - $output .= ' <a class="user-of-the-day" href="account/' . $uotd->uid . '">'; |
|
1672 | - $output .= ' <div class="picture">'; |
|
1673 | - $output .= theme('imagefield_image', $uotd_image['image'], $uotd_image['alt'], |
|
1667 | + } |
|
1668 | + $output .= '</div>'; |
|
1669 | + $output .= '<div class="boinc-overview-details">'; |
|
1670 | + $output .= ' <div class="detail-container">'; |
|
1671 | + $output .= ' <a class="user-of-the-day" href="account/' . $uotd->uid . '">'; |
|
1672 | + $output .= ' <div class="picture">'; |
|
1673 | + $output .= theme('imagefield_image', $uotd_image['image'], $uotd_image['alt'], |
|
1674 | 1674 | $uotd_image['alt'], array(), FALSE); |
1675 | - $output .= ' </div>'; |
|
1676 | - $output .= ' <div class="text">' . bts('User of the day', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1677 | - $output .= ' <div class="detail">' . $uotd->boincuser_name . '</div>'; |
|
1678 | - $output .= ' </a>'; |
|
1679 | - $output .= ' <div class="volunteers">'; |
|
1680 | - $output .= ' <div class="text">' . bts('Over 500,000 volunteers and counting.', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1681 | - $output .= ' <div class="platforms">'; |
|
1682 | - $output .= ' <div class="detail platform windows">' . bts('Windows', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1683 | - $output .= ' <div class="detail platform mac">' . bts('Mac', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1684 | - $output .= ' <div class="detail platform linux">' . bts('Linux', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1685 | - $output .= ' </div>'; |
|
1686 | - $output .= ' </div>'; |
|
1687 | - $output .= ' </div>'; |
|
1688 | - $output .= '</div>'; |
|
1689 | - return $output; |
|
1675 | + $output .= ' </div>'; |
|
1676 | + $output .= ' <div class="text">' . bts('User of the day', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1677 | + $output .= ' <div class="detail">' . $uotd->boincuser_name . '</div>'; |
|
1678 | + $output .= ' </a>'; |
|
1679 | + $output .= ' <div class="volunteers">'; |
|
1680 | + $output .= ' <div class="text">' . bts('Over 500,000 volunteers and counting.', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1681 | + $output .= ' <div class="platforms">'; |
|
1682 | + $output .= ' <div class="detail platform windows">' . bts('Windows', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1683 | + $output .= ' <div class="detail platform mac">' . bts('Mac', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1684 | + $output .= ' <div class="detail platform linux">' . bts('Linux', array(), NULL, 'boinc:front-page') . '</div>'; |
|
1685 | + $output .= ' </div>'; |
|
1686 | + $output .= ' </div>'; |
|
1687 | + $output .= ' </div>'; |
|
1688 | + $output .= '</div>'; |
|
1689 | + return $output; |
|
1690 | 1690 | } |
1691 | 1691 | |
1692 | 1692 | /** |
@@ -1694,81 +1694,81 @@ discard block |
||
1694 | 1694 | * Create a new user account based on supplied parameters. |
1695 | 1695 | */ |
1696 | 1696 | function boincuser_create_account() { |
1697 | - global $base_url; |
|
1697 | + global $base_url; |
|
1698 | 1698 | |
1699 | - require_boinc('boinc_db'); |
|
1700 | - require_boinc('user_util'); |
|
1701 | - require_boinc('xml'); |
|
1702 | - $params = array( |
|
1699 | + require_boinc('boinc_db'); |
|
1700 | + require_boinc('user_util'); |
|
1701 | + require_boinc('xml'); |
|
1702 | + $params = array( |
|
1703 | 1703 | 'email_addr' => isset($_GET['email_addr']) ? $_GET['email_addr'] : '', |
1704 | 1704 | 'user_name' => isset($_GET['user_name']) ? $_GET['user_name'] : '', |
1705 | 1705 | 'passwd_hash' => isset($_GET['passwd_hash']) ? $_GET['passwd_hash'] : '' |
1706 | - ); |
|
1706 | + ); |
|
1707 | 1707 | |
1708 | - // Begin output |
|
1709 | - xml_header(); |
|
1708 | + // Begin output |
|
1709 | + xml_header(); |
|
1710 | 1710 | |
1711 | - // Account creation disabled |
|
1712 | - $enablethisRPC = variable_get('boinc_weboptions_enableaccountcreateRPC', TRUE); |
|
1713 | - if (!$enablethisRPC) { |
|
1711 | + // Account creation disabled |
|
1712 | + $enablethisRPC = variable_get('boinc_weboptions_enableaccountcreateRPC', TRUE); |
|
1713 | + if (!$enablethisRPC) { |
|
1714 | 1714 | $mess = bts('Account creation is done through our Web site. Please register at @url', array( |
1715 | - '@url' => $base_url . '/user/registration', |
|
1715 | + '@url' => $base_url . '/user/registration', |
|
1716 | 1716 | ), |
1717 | 1717 | NULL, 'boinc:create_account'); |
1718 | 1718 | xml_error(-208, $mess); |
1719 | - } |
|
1720 | - // Invalid invite code |
|
1719 | + } |
|
1720 | + // Invalid invite code |
|
1721 | 1721 | |
1722 | - // Validate input |
|
1723 | - if (user_validate_mail($params['email_addr']) or !is_valid_email_addr($params['email_addr'])) { |
|
1722 | + // Validate input |
|
1723 | + if (user_validate_mail($params['email_addr']) or !is_valid_email_addr($params['email_addr'])) { |
|
1724 | 1724 | xml_error(-205); |
1725 | - } |
|
1725 | + } |
|
1726 | 1726 | |
1727 | - // Make sure user_name is unique and cleaned |
|
1728 | - $unique_name = create_proper_drupalname($params['user_name']); |
|
1729 | - if ($error = user_validate_name($unique_name)) { |
|
1727 | + // Make sure user_name is unique and cleaned |
|
1728 | + $unique_name = create_proper_drupalname($params['user_name']); |
|
1729 | + if ($error = user_validate_name($unique_name)) { |
|
1730 | 1730 | xml_error(-188, $error); |
1731 | - } |
|
1732 | - if (strlen($params['passwd_hash']) != 32) { |
|
1731 | + } |
|
1732 | + if (strlen($params['passwd_hash']) != 32) { |
|
1733 | 1733 | xml_error(-1, 'password hash length not 32'); |
1734 | - } |
|
1734 | + } |
|
1735 | 1735 | |
1736 | - // Process input |
|
1737 | - // Check this email against previous email addresses. |
|
1738 | - $tmpuser = BoincUser::lookup_prev_email_addr($params['email_addr']); |
|
1739 | - if ($tmpuser) { |
|
1736 | + // Process input |
|
1737 | + // Check this email against previous email addresses. |
|
1738 | + $tmpuser = BoincUser::lookup_prev_email_addr($params['email_addr']); |
|
1739 | + if ($tmpuser) { |
|
1740 | 1740 | xml_error(-137); |
1741 | - } |
|
1741 | + } |
|
1742 | 1742 | |
1743 | - // Check this email on current email addresses. |
|
1744 | - $boinc_user = BoincUser::lookup_email_addr($params['email_addr']); |
|
1745 | - if ($boinc_user) { |
|
1743 | + // Check this email on current email addresses. |
|
1744 | + $boinc_user = BoincUser::lookup_email_addr($params['email_addr']); |
|
1745 | + if ($boinc_user) { |
|
1746 | 1746 | // Return authenticator for existing users |
1747 | 1747 | if ( ($params['passwd_hash'] == $boinc_user->passwd_hash) or |
1748 | 1748 | password_verify($params['passwd_hash'], $boinc_user->passwd_hash) ) { |
1749 | - $output = array('authenticator' => $boinc_user->authenticator); |
|
1749 | + $output = array('authenticator' => $boinc_user->authenticator); |
|
1750 | 1750 | } |
1751 | 1751 | else { |
1752 | - xml_error(-137); |
|
1752 | + xml_error(-137); |
|
1753 | 1753 | } |
1754 | - } |
|
1755 | - else { |
|
1754 | + } |
|
1755 | + else { |
|
1756 | 1756 | // Verify that there isn't somehow a Drupal user already (not possible with proper function) |
1757 | 1757 | if ($existing_user = user_load(array('mail' => $params['email_addr']))) { |
1758 | - xml_error(-137, 'account error'); |
|
1758 | + xml_error(-137, 'account error'); |
|
1759 | 1759 | } |
1760 | 1760 | // Create new account |
1761 | 1761 | $unrestricted_role = array_search('community member', user_roles(true)); |
1762 | 1762 | |
1763 | 1763 | $newUser = array( |
1764 | - 'name' => $unique_name, |
|
1765 | - 'pass' => $params['passwd_hash'], // note: passing a hash here requires ALL passwords to be hashed via hook prior to interacting with the hash stored in the db |
|
1766 | - 'mail' => $params['email_addr'], |
|
1767 | - 'status' => 1, |
|
1768 | - 'init' => $params['email_addr'], |
|
1769 | - 'roles' => array($unrestricted_role => ''), |
|
1770 | - 'boincuser_name' => $params['user_name'], |
|
1771 | - 'boinchash_flag' => TRUE, |
|
1764 | + 'name' => $unique_name, |
|
1765 | + 'pass' => $params['passwd_hash'], // note: passing a hash here requires ALL passwords to be hashed via hook prior to interacting with the hash stored in the db |
|
1766 | + 'mail' => $params['email_addr'], |
|
1767 | + 'status' => 1, |
|
1768 | + 'init' => $params['email_addr'], |
|
1769 | + 'roles' => array($unrestricted_role => ''), |
|
1770 | + 'boincuser_name' => $params['user_name'], |
|
1771 | + 'boinchash_flag' => TRUE, |
|
1772 | 1772 | ); |
1773 | 1773 | |
1774 | 1774 | // Create the drupal user. If the drupal user cannot be created, |
@@ -1776,17 +1776,17 @@ discard block |
||
1776 | 1776 | // The user is created in the 'insert' op in hook_user. |
1777 | 1777 | $user = user_save(null, $newUser); |
1778 | 1778 | if (!$user) { |
1779 | - watchdog('boincuser', 'create_account: Failed to create Drupal user account for @email', array('@email' => $params['email_addr']), WATCHDOG_WARNING); |
|
1780 | - xml_error(-137, 'error creating BOINC account'); |
|
1779 | + watchdog('boincuser', 'create_account: Failed to create Drupal user account for @email', array('@email' => $params['email_addr']), WATCHDOG_WARNING); |
|
1780 | + xml_error(-137, 'error creating BOINC account'); |
|
1781 | 1781 | }// if drupal user created. |
1782 | 1782 | |
1783 | 1783 | $output = array('authenticator' => $user->boincuser_account_key); |
1784 | - }// if existing user found. |
|
1784 | + }// if existing user found. |
|
1785 | 1785 | |
1786 | - // Output authenticator |
|
1787 | - echo " <account_out>\n"; |
|
1788 | - echo " <authenticator>{$output['authenticator']}</authenticator>\n"; |
|
1789 | - echo "</account_out>\n"; |
|
1786 | + // Output authenticator |
|
1787 | + echo " <account_out>\n"; |
|
1788 | + echo " <authenticator>{$output['authenticator']}</authenticator>\n"; |
|
1789 | + echo "</account_out>\n"; |
|
1790 | 1790 | } |
1791 | 1791 | |
1792 | 1792 | /** |
@@ -1794,166 +1794,166 @@ discard block |
||
1794 | 1794 | * account is created using the BOINC clinet. |
1795 | 1795 | */ |
1796 | 1796 | function boincuser_account_finish() { |
1797 | - global $user; |
|
1797 | + global $user; |
|
1798 | 1798 | |
1799 | - $authtoken = isset($_GET['auth']) ? $_GET['auth'] : ''; |
|
1799 | + $authtoken = isset($_GET['auth']) ? $_GET['auth'] : ''; |
|
1800 | 1800 | |
1801 | - // Ensure there is a authentication token before continuing |
|
1802 | - if (empty($authtoken)) { |
|
1801 | + // Ensure there is a authentication token before continuing |
|
1802 | + if (empty($authtoken)) { |
|
1803 | 1803 | drupal_not_found(); |
1804 | 1804 | return ; |
1805 | - } |
|
1805 | + } |
|
1806 | 1806 | |
1807 | - if (strlen($authtoken) != 32) { |
|
1807 | + if (strlen($authtoken) != 32) { |
|
1808 | 1808 | drupal_set_message(bts('ERROR: There is no account with that authenticator.', array(), NULL, 'boinc:account-finish'), 'error'); |
1809 | 1809 | drupal_goto(); |
1810 | - } |
|
1810 | + } |
|
1811 | 1811 | |
1812 | - require_boinc('boinc_db'); |
|
1813 | - $boinc_user = BoincUser::lookup("authenticator='".addslashes($authtoken)."'"); |
|
1814 | - if (!$boinc_user) { |
|
1812 | + require_boinc('boinc_db'); |
|
1813 | + $boinc_user = BoincUser::lookup("authenticator='".addslashes($authtoken)."'"); |
|
1814 | + if (!$boinc_user) { |
|
1815 | 1815 | drupal_set_message(bts('ERROR: There is no account with that authenticator.', array(), NULL, 'boinc:account-finish'), 'error'); |
1816 | 1816 | drupal_goto(); |
1817 | - } |
|
1818 | - $user = user_load(get_drupal_id($boinc_user->id)); |
|
1817 | + } |
|
1818 | + $user = user_load(get_drupal_id($boinc_user->id)); |
|
1819 | 1819 | |
1820 | - if (!$user) { |
|
1820 | + if (!$user) { |
|
1821 | 1821 | drupal_set_message(bts('ERROR: There was a problem loading your account. Try logging in with your user name and password.', array(), NULL, 'boinc:account-finish'), 'error'); |
1822 | 1822 | drupal_goto(); |
1823 | - } |
|
1823 | + } |
|
1824 | 1824 | |
1825 | - // Lookup path to custom account finish page |
|
1826 | - $customaccountfinishpath = drupal_lookup_path('source', variable_get('boinc_weboptions_accountfinish', '') ); |
|
1827 | - if ( menu_valid_path(array('link_path' => $customaccountfinishpath)) ) { |
|
1825 | + // Lookup path to custom account finish page |
|
1826 | + $customaccountfinishpath = drupal_lookup_path('source', variable_get('boinc_weboptions_accountfinish', '') ); |
|
1827 | + if ( menu_valid_path(array('link_path' => $customaccountfinishpath)) ) { |
|
1828 | 1828 | $node = menu_get_object('node', 1, $customaccountfinishpath); |
1829 | 1829 | if ($node) { |
1830 | - return node_page_view($node); |
|
1830 | + return node_page_view($node); |
|
1831 | + } |
|
1831 | 1832 | } |
1832 | - } |
|
1833 | 1833 | |
1834 | - // open links in new window |
|
1835 | - $options = array( |
|
1834 | + // open links in new window |
|
1835 | + $options = array( |
|
1836 | 1836 | 'attributes' => array( 'target' => '_blank' ), |
1837 | - ); |
|
1837 | + ); |
|
1838 | 1838 | |
1839 | - // Check moderation page exists |
|
1840 | - $moderationpath = drupal_lookup_path('source', variable_get('boinc_weboptions_moderationpage', '') ); |
|
1841 | - if ( menu_valid_path(array('link_path' => $moderationpath)) ) { |
|
1839 | + // Check moderation page exists |
|
1840 | + $moderationpath = drupal_lookup_path('source', variable_get('boinc_weboptions_moderationpage', '') ); |
|
1841 | + if ( menu_valid_path(array('link_path' => $moderationpath)) ) { |
|
1842 | 1842 | $modsentence = bts('Please note: user profiles are subject to !moderation.', array('!moderation' => l(bts('moderation', array(), NULL, 'boinc:account-finish'), $moderationpath, $options)), NULL, 'boinc:account-finish'); |
1843 | - } else { |
|
1843 | + } else { |
|
1844 | 1844 | $modsentence = bts('Please note: user profiles are subject to moderation.', array(), NULL, 'boinc:account-finish'); |
1845 | - } |
|
1845 | + } |
|
1846 | 1846 | |
1847 | - $username = $user->boincuser_name; |
|
1848 | - $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
1849 | - $output = "<p>" . bts('Thank you @user_name for joining @site_name. Your account has been created. Your BOINC client should start working on assigned tasks soon, without any additional action or configuration. Please visit the links below for more information and additional options. (Links will open in a new window.)', |
|
1850 | - array( |
|
1847 | + $username = $user->boincuser_name; |
|
1848 | + $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
1849 | + $output = "<p>" . bts('Thank you @user_name for joining @site_name. Your account has been created. Your BOINC client should start working on assigned tasks soon, without any additional action or configuration. Please visit the links below for more information and additional options. (Links will open in a new window.)', |
|
1850 | + array( |
|
1851 | 1851 | '@user_name' => $username, |
1852 | 1852 | '@site_name' => $site_name, |
1853 | - ), NULL, 'boinc:account-finish') . "</p>"; |
|
1853 | + ), NULL, 'boinc:account-finish') . "</p>"; |
|
1854 | 1854 | |
1855 | - $links = array( |
|
1855 | + $links = array( |
|
1856 | 1856 | array( |
1857 | - 'data' => bts('Change your username at !community_preferences.', array( |
|
1857 | + 'data' => bts('Change your username at !community_preferences.', array( |
|
1858 | 1858 | '!community_preferences' => l(bts('Community Preferences', array(), NULL, 'boinc:account-fininsh'), 'account/prefs/community', $options), |
1859 | - ), NULL, 'boinc:account-finish'), |
|
1860 | - 'children' => array( |
|
1859 | + ), NULL, 'boinc:account-finish'), |
|
1860 | + 'children' => array( |
|
1861 | 1861 | bts('Your username is used to identify yourself to other volunteers on this Web site.', array(), NULL, 'boinc:account-finish'), |
1862 | 1862 | bts('In addition, you may set your account\'s default language and adjust notification settings.', array(), NULL, 'boinc:account-finish'), |
1863 | - ), |
|
1863 | + ), |
|
1864 | 1864 | ), |
1865 | 1865 | array( |
1866 | - 'data' => bts('Change your !computing_preferences.', array( |
|
1866 | + 'data' => bts('Change your !computing_preferences.', array( |
|
1867 | 1867 | '!computing_preferences' => l(bts('Computing Preferences', array(), NULL, 'boinc:account-finish'), 'account/prefs', $options), |
1868 | - ), NULL, 'boinc:account-finish'), |
|
1869 | - 'children' => array( |
|
1868 | + ), NULL, 'boinc:account-finish'), |
|
1869 | + 'children' => array( |
|
1870 | 1870 | bts('You may adjust how much CPU, RAM, and Disk space the BOINC client is allowed to use for tasks on your computer.', array(), NULL, 'boinc:account-finish'), |
1871 | 1871 | bts('By default, you will run @site_name tasks without any additional configuration.', array( |
1872 | - '@site_name' => $site_name, |
|
1872 | + '@site_name' => $site_name, |
|
1873 | 1873 | ), NULL, 'boinc:account-finish'), |
1874 | 1874 | bts('It is recommended new volunteers leave the default settings until they gain experience running some tasks. Ask questions in the !forums to get advice before making changes to a setting you don\'t understand.', array( |
1875 | - '!forums' => l(bts('forums', array(), NULL, 'boinc:account-finish'), 'community/forum', $options), |
|
1875 | + '!forums' => l(bts('forums', array(), NULL, 'boinc:account-finish'), 'community/forum', $options), |
|
1876 | 1876 | ), NULL, 'boinc:account-finish'), |
1877 | - ), |
|
1877 | + ), |
|
1878 | 1878 | ), |
1879 | 1879 | array( |
1880 | 1880 | 'data' => bts('Create a !user_profile.', array( |
1881 | - '!user_profile' => l(bts('User Profile', array(), NULL, 'boinc:account-finish'), '/account/profile/edit', $options), |
|
1881 | + '!user_profile' => l(bts('User Profile', array(), NULL, 'boinc:account-finish'), '/account/profile/edit', $options), |
|
1882 | 1882 | ), NULL, 'boinc:account-finish'), |
1883 | - 'children' => array( |
|
1883 | + 'children' => array( |
|
1884 | 1884 | bts('A user profile will inform other volunteers who you are and why you joined @site_name.', array( |
1885 | - '@site_name' => $site_name, |
|
1885 | + '@site_name' => $site_name, |
|
1886 | 1886 | ), NULL, 'boinc:account-finish'), |
1887 | 1887 | $modsentence, |
1888 | - ), |
|
1888 | + ), |
|
1889 | 1889 | ), |
1890 | 1890 | array( |
1891 | - 'data' => bts('Join a !team.', array( |
|
1891 | + 'data' => bts('Join a !team.', array( |
|
1892 | 1892 | '!team' => l(bts('Team', array(), NULL, 'boinc:account-finish'), '/community/teams', $options), |
1893 | - ), NULL, 'boinc:account-finish'), |
|
1894 | - 'children' => array( |
|
1893 | + ), NULL, 'boinc:account-finish'), |
|
1894 | + 'children' => array( |
|
1895 | 1895 | bts('You may join a team, made up of other volunteers.', array(), NULL, 'boinc:account-finish'), |
1896 | - ), |
|
1896 | + ), |
|
1897 | 1897 | ), |
1898 | 1898 | array( |
1899 | - 'data' => bts('Go to your !account_dashboard.', array( |
|
1899 | + 'data' => bts('Go to your !account_dashboard.', array( |
|
1900 | 1900 | '!account_dashboard'=> l(bts('Account Dashboard', array(), NULL, 'boinc:account-finish'), 'account/dashboard', $options), |
1901 | - ), NULL, 'boinc:account-finish'), |
|
1902 | - 'children' => array( |
|
1901 | + ), NULL, 'boinc:account-finish'), |
|
1902 | + 'children' => array( |
|
1903 | 1903 | bts('Your account dashboard has information and links about your computer(s) and task(s) assigned.', array(), NULL, 'boinc:account-finish'), |
1904 | - ), |
|
1904 | + ), |
|
1905 | 1905 | ), |
1906 | 1906 | array( |
1907 | - 'data' => bts('Visit our !help pages.', array( |
|
1907 | + 'data' => bts('Visit our !help pages.', array( |
|
1908 | 1908 | '!help' => l(bts('Help', array(), NULL, 'boinc:account-finish'), '/help', $options) |
1909 | - ), NULL, 'boinc:account-finish'), |
|
1910 | - 'children' => array( |
|
1909 | + ), NULL, 'boinc:account-finish'), |
|
1910 | + 'children' => array( |
|
1911 | 1911 | bts('Ask for help in our community\'s !forums.', array( |
1912 | - '!forums' => l(bts('forums', array(), NULL, 'boinc:account-finish'), 'community/forum', $options) |
|
1912 | + '!forums' => l(bts('forums', array(), NULL, 'boinc:account-finish'), 'community/forum', $options) |
|
1913 | 1913 | ), NULL, 'boinc:account-finish'), |
1914 | - ), |
|
1914 | + ), |
|
1915 | 1915 | ), |
1916 | - ); |
|
1916 | + ); |
|
1917 | 1917 | |
1918 | - //List of links |
|
1919 | - $output .= theme_item_list($links, $title = NULL, $type='ul'); |
|
1918 | + //List of links |
|
1919 | + $output .= theme_item_list($links, $title = NULL, $type='ul'); |
|
1920 | 1920 | |
1921 | - return $output; |
|
1921 | + return $output; |
|
1922 | 1922 | } |
1923 | 1923 | |
1924 | 1924 | /** |
1925 | 1925 | * Determine if the user has permission to control community access |
1926 | 1926 | */ |
1927 | 1927 | function boincuser_moderate_community_access() { |
1928 | - if (user_access('assign community member role') |
|
1928 | + if (user_access('assign community member role') |
|
1929 | 1929 | OR user_access('assign all roles')) { |
1930 | 1930 | return TRUE; |
1931 | - } |
|
1932 | - return FALSE; |
|
1931 | + } |
|
1932 | + return FALSE; |
|
1933 | 1933 | } |
1934 | 1934 | |
1935 | 1935 | /** |
1936 | 1936 | * Get the count of items in the moderation queue |
1937 | 1937 | */ |
1938 | 1938 | function boincuser_moderation_queue_count($caller = 'user') { |
1939 | - $allowed = FALSE; |
|
1940 | - switch ($caller) { |
|
1941 | - case 'cron': |
|
1939 | + $allowed = FALSE; |
|
1940 | + switch ($caller) { |
|
1941 | + case 'cron': |
|
1942 | 1942 | $allowed = TRUE; |
1943 | 1943 | break; |
1944 | - case 'user': |
|
1944 | + case 'user': |
|
1945 | 1945 | default: |
1946 | 1946 | $allowed = user_access('edit any profile content'); |
1947 | - } |
|
1948 | - if ($allowed) { |
|
1947 | + } |
|
1948 | + if ($allowed) { |
|
1949 | 1949 | return db_result(db_query(" |
1950 | 1950 | SELECT COUNT(*) |
1951 | 1951 | FROM {node} |
1952 | 1952 | WHERE type = 'profile' |
1953 | 1953 | AND moderate = 1" |
1954 | 1954 | )); |
1955 | - } |
|
1956 | - return NULL; |
|
1955 | + } |
|
1956 | + return NULL; |
|
1957 | 1957 | } |
1958 | 1958 | |
1959 | 1959 | /** |
@@ -1962,43 +1962,43 @@ discard block |
||
1962 | 1962 | * than through the user account info form. |
1963 | 1963 | */ |
1964 | 1964 | function boincuser_control($uid = NULL, $action = NULL) { |
1965 | - if (!$uid OR !$account = user_load($uid)) { |
|
1965 | + if (!$uid OR !$account = user_load($uid)) { |
|
1966 | 1966 | // What are you even doing here... |
1967 | 1967 | return FALSE; |
1968 | - } |
|
1969 | - switch ($action) { |
|
1970 | - case 'ban': |
|
1968 | + } |
|
1969 | + switch ($action) { |
|
1970 | + case 'ban': |
|
1971 | 1971 | if (boincuser_moderate_community_access()) { |
1972 | - $penalty_period = variable_get('boinc_penalty_period', 7*24*60*60); |
|
1973 | - $boincuser_record = array( |
|
1972 | + $penalty_period = variable_get('boinc_penalty_period', 7*24*60*60); |
|
1973 | + $boincuser_record = array( |
|
1974 | 1974 | 'uid' => $uid, |
1975 | 1975 | 'penalty_expiration' => time() + $penalty_period, |
1976 | - ); |
|
1977 | - drupal_write_record('boincuser', $boincuser_record, 'uid'); |
|
1978 | - $community_role = array_search('community member', user_roles(true)); |
|
1979 | - if (isset($account->roles[$community_role])) { |
|
1976 | + ); |
|
1977 | + drupal_write_record('boincuser', $boincuser_record, 'uid'); |
|
1978 | + $community_role = array_search('community member', user_roles(true)); |
|
1979 | + if (isset($account->roles[$community_role])) { |
|
1980 | 1980 | unset($account->roles[$community_role]); |
1981 | 1981 | user_save($account, array('roles' => $account->roles)); |
1982 | - } |
|
1982 | + } |
|
1983 | 1983 | } |
1984 | 1984 | break; |
1985 | - case 'lift-ban': |
|
1985 | + case 'lift-ban': |
|
1986 | 1986 | if (boincuser_moderate_community_access()) { |
1987 | - $boincuser_record = array( |
|
1987 | + $boincuser_record = array( |
|
1988 | 1988 | 'uid' => $uid, |
1989 | 1989 | 'penalty_expiration' => 0, |
1990 | - ); |
|
1991 | - drupal_write_record('boincuser', $boincuser_record, 'uid'); |
|
1992 | - $community_role = array_search('community member', user_roles(true)); |
|
1993 | - if (!isset($account->roles[$community_role])) { |
|
1990 | + ); |
|
1991 | + drupal_write_record('boincuser', $boincuser_record, 'uid'); |
|
1992 | + $community_role = array_search('community member', user_roles(true)); |
|
1993 | + if (!isset($account->roles[$community_role])) { |
|
1994 | 1994 | $account->roles[$community_role] = 'community member'; |
1995 | 1995 | user_save($account, array('roles' => $account->roles)); |
1996 | - } |
|
1996 | + } |
|
1997 | 1997 | } |
1998 | 1998 | break; |
1999 | - default: |
|
1999 | + default: |
|
2000 | 2000 | } |
2001 | - drupal_goto("account/{$account->uid}"); |
|
2001 | + drupal_goto("account/{$account->uid}"); |
|
2002 | 2002 | } |
2003 | 2003 | |
2004 | 2004 | /** |
@@ -2006,29 +2006,29 @@ discard block |
||
2006 | 2006 | * moderation flag. |
2007 | 2007 | */ |
2008 | 2008 | function boincuser_moderate_profile_approve($account) { |
2009 | - $node = new stdClass; |
|
2010 | - $node->type = 'profile'; |
|
2011 | - $node->language = ''; |
|
2012 | - $nid = content_profile_profile_exists($node, $account->uid); |
|
2013 | - $profile = node_load($nid); |
|
2014 | - $profile->moderate = 0; |
|
2015 | - $profile->status = 1; |
|
2016 | - node_save($profile); |
|
2017 | - drupal_set_message('This profile has been marked as approved.'); |
|
2018 | - drupal_goto(); |
|
2009 | + $node = new stdClass; |
|
2010 | + $node->type = 'profile'; |
|
2011 | + $node->language = ''; |
|
2012 | + $nid = content_profile_profile_exists($node, $account->uid); |
|
2013 | + $profile = node_load($nid); |
|
2014 | + $profile->moderate = 0; |
|
2015 | + $profile->status = 1; |
|
2016 | + node_save($profile); |
|
2017 | + drupal_set_message('This profile has been marked as approved.'); |
|
2018 | + drupal_goto(); |
|
2019 | 2019 | } |
2020 | 2020 | |
2021 | 2021 | /** |
2022 | 2022 | * Mark a user profile as rejected and notify the user of the reason. |
2023 | 2023 | */ |
2024 | 2024 | function boincuser_moderate_profile_reject($uid, $reason = '') { |
2025 | - $account = user_load($uid); |
|
2026 | - $node = new stdClass; |
|
2027 | - $node->type = 'profile'; |
|
2028 | - $node->language = ''; |
|
2029 | - $nid = content_profile_profile_exists($node, $uid); |
|
2030 | - $profile = node_load($nid); |
|
2031 | - if ($profile->nid) { |
|
2025 | + $account = user_load($uid); |
|
2026 | + $node = new stdClass; |
|
2027 | + $node->type = 'profile'; |
|
2028 | + $node->language = ''; |
|
2029 | + $nid = content_profile_profile_exists($node, $uid); |
|
2030 | + $profile = node_load($nid); |
|
2031 | + if ($profile->nid) { |
|
2032 | 2032 | global $user; |
2033 | 2033 | global $base_url; |
2034 | 2034 | global $base_path; |
@@ -2039,64 +2039,64 @@ discard block |
||
2039 | 2039 | $profile->status = 0; |
2040 | 2040 | node_save($profile); |
2041 | 2041 | $settings = array( |
2042 | - 'from' => '', |
|
2043 | - 'subject' => "Profile moderation at {$site_name}", |
|
2044 | - 'message' => '' |
|
2045 | - . "{$account->boincuser_name},\n" |
|
2046 | - . "\n" |
|
2047 | - . "{$moderator->boincuser_name} has rejected your profile at" |
|
2048 | - . " {$site_name} for the following reason: \n" |
|
2049 | - . "\n" |
|
2050 | - . "{$reason}\n" |
|
2051 | - . "\n" |
|
2052 | - . "\n" |
|
2053 | - . "Since it has not been approved, your profile is not visible to other" |
|
2054 | - . " {$site_name} users. Please make the needed changes here:\n" |
|
2055 | - . "\n" |
|
2056 | - . "{$site_url}account/profile \n" |
|
2057 | - . "\n" |
|
2058 | - . "Thanks, \n" |
|
2059 | - . "\n" |
|
2060 | - . "{$site_name} support team", |
|
2042 | + 'from' => '', |
|
2043 | + 'subject' => "Profile moderation at {$site_name}", |
|
2044 | + 'message' => '' |
|
2045 | + . "{$account->boincuser_name},\n" |
|
2046 | + . "\n" |
|
2047 | + . "{$moderator->boincuser_name} has rejected your profile at" |
|
2048 | + . " {$site_name} for the following reason: \n" |
|
2049 | + . "\n" |
|
2050 | + . "{$reason}\n" |
|
2051 | + . "\n" |
|
2052 | + . "\n" |
|
2053 | + . "Since it has not been approved, your profile is not visible to other" |
|
2054 | + . " {$site_name} users. Please make the needed changes here:\n" |
|
2055 | + . "\n" |
|
2056 | + . "{$site_url}account/profile \n" |
|
2057 | + . "\n" |
|
2058 | + . "Thanks, \n" |
|
2059 | + . "\n" |
|
2060 | + . "{$site_name} support team", |
|
2061 | 2061 | ); |
2062 | 2062 | rules_action_mail_to_user($account, $settings); |
2063 | 2063 | drupal_set_message('This profile has been marked as rejected.'); |
2064 | - } |
|
2065 | - drupal_goto(); |
|
2064 | + } |
|
2065 | + drupal_goto(); |
|
2066 | 2066 | } |
2067 | 2067 | |
2068 | 2068 | /** |
2069 | 2069 | * Ban a user and send a notification of the reason. |
2070 | 2070 | */ |
2071 | 2071 | function boincuser_moderate_user_ban($uid, $reason = '', $duration = '') { |
2072 | - if (user_access('assign community member role') |
|
2072 | + if (user_access('assign community member role') |
|
2073 | 2073 | OR user_access('assign all roles')) { |
2074 | 2074 | $account = user_load($uid); |
2075 | 2075 | if ($account->uid) { |
2076 | - module_load_include('inc', 'rules', 'modules/system.rules'); |
|
2077 | - if ($duration === '') { |
|
2076 | + module_load_include('inc', 'rules', 'modules/system.rules'); |
|
2077 | + if ($duration === '') { |
|
2078 | 2078 | $duration = variable_get('boinc_penalty_period', 7*24*60*60); |
2079 | - } |
|
2080 | - $penalty_expiration = ($duration > 0) ? time() + $duration : 4294967295; |
|
2081 | - $boincuser_record = array( |
|
2079 | + } |
|
2080 | + $penalty_expiration = ($duration > 0) ? time() + $duration : 4294967295; |
|
2081 | + $boincuser_record = array( |
|
2082 | 2082 | 'uid' => $uid, |
2083 | 2083 | 'penalty_expiration' => $penalty_expiration, |
2084 | - ); |
|
2085 | - drupal_write_record('boincuser', $boincuser_record, 'uid'); |
|
2084 | + ); |
|
2085 | + drupal_write_record('boincuser', $boincuser_record, 'uid'); |
|
2086 | 2086 | |
2087 | - $community_role = array_search('community member', user_roles(true)); |
|
2088 | - if (isset($account->roles[$community_role])) { |
|
2087 | + $community_role = array_search('community member', user_roles(true)); |
|
2088 | + if (isset($account->roles[$community_role])) { |
|
2089 | 2089 | unset($account->roles[$community_role]); |
2090 | 2090 | user_save($account, array('roles' => $account->roles)); |
2091 | - } |
|
2091 | + } |
|
2092 | 2092 | |
2093 | - global $user; |
|
2094 | - global $base_url; |
|
2095 | - global $base_path; |
|
2096 | - $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
2097 | - $site_url = $base_url . $base_path; |
|
2098 | - $moderator = user_load($user->uid); |
|
2099 | - $settings = array( |
|
2093 | + global $user; |
|
2094 | + global $base_url; |
|
2095 | + global $base_path; |
|
2096 | + $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
2097 | + $site_url = $base_url . $base_path; |
|
2098 | + $moderator = user_load($user->uid); |
|
2099 | + $settings = array( |
|
2100 | 2100 | 'from' => '', |
2101 | 2101 | 'subject' => "User moderation at {$site_name}", |
2102 | 2102 | 'message' => '' |
@@ -2117,12 +2117,12 @@ discard block |
||
2117 | 2117 | . "Thanks, \n" |
2118 | 2118 | . "\n" |
2119 | 2119 | . "{$site_name} support team", |
2120 | - ); |
|
2121 | - rules_action_mail_to_user($account, $settings); |
|
2122 | - drupal_set_message('This user has been banned.'); |
|
2120 | + ); |
|
2121 | + rules_action_mail_to_user($account, $settings); |
|
2122 | + drupal_set_message('This user has been banned.'); |
|
2123 | 2123 | } |
2124 | - } |
|
2125 | - drupal_goto(); |
|
2124 | + } |
|
2125 | + drupal_goto(); |
|
2126 | 2126 | } |
2127 | 2127 | |
2128 | 2128 | |
@@ -2134,15 +2134,15 @@ discard block |
||
2134 | 2134 | * |
2135 | 2135 | */ |
2136 | 2136 | function boincuser_get_weak_auth($boinc_id = null) { |
2137 | - if (!$boinc_id) { |
|
2137 | + if (!$boinc_id) { |
|
2138 | 2138 | global $user; |
2139 | 2139 | $account = user_load($user->uid); |
2140 | 2140 | $boinc_id = $account->boincuser_id; |
2141 | - } |
|
2141 | + } |
|
2142 | 2142 | |
2143 | - $boinc_user = boincuser_load($account->boincuser_id); |
|
2143 | + $boinc_user = boincuser_load($account->boincuser_id); |
|
2144 | 2144 | |
2145 | - return weak_auth($boinc_user); |
|
2145 | + return weak_auth($boinc_user); |
|
2146 | 2146 | } |
2147 | 2147 | |
2148 | 2148 | /** |
@@ -2151,75 +2151,75 @@ discard block |
||
2151 | 2151 | * Drupal User so must be inserted into comments, etc. (not so by default) |
2152 | 2152 | */ |
2153 | 2153 | function boincuser_get_user_profile_image($uid, $avatar = TRUE) { |
2154 | - // Though the function name implies otherwise, get the avatar by default |
|
2155 | - $image_field = ($avatar) ? 'field_image_fid' : 'field_profile_image_fid'; |
|
2156 | - $image_fid = db_result(db_query(" |
|
2154 | + // Though the function name implies otherwise, get the avatar by default |
|
2155 | + $image_field = ($avatar) ? 'field_image_fid' : 'field_profile_image_fid'; |
|
2156 | + $image_fid = db_result(db_query(" |
|
2157 | 2157 | SELECT ctp.%s |
2158 | 2158 | FROM {content_type_profile} ctp |
2159 | 2159 | INNER JOIN {node} n ON ctp.nid = n.nid |
2160 | 2160 | WHERE n.uid = %d AND n.type = '%s'", |
2161 | 2161 | $image_field, $uid, 'profile')); |
2162 | - $user_image['image'] = field_file_load($image_fid); |
|
2163 | - if (!$user_image['image']['filepath']) { |
|
2162 | + $user_image['image'] = field_file_load($image_fid); |
|
2163 | + if (!$user_image['image']['filepath']) { |
|
2164 | 2164 | // Load the default image if one does not exist |
2165 | 2165 | $account = user_load($uid); |
2166 | 2166 | if ($avatar AND module_exists('gravatar') AND user_access('use gravatar', $account) AND $account->gravatar) { |
2167 | - // Use a Gravatar rather than the system default image |
|
2168 | - $options = array( |
|
2167 | + // Use a Gravatar rather than the system default image |
|
2168 | + $options = array( |
|
2169 | 2169 | 'size' => 100, |
2170 | 2170 | 'rating' => 'G', |
2171 | - ); |
|
2172 | - // Get the Gravatar URL and see if the image exists |
|
2173 | - $url = gravatar_get_gravatar($account->mail, $options); |
|
2174 | - $headers = @get_headers($url); |
|
2175 | - if (preg_match("|200|", $headers[0])) { |
|
2171 | + ); |
|
2172 | + // Get the Gravatar URL and see if the image exists |
|
2173 | + $url = gravatar_get_gravatar($account->mail, $options); |
|
2174 | + $headers = @get_headers($url); |
|
2175 | + if (preg_match("|200|", $headers[0])) { |
|
2176 | 2176 | return $url; |
2177 | - } |
|
2177 | + } |
|
2178 | 2178 | } |
2179 | 2179 | // Get default image if nothing else works |
2180 | 2180 | $content_node_widget_settings = db_result(db_query("SELECT widget_settings FROM {content_node_field_instance} WHERE field_name = '%s'", ($avatar ? 'field_image' : 'field_profile_image'))); |
2181 | 2181 | $content_node_widget_settings = unserialize($content_node_widget_settings); |
2182 | 2182 | $user_image['image'] = $content_node_widget_settings['default_image']; |
2183 | - } |
|
2184 | - $user = user_load($uid); |
|
2185 | - // Use boinc username for image alt/title attributes |
|
2186 | - $user_image['alt'] = $user->boincuser_name; |
|
2187 | - return $user_image; |
|
2183 | + } |
|
2184 | + $user = user_load($uid); |
|
2185 | + // Use boinc username for image alt/title attributes |
|
2186 | + $user_image['alt'] = $user->boincuser_name; |
|
2187 | + return $user_image; |
|
2188 | 2188 | } |
2189 | 2189 | |
2190 | 2190 | /** |
2191 | 2191 | * Generate a table of a user's projects |
2192 | 2192 | */ |
2193 | 2193 | function boincuser_get_projects_table($account = null) { |
2194 | - if ($account AND is_numeric($account)) { |
|
2194 | + if ($account AND is_numeric($account)) { |
|
2195 | 2195 | $account = user_load($account); |
2196 | - } |
|
2197 | - $projects = boincuser_get_projects($account); |
|
2198 | - if (!$projects) return bts('no projects...', array(), NULL, 'boinc:account-dashboard'); |
|
2196 | + } |
|
2197 | + $projects = boincuser_get_projects($account); |
|
2198 | + if (!$projects) return bts('no projects...', array(), NULL, 'boinc:account-dashboard'); |
|
2199 | 2199 | |
2200 | - $output = ''; |
|
2201 | - $output .= '<table class="user-projects">' . "\n"; |
|
2202 | - $output .= '<thead>' . "\n"; |
|
2203 | - $output .= ' <tr>' . "\n"; |
|
2204 | - $output .= ' <th>' . bts('Name', array(), NULL, 'boinc:project-name:-1:ignoreoverwrite') . '</th>' . "\n"; |
|
2205 | - $output .= ' <th class="numeric">' . bts('Avg credit', array(), NULL, 'boinc:account-dashboard') . '</th>' . "\n"; |
|
2206 | - $output .= ' <th class="numeric">' . bts('Total credit', array(), NULL, 'boinc:user-or-team-total-credits') . '</th>' . "\n"; |
|
2207 | - $output .= ' </tr>' . "\n"; |
|
2208 | - $output .= '</thead>' . "\n"; |
|
2209 | - $output .= '<tbody>' . "\n"; |
|
2210 | - foreach ($projects AS $project) { |
|
2200 | + $output = ''; |
|
2201 | + $output .= '<table class="user-projects">' . "\n"; |
|
2202 | + $output .= '<thead>' . "\n"; |
|
2203 | + $output .= ' <tr>' . "\n"; |
|
2204 | + $output .= ' <th>' . bts('Name', array(), NULL, 'boinc:project-name:-1:ignoreoverwrite') . '</th>' . "\n"; |
|
2205 | + $output .= ' <th class="numeric">' . bts('Avg credit', array(), NULL, 'boinc:account-dashboard') . '</th>' . "\n"; |
|
2206 | + $output .= ' <th class="numeric">' . bts('Total credit', array(), NULL, 'boinc:user-or-team-total-credits') . '</th>' . "\n"; |
|
2207 | + $output .= ' </tr>' . "\n"; |
|
2208 | + $output .= '</thead>' . "\n"; |
|
2209 | + $output .= '<tbody>' . "\n"; |
|
2210 | + foreach ($projects AS $project) { |
|
2211 | 2211 | $url = rtrim($project->url, '/') . '/show_user.php?userid=' . $project->id; |
2212 | 2212 | $output .= ' <tr>' . "\n"; |
2213 | 2213 | $output .= ' <td>' . l($project->name, $url) . '</td>' . "\n"; |
2214 | 2214 | $output .= ' <td class="numeric">' . boincwork_format_stats((float) $project->expavg_credit) . '</td>' . "\n"; |
2215 | 2215 | $output .= ' <td class="numeric">' . boincwork_format_stats((float) $project->total_credit) . '</td>' . "\n"; |
2216 | 2216 | $output .= ' </tr>' . "\n"; |
2217 | - } |
|
2218 | - $output .= '</tbody>' . "\n"; |
|
2219 | - $output .= '</table>' . "\n"; |
|
2220 | - $more_link = ($account) ? "user/{$account->uid}/stats" : 'account/stats'; |
|
2221 | - //$output .= "<div class=\"more-link\"><a href=\"{$more_link}\">More stats</a></div>" . "\n"; |
|
2222 | - return $output; |
|
2217 | + } |
|
2218 | + $output .= '</tbody>' . "\n"; |
|
2219 | + $output .= '</table>' . "\n"; |
|
2220 | + $more_link = ($account) ? "user/{$account->uid}/stats" : 'account/stats'; |
|
2221 | + //$output .= "<div class=\"more-link\"><a href=\"{$more_link}\">More stats</a></div>" . "\n"; |
|
2222 | + return $output; |
|
2223 | 2223 | } |
2224 | 2224 | |
2225 | 2225 | /** |
@@ -2227,25 +2227,25 @@ discard block |
||
2227 | 2227 | */ |
2228 | 2228 | function boincuser_get_stats_user_data($cpid = null) { |
2229 | 2229 | |
2230 | - // [TODO] Set this stuff in site config! |
|
2231 | - $stats_server = 'stats.gridrepublic.org'; |
|
2232 | - $stats_rpc = 'rpc/get_user.php'; |
|
2230 | + // [TODO] Set this stuff in site config! |
|
2231 | + $stats_server = 'stats.gridrepublic.org'; |
|
2232 | + $stats_rpc = 'rpc/get_user.php'; |
|
2233 | 2233 | |
2234 | - // Construct query string |
|
2235 | - $get = array( |
|
2234 | + // Construct query string |
|
2235 | + $get = array( |
|
2236 | 2236 | 'cpid' => $cpid |
2237 | - ); |
|
2238 | - $args = array(); |
|
2239 | - foreach ($get as $arg => $value) $args[] = "{$arg}=" . rawurlencode($value); |
|
2240 | - $query = '?' . implode('&', $args); |
|
2237 | + ); |
|
2238 | + $args = array(); |
|
2239 | + foreach ($get as $arg => $value) $args[] = "{$arg}=" . rawurlencode($value); |
|
2240 | + $query = '?' . implode('&', $args); |
|
2241 | 2241 | |
2242 | - // Load XML from RPC |
|
2243 | - $target_url = "http://{$stats_server}/{$stats_rpc}{$query}"; |
|
2244 | - $result = drupal_http_request($target_url); |
|
2245 | - if (in_array($result->code, array(200, 304)) || in_array($result->redirect_code, array(200, 304))) { |
|
2242 | + // Load XML from RPC |
|
2243 | + $target_url = "http://{$stats_server}/{$stats_rpc}{$query}"; |
|
2244 | + $result = drupal_http_request($target_url); |
|
2245 | + if (in_array($result->code, array(200, 304)) || in_array($result->redirect_code, array(200, 304))) { |
|
2246 | 2246 | return simplexml_load_string($result->data); |
2247 | - } |
|
2248 | - return NULL; |
|
2247 | + } |
|
2248 | + return NULL; |
|
2249 | 2249 | } |
2250 | 2250 | |
2251 | 2251 | /** |
@@ -2253,15 +2253,15 @@ discard block |
||
2253 | 2253 | */ |
2254 | 2254 | function boincuser_get_projects($account = null) { |
2255 | 2255 | |
2256 | - // Use the current user by default |
|
2257 | - if (!$account) { |
|
2256 | + // Use the current user by default |
|
2257 | + if (!$account) { |
|
2258 | 2258 | global $user; |
2259 | 2259 | $account = user_load($user->uid); |
2260 | - } |
|
2260 | + } |
|
2261 | 2261 | |
2262 | - $account_stats = boincuser_get_stats_user_data($account->boincuser_cpid); |
|
2262 | + $account_stats = boincuser_get_stats_user_data($account->boincuser_cpid); |
|
2263 | 2263 | |
2264 | - return ($account_stats AND isset($account_stats->project)) ? $account_stats->project : null; |
|
2264 | + return ($account_stats AND isset($account_stats->project)) ? $account_stats->project : null; |
|
2265 | 2265 | } |
2266 | 2266 | |
2267 | 2267 | |
@@ -2269,11 +2269,11 @@ discard block |
||
2269 | 2269 | * Get the links to display under the user profile |
2270 | 2270 | */ |
2271 | 2271 | function boincuser_get_profile_links($uid) { |
2272 | - global $user; |
|
2273 | - $account = user_load($uid); |
|
2274 | - $profile = content_profile_load('profile', $account->uid); |
|
2275 | - $output = ''; |
|
2276 | - if ($profile) { |
|
2272 | + global $user; |
|
2273 | + $account = user_load($uid); |
|
2274 | + $profile = content_profile_load('profile', $account->uid); |
|
2275 | + $output = ''; |
|
2276 | + if ($profile) { |
|
2277 | 2277 | $profile_is_approved = ($profile->status AND !$profile->moderate); |
2278 | 2278 | $user_is_moderator = user_access('edit any profile content'); |
2279 | 2279 | $is_own_profile = ($user->uid == $account->uid); |
@@ -2281,15 +2281,15 @@ discard block |
||
2281 | 2281 | $links = array(); |
2282 | 2282 | |
2283 | 2283 | if ($profile->moderate AND $user_is_moderator) { |
2284 | - $links['approve_profile'] = array( |
|
2284 | + $links['approve_profile'] = array( |
|
2285 | 2285 | 'title' => bts('Approve profile', array(), NULL, 'boinc:moderate-user'), |
2286 | 2286 | 'href' => "{$profile_moderation_path}/approve", |
2287 | 2287 | 'attributes' => array( |
2288 | - 'title' => bts('Approve this profile content', array(), NULL, 'boinc:moderate-user'), |
|
2289 | - 'class' => 'first primary tab', |
|
2288 | + 'title' => bts('Approve this profile content', array(), NULL, 'boinc:moderate-user'), |
|
2289 | + 'class' => 'first primary tab', |
|
2290 | 2290 | ) |
2291 | - ); |
|
2292 | - /*$links['edit_profile'] = array( |
|
2291 | + ); |
|
2292 | + /*$links['edit_profile'] = array( |
|
2293 | 2293 | 'title' => bts('Edit profile', array(), NULL, 'boinc:moderate-user'), |
2294 | 2294 | 'href' => "{$profile_moderation_path}/edit", |
2295 | 2295 | 'attributes' => array( |
@@ -2297,27 +2297,27 @@ discard block |
||
2297 | 2297 | 'class' => 'tab', |
2298 | 2298 | ) |
2299 | 2299 | );*/ |
2300 | - $links['reject_profile'] = array( |
|
2300 | + $links['reject_profile'] = array( |
|
2301 | 2301 | 'title' => bts('Reject profile', array(), NULL, 'boinc:moderate-user'), |
2302 | 2302 | 'href' => "{$profile_moderation_path}/reject", |
2303 | 2303 | 'attributes' => array( |
2304 | - 'title' => bts('Reject this profile content', array(), NULL, 'boinc:moderate-user'), |
|
2305 | - 'class' => 'tab', |
|
2304 | + 'title' => bts('Reject this profile content', array(), NULL, 'boinc:moderate-user'), |
|
2305 | + 'class' => 'tab', |
|
2306 | 2306 | ) |
2307 | - ); |
|
2307 | + ); |
|
2308 | 2308 | } |
2309 | 2309 | $output .= '<ul class="tab-list">'; |
2310 | 2310 | $count = 0; |
2311 | 2311 | foreach ($links as $key => $link) { |
2312 | - $output .= '<li class="' . (($count == 0) ? 'first primary ' : '') . 'tab">'; |
|
2313 | - $output .= l($link['title'], $link['href'], array('query' => drupal_get_destination())); |
|
2314 | - $output .= '</li>'; |
|
2315 | - $count++; |
|
2312 | + $output .= '<li class="' . (($count == 0) ? 'first primary ' : '') . 'tab">'; |
|
2313 | + $output .= l($link['title'], $link['href'], array('query' => drupal_get_destination())); |
|
2314 | + $output .= '</li>'; |
|
2315 | + $count++; |
|
2316 | 2316 | } |
2317 | 2317 | $output .= '<li class="' . (($count) ? '' : 'first ') . 'last tab">' . flag_create_link('abuse_user_meta', $account->uid) . '</li>'; |
2318 | 2318 | $output .= '</ul>'; |
2319 | - } |
|
2320 | - return $output; |
|
2319 | + } |
|
2320 | + return $output; |
|
2321 | 2321 | /* |
2322 | 2322 | <ul class="tab-list"> |
2323 | 2323 | <li class="primary first tab"> |
@@ -2354,36 +2354,36 @@ discard block |
||
2354 | 2354 | */ |
2355 | 2355 | function boincuser_apachesolr_index_documents_alter(array &$documents, $entity, $entity_type, $env_id) { |
2356 | 2356 | |
2357 | - foreach ($documents as $document) { |
|
2357 | + foreach ($documents as $document) { |
|
2358 | 2358 | if ( $document->entity_type=='node' AND $document->bundle=='profile' ) { |
2359 | - // Node information. |
|
2360 | - $nid = $document->entity_id; |
|
2361 | - $node = node_load($nid); |
|
2362 | - $account = user_load($node->uid); |
|
2363 | - |
|
2364 | - // Use boincuser name and not drupal user name |
|
2365 | - $document->label = apachesolr_clean_text($account->boincuser_name); |
|
2366 | - // Author information |
|
2367 | - if ($node->uid == 0 || strlen($node->name) == 0) { |
|
2359 | + // Node information. |
|
2360 | + $nid = $document->entity_id; |
|
2361 | + $node = node_load($nid); |
|
2362 | + $account = user_load($node->uid); |
|
2363 | + |
|
2364 | + // Use boincuser name and not drupal user name |
|
2365 | + $document->label = apachesolr_clean_text($account->boincuser_name); |
|
2366 | + // Author information |
|
2367 | + if ($node->uid == 0 || strlen($node->name) == 0) { |
|
2368 | 2368 | // @see user_validate_name(). !'0' === TRUE. |
2369 | 2369 | $document->ss_name = '0'; |
2370 | - } |
|
2371 | - else { |
|
2370 | + } |
|
2371 | + else { |
|
2372 | 2372 | $document->ss_name = $account->boincuser_name; |
2373 | 2373 | // We want the name to be searchable for keywords. |
2374 | 2374 | $document->tos_name = $account->boincuser_name; |
2375 | - } |
|
2375 | + } |
|
2376 | 2376 | |
2377 | - // Rename "Profle" to "User" |
|
2378 | - $document->bundle = "User"; |
|
2379 | - $document->bundle_name = "User"; |
|
2377 | + // Rename "Profle" to "User" |
|
2378 | + $document->bundle = "User"; |
|
2379 | + $document->bundle_name = "User"; |
|
2380 | 2380 | |
2381 | - // Replace the Solr document's created field with the date the user |
|
2382 | - // account was created. This replaces the node creation date typically |
|
2383 | - // used for indexing nodes. |
|
2384 | - $document->ds_created = apachesolr_date_iso($account->created); |
|
2381 | + // Replace the Solr document's created field with the date the user |
|
2382 | + // account was created. This replaces the node creation date typically |
|
2383 | + // used for indexing nodes. |
|
2384 | + $document->ds_created = apachesolr_date_iso($account->created); |
|
2385 | + } |
|
2385 | 2386 | } |
2386 | - } |
|
2387 | 2387 | |
2388 | 2388 | } |
2389 | 2389 | |
@@ -2395,23 +2395,23 @@ discard block |
||
2395 | 2395 | * Implementation of hook_privatemsg_name_lookup(); |
2396 | 2396 | */ |
2397 | 2397 | function boincuser_privatemsg_name_lookup($string) { |
2398 | - // Get the BOINC ID from the name string, and lookup the |
|
2399 | - // corresponding drupal user. |
|
2400 | - $boincname = substr($string, 0, strrpos($string, '_')); |
|
2401 | - $boincid = substr($string, strrpos($string, '_') + 1); |
|
2402 | - $drupalid = get_drupal_id($boincid); |
|
2403 | - |
|
2404 | - // Name has spaced replaced with special UTF-8 characters in |
|
2405 | - // privatemsg module. We need to convert them back to spaces for the |
|
2406 | - // check below. |
|
2407 | - $boincname = preg_replace("/\\xc2\\xa0/", " ", $boincname); |
|
2408 | - if ($drupalid>0) { |
|
2398 | + // Get the BOINC ID from the name string, and lookup the |
|
2399 | + // corresponding drupal user. |
|
2400 | + $boincname = substr($string, 0, strrpos($string, '_')); |
|
2401 | + $boincid = substr($string, strrpos($string, '_') + 1); |
|
2402 | + $drupalid = get_drupal_id($boincid); |
|
2403 | + |
|
2404 | + // Name has spaced replaced with special UTF-8 characters in |
|
2405 | + // privatemsg module. We need to convert them back to spaces for the |
|
2406 | + // check below. |
|
2407 | + $boincname = preg_replace("/\\xc2\\xa0/", " ", $boincname); |
|
2408 | + if ($drupalid>0) { |
|
2409 | 2409 | if ($recipient = user_load(array('uid' => $drupalid))) { |
2410 | - // Double-check that the loaded user matches both boincuser_id |
|
2411 | - // and boincuser_name. |
|
2412 | - if ( ($boincid == $recipient->boincuser_id) AND ($boincname == $recipient->boincuser_name) ) { |
|
2410 | + // Double-check that the loaded user matches both boincuser_id |
|
2411 | + // and boincuser_name. |
|
2412 | + if ( ($boincid == $recipient->boincuser_id) AND ($boincname == $recipient->boincuser_name) ) { |
|
2413 | 2413 | return $recipient; |
2414 | - } |
|
2414 | + } |
|
2415 | + } |
|
2415 | 2416 | } |
2416 | - } |
|
2417 | 2417 | } |
@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | * The definition of the create team form |
15 | 15 | */ |
16 | 16 | function boincteam_create_form(&$form_state) { |
17 | - $form = array(); |
|
17 | + $form = array(); |
|
18 | 18 | |
19 | - $default = array( |
|
19 | + $default = array( |
|
20 | 20 | 'name' => '', |
21 | 21 | 'name_html' => '', |
22 | 22 | 'website' => '', |
@@ -24,105 +24,105 @@ discard block |
||
24 | 24 | 'country' => 0, |
25 | 25 | 'joinable' => TRUE, |
26 | 26 | 'description' => '', |
27 | - ); |
|
27 | + ); |
|
28 | 28 | |
29 | - // Standard option sets |
|
30 | - $form['boolean_options'] = array( |
|
29 | + // Standard option sets |
|
30 | + $form['boolean_options'] = array( |
|
31 | 31 | '#type' => 'value', |
32 | 32 | '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')), |
33 | - ); |
|
33 | + ); |
|
34 | 34 | |
35 | - // Vocabulary based option sets |
|
36 | - $form['type_options'] = array( |
|
35 | + // Vocabulary based option sets |
|
36 | + $form['type_options'] = array( |
|
37 | 37 | '#type' => 'value', |
38 | 38 | '#value' => array(0 => bts('Choose type', array(), NULL, 'boinc:form-choose')) |
39 | - ); |
|
40 | - $vocabs = taxonomy_get_vocabularies(NULL); |
|
41 | - foreach ($vocabs as $vocab) { |
|
39 | + ); |
|
40 | + $vocabs = taxonomy_get_vocabularies(NULL); |
|
41 | + foreach ($vocabs as $vocab) { |
|
42 | 42 | switch ($vocab->name) { |
43 | 43 | case 'Teams': |
44 | 44 | $team_types = taxonomy_get_tree($vocab->vid); |
45 | - if (module_exists('internationalization')) { |
|
45 | + if (module_exists('internationalization')) { |
|
46 | 46 | $team_types = i18ntaxonomy_localize_terms($team_types); |
47 | - } |
|
48 | - foreach ($team_types as $team_type) { |
|
47 | + } |
|
48 | + foreach ($team_types as $team_type) { |
|
49 | 49 | $form['type_options']['#value'][$team_type->tid] = $team_type->name; |
50 | - } |
|
51 | - break; |
|
50 | + } |
|
51 | + break; |
|
52 | 52 | default: |
53 | 53 | } |
54 | - } |
|
55 | - $form['country_options'] = array( |
|
54 | + } |
|
55 | + $form['country_options'] = array( |
|
56 | 56 | '#type' => 'value', |
57 | 57 | '#value' => boinccore_get_country_list(), |
58 | - ); |
|
58 | + ); |
|
59 | 59 | |
60 | - // Form elements |
|
61 | - $form['name'] = array( |
|
60 | + // Form elements |
|
61 | + $form['name'] = array( |
|
62 | 62 | '#title' => bts('Team name', array(), NULL, 'boinc:team-create/edit'), |
63 | 63 | '#type' => 'textfield', |
64 | 64 | '#default_value' => $default['name'], |
65 | 65 | '#size' => 34, |
66 | 66 | '#description' => bts('Text only, no HTML tags', array(), NULL, 'boinc:team-form-help'), |
67 | - ); |
|
68 | - $form['name_html'] = array( |
|
67 | + ); |
|
68 | + $form['name_html'] = array( |
|
69 | 69 | '#title' => bts('Team name -- HTML version (optional)', array(), NULL, 'boinc:team-create/edit'), |
70 | 70 | '#type' => 'textfield', |
71 | 71 | '#default_value' => $default['name_html'], |
72 | 72 | '#size' => 34, |
73 | 73 | '#description' => bts('You may use limited HTML tags', array(), NULL, 'boinc:team-form-help'), |
74 | - ); |
|
75 | - $form['website'] = array( |
|
74 | + ); |
|
75 | + $form['website'] = array( |
|
76 | 76 | '#title' => bts('Team website (optional)', array(), NULL, 'boinc:team-create/edit'), |
77 | 77 | '#type' => 'textfield', |
78 | 78 | '#default_value' => $default['website'], |
79 | 79 | '#size' => 34, |
80 | 80 | '#description' => bts("Displayed on the team's page", array(), NULL, 'boinc:team-create/edit'), |
81 | - ); |
|
82 | - $form['type'] = array( |
|
81 | + ); |
|
82 | + $form['type'] = array( |
|
83 | 83 | '#title' => bts('Type of team', array(), NULL, 'boinc:team-create/edit'), |
84 | 84 | '#type' => 'select', |
85 | 85 | '#options' => $form['type_options']['#value'], |
86 | 86 | '#default_value' => $default['type'], |
87 | - ); |
|
88 | - $form['country'] = array( |
|
87 | + ); |
|
88 | + $form['country'] = array( |
|
89 | 89 | '#title' => bts('Country', array(), NULL, 'boinc:country-of-origin'), |
90 | 90 | '#type' => 'select', |
91 | 91 | '#options' => $form['country_options']['#value'], |
92 | 92 | '#default_value' => $default['country'], |
93 | - ); |
|
94 | - $form['joinable'] = array( |
|
93 | + ); |
|
94 | + $form['joinable'] = array( |
|
95 | 95 | '#title' => bts('Accept new members?', array(), NULL, 'boinc:team-create/edit'), |
96 | 96 | '#type' => 'radios', |
97 | 97 | '#options' => $form['boolean_options']['#value'], |
98 | 98 | '#attributes' => array('class' => 'fancy'), |
99 | 99 | '#default_value' => $default['joinable'], |
100 | 100 | '#size' => 34, |
101 | - ); |
|
102 | - $form['description'] = array( |
|
101 | + ); |
|
102 | + $form['description'] = array( |
|
103 | 103 | '#title' => bts('Description of team', array(), NULL, 'boinc:team-create/edit'), |
104 | 104 | '#type' => 'textarea', |
105 | 105 | '#default_value' => $default['description'], |
106 | 106 | '#size' => 5, |
107 | 107 | '#description' => NULL, |
108 | - ); |
|
109 | - $form['format'] = filter_form(); |
|
108 | + ); |
|
109 | + $form['format'] = filter_form(); |
|
110 | 110 | |
111 | - // Form control |
|
112 | - $form['form control tabs prefix'] = array( |
|
111 | + // Form control |
|
112 | + $form['form control tabs prefix'] = array( |
|
113 | 113 | '#value' => '<ul class="form-control tab-list">' |
114 | - ); |
|
115 | - $form['submit'] = array( |
|
114 | + ); |
|
115 | + $form['submit'] = array( |
|
116 | 116 | '#prefix' => '<li class="first tab">', |
117 | 117 | '#type' => 'submit', |
118 | 118 | '#value' => bts('Save team', array(), NULL, 'boinc:team-form-save'), |
119 | 119 | '#suffix' => '</li>', |
120 | - ); |
|
121 | - $form['form control tabs'] = array( |
|
120 | + ); |
|
121 | + $form['form control tabs'] = array( |
|
122 | 122 | '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>' |
123 | - ); |
|
123 | + ); |
|
124 | 124 | |
125 | - return $form; |
|
125 | + return $form; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -130,41 +130,41 @@ discard block |
||
130 | 130 | */ |
131 | 131 | function boincteam_create_form_validate($form, &$form_state) { |
132 | 132 | |
133 | - $values = $form_state['values']; |
|
134 | - $name = $values['name']; |
|
133 | + $values = $form_state['values']; |
|
134 | + $name = $values['name']; |
|
135 | 135 | |
136 | - if (!$name) { |
|
136 | + if (!$name) { |
|
137 | 137 | form_set_error('name', bts('Team name is required.', array(), NULL, 'boinc:team-create/edit')); |
138 | - } |
|
139 | - else { |
|
138 | + } |
|
139 | + else { |
|
140 | 140 | require_boinc('boinc_db'); |
141 | 141 | if (BoincTeam::lookup_name($name)) { |
142 | - form_set_error('name', bts('A team named "@name" already exists.', |
|
142 | + form_set_error('name', bts('A team named "@name" already exists.', |
|
143 | 143 | array('@name' => $name), NULL, 'boinc:team-create/edit')); |
144 | 144 | } |
145 | - } |
|
145 | + } |
|
146 | 146 | |
147 | - if (!$values['type'] OR !isset($values['type_options'][$values['type']])) { |
|
147 | + if (!$values['type'] OR !isset($values['type_options'][$values['type']])) { |
|
148 | 148 | form_set_error('type', bts('Please select a team type.', array(), NULL, 'boinc:team-create/edit')); |
149 | - } |
|
149 | + } |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
153 | 153 | * The create team submit handler |
154 | 154 | */ |
155 | 155 | function boincteam_create_form_submit($form, &$form_state) { |
156 | - global $user; |
|
157 | - $account = user_load($user->uid); |
|
158 | - $values = $form_state['values']; |
|
159 | - //drupal_set_message('<pre>' . print_r($values,true) . '</pre>'); |
|
156 | + global $user; |
|
157 | + $account = user_load($user->uid); |
|
158 | + $values = $form_state['values']; |
|
159 | + //drupal_set_message('<pre>' . print_r($values,true) . '</pre>'); |
|
160 | 160 | |
161 | - $input_format = !empty($values['format']) ? $values['format'] : 4; |
|
162 | - $values['description'] = check_markup($values['description'], $input_format); |
|
161 | + $input_format = !empty($values['format']) ? $values['format'] : 4; |
|
162 | + $values['description'] = check_markup($values['description'], $input_format); |
|
163 | 163 | |
164 | - // Create the team in the BOINC db |
|
164 | + // Create the team in the BOINC db |
|
165 | 165 | |
166 | - require_boinc(array('user','team')); |
|
167 | - $boinc_team = make_team( |
|
166 | + require_boinc(array('user','team')); |
|
167 | + $boinc_team = make_team( |
|
168 | 168 | $account->boincuser_id, |
169 | 169 | $values['name'], |
170 | 170 | $values['website'], |
@@ -172,27 +172,27 @@ discard block |
||
172 | 172 | $values['name_html'], |
173 | 173 | $values['description'], |
174 | 174 | $values['country'] |
175 | - ); |
|
175 | + ); |
|
176 | 176 | |
177 | - if ($boinc_team) { |
|
177 | + if ($boinc_team) { |
|
178 | 178 | $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
179 | 179 | user_join_team($boinc_team, $boinc_user); |
180 | - } |
|
181 | - else { |
|
180 | + } |
|
181 | + else { |
|
182 | 182 | drupal_set_message(t('Teams cannot be created at this time. The @project administrators have been notified.', array('@project' => PROJECT))); |
183 | 183 | rules_invoke_event('boincteam_create_team_error', $values['name'], variable_get('boinc_admin_mailing_list_subject_tag', '')); |
184 | 184 | watchdog('BOINC team', 'BOINC teams cannot be created for an unknown |
185 | 185 | reason.', 'error'); |
186 | 186 | return FALSE; |
187 | - } |
|
187 | + } |
|
188 | 188 | |
189 | - // Create the team node in Drupal |
|
189 | + // Create the team node in Drupal |
|
190 | 190 | |
191 | - $teaser = node_teaser($values['description']); |
|
192 | - $created_time = time(); |
|
193 | - $input_format = variable_get('filter_default_format', 1); |
|
191 | + $teaser = node_teaser($values['description']); |
|
192 | + $created_time = time(); |
|
193 | + $input_format = variable_get('filter_default_format', 1); |
|
194 | 194 | |
195 | - $node = array( |
|
195 | + $node = array( |
|
196 | 196 | 'type' => 'team', |
197 | 197 | 'title' => $values['name'], |
198 | 198 | 'body' => $values['description'], |
@@ -206,21 +206,21 @@ discard block |
||
206 | 206 | 'moderate' => 0, |
207 | 207 | 'sticky' => 0, |
208 | 208 | 'format' => $input_format |
209 | - ); |
|
209 | + ); |
|
210 | 210 | |
211 | - // Use pathauto function, if available, to clean up the path |
|
212 | - if (module_exists('pathauto')) { |
|
211 | + // Use pathauto function, if available, to clean up the path |
|
212 | + if (module_exists('pathauto')) { |
|
213 | 213 | module_load_include('inc', 'pathauto', 'pathauto'); |
214 | 214 | $node['path'] = pathauto_cleanstring($values['name']); |
215 | - } |
|
216 | - else { |
|
215 | + } |
|
216 | + else { |
|
217 | 217 | drupal_set_message(t('Teams cannot be created at this time. The @project administrators have been notified.', array('@project' => PROJECT))); |
218 | 218 | rules_invoke_event('boincteam_create_team_nopathauto_error', $values['name'], variable_get('boinc_admin_mailing_list_subject_tag', '')); |
219 | 219 | watchdog('BOINC team', 'BOINC teams require the Pathauto module. Teams |
220 | 220 | cannot be created.', 'error'); |
221 | - } |
|
221 | + } |
|
222 | 222 | |
223 | - /* |
|
223 | + /* |
|
224 | 224 | // Add special organic group properties |
225 | 225 | $node['og_description'] = strip_tags($boincteam->description); |
226 | 226 | $node['og_selective'] = OG_OPEN; |
@@ -229,26 +229,26 @@ discard block |
||
229 | 229 | $node['og_private'] = 0; |
230 | 230 | */ |
231 | 231 | |
232 | - $node = (object) $node; // node_save requires an object form |
|
232 | + $node = (object) $node; // node_save requires an object form |
|
233 | 233 | |
234 | - /* |
|
234 | + /* |
|
235 | 235 | $node->field_description[]['value'] = $boincteam->description; |
236 | 236 | $node->field_url[]['value'] = $boincteam->url; |
237 | 237 | $node->field_country[]['value'] = $boincteam->country; |
238 | 238 | */ |
239 | 239 | |
240 | - $node->taxonomy[] = taxonomy_get_term($values['type']); |
|
240 | + $node->taxonomy[] = taxonomy_get_term($values['type']); |
|
241 | 241 | |
242 | - // Save the team node |
|
243 | - node_save($node); |
|
242 | + // Save the team node |
|
243 | + node_save($node); |
|
244 | 244 | |
245 | - // Save the team IDs to a BOINC <--> Drupal reference table. |
|
246 | - db_query('INSERT INTO {boincteam} (team_id, nid) VALUES (%d, %d)', $boinc_team->id, $node->nid); |
|
245 | + // Save the team IDs to a BOINC <--> Drupal reference table. |
|
246 | + db_query('INSERT INTO {boincteam} (team_id, nid) VALUES (%d, %d)', $boinc_team->id, $node->nid); |
|
247 | 247 | |
248 | - drupal_set_message(t('Team "@name" has been created.', |
|
248 | + drupal_set_message(t('Team "@name" has been created.', |
|
249 | 249 | array('@name' => $values['name']))); |
250 | 250 | |
251 | - $form_state['redirect'] = "community/teams/{$node->nid}"; |
|
251 | + $form_state['redirect'] = "community/teams/{$node->nid}"; |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -259,17 +259,17 @@ discard block |
||
259 | 259 | * The definition of the edit team form |
260 | 260 | */ |
261 | 261 | function boincteam_edit_form(&$form_state, $team_id) { |
262 | - $form = array(); |
|
262 | + $form = array(); |
|
263 | 263 | |
264 | - $team = node_load($team_id); |
|
265 | - $boincteam = boincteam_load(boincteam_lookup_id($team_id)); |
|
264 | + $team = node_load($team_id); |
|
265 | + $boincteam = boincteam_load(boincteam_lookup_id($team_id)); |
|
266 | 266 | |
267 | - $is_boinc_wide = ($boincteam->seti_id > 0) ? TRUE : FALSE; |
|
267 | + $is_boinc_wide = ($boincteam->seti_id > 0) ? TRUE : FALSE; |
|
268 | 268 | |
269 | - $form_state['storage']['team_id'] = $team_id; |
|
270 | - $form_state['storage']['is_boinc_wide'] = $is_boinc_wide; |
|
269 | + $form_state['storage']['team_id'] = $team_id; |
|
270 | + $form_state['storage']['is_boinc_wide'] = $is_boinc_wide; |
|
271 | 271 | |
272 | - $default = array( |
|
272 | + $default = array( |
|
273 | 273 | 'name' => $boincteam->name, |
274 | 274 | 'name_html' => $boincteam->name_html, |
275 | 275 | 'website' => $boincteam->url, |
@@ -277,79 +277,79 @@ discard block |
||
277 | 277 | 'country' => $boincteam->country, |
278 | 278 | 'joinable' => $boincteam->joinable, |
279 | 279 | 'description' => $boincteam->description, |
280 | - ); |
|
280 | + ); |
|
281 | 281 | |
282 | - // Standard option sets |
|
283 | - $form['boolean_options'] = array( |
|
282 | + // Standard option sets |
|
283 | + $form['boolean_options'] = array( |
|
284 | 284 | '#type' => 'value', |
285 | 285 | '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')), |
286 | - ); |
|
286 | + ); |
|
287 | 287 | |
288 | - // Vocabulary based option sets |
|
289 | - $form['type_options'] = array( |
|
288 | + // Vocabulary based option sets |
|
289 | + $form['type_options'] = array( |
|
290 | 290 | '#type' => 'value', |
291 | 291 | '#value' => array(0 => bts('Choose type', array(), NULL, 'boinc:form-choose')) |
292 | - ); |
|
293 | - $vocabs = taxonomy_get_vocabularies(NULL); |
|
294 | - foreach ($vocabs as $vocab) { |
|
292 | + ); |
|
293 | + $vocabs = taxonomy_get_vocabularies(NULL); |
|
294 | + foreach ($vocabs as $vocab) { |
|
295 | 295 | switch ($vocab->name) { |
296 | 296 | case 'Teams': |
297 | 297 | $team_types = taxonomy_get_tree($vocab->vid); |
298 | - if (module_exists('internationalization')) { |
|
298 | + if (module_exists('internationalization')) { |
|
299 | 299 | $team_types = i18ntaxonomy_localize_terms($team_types); |
300 | - } |
|
301 | - foreach ($team_types as $team_type) { |
|
300 | + } |
|
301 | + foreach ($team_types as $team_type) { |
|
302 | 302 | $form['type_options']['#value'][$team_type->tid] = $team_type->name; |
303 | - } |
|
304 | - break; |
|
303 | + } |
|
304 | + break; |
|
305 | 305 | default: |
306 | 306 | } |
307 | - } |
|
308 | - $form['country_options'] = array( |
|
307 | + } |
|
308 | + $form['country_options'] = array( |
|
309 | 309 | '#type' => 'value', |
310 | 310 | '#value' => boinccore_get_country_list(), |
311 | - ); |
|
311 | + ); |
|
312 | 312 | |
313 | - // Form elements |
|
314 | - $form['name'] = array( |
|
313 | + // Form elements |
|
314 | + $form['name'] = array( |
|
315 | 315 | '#title' => bts('Team name', array(), NULL, 'boinc:team-create/edit'), |
316 | 316 | '#type' => 'textfield', |
317 | 317 | '#default_value' => $default['name'], |
318 | 318 | '#size' => 34, |
319 | 319 | '#description' => bts('Text only, no HTML tags', array(), NULL, 'boinc:team-form-help'), |
320 | 320 | '#disabled' => $is_boinc_wide, |
321 | - ); |
|
322 | - $form['name_html'] = array( |
|
321 | + ); |
|
322 | + $form['name_html'] = array( |
|
323 | 323 | '#title' => bts('Team name -- HTML version (optional)', array(), NULL, 'boinc:team-create/edit'), |
324 | 324 | '#type' => 'textfield', |
325 | 325 | '#default_value' => $default['name_html'], |
326 | 326 | '#size' => 34, |
327 | 327 | '#description' => bts('You may use limited HTML tags', array(), NULL, 'boinc:team-form-help'), |
328 | 328 | '#disabled' => $is_boinc_wide, |
329 | - ); |
|
330 | - $form['website'] = array( |
|
329 | + ); |
|
330 | + $form['website'] = array( |
|
331 | 331 | '#title' => bts('Team website (optional)', array(), NULL, 'boinc:team-create/edit'), |
332 | 332 | '#type' => 'textfield', |
333 | 333 | '#default_value' => $default['website'], |
334 | 334 | '#size' => 34, |
335 | 335 | '#description' => bts("Displayed on the team's page", array(), NULL, 'boinc:team-create/edit'), |
336 | 336 | '#disabled' => $is_boinc_wide, |
337 | - ); |
|
338 | - $form['type'] = array( |
|
337 | + ); |
|
338 | + $form['type'] = array( |
|
339 | 339 | '#title' => bts('Type of team', array(), NULL, 'boinc:team-create/edit'), |
340 | 340 | '#type' => 'select', |
341 | 341 | '#options' => $form['type_options']['#value'], |
342 | 342 | '#default_value' => $default['type'], |
343 | 343 | '#disabled' => $is_boinc_wide, |
344 | - ); |
|
345 | - $form['country'] = array( |
|
344 | + ); |
|
345 | + $form['country'] = array( |
|
346 | 346 | '#title' => bts('Country', array(), NULL, 'boinc:country-of-origin'), |
347 | 347 | '#type' => 'select', |
348 | 348 | '#options' => $form['country_options']['#value'], |
349 | 349 | '#default_value' => $default['country'], |
350 | 350 | '#disabled' => $is_boinc_wide, |
351 | - ); |
|
352 | - $form['joinable'] = array( |
|
351 | + ); |
|
352 | + $form['joinable'] = array( |
|
353 | 353 | '#title' => bts('Accept new members?', array(), NULL, 'boinc:team-create/edit'), |
354 | 354 | '#type' => 'radios', |
355 | 355 | '#options' => $form['boolean_options']['#value'], |
@@ -357,49 +357,49 @@ discard block |
||
357 | 357 | '#default_value' => $default['joinable'], |
358 | 358 | '#size' => 34, |
359 | 359 | '#disabled' => $is_boinc_wide, |
360 | - ); |
|
361 | - if (!$is_boinc_wide) { |
|
360 | + ); |
|
361 | + if (!$is_boinc_wide) { |
|
362 | 362 | $form['description'] = array( |
363 | - '#title' => bts('Description of team', array(), NULL, 'boinc:team-create/edit'), |
|
364 | - '#type' => 'textarea', |
|
365 | - '#default_value' => $default['description'], |
|
366 | - '#size' => 5, |
|
367 | - '#description' => NULL, |
|
363 | + '#title' => bts('Description of team', array(), NULL, 'boinc:team-create/edit'), |
|
364 | + '#type' => 'textarea', |
|
365 | + '#default_value' => $default['description'], |
|
366 | + '#size' => 5, |
|
367 | + '#description' => NULL, |
|
368 | 368 | ); |
369 | 369 | $form['format'] = filter_form(); |
370 | 370 | |
371 | 371 | // Form control |
372 | 372 | $form['form control tabs prefix'] = array( |
373 | - '#value' => '<ul class="form-control tab-list">' |
|
373 | + '#value' => '<ul class="form-control tab-list">' |
|
374 | 374 | ); |
375 | 375 | $form['submit'] = array( |
376 | - '#prefix' => '<li class="first tab">', |
|
377 | - '#type' => 'submit', |
|
378 | - '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'), |
|
379 | - '#suffix' => '</li>', |
|
376 | + '#prefix' => '<li class="first tab">', |
|
377 | + '#type' => 'submit', |
|
378 | + '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'), |
|
379 | + '#suffix' => '</li>', |
|
380 | 380 | ); |
381 | 381 | $form['form control tabs'] = array( |
382 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), strstr($_GET['q'], '/edit', TRUE)) . '</li>' |
|
382 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), strstr($_GET['q'], '/edit', TRUE)) . '</li>' |
|
383 | 383 | ); |
384 | - } |
|
385 | - else { |
|
384 | + } |
|
385 | + else { |
|
386 | 386 | $form['description'] = array( |
387 | - '#prefix' => '<div class="form-item"><label>' . bts('Description', array(), NULL, 'boinc:team-description') . ':</label></div><div class="form-item">', |
|
388 | - '#value' => $default['description'], |
|
389 | - '#suffix' => '</div>', |
|
387 | + '#prefix' => '<div class="form-item"><label>' . bts('Description', array(), NULL, 'boinc:team-description') . ':</label></div><div class="form-item">', |
|
388 | + '#value' => $default['description'], |
|
389 | + '#suffix' => '</div>', |
|
390 | 390 | ); |
391 | 391 | drupal_set_message( |
392 | - bts('This is a BOINC-wide team. Changes can be made at the !site.', |
|
392 | + bts('This is a BOINC-wide team. Changes can be made at the !site.', |
|
393 | 393 | array('!site' => l(bts('BOINC-wide teams site', array(), NULL, 'boinc:link-to-BOINC-wide-teams-Website'), |
394 | - 'http://boinc.berkeley.edu/teams/' |
|
394 | + 'http://boinc.berkeley.edu/teams/' |
|
395 | 395 | )), |
396 | 396 | NULL, 'boinc:team-edit-warning-message'), |
397 | - 'warning'); |
|
398 | - } |
|
397 | + 'warning'); |
|
398 | + } |
|
399 | 399 | |
400 | - $form['#redirect'] = "community/teams/{$team_id}"; |
|
400 | + $form['#redirect'] = "community/teams/{$team_id}"; |
|
401 | 401 | |
402 | - return $form; |
|
402 | + return $form; |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | /** |
@@ -407,32 +407,32 @@ discard block |
||
407 | 407 | */ |
408 | 408 | function boincteam_edit_form_validate($form, &$form_state) { |
409 | 409 | |
410 | - $values = $form_state['values']; |
|
411 | - $name = $values['name']; |
|
410 | + $values = $form_state['values']; |
|
411 | + $name = $values['name']; |
|
412 | 412 | |
413 | - if ($form_state['storage']['is_boinc_wide']) { |
|
413 | + if ($form_state['storage']['is_boinc_wide']) { |
|
414 | 414 | form_set_error('none', bts('This team is managed by the BOINC-wide teams system and cannot be updated here.', array(), NULL, 'boinc:team-create/edit')); |
415 | - } |
|
416 | - else { |
|
415 | + } |
|
416 | + else { |
|
417 | 417 | if (!$name) { |
418 | - form_set_error('name', bts('Team name is required.', array(), NULL, 'boinc:team-create/edit')); |
|
418 | + form_set_error('name', bts('Team name is required.', array(), NULL, 'boinc:team-create/edit')); |
|
419 | 419 | } |
420 | 420 | else { |
421 | - $team = node_load($form_state['storage']['team_id']); |
|
422 | - if ($name != $team->title) { |
|
421 | + $team = node_load($form_state['storage']['team_id']); |
|
422 | + if ($name != $team->title) { |
|
423 | 423 | // If changing the name ("title" in Drupal terms), check that the new name is available |
424 | 424 | require_boinc('boinc_db'); |
425 | 425 | if (BoincTeam::lookup_name($name)) { |
426 | - form_set_error('name', bts('A team named "@name" already exists.', |
|
426 | + form_set_error('name', bts('A team named "@name" already exists.', |
|
427 | 427 | array('@name' => $name), NULL, 'boinc:team-create/edit')); |
428 | 428 | } |
429 | - } |
|
429 | + } |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | if (!$values['type'] OR !isset($values['type_options'][$values['type']])) { |
433 | - form_set_error('type', bts('Please select a team type.', array(), NULL, 'boinc:team-create/edit')); |
|
433 | + form_set_error('type', bts('Please select a team type.', array(), NULL, 'boinc:team-create/edit')); |
|
434 | + } |
|
434 | 435 | } |
435 | - } |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | /** |
@@ -440,18 +440,18 @@ discard block |
||
440 | 440 | */ |
441 | 441 | function boincteam_edit_form_submit($form, &$form_state) { |
442 | 442 | |
443 | - $team_id = $form_state['storage']['team_id']; |
|
444 | - $values = $form_state['values']; |
|
443 | + $team_id = $form_state['storage']['team_id']; |
|
444 | + $values = $form_state['values']; |
|
445 | 445 | |
446 | - $team = node_load($team_id); |
|
447 | - $boincteam_id = boincteam_lookup_id($team_id); |
|
446 | + $team = node_load($team_id); |
|
447 | + $boincteam_id = boincteam_lookup_id($team_id); |
|
448 | 448 | |
449 | - $input_format = !empty($values['format']) ? $values['format'] : 4; |
|
450 | - $values['description'] = check_markup($values['description'], $input_format); |
|
449 | + $input_format = !empty($values['format']) ? $values['format'] : 4; |
|
450 | + $values['description'] = check_markup($values['description'], $input_format); |
|
451 | 451 | |
452 | - // Update the team in the BOINC db |
|
453 | - db_set_active('boinc_rw'); |
|
454 | - db_query(" |
|
452 | + // Update the team in the BOINC db |
|
453 | + db_set_active('boinc_rw'); |
|
454 | + db_query(" |
|
455 | 455 | UPDATE {team} SET |
456 | 456 | name = '%s', |
457 | 457 | name_lc = '%s', |
@@ -471,32 +471,32 @@ discard block |
||
471 | 471 | $values['country'], |
472 | 472 | $values['joinable'], |
473 | 473 | $boincteam_id |
474 | - ); |
|
475 | - db_set_active('default'); |
|
474 | + ); |
|
475 | + db_set_active('default'); |
|
476 | 476 | |
477 | - // Update the team node in Drupal |
|
477 | + // Update the team node in Drupal |
|
478 | 478 | |
479 | - $team->title = $values['name']; |
|
480 | - $team->body = $values['description']; |
|
481 | - $team->teaser = node_teaser($values['description']); |
|
479 | + $team->title = $values['name']; |
|
480 | + $team->body = $values['description']; |
|
481 | + $team->teaser = node_teaser($values['description']); |
|
482 | 482 | |
483 | - /* |
|
483 | + /* |
|
484 | 484 | $node->field_description[]['value'] = $boincteam->description; |
485 | 485 | $node->field_url[]['value'] = $boincteam->url; |
486 | 486 | $node->field_country[]['value'] = $boincteam->country; |
487 | 487 | */ |
488 | 488 | |
489 | - // Replace any existing taxonomy with the new one |
|
490 | - $team->taxonomy = array(taxonomy_get_term($values['type'])); |
|
489 | + // Replace any existing taxonomy with the new one |
|
490 | + $team->taxonomy = array(taxonomy_get_term($values['type'])); |
|
491 | 491 | |
492 | - // Save the team node |
|
493 | - node_save($team); |
|
492 | + // Save the team node |
|
493 | + node_save($team); |
|
494 | 494 | |
495 | - drupal_set_message(t('Details for "@team" have been updated.', |
|
495 | + drupal_set_message(t('Details for "@team" have been updated.', |
|
496 | 496 | array('@team' => $values['name']))); |
497 | 497 | |
498 | - // The storage variable quietly kills redirection for some reason... unset it |
|
499 | - unset($form_state['storage']); |
|
498 | + // The storage variable quietly kills redirection for some reason... unset it |
|
499 | + unset($form_state['storage']); |
|
500 | 500 | } |
501 | 501 | |
502 | 502 | |
@@ -508,44 +508,44 @@ discard block |
||
508 | 508 | * The definition of the add team admin form |
509 | 509 | */ |
510 | 510 | function boincteam_add_admin_form(&$form_state, $team_id) { |
511 | - $form = array(); |
|
511 | + $form = array(); |
|
512 | 512 | |
513 | - $team = node_load($team_id); |
|
514 | - $boincteam = boincteam_load(boincteam_lookup_id($team_id)); |
|
513 | + $team = node_load($team_id); |
|
514 | + $boincteam = boincteam_load(boincteam_lookup_id($team_id)); |
|
515 | 515 | |
516 | - $form_state['storage']['team_id'] = $team_id; |
|
516 | + $form_state['storage']['team_id'] = $team_id; |
|
517 | 517 | |
518 | - $default = array( |
|
518 | + $default = array( |
|
519 | 519 | 'username' => '', |
520 | - ); |
|
520 | + ); |
|
521 | 521 | |
522 | - // Form elements |
|
523 | - $form['username'] = array( |
|
522 | + // Form elements |
|
523 | + $form['username'] = array( |
|
524 | 524 | '#title' => bts('Enter BOINC username', array(), NULL, 'boinc:team--add-admin'), |
525 | 525 | '#description' => bts('The number appearing in the suffix is the BOINC id. You can find a user\'s BOINC id on their user profile page.'), |
526 | 526 | '#type' => 'textfield', |
527 | 527 | '#default_value' => $default['username'], |
528 | 528 | '#size' => 34, |
529 | 529 | '#autocomplete_path' => "community/teams/${team_id}/user-name-autocomplete", |
530 | - ); |
|
530 | + ); |
|
531 | 531 | |
532 | - // Form control |
|
533 | - $form['form control tabs prefix'] = array( |
|
532 | + // Form control |
|
533 | + $form['form control tabs prefix'] = array( |
|
534 | 534 | '#value' => '<ul class="form-control tab-list">' |
535 | - ); |
|
536 | - $form['submit'] = array( |
|
535 | + ); |
|
536 | + $form['submit'] = array( |
|
537 | 537 | '#prefix' => '<li class="first tab">', |
538 | 538 | '#type' => 'submit', |
539 | 539 | '#value' => bts('Add', array(), NULL, 'boinc:form-add'), |
540 | 540 | '#suffix' => '</li>', |
541 | - ); |
|
542 | - $form['form control tabs'] = array( |
|
541 | + ); |
|
542 | + $form['form control tabs'] = array( |
|
543 | 543 | '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), strstr($_GET['q'], '/edit', TRUE)) . '</li>' |
544 | - ); |
|
544 | + ); |
|
545 | 545 | |
546 | - //$form['#redirect'] = "community/teams/{$team_id}"; |
|
546 | + //$form['#redirect'] = "community/teams/{$team_id}"; |
|
547 | 547 | |
548 | - return $form; |
|
548 | + return $form; |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | /** |
@@ -553,45 +553,45 @@ discard block |
||
553 | 553 | */ |
554 | 554 | function boincteam_add_admin_form_validate($form, &$form_state) { |
555 | 555 | |
556 | - $team_id = $form_state['storage']['team_id']; |
|
557 | - $values = $form_state['values']; |
|
558 | - $team = node_load($team_id); |
|
556 | + $team_id = $form_state['storage']['team_id']; |
|
557 | + $values = $form_state['values']; |
|
558 | + $team = node_load($team_id); |
|
559 | 559 | |
560 | - if (!$values['username']) { |
|
560 | + if (!$values['username']) { |
|
561 | 561 | form_set_error('username', bts('BOINC username is required.', array(), NULL, 'boinc:team-add-admin')); |
562 | - } |
|
563 | - else { |
|
562 | + } |
|
563 | + else { |
|
564 | 564 | // Load user account associated with username |
565 | 565 | $account = boincuser_privatemsg_name_lookup($values['username']); |
566 | 566 | // Validate the account |
567 | 567 | if ((!$account) OR ($account->team != $team_id)) { |
568 | - form_set_error('username', bts('There is no user on your team with name @username.', |
|
568 | + form_set_error('username', bts('There is no user on your team with name @username.', |
|
569 | 569 | array( |
570 | - '@username' => $account->boincuser_name |
|
570 | + '@username' => $account->boincuser_name |
|
571 | 571 | ), |
572 | - NULL, 'boinc:team-add-admin')); |
|
572 | + NULL, 'boinc:team-add-admin')); |
|
573 | 573 | } |
574 | 574 | elseif (boincteam_is_founder($team_id, $account->uid)) { |
575 | - form_set_error('username', bts('@user is the founder of @team! Team founder already have all admin privileges.', |
|
575 | + form_set_error('username', bts('@user is the founder of @team! Team founder already have all admin privileges.', |
|
576 | 576 | array( |
577 | - '@user' => $account->boincuser_name, |
|
578 | - '@team' => $team->title, |
|
577 | + '@user' => $account->boincuser_name, |
|
578 | + '@team' => $team->title, |
|
579 | 579 | ), |
580 | 580 | NULL, 'boinc:team-add-admin')); |
581 | 581 | } |
582 | 582 | elseif (boincteam_is_admin($team_id, $account->uid)) { |
583 | - form_set_error('username', bts('@user is already an admin of @team.', |
|
583 | + form_set_error('username', bts('@user is already an admin of @team.', |
|
584 | 584 | array( |
585 | - '@user' => $account->boincuser_name, |
|
586 | - '@team' => $team->title, |
|
585 | + '@user' => $account->boincuser_name, |
|
586 | + '@team' => $team->title, |
|
587 | 587 | ), |
588 | 588 | NULL, 'boinc:team-add-admin')); |
589 | 589 | } |
590 | 590 | else { |
591 | - $form_state['storage']['boincuser_id'] = $account->boincuser_id; |
|
592 | - $form_state['storage']['boincuser_name'] = $account->boincuser_name; |
|
591 | + $form_state['storage']['boincuser_id'] = $account->boincuser_id; |
|
592 | + $form_state['storage']['boincuser_name'] = $account->boincuser_name; |
|
593 | + } |
|
593 | 594 | } |
594 | - } |
|
595 | 595 | } |
596 | 596 | |
597 | 597 | /** |
@@ -599,17 +599,17 @@ discard block |
||
599 | 599 | */ |
600 | 600 | function boincteam_add_admin_form_submit($form, &$form_state) { |
601 | 601 | |
602 | - $team_id = $form_state['storage']['team_id']; |
|
603 | - $boincuser_id = $form_state['storage']['boincuser_id']; |
|
604 | - $user_name = $form_state['storage']['boincuser_name']; |
|
605 | - $values = $form_state['values']; |
|
602 | + $team_id = $form_state['storage']['team_id']; |
|
603 | + $boincuser_id = $form_state['storage']['boincuser_id']; |
|
604 | + $user_name = $form_state['storage']['boincuser_name']; |
|
605 | + $values = $form_state['values']; |
|
606 | 606 | |
607 | - $team = node_load($team_id); |
|
608 | - $boincteam_id = boincteam_lookup_id($team_id); |
|
607 | + $team = node_load($team_id); |
|
608 | + $boincteam_id = boincteam_lookup_id($team_id); |
|
609 | 609 | |
610 | - // Update the team in the BOINC db |
|
611 | - db_set_active('boinc_rw'); |
|
612 | - db_query(" |
|
610 | + // Update the team in the BOINC db |
|
611 | + db_set_active('boinc_rw'); |
|
612 | + db_query(" |
|
613 | 613 | INSERT INTO {team_admin} SET |
614 | 614 | teamid = '%d', |
615 | 615 | userid = '%d', |
@@ -617,17 +617,17 @@ discard block |
||
617 | 617 | $boincteam_id, |
618 | 618 | $boincuser_id, |
619 | 619 | time() |
620 | - ); |
|
621 | - db_set_active('default'); |
|
620 | + ); |
|
621 | + db_set_active('default'); |
|
622 | 622 | |
623 | - // Could assign a role in Drupal here, as needed |
|
623 | + // Could assign a role in Drupal here, as needed |
|
624 | 624 | |
625 | 625 | |
626 | - drupal_set_message(t('@user has been added as an admin.', |
|
626 | + drupal_set_message(t('@user has been added as an admin.', |
|
627 | 627 | array('@user' => $user_name))); |
628 | 628 | |
629 | - // The storage variable quietly kills redirection for some reason... unset it |
|
630 | - unset($form_state['storage']); |
|
629 | + // The storage variable quietly kills redirection for some reason... unset it |
|
630 | + unset($form_state['storage']); |
|
631 | 631 | } |
632 | 632 | |
633 | 633 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -639,80 +639,80 @@ discard block |
||
639 | 639 | * Send all team members an email message function |
640 | 640 | */ |
641 | 641 | function boincteam_sendmessagetoteam(&$form_state, $team_id) { |
642 | - global $user; |
|
643 | - $form = array(); |
|
642 | + global $user; |
|
643 | + $form = array(); |
|
644 | 644 | |
645 | - if (isset($form_state['values'])) { |
|
645 | + if (isset($form_state['values'])) { |
|
646 | 646 | $subject = $form_state['values']['subject']; |
647 | 647 | $body = $form_state['values']['body']; |
648 | - } |
|
649 | - else { |
|
648 | + } |
|
649 | + else { |
|
650 | 650 | $subject = ''; |
651 | 651 | $body = ''; |
652 | - } |
|
652 | + } |
|
653 | 653 | |
654 | - // Title |
|
655 | - $mytitle = bts('Send E-mail To All Team Members', array(), NULL, 'boinc:team-message-form'); |
|
656 | - drupal_set_title($mytitle); |
|
654 | + // Title |
|
655 | + $mytitle = bts('Send E-mail To All Team Members', array(), NULL, 'boinc:team-message-form'); |
|
656 | + drupal_set_title($mytitle); |
|
657 | 657 | |
658 | - $form['emailteam']['header'] = array( |
|
658 | + $form['emailteam']['header'] = array( |
|
659 | 659 | '#value' => '<h1>' . $mytitle . '</h1>', |
660 | 660 | '#weight' => '-10', |
661 | 661 | '#prefix' => "<div id='sendmessageteammembers-header'>", |
662 | 662 | '#suffix' => "</div>", |
663 | - ); |
|
663 | + ); |
|
664 | 664 | |
665 | - $form['emailteam']['instructions'] = array( |
|
665 | + $form['emailteam']['instructions'] = array( |
|
666 | 666 | '#value' => bts('This will send an email to all team members. If a team member has opt-ed out of notification e-mails, they will not receive your message. At the bottom of your message, there will be a link allowing team members to send you a Direct Message. This link is added automatically, you do not need to add it below in the Message box. Your email address will not be shown to the recipients.', array(), NULL, 'boinc:team-message-form'), |
667 | 667 | '#weight' => '-8', |
668 | 668 | '#prefix' => "<div id='sendmessageteammembers-instructions'>", |
669 | 669 | '#suffix' => "</div>", |
670 | - ); |
|
670 | + ); |
|
671 | 671 | |
672 | - // Subject |
|
673 | - $form['emailteam']['subject'] = array( |
|
672 | + // Subject |
|
673 | + $form['emailteam']['subject'] = array( |
|
674 | 674 | '#type' => 'textfield', |
675 | 675 | '#title' => bts('Subject', array(), NULL, 'boinc:team-message-form'), |
676 | 676 | '#size' => 50, |
677 | 677 | '#maxlength' => 255, |
678 | 678 | '#default_value' => $subject, |
679 | 679 | '#weight' => -5, |
680 | - ); |
|
680 | + ); |
|
681 | 681 | |
682 | - // Body |
|
683 | - $form['emailteam']['body'] = array( |
|
682 | + // Body |
|
683 | + $form['emailteam']['body'] = array( |
|
684 | 684 | '#type' => 'textarea', |
685 | 685 | '#title' => bts('Message', array(), NULL, 'boinc:team-message-form'), |
686 | 686 | '#rows' => 8, |
687 | 687 | '#weight' => 0, |
688 | 688 | '#default_value' => $body, |
689 | 689 | '#resizable' => TRUE, |
690 | - ); |
|
690 | + ); |
|
691 | 691 | |
692 | - // checkbox for 'sent to self' |
|
693 | - $form['emailteam']['selfsend'] = array( |
|
692 | + // checkbox for 'sent to self' |
|
693 | + $form['emailteam']['selfsend'] = array( |
|
694 | 694 | '#type' => 'checkbox', |
695 | 695 | '#title' => bts('Check this box if you wish to be sent a copy of your message to your email address.', array(), NULL, 'boinc:team-message-form'), |
696 | 696 | '#weight' => 10, |
697 | 697 | '#prefix' => '<div class="clearfix" id="confirm-checkbox">', |
698 | 698 | '#suffix' => '</div>', |
699 | - ); |
|
699 | + ); |
|
700 | 700 | |
701 | - // Add a captcha to form |
|
702 | - if (module_exists('captcha')) { |
|
701 | + // Add a captcha to form |
|
702 | + if (module_exists('captcha')) { |
|
703 | 703 | $form['register_captcha'] = array( |
704 | 704 | '#type' => 'captcha', |
705 | 705 | '#weight' => 1000, |
706 | 706 | ); |
707 | - } |
|
707 | + } |
|
708 | 708 | |
709 | - // form buttons |
|
710 | - $form['emailteam']['form control tabs prefix'] = array( |
|
709 | + // form buttons |
|
710 | + $form['emailteam']['form control tabs prefix'] = array( |
|
711 | 711 | '#value' => '<ul class="form-control tab-list">', |
712 | 712 | '#weight' => 1000, |
713 | - ); |
|
713 | + ); |
|
714 | 714 | |
715 | - $form['emailteam']['submit'] = array( |
|
715 | + $form['emailteam']['submit'] = array( |
|
716 | 716 | '#type' => 'submit', |
717 | 717 | '#value' => bts('Send message', array(), NULL, 'boinc:form-submit'), |
718 | 718 | '#submit' => array('boincteam_sendmessagetoteam_submit'), |
@@ -720,133 +720,133 @@ discard block |
||
720 | 720 | '#weight' => 1001, |
721 | 721 | '#prefix' => '<li class="first tab">', |
722 | 722 | '#suffix' => '</li>' |
723 | - ); |
|
723 | + ); |
|
724 | 724 | |
725 | - $title = bts('Cancel', array(), NULL, 'boinc:form-cancel'); |
|
726 | - $url = "community/teams/{$team_id}"; |
|
727 | - $form['emailteam']['cancel'] = array( |
|
725 | + $title = bts('Cancel', array(), NULL, 'boinc:form-cancel'); |
|
726 | + $url = "community/teams/{$team_id}"; |
|
727 | + $form['emailteam']['cancel'] = array( |
|
728 | 728 | '#value' => l($title, $url, array('attributes' => array('id' => 'edit-cancel'))), |
729 | 729 | '#weight' => 1005, |
730 | 730 | '#prefix' => '<li class="tab">', |
731 | 731 | '#suffix' => '</li>' |
732 | - ); |
|
732 | + ); |
|
733 | 733 | |
734 | - $form['emailteam']['form control tabs suffix'] = array( |
|
734 | + $form['emailteam']['form control tabs suffix'] = array( |
|
735 | 735 | '#value' => '</ul>', |
736 | 736 | '#weight' => 1010, |
737 | - ); |
|
737 | + ); |
|
738 | 738 | |
739 | - // Add team id information to form_state |
|
740 | - $form['_team_id'] = array( |
|
739 | + // Add team id information to form_state |
|
740 | + $form['_team_id'] = array( |
|
741 | 741 | '#type' => 'value', |
742 | 742 | '#value' => $team_id, |
743 | - ); |
|
743 | + ); |
|
744 | 744 | |
745 | - // Add sender user object to form_state |
|
746 | - $form['_senderuid'] = array( |
|
745 | + // Add sender user object to form_state |
|
746 | + $form['_senderuid'] = array( |
|
747 | 747 | '#type' => 'value', |
748 | 748 | '#value' => $user->uid, |
749 | - ); |
|
749 | + ); |
|
750 | 750 | |
751 | - // redirect after sending message |
|
752 | - $form['#redirect'] = "community/teams/{$team_id}"; |
|
751 | + // redirect after sending message |
|
752 | + $form['#redirect'] = "community/teams/{$team_id}"; |
|
753 | 753 | |
754 | - return $form; |
|
754 | + return $form; |
|
755 | 755 | } |
756 | 756 | |
757 | 757 | /** |
758 | 758 | * Send all team members validation handler |
759 | 759 | */ |
760 | 760 | function boincteam_sendmessagetoteam_validate($form, &$form_state) { |
761 | - $message = $form_state['values']; |
|
762 | - $message['timestamp'] = time(); |
|
763 | - // Avoid subjects which only consist of a space as these can not be clicked. |
|
764 | - $message['subject'] = trim($message['subject']); |
|
761 | + $message = $form_state['values']; |
|
762 | + $message['timestamp'] = time(); |
|
763 | + // Avoid subjects which only consist of a space as these can not be clicked. |
|
764 | + $message['subject'] = trim($message['subject']); |
|
765 | 765 | |
766 | - $trimed_body = trim(truncate_utf8(strip_tags($message['body']), 50, TRUE, TRUE)); |
|
767 | - if (empty($message['subject']) && !empty($trimed_body)) { |
|
766 | + $trimed_body = trim(truncate_utf8(strip_tags($message['body']), 50, TRUE, TRUE)); |
|
767 | + if (empty($message['subject']) && !empty($trimed_body)) { |
|
768 | 768 | $message['subject'] = $trimed_body; |
769 | 769 | $form_state['values']['subject'] = $message['subject']; |
770 | - } |
|
770 | + } |
|
771 | 771 | |
772 | - // Check subject line |
|
773 | - $message['subject'] = trim($message['subject']); |
|
774 | - if (empty($message['subject'])) { |
|
772 | + // Check subject line |
|
773 | + $message['subject'] = trim($message['subject']); |
|
774 | + if (empty($message['subject'])) { |
|
775 | 775 | form_set_error('subject', |
776 | - bts('Not allowed to send a message without subject', array(), NULL, 'boinc:team-message-form') |
|
776 | + bts('Not allowed to send a message without subject', array(), NULL, 'boinc:team-message-form') |
|
777 | 777 | ); |
778 | - } |
|
778 | + } |
|
779 | 779 | |
780 | - // Check body |
|
781 | - if ( ($message['body'] === NULL || $message['body'] === '') ) { |
|
780 | + // Check body |
|
781 | + if ( ($message['body'] === NULL || $message['body'] === '') ) { |
|
782 | 782 | form_set_error('body', |
783 | - bts('Not allowed to send an empty message.', array(), NULL, 'boinc:team-message-form') |
|
783 | + bts('Not allowed to send an empty message.', array(), NULL, 'boinc:team-message-form') |
|
784 | 784 | ); |
785 | - } |
|
785 | + } |
|
786 | 786 | |
787 | - // Check team id |
|
788 | - if (empty($message['_team_id'])) { |
|
787 | + // Check team id |
|
788 | + if (empty($message['_team_id'])) { |
|
789 | 789 | form_set_error('team_id', |
790 | - bts('Error, no team_id supplied.', array(), NULL, 'boinc:team-message-form') |
|
790 | + bts('Error, no team_id supplied.', array(), NULL, 'boinc:team-message-form') |
|
791 | 791 | ); |
792 | - } |
|
792 | + } |
|
793 | 793 | |
794 | - $form_state['validated_built_message'] = $message; |
|
794 | + $form_state['validated_built_message'] = $message; |
|
795 | 795 | } |
796 | 796 | |
797 | 797 | /** |
798 | 798 | * Send all team members submit handler |
799 | 799 | */ |
800 | 800 | function boincteam_sendmessagetoteam_submit($form, &$form_state) { |
801 | - module_load_include('inc', 'rules', 'modules/system.rules'); |
|
802 | - global $base_url; |
|
803 | - global $base_path; |
|
804 | - |
|
805 | - $suid = $form_state['values']['_senderuid']; |
|
806 | - $account = user_load(array('uid' => $suid )); |
|
807 | - $site_url = $base_url . $base_path . "messages/new/" . $suid; |
|
808 | - |
|
809 | - // Form is validated, now send to all team members. Lookup boinc |
|
810 | - // id of all team members, and then use user_load() to load user |
|
811 | - // object. Send message using email. |
|
812 | - // |
|
813 | - $boinc_id = boincteam_lookup_id($form_state['values']['_team_id']); |
|
814 | - // Email addresses, with those who have opt-ed out of notification |
|
815 | - // emails removed. |
|
816 | - $member_emails = _boincteam_emails($boinc_id); |
|
817 | - // Remove sender's email address, unless selfsend is true. |
|
818 | - if ( !$form_state['values']['selfsend'] ) { |
|
801 | + module_load_include('inc', 'rules', 'modules/system.rules'); |
|
802 | + global $base_url; |
|
803 | + global $base_path; |
|
804 | + |
|
805 | + $suid = $form_state['values']['_senderuid']; |
|
806 | + $account = user_load(array('uid' => $suid )); |
|
807 | + $site_url = $base_url . $base_path . "messages/new/" . $suid; |
|
808 | + |
|
809 | + // Form is validated, now send to all team members. Lookup boinc |
|
810 | + // id of all team members, and then use user_load() to load user |
|
811 | + // object. Send message using email. |
|
812 | + // |
|
813 | + $boinc_id = boincteam_lookup_id($form_state['values']['_team_id']); |
|
814 | + // Email addresses, with those who have opt-ed out of notification |
|
815 | + // emails removed. |
|
816 | + $member_emails = _boincteam_emails($boinc_id); |
|
817 | + // Remove sender's email address, unless selfsend is true. |
|
818 | + if ( !$form_state['values']['selfsend'] ) { |
|
819 | 819 | $pos = array_search($account->mail, $member_emails); |
820 | 820 | unset($member_emails[$pos]); |
821 | - } |
|
821 | + } |
|
822 | 822 | |
823 | - // Add link at bottom of body |
|
824 | - $mybody = $form_state['validated_built_message']['body']; |
|
825 | - $mybody .= "\n\n" |
|
826 | - . "To reply to the sender using a Direct Message (DM), please use this link:\n" |
|
827 | - . "${site_url}"; |
|
823 | + // Add link at bottom of body |
|
824 | + $mybody = $form_state['validated_built_message']['body']; |
|
825 | + $mybody .= "\n\n" |
|
826 | + . "To reply to the sender using a Direct Message (DM), please use this link:\n" |
|
827 | + . "${site_url}"; |
|
828 | 828 | |
829 | - // Transform HTML body into plain text |
|
830 | - $mybody = drupal_html_to_text($mybody); |
|
829 | + // Transform HTML body into plain text |
|
830 | + $mybody = drupal_html_to_text($mybody); |
|
831 | 831 | |
832 | - $emailsettings = array( |
|
832 | + $emailsettings = array( |
|
833 | 833 | 'from' => '', |
834 | 834 | 'to' => "webmaster@{$base_url}", |
835 | 835 | 'boincteam_headers' => array( |
836 | - 'Bcc' => implode(', ', $member_emails), |
|
836 | + 'Bcc' => implode(', ', $member_emails), |
|
837 | 837 | ), |
838 | 838 | 'subject' => $form_state['validated_built_message']['subject'], |
839 | 839 | 'message' => $mybody, |
840 | - ); |
|
841 | - rules_action_mail($emailsettings); |
|
840 | + ); |
|
841 | + rules_action_mail($emailsettings); |
|
842 | 842 | |
843 | - $om = bts( |
|
843 | + $om = bts( |
|
844 | 844 | 'Sent your email message to !number team members.', |
845 | 845 | array( '!number' => count($member_emails) ), |
846 | 846 | 'NULL', |
847 | 847 | 'boinc:team-message-sent' |
848 | - ); |
|
849 | - drupal_set_message($om, 'info'); |
|
848 | + ); |
|
849 | + drupal_set_message($om, 'info'); |
|
850 | 850 | |
851 | - $form_state['redirect'] = "community/teams/{$form_state['values']['_team_id']}"; |
|
851 | + $form_state['redirect'] = "community/teams/{$form_state['values']['_team_id']}"; |
|
852 | 852 | } |
@@ -310,9 +310,9 @@ discard block |
||
310 | 310 | $value=null; |
311 | 311 | } |
312 | 312 | if (isset($_GET[$order])) { |
313 | - $order = $_GET[$order]; |
|
313 | + $order = $_GET[$order]; |
|
314 | 314 | } else { |
315 | - $order = null; |
|
315 | + $order = null; |
|
316 | 316 | } |
317 | 317 | if ($value) { |
318 | 318 | if ($order == 'asc') { |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | $res = new StdClass; |
581 | 581 | $res->server_state = $ss; |
582 | 582 | row2(result_server_state_string($res), |
583 | - link_results("$server_state[$ss]", $urlquery,"server_state=$ss", '') |
|
583 | + link_results("$server_state[$ss]", $urlquery,"server_state=$ss", '') |
|
584 | 584 | ); |
585 | 585 | } |
586 | 586 | end_table(); |
@@ -1056,8 +1056,8 @@ discard block |
||
1056 | 1056 | |
1057 | 1057 | function validate_color($validate_state) { |
1058 | 1058 | switch ($validate_state) { |
1059 | - case 1: return '33cc33'; // valid, green |
|
1060 | - case 2: return 'ffa500'; // invalid result, orange |
|
1059 | + case 1: return '33cc33'; // valid, green |
|
1060 | + case 2: return 'ffa500'; // invalid result, orange |
|
1061 | 1061 | } |
1062 | 1062 | return ''; |
1063 | 1063 | } |