@@ -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 |
@@ -12,33 +12,33 @@ |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | |
15 | - require_once('./includes/bootstrap.inc'); |
|
16 | - drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); |
|
17 | - require_boinc('db'); |
|
15 | + require_once('./includes/bootstrap.inc'); |
|
16 | + drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); |
|
17 | + require_boinc('db'); |
|
18 | 18 | |
19 | - // Parse arguments |
|
20 | - $record_offset = isset($argv[1]) ? $argv[1] : 0; |
|
21 | - $chunk_size = isset($argv[2]) ? $argv[2] : 100; |
|
19 | + // Parse arguments |
|
20 | + $record_offset = isset($argv[1]) ? $argv[1] : 0; |
|
21 | + $chunk_size = isset($argv[2]) ? $argv[2] : 100; |
|
22 | 22 | |
23 | - // Construct sql conditions |
|
24 | - $limit = sprintf('LIMIT %d,%d', $record_offset, $chunk_size); |
|
23 | + // Construct sql conditions |
|
24 | + $limit = sprintf('LIMIT %d,%d', $record_offset, $chunk_size); |
|
25 | 25 | |
26 | - $total_count = 0; |
|
26 | + $total_count = 0; |
|
27 | 27 | |
28 | - // Get the users with subscriptions to import |
|
29 | - db_set_active('boinc'); |
|
30 | - $subscribed_boinc_users = db_query(" |
|
28 | + // Get the users with subscriptions to import |
|
29 | + db_set_active('boinc'); |
|
30 | + $subscribed_boinc_users = db_query(" |
|
31 | 31 | SELECT DISTINCT userid FROM {subscriptions} |
32 | 32 | ORDER BY userid ASC %s", $limit |
33 | - ); |
|
34 | - db_set_active('default'); |
|
33 | + ); |
|
34 | + db_set_active('default'); |
|
35 | 35 | |
36 | - // Import subscriptions |
|
37 | - while ($boinc_subscription = db_fetch_object($subscribed_boinc_users)) { |
|
36 | + // Import subscriptions |
|
37 | + while ($boinc_subscription = db_fetch_object($subscribed_boinc_users)) { |
|
38 | 38 | $uid = get_drupal_id($boinc_subscription->userid); |
39 | 39 | $count = boincuser_pull_subscriptions($uid); |
40 | 40 | $total_count += $count; |
41 | 41 | echo "\nuser: {$uid}; boinc_id: {$boinc_subscription->userid}; {$count} subscriptions"; |
42 | - } |
|
43 | - echo "\n"; |
|
44 | - echo $total_count; |
|
45 | 42 | \ No newline at end of file |
43 | + } |
|
44 | + echo "\n"; |
|
45 | + echo $total_count; |
|
46 | 46 | \ No newline at end of file |
@@ -12,26 +12,26 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | |
15 | - require_once('./includes/bootstrap.inc'); |
|
16 | - drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); |
|
17 | - require_boinc('db'); |
|
15 | + require_once('./includes/bootstrap.inc'); |
|
16 | + drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); |
|
17 | + require_boinc('db'); |
|
18 | 18 | |
19 | - // Parse arguments |
|
20 | - $import_lurkers = isset($argv[1]) ? $argv[1] : false; |
|
21 | - $record_offset = isset($argv[2]) ? $argv[2] : 0; |
|
22 | - $chunk_size = isset($argv[3]) ? $argv[3] : 100; |
|
19 | + // Parse arguments |
|
20 | + $import_lurkers = isset($argv[1]) ? $argv[1] : false; |
|
21 | + $record_offset = isset($argv[2]) ? $argv[2] : 0; |
|
22 | + $chunk_size = isset($argv[3]) ? $argv[3] : 100; |
|
23 | 23 | |
24 | - // Construct sql conditions |
|
25 | - $limit = sprintf('LIMIT %d,%d', $record_offset, $chunk_size); |
|
24 | + // Construct sql conditions |
|
25 | + $limit = sprintf('LIMIT %d,%d', $record_offset, $chunk_size); |
|
26 | 26 | |
27 | - $count = 0; |
|
27 | + $count = 0; |
|
28 | 28 | |
29 | - db_set_active('boinc'); |
|
30 | - if ($import_lurkers) { |
|
29 | + db_set_active('boinc'); |
|
30 | + if ($import_lurkers) { |
|
31 | 31 | $boinc_accounts = db_query('SELECT id FROM user ORDER BY id %s', $limit); |
32 | - } |
|
33 | - //else $boinc_accounts = db_query('SELECT DISTINCT user AS boinc_id FROM post ORDER BY boinc_id %s', $limit); |
|
34 | - else { |
|
32 | + } |
|
33 | + //else $boinc_accounts = db_query('SELECT DISTINCT user AS boinc_id FROM post ORDER BY boinc_id %s', $limit); |
|
34 | + else { |
|
35 | 35 | // Need to import any user who is currently ignored in order to keep them |
36 | 36 | // ignored... not particularly clean (ignored users are stored in a string) |
37 | 37 | $ignored_user_list = array(); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | ORDER BY userid ASC" |
43 | 43 | ); |
44 | 44 | while ($ignoring_user = db_fetch_object($ignoring_users)) { |
45 | - $ignored_user_list = $ignored_user_list + array_fill_keys(explode('|', trim($ignoring_user->ignorelist, '|')), 1); |
|
45 | + $ignored_user_list = $ignored_user_list + array_fill_keys(explode('|', trim($ignoring_user->ignorelist, '|')), 1); |
|
46 | 46 | } |
47 | 47 | $ignored_user_list = array_keys($ignored_user_list); |
48 | 48 | $boinc_accounts = db_query(" |
@@ -58,14 +58,14 @@ discard block |
||
58 | 58 | (SELECT DISTINCT senderid FROM {private_messages}) |
59 | 59 | ) AS usersToImport ORDER BY id ASC %s", implode(',', $ignored_user_list), $limit |
60 | 60 | ); |
61 | - } |
|
62 | - db_set_active('default'); |
|
61 | + } |
|
62 | + db_set_active('default'); |
|
63 | 63 | |
64 | - while ($boinc_account = db_fetch_object($boinc_accounts)) { |
|
64 | + while ($boinc_account = db_fetch_object($boinc_accounts)) { |
|
65 | 65 | // Grab the BOINC user object and create a Drupal user from it |
66 | 66 | if (boincuser_register_make_drupal_user($boinc_account->id)) { |
67 | - $count++; |
|
67 | + $count++; |
|
68 | + } |
|
68 | 69 | } |
69 | - } |
|
70 | 70 | |
71 | - echo $count; |
|
72 | 71 | \ No newline at end of file |
72 | + echo $count; |
|
73 | 73 | \ No newline at end of file |