1
|
|
|
<?php |
2
|
|
|
// $Id$ |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* @file |
6
|
|
|
* Enable BOINC features related to processing work and credit. |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
11
|
|
|
* Includes that provide supporting functions |
12
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
13
|
|
|
|
14
|
|
|
require_once('includes/boincwork.forms.inc'); |
15
|
|
|
require_once('includes/boincwork.helpers.inc'); |
16
|
|
|
require_once('includes/boincwork.rules.inc'); |
17
|
|
|
|
18
|
|
|
|
19
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
20
|
|
|
* Hooks into core modules |
21
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Implementation of hook_menu(). |
25
|
|
|
*/ |
26
|
|
|
function boincwork_menu() { |
27
|
|
|
require_boinc('util'); |
28
|
|
|
$items['account/prefs'] = array( |
29
|
|
|
'title' => 'Computing', |
30
|
|
|
'description' => '', |
31
|
|
|
'page callback' => 'generalprefs_page', |
32
|
|
|
'access callback' => 'user_is_logged_in', |
33
|
|
|
'type' => MENU_NORMAL_ITEM |
34
|
|
|
); |
35
|
|
|
$items['account/prefs/computing'] = array( |
36
|
|
|
'title' => 'Computing', |
37
|
|
|
'page callback' => 'generalprefs_page', |
38
|
|
|
'access callback' => 'user_is_logged_in', |
39
|
|
|
'type' => MENU_DEFAULT_LOCAL_TASK, |
40
|
|
|
'weight' => 0 |
41
|
|
|
); |
42
|
|
|
$items['account/prefs/project'] = array( |
43
|
|
|
'title' => 'Project', |
44
|
|
|
'page callback' => 'projectprefs_page', |
45
|
|
|
'access callback' => 'user_is_logged_in', |
46
|
|
|
'type' => MENU_LOCAL_TASK, |
47
|
|
|
'weight' => 5 |
48
|
|
|
); |
49
|
|
|
$items['account/prefs/community'] = array( |
50
|
|
|
'title' => 'Community', |
51
|
|
|
'page callback' => 'communityprefs_page', |
52
|
|
|
'access callback' => 'user_is_logged_in', |
53
|
|
|
'type' => MENU_LOCAL_TASK, |
54
|
|
|
'weight' => 10 |
55
|
|
|
); |
56
|
|
|
$items['account/prefs/privacy'] = array( |
57
|
|
|
'title' => 'Privacy', |
58
|
|
|
'page callback' => 'privacyprefs_page', |
59
|
|
|
'access callback' => 'user_is_logged_in', |
60
|
|
|
'type' => MENU_LOCAL_TASK, |
61
|
|
|
'weight' => 15 |
62
|
|
|
); |
63
|
|
|
if (module_exists('ignore_user')) { |
64
|
|
|
$items['account/prefs/privacy/ignore_user/add'] = array( |
65
|
|
|
'title' => 'Add from ignore list', |
66
|
|
|
'description' => 'Add user that you with to ignore to your ignore list.', |
67
|
|
|
'page callback' => 'boincwork_ignore_user_add_user', |
68
|
|
|
'access callback' => 'user_access', |
69
|
|
|
'access arguments' => array('ignore user'), |
70
|
|
|
'type' => MENU_CALLBACK, |
71
|
|
|
); |
72
|
|
|
$items['account/prefs/privacy/ignore_user/remove'] = array( |
73
|
|
|
'title' => 'Remove from ignore list', |
74
|
|
|
'description' => 'Remove user from your ignore list.', |
75
|
|
|
'page callback' => 'boincwork_ignore_user_remove_user', |
76
|
|
|
'access callback' => 'user_access', |
77
|
|
|
'access arguments' => array('ignore user'), |
78
|
|
|
'type' => MENU_CALLBACK, |
79
|
|
|
); |
80
|
|
|
}// endif module_exists |
81
|
|
|
$items['account/certs'] = array( |
82
|
|
|
'title' =>'Account certificate', |
83
|
|
|
'page callback' => 'boincwork_certificates', |
84
|
|
|
'access arguments' => array('access content'), |
85
|
|
|
'type' => MENU_CALLBACK |
86
|
|
|
); |
87
|
|
|
$items['admin/boinc/prefs/general'] = array( |
88
|
|
|
'title' => 'Preferences: General', |
89
|
|
|
'description' => 'Set options for BOINC preference set pages', |
90
|
|
|
'page callback' => 'drupal_get_form', |
91
|
|
|
'page arguments' => array('boincwork_admin_prefs_options_form'), |
92
|
|
|
'access arguments' => array('administer site configuration'), |
93
|
|
|
'type' => MENU_NORMAL_ITEM, |
94
|
|
|
'file' => 'boincwork.admin.inc' |
95
|
|
|
); |
96
|
|
|
$items['admin/boinc/prefs/presets'] = array( |
97
|
|
|
'title' => 'Preferences: Presets', |
98
|
|
|
'description' => 'Set values for BOINC preference set presets.', |
99
|
|
|
'page callback' => 'boincwork_admin_prefs_presets_page', |
100
|
|
|
'access arguments' => array('administer site configuration'), |
101
|
|
|
'type' => MENU_NORMAL_ITEM, |
102
|
|
|
'file' => 'boincwork.admin.inc' |
103
|
|
|
); |
104
|
|
|
$items['admin/boinc/prefs/upload'] = array( |
105
|
|
|
'title' => 'Preferences: Project-specific XML upload', |
106
|
|
|
'description' => 'Upload XML configuration for project specific preferences.', |
107
|
|
|
'page callback' => 'drupal_get_form', |
108
|
|
|
'page arguments' => array('boincwork_admin_prefs_upload_form'), |
109
|
|
|
'access arguments' => array('administer site configuration'), |
110
|
|
|
'type' => MENU_NORMAL_ITEM, |
111
|
|
|
'file' => 'boincwork.admin.inc' |
112
|
|
|
); |
113
|
|
|
$items['host/%/delete'] = array( |
114
|
|
|
'title' => 'Delete host', |
115
|
|
|
'page callback' => 'boincwork_host_delete', |
116
|
|
|
'page arguments' => array(1), |
117
|
|
|
'access callback' => 'user_is_logged_in', |
118
|
|
|
'type' => MENU_CALLBACK, |
119
|
|
|
); |
120
|
|
|
$items['host/%/log'] = array( |
121
|
|
|
'title' => 'Host log', |
122
|
|
|
'page callback' => 'boincwork_host_log', |
123
|
|
|
'page arguments' => array(1), |
124
|
|
|
'access callback' => 'user_is_logged_in', |
125
|
|
|
'type' => MENU_CALLBACK, |
126
|
|
|
); |
127
|
|
|
$items['host/%/merge'] = array( |
128
|
|
|
'title' => 'Merge computer', |
129
|
|
|
'page callback' => 'drupal_get_form', |
130
|
|
|
'page arguments' => array('boincwork_host_merge_form', 1), |
131
|
|
|
'access callback' => 'user_is_logged_in', |
132
|
|
|
'type' => MENU_CALLBACK, |
133
|
|
|
); |
134
|
|
|
$items['host/%/set-venue/%'] = array( |
135
|
|
|
'title' => 'Set host venue', |
136
|
|
|
'page callback' => 'boincwork_host_set_venue', |
137
|
|
|
'page arguments' => array(1,3), |
138
|
|
|
'access callback' => 'user_is_logged_in', |
139
|
|
|
'type' => MENU_CALLBACK, |
140
|
|
|
); |
141
|
|
|
$items['user/%/mobile'] = array( |
142
|
|
|
'title' => 'Mobile stats', |
143
|
|
|
'page callback' => 'boincwork_mobile_stats', |
144
|
|
|
'page arguments' => array(1), |
145
|
|
|
'access callback' => 'user_is_logged_in', |
146
|
|
|
'type' => MENU_CALLBACK |
147
|
|
|
); |
148
|
|
|
$items['server_status.php'] = array( |
149
|
|
|
'title' => 'Server status', |
150
|
|
|
'page callback' => 'boincwork_server_status', |
151
|
|
|
'access arguments' => array('access content'), |
152
|
|
|
'type' => MENU_CALLBACK |
153
|
|
|
); |
154
|
|
|
$items['job_file.php'] = array( |
155
|
|
|
'title' => 'Job file input', |
156
|
|
|
'page callback' => 'boincwork_job_file', |
157
|
|
|
'access arguments' => array('access content'), |
158
|
|
|
'type' => MENU_CALLBACK |
159
|
|
|
); |
160
|
|
|
$items['get_output.php'] = array( |
161
|
|
|
'title' => 'Get output file', |
162
|
|
|
'page callback' => 'boincwork_get_output', |
163
|
|
|
'access arguments' => array('access content'), |
164
|
|
|
'type' => MENU_CALLBACK |
165
|
|
|
); |
166
|
|
|
$items['get_project_config.php'] = array( |
167
|
|
|
'title' => 'Project config', |
168
|
|
|
'page callback' => 'boincwork_get_project_config', |
169
|
|
|
'access arguments' => array('access content'), |
170
|
|
|
'type' => MENU_CALLBACK |
171
|
|
|
); |
172
|
|
|
$items['submit_rpc_handler.php'] = array( |
173
|
|
|
'title' => 'Remote job submission', |
174
|
|
|
'page callback' => 'boincwork_submit_rpc_handler', |
175
|
|
|
'access arguments' => array('access content'), |
176
|
|
|
'type' => MENU_CALLBACK |
177
|
|
|
); |
178
|
|
|
$items['userw.php'] = array( |
179
|
|
|
'title' => 'User WAP', |
180
|
|
|
'page callback' => 'boincwork_user_wap', |
181
|
|
|
'access arguments' => array('access content'), |
182
|
|
|
'type' => MENU_CALLBACK |
183
|
|
|
); |
184
|
|
|
$items['account/tasks/%/%'] = array( |
185
|
|
|
'title' => 'Account Tasks Table', |
186
|
|
|
'description' => '', |
187
|
|
|
'page callback' => 'boincwork_account_task_table', |
188
|
|
|
'page arguments' => array(2,3), |
189
|
|
|
'access arguments' => array('access content'), |
190
|
|
|
'type' => MENU_CALLBACK, |
191
|
|
|
); |
192
|
|
|
$items['host/%/tasks/%/%'] = array( |
193
|
|
|
'title' => 'Host Tasks Table', |
194
|
|
|
'description' => '', |
195
|
|
|
'page callback' => 'boincwork_host_task_table', |
196
|
|
|
'page arguments' => array(1,3,4), |
197
|
|
|
'access arguments' => array('access content'), |
198
|
|
|
'type' => MENU_CALLBACK, |
199
|
|
|
); |
200
|
|
|
// Workunit task table disabled |
201
|
|
|
//$items['workunit/%/tasks/%/%'] = array( |
202
|
|
|
// 'title' => 'Workunit Tasks Table', |
203
|
|
|
// 'description' => '', |
204
|
|
|
// 'page callback' => 'boincwork_workunit_task_table', |
205
|
|
|
// 'page arguments' => array(1,3,4), |
206
|
|
|
// 'access arguments' => array('access content'), |
207
|
|
|
// 'type' => MENU_CALLBACK, |
208
|
|
|
//); |
209
|
|
|
return $items; |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* Implementation of hook_theme(). |
214
|
|
|
*/ |
215
|
|
|
function boincwork_theme() { |
216
|
|
|
return array( |
217
|
|
|
'boincwork_privacyprefs_form' => array( |
218
|
|
|
'arguments' => array('form'), |
219
|
|
|
), |
220
|
|
|
); |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
/** |
224
|
|
|
* Implementation of hook_views_api(). |
225
|
|
|
*/ |
226
|
|
|
function boincwork_views_api() { |
227
|
|
|
return array( |
228
|
|
|
'api' => 2.0, |
229
|
|
|
'path' => drupal_get_path('module', 'boincwork') |
230
|
|
|
); |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
/** |
234
|
|
|
* Implementation of hook_locale(). |
235
|
|
|
*/ |
236
|
|
|
function boincwork_locale($op = 'groups', $group = NULL) { |
237
|
|
|
switch ($op) { |
238
|
|
|
case 'groups': |
239
|
|
|
return array('project' => bts('Project')); |
240
|
|
|
case 'info': |
241
|
|
|
$info['project']['refresh callback'] = 'boincwork_locale_refresh'; |
242
|
|
|
$info['project']['format'] = FALSE; |
243
|
|
|
return $info; |
244
|
|
|
} |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
/** |
248
|
|
|
* Refresh strings. |
249
|
|
|
*/ |
250
|
|
|
function boincwork_locale_refresh() { |
251
|
|
|
// Mimic process of adding project specific prefs to the project preferences |
252
|
|
|
// form -- this parses the prefs XML and calls i18nstrings_update() |
253
|
|
|
$form = array(); |
254
|
|
|
$prefs = array( |
255
|
|
|
'project_specific' => array(), |
256
|
|
|
); |
257
|
|
|
boincwork_add_project_specific_prefs($form, $prefs); |
258
|
|
|
return TRUE; // Meaning it completed with no issues |
259
|
|
|
} |
260
|
|
|
|
261
|
|
|
|
262
|
|
|
/** |
263
|
|
|
* Implementation of hook_privatemsg_message_view_alter |
264
|
|
|
*/ |
265
|
|
|
|
266
|
|
|
function boincwork_privatemsg_message_view_alter(&$vars) { |
267
|
|
|
global $user; |
268
|
|
|
|
269
|
|
|
$author = $vars['message']['author']; |
270
|
|
|
if (!isset($vars['message']['thread_id'])) { |
271
|
|
|
// No thread id, this is probably only a preview |
272
|
|
|
return; |
273
|
|
|
} |
274
|
|
|
$thread_id = $vars['message']['thread_id']; |
275
|
|
|
|
276
|
|
|
if ($user->uid != $author->uid) { |
277
|
|
|
if ($vars['message']['is_blocked']) { |
278
|
|
|
$vars['message_actions']['unignore_user'] = array( |
279
|
|
|
'title' => bts('Stop Ignoring User', array(), NULL, 'boinc:ignore-user-remove'), |
280
|
|
|
'href' => 'account/prefs/privacy/ignore_user/remove/'. $author->uid, |
281
|
|
|
'query' => 'destination=messages/view/' . $thread_id, |
282
|
|
|
); |
283
|
|
|
} |
284
|
|
|
else { |
285
|
|
|
$vars['message_actions']['ignore_user'] = array( |
286
|
|
|
'title' => bts('Ignore User', array(), NULL, 'boinc:ignore-user-add'), |
287
|
|
|
'href' => 'account/prefs/privacy/ignore_user/add/'. $author->uid, |
288
|
|
|
'query' => 'destination=messages/view/' . $thread_id, |
289
|
|
|
); |
290
|
|
|
} |
291
|
|
|
} |
292
|
|
|
} |
293
|
|
|
|
294
|
|
|
/** |
295
|
|
|
* Implementation of hook_cron() |
296
|
|
|
*/ |
297
|
|
|
function boincwork_cron() { |
298
|
|
|
// Delete expired hosts in the BOINC database, host_delete table. |
299
|
|
|
require_boinc('boinc_db'); |
300
|
|
|
$num_deleted = BoincHostDeleted::delete_expired(); |
301
|
|
|
if ($num_deleted>0) { |
302
|
|
|
watchdog('boincwork', "Deleted ${num_deleted} hosts from host_deleted table", WATCHDOG_NOTICE); |
303
|
|
|
} |
304
|
|
|
} |
305
|
|
|
|
306
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
307
|
|
|
* Page callbacks from hook_menu() |
308
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
309
|
|
|
|
310
|
|
|
/** |
311
|
|
|
* General preferences menu callback. |
312
|
|
|
* Called when user goes to edit preferences page |
313
|
|
|
*/ |
314
|
|
|
function generalprefs_page($action = null, $venue = null, $advanced = FALSE) { |
315
|
|
|
|
316
|
|
|
// Keep the venue selected across preference pages |
317
|
|
|
boincwork_select_venue($venue); |
318
|
|
|
|
319
|
|
|
$pref_sets = array('generic', 'home', 'school', 'work'); |
320
|
|
|
$output = null; |
321
|
|
|
// Set the page title |
322
|
|
|
$title = 'Computing'; |
323
|
|
|
drupal_set_title($title); |
324
|
|
|
|
325
|
|
|
switch ($action) { |
326
|
|
|
|
327
|
|
|
case 'clear': |
328
|
|
|
// Remove settings from this preference set |
329
|
|
|
if ($venue AND $venue != 'generic') { |
330
|
|
|
boincwork_save_prefs(NULL, 'general', $venue); |
331
|
|
|
drupal_set_message(t('Settings for the "@name" preference set have been |
332
|
|
|
cleared', array('@name' => ucfirst($venue)))); |
333
|
|
|
// Set the generic preference set as active |
334
|
|
|
$_SESSION['prefs venue'] = 'generic'; |
335
|
|
|
} |
336
|
|
|
drupal_goto(); |
337
|
|
|
break; |
338
|
|
|
|
339
|
|
|
case 'combined': |
340
|
|
|
// Compare preference sets; tabular view |
341
|
|
|
|
342
|
|
|
foreach ($pref_sets as $pref_set) { |
343
|
|
|
$form_state = array(); |
344
|
|
|
$prefs[$pref_set] = drupal_retrieve_form('boincwork_generalprefs_form', $form_state, $pref_set); |
345
|
|
|
drupal_prepare_form('boincwork_generalprefs_form', $prefs[$pref_set], $form_state); |
|
|
|
|
346
|
|
|
} |
347
|
|
|
|
348
|
|
|
$output .= '<p>' . bts('These apply to all BOINC projects in which you participate.', array(), NULL, 'boinc:account-preferences-computing') . '<br/>'; |
349
|
|
|
$output .= bts('On computers attached to multiple projects, the most recently modified preferences will be used.', array(), NULL, 'boinc:account-preferences-computing') . '</p>'; |
350
|
|
|
$output .= '<p>' . bts('Preferences last modified: @mod_time', array('@mod_time' => pretty_time_str($prefs['generic']['prefs']['modified']['#value'])), NULL, 'boinc:account-preferences') . '</p>'; |
351
|
|
|
$output .= '<h2>' . bts('Combined preferences', array(), NULL, 'boinc:account-preferences') . ' ' . l('(' . bts('Switch View', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/computing') . '</h2>'; |
352
|
|
|
|
353
|
|
|
$output .= '<table class="preferences combined">'; |
354
|
|
|
|
355
|
|
|
$prefs_table = boincwork_make_prefs_table($prefs['generic']['prefs']['advanced']); |
356
|
|
|
|
357
|
|
|
foreach ($prefs_table as $category => $section) { |
358
|
|
|
$output .= '<tr class="section-heading">'; |
359
|
|
|
$output .= "<td>{$section['name']}</td>"; |
360
|
|
|
foreach ($pref_sets as $pref_set) { |
361
|
|
|
$output .= '<td>' . $pref_set . '</td>'; |
362
|
|
|
} |
363
|
|
|
$output .= '</tr>'; |
364
|
|
|
foreach ($section['elements'] as $name => $setting) { |
365
|
|
|
// Output the setting name and description, with an ugly exception |
366
|
|
|
// made for preferences with special formatting |
367
|
|
|
$special_map = array( |
368
|
|
|
'start_hour' => 'end_hour', |
369
|
|
|
'net_start_hour'=> 'net_end_hour', |
370
|
|
|
'daily_xfer_limit_mb' => 'daily_xfer_period_days', |
371
|
|
|
); |
372
|
|
|
$special_delimiter = array( |
373
|
|
|
'start_hour' => bts('and', array(), NULL, 'boinc:account-preference'), |
374
|
|
|
'net_start_hour'=> bts('and', array(), NULL, 'boinc:account-preference'), |
375
|
|
|
'daily_xfer_limit_mb' => bts('every', array(), NULL, 'boinc:account-preference'), |
376
|
|
|
); |
377
|
|
|
$special = isset($special_map[$name]); |
378
|
|
|
$very_special = in_array($name, $special_map); |
379
|
|
|
if ($very_special) { |
380
|
|
|
continue; |
381
|
|
|
} |
382
|
|
|
$output .= '<tr>'; |
383
|
|
|
$output .= '<td>'; |
384
|
|
|
$output .= "<div class=\"title\">{$setting['name']}</div>"; |
385
|
|
|
$output .= "<div class=\"description\">{$setting['description']}</div>"; |
386
|
|
|
$output .= '</td>'; |
387
|
|
|
// Output values for each preference set, again with ugly hacks for |
388
|
|
|
// time range preferences |
389
|
|
|
foreach ($pref_sets as $pref_set) { |
390
|
|
|
if (($prefs[$pref_set]) AND |
391
|
|
|
$prefs[$pref_set]['#established'] AND |
392
|
|
|
isset($prefs[$pref_set]['prefs']['advanced'][$category])) { |
393
|
|
|
$pref_setting = $prefs[$pref_set]['prefs']['advanced'][$category][$name]; |
394
|
|
|
$value = isset($pref_setting['#options']) ? $pref_setting['#options'][$pref_setting['#default_value']] : $pref_setting['#default_value']; |
395
|
|
|
if ($value == '') { |
396
|
|
|
$value = '---'; |
397
|
|
|
} |
398
|
|
|
if (!isset($pref_setting['#field_suffix'])) { |
399
|
|
|
$pref_setting['#field_suffix'] = ''; |
400
|
|
|
} |
401
|
|
|
if (!$special) { |
402
|
|
|
$output .= "<td>{$value} {$pref_setting['#field_suffix']}</td>"; |
403
|
|
|
} |
404
|
|
|
else { |
405
|
|
|
// The "very special" case where we merge two prefs |
406
|
|
|
$second_pref = $special_map[$name]; |
407
|
|
|
$second_pref_setting = $prefs[$pref_set]['prefs']['advanced'][$category][$second_pref]; |
408
|
|
|
$second_value = isset($second_pref_setting['#options']) ? $second_pref_setting['#options'][$second_pref_setting['#default_value']] : $second_pref_setting['#default_value']; |
409
|
|
|
$output .= "<td>{$value} {$pref_setting['#field_suffix']} {$special_delimiter[$name]}" . |
410
|
|
|
" {$second_value} {$second_pref_setting['#field_suffix']} </td>"; |
411
|
|
|
} |
412
|
|
|
} |
413
|
|
|
else { |
414
|
|
|
$output .= '<td>---</td>'; |
415
|
|
|
} |
416
|
|
|
} |
417
|
|
|
$output .= '</tr>'; |
418
|
|
|
} |
419
|
|
|
} |
420
|
|
|
|
421
|
|
|
// Empty line above action links... :/ |
422
|
|
|
$output .= '<tr>'; |
423
|
|
|
$output .= '<td> </td>'; |
424
|
|
|
$output .= '<td></td>'; |
425
|
|
|
$output .= '<td></td>'; |
426
|
|
|
$output .= '<td></td>'; |
427
|
|
|
$output .= '<td></td>'; |
428
|
|
|
$output .= '</td>'; |
429
|
|
|
|
430
|
|
|
// Show Add / Edit links for each preference set |
431
|
|
|
$output .= '<tr>'; |
432
|
|
|
$output .= '<td></td>'; |
433
|
|
|
foreach ($pref_sets as $pref_set) { |
434
|
|
|
$action_text = ($prefs[$pref_set]['#established']) ? bts('Edit', array(), NULL, 'boinc:form-edit') : bts('Add', array(), NULL, 'boinc:form-add'); |
435
|
|
|
$output .= '<td><ul class="tab-list"><li class="first tab">'; |
436
|
|
|
$output .= l($action_text, "account/prefs/computing/edit/{$pref_set}/1", |
437
|
|
|
array('fragment' => "") |
438
|
|
|
); |
439
|
|
|
// Show Clear links for established preference sets |
440
|
|
|
if ($pref_set != 'generic' AND $prefs[$pref_set]['#established']) { |
441
|
|
|
$output .= ' </li><li class="tab"> ' . l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/computing/clear/{$pref_set}", |
442
|
|
|
array( |
443
|
|
|
'query' => drupal_get_destination(), |
444
|
|
|
'attributes' => array( |
445
|
|
|
'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the "@name" preference set. Are you sure?', |
446
|
|
|
array('@name' => ucfirst($pref_set)), NULL, 'boinc:account-computing-preferences') . '\')' |
447
|
|
|
) |
448
|
|
|
) |
449
|
|
|
); |
450
|
|
|
} |
451
|
|
|
$output .= '</li></ul></td>'; |
452
|
|
|
} |
453
|
|
|
$output .= '</tr>'; |
454
|
|
|
|
455
|
|
|
$output .= '</table>'; |
456
|
|
|
|
457
|
|
|
break; |
458
|
|
|
|
459
|
|
|
case 'edit': |
460
|
|
|
default: |
461
|
|
|
|
462
|
|
|
// Return the HTML generated from the $form data structure. |
463
|
|
|
if (function_exists('jump_quickly')) { |
464
|
|
|
$path = 'account/prefs/computing/edit'; |
465
|
|
|
$venues = array( |
466
|
|
|
"{$path}/generic" => bts('Generic', array(), NULL, 'boinc:account-preferences-location'), |
467
|
|
|
"{$path}/home" => bts('Home', array(), NULL, 'boinc:account-preferences-location:-1:ignoreoverwrite'), |
468
|
|
|
"{$path}/school" => bts('School', array(), NULL, 'boinc:account-preferences-location'), |
469
|
|
|
"{$path}/work" => bts('Work', array(), NULL, 'boinc:account-preferences-location') |
470
|
|
|
); |
471
|
|
|
variable_set('jump_use_js_venues-Array', 1); |
472
|
|
|
drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js'); |
473
|
|
|
drupal_add_js(drupal_get_path('theme', 'boinc') . '/js/prefs.js', 'theme'); |
474
|
|
|
|
475
|
|
|
$output .= '<div id="venue-selector" class="simple-form-controls">'; |
476
|
|
|
$output .= ' <div class="form-item venue">'; |
477
|
|
|
$output .= ' <label>Preference set:</label>'; |
478
|
|
|
$output .= jump_quickly($venues, 'venues', 1, "{$path}/{$venue}"); |
479
|
|
|
$output .= ' </div>'; |
480
|
|
|
$output .= '</div>'; |
481
|
|
|
} |
482
|
|
|
$output .= drupal_get_form('boincwork_generalprefs_form', $venue, NULL, $advanced); |
483
|
|
|
|
484
|
|
|
// If viewing the edit page for a preference set that doesn't |
485
|
|
|
// exist, inform the user that preferences are not set. |
486
|
|
|
$form_state = array(); |
487
|
|
|
$current_set = drupal_retrieve_form('boincwork_generalprefs_form', $form_state, $venue); |
488
|
|
|
drupal_prepare_form('boincwork_generalprefs_form', $current_set, $form_state); |
489
|
|
|
|
490
|
|
|
if (!$current_set['#established']) { |
491
|
|
|
drupal_set_message(bts( |
492
|
|
|
"No preferences found for set '@venue'. Click SAVE CHANGES below to save the following preferences to your account.", |
493
|
|
|
array( '@venue' => $venue, ), |
494
|
|
|
NULL, 'boinc:account-preferences'), 'status'); |
495
|
|
|
} |
496
|
|
|
|
497
|
|
|
break; |
498
|
|
|
} |
499
|
|
|
|
500
|
|
|
return $output; |
501
|
|
|
} |
502
|
|
|
|
503
|
|
|
/** |
504
|
|
|
* Project preferences menu callback |
505
|
|
|
* Called when user goes to edit project preferences page. |
506
|
|
|
*/ |
507
|
|
|
function projectprefs_page($action = null, $venue = null) { |
508
|
|
|
|
509
|
|
|
// Keep the venue selected across preference pages |
510
|
|
|
boincwork_select_venue($venue); |
511
|
|
|
|
512
|
|
|
require_boinc(array('util', 'prefs')); |
513
|
|
|
global $project_has_beta; |
514
|
|
|
$pref_sets = array('generic', 'home', 'school', 'work'); |
515
|
|
|
$output = null; |
516
|
|
|
|
517
|
|
|
$title = 'Project'; |
518
|
|
|
drupal_set_title($title); |
519
|
|
|
|
520
|
|
|
switch ($action) { |
521
|
|
|
|
522
|
|
|
case 'clear': |
523
|
|
|
// Remove settings from this preference set |
524
|
|
|
if ($venue AND $venue != 'generic') { |
525
|
|
|
boincwork_save_prefs(NULL, 'project', $venue); |
526
|
|
|
drupal_set_message(t('Settings for the "@name" preference set have been |
527
|
|
|
cleared', array('@name' => ucfirst($venue)))); |
528
|
|
|
|
529
|
|
|
// Set the generic preference set as active |
530
|
|
|
$_SESSION['prefs venue'] = 'generic'; |
531
|
|
|
|
532
|
|
|
// If the user has removed their default preference set, make it generic |
533
|
|
|
boincwork_set_default_venue(); |
534
|
|
|
} |
535
|
|
|
drupal_goto(); |
536
|
|
|
break; |
537
|
|
|
|
538
|
|
|
case 'combined': |
539
|
|
|
|
540
|
|
|
// Compare preference sets; tabular view |
541
|
|
|
|
542
|
|
|
global $user; |
543
|
|
|
$account = user_load($user->uid); |
544
|
|
|
$boincuser = BoincUser::lookup_id($account->boincuser_id); |
545
|
|
|
|
546
|
|
|
foreach ($pref_sets as $pref_set) { |
547
|
|
|
$form_state = array(); |
548
|
|
|
$prefs[$pref_set] = drupal_retrieve_form('boincwork_projectprefs_form', $form_state, $pref_set); |
549
|
|
|
drupal_prepare_form('boincwork_projectprefs_form', $prefs[$pref_set], $form_state); |
|
|
|
|
550
|
|
|
} |
551
|
|
|
|
552
|
|
|
$output .= '<p>' . bts('Preferences last modified: @mod_time', array('@mod_time' => pretty_time_str($prefs['generic']['modified']['#value'])), NULL, 'boinc:account-preferences') . '</p>'; |
553
|
|
|
$output .= '<h2>' . bts('Combined preferences', array(), NULL, 'boinc:account-preferences') . ' ' . l('(' . bts('Switch View', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/project') . '</h2>'; |
554
|
|
|
|
555
|
|
|
$output .= '<table class="preferences combined">'; |
556
|
|
|
|
557
|
|
|
$prefs_table = boincwork_make_prefs_table($prefs['generic']); |
558
|
|
|
|
559
|
|
|
foreach ($prefs_table as $category => $section) { |
560
|
|
|
$output .= '<tr class="section-heading">'; |
561
|
|
|
$output .= "<td>{$section['name']}</td>"; |
562
|
|
|
foreach ($pref_sets as $pref_set) { |
563
|
|
|
$output .= '<td>' . $pref_set . '</td>'; |
564
|
|
|
} |
565
|
|
|
$output .= '</tr>'; |
566
|
|
|
foreach ($section['elements'] as $name => $setting) { |
567
|
|
|
$output .= '<tr>'; |
568
|
|
|
$output .= '<td>'; |
569
|
|
|
$output .= "<div class=\"title\">{$setting['name']}</div>"; |
570
|
|
|
$output .= "<div class=\"description\">{$setting['description']}</div>"; |
571
|
|
|
$output .= '</td>'; |
572
|
|
|
foreach ($pref_sets as $pref_set) { |
573
|
|
|
if (($prefs[$pref_set]) AND |
574
|
|
|
$prefs[$pref_set]['#established'] AND |
575
|
|
|
isset($prefs[$pref_set][$category])) { |
576
|
|
|
$pref_setting = $prefs[$pref_set][$category][$name]; |
577
|
|
|
$value = isset($pref_setting['#options']) ? $pref_setting['#options'][$pref_setting['#default_value']] : $pref_setting['#default_value']; |
578
|
|
|
if ($value == '') $value = '---'; |
579
|
|
|
if (!isset($pref_setting['#field_suffix'])) $pref_setting['#field_suffix'] = ''; |
580
|
|
|
$output .= "<td>{$value} {$pref_setting['#field_suffix']}</td>"; |
581
|
|
|
} else $output .= '<td>---</td>'; |
582
|
|
|
} |
583
|
|
|
$output .= '</tr>'; |
584
|
|
|
} |
585
|
|
|
} |
586
|
|
|
|
587
|
|
|
// Empty line above action links... :/ |
588
|
|
|
$output .= '<tr>'; |
589
|
|
|
$output .= '<td> </td>'; |
590
|
|
|
$output .= '<td></td>'; |
591
|
|
|
$output .= '<td></td>'; |
592
|
|
|
$output .= '<td></td>'; |
593
|
|
|
$output .= '<td></td>'; |
594
|
|
|
$output .= '</td>'; |
595
|
|
|
|
596
|
|
|
// Show Add / Edit links for each preference set |
597
|
|
|
$output .= '<tr>'; |
598
|
|
|
$output .= '<td></td>'; |
599
|
|
|
foreach ($pref_sets as $pref_set) { |
600
|
|
|
$action_text = ($prefs[$pref_set]['#established']) ? bts('Edit', array(), NULL, 'boinc:form-edit') : bts('Add', array(), NULL, 'boinc:form-add'); |
601
|
|
|
$output .= '<td><ul class="tab-list"><li class="first tab">'; |
602
|
|
|
$output .= l($action_text, "account/prefs/project/edit/{$pref_set}"); |
603
|
|
|
// Show Clear links for established preference sets |
604
|
|
|
if ($pref_set != 'generic' AND $prefs[$pref_set]['#established']) { |
605
|
|
|
$output .= ' </li><li class="tab"> ' . l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/project/clear/{$pref_set}", |
606
|
|
|
array( |
607
|
|
|
'query' => drupal_get_destination(), |
608
|
|
|
'attributes' => array( |
609
|
|
|
'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the "@name" preference set. Are you sure?', |
610
|
|
|
array('@name' => ucfirst($pref_set)), NULL, 'boinc:account-preferences-project') . '\')' |
611
|
|
|
) |
612
|
|
|
) |
613
|
|
|
); |
614
|
|
|
} |
615
|
|
|
$output .= '</li></ul></td>'; |
616
|
|
|
} |
617
|
|
|
|
618
|
|
|
$output .= '</table>'; |
619
|
|
|
|
620
|
|
|
break; |
621
|
|
|
|
622
|
|
|
case 'set-default': |
623
|
|
|
// Set this preference set as the one to use for any new hosts attached |
624
|
|
|
// to the user account |
625
|
|
|
boincwork_set_default_venue($venue); |
626
|
|
|
drupal_set_message( bts('The primary preference set has been changed to "@set"', array('@set' => $venue), NULL, 'boinc:account-preferences-project') ); |
627
|
|
|
drupal_goto('account/prefs/project/combined'); |
628
|
|
|
break; |
629
|
|
|
|
630
|
|
|
case 'edit': |
631
|
|
|
default: |
632
|
|
|
|
633
|
|
|
// Return the HTML generated from the $form data structure. |
634
|
|
|
require_boinc('util'); |
635
|
|
|
|
636
|
|
|
if (function_exists('jump_quickly')) { |
637
|
|
|
$path = 'account/prefs/project/edit'; |
638
|
|
|
$venues = array( |
639
|
|
|
"{$path}/generic" => bts('Generic', array(), NULL, 'boinc:account-preferences-location'), |
640
|
|
|
"{$path}/home" => bts('Home', array(), NULL, 'boinc:account-preferences-location:-1:ignoreoverwrite'), |
641
|
|
|
"{$path}/school" => bts('School', array(), NULL, 'boinc:account-preferences-location'), |
642
|
|
|
"{$path}/work" => bts('Work', array(), NULL, 'boinc:account-preferences-location') |
643
|
|
|
); |
644
|
|
|
variable_set('jump_use_js_venues-Array', 1); |
645
|
|
|
drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js'); |
646
|
|
|
drupal_add_js(drupal_get_path('theme', 'boinc') . '/js/prefs.js', 'theme'); |
647
|
|
|
|
648
|
|
|
$output .= '<div id="venue-selector" class="simple-form-controls">'; |
649
|
|
|
$output .= ' <div class="form-item venue">'; |
650
|
|
|
$output .= ' <label>Preference set:</label>'; |
651
|
|
|
$output .= jump_quickly($venues, 'venues', 1, "{$path}/{$venue}"); |
652
|
|
|
$output .= ' </div>'; |
653
|
|
|
$output .= '</div>'; |
654
|
|
|
} |
655
|
|
|
$output .= drupal_get_form('boincwork_projectprefs_form', $venue); |
656
|
|
|
|
657
|
|
|
// If viewing the edit page for a preference set that doesn't |
658
|
|
|
// exist, inform the user that preferences are not set. |
659
|
|
|
$form_state = array(); |
660
|
|
|
$current_set = drupal_retrieve_form('boincwork_projectprefs_form', $form_state, $venue); |
661
|
|
|
drupal_prepare_form('boincwork_projectprefs_form', $current_set, $form_state); |
662
|
|
|
|
663
|
|
|
if (!$current_set['#established']) { |
664
|
|
|
drupal_set_message(bts( |
665
|
|
|
"No preferences found for set '@venue'. Click SAVE CHANGES below to save the following preferences to your account.", |
666
|
|
|
array( '@venue' => $venue, ), |
667
|
|
|
NULL, 'boinc:account-preferences'), 'status'); |
668
|
|
|
} |
669
|
|
|
|
670
|
|
|
break; |
671
|
|
|
|
672
|
|
|
} |
673
|
|
|
return $output; |
674
|
|
|
} |
675
|
|
|
|
676
|
|
|
/** |
677
|
|
|
* Community preferences menu callback |
678
|
|
|
* Called when user goes to edit community preferences page. |
679
|
|
|
*/ |
680
|
|
|
function communityprefs_page($action = null) { |
681
|
|
|
|
682
|
|
|
require_boinc(array('util', 'prefs')); |
683
|
|
|
$output = null; |
684
|
|
|
|
685
|
|
|
$title = 'Community'; |
686
|
|
|
drupal_set_title($title); |
687
|
|
|
|
688
|
|
|
//$output .= '<h2>Community preferences</h2>'; |
689
|
|
|
|
690
|
|
|
$output .= drupal_get_form('communityprefs_form'); |
691
|
|
|
|
692
|
|
|
return $output; |
693
|
|
|
} |
694
|
|
|
|
695
|
|
|
/** |
696
|
|
|
* Privacy preferences menu callback |
697
|
|
|
* Called when user goes to edit privacy preferences page. |
698
|
|
|
*/ |
699
|
|
|
function privacyprefs_page($action = null) { |
700
|
|
|
|
701
|
|
|
require_boinc(array('util', 'prefs')); |
702
|
|
|
$output = null; |
703
|
|
|
$title = 'Privacy'; |
704
|
|
|
drupal_set_title($title); |
705
|
|
|
|
706
|
|
|
switch ($action) { |
707
|
|
|
case 'view': |
708
|
|
|
$form_state = array(); |
709
|
|
|
$prefs = drupal_retrieve_form('boincwork_privacyprefs_form', $form_state); |
710
|
|
|
drupal_prepare_form('boincwork_privacyprefs_form', $prefs, $form_state); |
711
|
|
|
$output .= '<table>'; |
712
|
|
|
|
713
|
|
|
$sections = array( |
714
|
|
|
'privacy' => $prefs['privacy'] |
715
|
|
|
); |
716
|
|
|
|
717
|
|
|
foreach ($sections as $section) { |
718
|
|
|
$output .= '<tr class="section-heading">'; |
719
|
|
|
$output .= "<td>{$section['#title']}</td></tr>"; |
720
|
|
|
foreach ($section as $name => $setting) { |
721
|
|
|
if ($name{0} == '#') continue; |
722
|
|
|
$value = isset($setting['#default_value']) ? $setting['#default_value'] : ''; |
723
|
|
|
if ($value AND isset($setting['#options'])) $value = $setting['#options'][$value]; |
724
|
|
|
elseif ($value == '') $value = '---'; |
725
|
|
|
if (!isset($setting['#title'])) $setting['#title'] = ''; |
726
|
|
|
if (!isset($setting['#description'])) $setting['#description'] = ''; |
727
|
|
|
if (!isset($setting['#field_suffix'])) $setting['#field_suffix'] = ''; |
728
|
|
|
$output .= '<tr>'; |
729
|
|
|
$output .= "<td>{$setting['#title']}<br/>{$setting['#description']}</td>"; |
730
|
|
|
$output .= "<td>{$value} {$setting['#field_suffix']}</td>"; |
731
|
|
|
$output .= '</tr>'; |
732
|
|
|
} |
733
|
|
|
} |
734
|
|
|
|
735
|
|
|
// Edit preferences link |
736
|
|
|
$output .= '<tr>'; |
737
|
|
|
$output .= '<td></td>'; |
738
|
|
|
$output .= '<td>' . l(bts('Edit privacy preferences', array('@project' => PROJECT), NULL, 'boinc:account-preferences-privacy'), "account/prefs/privacy/edit") . '</td>'; |
739
|
|
|
$output .= '</tr>'; |
740
|
|
|
|
741
|
|
|
$output .= '</table>'; |
742
|
|
|
|
743
|
|
|
break; |
744
|
|
|
|
745
|
|
|
case 'edit': |
746
|
|
|
default: |
747
|
|
|
require_boinc('util'); |
748
|
|
|
// Return the HTML generated from the $form data structure. |
749
|
|
|
$output .= drupal_get_form('boincwork_privacyprefs_form'); |
750
|
|
|
break; |
751
|
|
|
|
752
|
|
|
} |
753
|
|
|
|
754
|
|
|
return $output; |
755
|
|
|
} |
756
|
|
|
|
757
|
|
|
/** |
758
|
|
|
* Certificates menu callback |
759
|
|
|
* Called when user goes to account certificate pages |
760
|
|
|
*/ |
761
|
|
|
function boincwork_certificates($type = null, $border = null) { |
762
|
|
|
global $user; |
763
|
|
|
$drupuser = user_load($user->uid); |
764
|
|
|
// Load BOINC account and pre-authenticate with BOINC code |
765
|
|
|
require_boinc(array('util', 'cert')); |
766
|
|
|
$boincuser = BoincUser::lookup_id($drupuser->boincuser_id); |
767
|
|
|
//global $g_logged_in_user; |
768
|
|
|
//$g_logged_in_user = $boincuser; |
769
|
|
|
//print_r($boincuser); exit; |
770
|
|
|
switch ($type) { |
771
|
|
|
case 'all': |
772
|
|
|
//include_boinc('user/cert_all.php'); |
773
|
|
|
require_boinc(array('util','cert','user')); |
774
|
|
|
|
775
|
|
|
$join = date('j F Y', $boincuser->create_time); |
776
|
|
|
$today = date('j F Y', time(0)); |
|
|
|
|
777
|
|
|
|
778
|
|
|
if ($border=="no") { |
779
|
|
|
$border = 0; |
780
|
|
|
} else { |
781
|
|
|
$border=8; |
782
|
|
|
} |
783
|
|
|
|
784
|
|
|
$title_font = "\"Optima,ZapfChancery\""; |
785
|
|
|
$font = "\"Optima,Lucida Bright,Times New Roman\""; |
786
|
|
|
|
787
|
|
|
$boincuser = get_other_projects($boincuser); |
788
|
|
|
$total_credit = 0; |
789
|
|
|
foreach ($boincuser->projects as $p) { |
790
|
|
|
$total_credit += $p->total_credit; |
791
|
|
|
} |
792
|
|
|
|
793
|
|
|
$credit = credit_string($total_credit, false); |
794
|
|
|
|
795
|
|
|
function show_proj($p) { |
796
|
|
|
$join = date('j F Y', $p->create_time); |
797
|
|
|
echo "<tr> <td>$p->name</td><td> $p->total_credit</td><td>$join</td></tr> |
798
|
|
|
"; |
799
|
|
|
} |
800
|
|
|
|
801
|
|
|
echo " |
802
|
|
|
<table width=900 height=650 border=$border cellpadding=20><tr><td> |
803
|
|
|
<center> |
804
|
|
|
<table width=700 border=0><tr><td style=\"background-position:center; background-repeat:no-repeat\" background=http://boinc.berkeley.edu/logo/boinc_fade_600.png> |
805
|
|
|
<center> |
806
|
|
|
<font style=\"font-size: 52\" face=$title_font>Certificate of Computation |
807
|
|
|
|
808
|
|
|
<font face=$font style=\"font-size:28\"> |
809
|
|
|
<br><br> |
810
|
|
|
This certifies that |
811
|
|
|
<p> |
812
|
|
|
<font face=$font style=\"font-size:32\"> |
813
|
|
|
$boincuser->name |
814
|
|
|
|
815
|
|
|
<font face=$font style=\"font-size:18\"> |
816
|
|
|
<p> |
817
|
|
|
has contributed $credit |
818
|
|
|
to the following scientific research projects: |
819
|
|
|
|
820
|
|
|
<center> |
821
|
|
|
<table width=80%> |
822
|
|
|
<tr><th align=left>Project</th><th align=left>Cobblestones</th><th align=left>Joined</th></tr> |
823
|
|
|
"; |
824
|
|
|
foreach ($boincuser->projects as $p) { |
825
|
|
|
if ($p->total_credit<100) continue; |
826
|
|
|
show_proj($p); |
827
|
|
|
} |
828
|
|
|
echo " |
829
|
|
|
</table> |
830
|
|
|
</center> |
831
|
|
|
"; |
832
|
|
|
|
833
|
|
|
echo " |
834
|
|
|
</td> |
835
|
|
|
"; |
836
|
|
|
echo " |
837
|
|
|
</td><tr></table> |
838
|
|
|
"; |
839
|
|
|
break; |
840
|
|
|
|
841
|
|
|
case 'account': |
842
|
|
|
default: |
843
|
|
|
//include_boinc('user/cert1.php'); |
844
|
|
|
require_boinc(array('util','cert')); |
845
|
|
|
|
846
|
|
|
$join = date('j F Y', $boincuser->create_time); |
847
|
|
|
$today = date('j F Y', time(0)); |
848
|
|
|
|
849
|
|
|
if ($border=="no") { |
850
|
|
|
$border = 0; |
851
|
|
|
} else { |
852
|
|
|
$border=8; |
853
|
|
|
} |
854
|
|
|
|
855
|
|
|
$credit = credit_string($boincuser->total_credit, false); |
856
|
|
|
|
857
|
|
|
$title_font = "\"Optima,ZapfChancery\""; |
858
|
|
|
$font = "\"Optima,Lucida Bright,Times New Roman\""; |
859
|
|
|
|
860
|
|
|
echo " |
861
|
|
|
<table width=900 height=650 border=$border cellpadding=20><tr><td> |
862
|
|
|
<center> |
863
|
|
|
<table width=700 border=0><tr><td> |
864
|
|
|
<center> |
865
|
|
|
<font style=\"font-size: 52\" face=$title_font>Certificate of Computation |
866
|
|
|
|
867
|
|
|
|
868
|
|
|
<font face=$font style=\"font-size:28\"> |
869
|
|
|
<br><br><br> |
870
|
|
|
This certifies that |
871
|
|
|
<p> |
872
|
|
|
<font face=$font style=\"font-size:32\"> |
873
|
|
|
$boincuser->name |
874
|
|
|
|
875
|
|
|
<font face=$font style=\"font-size:18\"> |
876
|
|
|
<p> |
877
|
|
|
has participated in ".PROJECT." since $join, |
878
|
|
|
and has contributed $credit |
879
|
|
|
to ".PROJECT.". |
880
|
|
|
|
881
|
|
|
<br><br><br> |
882
|
|
|
</td><tr></table> |
883
|
|
|
<table width=100%><tr> |
884
|
|
|
<td width=40><br></td> |
885
|
|
|
<td align=left> |
886
|
|
|
<font face=$font style=\"font-size:16\"> |
887
|
|
|
"; |
888
|
|
|
if (defined("CERT_SIGNATURE")) { |
889
|
|
|
echo " |
890
|
|
|
<img src=".CERT_SIGNATURE."> |
891
|
|
|
<br> |
892
|
|
|
"; |
893
|
|
|
} |
894
|
|
|
if (defined("CERT_DIRECTOR_NAME")) { |
895
|
|
|
echo CERT_DIRECTOR_NAME." <br>Director, ".PROJECT." |
896
|
|
|
<br> |
897
|
|
|
"; |
898
|
|
|
} |
899
|
|
|
echo " |
900
|
|
|
<br> |
901
|
|
|
$today |
902
|
|
|
</td> |
903
|
|
|
"; |
904
|
|
|
if (defined("CERT_PROJECT_LOGO")) { |
905
|
|
|
echo " |
906
|
|
|
<td align=center valign=center> <img src=".CERT_PROJECT_LOGO."> </td> |
907
|
|
|
"; |
908
|
|
|
} |
909
|
|
|
if (defined("CERT_INSTITUTION_LOGO")) { |
910
|
|
|
echo " |
911
|
|
|
<td align=center width=30% valign=center><img src=".CERT_INSTITUTION_LOGO."></td> |
912
|
|
|
"; |
913
|
|
|
} |
914
|
|
|
echo " |
915
|
|
|
</td><tr></table> |
916
|
|
|
"; |
917
|
|
|
} |
918
|
|
|
} |
919
|
|
|
|
920
|
|
|
/** |
921
|
|
|
* Delete host menu callback |
922
|
|
|
* Called when user selects to delete a host |
923
|
|
|
*/ |
924
|
|
|
function boincwork_host_delete($host_id) { |
925
|
|
|
// Verify that host has no tasks |
926
|
|
|
if (boincwork_host_user_is_owner($host_id)) { |
927
|
|
|
if (!boincwork_host_get_task_count($host_id)) { |
928
|
|
|
// Delete the host record |
929
|
|
|
db_set_active('boinc_rw'); |
930
|
|
|
$host_deleted = db_query( |
931
|
|
|
"DELETE FROM {host} WHERE id = '%d'", |
932
|
|
|
$host_id |
933
|
|
|
); |
934
|
|
|
db_set_active('default'); |
935
|
|
|
if ($host_deleted) { |
936
|
|
|
drupal_set_message(t('Host @id has been removed from your account.', |
937
|
|
|
array('@id' => $host_id))); |
938
|
|
|
drupal_goto('account/computers'); |
939
|
|
|
} |
940
|
|
|
else { |
941
|
|
|
drupal_set_message(t('Host @id could not be deleted. Not sure why...', |
942
|
|
|
array('@id' => $host_id)), 'error' |
943
|
|
|
); |
944
|
|
|
} |
945
|
|
|
} |
946
|
|
|
else { |
947
|
|
|
drupal_set_message(t('Host @id cannot be deleted because it still has |
948
|
|
|
tasks associated with it. These tasks should be processed within the |
949
|
|
|
next few days, after which the host can be deleted.', |
950
|
|
|
array('@id' => $host_id)), 'warning' |
951
|
|
|
); |
952
|
|
|
} |
953
|
|
|
} |
954
|
|
|
else { |
955
|
|
|
drupal_set_message(t('You are not the owner of host @id, so you cannot |
956
|
|
|
delete it.', |
957
|
|
|
array('@id' => $host_id)), 'error' |
958
|
|
|
); |
959
|
|
|
} |
960
|
|
|
drupal_goto("host/{$host_id}"); |
961
|
|
|
} |
962
|
|
|
|
963
|
|
|
/** |
964
|
|
|
* Host log menu callback |
965
|
|
|
* Called when user accesses the log for a host |
966
|
|
|
*/ |
967
|
|
|
function boincwork_host_log($host_id = null) { |
968
|
|
|
$root_log_dir = variable_get('boinc_host_sched_logs_dir', ''); |
969
|
|
|
$log = ''; |
970
|
|
|
if ($root_log_dir AND $host_id) { |
971
|
|
|
$subdir = substr($host_id, 0, -3) OR $subdir = 0; |
972
|
|
|
$log = implode('/', array($root_log_dir, $subdir, $host_id)); |
973
|
|
|
} |
974
|
|
|
if ($log AND file_exists($log)) { |
975
|
|
|
header('Content-type: text/plain'); |
976
|
|
|
include($log); |
977
|
|
|
} |
978
|
|
|
} |
979
|
|
|
|
980
|
|
|
function boincwork_host_set_venue($host_id = NULL, $venue = NULL) { |
981
|
|
|
global $user; |
982
|
|
|
$account = user_load($user->uid); |
983
|
|
|
db_set_active('boinc_ro'); |
984
|
|
|
// Verify that this is my host |
985
|
|
|
$host_owner = db_result(db_query( |
986
|
|
|
"SELECT userid FROM {host} WHERE id = '%d'", |
987
|
|
|
$host_id |
988
|
|
|
)); |
989
|
|
|
db_set_active('default'); |
990
|
|
|
if ($host_owner AND $host_owner == $account->boincuser_id) { |
991
|
|
|
db_set_active('boinc_rw'); |
992
|
|
|
$updated = db_query( |
993
|
|
|
"UPDATE {host} SET venue = '%s' WHERE id = '%d'", |
994
|
|
|
$venue, $host_id |
995
|
|
|
); |
996
|
|
|
db_set_active('default'); |
997
|
|
|
if ($updated) { |
998
|
|
|
drupal_set_message( |
999
|
|
|
bts('The location for this host has been updated.', array(), NULL, 'boinc:account-host-details') |
1000
|
|
|
. bts('This will take effect next time the host contacts the project.', array(), NULL, 'boinc:account-host-details') |
1001
|
|
|
); |
1002
|
|
|
} |
1003
|
|
|
else { |
1004
|
|
|
drupal_set_message( |
1005
|
|
|
bts('Unable to save changes to this host for some reason!', array(), NULL, 'boinc:account-host-details'), |
1006
|
|
|
'error' |
1007
|
|
|
); |
1008
|
|
|
} |
1009
|
|
|
} |
1010
|
|
|
else { |
1011
|
|
|
drupal_set_message( |
1012
|
|
|
bts('You are not allowed to make changes to this host.', array(), NULL, 'boinc:account-host-details'), |
1013
|
|
|
'warning' |
1014
|
|
|
); |
1015
|
|
|
} |
1016
|
|
|
drupal_goto("host/{$host_id}"); |
1017
|
|
|
} |
1018
|
|
|
|
1019
|
|
|
/** |
1020
|
|
|
* Mobile stats menu callback |
1021
|
|
|
* Called when user accesses cell phone stats |
1022
|
|
|
*/ |
1023
|
|
|
function boincwork_mobile_stats($userid = null) { |
1024
|
|
|
$_GET['id'] = $userid; |
1025
|
|
|
include_boinc('user/userw.php'); |
1026
|
|
|
} |
1027
|
|
|
|
1028
|
|
|
/** |
1029
|
|
|
* Server status menu callback |
1030
|
|
|
* Called to build the server status page |
1031
|
|
|
*/ |
1032
|
|
|
function boincwork_server_status() { |
1033
|
|
|
include_boinc('user/server_status.php'); |
1034
|
|
|
} |
1035
|
|
|
|
1036
|
|
|
/** |
1037
|
|
|
* Page callback for the job input file RPC (job_file.php). |
1038
|
|
|
* RPC for managing job input files |
1039
|
|
|
*/ |
1040
|
|
|
function boincwork_job_file() { |
1041
|
|
|
include_boinc('user/job_file.php'); |
1042
|
|
|
} |
1043
|
|
|
|
1044
|
|
|
/** |
1045
|
|
|
* Page callback for the output file request RPC (get_output.php). |
1046
|
|
|
* Get output file from remote job submission |
1047
|
|
|
*/ |
1048
|
|
|
function boincwork_get_output() { |
1049
|
|
|
include_boinc('user/get_output.php'); |
1050
|
|
|
} |
1051
|
|
|
|
1052
|
|
|
/** |
1053
|
|
|
* Page callback for the project config RPC (get_project_config.php). |
1054
|
|
|
* Get the project configuration XML; used by client software |
1055
|
|
|
*/ |
1056
|
|
|
function boincwork_get_project_config() { |
1057
|
|
|
ob_start(); |
1058
|
|
|
include_boinc('user/get_project_config.php'); |
1059
|
|
|
$xml = ob_get_clean(); |
1060
|
|
|
$xml = load_configuration($xml); |
1061
|
|
|
|
1062
|
|
|
// obtain Drupal variables |
1063
|
|
|
$termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
1064
|
|
|
$overrideboinctou = variable_get('boinc_weboptions_overrideboinctou', FALSE); |
1065
|
|
|
|
1066
|
|
|
// If terms of use string exists and override is true, set terms-of-use |
1067
|
|
|
// to Drupal varaible. |
1068
|
|
|
if ( (!empty($termsofuse) && ($overrideboinctou)) ) { |
1069
|
|
|
if (!empty($xml['project_config']['terms_of_use'])) { |
1070
|
|
|
// Remove any existing terms of use |
1071
|
|
|
unset($xml['project_config']['terms_of_use']); |
1072
|
|
|
} |
1073
|
|
|
|
1074
|
|
|
// Add terms of use from Drupal |
1075
|
|
|
$xml['project_config']['terms_of_use']['@value'] = $termsofuse; |
1076
|
|
|
} |
1077
|
|
|
|
1078
|
|
|
print save_configuration($xml); |
|
|
|
|
1079
|
|
|
} |
1080
|
|
|
|
1081
|
|
|
|
1082
|
|
|
/** |
1083
|
|
|
* Page callback for the remote job submission RPC (submit_rpc_handler.php). |
1084
|
|
|
*/ |
1085
|
|
|
function boincwork_submit_rpc_handler() { |
1086
|
|
|
include_boinc('user/submit_rpc_handler.php'); |
1087
|
|
|
} |
1088
|
|
|
|
1089
|
|
|
/** |
1090
|
|
|
* Page callback for user WAP (userw.php). |
1091
|
|
|
*/ |
1092
|
|
|
function boincwork_user_wap() { |
1093
|
|
|
// Remove q from the GET request or BOINC will panic |
1094
|
|
|
unset($_GET['q']); |
1095
|
|
|
include_boinc('user/userw.php'); |
1096
|
|
|
} |
1097
|
|
|
|
1098
|
|
|
|
1099
|
|
|
/** |
1100
|
|
|
* Page callback for user account task table |
1101
|
|
|
*/ |
1102
|
|
|
function boincwork_account_task_table($tselect = NULL, $app_id = NULL) { |
1103
|
|
|
$title = bts('Tasks for your account', array(), NULL, 'boinc:account-task-table'); |
1104
|
|
|
drupal_set_title($title); |
1105
|
|
|
|
1106
|
|
|
global $user; |
1107
|
|
|
$account = user_load($user->uid); |
1108
|
|
|
return boincwork_tasktable(0, $account->boincuser_id, $tselect, $app_id); |
1109
|
|
|
} |
1110
|
|
|
|
1111
|
|
|
/** |
1112
|
|
|
* Page callback for host task table |
1113
|
|
|
*/ |
1114
|
|
|
function boincwork_host_task_table($host_id = NULL, $tselect = NULL, $app_id = NULL) { |
1115
|
|
|
require_boinc( array('util', 'result') ); |
1116
|
|
|
|
1117
|
|
|
$title = bts('Tasks for computer @host_id', array('@host_id' => $host_id), NULL, 'boinc:host-task-table'); |
1118
|
|
|
drupal_set_title($title); |
1119
|
|
|
|
1120
|
|
|
if (is_null($host_id)) { |
1121
|
|
|
drupal_set_message(bts('ERROR: Invalid host ID', array(), NULL, 'boinc:host-task-table'), 'error'); |
1122
|
|
|
return ''; |
1123
|
|
|
} |
1124
|
|
|
|
1125
|
|
|
return boincwork_tasktable(2, $host_id, $tselect, $app_id); |
1126
|
|
|
} |
1127
|
|
|
|
1128
|
|
|
/** |
1129
|
|
|
* Page callback for workunit task table |
1130
|
|
|
*/ |
1131
|
|
|
function boincwork_workunit_task_table($workunit_id = NULL, $tselect = NULL, $app_id = NULL) { |
1132
|
|
|
$title = bts('Tasks for workunit @workunit_id', array('@workunit_id' => $workunit_id), NULL, 'boinc:workunit-task-table'); |
1133
|
|
|
drupal_set_title($title); |
1134
|
|
|
|
1135
|
|
|
if (is_null($workunit_id)) { |
1136
|
|
|
drupal_set_message(bts('ERROR: Invalid workunit ID', array(), NULL, 'boinc:workunit-task-table'), 'error'); |
1137
|
|
|
return ''; |
1138
|
|
|
} |
1139
|
|
|
|
1140
|
|
|
return boincwork_tasktable(1, $workunit_id, $tselect, $app_id); |
1141
|
|
|
} |
1142
|
|
|
|
1143
|
|
|
/** |
1144
|
|
|
* Generic page callback |
1145
|
|
|
* Take a node ID and render that node as a page |
1146
|
|
|
*/ |
1147
|
|
|
function boincwork_view_page($nid) { |
1148
|
|
|
$node = node_load($nid); |
1149
|
|
|
return node_page_view($node); |
1150
|
|
|
} |
1151
|
|
|
|
1152
|
|
|
|
1153
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
1154
|
|
|
* Local supporting functions |
1155
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
1156
|
|
|
|
1157
|
|
|
/** |
1158
|
|
|
* Determine which venue should be selected |
1159
|
|
|
*/ |
1160
|
|
|
function boincwork_select_venue(&$venue) { |
1161
|
|
|
if (!$venue) { |
1162
|
|
|
$active_venue = isset($_SESSION['prefs venue']) ? $_SESSION['prefs venue'] : NULL; |
1163
|
|
|
if ($active_venue) { |
1164
|
|
|
$venue = $active_venue; |
1165
|
|
|
//unset($_SESSION['prefs venue']); |
1166
|
|
|
} |
1167
|
|
|
} |
1168
|
|
|
else { |
1169
|
|
|
// Set the active venue to keep it selected between computing and project |
1170
|
|
|
// preference pages |
1171
|
|
|
$_SESSION['prefs venue'] = $venue; |
1172
|
|
|
} |
1173
|
|
|
} |
1174
|
|
|
|