@@ -7,15 +7,15 @@ |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | class views_handler_argument_boincteam_id extends views_handler_argument_numeric { |
10 | - function construct() { |
|
10 | + function construct() { |
|
11 | 11 | parent::construct(); |
12 | - } |
|
12 | + } |
|
13 | 13 | |
14 | - function set_argument($arg) { |
|
14 | + function set_argument($arg) { |
|
15 | 15 | // When setting the ID argument, convert to BOINC ID |
16 | 16 | $id = is_numeric($arg) ? $arg : 0; |
17 | 17 | $boinc_id = db_result(db_query("SELECT team_id FROM {boincteam} WHERE nid = %d", $id)); |
18 | 18 | $this->argument = $boinc_id; |
19 | 19 | return $this->validate_arg($boinc_id); |
20 | - } |
|
20 | + } |
|
21 | 21 | } |
@@ -15,41 +15,41 @@ discard block |
||
15 | 15 | */ |
16 | 16 | function boincteam_sync() { |
17 | 17 | |
18 | - // Get the list of teams to import |
|
19 | - db_set_active('boinc'); |
|
20 | - $boinc_teams = db_query(' |
|
18 | + // Get the list of teams to import |
|
19 | + db_set_active('boinc'); |
|
20 | + $boinc_teams = db_query(' |
|
21 | 21 | SELECT id, name, description, userid, create_time, seti_id |
22 | 22 | FROM team |
23 | 23 | WHERE mod_time > FROM_UNIXTIME(%d)', |
24 | 24 | variable_get('boincteam_last_sync', 0) |
25 | - ); |
|
26 | - db_set_active('default'); |
|
25 | + ); |
|
26 | + db_set_active('default'); |
|
27 | 27 | |
28 | - $existing_teams = array(); |
|
28 | + $existing_teams = array(); |
|
29 | 29 | |
30 | - // Get the list of teams already in Drupal to be sure we're not importing |
|
31 | - // any twice |
|
32 | - $result = db_query(' |
|
30 | + // Get the list of teams already in Drupal to be sure we're not importing |
|
31 | + // any twice |
|
32 | + $result = db_query(' |
|
33 | 33 | SELECT nid, team_id FROM {boincteam}' |
34 | - ); |
|
35 | - while ($row = db_fetch_object($result)) { |
|
34 | + ); |
|
35 | + while ($row = db_fetch_object($result)) { |
|
36 | 36 | $existing_teams[$row->team_id] = $row->nid; |
37 | - } |
|
37 | + } |
|
38 | 38 | |
39 | - while ($boinc_team = db_fetch_object($boinc_teams)) { |
|
39 | + while ($boinc_team = db_fetch_object($boinc_teams)) { |
|
40 | 40 | $success = NULL; |
41 | 41 | if (isset($existing_teams[$boinc_team->id])) { |
42 | - if ($boinc_team->seti_id > 0) { |
|
42 | + if ($boinc_team->seti_id > 0) { |
|
43 | 43 | // Sync BOINC-wide teams |
44 | 44 | $nid = $existing_teams[$boinc_team->id]; |
45 | 45 | $success = boincteam_import($boinc_team, $nid); |
46 | - } |
|
46 | + } |
|
47 | 47 | } |
48 | 48 | else { |
49 | - // Import new teams created by RPC or ops/team_import.php |
|
50 | - $success = boincteam_import($boinc_team); |
|
49 | + // Import new teams created by RPC or ops/team_import.php |
|
50 | + $success = boincteam_import($boinc_team); |
|
51 | + } |
|
51 | 52 | } |
52 | - } |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | |
@@ -58,56 +58,56 @@ discard block |
||
58 | 58 | */ |
59 | 59 | function boincteam_import($boincteam, $nid = NULL) { |
60 | 60 | |
61 | - $input_format = variable_get('boincimport_input_format', 0); |
|
62 | - $team_type_map = variable_get('boincimport_team_types', array()); |
|
61 | + $input_format = variable_get('boincimport_input_format', 0); |
|
62 | + $team_type_map = variable_get('boincimport_team_types', array()); |
|
63 | 63 | |
64 | - // Save the team type affiliation |
|
65 | - $team_type_tid = $team_type_map[$boincteam->type]; |
|
64 | + // Save the team type affiliation |
|
65 | + $team_type_tid = $team_type_map[$boincteam->type]; |
|
66 | 66 | |
67 | - $boincteam->description = html_entity_decode($boincteam->description, ENT_QUOTES, 'utf-8'); |
|
68 | - // Be sure the text is filtered for the default input format |
|
69 | - $boincteam->description = check_markup($boincteam->description, $input_format); |
|
67 | + $boincteam->description = html_entity_decode($boincteam->description, ENT_QUOTES, 'utf-8'); |
|
68 | + // Be sure the text is filtered for the default input format |
|
69 | + $boincteam->description = check_markup($boincteam->description, $input_format); |
|
70 | 70 | |
71 | - $teaser = node_teaser($boincteam->description); |
|
71 | + $teaser = node_teaser($boincteam->description); |
|
72 | 72 | |
73 | - if ($nid) { |
|
73 | + if ($nid) { |
|
74 | 74 | // Update an existing node |
75 | 75 | $node = node_load($nid); |
76 | 76 | $node->title = $boincteam->name; |
77 | 77 | $node->body = $boincteam->description; |
78 | 78 | $node->teaser = $teaser; |
79 | 79 | $node->uid = boincuser_lookup_uid($boincteam->userid); |
80 | - } |
|
81 | - else { |
|
80 | + } |
|
81 | + else { |
|
82 | 82 | // Construct the team as a new node |
83 | 83 | $node = array( |
84 | - 'type' => 'team', |
|
85 | - 'title' => $boincteam->name, |
|
86 | - 'body' => $boincteam->description, |
|
87 | - 'teaser' => $teaser, |
|
88 | - 'uid' => boincuser_lookup_uid($boincteam->userid), |
|
89 | - 'path' => null, |
|
90 | - 'status' => 1, // published or not - always publish |
|
91 | - 'promote' => 0, |
|
92 | - 'created' => $boincteam->create_time, |
|
93 | - 'comment' => 0, // comments disabled |
|
94 | - 'moderate' => 0, |
|
95 | - 'sticky' => 0, |
|
96 | - 'format' => $input_format |
|
84 | + 'type' => 'team', |
|
85 | + 'title' => $boincteam->name, |
|
86 | + 'body' => $boincteam->description, |
|
87 | + 'teaser' => $teaser, |
|
88 | + 'uid' => boincuser_lookup_uid($boincteam->userid), |
|
89 | + 'path' => null, |
|
90 | + 'status' => 1, // published or not - always publish |
|
91 | + 'promote' => 0, |
|
92 | + 'created' => $boincteam->create_time, |
|
93 | + 'comment' => 0, // comments disabled |
|
94 | + 'moderate' => 0, |
|
95 | + 'sticky' => 0, |
|
96 | + 'format' => $input_format |
|
97 | 97 | ); |
98 | 98 | $node = (object) $node; // node_save requires an object form |
99 | - } |
|
99 | + } |
|
100 | 100 | |
101 | - $node->taxonomy[] = taxonomy_get_term($team_type_tid); |
|
101 | + $node->taxonomy[] = taxonomy_get_term($team_type_tid); |
|
102 | 102 | |
103 | - // Save the team node |
|
104 | - node_save($node); |
|
105 | - $success = ($node->nid) ? TRUE : FALSE; |
|
103 | + // Save the team node |
|
104 | + node_save($node); |
|
105 | + $success = ($node->nid) ? TRUE : FALSE; |
|
106 | 106 | |
107 | - if (!$nid) { |
|
107 | + if (!$nid) { |
|
108 | 108 | // Save the team IDs to a BOINC <--> Drupal reference table, if needed |
109 | 109 | db_query('INSERT INTO {boincteam} (team_id, nid) VALUES (%d, %d)', $boincteam->id, $node->nid); |
110 | - } |
|
110 | + } |
|
111 | 111 | |
112 | - return $success; |
|
112 | + return $success; |
|
113 | 113 | } |
@@ -13,80 +13,80 @@ |
||
13 | 13 | */ |
14 | 14 | function boincteam_forum_views_data() { |
15 | 15 | |
16 | - // ----------------------------------------------------------------------------------------------- |
|
17 | - // Definition for team table |
|
18 | - // ----------------------------------------------------------------------------------------------- |
|
16 | + // ----------------------------------------------------------------------------------------------- |
|
17 | + // Definition for team table |
|
18 | + // ----------------------------------------------------------------------------------------------- |
|
19 | 19 | |
20 | - $data['boincteam_forum_node']['table']['group'] = t('BOINC'); |
|
20 | + $data['boincteam_forum_node']['table']['group'] = t('BOINC'); |
|
21 | 21 | |
22 | - $data['boincteam_forum_node']['table']['base'] = array( |
|
23 | - 'field' => 'nid', |
|
24 | - 'title' => t('BOINC team forum topic'), |
|
25 | - 'help' => t('Forum topics for a team'), |
|
26 | - ); |
|
22 | + $data['boincteam_forum_node']['table']['base'] = array( |
|
23 | + 'field' => 'nid', |
|
24 | + 'title' => t('BOINC team forum topic'), |
|
25 | + 'help' => t('Forum topics for a team'), |
|
26 | + ); |
|
27 | 27 | |
28 | - // Describe each of the individual fields in this table to Views. For |
|
29 | - // each field, you may define what field, sort, argument, and/or filter |
|
30 | - // handlers it supports. This will determine where in the Views interface you |
|
31 | - // may use the field. |
|
28 | + // Describe each of the individual fields in this table to Views. For |
|
29 | + // each field, you may define what field, sort, argument, and/or filter |
|
30 | + // handlers it supports. This will determine where in the Views interface you |
|
31 | + // may use the field. |
|
32 | 32 | |
33 | - // Primary keys allowed as arguments |
|
33 | + // Primary keys allowed as arguments |
|
34 | 34 | |
35 | - $data['boincteam_forum_node']['tfid'] = array( |
|
35 | + $data['boincteam_forum_node']['tfid'] = array( |
|
36 | 36 | 'title' => t('Team forum ID'), |
37 | 37 | 'help' => t('The ID of the team forum containing this topic.'), |
38 | 38 | 'field' => array( |
39 | - 'handler' => 'views_handler_field_numeric', |
|
40 | - 'click sortable' => TRUE |
|
39 | + 'handler' => 'views_handler_field_numeric', |
|
40 | + 'click sortable' => TRUE |
|
41 | 41 | ), |
42 | 42 | 'argument' => array( |
43 | - 'handler' => 'views_handler_argument_numeric', |
|
44 | - 'name field' => 'title', // the field to display in the summary. |
|
45 | - 'numeric' => TRUE, |
|
46 | - 'validate type' => 'id' |
|
43 | + 'handler' => 'views_handler_argument_numeric', |
|
44 | + 'name field' => 'title', // the field to display in the summary. |
|
45 | + 'numeric' => TRUE, |
|
46 | + 'validate type' => 'id' |
|
47 | 47 | ), |
48 | 48 | 'relationship' => array( |
49 | - 'base' => 'boincteam_forum', |
|
50 | - 'field' => 'tfid', |
|
51 | - 'handler' => 'views_handler_relationship', |
|
52 | - 'label' => t('Team Forum') |
|
49 | + 'base' => 'boincteam_forum', |
|
50 | + 'field' => 'tfid', |
|
51 | + 'handler' => 'views_handler_relationship', |
|
52 | + 'label' => t('Team Forum') |
|
53 | 53 | ), |
54 | 54 | 'filter' => array( |
55 | - 'handler' => 'views_handler_filter_numeric' |
|
55 | + 'handler' => 'views_handler_filter_numeric' |
|
56 | 56 | ), |
57 | 57 | 'sort' => array( |
58 | - 'handler' => 'views_handler_sort_numeric' |
|
58 | + 'handler' => 'views_handler_sort_numeric' |
|
59 | 59 | ) |
60 | - ); |
|
60 | + ); |
|
61 | 61 | |
62 | - // Foreign key fields |
|
62 | + // Foreign key fields |
|
63 | 63 | |
64 | - $data['boincteam_forum_node']['nid'] = array( |
|
64 | + $data['boincteam_forum_node']['nid'] = array( |
|
65 | 65 | 'title' => t('Team forum node'), |
66 | 66 | 'help' => t('The node containing the content of this team forum topic.'), |
67 | 67 | // This is a foreign key to the {node} table. When the view is configured |
68 | 68 | // with this relationship, all the fields for the related user node will be |
69 | 69 | // available. |
70 | 70 | 'relationship' => array( |
71 | - 'base' => 'node', |
|
72 | - 'field' => 'nid', |
|
73 | - 'handler' => 'views_handler_relationship', |
|
74 | - 'label' => t('Team Forum Topic Node') |
|
71 | + 'base' => 'node', |
|
72 | + 'field' => 'nid', |
|
73 | + 'handler' => 'views_handler_relationship', |
|
74 | + 'label' => t('Team Forum Topic Node') |
|
75 | 75 | ), |
76 | 76 | 'field' => array( |
77 | - 'handler' => 'views_handler_field_numeric', |
|
78 | - 'click sortable' => TRUE |
|
77 | + 'handler' => 'views_handler_field_numeric', |
|
78 | + 'click sortable' => TRUE |
|
79 | 79 | ), |
80 | 80 | 'filter' => array( |
81 | - 'handler' => 'views_handler_filter_numeric' |
|
81 | + 'handler' => 'views_handler_filter_numeric' |
|
82 | 82 | ), |
83 | 83 | 'sort' => array( |
84 | - 'handler' => 'views_handler_sort_numeric' |
|
84 | + 'handler' => 'views_handler_sort_numeric' |
|
85 | 85 | ) |
86 | - ); |
|
86 | + ); |
|
87 | 87 | |
88 | - // Descriptions of general fields (alphabetized) |
|
89 | - // ... |
|
88 | + // Descriptions of general fields (alphabetized) |
|
89 | + // ... |
|
90 | 90 | |
91 | - return $data; |
|
91 | + return $data; |
|
92 | 92 | } |
@@ -7,15 +7,15 @@ |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | class views_handler_argument_boincuser_id extends views_handler_argument_numeric { |
10 | - function construct() { |
|
10 | + function construct() { |
|
11 | 11 | parent::construct(); |
12 | - } |
|
12 | + } |
|
13 | 13 | |
14 | - function set_argument($arg) { |
|
14 | + function set_argument($arg) { |
|
15 | 15 | // When setting the ID argument, convert to BOINC ID |
16 | 16 | $id = is_numeric($arg) ? $arg : 0; |
17 | 17 | $boinc_id = db_result(db_query("SELECT boinc_id FROM {boincuser} WHERE uid = %d", $id)); |
18 | 18 | $this->argument = $boinc_id; |
19 | 19 | return $this->validate_arg($boinc_id); |
20 | - } |
|
20 | + } |
|
21 | 21 | } |
@@ -6,15 +6,15 @@ |
||
6 | 6 | */ |
7 | 7 | |
8 | 8 | class views_handler_field_boincwork_host_app_et_avg extends views_handler_field { |
9 | - function construct() { |
|
9 | + function construct() { |
|
10 | 10 | parent::construct(); |
11 | - } |
|
11 | + } |
|
12 | 12 | |
13 | - function render($values) { |
|
13 | + function render($values) { |
|
14 | 14 | $gflops = 0; |
15 | 15 | if ($values->host_app_version_et_avg) { |
16 | - $gflops = 1e-9 / $values->host_app_version_et_avg; |
|
16 | + $gflops = 1e-9 / $values->host_app_version_et_avg; |
|
17 | 17 | } |
18 | 18 | return round($gflops, 2) . ' GFLOPS'; |
19 | - } |
|
19 | + } |
|
20 | 20 | } |
@@ -6,12 +6,12 @@ |
||
6 | 6 | */ |
7 | 7 | |
8 | 8 | class views_handler_field_boincwork_host_app_turnaround_avg extends views_handler_field { |
9 | - function construct() { |
|
9 | + function construct() { |
|
10 | 10 | parent::construct(); |
11 | - } |
|
11 | + } |
|
12 | 12 | |
13 | - function render($values) { |
|
13 | + function render($values) { |
|
14 | 14 | $time_in_days = $values->host_app_version_turnaround_avg / (24*60*60); |
15 | 15 | return round($time_in_days, 2) . ' ' . t('days'); |
16 | - } |
|
16 | + } |
|
17 | 17 | } |
@@ -6,11 +6,11 @@ |
||
6 | 6 | */ |
7 | 7 | |
8 | 8 | class views_handler_field_boincwork_app_version_number extends views_handler_field { |
9 | - function construct() { |
|
9 | + function construct() { |
|
10 | 10 | parent::construct(); |
11 | - } |
|
11 | + } |
|
12 | 12 | |
13 | - function render($values) { |
|
13 | + function render($values) { |
|
14 | 14 | return sprintf("%01.2f", $values->app_version_host_app_version_version_num / 100); |
15 | - } |
|
15 | + } |
|
16 | 16 | } |
@@ -7,185 +7,185 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | /** |
10 | - * The BOINC community form allows the setting of requirements for interaction |
|
11 | - * in the community sections of the site. |
|
12 | - */ |
|
10 | + * The BOINC community form allows the setting of requirements for interaction |
|
11 | + * in the community sections of the site. |
|
12 | + */ |
|
13 | 13 | function boinccore_admin_community(&$form_state) { |
14 | - $form = array(); |
|
15 | - $default = array( |
|
14 | + $form = array(); |
|
15 | + $default = array( |
|
16 | 16 | 'min_credit_to_post' => variable_get('boinc_comment_min_credit', 0), |
17 | 17 | 'penalty_period' => variable_get('boinc_penalty_period', 7*24*60*60), |
18 | 18 | 'moderator_mailing_list' => variable_get('boinc_moderator_mailing_list', ''), |
19 | 19 | 'moderator_force_individual_notifications' => variable_get('boinc_moderator_force_individual_notifications', 0), |
20 | - ); |
|
20 | + ); |
|
21 | 21 | |
22 | - // Define the form |
|
23 | - $form['boinc_comment_min_credit'] = array( |
|
22 | + // Define the form |
|
23 | + $form['boinc_comment_min_credit'] = array( |
|
24 | 24 | '#type' => 'textfield', |
25 | 25 | '#title' => t('Credit required for community participation'), |
26 | 26 | '#default_value' => $default['min_credit_to_post'], |
27 | 27 | '#description' => t('Set a minimum threshold of credit a user must have |
28 | 28 | earned before being allowed to create a profile, post comments or participate in forums.'), |
29 | - ); |
|
30 | - $form['boinc_penalty_period'] = array( |
|
29 | + ); |
|
30 | + $form['boinc_penalty_period'] = array( |
|
31 | 31 | '#type' => 'textfield', |
32 | 32 | '#title' => t('Penalty period'), |
33 | 33 | '#default_value' => $default['penalty_period'], |
34 | 34 | '#description' => t('The amount of time (in seconds) that user privileges |
35 | 35 | are revoked when a user is banned from community participation.'), |
36 | - ); |
|
37 | - $form['boinc_moderator_mailing_list'] = array( |
|
36 | + ); |
|
37 | + $form['boinc_moderator_mailing_list'] = array( |
|
38 | 38 | '#type' => 'textfield', |
39 | 39 | '#title' => t('Moderator mailing list'), |
40 | 40 | '#default_value' => $default['moderator_mailing_list'], |
41 | 41 | '#description' => t('As an alternative to sending moderator notifications |
42 | 42 | to individual users with the moderator role, enter a mailing list address |
43 | 43 | here to be the only target of the notification emails.'), |
44 | - ); |
|
45 | - $form['boinc_moderator_force_individual_notifications'] = array( |
|
44 | + ); |
|
45 | + $form['boinc_moderator_force_individual_notifications'] = array( |
|
46 | 46 | '#type' => 'checkbox', |
47 | 47 | '#title' => t('Always send individual notifications'), |
48 | 48 | '#default_value' => $default['moderator_force_individual_notifications'], |
49 | 49 | '#description' => t('Continue to send individual moderator notification |
50 | 50 | emails even when a mailing list is provided.'), |
51 | - ); |
|
51 | + ); |
|
52 | 52 | |
53 | - $form['tools'] = array( |
|
53 | + $form['tools'] = array( |
|
54 | 54 | '#title' => t('Tools'), |
55 | 55 | '#type' => 'fieldset', |
56 | 56 | '#description' => '', |
57 | 57 | '#collapsible' => TRUE, |
58 | 58 | '#collapsed' => FALSE, |
59 | 59 | '#attributes' => array('class' => '') |
60 | - ); |
|
61 | - $form['tools']['reset_uotd'] = array( |
|
60 | + ); |
|
61 | + $form['tools']['reset_uotd'] = array( |
|
62 | 62 | '#type' => 'submit', |
63 | 63 | '#value' => t('Force new UOTD'), |
64 | 64 | '#submit' => array('boinccore_reset_user_of_the_day'), |
65 | - ); |
|
65 | + ); |
|
66 | 66 | |
67 | - return system_settings_form($form); |
|
67 | + return system_settings_form($form); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
71 | - * Validate the BOINC community form. |
|
72 | - */ |
|
71 | + * Validate the BOINC community form. |
|
72 | + */ |
|
73 | 73 | function boinccore_admin_community_validate($form, &$form_state) { |
74 | - $values = $form_state['values']; |
|
75 | - if (!is_numeric($values['boinc_comment_min_credit'])) { |
|
74 | + $values = $form_state['values']; |
|
75 | + if (!is_numeric($values['boinc_comment_min_credit'])) { |
|
76 | 76 | form_set_error('boinc_comment_min_credit', t('The minimum credit value must be a number.')); |
77 | - } |
|
77 | + } |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
81 | - * Handle post-validation submission of BOINC community form. |
|
82 | - */ |
|
81 | + * Handle post-validation submission of BOINC community form. |
|
82 | + */ |
|
83 | 83 | function boinccore_admin_community_submit($form, &$form_state) { |
84 | - drupal_set_message(t('BOINC community settings have been updated.')); |
|
84 | + drupal_set_message(t('BOINC community settings have been updated.')); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
88 | 88 | * Force a reset of the user of the day |
89 | 89 | */ |
90 | 90 | function boinccore_reset_user_of_the_day() { |
91 | - if (boincuser_select_user_of_the_day()) { |
|
91 | + if (boincuser_select_user_of_the_day()) { |
|
92 | 92 | drupal_set_message(t('The user of the day has been reset.')); |
93 | - } |
|
93 | + } |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
97 | - * The standard page generator form provides an interface to create standard |
|
98 | - * pages, such as a Help or About page. |
|
99 | - */ |
|
97 | + * The standard page generator form provides an interface to create standard |
|
98 | + * pages, such as a Help or About page. |
|
99 | + */ |
|
100 | 100 | function boinccore_admin_default_content(&$form_state) { |
101 | - $form = array(); |
|
101 | + $form = array(); |
|
102 | 102 | |
103 | - // Define the form |
|
104 | - $form['page'] = array( |
|
103 | + // Define the form |
|
104 | + $form['page'] = array( |
|
105 | 105 | '#type' => 'select', |
106 | 106 | '#title' => t('Generate default content for'), |
107 | 107 | '#options' => array( |
108 | - 0 => t('all standard pages'), |
|
108 | + 0 => t('all standard pages'), |
|
109 | 109 | // 'about' => t('About page'), |
110 | - 'help' => t('Help page'), |
|
110 | + 'help' => t('Help page'), |
|
111 | 111 | ), |
112 | - ); |
|
113 | - $form['submit'] = array( |
|
112 | + ); |
|
113 | + $form['submit'] = array( |
|
114 | 114 | '#type' => 'submit', |
115 | 115 | '#value' => 'Generate content', |
116 | - ); |
|
116 | + ); |
|
117 | 117 | |
118 | - return $form; |
|
118 | + return $form; |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
122 | - * Generate content based on the selection made on the form |
|
123 | - */ |
|
122 | + * Generate content based on the selection made on the form |
|
123 | + */ |
|
124 | 124 | function boinccore_admin_default_content_submit($form, &$form_state) { |
125 | - $option = $form_state['values']['page']; |
|
126 | - $page_list = boinccore_admin_default_content_generate($option); |
|
127 | - $pages_generated = count($page_list); |
|
128 | - if ($pages_generated > 0) { |
|
125 | + $option = $form_state['values']['page']; |
|
126 | + $page_list = boinccore_admin_default_content_generate($option); |
|
127 | + $pages_generated = count($page_list); |
|
128 | + if ($pages_generated > 0) { |
|
129 | 129 | switch ($pages_generated) { |
130 | 130 | case 1: |
131 | 131 | $page_list = reset($page_list); |
132 | - break; |
|
132 | + break; |
|
133 | 133 | case 2: |
134 | 134 | $page_list = implode(' and ', $page_list); |
135 | - break; |
|
135 | + break; |
|
136 | 136 | default: |
137 | 137 | end($page_list); |
138 | - $page_list[key($page_list)] = 'and ' . $page_list[key($page_list)]; |
|
139 | - $page_list = implode(', ', $page_list); |
|
138 | + $page_list[key($page_list)] = 'and ' . $page_list[key($page_list)]; |
|
139 | + $page_list = implode(', ', $page_list); |
|
140 | 140 | } |
141 | 141 | drupal_set_message(t('Default content has been generated for the @listed |
142 | 142 | @pages.', array( |
143 | 143 | '@listed' => $page_list, |
144 | 144 | '@pages' => format_plural($pages_generated, 'page', 'pages'), |
145 | - ) |
|
145 | + ) |
|
146 | 146 | )); |
147 | - } |
|
148 | - else { |
|
147 | + } |
|
148 | + else { |
|
149 | 149 | if ($option) { |
150 | - drupal_set_message(t('The @specified page already exists.', |
|
150 | + drupal_set_message(t('The @specified page already exists.', |
|
151 | 151 | array('@specified' => $option)), 'warning'); |
152 | 152 | } |
153 | 153 | else { |
154 | - drupal_set_message(t('All pages already exist, so none can be recreated |
|
154 | + drupal_set_message(t('All pages already exist, so none can be recreated |
|
155 | 155 | automatically.'), 'warning'); |
156 | 156 | } |
157 | 157 | drupal_set_message(t('To recreate a page, first delete the existing page (or |
158 | 158 | remove its URL alias), then try this function again.'), 'warning'); |
159 | - } |
|
159 | + } |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
163 | - * |
|
164 | - */ |
|
163 | + * |
|
164 | + */ |
|
165 | 165 | function boinccore_admin_default_content_generate($pages = array()) { |
166 | - if (!$pages) { |
|
166 | + if (!$pages) { |
|
167 | 167 | // If not specified, attempt to generate all pages by default |
168 | 168 | $pages = array( |
169 | - 'help', |
|
169 | + 'help', |
|
170 | 170 | // 'about', |
171 | 171 | ); |
172 | - } |
|
173 | - elseif (!is_array($pages)) { |
|
172 | + } |
|
173 | + elseif (!is_array($pages)) { |
|
174 | 174 | $pages = array($pages); |
175 | - } |
|
176 | - $pages_generated = array(); |
|
177 | - if (in_array('about', $pages)) { |
|
175 | + } |
|
176 | + $pages_generated = array(); |
|
177 | + if (in_array('about', $pages)) { |
|
178 | 178 | // Create the default About page, if it doesn't exist |
179 | 179 | // TODO: what is the default About page...? |
180 | 180 | if (!drupal_lookup_path('source', 'about')) { |
181 | - drupal_set_message('The about page doesn\'t yet have a definition...', 'warning'); |
|
182 | - //$pages_generated[] = 'about'; |
|
181 | + drupal_set_message('The about page doesn\'t yet have a definition...', 'warning'); |
|
182 | + //$pages_generated[] = 'about'; |
|
183 | + } |
|
183 | 184 | } |
184 | - } |
|
185 | - if (in_array('help', $pages)) { |
|
185 | + if (in_array('help', $pages)) { |
|
186 | 186 | // Create the default Help page, if it doesn't exist |
187 | 187 | if (!drupal_lookup_path('source', 'help')) { |
188 | - $node = array( |
|
188 | + $node = array( |
|
189 | 189 | 'type' => 'page', |
190 | 190 | 'title' => t('Help'), |
191 | 191 | 'uid' => 1, |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | 'comment' => 0, // disable comments |
199 | 199 | 'moderate' => 0, |
200 | 200 | 'body' => preg_replace('/>\s+</', '><', |
201 | - '<p>Use this page to provide help and support for your site\'s |
|
201 | + '<p>Use this page to provide help and support for your site\'s |
|
202 | 202 | visitors:</p> |
203 | 203 | <ul> |
204 | 204 | <li>Add a link to your primary forum for getting help</li> |
@@ -209,21 +209,21 @@ discard block |
||
209 | 209 | 'sticky' => 0, |
210 | 210 | 'format' => 4, |
211 | 211 | //'teaser' => $teaser, |
212 | - ); |
|
213 | - $node = (object) $node; // node_save requires an object |
|
214 | - node_save($node); |
|
212 | + ); |
|
213 | + $node = (object) $node; // node_save requires an object |
|
214 | + node_save($node); |
|
215 | 215 | |
216 | - $item = array( |
|
216 | + $item = array( |
|
217 | 217 | 'link_path' => drupal_get_normal_path('help'), |
218 | 218 | 'link_title' => t('Help'), |
219 | 219 | 'menu_name' => 'primary-links', |
220 | 220 | 'weight' => 50, |
221 | - ); |
|
222 | - menu_link_save($item); |
|
223 | - $pages_generated[] = 'help'; |
|
221 | + ); |
|
222 | + menu_link_save($item); |
|
223 | + $pages_generated[] = 'help'; |
|
224 | + } |
|
224 | 225 | } |
225 | - } |
|
226 | - // Refresh the cache with these changes |
|
227 | - menu_cache_clear_all(); |
|
228 | - return $pages_generated; |
|
226 | + // Refresh the cache with these changes |
|
227 | + menu_cache_clear_all(); |
|
228 | + return $pages_generated; |
|
229 | 229 | } |
@@ -11,56 +11,56 @@ discard block |
||
11 | 11 | * at a time and avoid exhausting memory. |
12 | 12 | */ |
13 | 13 | |
14 | - require_once('./includes/bootstrap.inc'); |
|
15 | - drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); |
|
16 | - require_boinc('db'); |
|
14 | + require_once('./includes/bootstrap.inc'); |
|
15 | + drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); |
|
16 | + require_boinc('db'); |
|
17 | 17 | |
18 | - // Parse arguments |
|
19 | - $team_id = isset($argv[1]) ? $argv[1] : null; |
|
20 | - $team_type_tid = isset($argv[2]) ? $argv[2] : null; |
|
21 | - $input_format = isset($argv[3]) ? $argv[3] : null; |
|
18 | + // Parse arguments |
|
19 | + $team_id = isset($argv[1]) ? $argv[1] : null; |
|
20 | + $team_type_tid = isset($argv[2]) ? $argv[2] : null; |
|
21 | + $input_format = isset($argv[3]) ? $argv[3] : null; |
|
22 | 22 | |
23 | - $count = 0; |
|
23 | + $count = 0; |
|
24 | 24 | |
25 | - // Get teams from BOINC |
|
26 | - db_set_active('boinc'); |
|
27 | - $boincteam = db_fetch_object(db_query('SELECT * FROM team WHERE id=%d', array($team_id))); |
|
28 | - $boincteam_members = db_query('SELECT id FROM user WHERE teamid=%d', array($team_id)); |
|
29 | - $boincteam_admin = (int) db_result(db_query('SELECT userid FROM team_admin WHERE teamid=%d', array($team_id))); |
|
30 | - db_set_active('default'); |
|
25 | + // Get teams from BOINC |
|
26 | + db_set_active('boinc'); |
|
27 | + $boincteam = db_fetch_object(db_query('SELECT * FROM team WHERE id=%d', array($team_id))); |
|
28 | + $boincteam_members = db_query('SELECT id FROM user WHERE teamid=%d', array($team_id)); |
|
29 | + $boincteam_admin = (int) db_result(db_query('SELECT userid FROM team_admin WHERE teamid=%d', array($team_id))); |
|
30 | + db_set_active('default'); |
|
31 | 31 | |
32 | - $team_exists = db_query('SELECT team_id FROM {boincteam} WHERE team_id = %d', $boincteam->id); |
|
33 | - // FIXME: $team_exists==FALSE should be handled as an error and return an error code! |
|
32 | + $team_exists = db_query('SELECT team_id FROM {boincteam} WHERE team_id = %d', $boincteam->id); |
|
33 | + // FIXME: $team_exists==FALSE should be handled as an error and return an error code! |
|
34 | 34 | |
35 | - if ($team_exists != FALSE && db_fetch_object($team_exists) == FALSE) { |
|
35 | + if ($team_exists != FALSE && db_fetch_object($team_exists) == FALSE) { |
|
36 | 36 | $boincteam->description = _boincimport_text_sanitize($boincteam->description); |
37 | 37 | $teaser = node_teaser($boincteam->description); |
38 | 38 | |
39 | 39 | // Construct the team as an organic group node |
40 | 40 | $node = array( |
41 | - 'type' => 'team', |
|
42 | - 'title' => $boincteam->name, |
|
43 | - 'body' => $boincteam->description, |
|
44 | - 'teaser' => $teaser, |
|
45 | - 'uid' => boincuser_lookup_uid($boincteam->userid), |
|
46 | - 'path' => null, |
|
47 | - 'status' => 1, // published or not - always publish |
|
48 | - 'promote' => 0, |
|
49 | - 'created' => $boincteam->create_time, |
|
50 | - 'comment' => 0, // comments disabled |
|
51 | - 'moderate' => 0, |
|
52 | - 'sticky' => 0, |
|
53 | - 'format' => $input_format |
|
41 | + 'type' => 'team', |
|
42 | + 'title' => $boincteam->name, |
|
43 | + 'body' => $boincteam->description, |
|
44 | + 'teaser' => $teaser, |
|
45 | + 'uid' => boincuser_lookup_uid($boincteam->userid), |
|
46 | + 'path' => null, |
|
47 | + 'status' => 1, // published or not - always publish |
|
48 | + 'promote' => 0, |
|
49 | + 'created' => $boincteam->create_time, |
|
50 | + 'comment' => 0, // comments disabled |
|
51 | + 'moderate' => 0, |
|
52 | + 'sticky' => 0, |
|
53 | + 'format' => $input_format |
|
54 | 54 | ); |
55 | 55 | |
56 | 56 | // Use pathauto function, if available, to clean up the path |
57 | 57 | if (module_exists('pathauto')) { |
58 | - module_load_include('inc', 'pathauto', 'pathauto'); |
|
59 | - $node['path'] = pathauto_cleanstring($boincteam->name); |
|
58 | + module_load_include('inc', 'pathauto', 'pathauto'); |
|
59 | + $node['path'] = pathauto_cleanstring($boincteam->name); |
|
60 | 60 | } |
61 | 61 | else { |
62 | - echo 'Pathauto module is required!'; |
|
63 | - exit; |
|
62 | + echo 'Pathauto module is required!'; |
|
63 | + exit; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | $node = (object) $node; // node_save requires an object form |
@@ -72,22 +72,22 @@ discard block |
||
72 | 72 | |
73 | 73 | // Save the team IDs to a BOINC <--> Drupal reference table. |
74 | 74 | db_query('INSERT INTO {boincteam} (team_id, nid) VALUES (%d, %d)', $boincteam->id, $node->nid); |
75 | - } |
|
75 | + } |
|
76 | 76 | |
77 | - // Determine team membership |
|
78 | - db_set_active('boinc'); |
|
79 | - $boincteam_member_ids = array(); |
|
80 | - while ($boincuser = db_fetch_object($boincteam_members)) $boincteam_member_ids[] = $boincuser->id; |
|
81 | - db_set_active('default'); |
|
82 | - if ($boincteam_member_ids) { |
|
77 | + // Determine team membership |
|
78 | + db_set_active('boinc'); |
|
79 | + $boincteam_member_ids = array(); |
|
80 | + while ($boincuser = db_fetch_object($boincteam_members)) $boincteam_member_ids[] = $boincuser->id; |
|
81 | + db_set_active('default'); |
|
82 | + if ($boincteam_member_ids) { |
|
83 | 83 | $team_members = db_query('SELECT uid FROM {boincuser} WHERE boinc_id IN(%s)', implode(',', $boincteam_member_ids)); |
84 | 84 | $team_admin = (int) db_result(db_query('SELECT uid FROM {boincuser} WHERE boinc_id=%d', $boincteam_admin)); |
85 | 85 | |
86 | 86 | while ($drupal_user = db_fetch_object($team_members)) { |
87 | - // Add action to take on member accounts? |
|
88 | - $count++; |
|
87 | + // Add action to take on member accounts? |
|
88 | + $count++; |
|
89 | + } |
|
89 | 90 | } |
90 | - } |
|
91 | 91 | |
92 | - echo $count; |
|
93 | - |
|
94 | 92 | \ No newline at end of file |
93 | + echo $count; |
|
94 | + |
|
95 | 95 | \ No newline at end of file |