@@ -27,198 +27,198 @@ discard block |
||
27 | 27 | * with defined URL paths |
28 | 28 | */ |
29 | 29 | function boincuser_menu() { |
30 | - $items['account/posts'] = array( |
|
31 | - 'title' => 'Recent posts', |
|
32 | - 'description' => '', |
|
33 | - 'page callback' => 'boincuser_goto_recent_posts', |
|
34 | - 'access callback' => 'user_is_logged_in', |
|
35 | - 'type' => MENU_CALLBACK, |
|
36 | - ); |
|
37 | - $items['account/profile'] = array( |
|
38 | - 'title' => '', |
|
39 | - 'description' => '', |
|
40 | - 'page callback' => 'boincuser_view_profile', |
|
41 | - 'access callback' => 'user_is_logged_in', |
|
42 | - 'type' => MENU_NORMAL_ITEM |
|
43 | - ); |
|
44 | - $items['account/profile/view'] = array( |
|
45 | - 'title' => 'View', |
|
46 | - 'description' => 'Show a user profile', |
|
47 | - 'page callback' => 'boincuser_view_profile', |
|
48 | - 'access callback' => 'user_is_logged_in', |
|
49 | - 'type' => MENU_DEFAULT_LOCAL_TASK, |
|
50 | - 'weight' => 0 |
|
51 | - ); |
|
52 | - $items['account/profile/edit'] = array( |
|
53 | - 'title' => 'Edit', |
|
54 | - 'description' => 'Edit a user profile', |
|
55 | - 'page callback' => 'boincuser_edit_profile', |
|
56 | - 'access callback' => 'user_is_logged_in', |
|
57 | - 'type' => MENU_LOCAL_TASK, |
|
58 | - 'weight' => 5 |
|
59 | - ); |
|
60 | - $items['account/team'] = array( |
|
61 | - 'title' => 'User team', |
|
62 | - 'description' => '', |
|
63 | - 'page callback' => 'boincuser_goto_team', |
|
64 | - 'access callback' => 'user_is_logged_in', |
|
65 | - 'type' => MENU_CALLBACK, |
|
66 | - ); |
|
67 | - $items['moderate/profile/%user/approve'] = array( |
|
68 | - 'title' => 'Profile approval', |
|
69 | - 'description' => 'Approve profile content', |
|
70 | - 'page callback' => 'boincuser_moderate_profile_approve', |
|
71 | - 'page arguments' => array(2), |
|
72 | - 'access arguments' => array('edit any profile content'), |
|
73 | - 'type' => MENU_CALLBACK, |
|
74 | - 'weight' => 5 |
|
75 | - ); |
|
76 | - $items['moderate/profile/%user/edit'] = array( |
|
77 | - 'title' => 'Profile editor', |
|
78 | - 'description' => 'Edit a user profile', |
|
79 | - 'page callback' => 'boincuser_edit_profile', |
|
80 | - 'page arguments' => array(2), |
|
81 | - 'access arguments' => array('edit any profile content'), |
|
82 | - 'type' => MENU_CALLBACK, |
|
83 | - 'weight' => 5 |
|
84 | - ); |
|
85 | - $items['moderate/profile/%/reject'] = array( |
|
86 | - 'title' => bts('Reject profile', array(), NULL, 'boinc:moderate-user'), |
|
87 | - 'description' => 'Reject profile content', |
|
88 | - 'page callback' => 'drupal_get_form', |
|
89 | - 'page arguments' => array('boincuser_moderate_profile_reject_form', 2), |
|
90 | - 'access arguments' => array('edit any profile content'), |
|
91 | - 'type' => MENU_CALLBACK, |
|
92 | - 'weight' => 5 |
|
93 | - ); |
|
94 | - $items['moderate/user/%/ban'] = array( |
|
95 | - 'title' => bts('Ban user', array(), NULL, 'boinc:moderate-ban-user'), |
|
96 | - 'description' => 'Ban a user from using community features', |
|
97 | - 'page callback' => 'drupal_get_form', |
|
98 | - 'page arguments' => array('boincuser_moderate_user_ban_form', 2), |
|
99 | - 'access callback' => 'boincuser_moderate_community_access', |
|
100 | - 'type' => MENU_CALLBACK, |
|
101 | - ); |
|
102 | - $items['join'] = array( |
|
103 | - 'title' => '', |
|
104 | - 'description' => '', |
|
105 | - 'page callback' => 'join_page', |
|
106 | - 'access arguments' => array('access content'), |
|
107 | - 'type' => MENU_NORMAL_ITEM |
|
108 | - ); |
|
109 | - $items['join/new'] = array( |
|
110 | - 'title' => bts("I'm new"), |
|
111 | - 'page callback' => 'join_page', |
|
112 | - 'page arguments' => array(1), |
|
113 | - 'access arguments' => array('access content'), |
|
114 | - 'type' => MENU_DEFAULT_LOCAL_TASK, |
|
115 | - 'weight' => 0 |
|
116 | - ); |
|
117 | - $items['join/boinc'] = array( |
|
118 | - 'title' => bts("I'm a BOINC user"), |
|
119 | - 'page callback' => 'join_page', |
|
120 | - 'page arguments' => array(1), |
|
121 | - 'access arguments' => array('access content'), |
|
122 | - 'type' => MENU_LOCAL_TASK, |
|
123 | - 'weight' => 5 |
|
124 | - ); |
|
125 | - $items['user/login/auth'] = array( |
|
126 | - 'title' => bts('Authenticator login', array(), NULL, 'boinc:authenticator-login-page'), |
|
127 | - 'description' => 'Log in using a user authenticator', |
|
128 | - 'page callback' => 'drupal_get_form', |
|
129 | - 'page arguments' => array('boincuser_authloginform'), |
|
130 | - 'access arguments' => array('access content'), |
|
131 | - 'type' => MENU_CALLBACK, |
|
132 | - ); |
|
133 | - $items['user_control'] = array( |
|
134 | - 'page callback' => 'boincuser_control', |
|
135 | - 'access arguments' => array('access user profiles'), |
|
136 | - 'type' => MENU_CALLBACK |
|
137 | - ); |
|
138 | - $items['admin/boinc'] = array( |
|
139 | - 'title' => 'BOINC configuration', |
|
140 | - 'position' => 'right', |
|
141 | - 'weight' => -8, |
|
142 | - 'page callback' => 'system_admin_menu_block_page', |
|
143 | - 'access arguments' => array('administer site configuration'), |
|
144 | - 'file' => 'system.admin.inc', |
|
145 | - 'file path' => drupal_get_path('module', 'system'), |
|
146 | - ); |
|
147 | - $items['admin/boinc/environment'] = array( |
|
148 | - 'title' => 'Environment: General', |
|
149 | - 'description' => 'Set paths to BOINC functions and any other necessary |
|
30 | +$items['account/posts'] = array( |
|
31 | +'title' => 'Recent posts', |
|
32 | +'description' => '', |
|
33 | +'page callback' => 'boincuser_goto_recent_posts', |
|
34 | +'access callback' => 'user_is_logged_in', |
|
35 | +'type' => MENU_CALLBACK, |
|
36 | +); |
|
37 | +$items['account/profile'] = array( |
|
38 | +'title' => '', |
|
39 | +'description' => '', |
|
40 | +'page callback' => 'boincuser_view_profile', |
|
41 | +'access callback' => 'user_is_logged_in', |
|
42 | +'type' => MENU_NORMAL_ITEM |
|
43 | +); |
|
44 | +$items['account/profile/view'] = array( |
|
45 | +'title' => 'View', |
|
46 | +'description' => 'Show a user profile', |
|
47 | +'page callback' => 'boincuser_view_profile', |
|
48 | +'access callback' => 'user_is_logged_in', |
|
49 | +'type' => MENU_DEFAULT_LOCAL_TASK, |
|
50 | +'weight' => 0 |
|
51 | +); |
|
52 | +$items['account/profile/edit'] = array( |
|
53 | +'title' => 'Edit', |
|
54 | +'description' => 'Edit a user profile', |
|
55 | +'page callback' => 'boincuser_edit_profile', |
|
56 | +'access callback' => 'user_is_logged_in', |
|
57 | +'type' => MENU_LOCAL_TASK, |
|
58 | +'weight' => 5 |
|
59 | +); |
|
60 | +$items['account/team'] = array( |
|
61 | +'title' => 'User team', |
|
62 | +'description' => '', |
|
63 | +'page callback' => 'boincuser_goto_team', |
|
64 | +'access callback' => 'user_is_logged_in', |
|
65 | +'type' => MENU_CALLBACK, |
|
66 | +); |
|
67 | +$items['moderate/profile/%user/approve'] = array( |
|
68 | +'title' => 'Profile approval', |
|
69 | +'description' => 'Approve profile content', |
|
70 | +'page callback' => 'boincuser_moderate_profile_approve', |
|
71 | +'page arguments' => array(2), |
|
72 | +'access arguments' => array('edit any profile content'), |
|
73 | +'type' => MENU_CALLBACK, |
|
74 | +'weight' => 5 |
|
75 | +); |
|
76 | +$items['moderate/profile/%user/edit'] = array( |
|
77 | +'title' => 'Profile editor', |
|
78 | +'description' => 'Edit a user profile', |
|
79 | +'page callback' => 'boincuser_edit_profile', |
|
80 | +'page arguments' => array(2), |
|
81 | +'access arguments' => array('edit any profile content'), |
|
82 | +'type' => MENU_CALLBACK, |
|
83 | +'weight' => 5 |
|
84 | +); |
|
85 | +$items['moderate/profile/%/reject'] = array( |
|
86 | +'title' => bts('Reject profile', array(), NULL, 'boinc:moderate-user'), |
|
87 | +'description' => 'Reject profile content', |
|
88 | +'page callback' => 'drupal_get_form', |
|
89 | +'page arguments' => array('boincuser_moderate_profile_reject_form', 2), |
|
90 | +'access arguments' => array('edit any profile content'), |
|
91 | +'type' => MENU_CALLBACK, |
|
92 | +'weight' => 5 |
|
93 | +); |
|
94 | +$items['moderate/user/%/ban'] = array( |
|
95 | +'title' => bts('Ban user', array(), NULL, 'boinc:moderate-ban-user'), |
|
96 | +'description' => 'Ban a user from using community features', |
|
97 | +'page callback' => 'drupal_get_form', |
|
98 | +'page arguments' => array('boincuser_moderate_user_ban_form', 2), |
|
99 | +'access callback' => 'boincuser_moderate_community_access', |
|
100 | +'type' => MENU_CALLBACK, |
|
101 | +); |
|
102 | +$items['join'] = array( |
|
103 | +'title' => '', |
|
104 | +'description' => '', |
|
105 | +'page callback' => 'join_page', |
|
106 | +'access arguments' => array('access content'), |
|
107 | +'type' => MENU_NORMAL_ITEM |
|
108 | +); |
|
109 | +$items['join/new'] = array( |
|
110 | +'title' => bts("I'm new"), |
|
111 | +'page callback' => 'join_page', |
|
112 | +'page arguments' => array(1), |
|
113 | +'access arguments' => array('access content'), |
|
114 | +'type' => MENU_DEFAULT_LOCAL_TASK, |
|
115 | +'weight' => 0 |
|
116 | +); |
|
117 | +$items['join/boinc'] = array( |
|
118 | +'title' => bts("I'm a BOINC user"), |
|
119 | +'page callback' => 'join_page', |
|
120 | +'page arguments' => array(1), |
|
121 | +'access arguments' => array('access content'), |
|
122 | +'type' => MENU_LOCAL_TASK, |
|
123 | +'weight' => 5 |
|
124 | +); |
|
125 | +$items['user/login/auth'] = array( |
|
126 | +'title' => bts('Authenticator login', array(), NULL, 'boinc:authenticator-login-page'), |
|
127 | +'description' => 'Log in using a user authenticator', |
|
128 | +'page callback' => 'drupal_get_form', |
|
129 | +'page arguments' => array('boincuser_authloginform'), |
|
130 | +'access arguments' => array('access content'), |
|
131 | +'type' => MENU_CALLBACK, |
|
132 | +); |
|
133 | +$items['user_control'] = array( |
|
134 | +'page callback' => 'boincuser_control', |
|
135 | +'access arguments' => array('access user profiles'), |
|
136 | +'type' => MENU_CALLBACK |
|
137 | +); |
|
138 | +$items['admin/boinc'] = array( |
|
139 | +'title' => 'BOINC configuration', |
|
140 | +'position' => 'right', |
|
141 | +'weight' => -8, |
|
142 | +'page callback' => 'system_admin_menu_block_page', |
|
143 | +'access arguments' => array('administer site configuration'), |
|
144 | +'file' => 'system.admin.inc', |
|
145 | +'file path' => drupal_get_path('module', 'system'), |
|
146 | +); |
|
147 | +$items['admin/boinc/environment'] = array( |
|
148 | +'title' => 'Environment: General', |
|
149 | +'description' => 'Set paths to BOINC functions and any other necessary |
|
150 | 150 | variables that establish a BOINC environment.', |
151 | - 'page callback' => 'drupal_get_form', |
|
152 | - 'page arguments' => array('boincuser_admin_environment'), |
|
153 | - 'access arguments' => array('administer site configuration'), |
|
154 | - 'type' => MENU_NORMAL_ITEM, |
|
155 | - 'file' => 'boincuser.admin.inc' |
|
156 | - ); |
|
157 | - $items['admin/boinc/scheduler'] = array( |
|
158 | - 'title' => 'Environment: Scheduling server URLs', |
|
159 | - 'description' => 'Set BOINC scheduler options.', |
|
160 | - 'page callback' => 'drupal_get_form', |
|
161 | - 'page arguments' => array('boincuser_admin_scheduler'), |
|
162 | - 'access arguments' => array('administer site configuration'), |
|
163 | - 'type' => MENU_NORMAL_ITEM, |
|
164 | - 'file' => 'boincuser.admin.inc' |
|
165 | - ); |
|
166 | - $items['admin/boinc/weboptions'] = array( |
|
167 | - 'title' => 'Environment: Website Options', |
|
168 | - 'description' => 'Set options configuring this Drupal-BOINC Web site.', |
|
169 | - 'page callback' => 'drupal_get_form', |
|
170 | - 'page arguments' => array('boincuser_admin_weboptions'), |
|
171 | - 'access arguments' => array('administer site configuration'), |
|
172 | - 'type' => MENU_NORMAL_ITEM, |
|
173 | - 'file' => 'boincuser.admin.inc' |
|
174 | - ); |
|
151 | +'page callback' => 'drupal_get_form', |
|
152 | +'page arguments' => array('boincuser_admin_environment'), |
|
153 | +'access arguments' => array('administer site configuration'), |
|
154 | +'type' => MENU_NORMAL_ITEM, |
|
155 | +'file' => 'boincuser.admin.inc' |
|
156 | +); |
|
157 | +$items['admin/boinc/scheduler'] = array( |
|
158 | +'title' => 'Environment: Scheduling server URLs', |
|
159 | +'description' => 'Set BOINC scheduler options.', |
|
160 | +'page callback' => 'drupal_get_form', |
|
161 | +'page arguments' => array('boincuser_admin_scheduler'), |
|
162 | +'access arguments' => array('administer site configuration'), |
|
163 | +'type' => MENU_NORMAL_ITEM, |
|
164 | +'file' => 'boincuser.admin.inc' |
|
165 | +); |
|
166 | +$items['admin/boinc/weboptions'] = array( |
|
167 | +'title' => 'Environment: Website Options', |
|
168 | +'description' => 'Set options configuring this Drupal-BOINC Web site.', |
|
169 | +'page callback' => 'drupal_get_form', |
|
170 | +'page arguments' => array('boincuser_admin_weboptions'), |
|
171 | +'access arguments' => array('administer site configuration'), |
|
172 | +'type' => MENU_NORMAL_ITEM, |
|
173 | +'file' => 'boincuser.admin.inc' |
|
174 | +); |
|
175 | 175 | |
176 | - $items['create_account.php'] = array( |
|
177 | - 'title' => 'Create Account RPC', |
|
178 | - 'description' => 'RPC for creating user accounts.', |
|
179 | - 'page callback' => 'boincuser_create_account', |
|
180 | - 'access callback' => TRUE, |
|
181 | - 'type' => MENU_CALLBACK |
|
182 | - ); |
|
183 | - $items['account_finish.php'] = array( |
|
184 | - 'title' => 'Welcome to ' . variable_get('site_name', 'Drupal-BOINC'), |
|
185 | - 'description' => 'RPC for after a user has created an account.', |
|
186 | - 'page callback' => 'boincuser_account_finish', |
|
187 | - 'access callback' => TRUE, |
|
188 | - 'type' => MENU_CALLBACK, |
|
189 | - ); |
|
190 | - $items['boincuser/autocomplete'] = array( |
|
191 | - 'page callback' => '_boincuser_user_name_autocomplete', |
|
192 | - 'access callback' => TRUE, |
|
193 | - 'type' => MENU_CALLBACK, |
|
194 | - ); |
|
195 | - return $items; |
|
176 | +$items['create_account.php'] = array( |
|
177 | +'title' => 'Create Account RPC', |
|
178 | +'description' => 'RPC for creating user accounts.', |
|
179 | +'page callback' => 'boincuser_create_account', |
|
180 | +'access callback' => TRUE, |
|
181 | +'type' => MENU_CALLBACK |
|
182 | +); |
|
183 | +$items['account_finish.php'] = array( |
|
184 | +'title' => 'Welcome to ' . variable_get('site_name', 'Drupal-BOINC'), |
|
185 | +'description' => 'RPC for after a user has created an account.', |
|
186 | +'page callback' => 'boincuser_account_finish', |
|
187 | +'access callback' => TRUE, |
|
188 | +'type' => MENU_CALLBACK, |
|
189 | +); |
|
190 | +$items['boincuser/autocomplete'] = array( |
|
191 | +'page callback' => '_boincuser_user_name_autocomplete', |
|
192 | +'access callback' => TRUE, |
|
193 | +'type' => MENU_CALLBACK, |
|
194 | +); |
|
195 | +return $items; |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
199 | 199 | * |
200 | 200 | */ |
201 | 201 | function boincuser_init() { |
202 | - // Skip this check for charts, which are loaded separately |
|
203 | - // (may get duplicate or unexpected messages otherwise) |
|
204 | - if (substr($_GET['q'], 0, 7) == 'charts/') { |
|
205 | - return; |
|
206 | - } |
|
202 | +// Skip this check for charts, which are loaded separately |
|
203 | +// (may get duplicate or unexpected messages otherwise) |
|
204 | +if (substr($_GET['q'], 0, 7) == 'charts/') { |
|
205 | +return; |
|
206 | +} |
|
207 | 207 | |
208 | - // If admin user, do some basic site functionality checks |
|
209 | - if (user_access('administer site configuration')) { |
|
210 | - // Ensure we have a configured BOINC environment |
|
211 | - boinc_get_path(); |
|
212 | - boinc_get_scheduler_tags(); |
|
213 | - } |
|
208 | +// If admin user, do some basic site functionality checks |
|
209 | +if (user_access('administer site configuration')) { |
|
210 | +// Ensure we have a configured BOINC environment |
|
211 | +boinc_get_path(); |
|
212 | +boinc_get_scheduler_tags(); |
|
213 | +} |
|
214 | 214 | |
215 | - // Check credits for the verified contributor role |
|
216 | - boincuser_check_credit_requirements(); |
|
215 | +// Check credits for the verified contributor role |
|
216 | +boincuser_check_credit_requirements(); |
|
217 | 217 | |
218 | - if (module_exists('boincteam')) { |
|
219 | - // Display any persistent team messages |
|
220 | - boincteam_show_messages(); |
|
221 | - } |
|
218 | +if (module_exists('boincteam')) { |
|
219 | +// Display any persistent team messages |
|
220 | +boincteam_show_messages(); |
|
221 | +} |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | /** |
@@ -226,20 +226,20 @@ discard block |
||
226 | 226 | * Drupal user operations |
227 | 227 | */ |
228 | 228 | function boincuser_user($op, &$edit, &$account, $category = NULL) { |
229 | - // Handle BOINC integration for users with UID > 1 (skip anonymous and admin) |
|
230 | - if ($account->uid > 1) { |
|
231 | - switch($op) { |
|
232 | - case 'load': |
|
233 | - // User loading; insert BOINC data into the user object |
|
234 | - $drupal_user = db_fetch_object(db_query(" |
|
229 | +// Handle BOINC integration for users with UID > 1 (skip anonymous and admin) |
|
230 | +if ($account->uid > 1) { |
|
231 | +switch($op) { |
|
232 | +case 'load': |
|
233 | +// User loading; insert BOINC data into the user object |
|
234 | +$drupal_user = db_fetch_object(db_query(" |
|
235 | 235 | SELECT boinc_id, penalty_expiration |
236 | 236 | FROM {boincuser} WHERE uid = %d", |
237 | - $account->uid |
|
238 | - )); |
|
239 | - $account->boincuser_id = $drupal_user->boinc_id; |
|
240 | - $account->boincuser_penalty_expiration = $drupal_user->penalty_expiration; |
|
241 | - db_set_active('boinc_rw'); |
|
242 | - $boinc_user = db_fetch_object(db_query(" |
|
237 | +$account->uid |
|
238 | +)); |
|
239 | +$account->boincuser_id = $drupal_user->boinc_id; |
|
240 | +$account->boincuser_penalty_expiration = $drupal_user->penalty_expiration; |
|
241 | +db_set_active('boinc_rw'); |
|
242 | +$boinc_user = db_fetch_object(db_query(" |
|
243 | 243 | SELECT |
244 | 244 | name, |
245 | 245 | authenticator, |
@@ -252,28 +252,28 @@ discard block |
||
252 | 252 | venue |
253 | 253 | FROM {user} |
254 | 254 | WHERE id = %d", |
255 | - $account->boincuser_id |
|
256 | - )); |
|
257 | - $account->boincuser_name = $boinc_user->name; |
|
258 | - $account->boincuser_account_key = $boinc_user->authenticator; |
|
259 | - $account->boincuser_weak_auth = md5($boinc_user->authenticator . $boinc_user->passwd_hash); |
|
260 | - $account->boincuser_total_credit = round($boinc_user->total_credit); |
|
261 | - $account->boincuser_expavg_credit = round($boinc_user->expavg_credit); |
|
262 | - $account->boincuser_expavg_time = round($boinc_user->expavg_time); |
|
263 | - $account->boincuser_cpid = md5($boinc_user->cross_project_id . $account->mail); |
|
264 | - $account->boincuser_default_pref_set = $boinc_user->venue; |
|
265 | - $account->boincteam_id = $boinc_user->teamid; |
|
266 | - db_set_active('default'); |
|
267 | - // Set Drupal team ID |
|
268 | - $account->team = NULL; |
|
269 | - if ($account->boincteam_id) { |
|
270 | - $account->team = db_result(db_query(" |
|
255 | +$account->boincuser_id |
|
256 | +)); |
|
257 | +$account->boincuser_name = $boinc_user->name; |
|
258 | +$account->boincuser_account_key = $boinc_user->authenticator; |
|
259 | +$account->boincuser_weak_auth = md5($boinc_user->authenticator . $boinc_user->passwd_hash); |
|
260 | +$account->boincuser_total_credit = round($boinc_user->total_credit); |
|
261 | +$account->boincuser_expavg_credit = round($boinc_user->expavg_credit); |
|
262 | +$account->boincuser_expavg_time = round($boinc_user->expavg_time); |
|
263 | +$account->boincuser_cpid = md5($boinc_user->cross_project_id . $account->mail); |
|
264 | +$account->boincuser_default_pref_set = $boinc_user->venue; |
|
265 | +$account->boincteam_id = $boinc_user->teamid; |
|
266 | +db_set_active('default'); |
|
267 | +// Set Drupal team ID |
|
268 | +$account->team = NULL; |
|
269 | +if ($account->boincteam_id) { |
|
270 | +$account->team = db_result(db_query(" |
|
271 | 271 | SELECT nid FROM {boincteam} WHERE team_id = %d", |
272 | - $account->boincteam_id |
|
273 | - )); |
|
274 | - } |
|
275 | - // Set post count |
|
276 | - $account->post_count = db_result(db_query(" |
|
272 | +$account->boincteam_id |
|
273 | +)); |
|
274 | +} |
|
275 | +// Set post count |
|
276 | +$account->post_count = db_result(db_query(" |
|
277 | 277 | SELECT COUNT(*) + |
278 | 278 | ( |
279 | 279 | SELECT COUNT(*) FROM {node} |
@@ -285,13 +285,13 @@ discard block |
||
285 | 285 | INNER JOIN node ON comments.nid = node.nid |
286 | 286 | WHERE comments.uid = '%d' |
287 | 287 | AND node.status = 1", |
288 | - $account->uid, $account->uid |
|
289 | - )); |
|
290 | - break; |
|
288 | +$account->uid, $account->uid |
|
289 | +)); |
|
290 | +break; |
|
291 | 291 | |
292 | - case 'view': |
|
293 | - // SAMPLE: Add BOINC data to the user profile |
|
294 | - /*$account->content['summary']['boinc_id'] = array( |
|
292 | +case 'view': |
|
293 | +// SAMPLE: Add BOINC data to the user profile |
|
294 | +/*$account->content['summary']['boinc_id'] = array( |
|
295 | 295 | '#type' => 'user_profile_item', |
296 | 296 | '#title' => bts('BIONC ID'), |
297 | 297 | '#value' => $account->boincuser_id, |
@@ -305,137 +305,137 @@ discard block |
||
305 | 305 | '#attributes' => array('class' => 'boinc-data'), |
306 | 306 | '#weight' => 10 |
307 | 307 | );*/ |
308 | - break; |
|
308 | +break; |
|
309 | 309 | |
310 | - case 'validate': |
|
311 | - if (isset($edit['validation_source'])) { |
|
312 | - switch ($edit['validation_source']) { |
|
313 | - case 'user_register': |
|
314 | - // Information being checked before adding a user |
|
315 | - if (!boincuser_register_validate($edit)) { |
|
316 | - // BOINC user validation failed for registration; set an error accordingly |
|
317 | - form_set_error('mail', bts('An account already exists for @email. Log in or request password assistance to access your @project account.', array('@email' => $edit['mail'], '@project' => PROJECT), NULL, 'boinc:add-new-user')); |
|
318 | - } |
|
319 | - else { |
|
320 | - // Save profile information for use during Insert |
|
321 | - $_SESSION['profileInfo'] = array( |
|
322 | - 'country' => $edit['field_country'][0]['value'], |
|
323 | - 'zip' => $edit['field_zip'][0]['value'], |
|
324 | - 'url' => $edit['field_url'][0]['value'], |
|
325 | - 'background' => $edit['field_background'][0]['value'], |
|
326 | - 'opinions' => $edit['field_opinions'][0]['value'] |
|
327 | - ); |
|
328 | - // With BOINC validation passed, make sure name is unique |
|
329 | - $edit['name'] = create_proper_drupalname($edit['boincuser_name']); |
|
330 | - } |
|
331 | - break; |
|
310 | +case 'validate': |
|
311 | +if (isset($edit['validation_source'])) { |
|
312 | +switch ($edit['validation_source']) { |
|
313 | +case 'user_register': |
|
314 | +// Information being checked before adding a user |
|
315 | +if (!boincuser_register_validate($edit)) { |
|
316 | +// BOINC user validation failed for registration; set an error accordingly |
|
317 | +form_set_error('mail', bts('An account already exists for @email. Log in or request password assistance to access your @project account.', array('@email' => $edit['mail'], '@project' => PROJECT), NULL, 'boinc:add-new-user')); |
|
318 | +} |
|
319 | +else { |
|
320 | +// Save profile information for use during Insert |
|
321 | +$_SESSION['profileInfo'] = array( |
|
322 | +'country' => $edit['field_country'][0]['value'], |
|
323 | +'zip' => $edit['field_zip'][0]['value'], |
|
324 | +'url' => $edit['field_url'][0]['value'], |
|
325 | +'background' => $edit['field_background'][0]['value'], |
|
326 | +'opinions' => $edit['field_opinions'][0]['value'] |
|
327 | +); |
|
328 | +// With BOINC validation passed, make sure name is unique |
|
329 | +$edit['name'] = create_proper_drupalname($edit['boincuser_name']); |
|
330 | +} |
|
331 | +break; |
|
332 | 332 | |
333 | - case 'user_account': |
|
334 | - // Validate data before updating user account info |
|
335 | - boincuser_account_validate($edit, $account); |
|
336 | - break; |
|
333 | +case 'user_account': |
|
334 | +// Validate data before updating user account info |
|
335 | +boincuser_account_validate($edit, $account); |
|
336 | +break; |
|
337 | 337 | |
338 | - default: |
|
338 | +default: |
|
339 | 339 | |
340 | - } |
|
341 | - // We don't want to save validation source, so remove it |
|
342 | - $edit['validation_source'] = null; |
|
343 | - } |
|
344 | - break; |
|
340 | +} |
|
341 | + // We don't want to save validation source, so remove it |
|
342 | + $edit['validation_source'] = null; |
|
343 | + } |
|
344 | + break; |
|
345 | 345 | |
346 | - case 'insert': |
|
347 | - // New user being added to the system |
|
348 | - $profile_info = $_SESSION['profileInfo']; |
|
349 | - $imported = $_SESSION['importedUser']; |
|
350 | - unset($_SESSION['profileInfo']); |
|
351 | - unset($_SESSION['importedUser']); |
|
346 | +case 'insert': |
|
347 | + // New user being added to the system |
|
348 | + $profile_info = $_SESSION['profileInfo']; |
|
349 | + $imported = $_SESSION['importedUser']; |
|
350 | + unset($_SESSION['profileInfo']); |
|
351 | + unset($_SESSION['importedUser']); |
|
352 | 352 | |
353 | - watchdog( |
|
354 | - 'boincuser', |
|
355 | - 'Creating user account for %email_addr', |
|
356 | - array('%email_addr' => $edit['mail']), |
|
357 | - WATCHDOG_NOTICE |
|
358 | - ); |
|
353 | + watchdog( |
|
354 | + 'boincuser', |
|
355 | + 'Creating user account for %email_addr', |
|
356 | + array('%email_addr' => $edit['mail']), |
|
357 | + WATCHDOG_NOTICE |
|
358 | + ); |
|
359 | 359 | |
360 | - // NOTE: Registrations are normally handled via the create_account RPC, |
|
361 | - // so the following will not run (kept in case form registration is used) |
|
360 | + // NOTE: Registrations are normally handled via the create_account RPC, |
|
361 | + // so the following will not run (kept in case form registration is used) |
|
362 | 362 | |
363 | - // If from the registration form, create a BOINC user and relationships |
|
363 | + // If from the registration form, create a BOINC user and relationships |
|
364 | 364 | |
365 | - if ($profile_info and !$imported) { |
|
366 | - // Create a BOINC account unless importing from BOINC |
|
367 | - $user_params = array( |
|
368 | - 'email_addr' => $edit['mail'], |
|
369 | - 'name' => $edit['boincuser_name'], |
|
370 | - 'passwd_hash' => md5($edit['pass'].$edit['mail']), |
|
371 | - 'country' => $profile_info['country'], |
|
372 | - 'postal_code' => $profile_info['zip'] |
|
373 | - ); |
|
374 | - $boinc_user = boincuser_register_make_user($user_params); |
|
375 | - if (!$boinc_user) { |
|
376 | - // Account exists with this email addr |
|
377 | - form_set_error('email', bts('Error creating BOINC account.', array(), NULL, 'boinc:add-new-user')); |
|
378 | - return; |
|
379 | - } |
|
380 | - // Add user to community role by default (not banned) |
|
381 | - $unrestricted_role = array_search('community member', user_roles(true)); |
|
382 | - $edit['roles'] = array( |
|
383 | - $unrestricted_role => '' |
|
384 | - ); |
|
385 | - // Set profile data in BOINC db |
|
386 | - db_set_active('boinc_rw'); |
|
387 | - // TODO: add language, image support; error handling |
|
388 | - $reference = db_query("INSERT INTO {profile} SET userid='%d', response1='%s', response2='%s', verification=0", $boinc_user->id, $profile_info['background'], $profile_info['opinions']); |
|
389 | - if (!$reference) { |
|
390 | - drupal_set_message(t('Error creating BOINC profile.'), 'error'); |
|
391 | - } |
|
392 | - $reference = db_query("UPDATE {user} SET url='%s' WHERE id='%d'", $profile_info['url'], $boinc_user->id); |
|
393 | - if (!$reference) { |
|
394 | - drupal_set_message(t('Error updating BOINC account.'), 'error'); |
|
395 | - } |
|
396 | - db_set_active('default'); |
|
397 | - // Cross reference Drupal account with BOINC |
|
398 | - $reference = db_query("INSERT INTO {boincuser} SET uid='%d', boinc_id='%d'", $account->uid, $boinc_user->id); |
|
399 | - if (!$reference) { |
|
400 | - drupal_set_message(t('Error connecting BOINC account.'), 'error'); |
|
401 | - return; |
|
402 | - } |
|
403 | - // Don't save custom fields to the Drupal user object |
|
404 | - $edit['boincuser_name'] = null; |
|
405 | - } |
|
406 | - break; |
|
365 | + if ($profile_info and !$imported) { |
|
366 | + // Create a BOINC account unless importing from BOINC |
|
367 | + $user_params = array( |
|
368 | + 'email_addr' => $edit['mail'], |
|
369 | + 'name' => $edit['boincuser_name'], |
|
370 | + 'passwd_hash' => md5($edit['pass'].$edit['mail']), |
|
371 | + 'country' => $profile_info['country'], |
|
372 | + 'postal_code' => $profile_info['zip'] |
|
373 | + ); |
|
374 | + $boinc_user = boincuser_register_make_user($user_params); |
|
375 | + if (!$boinc_user) { |
|
376 | + // Account exists with this email addr |
|
377 | + form_set_error('email', bts('Error creating BOINC account.', array(), NULL, 'boinc:add-new-user')); |
|
378 | + return; |
|
379 | + } |
|
380 | + // Add user to community role by default (not banned) |
|
381 | + $unrestricted_role = array_search('community member', user_roles(true)); |
|
382 | + $edit['roles'] = array( |
|
383 | + $unrestricted_role => '' |
|
384 | + ); |
|
385 | + // Set profile data in BOINC db |
|
386 | + db_set_active('boinc_rw'); |
|
387 | + // TODO: add language, image support; error handling |
|
388 | + $reference = db_query("INSERT INTO {profile} SET userid='%d', response1='%s', response2='%s', verification=0", $boinc_user->id, $profile_info['background'], $profile_info['opinions']); |
|
389 | + if (!$reference) { |
|
390 | + drupal_set_message(t('Error creating BOINC profile.'), 'error'); |
|
391 | + } |
|
392 | + $reference = db_query("UPDATE {user} SET url='%s' WHERE id='%d'", $profile_info['url'], $boinc_user->id); |
|
393 | + if (!$reference) { |
|
394 | + drupal_set_message(t('Error updating BOINC account.'), 'error'); |
|
395 | + } |
|
396 | + db_set_active('default'); |
|
397 | + // Cross reference Drupal account with BOINC |
|
398 | + $reference = db_query("INSERT INTO {boincuser} SET uid='%d', boinc_id='%d'", $account->uid, $boinc_user->id); |
|
399 | + if (!$reference) { |
|
400 | + drupal_set_message(t('Error connecting BOINC account.'), 'error'); |
|
401 | + return; |
|
402 | + } |
|
403 | + // Don't save custom fields to the Drupal user object |
|
404 | + $edit['boincuser_name'] = null; |
|
405 | + } |
|
406 | + break; |
|
407 | 407 | |
408 | - case 'update': |
|
409 | - if (isset($edit['update_source'])) { |
|
410 | - require_boinc('boinc_db'); |
|
411 | - $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
412 | - switch ($edit['update_source']) { |
|
413 | - case 'user_account': |
|
414 | - // Ensure that BOINC data is altered |
|
415 | - $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
416 | - $changing_email = ($edit['mail'] AND $edit['mail'] != $boinc_user->email_addr) ? true : false; |
|
417 | - $changing_pass = ($edit['pass']) ? true : false; |
|
418 | - if ($changing_email OR $changing_pass) { |
|
419 | - // Set password hash appropriately |
|
420 | - $passwd = ($edit['pass']) ? $edit['pass'] : $edit['current_pass']; |
|
421 | - $passwd_hash = md5($passwd.$edit['mail']); |
|
422 | - $email_addr = $edit['mail']; |
|
423 | - // Update user account information |
|
424 | - $result = $boinc_user->update( |
|
425 | - "email_addr='{$email_addr}', passwd_hash='{$passwd_hash}'" |
|
426 | - ); |
|
427 | - } |
|
428 | - break; |
|
429 | - case 'user_profile': |
|
430 | - if ($edit['boincuser_name'] != $boinc_user->name) { |
|
431 | - $boincuser_name = $edit['boincuser_name']; |
|
432 | - $result = $boinc_user->update( |
|
433 | - "name='{$boincuser_name}'" |
|
434 | - ); |
|
435 | - } |
|
436 | - break; |
|
437 | - default: |
|
438 | - } |
|
408 | +case 'update': |
|
409 | + if (isset($edit['update_source'])) { |
|
410 | + require_boinc('boinc_db'); |
|
411 | + $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
412 | + switch ($edit['update_source']) { |
|
413 | + case 'user_account': |
|
414 | + // Ensure that BOINC data is altered |
|
415 | + $boinc_user = BoincUser::lookup_id($account->boincuser_id); |
|
416 | + $changing_email = ($edit['mail'] AND $edit['mail'] != $boinc_user->email_addr) ? true : false; |
|
417 | + $changing_pass = ($edit['pass']) ? true : false; |
|
418 | + if ($changing_email OR $changing_pass) { |
|
419 | + // Set password hash appropriately |
|
420 | + $passwd = ($edit['pass']) ? $edit['pass'] : $edit['current_pass']; |
|
421 | + $passwd_hash = md5($passwd.$edit['mail']); |
|
422 | + $email_addr = $edit['mail']; |
|
423 | + // Update user account information |
|
424 | + $result = $boinc_user->update( |
|
425 | + "email_addr='{$email_addr}', passwd_hash='{$passwd_hash}'" |
|
426 | + ); |
|
427 | + } |
|
428 | + break; |
|
429 | + case 'user_profile': |
|
430 | + if ($edit['boincuser_name'] != $boinc_user->name) { |
|
431 | + $boincuser_name = $edit['boincuser_name']; |
|
432 | + $result = $boinc_user->update( |
|
433 | + "name='{$boincuser_name}'" |
|
434 | + ); |
|
435 | + } |
|
436 | + break; |
|
437 | + default: |
|
438 | + } |
|
439 | 439 | // We don't want to save update source or duplicate custom fields, so |
440 | 440 | // remove them before continuing to core Drupal routines |
441 | 441 | $edit['update_source'] = null; |
@@ -443,12 +443,12 @@ discard block |
||
443 | 443 | } |
444 | 444 | break; |
445 | 445 | |
446 | - case 'delete': |
|
447 | - // Function is forward compatible to Drupal 7 |
|
448 | - boincuser_user_delete($account); |
|
449 | - break; |
|
446 | +case 'delete': |
|
447 | + // Function is forward compatible to Drupal 7 |
|
448 | + boincuser_user_delete($account); |
|
449 | + break; |
|
450 | 450 | |
451 | - default: |
|
451 | +default: |
|
452 | 452 | |
453 | 453 | } |
454 | 454 | } |
@@ -50,47 +50,47 @@ discard block |
||
50 | 50 | } |
51 | 51 | $resultLength = 0; |
52 | 52 | switch ($algo) { |
53 | - case PASSWORD_BCRYPT: |
|
54 | - $cost = PASSWORD_BCRYPT_DEFAULT_COST; |
|
55 | - if (isset($options['cost'])) { |
|
56 | - $cost = (int) $options['cost']; |
|
57 | - if ($cost < 4 || $cost > 31) { |
|
58 | - trigger_error(sprintf("password_hash(): Invalid bcrypt cost parameter specified: %d", $cost), E_USER_WARNING); |
|
59 | - return null; |
|
60 | - } |
|
53 | + case PASSWORD_BCRYPT: |
|
54 | + $cost = PASSWORD_BCRYPT_DEFAULT_COST; |
|
55 | + if (isset($options['cost'])) { |
|
56 | + $cost = (int) $options['cost']; |
|
57 | + if ($cost < 4 || $cost > 31) { |
|
58 | + trigger_error(sprintf("password_hash(): Invalid bcrypt cost parameter specified: %d", $cost), E_USER_WARNING); |
|
59 | + return null; |
|
61 | 60 | } |
62 | - // The length of salt to generate |
|
63 | - $raw_salt_len = 16; |
|
64 | - // The length required in the final serialization |
|
65 | - $required_salt_len = 22; |
|
66 | - $hash_format = sprintf("$2y$%02d$", $cost); |
|
67 | - // The expected length of the final crypt() output |
|
68 | - $resultLength = 60; |
|
69 | - break; |
|
70 | - default: |
|
71 | - trigger_error(sprintf("password_hash(): Unknown password hashing algorithm: %s", $algo), E_USER_WARNING); |
|
72 | - return null; |
|
61 | + } |
|
62 | + // The length of salt to generate |
|
63 | + $raw_salt_len = 16; |
|
64 | + // The length required in the final serialization |
|
65 | + $required_salt_len = 22; |
|
66 | + $hash_format = sprintf("$2y$%02d$", $cost); |
|
67 | + // The expected length of the final crypt() output |
|
68 | + $resultLength = 60; |
|
69 | + break; |
|
70 | + default: |
|
71 | + trigger_error(sprintf("password_hash(): Unknown password hashing algorithm: %s", $algo), E_USER_WARNING); |
|
72 | + return null; |
|
73 | 73 | } |
74 | 74 | $salt_req_encoding = false; |
75 | 75 | if (isset($options['salt'])) { |
76 | 76 | switch (gettype($options['salt'])) { |
77 | - case 'NULL': |
|
78 | - case 'boolean': |
|
79 | - case 'integer': |
|
80 | - case 'double': |
|
81 | - case 'string': |
|
77 | + case 'NULL': |
|
78 | + case 'boolean': |
|
79 | + case 'integer': |
|
80 | + case 'double': |
|
81 | + case 'string': |
|
82 | + $salt = (string) $options['salt']; |
|
83 | + break; |
|
84 | + case 'object': |
|
85 | + if (method_exists($options['salt'], '__tostring')) { |
|
82 | 86 | $salt = (string) $options['salt']; |
83 | 87 | break; |
84 | - case 'object': |
|
85 | - if (method_exists($options['salt'], '__tostring')) { |
|
86 | - $salt = (string) $options['salt']; |
|
87 | - break; |
|
88 | - } |
|
89 | - case 'array': |
|
90 | - case 'resource': |
|
91 | - default: |
|
92 | - trigger_error('password_hash(): Non-string salt parameter supplied', E_USER_WARNING); |
|
93 | - return null; |
|
88 | + } |
|
89 | + case 'array': |
|
90 | + case 'resource': |
|
91 | + default: |
|
92 | + trigger_error('password_hash(): Non-string salt parameter supplied', E_USER_WARNING); |
|
93 | + return null; |
|
94 | 94 | } |
95 | 95 | if (PasswordCompat\binary\_strlen($salt) < $required_salt_len) { |
96 | 96 | trigger_error(sprintf("password_hash(): Provided salt is too short: %d expecting %d", PasswordCompat\binary\_strlen($salt), $required_salt_len), E_USER_WARNING); |
@@ -212,12 +212,12 @@ discard block |
||
212 | 212 | return true; |
213 | 213 | } |
214 | 214 | switch ($algo) { |
215 | - case PASSWORD_BCRYPT: |
|
216 | - $cost = isset($options['cost']) ? (int) $options['cost'] : PASSWORD_BCRYPT_DEFAULT_COST; |
|
217 | - if ($cost !== $info['options']['cost']) { |
|
218 | - return true; |
|
219 | - } |
|
220 | - break; |
|
215 | + case PASSWORD_BCRYPT: |
|
216 | + $cost = isset($options['cost']) ? (int) $options['cost'] : PASSWORD_BCRYPT_DEFAULT_COST; |
|
217 | + if ($cost !== $info['options']['cost']) { |
|
218 | + return true; |
|
219 | + } |
|
220 | + break; |
|
221 | 221 | } |
222 | 222 | return false; |
223 | 223 | } |
@@ -50,11 +50,11 @@ |
||
50 | 50 | } |
51 | 51 | |
52 | 52 | switch ($this->options['format']) { |
53 | - case 'raw': |
|
54 | - $output = $value; |
|
55 | - break; |
|
56 | - default: |
|
57 | - $output = theme('filefield_meta_samplerate', $value); |
|
53 | + case 'raw': |
|
54 | + $output = $value; |
|
55 | + break; |
|
56 | + default: |
|
57 | + $output = theme('filefield_meta_samplerate', $value); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | return check_plain($this->options['prefix']) . $output . check_plain($this->options['suffix']); |
@@ -48,20 +48,20 @@ |
||
48 | 48 | $value = $values->{$this->field_alias}; |
49 | 49 | |
50 | 50 | switch ($this->options['format']) { |
51 | - case 'hours': |
|
52 | - $output = date('g', (int) $value); |
|
53 | - break; |
|
54 | - case 'minutes': |
|
55 | - $output = date('i', (int) $value); |
|
56 | - break; |
|
57 | - case 'seconds': |
|
58 | - $output = date('s', (int) $value); |
|
59 | - break; |
|
60 | - case 'total': |
|
61 | - $output = check_plain($value); |
|
62 | - break; |
|
63 | - default: |
|
64 | - $output = theme('filefield_meta_duration', $value); |
|
51 | + case 'hours': |
|
52 | + $output = date('g', (int) $value); |
|
53 | + break; |
|
54 | + case 'minutes': |
|
55 | + $output = date('i', (int) $value); |
|
56 | + break; |
|
57 | + case 'seconds': |
|
58 | + $output = date('s', (int) $value); |
|
59 | + break; |
|
60 | + case 'total': |
|
61 | + $output = check_plain($value); |
|
62 | + break; |
|
63 | + default: |
|
64 | + $output = theme('filefield_meta_duration', $value); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | // Check to see if hiding should happen before adding prefix and suffix. |
@@ -50,11 +50,11 @@ |
||
50 | 50 | } |
51 | 51 | |
52 | 52 | switch ($this->options['format']) { |
53 | - case 'raw': |
|
54 | - $output = $value; |
|
55 | - break; |
|
56 | - default: |
|
57 | - $output = theme('filefield_meta_bitrate', $value); |
|
53 | + case 'raw': |
|
54 | + $output = $value; |
|
55 | + break; |
|
56 | + default: |
|
57 | + $output = theme('filefield_meta_bitrate', $value); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | return check_plain($this->options['prefix']) . $output . check_plain($this->options['suffix']); |
@@ -22,19 +22,19 @@ discard block |
||
22 | 22 | unset($fields['table']); |
23 | 23 | foreach ($fields as $filefield_field => $definition) { |
24 | 24 | switch ($filefield_field) { |
25 | - case $content_field['field_name'] .'_fid': |
|
26 | - $filefield_fields[$filefield_field] = array( |
|
27 | - 'table' => $table, |
|
28 | - 'field' => $filefield_field, |
|
29 | - ); |
|
30 | - $filefield_arguments['content: '. $content_field['field_name']] = &$filefield_fields[$filefield_field]; |
|
31 | - break; |
|
32 | - case $content_field['field_name'] .'_list': |
|
33 | - $filefield_filters[$content_field['field_name'] .'_fid_not null'] = array( |
|
34 | - 'table' => $table, |
|
35 | - 'field' => $filefield_field, |
|
36 | - ); |
|
37 | - break; |
|
25 | + case $content_field['field_name'] .'_fid': |
|
26 | + $filefield_fields[$filefield_field] = array( |
|
27 | + 'table' => $table, |
|
28 | + 'field' => $filefield_field, |
|
29 | + ); |
|
30 | + $filefield_arguments['content: '. $content_field['field_name']] = &$filefield_fields[$filefield_field]; |
|
31 | + break; |
|
32 | + case $content_field['field_name'] .'_list': |
|
33 | + $filefield_filters[$content_field['field_name'] .'_fid_not null'] = array( |
|
34 | + 'table' => $table, |
|
35 | + 'field' => $filefield_field, |
|
36 | + ); |
|
37 | + break; |
|
38 | 38 | } |
39 | 39 | } |
40 | 40 | } |
@@ -43,39 +43,39 @@ discard block |
||
43 | 43 | } |
44 | 44 | } |
45 | 45 | switch ($type) { |
46 | - case 'field': |
|
47 | - if (isset($filefield_fields[$field['field']])) { |
|
48 | - $multiple = array(); |
|
49 | - switch ($field['handler']) { |
|
50 | - case 'content_views_field_handler_ungroup': |
|
51 | - $view->set_item_option($display, 'field', $id, 'multiple', array('group' => FALSE)); |
|
52 | - break; |
|
53 | - case 'content_views_field_handler_last': |
|
54 | - $multiple['multiple_reversed'] = TRUE; |
|
55 | - case 'content_views_field_handler_first': |
|
56 | - $multiple['multiple_number'] = 1; |
|
57 | - $view->set_item_option($display, 'field', $id, 'multiple', $multiple); |
|
58 | - break; |
|
59 | - } |
|
60 | - $view->set_item_option($display, 'field', $id, 'format', $field['options']); |
|
61 | - } |
|
46 | + case 'field': |
|
47 | + if (isset($filefield_fields[$field['field']])) { |
|
48 | + $multiple = array(); |
|
49 | + switch ($field['handler']) { |
|
50 | + case 'content_views_field_handler_ungroup': |
|
51 | + $view->set_item_option($display, 'field', $id, 'multiple', array('group' => FALSE)); |
|
62 | 52 | break; |
63 | - case 'filter': |
|
64 | - if (isset($filefield_filters[$field['field']])) { |
|
65 | - $filter = $filefield_filters[$field['field']]; |
|
66 | - $item = $view->get_item($display, 'filter', $id); |
|
67 | - $item['value'] = $field['value']; |
|
68 | - $item['table'] = $filter['table']; |
|
69 | - $item['field'] = $filter['field']; |
|
70 | - $view->set_item($display, 'filter', $id, $item); |
|
71 | - } |
|
53 | + case 'content_views_field_handler_last': |
|
54 | + $multiple['multiple_reversed'] = TRUE; |
|
55 | + case 'content_views_field_handler_first': |
|
56 | + $multiple['multiple_number'] = 1; |
|
57 | + $view->set_item_option($display, 'field', $id, 'multiple', $multiple); |
|
72 | 58 | break; |
73 | - case 'argument': |
|
74 | - if (isset($filefield_arguments[$field['type']])) { |
|
75 | - $argument = $filefield_arguments[$field['type']]; |
|
76 | - $options = $field['argoptions']; |
|
77 | - $view->add_item($display, 'argument', $argument['table'], $argument['field'], $options, $field['id']); |
|
59 | + } |
|
60 | + $view->set_item_option($display, 'field', $id, 'format', $field['options']); |
|
78 | 61 | } |
79 | 62 | break; |
63 | + case 'filter': |
|
64 | + if (isset($filefield_filters[$field['field']])) { |
|
65 | + $filter = $filefield_filters[$field['field']]; |
|
66 | + $item = $view->get_item($display, 'filter', $id); |
|
67 | + $item['value'] = $field['value']; |
|
68 | + $item['table'] = $filter['table']; |
|
69 | + $item['field'] = $filter['field']; |
|
70 | + $view->set_item($display, 'filter', $id, $item); |
|
71 | + } |
|
72 | + break; |
|
73 | + case 'argument': |
|
74 | + if (isset($filefield_arguments[$field['type']])) { |
|
75 | + $argument = $filefield_arguments[$field['type']]; |
|
76 | + $options = $field['argoptions']; |
|
77 | + $view->add_item($display, 'argument', $argument['table'], $argument['field'], $options, $field['id']); |
|
78 | + } |
|
79 | + break; |
|
80 | 80 | } |
81 | 81 | } |
@@ -123,126 +123,126 @@ |
||
123 | 123 | function _filefield_generic_icon_map($file) { |
124 | 124 | switch ($file['filemime']) { |
125 | 125 | // Word document types. |
126 | - case 'application/msword': |
|
127 | - case 'application/vnd.ms-word.document.macroEnabled.12': |
|
128 | - case 'application/vnd.oasis.opendocument.text': |
|
129 | - case 'application/vnd.oasis.opendocument.text-template': |
|
130 | - case 'application/vnd.oasis.opendocument.text-master': |
|
131 | - case 'application/vnd.oasis.opendocument.text-web': |
|
132 | - case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': |
|
133 | - case 'application/vnd.stardivision.writer': |
|
134 | - case 'application/vnd.sun.xml.writer': |
|
135 | - case 'application/vnd.sun.xml.writer.template': |
|
136 | - case 'application/vnd.sun.xml.writer.global': |
|
137 | - case 'application/vnd.wordperfect': |
|
138 | - case 'application/x-abiword': |
|
139 | - case 'application/x-applix-word': |
|
140 | - case 'application/x-kword': |
|
141 | - case 'application/x-kword-crypt': |
|
142 | - return 'x-office-document'; |
|
143 | - |
|
144 | - // Spreadsheet document types. |
|
145 | - case 'application/vnd.ms-excel': |
|
146 | - case 'application/vnd.ms-excel.sheet.macroEnabled.12': |
|
147 | - case 'application/vnd.oasis.opendocument.spreadsheet': |
|
148 | - case 'application/vnd.oasis.opendocument.spreadsheet-template': |
|
149 | - case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': |
|
150 | - case 'application/vnd.stardivision.calc': |
|
151 | - case 'application/vnd.sun.xml.calc': |
|
152 | - case 'application/vnd.sun.xml.calc.template': |
|
153 | - case 'application/vnd.lotus-1-2-3': |
|
154 | - case 'application/x-applix-spreadsheet': |
|
155 | - case 'application/x-gnumeric': |
|
156 | - case 'application/x-kspread': |
|
157 | - case 'application/x-kspread-crypt': |
|
158 | - return 'x-office-spreadsheet'; |
|
159 | - |
|
160 | - // Presentation document types. |
|
161 | - case 'application/vnd.ms-powerpoint': |
|
162 | - case 'application/vnd.ms-powerpoint.presentation.macroEnabled.12': |
|
163 | - case 'application/vnd.oasis.opendocument.presentation': |
|
164 | - case 'application/vnd.oasis.opendocument.presentation-template': |
|
165 | - case 'application/vnd.openxmlformats-officedocument.presentationml.presentation': |
|
166 | - case 'application/vnd.openxmlformats-officedocument.presentationml.slideshow': |
|
167 | - case 'application/vnd.stardivision.impress': |
|
168 | - case 'application/vnd.sun.xml.impress': |
|
169 | - case 'application/vnd.sun.xml.impress.template': |
|
170 | - case 'application/x-kpresenter': |
|
171 | - return 'x-office-presentation'; |
|
172 | - |
|
173 | - // Compressed archive types. |
|
174 | - case 'application/zip': |
|
175 | - case 'application/x-zip': |
|
176 | - case 'application/stuffit': |
|
177 | - case 'application/x-stuffit': |
|
178 | - case 'application/x-7z-compressed': |
|
179 | - case 'application/x-ace': |
|
180 | - case 'application/x-arj': |
|
181 | - case 'application/x-bzip': |
|
182 | - case 'application/x-bzip-compressed-tar': |
|
183 | - case 'application/x-compress': |
|
184 | - case 'application/x-compressed-tar': |
|
185 | - case 'application/x-cpio-compressed': |
|
186 | - case 'application/x-deb': |
|
187 | - case 'application/x-gzip': |
|
188 | - case 'application/x-java-archive': |
|
189 | - case 'application/x-lha': |
|
190 | - case 'application/x-lhz': |
|
191 | - case 'application/x-lzop': |
|
192 | - case 'application/x-rar': |
|
193 | - case 'application/x-rpm': |
|
194 | - case 'application/x-tzo': |
|
195 | - case 'application/x-tar': |
|
196 | - case 'application/x-tarz': |
|
197 | - case 'application/x-tgz': |
|
198 | - return 'package-x-generic'; |
|
199 | - |
|
200 | - // Script file types. |
|
201 | - case 'application/ecmascript': |
|
202 | - case 'application/javascript': |
|
203 | - case 'application/mathematica': |
|
204 | - case 'application/vnd.mozilla.xul+xml': |
|
205 | - case 'application/x-asp': |
|
206 | - case 'application/x-awk': |
|
207 | - case 'application/x-cgi': |
|
208 | - case 'application/x-csh': |
|
209 | - case 'application/x-m4': |
|
210 | - case 'application/x-perl': |
|
211 | - case 'application/x-php': |
|
212 | - case 'application/x-ruby': |
|
213 | - case 'application/x-shellscript': |
|
214 | - case 'text/vnd.wap.wmlscript': |
|
215 | - case 'text/x-emacs-lisp': |
|
216 | - case 'text/x-haskell': |
|
217 | - case 'text/x-literate-haskell': |
|
218 | - case 'text/x-lua': |
|
219 | - case 'text/x-makefile': |
|
220 | - case 'text/x-matlab': |
|
221 | - case 'text/x-python': |
|
222 | - case 'text/x-sql': |
|
223 | - case 'text/x-tcl': |
|
224 | - return 'text-x-script'; |
|
225 | - |
|
226 | - // HTML aliases. |
|
227 | - case 'application/xhtml+xml': |
|
228 | - return 'text-html'; |
|
229 | - |
|
230 | - // RTF files. |
|
231 | - case 'application/rtf': |
|
232 | - return 'text-rtf'; |
|
233 | - |
|
234 | - // Google earth files. |
|
235 | - case 'application/vnd.google-earth.kml+xml': |
|
236 | - case 'application/vnd.google-earth.kmz': |
|
237 | - return 'application-google-earth'; |
|
238 | - |
|
239 | - // Executable types. |
|
240 | - case 'application/x-macbinary': |
|
241 | - case 'application/x-ms-dos-executable': |
|
242 | - case 'application/x-pef-executable': |
|
243 | - return 'application-x-executable'; |
|
244 | - |
|
245 | - default: |
|
246 | - return FALSE; |
|
126 | + case 'application/msword': |
|
127 | + case 'application/vnd.ms-word.document.macroEnabled.12': |
|
128 | + case 'application/vnd.oasis.opendocument.text': |
|
129 | + case 'application/vnd.oasis.opendocument.text-template': |
|
130 | + case 'application/vnd.oasis.opendocument.text-master': |
|
131 | + case 'application/vnd.oasis.opendocument.text-web': |
|
132 | + case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': |
|
133 | + case 'application/vnd.stardivision.writer': |
|
134 | + case 'application/vnd.sun.xml.writer': |
|
135 | + case 'application/vnd.sun.xml.writer.template': |
|
136 | + case 'application/vnd.sun.xml.writer.global': |
|
137 | + case 'application/vnd.wordperfect': |
|
138 | + case 'application/x-abiword': |
|
139 | + case 'application/x-applix-word': |
|
140 | + case 'application/x-kword': |
|
141 | + case 'application/x-kword-crypt': |
|
142 | + return 'x-office-document'; |
|
143 | + |
|
144 | + // Spreadsheet document types. |
|
145 | + case 'application/vnd.ms-excel': |
|
146 | + case 'application/vnd.ms-excel.sheet.macroEnabled.12': |
|
147 | + case 'application/vnd.oasis.opendocument.spreadsheet': |
|
148 | + case 'application/vnd.oasis.opendocument.spreadsheet-template': |
|
149 | + case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': |
|
150 | + case 'application/vnd.stardivision.calc': |
|
151 | + case 'application/vnd.sun.xml.calc': |
|
152 | + case 'application/vnd.sun.xml.calc.template': |
|
153 | + case 'application/vnd.lotus-1-2-3': |
|
154 | + case 'application/x-applix-spreadsheet': |
|
155 | + case 'application/x-gnumeric': |
|
156 | + case 'application/x-kspread': |
|
157 | + case 'application/x-kspread-crypt': |
|
158 | + return 'x-office-spreadsheet'; |
|
159 | + |
|
160 | + // Presentation document types. |
|
161 | + case 'application/vnd.ms-powerpoint': |
|
162 | + case 'application/vnd.ms-powerpoint.presentation.macroEnabled.12': |
|
163 | + case 'application/vnd.oasis.opendocument.presentation': |
|
164 | + case 'application/vnd.oasis.opendocument.presentation-template': |
|
165 | + case 'application/vnd.openxmlformats-officedocument.presentationml.presentation': |
|
166 | + case 'application/vnd.openxmlformats-officedocument.presentationml.slideshow': |
|
167 | + case 'application/vnd.stardivision.impress': |
|
168 | + case 'application/vnd.sun.xml.impress': |
|
169 | + case 'application/vnd.sun.xml.impress.template': |
|
170 | + case 'application/x-kpresenter': |
|
171 | + return 'x-office-presentation'; |
|
172 | + |
|
173 | + // Compressed archive types. |
|
174 | + case 'application/zip': |
|
175 | + case 'application/x-zip': |
|
176 | + case 'application/stuffit': |
|
177 | + case 'application/x-stuffit': |
|
178 | + case 'application/x-7z-compressed': |
|
179 | + case 'application/x-ace': |
|
180 | + case 'application/x-arj': |
|
181 | + case 'application/x-bzip': |
|
182 | + case 'application/x-bzip-compressed-tar': |
|
183 | + case 'application/x-compress': |
|
184 | + case 'application/x-compressed-tar': |
|
185 | + case 'application/x-cpio-compressed': |
|
186 | + case 'application/x-deb': |
|
187 | + case 'application/x-gzip': |
|
188 | + case 'application/x-java-archive': |
|
189 | + case 'application/x-lha': |
|
190 | + case 'application/x-lhz': |
|
191 | + case 'application/x-lzop': |
|
192 | + case 'application/x-rar': |
|
193 | + case 'application/x-rpm': |
|
194 | + case 'application/x-tzo': |
|
195 | + case 'application/x-tar': |
|
196 | + case 'application/x-tarz': |
|
197 | + case 'application/x-tgz': |
|
198 | + return 'package-x-generic'; |
|
199 | + |
|
200 | + // Script file types. |
|
201 | + case 'application/ecmascript': |
|
202 | + case 'application/javascript': |
|
203 | + case 'application/mathematica': |
|
204 | + case 'application/vnd.mozilla.xul+xml': |
|
205 | + case 'application/x-asp': |
|
206 | + case 'application/x-awk': |
|
207 | + case 'application/x-cgi': |
|
208 | + case 'application/x-csh': |
|
209 | + case 'application/x-m4': |
|
210 | + case 'application/x-perl': |
|
211 | + case 'application/x-php': |
|
212 | + case 'application/x-ruby': |
|
213 | + case 'application/x-shellscript': |
|
214 | + case 'text/vnd.wap.wmlscript': |
|
215 | + case 'text/x-emacs-lisp': |
|
216 | + case 'text/x-haskell': |
|
217 | + case 'text/x-literate-haskell': |
|
218 | + case 'text/x-lua': |
|
219 | + case 'text/x-makefile': |
|
220 | + case 'text/x-matlab': |
|
221 | + case 'text/x-python': |
|
222 | + case 'text/x-sql': |
|
223 | + case 'text/x-tcl': |
|
224 | + return 'text-x-script'; |
|
225 | + |
|
226 | + // HTML aliases. |
|
227 | + case 'application/xhtml+xml': |
|
228 | + return 'text-html'; |
|
229 | + |
|
230 | + // RTF files. |
|
231 | + case 'application/rtf': |
|
232 | + return 'text-rtf'; |
|
233 | + |
|
234 | + // Google earth files. |
|
235 | + case 'application/vnd.google-earth.kml+xml': |
|
236 | + case 'application/vnd.google-earth.kmz': |
|
237 | + return 'application-google-earth'; |
|
238 | + |
|
239 | + // Executable types. |
|
240 | + case 'application/x-macbinary': |
|
241 | + case 'application/x-ms-dos-executable': |
|
242 | + case 'application/x-pef-executable': |
|
243 | + return 'application-x-executable'; |
|
244 | + |
|
245 | + default: |
|
246 | + return FALSE; |
|
247 | 247 | } |
248 | 248 | } |
@@ -313,10 +313,10 @@ |
||
313 | 313 | */ |
314 | 314 | function filefield_widget_settings($op, $widget) { |
315 | 315 | switch ($op) { |
316 | - case 'form': |
|
317 | - return filefield_widget_settings_form($widget); |
|
318 | - case 'save': |
|
319 | - return filefield_widget_settings_save($widget); |
|
316 | + case 'form': |
|
317 | + return filefield_widget_settings_form($widget); |
|
318 | + case 'save': |
|
319 | + return filefield_widget_settings_save($widget); |
|
320 | 320 | } |
321 | 321 | } |
322 | 322 |