@@ -11,12 +11,12 @@ discard block |
||
| 11 | 11 | * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
| 12 | 12 | |
| 13 | 13 | if (!function_exists('user_load_by_mail')) { |
| 14 | - /** |
|
| 15 | - * user_load_by_mail will be broken out of user_load |
|
| 16 | - */ |
|
| 17 | - function user_load_by_mail($mail) { |
|
| 14 | + /** |
|
| 15 | + * user_load_by_mail will be broken out of user_load |
|
| 16 | + */ |
|
| 17 | + function user_load_by_mail($mail) { |
|
| 18 | 18 | return user_load(array('mail' => $mail)); |
| 19 | - } |
|
| 19 | + } |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
@@ -28,14 +28,14 @@ discard block |
||
| 28 | 28 | * Get an image object from a given file and cck field |
| 29 | 29 | */ |
| 30 | 30 | function get_cck_image_object($image_path, $field_name, $content_type, $ignore_resolution = FALSE) { |
| 31 | - $field = content_fields($field_name, $content_type); |
|
| 32 | - $validators = array_merge(filefield_widget_upload_validators($field), imagefield_widget_upload_validators($field)); |
|
| 33 | - if ($ignore_resolution) { |
|
| 31 | + $field = content_fields($field_name, $content_type); |
|
| 32 | + $validators = array_merge(filefield_widget_upload_validators($field), imagefield_widget_upload_validators($field)); |
|
| 33 | + if ($ignore_resolution) { |
|
| 34 | 34 | unset($validators['filefield_validate_image_resolution']); |
| 35 | - } |
|
| 36 | - $target_path = filefield_widget_file_path($field); |
|
| 37 | - // Create the image object |
|
| 38 | - return field_file_save_file($image_path, $validators, $target_path, FILE_EXISTS_REPLACE); |
|
| 35 | + } |
|
| 36 | + $target_path = filefield_widget_file_path($field); |
|
| 37 | + // Create the image object |
|
| 38 | + return field_file_save_file($image_path, $validators, $target_path, FILE_EXISTS_REPLACE); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | |
@@ -47,73 +47,73 @@ discard block |
||
| 47 | 47 | * |
| 48 | 48 | */ |
| 49 | 49 | function boincuser_check_credit_requirements() { |
| 50 | - global $user; |
|
| 51 | - if (!$user->uid) { |
|
| 50 | + global $user; |
|
| 51 | + if (!$user->uid) { |
|
| 52 | 52 | return FALSE; |
| 53 | - } |
|
| 54 | - $account = user_load($user->uid); |
|
| 55 | - $min_credit_to_post = variable_get('boinc_comment_min_credit', 0); |
|
| 56 | - $community_role = array_search('community member', user_roles(true)); |
|
| 57 | - $unrestricted_role = array_search('verified contributor', user_roles(true)); |
|
| 58 | - |
|
| 59 | - // Set user roles based on current penalty status... |
|
| 60 | - if ($account->boincuser_penalty_expiration > time()) { |
|
| 53 | + } |
|
| 54 | + $account = user_load($user->uid); |
|
| 55 | + $min_credit_to_post = variable_get('boinc_comment_min_credit', 0); |
|
| 56 | + $community_role = array_search('community member', user_roles(true)); |
|
| 57 | + $unrestricted_role = array_search('verified contributor', user_roles(true)); |
|
| 58 | + |
|
| 59 | + // Set user roles based on current penalty status... |
|
| 60 | + if ($account->boincuser_penalty_expiration > time()) { |
|
| 61 | 61 | drupal_set_message(bts( |
| 62 | - 'You are banned from community participation until @date', |
|
| 63 | - array('@date' => format_date($account->boincuser_penalty_expiration)) |
|
| 62 | + 'You are banned from community participation until @date', |
|
| 63 | + array('@date' => format_date($account->boincuser_penalty_expiration)) |
|
| 64 | 64 | ), 'warning', FALSE); |
| 65 | 65 | if (isset($account->roles[$community_role])) { |
| 66 | - // Remove from the community role, if not already |
|
| 67 | - unset($account->roles[$community_role]); |
|
| 66 | + // Remove from the community role, if not already |
|
| 67 | + unset($account->roles[$community_role]); |
|
| 68 | 68 | } |
| 69 | 69 | if (isset($account->roles[$unrestricted_role])) { |
| 70 | - // Likewise, revoke extra privileges |
|
| 71 | - unset($account->roles[$unrestricted_role]); |
|
| 70 | + // Likewise, revoke extra privileges |
|
| 71 | + unset($account->roles[$unrestricted_role]); |
|
| 72 | 72 | } |
| 73 | 73 | user_save($account, array('roles' => $account->roles)); |
| 74 | - } |
|
| 75 | - else { |
|
| 74 | + } |
|
| 75 | + else { |
|
| 76 | 76 | if (!isset($account->roles[$community_role])) { |
| 77 | - // The user should be a 'community member' role. If the user was |
|
| 78 | - // previously banned, this will restore that role. |
|
| 79 | - $account->roles[$community_role] = 'community member'; |
|
| 80 | - user_save($account, array('roles' => $account->roles)); |
|
| 77 | + // The user should be a 'community member' role. If the user was |
|
| 78 | + // previously banned, this will restore that role. |
|
| 79 | + $account->roles[$community_role] = 'community member'; |
|
| 80 | + user_save($account, array('roles' => $account->roles)); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | // ... and total credit. |
| 84 | 84 | if ($account->boincuser_total_credit >= $min_credit_to_post) { |
| 85 | - if (!isset($account->roles[$unrestricted_role])) { |
|
| 85 | + if (!isset($account->roles[$unrestricted_role])) { |
|
| 86 | 86 | // This user is now above the credit threshold and is allowed full |
| 87 | 87 | // privileges |
| 88 | 88 | $account->roles[$unrestricted_role] = 'verified contributor'; |
| 89 | 89 | user_save($account, array('roles' => $account->roles)); |
| 90 | - } |
|
| 90 | + } |
|
| 91 | 91 | } |
| 92 | 92 | else { |
| 93 | - drupal_set_message(bts( |
|
| 93 | + drupal_set_message(bts( |
|
| 94 | 94 | 'You must earn @count more credits to be able to post comments on this site and create or modify your user profile.', |
| 95 | 95 | array('@count' => $min_credit_to_post - $account->boincuser_total_credit) |
| 96 | - ), 'warning', FALSE); |
|
| 97 | - if (isset($account->roles[$unrestricted_role])) { |
|
| 96 | + ), 'warning', FALSE); |
|
| 97 | + if (isset($account->roles[$unrestricted_role])) { |
|
| 98 | 98 | // Either the threshold has been raised or credits have been revoked; |
| 99 | 99 | // this user no longer qualifies for full privileges |
| 100 | 100 | unset($account->roles[$unrestricted_role]); |
| 101 | 101 | user_save($account, array('roles' => $account->roles)); |
| 102 | - } |
|
| 102 | + } |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - } |
|
| 105 | + } |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
| 109 | 109 | * Get the cid of the first comment the user has not seen on a given node |
| 110 | 110 | */ |
| 111 | 111 | function boincuser_get_first_unread_comment_id($nid, $uid = NULL) { |
| 112 | - if (!$uid) { |
|
| 112 | + if (!$uid) { |
|
| 113 | 113 | global $user; |
| 114 | 114 | $uid = $user->uid; |
| 115 | - } |
|
| 116 | - return db_result(db_query(" |
|
| 115 | + } |
|
| 116 | + return db_result(db_query(" |
|
| 117 | 117 | SELECT c.cid |
| 118 | 118 | FROM {node} n |
| 119 | 119 | INNER JOIN {comments} c ON c.nid = n.nid |
@@ -124,40 +124,40 @@ discard block |
||
| 124 | 124 | ORDER BY c.timestamp ASC |
| 125 | 125 | LIMIT 1", |
| 126 | 126 | $uid, $nid |
| 127 | - )); |
|
| 127 | + )); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
| 131 | 131 | * Choose and set the user of the day |
| 132 | 132 | */ |
| 133 | 133 | function boincuser_select_user_of_the_day() { |
| 134 | - // First get a list of users with recent credit |
|
| 135 | - db_set_active('boinc_rw'); |
|
| 136 | - $users_with_credit = db_query(" |
|
| 134 | + // First get a list of users with recent credit |
|
| 135 | + db_set_active('boinc_rw'); |
|
| 136 | + $users_with_credit = db_query(" |
|
| 137 | 137 | SELECT |
| 138 | 138 | id |
| 139 | 139 | FROM {user} u |
| 140 | 140 | JOIN {profile} p ON p.userid = u.id |
| 141 | 141 | WHERE expavg_credit > 1 |
| 142 | 142 | ORDER BY uotd_time ASC, RAND()" |
| 143 | - ); |
|
| 144 | - db_set_active('default'); |
|
| 145 | - $active_users = array(); |
|
| 146 | - while ($user_with_credit = db_fetch_object($users_with_credit)) { |
|
| 143 | + ); |
|
| 144 | + db_set_active('default'); |
|
| 145 | + $active_users = array(); |
|
| 146 | + while ($user_with_credit = db_fetch_object($users_with_credit)) { |
|
| 147 | 147 | $active_users[] = $user_with_credit->id; |
| 148 | - } |
|
| 149 | - $active_users = implode(',', $active_users); |
|
| 150 | - // Limit to users who have never been user of the day, if there are any |
|
| 151 | - $never_been_picked = db_result(db_query(" |
|
| 148 | + } |
|
| 149 | + $active_users = implode(',', $active_users); |
|
| 150 | + // Limit to users who have never been user of the day, if there are any |
|
| 151 | + $never_been_picked = db_result(db_query(" |
|
| 152 | 152 | SELECT COUNT(*) |
| 153 | 153 | FROM {boincuser} bu |
| 154 | 154 | WHERE bu.uotd_time = 0 |
| 155 | 155 | " . ($active_users ? " AND bu.boinc_id IN ({$active_users}) " : '') |
| 156 | - )); |
|
| 157 | - $new_uotd_uid = 0; |
|
| 158 | - while (!$new_uotd_uid) { |
|
| 156 | + )); |
|
| 157 | + $new_uotd_uid = 0; |
|
| 158 | + while (!$new_uotd_uid) { |
|
| 159 | 159 | // Select a user of the day randomly from the pool |
| 160 | - $new_uotd_uid = db_result(db_query(" |
|
| 160 | + $new_uotd_uid = db_result(db_query(" |
|
| 161 | 161 | SELECT |
| 162 | 162 | n.uid |
| 163 | 163 | FROM {node} n |
@@ -171,31 +171,31 @@ discard block |
||
| 171 | 171 | LIMIT 1" |
| 172 | 172 | )); |
| 173 | 173 | if (!$new_uotd_uid) { |
| 174 | - // Can't find a user with a profile; remove constraints on the pool |
|
| 175 | - if ($never_been_picked) { |
|
| 174 | + // Can't find a user with a profile; remove constraints on the pool |
|
| 175 | + if ($never_been_picked) { |
|
| 176 | 176 | // Allow users who have been previously selected |
| 177 | 177 | $never_been_picked = FALSE; |
| 178 | - } |
|
| 179 | - elseif ($active_users) { |
|
| 178 | + } |
|
| 179 | + elseif ($active_users) { |
|
| 180 | 180 | // Allow users who are not even active (getting desperate) |
| 181 | 181 | $active_users = FALSE; |
| 182 | - } |
|
| 183 | - else { |
|
| 182 | + } |
|
| 183 | + else { |
|
| 184 | 184 | // Process failed... |
| 185 | 185 | return FALSE; |
| 186 | - } |
|
| 186 | + } |
|
| 187 | 187 | } |
| 188 | - } |
|
| 189 | - $uotd = user_load($new_uotd_uid); |
|
| 190 | - if ($uotd->uid) { |
|
| 188 | + } |
|
| 189 | + $uotd = user_load($new_uotd_uid); |
|
| 190 | + if ($uotd->uid) { |
|
| 191 | 191 | db_query(" |
| 192 | 192 | UPDATE {boincuser} |
| 193 | 193 | SET uotd_time = '%d' |
| 194 | 194 | WHERE uid = '%d'", |
| 195 | - time(), $uotd->uid |
|
| 195 | + time(), $uotd->uid |
|
| 196 | 196 | ); |
| 197 | - } |
|
| 198 | - return $uotd; |
|
| 197 | + } |
|
| 198 | + return $uotd; |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | |
@@ -213,71 +213,71 @@ discard block |
||
| 213 | 213 | * new and prev email. |
| 214 | 214 | */ |
| 215 | 215 | function _boincuser_send_emailchange($account, $new_email=NULL, $prev_email=NULL, $adminuser=FALSE) { |
| 216 | - require_boinc('token'); |
|
| 217 | - module_load_include('inc', 'rules', 'modules/system.rules'); |
|
| 216 | + require_boinc('token'); |
|
| 217 | + module_load_include('inc', 'rules', 'modules/system.rules'); |
|
| 218 | 218 | |
| 219 | - global $base_url; |
|
| 220 | - $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
| 219 | + global $base_url; |
|
| 220 | + $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
| 221 | 221 | |
| 222 | - if (is_null($new_email)) { |
|
| 222 | + if (is_null($new_email)) { |
|
| 223 | 223 | $new_email = $account->mail; |
| 224 | - } |
|
| 225 | - if (is_null($prev_email)) { |
|
| 224 | + } |
|
| 225 | + if (is_null($prev_email)) { |
|
| 226 | 226 | $prev_email = $account->boincuser_previous_email_addr; |
| 227 | - } |
|
| 228 | - |
|
| 229 | - // @todo - set constant in drupal, or use BOINC contsants |
|
| 230 | - $duration = TOKEN_DURATION_ONE_WEEK; |
|
| 231 | - $changedate = date('F j, Y \a\t G:i T', time()); |
|
| 232 | - $newdate = date('F j, Y \a\t G:i T', $account->boincuser_email_addr_change_time + $duration); |
|
| 233 | - $token = create_token($account->boincuser_id, TOKEN_TYPE_CHANGE_EMAIL, $duration); |
|
| 234 | - if ($adminuser) { |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + // @todo - set constant in drupal, or use BOINC contsants |
|
| 230 | + $duration = TOKEN_DURATION_ONE_WEEK; |
|
| 231 | + $changedate = date('F j, Y \a\t G:i T', time()); |
|
| 232 | + $newdate = date('F j, Y \a\t G:i T', $account->boincuser_email_addr_change_time + $duration); |
|
| 233 | + $token = create_token($account->boincuser_id, TOKEN_TYPE_CHANGE_EMAIL, $duration); |
|
| 234 | + if ($adminuser) { |
|
| 235 | 235 | $graf1 = "Your email address was changed from {$prev_email} to {$new_email} " |
| 236 | - . "on {$changedate}. If you need to reverse this change, please look for " |
|
| 237 | - . "an email send to the email address: {$prev_email}.\n"; |
|
| 238 | - } |
|
| 239 | - else { |
|
| 236 | + . "on {$changedate}. If you need to reverse this change, please look for " |
|
| 237 | + . "an email send to the email address: {$prev_email}.\n"; |
|
| 238 | + } |
|
| 239 | + else { |
|
| 240 | 240 | $graf1 = "Your email address was changed from {$prev_email} to {$new_email} " |
| 241 | - . "on {$changedate}. You will not be able to change your email address " |
|
| 242 | - . "until {$newdate}. If you need to reverse this change, please look for " |
|
| 243 | - . "an email send to the email address: {$prev_email}.\n"; |
|
| 244 | - } |
|
| 245 | - |
|
| 246 | - // Send email #1 to current address |
|
| 247 | - $mysubject = "Notification of email change at {$site_name}"; |
|
| 248 | - $mymessage = '' |
|
| 249 | - . "{$account->boincuser_name},\n" |
|
| 250 | - . "\n" |
|
| 251 | - . $graf1 |
|
| 252 | - . "\n" |
|
| 253 | - . "Thanks, \n" |
|
| 254 | - . "{$site_name} support team\n"; |
|
| 255 | - |
|
| 256 | - $settings = array( |
|
| 241 | + . "on {$changedate}. You will not be able to change your email address " |
|
| 242 | + . "until {$newdate}. If you need to reverse this change, please look for " |
|
| 243 | + . "an email send to the email address: {$prev_email}.\n"; |
|
| 244 | + } |
|
| 245 | + |
|
| 246 | + // Send email #1 to current address |
|
| 247 | + $mysubject = "Notification of email change at {$site_name}"; |
|
| 248 | + $mymessage = '' |
|
| 249 | + . "{$account->boincuser_name},\n" |
|
| 250 | + . "\n" |
|
| 251 | + . $graf1 |
|
| 252 | + . "\n" |
|
| 253 | + . "Thanks, \n" |
|
| 254 | + . "{$site_name} support team\n"; |
|
| 255 | + |
|
| 256 | + $settings = array( |
|
| 257 | 257 | 'from' => '', |
| 258 | 258 | 'to' => $new_email, |
| 259 | 259 | 'subject' => $mysubject, |
| 260 | 260 | 'message' => $mymessage, |
| 261 | - ); |
|
| 262 | - rules_action_mail_to_user($account, $settings); |
|
| 263 | - |
|
| 264 | - // Send email #2 to previous address. |
|
| 265 | - $mymessage = '' |
|
| 266 | - . "Your email address has been changed. If you did not intend to take this action, then please click this link to reverse this change, or copy-and-paste the link into your browser location bar. You will need to change your password as well.\n" |
|
| 267 | - . "\n" |
|
| 268 | - . "{$base_url}/user/{$account->uid}/recoveremail/{$token}\n" |
|
| 269 | - . "\n" |
|
| 270 | - . "Thanks, \n" |
|
| 271 | - . "{$site_name} support team\n"; |
|
| 272 | - |
|
| 273 | - $settings = array( |
|
| 261 | + ); |
|
| 262 | + rules_action_mail_to_user($account, $settings); |
|
| 263 | + |
|
| 264 | + // Send email #2 to previous address. |
|
| 265 | + $mymessage = '' |
|
| 266 | + . "Your email address has been changed. If you did not intend to take this action, then please click this link to reverse this change, or copy-and-paste the link into your browser location bar. You will need to change your password as well.\n" |
|
| 267 | + . "\n" |
|
| 268 | + . "{$base_url}/user/{$account->uid}/recoveremail/{$token}\n" |
|
| 269 | + . "\n" |
|
| 270 | + . "Thanks, \n" |
|
| 271 | + . "{$site_name} support team\n"; |
|
| 272 | + |
|
| 273 | + $settings = array( |
|
| 274 | 274 | 'from' => '', |
| 275 | 275 | 'to' => $prev_email, |
| 276 | 276 | 'subject' => $mysubject, |
| 277 | 277 | 'message' => $mymessage, |
| 278 | - ); |
|
| 278 | + ); |
|
| 279 | 279 | |
| 280 | - rules_action_mail($settings); |
|
| 280 | + rules_action_mail($settings); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | /** |
@@ -287,32 +287,32 @@ discard block |
||
| 287 | 287 | * |
| 288 | 288 | */ |
| 289 | 289 | function create_proper_drupalname($requested_name) { |
| 290 | - if (!$requested_name) { |
|
| 290 | + if (!$requested_name) { |
|
| 291 | 291 | // If the name is empty, set it |
| 292 | 292 | $requested_name = 'anonymous'; |
| 293 | - } |
|
| 294 | - $same_name_tally = 1; |
|
| 295 | - |
|
| 296 | - // Remove extra spaces |
|
| 297 | - $name2 = preg_replace("/ {2,}/", " ", trim($requested_name)); |
|
| 298 | - // Remove any non-valid characters |
|
| 299 | - $cleaned_name = preg_replace('/[^a-zA-Z0-9_ \.-]/s', '_', $name2); |
|
| 300 | - // Truncate name |
|
| 301 | - $name_length = strlen($cleaned_name); |
|
| 302 | - if ($name_length > 56) { |
|
| 293 | + } |
|
| 294 | + $same_name_tally = 1; |
|
| 295 | + |
|
| 296 | + // Remove extra spaces |
|
| 297 | + $name2 = preg_replace("/ {2,}/", " ", trim($requested_name)); |
|
| 298 | + // Remove any non-valid characters |
|
| 299 | + $cleaned_name = preg_replace('/[^a-zA-Z0-9_ \.-]/s', '_', $name2); |
|
| 300 | + // Truncate name |
|
| 301 | + $name_length = strlen($cleaned_name); |
|
| 302 | + if ($name_length > 56) { |
|
| 303 | 303 | // Name is limited to 60 characters, but we want to leave space to add a |
| 304 | 304 | // tally if needed (for users with duplicate names); Limit to 56 chars and |
| 305 | 305 | // replace the middle of the string with "..." if too long |
| 306 | 306 | $cleaned_name = substr_replace($cleaned_name, '...', 28, ($name_length-56)+3); |
| 307 | - } |
|
| 307 | + } |
|
| 308 | 308 | |
| 309 | - // Determine if there are duplicate names, if so append a number to end. |
|
| 310 | - $unique_name = $cleaned_name; |
|
| 311 | - while (db_result(db_query("SELECT uid FROM {users} WHERE name = '{$unique_name}' LIMIT 1"))) { |
|
| 309 | + // Determine if there are duplicate names, if so append a number to end. |
|
| 310 | + $unique_name = $cleaned_name; |
|
| 311 | + while (db_result(db_query("SELECT uid FROM {users} WHERE name = '{$unique_name}' LIMIT 1"))) { |
|
| 312 | 312 | $same_name_tally++; |
| 313 | 313 | $unique_name = "{$cleaned_name}_{$same_name_tally}"; |
| 314 | - } |
|
| 315 | - return $unique_name; |
|
| 314 | + } |
|
| 315 | + return $unique_name; |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | |
@@ -326,9 +326,9 @@ discard block |
||
| 326 | 326 | * |
| 327 | 327 | */ |
| 328 | 328 | function boincuser_check_termsofuse($user) { |
| 329 | - require_boinc('consent'); |
|
| 330 | - $boinc_user = boincuser_load($user->uid, TRUE); |
|
| 331 | - return check_user_consent($boinc_user, CONSENT_TYPE_ENROLL); |
|
| 329 | + require_boinc('consent'); |
|
| 330 | + $boinc_user = boincuser_load($user->uid, TRUE); |
|
| 331 | + return check_user_consent($boinc_user, CONSENT_TYPE_ENROLL); |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | /** |
@@ -339,33 +339,33 @@ discard block |
||
| 339 | 339 | * |
| 340 | 340 | */ |
| 341 | 341 | function boincuser_consentto_termsofuse($user) { |
| 342 | - require_boinc('consent'); |
|
| 343 | - $boinc_user = boincuser_load($user->uid, TRUE); |
|
| 342 | + require_boinc('consent'); |
|
| 343 | + $boinc_user = boincuser_load($user->uid, TRUE); |
|
| 344 | 344 | |
| 345 | - list($checkct, $ctid) = check_consent_type(CONSENT_TYPE_ENROLL); |
|
| 346 | - if ($checkct) { |
|
| 345 | + list($checkct, $ctid) = check_consent_type(CONSENT_TYPE_ENROLL); |
|
| 346 | + if ($checkct) { |
|
| 347 | 347 | $rc1 = consent_to_a_policy($boinc_user, $ctid, 1, 0, 'Webform', time()); |
| 348 | 348 | if (!$rc1) { |
| 349 | - drupal_set_message( |
|
| 349 | + drupal_set_message( |
|
| 350 | 350 | bts("ERROR: Database error when attempting to INSERT into table consent with ID=@id. The @project administrators have been notified.", |
| 351 | 351 | array( |
| 352 | - '@id' => $boinc_user->id, |
|
| 353 | - '@project' => variable_get('site_name', 'Drupal-BOINC'), NULL, 'boinc:add-new-user' |
|
| 352 | + '@id' => $boinc_user->id, |
|
| 353 | + '@project' => variable_get('site_name', 'Drupal-BOINC'), NULL, 'boinc:add-new-user' |
|
| 354 | 354 | ), |
| 355 | 355 | 'NULL', 'boinc:consent-termsofuse'), |
| 356 | - 'error'); |
|
| 357 | - rules_invoke_event('boincuser_general_consent_error', variable_get('boinc_admin_mailing_list_subject_tag', '')); |
|
| 356 | + 'error'); |
|
| 357 | + rules_invoke_event('boincuser_general_consent_error', variable_get('boinc_admin_mailing_list_subject_tag', '')); |
|
| 358 | 358 | } |
| 359 | 359 | return $rc1; |
| 360 | - } |
|
| 361 | - else { |
|
| 360 | + } |
|
| 361 | + else { |
|
| 362 | 362 | drupal_set_message( |
| 363 | - bts('ERROR: Consent type for enrollment not found. The @project administrators have been nofitifed.', |
|
| 363 | + bts('ERROR: Consent type for enrollment not found. The @project administrators have been nofitifed.', |
|
| 364 | 364 | array('@project' => variable_get('site_name', 'Drupal-BOINC')), NULL, 'boinc:consent-termsofuse'), |
| 365 | 365 | 'error'); |
| 366 | 366 | rules_invoke_event('boincuser_general_consent_type_error', CONSENT_TYPE_ENROLL, variable_get('boinc_admin_mailing_list_subject_tag', '')); |
| 367 | - } |
|
| 368 | - return FALSE; |
|
| 367 | + } |
|
| 368 | + return FALSE; |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | /** |
@@ -374,16 +374,16 @@ discard block |
||
| 374 | 374 | */ |
| 375 | 375 | function _boincuser_ignore_paths($path, $paths_to_ignore) { |
| 376 | 376 | |
| 377 | - foreach ($paths_to_ignore as $pi) { |
|
| 377 | + foreach ($paths_to_ignore as $pi) { |
|
| 378 | 378 | // @todo Currently this function uses {} as PHP regexp |
| 379 | 379 | // delimiters. Curly brace is not really allowed un URLs, but a |
| 380 | 380 | // more robust function would first check for these curly braces |
| 381 | 381 | // in the path_to_ignore patterms, just in case. |
| 382 | 382 | if (preg_match('{' . $pi . '}', $path)) { |
| 383 | - return TRUE; |
|
| 383 | + return TRUE; |
|
| 384 | 384 | } |
| 385 | - } |
|
| 386 | - return FALSE; |
|
| 385 | + } |
|
| 386 | + return FALSE; |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | /** |
@@ -391,20 +391,20 @@ discard block |
||
| 391 | 391 | * Drupal's recover email path. |
| 392 | 392 | */ |
| 393 | 393 | function _boincuser_redirect_recover_email() { |
| 394 | - $params = array( |
|
| 394 | + $params = array( |
|
| 395 | 395 | 'boincid' => isset($_GET['id']) ? $_GET['id'] : '', |
| 396 | 396 | 'token' => isset($_GET['token']) ? $_GET['token'] : '' |
| 397 | - ); |
|
| 397 | + ); |
|
| 398 | 398 | |
| 399 | - // If boincid or token is not present, then go to the home page. |
|
| 400 | - if (empty($params['boincid']) or empty($params['token'])) { |
|
| 399 | + // If boincid or token is not present, then go to the home page. |
|
| 400 | + if (empty($params['boincid']) or empty($params['token'])) { |
|
| 401 | 401 | $redirect = ''; |
| 402 | - } |
|
| 403 | - else { |
|
| 402 | + } |
|
| 403 | + else { |
|
| 404 | 404 | $uid = boincuser_lookup_uid($params['boincid']); |
| 405 | 405 | $redirect = "/user/${uid}/recoveremail/${params['token']}"; |
| 406 | - } |
|
| 407 | - drupal_goto($redirect); |
|
| 406 | + } |
|
| 407 | + drupal_goto($redirect); |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -415,17 +415,17 @@ discard block |
||
| 415 | 415 | * Require BOINC library |
| 416 | 416 | */ |
| 417 | 417 | function require_boinc($libraries) { |
| 418 | - if ($include_dir = boinc_get_path('html_inc')) { |
|
| 418 | + if ($include_dir = boinc_get_path('html_inc')) { |
|
| 419 | 419 | $working_dir = getcwd(); |
| 420 | 420 | chdir($include_dir); |
| 421 | 421 | if (!is_array($libraries)) { |
| 422 | - $libraries = array($libraries); |
|
| 422 | + $libraries = array($libraries); |
|
| 423 | 423 | } |
| 424 | 424 | foreach ($libraries as $library) { |
| 425 | - require_once("{$library}.inc"); |
|
| 425 | + require_once("{$library}.inc"); |
|
| 426 | 426 | } |
| 427 | 427 | chdir($working_dir); |
| 428 | - } |
|
| 428 | + } |
|
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | /** |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | * The path from the BOINC html root must be included (e.g. user/file.php) |
| 434 | 434 | */ |
| 435 | 435 | function include_boinc($file) { |
| 436 | - if ($include_dir = boinc_get_path()) { |
|
| 436 | + if ($include_dir = boinc_get_path()) { |
|
| 437 | 437 | $include_dir .= '/html'; |
| 438 | 438 | $workingDir = getcwd(); |
| 439 | 439 | $path = dirname($file); |
@@ -441,84 +441,84 @@ discard block |
||
| 441 | 441 | chdir("{$include_dir}/{$path}"); |
| 442 | 442 | include($file); |
| 443 | 443 | chdir($workingDir); |
| 444 | - } |
|
| 444 | + } |
|
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | /** |
| 448 | 448 | * Get the BOINC include path |
| 449 | 449 | */ |
| 450 | 450 | function boinc_get_path($type = 'root') { |
| 451 | - $dir = "boinc_{$type}_dir"; |
|
| 452 | - if ($include_dir = variable_get("boinc_{$type}_dir", '')) { |
|
| 451 | + $dir = "boinc_{$type}_dir"; |
|
| 452 | + if ($include_dir = variable_get("boinc_{$type}_dir", '')) { |
|
| 453 | 453 | return $include_dir; |
| 454 | - } |
|
| 455 | - else { |
|
| 454 | + } |
|
| 455 | + else { |
|
| 456 | 456 | // Don't show errors on blacklisted pages |
| 457 | 457 | $page_blacklist = array( |
| 458 | - 'admin/boinc/environment' |
|
| 458 | + 'admin/boinc/environment' |
|
| 459 | 459 | ); |
| 460 | 460 | if (!in_array($_GET['q'], $page_blacklist)) { |
| 461 | - watchdog('boincuser', 'The BOINC environment is not configured. Please |
|
| 461 | + watchdog('boincuser', 'The BOINC environment is not configured. Please |
|
| 462 | 462 | !configure_it', array('!configure_it' => l(t('configure it now'), |
| 463 | 463 | 'admin/boinc/environment')), WATCHDOG_WARNING); |
| 464 | - if (user_access('administer site configuration')) { |
|
| 464 | + if (user_access('administer site configuration')) { |
|
| 465 | 465 | drupal_set_message(t('The BOINC environment is not configured. Please |
| 466 | 466 | !configure_it', array('!configure_it' => l(t('configure it now'), |
| 467 | 467 | 'admin/boinc/environment'))), 'warning', FALSE); |
| 468 | - } |
|
| 469 | - else { |
|
| 468 | + } |
|
| 469 | + else { |
|
| 470 | 470 | drupal_set_message(t('There is a problem with the site. Please contact |
| 471 | 471 | the system administrator.'), 'error', FALSE); |
| 472 | - } |
|
| 473 | - // Redirect home to display the error message and avoid fatal errors |
|
| 474 | - // (unless on a blacklisted page) |
|
| 475 | - $redirect_blacklist = array( |
|
| 472 | + } |
|
| 473 | + // Redirect home to display the error message and avoid fatal errors |
|
| 474 | + // (unless on a blacklisted page) |
|
| 475 | + $redirect_blacklist = array( |
|
| 476 | 476 | 'admin/settings/performance', |
| 477 | 477 | 'admin/boinc/environment', |
| 478 | 478 | 'home', |
| 479 | 479 | '' |
| 480 | - ); |
|
| 481 | - if (!in_array($_GET['q'], $redirect_blacklist)) { |
|
| 480 | + ); |
|
| 481 | + if (!in_array($_GET['q'], $redirect_blacklist)) { |
|
| 482 | 482 | drupal_goto(''); |
| 483 | - } |
|
| 483 | + } |
|
| 484 | 484 | } |
| 485 | 485 | else { |
| 486 | - // Clear the messages on the environment config page |
|
| 487 | - drupal_get_messages(); |
|
| 486 | + // Clear the messages on the environment config page |
|
| 487 | + drupal_get_messages(); |
|
| 488 | 488 | } |
| 489 | - } |
|
| 490 | - return FALSE; |
|
| 489 | + } |
|
| 490 | + return FALSE; |
|
| 491 | 491 | } |
| 492 | 492 | |
| 493 | 493 | /** |
| 494 | 494 | * Get the configured scheduler tags |
| 495 | 495 | */ |
| 496 | 496 | function boinc_get_scheduler_tags() { |
| 497 | - // Don't generate messages for blacklisted pages |
|
| 498 | - $page_blacklist = array( |
|
| 497 | + // Don't generate messages for blacklisted pages |
|
| 498 | + $page_blacklist = array( |
|
| 499 | 499 | 'admin/boinc/environment', |
| 500 | 500 | 'admin/boinc/scheduler' |
| 501 | - ); |
|
| 502 | - if ($url_config = variable_get('boinc_scheduler_urls', '')) { |
|
| 501 | + ); |
|
| 502 | + if ($url_config = variable_get('boinc_scheduler_urls', '')) { |
|
| 503 | 503 | return explode("\r\n", $url_config); |
| 504 | - } |
|
| 505 | - elseif (!in_array($_GET['q'], $page_blacklist)) { |
|
| 504 | + } |
|
| 505 | + elseif (!in_array($_GET['q'], $page_blacklist)) { |
|
| 506 | 506 | watchdog('boincuser', 'The BOINC scheduling server settings are not yet |
| 507 | 507 | configured. Please !verify for the settings to become effective.', |
| 508 | - array('!verify' => l(t('verify the default values') . ' <strong>' . |
|
| 508 | + array('!verify' => l(t('verify the default values') . ' <strong>' . |
|
| 509 | 509 | t('and') . '</strong> ' . t('save the configuration'), |
| 510 | 510 | 'admin/boinc/scheduler', array('html' => TRUE)) |
| 511 | - ), WATCHDOG_WARNING); |
|
| 511 | + ), WATCHDOG_WARNING); |
|
| 512 | 512 | if (user_access('administer site configuration')) { |
| 513 | - drupal_set_message(t('The BOINC scheduling server settings are not yet |
|
| 513 | + drupal_set_message(t('The BOINC scheduling server settings are not yet |
|
| 514 | 514 | configured. Please !verify for the settings to become effective', |
| 515 | 515 | array('!verify' => l(t('verify the default values') . ' <strong>' . |
| 516 | - t('and') . '</strong> ' . t('save the configuration'), |
|
| 517 | - 'admin/boinc/scheduler', array('html' => TRUE)) |
|
| 516 | + t('and') . '</strong> ' . t('save the configuration'), |
|
| 517 | + 'admin/boinc/scheduler', array('html' => TRUE)) |
|
| 518 | 518 | )), 'warning', FALSE); |
| 519 | 519 | } |
| 520 | - } |
|
| 521 | - return array(); |
|
| 520 | + } |
|
| 521 | + return array(); |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -530,41 +530,41 @@ discard block |
||
| 530 | 530 | * Determine if a BOINC ID matches the logged in user |
| 531 | 531 | */ |
| 532 | 532 | function is_current_boinc_user($boinc_id) { |
| 533 | - global $user; |
|
| 534 | - if (!$user->uid) { |
|
| 533 | + global $user; |
|
| 534 | + if (!$user->uid) { |
|
| 535 | 535 | return FALSE; |
| 536 | - } |
|
| 537 | - // boincuser_id is not stored in the global user, so load a new instance |
|
| 538 | - $drupuser = user_load($user->uid); |
|
| 539 | - return ($boinc_id == $drupuser->boincuser_id); |
|
| 536 | + } |
|
| 537 | + // boincuser_id is not stored in the global user, so load a new instance |
|
| 538 | + $drupuser = user_load($user->uid); |
|
| 539 | + return ($boinc_id == $drupuser->boincuser_id); |
|
| 540 | 540 | } |
| 541 | 541 | |
| 542 | 542 | /** |
| 543 | 543 | * Convert a BOINC ID to a Drupal ID |
| 544 | 544 | */ |
| 545 | 545 | function boincuser_lookup_uid($boinc_id) { |
| 546 | - $drupal_id = db_result(db_query("SELECT uid FROM {boincuser} WHERE boinc_id='%d'", $boinc_id)); |
|
| 547 | - return $drupal_id; |
|
| 546 | + $drupal_id = db_result(db_query("SELECT uid FROM {boincuser} WHERE boinc_id='%d'", $boinc_id)); |
|
| 547 | + return $drupal_id; |
|
| 548 | 548 | } |
| 549 | 549 | function get_drupal_id($boinc_id) { |
| 550 | - return boincuser_lookup_uid($boinc_id); |
|
| 550 | + return boincuser_lookup_uid($boinc_id); |
|
| 551 | 551 | } |
| 552 | 552 | |
| 553 | 553 | /** |
| 554 | 554 | * Get a BOINC user object |
| 555 | 555 | */ |
| 556 | 556 | function boincuser_load($user_id = NULL, $is_drupal_id = FALSE) { |
| 557 | - if (!$user_id) { |
|
| 557 | + if (!$user_id) { |
|
| 558 | 558 | global $user; |
| 559 | 559 | $user_id = $user->uid; |
| 560 | 560 | $is_drupal_id = TRUE; |
| 561 | - } |
|
| 562 | - if ($is_drupal_id) { |
|
| 561 | + } |
|
| 562 | + if ($is_drupal_id) { |
|
| 563 | 563 | $account = user_load($user_id); |
| 564 | 564 | $user_id = $account->boincuser_id; |
| 565 | - } |
|
| 566 | - require_boinc('boinc_db'); |
|
| 567 | - return BoincUser::lookup_id($user_id); |
|
| 565 | + } |
|
| 566 | + require_boinc('boinc_db'); |
|
| 567 | + return BoincUser::lookup_id($user_id); |
|
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | /** |
@@ -574,10 +574,10 @@ discard block |
||
| 574 | 574 | * page, delete button. |
| 575 | 575 | */ |
| 576 | 576 | function _boincuser_node_profile_delete_submit($form, &$form_state) { |
| 577 | - $node = $form['#node']; |
|
| 578 | - $deleteurl = 'node/'. $node->nid .'/delete'; |
|
| 579 | - $afterq = 'destination=account'; |
|
| 580 | - drupal_goto($deleteurl, $afterq); |
|
| 577 | + $node = $form['#node']; |
|
| 578 | + $deleteurl = 'node/'. $node->nid .'/delete'; |
|
| 579 | + $afterq = 'destination=account'; |
|
| 580 | + drupal_goto($deleteurl, $afterq); |
|
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -588,8 +588,8 @@ discard block |
||
| 588 | 588 | * Wrapper for boinc_version() function |
| 589 | 589 | */ |
| 590 | 590 | function get_boinc_version($x) { |
| 591 | - require_boinc('host'); |
|
| 592 | - return function_exists('boinc_version') ? boinc_version($x) : 'err!'; |
|
| 591 | + require_boinc('host'); |
|
| 592 | + return function_exists('boinc_version') ? boinc_version($x) : 'err!'; |
|
| 593 | 593 | } |
| 594 | 594 | |
| 595 | 595 | |
@@ -598,14 +598,14 @@ discard block |
||
| 598 | 598 | * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
| 599 | 599 | |
| 600 | 600 | /** |
| 601 | - * Generate the friend block header |
|
| 602 | - */ |
|
| 601 | + * Generate the friend block header |
|
| 602 | + */ |
|
| 603 | 603 | function boincuser_views_friends_block_header($context = null) { |
| 604 | - // Get the friend count for the user being viewed |
|
| 605 | - $view = views_get_current_view(); |
|
| 606 | - $account_id = $view->args[0]; |
|
| 607 | - $friend_count = flag_friend_get_friend_count($account_id); |
|
| 608 | - return '<h2 class="pane-title">' . bts('Friends (@count)', |
|
| 604 | + // Get the friend count for the user being viewed |
|
| 605 | + $view = views_get_current_view(); |
|
| 606 | + $account_id = $view->args[0]; |
|
| 607 | + $friend_count = flag_friend_get_friend_count($account_id); |
|
| 608 | + return '<h2 class="pane-title">' . bts('Friends (@count)', |
|
| 609 | 609 | array('@count' => $friend_count)) . '</h2>'; |
| 610 | 610 | } |
| 611 | 611 | |
@@ -614,13 +614,13 @@ discard block |
||
| 614 | 614 | * database. |
| 615 | 615 | */ |
| 616 | 616 | function _boincuser_user_name_autocomplete($string) { |
| 617 | - $matches = array(); |
|
| 618 | - db_set_active('boinc_ro'); |
|
| 619 | - $result = db_query_range("SELECT id,name FROM {user} WHERE name LIKE '%s%'", $string, 0, 10); |
|
| 620 | - db_set_active('default'); |
|
| 621 | - while ($user = db_fetch_object($result)) { |
|
| 622 | - $matches[$user->name . '_' . $user->id] = htmlentities($user->name) . " (" . $user->id . ')'; |
|
| 623 | - } |
|
| 624 | - |
|
| 625 | - drupal_json((object)$matches); |
|
| 617 | + $matches = array(); |
|
| 618 | + db_set_active('boinc_ro'); |
|
| 619 | + $result = db_query_range("SELECT id,name FROM {user} WHERE name LIKE '%s%'", $string, 0, 10); |
|
| 620 | + db_set_active('default'); |
|
| 621 | + while ($user = db_fetch_object($result)) { |
|
| 622 | + $matches[$user->name . '_' . $user->id] = htmlentities($user->name) . " (" . $user->id . ')'; |
|
| 623 | + } |
|
| 624 | + |
|
| 625 | + drupal_json((object)$matches); |
|
| 626 | 626 | } |
@@ -27,44 +27,44 @@ discard block |
||
| 27 | 27 | * with defined URL paths |
| 28 | 28 | */ |
| 29 | 29 | function boincuser_menu() { |
| 30 | - $items['account/posts'] = array( |
|
| 30 | + $items['account/posts'] = array( |
|
| 31 | 31 | 'title' => 'Recent posts', |
| 32 | 32 | 'description' => '', |
| 33 | 33 | 'page callback' => 'boincuser_goto_recent_posts', |
| 34 | 34 | 'access callback' => 'user_is_logged_in', |
| 35 | 35 | 'type' => MENU_CALLBACK, |
| 36 | - ); |
|
| 37 | - $items['account/profile'] = array( |
|
| 36 | + ); |
|
| 37 | + $items['account/profile'] = array( |
|
| 38 | 38 | 'title' => '', |
| 39 | 39 | 'description' => '', |
| 40 | 40 | 'page callback' => 'boincuser_view_profile', |
| 41 | 41 | 'access callback' => 'user_is_logged_in', |
| 42 | 42 | 'type' => MENU_NORMAL_ITEM |
| 43 | - ); |
|
| 44 | - $items['account/profile/view'] = array( |
|
| 43 | + ); |
|
| 44 | + $items['account/profile/view'] = array( |
|
| 45 | 45 | 'title' => 'View', |
| 46 | 46 | 'description' => 'Show a user profile', |
| 47 | 47 | 'page callback' => 'boincuser_view_profile', |
| 48 | 48 | 'access callback' => 'user_is_logged_in', |
| 49 | 49 | 'type' => MENU_DEFAULT_LOCAL_TASK, |
| 50 | 50 | 'weight' => 0 |
| 51 | - ); |
|
| 52 | - $items['account/profile/edit'] = array( |
|
| 51 | + ); |
|
| 52 | + $items['account/profile/edit'] = array( |
|
| 53 | 53 | 'title' => 'Edit', |
| 54 | 54 | 'description' => 'Edit a user profile', |
| 55 | 55 | 'page callback' => 'boincuser_edit_profile', |
| 56 | 56 | 'access arguments' => array('edit own profile content'), |
| 57 | 57 | 'type' => MENU_LOCAL_TASK, |
| 58 | 58 | 'weight' => 5 |
| 59 | - ); |
|
| 60 | - $items['account/team'] = array( |
|
| 59 | + ); |
|
| 60 | + $items['account/team'] = array( |
|
| 61 | 61 | 'title' => 'User team', |
| 62 | 62 | 'description' => '', |
| 63 | 63 | 'page callback' => 'boincuser_goto_team', |
| 64 | 64 | 'access callback' => 'user_is_logged_in', |
| 65 | 65 | 'type' => MENU_CALLBACK, |
| 66 | - ); |
|
| 67 | - $items['moderate/profile/%user/approve'] = array( |
|
| 66 | + ); |
|
| 67 | + $items['moderate/profile/%user/approve'] = array( |
|
| 68 | 68 | 'title' => 'Profile approval', |
| 69 | 69 | 'description' => 'Approve profile content', |
| 70 | 70 | 'page callback' => 'boincuser_moderate_profile_approve', |
@@ -72,8 +72,8 @@ discard block |
||
| 72 | 72 | 'access arguments' => array('edit any profile content'), |
| 73 | 73 | 'type' => MENU_CALLBACK, |
| 74 | 74 | 'weight' => 5 |
| 75 | - ); |
|
| 76 | - $items['moderate/profile/%user/edit'] = array( |
|
| 75 | + ); |
|
| 76 | + $items['moderate/profile/%user/edit'] = array( |
|
| 77 | 77 | 'title' => 'Profile editor', |
| 78 | 78 | 'description' => 'Edit a user profile', |
| 79 | 79 | 'page callback' => 'boincuser_edit_profile', |
@@ -81,8 +81,8 @@ discard block |
||
| 81 | 81 | 'access arguments' => array('edit any profile content'), |
| 82 | 82 | 'type' => MENU_CALLBACK, |
| 83 | 83 | 'weight' => 5 |
| 84 | - ); |
|
| 85 | - $items['moderate/profile/%/reject'] = array( |
|
| 84 | + ); |
|
| 85 | + $items['moderate/profile/%/reject'] = array( |
|
| 86 | 86 | 'title' => bts('Reject profile', array(), NULL, 'boinc:moderate-user'), |
| 87 | 87 | 'description' => 'Reject profile content', |
| 88 | 88 | 'page callback' => 'drupal_get_form', |
@@ -90,60 +90,60 @@ discard block |
||
| 90 | 90 | 'access arguments' => array('edit any profile content'), |
| 91 | 91 | 'type' => MENU_CALLBACK, |
| 92 | 92 | 'weight' => 5 |
| 93 | - ); |
|
| 94 | - $items['moderate/user/%/ban'] = array( |
|
| 93 | + ); |
|
| 94 | + $items['moderate/user/%/ban'] = array( |
|
| 95 | 95 | 'title' => bts('Ban user', array(), NULL, 'boinc:moderate-ban-user'), |
| 96 | 96 | 'description' => 'Ban a user from using community features', |
| 97 | 97 | 'page callback' => 'drupal_get_form', |
| 98 | 98 | 'page arguments' => array('boincuser_moderate_user_ban_form', 2), |
| 99 | 99 | 'access callback' => 'boincuser_moderate_community_access', |
| 100 | 100 | 'type' => MENU_CALLBACK, |
| 101 | - ); |
|
| 102 | - $items['join'] = array( |
|
| 101 | + ); |
|
| 102 | + $items['join'] = array( |
|
| 103 | 103 | 'title' => '', |
| 104 | 104 | 'description' => '', |
| 105 | 105 | 'page callback' => 'join_page', |
| 106 | 106 | 'access arguments' => array('access content'), |
| 107 | 107 | 'type' => MENU_NORMAL_ITEM |
| 108 | - ); |
|
| 109 | - $items['join/new'] = array( |
|
| 108 | + ); |
|
| 109 | + $items['join/new'] = array( |
|
| 110 | 110 | 'title' => bts("I'm new"), |
| 111 | 111 | 'page callback' => 'join_page', |
| 112 | 112 | 'page arguments' => array(1), |
| 113 | 113 | 'access arguments' => array('access content'), |
| 114 | 114 | 'type' => MENU_DEFAULT_LOCAL_TASK, |
| 115 | 115 | 'weight' => 0 |
| 116 | - ); |
|
| 117 | - $items['join/boinc'] = array( |
|
| 116 | + ); |
|
| 117 | + $items['join/boinc'] = array( |
|
| 118 | 118 | 'title' => bts("I'm a BOINC user"), |
| 119 | 119 | 'page callback' => 'join_page', |
| 120 | 120 | 'page arguments' => array(1), |
| 121 | 121 | 'access arguments' => array('access content'), |
| 122 | 122 | 'type' => MENU_LOCAL_TASK, |
| 123 | 123 | 'weight' => 5 |
| 124 | - ); |
|
| 125 | - $items['user/login/auth'] = array( |
|
| 124 | + ); |
|
| 125 | + $items['user/login/auth'] = array( |
|
| 126 | 126 | 'title' => bts('Authenticator login', array(), NULL, 'boinc:authenticator-login-page'), |
| 127 | 127 | 'description' => 'Log in using a user authenticator', |
| 128 | 128 | 'page callback' => 'drupal_get_form', |
| 129 | 129 | 'page arguments' => array('boincuser_authloginform'), |
| 130 | 130 | 'access arguments' => array('access content'), |
| 131 | 131 | 'type' => MENU_CALLBACK, |
| 132 | - ); |
|
| 133 | - $items['user/termsofuse'] = array( |
|
| 132 | + ); |
|
| 133 | + $items['user/termsofuse'] = array( |
|
| 134 | 134 | 'title' => bts('Terms of Use', array(), NULL, 'boinc:termsofuse-form'), |
| 135 | 135 | 'description' => 'A site\'s term of use.', |
| 136 | 136 | 'page callback' => 'drupal_get_form', |
| 137 | 137 | 'page arguments' => array('boincuser_termsofuse_form'), |
| 138 | 138 | 'access callback' => 'user_is_logged_in', |
| 139 | 139 | 'type' => MENU_CALLBACK, |
| 140 | - ); |
|
| 141 | - $items['user_control'] = array( |
|
| 140 | + ); |
|
| 141 | + $items['user_control'] = array( |
|
| 142 | 142 | 'page callback' => 'boincuser_control', |
| 143 | 143 | 'access arguments' => array('access user profiles'), |
| 144 | 144 | 'type' => MENU_CALLBACK |
| 145 | - ); |
|
| 146 | - $items['admin/boinc'] = array( |
|
| 145 | + ); |
|
| 146 | + $items['admin/boinc'] = array( |
|
| 147 | 147 | 'title' => 'BOINC configuration', |
| 148 | 148 | 'position' => 'right', |
| 149 | 149 | 'weight' => -8, |
@@ -151,8 +151,8 @@ discard block |
||
| 151 | 151 | 'access arguments' => array('administer site configuration'), |
| 152 | 152 | 'file' => 'system.admin.inc', |
| 153 | 153 | 'file path' => drupal_get_path('module', 'system'), |
| 154 | - ); |
|
| 155 | - $items['admin/boinc/environment'] = array( |
|
| 154 | + ); |
|
| 155 | + $items['admin/boinc/environment'] = array( |
|
| 156 | 156 | 'title' => 'Environment: General', |
| 157 | 157 | 'description' => 'Set paths to BOINC functions and any other necessary |
| 158 | 158 | variables that establish a BOINC environment.', |
@@ -161,8 +161,8 @@ discard block |
||
| 161 | 161 | 'access arguments' => array('administer site configuration'), |
| 162 | 162 | 'type' => MENU_NORMAL_ITEM, |
| 163 | 163 | 'file' => 'boincuser.admin.inc' |
| 164 | - ); |
|
| 165 | - $items['admin/boinc/scheduler'] = array( |
|
| 164 | + ); |
|
| 165 | + $items['admin/boinc/scheduler'] = array( |
|
| 166 | 166 | 'title' => 'Environment: Scheduling server URLs', |
| 167 | 167 | 'description' => 'Set BOINC scheduler options.', |
| 168 | 168 | 'page callback' => 'drupal_get_form', |
@@ -170,8 +170,8 @@ discard block |
||
| 170 | 170 | 'access arguments' => array('administer site configuration'), |
| 171 | 171 | 'type' => MENU_NORMAL_ITEM, |
| 172 | 172 | 'file' => 'boincuser.admin.inc' |
| 173 | - ); |
|
| 174 | - $items['admin/boinc/weboptions'] = array( |
|
| 173 | + ); |
|
| 174 | + $items['admin/boinc/weboptions'] = array( |
|
| 175 | 175 | 'title' => 'Environment: Website Options', |
| 176 | 176 | 'description' => 'Set options configuring this Drupal-BOINC Web site.', |
| 177 | 177 | 'page callback' => 'drupal_get_form', |
@@ -179,117 +179,117 @@ discard block |
||
| 179 | 179 | 'access arguments' => array('administer site configuration'), |
| 180 | 180 | 'type' => MENU_NORMAL_ITEM, |
| 181 | 181 | 'file' => 'boincuser.admin.inc' |
| 182 | - ); |
|
| 182 | + ); |
|
| 183 | 183 | |
| 184 | - $items['create_account.php'] = array( |
|
| 184 | + $items['create_account.php'] = array( |
|
| 185 | 185 | 'title' => 'Create Account RPC', |
| 186 | 186 | 'description' => 'RPC for creating user accounts.', |
| 187 | 187 | 'page callback' => 'boincuser_create_account', |
| 188 | 188 | 'access callback' => TRUE, |
| 189 | 189 | 'type' => MENU_CALLBACK |
| 190 | - ); |
|
| 191 | - $items['account_finish.php'] = array( |
|
| 190 | + ); |
|
| 191 | + $items['account_finish.php'] = array( |
|
| 192 | 192 | 'title' => 'Welcome to ' . variable_get('site_name', 'Drupal-BOINC'), |
| 193 | 193 | 'description' => 'RPC for after a user has created an account.', |
| 194 | 194 | 'page callback' => 'boincuser_account_finish', |
| 195 | 195 | 'access callback' => TRUE, |
| 196 | 196 | 'type' => MENU_CALLBACK, |
| 197 | - ); |
|
| 198 | - $items['boincuser/autocomplete'] = array( |
|
| 197 | + ); |
|
| 198 | + $items['boincuser/autocomplete'] = array( |
|
| 199 | 199 | 'page callback' => '_boincuser_user_name_autocomplete', |
| 200 | 200 | 'access callback' => TRUE, |
| 201 | 201 | 'type' => MENU_CALLBACK, |
| 202 | - ); |
|
| 203 | - $items['user/%user/recoveremail/%'] = array( |
|
| 202 | + ); |
|
| 203 | + $items['user/%user/recoveremail/%'] = array( |
|
| 204 | 204 | 'title' => t('Recover previous email'), |
| 205 | 205 | 'description' => t('Form to revert email to previous address.'), |
| 206 | 206 | 'page callback' => 'drupal_get_form', |
| 207 | 207 | 'page arguments' => array('boincuser_revertemail', 3), |
| 208 | 208 | 'access callback' => 'user_is_logged_in', |
| 209 | 209 | 'type' => MENU_CALLBACK, |
| 210 | - ); |
|
| 211 | - $items['recover_email.php'] = array( |
|
| 210 | + ); |
|
| 211 | + $items['recover_email.php'] = array( |
|
| 212 | 212 | 'title' => t('Recover previous email'), |
| 213 | 213 | 'description' => t('redirect'), |
| 214 | 214 | 'page callback' => '_boincuser_redirect_recover_email', |
| 215 | 215 | 'access callback' => TRUE, |
| 216 | 216 | 'type' => MENU_CALLBACK, |
| 217 | - ); |
|
| 218 | - return $items; |
|
| 217 | + ); |
|
| 218 | + return $items; |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | /** |
| 222 | 222 | * Implementation of hook_init() |
| 223 | 223 | */ |
| 224 | 224 | function boincuser_init() { |
| 225 | - global $user; |
|
| 226 | - // Skip this check for charts, which are loaded separately |
|
| 227 | - // (may get duplicate or unexpected messages otherwise) |
|
| 228 | - if (substr($_GET['q'], 0, 7) == 'charts/') { |
|
| 225 | + global $user; |
|
| 226 | + // Skip this check for charts, which are loaded separately |
|
| 227 | + // (may get duplicate or unexpected messages otherwise) |
|
| 228 | + if (substr($_GET['q'], 0, 7) == 'charts/') { |
|
| 229 | 229 | return; |
| 230 | - } |
|
| 230 | + } |
|
| 231 | 231 | |
| 232 | - // If admin user, do some basic site functionality checks |
|
| 233 | - if (user_access('administer site configuration')) { |
|
| 232 | + // If admin user, do some basic site functionality checks |
|
| 233 | + if (user_access('administer site configuration')) { |
|
| 234 | 234 | // Ensure we have a configured BOINC environment |
| 235 | 235 | boinc_get_path(); |
| 236 | 236 | boinc_get_scheduler_tags(); |
| 237 | - } |
|
| 237 | + } |
|
| 238 | 238 | |
| 239 | - // Check credits for the verified contributor role |
|
| 240 | - boincuser_check_credit_requirements(); |
|
| 239 | + // Check credits for the verified contributor role |
|
| 240 | + boincuser_check_credit_requirements(); |
|
| 241 | 241 | |
| 242 | - if (module_exists('boincteam')) { |
|
| 242 | + if (module_exists('boincteam')) { |
|
| 243 | 243 | // Display any persistent team messages |
| 244 | 244 | boincteam_show_messages(); |
| 245 | - } |
|
| 245 | + } |
|
| 246 | 246 | |
| 247 | - // Check if user has agreed to the terms of use. If not, send the |
|
| 248 | - // user to the terms-of-use form. This is only makes sense if the |
|
| 249 | - // termsofuse is enabled, by having text in the termsofuse variable. |
|
| 250 | - $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE); |
|
| 251 | - $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
| 252 | - if ( (!empty($termsofuse)) and ($user->uid) ) { |
|
| 247 | + // Check if user has agreed to the terms of use. If not, send the |
|
| 248 | + // user to the terms-of-use form. This is only makes sense if the |
|
| 249 | + // termsofuse is enabled, by having text in the termsofuse variable. |
|
| 250 | + $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE); |
|
| 251 | + $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
| 252 | + if ( (!empty($termsofuse)) and ($user->uid) ) { |
|
| 253 | 253 | if ( !boincuser_check_termsofuse($user) and ($existinguser_tou) ) { |
| 254 | 254 | |
| 255 | - // Admins are exempt, otherwise the admin may not be able to |
|
| 256 | - // access the site! |
|
| 257 | - $administrator_role = array_search('administrator', user_roles(true)); |
|
| 258 | - if (!isset($user->roles[$administrator_role])) { |
|
| 255 | + // Admins are exempt, otherwise the admin may not be able to |
|
| 256 | + // access the site! |
|
| 257 | + $administrator_role = array_search('administrator', user_roles(true)); |
|
| 258 | + if (!isset($user->roles[$administrator_role])) { |
|
| 259 | 259 | $path = drupal_get_path_alias($_GET['q']); |
| 260 | 260 | |
| 261 | 261 | // Any paths that should NOT be redirected go here. |
| 262 | 262 | // The site will not function correctly if these are not exempt! |
| 263 | 263 | $paths0 = array( |
| 264 | - 'user/termsofuse', |
|
| 265 | - 'logout', |
|
| 266 | - 'account/info/edit', |
|
| 267 | - 'user/' . $user->uid . '/edit', |
|
| 268 | - 'user/' . $user->uid . '/recoveremail/*', |
|
| 269 | - 'recover_email.php', |
|
| 264 | + 'user/termsofuse', |
|
| 265 | + 'logout', |
|
| 266 | + 'account/info/edit', |
|
| 267 | + 'user/' . $user->uid . '/edit', |
|
| 268 | + 'user/' . $user->uid . '/recoveremail/*', |
|
| 269 | + 'recover_email.php', |
|
| 270 | 270 | ); |
| 271 | 271 | if (module_exists('boincuser_delete')) { |
| 272 | - $paths0[] = 'user/' . $user->uid . '/delete'; |
|
| 273 | - $paths0[] = 'user/' . $user->uid . '/deleteconfirm/*'; |
|
| 274 | - $paths0[] = 'user/' . $user->uid . '/odeleteconfirm/*'; |
|
| 272 | + $paths0[] = 'user/' . $user->uid . '/delete'; |
|
| 273 | + $paths0[] = 'user/' . $user->uid . '/deleteconfirm/*'; |
|
| 274 | + $paths0[] = 'user/' . $user->uid . '/odeleteconfirm/*'; |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | // Paths added by the admin |
| 278 | 278 | $paths1 = preg_split('/\r\n|\r|\n/', variable_get('boinc_weboptions_pathstoignore', "moderation\ncontent/moderation\nprivacy")); |
| 279 | 279 | $paths2 = array(); |
| 280 | 280 | if (is_array($paths1)) { |
| 281 | - $paths2 = array_map('strtolower', $paths1); |
|
| 281 | + $paths2 = array_map('strtolower', $paths1); |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | // paths to ignore |
| 285 | 285 | $paths_to_ignore = array_unique( array_merge($paths0, $paths2) ); |
| 286 | 286 | |
| 287 | 287 | if (!_boincuser_ignore_paths($path, $paths_to_ignore)) { |
| 288 | - drupal_goto('user/termsofuse'); |
|
| 288 | + drupal_goto('user/termsofuse'); |
|
| 289 | + } |
|
| 289 | 290 | } |
| 290 | - } |
|
| 291 | 291 | } |
| 292 | - } |
|
| 292 | + } |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | /** |
@@ -297,13 +297,13 @@ discard block |
||
| 297 | 297 | * Drupal user operations |
| 298 | 298 | */ |
| 299 | 299 | function boincuser_user($op, &$edit, &$account, $category = NULL) { |
| 300 | - require_boinc('boinc_db'); |
|
| 301 | - require_boinc('user'); |
|
| 302 | - require_boinc('xml'); |
|
| 300 | + require_boinc('boinc_db'); |
|
| 301 | + require_boinc('user'); |
|
| 302 | + require_boinc('xml'); |
|
| 303 | 303 | |
| 304 | - require_boinc('password_compat/password'); |
|
| 305 | - // Handle BOINC integration for users with UID > 1 (skip anonymous and admin) |
|
| 306 | - if (isset($account->uid) && ($account->uid > 1)) { |
|
| 304 | + require_boinc('password_compat/password'); |
|
| 305 | + // Handle BOINC integration for users with UID > 1 (skip anonymous and admin) |
|
| 306 | + if (isset($account->uid) && ($account->uid > 1)) { |
|
| 307 | 307 | switch($op) { |
| 308 | 308 | case 'load': |
| 309 | 309 | // User loading; insert BOINC data into the user object |
@@ -311,11 +311,11 @@ discard block |
||
| 311 | 311 | SELECT boinc_id, penalty_expiration |
| 312 | 312 | FROM {boincuser} WHERE uid = %d", |
| 313 | 313 | $account->uid |
| 314 | - )); |
|
| 315 | - $account->boincuser_id = $drupal_user->boinc_id; |
|
| 316 | - $account->boincuser_penalty_expiration = $drupal_user->penalty_expiration; |
|
| 317 | - db_set_active('boinc_rw'); |
|
| 318 | - $boinc_user = db_fetch_object(db_query(" |
|
| 314 | + )); |
|
| 315 | + $account->boincuser_id = $drupal_user->boinc_id; |
|
| 316 | + $account->boincuser_penalty_expiration = $drupal_user->penalty_expiration; |
|
| 317 | + db_set_active('boinc_rw'); |
|
| 318 | + $boinc_user = db_fetch_object(db_query(" |
|
| 319 | 319 | SELECT |
| 320 | 320 | name, |
| 321 | 321 | authenticator, |
@@ -331,29 +331,29 @@ discard block |
||
| 331 | 331 | FROM {user} |
| 332 | 332 | WHERE id = %d", |
| 333 | 333 | $account->boincuser_id |
| 334 | - )); |
|
| 335 | - $account->boincuser_name = $boinc_user->name; |
|
| 336 | - $account->boincuser_account_key = $boinc_user->authenticator; |
|
| 337 | - $account->boincuser_weak_auth = md5($boinc_user->authenticator . $boinc_user->passwd_hash); |
|
| 338 | - $account->boincuser_total_credit = round($boinc_user->total_credit); |
|
| 339 | - $account->boincuser_expavg_credit = round($boinc_user->expavg_credit); |
|
| 340 | - $account->boincuser_expavg_time = round($boinc_user->expavg_time); |
|
| 341 | - $account->boincuser_cpid = md5($boinc_user->cross_project_id . $account->mail); |
|
| 342 | - $account->boincuser_default_pref_set = $boinc_user->venue; |
|
| 343 | - $account->boincteam_id = $boinc_user->teamid; |
|
| 344 | - $account->boincuser_previous_email_addr = $boinc_user->previous_email_addr; |
|
| 345 | - $account->boincuser_email_addr_change_time = $boinc_user->email_addr_change_time; |
|
| 346 | - db_set_active('default'); |
|
| 347 | - // Set Drupal team ID |
|
| 348 | - $account->team = NULL; |
|
| 349 | - if ($account->boincteam_id) { |
|
| 334 | + )); |
|
| 335 | + $account->boincuser_name = $boinc_user->name; |
|
| 336 | + $account->boincuser_account_key = $boinc_user->authenticator; |
|
| 337 | + $account->boincuser_weak_auth = md5($boinc_user->authenticator . $boinc_user->passwd_hash); |
|
| 338 | + $account->boincuser_total_credit = round($boinc_user->total_credit); |
|
| 339 | + $account->boincuser_expavg_credit = round($boinc_user->expavg_credit); |
|
| 340 | + $account->boincuser_expavg_time = round($boinc_user->expavg_time); |
|
| 341 | + $account->boincuser_cpid = md5($boinc_user->cross_project_id . $account->mail); |
|
| 342 | + $account->boincuser_default_pref_set = $boinc_user->venue; |
|
| 343 | + $account->boincteam_id = $boinc_user->teamid; |
|
| 344 | + $account->boincuser_previous_email_addr = $boinc_user->previous_email_addr; |
|
| 345 | + $account->boincuser_email_addr_change_time = $boinc_user->email_addr_change_time; |
|
| 346 | + db_set_active('default'); |
|
| 347 | + // Set Drupal team ID |
|
| 348 | + $account->team = NULL; |
|
| 349 | + if ($account->boincteam_id) { |
|
| 350 | 350 | $account->team = db_result(db_query(" |
| 351 | 351 | SELECT nid FROM {boincteam} WHERE team_id = %d", |
| 352 | - $account->boincteam_id |
|
| 352 | + $account->boincteam_id |
|
| 353 | 353 | )); |
| 354 | - } |
|
| 355 | - // Set post count |
|
| 356 | - $account->post_count = db_result(db_query(" |
|
| 354 | + } |
|
| 355 | + // Set post count |
|
| 356 | + $account->post_count = db_result(db_query(" |
|
| 357 | 357 | SELECT COUNT(*) + |
| 358 | 358 | ( |
| 359 | 359 | SELECT COUNT(*) FROM {node} |
@@ -366,8 +366,8 @@ discard block |
||
| 366 | 366 | WHERE comments.uid = '%d' |
| 367 | 367 | AND node.status = 1", |
| 368 | 368 | $account->uid, $account->uid |
| 369 | - )); |
|
| 370 | - break; |
|
| 369 | + )); |
|
| 370 | + break; |
|
| 371 | 371 | |
| 372 | 372 | case 'view': |
| 373 | 373 | // SAMPLE: Add BOINC data to the user profile |
@@ -393,74 +393,74 @@ discard block |
||
| 393 | 393 | case 'user_account': |
| 394 | 394 | // Validate data before updating user account info |
| 395 | 395 | boincuser_account_validate($edit, $account); |
| 396 | - break; |
|
| 396 | + break; |
|
| 397 | 397 | |
| 398 | 398 | default: |
| 399 | 399 | |
| 400 | 400 | } |
| 401 | 401 | // We don't want to save validation source, so remove it |
| 402 | 402 | $edit['validation_source'] = null; |
| 403 | - } |
|
| 404 | - break; |
|
| 403 | + } |
|
| 404 | + break; |
|
| 405 | 405 | |
| 406 | 406 | case 'insert': |
| 407 | 407 | // New user being added to the system |
| 408 | 408 | $imported = $_SESSION['importedUser']; |
| 409 | - unset($_SESSION['importedUser']); |
|
| 409 | + unset($_SESSION['importedUser']); |
|
| 410 | 410 | |
| 411 | - watchdog( |
|
| 411 | + watchdog( |
|
| 412 | 412 | 'boincuser', |
| 413 | 413 | 'Creating user account for %email_addr', |
| 414 | 414 | array('%email_addr' => $edit['mail']), |
| 415 | 415 | WATCHDOG_NOTICE |
| 416 | - ); |
|
| 416 | + ); |
|
| 417 | 417 | |
| 418 | - // The create_acount RPC will call this block of code when |
|
| 419 | - // user_save() is used. If user is registering using the Web |
|
| 420 | - // registration form, create a BOINC user and relationships. |
|
| 421 | - // Create a BOINC account unless importing from BOINC. |
|
| 422 | - if (!$imported) { |
|
| 418 | + // The create_acount RPC will call this block of code when |
|
| 419 | + // user_save() is used. If user is registering using the Web |
|
| 420 | + // registration form, create a BOINC user and relationships. |
|
| 421 | + // Create a BOINC account unless importing from BOINC. |
|
| 422 | + if (!$imported) { |
|
| 423 | 423 | |
| 424 | 424 | // set email address lower-case |
| 425 | 425 | $lower_email_addr = strtolower($edit['mail']); |
| 426 | 426 | |
| 427 | 427 | if ($edit['boincuser_name']) { |
| 428 | - $myname = $edit['boincuser_name']; |
|
| 428 | + $myname = $edit['boincuser_name']; |
|
| 429 | 429 | } |
| 430 | 430 | else if ($edit['name']) { |
| 431 | - $myname = $edit['name']; |
|
| 431 | + $myname = $edit['name']; |
|
| 432 | 432 | } |
| 433 | 433 | else { |
| 434 | - $myname = 'noname'; |
|
| 434 | + $myname = 'noname'; |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | $user_params = array( |
| 438 | - 'email_addr' => $lower_email_addr, |
|
| 439 | - 'name' => $myname, |
|
| 438 | + 'email_addr' => $lower_email_addr, |
|
| 439 | + 'name' => $myname, |
|
| 440 | 440 | ); |
| 441 | 441 | |
| 442 | 442 | // If the 'pass' variable is already a hash, then don't hash it again. |
| 443 | 443 | if ($edit['boinchash_flag']) { |
| 444 | - $user_params['passwd_hash'] = $edit['pass']; |
|
| 444 | + $user_params['passwd_hash'] = $edit['pass']; |
|
| 445 | 445 | } |
| 446 | 446 | else { |
| 447 | - // The passwd_hash here is only the md5() hash. This is |
|
| 448 | - // because BOINC make_user(), called later, will run |
|
| 449 | - // password_hash() on this md5 hash. |
|
| 450 | - $user_params['passwd_hash'] = md5($edit['pass'].$lower_email_addr); |
|
| 447 | + // The passwd_hash here is only the md5() hash. This is |
|
| 448 | + // because BOINC make_user(), called later, will run |
|
| 449 | + // password_hash() on this md5 hash. |
|
| 450 | + $user_params['passwd_hash'] = md5($edit['pass'].$lower_email_addr); |
|
| 451 | 451 | } |
| 452 | 452 | |
| 453 | 453 | $boinc_user = boincuser_register_make_user($user_params); |
| 454 | 454 | if (!$boinc_user) { |
| 455 | - // Account exists with this email addr |
|
| 456 | - form_set_error('email', bts('Error creating BOINC account.', array(), NULL, 'boinc:add-new-user')); |
|
| 457 | - return; |
|
| 455 | + // Account exists with this email addr |
|
| 456 | + form_set_error('email', bts('Error creating BOINC account.', array(), NULL, 'boinc:add-new-user')); |
|
| 457 | + return; |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | // Add user to community role by default (not banned) |
| 461 | 461 | $unrestricted_role = array_search('community member', user_roles(true)); |
| 462 | 462 | $edit['roles'] = array( |
| 463 | - $unrestricted_role => '' |
|
| 463 | + $unrestricted_role => '' |
|
| 464 | 464 | ); |
| 465 | 465 | |
| 466 | 466 | // Disable show_hosts flag, set to TRUE by default |
@@ -471,14 +471,14 @@ discard block |
||
| 471 | 471 | // Cross reference Drupal account with BOINC |
| 472 | 472 | $reference = db_query("INSERT INTO {boincuser} SET uid='%d', boinc_id='%d'", $account->uid, $boinc_user->id); |
| 473 | 473 | if (!$reference) { |
| 474 | - drupal_set_message(t('Error connecting BOINC account.'), 'error'); |
|
| 475 | - return; |
|
| 474 | + drupal_set_message(t('Error connecting BOINC account.'), 'error'); |
|
| 475 | + return; |
|
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | // if terms of use exist, the user must agree. |
| 479 | 479 | $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
| 480 | 480 | if (!empty($termsofuse)) { |
| 481 | - $reference2 = boincuser_consentto_termsofuse($account); |
|
| 481 | + $reference2 = boincuser_consentto_termsofuse($account); |
|
| 482 | 482 | } |
| 483 | 483 | |
| 484 | 484 | // Don't save custom fields to the Drupal user object |
@@ -486,10 +486,10 @@ discard block |
||
| 486 | 486 | $edit['boinchash_flag'] = null; |
| 487 | 487 | // Set email address to lower case in Drupal users table |
| 488 | 488 | if ($account) { |
| 489 | - user_save($account, array('mail' => $lower_email_addr)); |
|
| 489 | + user_save($account, array('mail' => $lower_email_addr)); |
|
| 490 | 490 | } |
| 491 | - } |
|
| 492 | - break; |
|
| 491 | + } |
|
| 492 | + break; |
|
| 493 | 493 | |
| 494 | 494 | case 'update': |
| 495 | 495 | if (isset($edit['update_source'])) { |
@@ -500,8 +500,8 @@ discard block |
||
| 500 | 500 | // Ensure that BOINC data is altered |
| 501 | 501 | |
| 502 | 502 | $changing_email = ($edit['mail'] AND $edit['mail'] != $boinc_user->email_addr) ? true : false; |
| 503 | - $changing_pass = ($edit['pass']) ? true : false; |
|
| 504 | - if ($changing_email OR $changing_pass) { |
|
| 503 | + $changing_pass = ($edit['pass']) ? true : false; |
|
| 504 | + if ($changing_email OR $changing_pass) { |
|
| 505 | 505 | // set email address to lower-case |
| 506 | 506 | $lower_email_addr = strtolower($edit['mail']); |
| 507 | 507 | |
@@ -510,47 +510,47 @@ discard block |
||
| 510 | 510 | $passwd_hash = password_hash( md5($passwd.$lower_email_addr), PASSWORD_DEFAULT ); |
| 511 | 511 | // Algorithm for changing email and/or password |
| 512 | 512 | if ($changing_email) { |
| 513 | - // locally store current email to set as previous email |
|
| 514 | - $prev_email = $account->mail; |
|
| 515 | - $mytime = (user_access('administer users')) ? $boinc_user->email_addr_change_time : time(); |
|
| 516 | - $querypart = "email_addr='{$lower_email_addr}', passwd_hash='{$passwd_hash}', previous_email_addr = '{$prev_email}', email_addr_change_time = $mytime"; |
|
| 513 | + // locally store current email to set as previous email |
|
| 514 | + $prev_email = $account->mail; |
|
| 515 | + $mytime = (user_access('administer users')) ? $boinc_user->email_addr_change_time : time(); |
|
| 516 | + $querypart = "email_addr='{$lower_email_addr}', passwd_hash='{$passwd_hash}', previous_email_addr = '{$prev_email}', email_addr_change_time = $mytime"; |
|
| 517 | 517 | } |
| 518 | 518 | else { |
| 519 | - $querypart = "email_addr='{$lower_email_addr}', passwd_hash='{$passwd_hash}'"; |
|
| 519 | + $querypart = "email_addr='{$lower_email_addr}', passwd_hash='{$passwd_hash}'"; |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | // Update user account information |
| 523 | 523 | $result = $boinc_user->update($querypart); |
| 524 | 524 | |
| 525 | 525 | if ($changing_email) { |
| 526 | - // reload account |
|
| 527 | - $account = user_load($account->uid); |
|
| 528 | - _boincuser_send_emailchange($account, $lower_email_addr, $prev_email, user_access('administer users')); |
|
| 526 | + // reload account |
|
| 527 | + $account = user_load($account->uid); |
|
| 528 | + _boincuser_send_emailchange($account, $lower_email_addr, $prev_email, user_access('administer users')); |
|
| 529 | 529 | } |
| 530 | 530 | |
| 531 | 531 | // Change email to edit to lower-case version, this sets |
| 532 | 532 | // email in Drupal database to the lower-case email |
| 533 | 533 | // address. |
| 534 | 534 | $edit['mail'] = strtolower($lower_email_addr); |
| 535 | - } |
|
| 535 | + } |
|
| 536 | 536 | |
| 537 | - // Change boinc username |
|
| 538 | - if ($edit['boincuser_name'] and ($edit['boincuser_name'] != $boinc_user->name)) { |
|
| 537 | + // Change boinc username |
|
| 538 | + if ($edit['boincuser_name'] and ($edit['boincuser_name'] != $boinc_user->name)) { |
|
| 539 | 539 | $boincuser_name = $edit['boincuser_name']; |
| 540 | 540 | $result = $boinc_user->update( |
| 541 | 541 | "name='{$boincuser_name}'" |
| 542 | 542 | ); |
| 543 | - } |
|
| 543 | + } |
|
| 544 | 544 | |
| 545 | - break; |
|
| 545 | + break; |
|
| 546 | 546 | case 'user_profile': |
| 547 | 547 | if ($edit['boincuser_name'] != $boinc_user->name) { |
| 548 | 548 | $boincuser_name = $edit['boincuser_name']; |
| 549 | 549 | $result = $boinc_user->update( |
| 550 | 550 | "name='{$boincuser_name}'" |
| 551 | 551 | ); |
| 552 | - } |
|
| 553 | - break; |
|
| 552 | + } |
|
| 553 | + break; |
|
| 554 | 554 | default: |
| 555 | 555 | } |
| 556 | 556 | // We don't want to save update source or duplicate custom fields, so |
@@ -558,23 +558,23 @@ discard block |
||
| 558 | 558 | $edit['update_source'] = null; |
| 559 | 559 | $edit['boincuser_name'] = null; |
| 560 | 560 | $edit['current_pass'] = null; |
| 561 | - } |
|
| 562 | - break; |
|
| 561 | + } |
|
| 562 | + break; |
|
| 563 | 563 | |
| 564 | 564 | case 'login': |
| 565 | 565 | // Function is forward compatible to Drupal 7 |
| 566 | 566 | boincuser_user_login($edit, $account); |
| 567 | - break; |
|
| 567 | + break; |
|
| 568 | 568 | |
| 569 | 569 | case 'delete': |
| 570 | 570 | // Function is forward compatible to Drupal 7 |
| 571 | 571 | boincuser_user_delete($account); |
| 572 | - break; |
|
| 572 | + break; |
|
| 573 | 573 | |
| 574 | 574 | default: |
| 575 | 575 | |
| 576 | 576 | } |
| 577 | - } |
|
| 577 | + } |
|
| 578 | 578 | } |
| 579 | 579 | |
| 580 | 580 | /** |
@@ -583,39 +583,39 @@ discard block |
||
| 583 | 583 | *(forward compatible to Drupal 7). |
| 584 | 584 | */ |
| 585 | 585 | function boincuser_user_login(&$edit, $account) { |
| 586 | - $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE); |
|
| 587 | - $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
| 588 | - |
|
| 589 | - // Use the same code as boincuser_form_alter(), for case |
|
| 590 | - // 'user_profile_form', if the refering page is the user password |
|
| 591 | - // reset form, then do not check for terms of use. |
|
| 592 | - $reset_pass = (strpos($_SERVER['HTTP_REFERER'], "/user/reset/$account->uid") === FALSE) ? 0 : 1; |
|
| 593 | - if ($reset_pass) { |
|
| 586 | + $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE); |
|
| 587 | + $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
| 588 | + |
|
| 589 | + // Use the same code as boincuser_form_alter(), for case |
|
| 590 | + // 'user_profile_form', if the refering page is the user password |
|
| 591 | + // reset form, then do not check for terms of use. |
|
| 592 | + $reset_pass = (strpos($_SERVER['HTTP_REFERER'], "/user/reset/$account->uid") === FALSE) ? 0 : 1; |
|
| 593 | + if ($reset_pass) { |
|
| 594 | 594 | return; |
| 595 | - } |
|
| 595 | + } |
|
| 596 | 596 | |
| 597 | - // Check if user has agreed to terms of use. |
|
| 598 | - if ( (!empty($termsofuse)) and ($account->uid) and |
|
| 597 | + // Check if user has agreed to terms of use. |
|
| 598 | + if ( (!empty($termsofuse)) and ($account->uid) and |
|
| 599 | 599 | (!boincuser_check_termsofuse($account)) and ($existinguser_tou) ) { |
| 600 | 600 | |
| 601 | 601 | // Admins are exempted. |
| 602 | 602 | $administrator_role = array_search('administrator', user_roles(true)); |
| 603 | 603 | if (!isset($account->roles[$administrator_role])) { |
| 604 | 604 | |
| 605 | - // Find and save the current destination and use as an parameter |
|
| 606 | - // to send the user back to here he/she came from. |
|
| 607 | - $np = ltrim('user/termsofuse', '/'); |
|
| 608 | - $path_for_destination = rawurlencode($np); |
|
| 605 | + // Find and save the current destination and use as an parameter |
|
| 606 | + // to send the user back to here he/she came from. |
|
| 607 | + $np = ltrim('user/termsofuse', '/'); |
|
| 608 | + $path_for_destination = rawurlencode($np); |
|
| 609 | 609 | |
| 610 | - $query_for_destination = ''; |
|
| 611 | - $prevdest = $_REQUEST['destination']; |
|
| 612 | - if ($prevdest) { |
|
| 610 | + $query_for_destination = ''; |
|
| 611 | + $prevdest = $_REQUEST['destination']; |
|
| 612 | + if ($prevdest) { |
|
| 613 | 613 | $query_for_destination = '?destination=' . $prevdest; |
| 614 | - } |
|
| 615 | - $_REQUEST['destination'] = $path_for_destination . $query_for_destination; |
|
| 614 | + } |
|
| 615 | + $_REQUEST['destination'] = $path_for_destination . $query_for_destination; |
|
| 616 | 616 | |
| 617 | 617 | } |
| 618 | - } |
|
| 618 | + } |
|
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | /** |
@@ -624,16 +624,16 @@ discard block |
||
| 624 | 624 | */ |
| 625 | 625 | function boincuser_user_delete($account) { |
| 626 | 626 | |
| 627 | - $boincid = $account->boincuser_id; |
|
| 628 | - // bug in comment module, remove user name from comments. Find all |
|
| 629 | - // comments with uid=0 and clear the field 'name'. |
|
| 630 | - $qrc1 = db_query("UPDATE {comments} SET comments.name='' WHERE comments.uid=0"); |
|
| 627 | + $boincid = $account->boincuser_id; |
|
| 628 | + // bug in comment module, remove user name from comments. Find all |
|
| 629 | + // comments with uid=0 and clear the field 'name'. |
|
| 630 | + $qrc1 = db_query("UPDATE {comments} SET comments.name='' WHERE comments.uid=0"); |
|
| 631 | 631 | |
| 632 | - // Delete entry in drupal boincuser table. |
|
| 633 | - $qrc2 = db_query("DELETE FROM {boincuser} WHERE uid=%d", $account->uid); |
|
| 634 | - if (!$qrc2) { |
|
| 632 | + // Delete entry in drupal boincuser table. |
|
| 633 | + $qrc2 = db_query("DELETE FROM {boincuser} WHERE uid=%d", $account->uid); |
|
| 634 | + if (!$qrc2) { |
|
| 635 | 635 | watchdog('user', 'Error deleting user account, boincuser table UID: %uid.', array('%uid' => $account->uid), WATCHDOG_ERROR); |
| 636 | - } |
|
| 636 | + } |
|
| 637 | 637 | } |
| 638 | 638 | |
| 639 | 639 | |
@@ -642,13 +642,13 @@ discard block |
||
| 642 | 642 | * Obsolete in Drupal 7... |
| 643 | 643 | */ |
| 644 | 644 | function boincuser_nodeapi(&$node, $op, $a3 = null, $a4 = null) { |
| 645 | - // In Drupal 7, these operation cases will all exist as their own hooks, |
|
| 646 | - // so let's approximate that here so that this function can simply be removed |
|
| 647 | - // upon migration to 7 |
|
| 648 | - switch($op) { |
|
| 649 | - case 'update': |
|
| 645 | + // In Drupal 7, these operation cases will all exist as their own hooks, |
|
| 646 | + // so let's approximate that here so that this function can simply be removed |
|
| 647 | + // upon migration to 7 |
|
| 648 | + switch($op) { |
|
| 649 | + case 'update': |
|
| 650 | 650 | boincuser_node_update($node); |
| 651 | - } |
|
| 651 | + } |
|
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | /** |
@@ -656,8 +656,8 @@ discard block |
||
| 656 | 656 | * is updated (forward compatible to Drupal 7) |
| 657 | 657 | */ |
| 658 | 658 | function boincuser_node_update($node) { |
| 659 | - switch($node->type) { |
|
| 660 | - case 'profile': |
|
| 659 | + switch($node->type) { |
|
| 660 | + case 'profile': |
|
| 661 | 661 | // Update the BOINC database directly |
| 662 | 662 | $account = user_load($node->uid); |
| 663 | 663 | // Save user account data |
@@ -669,11 +669,11 @@ discard block |
||
| 669 | 669 | UPDATE user |
| 670 | 670 | SET country = '%s', postal_code = '%s', url = '%s', has_profile = 1 |
| 671 | 671 | WHERE id = %d", |
| 672 | - $country, $postal_code, $url, $account->boincuser_id |
|
| 672 | + $country, $postal_code, $url, $account->boincuser_id |
|
| 673 | 673 | ); |
| 674 | 674 | db_set_active('default'); |
| 675 | 675 | if (!$account_updated) { |
| 676 | - drupal_set_message(t('Error saving BOINC account info.'), 'error'); |
|
| 676 | + drupal_set_message(t('Error saving BOINC account info.'), 'error'); |
|
| 677 | 677 | } |
| 678 | 678 | // Save profile data |
| 679 | 679 | $response1 = $node->field_background[0]['value']; |
@@ -684,16 +684,16 @@ discard block |
||
| 684 | 684 | SET userid = %d, response1 = '%s', response2 = '%s' |
| 685 | 685 | ON DUPLICATE KEY UPDATE |
| 686 | 686 | response1 = '%s', response2 = '%s'", |
| 687 | - $account->boincuser_id, $response1, $response2, |
|
| 688 | - $response1, $response2 |
|
| 687 | + $account->boincuser_id, $response1, $response2, |
|
| 688 | + $response1, $response2 |
|
| 689 | 689 | ); |
| 690 | 690 | db_set_active('default'); |
| 691 | 691 | if (!$profile_updated) { |
| 692 | - drupal_set_message(t('Error saving BOINC profile.'), 'error'); |
|
| 692 | + drupal_set_message(t('Error saving BOINC profile.'), 'error'); |
|
| 693 | 693 | } |
| 694 | 694 | break; |
| 695 | 695 | |
| 696 | - default: |
|
| 696 | + default: |
|
| 697 | 697 | |
| 698 | 698 | } |
| 699 | 699 | } |
@@ -702,21 +702,21 @@ discard block |
||
| 702 | 702 | * Implementation of hook_views_api() |
| 703 | 703 | */ |
| 704 | 704 | function boincuser_views_api() { |
| 705 | - return array( |
|
| 705 | + return array( |
|
| 706 | 706 | 'api' => 2.0, |
| 707 | 707 | 'path' => drupal_get_path('module', 'boincuser') |
| 708 | - ); |
|
| 708 | + ); |
|
| 709 | 709 | } |
| 710 | 710 | |
| 711 | 711 | /** |
| 712 | 712 | * Implementation of hook_form_alter() |
| 713 | 713 | */ |
| 714 | 714 | function boincuser_form_alter(&$form, $form_state, $form_id) { |
| 715 | - require_boinc('token'); |
|
| 715 | + require_boinc('token'); |
|
| 716 | 716 | |
| 717 | - global $user; |
|
| 718 | - switch ($form_id) { |
|
| 719 | - case 'flag_confirm': |
|
| 717 | + global $user; |
|
| 718 | + switch ($form_id) { |
|
| 719 | + case 'flag_confirm': |
|
| 720 | 720 | // The URL seems to be the only way to put any kind of context to this |
| 721 | 721 | // request! |
| 722 | 722 | $action = arg(2); |
@@ -725,25 +725,25 @@ discard block |
||
| 725 | 725 | |
| 726 | 726 | // Wrap action buttons for styling consistency |
| 727 | 727 | $form['form control tabs prefix'] = array( |
| 728 | - '#value' => '<ul class="form-control tab-list">', |
|
| 729 | - '#weight' => 1001, |
|
| 728 | + '#value' => '<ul class="form-control tab-list">', |
|
| 729 | + '#weight' => 1001, |
|
| 730 | 730 | ); |
| 731 | 731 | |
| 732 | 732 | switch ($flag_type) { |
| 733 | 733 | case 'friend': |
| 734 | 734 | $friend_id = $form['content_id']['#value']; |
| 735 | - $flag = flag_get_flag('friend'); |
|
| 736 | - $friend_status = flag_friend_determine_friend_status($flag, $friend_id, $user->uid); |
|
| 737 | - |
|
| 738 | - // General friend form overrides |
|
| 739 | - $form['flag_friend_submit']['#prefix'] = '<li class="first tab">'; |
|
| 740 | - $form['flag_friend_submit']['#value'] = bts('Send request', array(), NULL, 'boinc:friends-page'); |
|
| 741 | - $form['flag_friend_submit']['#type'] = 'submit'; |
|
| 742 | - $form['flag_friend_submit']['#suffix'] = '</li>'; |
|
| 743 | - $form['flag_friend_submit']['#weight'] = 1002; |
|
| 744 | - |
|
| 745 | - switch ($friend_status) { |
|
| 746 | - case FLAG_FRIEND_BOTH: |
|
| 735 | + $flag = flag_get_flag('friend'); |
|
| 736 | + $friend_status = flag_friend_determine_friend_status($flag, $friend_id, $user->uid); |
|
| 737 | + |
|
| 738 | + // General friend form overrides |
|
| 739 | + $form['flag_friend_submit']['#prefix'] = '<li class="first tab">'; |
|
| 740 | + $form['flag_friend_submit']['#value'] = bts('Send request', array(), NULL, 'boinc:friends-page'); |
|
| 741 | + $form['flag_friend_submit']['#type'] = 'submit'; |
|
| 742 | + $form['flag_friend_submit']['#suffix'] = '</li>'; |
|
| 743 | + $form['flag_friend_submit']['#weight'] = 1002; |
|
| 744 | + |
|
| 745 | + switch ($friend_status) { |
|
| 746 | + case FLAG_FRIEND_BOTH: |
|
| 747 | 747 | case FLAG_FRIEND_FLAGGED: |
| 748 | 748 | unset($form['actions']); |
| 749 | 749 | $form['flag_friend_submit']['#value'] = bts('Remove friend', array(), NULL, 'boinc:friends-remove'); |
@@ -752,53 +752,53 @@ discard block |
||
| 752 | 752 | $form['#submit'][] = 'boincuser_fix_unfriend_form_submit'; |
| 753 | 753 | $form['#submit'][] = $final_handler; |
| 754 | 754 | break; |
| 755 | - case FLAG_FRIEND_PENDING: |
|
| 755 | + case FLAG_FRIEND_PENDING: |
|
| 756 | 756 | unset($form['actions']); |
| 757 | 757 | $form['flag_friend_submit']['#value'] = bts('Remove request', array(), NULL, 'boinc:friends-page'); |
| 758 | 758 | break; |
| 759 | - case FLAG_FRIEND_APPROVAL: |
|
| 759 | + case FLAG_FRIEND_APPROVAL: |
|
| 760 | 760 | if ($action == 'flag') { |
| 761 | - $form['flag_friend_submit']['#value'] = bts('Approve request', array(), NULL, 'boinc:friends-page'); |
|
| 761 | + $form['flag_friend_submit']['#value'] = bts('Approve request', array(), NULL, 'boinc:friends-page'); |
|
| 762 | 762 | } |
| 763 | 763 | elseif ($action == 'unflag') { |
| 764 | - unset($form['actions']); |
|
| 765 | - $form['flag_friend_submit']['#value'] = bts('Deny request', array(), NULL, 'boinc:friends-page'); |
|
| 764 | + unset($form['actions']); |
|
| 765 | + $form['flag_friend_submit']['#value'] = bts('Deny request', array(), NULL, 'boinc:friends-page'); |
|
| 766 | 766 | } |
| 767 | 767 | break; |
| 768 | - case FLAG_FRIEND_UNFLAGGED: |
|
| 768 | + case FLAG_FRIEND_UNFLAGGED: |
|
| 769 | 769 | default: |
| 770 | 770 | $user_links[] = array( |
| 771 | - 'title' => bts('Add as friend', array(), NULL, 'boinc:friends-add'), |
|
| 772 | - 'href' => "flag/confirm/flag/friend/{$account->uid}" |
|
| 771 | + 'title' => bts('Add as friend', array(), NULL, 'boinc:friends-add'), |
|
| 772 | + 'href' => "flag/confirm/flag/friend/{$account->uid}" |
|
| 773 | 773 | ); |
| 774 | - } |
|
| 775 | - break; |
|
| 774 | + } |
|
| 775 | + break; |
|
| 776 | 776 | |
| 777 | 777 | default: |
| 778 | 778 | } |
| 779 | 779 | |
| 780 | 780 | $form['cancel'] = array( |
| 781 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $cancel_dest) . '</li>', |
|
| 782 | - '#weight' => 1004, |
|
| 781 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $cancel_dest) . '</li>', |
|
| 782 | + '#weight' => 1004, |
|
| 783 | 783 | ); |
| 784 | 784 | $form['form control tabs suffix'] = array( |
| 785 | - '#value' => '</ul>', |
|
| 786 | - '#weight' => 1010, |
|
| 785 | + '#value' => '</ul>', |
|
| 786 | + '#weight' => 1010, |
|
| 787 | 787 | ); |
| 788 | 788 | |
| 789 | 789 | break; |
| 790 | 790 | |
| 791 | - // General node edit form |
|
| 792 | - case 'news_node_form': |
|
| 791 | + // General node edit form |
|
| 792 | + case 'news_node_form': |
|
| 793 | 793 | $form['separator_bottom'] = array( |
| 794 | - '#value' => '<div class="separator buttons"></div>', |
|
| 795 | - '#weight' => 999, |
|
| 794 | + '#value' => '<div class="separator buttons"></div>', |
|
| 795 | + '#weight' => 999, |
|
| 796 | 796 | ); |
| 797 | 797 | |
| 798 | 798 | // Wrap action buttons for styling consistency |
| 799 | 799 | $form['buttons']['form control tabs prefix'] = array( |
| 800 | - '#value' => '<ul class="form-control tab-list">', |
|
| 801 | - '#weight' => 1001, |
|
| 800 | + '#value' => '<ul class="form-control tab-list">', |
|
| 801 | + '#weight' => 1001, |
|
| 802 | 802 | ); |
| 803 | 803 | $form['buttons']['submit']['#prefix'] = '<li class="first tab">'; |
| 804 | 804 | $form['buttons']['submit']['#value'] = bts('Save changes', array(), NULL, 'boinc:form-save'); |
@@ -811,15 +811,15 @@ discard block |
||
| 811 | 811 | $form['buttons']['preview_changes']['#suffix'] = '</li>'; |
| 812 | 812 | $form['buttons']['preview_changes']['#weight'] = 1004; |
| 813 | 813 | $form['buttons']['cancel'] = array( |
| 814 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "node/{$form['nid']['#value']}") . '</li>', |
|
| 815 | - '#weight' => 1005, |
|
| 814 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "node/{$form['nid']['#value']}") . '</li>', |
|
| 815 | + '#weight' => 1005, |
|
| 816 | 816 | ); |
| 817 | 817 | $form['buttons']['delete']['#prefix'] = '<li class="tab">'; |
| 818 | 818 | $form['buttons']['delete']['#suffix'] = '</li>'; |
| 819 | 819 | $form['buttons']['delete']['#weight'] = 1006; |
| 820 | 820 | $form['buttons']['form control tabs suffix'] = array( |
| 821 | - '#value' => '</ul>', |
|
| 822 | - '#weight' => 1010, |
|
| 821 | + '#value' => '</ul>', |
|
| 822 | + '#weight' => 1010, |
|
| 823 | 823 | ); |
| 824 | 824 | |
| 825 | 825 | // Preview is ugly, unset until it works |
@@ -827,16 +827,16 @@ discard block |
||
| 827 | 827 | |
| 828 | 828 | break; |
| 829 | 829 | |
| 830 | - case 'node_delete_confirm': |
|
| 830 | + case 'node_delete_confirm': |
|
| 831 | 831 | $form['separator_bottom'] = array( |
| 832 | - '#value' => '<div class="separator buttons"></div>', |
|
| 833 | - '#weight' => 999, |
|
| 832 | + '#value' => '<div class="separator buttons"></div>', |
|
| 833 | + '#weight' => 999, |
|
| 834 | 834 | ); |
| 835 | 835 | |
| 836 | 836 | // Wrap action buttons for styling consistency |
| 837 | 837 | $form['actions']['form control tabs prefix'] = array( |
| 838 | - '#value' => '<ul class="form-control tab-list">', |
|
| 839 | - '#weight' => 1001, |
|
| 838 | + '#value' => '<ul class="form-control tab-list">', |
|
| 839 | + '#weight' => 1001, |
|
| 840 | 840 | ); |
| 841 | 841 | $form['actions']['submit']['#prefix'] = '<li class="first tab">'; |
| 842 | 842 | $form['actions']['submit']['#value'] = bts('Delete', array(), NULL, 'boinc:form-delete'); |
@@ -844,23 +844,23 @@ discard block |
||
| 844 | 844 | $form['actions']['submit']['#weight'] = 1002; |
| 845 | 845 | $form['actions']['cancel'] = array( |
| 846 | 846 | '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "node/{$form['nid']['#value']}") . '</li>', |
| 847 | - '#weight' => 1005, |
|
| 847 | + '#weight' => 1005, |
|
| 848 | 848 | ); |
| 849 | 849 | $form['actions']['form control tabs suffix'] = array( |
| 850 | - '#value' => '</ul>', |
|
| 851 | - '#weight' => 1010, |
|
| 850 | + '#value' => '</ul>', |
|
| 851 | + '#weight' => 1010, |
|
| 852 | 852 | ); |
| 853 | 853 | $form['#redirect'] = 'account/profile'; |
| 854 | 854 | break; |
| 855 | 855 | |
| 856 | - case 'privatemsg_new': |
|
| 856 | + case 'privatemsg_new': |
|
| 857 | 857 | |
| 858 | 858 | $form['privatemsg']['body']['#title'] = ''; |
| 859 | 859 | |
| 860 | 860 | // Wrap action buttons for styling consistency |
| 861 | 861 | $form['privatemsg']['form control tabs prefix'] = array( |
| 862 | - '#value' => '<ul class="form-control tab-list">', |
|
| 863 | - '#weight' => 1001, |
|
| 862 | + '#value' => '<ul class="form-control tab-list">', |
|
| 863 | + '#weight' => 1001, |
|
| 864 | 864 | ); |
| 865 | 865 | $form['privatemsg']['submit']['#prefix'] = '<li class="first tab">'; |
| 866 | 866 | $form['privatemsg']['submit']['#value'] = bts('Send message', array(), NULL, 'boinc:private-message'); |
@@ -870,26 +870,26 @@ discard block |
||
| 870 | 870 | $form['privatemsg']['preview']['#suffix'] = '</li>'; |
| 871 | 871 | $form['privatemsg']['preview']['#weight'] = 1003; |
| 872 | 872 | $form['privatemsg']['cancel'] = array( |
| 873 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
| 874 | - '#weight' => 1004, |
|
| 873 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
| 874 | + '#weight' => 1004, |
|
| 875 | 875 | ); |
| 876 | 876 | $form['privatemsg']['form control tabs suffix'] = array( |
| 877 | - '#value' => '</ul>', |
|
| 878 | - '#weight' => 1010, |
|
| 877 | + '#value' => '</ul>', |
|
| 878 | + '#weight' => 1010, |
|
| 879 | 879 | ); |
| 880 | 880 | |
| 881 | 881 | unset($form['privatemsg']['recipient_display']); |
| 882 | 882 | |
| 883 | 883 | break; |
| 884 | 884 | |
| 885 | - // Login form |
|
| 886 | - case 'user_login': |
|
| 885 | + // Login form |
|
| 886 | + case 'user_login': |
|
| 887 | 887 | case 'user_login_block': |
| 888 | 888 | drupal_set_title(bts('Login', array(), NULL, 'boinc:menu-link')); |
| 889 | 889 | // Replace name with email in login form |
| 890 | 890 | unset($form['name']); |
| 891 | 891 | array_unshift($form, array( |
| 892 | - 'email' => array( |
|
| 892 | + 'email' => array( |
|
| 893 | 893 | '#type' => 'textfield', |
| 894 | 894 | '#title' => bts('Email address', array(), NULL, 'boinc:email-address-to-login'), |
| 895 | 895 | '#size' => ($form_id == 'user_login_block') ? 15 : 60, |
@@ -897,18 +897,18 @@ discard block |
||
| 897 | 897 | '#required' => TRUE, |
| 898 | 898 | '#attributes' => array('tabindex' => '1'), |
| 899 | 899 | '#description' => bts('Enter your @s email address.', array('@s' => variable_get('site_name', 'Drupal-BOINC')), NULL, 'boinc:standard-login-page') |
| 900 | - ), |
|
| 901 | - 'validation_source' => array( |
|
| 900 | + ), |
|
| 901 | + 'validation_source' => array( |
|
| 902 | 902 | '#type' => 'hidden', |
| 903 | 903 | '#value' => 'user_login' |
| 904 | - ) |
|
| 904 | + ) |
|
| 905 | 905 | )); |
| 906 | 906 | $form['#redirect'] = 'home'; |
| 907 | 907 | |
| 908 | 908 | // Wrap action buttons for styling consistency |
| 909 | 909 | $form['buttons']['form control tabs prefix'] = array( |
| 910 | - '#value' => '<ul class="form-control tab-list">', |
|
| 911 | - '#weight' => 1001, |
|
| 910 | + '#value' => '<ul class="form-control tab-list">', |
|
| 911 | + '#weight' => 1001, |
|
| 912 | 912 | ); |
| 913 | 913 | $form['buttons']['submit'] = $form['submit']; |
| 914 | 914 | $form['buttons']['submit']['#prefix'] = '<li class="first tab">'; |
@@ -916,8 +916,8 @@ discard block |
||
| 916 | 916 | $form['buttons']['submit']['#suffix'] = '</li>'; |
| 917 | 917 | $form['buttons']['submit']['#weight'] = 1002; |
| 918 | 918 | $form['buttons']['form control tabs suffix'] = array( |
| 919 | - '#value' => '</ul>', |
|
| 920 | - '#weight' => 1010, |
|
| 919 | + '#value' => '</ul>', |
|
| 920 | + '#weight' => 1010, |
|
| 921 | 921 | ); |
| 922 | 922 | unset($form['submit']); |
| 923 | 923 | |
@@ -926,23 +926,23 @@ discard block |
||
| 926 | 926 | isset($form['buttons']['submit']['#attributes']) ? array_push($form['buttons']['submit']['#attributes'], array('tabindex' => '3')) : $form['buttons']['submit']['#attributes'] = array('tabindex' => '3'); |
| 927 | 927 | // If the user login form is being submitted, use BOINC validation handler. |
| 928 | 928 | if (isset($form_state['post']['email']) and isset($form_state['post']['pass'])) { |
| 929 | - // Find the local validation function's entry so we can replace it. |
|
| 930 | - $array_key = array_search('user_login_authenticate_validate', $form['#validate']); |
|
| 931 | - if ($array_key === FALSE) { |
|
| 929 | + // Find the local validation function's entry so we can replace it. |
|
| 930 | + $array_key = array_search('user_login_authenticate_validate', $form['#validate']); |
|
| 931 | + if ($array_key === FALSE) { |
|
| 932 | 932 | // Could not find it. Some other module must have run form_alter(). |
| 933 | 933 | // We will simply add our validation just before the final validator. |
| 934 | 934 | $final_validator = array_pop($form['#validate']); |
| 935 | 935 | $form['#validate'][] = 'boincuser_login_validate'; |
| 936 | 936 | $form['#validate'][] = $final_validator; |
| 937 | - } else { |
|
| 937 | + } else { |
|
| 938 | 938 | // Replace the local validation function with BOINC validation |
| 939 | 939 | $form['#validate'][$array_key] = 'boincuser_login_validate'; |
| 940 | - } |
|
| 940 | + } |
|
| 941 | 941 | } |
| 942 | 942 | break; |
| 943 | 943 | |
| 944 | - // User credentials form |
|
| 945 | - case 'user_profile_form': |
|
| 944 | + // User credentials form |
|
| 945 | + case 'user_profile_form': |
|
| 946 | 946 | |
| 947 | 947 | // Use the displaly name as the title, not the username |
| 948 | 948 | $account = user_load($form['#uid']); |
@@ -950,28 +950,28 @@ discard block |
||
| 950 | 950 | |
| 951 | 951 | // Message for admins |
| 952 | 952 | if (user_access('administer users')) { |
| 953 | - drupal_set_message( |
|
| 953 | + drupal_set_message( |
|
| 954 | 954 | bts('WARNING: You are editing the information for user. Please note: you may change a user\'s password by itself. But to change the user\'s email address you must change both the email address and the password simultaneously.') |
| 955 | - , 'warning'); |
|
| 955 | + , 'warning'); |
|
| 956 | 956 | } |
| 957 | 957 | |
| 958 | 958 | // Set special message if user has not agreed to TOU |
| 959 | 959 | $existinguser_tou = variable_get('boinc_weboptions_existinguser_tou', FALSE); |
| 960 | 960 | $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
| 961 | 961 | if ( (!boincuser_check_termsofuse($account)) and ($existinguser_tou) and (!empty($termsofuse)) and (!user_access('administer users')) ) { |
| 962 | - drupal_set_message( |
|
| 962 | + drupal_set_message( |
|
| 963 | 963 | bts('INFO: You have not agreed to the terms of use for @project. You may use this form to change your email address and/or password. Please note: you may not delete your account within seven (7) days of changing your email address.', |
| 964 | 964 | array( |
| 965 | - '@project' => variable_get('site_name','Drupal-BOINC'), |
|
| 965 | + '@project' => variable_get('site_name','Drupal-BOINC'), |
|
| 966 | 966 | ), NULL, 'boinc:account-credentials-change') |
| 967 | - , 'info'); |
|
| 967 | + , 'info'); |
|
| 968 | 968 | } |
| 969 | 969 | |
| 970 | 970 | // A bit hackish... but don't require the user to enter his password if |
| 971 | 971 | // coming from the password reset function |
| 972 | 972 | $reset_pass = (strpos($_SERVER['HTTP_REFERER'], "/user/reset/{$form['#uid']}") === FALSE) ? 0 : 1; |
| 973 | 973 | if ($reset_pass) { |
| 974 | - $_SESSION['reset_pass'] = 1; |
|
| 974 | + $_SESSION['reset_pass'] = 1; |
|
| 975 | 975 | } |
| 976 | 976 | |
| 977 | 977 | // Adjust form elements already present |
@@ -983,8 +983,8 @@ discard block |
||
| 983 | 983 | $form['account']['pass']['#size'] = 17; |
| 984 | 984 | |
| 985 | 985 | if (user_access('administer users')) { |
| 986 | - // Add BOINC username (aka displayname) |
|
| 987 | - $form['account']['boincuser_name'] = array( |
|
| 986 | + // Add BOINC username (aka displayname) |
|
| 987 | + $form['account']['boincuser_name'] = array( |
|
| 988 | 988 | '#type' => 'textfield', |
| 989 | 989 | '#title' => bts('BOINC Username', array(), NULL, 'boinc:user-or-team-name'), |
| 990 | 990 | '#default_value' => $account->boincuser_name, |
@@ -992,68 +992,68 @@ discard block |
||
| 992 | 992 | '#required' => TRUE, |
| 993 | 993 | '#description' => bts('This is the BOINC (external) username. This is the same setting as found in Account -> Preferences -> Community.', array(), NULL, 'boinc:username-change'), |
| 994 | 994 | '#size' => 40, |
| 995 | - ); |
|
| 995 | + ); |
|
| 996 | 996 | } |
| 997 | 997 | |
| 998 | 998 | // If email address was changed less than 7 days (7 * 86400 s) |
| 999 | 999 | // ago, it cannot be changed again. |
| 1000 | 1000 | $duration = TOKEN_DURATION_ONE_WEEK; |
| 1001 | 1001 | if (($account->boincuser_email_addr_change_time + $duration) > time() and (!user_access('administer users'))) { |
| 1002 | - $form['account']['mail']['#required'] = FALSE; |
|
| 1003 | - $form['account']['mailhelp'] = array( |
|
| 1002 | + $form['account']['mail']['#required'] = FALSE; |
|
| 1003 | + $form['account']['mailhelp'] = array( |
|
| 1004 | 1004 | '#value' => bts("You email address was changed within the past seven (7) days. Please look for an email to !prev_email if you need to revert this change. You may change your email address on !time.", |
| 1005 | - array( |
|
| 1005 | + array( |
|
| 1006 | 1006 | '!prev_email' => $account->boincuser_previous_email_addr, |
| 1007 | 1007 | '!time' => date('F j, Y \a\t G:i T', $account->boincuser_email_addr_change_time + $duration), |
| 1008 | - ), NULL, 'boinc:account-credentials-change'), |
|
| 1009 | - ); |
|
| 1008 | + ), NULL, 'boinc:account-credentials-change'), |
|
| 1009 | + ); |
|
| 1010 | 1010 | } |
| 1011 | 1011 | |
| 1012 | 1012 | if (!$reset_pass AND ($user->uid == $account->uid OR !user_access('administer users'))) { |
| 1013 | - // Add a password authenticator, required to change email or pw |
|
| 1014 | - $form['account']['current_pass'] = array( |
|
| 1013 | + // Add a password authenticator, required to change email or pw |
|
| 1014 | + $form['account']['current_pass'] = array( |
|
| 1015 | 1015 | '#type' => 'password', |
| 1016 | 1016 | '#title' => bts('Enter your password to save changes', array(), NULL, 'boinc:account-credentials-change'), |
| 1017 | 1017 | '#description' => bts('Enter your current password if changing your email |
| 1018 | 1018 | address or password.', array(), NULL, 'boinc:account-credentials-change'), |
| 1019 | 1019 | '#size' => 17, |
| 1020 | 1020 | '#attributes' => array( |
| 1021 | - 'autocomplete' => 'off', |
|
| 1021 | + 'autocomplete' => 'off', |
|
| 1022 | 1022 | ), |
| 1023 | - ); |
|
| 1023 | + ); |
|
| 1024 | 1024 | } |
| 1025 | 1025 | |
| 1026 | 1026 | // Add account keys, CPID, etc |
| 1027 | 1027 | $form['account']['boincuser_id'] = array( |
| 1028 | - '#value' => ' |
|
| 1028 | + '#value' => ' |
|
| 1029 | 1029 | <div class="form-item"> |
| 1030 | 1030 | <label>' . bts('BOINC user ID', array(), NULL, 'boinc:account-credentials-change') . '</label> |
| 1031 | 1031 | <span>' . $account->boincuser_id . '</span> |
| 1032 | 1032 | </div>', |
| 1033 | 1033 | ); |
| 1034 | 1034 | $form['account']['user_id'] = array( |
| 1035 | - '#value' => ' |
|
| 1035 | + '#value' => ' |
|
| 1036 | 1036 | <div class="form-item"> |
| 1037 | 1037 | <label>' . bts('Drupal user ID', array(), NULL, 'boinc:account-credentials-change') . '</label> |
| 1038 | 1038 | <span>' . $account->uid . '</span> |
| 1039 | 1039 | </div>', |
| 1040 | 1040 | ); |
| 1041 | 1041 | $form['account']['account_key'] = array( |
| 1042 | - '#value' => ' |
|
| 1042 | + '#value' => ' |
|
| 1043 | 1043 | <div class="form-item"> |
| 1044 | 1044 | <label>' . bts('Account key', array(), NULL, 'boinc:account-credentials-change') . '</label> |
| 1045 | 1045 | <span>' . $account->boincuser_account_key . '</span> |
| 1046 | 1046 | </div>', |
| 1047 | 1047 | ); |
| 1048 | 1048 | $form['account']['weak_account_key'] = array( |
| 1049 | - '#value' => ' |
|
| 1049 | + '#value' => ' |
|
| 1050 | 1050 | <div class="form-item"> |
| 1051 | 1051 | <label>' . bts('Weak account key', array(), NULL, 'boinc:account-credentials-change') . '</label> |
| 1052 | 1052 | <span>' . "{$account->boincuser_id}_{$account->boincuser_weak_auth}" . '</span> |
| 1053 | 1053 | </div>', |
| 1054 | 1054 | ); |
| 1055 | 1055 | $form['account']['cpid'] = array( |
| 1056 | - '#value' => ' |
|
| 1056 | + '#value' => ' |
|
| 1057 | 1057 | <div class="form-item"> |
| 1058 | 1058 | <label>' . bts('Cross-project ID', array(), NULL, 'boinc:account-credentials-change') . '</label> |
| 1059 | 1059 | <span>' . $account->boincuser_cpid . '</span> |
@@ -1061,30 +1061,30 @@ discard block |
||
| 1061 | 1061 | ); |
| 1062 | 1062 | |
| 1063 | 1063 | $form['account']['separator_bottom'] = array( |
| 1064 | - '#value' => '<div class="separator buttons"></div>' |
|
| 1064 | + '#value' => '<div class="separator buttons"></div>' |
|
| 1065 | 1065 | ); |
| 1066 | 1066 | |
| 1067 | 1067 | // Wrap action buttons for styling consistency |
| 1068 | 1068 | $form['form control tabs prefix'] = array( |
| 1069 | - '#value' => '<ul class="form-control tab-list">', |
|
| 1070 | - '#weight' => 1001, |
|
| 1069 | + '#value' => '<ul class="form-control tab-list">', |
|
| 1070 | + '#weight' => 1001, |
|
| 1071 | 1071 | ); |
| 1072 | 1072 | $form['submit']['#prefix'] = '<li class="first tab">'; |
| 1073 | 1073 | $form['submit']['#value'] = bts('Save changes', array(), NULL, 'boinc:form-save'); |
| 1074 | 1074 | $form['submit']['#suffix'] = '</li>'; |
| 1075 | 1075 | $form['submit']['#weight'] = 1002; |
| 1076 | 1076 | $form['cancel'] = array( |
| 1077 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
| 1078 | - '#weight' => 1003, |
|
| 1077 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
| 1078 | + '#weight' => 1003, |
|
| 1079 | 1079 | ); |
| 1080 | 1080 | if (isset($form['delete']) AND is_array($form['delete'])) { |
| 1081 | - $form['delete']['#prefix'] = '<li class="first alt tab">'; |
|
| 1082 | - $form['delete']['#suffix'] = '</li>'; |
|
| 1083 | - $form['delete']['#weight'] = 1004; |
|
| 1081 | + $form['delete']['#prefix'] = '<li class="first alt tab">'; |
|
| 1082 | + $form['delete']['#suffix'] = '</li>'; |
|
| 1083 | + $form['delete']['#weight'] = 1004; |
|
| 1084 | 1084 | } |
| 1085 | 1085 | $form['form control tabs suffix'] = array( |
| 1086 | - '#value' => '</ul>', |
|
| 1087 | - '#weight' => 1010, |
|
| 1086 | + '#value' => '</ul>', |
|
| 1087 | + '#weight' => 1010, |
|
| 1088 | 1088 | ); |
| 1089 | 1089 | |
| 1090 | 1090 | // Rearrange form elements |
@@ -1104,7 +1104,7 @@ discard block |
||
| 1104 | 1104 | // Remove redundant / unnecessary form elements |
| 1105 | 1105 | unset($form['theme_select']); |
| 1106 | 1106 | if (!module_exists('boincuser_delete')) { |
| 1107 | - unset($form['delete']); |
|
| 1107 | + unset($form['delete']); |
|
| 1108 | 1108 | } |
| 1109 | 1109 | |
| 1110 | 1110 | // These are on the Community preferences form (boincwork module) |
@@ -1120,18 +1120,18 @@ discard block |
||
| 1120 | 1120 | |
| 1121 | 1121 | // Internal fields to indicate where these user changes are taking place |
| 1122 | 1122 | array_unshift($form, array( |
| 1123 | - 'validation_source' => array( |
|
| 1123 | + 'validation_source' => array( |
|
| 1124 | 1124 | '#type' => 'hidden', |
| 1125 | 1125 | '#value' => 'user_account' |
| 1126 | - ), |
|
| 1127 | - 'update_source' => array( |
|
| 1126 | + ), |
|
| 1127 | + 'update_source' => array( |
|
| 1128 | 1128 | '#type' => 'hidden', |
| 1129 | 1129 | '#value' => 'user_account' |
| 1130 | - ) |
|
| 1130 | + ) |
|
| 1131 | 1131 | )); |
| 1132 | 1132 | break; |
| 1133 | 1133 | |
| 1134 | - case 'profile_node_form': |
|
| 1134 | + case 'profile_node_form': |
|
| 1135 | 1135 | |
| 1136 | 1136 | // Use the display name as the title, not the username |
| 1137 | 1137 | $account = user_load($form['uid']['#value']); |
@@ -1142,22 +1142,22 @@ discard block |
||
| 1142 | 1142 | $form['title']['#access'] = FALSE; |
| 1143 | 1143 | |
| 1144 | 1144 | $form['separator_bottom'] = array( |
| 1145 | - '#value' => '<div class="separator buttons"></div>', |
|
| 1146 | - '#weight' => 999, |
|
| 1145 | + '#value' => '<div class="separator buttons"></div>', |
|
| 1146 | + '#weight' => 999, |
|
| 1147 | 1147 | ); |
| 1148 | 1148 | |
| 1149 | 1149 | if (module_exists('captcha')) { |
| 1150 | - // Add an optional captcha |
|
| 1151 | - $form['profile_captcha'] = array( |
|
| 1150 | + // Add an optional captcha |
|
| 1151 | + $form['profile_captcha'] = array( |
|
| 1152 | 1152 | '#type' => 'captcha', |
| 1153 | 1153 | '#weight' => 1000, |
| 1154 | - ); |
|
| 1154 | + ); |
|
| 1155 | 1155 | } |
| 1156 | 1156 | |
| 1157 | 1157 | // Wrap action buttons for styling consistency |
| 1158 | 1158 | $form['buttons']['form control tabs prefix'] = array( |
| 1159 | - '#value' => '<ul class="form-control tab-list">', |
|
| 1160 | - '#weight' => 1001, |
|
| 1159 | + '#value' => '<ul class="form-control tab-list">', |
|
| 1160 | + '#weight' => 1001, |
|
| 1161 | 1161 | ); |
| 1162 | 1162 | $form['buttons']['submit']['#prefix'] = '<li class="first tab">'; |
| 1163 | 1163 | $form['buttons']['submit']['#value'] = bts('Save changes', array(), NULL, 'boinc:form-save'); |
@@ -1170,8 +1170,8 @@ discard block |
||
| 1170 | 1170 | $form['buttons']['preview_changes']['#suffix'] = '</li>'; |
| 1171 | 1171 | $form['buttons']['preview_changes']['#weight'] = 1004; |
| 1172 | 1172 | $form['buttons']['cancel'] = array( |
| 1173 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
| 1174 | - '#weight' => 1005, |
|
| 1173 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>', |
|
| 1174 | + '#weight' => 1005, |
|
| 1175 | 1175 | ); |
| 1176 | 1176 | $form['buttons']['delete']['#prefix'] = '<li class="tab">'; |
| 1177 | 1177 | $form['buttons']['delete']['#suffix'] = '</li>'; |
@@ -1179,8 +1179,8 @@ discard block |
||
| 1179 | 1179 | $form['buttons']['delete']['#weight'] = 1006; |
| 1180 | 1180 | $form['buttons']['delete']['#submit'] = array('_boincuser_node_profile_delete_submit'); |
| 1181 | 1181 | $form['buttons']['form control tabs suffix'] = array( |
| 1182 | - '#value' => '</ul>', |
|
| 1183 | - '#weight' => 1010, |
|
| 1182 | + '#value' => '</ul>', |
|
| 1183 | + '#weight' => 1010, |
|
| 1184 | 1184 | ); |
| 1185 | 1185 | |
| 1186 | 1186 | $form['#after_build'][] = 'boincuser_profile_node_form_after_build'; |
@@ -1193,33 +1193,33 @@ discard block |
||
| 1193 | 1193 | |
| 1194 | 1194 | // Internal fields to indicate where these user changes are taking place |
| 1195 | 1195 | array_unshift($form, array( |
| 1196 | - 'validation_source' => array( |
|
| 1196 | + 'validation_source' => array( |
|
| 1197 | 1197 | '#type' => 'hidden', |
| 1198 | 1198 | '#value' => 'user_profile' |
| 1199 | - ), |
|
| 1200 | - 'update_source' => array( |
|
| 1199 | + ), |
|
| 1200 | + 'update_source' => array( |
|
| 1201 | 1201 | '#type' => 'hidden', |
| 1202 | 1202 | '#value' => 'user_profile' |
| 1203 | - ) |
|
| 1203 | + ) |
|
| 1204 | 1204 | )); |
| 1205 | 1205 | break; |
| 1206 | 1206 | |
| 1207 | - // Registration form |
|
| 1208 | - case 'user_register': |
|
| 1207 | + // Registration form |
|
| 1208 | + case 'user_register': |
|
| 1209 | 1209 | array_unshift($form, array( |
| 1210 | - 'boincuser_name' => array( |
|
| 1210 | + 'boincuser_name' => array( |
|
| 1211 | 1211 | '#type' => 'textfield', |
| 1212 | 1212 | '#title' => bts('Name', array(), NULL, 'boinc:user-or-team-name'), |
| 1213 | 1213 | '#default_value' => $edit['boincuser_name'], |
| 1214 | 1214 | '#maxlength' => USERNAME_MAX_LENGTH, |
| 1215 | 1215 | '#description' => bts('Spaces are allowed; punctuation is not allowed except for periods, hyphens, and underscores.', array(), NULL, 'boinc:user-register'), |
| 1216 | 1216 | '#required' => TRUE |
| 1217 | - ), |
|
| 1217 | + ), |
|
| 1218 | 1218 | )); |
| 1219 | 1219 | // Set name temporarily to dummy value to beat validation |
| 1220 | 1220 | $form['name'] = array( |
| 1221 | - '#type' => 'hidden', |
|
| 1222 | - '#value' => rand() . '.' . time() |
|
| 1221 | + '#type' => 'hidden', |
|
| 1222 | + '#value' => rand() . '.' . time() |
|
| 1223 | 1223 | ); |
| 1224 | 1224 | |
| 1225 | 1225 | // Add JS for submit button disabling |
@@ -1229,50 +1229,50 @@ discard block |
||
| 1229 | 1229 | $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
| 1230 | 1230 | if (!empty($termsofuse)) { |
| 1231 | 1231 | |
| 1232 | - $form['termsofuse'] = array( |
|
| 1232 | + $form['termsofuse'] = array( |
|
| 1233 | 1233 | '#type' => 'fieldset', |
| 1234 | 1234 | '#prefix' => '<div id="termsofuse-wrapper">', // This is our wrapper div. |
| 1235 | 1235 | '#suffix' => '</div>', |
| 1236 | 1236 | '#tree' => TRUE, |
| 1237 | 1237 | '#weight' => -15, |
| 1238 | - ); |
|
| 1238 | + ); |
|
| 1239 | 1239 | |
| 1240 | - $form['termsofuse']['title1'] = array( |
|
| 1240 | + $form['termsofuse']['title1'] = array( |
|
| 1241 | 1241 | '#weight' => -12, |
| 1242 | 1242 | '#value' => '<h2>' . bts(variable_get('boinc_weboptions_registrationtitle', 'Please read and acknowledge our terms of use'), array(), NULL, 'project:user-register' ) . '</h2>', |
| 1243 | 1243 | '#prefix' => '<div id="register-title1">', |
| 1244 | 1244 | '#suffix' => '</div>', |
| 1245 | - ); |
|
| 1245 | + ); |
|
| 1246 | 1246 | |
| 1247 | - $form['termsofuse']['body'] = array( |
|
| 1247 | + $form['termsofuse']['body'] = array( |
|
| 1248 | 1248 | '#weight' => -10, |
| 1249 | 1249 | '#value' => bts($termsofuse, array(), NULL, 'project:user-register'), |
| 1250 | 1250 | '#prefix' => '<div id="register-termsofuse">', |
| 1251 | 1251 | '#suffix' => '</div>', |
| 1252 | - ); |
|
| 1252 | + ); |
|
| 1253 | 1253 | |
| 1254 | - $form['termsofuse']['agreeTOU'] = array( |
|
| 1254 | + $form['termsofuse']['agreeTOU'] = array( |
|
| 1255 | 1255 | '#type' => 'checkbox', |
| 1256 | 1256 | '#title' => bts(variable_get('boinc_weboptions_agreequestion', 'Do you agree with the above terms of use?'), array(), NULL, 'project:user-register'), |
| 1257 | 1257 | '#weight' => -8, |
| 1258 | 1258 | '#prefix' => '<div id="register-checkbox">', |
| 1259 | 1259 | '#suffix' => '</div>', |
| 1260 | - ); |
|
| 1260 | + ); |
|
| 1261 | 1261 | } |
| 1262 | 1262 | |
| 1263 | 1263 | $form['title2'] = array( |
| 1264 | - '#weight' => -6, |
|
| 1265 | - '#value' => '<h2>' . bts(variable_get('boinc_weboptions_registrationtitle2', 'Fill in your name, email, and choose a secure passphrase.'), array(), NULL, 'project:user-register') . '</h2>', |
|
| 1266 | - '#prefix' => '<div id="register-title2">', |
|
| 1267 | - '#suffix' => '</div>', |
|
| 1264 | + '#weight' => -6, |
|
| 1265 | + '#value' => '<h2>' . bts(variable_get('boinc_weboptions_registrationtitle2', 'Fill in your name, email, and choose a secure passphrase.'), array(), NULL, 'project:user-register') . '</h2>', |
|
| 1266 | + '#prefix' => '<div id="register-title2">', |
|
| 1267 | + '#suffix' => '</div>', |
|
| 1268 | 1268 | ); |
| 1269 | 1269 | |
| 1270 | 1270 | if (module_exists('captcha')) { |
| 1271 | - // Add an optional captcha |
|
| 1272 | - $form['register_captcha'] = array( |
|
| 1271 | + // Add an optional captcha |
|
| 1272 | + $form['register_captcha'] = array( |
|
| 1273 | 1273 | '#type' => 'captcha', |
| 1274 | 1274 | '#weight' => 1000, |
| 1275 | - ); |
|
| 1275 | + ); |
|
| 1276 | 1276 | } |
| 1277 | 1277 | |
| 1278 | 1278 | $form['#validate'][] = 'boincuser_register_validate'; |
@@ -1280,45 +1280,45 @@ discard block |
||
| 1280 | 1280 | $form['submit']['#weight'] = 1001; |
| 1281 | 1281 | break; |
| 1282 | 1282 | |
| 1283 | - // Request new password form |
|
| 1284 | - case 'user_pass': |
|
| 1283 | + // Request new password form |
|
| 1284 | + case 'user_pass': |
|
| 1285 | 1285 | drupal_set_title(bts('Forgot password', array(), NULL, 'boinc:forgot-password')); |
| 1286 | 1286 | // Replace name/email text box with email only; retain "name" label |
| 1287 | 1287 | // for compatibility with standard Drupal submit function |
| 1288 | 1288 | unset($form['name']); |
| 1289 | 1289 | array_unshift($form, array( |
| 1290 | - 'name' => array( |
|
| 1290 | + 'name' => array( |
|
| 1291 | 1291 | '#type' => 'textfield', |
| 1292 | 1292 | '#title' => bts('Email address', array(), NULL, 'boinc:email-address-to-login'), |
| 1293 | 1293 | '#size' => 60, |
| 1294 | 1294 | '#maxlength' => EMAIL_MAX_LENGTH, |
| 1295 | 1295 | '#required' => TRUE, |
| 1296 | 1296 | '#description' => bts( |
| 1297 | - 'Enter your email address to receive instructions for resetting your password (or use the !authenticator_login).', |
|
| 1298 | - array( |
|
| 1297 | + 'Enter your email address to receive instructions for resetting your password (or use the !authenticator_login).', |
|
| 1298 | + array( |
|
| 1299 | 1299 | '!authenticator_login' => l( |
| 1300 | - bts('authenticator-based login', array(), NULL, 'boinc:forgot-password'), |
|
| 1301 | - 'user/login/auth' |
|
| 1300 | + bts('authenticator-based login', array(), NULL, 'boinc:forgot-password'), |
|
| 1301 | + 'user/login/auth' |
|
| 1302 | + ) |
|
| 1302 | 1303 | ) |
| 1303 | - ) |
|
| 1304 | 1304 | , NULL, 'boinc:forgot-password'), |
| 1305 | - ), |
|
| 1305 | + ), |
|
| 1306 | 1306 | )); |
| 1307 | 1307 | |
| 1308 | 1308 | if (module_exists('captcha')) { |
| 1309 | - // Add an optional captcha |
|
| 1310 | - $form['register_captcha'] = array( |
|
| 1309 | + // Add an optional captcha |
|
| 1310 | + $form['register_captcha'] = array( |
|
| 1311 | 1311 | '#type' => 'captcha', |
| 1312 | 1312 | '#weight' => 0, |
| 1313 | 1313 | '#prefix' => '<div id="captcha-password-reset">', |
| 1314 | 1314 | '#suffix' => '</div>' |
| 1315 | - ); |
|
| 1315 | + ); |
|
| 1316 | 1316 | } |
| 1317 | 1317 | |
| 1318 | 1318 | // Wrap action buttons for styling consistency |
| 1319 | 1319 | $form['buttons']['form control tabs prefix'] = array( |
| 1320 | - '#value' => '<ul class="form-control tab-list">', |
|
| 1321 | - '#weight' => 1001, |
|
| 1320 | + '#value' => '<ul class="form-control tab-list">', |
|
| 1321 | + '#weight' => 1001, |
|
| 1322 | 1322 | ); |
| 1323 | 1323 | $form['buttons']['submit'] = $form['submit']; |
| 1324 | 1324 | $form['buttons']['submit']['#prefix'] = '<li class="first tab">'; |
@@ -1326,26 +1326,26 @@ discard block |
||
| 1326 | 1326 | $form['buttons']['submit']['#suffix'] = '</li>'; |
| 1327 | 1327 | $form['buttons']['submit']['#weight'] = 1002; |
| 1328 | 1328 | $form['buttons']['cancel'] = array( |
| 1329 | - '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'user/login') . '</li>', |
|
| 1330 | - '#weight' => 1005, |
|
| 1329 | + '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), 'user/login') . '</li>', |
|
| 1330 | + '#weight' => 1005, |
|
| 1331 | 1331 | ); |
| 1332 | 1332 | $form['buttons']['form control tabs suffix'] = array( |
| 1333 | - '#value' => '</ul>', |
|
| 1334 | - '#weight' => 1010, |
|
| 1333 | + '#value' => '</ul>', |
|
| 1334 | + '#weight' => 1010, |
|
| 1335 | 1335 | ); |
| 1336 | 1336 | unset($form['submit']); |
| 1337 | 1337 | |
| 1338 | 1338 | // If the form is being submitted, use BOINC validation handler. |
| 1339 | 1339 | if (isset($form_state['post']['name'])) { |
| 1340 | - // Prepend the BOINC validation function to local validation |
|
| 1341 | - array_unshift($form['#validate'], 'boincuser_request_pass_validate'); |
|
| 1340 | + // Prepend the BOINC validation function to local validation |
|
| 1341 | + array_unshift($form['#validate'], 'boincuser_request_pass_validate'); |
|
| 1342 | 1342 | } |
| 1343 | 1343 | break; |
| 1344 | 1344 | |
| 1345 | - case 'views_exposed_form': |
|
| 1345 | + case 'views_exposed_form': |
|
| 1346 | 1346 | $form['submit']['#value'] = bts('Search', array(), NULL, 'boinc:search-user'); |
| 1347 | 1347 | break; |
| 1348 | - } |
|
| 1348 | + } |
|
| 1349 | 1349 | } |
| 1350 | 1350 | |
| 1351 | 1351 | /** |
@@ -1353,10 +1353,10 @@ discard block |
||
| 1353 | 1353 | * built; this is called from boincuser_form_alter() |
| 1354 | 1354 | */ |
| 1355 | 1355 | function boincuser_profile_node_form_after_build($form, &$form_state) { |
| 1356 | - // Move to community prefs form |
|
| 1357 | - $form_state['storage']['avatar'] = $form['field_image']; |
|
| 1358 | - unset($form['field_image']); |
|
| 1359 | - return $form; |
|
| 1356 | + // Move to community prefs form |
|
| 1357 | + $form_state['storage']['avatar'] = $form['field_image']; |
|
| 1358 | + unset($form['field_image']); |
|
| 1359 | + return $form; |
|
| 1360 | 1360 | } |
| 1361 | 1361 | |
| 1362 | 1362 | /** |
@@ -1364,8 +1364,8 @@ discard block |
||
| 1364 | 1364 | * @see http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hook_elements/6 |
| 1365 | 1365 | */ |
| 1366 | 1366 | function boincuser_elements() { |
| 1367 | - $type['password_confirm']['#process'][] = 'boincuser_process_password_confirm'; |
|
| 1368 | - return $type; |
|
| 1367 | + $type['password_confirm']['#process'][] = 'boincuser_process_password_confirm'; |
|
| 1368 | + return $type; |
|
| 1369 | 1369 | } |
| 1370 | 1370 | |
| 1371 | 1371 | /** |
@@ -1373,11 +1373,11 @@ discard block |
||
| 1373 | 1373 | * profile form |
| 1374 | 1374 | */ |
| 1375 | 1375 | function boincuser_process_password_confirm($element) { |
| 1376 | - // Check if parent element is "account". |
|
| 1377 | - if ($element['#array_parents'][0] == 'account') { |
|
| 1376 | + // Check if parent element is "account". |
|
| 1377 | + if ($element['#array_parents'][0] == 'account') { |
|
| 1378 | 1378 | $element['pass1']['#title'] = bts('Change password', array(), NULL, 'boinc:forgot-password'); |
| 1379 | - } |
|
| 1380 | - return $element; |
|
| 1379 | + } |
|
| 1380 | + return $element; |
|
| 1381 | 1381 | } |
| 1382 | 1382 | |
| 1383 | 1383 | /** |
@@ -1385,42 +1385,42 @@ discard block |
||
| 1385 | 1385 | * Register theme functions for use in this module. |
| 1386 | 1386 | */ |
| 1387 | 1387 | function boincuser_theme($existing, $type, $theme, $path) { |
| 1388 | - return array( |
|
| 1388 | + return array( |
|
| 1389 | 1389 | 'boincuser_user_pass' => array( |
| 1390 | - 'arguments' => array() |
|
| 1390 | + 'arguments' => array() |
|
| 1391 | 1391 | ) |
| 1392 | - ); |
|
| 1392 | + ); |
|
| 1393 | 1393 | } |
| 1394 | 1394 | |
| 1395 | 1395 | /** |
| 1396 | 1396 | * Implementation of hook_token_values |
| 1397 | 1397 | */ |
| 1398 | 1398 | function boincuser_token_values($type, $object = NULL, $options = array()) { |
| 1399 | - if ($type == 'user') { |
|
| 1399 | + if ($type == 'user') { |
|
| 1400 | 1400 | $account = user_load($object->uid); |
| 1401 | 1401 | $tokens['display-name'] = $account->boincuser_name; |
| 1402 | 1402 | return $tokens; |
| 1403 | - } |
|
| 1403 | + } |
|
| 1404 | 1404 | } |
| 1405 | 1405 | |
| 1406 | 1406 | /** |
| 1407 | 1407 | * Implementation of hook_token_list |
| 1408 | 1408 | */ |
| 1409 | 1409 | function boincuser_token_list($type = 'all') { |
| 1410 | - if ($type == 'user' || $type == 'all') { |
|
| 1410 | + if ($type == 'user' || $type == 'all') { |
|
| 1411 | 1411 | $tokens['user']['display-name'] = t("The user's name that should be displayed"); |
| 1412 | 1412 | return $tokens; |
| 1413 | - } |
|
| 1413 | + } |
|
| 1414 | 1414 | } |
| 1415 | 1415 | |
| 1416 | 1416 | /** |
| 1417 | 1417 | * Implementation of hook_views_pre_execute() |
| 1418 | 1418 | */ |
| 1419 | 1419 | function boincuser_views_pre_execute(&$view) { |
| 1420 | - if ($view->args) { |
|
| 1420 | + if ($view->args) { |
|
| 1421 | 1421 | $account_id = $view->args[0]; |
| 1422 | - } |
|
| 1423 | - if ($view->name=="user_activity") { |
|
| 1422 | + } |
|
| 1423 | + if ($view->name=="user_activity") { |
|
| 1424 | 1424 | // Run the following custom query for the user_activity view |
| 1425 | 1425 | $view->build_info['query']= " |
| 1426 | 1426 | SELECT node_revisions.vid AS vid, |
@@ -1452,25 +1452,25 @@ discard block |
||
| 1452 | 1452 | |
| 1453 | 1453 | // count_query determines the pager. Do this so the right item count is returned. |
| 1454 | 1454 | $view->build_info['count_query'] = $view->build_info['query']; |
| 1455 | - } |
|
| 1455 | + } |
|
| 1456 | 1456 | } |
| 1457 | 1457 | |
| 1458 | 1458 | /** |
| 1459 | 1459 | * Implementation of hook_cron() |
| 1460 | 1460 | */ |
| 1461 | 1461 | function boincuser_cron() { |
| 1462 | - // Delete expired users in the BOINC database, user_delete table. |
|
| 1463 | - require_boinc('boinc_db'); |
|
| 1464 | - $num_deleted = BoincUserDeleted::delete_expired(); |
|
| 1465 | - if ($num_deleted>0) { |
|
| 1462 | + // Delete expired users in the BOINC database, user_delete table. |
|
| 1463 | + require_boinc('boinc_db'); |
|
| 1464 | + $num_deleted = BoincUserDeleted::delete_expired(); |
|
| 1465 | + if ($num_deleted>0) { |
|
| 1466 | 1466 | watchdog('boincuser', "Deleted ${num_deleted} users from user_deleted table", WATCHDOG_NOTICE); |
| 1467 | - } |
|
| 1467 | + } |
|
| 1468 | 1468 | |
| 1469 | - // Delete expired tokens from token table |
|
| 1470 | - $tokens_deleted = BoincToken::delete_expired(); |
|
| 1471 | - if ($tokens_deleted>0) { |
|
| 1469 | + // Delete expired tokens from token table |
|
| 1470 | + $tokens_deleted = BoincToken::delete_expired(); |
|
| 1471 | + if ($tokens_deleted>0) { |
|
| 1472 | 1472 | watchdog('boincuser', "Deleted ${tokens_deleted} tokens from token table", WATCHDOG_NOTICE); |
| 1473 | - } |
|
| 1473 | + } |
|
| 1474 | 1474 | } |
| 1475 | 1475 | |
| 1476 | 1476 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -1481,17 +1481,17 @@ discard block |
||
| 1481 | 1481 | * Page callback shortcut to recent posts for the logged in user |
| 1482 | 1482 | */ |
| 1483 | 1483 | function boincuser_goto_recent_posts() { |
| 1484 | - global $user; |
|
| 1485 | - drupal_goto("account/{$user->uid}/posts"); |
|
| 1484 | + global $user; |
|
| 1485 | + drupal_goto("account/{$user->uid}/posts"); |
|
| 1486 | 1486 | } |
| 1487 | 1487 | |
| 1488 | 1488 | /** |
| 1489 | 1489 | * Page callback shortcut to the team of the logged in user |
| 1490 | 1490 | */ |
| 1491 | 1491 | function boincuser_goto_team() { |
| 1492 | - global $user; |
|
| 1493 | - $account = user_load($user->uid); |
|
| 1494 | - drupal_goto("community/teams/{$account->team}"); |
|
| 1492 | + global $user; |
|
| 1493 | + $account = user_load($user->uid); |
|
| 1494 | + drupal_goto("community/teams/{$account->team}"); |
|
| 1495 | 1495 | } |
| 1496 | 1496 | |
| 1497 | 1497 | /** |
@@ -1500,93 +1500,93 @@ discard block |
||
| 1500 | 1500 | * user profile pages, so use a wrapper for display |
| 1501 | 1501 | */ |
| 1502 | 1502 | function boincuser_view_profile($account = null) { |
| 1503 | - // Create the user profile page |
|
| 1504 | - if (!$account) { |
|
| 1503 | + // Create the user profile page |
|
| 1504 | + if (!$account) { |
|
| 1505 | 1505 | global $user; |
| 1506 | 1506 | $account = $user; |
| 1507 | - } |
|
| 1507 | + } |
|
| 1508 | 1508 | |
| 1509 | - $min_credit_to_post = variable_get('boinc_comment_min_credit', 0); |
|
| 1510 | - $verified_contributor = array_search('verified contributor', user_roles(true)); |
|
| 1511 | - if (!isset($account->roles[$verified_contributor])) { |
|
| 1509 | + $min_credit_to_post = variable_get('boinc_comment_min_credit', 0); |
|
| 1510 | + $verified_contributor = array_search('verified contributor', user_roles(true)); |
|
| 1511 | + if (!isset($account->roles[$verified_contributor])) { |
|
| 1512 | 1512 | drupal_set_message(bts( |
| 1513 | 1513 | 'You may only create or modify your user profile after earning @count credits.', |
| 1514 | 1514 | array('@count' => $min_credit_to_post), NULL, 'boinc:view-profile' |
| 1515 | 1515 | ), 'warning', FALSE); |
| 1516 | - } |
|
| 1516 | + } |
|
| 1517 | 1517 | |
| 1518 | - // For now, just call the user module profile view function |
|
| 1519 | - user_build_content($account); |
|
| 1520 | - return theme('user_profile', $account); |
|
| 1518 | + // For now, just call the user module profile view function |
|
| 1519 | + user_build_content($account); |
|
| 1520 | + return theme('user_profile', $account); |
|
| 1521 | 1521 | } |
| 1522 | 1522 | |
| 1523 | 1523 | /** |
| 1524 | 1524 | * Page callback for editing a user profile |
| 1525 | 1525 | */ |
| 1526 | 1526 | function boincuser_edit_profile($account = null) { |
| 1527 | - // Create the user profile form |
|
| 1528 | - if (!$account) { |
|
| 1527 | + // Create the user profile form |
|
| 1528 | + if (!$account) { |
|
| 1529 | 1529 | global $user; |
| 1530 | 1530 | $account = $user; |
| 1531 | - } |
|
| 1532 | - // Render the form |
|
| 1533 | - module_load_include('pages.inc', 'node', 'node'); |
|
| 1534 | - return content_profile_page_edit('profile', $account); |
|
| 1531 | + } |
|
| 1532 | + // Render the form |
|
| 1533 | + module_load_include('pages.inc', 'node', 'node'); |
|
| 1534 | + return content_profile_page_edit('profile', $account); |
|
| 1535 | 1535 | } |
| 1536 | 1536 | |
| 1537 | 1537 | /** |
| 1538 | - * Join page menu callback. |
|
| 1539 | - * Display instructions on joining for new or existing BOINC users |
|
| 1540 | - */ |
|
| 1538 | + * Join page menu callback. |
|
| 1539 | + * Display instructions on joining for new or existing BOINC users |
|
| 1540 | + */ |
|
| 1541 | 1541 | function join_page($type = null) { |
| 1542 | - global $base_url; |
|
| 1543 | - /* The paths/links to the rules-and-policies page is hardcoded |
|
| 1542 | + global $base_url; |
|
| 1543 | + /* The paths/links to the rules-and-policies page is hardcoded |
|
| 1544 | 1544 | * here. An improvement would be admin settings for the Join Page |
| 1545 | 1545 | * where this path could be set. |
| 1546 | 1546 | */ |
| 1547 | - $ruleslinkA = 'rules-and-policies'; |
|
| 1548 | - $ruleslinkB = 'content/rules-and-policies'; |
|
| 1549 | - $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
| 1550 | - $registration_enabled = variable_get('user_register', 0); |
|
| 1551 | - $output = '<div class="join">'; |
|
| 1552 | - switch ($type) { |
|
| 1553 | - case 'boinc': |
|
| 1547 | + $ruleslinkA = 'rules-and-policies'; |
|
| 1548 | + $ruleslinkB = 'content/rules-and-policies'; |
|
| 1549 | + $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
| 1550 | + $registration_enabled = variable_get('user_register', 0); |
|
| 1551 | + $output = '<div class="join">'; |
|
| 1552 | + switch ($type) { |
|
| 1553 | + case 'boinc': |
|
| 1554 | 1554 | $output .= '<ol>'; |
| 1555 | 1555 | if ($registration_enabled) { |
| 1556 | - $output .= '<li>' . bts('First !create_an_account here at @sitename.', |
|
| 1557 | - array( |
|
| 1556 | + $output .= '<li>' . bts('First !create_an_account here at @sitename.', |
|
| 1557 | + array( |
|
| 1558 | 1558 | '!create_an_account' => l(bts('create an account', array(), NULL, 'boinc:join-page'), 'user/registration'), |
| 1559 | 1559 | '@sitename' => $site_name, |
| 1560 | - ), NULL, 'boinc:join-page') . '</li>'; |
|
| 1560 | + ), NULL, 'boinc:join-page') . '</li>'; |
|
| 1561 | 1561 | } |
| 1562 | 1562 | $output .= ' <li>' . bts("Install BOINC on this device if not already present.", array(), NULL, 'boinc:join-page') . '</li>'; |
| 1563 | 1563 | $output .= ' <li>' . bts("Select <i>Tools / Add Project</i>. Choose @sitename from the list, or enter @siteurl.", |
| 1564 | 1564 | array( |
| 1565 | - '@sitename' => $site_name, |
|
| 1566 | - '@siteurl' => $base_url, |
|
| 1565 | + '@sitename' => $site_name, |
|
| 1566 | + '@siteurl' => $base_url, |
|
| 1567 | 1567 | ), NULL, 'boinc:join-page') . '</li>'; |
| 1568 | 1568 | if ($registration_enabled) { |
| 1569 | - $output .= '<li>' . bts("If you're running a command-line or pre-5.0 version of BOINC, use <b>!boinccmd</b> to add the project.", |
|
| 1569 | + $output .= '<li>' . bts("If you're running a command-line or pre-5.0 version of BOINC, use <b>!boinccmd</b> to add the project.", |
|
| 1570 | 1570 | array( |
| 1571 | - '!boinccmd' => l('boinccmd --project_attach', 'http://boinc.berkeley.edu/wiki/Boinccmd_tool'), |
|
| 1571 | + '!boinccmd' => l('boinccmd --project_attach', 'http://boinc.berkeley.edu/wiki/Boinccmd_tool'), |
|
| 1572 | 1572 | ), NULL, 'boinc:join-page') . '</li>'; |
| 1573 | 1573 | } |
| 1574 | 1574 | else { |
| 1575 | - $output .= '<li>' . bts("If you're running a command-line version of BOINC, |
|
| 1575 | + $output .= '<li>' . bts("If you're running a command-line version of BOINC, |
|
| 1576 | 1576 | please follow the <b>!instructionslink</b> to first <i>create an account</i>, and then <i>attach</i> to this project. Use the same project URL as above.", |
| 1577 | 1577 | array( |
| 1578 | - '!instructionslink' => l('instructions', 'http://boinc.berkeley.edu/wiki/Boinccmd_tool'), |
|
| 1578 | + '!instructionslink' => l('instructions', 'http://boinc.berkeley.edu/wiki/Boinccmd_tool'), |
|
| 1579 | 1579 | ), NULL, 'boinc:join-page') . '</li>'; |
| 1580 | 1580 | } |
| 1581 | 1581 | $output .= '<li>' . bts("If you're running a pre-5.0 version of BOINC, please |
| 1582 | 1582 | upgrade to a more recent version of BOINC to create an account |
| 1583 | 1583 | at @this_project.", |
| 1584 | - array( |
|
| 1584 | + array( |
|
| 1585 | 1585 | '@this_project' => $site_name, |
| 1586 | - ), NULL, 'boinc:join-page') . '</li>'; |
|
| 1586 | + ), NULL, 'boinc:join-page') . '</li>'; |
|
| 1587 | 1587 | $output .= '</ol>'; |
| 1588 | 1588 | break; |
| 1589 | - case 'new': |
|
| 1589 | + case 'new': |
|
| 1590 | 1590 | default: |
| 1591 | 1591 | // Determine if there is a link to rules-and-policies |
| 1592 | 1592 | //$ruleslink=''; |
@@ -1601,16 +1601,16 @@ discard block |
||
| 1601 | 1601 | // Join page output |
| 1602 | 1602 | $output .= '<ol>'; |
| 1603 | 1603 | if ($registration_enabled) { |
| 1604 | - $output .= '<li>' . bts('First !create_an_account here at @sitename.', |
|
| 1605 | - array( |
|
| 1604 | + $output .= '<li>' . bts('First !create_an_account here at @sitename.', |
|
| 1605 | + array( |
|
| 1606 | 1606 | '!create_an_account' => l(bts('create an account', array(), NULL, 'boinc:join-page'), 'user/registration'), |
| 1607 | 1607 | '@sitename' => $site_name, |
| 1608 | - ), NULL, 'boinc:join-page') . '</li>'; |
|
| 1608 | + ), NULL, 'boinc:join-page') . '</li>'; |
|
| 1609 | 1609 | } |
| 1610 | 1610 | else if ( menu_valid_path(array('link_path' => $ruleslink)) ) { |
| 1611 | - $output .= ' <li>' . bts("Read our !rules_and_policies.", array( |
|
| 1611 | + $output .= ' <li>' . bts("Read our !rules_and_policies.", array( |
|
| 1612 | 1612 | '!rules_and_policies' => l(bts('Rules and Policies', array(), NULL, 'boinc:join-page'), $ruleslink), |
| 1613 | - ), NULL, 'boinc:join-page') . '</li>'; |
|
| 1613 | + ), NULL, 'boinc:join-page') . '</li>'; |
|
| 1614 | 1614 | } |
| 1615 | 1615 | $output .= ' <li>' . bts('Download the BOINC desktop software.', array(), NULL, 'boinc:join-page'); |
| 1616 | 1616 | $output .= ' <p>'; |
@@ -1620,73 +1620,73 @@ discard block |
||
| 1620 | 1620 | $output .= ' </li>'; |
| 1621 | 1621 | $output .= ' <li>' . bts('Run the installer.', array(), NULL, 'boinc:join-page') . '</li>'; |
| 1622 | 1622 | $output .= ' <li>' . bts('Choose @sitename from the list, or enter @siteurl.', array( |
| 1623 | - '@sitename' => $site_name, |
|
| 1624 | - '@siteurl' => $base_url, |
|
| 1623 | + '@sitename' => $site_name, |
|
| 1624 | + '@siteurl' => $base_url, |
|
| 1625 | 1625 | ), NULL, 'boinc:join-page') . '</li>'; |
| 1626 | 1626 | $output .= '</ol>'; |
| 1627 | - } |
|
| 1628 | - $output .= '</div>'; |
|
| 1629 | - return $output; |
|
| 1627 | + } |
|
| 1628 | + $output .= '</div>'; |
|
| 1629 | + return $output; |
|
| 1630 | 1630 | } |
| 1631 | 1631 | |
| 1632 | 1632 | /** |
| 1633 | - * Home page content for embedding in Panels page |
|
| 1634 | - */ |
|
| 1633 | + * Home page content for embedding in Panels page |
|
| 1634 | + */ |
|
| 1635 | 1635 | function boincuser_home_page() { |
| 1636 | - global $user; |
|
| 1637 | - $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
| 1638 | - // get the front page message from database; this is set in the admin interface under BOINC Other |
|
| 1639 | - $site_message = variable_get('boinc_other_frontpage',''); |
|
| 1636 | + global $user; |
|
| 1637 | + $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
| 1638 | + // get the front page message from database; this is set in the admin interface under BOINC Other |
|
| 1639 | + $site_message = variable_get('boinc_other_frontpage',''); |
|
| 1640 | 1640 | |
| 1641 | - // Determine the user of the day |
|
| 1642 | - $current_uotd = db_fetch_object(db_query(" |
|
| 1641 | + // Determine the user of the day |
|
| 1642 | + $current_uotd = db_fetch_object(db_query(" |
|
| 1643 | 1643 | SELECT |
| 1644 | 1644 | uid, |
| 1645 | 1645 | uotd_time |
| 1646 | 1646 | FROM {boincuser} |
| 1647 | 1647 | ORDER BY uotd_time DESC |
| 1648 | 1648 | LIMIT 1" |
| 1649 | - )); |
|
| 1650 | - if ($current_uotd->uotd_time < strtotime('today midnight')) { |
|
| 1649 | + )); |
|
| 1650 | + if ($current_uotd->uotd_time < strtotime('today midnight')) { |
|
| 1651 | 1651 | $uotd = boincuser_select_user_of_the_day(); |
| 1652 | - } |
|
| 1653 | - else { |
|
| 1652 | + } |
|
| 1653 | + else { |
|
| 1654 | 1654 | $uotd = user_load($current_uotd->uid); |
| 1655 | - } |
|
| 1656 | - $uotd_image = boincuser_get_user_profile_image($uotd->uid, FALSE); |
|
| 1657 | - $output = '<h2 class="pane-title">'; |
|
| 1658 | - $output .= ($user->uid) ? bts('Welcome back!', array(), NULL, 'boinc:front-page') : ($site_name ? bts('What is @this_project?', array('@this_project' => $site_name)) : bts('Welcome!', array(), NULL, 'boinc:front-page')); |
|
| 1659 | - $output .= '</h2>'; |
|
| 1660 | - $output .= '<div class="boinc-overview balance-height-front">'; |
|
| 1661 | - $output .= ' <div>' . bts($site_message, array(), NULL, "project:front page") . ' ' . l(bts('Learn more', array(), NULL, 'boinc:front-page'), 'about') . '</div>'; |
|
| 1662 | - if ($user->uid) { |
|
| 1655 | + } |
|
| 1656 | + $uotd_image = boincuser_get_user_profile_image($uotd->uid, FALSE); |
|
| 1657 | + $output = '<h2 class="pane-title">'; |
|
| 1658 | + $output .= ($user->uid) ? bts('Welcome back!', array(), NULL, 'boinc:front-page') : ($site_name ? bts('What is @this_project?', array('@this_project' => $site_name)) : bts('Welcome!', array(), NULL, 'boinc:front-page')); |
|
| 1659 | + $output .= '</h2>'; |
|
| 1660 | + $output .= '<div class="boinc-overview balance-height-front">'; |
|
| 1661 | + $output .= ' <div>' . bts($site_message, array(), NULL, "project:front page") . ' ' . l(bts('Learn more', array(), NULL, 'boinc:front-page'), 'about') . '</div>'; |
|
| 1662 | + if ($user->uid) { |
|
| 1663 | 1663 | $output .= ' <div>' . l(bts('View account', array(), NULL, 'boinc:front-page'), 'dashboard', array('attributes' => array('class' => 'join button'))) . '</div>'; |
| 1664 | - } |
|
| 1665 | - else { |
|
| 1664 | + } |
|
| 1665 | + else { |
|
| 1666 | 1666 | $output .= ' <div>' . l(bts('Join now', array(), NULL, 'boinc:front-page'), 'join', array('attributes' => array('class' => 'join button'))) . '</div>'; |
| 1667 | - } |
|
| 1668 | - $output .= '</div>'; |
|
| 1669 | - $output .= '<div class="boinc-overview-details">'; |
|
| 1670 | - $output .= ' <div class="detail-container">'; |
|
| 1671 | - $output .= ' <a class="user-of-the-day" href="account/' . $uotd->uid . '">'; |
|
| 1672 | - $output .= ' <div class="picture">'; |
|
| 1673 | - $output .= theme('imagefield_image', $uotd_image['image'], $uotd_image['alt'], |
|
| 1667 | + } |
|
| 1668 | + $output .= '</div>'; |
|
| 1669 | + $output .= '<div class="boinc-overview-details">'; |
|
| 1670 | + $output .= ' <div class="detail-container">'; |
|
| 1671 | + $output .= ' <a class="user-of-the-day" href="account/' . $uotd->uid . '">'; |
|
| 1672 | + $output .= ' <div class="picture">'; |
|
| 1673 | + $output .= theme('imagefield_image', $uotd_image['image'], $uotd_image['alt'], |
|
| 1674 | 1674 | $uotd_image['alt'], array(), FALSE); |
| 1675 | - $output .= ' </div>'; |
|
| 1676 | - $output .= ' <div class="text">' . bts('User of the day', array(), NULL, 'boinc:front-page') . '</div>'; |
|
| 1677 | - $output .= ' <div class="detail">' . $uotd->boincuser_name . '</div>'; |
|
| 1678 | - $output .= ' </a>'; |
|
| 1679 | - $output .= ' <div class="volunteers">'; |
|
| 1680 | - $output .= ' <div class="text">' . bts('Over 500,000 volunteers and counting.', array(), NULL, 'boinc:front-page') . '</div>'; |
|
| 1681 | - $output .= ' <div class="platforms">'; |
|
| 1682 | - $output .= ' <div class="detail platform windows">' . bts('Windows', array(), NULL, 'boinc:front-page') . '</div>'; |
|
| 1683 | - $output .= ' <div class="detail platform mac">' . bts('Mac', array(), NULL, 'boinc:front-page') . '</div>'; |
|
| 1684 | - $output .= ' <div class="detail platform linux">' . bts('Linux', array(), NULL, 'boinc:front-page') . '</div>'; |
|
| 1685 | - $output .= ' </div>'; |
|
| 1686 | - $output .= ' </div>'; |
|
| 1687 | - $output .= ' </div>'; |
|
| 1688 | - $output .= '</div>'; |
|
| 1689 | - return $output; |
|
| 1675 | + $output .= ' </div>'; |
|
| 1676 | + $output .= ' <div class="text">' . bts('User of the day', array(), NULL, 'boinc:front-page') . '</div>'; |
|
| 1677 | + $output .= ' <div class="detail">' . $uotd->boincuser_name . '</div>'; |
|
| 1678 | + $output .= ' </a>'; |
|
| 1679 | + $output .= ' <div class="volunteers">'; |
|
| 1680 | + $output .= ' <div class="text">' . bts('Over 500,000 volunteers and counting.', array(), NULL, 'boinc:front-page') . '</div>'; |
|
| 1681 | + $output .= ' <div class="platforms">'; |
|
| 1682 | + $output .= ' <div class="detail platform windows">' . bts('Windows', array(), NULL, 'boinc:front-page') . '</div>'; |
|
| 1683 | + $output .= ' <div class="detail platform mac">' . bts('Mac', array(), NULL, 'boinc:front-page') . '</div>'; |
|
| 1684 | + $output .= ' <div class="detail platform linux">' . bts('Linux', array(), NULL, 'boinc:front-page') . '</div>'; |
|
| 1685 | + $output .= ' </div>'; |
|
| 1686 | + $output .= ' </div>'; |
|
| 1687 | + $output .= ' </div>'; |
|
| 1688 | + $output .= '</div>'; |
|
| 1689 | + return $output; |
|
| 1690 | 1690 | } |
| 1691 | 1691 | |
| 1692 | 1692 | /** |
@@ -1694,81 +1694,81 @@ discard block |
||
| 1694 | 1694 | * Create a new user account based on supplied parameters. |
| 1695 | 1695 | */ |
| 1696 | 1696 | function boincuser_create_account() { |
| 1697 | - global $base_url; |
|
| 1697 | + global $base_url; |
|
| 1698 | 1698 | |
| 1699 | - require_boinc('boinc_db'); |
|
| 1700 | - require_boinc('user_util'); |
|
| 1701 | - require_boinc('xml'); |
|
| 1702 | - $params = array( |
|
| 1699 | + require_boinc('boinc_db'); |
|
| 1700 | + require_boinc('user_util'); |
|
| 1701 | + require_boinc('xml'); |
|
| 1702 | + $params = array( |
|
| 1703 | 1703 | 'email_addr' => isset($_GET['email_addr']) ? $_GET['email_addr'] : '', |
| 1704 | 1704 | 'user_name' => isset($_GET['user_name']) ? $_GET['user_name'] : '', |
| 1705 | 1705 | 'passwd_hash' => isset($_GET['passwd_hash']) ? $_GET['passwd_hash'] : '' |
| 1706 | - ); |
|
| 1706 | + ); |
|
| 1707 | 1707 | |
| 1708 | - // Begin output |
|
| 1709 | - xml_header(); |
|
| 1708 | + // Begin output |
|
| 1709 | + xml_header(); |
|
| 1710 | 1710 | |
| 1711 | - // Account creation disabled |
|
| 1712 | - $enablethisRPC = variable_get('boinc_weboptions_enableaccountcreateRPC', TRUE); |
|
| 1713 | - if (!$enablethisRPC) { |
|
| 1711 | + // Account creation disabled |
|
| 1712 | + $enablethisRPC = variable_get('boinc_weboptions_enableaccountcreateRPC', TRUE); |
|
| 1713 | + if (!$enablethisRPC) { |
|
| 1714 | 1714 | $mess = bts('Account creation is done through our Web site. Please register at @url', array( |
| 1715 | - '@url' => $base_url . '/user/registration', |
|
| 1715 | + '@url' => $base_url . '/user/registration', |
|
| 1716 | 1716 | ), |
| 1717 | 1717 | NULL, 'boinc:create_account'); |
| 1718 | 1718 | xml_error(-208, $mess); |
| 1719 | - } |
|
| 1720 | - // Invalid invite code |
|
| 1719 | + } |
|
| 1720 | + // Invalid invite code |
|
| 1721 | 1721 | |
| 1722 | - // Validate input |
|
| 1723 | - if (user_validate_mail($params['email_addr']) or !is_valid_email_addr($params['email_addr'])) { |
|
| 1722 | + // Validate input |
|
| 1723 | + if (user_validate_mail($params['email_addr']) or !is_valid_email_addr($params['email_addr'])) { |
|
| 1724 | 1724 | xml_error(-205); |
| 1725 | - } |
|
| 1725 | + } |
|
| 1726 | 1726 | |
| 1727 | - // Make sure user_name is unique and cleaned |
|
| 1728 | - $unique_name = create_proper_drupalname($params['user_name']); |
|
| 1729 | - if ($error = user_validate_name($unique_name)) { |
|
| 1727 | + // Make sure user_name is unique and cleaned |
|
| 1728 | + $unique_name = create_proper_drupalname($params['user_name']); |
|
| 1729 | + if ($error = user_validate_name($unique_name)) { |
|
| 1730 | 1730 | xml_error(-188, $error); |
| 1731 | - } |
|
| 1732 | - if (strlen($params['passwd_hash']) != 32) { |
|
| 1731 | + } |
|
| 1732 | + if (strlen($params['passwd_hash']) != 32) { |
|
| 1733 | 1733 | xml_error(-1, 'password hash length not 32'); |
| 1734 | - } |
|
| 1734 | + } |
|
| 1735 | 1735 | |
| 1736 | - // Process input |
|
| 1737 | - // Check this email against previous email addresses. |
|
| 1738 | - $tmpuser = BoincUser::lookup_prev_email_addr($params['email_addr']); |
|
| 1739 | - if ($tmpuser) { |
|
| 1736 | + // Process input |
|
| 1737 | + // Check this email against previous email addresses. |
|
| 1738 | + $tmpuser = BoincUser::lookup_prev_email_addr($params['email_addr']); |
|
| 1739 | + if ($tmpuser) { |
|
| 1740 | 1740 | xml_error(-137); |
| 1741 | - } |
|
| 1741 | + } |
|
| 1742 | 1742 | |
| 1743 | - // Check this email on current email addresses. |
|
| 1744 | - $boinc_user = BoincUser::lookup_email_addr($params['email_addr']); |
|
| 1745 | - if ($boinc_user) { |
|
| 1743 | + // Check this email on current email addresses. |
|
| 1744 | + $boinc_user = BoincUser::lookup_email_addr($params['email_addr']); |
|
| 1745 | + if ($boinc_user) { |
|
| 1746 | 1746 | // Return authenticator for existing users |
| 1747 | 1747 | if ( ($params['passwd_hash'] == $boinc_user->passwd_hash) or |
| 1748 | 1748 | password_verify($params['passwd_hash'], $boinc_user->passwd_hash) ) { |
| 1749 | - $output = array('authenticator' => $boinc_user->authenticator); |
|
| 1749 | + $output = array('authenticator' => $boinc_user->authenticator); |
|
| 1750 | 1750 | } |
| 1751 | 1751 | else { |
| 1752 | - xml_error(-137); |
|
| 1752 | + xml_error(-137); |
|
| 1753 | 1753 | } |
| 1754 | - } |
|
| 1755 | - else { |
|
| 1754 | + } |
|
| 1755 | + else { |
|
| 1756 | 1756 | // Verify that there isn't somehow a Drupal user already (not possible with proper function) |
| 1757 | 1757 | if ($existing_user = user_load(array('mail' => $params['email_addr']))) { |
| 1758 | - xml_error(-137, 'account error'); |
|
| 1758 | + xml_error(-137, 'account error'); |
|
| 1759 | 1759 | } |
| 1760 | 1760 | // Create new account |
| 1761 | 1761 | $unrestricted_role = array_search('community member', user_roles(true)); |
| 1762 | 1762 | |
| 1763 | 1763 | $newUser = array( |
| 1764 | - 'name' => $unique_name, |
|
| 1765 | - 'pass' => $params['passwd_hash'], // note: passing a hash here requires ALL passwords to be hashed via hook prior to interacting with the hash stored in the db |
|
| 1766 | - 'mail' => $params['email_addr'], |
|
| 1767 | - 'status' => 1, |
|
| 1768 | - 'init' => $params['email_addr'], |
|
| 1769 | - 'roles' => array($unrestricted_role => ''), |
|
| 1770 | - 'boincuser_name' => $params['user_name'], |
|
| 1771 | - 'boinchash_flag' => TRUE, |
|
| 1764 | + 'name' => $unique_name, |
|
| 1765 | + 'pass' => $params['passwd_hash'], // note: passing a hash here requires ALL passwords to be hashed via hook prior to interacting with the hash stored in the db |
|
| 1766 | + 'mail' => $params['email_addr'], |
|
| 1767 | + 'status' => 1, |
|
| 1768 | + 'init' => $params['email_addr'], |
|
| 1769 | + 'roles' => array($unrestricted_role => ''), |
|
| 1770 | + 'boincuser_name' => $params['user_name'], |
|
| 1771 | + 'boinchash_flag' => TRUE, |
|
| 1772 | 1772 | ); |
| 1773 | 1773 | |
| 1774 | 1774 | // Create the drupal user. If the drupal user cannot be created, |
@@ -1776,17 +1776,17 @@ discard block |
||
| 1776 | 1776 | // The user is created in the 'insert' op in hook_user. |
| 1777 | 1777 | $user = user_save(null, $newUser); |
| 1778 | 1778 | if (!$user) { |
| 1779 | - watchdog('boincuser', 'create_account: Failed to create Drupal user account for @email', array('@email' => $params['email_addr']), WATCHDOG_WARNING); |
|
| 1780 | - xml_error(-137, 'error creating BOINC account'); |
|
| 1779 | + watchdog('boincuser', 'create_account: Failed to create Drupal user account for @email', array('@email' => $params['email_addr']), WATCHDOG_WARNING); |
|
| 1780 | + xml_error(-137, 'error creating BOINC account'); |
|
| 1781 | 1781 | }// if drupal user created. |
| 1782 | 1782 | |
| 1783 | 1783 | $output = array('authenticator' => $user->boincuser_account_key); |
| 1784 | - }// if existing user found. |
|
| 1784 | + }// if existing user found. |
|
| 1785 | 1785 | |
| 1786 | - // Output authenticator |
|
| 1787 | - echo " <account_out>\n"; |
|
| 1788 | - echo " <authenticator>{$output['authenticator']}</authenticator>\n"; |
|
| 1789 | - echo "</account_out>\n"; |
|
| 1786 | + // Output authenticator |
|
| 1787 | + echo " <account_out>\n"; |
|
| 1788 | + echo " <authenticator>{$output['authenticator']}</authenticator>\n"; |
|
| 1789 | + echo "</account_out>\n"; |
|
| 1790 | 1790 | } |
| 1791 | 1791 | |
| 1792 | 1792 | /** |
@@ -1794,166 +1794,166 @@ discard block |
||
| 1794 | 1794 | * account is created using the BOINC clinet. |
| 1795 | 1795 | */ |
| 1796 | 1796 | function boincuser_account_finish() { |
| 1797 | - global $user; |
|
| 1797 | + global $user; |
|
| 1798 | 1798 | |
| 1799 | - $authtoken = isset($_GET['auth']) ? $_GET['auth'] : ''; |
|
| 1799 | + $authtoken = isset($_GET['auth']) ? $_GET['auth'] : ''; |
|
| 1800 | 1800 | |
| 1801 | - // Ensure there is a authentication token before continuing |
|
| 1802 | - if (empty($authtoken)) { |
|
| 1801 | + // Ensure there is a authentication token before continuing |
|
| 1802 | + if (empty($authtoken)) { |
|
| 1803 | 1803 | drupal_not_found(); |
| 1804 | 1804 | return ; |
| 1805 | - } |
|
| 1805 | + } |
|
| 1806 | 1806 | |
| 1807 | - if (strlen($authtoken) != 32) { |
|
| 1807 | + if (strlen($authtoken) != 32) { |
|
| 1808 | 1808 | drupal_set_message(bts('ERROR: There is no account with that authenticator.', array(), NULL, 'boinc:account-finish'), 'error'); |
| 1809 | 1809 | drupal_goto(); |
| 1810 | - } |
|
| 1810 | + } |
|
| 1811 | 1811 | |
| 1812 | - require_boinc('boinc_db'); |
|
| 1813 | - $boinc_user = BoincUser::lookup("authenticator='".addslashes($authtoken)."'"); |
|
| 1814 | - if (!$boinc_user) { |
|
| 1812 | + require_boinc('boinc_db'); |
|
| 1813 | + $boinc_user = BoincUser::lookup("authenticator='".addslashes($authtoken)."'"); |
|
| 1814 | + if (!$boinc_user) { |
|
| 1815 | 1815 | drupal_set_message(bts('ERROR: There is no account with that authenticator.', array(), NULL, 'boinc:account-finish'), 'error'); |
| 1816 | 1816 | drupal_goto(); |
| 1817 | - } |
|
| 1818 | - $user = user_load(get_drupal_id($boinc_user->id)); |
|
| 1817 | + } |
|
| 1818 | + $user = user_load(get_drupal_id($boinc_user->id)); |
|
| 1819 | 1819 | |
| 1820 | - if (!$user) { |
|
| 1820 | + if (!$user) { |
|
| 1821 | 1821 | drupal_set_message(bts('ERROR: There was a problem loading your account. Try logging in with your user name and password.', array(), NULL, 'boinc:account-finish'), 'error'); |
| 1822 | 1822 | drupal_goto(); |
| 1823 | - } |
|
| 1823 | + } |
|
| 1824 | 1824 | |
| 1825 | - // Lookup path to custom account finish page |
|
| 1826 | - $customaccountfinishpath = drupal_lookup_path('source', variable_get('boinc_weboptions_accountfinish', '') ); |
|
| 1827 | - if ( menu_valid_path(array('link_path' => $customaccountfinishpath)) ) { |
|
| 1825 | + // Lookup path to custom account finish page |
|
| 1826 | + $customaccountfinishpath = drupal_lookup_path('source', variable_get('boinc_weboptions_accountfinish', '') ); |
|
| 1827 | + if ( menu_valid_path(array('link_path' => $customaccountfinishpath)) ) { |
|
| 1828 | 1828 | $node = menu_get_object('node', 1, $customaccountfinishpath); |
| 1829 | 1829 | if ($node) { |
| 1830 | - return node_page_view($node); |
|
| 1830 | + return node_page_view($node); |
|
| 1831 | + } |
|
| 1831 | 1832 | } |
| 1832 | - } |
|
| 1833 | 1833 | |
| 1834 | - // open links in new window |
|
| 1835 | - $options = array( |
|
| 1834 | + // open links in new window |
|
| 1835 | + $options = array( |
|
| 1836 | 1836 | 'attributes' => array( 'target' => '_blank' ), |
| 1837 | - ); |
|
| 1837 | + ); |
|
| 1838 | 1838 | |
| 1839 | - // Check moderation page exists |
|
| 1840 | - $moderationpath = drupal_lookup_path('source', variable_get('boinc_weboptions_moderationpage', '') ); |
|
| 1841 | - if ( menu_valid_path(array('link_path' => $moderationpath)) ) { |
|
| 1839 | + // Check moderation page exists |
|
| 1840 | + $moderationpath = drupal_lookup_path('source', variable_get('boinc_weboptions_moderationpage', '') ); |
|
| 1841 | + if ( menu_valid_path(array('link_path' => $moderationpath)) ) { |
|
| 1842 | 1842 | $modsentence = bts('Please note: user profiles are subject to !moderation.', array('!moderation' => l(bts('moderation', array(), NULL, 'boinc:account-finish'), $moderationpath, $options)), NULL, 'boinc:account-finish'); |
| 1843 | - } else { |
|
| 1843 | + } else { |
|
| 1844 | 1844 | $modsentence = bts('Please note: user profiles are subject to moderation.', array(), NULL, 'boinc:account-finish'); |
| 1845 | - } |
|
| 1845 | + } |
|
| 1846 | 1846 | |
| 1847 | - $username = $user->boincuser_name; |
|
| 1848 | - $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
| 1849 | - $output = "<p>" . bts('Thank you @user_name for joining @site_name. Your account has been created. Your BOINC client should start working on assigned tasks soon, without any additional action or configuration. Please visit the links below for more information and additional options. (Links will open in a new window.)', |
|
| 1850 | - array( |
|
| 1847 | + $username = $user->boincuser_name; |
|
| 1848 | + $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
| 1849 | + $output = "<p>" . bts('Thank you @user_name for joining @site_name. Your account has been created. Your BOINC client should start working on assigned tasks soon, without any additional action or configuration. Please visit the links below for more information and additional options. (Links will open in a new window.)', |
|
| 1850 | + array( |
|
| 1851 | 1851 | '@user_name' => $username, |
| 1852 | 1852 | '@site_name' => $site_name, |
| 1853 | - ), NULL, 'boinc:account-finish') . "</p>"; |
|
| 1853 | + ), NULL, 'boinc:account-finish') . "</p>"; |
|
| 1854 | 1854 | |
| 1855 | - $links = array( |
|
| 1855 | + $links = array( |
|
| 1856 | 1856 | array( |
| 1857 | - 'data' => bts('Change your username at !community_preferences.', array( |
|
| 1857 | + 'data' => bts('Change your username at !community_preferences.', array( |
|
| 1858 | 1858 | '!community_preferences' => l(bts('Community Preferences', array(), NULL, 'boinc:account-fininsh'), 'account/prefs/community', $options), |
| 1859 | - ), NULL, 'boinc:account-finish'), |
|
| 1860 | - 'children' => array( |
|
| 1859 | + ), NULL, 'boinc:account-finish'), |
|
| 1860 | + 'children' => array( |
|
| 1861 | 1861 | bts('Your username is used to identify yourself to other volunteers on this Web site.', array(), NULL, 'boinc:account-finish'), |
| 1862 | 1862 | bts('In addition, you may set your account\'s default language and adjust notification settings.', array(), NULL, 'boinc:account-finish'), |
| 1863 | - ), |
|
| 1863 | + ), |
|
| 1864 | 1864 | ), |
| 1865 | 1865 | array( |
| 1866 | - 'data' => bts('Change your !computing_preferences.', array( |
|
| 1866 | + 'data' => bts('Change your !computing_preferences.', array( |
|
| 1867 | 1867 | '!computing_preferences' => l(bts('Computing Preferences', array(), NULL, 'boinc:account-finish'), 'account/prefs', $options), |
| 1868 | - ), NULL, 'boinc:account-finish'), |
|
| 1869 | - 'children' => array( |
|
| 1868 | + ), NULL, 'boinc:account-finish'), |
|
| 1869 | + 'children' => array( |
|
| 1870 | 1870 | bts('You may adjust how much CPU, RAM, and Disk space the BOINC client is allowed to use for tasks on your computer.', array(), NULL, 'boinc:account-finish'), |
| 1871 | 1871 | bts('By default, you will run @site_name tasks without any additional configuration.', array( |
| 1872 | - '@site_name' => $site_name, |
|
| 1872 | + '@site_name' => $site_name, |
|
| 1873 | 1873 | ), NULL, 'boinc:account-finish'), |
| 1874 | 1874 | bts('It is recommended new volunteers leave the default settings until they gain experience running some tasks. Ask questions in the !forums to get advice before making changes to a setting you don\'t understand.', array( |
| 1875 | - '!forums' => l(bts('forums', array(), NULL, 'boinc:account-finish'), 'community/forum', $options), |
|
| 1875 | + '!forums' => l(bts('forums', array(), NULL, 'boinc:account-finish'), 'community/forum', $options), |
|
| 1876 | 1876 | ), NULL, 'boinc:account-finish'), |
| 1877 | - ), |
|
| 1877 | + ), |
|
| 1878 | 1878 | ), |
| 1879 | 1879 | array( |
| 1880 | 1880 | 'data' => bts('Create a !user_profile.', array( |
| 1881 | - '!user_profile' => l(bts('User Profile', array(), NULL, 'boinc:account-finish'), '/account/profile/edit', $options), |
|
| 1881 | + '!user_profile' => l(bts('User Profile', array(), NULL, 'boinc:account-finish'), '/account/profile/edit', $options), |
|
| 1882 | 1882 | ), NULL, 'boinc:account-finish'), |
| 1883 | - 'children' => array( |
|
| 1883 | + 'children' => array( |
|
| 1884 | 1884 | bts('A user profile will inform other volunteers who you are and why you joined @site_name.', array( |
| 1885 | - '@site_name' => $site_name, |
|
| 1885 | + '@site_name' => $site_name, |
|
| 1886 | 1886 | ), NULL, 'boinc:account-finish'), |
| 1887 | 1887 | $modsentence, |
| 1888 | - ), |
|
| 1888 | + ), |
|
| 1889 | 1889 | ), |
| 1890 | 1890 | array( |
| 1891 | - 'data' => bts('Join a !team.', array( |
|
| 1891 | + 'data' => bts('Join a !team.', array( |
|
| 1892 | 1892 | '!team' => l(bts('Team', array(), NULL, 'boinc:account-finish'), '/community/teams', $options), |
| 1893 | - ), NULL, 'boinc:account-finish'), |
|
| 1894 | - 'children' => array( |
|
| 1893 | + ), NULL, 'boinc:account-finish'), |
|
| 1894 | + 'children' => array( |
|
| 1895 | 1895 | bts('You may join a team, made up of other volunteers.', array(), NULL, 'boinc:account-finish'), |
| 1896 | - ), |
|
| 1896 | + ), |
|
| 1897 | 1897 | ), |
| 1898 | 1898 | array( |
| 1899 | - 'data' => bts('Go to your !account_dashboard.', array( |
|
| 1899 | + 'data' => bts('Go to your !account_dashboard.', array( |
|
| 1900 | 1900 | '!account_dashboard'=> l(bts('Account Dashboard', array(), NULL, 'boinc:account-finish'), 'account/dashboard', $options), |
| 1901 | - ), NULL, 'boinc:account-finish'), |
|
| 1902 | - 'children' => array( |
|
| 1901 | + ), NULL, 'boinc:account-finish'), |
|
| 1902 | + 'children' => array( |
|
| 1903 | 1903 | bts('Your account dashboard has information and links about your computer(s) and task(s) assigned.', array(), NULL, 'boinc:account-finish'), |
| 1904 | - ), |
|
| 1904 | + ), |
|
| 1905 | 1905 | ), |
| 1906 | 1906 | array( |
| 1907 | - 'data' => bts('Visit our !help pages.', array( |
|
| 1907 | + 'data' => bts('Visit our !help pages.', array( |
|
| 1908 | 1908 | '!help' => l(bts('Help', array(), NULL, 'boinc:account-finish'), '/help', $options) |
| 1909 | - ), NULL, 'boinc:account-finish'), |
|
| 1910 | - 'children' => array( |
|
| 1909 | + ), NULL, 'boinc:account-finish'), |
|
| 1910 | + 'children' => array( |
|
| 1911 | 1911 | bts('Ask for help in our community\'s !forums.', array( |
| 1912 | - '!forums' => l(bts('forums', array(), NULL, 'boinc:account-finish'), 'community/forum', $options) |
|
| 1912 | + '!forums' => l(bts('forums', array(), NULL, 'boinc:account-finish'), 'community/forum', $options) |
|
| 1913 | 1913 | ), NULL, 'boinc:account-finish'), |
| 1914 | - ), |
|
| 1914 | + ), |
|
| 1915 | 1915 | ), |
| 1916 | - ); |
|
| 1916 | + ); |
|
| 1917 | 1917 | |
| 1918 | - //List of links |
|
| 1919 | - $output .= theme_item_list($links, $title = NULL, $type='ul'); |
|
| 1918 | + //List of links |
|
| 1919 | + $output .= theme_item_list($links, $title = NULL, $type='ul'); |
|
| 1920 | 1920 | |
| 1921 | - return $output; |
|
| 1921 | + return $output; |
|
| 1922 | 1922 | } |
| 1923 | 1923 | |
| 1924 | 1924 | /** |
| 1925 | 1925 | * Determine if the user has permission to control community access |
| 1926 | 1926 | */ |
| 1927 | 1927 | function boincuser_moderate_community_access() { |
| 1928 | - if (user_access('assign community member role') |
|
| 1928 | + if (user_access('assign community member role') |
|
| 1929 | 1929 | OR user_access('assign all roles')) { |
| 1930 | 1930 | return TRUE; |
| 1931 | - } |
|
| 1932 | - return FALSE; |
|
| 1931 | + } |
|
| 1932 | + return FALSE; |
|
| 1933 | 1933 | } |
| 1934 | 1934 | |
| 1935 | 1935 | /** |
| 1936 | 1936 | * Get the count of items in the moderation queue |
| 1937 | 1937 | */ |
| 1938 | 1938 | function boincuser_moderation_queue_count($caller = 'user') { |
| 1939 | - $allowed = FALSE; |
|
| 1940 | - switch ($caller) { |
|
| 1941 | - case 'cron': |
|
| 1939 | + $allowed = FALSE; |
|
| 1940 | + switch ($caller) { |
|
| 1941 | + case 'cron': |
|
| 1942 | 1942 | $allowed = TRUE; |
| 1943 | 1943 | break; |
| 1944 | - case 'user': |
|
| 1944 | + case 'user': |
|
| 1945 | 1945 | default: |
| 1946 | 1946 | $allowed = user_access('edit any profile content'); |
| 1947 | - } |
|
| 1948 | - if ($allowed) { |
|
| 1947 | + } |
|
| 1948 | + if ($allowed) { |
|
| 1949 | 1949 | return db_result(db_query(" |
| 1950 | 1950 | SELECT COUNT(*) |
| 1951 | 1951 | FROM {node} |
| 1952 | 1952 | WHERE type = 'profile' |
| 1953 | 1953 | AND moderate = 1" |
| 1954 | 1954 | )); |
| 1955 | - } |
|
| 1956 | - return NULL; |
|
| 1955 | + } |
|
| 1956 | + return NULL; |
|
| 1957 | 1957 | } |
| 1958 | 1958 | |
| 1959 | 1959 | /** |
@@ -1962,43 +1962,43 @@ discard block |
||
| 1962 | 1962 | * than through the user account info form. |
| 1963 | 1963 | */ |
| 1964 | 1964 | function boincuser_control($uid = NULL, $action = NULL) { |
| 1965 | - if (!$uid OR !$account = user_load($uid)) { |
|
| 1965 | + if (!$uid OR !$account = user_load($uid)) { |
|
| 1966 | 1966 | // What are you even doing here... |
| 1967 | 1967 | return FALSE; |
| 1968 | - } |
|
| 1969 | - switch ($action) { |
|
| 1970 | - case 'ban': |
|
| 1968 | + } |
|
| 1969 | + switch ($action) { |
|
| 1970 | + case 'ban': |
|
| 1971 | 1971 | if (boincuser_moderate_community_access()) { |
| 1972 | - $penalty_period = variable_get('boinc_penalty_period', 7*24*60*60); |
|
| 1973 | - $boincuser_record = array( |
|
| 1972 | + $penalty_period = variable_get('boinc_penalty_period', 7*24*60*60); |
|
| 1973 | + $boincuser_record = array( |
|
| 1974 | 1974 | 'uid' => $uid, |
| 1975 | 1975 | 'penalty_expiration' => time() + $penalty_period, |
| 1976 | - ); |
|
| 1977 | - drupal_write_record('boincuser', $boincuser_record, 'uid'); |
|
| 1978 | - $community_role = array_search('community member', user_roles(true)); |
|
| 1979 | - if (isset($account->roles[$community_role])) { |
|
| 1976 | + ); |
|
| 1977 | + drupal_write_record('boincuser', $boincuser_record, 'uid'); |
|
| 1978 | + $community_role = array_search('community member', user_roles(true)); |
|
| 1979 | + if (isset($account->roles[$community_role])) { |
|
| 1980 | 1980 | unset($account->roles[$community_role]); |
| 1981 | 1981 | user_save($account, array('roles' => $account->roles)); |
| 1982 | - } |
|
| 1982 | + } |
|
| 1983 | 1983 | } |
| 1984 | 1984 | break; |
| 1985 | - case 'lift-ban': |
|
| 1985 | + case 'lift-ban': |
|
| 1986 | 1986 | if (boincuser_moderate_community_access()) { |
| 1987 | - $boincuser_record = array( |
|
| 1987 | + $boincuser_record = array( |
|
| 1988 | 1988 | 'uid' => $uid, |
| 1989 | 1989 | 'penalty_expiration' => 0, |
| 1990 | - ); |
|
| 1991 | - drupal_write_record('boincuser', $boincuser_record, 'uid'); |
|
| 1992 | - $community_role = array_search('community member', user_roles(true)); |
|
| 1993 | - if (!isset($account->roles[$community_role])) { |
|
| 1990 | + ); |
|
| 1991 | + drupal_write_record('boincuser', $boincuser_record, 'uid'); |
|
| 1992 | + $community_role = array_search('community member', user_roles(true)); |
|
| 1993 | + if (!isset($account->roles[$community_role])) { |
|
| 1994 | 1994 | $account->roles[$community_role] = 'community member'; |
| 1995 | 1995 | user_save($account, array('roles' => $account->roles)); |
| 1996 | - } |
|
| 1996 | + } |
|
| 1997 | 1997 | } |
| 1998 | 1998 | break; |
| 1999 | - default: |
|
| 1999 | + default: |
|
| 2000 | 2000 | } |
| 2001 | - drupal_goto("account/{$account->uid}"); |
|
| 2001 | + drupal_goto("account/{$account->uid}"); |
|
| 2002 | 2002 | } |
| 2003 | 2003 | |
| 2004 | 2004 | /** |
@@ -2006,29 +2006,29 @@ discard block |
||
| 2006 | 2006 | * moderation flag. |
| 2007 | 2007 | */ |
| 2008 | 2008 | function boincuser_moderate_profile_approve($account) { |
| 2009 | - $node = new stdClass; |
|
| 2010 | - $node->type = 'profile'; |
|
| 2011 | - $node->language = ''; |
|
| 2012 | - $nid = content_profile_profile_exists($node, $account->uid); |
|
| 2013 | - $profile = node_load($nid); |
|
| 2014 | - $profile->moderate = 0; |
|
| 2015 | - $profile->status = 1; |
|
| 2016 | - node_save($profile); |
|
| 2017 | - drupal_set_message('This profile has been marked as approved.'); |
|
| 2018 | - drupal_goto(); |
|
| 2009 | + $node = new stdClass; |
|
| 2010 | + $node->type = 'profile'; |
|
| 2011 | + $node->language = ''; |
|
| 2012 | + $nid = content_profile_profile_exists($node, $account->uid); |
|
| 2013 | + $profile = node_load($nid); |
|
| 2014 | + $profile->moderate = 0; |
|
| 2015 | + $profile->status = 1; |
|
| 2016 | + node_save($profile); |
|
| 2017 | + drupal_set_message('This profile has been marked as approved.'); |
|
| 2018 | + drupal_goto(); |
|
| 2019 | 2019 | } |
| 2020 | 2020 | |
| 2021 | 2021 | /** |
| 2022 | 2022 | * Mark a user profile as rejected and notify the user of the reason. |
| 2023 | 2023 | */ |
| 2024 | 2024 | function boincuser_moderate_profile_reject($uid, $reason = '') { |
| 2025 | - $account = user_load($uid); |
|
| 2026 | - $node = new stdClass; |
|
| 2027 | - $node->type = 'profile'; |
|
| 2028 | - $node->language = ''; |
|
| 2029 | - $nid = content_profile_profile_exists($node, $uid); |
|
| 2030 | - $profile = node_load($nid); |
|
| 2031 | - if ($profile->nid) { |
|
| 2025 | + $account = user_load($uid); |
|
| 2026 | + $node = new stdClass; |
|
| 2027 | + $node->type = 'profile'; |
|
| 2028 | + $node->language = ''; |
|
| 2029 | + $nid = content_profile_profile_exists($node, $uid); |
|
| 2030 | + $profile = node_load($nid); |
|
| 2031 | + if ($profile->nid) { |
|
| 2032 | 2032 | global $user; |
| 2033 | 2033 | global $base_url; |
| 2034 | 2034 | global $base_path; |
@@ -2039,64 +2039,64 @@ discard block |
||
| 2039 | 2039 | $profile->status = 0; |
| 2040 | 2040 | node_save($profile); |
| 2041 | 2041 | $settings = array( |
| 2042 | - 'from' => '', |
|
| 2043 | - 'subject' => "Profile moderation at {$site_name}", |
|
| 2044 | - 'message' => '' |
|
| 2045 | - . "{$account->boincuser_name},\n" |
|
| 2046 | - . "\n" |
|
| 2047 | - . "{$moderator->boincuser_name} has rejected your profile at" |
|
| 2048 | - . " {$site_name} for the following reason: \n" |
|
| 2049 | - . "\n" |
|
| 2050 | - . "{$reason}\n" |
|
| 2051 | - . "\n" |
|
| 2052 | - . "\n" |
|
| 2053 | - . "Since it has not been approved, your profile is not visible to other" |
|
| 2054 | - . " {$site_name} users. Please make the needed changes here:\n" |
|
| 2055 | - . "\n" |
|
| 2056 | - . "{$site_url}account/profile \n" |
|
| 2057 | - . "\n" |
|
| 2058 | - . "Thanks, \n" |
|
| 2059 | - . "\n" |
|
| 2060 | - . "{$site_name} support team", |
|
| 2042 | + 'from' => '', |
|
| 2043 | + 'subject' => "Profile moderation at {$site_name}", |
|
| 2044 | + 'message' => '' |
|
| 2045 | + . "{$account->boincuser_name},\n" |
|
| 2046 | + . "\n" |
|
| 2047 | + . "{$moderator->boincuser_name} has rejected your profile at" |
|
| 2048 | + . " {$site_name} for the following reason: \n" |
|
| 2049 | + . "\n" |
|
| 2050 | + . "{$reason}\n" |
|
| 2051 | + . "\n" |
|
| 2052 | + . "\n" |
|
| 2053 | + . "Since it has not been approved, your profile is not visible to other" |
|
| 2054 | + . " {$site_name} users. Please make the needed changes here:\n" |
|
| 2055 | + . "\n" |
|
| 2056 | + . "{$site_url}account/profile \n" |
|
| 2057 | + . "\n" |
|
| 2058 | + . "Thanks, \n" |
|
| 2059 | + . "\n" |
|
| 2060 | + . "{$site_name} support team", |
|
| 2061 | 2061 | ); |
| 2062 | 2062 | rules_action_mail_to_user($account, $settings); |
| 2063 | 2063 | drupal_set_message('This profile has been marked as rejected.'); |
| 2064 | - } |
|
| 2065 | - drupal_goto(); |
|
| 2064 | + } |
|
| 2065 | + drupal_goto(); |
|
| 2066 | 2066 | } |
| 2067 | 2067 | |
| 2068 | 2068 | /** |
| 2069 | 2069 | * Ban a user and send a notification of the reason. |
| 2070 | 2070 | */ |
| 2071 | 2071 | function boincuser_moderate_user_ban($uid, $reason = '', $duration = '') { |
| 2072 | - if (user_access('assign community member role') |
|
| 2072 | + if (user_access('assign community member role') |
|
| 2073 | 2073 | OR user_access('assign all roles')) { |
| 2074 | 2074 | $account = user_load($uid); |
| 2075 | 2075 | if ($account->uid) { |
| 2076 | - module_load_include('inc', 'rules', 'modules/system.rules'); |
|
| 2077 | - if ($duration === '') { |
|
| 2076 | + module_load_include('inc', 'rules', 'modules/system.rules'); |
|
| 2077 | + if ($duration === '') { |
|
| 2078 | 2078 | $duration = variable_get('boinc_penalty_period', 7*24*60*60); |
| 2079 | - } |
|
| 2080 | - $penalty_expiration = ($duration > 0) ? time() + $duration : 4294967295; |
|
| 2081 | - $boincuser_record = array( |
|
| 2079 | + } |
|
| 2080 | + $penalty_expiration = ($duration > 0) ? time() + $duration : 4294967295; |
|
| 2081 | + $boincuser_record = array( |
|
| 2082 | 2082 | 'uid' => $uid, |
| 2083 | 2083 | 'penalty_expiration' => $penalty_expiration, |
| 2084 | - ); |
|
| 2085 | - drupal_write_record('boincuser', $boincuser_record, 'uid'); |
|
| 2084 | + ); |
|
| 2085 | + drupal_write_record('boincuser', $boincuser_record, 'uid'); |
|
| 2086 | 2086 | |
| 2087 | - $community_role = array_search('community member', user_roles(true)); |
|
| 2088 | - if (isset($account->roles[$community_role])) { |
|
| 2087 | + $community_role = array_search('community member', user_roles(true)); |
|
| 2088 | + if (isset($account->roles[$community_role])) { |
|
| 2089 | 2089 | unset($account->roles[$community_role]); |
| 2090 | 2090 | user_save($account, array('roles' => $account->roles)); |
| 2091 | - } |
|
| 2092 | - |
|
| 2093 | - global $user; |
|
| 2094 | - global $base_url; |
|
| 2095 | - global $base_path; |
|
| 2096 | - $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
| 2097 | - $site_url = $base_url . $base_path; |
|
| 2098 | - $moderator = user_load($user->uid); |
|
| 2099 | - $settings = array( |
|
| 2091 | + } |
|
| 2092 | + |
|
| 2093 | + global $user; |
|
| 2094 | + global $base_url; |
|
| 2095 | + global $base_path; |
|
| 2096 | + $site_name = variable_get('site_name', 'Drupal-BOINC'); |
|
| 2097 | + $site_url = $base_url . $base_path; |
|
| 2098 | + $moderator = user_load($user->uid); |
|
| 2099 | + $settings = array( |
|
| 2100 | 2100 | 'from' => '', |
| 2101 | 2101 | 'subject' => "User moderation at {$site_name}", |
| 2102 | 2102 | 'message' => '' |
@@ -2117,12 +2117,12 @@ discard block |
||
| 2117 | 2117 | . "Thanks, \n" |
| 2118 | 2118 | . "\n" |
| 2119 | 2119 | . "{$site_name} support team", |
| 2120 | - ); |
|
| 2121 | - rules_action_mail_to_user($account, $settings); |
|
| 2122 | - drupal_set_message('This user has been banned.'); |
|
| 2120 | + ); |
|
| 2121 | + rules_action_mail_to_user($account, $settings); |
|
| 2122 | + drupal_set_message('This user has been banned.'); |
|
| 2123 | 2123 | } |
| 2124 | - } |
|
| 2125 | - drupal_goto(); |
|
| 2124 | + } |
|
| 2125 | + drupal_goto(); |
|
| 2126 | 2126 | } |
| 2127 | 2127 | |
| 2128 | 2128 | |
@@ -2134,15 +2134,15 @@ discard block |
||
| 2134 | 2134 | * |
| 2135 | 2135 | */ |
| 2136 | 2136 | function boincuser_get_weak_auth($boinc_id = null) { |
| 2137 | - if (!$boinc_id) { |
|
| 2137 | + if (!$boinc_id) { |
|
| 2138 | 2138 | global $user; |
| 2139 | 2139 | $account = user_load($user->uid); |
| 2140 | 2140 | $boinc_id = $account->boincuser_id; |
| 2141 | - } |
|
| 2141 | + } |
|
| 2142 | 2142 | |
| 2143 | - $boinc_user = boincuser_load($account->boincuser_id); |
|
| 2143 | + $boinc_user = boincuser_load($account->boincuser_id); |
|
| 2144 | 2144 | |
| 2145 | - return weak_auth($boinc_user); |
|
| 2145 | + return weak_auth($boinc_user); |
|
| 2146 | 2146 | } |
| 2147 | 2147 | |
| 2148 | 2148 | /** |
@@ -2151,75 +2151,75 @@ discard block |
||
| 2151 | 2151 | * Drupal User so must be inserted into comments, etc. (not so by default) |
| 2152 | 2152 | */ |
| 2153 | 2153 | function boincuser_get_user_profile_image($uid, $avatar = TRUE) { |
| 2154 | - // Though the function name implies otherwise, get the avatar by default |
|
| 2155 | - $image_field = ($avatar) ? 'field_image_fid' : 'field_profile_image_fid'; |
|
| 2156 | - $image_fid = db_result(db_query(" |
|
| 2154 | + // Though the function name implies otherwise, get the avatar by default |
|
| 2155 | + $image_field = ($avatar) ? 'field_image_fid' : 'field_profile_image_fid'; |
|
| 2156 | + $image_fid = db_result(db_query(" |
|
| 2157 | 2157 | SELECT ctp.%s |
| 2158 | 2158 | FROM {content_type_profile} ctp |
| 2159 | 2159 | INNER JOIN {node} n ON ctp.nid = n.nid |
| 2160 | 2160 | WHERE n.uid = %d AND n.type = '%s'", |
| 2161 | 2161 | $image_field, $uid, 'profile')); |
| 2162 | - $user_image['image'] = field_file_load($image_fid); |
|
| 2163 | - if (!$user_image['image']['filepath']) { |
|
| 2162 | + $user_image['image'] = field_file_load($image_fid); |
|
| 2163 | + if (!$user_image['image']['filepath']) { |
|
| 2164 | 2164 | // Load the default image if one does not exist |
| 2165 | 2165 | $account = user_load($uid); |
| 2166 | 2166 | if ($avatar AND module_exists('gravatar') AND user_access('use gravatar', $account) AND $account->gravatar) { |
| 2167 | - // Use a Gravatar rather than the system default image |
|
| 2168 | - $options = array( |
|
| 2167 | + // Use a Gravatar rather than the system default image |
|
| 2168 | + $options = array( |
|
| 2169 | 2169 | 'size' => 100, |
| 2170 | 2170 | 'rating' => 'G', |
| 2171 | - ); |
|
| 2172 | - // Get the Gravatar URL and see if the image exists |
|
| 2173 | - $url = gravatar_get_gravatar($account->mail, $options); |
|
| 2174 | - $headers = @get_headers($url); |
|
| 2175 | - if (preg_match("|200|", $headers[0])) { |
|
| 2171 | + ); |
|
| 2172 | + // Get the Gravatar URL and see if the image exists |
|
| 2173 | + $url = gravatar_get_gravatar($account->mail, $options); |
|
| 2174 | + $headers = @get_headers($url); |
|
| 2175 | + if (preg_match("|200|", $headers[0])) { |
|
| 2176 | 2176 | return $url; |
| 2177 | - } |
|
| 2177 | + } |
|
| 2178 | 2178 | } |
| 2179 | 2179 | // Get default image if nothing else works |
| 2180 | 2180 | $content_node_widget_settings = db_result(db_query("SELECT widget_settings FROM {content_node_field_instance} WHERE field_name = '%s'", ($avatar ? 'field_image' : 'field_profile_image'))); |
| 2181 | 2181 | $content_node_widget_settings = unserialize($content_node_widget_settings); |
| 2182 | 2182 | $user_image['image'] = $content_node_widget_settings['default_image']; |
| 2183 | - } |
|
| 2184 | - $user = user_load($uid); |
|
| 2185 | - // Use boinc username for image alt/title attributes |
|
| 2186 | - $user_image['alt'] = $user->boincuser_name; |
|
| 2187 | - return $user_image; |
|
| 2183 | + } |
|
| 2184 | + $user = user_load($uid); |
|
| 2185 | + // Use boinc username for image alt/title attributes |
|
| 2186 | + $user_image['alt'] = $user->boincuser_name; |
|
| 2187 | + return $user_image; |
|
| 2188 | 2188 | } |
| 2189 | 2189 | |
| 2190 | 2190 | /** |
| 2191 | 2191 | * Generate a table of a user's projects |
| 2192 | 2192 | */ |
| 2193 | 2193 | function boincuser_get_projects_table($account = null) { |
| 2194 | - if ($account AND is_numeric($account)) { |
|
| 2194 | + if ($account AND is_numeric($account)) { |
|
| 2195 | 2195 | $account = user_load($account); |
| 2196 | - } |
|
| 2197 | - $projects = boincuser_get_projects($account); |
|
| 2198 | - if (!$projects) return bts('no projects...', array(), NULL, 'boinc:account-dashboard'); |
|
| 2199 | - |
|
| 2200 | - $output = ''; |
|
| 2201 | - $output .= '<table class="user-projects">' . "\n"; |
|
| 2202 | - $output .= '<thead>' . "\n"; |
|
| 2203 | - $output .= ' <tr>' . "\n"; |
|
| 2204 | - $output .= ' <th>' . bts('Name', array(), NULL, 'boinc:project-name:-1:ignoreoverwrite') . '</th>' . "\n"; |
|
| 2205 | - $output .= ' <th class="numeric">' . bts('Avg credit', array(), NULL, 'boinc:account-dashboard') . '</th>' . "\n"; |
|
| 2206 | - $output .= ' <th class="numeric">' . bts('Total credit', array(), NULL, 'boinc:user-or-team-total-credits') . '</th>' . "\n"; |
|
| 2207 | - $output .= ' </tr>' . "\n"; |
|
| 2208 | - $output .= '</thead>' . "\n"; |
|
| 2209 | - $output .= '<tbody>' . "\n"; |
|
| 2210 | - foreach ($projects AS $project) { |
|
| 2196 | + } |
|
| 2197 | + $projects = boincuser_get_projects($account); |
|
| 2198 | + if (!$projects) return bts('no projects...', array(), NULL, 'boinc:account-dashboard'); |
|
| 2199 | + |
|
| 2200 | + $output = ''; |
|
| 2201 | + $output .= '<table class="user-projects">' . "\n"; |
|
| 2202 | + $output .= '<thead>' . "\n"; |
|
| 2203 | + $output .= ' <tr>' . "\n"; |
|
| 2204 | + $output .= ' <th>' . bts('Name', array(), NULL, 'boinc:project-name:-1:ignoreoverwrite') . '</th>' . "\n"; |
|
| 2205 | + $output .= ' <th class="numeric">' . bts('Avg credit', array(), NULL, 'boinc:account-dashboard') . '</th>' . "\n"; |
|
| 2206 | + $output .= ' <th class="numeric">' . bts('Total credit', array(), NULL, 'boinc:user-or-team-total-credits') . '</th>' . "\n"; |
|
| 2207 | + $output .= ' </tr>' . "\n"; |
|
| 2208 | + $output .= '</thead>' . "\n"; |
|
| 2209 | + $output .= '<tbody>' . "\n"; |
|
| 2210 | + foreach ($projects AS $project) { |
|
| 2211 | 2211 | $url = rtrim($project->url, '/') . '/show_user.php?userid=' . $project->id; |
| 2212 | 2212 | $output .= ' <tr>' . "\n"; |
| 2213 | 2213 | $output .= ' <td>' . l($project->name, $url) . '</td>' . "\n"; |
| 2214 | 2214 | $output .= ' <td class="numeric">' . boincwork_format_stats((float) $project->expavg_credit) . '</td>' . "\n"; |
| 2215 | 2215 | $output .= ' <td class="numeric">' . boincwork_format_stats((float) $project->total_credit) . '</td>' . "\n"; |
| 2216 | 2216 | $output .= ' </tr>' . "\n"; |
| 2217 | - } |
|
| 2218 | - $output .= '</tbody>' . "\n"; |
|
| 2219 | - $output .= '</table>' . "\n"; |
|
| 2220 | - $more_link = ($account) ? "user/{$account->uid}/stats" : 'account/stats'; |
|
| 2221 | - //$output .= "<div class=\"more-link\"><a href=\"{$more_link}\">More stats</a></div>" . "\n"; |
|
| 2222 | - return $output; |
|
| 2217 | + } |
|
| 2218 | + $output .= '</tbody>' . "\n"; |
|
| 2219 | + $output .= '</table>' . "\n"; |
|
| 2220 | + $more_link = ($account) ? "user/{$account->uid}/stats" : 'account/stats'; |
|
| 2221 | + //$output .= "<div class=\"more-link\"><a href=\"{$more_link}\">More stats</a></div>" . "\n"; |
|
| 2222 | + return $output; |
|
| 2223 | 2223 | } |
| 2224 | 2224 | |
| 2225 | 2225 | /** |
@@ -2227,25 +2227,25 @@ discard block |
||
| 2227 | 2227 | */ |
| 2228 | 2228 | function boincuser_get_stats_user_data($cpid = null) { |
| 2229 | 2229 | |
| 2230 | - // [TODO] Set this stuff in site config! |
|
| 2231 | - $stats_server = 'stats.gridrepublic.org'; |
|
| 2232 | - $stats_rpc = 'rpc/get_user.php'; |
|
| 2230 | + // [TODO] Set this stuff in site config! |
|
| 2231 | + $stats_server = 'stats.gridrepublic.org'; |
|
| 2232 | + $stats_rpc = 'rpc/get_user.php'; |
|
| 2233 | 2233 | |
| 2234 | - // Construct query string |
|
| 2235 | - $get = array( |
|
| 2234 | + // Construct query string |
|
| 2235 | + $get = array( |
|
| 2236 | 2236 | 'cpid' => $cpid |
| 2237 | - ); |
|
| 2238 | - $args = array(); |
|
| 2239 | - foreach ($get as $arg => $value) $args[] = "{$arg}=" . rawurlencode($value); |
|
| 2240 | - $query = '?' . implode('&', $args); |
|
| 2241 | - |
|
| 2242 | - // Load XML from RPC |
|
| 2243 | - $target_url = "http://{$stats_server}/{$stats_rpc}{$query}"; |
|
| 2244 | - $result = drupal_http_request($target_url); |
|
| 2245 | - if (in_array($result->code, array(200, 304)) || in_array($result->redirect_code, array(200, 304))) { |
|
| 2237 | + ); |
|
| 2238 | + $args = array(); |
|
| 2239 | + foreach ($get as $arg => $value) $args[] = "{$arg}=" . rawurlencode($value); |
|
| 2240 | + $query = '?' . implode('&', $args); |
|
| 2241 | + |
|
| 2242 | + // Load XML from RPC |
|
| 2243 | + $target_url = "http://{$stats_server}/{$stats_rpc}{$query}"; |
|
| 2244 | + $result = drupal_http_request($target_url); |
|
| 2245 | + if (in_array($result->code, array(200, 304)) || in_array($result->redirect_code, array(200, 304))) { |
|
| 2246 | 2246 | return simplexml_load_string($result->data); |
| 2247 | - } |
|
| 2248 | - return NULL; |
|
| 2247 | + } |
|
| 2248 | + return NULL; |
|
| 2249 | 2249 | } |
| 2250 | 2250 | |
| 2251 | 2251 | /** |
@@ -2253,15 +2253,15 @@ discard block |
||
| 2253 | 2253 | */ |
| 2254 | 2254 | function boincuser_get_projects($account = null) { |
| 2255 | 2255 | |
| 2256 | - // Use the current user by default |
|
| 2257 | - if (!$account) { |
|
| 2256 | + // Use the current user by default |
|
| 2257 | + if (!$account) { |
|
| 2258 | 2258 | global $user; |
| 2259 | 2259 | $account = user_load($user->uid); |
| 2260 | - } |
|
| 2260 | + } |
|
| 2261 | 2261 | |
| 2262 | - $account_stats = boincuser_get_stats_user_data($account->boincuser_cpid); |
|
| 2262 | + $account_stats = boincuser_get_stats_user_data($account->boincuser_cpid); |
|
| 2263 | 2263 | |
| 2264 | - return ($account_stats AND isset($account_stats->project)) ? $account_stats->project : null; |
|
| 2264 | + return ($account_stats AND isset($account_stats->project)) ? $account_stats->project : null; |
|
| 2265 | 2265 | } |
| 2266 | 2266 | |
| 2267 | 2267 | |
@@ -2269,11 +2269,11 @@ discard block |
||
| 2269 | 2269 | * Get the links to display under the user profile |
| 2270 | 2270 | */ |
| 2271 | 2271 | function boincuser_get_profile_links($uid) { |
| 2272 | - global $user; |
|
| 2273 | - $account = user_load($uid); |
|
| 2274 | - $profile = content_profile_load('profile', $account->uid); |
|
| 2275 | - $output = ''; |
|
| 2276 | - if ($profile) { |
|
| 2272 | + global $user; |
|
| 2273 | + $account = user_load($uid); |
|
| 2274 | + $profile = content_profile_load('profile', $account->uid); |
|
| 2275 | + $output = ''; |
|
| 2276 | + if ($profile) { |
|
| 2277 | 2277 | $profile_is_approved = ($profile->status AND !$profile->moderate); |
| 2278 | 2278 | $user_is_moderator = user_access('edit any profile content'); |
| 2279 | 2279 | $is_own_profile = ($user->uid == $account->uid); |
@@ -2281,15 +2281,15 @@ discard block |
||
| 2281 | 2281 | $links = array(); |
| 2282 | 2282 | |
| 2283 | 2283 | if ($profile->moderate AND $user_is_moderator) { |
| 2284 | - $links['approve_profile'] = array( |
|
| 2284 | + $links['approve_profile'] = array( |
|
| 2285 | 2285 | 'title' => bts('Approve profile', array(), NULL, 'boinc:moderate-user'), |
| 2286 | 2286 | 'href' => "{$profile_moderation_path}/approve", |
| 2287 | 2287 | 'attributes' => array( |
| 2288 | - 'title' => bts('Approve this profile content', array(), NULL, 'boinc:moderate-user'), |
|
| 2289 | - 'class' => 'first primary tab', |
|
| 2288 | + 'title' => bts('Approve this profile content', array(), NULL, 'boinc:moderate-user'), |
|
| 2289 | + 'class' => 'first primary tab', |
|
| 2290 | 2290 | ) |
| 2291 | - ); |
|
| 2292 | - /*$links['edit_profile'] = array( |
|
| 2291 | + ); |
|
| 2292 | + /*$links['edit_profile'] = array( |
|
| 2293 | 2293 | 'title' => bts('Edit profile', array(), NULL, 'boinc:moderate-user'), |
| 2294 | 2294 | 'href' => "{$profile_moderation_path}/edit", |
| 2295 | 2295 | 'attributes' => array( |
@@ -2297,27 +2297,27 @@ discard block |
||
| 2297 | 2297 | 'class' => 'tab', |
| 2298 | 2298 | ) |
| 2299 | 2299 | );*/ |
| 2300 | - $links['reject_profile'] = array( |
|
| 2300 | + $links['reject_profile'] = array( |
|
| 2301 | 2301 | 'title' => bts('Reject profile', array(), NULL, 'boinc:moderate-user'), |
| 2302 | 2302 | 'href' => "{$profile_moderation_path}/reject", |
| 2303 | 2303 | 'attributes' => array( |
| 2304 | - 'title' => bts('Reject this profile content', array(), NULL, 'boinc:moderate-user'), |
|
| 2305 | - 'class' => 'tab', |
|
| 2304 | + 'title' => bts('Reject this profile content', array(), NULL, 'boinc:moderate-user'), |
|
| 2305 | + 'class' => 'tab', |
|
| 2306 | 2306 | ) |
| 2307 | - ); |
|
| 2307 | + ); |
|
| 2308 | 2308 | } |
| 2309 | 2309 | $output .= '<ul class="tab-list">'; |
| 2310 | 2310 | $count = 0; |
| 2311 | 2311 | foreach ($links as $key => $link) { |
| 2312 | - $output .= '<li class="' . (($count == 0) ? 'first primary ' : '') . 'tab">'; |
|
| 2313 | - $output .= l($link['title'], $link['href'], array('query' => drupal_get_destination())); |
|
| 2314 | - $output .= '</li>'; |
|
| 2315 | - $count++; |
|
| 2312 | + $output .= '<li class="' . (($count == 0) ? 'first primary ' : '') . 'tab">'; |
|
| 2313 | + $output .= l($link['title'], $link['href'], array('query' => drupal_get_destination())); |
|
| 2314 | + $output .= '</li>'; |
|
| 2315 | + $count++; |
|
| 2316 | 2316 | } |
| 2317 | 2317 | $output .= '<li class="' . (($count) ? '' : 'first ') . 'last tab">' . flag_create_link('abuse_user_meta', $account->uid) . '</li>'; |
| 2318 | 2318 | $output .= '</ul>'; |
| 2319 | - } |
|
| 2320 | - return $output; |
|
| 2319 | + } |
|
| 2320 | + return $output; |
|
| 2321 | 2321 | /* |
| 2322 | 2322 | <ul class="tab-list"> |
| 2323 | 2323 | <li class="primary first tab"> |
@@ -2354,36 +2354,36 @@ discard block |
||
| 2354 | 2354 | */ |
| 2355 | 2355 | function boincuser_apachesolr_index_documents_alter(array &$documents, $entity, $entity_type, $env_id) { |
| 2356 | 2356 | |
| 2357 | - foreach ($documents as $document) { |
|
| 2357 | + foreach ($documents as $document) { |
|
| 2358 | 2358 | if ( $document->entity_type=='node' AND $document->bundle=='profile' ) { |
| 2359 | - // Node information. |
|
| 2360 | - $nid = $document->entity_id; |
|
| 2361 | - $node = node_load($nid); |
|
| 2362 | - $account = user_load($node->uid); |
|
| 2363 | - |
|
| 2364 | - // Use boincuser name and not drupal user name |
|
| 2365 | - $document->label = apachesolr_clean_text($account->boincuser_name); |
|
| 2366 | - // Author information |
|
| 2367 | - if ($node->uid == 0 || strlen($node->name) == 0) { |
|
| 2359 | + // Node information. |
|
| 2360 | + $nid = $document->entity_id; |
|
| 2361 | + $node = node_load($nid); |
|
| 2362 | + $account = user_load($node->uid); |
|
| 2363 | + |
|
| 2364 | + // Use boincuser name and not drupal user name |
|
| 2365 | + $document->label = apachesolr_clean_text($account->boincuser_name); |
|
| 2366 | + // Author information |
|
| 2367 | + if ($node->uid == 0 || strlen($node->name) == 0) { |
|
| 2368 | 2368 | // @see user_validate_name(). !'0' === TRUE. |
| 2369 | 2369 | $document->ss_name = '0'; |
| 2370 | - } |
|
| 2371 | - else { |
|
| 2370 | + } |
|
| 2371 | + else { |
|
| 2372 | 2372 | $document->ss_name = $account->boincuser_name; |
| 2373 | 2373 | // We want the name to be searchable for keywords. |
| 2374 | 2374 | $document->tos_name = $account->boincuser_name; |
| 2375 | - } |
|
| 2375 | + } |
|
| 2376 | 2376 | |
| 2377 | - // Rename "Profle" to "User" |
|
| 2378 | - $document->bundle = "User"; |
|
| 2379 | - $document->bundle_name = "User"; |
|
| 2377 | + // Rename "Profle" to "User" |
|
| 2378 | + $document->bundle = "User"; |
|
| 2379 | + $document->bundle_name = "User"; |
|
| 2380 | 2380 | |
| 2381 | - // Replace the Solr document's created field with the date the user |
|
| 2382 | - // account was created. This replaces the node creation date typically |
|
| 2383 | - // used for indexing nodes. |
|
| 2384 | - $document->ds_created = apachesolr_date_iso($account->created); |
|
| 2381 | + // Replace the Solr document's created field with the date the user |
|
| 2382 | + // account was created. This replaces the node creation date typically |
|
| 2383 | + // used for indexing nodes. |
|
| 2384 | + $document->ds_created = apachesolr_date_iso($account->created); |
|
| 2385 | + } |
|
| 2385 | 2386 | } |
| 2386 | - } |
|
| 2387 | 2387 | |
| 2388 | 2388 | } |
| 2389 | 2389 | |
@@ -2395,23 +2395,23 @@ discard block |
||
| 2395 | 2395 | * Implementation of hook_privatemsg_name_lookup(); |
| 2396 | 2396 | */ |
| 2397 | 2397 | function boincuser_privatemsg_name_lookup($string) { |
| 2398 | - // Get the BOINC ID from the name string, and lookup the |
|
| 2399 | - // corresponding drupal user. |
|
| 2400 | - $boincname = substr($string, 0, strrpos($string, '_')); |
|
| 2401 | - $boincid = substr($string, strrpos($string, '_') + 1); |
|
| 2402 | - $drupalid = get_drupal_id($boincid); |
|
| 2403 | - |
|
| 2404 | - // Name has spaced replaced with special UTF-8 characters in |
|
| 2405 | - // privatemsg module. We need to convert them back to spaces for the |
|
| 2406 | - // check below. |
|
| 2407 | - $boincname = preg_replace("/\\xc2\\xa0/", " ", $boincname); |
|
| 2408 | - if ($drupalid>0) { |
|
| 2398 | + // Get the BOINC ID from the name string, and lookup the |
|
| 2399 | + // corresponding drupal user. |
|
| 2400 | + $boincname = substr($string, 0, strrpos($string, '_')); |
|
| 2401 | + $boincid = substr($string, strrpos($string, '_') + 1); |
|
| 2402 | + $drupalid = get_drupal_id($boincid); |
|
| 2403 | + |
|
| 2404 | + // Name has spaced replaced with special UTF-8 characters in |
|
| 2405 | + // privatemsg module. We need to convert them back to spaces for the |
|
| 2406 | + // check below. |
|
| 2407 | + $boincname = preg_replace("/\\xc2\\xa0/", " ", $boincname); |
|
| 2408 | + if ($drupalid>0) { |
|
| 2409 | 2409 | if ($recipient = user_load(array('uid' => $drupalid))) { |
| 2410 | - // Double-check that the loaded user matches both boincuser_id |
|
| 2411 | - // and boincuser_name. |
|
| 2412 | - if ( ($boincid == $recipient->boincuser_id) AND ($boincname == $recipient->boincuser_name) ) { |
|
| 2410 | + // Double-check that the loaded user matches both boincuser_id |
|
| 2411 | + // and boincuser_name. |
|
| 2412 | + if ( ($boincid == $recipient->boincuser_id) AND ($boincname == $recipient->boincuser_name) ) { |
|
| 2413 | 2413 | return $recipient; |
| 2414 | - } |
|
| 2414 | + } |
|
| 2415 | + } |
|
| 2415 | 2416 | } |
| 2416 | - } |
|
| 2417 | 2417 | } |
@@ -13,255 +13,255 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | function boincuser_views_data() { |
| 15 | 15 | |
| 16 | - // ----------------------------------------------------------------------------------------------- |
|
| 17 | - // Definition for user table |
|
| 18 | - // ----------------------------------------------------------------------------------------------- |
|
| 16 | + // ----------------------------------------------------------------------------------------------- |
|
| 17 | + // Definition for user table |
|
| 18 | + // ----------------------------------------------------------------------------------------------- |
|
| 19 | 19 | |
| 20 | - $data['user']['table']['group'] = t('BOINC'); |
|
| 20 | + $data['user']['table']['group'] = t('BOINC'); |
|
| 21 | 21 | |
| 22 | - $data['user']['table']['base'] = array( |
|
| 23 | - 'field' => 'id', |
|
| 24 | - 'title' => t('BOINC user'), |
|
| 25 | - 'help' => t('BOINC account data for a user'), |
|
| 26 | - 'database' => 'boinc_ro' |
|
| 27 | - ); |
|
| 22 | + $data['user']['table']['base'] = array( |
|
| 23 | + 'field' => 'id', |
|
| 24 | + 'title' => t('BOINC user'), |
|
| 25 | + 'help' => t('BOINC account data for a user'), |
|
| 26 | + 'database' => 'boinc_ro' |
|
| 27 | + ); |
|
| 28 | 28 | |
| 29 | - // Describe each of the individual fields in this table to Views. For |
|
| 30 | - // each field, you may define what field, sort, argument, and/or filter |
|
| 31 | - // handlers it supports. This will determine where in the Views interface you |
|
| 32 | - // may use the field. |
|
| 29 | + // Describe each of the individual fields in this table to Views. For |
|
| 30 | + // each field, you may define what field, sort, argument, and/or filter |
|
| 31 | + // handlers it supports. This will determine where in the Views interface you |
|
| 32 | + // may use the field. |
|
| 33 | 33 | |
| 34 | - // Primary keys allowed as arguments |
|
| 34 | + // Primary keys allowed as arguments |
|
| 35 | 35 | |
| 36 | - $data['user']['id'] = array( |
|
| 36 | + $data['user']['id'] = array( |
|
| 37 | 37 | 'title' => bts('Id', array(), NULL, 'boinc:user-id'), |
| 38 | 38 | 'help' => t('The BOINC ID of the user account.'), |
| 39 | 39 | 'field' => array( |
| 40 | - 'handler' => 'views_handler_field_numeric', |
|
| 41 | - 'click sortable' => TRUE |
|
| 40 | + 'handler' => 'views_handler_field_numeric', |
|
| 41 | + 'click sortable' => TRUE |
|
| 42 | 42 | ), |
| 43 | 43 | 'argument' => array( |
| 44 | - 'handler' => 'views_handler_argument_boincuser_id', // custom handler |
|
| 45 | - 'name field' => 'title', // the field to display in the summary. |
|
| 46 | - 'numeric' => TRUE, |
|
| 47 | - 'validate type' => 'id' |
|
| 44 | + 'handler' => 'views_handler_argument_boincuser_id', // custom handler |
|
| 45 | + 'name field' => 'title', // the field to display in the summary. |
|
| 46 | + 'numeric' => TRUE, |
|
| 47 | + 'validate type' => 'id' |
|
| 48 | 48 | ), |
| 49 | 49 | 'filter' => array( |
| 50 | - 'handler' => 'views_handler_filter_numeric' |
|
| 50 | + 'handler' => 'views_handler_filter_numeric' |
|
| 51 | 51 | ), |
| 52 | 52 | 'sort' => array( |
| 53 | - 'handler' => 'views_handler_sort_numeric' |
|
| 53 | + 'handler' => 'views_handler_sort_numeric' |
|
| 54 | 54 | ) |
| 55 | - ); |
|
| 56 | - $data['user']['teamid'] = array( |
|
| 55 | + ); |
|
| 56 | + $data['user']['teamid'] = array( |
|
| 57 | 57 | 'title' => bts('Team ID', array(), NULL, 'boinc:team-id'), |
| 58 | 58 | 'help' => t('The ID of the user\'s team.'), |
| 59 | 59 | 'field' => array( |
| 60 | - 'handler' => 'views_handler_field_numeric', |
|
| 61 | - 'click sortable' => TRUE, |
|
| 60 | + 'handler' => 'views_handler_field_numeric', |
|
| 61 | + 'click sortable' => TRUE, |
|
| 62 | 62 | ), |
| 63 | 63 | 'argument' => array( |
| 64 | - 'handler' => 'views_handler_argument_boincteam_id', // custom handler |
|
| 65 | - 'name field' => 'title', // the field to display in the summary. |
|
| 66 | - 'numeric' => TRUE, |
|
| 67 | - 'validate type' => 'id' |
|
| 64 | + 'handler' => 'views_handler_argument_boincteam_id', // custom handler |
|
| 65 | + 'name field' => 'title', // the field to display in the summary. |
|
| 66 | + 'numeric' => TRUE, |
|
| 67 | + 'validate type' => 'id' |
|
| 68 | 68 | ), |
| 69 | 69 | 'filter' => array( |
| 70 | - 'handler' => 'views_handler_filter_numeric' |
|
| 70 | + 'handler' => 'views_handler_filter_numeric' |
|
| 71 | 71 | ), |
| 72 | 72 | 'sort' => array( |
| 73 | - 'handler' => 'views_handler_sort_numeric' |
|
| 73 | + 'handler' => 'views_handler_sort_numeric' |
|
| 74 | 74 | ) |
| 75 | - ); |
|
| 75 | + ); |
|
| 76 | 76 | |
| 77 | - // Descriptions of general host fields (alphabetized) |
|
| 77 | + // Descriptions of general host fields (alphabetized) |
|
| 78 | 78 | |
| 79 | - $data['user']['authenticator'] = array( |
|
| 79 | + $data['user']['authenticator'] = array( |
|
| 80 | 80 | 'title' => bts('Account Key', array(), NULL, 'boinc:user-info'), |
| 81 | 81 | 'help' => t('The BOINC account key of the user.'), |
| 82 | 82 | 'field' => array( |
| 83 | - 'handler' => 'views_handler_field', |
|
| 84 | - 'click sortable' => TRUE |
|
| 83 | + 'handler' => 'views_handler_field', |
|
| 84 | + 'click sortable' => TRUE |
|
| 85 | 85 | ), |
| 86 | 86 | 'filter' => array( |
| 87 | - 'handler' => 'views_handler_filter_string' |
|
| 87 | + 'handler' => 'views_handler_filter_string' |
|
| 88 | 88 | ), |
| 89 | 89 | 'sort' => array( |
| 90 | - 'handler' => 'views_handler_sort_string' |
|
| 90 | + 'handler' => 'views_handler_sort_string' |
|
| 91 | 91 | ) |
| 92 | - ); |
|
| 93 | - $data['user']['country'] = array( |
|
| 92 | + ); |
|
| 93 | + $data['user']['country'] = array( |
|
| 94 | 94 | 'title' => bts('Country', array(), NULL, 'boinc:country-of-origin'), |
| 95 | 95 | 'help' => t('The country of the user.'), |
| 96 | 96 | 'field' => array( |
| 97 | - 'handler' => 'views_handler_field', |
|
| 98 | - 'click sortable' => TRUE |
|
| 97 | + 'handler' => 'views_handler_field', |
|
| 98 | + 'click sortable' => TRUE |
|
| 99 | 99 | ), |
| 100 | 100 | 'filter' => array( |
| 101 | - 'handler' => 'views_handler_filter_string' |
|
| 101 | + 'handler' => 'views_handler_filter_string' |
|
| 102 | 102 | ), |
| 103 | 103 | 'sort' => array( |
| 104 | - 'handler' => 'views_handler_sort_string' |
|
| 104 | + 'handler' => 'views_handler_sort_string' |
|
| 105 | 105 | ) |
| 106 | - ); |
|
| 107 | - $data['user']['create_time'] = array( |
|
| 106 | + ); |
|
| 107 | + $data['user']['create_time'] = array( |
|
| 108 | 108 | 'title' => bts('Member since', array(), NULL, 'boinc:user-info'), |
| 109 | 109 | 'help' => t('When the BOINC account was created.'), |
| 110 | 110 | 'field' => array( |
| 111 | - 'handler' => 'views_handler_field_date', |
|
| 112 | - 'click sortable' => TRUE |
|
| 111 | + 'handler' => 'views_handler_field_date', |
|
| 112 | + 'click sortable' => TRUE |
|
| 113 | 113 | ), |
| 114 | 114 | 'filter' => array( |
| 115 | - 'handler' => 'views_handler_filter_date' |
|
| 115 | + 'handler' => 'views_handler_filter_date' |
|
| 116 | 116 | ), |
| 117 | 117 | 'sort' => array( |
| 118 | - 'handler' => 'views_handler_sort_date' |
|
| 118 | + 'handler' => 'views_handler_sort_date' |
|
| 119 | 119 | ) |
| 120 | - ); |
|
| 121 | - $data['user']['cross_project_id'] = array( |
|
| 120 | + ); |
|
| 121 | + $data['user']['cross_project_id'] = array( |
|
| 122 | 122 | 'title' => bts('CPID', array(), NULL, 'boinc:user-info'), |
| 123 | 123 | 'help' => t('The cross project user identifier.'), |
| 124 | 124 | 'field' => array( |
| 125 | - 'handler' => 'views_handler_field', |
|
| 126 | - 'click sortable' => TRUE |
|
| 125 | + 'handler' => 'views_handler_field', |
|
| 126 | + 'click sortable' => TRUE |
|
| 127 | 127 | ), |
| 128 | 128 | 'filter' => array( |
| 129 | - 'handler' => 'views_handler_filter_string' |
|
| 129 | + 'handler' => 'views_handler_filter_string' |
|
| 130 | 130 | ), |
| 131 | 131 | 'sort' => array( |
| 132 | - 'handler' => 'views_handler_sort_string' |
|
| 132 | + 'handler' => 'views_handler_sort_string' |
|
| 133 | 133 | ) |
| 134 | - ); |
|
| 135 | - $data['user']['email_addr'] = array( |
|
| 136 | - 'title' => bts('Email Address', array(), NULL, 'boinc:user-info'), |
|
| 134 | + ); |
|
| 135 | + $data['user']['email_addr'] = array( |
|
| 136 | + 'title' => bts('Email Address', array(), NULL, 'boinc:user-info'), |
|
| 137 | 137 | 'help' => t('The BOINC account email address.'), |
| 138 | 138 | 'field' => array( |
| 139 | - 'handler' => 'views_handler_field', |
|
| 140 | - 'click sortable' => TRUE |
|
| 139 | + 'handler' => 'views_handler_field', |
|
| 140 | + 'click sortable' => TRUE |
|
| 141 | 141 | ), |
| 142 | 142 | 'filter' => array( |
| 143 | - 'handler' => 'views_handler_filter_string' |
|
| 143 | + 'handler' => 'views_handler_filter_string' |
|
| 144 | 144 | ), |
| 145 | 145 | 'sort' => array( |
| 146 | - 'handler' => 'views_handler_sort_string' |
|
| 146 | + 'handler' => 'views_handler_sort_string' |
|
| 147 | 147 | ) |
| 148 | - ); |
|
| 149 | - $data['user']['expavg_credit'] = array( |
|
| 148 | + ); |
|
| 149 | + $data['user']['expavg_credit'] = array( |
|
| 150 | 150 | 'title' => bts('Recent average credit', array(), NULL, 'boinc:user-or-team-RAC'), |
| 151 | 151 | 'help' => t('A decaying average of credit per day for the user.'), |
| 152 | 152 | 'field' => array( |
| 153 | - 'handler' => 'views_handler_field_numeric', |
|
| 154 | - 'click sortable' => TRUE, |
|
| 155 | - 'float' => TRUE |
|
| 153 | + 'handler' => 'views_handler_field_numeric', |
|
| 154 | + 'click sortable' => TRUE, |
|
| 155 | + 'float' => TRUE |
|
| 156 | 156 | ), |
| 157 | 157 | 'filter' => array( |
| 158 | - 'handler' => 'views_handler_filter_numeric' |
|
| 158 | + 'handler' => 'views_handler_filter_numeric' |
|
| 159 | 159 | ), |
| 160 | 160 | 'sort' => array( |
| 161 | - 'handler' => 'views_handler_sort_numeric' |
|
| 161 | + 'handler' => 'views_handler_sort_numeric' |
|
| 162 | 162 | ) |
| 163 | - ); |
|
| 164 | - $data['user']['name'] = array( |
|
| 163 | + ); |
|
| 164 | + $data['user']['name'] = array( |
|
| 165 | 165 | 'title' => bts('Name', array(), NULL, 'boinc:user-or-team-name'), |
| 166 | 166 | 'help' => t('The BOINC account user name.'), |
| 167 | 167 | 'field' => array( |
| 168 | - 'handler' => 'views_handler_field', |
|
| 169 | - 'click sortable' => TRUE |
|
| 168 | + 'handler' => 'views_handler_field', |
|
| 169 | + 'click sortable' => TRUE |
|
| 170 | 170 | ), |
| 171 | 171 | 'filter' => array( |
| 172 | - 'handler' => 'views_handler_filter_string' |
|
| 172 | + 'handler' => 'views_handler_filter_string' |
|
| 173 | 173 | ), |
| 174 | 174 | 'sort' => array( |
| 175 | - 'handler' => 'views_handler_sort_string' |
|
| 175 | + 'handler' => 'views_handler_sort_string' |
|
| 176 | 176 | ) |
| 177 | - ); |
|
| 178 | - $data['user']['passwd_hash'] = array( |
|
| 177 | + ); |
|
| 178 | + $data['user']['passwd_hash'] = array( |
|
| 179 | 179 | 'title' => bts('Password Hash', array(), NULL, 'boinc:user-info'), |
| 180 | 180 | 'help' => t('The user password hash'), |
| 181 | 181 | 'field' => array( |
| 182 | - 'handler' => 'views_handler_field', |
|
| 183 | - 'click sortable' => TRUE |
|
| 182 | + 'handler' => 'views_handler_field', |
|
| 183 | + 'click sortable' => TRUE |
|
| 184 | 184 | ), |
| 185 | 185 | 'filter' => array( |
| 186 | - 'handler' => 'views_handler_filter_string' |
|
| 186 | + 'handler' => 'views_handler_filter_string' |
|
| 187 | 187 | ), |
| 188 | 188 | 'sort' => array( |
| 189 | - 'handler' => 'views_handler_sort_string' |
|
| 189 | + 'handler' => 'views_handler_sort_string' |
|
| 190 | 190 | ) |
| 191 | - ); |
|
| 192 | - $data['user']['postal_code'] = array( |
|
| 191 | + ); |
|
| 192 | + $data['user']['postal_code'] = array( |
|
| 193 | 193 | 'title' => bts('Postal Code', array(), NULL, 'boinc:user-info'), |
| 194 | 194 | 'help' => t('The postal code of the user.'), |
| 195 | 195 | 'field' => array( |
| 196 | - 'handler' => 'views_handler_field', |
|
| 197 | - 'click sortable' => TRUE |
|
| 196 | + 'handler' => 'views_handler_field', |
|
| 197 | + 'click sortable' => TRUE |
|
| 198 | 198 | ), |
| 199 | 199 | 'filter' => array( |
| 200 | - 'handler' => 'views_handler_filter_string' |
|
| 200 | + 'handler' => 'views_handler_filter_string' |
|
| 201 | 201 | ), |
| 202 | 202 | 'sort' => array( |
| 203 | - 'handler' => 'views_handler_sort_string' |
|
| 203 | + 'handler' => 'views_handler_sort_string' |
|
| 204 | 204 | ) |
| 205 | - ); |
|
| 206 | - $data['user']['send_email'] = array( |
|
| 205 | + ); |
|
| 206 | + $data['user']['send_email'] = array( |
|
| 207 | 207 | 'title' => bts('Send Email', array(), NULL, 'boinc:user-info'), |
| 208 | 208 | 'help' => t('User preference to allow email communications.'), |
| 209 | 209 | 'field' => array( |
| 210 | - 'handler' => 'views_handler_field_numeric', |
|
| 211 | - 'click sortable' => TRUE |
|
| 210 | + 'handler' => 'views_handler_field_numeric', |
|
| 211 | + 'click sortable' => TRUE |
|
| 212 | 212 | ), |
| 213 | 213 | 'filter' => array( |
| 214 | - 'handler' => 'views_handler_filter_numeric' |
|
| 214 | + 'handler' => 'views_handler_filter_numeric' |
|
| 215 | 215 | ), |
| 216 | 216 | 'sort' => array( |
| 217 | - 'handler' => 'views_handler_sort_numeric' |
|
| 217 | + 'handler' => 'views_handler_sort_numeric' |
|
| 218 | 218 | ) |
| 219 | - ); |
|
| 220 | - $data['user']['show_hosts'] = array( |
|
| 219 | + ); |
|
| 220 | + $data['user']['show_hosts'] = array( |
|
| 221 | 221 | 'title' => bts('Show Hosts', array(), NULL, 'boinc:user-info'), |
| 222 | 222 | 'help' => t('User preference to display owned computers.'), |
| 223 | 223 | 'field' => array( |
| 224 | - 'handler' => 'views_handler_field_numeric', |
|
| 225 | - 'click sortable' => TRUE |
|
| 224 | + 'handler' => 'views_handler_field_numeric', |
|
| 225 | + 'click sortable' => TRUE |
|
| 226 | 226 | ), |
| 227 | 227 | 'filter' => array( |
| 228 | - 'handler' => 'views_handler_filter_numeric' |
|
| 228 | + 'handler' => 'views_handler_filter_numeric' |
|
| 229 | 229 | ), |
| 230 | 230 | 'sort' => array( |
| 231 | - 'handler' => 'views_handler_sort_numeric' |
|
| 231 | + 'handler' => 'views_handler_sort_numeric' |
|
| 232 | 232 | ) |
| 233 | - ); |
|
| 234 | - $data['user']['total_credit'] = array( |
|
| 233 | + ); |
|
| 234 | + $data['user']['total_credit'] = array( |
|
| 235 | 235 | 'title' => bts('Total credit', array(), NULL, 'boinc:user-or-team-total-credits'), |
| 236 | 236 | 'help' => t('The total accumulated BOINC credit for the user.'), |
| 237 | 237 | 'field' => array( |
| 238 | - 'handler' => 'views_handler_field_numeric', |
|
| 239 | - 'click sortable' => TRUE, |
|
| 240 | - 'float' => TRUE |
|
| 238 | + 'handler' => 'views_handler_field_numeric', |
|
| 239 | + 'click sortable' => TRUE, |
|
| 240 | + 'float' => TRUE |
|
| 241 | 241 | ), |
| 242 | 242 | 'filter' => array( |
| 243 | - 'handler' => 'views_handler_filter_numeric' |
|
| 243 | + 'handler' => 'views_handler_filter_numeric' |
|
| 244 | 244 | ), |
| 245 | 245 | 'sort' => array( |
| 246 | - 'handler' => 'views_handler_sort_numeric' |
|
| 246 | + 'handler' => 'views_handler_sort_numeric' |
|
| 247 | 247 | ) |
| 248 | - ); |
|
| 249 | - $data['user']['url'] = array( |
|
| 248 | + ); |
|
| 249 | + $data['user']['url'] = array( |
|
| 250 | 250 | 'title' => bts('URL', array(), NULL, 'boinc:website-of-user-or-team'), |
| 251 | 251 | 'help' => t('The URL provided by the user'), |
| 252 | 252 | 'field' => array( |
| 253 | - 'handler' => 'views_handler_field', |
|
| 254 | - 'click sortable' => TRUE |
|
| 253 | + 'handler' => 'views_handler_field', |
|
| 254 | + 'click sortable' => TRUE |
|
| 255 | 255 | ), |
| 256 | 256 | 'filter' => array( |
| 257 | - 'handler' => 'views_handler_filter_string' |
|
| 257 | + 'handler' => 'views_handler_filter_string' |
|
| 258 | 258 | ), |
| 259 | 259 | 'sort' => array( |
| 260 | - 'handler' => 'views_handler_sort_string' |
|
| 260 | + 'handler' => 'views_handler_sort_string' |
|
| 261 | 261 | ) |
| 262 | - ); |
|
| 262 | + ); |
|
| 263 | 263 | |
| 264 | - return $data; |
|
| 264 | + return $data; |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | /* |
@@ -272,17 +272,17 @@ discard block |
||
| 272 | 272 | */ |
| 273 | 273 | |
| 274 | 274 | function boincuser_views_handlers() { |
| 275 | - return array( |
|
| 275 | + return array( |
|
| 276 | 276 | 'info' => array( |
| 277 | - 'path' => drupal_get_path('module', 'boincuser') . '/views', |
|
| 277 | + 'path' => drupal_get_path('module', 'boincuser') . '/views', |
|
| 278 | 278 | ), |
| 279 | 279 | 'handlers' => array( |
| 280 | - 'views_handler_argument_boincuser_id' => array( |
|
| 280 | + 'views_handler_argument_boincuser_id' => array( |
|
| 281 | 281 | 'parent' => 'views_handler_argument_numeric' |
| 282 | - ), |
|
| 283 | - 'views_handler_argument_boincteam_id' => array( |
|
| 282 | + ), |
|
| 283 | + 'views_handler_argument_boincteam_id' => array( |
|
| 284 | 284 | 'parent' => 'views_handler_argument_numeric' |
| 285 | - ), |
|
| 285 | + ), |
|
| 286 | 286 | ) |
| 287 | - ); |
|
| 287 | + ); |
|
| 288 | 288 | } |
@@ -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_rw'); |
|
| 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_rw'); |
|
| 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 | - } |
|
| 76 | - |
|
| 77 | - // Determine team membership |
|
| 78 | - db_set_active('boinc_rw'); |
|
| 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) { |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + // Determine team membership |
|
| 78 | + db_set_active('boinc_rw'); |
|
| 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; |
|
| 92 | + echo $count; |
|
| 93 | 93 | |
@@ -5,45 +5,45 @@ discard block |
||
| 5 | 5 | * Callback admin/boinc/import/settings |
| 6 | 6 | */ |
| 7 | 7 | function boincimport_admin_settings() { |
| 8 | - global $conf ; |
|
| 9 | - global $db_url; |
|
| 10 | - global $base_url; |
|
| 11 | - $stage = variable_get('boincimport_config_stage', 0); |
|
| 8 | + global $conf ; |
|
| 9 | + global $db_url; |
|
| 10 | + global $base_url; |
|
| 11 | + $stage = variable_get('boincimport_config_stage', 0); |
|
| 12 | 12 | |
| 13 | - // Start with a quick sanity check on the BOINC environment |
|
| 14 | - boinc_get_path(); |
|
| 13 | + // Start with a quick sanity check on the BOINC environment |
|
| 14 | + boinc_get_path(); |
|
| 15 | 15 | |
| 16 | - //We'll be checking that the setup is complete. |
|
| 17 | - //If it is not complete, the migration will not go ahead. |
|
| 18 | - $ready_for_migration = 1; |
|
| 16 | + //We'll be checking that the setup is complete. |
|
| 17 | + //If it is not complete, the migration will not go ahead. |
|
| 18 | + $ready_for_migration = 1; |
|
| 19 | 19 | |
| 20 | - // Checking that the migration has been tested on a copy first. |
|
| 21 | - $form['test'] = array( |
|
| 20 | + // Checking that the migration has been tested on a copy first. |
|
| 21 | + $form['test'] = array( |
|
| 22 | 22 | '#type' => 'fieldset', |
| 23 | 23 | '#title' => t('Test on copy first'), |
| 24 | 24 | '#collapsible' => TRUE, |
| 25 | 25 | '#collapsed' => TRUE, |
| 26 | - ); |
|
| 26 | + ); |
|
| 27 | 27 | |
| 28 | - $output = ''; |
|
| 29 | - if (!variable_get('boincimport_tested', 0)) { |
|
| 28 | + $output = ''; |
|
| 29 | + if (!variable_get('boincimport_tested', 0)) { |
|
| 30 | 30 | $form['test']['#collapsed']= FALSE; |
| 31 | 31 | $output = '<span class="marker">'; |
| 32 | 32 | $ready_for_migration = 0; |
| 33 | - } |
|
| 34 | - $output .= '<p>' . t('The migration will modify and even destroy some data. You |
|
| 33 | + } |
|
| 34 | + $output .= '<p>' . t('The migration will modify and even destroy some data. You |
|
| 35 | 35 | must test this module on a copy of your data first, several times if necessary. |
| 36 | 36 | Only use this module on your live data when you are familiar with the procedure |
| 37 | 37 | and you\'re confident everything will run smoothly.') . '</p><p>' . t('Also, you |
| 38 | 38 | should make a full backup of your database just prior to performing the |
| 39 | 39 | migration on the live data. It is better to turn off both the BOINC site and the |
| 40 | 40 | Drupal site during the migration.') . '</p>'; |
| 41 | - if (!variable_get('boincimport_tested', 0)) { |
|
| 41 | + if (!variable_get('boincimport_tested', 0)) { |
|
| 42 | 42 | $output .= '</span>'; |
| 43 | - } |
|
| 44 | - $form['test']['intro'] = array('#value' => $output); |
|
| 43 | + } |
|
| 44 | + $form['test']['intro'] = array('#value' => $output); |
|
| 45 | 45 | |
| 46 | - $form['test']['boincimport_tested'] = array( |
|
| 46 | + $form['test']['boincimport_tested'] = array( |
|
| 47 | 47 | '#type' => 'checkbox', |
| 48 | 48 | '#title' => t('I am running a trial migration on a disposable copy of the database |
| 49 | 49 | OR I have already done so and I am running this on my live site, confident that |
@@ -51,64 +51,64 @@ discard block |
||
| 51 | 51 | '#return_value' => 1, |
| 52 | 52 | '#default_value' => variable_get('boincimport_tested', 0), |
| 53 | 53 | '#description' => '', |
| 54 | - ); |
|
| 54 | + ); |
|
| 55 | 55 | |
| 56 | - // Where is BOINC data? |
|
| 57 | - $pre = variable_get('boincimport_table_prefix', ''); |
|
| 58 | - $tables = array($pre .'forum', $pre .'post', $pre .'thread', $pre .'user'); |
|
| 59 | - $db = (is_array($db_url) AND isset($db_url['boinc_rw'])) ? 'boinc_rw' : 'default'; |
|
| 60 | - $result = _boincimport_check_tables($tables, $db, 0); |
|
| 56 | + // Where is BOINC data? |
|
| 57 | + $pre = variable_get('boincimport_table_prefix', ''); |
|
| 58 | + $tables = array($pre .'forum', $pre .'post', $pre .'thread', $pre .'user'); |
|
| 59 | + $db = (is_array($db_url) AND isset($db_url['boinc_rw'])) ? 'boinc_rw' : 'default'; |
|
| 60 | + $result = _boincimport_check_tables($tables, $db, 0); |
|
| 61 | 61 | |
| 62 | - $config_path = conf_path(); |
|
| 63 | - $form['boinc_data'] = array( |
|
| 62 | + $config_path = conf_path(); |
|
| 63 | + $form['boinc_data'] = array( |
|
| 64 | 64 | '#type' => 'fieldset', |
| 65 | 65 | '#title' => t('Location of BOINC data'), |
| 66 | 66 | '#collapsible' => TRUE, |
| 67 | 67 | '#collapsed' => TRUE, |
| 68 | - ); |
|
| 69 | - $form['boinc_data']['boincimport_db_configured'] = array( |
|
| 68 | + ); |
|
| 69 | + $form['boinc_data']['boincimport_db_configured'] = array( |
|
| 70 | 70 | '#type' => 'checkbox', |
| 71 | 71 | '#title' => t('There is a \'boinc\' database connection string configured in %file', |
| 72 | - array('%file' => "{$config_path}/settings.php")), |
|
| 72 | + array('%file' => "{$config_path}/settings.php")), |
|
| 73 | 73 | '#return_value' => 1, |
| 74 | 74 | '#default_value' => variable_get('boincimport_db_configured', 1), |
| 75 | 75 | '#description' => '', |
| 76 | 76 | '#disabled' => ($result['result']) ? TRUE : FALSE |
| 77 | - ); |
|
| 78 | - if (variable_get('boincimport_db_configured', 1) != 1) { |
|
| 77 | + ); |
|
| 78 | + if (variable_get('boincimport_db_configured', 1) != 1) { |
|
| 79 | 79 | $default_db_url = is_array($db_url) ? end($db_url) : $db_url; |
| 80 | 80 | $url = variable_get('boincimport_db_url', $default_db_url); |
| 81 | 81 | if (!preg_match('{(mysql|pgsql):\/\/(.+):(.*?)@(.+)/(\w+)}i', $url)) { |
| 82 | - $output = '<p class="marker">'. t('Set the address of the BOINC database |
|
| 82 | + $output = '<p class="marker">'. t('Set the address of the BOINC database |
|
| 83 | 83 | according to the following format:') . '<br /><pre> |
| 84 | 84 | mysql://boinc_username:boinc_password@localhost/boinc_database |
| 85 | 85 | </pre></p>'; |
| 86 | - $ready_for_migration = 0; |
|
| 87 | - $form['boinc_data']['#collapsed'] = FALSE; |
|
| 88 | - $form['boinc_data']['db_connect_string_note'] = array('#value' => $output); |
|
| 86 | + $ready_for_migration = 0; |
|
| 87 | + $form['boinc_data']['#collapsed'] = FALSE; |
|
| 88 | + $form['boinc_data']['db_connect_string_note'] = array('#value' => $output); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | $form['boinc_data']['boincimport_db_url'] = array( |
| 92 | - '#type' => 'textfield', |
|
| 93 | - '#title' => t('BOINC database location'), |
|
| 94 | - '#default_value' => variable_get('boincimport_db_url', $default_db_url), |
|
| 95 | - '#size' => 80, |
|
| 96 | - '#maxlength' => 255, |
|
| 97 | - '#description' => '', |
|
| 92 | + '#type' => 'textfield', |
|
| 93 | + '#title' => t('BOINC database location'), |
|
| 94 | + '#default_value' => variable_get('boincimport_db_url', $default_db_url), |
|
| 95 | + '#size' => 80, |
|
| 96 | + '#maxlength' => 255, |
|
| 97 | + '#description' => '', |
|
| 98 | 98 | ); |
| 99 | - } |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - $output = '<p>' . t('Note that due to a limitation within Drupal core, we cannot |
|
| 101 | + $output = '<p>' . t('Note that due to a limitation within Drupal core, we cannot |
|
| 102 | 102 | import messages from one database type to another database type. E.g, we |
| 103 | 103 | cannot import BOINC from a myqsl DB, to a postgresql DB. You need to import |
| 104 | 104 | the data into the same type of database first (import all the BOINC data, as is, |
| 105 | 105 | from mysql to postgresql).') . '</p><p>' . t('If both BOINC and Drupal are on |
| 106 | 106 | postgresql, see !this_issue.', array('!this_issue' => l(t('this issue'), |
| 107 | 107 | 'http://drupal.org/node/64877', array('attributes' => array('target' => '_blank'))))) . '</p>'; |
| 108 | - $form['boinc_data']['note'] = array('#value' => $output); |
|
| 108 | + $form['boinc_data']['note'] = array('#value' => $output); |
|
| 109 | 109 | |
| 110 | - // BOINC table prefix |
|
| 111 | - $form['boinc_data']['boincimport_table_prefix'] = array( |
|
| 110 | + // BOINC table prefix |
|
| 111 | + $form['boinc_data']['boincimport_table_prefix'] = array( |
|
| 112 | 112 | '#type' => 'textfield', |
| 113 | 113 | '#title' => t('BOINC table prefix'), |
| 114 | 114 | '#default_value' => variable_get('boincimport_table_prefix', ''), |
@@ -116,30 +116,30 @@ discard block |
||
| 116 | 116 | '#maxlength' => 255, |
| 117 | 117 | '#description' => t('What prefix is used for your BOINC tables?'), |
| 118 | 118 | '#disabled' => ($result['result']) ? TRUE : FALSE |
| 119 | - ); |
|
| 119 | + ); |
|
| 120 | 120 | |
| 121 | - $output = $result['html']; |
|
| 122 | - if ($result['result'] != 1) { |
|
| 121 | + $output = $result['html']; |
|
| 122 | + if ($result['result'] != 1) { |
|
| 123 | 123 | $ready_for_migration = 0; |
| 124 | 124 | $form['boinc_data']['#collapsed']= FALSE; |
| 125 | 125 | $output .= '<span class="marker">'; |
| 126 | 126 | $output .= t('Some tables couldn\'t be found. Are the database settings correct? |
| 127 | 127 | Please correct the errors so that the BOINC tables can be accessed.'); |
| 128 | 128 | $output .= '</span>'; |
| 129 | - } |
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | - $form['boinc_data']['result'] = array('#value' => $output); |
|
| 131 | + $form['boinc_data']['result'] = array('#value' => $output); |
|
| 132 | 132 | |
| 133 | - // USERS settings |
|
| 134 | - $form['users'] = array( |
|
| 133 | + // USERS settings |
|
| 134 | + $form['users'] = array( |
|
| 135 | 135 | '#type' => 'fieldset', |
| 136 | 136 | '#title' => t('User import'), |
| 137 | 137 | '#collapsible' => TRUE, |
| 138 | 138 | '#collapsed' => TRUE, |
| 139 | - ); |
|
| 139 | + ); |
|
| 140 | 140 | |
| 141 | - // User import batch size |
|
| 142 | - $form['users']['boincimport_user_batch_size'] = array( |
|
| 141 | + // User import batch size |
|
| 142 | + $form['users']['boincimport_user_batch_size'] = array( |
|
| 143 | 143 | '#type' => 'textfield', |
| 144 | 144 | '#title' => t('Number of accounts to process at a time'), |
| 145 | 145 | '#default_value' => variable_get('boincimport_user_batch_size', 50), |
@@ -148,10 +148,10 @@ discard block |
||
| 148 | 148 | '#description' => t('Due to memory intensive API calls, this value may have to |
| 149 | 149 | be adjusted to avoid exhausting system resources. The default value is a |
| 150 | 150 | balance between performance and reliability.') |
| 151 | - ); |
|
| 151 | + ); |
|
| 152 | 152 | |
| 153 | - // Import users who have never posted? |
|
| 154 | - $form['users']['boincimport_import_lurkers'] = array( |
|
| 153 | + // Import users who have never posted? |
|
| 154 | + $form['users']['boincimport_import_lurkers'] = array( |
|
| 155 | 155 | '#type' => 'checkbox', |
| 156 | 156 | '#title' => t('Import users who have never posted?'), |
| 157 | 157 | '#return_value' => 1, |
@@ -160,199 +160,199 @@ discard block |
||
| 160 | 160 | involvement? This may not be desired, as it can take a very long time to |
| 161 | 161 | import tens or hundreds of thousands of accounts. (note that users who |
| 162 | 162 | are not imported now will still be imported on-the-fly upon login)'), |
| 163 | - ); |
|
| 163 | + ); |
|
| 164 | 164 | |
| 165 | - // Input format settings |
|
| 166 | - $form['input'] = array( |
|
| 165 | + // Input format settings |
|
| 166 | + $form['input'] = array( |
|
| 167 | 167 | '#type' => 'fieldset', |
| 168 | 168 | '#title' => t('Input format settings'), |
| 169 | 169 | '#collapsible' => TRUE, |
| 170 | 170 | '#collapsed' => TRUE |
| 171 | - ); |
|
| 172 | - $output = '<p>'. t('Select which !input_format should be used for the imported |
|
| 171 | + ); |
|
| 172 | + $output = '<p>'. t('Select which !input_format should be used for the imported |
|
| 173 | 173 | messages. It is highly-recommended that this value be left as it is, as the |
| 174 | 174 | Full HTML and PHP code formats can be very dangerous!', |
| 175 | 175 | array('!input_format' => l(t('input format'), 'admin/settings/filters'))) .'</p>'; |
| 176 | - $form['input']['intro'] = array('#value' => $output); |
|
| 176 | + $form['input']['intro'] = array('#value' => $output); |
|
| 177 | 177 | |
| 178 | - $formats = db_query('SELECT format, name FROM {filter_formats}'); |
|
| 179 | - while ($format = db_fetch_array($formats)) { |
|
| 178 | + $formats = db_query('SELECT format, name FROM {filter_formats}'); |
|
| 179 | + while ($format = db_fetch_array($formats)) { |
|
| 180 | 180 | $input_formats[$format['format']]= $format['name']; |
| 181 | - } |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | - // By default, use the format named "Rich text"; fall back to Filtered HTML |
|
| 184 | - $default_input_format = db_result(db_query(" |
|
| 183 | + // By default, use the format named "Rich text"; fall back to Filtered HTML |
|
| 184 | + $default_input_format = db_result(db_query(" |
|
| 185 | 185 | SELECT format FROM {filter_formats} WHERE name = '%s'", 'Rich text')); |
| 186 | - if (!$default_input_format) $default_input_format = 1; |
|
| 186 | + if (!$default_input_format) $default_input_format = 1; |
|
| 187 | 187 | |
| 188 | - $input_format = variable_get('boincimport_input_format', $default_input_format); |
|
| 189 | - $form['input']['boincimport_input_format'] = array( |
|
| 188 | + $input_format = variable_get('boincimport_input_format', $default_input_format); |
|
| 189 | + $form['input']['boincimport_input_format'] = array( |
|
| 190 | 190 | '#type' => 'radios', |
| 191 | 191 | '#title' => t('Input format'), |
| 192 | 192 | '#default_value' => $input_format, |
| 193 | 193 | '#options' => $input_formats |
| 194 | - ); |
|
| 195 | - if (!$input_format) { |
|
| 194 | + ); |
|
| 195 | + if (!$input_format) { |
|
| 196 | 196 | $ready_for_migration = 0; |
| 197 | 197 | $form['input']['#collapsed']= FALSE; |
| 198 | - } |
|
| 199 | - $output = '<p><em>'. t('This setting will be applied to all posts and private |
|
| 198 | + } |
|
| 199 | + $output = '<p><em>'. t('This setting will be applied to all posts and private |
|
| 200 | 200 | messages.') .'</em></p>'; |
| 201 | - $form['input']['result'] = array('#value' => $output); |
|
| 201 | + $form['input']['result'] = array('#value' => $output); |
|
| 202 | 202 | |
| 203 | - // BBcode settings |
|
| 204 | - $form['bbcode'] = array( |
|
| 203 | + // BBcode settings |
|
| 204 | + $form['bbcode'] = array( |
|
| 205 | 205 | '#type' => 'fieldset', |
| 206 | 206 | '#title' => t('BBcode settings'), |
| 207 | 207 | '#collapsible' => TRUE, |
| 208 | 208 | '#collapsed' => TRUE, |
| 209 | - ); |
|
| 209 | + ); |
|
| 210 | 210 | |
| 211 | - $output = '<p>' . t('BOINC posts are often formatted in BBcode. During the |
|
| 211 | + $output = '<p>' . t('BOINC posts are often formatted in BBcode. During the |
|
| 212 | 212 | import process, BBcode can be handled in two diffent ways') . ':</p>'; |
| 213 | - $output .= '<ul><li>' . t('Leave the BBcode as is and use the !bbcode_module |
|
| 213 | + $output .= '<ul><li>' . t('Leave the BBcode as is and use the !bbcode_module |
|
| 214 | 214 | after the migration to filter the imported posts. In this case, the module |
| 215 | 215 | is not required during the migration, but will need to be installed and |
| 216 | 216 | configured later.', |
| 217 | 217 | array('!bbcode_module' => l(t('bbcode module'), 'http://drupal.org/project/bbcode', |
| 218 | 218 | array('attributes' => array('target' => '_blank'))))) . '</li>'; |
| 219 | - $output .= '<li>' . t('Filter the BBcode now and replace it with plain HTML. |
|
| 219 | + $output .= '<li>' . t('Filter the BBcode now and replace it with plain HTML. |
|
| 220 | 220 | The BBcode module will be required during the migration process, but can |
| 221 | 221 | be disabled afterwards.') . '</li></ul>'; |
| 222 | - $output .= '<p>' . t('An appropriate input filter should be chosen, as well, |
|
| 222 | + $output .= '<p>' . t('An appropriate input filter should be chosen, as well, |
|
| 223 | 223 | as it will affect how the post is displayed. For example, if BBcode is |
| 224 | 224 | removed and replaced by HTML, some HTML tags will be stripped by the |
| 225 | 225 | "Filtered HTML" input format unless they are first added to the list of |
| 226 | 226 | allowed tags in that format. See the !input_formats page.', |
| 227 | 227 | array('!input_formats' => l(t('input formats'), 'admin/settings/filters'))) . '</p>'; |
| 228 | 228 | |
| 229 | - $form['bbcode']['intro'] = array('#value' => $output); |
|
| 230 | - $form['bbcode']['boincimport_bbcode'] = array( |
|
| 229 | + $form['bbcode']['intro'] = array('#value' => $output); |
|
| 230 | + $form['bbcode']['boincimport_bbcode'] = array( |
|
| 231 | 231 | '#type' => 'radios', |
| 232 | 232 | '#title' => t('BBcode handling'), |
| 233 | 233 | '#default_value' => variable_get('boincimport_bbcode', 0), |
| 234 | 234 | '#options' => array(t('Leave BBcode as is.'), t('Transform BBcode into HTML.')), |
| 235 | 235 | '#description' => '', |
| 236 | - ); |
|
| 236 | + ); |
|
| 237 | 237 | |
| 238 | - $module_status = _boincimport_check_module('bbcode'); |
|
| 239 | - $bbcode_disabled = ($module_status['result'] == 0) ? true : false; |
|
| 240 | - $output = $module_status['html']; |
|
| 238 | + $module_status = _boincimport_check_module('bbcode'); |
|
| 239 | + $bbcode_disabled = ($module_status['result'] == 0) ? true : false; |
|
| 240 | + $output = $module_status['html']; |
|
| 241 | 241 | |
| 242 | - if (variable_get('boincimport_bbcode', 0)) { |
|
| 242 | + if (variable_get('boincimport_bbcode', 0)) { |
|
| 243 | 243 | if ($bbcode_disabled) { |
| 244 | - $ready_for_migration = 0; |
|
| 245 | - $form['bbcode']['#collapsed'] = FALSE; |
|
| 246 | - $output .= '<p><span class="marker">'; |
|
| 247 | - $output .= t('The !bbcode_module is required to transform BBcode into HTML. |
|
| 244 | + $ready_for_migration = 0; |
|
| 245 | + $form['bbcode']['#collapsed'] = FALSE; |
|
| 246 | + $output .= '<p><span class="marker">'; |
|
| 247 | + $output .= t('The !bbcode_module is required to transform BBcode into HTML. |
|
| 248 | 248 | You first need to !enable_bbcode', array( |
| 249 | - '!bbcode_module' => l(t('bbcode module'), 'http://drupal.org/project/bbcode', array('attributes' => array('target' => '_blank'))), |
|
| 250 | - '!enable_bbcode' => l(t('enable the bbcode module'), 'admin/build/modules'))); |
|
| 251 | - $output .= '</span></p>'; |
|
| 249 | + '!bbcode_module' => l(t('bbcode module'), 'http://drupal.org/project/bbcode', array('attributes' => array('target' => '_blank'))), |
|
| 250 | + '!enable_bbcode' => l(t('enable the bbcode module'), 'admin/build/modules'))); |
|
| 251 | + $output .= '</span></p>'; |
|
| 252 | 252 | } |
| 253 | 253 | $sql = "SELECT COUNT(*) FROM {filters} WHERE module = 'bbcode' AND format = %d"; |
| 254 | 254 | $result = db_query($sql, $input_format); |
| 255 | 255 | if (!db_result($result)) { |
| 256 | - $form['bbcode']['#collapsed'] = FALSE; |
|
| 257 | - $output .= '<p class="marker">'. t('You need to !enable_bbcode_input and |
|
| 256 | + $form['bbcode']['#collapsed'] = FALSE; |
|
| 257 | + $output .= '<p class="marker">'. t('You need to !enable_bbcode_input and |
|
| 258 | 258 | then !configure_bbcode_options', array( |
| 259 | - '!enable_bbcode_input' => l(t('enable BBcode in the selected input format'), "admin/settings/filters/{$input_format}"), |
|
| 260 | - '!configure_bbcode_options' => l(t('configure BBcode options'), "admin/settings/filters/{$input_format}/configure"))) .'</p>'; |
|
| 259 | + '!enable_bbcode_input' => l(t('enable BBcode in the selected input format'), "admin/settings/filters/{$input_format}"), |
|
| 260 | + '!configure_bbcode_options' => l(t('configure BBcode options'), "admin/settings/filters/{$input_format}/configure"))) .'</p>'; |
|
| 261 | 261 | } |
| 262 | 262 | $output .= '<p>'. t('For best results, !disable_all_options', |
| 263 | 263 | array('!disable_all_options' => l(t('all four BBcode configure options should be disabled'), "admin/settings/filters/{$input_format}/configure"))) . '.</p>'; |
| 264 | - } else { |
|
| 264 | + } else { |
|
| 265 | 265 | if ($bbcode_disabled) { |
| 266 | - $form['bbcode']['#collapsed'] = FALSE; |
|
| 267 | - $output .= '<p>'. t('The !bbcode_module is recommended, but not required. |
|
| 266 | + $form['bbcode']['#collapsed'] = FALSE; |
|
| 267 | + $output .= '<p>'. t('The !bbcode_module is recommended, but not required. |
|
| 268 | 268 | You may !enable_bbcode after having installed it.', array( |
| 269 | - '!bbcode_module' => l(t('bbcode module'), 'http://drupal.org/project/bbcode', array('attributes' => array('target' => '_blank'))), |
|
| 270 | - '!enable_bbcode' => l(t('enable the bbcode module'), 'admin/build/modules'))) .'</p>'; |
|
| 269 | + '!bbcode_module' => l(t('bbcode module'), 'http://drupal.org/project/bbcode', array('attributes' => array('target' => '_blank'))), |
|
| 270 | + '!enable_bbcode' => l(t('enable the bbcode module'), 'admin/build/modules'))) .'</p>'; |
|
| 271 | 271 | } |
| 272 | 272 | $output .= '<p>' . t('Don\'t forget to !enable_bbcode_input and then !configure_bbcode_options.', array( |
| 273 | - '!enable_bbcode_input' => l(t('enable BBcode in the selected input format'), "admin/settings/filters/{$input_format}"), |
|
| 274 | - '!configure_bbcode_options' => l(t('configure BBcode options'), "admin/settings/filters/{$input_format}/configure"))) . '</p>'; |
|
| 273 | + '!enable_bbcode_input' => l(t('enable BBcode in the selected input format'), "admin/settings/filters/{$input_format}"), |
|
| 274 | + '!configure_bbcode_options' => l(t('configure BBcode options'), "admin/settings/filters/{$input_format}/configure"))) . '</p>'; |
|
| 275 | 275 | $output .= '<p>' . t('You may want to enable it for other input formats, too.') . '</p>'; |
| 276 | - } |
|
| 277 | - $output .= '<p><em>'. t('This setting will be applied to all posts, private |
|
| 276 | + } |
|
| 277 | + $output .= '<p><em>'. t('This setting will be applied to all posts, private |
|
| 278 | 278 | messages and the users\' signature.') .'</em></p>'; |
| 279 | 279 | |
| 280 | - $form['bbcode']['result'] = array('#value' => $output); |
|
| 280 | + $form['bbcode']['result'] = array('#value' => $output); |
|
| 281 | 281 | |
| 282 | - // URL transform settings |
|
| 283 | - $form['url_transforms'] = array( |
|
| 282 | + // URL transform settings |
|
| 283 | + $form['url_transforms'] = array( |
|
| 284 | 284 | '#type' => 'fieldset', |
| 285 | 285 | '#title' => t('URL transforms'), |
| 286 | 286 | '#collapsible' => TRUE, |
| 287 | 287 | '#collapsed' => TRUE, |
| 288 | - ); |
|
| 289 | - if (!variable_get('boincimport_base_url_boinc', 0)) { |
|
| 288 | + ); |
|
| 289 | + if (!variable_get('boincimport_base_url_boinc', 0)) { |
|
| 290 | 290 | $form['url_transforms']['#collapsed']= FALSE; |
| 291 | 291 | $output = '<span class="marker">'; |
| 292 | 292 | $ready_for_migration = 0; |
| 293 | - } |
|
| 293 | + } |
|
| 294 | 294 | |
| 295 | - // List of BOINC domains possible in URLs to transform |
|
| 296 | - $form['url_transforms']['boincimport_base_url_boinc'] = array( |
|
| 295 | + // List of BOINC domains possible in URLs to transform |
|
| 296 | + $form['url_transforms']['boincimport_base_url_boinc'] = array( |
|
| 297 | 297 | '#type' => 'textarea', |
| 298 | 298 | '#title' => t('BOINC base URLs to transform'), |
| 299 | 299 | '#default_value' => variable_get('boincimport_base_url_boinc', ''), |
| 300 | 300 | '#description' => t('List URL bases that should be transformed from |
| 301 | 301 | BOINC format to Drupal format (enter one domain per line, including http://).'), |
| 302 | - ); |
|
| 302 | + ); |
|
| 303 | 303 | |
| 304 | - // The Drupal domain to use in URL transform results |
|
| 305 | - $form['url_transforms']['boincimport_base_url_drupal'] = array( |
|
| 304 | + // The Drupal domain to use in URL transform results |
|
| 305 | + $form['url_transforms']['boincimport_base_url_drupal'] = array( |
|
| 306 | 306 | '#type' => 'textfield', |
| 307 | 307 | '#title' => t('Target Drupal base URL'), |
| 308 | 308 | '#default_value' => variable_get('boincimport_base_url_drupal', ''), |
| 309 | 309 | '#description' => t('Specify the URL base to use in transform results. If |
| 310 | 310 | left blank, the base_url configured in this Drupal environment will be |
| 311 | 311 | used (currently: %url)', array('%url' =>$base_url)), |
| 312 | - ); |
|
| 312 | + ); |
|
| 313 | 313 | |
| 314 | - // Are we ready for migration? |
|
| 315 | - $form['migration'] = array( |
|
| 314 | + // Are we ready for migration? |
|
| 315 | + $form['migration'] = array( |
|
| 316 | 316 | '#type' => 'fieldset', |
| 317 | 317 | '#title' => 'Migration', |
| 318 | 318 | '#collapsible' => TRUE, |
| 319 | 319 | '#collapsed' => FALSE, |
| 320 | - ); |
|
| 321 | - variable_set('boincimport_ready', $ready_for_migration); |
|
| 322 | - if ($ready_for_migration) { |
|
| 320 | + ); |
|
| 321 | + variable_set('boincimport_ready', $ready_for_migration); |
|
| 322 | + if ($ready_for_migration) { |
|
| 323 | 323 | $output = '<p>'. t('Check the settings above one more time. If everything |
| 324 | 324 | is ok, !proceed.', array('!proceed' => l(t('you can now proceed with the migration'), 'admin/boinc/import/process'))) .'</p>'; |
| 325 | - } else { |
|
| 325 | + } else { |
|
| 326 | 326 | $output = '<p class="marker">'. t('You are not ready for the migration yet. |
| 327 | 327 | Please check the settings above.') .'</p>'; |
| 328 | - } |
|
| 328 | + } |
|
| 329 | 329 | |
| 330 | - $form['migration']['info'] = array('#value' => $output); |
|
| 331 | - return system_settings_form($form); |
|
| 330 | + $form['migration']['info'] = array('#value' => $output); |
|
| 331 | + return system_settings_form($form); |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | /** |
| 335 | 335 | * Callback admin/boinc/import/post_configuration |
| 336 | 336 | */ |
| 337 | 337 | function boincimport_post_configuration() { |
| 338 | - $output = '<p>'. t('This page will help to tie up any loose ends following |
|
| 338 | + $output = '<p>'. t('This page will help to tie up any loose ends following |
|
| 339 | 339 | the BOINC data import process. Before continuing, it may be best to have |
| 340 | 340 | already:') .'</p>'; |
| 341 | - $output .= '<ul>'; |
|
| 342 | - $output .= '<li>'. t('Imported users, teams, and forums using the BOINC |
|
| 341 | + $output .= '<ul>'; |
|
| 342 | + $output .= '<li>'. t('Imported users, teams, and forums using the BOINC |
|
| 343 | 343 | import module') .'</li>'; |
| 344 | - $output .= '<li>'. t('Imported any additional data using add on modules if |
|
| 344 | + $output .= '<li>'. t('Imported any additional data using add on modules if |
|
| 345 | 345 | available.') .'</li>'; |
| 346 | - $output .= '</ul>'; |
|
| 347 | - //User Set up |
|
| 348 | - $output .= '<h2>'. t('User settings') .'</h2>'; |
|
| 349 | - $output .= '<p>'. t('Make sure your !user_settings are correct. Specifically, |
|
| 346 | + $output .= '</ul>'; |
|
| 347 | + //User Set up |
|
| 348 | + $output .= '<h2>'. t('User settings') .'</h2>'; |
|
| 349 | + $output .= '<p>'. t('Make sure your !user_settings are correct. Specifically, |
|
| 350 | 350 | you can enable or disable signatures there. ', array( |
| 351 | - '!user_settings' => l(t('user settings'), 'admin/user/settings') |
|
| 351 | + '!user_settings' => l(t('user settings'), 'admin/user/settings') |
|
| 352 | 352 | )) .'</p>'; |
| 353 | - $output .= '<p>' . t('Note that avatar/picture support is not tied to user |
|
| 353 | + $output .= '<p>' . t('Note that avatar/picture support is not tied to user |
|
| 354 | 354 | settings Picture support at this time.') . '</p>'; |
| 355 | - /*$output .= '<p>' . t('In order to activate avatar/picture support, you need to |
|
| 355 | + /*$output .= '<p>' . t('In order to activate avatar/picture support, you need to |
|
| 356 | 356 | enable pictures on this page and also:') . '</p>'; |
| 357 | 357 | $output .= '<ul>'; |
| 358 | 358 | $output .= '<li>'. t('Tick the checkboxes to allow "User pictures in posts" and/or |
@@ -365,73 +365,73 @@ discard block |
||
| 365 | 365 | )) .'</li>'; |
| 366 | 366 | $output .= '</ul>'; */ |
| 367 | 367 | |
| 368 | - // Forum Set up |
|
| 369 | - $output .= '<h2>'. t('Forum settings') .'</h2>'; |
|
| 370 | - $output .= '<p>'. t('Check any additional changes to make on the |
|
| 368 | + // Forum Set up |
|
| 369 | + $output .= '<h2>'. t('Forum settings') .'</h2>'; |
|
| 370 | + $output .= '<p>'. t('Check any additional changes to make on the |
|
| 371 | 371 | !forum_settings page.', array( |
| 372 | - '!forum_settings' => l(t('forum settings'), 'admin/content/forum/settings') |
|
| 372 | + '!forum_settings' => l(t('forum settings'), 'admin/content/forum/settings') |
|
| 373 | 373 | )) .'</p>'; |
| 374 | - $output .= '<p>'. t('It also may be a good idea to look at the !forum_list to |
|
| 374 | + $output .= '<p>'. t('It also may be a good idea to look at the !forum_list to |
|
| 375 | 375 | verify that all necessary containers and forums are in place.', array( |
| 376 | - '!forum_list' => l(t('forum list'), 'admin/content/forum') |
|
| 376 | + '!forum_list' => l(t('forum list'), 'admin/content/forum') |
|
| 377 | 377 | )) .'</p>'; |
| 378 | - /*$output .= '<p>'. t('If need be, set up the private forums as explained in the |
|
| 378 | + /*$output .= '<p>'. t('If need be, set up the private forums as explained in the |
|
| 379 | 379 | !documentation.', array( |
| 380 | 380 | '!documentation' => l(t('documentation'), 'http://drupal.org/node/58969', array('attributes' => array('target' => '_blank'))) |
| 381 | 381 | )) .'</p>'; |
| 382 | 382 | */ |
| 383 | - /* |
|
| 383 | + /* |
|
| 384 | 384 | // Redirection from old URLs: |
| 385 | 385 | $output .= '<h2>'. t('Redirection from BOINC forum URLs to new Drupal forum URLs') .'</h2>'; |
| 386 | 386 | $output .= '<p>'. t('Enable the boincforum_redirect.module. This way, users |
| 387 | 387 | accessing URLs from your old BOINC installation will be redirected to your new |
| 388 | 388 | Drupal forum.') .'</p>'; |
| 389 | 389 | */ |
| 390 | - // BBcode |
|
| 391 | - $bbcode = variable_get('boincimport_bbcode', 0); |
|
| 392 | - if ($bbcode) { |
|
| 390 | + // BBcode |
|
| 391 | + $bbcode = variable_get('boincimport_bbcode', 0); |
|
| 392 | + if ($bbcode) { |
|
| 393 | 393 | $output .= '<h2>'. t('Remove BBcode module') .'</h2>'; |
| 394 | 394 | $output .= '<p>'. t('The BBcode has been cleaned from the posts. You shouldn\'t |
| 395 | 395 | need the bbcode module anymore. You can disable it.') .'</p>'; |
| 396 | - } else { |
|
| 396 | + } else { |
|
| 397 | 397 | $output .= '<h2>'. t('Configure BBcode module') .'</h2>'; |
| 398 | 398 | $output .= '<p>'. t('Most likely, there are many BOINC forum postings |
| 399 | 399 | formatted in BBcode. It would be a good idea to verify that BBcode is |
| 400 | 400 | being formatted correctly in the imported posts. Have a look around |
| 401 | 401 | !the_forum.', array( |
| 402 | 402 | '!the_forum' => l(t('the forum'), 'community') |
| 403 | - )) . '</p>'; |
|
| 404 | - } |
|
| 403 | + )) . '</p>'; |
|
| 404 | + } |
|
| 405 | 405 | |
| 406 | - return $output; |
|
| 406 | + return $output; |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | /** |
| 410 | 410 | * Callback admin/boinc/import |
| 411 | 411 | */ |
| 412 | 412 | function boincimport_main() { |
| 413 | - // Start with a quick sanity check on the BOINC environment |
|
| 414 | - boinc_get_path(); |
|
| 415 | - // If that's ok, on with the show |
|
| 416 | - $output .= t('You may want to !check_documentation before starting.', array( |
|
| 413 | + // Start with a quick sanity check on the BOINC environment |
|
| 414 | + boinc_get_path(); |
|
| 415 | + // If that's ok, on with the show |
|
| 416 | + $output .= t('You may want to !check_documentation before starting.', array( |
|
| 417 | 417 | '!check_documentation' => l(t('check the documentation'), 'http://boinc.berkeley.edu/trac/wiki/InstallDrupal', array('attributes' =>array('target' => '_blank'))) |
| 418 | - )); |
|
| 419 | - $output = '<ol><li>'; |
|
| 420 | - $output .= l(t('Configure the migration'), 'admin/boinc/import/settings'); |
|
| 421 | - $output .= '</li>'; |
|
| 422 | - $output .= '<li>'; |
|
| 423 | - $output .= l(t('Execute the migration'), 'admin/boinc/import/process'); |
|
| 424 | - $output .= '</li>'; |
|
| 425 | - $output .= '<li>'; |
|
| 426 | - $output .= l(t('Post migration configuration'), 'admin/boinc/import/post_configuration'); |
|
| 427 | - $output .= '</li>'; |
|
| 428 | - $output .= '<li>'; |
|
| 429 | - $output .= t('!cleanup (Accessing this link will delete all the saved BOINC forum |
|
| 418 | + )); |
|
| 419 | + $output = '<ol><li>'; |
|
| 420 | + $output .= l(t('Configure the migration'), 'admin/boinc/import/settings'); |
|
| 421 | + $output .= '</li>'; |
|
| 422 | + $output .= '<li>'; |
|
| 423 | + $output .= l(t('Execute the migration'), 'admin/boinc/import/process'); |
|
| 424 | + $output .= '</li>'; |
|
| 425 | + $output .= '<li>'; |
|
| 426 | + $output .= l(t('Post migration configuration'), 'admin/boinc/import/post_configuration'); |
|
| 427 | + $output .= '</li>'; |
|
| 428 | + $output .= '<li>'; |
|
| 429 | + $output .= t('!cleanup (Accessing this link will delete all the saved BOINC forum |
|
| 430 | 430 | conversion settings: click only when you\'re done with all the above.)', array( |
| 431 | - '!cleanup' => l(t('Cleanup'), 'admin/boinc/import/cleanup') |
|
| 431 | + '!cleanup' => l(t('Cleanup'), 'admin/boinc/import/cleanup') |
|
| 432 | 432 | )); |
| 433 | - $output .= '</li>'; |
|
| 434 | - /*$output .= '<li>'; |
|
| 433 | + $output .= '</li>'; |
|
| 434 | + /*$output .= '<li>'; |
|
| 435 | 435 | $output .= t('Enable the boincforum_redirect module for seamless redirection |
| 436 | 436 | from the old forums to the new. This module requires !clean_urls to be active.', array( |
| 437 | 437 | '!clean_urls' => l(t('Clean URLs'), 'admin/settings/clean-urls') |
@@ -442,14 +442,14 @@ discard block |
||
| 442 | 442 | uninstall BOINC forum - This will delete tables necessary for redirection. You can, |
| 443 | 443 | however, deactivate the module safely.'); |
| 444 | 444 | $output .= '</li>';*/ |
| 445 | - $output .= '</ol>'; |
|
| 445 | + $output .= '</ol>'; |
|
| 446 | 446 | |
| 447 | - // process will die() if the link to the BOINC database is wrong: |
|
| 448 | - $output .= '<p>'. t('If the BOINC data is in another database, but you made a |
|
| 447 | + // process will die() if the link to the BOINC database is wrong: |
|
| 448 | + $output .= '<p>'. t('If the BOINC data is in another database, but you made a |
|
| 449 | 449 | mistake while setting up the data base url, you may be unable to access the |
| 450 | 450 | setting page due to some limitations of the core of Drupal. !reset_db_url.', array( |
| 451 | - '!reset_db_url' => l(t('Click here to reset the database url'), 'admin/boinc/import/reset') |
|
| 451 | + '!reset_db_url' => l(t('Click here to reset the database url'), 'admin/boinc/import/reset') |
|
| 452 | 452 | )) .'</p>'; |
| 453 | 453 | |
| 454 | - return $output; |
|
| 454 | + return $output; |
|
| 455 | 455 | } |
@@ -19,9 +19,9 @@ discard block |
||
| 19 | 19 | * Implementation of hook_menu() |
| 20 | 20 | */ |
| 21 | 21 | function boincimport_menu() { |
| 22 | - $items = array(); |
|
| 22 | + $items = array(); |
|
| 23 | 23 | |
| 24 | - $items['admin/boinc/import'] = array( |
|
| 24 | + $items['admin/boinc/import'] = array( |
|
| 25 | 25 | 'title' => 'Environment: Data import', |
| 26 | 26 | 'description' => 'Overview of the BOINC data import process.', |
| 27 | 27 | 'access callback' => 'user_access', |
@@ -29,8 +29,8 @@ discard block |
||
| 29 | 29 | 'page callback' => 'boincimport_main', |
| 30 | 30 | 'file' => 'boincimport.pages.inc', |
| 31 | 31 | 'type' => MENU_NORMAL_ITEM, |
| 32 | - ); |
|
| 33 | - $items['admin/boinc/import/post_configuration'] = array( |
|
| 32 | + ); |
|
| 33 | + $items['admin/boinc/import/post_configuration'] = array( |
|
| 34 | 34 | 'title' => 'Post-migration configuration', |
| 35 | 35 | 'description' => 'Tie up a few odds and ends in the system configuration |
| 36 | 36 | after data importation is complete.', |
@@ -39,44 +39,44 @@ discard block |
||
| 39 | 39 | 'page callback' => 'boincimport_post_configuration', |
| 40 | 40 | 'file' => 'boincimport.pages.inc', |
| 41 | 41 | 'type' => MENU_CALLBACK, |
| 42 | - ); |
|
| 43 | - $items['admin/boinc/import/cleanup'] = array( |
|
| 42 | + ); |
|
| 43 | + $items['admin/boinc/import/cleanup'] = array( |
|
| 44 | 44 | 'title' => 'Cleanup', |
| 45 | 45 | 'access callback' => 'user_access', |
| 46 | 46 | 'access arguments' => array('import boinc data'), |
| 47 | 47 | 'page callback' => 'boincimport_cleanup', |
| 48 | 48 | 'type' => MENU_CALLBACK, |
| 49 | - ); |
|
| 50 | - $items['admin/boinc/import/complete/%'] = array( |
|
| 49 | + ); |
|
| 50 | + $items['admin/boinc/import/complete/%'] = array( |
|
| 51 | 51 | 'title' => 'Complete', |
| 52 | 52 | 'access callback' => 'user_access', |
| 53 | 53 | 'access arguments' => array('import boinc data'), |
| 54 | 54 | 'page callback' => 'boincimport_complete', |
| 55 | 55 | 'page arguments' => array(4), |
| 56 | 56 | 'type' => MENU_CALLBACK, |
| 57 | - ); |
|
| 58 | - $items['admin/boinc/import/process'] = array( |
|
| 57 | + ); |
|
| 58 | + $items['admin/boinc/import/process'] = array( |
|
| 59 | 59 | 'title' => 'Execute migration', |
| 60 | 60 | 'access callback' => 'user_access', |
| 61 | 61 | 'access arguments' => array('import boinc data'), |
| 62 | 62 | 'page callback' => 'boincimport_process', |
| 63 | 63 | 'type' => MENU_CALLBACK, |
| 64 | - ); |
|
| 65 | - $items['admin/boinc/import/reset'] = array( |
|
| 64 | + ); |
|
| 65 | + $items['admin/boinc/import/reset'] = array( |
|
| 66 | 66 | 'title' => 'Reset BOINC database URL', |
| 67 | 67 | 'access callback' => 'user_access', |
| 68 | 68 | 'access arguments' => array('import boinc data'), |
| 69 | 69 | 'page callback' => 'boincimport_reset', |
| 70 | 70 | 'type' => MENU_CALLBACK, |
| 71 | - ); |
|
| 72 | - $items['admin/boinc/import/unlock'] = array( |
|
| 71 | + ); |
|
| 72 | + $items['admin/boinc/import/unlock'] = array( |
|
| 73 | 73 | 'title' => 'Unlock BOINC import process', |
| 74 | 74 | 'access callback' => 'user_access', |
| 75 | 75 | 'access arguments' => array('import boinc data'), |
| 76 | 76 | 'page callback' => 'boincimport_unlock', |
| 77 | 77 | 'type' => MENU_CALLBACK, |
| 78 | - ); |
|
| 79 | - $items['admin/boinc/import/settings'] = array( |
|
| 78 | + ); |
|
| 79 | + $items['admin/boinc/import/settings'] = array( |
|
| 80 | 80 | 'title' => 'BOINC data import settings', |
| 81 | 81 | 'description' => 'Configure the BOINC data import process in preparation |
| 82 | 82 | for pulling user accounts, teams, and forums into Drupal.', |
@@ -86,37 +86,37 @@ discard block |
||
| 86 | 86 | 'page arguments' => array('boincimport_admin_settings'), |
| 87 | 87 | 'file' => 'boincimport.pages.inc', |
| 88 | 88 | 'type' => MENU_CALLBACK, |
| 89 | - ); |
|
| 90 | - return $items; |
|
| 89 | + ); |
|
| 90 | + return $items; |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
| 94 | 94 | * Implementation of hook_perm() |
| 95 | 95 | */ |
| 96 | 96 | function boincimport_perm() { |
| 97 | - return array('import boinc data'); |
|
| 97 | + return array('import boinc data'); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
| 101 | 101 | * Callback admin/boinc/import/reset |
| 102 | 102 | */ |
| 103 | 103 | function boincimport_reset() { |
| 104 | - global $db_url; |
|
| 105 | - $boinc_db_url = (is_array($db_url)) ? (isset($db_url['boinc_rw']) ? $db_url['boinc_rw'] : $db_url['default']) : $db_url; |
|
| 106 | - variable_set('boincimport_db_url', $boinc_db_url); |
|
| 107 | - variable_set('boincimport_ready', 0); |
|
| 108 | - return '<p>'. t('The BOINC database URL has been reset. You may now <a href="@configlink">go back to the configuration page</a>.', |
|
| 109 | - array('@configlink' => url('admin/boinc/import/settings'))) .'</p>'; |
|
| 104 | + global $db_url; |
|
| 105 | + $boinc_db_url = (is_array($db_url)) ? (isset($db_url['boinc_rw']) ? $db_url['boinc_rw'] : $db_url['default']) : $db_url; |
|
| 106 | + variable_set('boincimport_db_url', $boinc_db_url); |
|
| 107 | + variable_set('boincimport_ready', 0); |
|
| 108 | + return '<p>'. t('The BOINC database URL has been reset. You may now <a href="@configlink">go back to the configuration page</a>.', |
|
| 109 | + array('@configlink' => url('admin/boinc/import/settings'))) .'</p>'; |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
| 113 | 113 | * Callback admin/boinc/import/unlock |
| 114 | 114 | */ |
| 115 | 115 | function boincimport_unlock() { |
| 116 | - variable_del('boincimport_process_locked'); |
|
| 117 | - return '<p>'. t('The BOINC data import process has been unlocked. You may |
|
| 116 | + variable_del('boincimport_process_locked'); |
|
| 117 | + return '<p>'. t('The BOINC data import process has been unlocked. You may |
|
| 118 | 118 | now !proceed_with_import.', array( |
| 119 | - '!proceed_with_import' => l(t('proceed with the import'), |
|
| 119 | + '!proceed_with_import' => l(t('proceed with the import'), |
|
| 120 | 120 | 'admin/boinc/import/process') |
| 121 | 121 | )) .'</p>'; |
| 122 | 122 | } |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | * Callback admin/boinc/import/cleanup |
| 126 | 126 | */ |
| 127 | 127 | function boincimport_cleanup() { |
| 128 | - return boincimport_process_cleanup() .'<p>'. t('Drupal database cleaned.') .'</p>'; |
|
| 128 | + return boincimport_process_cleanup() .'<p>'. t('Drupal database cleaned.') .'</p>'; |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -139,23 +139,23 @@ discard block |
||
| 139 | 139 | * want to test. Therefore, the test part of the code is not used, now. |
| 140 | 140 | */ |
| 141 | 141 | function _boincimport_db_connect($test= 0) { |
| 142 | - global $db_url; |
|
| 143 | - $db_ready = variable_get('boincimport_db_configured', 1); |
|
| 144 | - if (!$db_ready) { |
|
| 142 | + global $db_url; |
|
| 143 | + $db_ready = variable_get('boincimport_db_configured', 1); |
|
| 144 | + if (!$db_ready) { |
|
| 145 | 145 | if (is_array($db_url)) { |
| 146 | - $db_url2 = $db_url; |
|
| 146 | + $db_url2 = $db_url; |
|
| 147 | 147 | } else { |
| 148 | - $db_url2['default'] = $db_url; |
|
| 148 | + $db_url2['default'] = $db_url; |
|
| 149 | 149 | } |
| 150 | 150 | $db_url2['boinc_rw'] = variable_get('boincimport_db_url', $db_url); |
| 151 | 151 | $GLOBALS['db_url'] =& $db_url2; |
| 152 | 152 | if ($test) { |
| 153 | - if (!db_connect($db_url2['boinc_rw'])) { |
|
| 153 | + if (!db_connect($db_url2['boinc_rw'])) { |
|
| 154 | 154 | return 0; |
| 155 | - } |
|
| 155 | + } |
|
| 156 | 156 | } |
| 157 | - } |
|
| 158 | - return 1; |
|
| 157 | + } |
|
| 158 | + return 1; |
|
| 159 | 159 | |
| 160 | 160 | } |
| 161 | 161 | |
@@ -167,17 +167,17 @@ discard block |
||
| 167 | 167 | * $out['result'] = boolean. |
| 168 | 168 | */ |
| 169 | 169 | function _boincimport_check_module($module) { |
| 170 | - $out['html'] = '<ul>'; |
|
| 171 | - $result = module_exists($module); |
|
| 172 | - $out['result'] = $result; |
|
| 173 | - if ($result == 1) { |
|
| 170 | + $out['html'] = '<ul>'; |
|
| 171 | + $result = module_exists($module); |
|
| 172 | + $out['result'] = $result; |
|
| 173 | + if ($result == 1) { |
|
| 174 | 174 | $out['html'] .= '<li>'. t('Module %module is enabled. OK!', array('%module' => $module)) .'</li>'; |
| 175 | - } |
|
| 176 | - else { |
|
| 175 | + } |
|
| 176 | + else { |
|
| 177 | 177 | $out['html'] .= '<li><span class="marker">'. t('Module %module is disabled.', array('%module' => $module)) .'</span></li>'; |
| 178 | - } |
|
| 179 | - $out['html'] .= '</ul>'; |
|
| 180 | - return $out; |
|
| 178 | + } |
|
| 179 | + $out['html'] .= '</ul>'; |
|
| 180 | + return $out; |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | /** |
@@ -188,259 +188,259 @@ discard block |
||
| 188 | 188 | * $out['result'] = boolean. |
| 189 | 189 | */ |
| 190 | 190 | function _boincimport_check_tables($tables = array(), $db = 'default' , $prefix = 1) { |
| 191 | - _boincimport_db_connect(); |
|
| 191 | + _boincimport_db_connect(); |
|
| 192 | 192 | |
| 193 | - $out['html'] = '<ul>'; |
|
| 194 | - $out['result']= 1; |
|
| 195 | - foreach ($tables as $table) { |
|
| 193 | + $out['html'] = '<ul>'; |
|
| 194 | + $out['result']= 1; |
|
| 195 | + foreach ($tables as $table) { |
|
| 196 | 196 | if ($prefix) { |
| 197 | - $table = db_prefix_tables('{'. $table .'}'); |
|
| 197 | + $table = db_prefix_tables('{'. $table .'}'); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | db_set_active($db); |
| 201 | 201 | if ($GLOBALS['db_type'] == 'pgsql') { |
| 202 | - // adapt from db_table_exists in database.pgsql.inc |
|
| 203 | - $result = (bool) db_result(db_query("SELECT COUNT(*) FROM pg_class WHERE relname = '%s'", $table)); |
|
| 202 | + // adapt from db_table_exists in database.pgsql.inc |
|
| 203 | + $result = (bool) db_result(db_query("SELECT COUNT(*) FROM pg_class WHERE relname = '%s'", $table)); |
|
| 204 | 204 | } |
| 205 | 205 | else { |
| 206 | - // adapt from db_table_exists in database.mysql.inc |
|
| 207 | - $result = (bool) db_fetch_object(db_query("SHOW TABLES LIKE '%s'", $table)); |
|
| 206 | + // adapt from db_table_exists in database.mysql.inc |
|
| 207 | + $result = (bool) db_fetch_object(db_query("SHOW TABLES LIKE '%s'", $table)); |
|
| 208 | 208 | } |
| 209 | 209 | db_set_active('default'); |
| 210 | 210 | if ($result) { |
| 211 | - $out['html'] .= '<li>'. t('Table %table: OK!', array('%table' => $table)) .'</li>'; |
|
| 211 | + $out['html'] .= '<li>'. t('Table %table: OK!', array('%table' => $table)) .'</li>'; |
|
| 212 | 212 | } |
| 213 | 213 | else { |
| 214 | - $out['html'] .= '<li><span class="marker">'. t('Table <strong>%table</strong> does not exist!', array('%table' => $table)) .'</span></li>'; |
|
| 215 | - $out['result']= 0; |
|
| 214 | + $out['html'] .= '<li><span class="marker">'. t('Table <strong>%table</strong> does not exist!', array('%table' => $table)) .'</span></li>'; |
|
| 215 | + $out['result']= 0; |
|
| 216 | 216 | } |
| 217 | - } |
|
| 218 | - $out['html'] .= '</ul>'; |
|
| 219 | - return $out; |
|
| 217 | + } |
|
| 218 | + $out['html'] .= '</ul>'; |
|
| 219 | + return $out; |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | |
| 223 | 223 | |
| 224 | 224 | function boincimport_process() { |
| 225 | - // Start with a quick sanity check on the BOINC environment |
|
| 226 | - boinc_get_path(); |
|
| 225 | + // Start with a quick sanity check on the BOINC environment |
|
| 226 | + boinc_get_path(); |
|
| 227 | 227 | |
| 228 | - if (!variable_get('boincimport_ready', 0)) { |
|
| 228 | + if (!variable_get('boincimport_ready', 0)) { |
|
| 229 | 229 | return '<p>'. t('You cannot import the data now. Please <a href="@settings">complete the setup first</a>', array('@settings' => url('admin/boinc/import/settings'))) .'</p>'; |
| 230 | - } |
|
| 230 | + } |
|
| 231 | 231 | |
| 232 | - $output = 'BOINC import process form'; |
|
| 233 | - $output .= drupal_get_form('boincimport_process_form'); |
|
| 234 | - return $output; |
|
| 232 | + $output = 'BOINC import process form'; |
|
| 233 | + $output .= drupal_get_form('boincimport_process_form'); |
|
| 234 | + return $output; |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | function boincimport_process_form() { |
| 238 | - $form = array(); |
|
| 239 | - _boincimport_db_connect() ; |
|
| 240 | - // Causes problems with form api redirect |
|
| 241 | - //ini_set('display_errors', TRUE); |
|
| 238 | + $form = array(); |
|
| 239 | + _boincimport_db_connect() ; |
|
| 240 | + // Causes problems with form api redirect |
|
| 241 | + //ini_set('display_errors', TRUE); |
|
| 242 | 242 | |
| 243 | - // Adjust how long you want the script to run... |
|
| 244 | - if (!ini_get('safe_mode')) { |
|
| 243 | + // Adjust how long you want the script to run... |
|
| 244 | + if (!ini_get('safe_mode')) { |
|
| 245 | 245 | // This will always be set on PHP7, but not on PHP5 with safe mode |
| 246 | 246 | set_time_limit(variable_get('boincimport_time_limit', 0)); |
| 247 | - } |
|
| 247 | + } |
|
| 248 | 248 | |
| 249 | - // Check for a lock on the import process |
|
| 250 | - if (variable_get('boincimport_process_locked', 0)) { |
|
| 249 | + // Check for a lock on the import process |
|
| 250 | + if (variable_get('boincimport_process_locked', 0)) { |
|
| 251 | 251 | drupal_set_message(t('The import process is locked. If you are sure that |
| 252 | 252 | it is no longer running, you may !unlock_it', |
| 253 | - array('!unlock_it' => l(t('release the lock'), |
|
| 253 | + array('!unlock_it' => l(t('release the lock'), |
|
| 254 | 254 | 'admin/boinc/import/unlock') |
| 255 | - )), 'warning'); |
|
| 255 | + )), 'warning'); |
|
| 256 | 256 | watchdog('boincimport', 'The import process is locked. If you are sure that |
| 257 | 257 | it is no longer running, you may !unlock_it', |
| 258 | - array('!unlock_it' => l(t('release the lock'), |
|
| 258 | + array('!unlock_it' => l(t('release the lock'), |
|
| 259 | 259 | 'admin/boinc/import/unlock') |
| 260 | - ), WATCHDOG_WARNING); |
|
| 261 | - } |
|
| 262 | - else { |
|
| 260 | + ), WATCHDOG_WARNING); |
|
| 261 | + } |
|
| 262 | + else { |
|
| 263 | 263 | $boincimport_functions = array( |
| 264 | - 'users' => t('Import users'), |
|
| 265 | - 'teams' => t('Import teams'), |
|
| 266 | - 'friends' => t('Import friendships'), |
|
| 267 | - 'preferences' => t('Import user preferences'), |
|
| 268 | - 'private messages' => t('Import private messages'), |
|
| 269 | - 'categories' => t('Import forum containers'), |
|
| 270 | - 'topics' => t('Import topics'), |
|
| 271 | - 'posts' => t('Import posts'), |
|
| 272 | - 'team forums' => t('Import team forums'), |
|
| 273 | - 'team topics' => t('Import team topics'), |
|
| 274 | - 'team posts' => t('Import team posts'), |
|
| 275 | - 'url' => t('Transform URLs'), |
|
| 264 | + 'users' => t('Import users'), |
|
| 265 | + 'teams' => t('Import teams'), |
|
| 266 | + 'friends' => t('Import friendships'), |
|
| 267 | + 'preferences' => t('Import user preferences'), |
|
| 268 | + 'private messages' => t('Import private messages'), |
|
| 269 | + 'categories' => t('Import forum containers'), |
|
| 270 | + 'topics' => t('Import topics'), |
|
| 271 | + 'posts' => t('Import posts'), |
|
| 272 | + 'team forums' => t('Import team forums'), |
|
| 273 | + 'team topics' => t('Import team topics'), |
|
| 274 | + 'team posts' => t('Import team posts'), |
|
| 275 | + 'url' => t('Transform URLs'), |
|
| 276 | 276 | ); |
| 277 | 277 | |
| 278 | 278 | $form['import'] = array( |
| 279 | - '#type' => 'select', |
|
| 280 | - '#title' => t('Next import to perform'), |
|
| 281 | - '#default_value' => $_SESSION['boincimport_stage_selected'], |
|
| 282 | - '#options' => $boincimport_functions, |
|
| 279 | + '#type' => 'select', |
|
| 280 | + '#title' => t('Next import to perform'), |
|
| 281 | + '#default_value' => $_SESSION['boincimport_stage_selected'], |
|
| 282 | + '#options' => $boincimport_functions, |
|
| 283 | 283 | ); |
| 284 | 284 | $form[] = array( |
| 285 | - '#type' => 'submit', |
|
| 286 | - '#value' => t('Import'), |
|
| 285 | + '#type' => 'submit', |
|
| 286 | + '#value' => t('Import'), |
|
| 287 | 287 | ); |
| 288 | - } |
|
| 289 | - return $form; |
|
| 288 | + } |
|
| 289 | + return $form; |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | function boincimport_process_form_submit($form, $form_state) { |
| 293 | 293 | |
| 294 | - // Lock the import process |
|
| 295 | - if (!variable_get('boincimport_process_locked', 0)) { |
|
| 294 | + // Lock the import process |
|
| 295 | + if (!variable_get('boincimport_process_locked', 0)) { |
|
| 296 | 296 | variable_set('boincimport_process_locked', 1); |
| 297 | - } |
|
| 298 | - else { |
|
| 297 | + } |
|
| 298 | + else { |
|
| 299 | 299 | watchdog('boincimport', 'The import process is locked, but another process |
| 300 | 300 | is trying to access it...', array(), WATCHDOG_WARNING); |
| 301 | - } |
|
| 301 | + } |
|
| 302 | 302 | |
| 303 | - switch ($form_state['values']['import']) { |
|
| 303 | + switch ($form_state['values']['import']) { |
|
| 304 | 304 | case 'users': |
| 305 | 305 | boincimport_users(); |
| 306 | - break; |
|
| 306 | + break; |
|
| 307 | 307 | |
| 308 | 308 | case 'teams': |
| 309 | 309 | boincimport_teams(); |
| 310 | - if (!variable_get('boincimport_import_team_successful', 0)) { |
|
| 310 | + if (!variable_get('boincimport_import_team_successful', 0)) { |
|
| 311 | 311 | $_SESSION['boincimport_stage_selected'] = 'teams'; |
| 312 | - } |
|
| 313 | - else { |
|
| 312 | + } |
|
| 313 | + else { |
|
| 314 | 314 | $_SESSION['boincimport_stage_selected'] = 'friends'; |
| 315 | - } |
|
| 316 | - break; |
|
| 315 | + } |
|
| 316 | + break; |
|
| 317 | 317 | |
| 318 | 318 | case 'friends': |
| 319 | 319 | boincimport_friends(); |
| 320 | - if (!variable_get('boincimport_import_friend_successful', 0)) { |
|
| 320 | + if (!variable_get('boincimport_import_friend_successful', 0)) { |
|
| 321 | 321 | $_SESSION['boincimport_stage_selected'] = 'friends'; |
| 322 | - } |
|
| 323 | - else { |
|
| 322 | + } |
|
| 323 | + else { |
|
| 324 | 324 | $_SESSION['boincimport_stage_selected'] = 'preferences'; |
| 325 | - } |
|
| 326 | - break; |
|
| 325 | + } |
|
| 326 | + break; |
|
| 327 | 327 | |
| 328 | 328 | case 'preferences': |
| 329 | 329 | boincimport_preferences(); |
| 330 | - if (!variable_get('boincimport_import_preferences_successful', 0)) { |
|
| 330 | + if (!variable_get('boincimport_import_preferences_successful', 0)) { |
|
| 331 | 331 | $_SESSION['boincimport_stage_selected'] = 'preferences'; |
| 332 | - } |
|
| 333 | - else { |
|
| 332 | + } |
|
| 333 | + else { |
|
| 334 | 334 | $_SESSION['boincimport_stage_selected'] = 'private messages'; |
| 335 | - } |
|
| 336 | - break; |
|
| 335 | + } |
|
| 336 | + break; |
|
| 337 | 337 | |
| 338 | 338 | case 'private messages': |
| 339 | 339 | boincimport_private_msgs(); |
| 340 | - if (!variable_get('boincimport_import_private_msg_successful', 0)) { |
|
| 340 | + if (!variable_get('boincimport_import_private_msg_successful', 0)) { |
|
| 341 | 341 | $_SESSION['boincimport_stage_selected'] = 'private messages'; |
| 342 | - } |
|
| 343 | - else { |
|
| 342 | + } |
|
| 343 | + else { |
|
| 344 | 344 | $_SESSION['boincimport_stage_selected'] = 'categories'; |
| 345 | - } |
|
| 346 | - break; |
|
| 345 | + } |
|
| 346 | + break; |
|
| 347 | 347 | |
| 348 | 348 | case 'categories': |
| 349 | 349 | boincimport_forum_categories(); |
| 350 | - if (!variable_get('boincimport_import_category_successful', 0)) { |
|
| 350 | + if (!variable_get('boincimport_import_category_successful', 0)) { |
|
| 351 | 351 | $_SESSION['boincimport_stage_selected'] = 'categories'; |
| 352 | - } |
|
| 353 | - else { |
|
| 352 | + } |
|
| 353 | + else { |
|
| 354 | 354 | $_SESSION['boincimport_stage_selected'] = 'topics'; |
| 355 | - } |
|
| 356 | - break; |
|
| 355 | + } |
|
| 356 | + break; |
|
| 357 | 357 | |
| 358 | 358 | case 'topics': |
| 359 | 359 | boincimport_forum_topics(); |
| 360 | - if (!variable_get('boincimport_import_topic_successful', 0)) { |
|
| 360 | + if (!variable_get('boincimport_import_topic_successful', 0)) { |
|
| 361 | 361 | $_SESSION['boincimport_stage_selected'] = 'topics'; |
| 362 | - } |
|
| 363 | - else { |
|
| 362 | + } |
|
| 363 | + else { |
|
| 364 | 364 | $_SESSION['boincimport_stage_selected'] = 'posts'; |
| 365 | - } |
|
| 366 | - break; |
|
| 365 | + } |
|
| 366 | + break; |
|
| 367 | 367 | |
| 368 | 368 | case 'posts': |
| 369 | 369 | boincimport_forum_posts(); |
| 370 | - if (!variable_get('boincimport_import_post_successful', 0)) { |
|
| 370 | + if (!variable_get('boincimport_import_post_successful', 0)) { |
|
| 371 | 371 | $_SESSION['boincimport_stage_selected'] = 'posts'; |
| 372 | - } |
|
| 373 | - else { |
|
| 372 | + } |
|
| 373 | + else { |
|
| 374 | 374 | $_SESSION['boincimport_stage_selected'] = 'url'; |
| 375 | - } |
|
| 376 | - break; |
|
| 375 | + } |
|
| 376 | + break; |
|
| 377 | 377 | |
| 378 | 378 | case 'team forums': |
| 379 | 379 | boincimport_team_forums(); |
| 380 | - if (!variable_get('boincimport_team_forum_successful', 0)) { |
|
| 380 | + if (!variable_get('boincimport_team_forum_successful', 0)) { |
|
| 381 | 381 | $_SESSION['boincimport_stage_selected'] = 'team forums'; |
| 382 | - } |
|
| 383 | - else { |
|
| 382 | + } |
|
| 383 | + else { |
|
| 384 | 384 | $_SESSION['boincimport_stage_selected'] = 'team topics'; |
| 385 | - } |
|
| 386 | - break; |
|
| 385 | + } |
|
| 386 | + break; |
|
| 387 | 387 | |
| 388 | 388 | case 'team topics': |
| 389 | 389 | boincimport_team_forum_topics(); |
| 390 | - if (!variable_get('boincimport_team_topic_successful', 0)) { |
|
| 390 | + if (!variable_get('boincimport_team_topic_successful', 0)) { |
|
| 391 | 391 | $_SESSION['boincimport_stage_selected'] = 'team topics'; |
| 392 | - } |
|
| 393 | - else { |
|
| 392 | + } |
|
| 393 | + else { |
|
| 394 | 394 | $_SESSION['boincimport_stage_selected'] = 'team posts'; |
| 395 | - } |
|
| 396 | - break; |
|
| 395 | + } |
|
| 396 | + break; |
|
| 397 | 397 | |
| 398 | 398 | case 'team posts': |
| 399 | 399 | boincimport_team_forum_posts(); |
| 400 | - if (!variable_get('boincimport_team_post_successful', 0)) { |
|
| 400 | + if (!variable_get('boincimport_team_post_successful', 0)) { |
|
| 401 | 401 | $_SESSION['boincimport_stage_selected'] = 'team posts'; |
| 402 | - } |
|
| 403 | - else { |
|
| 402 | + } |
|
| 403 | + else { |
|
| 404 | 404 | $_SESSION['boincimport_stage_selected'] = 'url'; |
| 405 | - } |
|
| 406 | - break; |
|
| 405 | + } |
|
| 406 | + break; |
|
| 407 | 407 | |
| 408 | 408 | case 'url': |
| 409 | 409 | boincimport_replace_urls(); |
| 410 | - if (!variable_get('boincimport_replace_url_successful', 0)) { |
|
| 410 | + if (!variable_get('boincimport_replace_url_successful', 0)) { |
|
| 411 | 411 | $_SESSION['boincimport_stage_selected'] = 'url'; |
| 412 | - } |
|
| 413 | - else { |
|
| 412 | + } |
|
| 413 | + else { |
|
| 414 | 414 | drupal_set_message('Congratulations. Import Finished'); |
| 415 | 415 | drupal_set_message('Please visit the '. l('Post migration configuration', 'admin/boinc/import/post_configuration') .' page'); |
| 416 | 416 | watchdog('boincimport', 'Import process is complete', array(), WATCHDOG_INFO); |
| 417 | 417 | unset($_SESSION['boincimport_stage_selected']); |
| 418 | - } |
|
| 419 | - break; |
|
| 418 | + } |
|
| 419 | + break; |
|
| 420 | 420 | default: |
| 421 | 421 | $_SESSION['boincimport_stage_selected'] = 'users'; |
| 422 | - break; |
|
| 423 | - } |
|
| 422 | + break; |
|
| 423 | + } |
|
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | function boincimport_complete($section) { |
| 427 | - switch ($section) { |
|
| 428 | - case 'users': |
|
| 427 | + switch ($section) { |
|
| 428 | + case 'users': |
|
| 429 | 429 | // Set the user import successful flag in the variable table |
| 430 | 430 | variable_set('boincimport_import_user_successful', '1'); |
| 431 | 431 | $_SESSION['boincimport_stage_selected'] = 'teams'; |
| 432 | 432 | break; |
| 433 | - case 'teams': |
|
| 433 | + case 'teams': |
|
| 434 | 434 | |
| 435 | 435 | break; |
| 436 | 436 | |
| 437 | - default: |
|
| 437 | + default: |
|
| 438 | 438 | } |
| 439 | 439 | |
| 440 | - // Release the lock on the import process |
|
| 441 | - variable_del('boincimport_process_locked'); |
|
| 440 | + // Release the lock on the import process |
|
| 441 | + variable_del('boincimport_process_locked'); |
|
| 442 | 442 | |
| 443 | - drupal_goto('admin/boinc/import/process'); |
|
| 443 | + drupal_goto('admin/boinc/import/process'); |
|
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | |
@@ -452,26 +452,26 @@ discard block |
||
| 452 | 452 | * Import users (at least those required for further data import) |
| 453 | 453 | */ |
| 454 | 454 | function boincimport_users() { |
| 455 | - // Check whether the user table has been successfully imported already |
|
| 456 | - if (variable_get('boincimport_import_user_successful', 0)) { |
|
| 455 | + // Check whether the user table has been successfully imported already |
|
| 456 | + if (variable_get('boincimport_import_user_successful', 0)) { |
|
| 457 | 457 | drupal_set_message(t('Note: user import has already run successfully')); |
| 458 | 458 | watchdog( |
| 459 | - 'boincimport', 'Note: user import has already run successfully', |
|
| 460 | - array(), WATCHDOG_INFO |
|
| 459 | + 'boincimport', 'Note: user import has already run successfully', |
|
| 460 | + array(), WATCHDOG_INFO |
|
| 461 | 461 | ); |
| 462 | - } |
|
| 462 | + } |
|
| 463 | 463 | |
| 464 | - if (!variable_get('boincimport_import_user_started', 0)) { |
|
| 464 | + if (!variable_get('boincimport_import_user_started', 0)) { |
|
| 465 | 465 | // Could prepare database tables, if new fields are necessary, etc. |
| 466 | 466 | variable_set('boincimport_import_user_started', 1); |
| 467 | - } |
|
| 467 | + } |
|
| 468 | 468 | |
| 469 | - $pre = variable_get('boincimport_table_prefix', ''); |
|
| 470 | - $import_lurkers = variable_get('boincimport_import_lurkers', 1); |
|
| 469 | + $pre = variable_get('boincimport_table_prefix', ''); |
|
| 470 | + $import_lurkers = variable_get('boincimport_import_lurkers', 1); |
|
| 471 | 471 | |
| 472 | - // Determine which users need to be processed |
|
| 473 | - db_set_active('boinc_rw'); |
|
| 474 | - if ($import_lurkers) { |
|
| 472 | + // Determine which users need to be processed |
|
| 473 | + db_set_active('boinc_rw'); |
|
| 474 | + if ($import_lurkers) { |
|
| 475 | 475 | // Import all users, even those who have no community participation; other |
| 476 | 476 | // users will be imported when they first try to log into the drupal site |
| 477 | 477 | $boinc_accounts = db_query(' |
@@ -479,8 +479,8 @@ discard block |
||
| 479 | 479 | ORDER BY id ASC' |
| 480 | 480 | ); |
| 481 | 481 | $user_count = mysqli_num_rows($boinc_accounts); |
| 482 | - } |
|
| 483 | - else { |
|
| 482 | + } |
|
| 483 | + else { |
|
| 484 | 484 | // Need to import any user who is currently ignored in order to keep them |
| 485 | 485 | // ignored... not particularly clean (ignored users are stored in a string) |
| 486 | 486 | $ignored_user_list = array(0); |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | ORDER BY userid ASC" |
| 492 | 492 | ); |
| 493 | 493 | while ($ignoring_user = db_fetch_object($ignoring_users)) { |
| 494 | - $ignored_user_list = $ignored_user_list + array_fill_keys(explode('|', trim($ignoring_user->ignorelist, '|')), 1); |
|
| 494 | + $ignored_user_list = $ignored_user_list + array_fill_keys(explode('|', trim($ignoring_user->ignorelist, '|')), 1); |
|
| 495 | 495 | } |
| 496 | 496 | $ignored_user_list = array_keys($ignored_user_list); |
| 497 | 497 | // Get IDs for all users who will need to be imported now |
@@ -507,86 +507,86 @@ discard block |
||
| 507 | 507 | (SELECT DISTINCT userid FROM {private_messages}) UNION |
| 508 | 508 | (SELECT DISTINCT senderid FROM {private_messages}) |
| 509 | 509 | ) AS usersToImport", |
| 510 | - implode(',', $ignored_user_list) |
|
| 510 | + implode(',', $ignored_user_list) |
|
| 511 | 511 | ); |
| 512 | 512 | $user_count = mysqli_num_rows($boinc_accounts); |
| 513 | - } |
|
| 514 | - db_set_active('default'); |
|
| 513 | + } |
|
| 514 | + db_set_active('default'); |
|
| 515 | 515 | |
| 516 | - if (!$user_count) { |
|
| 516 | + if (!$user_count) { |
|
| 517 | 517 | drupal_set_message( |
| 518 | - t('There were no users found: Aborting script'), 'error' |
|
| 518 | + t('There were no users found: Aborting script'), 'error' |
|
| 519 | 519 | ); |
| 520 | 520 | watchdog('boincimport', |
| 521 | - 'There were no users found: Aborting script', array(), WATCHDOG_INFO |
|
| 521 | + 'There were no users found: Aborting script', array(), WATCHDOG_INFO |
|
| 522 | 522 | ); |
| 523 | 523 | // Release the lock on the import process |
| 524 | 524 | variable_del('boincimport_process_locked'); |
| 525 | 525 | return t('There were no users found: Aborting script.'); |
| 526 | - } |
|
| 526 | + } |
|
| 527 | 527 | |
| 528 | - watchdog('boincimport', |
|
| 528 | + watchdog('boincimport', |
|
| 529 | 529 | 'Found %user_count users: Beginning import', |
| 530 | 530 | array('%user_count' => $user_count), WATCHDOG_INFO |
| 531 | - ); |
|
| 532 | - |
|
| 533 | - // User import relies on Drupal and BOINC APIs to manage data being read |
|
| 534 | - // from one database and saved to the other. This approach keeps things |
|
| 535 | - // clean and simple, but since a sizable user base will wreak havoc on system |
|
| 536 | - // resources, the job is broken into batches here and each batch is processed |
|
| 537 | - // by a separate process. |
|
| 538 | - |
|
| 539 | - //$batch_size = variable_get('boincimport_user_batch_size', 50); |
|
| 540 | - //$batch_count = $user_count - ($user_count % $batch_size) + $batch_size; |
|
| 541 | - $operations = array(); |
|
| 542 | - $existing_users = array(); |
|
| 543 | - $duplicates = array(); |
|
| 544 | - |
|
| 545 | - // Get the list of users already in Drupal to be sure we're not importing |
|
| 546 | - // any twice |
|
| 547 | - $result = db_query(' |
|
| 531 | + ); |
|
| 532 | + |
|
| 533 | + // User import relies on Drupal and BOINC APIs to manage data being read |
|
| 534 | + // from one database and saved to the other. This approach keeps things |
|
| 535 | + // clean and simple, but since a sizable user base will wreak havoc on system |
|
| 536 | + // resources, the job is broken into batches here and each batch is processed |
|
| 537 | + // by a separate process. |
|
| 538 | + |
|
| 539 | + //$batch_size = variable_get('boincimport_user_batch_size', 50); |
|
| 540 | + //$batch_count = $user_count - ($user_count % $batch_size) + $batch_size; |
|
| 541 | + $operations = array(); |
|
| 542 | + $existing_users = array(); |
|
| 543 | + $duplicates = array(); |
|
| 544 | + |
|
| 545 | + // Get the list of users already in Drupal to be sure we're not importing |
|
| 546 | + // any twice |
|
| 547 | + $result = db_query(' |
|
| 548 | 548 | SELECT uid, boinc_id FROM {boincuser}' |
| 549 | - ); |
|
| 550 | - while ($row = db_fetch_object($result)) { |
|
| 549 | + ); |
|
| 550 | + while ($row = db_fetch_object($result)) { |
|
| 551 | 551 | $existing_users[$row->boinc_id] = $row->uid; |
| 552 | - } |
|
| 552 | + } |
|
| 553 | 553 | |
| 554 | - // Create batches to process |
|
| 555 | - while ($boinc_account = db_fetch_object($boinc_accounts)) { |
|
| 556 | - if (isset($existing_users[$boinc_account->id])) { |
|
| 557 | - // This user has already been imported |
|
| 558 | - $duplicates[] = $boinc_account->id; |
|
| 554 | + // Create batches to process |
|
| 555 | + while ($boinc_account = db_fetch_object($boinc_accounts)) { |
|
| 556 | + if (isset($existing_users[$boinc_account->id])) { |
|
| 557 | + // This user has already been imported |
|
| 558 | + $duplicates[] = $boinc_account->id; |
|
| 559 | 559 | } |
| 560 | 560 | else { |
| 561 | - $operations[] = array( |
|
| 561 | + $operations[] = array( |
|
| 562 | 562 | 'boincimport_users_op', array( |
| 563 | - $boinc_account->id |
|
| 563 | + $boinc_account->id |
|
| 564 | 564 | ) |
| 565 | - ); |
|
| 565 | + ); |
|
| 566 | + } |
|
| 566 | 567 | } |
| 567 | - } |
|
| 568 | 568 | |
| 569 | - if ($duplicates) { |
|
| 569 | + if ($duplicates) { |
|
| 570 | 570 | drupal_set_message(t( |
| 571 | - 'Skipped @count accounts that were already imported', |
|
| 572 | - array('@count' => count($duplicates)) |
|
| 571 | + 'Skipped @count accounts that were already imported', |
|
| 572 | + array('@count' => count($duplicates)) |
|
| 573 | 573 | )); |
| 574 | 574 | watchdog('boincimport', |
| 575 | - 'Skipped @count accounts that were already imported', |
|
| 576 | - array('@count' => count($duplicates)), WATCHDOG_INFO |
|
| 575 | + 'Skipped @count accounts that were already imported', |
|
| 576 | + array('@count' => count($duplicates)), WATCHDOG_INFO |
|
| 577 | 577 | ); |
| 578 | - } |
|
| 578 | + } |
|
| 579 | 579 | |
| 580 | - $batch = array( |
|
| 580 | + $batch = array( |
|
| 581 | 581 | 'operations' => $operations, |
| 582 | 582 | 'finished' => 'boincimport_users_finished', |
| 583 | 583 | 'title' => t('Importing users'), |
| 584 | 584 | 'init_message' => t('Beginning user import...'), |
| 585 | 585 | 'progress_message' => t('Processed @current out of @total users.'), |
| 586 | 586 | 'error_message' => t('User import has encountered an error.'), |
| 587 | - ); |
|
| 587 | + ); |
|
| 588 | 588 | |
| 589 | - batch_set($batch); |
|
| 589 | + batch_set($batch); |
|
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | /** |
@@ -594,81 +594,81 @@ discard block |
||
| 594 | 594 | */ |
| 595 | 595 | function boincimport_users_op($boinc_id, &$context) { |
| 596 | 596 | |
| 597 | - // Use the $context['sandbox'] to store information needed to track progress |
|
| 598 | - // between successive calls. |
|
| 599 | - if (!isset($context['sandbox']['progress'])) { |
|
| 597 | + // Use the $context['sandbox'] to store information needed to track progress |
|
| 598 | + // between successive calls. |
|
| 599 | + if (!isset($context['sandbox']['progress'])) { |
|
| 600 | 600 | $context['sandbox']['progress'] = 0; |
| 601 | 601 | $context['sandbox']['current_user'] = 0; |
| 602 | 602 | $context['sandbox']['max'] = 1; |
| 603 | - } |
|
| 603 | + } |
|
| 604 | 604 | |
| 605 | - // Note about batch size: When a batch is processed, the batch update engine |
|
| 606 | - // determines whether it should continue processing in the same request or |
|
| 607 | - // provide progress feedback to the user and wait for the next request. |
|
| 605 | + // Note about batch size: When a batch is processed, the batch update engine |
|
| 606 | + // determines whether it should continue processing in the same request or |
|
| 607 | + // provide progress feedback to the user and wait for the next request. |
|
| 608 | 608 | |
| 609 | - // Grab the BOINC user object and create a Drupal user from it |
|
| 610 | - $account = boincuser_register_make_drupal_user($boinc_id); |
|
| 611 | - $message = ''; |
|
| 612 | - if ($account) { |
|
| 609 | + // Grab the BOINC user object and create a Drupal user from it |
|
| 610 | + $account = boincuser_register_make_drupal_user($boinc_id); |
|
| 611 | + $message = ''; |
|
| 612 | + if ($account) { |
|
| 613 | 613 | // Store some result for post-processing in the finished callback. |
| 614 | 614 | $context['results']['success'][] = $boinc_id; |
| 615 | 615 | $message = "Successfully imported user {$boinc_id}"; |
| 616 | - } |
|
| 617 | - else { |
|
| 616 | + } |
|
| 617 | + else { |
|
| 618 | 618 | $context['results']['failure'][] = $boinc_id; |
| 619 | 619 | $message = "Failed to import user {$boinc_id}!"; |
| 620 | 620 | watchdog('boincimport', |
| 621 | - 'Failed to import user @id!', |
|
| 622 | - array('@id' => $boinc_id), WATCHDOG_WARNING |
|
| 621 | + 'Failed to import user @id!', |
|
| 622 | + array('@id' => $boinc_id), WATCHDOG_WARNING |
|
| 623 | 623 | ); |
| 624 | - } |
|
| 624 | + } |
|
| 625 | 625 | |
| 626 | - // Update our progress information. |
|
| 627 | - $context['sandbox']['progress']++; |
|
| 628 | - $context['sandbox']['current_user'] = $boinc_id; |
|
| 629 | - $context['message'] = $message; |
|
| 626 | + // Update our progress information. |
|
| 627 | + $context['sandbox']['progress']++; |
|
| 628 | + $context['sandbox']['current_user'] = $boinc_id; |
|
| 629 | + $context['message'] = $message; |
|
| 630 | 630 | |
| 631 | - // Update the progress for the batch engine |
|
| 632 | - if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 631 | + // Update the progress for the batch engine |
|
| 632 | + if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 633 | 633 | $context['finished'] = 1; |
| 634 | - } |
|
| 635 | - else { |
|
| 634 | + } |
|
| 635 | + else { |
|
| 636 | 636 | $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
| 637 | - } |
|
| 637 | + } |
|
| 638 | 638 | } |
| 639 | 639 | |
| 640 | 640 | /** |
| 641 | 641 | * Batch 'finished' callback |
| 642 | 642 | */ |
| 643 | 643 | function boincimport_users_finished($success, $results, $operations) { |
| 644 | - if ($success) { |
|
| 644 | + if ($success) { |
|
| 645 | 645 | // Let's count our successes |
| 646 | 646 | $total_imported = count($results['success']); |
| 647 | 647 | $total_failures = count($results['failure']); |
| 648 | 648 | $message = t( |
| 649 | - 'Successfully imported @count users (@fail_count failures)', |
|
| 650 | - array('@count' => $total_imported, '@fail_count' => $total_failures) |
|
| 649 | + 'Successfully imported @count users (@fail_count failures)', |
|
| 650 | + array('@count' => $total_imported, '@fail_count' => $total_failures) |
|
| 651 | 651 | ); |
| 652 | 652 | watchdog('boincimport', |
| 653 | - 'Successfully imported @count users (@fail_count failures).', |
|
| 654 | - array('@count' => $total_imported, '@fail_count' => $total_failures), |
|
| 655 | - WATCHDOG_INFO |
|
| 653 | + 'Successfully imported @count users (@fail_count failures).', |
|
| 654 | + array('@count' => $total_imported, '@fail_count' => $total_failures), |
|
| 655 | + WATCHDOG_INFO |
|
| 656 | 656 | ); |
| 657 | 657 | // Set the user import successful flag in the variable table |
| 658 | 658 | variable_set('boincimport_import_user_successful', '1'); |
| 659 | 659 | $_SESSION['boincimport_stage_selected'] = 'teams'; |
| 660 | - } |
|
| 661 | - else { |
|
| 660 | + } |
|
| 661 | + else { |
|
| 662 | 662 | // An error occurred. |
| 663 | 663 | // $operations contains the operations that remained unprocessed. |
| 664 | 664 | $error_operation = reset($operations); |
| 665 | 665 | $message = 'An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE); |
| 666 | - } |
|
| 667 | - drupal_set_message($message); |
|
| 666 | + } |
|
| 667 | + drupal_set_message($message); |
|
| 668 | 668 | |
| 669 | - // Release the lock on the import process |
|
| 670 | - variable_del('boincimport_process_locked'); |
|
| 671 | - drupal_goto('admin/boinc/import/process'); |
|
| 669 | + // Release the lock on the import process |
|
| 670 | + variable_del('boincimport_process_locked'); |
|
| 671 | + drupal_goto('admin/boinc/import/process'); |
|
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | |
@@ -681,23 +681,23 @@ discard block |
||
| 681 | 681 | */ |
| 682 | 682 | function boincimport_teams() { |
| 683 | 683 | |
| 684 | - // Check whether the team table has been successfully imported already |
|
| 685 | - if (variable_get('boincimport_import_team_successful', 0)) { |
|
| 684 | + // Check whether the team table has been successfully imported already |
|
| 685 | + if (variable_get('boincimport_import_team_successful', 0)) { |
|
| 686 | 686 | drupal_set_message(t('Note: team import has already run successfully')); |
| 687 | 687 | watchdog( |
| 688 | - 'boincimport', 'Note: team import has already run successfully', |
|
| 689 | - array(), WATCHDOG_INFO |
|
| 688 | + 'boincimport', 'Note: team import has already run successfully', |
|
| 689 | + array(), WATCHDOG_INFO |
|
| 690 | 690 | ); |
| 691 | - } |
|
| 691 | + } |
|
| 692 | 692 | |
| 693 | - if (!variable_get('boincimport_import_team_started', 0)) { |
|
| 693 | + if (!variable_get('boincimport_import_team_started', 0)) { |
|
| 694 | 694 | // Could prepare database tables, if new fields are necessary, etc. |
| 695 | 695 | variable_set('boincimport_import_team_started', 1); |
| 696 | - } |
|
| 696 | + } |
|
| 697 | 697 | |
| 698 | - // Initialize the map of BOINC team types to taxonomy IDs, if needed |
|
| 699 | - $team_type_map = variable_get('boincimport_team_types', array()); |
|
| 700 | - if (!$team_type_map) { |
|
| 698 | + // Initialize the map of BOINC team types to taxonomy IDs, if needed |
|
| 699 | + $team_type_map = variable_get('boincimport_team_types', array()); |
|
| 700 | + if (!$team_type_map) { |
|
| 701 | 701 | // Import team types from BOINC to a Drupal vocabulary |
| 702 | 702 | require_boinc('team_types'); |
| 703 | 703 | global $team_types; |
@@ -705,112 +705,112 @@ discard block |
||
| 705 | 705 | // Create vocabulary if it isn't set |
| 706 | 706 | $team_vid = db_result(db_query('SELECT vid FROM {vocabulary} WHERE name="%s"', 'Teams')); |
| 707 | 707 | if (!$team_vid) { |
| 708 | - $team_vocab = array( |
|
| 708 | + $team_vocab = array( |
|
| 709 | 709 | 'name' => t('Teams'), |
| 710 | 710 | 'description' => t('Types of BOINC teams'), |
| 711 | - ); |
|
| 712 | - taxonomy_save_vocabulary($team_vocab); |
|
| 713 | - $team_vid = db_result(db_query('SELECT vid FROM {vocabulary} WHERE name="%s"', 'Teams')); |
|
| 711 | + ); |
|
| 712 | + taxonomy_save_vocabulary($team_vocab); |
|
| 713 | + $team_vid = db_result(db_query('SELECT vid FROM {vocabulary} WHERE name="%s"', 'Teams')); |
|
| 714 | 714 | } |
| 715 | 715 | |
| 716 | 716 | foreach ($team_types as $boinc_type_id => $name) { |
| 717 | - // Check for an existing term in the vocabulary |
|
| 718 | - $team_type_id = db_result(db_query("SELECT tid FROM {term_data} WHERE vid = '{$team_vid}' AND LOWER(name) = LOWER('%s')", trim($name))); |
|
| 719 | - if ($team_type_id) { |
|
| 717 | + // Check for an existing term in the vocabulary |
|
| 718 | + $team_type_id = db_result(db_query("SELECT tid FROM {term_data} WHERE vid = '{$team_vid}' AND LOWER(name) = LOWER('%s')", trim($name))); |
|
| 719 | + if ($team_type_id) { |
|
| 720 | 720 | $team_type = array( |
| 721 | - 'tid' => $team_type_id |
|
| 721 | + 'tid' => $team_type_id |
|
| 722 | 722 | ); |
| 723 | - } |
|
| 724 | - else { |
|
| 723 | + } |
|
| 724 | + else { |
|
| 725 | 725 | if (!$name) continue; |
| 726 | 726 | $team_type = array( |
| 727 | - 'name' => strip_tags($name), |
|
| 728 | - 'vid' => $team_vid, |
|
| 729 | - 'description' => '', |
|
| 730 | - 'parent' => 0 |
|
| 727 | + 'name' => strip_tags($name), |
|
| 728 | + 'vid' => $team_vid, |
|
| 729 | + 'description' => '', |
|
| 730 | + 'parent' => 0 |
|
| 731 | 731 | ); |
| 732 | 732 | taxonomy_save_term($team_type); |
| 733 | - } |
|
| 734 | - // Note the taxonomy ID for mapping forums to categories |
|
| 735 | - $team_type_map[$boinc_type_id] = $team_type['tid']; |
|
| 733 | + } |
|
| 734 | + // Note the taxonomy ID for mapping forums to categories |
|
| 735 | + $team_type_map[$boinc_type_id] = $team_type['tid']; |
|
| 736 | 736 | } |
| 737 | 737 | variable_set('boincimport_team_types', $team_type_map); |
| 738 | - } |
|
| 738 | + } |
|
| 739 | 739 | |
| 740 | - $pre = variable_get('boincimport_table_prefix', ''); |
|
| 740 | + $pre = variable_get('boincimport_table_prefix', ''); |
|
| 741 | 741 | |
| 742 | - // Get the list of teams to import |
|
| 743 | - db_set_active('boinc_rw'); |
|
| 744 | - $boinc_teams = db_query(' |
|
| 742 | + // Get the list of teams to import |
|
| 743 | + db_set_active('boinc_rw'); |
|
| 744 | + $boinc_teams = db_query(' |
|
| 745 | 745 | SELECT id, name, description, userid, create_time |
| 746 | 746 | FROM %steam', |
| 747 | 747 | $pre |
| 748 | - ); |
|
| 749 | - $team_count = mysqli_num_rows($boinc_teams); |
|
| 750 | - db_set_active('default'); |
|
| 748 | + ); |
|
| 749 | + $team_count = mysqli_num_rows($boinc_teams); |
|
| 750 | + db_set_active('default'); |
|
| 751 | 751 | |
| 752 | - if (!$team_count) { |
|
| 752 | + if (!$team_count) { |
|
| 753 | 753 | drupal_set_message( |
| 754 | - t('There were no teams found: Aborting script'), 'error' |
|
| 754 | + t('There were no teams found: Aborting script'), 'error' |
|
| 755 | 755 | ); |
| 756 | 756 | watchdog('boincimport', |
| 757 | - 'There were no teams found: Aborting script', array(), WATCHDOG_INFO |
|
| 757 | + 'There were no teams found: Aborting script', array(), WATCHDOG_INFO |
|
| 758 | 758 | ); |
| 759 | 759 | // Release the lock on the import process |
| 760 | 760 | variable_del('boincimport_process_locked'); |
| 761 | 761 | return t('There were no teams found: Aborting script.'); |
| 762 | - } |
|
| 762 | + } |
|
| 763 | 763 | |
| 764 | - watchdog('boincimport', |
|
| 764 | + watchdog('boincimport', |
|
| 765 | 765 | 'Found %team_count teams: Beginning Import', |
| 766 | 766 | array('%team_count' => $team_count), WATCHDOG_INFO |
| 767 | - ); |
|
| 767 | + ); |
|
| 768 | 768 | |
| 769 | - $operations = array(); |
|
| 770 | - $existing_teams = array(); |
|
| 771 | - $duplicates = array(); |
|
| 769 | + $operations = array(); |
|
| 770 | + $existing_teams = array(); |
|
| 771 | + $duplicates = array(); |
|
| 772 | 772 | |
| 773 | - // Get the list of teams already in Drupal to be sure we're not importing |
|
| 774 | - // any twice |
|
| 775 | - $result = db_query(' |
|
| 773 | + // Get the list of teams already in Drupal to be sure we're not importing |
|
| 774 | + // any twice |
|
| 775 | + $result = db_query(' |
|
| 776 | 776 | SELECT nid, team_id FROM {boincteam}' |
| 777 | - ); |
|
| 778 | - while ($row = db_fetch_object($result)) { |
|
| 777 | + ); |
|
| 778 | + while ($row = db_fetch_object($result)) { |
|
| 779 | 779 | $existing_teams[$row->team_id] = $row->nid; |
| 780 | - } |
|
| 780 | + } |
|
| 781 | 781 | |
| 782 | - // Create batches to process |
|
| 783 | - while ($boinc_team = db_fetch_object($boinc_teams)) { |
|
| 784 | - if (isset($existing_teams[$boinc_team->id])) { |
|
| 785 | - // This team has already been imported |
|
| 786 | - $duplicates[] = $boinc_team->id; |
|
| 782 | + // Create batches to process |
|
| 783 | + while ($boinc_team = db_fetch_object($boinc_teams)) { |
|
| 784 | + if (isset($existing_teams[$boinc_team->id])) { |
|
| 785 | + // This team has already been imported |
|
| 786 | + $duplicates[] = $boinc_team->id; |
|
| 787 | 787 | } |
| 788 | 788 | else { |
| 789 | - $operations[] = array( |
|
| 789 | + $operations[] = array( |
|
| 790 | 790 | 'boincimport_teams_op', array( |
| 791 | - $boinc_team |
|
| 791 | + $boinc_team |
|
| 792 | 792 | ) |
| 793 | - ); |
|
| 793 | + ); |
|
| 794 | + } |
|
| 794 | 795 | } |
| 795 | - } |
|
| 796 | 796 | |
| 797 | - if ($duplicates) { |
|
| 797 | + if ($duplicates) { |
|
| 798 | 798 | drupal_set_message(t( |
| 799 | - 'Skipped @count teams that were already imported', |
|
| 800 | - array('@count' => count($duplicates)) |
|
| 799 | + 'Skipped @count teams that were already imported', |
|
| 800 | + array('@count' => count($duplicates)) |
|
| 801 | 801 | )); |
| 802 | - } |
|
| 802 | + } |
|
| 803 | 803 | |
| 804 | - $batch = array( |
|
| 804 | + $batch = array( |
|
| 805 | 805 | 'operations' => $operations, |
| 806 | 806 | 'finished' => 'boincimport_teams_finished', |
| 807 | 807 | 'title' => t('Importing teams'), |
| 808 | 808 | 'init_message' => t('Beginning team import...'), |
| 809 | 809 | 'progress_message' => t('Processed @current out of @total teams.'), |
| 810 | 810 | 'error_message' => t('Team import has encountered an error.'), |
| 811 | - ); |
|
| 811 | + ); |
|
| 812 | 812 | |
| 813 | - batch_set($batch); |
|
| 813 | + batch_set($batch); |
|
| 814 | 814 | } |
| 815 | 815 | |
| 816 | 816 | /** |
@@ -819,67 +819,67 @@ discard block |
||
| 819 | 819 | */ |
| 820 | 820 | function boincimport_teams_op($boincteam, &$context) { |
| 821 | 821 | |
| 822 | - $success = boincteam_import($boincteam); |
|
| 822 | + $success = boincteam_import($boincteam); |
|
| 823 | 823 | |
| 824 | - $message = ''; |
|
| 825 | - if ($success) { |
|
| 824 | + $message = ''; |
|
| 825 | + if ($success) { |
|
| 826 | 826 | // Store some result for post-processing in the finished callback. |
| 827 | 827 | $context['results']['success'][] = $boincteam->id; |
| 828 | 828 | $message = "Successfully imported team {$boincteam->id}"; |
| 829 | - } |
|
| 830 | - else { |
|
| 829 | + } |
|
| 830 | + else { |
|
| 831 | 831 | $context['results']['failure'][] = $boincteam->id; |
| 832 | 832 | $message = "Failed to import team {$boincteam->id}!"; |
| 833 | 833 | watchdog('boincimport', |
| 834 | - 'Failed to import team @id!', |
|
| 835 | - array('@id' => $boincteam->id), WATCHDOG_WARNING |
|
| 834 | + 'Failed to import team @id!', |
|
| 835 | + array('@id' => $boincteam->id), WATCHDOG_WARNING |
|
| 836 | 836 | ); |
| 837 | - } |
|
| 837 | + } |
|
| 838 | 838 | |
| 839 | - // Update our progress information. |
|
| 840 | - $context['sandbox']['progress']++; |
|
| 841 | - $context['sandbox']['current_team'] = $boincteam->id; |
|
| 842 | - $context['message'] = $message; |
|
| 839 | + // Update our progress information. |
|
| 840 | + $context['sandbox']['progress']++; |
|
| 841 | + $context['sandbox']['current_team'] = $boincteam->id; |
|
| 842 | + $context['message'] = $message; |
|
| 843 | 843 | |
| 844 | - // Update the progress for the batch engine |
|
| 845 | - if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 844 | + // Update the progress for the batch engine |
|
| 845 | + if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 846 | 846 | $context['finished'] = 1; |
| 847 | - } |
|
| 848 | - else { |
|
| 847 | + } |
|
| 848 | + else { |
|
| 849 | 849 | $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
| 850 | - } |
|
| 850 | + } |
|
| 851 | 851 | } |
| 852 | 852 | |
| 853 | 853 | /** |
| 854 | 854 | * Batch 'finished' callback |
| 855 | 855 | */ |
| 856 | 856 | function boincimport_teams_finished($success, $results, $operations) { |
| 857 | - if ($success) { |
|
| 857 | + if ($success) { |
|
| 858 | 858 | // Let's count our successes |
| 859 | 859 | $total_imported = count($results['success']); |
| 860 | 860 | $message = t( |
| 861 | - 'Successfully imported @count teams', |
|
| 862 | - array('@count' => $total_imported) |
|
| 861 | + 'Successfully imported @count teams', |
|
| 862 | + array('@count' => $total_imported) |
|
| 863 | 863 | ); |
| 864 | 864 | watchdog('boincimport', |
| 865 | - 'Successfully imported @count teams.', |
|
| 866 | - array('@count' => $total_imported), WATCHDOG_INFO |
|
| 865 | + 'Successfully imported @count teams.', |
|
| 866 | + array('@count' => $total_imported), WATCHDOG_INFO |
|
| 867 | 867 | ); |
| 868 | 868 | // Set the team import successful flag in the variable table |
| 869 | 869 | variable_set('boincimport_import_team_successful', '1'); |
| 870 | 870 | $_SESSION['boincimport_stage_selected'] = 'friends'; |
| 871 | - } |
|
| 872 | - else { |
|
| 871 | + } |
|
| 872 | + else { |
|
| 873 | 873 | // An error occurred. |
| 874 | 874 | // $operations contains the operations that remained unprocessed. |
| 875 | 875 | $error_operation = reset($operations); |
| 876 | 876 | $message = 'An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE); |
| 877 | - } |
|
| 878 | - drupal_set_message($message); |
|
| 877 | + } |
|
| 878 | + drupal_set_message($message); |
|
| 879 | 879 | |
| 880 | - // Release the lock on the import process |
|
| 881 | - variable_del('boincimport_process_locked'); |
|
| 882 | - drupal_goto('admin/boinc/import/process'); |
|
| 880 | + // Release the lock on the import process |
|
| 881 | + variable_del('boincimport_process_locked'); |
|
| 882 | + drupal_goto('admin/boinc/import/process'); |
|
| 883 | 883 | } |
| 884 | 884 | |
| 885 | 885 | |
@@ -892,25 +892,25 @@ discard block |
||
| 892 | 892 | */ |
| 893 | 893 | function boincimport_friends() { |
| 894 | 894 | |
| 895 | - // Check whether friendships have been successfully imported already |
|
| 896 | - if (variable_get('boincimport_import_friend_successful', 0)) { |
|
| 895 | + // Check whether friendships have been successfully imported already |
|
| 896 | + if (variable_get('boincimport_import_friend_successful', 0)) { |
|
| 897 | 897 | drupal_set_message(t('Note: Friends import has already run successfully')); |
| 898 | 898 | watchdog( |
| 899 | - 'boincimport', 'Note: Friends import has already run successfully', |
|
| 900 | - array(), WATCHDOG_INFO |
|
| 899 | + 'boincimport', 'Note: Friends import has already run successfully', |
|
| 900 | + array(), WATCHDOG_INFO |
|
| 901 | 901 | ); |
| 902 | - } |
|
| 902 | + } |
|
| 903 | 903 | |
| 904 | - if (!variable_get('boincimport_import_friend_started', 0)) { |
|
| 904 | + if (!variable_get('boincimport_import_friend_started', 0)) { |
|
| 905 | 905 | // Could prepare database tables, if new fields are necessary, etc. |
| 906 | 906 | variable_set('boincimport_import_friend_started', 1); |
| 907 | - } |
|
| 907 | + } |
|
| 908 | 908 | |
| 909 | - $pre = variable_get('boincimport_table_prefix', ''); |
|
| 909 | + $pre = variable_get('boincimport_table_prefix', ''); |
|
| 910 | 910 | |
| 911 | - // Get stuff to import |
|
| 912 | - db_set_active('boinc_rw'); |
|
| 913 | - $friendships = db_query(' |
|
| 911 | + // Get stuff to import |
|
| 912 | + db_set_active('boinc_rw'); |
|
| 913 | + $friendships = db_query(' |
|
| 914 | 914 | SELECT |
| 915 | 915 | f1.user_src, |
| 916 | 916 | f1.user_dest, |
@@ -924,51 +924,51 @@ discard block |
||
| 924 | 924 | AND (f2.user_src IS NULL OR f1.create_time < f2.create_time) |
| 925 | 925 | ORDER BY create_time', |
| 926 | 926 | $pre, $pre |
| 927 | - ); |
|
| 928 | - $friendship_count = mysqli_num_rows($friendships); |
|
| 929 | - db_set_active('default'); |
|
| 927 | + ); |
|
| 928 | + $friendship_count = mysqli_num_rows($friendships); |
|
| 929 | + db_set_active('default'); |
|
| 930 | 930 | |
| 931 | - if (!$friendship_count) { |
|
| 931 | + if (!$friendship_count) { |
|
| 932 | 932 | drupal_set_message( |
| 933 | - t('There were no friendships found: Aborting script'), 'error' |
|
| 933 | + t('There were no friendships found: Aborting script'), 'error' |
|
| 934 | 934 | ); |
| 935 | 935 | watchdog('boincimport', |
| 936 | - 'There were no friendships found: Aborting script', array(), WATCHDOG_INFO |
|
| 936 | + 'There were no friendships found: Aborting script', array(), WATCHDOG_INFO |
|
| 937 | 937 | ); |
| 938 | 938 | // Release the lock on the import process |
| 939 | 939 | variable_del('boincimport_process_locked'); |
| 940 | 940 | return t('There were no friendships found: Aborting script.'); |
| 941 | - } |
|
| 941 | + } |
|
| 942 | 942 | |
| 943 | - watchdog('boincimport', |
|
| 943 | + watchdog('boincimport', |
|
| 944 | 944 | 'Found %count friend relationships: Beginning Import', |
| 945 | 945 | array('%count' => $friendship_count), WATCHDOG_INFO |
| 946 | - ); |
|
| 946 | + ); |
|
| 947 | 947 | |
| 948 | - $operations = array(); |
|
| 948 | + $operations = array(); |
|
| 949 | 949 | |
| 950 | - // It doesn't matter if a friend relationship has already been imported, just |
|
| 951 | - // do it again if so |
|
| 950 | + // It doesn't matter if a friend relationship has already been imported, just |
|
| 951 | + // do it again if so |
|
| 952 | 952 | |
| 953 | - // Create batches to process |
|
| 954 | - while ($friendship = db_fetch_object($friendships)) { |
|
| 953 | + // Create batches to process |
|
| 954 | + while ($friendship = db_fetch_object($friendships)) { |
|
| 955 | 955 | $operations[] = array( |
| 956 | - 'boincimport_friends_op', array( |
|
| 956 | + 'boincimport_friends_op', array( |
|
| 957 | 957 | $friendship |
| 958 | - ) |
|
| 958 | + ) |
|
| 959 | 959 | ); |
| 960 | - } |
|
| 960 | + } |
|
| 961 | 961 | |
| 962 | - $batch = array( |
|
| 962 | + $batch = array( |
|
| 963 | 963 | 'operations' => $operations, |
| 964 | 964 | 'finished' => 'boincimport_friends_finished', |
| 965 | 965 | 'title' => t('Importing friend relationships'), |
| 966 | 966 | 'init_message' => t('Beginning friend import...'), |
| 967 | 967 | 'progress_message' => t('Processed @current out of @total friendships.'), |
| 968 | 968 | 'error_message' => t('Friend import has encountered an error.'), |
| 969 | - ); |
|
| 969 | + ); |
|
| 970 | 970 | |
| 971 | - batch_set($batch); |
|
| 971 | + batch_set($batch); |
|
| 972 | 972 | } |
| 973 | 973 | |
| 974 | 974 | /** |
@@ -977,83 +977,83 @@ discard block |
||
| 977 | 977 | */ |
| 978 | 978 | function boincimport_friends_op($friendship, &$context) { |
| 979 | 979 | |
| 980 | - $input_format = variable_get('boincimport_input_format', 0); |
|
| 981 | - $success = FALSE; |
|
| 982 | - $message = ''; |
|
| 980 | + $input_format = variable_get('boincimport_input_format', 0); |
|
| 981 | + $success = FALSE; |
|
| 982 | + $message = ''; |
|
| 983 | 983 | |
| 984 | - // Convert BOINC friends to Drupal friends |
|
| 985 | - $uid = boincuser_lookup_uid($friendship->user_src); |
|
| 986 | - $friend_uid = boincuser_lookup_uid($friendship->user_dest); |
|
| 987 | - if ($uid AND $friend_uid) { |
|
| 984 | + // Convert BOINC friends to Drupal friends |
|
| 985 | + $uid = boincuser_lookup_uid($friendship->user_src); |
|
| 986 | + $friend_uid = boincuser_lookup_uid($friendship->user_dest); |
|
| 987 | + if ($uid AND $friend_uid) { |
|
| 988 | 988 | $success = db_query(" |
| 989 | 989 | INSERT IGNORE INTO {flag_friend} |
| 990 | 990 | SET uid = '%d', friend_uid = '%d', created = '%d'", |
| 991 | - $uid, $friend_uid, $friendship->create_time |
|
| 991 | + $uid, $friend_uid, $friendship->create_time |
|
| 992 | 992 | ); |
| 993 | - } |
|
| 994 | - else { |
|
| 993 | + } |
|
| 994 | + else { |
|
| 995 | 995 | $boinc_id = ($uid) ? $friendship->user_dest : $friendship->user_src; |
| 996 | 996 | $message = "No Drupal account exists for BOINC user {$boinc_id}!"; |
| 997 | - } |
|
| 997 | + } |
|
| 998 | 998 | |
| 999 | - if ($success) { |
|
| 999 | + if ($success) { |
|
| 1000 | 1000 | // Store some result for post-processing in the finished callback. |
| 1001 | 1001 | $context['results']['success'][] = $uid; |
| 1002 | 1002 | $message = "Successfully made users {$uid} and {$friend_uid} friends"; |
| 1003 | - } |
|
| 1004 | - else { |
|
| 1003 | + } |
|
| 1004 | + else { |
|
| 1005 | 1005 | $context['results']['failure'][] = $uid; |
| 1006 | 1006 | if (!$message) { |
| 1007 | - $message = "Failed to make users {$uid} and {$friend_uid} friends!"; |
|
| 1007 | + $message = "Failed to make users {$uid} and {$friend_uid} friends!"; |
|
| 1008 | 1008 | } |
| 1009 | 1009 | watchdog('boincimport', $message, array(), WATCHDOG_WARNING); |
| 1010 | - } |
|
| 1010 | + } |
|
| 1011 | 1011 | |
| 1012 | - // Update our progress information. |
|
| 1013 | - $context['sandbox']['progress']++; |
|
| 1014 | - $context['sandbox']['current_user'] = $uid; |
|
| 1015 | - $context['message'] = $message; |
|
| 1012 | + // Update our progress information. |
|
| 1013 | + $context['sandbox']['progress']++; |
|
| 1014 | + $context['sandbox']['current_user'] = $uid; |
|
| 1015 | + $context['message'] = $message; |
|
| 1016 | 1016 | |
| 1017 | - // Update the progress for the batch engine |
|
| 1018 | - if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 1017 | + // Update the progress for the batch engine |
|
| 1018 | + if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 1019 | 1019 | $context['finished'] = 1; |
| 1020 | - } |
|
| 1021 | - else { |
|
| 1020 | + } |
|
| 1021 | + else { |
|
| 1022 | 1022 | $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
| 1023 | - } |
|
| 1023 | + } |
|
| 1024 | 1024 | } |
| 1025 | 1025 | |
| 1026 | 1026 | /** |
| 1027 | 1027 | * Batch 'finished' callback |
| 1028 | 1028 | */ |
| 1029 | 1029 | function boincimport_friends_finished($success, $results, $operations) { |
| 1030 | - if ($success) { |
|
| 1030 | + if ($success) { |
|
| 1031 | 1031 | // Let's count our successes |
| 1032 | 1032 | $total_imported = count($results['success']); |
| 1033 | 1033 | $failures = count($results['failure']); |
| 1034 | 1034 | $message = t( |
| 1035 | - 'Successfully imported @count friendships (@failed failures)', |
|
| 1036 | - array( |
|
| 1035 | + 'Successfully imported @count friendships (@failed failures)', |
|
| 1036 | + array( |
|
| 1037 | 1037 | '@count' => $total_imported, |
| 1038 | 1038 | '@failed' => $failures, |
| 1039 | - ) |
|
| 1039 | + ) |
|
| 1040 | 1040 | ); |
| 1041 | 1041 | watchdog('boincimport', $message, array(), WATCHDOG_INFO); |
| 1042 | 1042 | // Set the friend import successful flag in the variable table |
| 1043 | 1043 | variable_set('boincimport_import_friend_successful', '1'); |
| 1044 | 1044 | $_SESSION['boincimport_stage_selected'] = 'preferences'; |
| 1045 | - } |
|
| 1046 | - else { |
|
| 1045 | + } |
|
| 1046 | + else { |
|
| 1047 | 1047 | // An error occurred. |
| 1048 | 1048 | // $operations contains the operations that remained unprocessed. |
| 1049 | 1049 | $error_operation = reset($operations); |
| 1050 | 1050 | $message = 'An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE); |
| 1051 | - } |
|
| 1052 | - drupal_set_message($message); |
|
| 1051 | + } |
|
| 1052 | + drupal_set_message($message); |
|
| 1053 | 1053 | |
| 1054 | - // Release the lock on the import process |
|
| 1055 | - variable_del('boincimport_process_locked'); |
|
| 1056 | - drupal_goto('admin/boinc/import/process'); |
|
| 1054 | + // Release the lock on the import process |
|
| 1055 | + variable_del('boincimport_process_locked'); |
|
| 1056 | + drupal_goto('admin/boinc/import/process'); |
|
| 1057 | 1057 | } |
| 1058 | 1058 | |
| 1059 | 1059 | |
@@ -1066,78 +1066,78 @@ discard block |
||
| 1066 | 1066 | */ |
| 1067 | 1067 | function boincimport_preferences() { |
| 1068 | 1068 | |
| 1069 | - // Check whether preferences have been successfully imported already |
|
| 1070 | - if (variable_get('boincimport_import_preferences_successful', 0)) { |
|
| 1069 | + // Check whether preferences have been successfully imported already |
|
| 1070 | + if (variable_get('boincimport_import_preferences_successful', 0)) { |
|
| 1071 | 1071 | drupal_set_message(t('Note: preferences import has already run successfully')); |
| 1072 | 1072 | watchdog( |
| 1073 | - 'boincimport', 'Note: preferences import has already run successfully', |
|
| 1074 | - array(), WATCHDOG_INFO |
|
| 1073 | + 'boincimport', 'Note: preferences import has already run successfully', |
|
| 1074 | + array(), WATCHDOG_INFO |
|
| 1075 | 1075 | ); |
| 1076 | - } |
|
| 1076 | + } |
|
| 1077 | 1077 | |
| 1078 | - if (!variable_get('boincimport_import_preferences_started', 0)) { |
|
| 1078 | + if (!variable_get('boincimport_import_preferences_started', 0)) { |
|
| 1079 | 1079 | // Could prepare database tables, if new fields are necessary, etc. |
| 1080 | 1080 | variable_set('boincimport_import_preferences_started', 1); |
| 1081 | - } |
|
| 1081 | + } |
|
| 1082 | 1082 | |
| 1083 | - $pre = variable_get('boincimport_table_prefix', ''); |
|
| 1083 | + $pre = variable_get('boincimport_table_prefix', ''); |
|
| 1084 | 1084 | |
| 1085 | - // Currently the only preferences being imported are BOINC "filtered users" |
|
| 1086 | - // This concept of users blocking other users when they don't get along maps |
|
| 1087 | - // to the Drupal ignore users module |
|
| 1085 | + // Currently the only preferences being imported are BOINC "filtered users" |
|
| 1086 | + // This concept of users blocking other users when they don't get along maps |
|
| 1087 | + // to the Drupal ignore users module |
|
| 1088 | 1088 | |
| 1089 | - // Find users who are involved in quarrels |
|
| 1090 | - db_set_active('boinc_rw'); |
|
| 1091 | - $quarrelers = db_query(" |
|
| 1089 | + // Find users who are involved in quarrels |
|
| 1090 | + db_set_active('boinc_rw'); |
|
| 1091 | + $quarrelers = db_query(" |
|
| 1092 | 1092 | SELECT userid, ignorelist |
| 1093 | 1093 | FROM %sforum_preferences |
| 1094 | 1094 | WHERE ignorelist <> ''", |
| 1095 | 1095 | $pre |
| 1096 | - ); |
|
| 1097 | - $quarreler_count = mysqli_num_rows($quarrelers); |
|
| 1098 | - db_set_active('default'); |
|
| 1096 | + ); |
|
| 1097 | + $quarreler_count = mysqli_num_rows($quarrelers); |
|
| 1098 | + db_set_active('default'); |
|
| 1099 | 1099 | |
| 1100 | - if (!$quarreler_count) { |
|
| 1100 | + if (!$quarreler_count) { |
|
| 1101 | 1101 | drupal_set_message( |
| 1102 | - t('There were no quarrels found: Moving on...') |
|
| 1102 | + t('There were no quarrels found: Moving on...') |
|
| 1103 | 1103 | ); |
| 1104 | 1104 | watchdog('boincimport', |
| 1105 | - 'There were no quarrels found: Moving on...', array(), WATCHDOG_INFO |
|
| 1105 | + 'There were no quarrels found: Moving on...', array(), WATCHDOG_INFO |
|
| 1106 | 1106 | ); |
| 1107 | 1107 | // Release the lock on the import process |
| 1108 | 1108 | variable_del('boincimport_process_locked'); |
| 1109 | 1109 | return t('There were no quarrels found: Moving on...'); |
| 1110 | - } |
|
| 1110 | + } |
|
| 1111 | 1111 | |
| 1112 | - watchdog('boincimport', |
|
| 1112 | + watchdog('boincimport', |
|
| 1113 | 1113 | 'Found %count quarreling users: Beginning Import', |
| 1114 | 1114 | array('%count' => $quarreler_count), WATCHDOG_INFO |
| 1115 | - ); |
|
| 1115 | + ); |
|
| 1116 | 1116 | |
| 1117 | - $operations = array(); |
|
| 1117 | + $operations = array(); |
|
| 1118 | 1118 | |
| 1119 | - // It doesn't matter if a filtered user preference has already been imported, |
|
| 1120 | - // just do it again if so |
|
| 1119 | + // It doesn't matter if a filtered user preference has already been imported, |
|
| 1120 | + // just do it again if so |
|
| 1121 | 1121 | |
| 1122 | - // Create batches to process |
|
| 1123 | - while ($quarreler = db_fetch_object($quarrelers)) { |
|
| 1122 | + // Create batches to process |
|
| 1123 | + while ($quarreler = db_fetch_object($quarrelers)) { |
|
| 1124 | 1124 | $operations[] = array( |
| 1125 | - 'boincimport_quarrels_op', array( |
|
| 1125 | + 'boincimport_quarrels_op', array( |
|
| 1126 | 1126 | $quarreler |
| 1127 | - ) |
|
| 1127 | + ) |
|
| 1128 | 1128 | ); |
| 1129 | - } |
|
| 1129 | + } |
|
| 1130 | 1130 | |
| 1131 | - $batch = array( |
|
| 1131 | + $batch = array( |
|
| 1132 | 1132 | 'operations' => $operations, |
| 1133 | 1133 | 'finished' => 'boincimport_preferences_finished', |
| 1134 | 1134 | 'title' => t('Importing preferences'), |
| 1135 | 1135 | 'init_message' => t('Beginning preference import...'), |
| 1136 | 1136 | 'progress_message' => t('Processed @current out of @total preferences.'), |
| 1137 | 1137 | 'error_message' => t('Preference import has encountered an error.'), |
| 1138 | - ); |
|
| 1138 | + ); |
|
| 1139 | 1139 | |
| 1140 | - batch_set($batch); |
|
| 1140 | + batch_set($batch); |
|
| 1141 | 1141 | } |
| 1142 | 1142 | |
| 1143 | 1143 | /** |
@@ -1146,99 +1146,99 @@ discard block |
||
| 1146 | 1146 | */ |
| 1147 | 1147 | function boincimport_quarrels_op($boinc_user, &$context) { |
| 1148 | 1148 | |
| 1149 | - $success = FALSE; |
|
| 1150 | - $uid = boincuser_lookup_uid($boinc_user->userid); |
|
| 1151 | - $ignored_users = explode('|', trim($boinc_user->ignorelist, '|')); |
|
| 1152 | - foreach ($ignored_users as $ignored_user) { |
|
| 1149 | + $success = FALSE; |
|
| 1150 | + $uid = boincuser_lookup_uid($boinc_user->userid); |
|
| 1151 | + $ignored_users = explode('|', trim($boinc_user->ignorelist, '|')); |
|
| 1152 | + foreach ($ignored_users as $ignored_user) { |
|
| 1153 | 1153 | $ignored_user_uid = boincuser_lookup_uid($ignored_user); |
| 1154 | 1154 | if (!$ignored_user_uid) { |
| 1155 | - $context['results']['warning'][] = "{$uid}:{$ignored_user_uid}"; |
|
| 1156 | - watchdog('boincimport', |
|
| 1155 | + $context['results']['warning'][] = "{$uid}:{$ignored_user_uid}"; |
|
| 1156 | + watchdog('boincimport', |
|
| 1157 | 1157 | 'Error adding to ignore list of user @uid: No Drupal ID found for BOINC user @boinc_id', |
| 1158 | 1158 | array('@boinc_id' => $ignored_user, '@uid' => $uid), |
| 1159 | 1159 | WATCHDOG_WARNING |
| 1160 | - ); |
|
| 1161 | - continue; |
|
| 1160 | + ); |
|
| 1161 | + continue; |
|
| 1162 | 1162 | } |
| 1163 | 1163 | $user_ignored = db_query(" |
| 1164 | 1164 | INSERT IGNORE INTO {ignore_user} |
| 1165 | 1165 | SET uid = '%d', iuid = '%d'", |
| 1166 | - $uid, $ignored_user_uid |
|
| 1166 | + $uid, $ignored_user_uid |
|
| 1167 | 1167 | ); |
| 1168 | 1168 | if ($user_ignored) { |
| 1169 | - $success = TRUE; |
|
| 1169 | + $success = TRUE; |
|
| 1170 | 1170 | } |
| 1171 | 1171 | else { |
| 1172 | - $context['results']['warning'][] = "{$uid}:{$ignored_user_uid}"; |
|
| 1173 | - watchdog('boincimport', |
|
| 1172 | + $context['results']['warning'][] = "{$uid}:{$ignored_user_uid}"; |
|
| 1173 | + watchdog('boincimport', |
|
| 1174 | 1174 | 'Could not add user @ignored_uid to the ignore list of user @uid', |
| 1175 | 1175 | array('@ignored_uid' => $ignored_user_uid, '@uid' => $uid), |
| 1176 | 1176 | WATCHDOG_WARNING |
| 1177 | - ); |
|
| 1177 | + ); |
|
| 1178 | + } |
|
| 1178 | 1179 | } |
| 1179 | - } |
|
| 1180 | 1180 | |
| 1181 | - $message = ''; |
|
| 1182 | - if ($success) { |
|
| 1181 | + $message = ''; |
|
| 1182 | + if ($success) { |
|
| 1183 | 1183 | // Store some result for post-processing in the finished callback. |
| 1184 | 1184 | $context['results']['success'][] = $uid; |
| 1185 | 1185 | $message = "Successfully imported ignored users for user {$uid}"; |
| 1186 | - } |
|
| 1187 | - else { |
|
| 1186 | + } |
|
| 1187 | + else { |
|
| 1188 | 1188 | $context['results']['failure'][] = $uid; |
| 1189 | 1189 | $message = "Failed to import any user filter preferences for user {$uid}!"; |
| 1190 | 1190 | watchdog('boincimport', |
| 1191 | - 'Failed to import any user filter preferences for user @id!', |
|
| 1192 | - array('@id' => $uid), WATCHDOG_WARNING |
|
| 1191 | + 'Failed to import any user filter preferences for user @id!', |
|
| 1192 | + array('@id' => $uid), WATCHDOG_WARNING |
|
| 1193 | 1193 | ); |
| 1194 | - } |
|
| 1194 | + } |
|
| 1195 | 1195 | |
| 1196 | - // Update our progress information. |
|
| 1197 | - $context['sandbox']['progress']++; |
|
| 1198 | - $context['sandbox']['current_user'] = $uid; |
|
| 1199 | - $context['message'] = $message; |
|
| 1196 | + // Update our progress information. |
|
| 1197 | + $context['sandbox']['progress']++; |
|
| 1198 | + $context['sandbox']['current_user'] = $uid; |
|
| 1199 | + $context['message'] = $message; |
|
| 1200 | 1200 | |
| 1201 | - // Update the progress for the batch engine |
|
| 1202 | - if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 1201 | + // Update the progress for the batch engine |
|
| 1202 | + if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 1203 | 1203 | $context['finished'] = 1; |
| 1204 | - } |
|
| 1205 | - else { |
|
| 1204 | + } |
|
| 1205 | + else { |
|
| 1206 | 1206 | $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
| 1207 | - } |
|
| 1207 | + } |
|
| 1208 | 1208 | } |
| 1209 | 1209 | |
| 1210 | 1210 | /** |
| 1211 | 1211 | * Batch 'finished' callback |
| 1212 | 1212 | */ |
| 1213 | 1213 | function boincimport_preferences_finished($success, $results, $operations) { |
| 1214 | - if ($success) { |
|
| 1214 | + if ($success) { |
|
| 1215 | 1215 | // Let's count our successes |
| 1216 | 1216 | $total_imported = count($results['success']); |
| 1217 | 1217 | $total_warnings = count($results['warning']); |
| 1218 | 1218 | $message = t( |
| 1219 | - 'Successfully imported preferences for @count users (with @warn warnings)', |
|
| 1220 | - array('@count' => $total_imported, '@warn' => $total_warnings) |
|
| 1219 | + 'Successfully imported preferences for @count users (with @warn warnings)', |
|
| 1220 | + array('@count' => $total_imported, '@warn' => $total_warnings) |
|
| 1221 | 1221 | ); |
| 1222 | 1222 | watchdog('boincimport', |
| 1223 | - 'Successfully imported preferences for @count users (with @warn warnings)', |
|
| 1224 | - array('@count' => $total_imported, '@warn' => $total_warnings), |
|
| 1225 | - WATCHDOG_INFO |
|
| 1223 | + 'Successfully imported preferences for @count users (with @warn warnings)', |
|
| 1224 | + array('@count' => $total_imported, '@warn' => $total_warnings), |
|
| 1225 | + WATCHDOG_INFO |
|
| 1226 | 1226 | ); |
| 1227 | 1227 | // Set the preference import successful flag in the variable table |
| 1228 | 1228 | variable_set('boincimport_import_preferences_successful', '1'); |
| 1229 | 1229 | $_SESSION['boincimport_stage_selected'] = 'private messages'; |
| 1230 | - } |
|
| 1231 | - else { |
|
| 1230 | + } |
|
| 1231 | + else { |
|
| 1232 | 1232 | // An error occurred. |
| 1233 | 1233 | // $operations contains the operations that remained unprocessed. |
| 1234 | 1234 | $error_operation = reset($operations); |
| 1235 | 1235 | $message = 'An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE); |
| 1236 | - } |
|
| 1237 | - drupal_set_message($message); |
|
| 1236 | + } |
|
| 1237 | + drupal_set_message($message); |
|
| 1238 | 1238 | |
| 1239 | - // Release the lock on the import process |
|
| 1240 | - variable_del('boincimport_process_locked'); |
|
| 1241 | - drupal_goto('admin/boinc/import/process'); |
|
| 1239 | + // Release the lock on the import process |
|
| 1240 | + variable_del('boincimport_process_locked'); |
|
| 1241 | + drupal_goto('admin/boinc/import/process'); |
|
| 1242 | 1242 | } |
| 1243 | 1243 | |
| 1244 | 1244 | |
@@ -1251,74 +1251,74 @@ discard block |
||
| 1251 | 1251 | */ |
| 1252 | 1252 | function boincimport_private_msgs() { |
| 1253 | 1253 | |
| 1254 | - // Check whether private messages have been successfully imported already |
|
| 1255 | - if (variable_get('boincimport_import_private_msg_successful', 0)) { |
|
| 1254 | + // Check whether private messages have been successfully imported already |
|
| 1255 | + if (variable_get('boincimport_import_private_msg_successful', 0)) { |
|
| 1256 | 1256 | drupal_set_message(t('Private message import has already run successfully -- repeating this process could result in duplicate messages!'), 'warning'); |
| 1257 | 1257 | watchdog( |
| 1258 | - 'boincimport', 'Private message import has already run successfully', |
|
| 1259 | - array(), WATCHDOG_WARNING |
|
| 1258 | + 'boincimport', 'Private message import has already run successfully', |
|
| 1259 | + array(), WATCHDOG_WARNING |
|
| 1260 | 1260 | ); |
| 1261 | 1261 | return; |
| 1262 | - } |
|
| 1262 | + } |
|
| 1263 | 1263 | |
| 1264 | - if (!variable_get('boincimport_import_private_msg_started', 0)) { |
|
| 1264 | + if (!variable_get('boincimport_import_private_msg_started', 0)) { |
|
| 1265 | 1265 | // Could prepare database tables, if new fields are necessary, etc. |
| 1266 | 1266 | variable_set('boincimport_import_private_msg_started', 1); |
| 1267 | - } |
|
| 1267 | + } |
|
| 1268 | 1268 | |
| 1269 | - $pre = variable_get('boincimport_table_prefix', ''); |
|
| 1269 | + $pre = variable_get('boincimport_table_prefix', ''); |
|
| 1270 | 1270 | |
| 1271 | - // Get stuff to import |
|
| 1272 | - db_set_active('boinc_rw'); |
|
| 1273 | - $boinc_private_msgs = db_query(' |
|
| 1271 | + // Get stuff to import |
|
| 1272 | + db_set_active('boinc_rw'); |
|
| 1273 | + $boinc_private_msgs = db_query(' |
|
| 1274 | 1274 | SELECT id, subject, content, userid, senderid, date, opened |
| 1275 | 1275 | FROM %sprivate_messages', |
| 1276 | 1276 | $pre |
| 1277 | - ); |
|
| 1278 | - $private_msg_count = mysqli_num_rows($boinc_private_msgs); |
|
| 1279 | - db_set_active('default'); |
|
| 1277 | + ); |
|
| 1278 | + $private_msg_count = mysqli_num_rows($boinc_private_msgs); |
|
| 1279 | + db_set_active('default'); |
|
| 1280 | 1280 | |
| 1281 | - if (!$private_msg_count) { |
|
| 1281 | + if (!$private_msg_count) { |
|
| 1282 | 1282 | drupal_set_message( |
| 1283 | - t('There were no private messages found: Moving on...') |
|
| 1283 | + t('There were no private messages found: Moving on...') |
|
| 1284 | 1284 | ); |
| 1285 | 1285 | watchdog('boincimport', |
| 1286 | - 'There were no private messages found: Moving on...', array(), WATCHDOG_INFO |
|
| 1286 | + 'There were no private messages found: Moving on...', array(), WATCHDOG_INFO |
|
| 1287 | 1287 | ); |
| 1288 | 1288 | // Release the lock on the import process |
| 1289 | 1289 | variable_del('boincimport_process_locked'); |
| 1290 | 1290 | return t('There were no private messages found: Moving on...'); |
| 1291 | - } |
|
| 1291 | + } |
|
| 1292 | 1292 | |
| 1293 | - watchdog('boincimport', |
|
| 1293 | + watchdog('boincimport', |
|
| 1294 | 1294 | 'Found %count private messages: Beginning Import', |
| 1295 | 1295 | array('%count' => $private_msg_count), WATCHDOG_INFO |
| 1296 | - ); |
|
| 1296 | + ); |
|
| 1297 | 1297 | |
| 1298 | - $operations = array(); |
|
| 1298 | + $operations = array(); |
|
| 1299 | 1299 | |
| 1300 | - // We don't know if a given private message has been imported already or not; |
|
| 1301 | - // if this is needed, a relation table must be added to the Drupal DB |
|
| 1300 | + // We don't know if a given private message has been imported already or not; |
|
| 1301 | + // if this is needed, a relation table must be added to the Drupal DB |
|
| 1302 | 1302 | |
| 1303 | - // Create batches to process |
|
| 1304 | - while ($boinc_private_msg = db_fetch_object($boinc_private_msgs)) { |
|
| 1303 | + // Create batches to process |
|
| 1304 | + while ($boinc_private_msg = db_fetch_object($boinc_private_msgs)) { |
|
| 1305 | 1305 | $operations[] = array( |
| 1306 | - 'boincimport_private_msgs_op', array( |
|
| 1306 | + 'boincimport_private_msgs_op', array( |
|
| 1307 | 1307 | $boinc_private_msg |
| 1308 | - ) |
|
| 1308 | + ) |
|
| 1309 | 1309 | ); |
| 1310 | - } |
|
| 1310 | + } |
|
| 1311 | 1311 | |
| 1312 | - $batch = array( |
|
| 1312 | + $batch = array( |
|
| 1313 | 1313 | 'operations' => $operations, |
| 1314 | 1314 | 'finished' => 'boincimport_private_msgs_finished', |
| 1315 | 1315 | 'title' => t('Importing private messages'), |
| 1316 | 1316 | 'init_message' => t('Beginning private message import...'), |
| 1317 | 1317 | 'progress_message' => t('Processed @current out of @total private messages.'), |
| 1318 | 1318 | 'error_message' => t('Private message import has encountered an error.'), |
| 1319 | - ); |
|
| 1319 | + ); |
|
| 1320 | 1320 | |
| 1321 | - batch_set($batch); |
|
| 1321 | + batch_set($batch); |
|
| 1322 | 1322 | } |
| 1323 | 1323 | |
| 1324 | 1324 | /** |
@@ -1327,95 +1327,95 @@ discard block |
||
| 1327 | 1327 | */ |
| 1328 | 1328 | function boincimport_private_msgs_op($pm, &$context) { |
| 1329 | 1329 | |
| 1330 | - $input_format = variable_get('boincimport_input_format', 0); |
|
| 1330 | + $input_format = variable_get('boincimport_input_format', 0); |
|
| 1331 | 1331 | |
| 1332 | - $uid = boincuser_lookup_uid($pm->userid); |
|
| 1333 | - $sender_uid = boincuser_lookup_uid($pm->senderid); |
|
| 1332 | + $uid = boincuser_lookup_uid($pm->userid); |
|
| 1333 | + $sender_uid = boincuser_lookup_uid($pm->senderid); |
|
| 1334 | 1334 | |
| 1335 | - $pm->content = _boincimport_strip_bbcode($pm->content); |
|
| 1336 | - $pm->content = _boincimport_text_sanitize($pm->content); |
|
| 1335 | + $pm->content = _boincimport_strip_bbcode($pm->content); |
|
| 1336 | + $pm->content = _boincimport_text_sanitize($pm->content); |
|
| 1337 | 1337 | |
| 1338 | - // First save the message |
|
| 1339 | - $message_added = db_query(" |
|
| 1338 | + // First save the message |
|
| 1339 | + $message_added = db_query(" |
|
| 1340 | 1340 | INSERT INTO {pm_message} (subject, author, body, format, timestamp) |
| 1341 | 1341 | VALUES ('%s', %d, '%s', %d, %d)", |
| 1342 | 1342 | $pm->subject, $sender_uid, $pm->content, $input_format, $pm->date |
| 1343 | - ); |
|
| 1344 | - $mid = db_last_insert_id('pm_message', 'mid'); |
|
| 1343 | + ); |
|
| 1344 | + $mid = db_last_insert_id('pm_message', 'mid'); |
|
| 1345 | 1345 | |
| 1346 | - // Then attach recipients and set status (note that threads are not a BOINC |
|
| 1347 | - // feature, so just consider every message to be a new thread) |
|
| 1348 | - $recipient_added = db_query(" |
|
| 1346 | + // Then attach recipients and set status (note that threads are not a BOINC |
|
| 1347 | + // feature, so just consider every message to be a new thread) |
|
| 1348 | + $recipient_added = db_query(" |
|
| 1349 | 1349 | INSERT INTO {pm_index} (mid, thread_id, uid, is_new, deleted) |
| 1350 | 1350 | VALUES (%d, %d, %d, %d, 0)", |
| 1351 | 1351 | $mid, $mid, $uid, !$pm->opened |
| 1352 | - ); |
|
| 1353 | - // In Drupal, the sender should be attached as well |
|
| 1354 | - $sender_added = db_query(" |
|
| 1352 | + ); |
|
| 1353 | + // In Drupal, the sender should be attached as well |
|
| 1354 | + $sender_added = db_query(" |
|
| 1355 | 1355 | INSERT INTO {pm_index} (mid, thread_id, uid, is_new, deleted) |
| 1356 | 1356 | VALUES (%d, %d, %d, %d, 0)", |
| 1357 | 1357 | $mid, $mid, $sender_uid, 0 |
| 1358 | - ); |
|
| 1358 | + ); |
|
| 1359 | 1359 | |
| 1360 | - $message = ''; |
|
| 1361 | - if ($message_added AND $recipient_added AND $sender_added) { |
|
| 1360 | + $message = ''; |
|
| 1361 | + if ($message_added AND $recipient_added AND $sender_added) { |
|
| 1362 | 1362 | // Store some result for post-processing in the finished callback. |
| 1363 | 1363 | $context['results']['success'][] = $pm->id; |
| 1364 | 1364 | $message = "Successfully imported private message {$pm->id}"; |
| 1365 | - } |
|
| 1366 | - else { |
|
| 1365 | + } |
|
| 1366 | + else { |
|
| 1367 | 1367 | $context['results']['failure'][] = $pm->id; |
| 1368 | 1368 | $message = "Failed to import private message {$pm->id}!"; |
| 1369 | 1369 | watchdog('boincimport', |
| 1370 | - 'Failed to import private message @id!', |
|
| 1371 | - array('@id' => $pm->id), WATCHDOG_WARNING |
|
| 1370 | + 'Failed to import private message @id!', |
|
| 1371 | + array('@id' => $pm->id), WATCHDOG_WARNING |
|
| 1372 | 1372 | ); |
| 1373 | - } |
|
| 1373 | + } |
|
| 1374 | 1374 | |
| 1375 | - // Update our progress information. |
|
| 1376 | - $context['sandbox']['progress']++; |
|
| 1377 | - $context['sandbox']['current_pm'] = $pm->id; |
|
| 1378 | - $context['message'] = $message; |
|
| 1375 | + // Update our progress information. |
|
| 1376 | + $context['sandbox']['progress']++; |
|
| 1377 | + $context['sandbox']['current_pm'] = $pm->id; |
|
| 1378 | + $context['message'] = $message; |
|
| 1379 | 1379 | |
| 1380 | - // Update the progress for the batch engine |
|
| 1381 | - if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 1380 | + // Update the progress for the batch engine |
|
| 1381 | + if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 1382 | 1382 | $context['finished'] = 1; |
| 1383 | - } |
|
| 1384 | - else { |
|
| 1383 | + } |
|
| 1384 | + else { |
|
| 1385 | 1385 | $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
| 1386 | - } |
|
| 1386 | + } |
|
| 1387 | 1387 | } |
| 1388 | 1388 | |
| 1389 | 1389 | /** |
| 1390 | 1390 | * Batch 'finished' callback |
| 1391 | 1391 | */ |
| 1392 | 1392 | function boincimport_private_msgs_finished($success, $results, $operations) { |
| 1393 | - if ($success) { |
|
| 1393 | + if ($success) { |
|
| 1394 | 1394 | // Let's count our successes |
| 1395 | 1395 | $total_imported = count($results['success']); |
| 1396 | 1396 | $message = t( |
| 1397 | - 'Successfully imported @count private messages', |
|
| 1398 | - array('@count' => $total_imported) |
|
| 1397 | + 'Successfully imported @count private messages', |
|
| 1398 | + array('@count' => $total_imported) |
|
| 1399 | 1399 | ); |
| 1400 | 1400 | watchdog('boincimport', |
| 1401 | - 'Successfully imported @count private messages.', |
|
| 1402 | - array('@count' => $total_imported), WATCHDOG_INFO |
|
| 1401 | + 'Successfully imported @count private messages.', |
|
| 1402 | + array('@count' => $total_imported), WATCHDOG_INFO |
|
| 1403 | 1403 | ); |
| 1404 | 1404 | // Set the private message import successful flag in the variable table |
| 1405 | 1405 | variable_set('boincimport_import_private_msg_successful', '1'); |
| 1406 | 1406 | $_SESSION['boincimport_stage_selected'] = 'categories'; |
| 1407 | - } |
|
| 1408 | - else { |
|
| 1407 | + } |
|
| 1408 | + else { |
|
| 1409 | 1409 | // An error occurred. |
| 1410 | 1410 | // $operations contains the operations that remained unprocessed. |
| 1411 | 1411 | $error_operation = reset($operations); |
| 1412 | 1412 | $message = 'An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE); |
| 1413 | - } |
|
| 1414 | - drupal_set_message($message); |
|
| 1413 | + } |
|
| 1414 | + drupal_set_message($message); |
|
| 1415 | 1415 | |
| 1416 | - // Release the lock on the import process |
|
| 1417 | - variable_del('boincimport_process_locked'); |
|
| 1418 | - drupal_goto('admin/boinc/import/process'); |
|
| 1416 | + // Release the lock on the import process |
|
| 1417 | + variable_del('boincimport_process_locked'); |
|
| 1418 | + drupal_goto('admin/boinc/import/process'); |
|
| 1419 | 1419 | } |
| 1420 | 1420 | |
| 1421 | 1421 | |
@@ -1428,196 +1428,196 @@ discard block |
||
| 1428 | 1428 | */ |
| 1429 | 1429 | function boincimport_forum_categories() { |
| 1430 | 1430 | |
| 1431 | - // Check whether forums have been successfully imported already |
|
| 1432 | - if (variable_get('boincimport_import_forum_category_successful', 0)) { |
|
| 1431 | + // Check whether forums have been successfully imported already |
|
| 1432 | + if (variable_get('boincimport_import_forum_category_successful', 0)) { |
|
| 1433 | 1433 | drupal_set_message(t('Note: forum container import has already run successfully')); |
| 1434 | 1434 | watchdog( |
| 1435 | - 'boincimport', 'Note: forum container import has already run successfully', |
|
| 1436 | - array(), WATCHDOG_INFO |
|
| 1435 | + 'boincimport', 'Note: forum container import has already run successfully', |
|
| 1436 | + array(), WATCHDOG_INFO |
|
| 1437 | 1437 | ); |
| 1438 | - } |
|
| 1438 | + } |
|
| 1439 | 1439 | |
| 1440 | - if (!variable_get('boincimport_import_forum_category_started', 0)) { |
|
| 1440 | + if (!variable_get('boincimport_import_forum_category_started', 0)) { |
|
| 1441 | 1441 | // Could prepare database tables, if new fields are necessary, etc. |
| 1442 | 1442 | variable_set('boincimport_import_forum_category_started', 1); |
| 1443 | - } |
|
| 1443 | + } |
|
| 1444 | 1444 | |
| 1445 | - $pre = variable_get('boincimport_table_prefix', ''); |
|
| 1445 | + $pre = variable_get('boincimport_table_prefix', ''); |
|
| 1446 | 1446 | |
| 1447 | - // Retrieve the vocabulary vid named "Forums" |
|
| 1448 | - //$forum_vid = variable_get('forum_nav_vocabulary', 0); |
|
| 1449 | - $forum_vid = db_result(db_query(' |
|
| 1447 | + // Retrieve the vocabulary vid named "Forums" |
|
| 1448 | + //$forum_vid = variable_get('forum_nav_vocabulary', 0); |
|
| 1449 | + $forum_vid = db_result(db_query(' |
|
| 1450 | 1450 | SELECT vid FROM {vocabulary} |
| 1451 | 1451 | WHERE name="%s"', |
| 1452 | 1452 | 'Forums' |
| 1453 | - )); |
|
| 1454 | - if (!$forum_vid) { |
|
| 1453 | + )); |
|
| 1454 | + if (!$forum_vid) { |
|
| 1455 | 1455 | $forum_vocab = array( |
| 1456 | - 'name' => t('Forums'), |
|
| 1457 | - 'description' => t('The different forum categories / containers'), |
|
| 1456 | + 'name' => t('Forums'), |
|
| 1457 | + 'description' => t('The different forum categories / containers'), |
|
| 1458 | 1458 | ); |
| 1459 | 1459 | taxonomy_save_vocabulary($forum_vocab); |
| 1460 | 1460 | $forum_vid = db_result(db_query(' |
| 1461 | 1461 | SELECT vid FROM {vocabulary} |
| 1462 | 1462 | WHERE name="%s"', |
| 1463 | - 'Forums' |
|
| 1463 | + 'Forums' |
|
| 1464 | 1464 | )); |
| 1465 | - } |
|
| 1465 | + } |
|
| 1466 | 1466 | |
| 1467 | - // Get both categories and forums from BOINC |
|
| 1468 | - db_set_active('boinc_rw'); |
|
| 1469 | - $boinc_forum_categories = db_query(' |
|
| 1467 | + // Get both categories and forums from BOINC |
|
| 1468 | + db_set_active('boinc_rw'); |
|
| 1469 | + $boinc_forum_categories = db_query(' |
|
| 1470 | 1470 | SELECT id, name |
| 1471 | 1471 | FROM %scategory |
| 1472 | 1472 | ORDER BY orderID', |
| 1473 | 1473 | $pre |
| 1474 | - ); |
|
| 1475 | - $forum_category_count = mysqli_num_rows($boinc_forum_categories); |
|
| 1476 | - $boinc_forums = db_query(' |
|
| 1474 | + ); |
|
| 1475 | + $forum_category_count = mysqli_num_rows($boinc_forum_categories); |
|
| 1476 | + $boinc_forums = db_query(' |
|
| 1477 | 1477 | SELECT id, category, title, description, orderID |
| 1478 | 1478 | FROM %sforum |
| 1479 | 1479 | WHERE parent_type = 0 |
| 1480 | 1480 | ORDER BY category', |
| 1481 | 1481 | $pre |
| 1482 | - ); |
|
| 1483 | - $forum_count = mysqli_num_rows($boinc_forums); |
|
| 1484 | - db_set_active('default'); |
|
| 1482 | + ); |
|
| 1483 | + $forum_count = mysqli_num_rows($boinc_forums); |
|
| 1484 | + db_set_active('default'); |
|
| 1485 | 1485 | |
| 1486 | - if (!$forum_category_count) { |
|
| 1486 | + if (!$forum_category_count) { |
|
| 1487 | 1487 | drupal_set_message( |
| 1488 | - t('There were no forum containers found: Aborting script'), 'warning' |
|
| 1488 | + t('There were no forum containers found: Aborting script'), 'warning' |
|
| 1489 | 1489 | ); |
| 1490 | 1490 | watchdog('boincimport', |
| 1491 | - 'There were no forum containers found: Aborting script', array(), WATCHDOG_WARNING |
|
| 1491 | + 'There were no forum containers found: Aborting script', array(), WATCHDOG_WARNING |
|
| 1492 | 1492 | ); |
| 1493 | 1493 | // Release the lock on the import process |
| 1494 | 1494 | variable_del('boincimport_process_locked'); |
| 1495 | 1495 | return t('There were no forum containers found: Aborting script.'); |
| 1496 | - } |
|
| 1497 | - if (!$forum_count) { |
|
| 1496 | + } |
|
| 1497 | + if (!$forum_count) { |
|
| 1498 | 1498 | drupal_set_message( |
| 1499 | - t('There were no forums found: Aborting script'), 'warning' |
|
| 1499 | + t('There were no forums found: Aborting script'), 'warning' |
|
| 1500 | 1500 | ); |
| 1501 | 1501 | watchdog('boincimport', |
| 1502 | - 'There were no forums found: Aborting script', array(), WATCHDOG_WARNING |
|
| 1502 | + 'There were no forums found: Aborting script', array(), WATCHDOG_WARNING |
|
| 1503 | 1503 | ); |
| 1504 | 1504 | // Release the lock on the import process |
| 1505 | 1505 | variable_del('boincimport_process_locked'); |
| 1506 | 1506 | return t('There were no forums found: Aborting script.'); |
| 1507 | - } |
|
| 1507 | + } |
|
| 1508 | 1508 | |
| 1509 | - watchdog('boincimport', |
|
| 1509 | + watchdog('boincimport', |
|
| 1510 | 1510 | 'Found %forum_count forums in %category_count containers: Beginning Import', |
| 1511 | 1511 | array( |
| 1512 | - '%forum_count' => $forum_count, |
|
| 1513 | - '%category_count' => $forum_category_count, |
|
| 1512 | + '%forum_count' => $forum_count, |
|
| 1513 | + '%category_count' => $forum_category_count, |
|
| 1514 | 1514 | ), WATCHDOG_INFO |
| 1515 | - ); |
|
| 1516 | - |
|
| 1517 | - $operations = array(); |
|
| 1518 | - $existing_categories = array(); |
|
| 1519 | - $existing_forums = array(); |
|
| 1520 | - $duplicate_categories = array(); |
|
| 1521 | - $duplicate_forums = array(); |
|
| 1522 | - $category_map = array(); |
|
| 1523 | - |
|
| 1524 | - // Get the list of categories already in Drupal so as not to import any twice |
|
| 1525 | - $category_tree = taxonomy_get_tree($forum_vid, 0, -1, 1); |
|
| 1526 | - foreach ($category_tree as $term) { |
|
| 1515 | + ); |
|
| 1516 | + |
|
| 1517 | + $operations = array(); |
|
| 1518 | + $existing_categories = array(); |
|
| 1519 | + $existing_forums = array(); |
|
| 1520 | + $duplicate_categories = array(); |
|
| 1521 | + $duplicate_forums = array(); |
|
| 1522 | + $category_map = array(); |
|
| 1523 | + |
|
| 1524 | + // Get the list of categories already in Drupal so as not to import any twice |
|
| 1525 | + $category_tree = taxonomy_get_tree($forum_vid, 0, -1, 1); |
|
| 1526 | + foreach ($category_tree as $term) { |
|
| 1527 | 1527 | $existing_categories[] = $term->name; |
| 1528 | - } |
|
| 1528 | + } |
|
| 1529 | 1529 | |
| 1530 | - // Get the list of forums already in Drupal |
|
| 1531 | - $result = db_query(' |
|
| 1530 | + // Get the list of forums already in Drupal |
|
| 1531 | + $result = db_query(' |
|
| 1532 | 1532 | SELECT forum_id, tid FROM {boincimport_temp_forum}' |
| 1533 | - ); |
|
| 1534 | - while ($row = db_fetch_object($result)) { |
|
| 1533 | + ); |
|
| 1534 | + while ($row = db_fetch_object($result)) { |
|
| 1535 | 1535 | $existing_forums[$row->forum_id] = $row->tid; |
| 1536 | - } |
|
| 1536 | + } |
|
| 1537 | 1537 | |
| 1538 | - // Create batches to process |
|
| 1538 | + // Create batches to process |
|
| 1539 | 1539 | |
| 1540 | - // Set up the "hidden" category, if necessary |
|
| 1541 | - // This is to support automatic hiding of empty categories |
|
| 1542 | - $hidden_forum_tid = db_result(db_query(' |
|
| 1540 | + // Set up the "hidden" category, if necessary |
|
| 1541 | + // This is to support automatic hiding of empty categories |
|
| 1542 | + $hidden_forum_tid = db_result(db_query(' |
|
| 1543 | 1543 | SELECT tid FROM {term_data} |
| 1544 | 1544 | WHERE vid = %d |
| 1545 | 1545 | AND name = "%s"', |
| 1546 | 1546 | $forum_vid, 'Hidden' |
| 1547 | - )); |
|
| 1548 | - if (!$hidden_forum_tid) { |
|
| 1547 | + )); |
|
| 1548 | + if (!$hidden_forum_tid) { |
|
| 1549 | 1549 | $operations[] = array( |
| 1550 | - 'boincimport_forum_categories_op', array( |
|
| 1550 | + 'boincimport_forum_categories_op', array( |
|
| 1551 | 1551 | NULL, $forum_vid, $pre, TRUE |
| 1552 | - ) |
|
| 1552 | + ) |
|
| 1553 | 1553 | ); |
| 1554 | - } |
|
| 1554 | + } |
|
| 1555 | 1555 | |
| 1556 | - // Import categories |
|
| 1557 | - while ($boinc_forum_category = db_fetch_object($boinc_forum_categories)) { |
|
| 1556 | + // Import categories |
|
| 1557 | + while ($boinc_forum_category = db_fetch_object($boinc_forum_categories)) { |
|
| 1558 | 1558 | if (in_array($boinc_forum_category->name, $existing_categories)) { |
| 1559 | - // This category has already been imported |
|
| 1560 | - $duplicate_categories[] = $boinc_forum_category->name; |
|
| 1559 | + // This category has already been imported |
|
| 1560 | + $duplicate_categories[] = $boinc_forum_category->name; |
|
| 1561 | 1561 | } |
| 1562 | 1562 | else { |
| 1563 | - $operations[] = array( |
|
| 1563 | + $operations[] = array( |
|
| 1564 | 1564 | 'boincimport_forum_categories_op', array( |
| 1565 | - $boinc_forum_category, $forum_vid, $pre, FALSE |
|
| 1565 | + $boinc_forum_category, $forum_vid, $pre, FALSE |
|
| 1566 | 1566 | ) |
| 1567 | - ); |
|
| 1567 | + ); |
|
| 1568 | + } |
|
| 1568 | 1569 | } |
| 1569 | - } |
|
| 1570 | 1570 | |
| 1571 | - // Import forums |
|
| 1572 | - while ($boinc_forum = db_fetch_object($boinc_forums)) { |
|
| 1573 | - if (isset($existing_forums[$boinc_forum->id])) { |
|
| 1574 | - // This forum has already been imported |
|
| 1575 | - $duplicates[] = $boinc_forum->id; |
|
| 1571 | + // Import forums |
|
| 1572 | + while ($boinc_forum = db_fetch_object($boinc_forums)) { |
|
| 1573 | + if (isset($existing_forums[$boinc_forum->id])) { |
|
| 1574 | + // This forum has already been imported |
|
| 1575 | + $duplicates[] = $boinc_forum->id; |
|
| 1576 | 1576 | } |
| 1577 | 1577 | else { |
| 1578 | - $operations[] = array( |
|
| 1578 | + $operations[] = array( |
|
| 1579 | 1579 | 'boincimport_forums_op', array( |
| 1580 | - $boinc_forum, $forum_vid, $pre |
|
| 1580 | + $boinc_forum, $forum_vid, $pre |
|
| 1581 | 1581 | ) |
| 1582 | - ); |
|
| 1582 | + ); |
|
| 1583 | + } |
|
| 1583 | 1584 | } |
| 1584 | - } |
|
| 1585 | 1585 | |
| 1586 | - // Report any duplicates that were skipped |
|
| 1587 | - $skipped_message = array(); |
|
| 1588 | - $categories_skipped = count($duplicate_categories); |
|
| 1589 | - $forums_skipped = count($duplicate_forums); |
|
| 1590 | - if ($categories_skipped) { |
|
| 1586 | + // Report any duplicates that were skipped |
|
| 1587 | + $skipped_message = array(); |
|
| 1588 | + $categories_skipped = count($duplicate_categories); |
|
| 1589 | + $forums_skipped = count($duplicate_forums); |
|
| 1590 | + if ($categories_skipped) { |
|
| 1591 | 1591 | $skipped_message[] = format_plural( |
| 1592 | - $categories_skipped, |
|
| 1593 | - '1 container', |
|
| 1594 | - '@count containers' |
|
| 1592 | + $categories_skipped, |
|
| 1593 | + '1 container', |
|
| 1594 | + '@count containers' |
|
| 1595 | 1595 | ); |
| 1596 | - } |
|
| 1597 | - if ($forums_skipped) { |
|
| 1596 | + } |
|
| 1597 | + if ($forums_skipped) { |
|
| 1598 | 1598 | $skipped_message[] = format_plural( |
| 1599 | - $forums_skipped, |
|
| 1600 | - '1 forum', |
|
| 1601 | - '@count forums' |
|
| 1599 | + $forums_skipped, |
|
| 1600 | + '1 forum', |
|
| 1601 | + '@count forums' |
|
| 1602 | 1602 | ); |
| 1603 | - } |
|
| 1604 | - if ($skipped_message) { |
|
| 1603 | + } |
|
| 1604 | + if ($skipped_message) { |
|
| 1605 | 1605 | drupal_set_message(t('Skipped @forums that were already imported', |
| 1606 | - array('@forums' => implode(' and ', $skipped_message)) |
|
| 1606 | + array('@forums' => implode(' and ', $skipped_message)) |
|
| 1607 | 1607 | )); |
| 1608 | - } |
|
| 1608 | + } |
|
| 1609 | 1609 | |
| 1610 | - // Create and run the batch |
|
| 1611 | - $batch = array( |
|
| 1610 | + // Create and run the batch |
|
| 1611 | + $batch = array( |
|
| 1612 | 1612 | 'operations' => $operations, |
| 1613 | 1613 | 'finished' => 'boincimport_forums_finished', |
| 1614 | 1614 | 'title' => t('Importing forums'), |
| 1615 | 1615 | 'init_message' => t('Beginning forum import...'), |
| 1616 | 1616 | 'progress_message' => t('Processed @current out of @total forums.'), |
| 1617 | 1617 | 'error_message' => t('Forum import has encountered an error.'), |
| 1618 | - ); |
|
| 1618 | + ); |
|
| 1619 | 1619 | |
| 1620 | - batch_set($batch); |
|
| 1620 | + batch_set($batch); |
|
| 1621 | 1621 | } |
| 1622 | 1622 | |
| 1623 | 1623 | /** |
@@ -1626,92 +1626,92 @@ discard block |
||
| 1626 | 1626 | */ |
| 1627 | 1627 | function boincimport_forum_categories_op($category, $forum_vid, $pre, $create_hidden, &$context) { |
| 1628 | 1628 | |
| 1629 | - // Set term parameters for categories |
|
| 1630 | - $forum_id = 0; |
|
| 1631 | - $parent_id = 0; |
|
| 1632 | - $description = ''; |
|
| 1633 | - $weight = 0; |
|
| 1634 | - $hidden = FALSE; |
|
| 1629 | + // Set term parameters for categories |
|
| 1630 | + $forum_id = 0; |
|
| 1631 | + $parent_id = 0; |
|
| 1632 | + $description = ''; |
|
| 1633 | + $weight = 0; |
|
| 1634 | + $hidden = FALSE; |
|
| 1635 | 1635 | |
| 1636 | - $category_map = variable_get('boincimport_forum_category_map', array()); |
|
| 1636 | + $category_map = variable_get('boincimport_forum_category_map', array()); |
|
| 1637 | 1637 | |
| 1638 | - if (!$category AND $create_hidden) { |
|
| 1638 | + if (!$category AND $create_hidden) { |
|
| 1639 | 1639 | // Create the special "hidden" container |
| 1640 | 1640 | $category = new stdClass(); |
| 1641 | 1641 | $category->name = 'Hidden'; |
| 1642 | 1642 | $category->id = 0; |
| 1643 | 1643 | $hidden = TRUE; |
| 1644 | - } |
|
| 1645 | - else { |
|
| 1644 | + } |
|
| 1645 | + else { |
|
| 1646 | 1646 | // If this container is empty, put it into the hidden container |
| 1647 | 1647 | db_set_active('boinc_rw'); |
| 1648 | 1648 | $forums_contained = db_result(db_query(' |
| 1649 | 1649 | SELECT count(*) FROM %sforum |
| 1650 | 1650 | WHERE parent_type = 0 |
| 1651 | 1651 | AND category = %d', |
| 1652 | - $pre, $category->id)); |
|
| 1652 | + $pre, $category->id)); |
|
| 1653 | 1653 | db_set_active('default'); |
| 1654 | 1654 | if (!$forums_contained) { |
| 1655 | - $parent_id = $category_map[0]; |
|
| 1656 | - $hidden = TRUE; |
|
| 1655 | + $parent_id = $category_map[0]; |
|
| 1656 | + $hidden = TRUE; |
|
| 1657 | + } |
|
| 1657 | 1658 | } |
| 1658 | - } |
|
| 1659 | 1659 | |
| 1660 | - $forum = array( |
|
| 1660 | + $forum = array( |
|
| 1661 | 1661 | 'name' => $category->name, |
| 1662 | 1662 | 'vid' => $forum_vid, |
| 1663 | 1663 | 'description' => $description, |
| 1664 | 1664 | 'parent' => $parent_id, |
| 1665 | 1665 | 'weight' => $weight, |
| 1666 | - ); |
|
| 1667 | - $forum['description'] = strip_tags($forum['description']); |
|
| 1666 | + ); |
|
| 1667 | + $forum['description'] = strip_tags($forum['description']); |
|
| 1668 | 1668 | |
| 1669 | - taxonomy_save_term($forum); |
|
| 1670 | - $success = isset($forum['tid']); |
|
| 1669 | + taxonomy_save_term($forum); |
|
| 1670 | + $success = isset($forum['tid']); |
|
| 1671 | 1671 | |
| 1672 | - // Serialize the forum containers |
|
| 1673 | - $containers = variable_get('forum_containers', array()); |
|
| 1674 | - $containers[] = $forum['tid']; |
|
| 1675 | - variable_set('forum_containers', $containers); |
|
| 1672 | + // Serialize the forum containers |
|
| 1673 | + $containers = variable_get('forum_containers', array()); |
|
| 1674 | + $containers[] = $forum['tid']; |
|
| 1675 | + variable_set('forum_containers', $containers); |
|
| 1676 | 1676 | |
| 1677 | - // Note the taxonomy ID for mapping forums to categories |
|
| 1678 | - $category_map[$category->id] = $forum['tid']; |
|
| 1679 | - variable_set('boincimport_forum_category_map', $category_map); |
|
| 1677 | + // Note the taxonomy ID for mapping forums to categories |
|
| 1678 | + $category_map[$category->id] = $forum['tid']; |
|
| 1679 | + variable_set('boincimport_forum_category_map', $category_map); |
|
| 1680 | 1680 | |
| 1681 | - boincimport_forum_set_permissions($forum, $hidden); |
|
| 1681 | + boincimport_forum_set_permissions($forum, $hidden); |
|
| 1682 | 1682 | |
| 1683 | - $message = ''; |
|
| 1684 | - if ($success) { |
|
| 1683 | + $message = ''; |
|
| 1684 | + if ($success) { |
|
| 1685 | 1685 | // Store some result for post-processing in the finished callback. |
| 1686 | 1686 | if (!$category AND $create_hidden) { |
| 1687 | - $message = "Created special hidden container"; |
|
| 1687 | + $message = "Created special hidden container"; |
|
| 1688 | 1688 | } |
| 1689 | 1689 | else { |
| 1690 | - $context['results']['categories']['success'][] = $category->id; |
|
| 1691 | - $message = "Successfully imported container {$category->id}"; |
|
| 1690 | + $context['results']['categories']['success'][] = $category->id; |
|
| 1691 | + $message = "Successfully imported container {$category->id}"; |
|
| 1692 | 1692 | } |
| 1693 | - } |
|
| 1694 | - else { |
|
| 1693 | + } |
|
| 1694 | + else { |
|
| 1695 | 1695 | $context['results']['categories']['failure'][] = $category->id; |
| 1696 | 1696 | $message = "Failed to import container {$category->id}!"; |
| 1697 | 1697 | watchdog('boincimport', |
| 1698 | - 'Failed to import container @id!', |
|
| 1699 | - array('@id' => $category->id), WATCHDOG_WARNING |
|
| 1698 | + 'Failed to import container @id!', |
|
| 1699 | + array('@id' => $category->id), WATCHDOG_WARNING |
|
| 1700 | 1700 | ); |
| 1701 | - } |
|
| 1701 | + } |
|
| 1702 | 1702 | |
| 1703 | - // Update our progress information. |
|
| 1704 | - $context['sandbox']['progress']++; |
|
| 1705 | - $context['sandbox']['current_category'] = $category->id; |
|
| 1706 | - $context['message'] = $message; |
|
| 1703 | + // Update our progress information. |
|
| 1704 | + $context['sandbox']['progress']++; |
|
| 1705 | + $context['sandbox']['current_category'] = $category->id; |
|
| 1706 | + $context['message'] = $message; |
|
| 1707 | 1707 | |
| 1708 | - // Update the progress for the batch engine |
|
| 1709 | - if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 1708 | + // Update the progress for the batch engine |
|
| 1709 | + if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 1710 | 1710 | $context['finished'] = 1; |
| 1711 | - } |
|
| 1712 | - else { |
|
| 1711 | + } |
|
| 1712 | + else { |
|
| 1713 | 1713 | $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
| 1714 | - } |
|
| 1714 | + } |
|
| 1715 | 1715 | } |
| 1716 | 1716 | |
| 1717 | 1717 | /** |
@@ -1720,40 +1720,40 @@ discard block |
||
| 1720 | 1720 | */ |
| 1721 | 1721 | function boincimport_forums_op($boincforum, $forum_vid, $pre = '', &$context) { |
| 1722 | 1722 | |
| 1723 | - $hidden_forum = FALSE; |
|
| 1724 | - $open_forum = FALSE; |
|
| 1725 | - $category_map = variable_get('boincimport_forum_category_map', array()); |
|
| 1726 | - |
|
| 1727 | - // Set term parameters for forums |
|
| 1728 | - $forum_id = $boincforum->id; |
|
| 1729 | - $parent_id = isset($category_map[$boincforum->category]) ? $category_map[$boincforum->category] : $category_map[0]; |
|
| 1730 | - $name = $boincforum->title; |
|
| 1731 | - $description = $boincforum->description; |
|
| 1732 | - $weight = $boincforum->orderID; |
|
| 1733 | - if ($parent_id == $category_map[0]) { |
|
| 1723 | + $hidden_forum = FALSE; |
|
| 1724 | + $open_forum = FALSE; |
|
| 1725 | + $category_map = variable_get('boincimport_forum_category_map', array()); |
|
| 1726 | + |
|
| 1727 | + // Set term parameters for forums |
|
| 1728 | + $forum_id = $boincforum->id; |
|
| 1729 | + $parent_id = isset($category_map[$boincforum->category]) ? $category_map[$boincforum->category] : $category_map[0]; |
|
| 1730 | + $name = $boincforum->title; |
|
| 1731 | + $description = $boincforum->description; |
|
| 1732 | + $weight = $boincforum->orderID; |
|
| 1733 | + if ($parent_id == $category_map[0]) { |
|
| 1734 | 1734 | // If this forum is hidden, flag for appropriate access controls |
| 1735 | 1735 | $hidden_forum = TRUE; |
| 1736 | - } |
|
| 1737 | - if ($name == 'Getting Started') { |
|
| 1736 | + } |
|
| 1737 | + if ($name == 'Getting Started') { |
|
| 1738 | 1738 | // Must allow users to post in this forum even if they have no credit! |
| 1739 | 1739 | $open_forum = TRUE; |
| 1740 | - } |
|
| 1740 | + } |
|
| 1741 | 1741 | |
| 1742 | - // Try to detect a BOINC news forum and flag it so that news can be |
|
| 1743 | - // imported into a Drupal news content type later |
|
| 1744 | - if ($name == 'News') { |
|
| 1742 | + // Try to detect a BOINC news forum and flag it so that news can be |
|
| 1743 | + // imported into a Drupal news content type later |
|
| 1744 | + if ($name == 'News') { |
|
| 1745 | 1745 | // Save the ID of the News forum for later import |
| 1746 | 1746 | variable_set('boincimport_news_forum_id', $forum_id); |
| 1747 | 1747 | $success = TRUE; |
| 1748 | - } |
|
| 1749 | - else { |
|
| 1748 | + } |
|
| 1749 | + else { |
|
| 1750 | 1750 | // Save all other forums as taxonomy terms |
| 1751 | 1751 | $forum = array( |
| 1752 | - 'name' => $name, |
|
| 1753 | - 'vid' => $forum_vid, |
|
| 1754 | - 'description' => $description, |
|
| 1755 | - 'parent' => $parent_id, |
|
| 1756 | - 'weight' => $weight, |
|
| 1752 | + 'name' => $name, |
|
| 1753 | + 'vid' => $forum_vid, |
|
| 1754 | + 'description' => $description, |
|
| 1755 | + 'parent' => $parent_id, |
|
| 1756 | + 'weight' => $weight, |
|
| 1757 | 1757 | ); |
| 1758 | 1758 | $forum['description'] = strip_tags($forum['description']); |
| 1759 | 1759 | |
@@ -1765,31 +1765,31 @@ discard block |
||
| 1765 | 1765 | |
| 1766 | 1766 | // Set access controls |
| 1767 | 1767 | boincimport_forum_set_permissions($forum, $hidden_forum, $open_forum); |
| 1768 | - } |
|
| 1768 | + } |
|
| 1769 | 1769 | |
| 1770 | - $message = ''; |
|
| 1771 | - if ($success) { |
|
| 1770 | + $message = ''; |
|
| 1771 | + if ($success) { |
|
| 1772 | 1772 | // Store some result for post-processing in the finished callback. |
| 1773 | 1773 | $context['results']['forums']['success'][] = $forum_id; |
| 1774 | 1774 | $message = "Successfully imported forum {$forum_id}"; |
| 1775 | - } |
|
| 1776 | - else { |
|
| 1775 | + } |
|
| 1776 | + else { |
|
| 1777 | 1777 | $context['results']['forums']['failure'][] = $forum_id; |
| 1778 | 1778 | $message = "Failed to import forum {$forum_id}!"; |
| 1779 | - } |
|
| 1779 | + } |
|
| 1780 | 1780 | |
| 1781 | - // Update our progress information. |
|
| 1782 | - $context['sandbox']['progress']++; |
|
| 1783 | - $context['sandbox']['current_forum'] = $forum_id; |
|
| 1784 | - $context['message'] = $message; |
|
| 1781 | + // Update our progress information. |
|
| 1782 | + $context['sandbox']['progress']++; |
|
| 1783 | + $context['sandbox']['current_forum'] = $forum_id; |
|
| 1784 | + $context['message'] = $message; |
|
| 1785 | 1785 | |
| 1786 | - // Update the progress for the batch engine |
|
| 1787 | - if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 1786 | + // Update the progress for the batch engine |
|
| 1787 | + if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 1788 | 1788 | $context['finished'] = 1; |
| 1789 | - } |
|
| 1790 | - else { |
|
| 1789 | + } |
|
| 1790 | + else { |
|
| 1791 | 1791 | $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
| 1792 | - } |
|
| 1792 | + } |
|
| 1793 | 1793 | } |
| 1794 | 1794 | |
| 1795 | 1795 | /** |
@@ -1797,46 +1797,46 @@ discard block |
||
| 1797 | 1797 | */ |
| 1798 | 1798 | function boincimport_forum_set_permissions($forum, $hidden = FALSE, $open = FALSE) { |
| 1799 | 1799 | |
| 1800 | - // Set access controls |
|
| 1801 | - $forum_perms = array(); |
|
| 1802 | - $role_map = array_flip(user_roles()); |
|
| 1803 | - $forum_perms[$role_map['anonymous user']] = array( |
|
| 1800 | + // Set access controls |
|
| 1801 | + $forum_perms = array(); |
|
| 1802 | + $role_map = array_flip(user_roles()); |
|
| 1803 | + $forum_perms[$role_map['anonymous user']] = array( |
|
| 1804 | 1804 | 'view' => (int) !$hidden, |
| 1805 | 1805 | 'update' => 0, |
| 1806 | 1806 | 'delete' => 0, |
| 1807 | 1807 | 'create' => 0, |
| 1808 | - ); |
|
| 1809 | - $forum_perms[$role_map['authenticated user']] = array( |
|
| 1808 | + ); |
|
| 1809 | + $forum_perms[$role_map['authenticated user']] = array( |
|
| 1810 | 1810 | 'view' => (int) !$hidden, |
| 1811 | 1811 | 'update' => 0, |
| 1812 | 1812 | 'delete' => 0, |
| 1813 | 1813 | 'create' => 0, |
| 1814 | - ); |
|
| 1815 | - $forum_perms[$role_map['community member']] = array( |
|
| 1814 | + ); |
|
| 1815 | + $forum_perms[$role_map['community member']] = array( |
|
| 1816 | 1816 | 'view' => (int) !$hidden, |
| 1817 | 1817 | 'update' => 0, |
| 1818 | 1818 | 'delete' => 0, |
| 1819 | 1819 | 'create' => (int) $open, |
| 1820 | - ); |
|
| 1821 | - $forum_perms[$role_map['verified contributor']] = array( |
|
| 1820 | + ); |
|
| 1821 | + $forum_perms[$role_map['verified contributor']] = array( |
|
| 1822 | 1822 | 'view' => (int) !$hidden, |
| 1823 | 1823 | 'update' => 0, |
| 1824 | 1824 | 'delete' => 0, |
| 1825 | 1825 | 'create' => (int) !$hidden, |
| 1826 | - ); |
|
| 1827 | - $forum_perms[$role_map['moderator']] = array( |
|
| 1826 | + ); |
|
| 1827 | + $forum_perms[$role_map['moderator']] = array( |
|
| 1828 | 1828 | 'view' => (int) !$hidden, |
| 1829 | 1829 | 'update' => (int) !$hidden, |
| 1830 | 1830 | 'delete' => 0, |
| 1831 | 1831 | 'create' => (int) !$hidden, |
| 1832 | - ); |
|
| 1833 | - $forum_perms[$role_map['administrator']] = array( |
|
| 1832 | + ); |
|
| 1833 | + $forum_perms[$role_map['administrator']] = array( |
|
| 1834 | 1834 | 'view' => 1, |
| 1835 | 1835 | 'update' => 1, |
| 1836 | 1836 | 'delete' => 1, |
| 1837 | 1837 | 'create' => 1, |
| 1838 | - ); |
|
| 1839 | - foreach ($forum_perms as $role => $perm) { |
|
| 1838 | + ); |
|
| 1839 | + foreach ($forum_perms as $role => $perm) { |
|
| 1840 | 1840 | db_query(' |
| 1841 | 1841 | INSERT INTO {forum_access} |
| 1842 | 1842 | SET tid = %d, rid = %d, |
@@ -1845,61 +1845,61 @@ discard block |
||
| 1845 | 1845 | ON DUPLICATE KEY UPDATE |
| 1846 | 1846 | grant_view = %d, grant_update = %d, |
| 1847 | 1847 | grant_delete = %d, grant_create = %d', |
| 1848 | - $forum['tid'], $role, |
|
| 1849 | - $perm['view'], $perm['update'], |
|
| 1850 | - $perm['delete'], $perm['create'], |
|
| 1851 | - $perm['view'], $perm['update'], |
|
| 1852 | - $perm['delete'], $perm['create']); |
|
| 1853 | - } |
|
| 1848 | + $forum['tid'], $role, |
|
| 1849 | + $perm['view'], $perm['update'], |
|
| 1850 | + $perm['delete'], $perm['create'], |
|
| 1851 | + $perm['view'], $perm['update'], |
|
| 1852 | + $perm['delete'], $perm['create']); |
|
| 1853 | + } |
|
| 1854 | 1854 | } |
| 1855 | 1855 | |
| 1856 | 1856 | /** |
| 1857 | 1857 | * Batch 'finished' callback |
| 1858 | 1858 | */ |
| 1859 | 1859 | function boincimport_forums_finished($success, $results, $operations) { |
| 1860 | - if ($success) { |
|
| 1860 | + if ($success) { |
|
| 1861 | 1861 | // Let's count our successes |
| 1862 | 1862 | $categories_imported = count($results['categories']['success']); |
| 1863 | 1863 | $forums_imported = count($results['forums']['success']); |
| 1864 | 1864 | |
| 1865 | 1865 | $success_message = array(); |
| 1866 | 1866 | if ($categories_imported) { |
| 1867 | - $success_message[] = format_plural( |
|
| 1867 | + $success_message[] = format_plural( |
|
| 1868 | 1868 | $categories_imported, |
| 1869 | 1869 | '1 container', |
| 1870 | 1870 | '@count containers' |
| 1871 | - ); |
|
| 1871 | + ); |
|
| 1872 | 1872 | } |
| 1873 | 1873 | if ($forums_imported) { |
| 1874 | - $success_message[] = format_plural( |
|
| 1874 | + $success_message[] = format_plural( |
|
| 1875 | 1875 | $forums_imported, |
| 1876 | 1876 | '1 forum', |
| 1877 | 1877 | '@count forums' |
| 1878 | - ); |
|
| 1878 | + ); |
|
| 1879 | 1879 | } |
| 1880 | 1880 | $message = t( |
| 1881 | - 'Successfully imported @forums', |
|
| 1882 | - array('@forums' => implode(' and ', $success_message)) |
|
| 1881 | + 'Successfully imported @forums', |
|
| 1882 | + array('@forums' => implode(' and ', $success_message)) |
|
| 1883 | 1883 | ); |
| 1884 | 1884 | watchdog('boincimport', |
| 1885 | - 'Successfully imported @forums', |
|
| 1886 | - array('@forums' => implode(' and ', $success_message)), WATCHDOG_INFO |
|
| 1885 | + 'Successfully imported @forums', |
|
| 1886 | + array('@forums' => implode(' and ', $success_message)), WATCHDOG_INFO |
|
| 1887 | 1887 | ); |
| 1888 | 1888 | // Set the forum import successful flag in the variable table |
| 1889 | 1889 | variable_set('boincimport_import_forum_successful', '1'); |
| 1890 | 1890 | $_SESSION['boincimport_stage_selected'] = 'topics'; |
| 1891 | - } |
|
| 1892 | - else { |
|
| 1891 | + } |
|
| 1892 | + else { |
|
| 1893 | 1893 | // An error occurred. |
| 1894 | 1894 | // $operations contains the operations that remained unprocessed. |
| 1895 | 1895 | $error_operation = reset($operations); |
| 1896 | 1896 | $message = 'An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE); |
| 1897 | - } |
|
| 1898 | - drupal_set_message($message); |
|
| 1897 | + } |
|
| 1898 | + drupal_set_message($message); |
|
| 1899 | 1899 | |
| 1900 | - // Release the lock on the import process |
|
| 1901 | - variable_del('boincimport_process_locked'); |
|
| 1902 | - drupal_goto('admin/boinc/import/process'); |
|
| 1900 | + // Release the lock on the import process |
|
| 1901 | + variable_del('boincimport_process_locked'); |
|
| 1902 | + drupal_goto('admin/boinc/import/process'); |
|
| 1903 | 1903 | } |
| 1904 | 1904 | |
| 1905 | 1905 | |
@@ -1911,82 +1911,82 @@ discard block |
||
| 1911 | 1911 | */ |
| 1912 | 1912 | function boincimport_forum_topics() { |
| 1913 | 1913 | |
| 1914 | - // Check whether topics have been successfully imported already |
|
| 1915 | - if (variable_get('boincimport_import_topic_successful', 0)) { |
|
| 1914 | + // Check whether topics have been successfully imported already |
|
| 1915 | + if (variable_get('boincimport_import_topic_successful', 0)) { |
|
| 1916 | 1916 | drupal_set_message(t('Topic import has already run successfully'), 'warning'); |
| 1917 | 1917 | watchdog( |
| 1918 | - 'boincimport', 'Topic import has already run successfully', |
|
| 1919 | - array(), WATCHDOG_WARNING |
|
| 1918 | + 'boincimport', 'Topic import has already run successfully', |
|
| 1919 | + array(), WATCHDOG_WARNING |
|
| 1920 | 1920 | ); |
| 1921 | 1921 | // Release the lock on the import process |
| 1922 | 1922 | variable_del('boincimport_process_locked'); |
| 1923 | 1923 | return; |
| 1924 | - } |
|
| 1924 | + } |
|
| 1925 | 1925 | |
| 1926 | - if (!variable_get('boincimport_import_topic_started', 0)) { |
|
| 1926 | + if (!variable_get('boincimport_import_topic_started', 0)) { |
|
| 1927 | 1927 | // Could prepare database tables, if new fields are necessary, etc. |
| 1928 | 1928 | variable_set('boincimport_import_topic_started', 1); |
| 1929 | - } |
|
| 1929 | + } |
|
| 1930 | 1930 | |
| 1931 | - $pre = variable_get('boincimport_table_prefix', ''); |
|
| 1931 | + $pre = variable_get('boincimport_table_prefix', ''); |
|
| 1932 | 1932 | |
| 1933 | - // Get the count of non-team topics to import |
|
| 1934 | - db_set_active('boinc_rw'); |
|
| 1935 | - $topic_count = db_result(db_query(' |
|
| 1933 | + // Get the count of non-team topics to import |
|
| 1934 | + db_set_active('boinc_rw'); |
|
| 1935 | + $topic_count = db_result(db_query(' |
|
| 1936 | 1936 | SELECT COUNT(DISTINCT t.id) |
| 1937 | 1937 | FROM %sthread t |
| 1938 | 1938 | JOIN %sforum f ON f.id = t.forum |
| 1939 | 1939 | JOIN %spost p ON p.thread = t.id |
| 1940 | 1940 | WHERE f.parent_type = 0', |
| 1941 | 1941 | $pre, $pre, $pre |
| 1942 | - )); |
|
| 1943 | - db_set_active('default'); |
|
| 1942 | + )); |
|
| 1943 | + db_set_active('default'); |
|
| 1944 | 1944 | |
| 1945 | - if (!$topic_count) { |
|
| 1945 | + if (!$topic_count) { |
|
| 1946 | 1946 | drupal_set_message( |
| 1947 | - t('There were no topics found: Aborting script'), 'warning' |
|
| 1947 | + t('There were no topics found: Aborting script'), 'warning' |
|
| 1948 | 1948 | ); |
| 1949 | 1949 | watchdog('boincimport', |
| 1950 | - 'There were no topics found: Aborting script', array(), WATCHDOG_WARNING |
|
| 1950 | + 'There were no topics found: Aborting script', array(), WATCHDOG_WARNING |
|
| 1951 | 1951 | ); |
| 1952 | 1952 | // Release the lock on the import process |
| 1953 | 1953 | variable_del('boincimport_process_locked'); |
| 1954 | 1954 | return t('There were no topics found: Aborting script.'); |
| 1955 | - } |
|
| 1955 | + } |
|
| 1956 | 1956 | |
| 1957 | - watchdog('boincimport', |
|
| 1957 | + watchdog('boincimport', |
|
| 1958 | 1958 | 'Found %count topics: Beginning Import', |
| 1959 | 1959 | array('%count' => $topic_count), WATCHDOG_INFO |
| 1960 | - ); |
|
| 1960 | + ); |
|
| 1961 | 1961 | |
| 1962 | - $operations = array(); |
|
| 1963 | - $batch_size = 100; |
|
| 1962 | + $operations = array(); |
|
| 1963 | + $batch_size = 100; |
|
| 1964 | 1964 | |
| 1965 | - // Create batches to process |
|
| 1966 | - for ($offset = 0; $offset < $topic_count; $offset+=$batch_size) { |
|
| 1965 | + // Create batches to process |
|
| 1966 | + for ($offset = 0; $offset < $topic_count; $offset+=$batch_size) { |
|
| 1967 | 1967 | $topics_per_batch = $batch_size; |
| 1968 | 1968 | if ($offset + $batch_size > $topic_count) { |
| 1969 | - $topics_per_batch = $topic_count - $offset; |
|
| 1969 | + $topics_per_batch = $topic_count - $offset; |
|
| 1970 | 1970 | } |
| 1971 | 1971 | $operations[] = array( |
| 1972 | - 'boincimport_topics_op', array( |
|
| 1972 | + 'boincimport_topics_op', array( |
|
| 1973 | 1973 | $offset, $topics_per_batch, $pre |
| 1974 | - ) |
|
| 1974 | + ) |
|
| 1975 | 1975 | ); |
| 1976 | - } |
|
| 1976 | + } |
|
| 1977 | 1977 | |
| 1978 | - $batch = array( |
|
| 1978 | + $batch = array( |
|
| 1979 | 1979 | 'operations' => $operations, |
| 1980 | 1980 | 'finished' => 'boincimport_topics_finished', |
| 1981 | 1981 | 'title' => t('Importing topics'), |
| 1982 | 1982 | 'init_message' => t('Beginning topic import...'), |
| 1983 | 1983 | 'progress_message' => t('Processed @current out of @total batches (@size topics per batch).', array( |
| 1984 | - '@size' => $batch_size, |
|
| 1984 | + '@size' => $batch_size, |
|
| 1985 | 1985 | )), |
| 1986 | 1986 | 'error_message' => t('Topic import has encountered an error.'), |
| 1987 | - ); |
|
| 1987 | + ); |
|
| 1988 | 1988 | |
| 1989 | - batch_set($batch); |
|
| 1989 | + batch_set($batch); |
|
| 1990 | 1990 | } |
| 1991 | 1991 | |
| 1992 | 1992 | /** |
@@ -1994,18 +1994,18 @@ discard block |
||
| 1994 | 1994 | * Create a Drupal node from the given BOINC topic object |
| 1995 | 1995 | */ |
| 1996 | 1996 | function boincimport_topics_op($offset, $batch_size, $pre = '', &$context) { |
| 1997 | - // Initialize the batch, if needed |
|
| 1998 | - if (!isset($context['sandbox']['progress'])) { |
|
| 1997 | + // Initialize the batch, if needed |
|
| 1998 | + if (!isset($context['sandbox']['progress'])) { |
|
| 1999 | 1999 | $context['sandbox']['progress'] = 0; |
| 2000 | 2000 | $context['sandbox']['max'] = $batch_size; |
| 2001 | - } |
|
| 2001 | + } |
|
| 2002 | 2002 | |
| 2003 | - $input_format = variable_get('boincimport_input_format', 0); |
|
| 2004 | - $news_forum_id = variable_get('boincimport_news_forum_id', 0); |
|
| 2003 | + $input_format = variable_get('boincimport_input_format', 0); |
|
| 2004 | + $news_forum_id = variable_get('boincimport_news_forum_id', 0); |
|
| 2005 | 2005 | |
| 2006 | - // Get the topic to import |
|
| 2007 | - db_set_active('boinc_rw'); |
|
| 2008 | - $topics = db_query(' |
|
| 2006 | + // Get the topic to import |
|
| 2007 | + db_set_active('boinc_rw'); |
|
| 2008 | + $topics = db_query(' |
|
| 2009 | 2009 | SELECT DISTINCT t.id, t.title, t.owner, t.forum, t.locked, t.hidden, |
| 2010 | 2010 | t.sticky, t.timestamp, t.create_time |
| 2011 | 2011 | FROM %sthread t |
@@ -2015,10 +2015,10 @@ discard block |
||
| 2015 | 2015 | ORDER BY t.id ASC |
| 2016 | 2016 | LIMIT %d,%d', |
| 2017 | 2017 | $pre, $pre, $pre, $offset, $batch_size |
| 2018 | - ); |
|
| 2019 | - db_set_active('default'); |
|
| 2018 | + ); |
|
| 2019 | + db_set_active('default'); |
|
| 2020 | 2020 | |
| 2021 | - while ($topic = db_fetch_object($topics)) { |
|
| 2021 | + while ($topic = db_fetch_object($topics)) { |
|
| 2022 | 2022 | |
| 2023 | 2023 | $error_detail = ''; |
| 2024 | 2024 | |
@@ -2031,52 +2031,52 @@ discard block |
||
| 2031 | 2031 | WHERE thread = %d |
| 2032 | 2032 | ORDER BY timestamp ASC |
| 2033 | 2033 | LIMIT 1', |
| 2034 | - $pre, $topic->id |
|
| 2034 | + $pre, $topic->id |
|
| 2035 | 2035 | )); |
| 2036 | 2036 | db_set_active('default'); |
| 2037 | 2037 | |
| 2038 | 2038 | $duplicate = db_result(db_query(' |
| 2039 | 2039 | SELECT COUNT(*) FROM {boincimport_temp_topic} |
| 2040 | 2040 | WHERE topic_id = %d', |
| 2041 | - $topic->id |
|
| 2041 | + $topic->id |
|
| 2042 | 2042 | )); |
| 2043 | 2043 | |
| 2044 | 2044 | if ($duplicate OR !$post) { |
| 2045 | - $success = FALSE; |
|
| 2045 | + $success = FALSE; |
|
| 2046 | 2046 | } |
| 2047 | 2047 | |
| 2048 | 2048 | else { |
| 2049 | - // Get the user and term IDs along with other data to define the topic |
|
| 2050 | - $uid = boincuser_lookup_uid($topic->owner); |
|
| 2051 | - $tid = db_result(db_query(' |
|
| 2049 | + // Get the user and term IDs along with other data to define the topic |
|
| 2050 | + $uid = boincuser_lookup_uid($topic->owner); |
|
| 2051 | + $tid = db_result(db_query(' |
|
| 2052 | 2052 | SELECT tid FROM {boincimport_temp_forum} |
| 2053 | 2053 | WHERE forum_id = %d', |
| 2054 | 2054 | $topic->forum |
| 2055 | - )); |
|
| 2056 | - if (!$topic->owner) { |
|
| 2055 | + )); |
|
| 2056 | + if (!$topic->owner) { |
|
| 2057 | 2057 | $uid = 0; |
| 2058 | - } |
|
| 2058 | + } |
|
| 2059 | 2059 | |
| 2060 | - $node_type = 'forum'; |
|
| 2061 | - $promote = 0; |
|
| 2062 | - $comment = ($topic->locked) ? 1 : 2; |
|
| 2060 | + $node_type = 'forum'; |
|
| 2061 | + $promote = 0; |
|
| 2062 | + $comment = ($topic->locked) ? 1 : 2; |
|
| 2063 | 2063 | |
| 2064 | - $post->content = _boincimport_strip_bbcode($post->content); |
|
| 2065 | - $post->content = _boincimport_text_sanitize($post->content); |
|
| 2066 | - $teaser = node_teaser($post->content); |
|
| 2064 | + $post->content = _boincimport_strip_bbcode($post->content); |
|
| 2065 | + $post->content = _boincimport_text_sanitize($post->content); |
|
| 2066 | + $teaser = node_teaser($post->content); |
|
| 2067 | 2067 | |
| 2068 | - if ($topic->timestamp < $topic->create_time) { |
|
| 2068 | + if ($topic->timestamp < $topic->create_time) { |
|
| 2069 | 2069 | $topic->timestamp = $topic->create_time; |
| 2070 | - } |
|
| 2070 | + } |
|
| 2071 | 2071 | |
| 2072 | - // If dealing with a News topic, be sure it is imported as such |
|
| 2073 | - if ($news_forum_id AND $topic->forum == $news_forum_id) { |
|
| 2072 | + // If dealing with a News topic, be sure it is imported as such |
|
| 2073 | + if ($news_forum_id AND $topic->forum == $news_forum_id) { |
|
| 2074 | 2074 | $node_type = 'news'; |
| 2075 | 2075 | $promote = 1; |
| 2076 | - } |
|
| 2076 | + } |
|
| 2077 | 2077 | |
| 2078 | - // Construct the thread as a forum topic node |
|
| 2079 | - $node = array( |
|
| 2078 | + // Construct the thread as a forum topic node |
|
| 2079 | + $node = array( |
|
| 2080 | 2080 | 'type' => $node_type, |
| 2081 | 2081 | 'title' => $topic->title, |
| 2082 | 2082 | 'uid' => $uid, |
@@ -2090,61 +2090,61 @@ discard block |
||
| 2090 | 2090 | 'sticky' => $topic->sticky, |
| 2091 | 2091 | 'format' => $input_format, |
| 2092 | 2092 | 'teaser' => $teaser, |
| 2093 | - ); |
|
| 2094 | - $node['tid'] = $tid; |
|
| 2095 | - |
|
| 2096 | - // Save the topic node |
|
| 2097 | - $node = (object) $node; // node_save requires an object form |
|
| 2098 | - node_save($node); |
|
| 2099 | - taxonomy_node_save($node, array($tid)); |
|
| 2100 | - $success = ($node->nid) ? TRUE : FALSE; |
|
| 2101 | - if ($success) { |
|
| 2093 | + ); |
|
| 2094 | + $node['tid'] = $tid; |
|
| 2095 | + |
|
| 2096 | + // Save the topic node |
|
| 2097 | + $node = (object) $node; // node_save requires an object form |
|
| 2098 | + node_save($node); |
|
| 2099 | + taxonomy_node_save($node, array($tid)); |
|
| 2100 | + $success = ($node->nid) ? TRUE : FALSE; |
|
| 2101 | + if ($success) { |
|
| 2102 | 2102 | $success = db_query(' |
| 2103 | 2103 | INSERT INTO {boincimport_temp_topic} (topic_id, post_id, nid) |
| 2104 | 2104 | VALUES (%d, %d, %d)', $topic->id, $post->id, $node->nid |
| 2105 | 2105 | ); |
| 2106 | 2106 | if ($success) { |
| 2107 | - // Hack to keep the topics in correct order |
|
| 2108 | - $success = db_query('UPDATE {node_comment_statistics} SET last_comment_timestamp = %d WHERE nid = %d', $node->created, $node->nid); |
|
| 2109 | - if (!$success) { |
|
| 2107 | + // Hack to keep the topics in correct order |
|
| 2108 | + $success = db_query('UPDATE {node_comment_statistics} SET last_comment_timestamp = %d WHERE nid = %d', $node->created, $node->nid); |
|
| 2109 | + if (!$success) { |
|
| 2110 | 2110 | $error_detail = 'topic imported, but failed to set last comment timestamp'; |
| 2111 | - } |
|
| 2111 | + } |
|
| 2112 | 2112 | } |
| 2113 | 2113 | else { |
| 2114 | - $error_detail = 'topic node saved, but failed to link in boincimport_temp_topic table'; |
|
| 2114 | + $error_detail = 'topic node saved, but failed to link in boincimport_temp_topic table'; |
|
| 2115 | 2115 | } |
| 2116 | - } |
|
| 2117 | - else { |
|
| 2116 | + } |
|
| 2117 | + else { |
|
| 2118 | 2118 | $error_detail = 'failed to save topic node to database'; |
| 2119 | - } |
|
| 2119 | + } |
|
| 2120 | 2120 | } |
| 2121 | 2121 | |
| 2122 | 2122 | // See if the import worked |
| 2123 | 2123 | $message = ''; |
| 2124 | 2124 | if ($success) { |
| 2125 | - // Store some result for post-processing in the finished callback. |
|
| 2126 | - $context['results']['success'][] = $topic->id; |
|
| 2127 | - $message = "Successfully imported topic {$topic->id}"; |
|
| 2125 | + // Store some result for post-processing in the finished callback. |
|
| 2126 | + $context['results']['success'][] = $topic->id; |
|
| 2127 | + $message = "Successfully imported topic {$topic->id}"; |
|
| 2128 | 2128 | } |
| 2129 | 2129 | elseif ($duplicate) { |
| 2130 | - $context['results']['duplicate'][] = $topic->id; |
|
| 2131 | - $message = "Topic {$topic->id} was already imported"; |
|
| 2130 | + $context['results']['duplicate'][] = $topic->id; |
|
| 2131 | + $message = "Topic {$topic->id} was already imported"; |
|
| 2132 | 2132 | } |
| 2133 | 2133 | elseif (!$post) { |
| 2134 | - $context['results']['empty'][] = $topic->id; |
|
| 2135 | - $message = "Skipping topic {$topic->id} as empty"; |
|
| 2134 | + $context['results']['empty'][] = $topic->id; |
|
| 2135 | + $message = "Skipping topic {$topic->id} as empty"; |
|
| 2136 | 2136 | } |
| 2137 | 2137 | else { |
| 2138 | - $context['results']['failure'][] = $topic->id; |
|
| 2139 | - $message = "Failed to import topic {$topic->id}!"; |
|
| 2140 | - watchdog('boincimport', |
|
| 2138 | + $context['results']['failure'][] = $topic->id; |
|
| 2139 | + $message = "Failed to import topic {$topic->id}!"; |
|
| 2140 | + watchdog('boincimport', |
|
| 2141 | 2141 | 'Failed to import topic @id! (@error)', |
| 2142 | 2142 | array( |
| 2143 | - '@id' => $topic->id, |
|
| 2144 | - '@error' => $error_detail, |
|
| 2143 | + '@id' => $topic->id, |
|
| 2144 | + '@error' => $error_detail, |
|
| 2145 | 2145 | ), |
| 2146 | 2146 | WATCHDOG_WARNING |
| 2147 | - ); |
|
| 2147 | + ); |
|
| 2148 | 2148 | } |
| 2149 | 2149 | |
| 2150 | 2150 | // Update our progress information. |
@@ -2154,54 +2154,54 @@ discard block |
||
| 2154 | 2154 | |
| 2155 | 2155 | // Update the progress for the batch engine |
| 2156 | 2156 | if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
| 2157 | - $context['finished'] = 1; |
|
| 2157 | + $context['finished'] = 1; |
|
| 2158 | 2158 | } |
| 2159 | 2159 | else { |
| 2160 | - $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
|
| 2160 | + $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
|
| 2161 | + } |
|
| 2161 | 2162 | } |
| 2162 | - } |
|
| 2163 | 2163 | } |
| 2164 | 2164 | |
| 2165 | 2165 | /** |
| 2166 | 2166 | * Batch 'finished' callback |
| 2167 | 2167 | */ |
| 2168 | 2168 | function boincimport_topics_finished($success, $results, $operations) { |
| 2169 | - if ($success) { |
|
| 2169 | + if ($success) { |
|
| 2170 | 2170 | // Let's count our successes |
| 2171 | 2171 | $total_imported = count($results['success']); |
| 2172 | 2172 | $duplicates = count($results['duplicate']); |
| 2173 | 2173 | $empty_topics = count($results['empty']); |
| 2174 | 2174 | $message = t( |
| 2175 | - 'Successfully imported @count topics (skipped @duplicates already imported, @abandoned empty topics)', |
|
| 2176 | - array( |
|
| 2175 | + 'Successfully imported @count topics (skipped @duplicates already imported, @abandoned empty topics)', |
|
| 2176 | + array( |
|
| 2177 | 2177 | '@count' => $total_imported, |
| 2178 | 2178 | '@duplicates' => $duplicates, |
| 2179 | 2179 | '@abandoned' => $empty_topics, |
| 2180 | - ) |
|
| 2180 | + ) |
|
| 2181 | 2181 | ); |
| 2182 | 2182 | watchdog('boincimport', |
| 2183 | - 'Successfully imported @count topics (skipped @duplicates already imported, @abandoned empty topics).', |
|
| 2184 | - array( |
|
| 2183 | + 'Successfully imported @count topics (skipped @duplicates already imported, @abandoned empty topics).', |
|
| 2184 | + array( |
|
| 2185 | 2185 | '@count' => $total_imported, |
| 2186 | 2186 | '@duplicates' => $duplicates, |
| 2187 | 2187 | '@abandoned' => $empty_topics, |
| 2188 | - ), WATCHDOG_INFO |
|
| 2188 | + ), WATCHDOG_INFO |
|
| 2189 | 2189 | ); |
| 2190 | 2190 | // Set the topic import successful flag in the variable table |
| 2191 | 2191 | variable_set('boincimport_import_topic_successful', '1'); |
| 2192 | 2192 | $_SESSION['boincimport_stage_selected'] = 'posts'; |
| 2193 | - } |
|
| 2194 | - else { |
|
| 2193 | + } |
|
| 2194 | + else { |
|
| 2195 | 2195 | // An error occurred. |
| 2196 | 2196 | // $operations contains the operations that remained unprocessed. |
| 2197 | 2197 | $error_operation = reset($operations); |
| 2198 | 2198 | $message = 'An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE); |
| 2199 | - } |
|
| 2200 | - drupal_set_message($message); |
|
| 2199 | + } |
|
| 2200 | + drupal_set_message($message); |
|
| 2201 | 2201 | |
| 2202 | - // Release the lock on the import process |
|
| 2203 | - variable_del('boincimport_process_locked'); |
|
| 2204 | - drupal_goto('admin/boinc/import/process'); |
|
| 2202 | + // Release the lock on the import process |
|
| 2203 | + variable_del('boincimport_process_locked'); |
|
| 2204 | + drupal_goto('admin/boinc/import/process'); |
|
| 2205 | 2205 | } |
| 2206 | 2206 | |
| 2207 | 2207 | |
@@ -2214,91 +2214,91 @@ discard block |
||
| 2214 | 2214 | */ |
| 2215 | 2215 | function boincimport_forum_posts() { |
| 2216 | 2216 | |
| 2217 | - // Check whether forum posts have been successfully imported already |
|
| 2218 | - if (variable_get('boincimport_import_post_successful', 0)) { |
|
| 2217 | + // Check whether forum posts have been successfully imported already |
|
| 2218 | + if (variable_get('boincimport_import_post_successful', 0)) { |
|
| 2219 | 2219 | drupal_set_message(t('Forum post import has already run successfully'), 'warning'); |
| 2220 | 2220 | watchdog( |
| 2221 | - 'boincimport', 'Forum post import has already run successfully', |
|
| 2222 | - array(), WATCHDOG_WARNING |
|
| 2221 | + 'boincimport', 'Forum post import has already run successfully', |
|
| 2222 | + array(), WATCHDOG_WARNING |
|
| 2223 | 2223 | ); |
| 2224 | 2224 | // Release the lock on the import process |
| 2225 | 2225 | variable_del('boincimport_process_locked'); |
| 2226 | 2226 | return; |
| 2227 | - } |
|
| 2227 | + } |
|
| 2228 | 2228 | |
| 2229 | - if (!variable_get('boincimport_import_post_started', 0)) { |
|
| 2229 | + if (!variable_get('boincimport_import_post_started', 0)) { |
|
| 2230 | 2230 | // Could prepare database tables, if new fields are necessary, etc. |
| 2231 | 2231 | variable_set('boincimport_import_post_started', 1); |
| 2232 | - } |
|
| 2232 | + } |
|
| 2233 | 2233 | |
| 2234 | - $pre = variable_get('boincimport_table_prefix', ''); |
|
| 2234 | + $pre = variable_get('boincimport_table_prefix', ''); |
|
| 2235 | 2235 | |
| 2236 | - // Get the BOINC threads and get a count of posts to import |
|
| 2237 | - db_set_active('boinc_rw'); |
|
| 2238 | - $topic_count = db_result(db_query(" |
|
| 2236 | + // Get the BOINC threads and get a count of posts to import |
|
| 2237 | + db_set_active('boinc_rw'); |
|
| 2238 | + $topic_count = db_result(db_query(" |
|
| 2239 | 2239 | SELECT COUNT(DISTINCT t.id) FROM %sthread t |
| 2240 | 2240 | JOIN %sforum f ON f.id = t.forum |
| 2241 | 2241 | JOIN %spost p ON p.thread = t.id |
| 2242 | 2242 | WHERE f.parent_type = 0", $pre, $pre, $pre |
| 2243 | - )); |
|
| 2244 | - $total_post_count = db_result(db_query(" |
|
| 2243 | + )); |
|
| 2244 | + $total_post_count = db_result(db_query(" |
|
| 2245 | 2245 | SELECT COUNT(p.id) FROM %spost p |
| 2246 | 2246 | JOIN %sthread t ON t.id = p.thread |
| 2247 | 2247 | JOIN %sforum f ON f.id = t.forum |
| 2248 | 2248 | WHERE f.parent_type = 0", $pre, $pre, $pre |
| 2249 | - )); |
|
| 2250 | - $post_count = $total_post_count - $topic_count; |
|
| 2251 | - db_set_active('default'); |
|
| 2249 | + )); |
|
| 2250 | + $post_count = $total_post_count - $topic_count; |
|
| 2251 | + db_set_active('default'); |
|
| 2252 | 2252 | |
| 2253 | - if ($post_count <= 0) { |
|
| 2253 | + if ($post_count <= 0) { |
|
| 2254 | 2254 | drupal_set_message( |
| 2255 | - t('There were no posts found: Aborting script'), 'warning' |
|
| 2255 | + t('There were no posts found: Aborting script'), 'warning' |
|
| 2256 | 2256 | ); |
| 2257 | 2257 | watchdog('boincimport', |
| 2258 | - 'There were no posts found: Aborting script', array(), WATCHDOG_WARNING |
|
| 2258 | + 'There were no posts found: Aborting script', array(), WATCHDOG_WARNING |
|
| 2259 | 2259 | ); |
| 2260 | 2260 | // Release the lock on the import process |
| 2261 | 2261 | variable_del('boincimport_process_locked'); |
| 2262 | 2262 | return t('There were no posts found: Aborting script.'); |
| 2263 | - } |
|
| 2263 | + } |
|
| 2264 | 2264 | |
| 2265 | - watchdog('boincimport', |
|
| 2265 | + watchdog('boincimport', |
|
| 2266 | 2266 | 'Found %count posts: Beginning Import', |
| 2267 | 2267 | array('%count' => $post_count), WATCHDOG_INFO |
| 2268 | - ); |
|
| 2268 | + ); |
|
| 2269 | 2269 | |
| 2270 | - $operations = array(); |
|
| 2271 | - $batch_size = 100; |
|
| 2270 | + $operations = array(); |
|
| 2271 | + $batch_size = 100; |
|
| 2272 | 2272 | |
| 2273 | - // Create batches to process |
|
| 2274 | - for ($offset = 0; $offset < $topic_count; $offset+=$batch_size) { |
|
| 2273 | + // Create batches to process |
|
| 2274 | + for ($offset = 0; $offset < $topic_count; $offset+=$batch_size) { |
|
| 2275 | 2275 | $topics_per_batch = $batch_size; |
| 2276 | 2276 | if ($offset + $batch_size > $topic_count) { |
| 2277 | - $topics_per_batch = $topic_count - $offset; |
|
| 2277 | + $topics_per_batch = $topic_count - $offset; |
|
| 2278 | 2278 | } |
| 2279 | 2279 | $operations[] = array( |
| 2280 | - 'boincimport_posts_op', array( |
|
| 2280 | + 'boincimport_posts_op', array( |
|
| 2281 | 2281 | $offset, $topics_per_batch |
| 2282 | - ) |
|
| 2282 | + ) |
|
| 2283 | 2283 | ); |
| 2284 | - } |
|
| 2284 | + } |
|
| 2285 | 2285 | |
| 2286 | - $batch = array( |
|
| 2286 | + $batch = array( |
|
| 2287 | 2287 | 'operations' => $operations, |
| 2288 | 2288 | 'finished' => 'boincimport_posts_finished', |
| 2289 | 2289 | 'title' => t('Importing posts'), |
| 2290 | 2290 | 'init_message' => t('Beginning post import...'), |
| 2291 | 2291 | 'progress_message' => t( |
| 2292 | - 'Processed posts in @current out of @total batches (@size topics per batch).', |
|
| 2293 | - array( |
|
| 2292 | + 'Processed posts in @current out of @total batches (@size topics per batch).', |
|
| 2293 | + array( |
|
| 2294 | 2294 | '@size' => $batch_size, |
| 2295 | 2295 | // @current and @total are managed by the batch API |
| 2296 | - ) |
|
| 2296 | + ) |
|
| 2297 | 2297 | ), |
| 2298 | 2298 | 'error_message' => t('Post import has encountered an error.'), |
| 2299 | - ); |
|
| 2299 | + ); |
|
| 2300 | 2300 | |
| 2301 | - batch_set($batch); |
|
| 2301 | + batch_set($batch); |
|
| 2302 | 2302 | } |
| 2303 | 2303 | |
| 2304 | 2304 | /** |
@@ -2306,17 +2306,17 @@ discard block |
||
| 2306 | 2306 | * Create a Drupal comment from the given BOINC post object |
| 2307 | 2307 | */ |
| 2308 | 2308 | function boincimport_posts_op($offset, $batch_size, &$context) { |
| 2309 | - // Initialize the batch, if needed |
|
| 2310 | - if (!isset($context['sandbox']['progress'])) { |
|
| 2309 | + // Initialize the batch, if needed |
|
| 2310 | + if (!isset($context['sandbox']['progress'])) { |
|
| 2311 | 2311 | $context['sandbox']['progress'] = 0; |
| 2312 | 2312 | $context['sandbox']['max'] = $batch_size; |
| 2313 | - } |
|
| 2313 | + } |
|
| 2314 | 2314 | |
| 2315 | - $input_format = variable_get('boincimport_input_format', 0); |
|
| 2315 | + $input_format = variable_get('boincimport_input_format', 0); |
|
| 2316 | 2316 | |
| 2317 | - // Get the topics with posts to import |
|
| 2318 | - db_set_active('boinc_rw'); |
|
| 2319 | - $boinc_topic_ids = db_query(' |
|
| 2317 | + // Get the topics with posts to import |
|
| 2318 | + db_set_active('boinc_rw'); |
|
| 2319 | + $boinc_topic_ids = db_query(' |
|
| 2320 | 2320 | SELECT DISTINCT t.id FROM %sthread t |
| 2321 | 2321 | JOIN %sforum f ON f.id = t.forum |
| 2322 | 2322 | JOIN %spost p ON p.thread = t.id |
@@ -2324,10 +2324,10 @@ discard block |
||
| 2324 | 2324 | ORDER BY t.id |
| 2325 | 2325 | LIMIT %d,%d', |
| 2326 | 2326 | $pre, $pre, $pre, $offset, $batch_size |
| 2327 | - ); |
|
| 2328 | - db_set_active('default'); |
|
| 2327 | + ); |
|
| 2328 | + db_set_active('default'); |
|
| 2329 | 2329 | |
| 2330 | - while ($boinc_topic = db_fetch_object($boinc_topic_ids)) { |
|
| 2330 | + while ($boinc_topic = db_fetch_object($boinc_topic_ids)) { |
|
| 2331 | 2331 | // Get the posts in this topic |
| 2332 | 2332 | db_set_active('boinc_rw'); |
| 2333 | 2333 | $boinc_posts = db_query(' |
@@ -2345,29 +2345,29 @@ discard block |
||
| 2345 | 2345 | |
| 2346 | 2346 | while ($post = db_fetch_object($boinc_posts)) { |
| 2347 | 2347 | |
| 2348 | - // Skip the first post as it has already been imported as a topic |
|
| 2349 | - if ($first_post) { |
|
| 2348 | + // Skip the first post as it has already been imported as a topic |
|
| 2349 | + if ($first_post) { |
|
| 2350 | 2350 | $first_post = false; |
| 2351 | 2351 | continue; |
| 2352 | - } |
|
| 2352 | + } |
|
| 2353 | 2353 | |
| 2354 | - // Making it this far confirms that there are posts to import |
|
| 2355 | - $topic_has_responses = TRUE; |
|
| 2354 | + // Making it this far confirms that there are posts to import |
|
| 2355 | + $topic_has_responses = TRUE; |
|
| 2356 | 2356 | |
| 2357 | - $is_duplicate = db_result(db_query(' |
|
| 2357 | + $is_duplicate = db_result(db_query(' |
|
| 2358 | 2358 | SELECT COUNT(*) FROM {boincimport_temp_post} |
| 2359 | 2359 | WHERE post_id = %d', |
| 2360 | 2360 | $post->id |
| 2361 | - )); |
|
| 2362 | - if ($is_duplicate) { |
|
| 2361 | + )); |
|
| 2362 | + if ($is_duplicate) { |
|
| 2363 | 2363 | // This post has already been imported |
| 2364 | 2364 | $context['results']['posts']['duplicate'][] = $post->id; |
| 2365 | 2365 | $duplicate_posts++; |
| 2366 | 2366 | continue; |
| 2367 | - } |
|
| 2367 | + } |
|
| 2368 | 2368 | |
| 2369 | - // Make sure the post is valid |
|
| 2370 | - if ($post->content) { |
|
| 2369 | + // Make sure the post is valid |
|
| 2370 | + if ($post->content) { |
|
| 2371 | 2371 | |
| 2372 | 2372 | // Get user, node, and parent IDs for the post and sanitize |
| 2373 | 2373 | $uid = boincuser_lookup_uid($post->user); |
@@ -2376,14 +2376,14 @@ discard block |
||
| 2376 | 2376 | FROM {boincimport_temp_topic} btt |
| 2377 | 2377 | LEFT JOIN {node_revisions} AS nr ON btt.nid = nr.nid |
| 2378 | 2378 | WHERE btt.topic_id = %d', |
| 2379 | - $post->thread |
|
| 2379 | + $post->thread |
|
| 2380 | 2380 | )); |
| 2381 | 2381 | $nid = $node->nid; |
| 2382 | 2382 | $pid = db_result(db_query(' |
| 2383 | 2383 | SELECT cid |
| 2384 | 2384 | FROM {boincimport_temp_post} |
| 2385 | 2385 | WHERE post_id = %d', |
| 2386 | - $post->parent_post)); |
|
| 2386 | + $post->parent_post)); |
|
| 2387 | 2387 | if (is_null($pid)) $pid = 0; |
| 2388 | 2388 | if (!$uid) $uid = 0; |
| 2389 | 2389 | |
@@ -2394,85 +2394,85 @@ discard block |
||
| 2394 | 2394 | SELECT COUNT(*) |
| 2395 | 2395 | FROM {comments} |
| 2396 | 2396 | WHERE nid = %d', |
| 2397 | - $nid |
|
| 2397 | + $nid |
|
| 2398 | 2398 | )); |
| 2399 | 2399 | $post_reply = $pid; |
| 2400 | 2400 | |
| 2401 | 2401 | if ($post_reply OR $topic_reply) { |
| 2402 | - // Create a subject for the post from the post content. The body may be in |
|
| 2403 | - // any format, so we: |
|
| 2404 | - // 1) Filter it into HTML |
|
| 2405 | - // 2) Strip out all HTML tags |
|
| 2406 | - // 3) Convert entities back to plain-text. |
|
| 2407 | - // Note: format is checked by check_markup(). |
|
| 2408 | - $subject = truncate_utf8(trim(decode_entities(strip_tags(check_markup($post->content, $input_format)))), 29, TRUE); |
|
| 2409 | - // Replace "Quote:" with "RE:" |
|
| 2410 | - $subject = str_replace('Quote:', 'RE: ', $subject); |
|
| 2411 | - // Fringe cases where the comment body is populated only by HTML tags |
|
| 2412 | - // will require a default subject... |
|
| 2413 | - if ($subject === '') |
|
| 2402 | + // Create a subject for the post from the post content. The body may be in |
|
| 2403 | + // any format, so we: |
|
| 2404 | + // 1) Filter it into HTML |
|
| 2405 | + // 2) Strip out all HTML tags |
|
| 2406 | + // 3) Convert entities back to plain-text. |
|
| 2407 | + // Note: format is checked by check_markup(). |
|
| 2408 | + $subject = truncate_utf8(trim(decode_entities(strip_tags(check_markup($post->content, $input_format)))), 29, TRUE); |
|
| 2409 | + // Replace "Quote:" with "RE:" |
|
| 2410 | + $subject = str_replace('Quote:', 'RE: ', $subject); |
|
| 2411 | + // Fringe cases where the comment body is populated only by HTML tags |
|
| 2412 | + // will require a default subject... |
|
| 2413 | + if ($subject === '') |
|
| 2414 | 2414 | $subject = "RE: {$node->title}"; |
| 2415 | 2415 | } else { |
| 2416 | - // This is the first post in the topic |
|
| 2417 | - $subject = $node->title; |
|
| 2416 | + // This is the first post in the topic |
|
| 2417 | + $subject = $node->title; |
|
| 2418 | 2418 | } |
| 2419 | 2419 | |
| 2420 | 2420 | // Construct the post as a Drupal comment |
| 2421 | 2421 | $comment = array( |
| 2422 | - 'pid' => $pid, |
|
| 2423 | - 'nid' => $nid, |
|
| 2424 | - 'uid' => $uid, |
|
| 2425 | - 'subject' => $subject, |
|
| 2426 | - 'comment' => $post->content, |
|
| 2427 | - 'timestamp' => $post->timestamp, |
|
| 2428 | - 'status' => $post->hidden, |
|
| 2429 | - 'format' => $input_format |
|
| 2422 | + 'pid' => $pid, |
|
| 2423 | + 'nid' => $nid, |
|
| 2424 | + 'uid' => $uid, |
|
| 2425 | + 'subject' => $subject, |
|
| 2426 | + 'comment' => $post->content, |
|
| 2427 | + 'timestamp' => $post->timestamp, |
|
| 2428 | + 'status' => $post->hidden, |
|
| 2429 | + 'format' => $input_format |
|
| 2430 | 2430 | ); |
| 2431 | 2431 | |
| 2432 | 2432 | // Save the comment |
| 2433 | 2433 | if (boincimport_forum_comment_save($comment)) { |
| 2434 | - $success = db_query(' |
|
| 2434 | + $success = db_query(' |
|
| 2435 | 2435 | INSERT INTO {boincimport_temp_post} (post_id, cid) |
| 2436 | 2436 | VALUES (%d, %d)', |
| 2437 | 2437 | $post->id, $comment['cid'] |
| 2438 | - ); |
|
| 2439 | - if ($success) { |
|
| 2438 | + ); |
|
| 2439 | + if ($success) { |
|
| 2440 | 2440 | $posts_imported++; |
| 2441 | 2441 | $context['results']['posts']['success'][] = $post->id; |
| 2442 | - } |
|
| 2443 | - else { |
|
| 2442 | + } |
|
| 2443 | + else { |
|
| 2444 | 2444 | $context['results']['posts']['failure'][] = $post->id; |
| 2445 | 2445 | $error_posts++; |
| 2446 | - } |
|
| 2446 | + } |
|
| 2447 | 2447 | } |
| 2448 | 2448 | else { |
| 2449 | - $context['results']['posts']['failure'][] = $post->id; |
|
| 2450 | - $error_posts++; |
|
| 2449 | + $context['results']['posts']['failure'][] = $post->id; |
|
| 2450 | + $error_posts++; |
|
| 2451 | 2451 | } |
| 2452 | - } |
|
| 2453 | - else { |
|
| 2452 | + } |
|
| 2453 | + else { |
|
| 2454 | 2454 | $context['results']['posts']['empty'][] = $post->id; |
| 2455 | 2455 | $empty_posts++; |
| 2456 | - } |
|
| 2456 | + } |
|
| 2457 | 2457 | } |
| 2458 | 2458 | |
| 2459 | 2459 | $message = ''; |
| 2460 | 2460 | if ($success OR !$topic_has_responses) { |
| 2461 | - // Store some result for post-processing in the finished callback. |
|
| 2462 | - $context['results']['success'][] = $boinc_topic->id; |
|
| 2463 | - $message = "Imported {$posts_imported} post(s) for topic {$boinc_topic->id}"; |
|
| 2461 | + // Store some result for post-processing in the finished callback. |
|
| 2462 | + $context['results']['success'][] = $boinc_topic->id; |
|
| 2463 | + $message = "Imported {$posts_imported} post(s) for topic {$boinc_topic->id}"; |
|
| 2464 | 2464 | } |
| 2465 | 2465 | else { |
| 2466 | - $context['results']['failure'][] = $boinc_topic->id; |
|
| 2467 | - $message = "Failed to import any posts for topic {$boinc_topic->id} (excluded {$error_posts} errors, {$duplicate_posts} duplicates, and {$empty_posts} empty)"; |
|
| 2468 | - watchdog('boincimport', 'Failed to import any posts for topic @id (excluded @error_posts errors, @duplicate_posts duplicates, and @empty_posts empty)', |
|
| 2466 | + $context['results']['failure'][] = $boinc_topic->id; |
|
| 2467 | + $message = "Failed to import any posts for topic {$boinc_topic->id} (excluded {$error_posts} errors, {$duplicate_posts} duplicates, and {$empty_posts} empty)"; |
|
| 2468 | + watchdog('boincimport', 'Failed to import any posts for topic @id (excluded @error_posts errors, @duplicate_posts duplicates, and @empty_posts empty)', |
|
| 2469 | 2469 | array( |
| 2470 | - '@id' => $boinc_topic->id, |
|
| 2471 | - '@error_posts' => $error_posts, |
|
| 2472 | - '@duplicate_posts' => $duplicate_posts, |
|
| 2473 | - '@empty_posts' => $empty_posts, |
|
| 2470 | + '@id' => $boinc_topic->id, |
|
| 2471 | + '@error_posts' => $error_posts, |
|
| 2472 | + '@duplicate_posts' => $duplicate_posts, |
|
| 2473 | + '@empty_posts' => $empty_posts, |
|
| 2474 | 2474 | ), WATCHDOG_WARNING |
| 2475 | - ); |
|
| 2475 | + ); |
|
| 2476 | 2476 | } |
| 2477 | 2477 | |
| 2478 | 2478 | // Update our progress information. |
@@ -2482,19 +2482,19 @@ discard block |
||
| 2482 | 2482 | |
| 2483 | 2483 | // Update the progress for the batch engine |
| 2484 | 2484 | if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
| 2485 | - $context['finished'] = 1; |
|
| 2485 | + $context['finished'] = 1; |
|
| 2486 | 2486 | } |
| 2487 | 2487 | else { |
| 2488 | - $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
|
| 2488 | + $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
|
| 2489 | + } |
|
| 2489 | 2490 | } |
| 2490 | - } |
|
| 2491 | 2491 | } |
| 2492 | 2492 | |
| 2493 | 2493 | /** |
| 2494 | 2494 | * Batch 'finished' callback |
| 2495 | 2495 | */ |
| 2496 | 2496 | function boincimport_posts_finished($success, $results, $operations) { |
| 2497 | - if ($success) { |
|
| 2497 | + if ($success) { |
|
| 2498 | 2498 | // Let's count our successes |
| 2499 | 2499 | $posts_imported = count($results['posts']['success']); |
| 2500 | 2500 | $topic_count = count($results['success']); |
@@ -2503,39 +2503,39 @@ discard block |
||
| 2503 | 2503 | $empty_posts = count($results['posts']['empty']); |
| 2504 | 2504 | $failed_posts = count($results['posts']['failure']); |
| 2505 | 2505 | $message = t( |
| 2506 | - 'Successfully imported @post_count posts in @topic_count topics ' . |
|
| 2507 | - '(@skipped topics either had no replies or all replies were already imported, ' . |
|
| 2508 | - '@duplicates posts were skipped as already imported, ' . |
|
| 2509 | - '@empty_posts had no content, ' . |
|
| 2510 | - 'and @error_posts encountered errors during import)', |
|
| 2511 | - array( |
|
| 2506 | + 'Successfully imported @post_count posts in @topic_count topics ' . |
|
| 2507 | + '(@skipped topics either had no replies or all replies were already imported, ' . |
|
| 2508 | + '@duplicates posts were skipped as already imported, ' . |
|
| 2509 | + '@empty_posts had no content, ' . |
|
| 2510 | + 'and @error_posts encountered errors during import)', |
|
| 2511 | + array( |
|
| 2512 | 2512 | '@post_count' => $posts_imported, |
| 2513 | 2513 | '@topic_count' => $topic_count, |
| 2514 | 2514 | '@skipped' => $topics_skipped, |
| 2515 | 2515 | '@duplicates' => $duplicates, |
| 2516 | 2516 | '@empty_posts' => $empty_posts, |
| 2517 | 2517 | '@error_posts' => $failed_posts, |
| 2518 | - ) |
|
| 2518 | + ) |
|
| 2519 | 2519 | ); |
| 2520 | 2520 | watchdog('boincimport', |
| 2521 | - $message, |
|
| 2522 | - array(), WATCHDOG_INFO |
|
| 2521 | + $message, |
|
| 2522 | + array(), WATCHDOG_INFO |
|
| 2523 | 2523 | ); |
| 2524 | 2524 | // Set the post import successful flag in the variable table |
| 2525 | 2525 | variable_set('boincimport_import_post_successful', '1'); |
| 2526 | 2526 | $_SESSION['boincimport_stage_selected'] = 'team forums'; |
| 2527 | - } |
|
| 2528 | - else { |
|
| 2527 | + } |
|
| 2528 | + else { |
|
| 2529 | 2529 | // An error occurred. |
| 2530 | 2530 | // $operations contains the operations that remained unprocessed. |
| 2531 | 2531 | $error_operation = reset($operations); |
| 2532 | 2532 | $message = 'An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE); |
| 2533 | - } |
|
| 2534 | - drupal_set_message($message); |
|
| 2533 | + } |
|
| 2534 | + drupal_set_message($message); |
|
| 2535 | 2535 | |
| 2536 | - // Release the lock on the import process |
|
| 2537 | - variable_del('boincimport_process_locked'); |
|
| 2538 | - drupal_goto('admin/boinc/import/process'); |
|
| 2536 | + // Release the lock on the import process |
|
| 2537 | + variable_del('boincimport_process_locked'); |
|
| 2538 | + drupal_goto('admin/boinc/import/process'); |
|
| 2539 | 2539 | } |
| 2540 | 2540 | |
| 2541 | 2541 | |
@@ -2548,97 +2548,97 @@ discard block |
||
| 2548 | 2548 | */ |
| 2549 | 2549 | function boincimport_team_forums() { |
| 2550 | 2550 | |
| 2551 | - // Check whether team forums have been successfully imported already |
|
| 2552 | - if (variable_get('boincimport_import_team_forum_successful', 0)) { |
|
| 2551 | + // Check whether team forums have been successfully imported already |
|
| 2552 | + if (variable_get('boincimport_import_team_forum_successful', 0)) { |
|
| 2553 | 2553 | drupal_set_message(t('Team forum import has already run successfully'), 'warning'); |
| 2554 | 2554 | watchdog( |
| 2555 | - 'boincimport', 'Team forum import has already run successfully', |
|
| 2556 | - array(), WATCHDOG_WARNING |
|
| 2555 | + 'boincimport', 'Team forum import has already run successfully', |
|
| 2556 | + array(), WATCHDOG_WARNING |
|
| 2557 | 2557 | ); |
| 2558 | - } |
|
| 2558 | + } |
|
| 2559 | 2559 | |
| 2560 | - if (!variable_get('boincimport_import_team_forum_started', 0)) { |
|
| 2560 | + if (!variable_get('boincimport_import_team_forum_started', 0)) { |
|
| 2561 | 2561 | // Could prepare database tables, if new fields are necessary, etc. |
| 2562 | 2562 | variable_set('boincimport_import_team_forum_started', 1); |
| 2563 | - } |
|
| 2563 | + } |
|
| 2564 | 2564 | |
| 2565 | - $pre = variable_get('boincimport_table_prefix', ''); |
|
| 2565 | + $pre = variable_get('boincimport_table_prefix', ''); |
|
| 2566 | 2566 | |
| 2567 | - // Get team forums from BOINC database |
|
| 2568 | - db_set_active('boinc_rw'); |
|
| 2569 | - $boincteam_forums = db_query(' |
|
| 2567 | + // Get team forums from BOINC database |
|
| 2568 | + db_set_active('boinc_rw'); |
|
| 2569 | + $boincteam_forums = db_query(' |
|
| 2570 | 2570 | SELECT id, title, description, category, timestamp, post_min_interval, |
| 2571 | 2571 | post_min_total_credit, post_min_expavg_credit |
| 2572 | 2572 | FROM %sforum |
| 2573 | 2573 | WHERE parent_type = 1 |
| 2574 | 2574 | ORDER BY id ASC', |
| 2575 | 2575 | $pre |
| 2576 | - ); |
|
| 2577 | - $team_forum_count = mysqli_num_rows($boincteam_forums); |
|
| 2578 | - db_set_active('default'); |
|
| 2576 | + ); |
|
| 2577 | + $team_forum_count = mysqli_num_rows($boincteam_forums); |
|
| 2578 | + db_set_active('default'); |
|
| 2579 | 2579 | |
| 2580 | - if (!$team_forum_count) { |
|
| 2580 | + if (!$team_forum_count) { |
|
| 2581 | 2581 | drupal_set_message( |
| 2582 | - t('There were no team forums found: Aborting script'), 'warning' |
|
| 2582 | + t('There were no team forums found: Aborting script'), 'warning' |
|
| 2583 | 2583 | ); |
| 2584 | 2584 | watchdog('boincimport', |
| 2585 | - 'There were no team forums found: Aborting script', array(), WATCHDOG_WARNING |
|
| 2585 | + 'There were no team forums found: Aborting script', array(), WATCHDOG_WARNING |
|
| 2586 | 2586 | ); |
| 2587 | 2587 | // Release the lock on the import process |
| 2588 | 2588 | variable_del('boincimport_process_locked'); |
| 2589 | 2589 | return t('There were no BLAH found: Aborting script.'); |
| 2590 | - } |
|
| 2590 | + } |
|
| 2591 | 2591 | |
| 2592 | - watchdog('boincimport', |
|
| 2592 | + watchdog('boincimport', |
|
| 2593 | 2593 | 'Found %count team forums: Beginning Import', |
| 2594 | 2594 | array('%count' => $team_forum_count), WATCHDOG_INFO |
| 2595 | - ); |
|
| 2595 | + ); |
|
| 2596 | 2596 | |
| 2597 | - $operations = array(); |
|
| 2598 | - $existing_team_forums = array(); |
|
| 2599 | - $duplicates = array(); |
|
| 2597 | + $operations = array(); |
|
| 2598 | + $existing_team_forums = array(); |
|
| 2599 | + $duplicates = array(); |
|
| 2600 | 2600 | |
| 2601 | - // Get the list of team forums already in Drupal to be sure we're not |
|
| 2602 | - // importing any twice |
|
| 2603 | - $result = db_query(' |
|
| 2601 | + // Get the list of team forums already in Drupal to be sure we're not |
|
| 2602 | + // importing any twice |
|
| 2603 | + $result = db_query(' |
|
| 2604 | 2604 | SELECT nid, boinc_id FROM {boincteam_forum}' |
| 2605 | - ); |
|
| 2606 | - while ($row = db_fetch_object($result)) { |
|
| 2605 | + ); |
|
| 2606 | + while ($row = db_fetch_object($result)) { |
|
| 2607 | 2607 | $existing_team_forums[$row->boinc_id] = $row->nid; |
| 2608 | - } |
|
| 2608 | + } |
|
| 2609 | 2609 | |
| 2610 | - // Create batches to process |
|
| 2611 | - while ($boincteam_forum = db_fetch_object($boincteam_forums)) { |
|
| 2612 | - if (isset($existing_team_forums[$boincteam_forum->id])) { |
|
| 2613 | - // This team has already been imported |
|
| 2614 | - $duplicates[] = $boincteam_forum->id; |
|
| 2610 | + // Create batches to process |
|
| 2611 | + while ($boincteam_forum = db_fetch_object($boincteam_forums)) { |
|
| 2612 | + if (isset($existing_team_forums[$boincteam_forum->id])) { |
|
| 2613 | + // This team has already been imported |
|
| 2614 | + $duplicates[] = $boincteam_forum->id; |
|
| 2615 | 2615 | } |
| 2616 | 2616 | else { |
| 2617 | - $operations[] = array( |
|
| 2617 | + $operations[] = array( |
|
| 2618 | 2618 | 'boincimport_team_forums_op', array( |
| 2619 | - $boincteam_forum |
|
| 2619 | + $boincteam_forum |
|
| 2620 | 2620 | ) |
| 2621 | - ); |
|
| 2621 | + ); |
|
| 2622 | + } |
|
| 2622 | 2623 | } |
| 2623 | - } |
|
| 2624 | 2624 | |
| 2625 | - if ($duplicates) { |
|
| 2625 | + if ($duplicates) { |
|
| 2626 | 2626 | drupal_set_message(t( |
| 2627 | - 'Skipped @count team forums that were already imported', |
|
| 2628 | - array('@count' => count($duplicates)) |
|
| 2627 | + 'Skipped @count team forums that were already imported', |
|
| 2628 | + array('@count' => count($duplicates)) |
|
| 2629 | 2629 | )); |
| 2630 | - } |
|
| 2630 | + } |
|
| 2631 | 2631 | |
| 2632 | - $batch = array( |
|
| 2632 | + $batch = array( |
|
| 2633 | 2633 | 'operations' => $operations, |
| 2634 | 2634 | 'finished' => 'boincimport_team_forums_finished', |
| 2635 | 2635 | 'title' => t('Importing team forums'), |
| 2636 | 2636 | 'init_message' => t('Beginning team forum import...'), |
| 2637 | 2637 | 'progress_message' => t('Processed @current out of @total team forums.'), |
| 2638 | 2638 | 'error_message' => t('Team forum import has encountered an error.'), |
| 2639 | - ); |
|
| 2639 | + ); |
|
| 2640 | 2640 | |
| 2641 | - batch_set($batch); |
|
| 2641 | + batch_set($batch); |
|
| 2642 | 2642 | } |
| 2643 | 2643 | |
| 2644 | 2644 | /** |
@@ -2648,15 +2648,15 @@ discard block |
||
| 2648 | 2648 | */ |
| 2649 | 2649 | function boincimport_team_forums_op($boincteam_forum, &$context) { |
| 2650 | 2650 | |
| 2651 | - $input_format = variable_get('boincimport_input_format', 0); |
|
| 2651 | + $input_format = variable_get('boincimport_input_format', 0); |
|
| 2652 | 2652 | |
| 2653 | - // Set term parameters for forums |
|
| 2654 | - $forum_id = $boincteam_forum->id; |
|
| 2655 | - $team_id = boincteam_lookup_nid($boincteam_forum->category); |
|
| 2656 | - $name = $boincteam_forum->title; |
|
| 2657 | - $description = strip_tags($boincteam_forum->description); |
|
| 2653 | + // Set term parameters for forums |
|
| 2654 | + $forum_id = $boincteam_forum->id; |
|
| 2655 | + $team_id = boincteam_lookup_nid($boincteam_forum->category); |
|
| 2656 | + $name = $boincteam_forum->title; |
|
| 2657 | + $description = strip_tags($boincteam_forum->description); |
|
| 2658 | 2658 | |
| 2659 | - $success = db_query(" |
|
| 2659 | + $success = db_query(" |
|
| 2660 | 2660 | INSERT INTO {boincteam_forum} SET |
| 2661 | 2661 | boinc_id = %d, |
| 2662 | 2662 | nid = %d, |
@@ -2672,67 +2672,67 @@ discard block |
||
| 2672 | 2672 | time(), 0, $boincteam_forum->post_min_interval, |
| 2673 | 2673 | $boincteam_forum->post_min_total_credit, |
| 2674 | 2674 | $boincteam_forum->post_min_expavg_credit |
| 2675 | - ); |
|
| 2675 | + ); |
|
| 2676 | 2676 | |
| 2677 | - $message = ''; |
|
| 2678 | - if ($success) { |
|
| 2677 | + $message = ''; |
|
| 2678 | + if ($success) { |
|
| 2679 | 2679 | // Store some result for post-processing in the finished callback. |
| 2680 | 2680 | $context['results']['success'][] = $forum_id; |
| 2681 | 2681 | $message = "Successfully imported team forum {$forum_id}"; |
| 2682 | - } |
|
| 2683 | - else { |
|
| 2682 | + } |
|
| 2683 | + else { |
|
| 2684 | 2684 | $context['results']['failure'][] = $forum_id; |
| 2685 | 2685 | $message = "Failed to import team forum {$forum_id}!"; |
| 2686 | 2686 | watchdog('boincimport', |
| 2687 | - 'Failed to import team forum @id!', |
|
| 2688 | - array('@id' => $forum_id), WATCHDOG_WARNING |
|
| 2687 | + 'Failed to import team forum @id!', |
|
| 2688 | + array('@id' => $forum_id), WATCHDOG_WARNING |
|
| 2689 | 2689 | ); |
| 2690 | - } |
|
| 2690 | + } |
|
| 2691 | 2691 | |
| 2692 | - // Update our progress information. |
|
| 2693 | - $context['sandbox']['progress']++; |
|
| 2694 | - $context['sandbox']['current_forum'] = $forum_id; |
|
| 2695 | - $context['message'] = $message; |
|
| 2692 | + // Update our progress information. |
|
| 2693 | + $context['sandbox']['progress']++; |
|
| 2694 | + $context['sandbox']['current_forum'] = $forum_id; |
|
| 2695 | + $context['message'] = $message; |
|
| 2696 | 2696 | |
| 2697 | - // Update the progress for the batch engine |
|
| 2698 | - if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 2697 | + // Update the progress for the batch engine |
|
| 2698 | + if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 2699 | 2699 | $context['finished'] = 1; |
| 2700 | - } |
|
| 2701 | - else { |
|
| 2700 | + } |
|
| 2701 | + else { |
|
| 2702 | 2702 | $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
| 2703 | - } |
|
| 2703 | + } |
|
| 2704 | 2704 | } |
| 2705 | 2705 | |
| 2706 | 2706 | /** |
| 2707 | 2707 | * Batch 'finished' callback |
| 2708 | 2708 | */ |
| 2709 | 2709 | function boincimport_team_forums_finished($success, $results, $operations) { |
| 2710 | - if ($success) { |
|
| 2710 | + if ($success) { |
|
| 2711 | 2711 | // Let's count our successes |
| 2712 | 2712 | $total_imported = count($results['success']); |
| 2713 | 2713 | $message = t( |
| 2714 | - 'Successfully imported @count team forums', |
|
| 2715 | - array('@count' => $total_imported) |
|
| 2714 | + 'Successfully imported @count team forums', |
|
| 2715 | + array('@count' => $total_imported) |
|
| 2716 | 2716 | ); |
| 2717 | 2717 | watchdog('boincimport', |
| 2718 | - 'Successfully imported @count team forums.', |
|
| 2719 | - array('@count' => $total_imported), WATCHDOG_INFO |
|
| 2718 | + 'Successfully imported @count team forums.', |
|
| 2719 | + array('@count' => $total_imported), WATCHDOG_INFO |
|
| 2720 | 2720 | ); |
| 2721 | 2721 | // Set the team forum import successful flag in the variable table |
| 2722 | 2722 | variable_set('boincimport_import_team_forum_successful', '1'); |
| 2723 | 2723 | $_SESSION['boincimport_stage_selected'] = 'team topics'; |
| 2724 | - } |
|
| 2725 | - else { |
|
| 2724 | + } |
|
| 2725 | + else { |
|
| 2726 | 2726 | // An error occurred. |
| 2727 | 2727 | // $operations contains the operations that remained unprocessed. |
| 2728 | 2728 | $error_operation = reset($operations); |
| 2729 | 2729 | $message = 'An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE); |
| 2730 | - } |
|
| 2731 | - drupal_set_message($message); |
|
| 2730 | + } |
|
| 2731 | + drupal_set_message($message); |
|
| 2732 | 2732 | |
| 2733 | - // Release the lock on the import process |
|
| 2734 | - variable_del('boincimport_process_locked'); |
|
| 2735 | - drupal_goto('admin/boinc/import/process'); |
|
| 2733 | + // Release the lock on the import process |
|
| 2734 | + variable_del('boincimport_process_locked'); |
|
| 2735 | + drupal_goto('admin/boinc/import/process'); |
|
| 2736 | 2736 | } |
| 2737 | 2737 | |
| 2738 | 2738 | |
@@ -2745,25 +2745,25 @@ discard block |
||
| 2745 | 2745 | */ |
| 2746 | 2746 | function boincimport_team_forum_topics() { |
| 2747 | 2747 | |
| 2748 | - // Check whether team forum topics have been successfully imported already |
|
| 2749 | - if (variable_get('boincimport_import_team_topic_successful', 0)) { |
|
| 2748 | + // Check whether team forum topics have been successfully imported already |
|
| 2749 | + if (variable_get('boincimport_import_team_topic_successful', 0)) { |
|
| 2750 | 2750 | drupal_set_message(t('Team topic import has already run successfully'), 'warning'); |
| 2751 | 2751 | watchdog( |
| 2752 | - 'boincimport', 'Team topic import has already run successfully', |
|
| 2753 | - array(), WATCHDOG_WARNING |
|
| 2752 | + 'boincimport', 'Team topic import has already run successfully', |
|
| 2753 | + array(), WATCHDOG_WARNING |
|
| 2754 | 2754 | ); |
| 2755 | - } |
|
| 2755 | + } |
|
| 2756 | 2756 | |
| 2757 | - if (!variable_get('boincimport_import_team_topic_started', 0)) { |
|
| 2757 | + if (!variable_get('boincimport_import_team_topic_started', 0)) { |
|
| 2758 | 2758 | // Could prepare database tables, if new fields are necessary, etc. |
| 2759 | 2759 | variable_set('boincimport_import_team_topic_started', 1); |
| 2760 | - } |
|
| 2760 | + } |
|
| 2761 | 2761 | |
| 2762 | - $pre = variable_get('boincimport_table_prefix', ''); |
|
| 2762 | + $pre = variable_get('boincimport_table_prefix', ''); |
|
| 2763 | 2763 | |
| 2764 | - // Get all team topics to import from BOINC |
|
| 2765 | - db_set_active('boinc_rw'); |
|
| 2766 | - $boincteam_topics = db_query(' |
|
| 2764 | + // Get all team topics to import from BOINC |
|
| 2765 | + db_set_active('boinc_rw'); |
|
| 2766 | + $boincteam_topics = db_query(' |
|
| 2767 | 2767 | SELECT DISTINCT t.id, t.title, t.owner, t.forum, t.locked, t.hidden, |
| 2768 | 2768 | t.sticky, t.timestamp, t.create_time |
| 2769 | 2769 | FROM %sthread t |
@@ -2772,78 +2772,78 @@ discard block |
||
| 2772 | 2772 | WHERE f.parent_type = 1 |
| 2773 | 2773 | ORDER BY id', |
| 2774 | 2774 | $pre, $pre, $pre |
| 2775 | - ); |
|
| 2776 | - $boincteam_topic_count = mysqli_num_rows($boincteam_topics); |
|
| 2777 | - $total_team_topic_count = db_result(db_query(' |
|
| 2775 | + ); |
|
| 2776 | + $boincteam_topic_count = mysqli_num_rows($boincteam_topics); |
|
| 2777 | + $total_team_topic_count = db_result(db_query(' |
|
| 2778 | 2778 | SELECT COUNT(*) FROM %sthread t |
| 2779 | 2779 | JOIN %sforum f ON f.id = t.forum |
| 2780 | 2780 | WHERE f.parent_type = 1', $pre, $pre |
| 2781 | - )); |
|
| 2782 | - $empty_topic_count = $total_team_topic_count - $boincteam_topic_count; |
|
| 2783 | - db_set_active('default'); |
|
| 2781 | + )); |
|
| 2782 | + $empty_topic_count = $total_team_topic_count - $boincteam_topic_count; |
|
| 2783 | + db_set_active('default'); |
|
| 2784 | 2784 | |
| 2785 | - if (!$boincteam_topic_count) { |
|
| 2785 | + if (!$boincteam_topic_count) { |
|
| 2786 | 2786 | drupal_set_message( |
| 2787 | - t('There were no team topics found: Aborting script'), 'warning' |
|
| 2787 | + t('There were no team topics found: Aborting script'), 'warning' |
|
| 2788 | 2788 | ); |
| 2789 | 2789 | watchdog('boincimport', |
| 2790 | - 'There were no team topics found: Aborting script', array(), WATCHDOG_WARNING |
|
| 2790 | + 'There were no team topics found: Aborting script', array(), WATCHDOG_WARNING |
|
| 2791 | 2791 | ); |
| 2792 | 2792 | // Release the lock on the import process |
| 2793 | 2793 | variable_del('boincimport_process_locked'); |
| 2794 | 2794 | return t('There were no team topics found: Aborting script.'); |
| 2795 | - } |
|
| 2795 | + } |
|
| 2796 | 2796 | |
| 2797 | - watchdog('boincimport', |
|
| 2797 | + watchdog('boincimport', |
|
| 2798 | 2798 | 'Found %count team topics: Beginning Import', |
| 2799 | 2799 | array('%count' => $boincteam_topic_count), WATCHDOG_INFO |
| 2800 | - ); |
|
| 2800 | + ); |
|
| 2801 | 2801 | |
| 2802 | - $operations = array(); |
|
| 2803 | - $existing_team_topics = array(); |
|
| 2804 | - $duplicates = array(); |
|
| 2802 | + $operations = array(); |
|
| 2803 | + $existing_team_topics = array(); |
|
| 2804 | + $duplicates = array(); |
|
| 2805 | 2805 | |
| 2806 | - // Get the list of team topics already in Drupal to be sure we're not |
|
| 2807 | - // importing any twice |
|
| 2808 | - $result = db_query(' |
|
| 2806 | + // Get the list of team topics already in Drupal to be sure we're not |
|
| 2807 | + // importing any twice |
|
| 2808 | + $result = db_query(' |
|
| 2809 | 2809 | SELECT nid, topic_id FROM {boincimport_temp_topic}' |
| 2810 | - ); |
|
| 2811 | - while ($row = db_fetch_object($result)) { |
|
| 2810 | + ); |
|
| 2811 | + while ($row = db_fetch_object($result)) { |
|
| 2812 | 2812 | $existing_team_topics[$row->topic_id] = $row->nid; |
| 2813 | - } |
|
| 2813 | + } |
|
| 2814 | 2814 | |
| 2815 | - // Create batches to process |
|
| 2816 | - while ($boincteam_topic = db_fetch_object($boincteam_topics)) { |
|
| 2817 | - if (isset($existing_team_topics[$boincteam_topic->id])) { |
|
| 2818 | - // This team topic has already been imported |
|
| 2819 | - $duplicates[] = $boincteam_topic->id; |
|
| 2815 | + // Create batches to process |
|
| 2816 | + while ($boincteam_topic = db_fetch_object($boincteam_topics)) { |
|
| 2817 | + if (isset($existing_team_topics[$boincteam_topic->id])) { |
|
| 2818 | + // This team topic has already been imported |
|
| 2819 | + $duplicates[] = $boincteam_topic->id; |
|
| 2820 | 2820 | } |
| 2821 | 2821 | else { |
| 2822 | - $operations[] = array( |
|
| 2822 | + $operations[] = array( |
|
| 2823 | 2823 | 'boincimport_team_topics_op', array( |
| 2824 | - $boincteam_topic |
|
| 2824 | + $boincteam_topic |
|
| 2825 | 2825 | ) |
| 2826 | - ); |
|
| 2826 | + ); |
|
| 2827 | + } |
|
| 2827 | 2828 | } |
| 2828 | - } |
|
| 2829 | 2829 | |
| 2830 | - if ($duplicates) { |
|
| 2830 | + if ($duplicates) { |
|
| 2831 | 2831 | drupal_set_message(t( |
| 2832 | - 'Skipped @count team topics that were already imported', |
|
| 2833 | - array('@count' => count($duplicates)) |
|
| 2832 | + 'Skipped @count team topics that were already imported', |
|
| 2833 | + array('@count' => count($duplicates)) |
|
| 2834 | 2834 | )); |
| 2835 | - } |
|
| 2835 | + } |
|
| 2836 | 2836 | |
| 2837 | - $batch = array( |
|
| 2837 | + $batch = array( |
|
| 2838 | 2838 | 'operations' => $operations, |
| 2839 | 2839 | 'finished' => 'boincimport_team_topics_finished', |
| 2840 | 2840 | 'title' => t('Importing team topics'), |
| 2841 | 2841 | 'init_message' => t('Beginning team topic import...'), |
| 2842 | 2842 | 'progress_message' => t('Processed @current out of @total team topics.'), |
| 2843 | 2843 | 'error_message' => t('Team topic import has encountered an error.'), |
| 2844 | - ); |
|
| 2844 | + ); |
|
| 2845 | 2845 | |
| 2846 | - batch_set($batch); |
|
| 2846 | + batch_set($batch); |
|
| 2847 | 2847 | } |
| 2848 | 2848 | |
| 2849 | 2849 | /** |
@@ -2852,21 +2852,21 @@ discard block |
||
| 2852 | 2852 | */ |
| 2853 | 2853 | function boincimport_team_topics_op($topic, &$context) { |
| 2854 | 2854 | |
| 2855 | - $input_format = variable_get('boincimport_input_format', 0); |
|
| 2856 | - $success = FALSE; |
|
| 2857 | - $missing_parent = array(); |
|
| 2858 | - $empty_topics = array(); |
|
| 2855 | + $input_format = variable_get('boincimport_input_format', 0); |
|
| 2856 | + $success = FALSE; |
|
| 2857 | + $missing_parent = array(); |
|
| 2858 | + $empty_topics = array(); |
|
| 2859 | 2859 | |
| 2860 | - // Verify that the team forum container has been imported |
|
| 2861 | - $team_forum_id = db_result(db_query(" |
|
| 2860 | + // Verify that the team forum container has been imported |
|
| 2861 | + $team_forum_id = db_result(db_query(" |
|
| 2862 | 2862 | SELECT tfid FROM {boincteam_forum} |
| 2863 | 2863 | WHERE boinc_id = %d", |
| 2864 | 2864 | $topic->forum |
| 2865 | - )); |
|
| 2866 | - if (!$team_forum_id) { |
|
| 2865 | + )); |
|
| 2866 | + if (!$team_forum_id) { |
|
| 2867 | 2867 | $missing_parent[] = $topic->id; |
| 2868 | - } |
|
| 2869 | - else { |
|
| 2868 | + } |
|
| 2869 | + else { |
|
| 2870 | 2870 | // Get the content of the post that started the topic |
| 2871 | 2871 | db_set_active('boinc_rw'); |
| 2872 | 2872 | $query = db_query(' |
@@ -2875,36 +2875,36 @@ discard block |
||
| 2875 | 2875 | WHERE thread = %d |
| 2876 | 2876 | ORDER BY timestamp ASC |
| 2877 | 2877 | LIMIT 1', |
| 2878 | - $pre, $topic->id); |
|
| 2878 | + $pre, $topic->id); |
|
| 2879 | 2879 | db_set_active('default'); |
| 2880 | 2880 | |
| 2881 | 2881 | // Skip this topic if there are no posts |
| 2882 | 2882 | if (!$post = db_fetch_object($query)) { |
| 2883 | - // Empty topics should have already been filtered out of the import, so |
|
| 2884 | - // consider this an error condition |
|
| 2885 | - $empty_topics[] = $topic->id; |
|
| 2883 | + // Empty topics should have already been filtered out of the import, so |
|
| 2884 | + // consider this an error condition |
|
| 2885 | + $empty_topics[] = $topic->id; |
|
| 2886 | 2886 | } |
| 2887 | 2887 | else { |
| 2888 | - // Get the user ID along with other data to define the topic |
|
| 2889 | - $uid = boincuser_lookup_uid($topic->owner); |
|
| 2890 | - if (!$topic->owner) { |
|
| 2888 | + // Get the user ID along with other data to define the topic |
|
| 2889 | + $uid = boincuser_lookup_uid($topic->owner); |
|
| 2890 | + if (!$topic->owner) { |
|
| 2891 | 2891 | $uid = 0; |
| 2892 | - } |
|
| 2892 | + } |
|
| 2893 | 2893 | |
| 2894 | - $node_type = 'team_forum'; |
|
| 2895 | - $promote = 0; |
|
| 2896 | - $comment = ($topic->locked) ? 1 : 2; |
|
| 2894 | + $node_type = 'team_forum'; |
|
| 2895 | + $promote = 0; |
|
| 2896 | + $comment = ($topic->locked) ? 1 : 2; |
|
| 2897 | 2897 | |
| 2898 | - $post->content = _boincimport_strip_bbcode($post->content); |
|
| 2899 | - $post->content = _boincimport_text_sanitize($post->content); |
|
| 2900 | - $teaser = node_teaser($post->content); |
|
| 2898 | + $post->content = _boincimport_strip_bbcode($post->content); |
|
| 2899 | + $post->content = _boincimport_text_sanitize($post->content); |
|
| 2900 | + $teaser = node_teaser($post->content); |
|
| 2901 | 2901 | |
| 2902 | - if ($topic->timestamp < $topic->create_time) { |
|
| 2902 | + if ($topic->timestamp < $topic->create_time) { |
|
| 2903 | 2903 | $topic->timestamp = $topic->create_time; |
| 2904 | - } |
|
| 2904 | + } |
|
| 2905 | 2905 | |
| 2906 | - // Construct the thread as a team_forum topic node |
|
| 2907 | - $node = array( |
|
| 2906 | + // Construct the thread as a team_forum topic node |
|
| 2907 | + $node = array( |
|
| 2908 | 2908 | 'type' => $node_type, |
| 2909 | 2909 | 'title' => $topic->title, |
| 2910 | 2910 | 'uid' => $uid, |
@@ -2919,89 +2919,89 @@ discard block |
||
| 2919 | 2919 | 'format' => $input_format, |
| 2920 | 2920 | 'teaser' => $teaser, |
| 2921 | 2921 | 'tfid' => $team_forum_id, |
| 2922 | - ); |
|
| 2922 | + ); |
|
| 2923 | 2923 | |
| 2924 | - // Save the team topic node |
|
| 2925 | - $node = (object) $node; // node_save requires an object form |
|
| 2926 | - node_save($node); |
|
| 2924 | + // Save the team topic node |
|
| 2925 | + $node = (object) $node; // node_save requires an object form |
|
| 2926 | + node_save($node); |
|
| 2927 | 2927 | |
| 2928 | - if ($node->nid) { |
|
| 2928 | + if ($node->nid) { |
|
| 2929 | 2929 | db_query(' |
| 2930 | 2930 | INSERT INTO {boincimport_temp_topic} (topic_id, post_id, nid) |
| 2931 | 2931 | VALUES (%d, %d, %d)', |
| 2932 | - $topic->id, $post->id, $node->nid |
|
| 2932 | + $topic->id, $post->id, $node->nid |
|
| 2933 | 2933 | ); |
| 2934 | 2934 | // Hack to keep the topics in correct order |
| 2935 | 2935 | db_query(' |
| 2936 | 2936 | UPDATE {node_comment_statistics} |
| 2937 | 2937 | SET last_comment_timestamp = %d |
| 2938 | 2938 | WHERE nid = %d', |
| 2939 | - $node->created, $node->nid |
|
| 2939 | + $node->created, $node->nid |
|
| 2940 | 2940 | ); |
| 2941 | 2941 | $success = TRUE; |
| 2942 | - } |
|
| 2942 | + } |
|
| 2943 | + } |
|
| 2943 | 2944 | } |
| 2944 | - } |
|
| 2945 | 2945 | |
| 2946 | - $message = ''; |
|
| 2947 | - if ($success) { |
|
| 2946 | + $message = ''; |
|
| 2947 | + if ($success) { |
|
| 2948 | 2948 | // Store some result for post-processing in the finished callback. |
| 2949 | 2949 | $context['results']['success'][] = $topic->id; |
| 2950 | 2950 | $message = "Successfully imported team topic {$topic->id}"; |
| 2951 | - } |
|
| 2952 | - else { |
|
| 2951 | + } |
|
| 2952 | + else { |
|
| 2953 | 2953 | $context['results']['failure'][] = $topic->id; |
| 2954 | 2954 | $message = "Failed to import team topic {$topic->id}!"; |
| 2955 | 2955 | watchdog('boincimport', |
| 2956 | - 'Failed to import team topic @id!', |
|
| 2957 | - array('@id' => $topic->id), WATCHDOG_WARNING |
|
| 2956 | + 'Failed to import team topic @id!', |
|
| 2957 | + array('@id' => $topic->id), WATCHDOG_WARNING |
|
| 2958 | 2958 | ); |
| 2959 | - } |
|
| 2959 | + } |
|
| 2960 | 2960 | |
| 2961 | - // Update our progress information. |
|
| 2962 | - $context['sandbox']['progress']++; |
|
| 2963 | - $context['sandbox']['current_topic'] = $topic->id; |
|
| 2964 | - $context['message'] = $message; |
|
| 2961 | + // Update our progress information. |
|
| 2962 | + $context['sandbox']['progress']++; |
|
| 2963 | + $context['sandbox']['current_topic'] = $topic->id; |
|
| 2964 | + $context['message'] = $message; |
|
| 2965 | 2965 | |
| 2966 | - // Update the progress for the batch engine |
|
| 2967 | - if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 2966 | + // Update the progress for the batch engine |
|
| 2967 | + if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 2968 | 2968 | $context['finished'] = 1; |
| 2969 | - } |
|
| 2970 | - else { |
|
| 2969 | + } |
|
| 2970 | + else { |
|
| 2971 | 2971 | $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
| 2972 | - } |
|
| 2972 | + } |
|
| 2973 | 2973 | } |
| 2974 | 2974 | |
| 2975 | 2975 | /** |
| 2976 | 2976 | * Batch 'finished' callback |
| 2977 | 2977 | */ |
| 2978 | 2978 | function boincimport_team_topics_finished($success, $results, $operations) { |
| 2979 | - if ($success) { |
|
| 2979 | + if ($success) { |
|
| 2980 | 2980 | // Let's count our successes |
| 2981 | 2981 | $total_imported = count($results['success']); |
| 2982 | 2982 | $message = t( |
| 2983 | - 'Successfully imported @count team topics', |
|
| 2984 | - array('@count' => $total_imported) |
|
| 2983 | + 'Successfully imported @count team topics', |
|
| 2984 | + array('@count' => $total_imported) |
|
| 2985 | 2985 | ); |
| 2986 | 2986 | watchdog('boincimport', |
| 2987 | - 'Successfully imported @count team topics.', |
|
| 2988 | - array('@count' => $total_imported), WATCHDOG_INFO |
|
| 2987 | + 'Successfully imported @count team topics.', |
|
| 2988 | + array('@count' => $total_imported), WATCHDOG_INFO |
|
| 2989 | 2989 | ); |
| 2990 | 2990 | // Set the BLAH import successful flag in the variable table |
| 2991 | 2991 | variable_set('boincimport_import_team_topic_successful', '1'); |
| 2992 | 2992 | $_SESSION['boincimport_stage_selected'] = 'team posts'; |
| 2993 | - } |
|
| 2994 | - else { |
|
| 2993 | + } |
|
| 2994 | + else { |
|
| 2995 | 2995 | // An error occurred. |
| 2996 | 2996 | // $operations contains the operations that remained unprocessed. |
| 2997 | 2997 | $error_operation = reset($operations); |
| 2998 | 2998 | $message = 'An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE); |
| 2999 | - } |
|
| 3000 | - drupal_set_message($message); |
|
| 2999 | + } |
|
| 3000 | + drupal_set_message($message); |
|
| 3001 | 3001 | |
| 3002 | - // Release the lock on the import process |
|
| 3003 | - variable_del('boincimport_process_locked'); |
|
| 3004 | - drupal_goto('admin/boinc/import/process'); |
|
| 3002 | + // Release the lock on the import process |
|
| 3003 | + variable_del('boincimport_process_locked'); |
|
| 3004 | + drupal_goto('admin/boinc/import/process'); |
|
| 3005 | 3005 | } |
| 3006 | 3006 | |
| 3007 | 3007 | |
@@ -3014,81 +3014,81 @@ discard block |
||
| 3014 | 3014 | */ |
| 3015 | 3015 | function boincimport_team_forum_posts() { |
| 3016 | 3016 | |
| 3017 | - // Check whether team forum posts have been successfully imported already |
|
| 3018 | - if (variable_get('boincimport_import_team_post_successful', 0)) { |
|
| 3017 | + // Check whether team forum posts have been successfully imported already |
|
| 3018 | + if (variable_get('boincimport_import_team_post_successful', 0)) { |
|
| 3019 | 3019 | drupal_set_message(t('Team forum post import has already run successfully'), 'warning'); |
| 3020 | 3020 | watchdog( |
| 3021 | - 'boincimport', 'Team forum post import has already run successfully', |
|
| 3022 | - array(), WATCHDOG_WARNING |
|
| 3021 | + 'boincimport', 'Team forum post import has already run successfully', |
|
| 3022 | + array(), WATCHDOG_WARNING |
|
| 3023 | 3023 | ); |
| 3024 | 3024 | // Release the lock on the import process |
| 3025 | 3025 | variable_del('boincimport_process_locked'); |
| 3026 | 3026 | return; |
| 3027 | - } |
|
| 3027 | + } |
|
| 3028 | 3028 | |
| 3029 | - if (!variable_get('boincimport_import_team_post_started', 0)) { |
|
| 3029 | + if (!variable_get('boincimport_import_team_post_started', 0)) { |
|
| 3030 | 3030 | // Could prepare database tables, if new fields are necessary, etc. |
| 3031 | 3031 | variable_set('boincimport_import_team_post_started', 1); |
| 3032 | - } |
|
| 3032 | + } |
|
| 3033 | 3033 | |
| 3034 | - $pre = variable_get('boincimport_table_prefix', ''); |
|
| 3034 | + $pre = variable_get('boincimport_table_prefix', ''); |
|
| 3035 | 3035 | |
| 3036 | - // Get the BOINC threads and get a count of team posts to import |
|
| 3037 | - db_set_active('boinc_rw'); |
|
| 3038 | - $team_topic_ids = db_query(' |
|
| 3036 | + // Get the BOINC threads and get a count of team posts to import |
|
| 3037 | + db_set_active('boinc_rw'); |
|
| 3038 | + $team_topic_ids = db_query(' |
|
| 3039 | 3039 | SELECT DISTINCT t.id FROM %sthread t |
| 3040 | 3040 | JOIN %sforum f ON f.id = t.forum |
| 3041 | 3041 | JOIN %spost p ON p.thread = t.id |
| 3042 | 3042 | WHERE f.parent_type = 1 |
| 3043 | 3043 | ORDER BY id', $pre, $pre |
| 3044 | - ); |
|
| 3045 | - $team_topic_count = db_result(db_query(" |
|
| 3044 | + ); |
|
| 3045 | + $team_topic_count = db_result(db_query(" |
|
| 3046 | 3046 | SELECT COUNT(DISTINCT t.id) FROM %sthread t |
| 3047 | 3047 | JOIN %sforum f ON f.id = t.forum |
| 3048 | 3048 | JOIN %spost p ON p.thread = t.id |
| 3049 | 3049 | WHERE f.parent_type = 1", $pre, $pre, $pre |
| 3050 | - )); |
|
| 3051 | - $total_team_post_count = db_result(db_query(" |
|
| 3050 | + )); |
|
| 3051 | + $total_team_post_count = db_result(db_query(" |
|
| 3052 | 3052 | SELECT COUNT(p.id) FROM %spost p |
| 3053 | 3053 | JOIN %sthread t ON t.id = p.thread |
| 3054 | 3054 | JOIN %sforum f ON f.id = t.forum |
| 3055 | 3055 | WHERE f.parent_type = 1", $pre, $pre, $pre |
| 3056 | - )); |
|
| 3057 | - $team_post_count = $total_team_post_count - $team_topic_count; |
|
| 3058 | - db_set_active('default'); |
|
| 3056 | + )); |
|
| 3057 | + $team_post_count = $total_team_post_count - $team_topic_count; |
|
| 3058 | + db_set_active('default'); |
|
| 3059 | 3059 | |
| 3060 | - if ($team_post_count <= 0) { |
|
| 3060 | + if ($team_post_count <= 0) { |
|
| 3061 | 3061 | drupal_set_message( |
| 3062 | - t('There were no team posts found: Aborting script'), 'warning' |
|
| 3062 | + t('There were no team posts found: Aborting script'), 'warning' |
|
| 3063 | 3063 | ); |
| 3064 | 3064 | watchdog('boincimport', |
| 3065 | - 'There were no team posts found: Aborting script', array(), WATCHDOG_WARNING |
|
| 3065 | + 'There were no team posts found: Aborting script', array(), WATCHDOG_WARNING |
|
| 3066 | 3066 | ); |
| 3067 | 3067 | // Release the lock on the import process |
| 3068 | 3068 | variable_del('boincimport_process_locked'); |
| 3069 | 3069 | return t('There were no posts found: Aborting script.'); |
| 3070 | - } |
|
| 3070 | + } |
|
| 3071 | 3071 | |
| 3072 | - watchdog('boincimport', |
|
| 3072 | + watchdog('boincimport', |
|
| 3073 | 3073 | 'Found %count team posts: Beginning Import', |
| 3074 | 3074 | array('%count' => $team_post_count), WATCHDOG_INFO |
| 3075 | - ); |
|
| 3075 | + ); |
|
| 3076 | 3076 | |
| 3077 | - $operations = array(); |
|
| 3078 | - $existing_posts = array(); |
|
| 3079 | - $duplicates = array(); |
|
| 3077 | + $operations = array(); |
|
| 3078 | + $existing_posts = array(); |
|
| 3079 | + $duplicates = array(); |
|
| 3080 | 3080 | |
| 3081 | - // Get the list of team posts already in Drupal to be sure we're not |
|
| 3082 | - // importing any twice |
|
| 3083 | - $result = db_query(' |
|
| 3081 | + // Get the list of team posts already in Drupal to be sure we're not |
|
| 3082 | + // importing any twice |
|
| 3083 | + $result = db_query(' |
|
| 3084 | 3084 | SELECT cid, post_id FROM {boincimport_temp_post}' |
| 3085 | - ); |
|
| 3086 | - while ($row = db_fetch_object($result)) { |
|
| 3085 | + ); |
|
| 3086 | + while ($row = db_fetch_object($result)) { |
|
| 3087 | 3087 | $existing_posts[$row->post_id] = $row->cid; |
| 3088 | - } |
|
| 3088 | + } |
|
| 3089 | 3089 | |
| 3090 | - // Create batches to process |
|
| 3091 | - while ($boincteam_topic = db_fetch_object($team_topic_ids)) { |
|
| 3090 | + // Create batches to process |
|
| 3091 | + while ($boincteam_topic = db_fetch_object($team_topic_ids)) { |
|
| 3092 | 3092 | |
| 3093 | 3093 | db_set_active('boinc_rw'); |
| 3094 | 3094 | $boincteam_posts = db_query(' |
@@ -3096,7 +3096,7 @@ discard block |
||
| 3096 | 3096 | FROM %spost |
| 3097 | 3097 | WHERE thread = %d |
| 3098 | 3098 | ORDER BY timestamp ASC', |
| 3099 | - $pre, $boincteam_topic->id |
|
| 3099 | + $pre, $boincteam_topic->id |
|
| 3100 | 3100 | ); |
| 3101 | 3101 | db_set_active('default'); |
| 3102 | 3102 | |
@@ -3104,43 +3104,43 @@ discard block |
||
| 3104 | 3104 | |
| 3105 | 3105 | while ($boincteam_post = db_fetch_object($boincteam_posts)) { |
| 3106 | 3106 | |
| 3107 | - // Skip the first post as it has already been imported as a topic |
|
| 3108 | - if ($first_post) { |
|
| 3107 | + // Skip the first post as it has already been imported as a topic |
|
| 3108 | + if ($first_post) { |
|
| 3109 | 3109 | $first_post = false; |
| 3110 | 3110 | continue; |
| 3111 | - } |
|
| 3111 | + } |
|
| 3112 | 3112 | |
| 3113 | - if (isset($existing_posts[$boincteam_post->id])) { |
|
| 3113 | + if (isset($existing_posts[$boincteam_post->id])) { |
|
| 3114 | 3114 | // This post has already been imported |
| 3115 | 3115 | $duplicates[] = $boincteam_post->id; |
| 3116 | - } |
|
| 3117 | - else { |
|
| 3116 | + } |
|
| 3117 | + else { |
|
| 3118 | 3118 | $operations[] = array( |
| 3119 | - 'boincimport_team_posts_op', array( |
|
| 3119 | + 'boincimport_team_posts_op', array( |
|
| 3120 | 3120 | $boincteam_post |
| 3121 | - ) |
|
| 3121 | + ) |
|
| 3122 | 3122 | ); |
| 3123 | - } |
|
| 3123 | + } |
|
| 3124 | + } |
|
| 3124 | 3125 | } |
| 3125 | - } |
|
| 3126 | 3126 | |
| 3127 | - if ($duplicates) { |
|
| 3127 | + if ($duplicates) { |
|
| 3128 | 3128 | drupal_set_message(t( |
| 3129 | - 'Skipped @count team posts that were already imported', |
|
| 3130 | - array('@count' => count($duplicates)) |
|
| 3129 | + 'Skipped @count team posts that were already imported', |
|
| 3130 | + array('@count' => count($duplicates)) |
|
| 3131 | 3131 | )); |
| 3132 | - } |
|
| 3132 | + } |
|
| 3133 | 3133 | |
| 3134 | - $batch = array( |
|
| 3134 | + $batch = array( |
|
| 3135 | 3135 | 'operations' => $operations, |
| 3136 | 3136 | 'finished' => 'boincimport_team_posts_finished', |
| 3137 | 3137 | 'title' => t('Importing team posts'), |
| 3138 | 3138 | 'init_message' => t('Beginning team post import...'), |
| 3139 | 3139 | 'progress_message' => t('Processed @current out of @total team posts.'), |
| 3140 | 3140 | 'error_message' => t('Team post import has encountered an error.'), |
| 3141 | - ); |
|
| 3141 | + ); |
|
| 3142 | 3142 | |
| 3143 | - batch_set($batch); |
|
| 3143 | + batch_set($batch); |
|
| 3144 | 3144 | } |
| 3145 | 3145 | |
| 3146 | 3146 | /** |
@@ -3149,11 +3149,11 @@ discard block |
||
| 3149 | 3149 | */ |
| 3150 | 3150 | function boincimport_team_posts_op($post, &$context) { |
| 3151 | 3151 | |
| 3152 | - $input_format = variable_get('boincimport_input_format', 0); |
|
| 3153 | - $success = FALSE; |
|
| 3152 | + $input_format = variable_get('boincimport_input_format', 0); |
|
| 3153 | + $success = FALSE; |
|
| 3154 | 3154 | |
| 3155 | - // Make sure the post is valid |
|
| 3156 | - if ($post->content) { |
|
| 3155 | + // Make sure the post is valid |
|
| 3156 | + if ($post->content) { |
|
| 3157 | 3157 | |
| 3158 | 3158 | // Get user, node, and parent IDs for the post and sanitize |
| 3159 | 3159 | $uid = boincuser_lookup_uid($post->user); |
@@ -3162,14 +3162,14 @@ discard block |
||
| 3162 | 3162 | FROM {boincimport_temp_topic} btt |
| 3163 | 3163 | LEFT JOIN {node_revisions} AS nr ON btt.nid = nr.nid |
| 3164 | 3164 | WHERE btt.topic_id = %d', |
| 3165 | - $post->thread |
|
| 3165 | + $post->thread |
|
| 3166 | 3166 | )); |
| 3167 | 3167 | $nid = $node->nid; |
| 3168 | 3168 | $pid = db_result(db_query(' |
| 3169 | 3169 | SELECT cid |
| 3170 | 3170 | FROM {boincimport_temp_post} |
| 3171 | 3171 | WHERE post_id = %d', |
| 3172 | - $post->parent_post)); |
|
| 3172 | + $post->parent_post)); |
|
| 3173 | 3173 | if (is_null($pid)) $pid = 0; |
| 3174 | 3174 | if (!$uid) $uid = 0; |
| 3175 | 3175 | |
@@ -3180,110 +3180,110 @@ discard block |
||
| 3180 | 3180 | SELECT COUNT(*) |
| 3181 | 3181 | FROM {comments} |
| 3182 | 3182 | WHERE nid = %d', |
| 3183 | - $nid |
|
| 3183 | + $nid |
|
| 3184 | 3184 | )); |
| 3185 | 3185 | $post_reply = $pid; |
| 3186 | 3186 | |
| 3187 | 3187 | if ($post_reply OR $topic_reply) { |
| 3188 | - // Create a subject for the post from the post content. The body may be in |
|
| 3189 | - // any format, so we: |
|
| 3190 | - // 1) Filter it into HTML |
|
| 3191 | - // 2) Strip out all HTML tags |
|
| 3192 | - // 3) Convert entities back to plain-text. |
|
| 3193 | - // Note: format is checked by check_markup(). |
|
| 3194 | - $subject = truncate_utf8(trim(decode_entities(strip_tags(check_markup($post->content, $input_format)))), 29, TRUE); |
|
| 3195 | - // Replace "Quote:" with "RE:" |
|
| 3196 | - $subject = str_replace('Quote:', 'RE: ', $subject); |
|
| 3197 | - // Fringe cases where the comment body is populated only by HTML tags |
|
| 3198 | - // will require a default subject... |
|
| 3199 | - if ($subject === '') |
|
| 3188 | + // Create a subject for the post from the post content. The body may be in |
|
| 3189 | + // any format, so we: |
|
| 3190 | + // 1) Filter it into HTML |
|
| 3191 | + // 2) Strip out all HTML tags |
|
| 3192 | + // 3) Convert entities back to plain-text. |
|
| 3193 | + // Note: format is checked by check_markup(). |
|
| 3194 | + $subject = truncate_utf8(trim(decode_entities(strip_tags(check_markup($post->content, $input_format)))), 29, TRUE); |
|
| 3195 | + // Replace "Quote:" with "RE:" |
|
| 3196 | + $subject = str_replace('Quote:', 'RE: ', $subject); |
|
| 3197 | + // Fringe cases where the comment body is populated only by HTML tags |
|
| 3198 | + // will require a default subject... |
|
| 3199 | + if ($subject === '') |
|
| 3200 | 3200 | $subject = "RE: {$node->title}"; |
| 3201 | 3201 | } else { |
| 3202 | - // This is the first post in the topic |
|
| 3203 | - $subject = $node->title; |
|
| 3202 | + // This is the first post in the topic |
|
| 3203 | + $subject = $node->title; |
|
| 3204 | 3204 | } |
| 3205 | 3205 | |
| 3206 | 3206 | // Construct the post as a Drupal comment |
| 3207 | 3207 | $comment = array( |
| 3208 | - 'pid' => $pid, |
|
| 3209 | - 'nid' => $nid, |
|
| 3210 | - 'uid' => $uid, |
|
| 3211 | - 'subject' => $subject, |
|
| 3212 | - 'comment' => $post->content, |
|
| 3213 | - 'timestamp' => $post->timestamp, |
|
| 3214 | - 'status' => $post->hidden, |
|
| 3215 | - 'format' => $input_format |
|
| 3208 | + 'pid' => $pid, |
|
| 3209 | + 'nid' => $nid, |
|
| 3210 | + 'uid' => $uid, |
|
| 3211 | + 'subject' => $subject, |
|
| 3212 | + 'comment' => $post->content, |
|
| 3213 | + 'timestamp' => $post->timestamp, |
|
| 3214 | + 'status' => $post->hidden, |
|
| 3215 | + 'format' => $input_format |
|
| 3216 | 3216 | ); |
| 3217 | 3217 | |
| 3218 | 3218 | // Save the comment |
| 3219 | 3219 | if (boincimport_forum_comment_save($comment)) { |
| 3220 | - $success = db_query(' |
|
| 3220 | + $success = db_query(' |
|
| 3221 | 3221 | INSERT INTO {boincimport_temp_post} (post_id, cid) |
| 3222 | 3222 | VALUES (%d, %d)', |
| 3223 | 3223 | $post->id, $comment['cid'] |
| 3224 | - ); |
|
| 3224 | + ); |
|
| 3225 | + } |
|
| 3225 | 3226 | } |
| 3226 | - } |
|
| 3227 | 3227 | |
| 3228 | - $message = ''; |
|
| 3229 | - if ($success) { |
|
| 3228 | + $message = ''; |
|
| 3229 | + if ($success) { |
|
| 3230 | 3230 | // Store some result for post-processing in the finished callback. |
| 3231 | 3231 | $context['results']['success'][] = $post->id; |
| 3232 | 3232 | $message = "Successfully imported team post {$post->id}"; |
| 3233 | - } |
|
| 3234 | - else { |
|
| 3233 | + } |
|
| 3234 | + else { |
|
| 3235 | 3235 | $context['results']['failure'][] = $post->id; |
| 3236 | 3236 | $message = "Failed to import team post {$post->id}!"; |
| 3237 | 3237 | watchdog('boincimport', |
| 3238 | - 'Failed to import team post @id!', |
|
| 3239 | - array('@id' => $post->id), WATCHDOG_WARNING |
|
| 3238 | + 'Failed to import team post @id!', |
|
| 3239 | + array('@id' => $post->id), WATCHDOG_WARNING |
|
| 3240 | 3240 | ); |
| 3241 | - } |
|
| 3241 | + } |
|
| 3242 | 3242 | |
| 3243 | - // Update our progress information. |
|
| 3244 | - $context['sandbox']['progress']++; |
|
| 3245 | - $context['sandbox']['current_post'] = $post->id; |
|
| 3246 | - $context['message'] = $message; |
|
| 3243 | + // Update our progress information. |
|
| 3244 | + $context['sandbox']['progress']++; |
|
| 3245 | + $context['sandbox']['current_post'] = $post->id; |
|
| 3246 | + $context['message'] = $message; |
|
| 3247 | 3247 | |
| 3248 | - // Update the progress for the batch engine |
|
| 3249 | - if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 3248 | + // Update the progress for the batch engine |
|
| 3249 | + if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 3250 | 3250 | $context['finished'] = 1; |
| 3251 | - } |
|
| 3252 | - else { |
|
| 3251 | + } |
|
| 3252 | + else { |
|
| 3253 | 3253 | $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
| 3254 | - } |
|
| 3254 | + } |
|
| 3255 | 3255 | } |
| 3256 | 3256 | |
| 3257 | 3257 | /** |
| 3258 | 3258 | * Batch 'finished' callback |
| 3259 | 3259 | */ |
| 3260 | 3260 | function boincimport_team_posts_finished($success, $results, $operations) { |
| 3261 | - if ($success) { |
|
| 3261 | + if ($success) { |
|
| 3262 | 3262 | // Let's count our successes |
| 3263 | 3263 | $total_imported = count($results['success']); |
| 3264 | 3264 | $message = t( |
| 3265 | - 'Successfully imported @count team posts', |
|
| 3266 | - array('@count' => $total_imported) |
|
| 3265 | + 'Successfully imported @count team posts', |
|
| 3266 | + array('@count' => $total_imported) |
|
| 3267 | 3267 | ); |
| 3268 | 3268 | watchdog('boincimport', |
| 3269 | - 'Successfully imported @count team posts.', |
|
| 3270 | - array('@count' => $total_imported), WATCHDOG_INFO |
|
| 3269 | + 'Successfully imported @count team posts.', |
|
| 3270 | + array('@count' => $total_imported), WATCHDOG_INFO |
|
| 3271 | 3271 | ); |
| 3272 | 3272 | // Set the team post import successful flag in the variable table |
| 3273 | 3273 | variable_set('boincimport_import_team_post_successful', '1'); |
| 3274 | 3274 | $_SESSION['boincimport_stage_selected'] = 'url'; |
| 3275 | - } |
|
| 3276 | - else { |
|
| 3275 | + } |
|
| 3276 | + else { |
|
| 3277 | 3277 | // An error occurred. |
| 3278 | 3278 | // $operations contains the operations that remained unprocessed. |
| 3279 | 3279 | $error_operation = reset($operations); |
| 3280 | 3280 | $message = 'An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE); |
| 3281 | - } |
|
| 3282 | - drupal_set_message($message); |
|
| 3281 | + } |
|
| 3282 | + drupal_set_message($message); |
|
| 3283 | 3283 | |
| 3284 | - // Release the lock on the import process |
|
| 3285 | - variable_del('boincimport_process_locked'); |
|
| 3286 | - drupal_goto('admin/boinc/import/process'); |
|
| 3284 | + // Release the lock on the import process |
|
| 3285 | + variable_del('boincimport_process_locked'); |
|
| 3286 | + drupal_goto('admin/boinc/import/process'); |
|
| 3287 | 3287 | } |
| 3288 | 3288 | |
| 3289 | 3289 | |
@@ -3296,71 +3296,71 @@ discard block |
||
| 3296 | 3296 | */ |
| 3297 | 3297 | function boincimport_subscriptions() { |
| 3298 | 3298 | |
| 3299 | - // Check whether subscriptions have been successfully imported already |
|
| 3300 | - if (variable_get('boincimport_import_subscription_successful', 0)) { |
|
| 3299 | + // Check whether subscriptions have been successfully imported already |
|
| 3300 | + if (variable_get('boincimport_import_subscription_successful', 0)) { |
|
| 3301 | 3301 | drupal_set_message(t('Subscription import has already run successfully'), 'warning'); |
| 3302 | 3302 | watchdog( |
| 3303 | - 'boincimport', 'Subscription import has already run successfully', |
|
| 3304 | - array(), WATCHDOG_WARNING |
|
| 3303 | + 'boincimport', 'Subscription import has already run successfully', |
|
| 3304 | + array(), WATCHDOG_WARNING |
|
| 3305 | 3305 | ); |
| 3306 | - } |
|
| 3306 | + } |
|
| 3307 | 3307 | |
| 3308 | - if (!variable_get('boincimport_import_subscription_started', 0)) { |
|
| 3308 | + if (!variable_get('boincimport_import_subscription_started', 0)) { |
|
| 3309 | 3309 | // Could prepare database tables, if new fields are necessary, etc. |
| 3310 | 3310 | variable_set('boincimport_import_subscription_started', 1); |
| 3311 | - } |
|
| 3311 | + } |
|
| 3312 | 3312 | |
| 3313 | - $pre = variable_get('boincimport_table_prefix', ''); |
|
| 3313 | + $pre = variable_get('boincimport_table_prefix', ''); |
|
| 3314 | 3314 | |
| 3315 | - // Get users with subscriptions to import |
|
| 3316 | - db_set_active('boinc_rw'); |
|
| 3317 | - $users_with_subscriptions = db_query(' |
|
| 3315 | + // Get users with subscriptions to import |
|
| 3316 | + db_set_active('boinc_rw'); |
|
| 3317 | + $users_with_subscriptions = db_query(' |
|
| 3318 | 3318 | SELECT DISTINCT userid |
| 3319 | 3319 | FROM %ssubscriptions |
| 3320 | 3320 | ORDER BY userid ASC', |
| 3321 | 3321 | $pre |
| 3322 | - ); |
|
| 3323 | - $user_count = mysqli_num_rows($users_with_subscriptions); |
|
| 3324 | - db_set_active('default'); |
|
| 3322 | + ); |
|
| 3323 | + $user_count = mysqli_num_rows($users_with_subscriptions); |
|
| 3324 | + db_set_active('default'); |
|
| 3325 | 3325 | |
| 3326 | - if (!$user_count) { |
|
| 3326 | + if (!$user_count) { |
|
| 3327 | 3327 | drupal_set_message( |
| 3328 | - t('There were no subscriptions found: Aborting script'), 'warning' |
|
| 3328 | + t('There were no subscriptions found: Aborting script'), 'warning' |
|
| 3329 | 3329 | ); |
| 3330 | 3330 | watchdog('boincimport', |
| 3331 | - 'There were no subscriptions found: Aborting script', array(), WATCHDOG_WARNING |
|
| 3331 | + 'There were no subscriptions found: Aborting script', array(), WATCHDOG_WARNING |
|
| 3332 | 3332 | ); |
| 3333 | 3333 | // Release the lock on the import process |
| 3334 | 3334 | variable_del('boincimport_process_locked'); |
| 3335 | 3335 | return t('There were no subscriptions found: Aborting script.'); |
| 3336 | - } |
|
| 3336 | + } |
|
| 3337 | 3337 | |
| 3338 | - watchdog('boincimport', |
|
| 3338 | + watchdog('boincimport', |
|
| 3339 | 3339 | 'Found %count users with subscriptions: Beginning import', |
| 3340 | 3340 | array('%count' => $user_count), WATCHDOG_INFO |
| 3341 | - ); |
|
| 3341 | + ); |
|
| 3342 | 3342 | |
| 3343 | - $operations = array(); |
|
| 3343 | + $operations = array(); |
|
| 3344 | 3344 | |
| 3345 | - // Create batches to process |
|
| 3346 | - while ($subscribed_user = db_fetch_object($users_with_subscriptions)) { |
|
| 3345 | + // Create batches to process |
|
| 3346 | + while ($subscribed_user = db_fetch_object($users_with_subscriptions)) { |
|
| 3347 | 3347 | $operations[] = array( |
| 3348 | - 'boincimport_subscriptions_op', array( |
|
| 3348 | + 'boincimport_subscriptions_op', array( |
|
| 3349 | 3349 | $subscribed_user->userid |
| 3350 | - ) |
|
| 3350 | + ) |
|
| 3351 | 3351 | ); |
| 3352 | - } |
|
| 3352 | + } |
|
| 3353 | 3353 | |
| 3354 | - $batch = array( |
|
| 3354 | + $batch = array( |
|
| 3355 | 3355 | 'operations' => $operations, |
| 3356 | 3356 | 'finished' => 'boincimport_subscriptions_finished', |
| 3357 | 3357 | 'title' => t('Importing subscriptions'), |
| 3358 | 3358 | 'init_message' => t('Beginning subscription import...'), |
| 3359 | 3359 | 'progress_message' => t('Processed @current out of @total subscriptions.'), |
| 3360 | 3360 | 'error_message' => t('Subscription import has encountered an error.'), |
| 3361 | - ); |
|
| 3361 | + ); |
|
| 3362 | 3362 | |
| 3363 | - batch_set($batch); |
|
| 3363 | + batch_set($batch); |
|
| 3364 | 3364 | } |
| 3365 | 3365 | |
| 3366 | 3366 | /** |
@@ -3369,72 +3369,72 @@ discard block |
||
| 3369 | 3369 | */ |
| 3370 | 3370 | function boincimport_subscriptions_op($boincuser_id, &$context) { |
| 3371 | 3371 | |
| 3372 | - // Get the drupal user and pull subscriptions |
|
| 3373 | - $uid = get_drupal_id($boincuser_id); |
|
| 3374 | - $count = boincuser_pull_subscriptions($uid); |
|
| 3372 | + // Get the drupal user and pull subscriptions |
|
| 3373 | + $uid = get_drupal_id($boincuser_id); |
|
| 3374 | + $count = boincuser_pull_subscriptions($uid); |
|
| 3375 | 3375 | |
| 3376 | - $message = ''; |
|
| 3377 | - if ($count) { |
|
| 3376 | + $message = ''; |
|
| 3377 | + if ($count) { |
|
| 3378 | 3378 | // Store some result for post-processing in the finished callback. |
| 3379 | 3379 | $context['results']['success'][] = $boincuser_id; |
| 3380 | 3380 | $context['results']['subscriptions'][$boincuser_id] = $count; |
| 3381 | 3381 | $message = "Successfully imported {$count} subscriptions for user {$boincuser_id}"; |
| 3382 | - } |
|
| 3383 | - else { |
|
| 3382 | + } |
|
| 3383 | + else { |
|
| 3384 | 3384 | $context['results']['failure'][] = $boincuser_id; |
| 3385 | 3385 | $message = "Failed to import subscriptions for user {$boincuser_id}!"; |
| 3386 | 3386 | watchdog('boincimport', |
| 3387 | - 'Failed to import subscriptions for user @id!', |
|
| 3388 | - array('@id' => $boincuser_id), WATCHDOG_WARNING |
|
| 3387 | + 'Failed to import subscriptions for user @id!', |
|
| 3388 | + array('@id' => $boincuser_id), WATCHDOG_WARNING |
|
| 3389 | 3389 | ); |
| 3390 | - } |
|
| 3390 | + } |
|
| 3391 | 3391 | |
| 3392 | - // Update our progress information. |
|
| 3393 | - $context['sandbox']['progress']++; |
|
| 3394 | - $context['sandbox']['current_user'] = $boincuser_id; |
|
| 3395 | - $context['message'] = $message; |
|
| 3392 | + // Update our progress information. |
|
| 3393 | + $context['sandbox']['progress']++; |
|
| 3394 | + $context['sandbox']['current_user'] = $boincuser_id; |
|
| 3395 | + $context['message'] = $message; |
|
| 3396 | 3396 | |
| 3397 | - // Update the progress for the batch engine |
|
| 3398 | - if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 3397 | + // Update the progress for the batch engine |
|
| 3398 | + if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 3399 | 3399 | $context['finished'] = 1; |
| 3400 | - } |
|
| 3401 | - else { |
|
| 3400 | + } |
|
| 3401 | + else { |
|
| 3402 | 3402 | $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
| 3403 | - } |
|
| 3403 | + } |
|
| 3404 | 3404 | } |
| 3405 | 3405 | |
| 3406 | 3406 | /** |
| 3407 | 3407 | * Batch 'finished' callback |
| 3408 | 3408 | */ |
| 3409 | 3409 | function boincimport_subscriptions_finished($success, $results, $operations) { |
| 3410 | - if ($success) { |
|
| 3410 | + if ($success) { |
|
| 3411 | 3411 | // Let's count our successes |
| 3412 | 3412 | $user_count = count($results['success']); |
| 3413 | 3413 | $subscriptions_imported = array_sum($results['subscriptions']); |
| 3414 | 3414 | $message = t( |
| 3415 | - 'Successfully imported @count subscriptions for @distinct users', |
|
| 3416 | - array('@count' => $subscriptions_imported, '@distinct' => $user_count) |
|
| 3415 | + 'Successfully imported @count subscriptions for @distinct users', |
|
| 3416 | + array('@count' => $subscriptions_imported, '@distinct' => $user_count) |
|
| 3417 | 3417 | ); |
| 3418 | 3418 | watchdog('boincimport', |
| 3419 | - 'Successfully imported @count subscriptions for @distinct users.', |
|
| 3420 | - array('@count' => $subscriptions_imported, '@distinct' => $user_count), |
|
| 3421 | - WATCHDOG_INFO |
|
| 3419 | + 'Successfully imported @count subscriptions for @distinct users.', |
|
| 3420 | + array('@count' => $subscriptions_imported, '@distinct' => $user_count), |
|
| 3421 | + WATCHDOG_INFO |
|
| 3422 | 3422 | ); |
| 3423 | 3423 | // Set the subscription import successful flag in the variable table |
| 3424 | 3424 | variable_set('boincimport_import_subscription_successful', '1'); |
| 3425 | 3425 | $_SESSION['boincimport_stage_selected'] = 'url'; |
| 3426 | - } |
|
| 3427 | - else { |
|
| 3426 | + } |
|
| 3427 | + else { |
|
| 3428 | 3428 | // An error occurred. |
| 3429 | 3429 | // $operations contains the operations that remained unprocessed. |
| 3430 | 3430 | $error_operation = reset($operations); |
| 3431 | 3431 | $message = 'An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE); |
| 3432 | - } |
|
| 3433 | - drupal_set_message($message); |
|
| 3432 | + } |
|
| 3433 | + drupal_set_message($message); |
|
| 3434 | 3434 | |
| 3435 | - // Release the lock on the import process |
|
| 3436 | - variable_del('boincimport_process_locked'); |
|
| 3437 | - drupal_goto('admin/boinc/import/process'); |
|
| 3435 | + // Release the lock on the import process |
|
| 3436 | + variable_del('boincimport_process_locked'); |
|
| 3437 | + drupal_goto('admin/boinc/import/process'); |
|
| 3438 | 3438 | } |
| 3439 | 3439 | |
| 3440 | 3440 | |
@@ -3446,112 +3446,112 @@ discard block |
||
| 3446 | 3446 | */ |
| 3447 | 3447 | function boincimport_replace_urls() { |
| 3448 | 3448 | |
| 3449 | - // Check whether URLs have already been fixed |
|
| 3450 | - if (variable_get('boincimport_replace_url_successful', 0)) { |
|
| 3449 | + // Check whether URLs have already been fixed |
|
| 3450 | + if (variable_get('boincimport_replace_url_successful', 0)) { |
|
| 3451 | 3451 | drupal_set_message(t('URLs have already been updated'), 'warning'); |
| 3452 | 3452 | watchdog( |
| 3453 | - 'boincimport', 'URLs have already been updated', |
|
| 3454 | - array(), WATCHDOG_WARNING |
|
| 3453 | + 'boincimport', 'URLs have already been updated', |
|
| 3454 | + array(), WATCHDOG_WARNING |
|
| 3455 | 3455 | ); |
| 3456 | - } |
|
| 3456 | + } |
|
| 3457 | 3457 | |
| 3458 | - if (!variable_get('boincimport_replace_url_started', 0)) { |
|
| 3458 | + if (!variable_get('boincimport_replace_url_started', 0)) { |
|
| 3459 | 3459 | // Could prepare database tables, if new fields are necessary, etc. |
| 3460 | 3460 | variable_set('boincimport_replace_url_started', 1); |
| 3461 | - } |
|
| 3461 | + } |
|
| 3462 | 3462 | |
| 3463 | - // Get the count of nodes and comments to process for URL updates |
|
| 3464 | - $node_count = db_result(db_query(' |
|
| 3463 | + // Get the count of nodes and comments to process for URL updates |
|
| 3464 | + $node_count = db_result(db_query(' |
|
| 3465 | 3465 | SELECT COUNT(DISTINCT btt.nid) |
| 3466 | 3466 | FROM {boincimport_temp_topic} AS btt |
| 3467 | 3467 | LEFT JOIN {node_revisions} AS nr ON btt.nid = nr.nid' |
| 3468 | - )); |
|
| 3468 | + )); |
|
| 3469 | 3469 | |
| 3470 | - $comment_count = db_result(db_query(' |
|
| 3470 | + $comment_count = db_result(db_query(' |
|
| 3471 | 3471 | SELECT COUNT(c.cid) |
| 3472 | 3472 | FROM {boincimport_temp_post} AS p |
| 3473 | 3473 | LEFT JOIN {comments} AS c ON p.cid = c.cid' |
| 3474 | - )); |
|
| 3474 | + )); |
|
| 3475 | 3475 | |
| 3476 | - $pm_count = db_result(db_query(' |
|
| 3476 | + $pm_count = db_result(db_query(' |
|
| 3477 | 3477 | SELECT COUNT(*) |
| 3478 | 3478 | FROM {pm_message} pm' |
| 3479 | - )); |
|
| 3479 | + )); |
|
| 3480 | 3480 | |
| 3481 | - if (!$node_count AND !$comment_count AND !$pm_count) { |
|
| 3481 | + if (!$node_count AND !$comment_count AND !$pm_count) { |
|
| 3482 | 3482 | drupal_set_message( |
| 3483 | - t('There were no nodes, comments, or private messages found: Aborting script'), 'warning' |
|
| 3483 | + t('There were no nodes, comments, or private messages found: Aborting script'), 'warning' |
|
| 3484 | 3484 | ); |
| 3485 | 3485 | watchdog('boincimport', |
| 3486 | - 'There were no nodes,comments, or private messages found: Aborting script', array(), WATCHDOG_WARNING |
|
| 3486 | + 'There were no nodes,comments, or private messages found: Aborting script', array(), WATCHDOG_WARNING |
|
| 3487 | 3487 | ); |
| 3488 | 3488 | // Release the lock on the import process |
| 3489 | 3489 | variable_del('boincimport_process_locked'); |
| 3490 | 3490 | return t('There were no nodes, comments, or private messages found: Aborting script.'); |
| 3491 | - } |
|
| 3491 | + } |
|
| 3492 | 3492 | |
| 3493 | - watchdog('boincimport', |
|
| 3493 | + watchdog('boincimport', |
|
| 3494 | 3494 | 'Found %node_count nodes, %comment_count comments, and %pm_count private messages: Updating URLs...', |
| 3495 | 3495 | array( |
| 3496 | - '%node_count' => $node_count, |
|
| 3497 | - '%comment_count' => $comment_count, |
|
| 3498 | - '%pm_count' => $pm_count, |
|
| 3496 | + '%node_count' => $node_count, |
|
| 3497 | + '%comment_count' => $comment_count, |
|
| 3498 | + '%pm_count' => $pm_count, |
|
| 3499 | 3499 | ), |
| 3500 | 3500 | WATCHDOG_INFO |
| 3501 | - ); |
|
| 3501 | + ); |
|
| 3502 | 3502 | |
| 3503 | - $operations = array(); |
|
| 3504 | - $batch_size = 100; |
|
| 3503 | + $operations = array(); |
|
| 3504 | + $batch_size = 100; |
|
| 3505 | 3505 | |
| 3506 | - // Create node batches to process |
|
| 3507 | - for ($offset = 0; $offset < $node_count; $offset+=$batch_size) { |
|
| 3506 | + // Create node batches to process |
|
| 3507 | + for ($offset = 0; $offset < $node_count; $offset+=$batch_size) { |
|
| 3508 | 3508 | $nodes_per_batch = $batch_size; |
| 3509 | 3509 | if ($offset + $batch_size > $node_count) { |
| 3510 | - $nodes_per_batch = $node_count - $offset; |
|
| 3510 | + $nodes_per_batch = $node_count - $offset; |
|
| 3511 | 3511 | } |
| 3512 | 3512 | $operations[] = array( |
| 3513 | - 'boincimport_replace_urls_node_op', array( |
|
| 3513 | + 'boincimport_replace_urls_node_op', array( |
|
| 3514 | 3514 | $offset, $nodes_per_batch |
| 3515 | - ) |
|
| 3515 | + ) |
|
| 3516 | 3516 | ); |
| 3517 | - } |
|
| 3518 | - // Add comment batches |
|
| 3519 | - for ($offset = 0; $offset < $comment_count; $offset+=$batch_size) { |
|
| 3517 | + } |
|
| 3518 | + // Add comment batches |
|
| 3519 | + for ($offset = 0; $offset < $comment_count; $offset+=$batch_size) { |
|
| 3520 | 3520 | $comments_per_batch = $batch_size; |
| 3521 | 3521 | if ($offset + $batch_size > $comment_count) { |
| 3522 | - $comments_per_batch = $comment_count - $offset; |
|
| 3522 | + $comments_per_batch = $comment_count - $offset; |
|
| 3523 | 3523 | } |
| 3524 | 3524 | $operations[] = array( |
| 3525 | - 'boincimport_replace_urls_comment_op', array( |
|
| 3525 | + 'boincimport_replace_urls_comment_op', array( |
|
| 3526 | 3526 | $offset, $comments_per_batch |
| 3527 | - ) |
|
| 3527 | + ) |
|
| 3528 | 3528 | ); |
| 3529 | - } |
|
| 3530 | - // And don't forget to process private messages |
|
| 3531 | - for ($offset = 0; $offset < $pm_count; $offset+=$batch_size) { |
|
| 3529 | + } |
|
| 3530 | + // And don't forget to process private messages |
|
| 3531 | + for ($offset = 0; $offset < $pm_count; $offset+=$batch_size) { |
|
| 3532 | 3532 | $messages_per_batch = $batch_size; |
| 3533 | 3533 | if ($offset + $batch_size > $pm_count) { |
| 3534 | - $messages_per_batch = $pm_count - $offset; |
|
| 3534 | + $messages_per_batch = $pm_count - $offset; |
|
| 3535 | 3535 | } |
| 3536 | 3536 | $operations[] = array( |
| 3537 | - 'boincimport_replace_urls_pm_op', array( |
|
| 3537 | + 'boincimport_replace_urls_pm_op', array( |
|
| 3538 | 3538 | $offset, $messages_per_batch |
| 3539 | - ) |
|
| 3539 | + ) |
|
| 3540 | 3540 | ); |
| 3541 | - } |
|
| 3541 | + } |
|
| 3542 | 3542 | |
| 3543 | - $batch = array( |
|
| 3543 | + $batch = array( |
|
| 3544 | 3544 | 'operations' => $operations, |
| 3545 | 3545 | 'finished' => 'boincimport_replace_urls_finished', |
| 3546 | 3546 | 'title' => t('Updating URLs...'), |
| 3547 | 3547 | 'init_message' => t('Beginning URL update...'), |
| 3548 | 3548 | 'progress_message' => t('Processed URLs in @current out of @total batches (@size items per batch).', array( |
| 3549 | - '@size' => $batch_size, |
|
| 3549 | + '@size' => $batch_size, |
|
| 3550 | 3550 | )), |
| 3551 | 3551 | 'error_message' => t('URL update has encountered an error.'), |
| 3552 | - ); |
|
| 3552 | + ); |
|
| 3553 | 3553 | |
| 3554 | - batch_set($batch); |
|
| 3554 | + batch_set($batch); |
|
| 3555 | 3555 | } |
| 3556 | 3556 | |
| 3557 | 3557 | /** |
@@ -3559,27 +3559,27 @@ discard block |
||
| 3559 | 3559 | * Find URLs for the old system and update them with Drupal paths |
| 3560 | 3560 | */ |
| 3561 | 3561 | function boincimport_replace_urls_node_op($offset, $batch_size, &$context) { |
| 3562 | - // Initialize the batch, if needed |
|
| 3563 | - if (!isset($context['sandbox']['progress'])) { |
|
| 3562 | + // Initialize the batch, if needed |
|
| 3563 | + if (!isset($context['sandbox']['progress'])) { |
|
| 3564 | 3564 | $context['sandbox']['progress'] = 0; |
| 3565 | 3565 | $context['sandbox']['max'] = $batch_size; |
| 3566 | - } |
|
| 3566 | + } |
|
| 3567 | 3567 | |
| 3568 | - $input_format = variable_get('boincimport_input_format', 0); |
|
| 3568 | + $input_format = variable_get('boincimport_input_format', 0); |
|
| 3569 | 3569 | |
| 3570 | - // Since topics have just been imported, there should be only one vid for |
|
| 3571 | - // each nid, so we can update node_revisions by nid |
|
| 3572 | - // Get nodes to process |
|
| 3573 | - $nodes = db_query(' |
|
| 3570 | + // Since topics have just been imported, there should be only one vid for |
|
| 3571 | + // each nid, so we can update node_revisions by nid |
|
| 3572 | + // Get nodes to process |
|
| 3573 | + $nodes = db_query(' |
|
| 3574 | 3574 | SELECT btt.nid, nr.body, nr.teaser |
| 3575 | 3575 | FROM {boincimport_temp_topic} AS btt |
| 3576 | 3576 | LEFT JOIN {node_revisions} AS nr ON btt.nid = nr.nid |
| 3577 | 3577 | ORDER BY btt.nid |
| 3578 | 3578 | LIMIT %d,%d', |
| 3579 | 3579 | $offset, $batch_size |
| 3580 | - ); |
|
| 3580 | + ); |
|
| 3581 | 3581 | |
| 3582 | - while ($node = db_fetch_object($nodes)) { |
|
| 3582 | + while ($node = db_fetch_object($nodes)) { |
|
| 3583 | 3583 | $updated = FALSE; |
| 3584 | 3584 | |
| 3585 | 3585 | // Update URLs in node contents |
@@ -3588,23 +3588,23 @@ discard block |
||
| 3588 | 3588 | $node->body = _boincimport_replace_links($node->body); |
| 3589 | 3589 | $node->teaser = _boincimport_replace_links($node->teaser); |
| 3590 | 3590 | if ($node->body != $original_body OR $node->teaser != $original_teaser) { |
| 3591 | - $updated = db_query(" |
|
| 3591 | + $updated = db_query(" |
|
| 3592 | 3592 | UPDATE {node_revisions} |
| 3593 | 3593 | SET body= '%s', teaser = '%s' |
| 3594 | 3594 | WHERE nid = %d", |
| 3595 | 3595 | $node->body, $node->teaser, $node->nid |
| 3596 | - ); |
|
| 3596 | + ); |
|
| 3597 | 3597 | } |
| 3598 | 3598 | |
| 3599 | 3599 | $message = ''; |
| 3600 | 3600 | $context['results']['success'][] = $node->nid; |
| 3601 | 3601 | if ($updated) { |
| 3602 | - // Store some result for post-processing in the finished callback. |
|
| 3603 | - $context['results']['nodes']['updated'][] = $node->nid; |
|
| 3604 | - $message = "Successfully updated node {$node->nid}"; |
|
| 3602 | + // Store some result for post-processing in the finished callback. |
|
| 3603 | + $context['results']['nodes']['updated'][] = $node->nid; |
|
| 3604 | + $message = "Successfully updated node {$node->nid}"; |
|
| 3605 | 3605 | } |
| 3606 | 3606 | else { |
| 3607 | - $message = "No changes made to node {$node->nid}!"; |
|
| 3607 | + $message = "No changes made to node {$node->nid}!"; |
|
| 3608 | 3608 | } |
| 3609 | 3609 | |
| 3610 | 3610 | // Update our progress information. |
@@ -3614,12 +3614,12 @@ discard block |
||
| 3614 | 3614 | |
| 3615 | 3615 | // Update the progress for the batch engine |
| 3616 | 3616 | if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
| 3617 | - $context['finished'] = 1; |
|
| 3617 | + $context['finished'] = 1; |
|
| 3618 | 3618 | } |
| 3619 | 3619 | else { |
| 3620 | - $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
|
| 3620 | + $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
|
| 3621 | + } |
|
| 3621 | 3622 | } |
| 3622 | - } |
|
| 3623 | 3623 | } |
| 3624 | 3624 | |
| 3625 | 3625 | /** |
@@ -3627,48 +3627,48 @@ discard block |
||
| 3627 | 3627 | * Find URLs for the old system and update them with Drupal paths |
| 3628 | 3628 | */ |
| 3629 | 3629 | function boincimport_replace_urls_comment_op($offset, $batch_size, &$context) { |
| 3630 | - // Initialize the batch, if needed |
|
| 3631 | - if (!isset($context['sandbox']['progress'])) { |
|
| 3630 | + // Initialize the batch, if needed |
|
| 3631 | + if (!isset($context['sandbox']['progress'])) { |
|
| 3632 | 3632 | $context['sandbox']['progress'] = 0; |
| 3633 | 3633 | $context['sandbox']['max'] = $batch_size; |
| 3634 | - } |
|
| 3634 | + } |
|
| 3635 | 3635 | |
| 3636 | - $input_format = variable_get('boincimport_input_format', 0); |
|
| 3636 | + $input_format = variable_get('boincimport_input_format', 0); |
|
| 3637 | 3637 | |
| 3638 | - // Get comments to process |
|
| 3639 | - $comments = db_query(' |
|
| 3638 | + // Get comments to process |
|
| 3639 | + $comments = db_query(' |
|
| 3640 | 3640 | SELECT c.cid, c.comment |
| 3641 | 3641 | FROM {boincimport_temp_post} AS p |
| 3642 | 3642 | LEFT JOIN {comments} AS c ON p.cid = c.cid |
| 3643 | 3643 | ORDER BY c.cid |
| 3644 | 3644 | LIMIT %d,%d', |
| 3645 | 3645 | $offset, $batch_size |
| 3646 | - ); |
|
| 3646 | + ); |
|
| 3647 | 3647 | |
| 3648 | - while ($comment = db_fetch_object($comments)) { |
|
| 3648 | + while ($comment = db_fetch_object($comments)) { |
|
| 3649 | 3649 | $updated = FALSE; |
| 3650 | 3650 | |
| 3651 | 3651 | // Update URLs in comment contents |
| 3652 | 3652 | $original_comment = $comment->comment; |
| 3653 | 3653 | $comment->comment = _boincimport_replace_links($comment->comment); |
| 3654 | 3654 | if ($comment->comment != $original_comment) { |
| 3655 | - $updated = db_query(" |
|
| 3655 | + $updated = db_query(" |
|
| 3656 | 3656 | UPDATE {comments} |
| 3657 | 3657 | SET comment= '%s' |
| 3658 | 3658 | WHERE cid = %d", |
| 3659 | 3659 | $comment->comment, $comment->cid |
| 3660 | - ); |
|
| 3660 | + ); |
|
| 3661 | 3661 | } |
| 3662 | 3662 | |
| 3663 | 3663 | $message = ''; |
| 3664 | 3664 | $context['results']['success'][] = $comment->cid; |
| 3665 | 3665 | if ($updated) { |
| 3666 | - // Store some result for post-processing in the finished callback. |
|
| 3667 | - $context['results']['comments']['updated'][] = $comment->cid; |
|
| 3668 | - $message = "Successfully updated comment {$comment->cid}"; |
|
| 3666 | + // Store some result for post-processing in the finished callback. |
|
| 3667 | + $context['results']['comments']['updated'][] = $comment->cid; |
|
| 3668 | + $message = "Successfully updated comment {$comment->cid}"; |
|
| 3669 | 3669 | } |
| 3670 | 3670 | else { |
| 3671 | - $message = "No changes made to comment {$comment->cid}!"; |
|
| 3671 | + $message = "No changes made to comment {$comment->cid}!"; |
|
| 3672 | 3672 | } |
| 3673 | 3673 | |
| 3674 | 3674 | // Update our progress information. |
@@ -3678,12 +3678,12 @@ discard block |
||
| 3678 | 3678 | |
| 3679 | 3679 | // Update the progress for the batch engine |
| 3680 | 3680 | if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
| 3681 | - $context['finished'] = 1; |
|
| 3681 | + $context['finished'] = 1; |
|
| 3682 | 3682 | } |
| 3683 | 3683 | else { |
| 3684 | - $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
|
| 3684 | + $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
|
| 3685 | + } |
|
| 3685 | 3686 | } |
| 3686 | - } |
|
| 3687 | 3687 | } |
| 3688 | 3688 | |
| 3689 | 3689 | /** |
@@ -3691,47 +3691,47 @@ discard block |
||
| 3691 | 3691 | * Find URLs for the old system and update them with Drupal paths |
| 3692 | 3692 | */ |
| 3693 | 3693 | function boincimport_replace_urls_pm_op($offset, $batch_size, &$context) { |
| 3694 | - // Initialize the batch, if needed |
|
| 3695 | - if (!isset($context['sandbox']['progress'])) { |
|
| 3694 | + // Initialize the batch, if needed |
|
| 3695 | + if (!isset($context['sandbox']['progress'])) { |
|
| 3696 | 3696 | $context['sandbox']['progress'] = 0; |
| 3697 | 3697 | $context['sandbox']['max'] = $batch_size; |
| 3698 | - } |
|
| 3698 | + } |
|
| 3699 | 3699 | |
| 3700 | - $input_format = variable_get('boincimport_input_format', 0); |
|
| 3700 | + $input_format = variable_get('boincimport_input_format', 0); |
|
| 3701 | 3701 | |
| 3702 | - // Get private messages to process |
|
| 3703 | - $messages = db_query(' |
|
| 3702 | + // Get private messages to process |
|
| 3703 | + $messages = db_query(' |
|
| 3704 | 3704 | SELECT pm.mid, pm.body |
| 3705 | 3705 | FROM {pm_message} pm |
| 3706 | 3706 | ORDER BY pm.mid |
| 3707 | 3707 | LIMIT %d,%d', |
| 3708 | 3708 | $offset, $batch_size |
| 3709 | - ); |
|
| 3709 | + ); |
|
| 3710 | 3710 | |
| 3711 | - while ($pm = db_fetch_object($messages)) { |
|
| 3711 | + while ($pm = db_fetch_object($messages)) { |
|
| 3712 | 3712 | $updated = FALSE; |
| 3713 | 3713 | |
| 3714 | 3714 | // Update URLs in private message body |
| 3715 | 3715 | $original_pm_body = $pm->body; |
| 3716 | 3716 | $pm->body = _boincimport_replace_links($pm->body); |
| 3717 | 3717 | if ($pm->body != $original_pm_body) { |
| 3718 | - $updated = db_query(" |
|
| 3718 | + $updated = db_query(" |
|
| 3719 | 3719 | UPDATE {pm_message} |
| 3720 | 3720 | SET body= '%s' |
| 3721 | 3721 | WHERE mid = %d", |
| 3722 | 3722 | $pm->body, $pm->mid |
| 3723 | - ); |
|
| 3723 | + ); |
|
| 3724 | 3724 | } |
| 3725 | 3725 | |
| 3726 | 3726 | $message = ''; |
| 3727 | 3727 | $context['results']['success'][] = $pm->mid; |
| 3728 | 3728 | if ($updated) { |
| 3729 | - // Store some result for post-processing in the finished callback. |
|
| 3730 | - $context['results']['pm']['updated'][] = $pm->mid; |
|
| 3731 | - $message = "Successfully updated private message {$pm->mid}"; |
|
| 3729 | + // Store some result for post-processing in the finished callback. |
|
| 3730 | + $context['results']['pm']['updated'][] = $pm->mid; |
|
| 3731 | + $message = "Successfully updated private message {$pm->mid}"; |
|
| 3732 | 3732 | } |
| 3733 | 3733 | else { |
| 3734 | - $message = "No changes made to private message {$pm->mid}!"; |
|
| 3734 | + $message = "No changes made to private message {$pm->mid}!"; |
|
| 3735 | 3735 | } |
| 3736 | 3736 | |
| 3737 | 3737 | // Update our progress information. |
@@ -3741,85 +3741,85 @@ discard block |
||
| 3741 | 3741 | |
| 3742 | 3742 | // Update the progress for the batch engine |
| 3743 | 3743 | if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
| 3744 | - $context['finished'] = 1; |
|
| 3744 | + $context['finished'] = 1; |
|
| 3745 | 3745 | } |
| 3746 | 3746 | else { |
| 3747 | - $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
|
| 3747 | + $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
|
| 3748 | + } |
|
| 3748 | 3749 | } |
| 3749 | - } |
|
| 3750 | 3750 | } |
| 3751 | 3751 | |
| 3752 | 3752 | /** |
| 3753 | 3753 | * Batch 'finished' callback |
| 3754 | 3754 | */ |
| 3755 | 3755 | function boincimport_replace_urls_finished($success, $results, $operations) { |
| 3756 | - if ($success) { |
|
| 3756 | + if ($success) { |
|
| 3757 | 3757 | // Let's count our successes |
| 3758 | 3758 | $total_processed = count($results['success']); |
| 3759 | 3759 | $nodes_updated = count($results['nodes']['updated']); |
| 3760 | 3760 | $comments_updated = count($results['comments']['updated']); |
| 3761 | 3761 | $private_messages_updated = count($results['pm']['updated']); |
| 3762 | 3762 | $message = t( |
| 3763 | - 'Successfully processed @count nodes, comments, and private messages (@nodes_updated nodes, @comments_updated comments, and @pm_updated private messages were updated)', |
|
| 3764 | - array( |
|
| 3763 | + 'Successfully processed @count nodes, comments, and private messages (@nodes_updated nodes, @comments_updated comments, and @pm_updated private messages were updated)', |
|
| 3764 | + array( |
|
| 3765 | 3765 | '@count' => $total_processed, |
| 3766 | 3766 | '@nodes_updated' => $nodes_updated, |
| 3767 | 3767 | '@comments_updated' => $comments_updated, |
| 3768 | 3768 | '@pm_updated' => $private_messages_updated, |
| 3769 | - ) |
|
| 3769 | + ) |
|
| 3770 | 3770 | ); |
| 3771 | 3771 | if ($private_messages_updated) { |
| 3772 | - watchdog('boincimport', |
|
| 3772 | + watchdog('boincimport', |
|
| 3773 | 3773 | 'Updated URLs in these private_messages: @mid_list', |
| 3774 | 3774 | array( |
| 3775 | - '@mid_list' => implode(', ', $results['pm']['updated']), |
|
| 3775 | + '@mid_list' => implode(', ', $results['pm']['updated']), |
|
| 3776 | 3776 | ), |
| 3777 | 3777 | WATCHDOG_INFO |
| 3778 | - ); |
|
| 3778 | + ); |
|
| 3779 | 3779 | } |
| 3780 | 3780 | if ($comments_updated) { |
| 3781 | - watchdog('boincimport', |
|
| 3781 | + watchdog('boincimport', |
|
| 3782 | 3782 | 'Updated URLs in these comments: @cid_list', |
| 3783 | 3783 | array( |
| 3784 | - '@cid_list' => implode(', ', $results['comments']['updated']), |
|
| 3784 | + '@cid_list' => implode(', ', $results['comments']['updated']), |
|
| 3785 | 3785 | ), |
| 3786 | 3786 | WATCHDOG_INFO |
| 3787 | - ); |
|
| 3787 | + ); |
|
| 3788 | 3788 | } |
| 3789 | 3789 | if ($nodes_updated) { |
| 3790 | - watchdog('boincimport', |
|
| 3790 | + watchdog('boincimport', |
|
| 3791 | 3791 | 'Updated URLs in these nodes: @nid_list', |
| 3792 | 3792 | array( |
| 3793 | - '@nid_list' => implode(', ', $results['nodes']['updated']), |
|
| 3793 | + '@nid_list' => implode(', ', $results['nodes']['updated']), |
|
| 3794 | 3794 | ), |
| 3795 | 3795 | WATCHDOG_INFO |
| 3796 | - ); |
|
| 3796 | + ); |
|
| 3797 | 3797 | } |
| 3798 | 3798 | watchdog('boincimport', |
| 3799 | - 'Successfully processed @count nodes, comments, and private messages (@nodes_updated nodes, @comments_updated comments, and @pm_updated private messages were updated)', |
|
| 3800 | - array( |
|
| 3799 | + 'Successfully processed @count nodes, comments, and private messages (@nodes_updated nodes, @comments_updated comments, and @pm_updated private messages were updated)', |
|
| 3800 | + array( |
|
| 3801 | 3801 | '@count' => $total_processed, |
| 3802 | 3802 | '@nodes_updated' => $nodes_updated, |
| 3803 | 3803 | '@comments_updated' => $comments_updated, |
| 3804 | 3804 | '@pm_updated' => $private_messages_updated, |
| 3805 | - ), |
|
| 3806 | - WATCHDOG_INFO |
|
| 3805 | + ), |
|
| 3806 | + WATCHDOG_INFO |
|
| 3807 | 3807 | ); |
| 3808 | 3808 | // Set the replace URLs successful flag in the variable table |
| 3809 | 3809 | variable_set('boincimport_replace_urls_successful', '1'); |
| 3810 | 3810 | $_SESSION['boincimport_stage_selected'] = 'users'; |
| 3811 | - } |
|
| 3812 | - else { |
|
| 3811 | + } |
|
| 3812 | + else { |
|
| 3813 | 3813 | // An error occurred. |
| 3814 | 3814 | // $operations contains the operations that remained unprocessed. |
| 3815 | 3815 | $error_operation = reset($operations); |
| 3816 | 3816 | $message = 'An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE); |
| 3817 | - } |
|
| 3818 | - drupal_set_message($message); |
|
| 3817 | + } |
|
| 3818 | + drupal_set_message($message); |
|
| 3819 | 3819 | |
| 3820 | - // Release the lock on the import process |
|
| 3821 | - variable_del('boincimport_process_locked'); |
|
| 3822 | - drupal_goto('admin/boinc/import/process'); |
|
| 3820 | + // Release the lock on the import process |
|
| 3821 | + variable_del('boincimport_process_locked'); |
|
| 3822 | + drupal_goto('admin/boinc/import/process'); |
|
| 3823 | 3823 | } |
| 3824 | 3824 | |
| 3825 | 3825 | |
@@ -3831,43 +3831,43 @@ discard block |
||
| 3831 | 3831 | * Remove temporary variables, clear caches, etc. |
| 3832 | 3832 | */ |
| 3833 | 3833 | function boincimport_process_cleanup() { |
| 3834 | - db_set_active('default'); |
|
| 3835 | - |
|
| 3836 | - variable_del('boincimport_base_url_boinc'); |
|
| 3837 | - variable_del('boincimport_base_url_drupal'); |
|
| 3838 | - variable_del('boincimport_import_user_successful'); |
|
| 3839 | - variable_del('boincimport_import_user_started'); |
|
| 3840 | - variable_del('boincimport_import_team_successful'); |
|
| 3841 | - variable_del('boincimport_import_team_started'); |
|
| 3842 | - variable_del('boincimport_import_category_successful'); |
|
| 3843 | - variable_del('boincimport_replace_url_successful'); |
|
| 3844 | - variable_del('boincimport_import_category_started'); |
|
| 3845 | - variable_del('boincimport_import_topic_successful'); |
|
| 3846 | - variable_del('boincimport_import_topic_started'); |
|
| 3847 | - variable_del('boincimport_import_post_successful'); |
|
| 3848 | - variable_del('boincimport_import_post_started'); |
|
| 3849 | - variable_del('boincimport_team_forum_successful'); |
|
| 3850 | - variable_del('boincimport_team_topic_successful'); |
|
| 3851 | - variable_del('boincimport_team_post_successful'); |
|
| 3852 | - variable_del('boincimport_team_post_started'); |
|
| 3853 | - variable_del('boincimport_ready'); |
|
| 3854 | - variable_del('boincimport_db_url'); |
|
| 3855 | - variable_del('boincimport_tested'); |
|
| 3856 | - variable_del('boincimport_db_configured'); |
|
| 3857 | - variable_del('boincimport_table_prefix'); |
|
| 3858 | - variable_del('boincimport_team_types'); |
|
| 3859 | - variable_del('boincimport_time_limit'); |
|
| 3860 | - variable_del('boincimport_import_lurkers'); |
|
| 3861 | - variable_del('boincimport_import_polls'); |
|
| 3862 | - variable_del('boincimport_import_poll_started'); |
|
| 3863 | - variable_del('boincimport_import_poll_successful'); |
|
| 3864 | - variable_del('boincimport_import_pm_successful'); |
|
| 3865 | - variable_del('boincimport_encode'); |
|
| 3866 | - variable_del('boincimport_encoding_phpbb'); |
|
| 3867 | - variable_del('boincimport_encoding_drupal'); |
|
| 3868 | - variable_del('boincimport_version'); |
|
| 3869 | - |
|
| 3870 | - db_query('DELETE FROM {cache}'); |
|
| 3834 | + db_set_active('default'); |
|
| 3835 | + |
|
| 3836 | + variable_del('boincimport_base_url_boinc'); |
|
| 3837 | + variable_del('boincimport_base_url_drupal'); |
|
| 3838 | + variable_del('boincimport_import_user_successful'); |
|
| 3839 | + variable_del('boincimport_import_user_started'); |
|
| 3840 | + variable_del('boincimport_import_team_successful'); |
|
| 3841 | + variable_del('boincimport_import_team_started'); |
|
| 3842 | + variable_del('boincimport_import_category_successful'); |
|
| 3843 | + variable_del('boincimport_replace_url_successful'); |
|
| 3844 | + variable_del('boincimport_import_category_started'); |
|
| 3845 | + variable_del('boincimport_import_topic_successful'); |
|
| 3846 | + variable_del('boincimport_import_topic_started'); |
|
| 3847 | + variable_del('boincimport_import_post_successful'); |
|
| 3848 | + variable_del('boincimport_import_post_started'); |
|
| 3849 | + variable_del('boincimport_team_forum_successful'); |
|
| 3850 | + variable_del('boincimport_team_topic_successful'); |
|
| 3851 | + variable_del('boincimport_team_post_successful'); |
|
| 3852 | + variable_del('boincimport_team_post_started'); |
|
| 3853 | + variable_del('boincimport_ready'); |
|
| 3854 | + variable_del('boincimport_db_url'); |
|
| 3855 | + variable_del('boincimport_tested'); |
|
| 3856 | + variable_del('boincimport_db_configured'); |
|
| 3857 | + variable_del('boincimport_table_prefix'); |
|
| 3858 | + variable_del('boincimport_team_types'); |
|
| 3859 | + variable_del('boincimport_time_limit'); |
|
| 3860 | + variable_del('boincimport_import_lurkers'); |
|
| 3861 | + variable_del('boincimport_import_polls'); |
|
| 3862 | + variable_del('boincimport_import_poll_started'); |
|
| 3863 | + variable_del('boincimport_import_poll_successful'); |
|
| 3864 | + variable_del('boincimport_import_pm_successful'); |
|
| 3865 | + variable_del('boincimport_encode'); |
|
| 3866 | + variable_del('boincimport_encoding_phpbb'); |
|
| 3867 | + variable_del('boincimport_encoding_drupal'); |
|
| 3868 | + variable_del('boincimport_version'); |
|
| 3869 | + |
|
| 3870 | + db_query('DELETE FROM {cache}'); |
|
| 3871 | 3871 | } |
| 3872 | 3872 | |
| 3873 | 3873 | /** |
@@ -3875,15 +3875,15 @@ discard block |
||
| 3875 | 3875 | */ |
| 3876 | 3876 | |
| 3877 | 3877 | function boincimport_forum_comment_save(&$edit) { |
| 3878 | - // Here we are building the thread field. See the comment in comment_render(). |
|
| 3879 | - if ($edit['pid'] == 0) { |
|
| 3878 | + // Here we are building the thread field. See the comment in comment_render(). |
|
| 3879 | + if ($edit['pid'] == 0) { |
|
| 3880 | 3880 | // This is a comment with no parent comment (depth 0): we start by retrieving |
| 3881 | 3881 | // the maximum thread level. |
| 3882 | 3882 | $max = db_result(db_query('SELECT MAX(thread) FROM {comments} WHERE nid = %d', $edit['nid'])); |
| 3883 | 3883 | // Strip the "/" from the end of the thread. |
| 3884 | 3884 | $max = rtrim($max, '/'); |
| 3885 | 3885 | $thread = int2vancode(vancode2int($max)+1) .'/'; |
| 3886 | - } else { |
|
| 3886 | + } else { |
|
| 3887 | 3887 | // This is comment with a parent comment: we increase the part of the thread |
| 3888 | 3888 | // value at the proper depth. |
| 3889 | 3889 | $parent = db_fetch_object(db_query('SELECT * FROM {comments} WHERE cid = %d', $edit['pid'])); |
@@ -3892,71 +3892,71 @@ discard block |
||
| 3892 | 3892 | // Get the max value in _this_ thread. |
| 3893 | 3893 | $max = db_result(db_query("SELECT MAX(thread) FROM {comments} WHERE thread LIKE '%s.%%' AND nid = %d", $parent->thread, $edit['nid'])); |
| 3894 | 3894 | if ($max == '') { |
| 3895 | - // First child of this parent. |
|
| 3896 | - $thread = $parent->thread .'.'. int2vancode(1) .'/'; |
|
| 3895 | + // First child of this parent. |
|
| 3896 | + $thread = $parent->thread .'.'. int2vancode(1) .'/'; |
|
| 3897 | 3897 | } else { |
| 3898 | - // Strip the "/" at the end of the thread. |
|
| 3899 | - $max = rtrim($max, '/'); |
|
| 3900 | - // We need to get the value at the correct depth. |
|
| 3901 | - $parts = explode('.', $max); |
|
| 3902 | - $parent_depth = count(explode('.', $parent->thread)); |
|
| 3903 | - $last = $parts[$parent_depth]; |
|
| 3904 | - // Finally, build the thread field for this new comment. |
|
| 3905 | - $thread = $parent->thread .'.'. int2vancode(vancode2int($last) + 1) .'/'; |
|
| 3898 | + // Strip the "/" at the end of the thread. |
|
| 3899 | + $max = rtrim($max, '/'); |
|
| 3900 | + // We need to get the value at the correct depth. |
|
| 3901 | + $parts = explode('.', $max); |
|
| 3902 | + $parent_depth = count(explode('.', $parent->thread)); |
|
| 3903 | + $last = $parts[$parent_depth]; |
|
| 3904 | + // Finally, build the thread field for this new comment. |
|
| 3905 | + $thread = $parent->thread .'.'. int2vancode(vancode2int($last) + 1) .'/'; |
|
| 3906 | + } |
|
| 3906 | 3907 | } |
| 3907 | - } |
|
| 3908 | 3908 | |
| 3909 | - $status = 0; // 1 - not published, 0 - published |
|
| 3910 | - $format = variable_get('boincimport_input_format', 0); |
|
| 3911 | - $score = 0; // 0 default value, comments get higher score depending on the author's roles |
|
| 3912 | - $users = serialize(array(0 => 1)); // default value for everybody!! |
|
| 3909 | + $status = 0; // 1 - not published, 0 - published |
|
| 3910 | + $format = variable_get('boincimport_input_format', 0); |
|
| 3911 | + $score = 0; // 0 default value, comments get higher score depending on the author's roles |
|
| 3912 | + $users = serialize(array(0 => 1)); // default value for everybody!! |
|
| 3913 | 3913 | |
| 3914 | - if ($edit['uid'] === $user->uid) { // '===' because we want to modify anonymous users too |
|
| 3914 | + if ($edit['uid'] === $user->uid) { // '===' because we want to modify anonymous users too |
|
| 3915 | 3915 | $edit['name'] = $user->name; |
| 3916 | - } |
|
| 3916 | + } |
|
| 3917 | 3917 | |
| 3918 | - $success = db_query("INSERT INTO {comments} (nid, pid, uid, subject, comment, format, hostname, timestamp, status, thread, name) VALUES (%d, %d, %d, '%s', '%s', %d, '%s', %d, %d, '%s', '%s')", $edit['nid'], $edit['pid'], $edit['uid'], $edit['subject'], $edit['comment'], $edit['format'], ip_address(), $edit['timestamp'], $edit['status'], $thread, $edit['name']); |
|
| 3919 | - if ($success) { |
|
| 3918 | + $success = db_query("INSERT INTO {comments} (nid, pid, uid, subject, comment, format, hostname, timestamp, status, thread, name) VALUES (%d, %d, %d, '%s', '%s', %d, '%s', %d, %d, '%s', '%s')", $edit['nid'], $edit['pid'], $edit['uid'], $edit['subject'], $edit['comment'], $edit['format'], ip_address(), $edit['timestamp'], $edit['status'], $thread, $edit['name']); |
|
| 3919 | + if ($success) { |
|
| 3920 | 3920 | $edit['cid'] = db_last_insert_id('comments', 'cid'); |
| 3921 | 3921 | _comment_update_node_statistics($edit['nid']); |
| 3922 | - } |
|
| 3923 | - return $success; |
|
| 3922 | + } |
|
| 3923 | + return $success; |
|
| 3924 | 3924 | } |
| 3925 | 3925 | |
| 3926 | 3926 | /** |
| 3927 | 3927 | * Strips text of extra phpbb3 markup and if requested, also strips all bbcode from text. |
| 3928 | 3928 | */ |
| 3929 | 3929 | function _boincimport_strip_bbcode($text) { |
| 3930 | - // Strip the text of extra markup - regular expressions taken from phpbb3 includes/function.php, function get_preg_expression(). |
|
| 3931 | - $match = array( |
|
| 3930 | + // Strip the text of extra markup - regular expressions taken from phpbb3 includes/function.php, function get_preg_expression(). |
|
| 3931 | + $match = array( |
|
| 3932 | 3932 | '#<!\-\- e \-\-><a href="mailto:(.*?)">.*?</a><!\-\- e \-\->#', |
| 3933 | 3933 | '#<!\-\- l \-\-><a (?:class="[\w-]+" )?href="(.*?)(?:(&|\?)sid=[0-9a-f]{32})?">.*?</a><!\-\- l \-\->#', |
| 3934 | 3934 | '#<!\-\- ([mw]) \-\-><a (?:class="[\w-]+" )?href="(.*?)">.*?</a><!\-\- \1 \-\->#', |
| 3935 | 3935 | '#<!\-\- s(.*?) \-\-><img src="\{SMILIES_PATH\}\/.*? \/><!\-\- s\1 \-\->#', |
| 3936 | 3936 | '#<!\-\- .*? \-\->#s', |
| 3937 | 3937 | '#<.*?>#s', |
| 3938 | - ); |
|
| 3939 | - $replace = array('$1', '$1', '$2', '$1', '', ''); |
|
| 3940 | - $text = preg_replace($match, $replace, $text); |
|
| 3938 | + ); |
|
| 3939 | + $replace = array('$1', '$1', '$2', '$1', '', ''); |
|
| 3940 | + $text = preg_replace($match, $replace, $text); |
|
| 3941 | 3941 | |
| 3942 | - // If BBcode conversion to has been selected, the following will convert the |
|
| 3943 | - // BBcode to normal html |
|
| 3944 | - if (variable_get('boincimport_bbcode', 0)) { |
|
| 3942 | + // If BBcode conversion to has been selected, the following will convert the |
|
| 3943 | + // BBcode to normal html |
|
| 3944 | + if (variable_get('boincimport_bbcode', 0)) { |
|
| 3945 | 3945 | $input_format = variable_get('boincimport_input_format', 0); |
| 3946 | 3946 | $text = bbcode_filter('process', 0 , $input_format, $text); |
| 3947 | - } |
|
| 3948 | - return $text; |
|
| 3947 | + } |
|
| 3948 | + return $text; |
|
| 3949 | 3949 | } |
| 3950 | 3950 | |
| 3951 | 3951 | /** |
| 3952 | 3952 | * Function to properly encode strings. |
| 3953 | 3953 | */ |
| 3954 | 3954 | function _boincimport_text_sanitize($text) { |
| 3955 | - $input_format = variable_get('boincimport_input_format', 0); |
|
| 3956 | - $text = html_entity_decode($text, ENT_QUOTES, 'utf-8'); |
|
| 3957 | - // Be sure the text is filtered for the default input format |
|
| 3958 | - $text = check_markup($text, $input_format); |
|
| 3959 | - return $text; |
|
| 3955 | + $input_format = variable_get('boincimport_input_format', 0); |
|
| 3956 | + $text = html_entity_decode($text, ENT_QUOTES, 'utf-8'); |
|
| 3957 | + // Be sure the text is filtered for the default input format |
|
| 3958 | + $text = check_markup($text, $input_format); |
|
| 3959 | + return $text; |
|
| 3960 | 3960 | } |
| 3961 | 3961 | |
| 3962 | 3962 | |
@@ -3965,25 +3965,25 @@ discard block |
||
| 3965 | 3965 | */ |
| 3966 | 3966 | function _boincimport_replace_links($html) { |
| 3967 | 3967 | |
| 3968 | - $transformer = new BoincImportUrlTransformer(); |
|
| 3969 | - |
|
| 3970 | - // Update links to posts, threads, and forums |
|
| 3971 | - $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)forum_thread\.php\?id=(\d+)&postid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformPostLinks'), $html); |
|
| 3972 | - $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)forum_thread\.php\?id=(\d+)(&\w+=\w*)*?(#(\d+)?)}i', array($transformer, 'transformOldPostLinks'), $html); |
|
| 3973 | - $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)forum_thread\.php\?id=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformTopicLinks'), $html); |
|
| 3974 | - $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)forum_forum\.php\?id=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformForumLinks'), $html); |
|
| 3975 | - $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)show_user\.php\?userid=(\d+)((&\w+=\w*)+)?}i', array($transformer, 'transformUserLinks'), $html); |
|
| 3976 | - $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)workunit\.php\?wuid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformWorkUnitLinks'), $html); |
|
| 3977 | - $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)result\.php\?resultid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformResultLinks'), $html); |
|
| 3978 | - $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)results\.php\?userid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformUserResultsLinks'), $html); |
|
| 3979 | - $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)results\.php\?hostid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformHostResultsLinks'), $html); |
|
| 3980 | - $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)show_host_detail\.php\?hostid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformHostLinks'), $html); |
|
| 3981 | - $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)hosts_user\.php\?userid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformUserHostsLinks'), $html); |
|
| 3982 | - |
|
| 3983 | - // Update any links to the top level index |
|
| 3984 | - $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)forum_index.php}i', array($transformer, 'transformForumIndexLinks'), $html); |
|
| 3985 | - |
|
| 3986 | - return $html; |
|
| 3968 | + $transformer = new BoincImportUrlTransformer(); |
|
| 3969 | + |
|
| 3970 | + // Update links to posts, threads, and forums |
|
| 3971 | + $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)forum_thread\.php\?id=(\d+)&postid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformPostLinks'), $html); |
|
| 3972 | + $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)forum_thread\.php\?id=(\d+)(&\w+=\w*)*?(#(\d+)?)}i', array($transformer, 'transformOldPostLinks'), $html); |
|
| 3973 | + $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)forum_thread\.php\?id=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformTopicLinks'), $html); |
|
| 3974 | + $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)forum_forum\.php\?id=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformForumLinks'), $html); |
|
| 3975 | + $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)show_user\.php\?userid=(\d+)((&\w+=\w*)+)?}i', array($transformer, 'transformUserLinks'), $html); |
|
| 3976 | + $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)workunit\.php\?wuid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformWorkUnitLinks'), $html); |
|
| 3977 | + $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)result\.php\?resultid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformResultLinks'), $html); |
|
| 3978 | + $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)results\.php\?userid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformUserResultsLinks'), $html); |
|
| 3979 | + $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)results\.php\?hostid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformHostResultsLinks'), $html); |
|
| 3980 | + $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)show_host_detail\.php\?hostid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformHostLinks'), $html); |
|
| 3981 | + $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)hosts_user\.php\?userid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformUserHostsLinks'), $html); |
|
| 3982 | + |
|
| 3983 | + // Update any links to the top level index |
|
| 3984 | + $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)forum_index.php}i', array($transformer, 'transformForumIndexLinks'), $html); |
|
| 3985 | + |
|
| 3986 | + return $html; |
|
| 3987 | 3987 | } |
| 3988 | 3988 | |
| 3989 | 3989 | /** |
@@ -3991,14 +3991,14 @@ discard block |
||
| 3991 | 3991 | */ |
| 3992 | 3992 | class BoincImportUrlTransformer { |
| 3993 | 3993 | |
| 3994 | - var $basePath; |
|
| 3995 | - var $boincDomain; |
|
| 3996 | - var $drupalDomain; |
|
| 3994 | + var $basePath; |
|
| 3995 | + var $boincDomain; |
|
| 3996 | + var $drupalDomain; |
|
| 3997 | 3997 | |
| 3998 | - /** |
|
| 3999 | - * Constructor |
|
| 4000 | - */ |
|
| 4001 | - function __construct() { |
|
| 3998 | + /** |
|
| 3999 | + * Constructor |
|
| 4000 | + */ |
|
| 4001 | + function __construct() { |
|
| 4002 | 4002 | global $base_url; |
| 4003 | 4003 | global $base_path; |
| 4004 | 4004 | $boinc_base_urls = variable_get('boincimport_base_url_boinc', ''); |
@@ -4008,208 +4008,208 @@ discard block |
||
| 4008 | 4008 | $this->boincDomains = array(); |
| 4009 | 4009 | $boinc_base_urls = preg_split('/\s+/', $boinc_base_urls); |
| 4010 | 4010 | foreach ($boinc_base_urls as $url) { |
| 4011 | - $domain = parse_url($url, PHP_URL_HOST); |
|
| 4012 | - if ($domain) { |
|
| 4011 | + $domain = parse_url($url, PHP_URL_HOST); |
|
| 4012 | + if ($domain) { |
|
| 4013 | 4013 | $this->boincDomains[$domain] = TRUE; |
| 4014 | - } |
|
| 4014 | + } |
|
| 4015 | 4015 | } |
| 4016 | 4016 | if (!$this->boincDomains) { |
| 4017 | - watchdog('boincimport', 'No valid BOINC base URLs found to transform!', |
|
| 4017 | + watchdog('boincimport', 'No valid BOINC base URLs found to transform!', |
|
| 4018 | 4018 | array(), WATCHDOG_WARNING); |
| 4019 | 4019 | } |
| 4020 | - } |
|
| 4020 | + } |
|
| 4021 | 4021 | |
| 4022 | - // old-style constructor for backwards compatibility |
|
| 4023 | - function BoincImportUrlTransformer() { |
|
| 4022 | + // old-style constructor for backwards compatibility |
|
| 4023 | + function BoincImportUrlTransformer() { |
|
| 4024 | 4024 | self::__construct(); |
| 4025 | - } |
|
| 4025 | + } |
|
| 4026 | 4026 | |
| 4027 | - /** |
|
| 4028 | - * Get what the new base URL should be (needed for every transformation) |
|
| 4029 | - */ |
|
| 4030 | - function getNewBaseUrl($matches) { |
|
| 4027 | + /** |
|
| 4028 | + * Get what the new base URL should be (needed for every transformation) |
|
| 4029 | + */ |
|
| 4030 | + function getNewBaseUrl($matches) { |
|
| 4031 | 4031 | $http = $matches[1]; |
| 4032 | 4032 | $domain = trim($matches[2], '/'); |
| 4033 | 4033 | if ($http) { |
| 4034 | - if (isset($this->boincDomains[$domain])) { |
|
| 4034 | + if (isset($this->boincDomains[$domain])) { |
|
| 4035 | 4035 | // This is a URL configured to be transformed |
| 4036 | 4036 | return "{$http}://{$this->drupalDomain}{$this->basePath}"; |
| 4037 | - } |
|
| 4038 | - else { |
|
| 4037 | + } |
|
| 4038 | + else { |
|
| 4039 | 4039 | // This URL should not be transformed |
| 4040 | 4040 | return NULL; |
| 4041 | - } |
|
| 4041 | + } |
|
| 4042 | 4042 | } |
| 4043 | 4043 | else { |
| 4044 | - // This is a relative URL |
|
| 4045 | - return $this->basePath; |
|
| 4044 | + // This is a relative URL |
|
| 4045 | + return $this->basePath; |
|
| 4046 | + } |
|
| 4046 | 4047 | } |
| 4047 | - } |
|
| 4048 | 4048 | |
| 4049 | - /** |
|
| 4050 | - * Replace links to specific posts. If the given post is the first in the |
|
| 4051 | - * thread, it is a topic node in Drupal, not a comment. |
|
| 4052 | - */ |
|
| 4053 | - function transformPostLinks($matches) { |
|
| 4049 | + /** |
|
| 4050 | + * Replace links to specific posts. If the given post is the first in the |
|
| 4051 | + * thread, it is a topic node in Drupal, not a comment. |
|
| 4052 | + */ |
|
| 4053 | + function transformPostLinks($matches) { |
|
| 4054 | 4054 | $link = $matches[0]; |
| 4055 | 4055 | $newBaseUrl = $this->getNewBaseUrl($matches); |
| 4056 | 4056 | if ($newBaseUrl !== NULL) { |
| 4057 | - $id = db_result(db_query(' |
|
| 4057 | + $id = db_result(db_query(' |
|
| 4058 | 4058 | SELECT p.cid |
| 4059 | 4059 | FROM {boincimport_temp_post} p |
| 4060 | 4060 | WHERE p.post_id = %d', |
| 4061 | 4061 | $matches[4] |
| 4062 | - )); |
|
| 4063 | - if ($id) { |
|
| 4062 | + )); |
|
| 4063 | + if ($id) { |
|
| 4064 | 4064 | $link = "{$newBaseUrl}goto/comment/{$id}"; |
| 4065 | - } |
|
| 4066 | - else { |
|
| 4065 | + } |
|
| 4066 | + else { |
|
| 4067 | 4067 | // This post is not in the post import table, so it's probably a topic |
| 4068 | 4068 | $link = $this->transformTopicLinks($matches); |
| 4069 | - } |
|
| 4069 | + } |
|
| 4070 | 4070 | } |
| 4071 | 4071 | return $link; |
| 4072 | - } |
|
| 4072 | + } |
|
| 4073 | 4073 | |
| 4074 | - /** |
|
| 4075 | - * Replace links that include anchors to specific posts. If the given post is |
|
| 4076 | - * the first in the thread, it is a topic node in Drupal, not a comment. |
|
| 4077 | - */ |
|
| 4078 | - function transformOldPostLinks($matches) { |
|
| 4074 | + /** |
|
| 4075 | + * Replace links that include anchors to specific posts. If the given post is |
|
| 4076 | + * the first in the thread, it is a topic node in Drupal, not a comment. |
|
| 4077 | + */ |
|
| 4078 | + function transformOldPostLinks($matches) { |
|
| 4079 | 4079 | $link = $matches[0]; |
| 4080 | 4080 | $newBaseUrl = $this->getNewBaseUrl($matches); |
| 4081 | 4081 | if ($newBaseUrl !== NULL) { |
| 4082 | - $id = db_result(db_query(' |
|
| 4082 | + $id = db_result(db_query(' |
|
| 4083 | 4083 | SELECT p.cid |
| 4084 | 4084 | FROM {boincimport_temp_post} p |
| 4085 | 4085 | WHERE p.post_id = %d', |
| 4086 | 4086 | $matches[6] |
| 4087 | - )); |
|
| 4088 | - if ($id) { |
|
| 4087 | + )); |
|
| 4088 | + if ($id) { |
|
| 4089 | 4089 | $link = "{$newBaseUrl}goto/comment/{$id}"; |
| 4090 | - } |
|
| 4091 | - else { |
|
| 4090 | + } |
|
| 4091 | + else { |
|
| 4092 | 4092 | // This post is not in the post import table, so it's probably a topic |
| 4093 | 4093 | $link = $this->transformTopicLinks($matches); |
| 4094 | - } |
|
| 4094 | + } |
|
| 4095 | 4095 | } |
| 4096 | 4096 | return $link; |
| 4097 | - } |
|
| 4097 | + } |
|
| 4098 | 4098 | |
| 4099 | - function transformTopicLinks($matches) { |
|
| 4099 | + function transformTopicLinks($matches) { |
|
| 4100 | 4100 | $link = $matches[0]; |
| 4101 | 4101 | $newBaseUrl = $this->getNewBaseUrl($matches); |
| 4102 | 4102 | if ($newBaseUrl !== NULL) { |
| 4103 | - $id = db_result(db_query(' |
|
| 4103 | + $id = db_result(db_query(' |
|
| 4104 | 4104 | SELECT nid |
| 4105 | 4105 | FROM {boincimport_temp_topic} |
| 4106 | 4106 | WHERE topic_id = %d', |
| 4107 | 4107 | $matches[3] |
| 4108 | - )); |
|
| 4109 | - $link = "{$newBaseUrl}node/{$id}"; |
|
| 4108 | + )); |
|
| 4109 | + $link = "{$newBaseUrl}node/{$id}"; |
|
| 4110 | 4110 | } |
| 4111 | 4111 | return $link; |
| 4112 | - } |
|
| 4112 | + } |
|
| 4113 | 4113 | |
| 4114 | - function transformForumLinks($matches) { |
|
| 4114 | + function transformForumLinks($matches) { |
|
| 4115 | 4115 | $link = $matches[0]; |
| 4116 | 4116 | $newBaseUrl = $this->getNewBaseUrl($matches); |
| 4117 | 4117 | if ($newBaseUrl !== NULL) { |
| 4118 | - $forum = db_fetch_object(db_query(' |
|
| 4118 | + $forum = db_fetch_object(db_query(' |
|
| 4119 | 4119 | SELECT tid |
| 4120 | 4120 | FROM {boincimport_temp_forum} |
| 4121 | 4121 | WHERE forum_id = %d', |
| 4122 | 4122 | $matches[3] |
| 4123 | - )); |
|
| 4124 | - $link = "{$newBaseUrl}community/forum/{$forum->tid}"; |
|
| 4123 | + )); |
|
| 4124 | + $link = "{$newBaseUrl}community/forum/{$forum->tid}"; |
|
| 4125 | 4125 | } |
| 4126 | 4126 | return $link; |
| 4127 | - } |
|
| 4127 | + } |
|
| 4128 | 4128 | |
| 4129 | - function transformUserLinks($matches) { |
|
| 4129 | + function transformUserLinks($matches) { |
|
| 4130 | 4130 | $link = $matches[0]; |
| 4131 | 4131 | $newBaseUrl = $this->getNewBaseUrl($matches); |
| 4132 | 4132 | if ($newBaseUrl !== NULL) { |
| 4133 | - // Make sure this isn't an RPC link (no need to transform those) |
|
| 4134 | - if (!$matches[5]) { |
|
| 4133 | + // Make sure this isn't an RPC link (no need to transform those) |
|
| 4134 | + if (!$matches[5]) { |
|
| 4135 | 4135 | // TODO: This regex doesn't seem to capture the format=xml part of the |
| 4136 | 4136 | // URL, making it impossible to distinguish if this is an RPC or not... |
| 4137 | 4137 | //watchdog('DEBUG', 'matches: @m', array('@m' => print_r($matches,true)), WATCHDOG_DEBUG); |
| 4138 | 4138 | $uid = boincuser_lookup_uid($matches[3]); |
| 4139 | 4139 | $link = "{$newBaseUrl}account/{$uid}"; |
| 4140 | - } |
|
| 4140 | + } |
|
| 4141 | 4141 | } |
| 4142 | 4142 | return $link; |
| 4143 | - } |
|
| 4143 | + } |
|
| 4144 | 4144 | |
| 4145 | - function transformWorkUnitLinks($matches) { |
|
| 4145 | + function transformWorkUnitLinks($matches) { |
|
| 4146 | 4146 | $link = $matches[0]; |
| 4147 | 4147 | $newBaseUrl = $this->getNewBaseUrl($matches); |
| 4148 | 4148 | if ($newBaseUrl !== NULL) { |
| 4149 | - $id = $matches[3]; |
|
| 4150 | - $link = "{$newBaseUrl}workunit/{$id}"; |
|
| 4149 | + $id = $matches[3]; |
|
| 4150 | + $link = "{$newBaseUrl}workunit/{$id}"; |
|
| 4151 | 4151 | } |
| 4152 | 4152 | return $link; |
| 4153 | - } |
|
| 4153 | + } |
|
| 4154 | 4154 | |
| 4155 | - function transformResultLinks($matches) { |
|
| 4155 | + function transformResultLinks($matches) { |
|
| 4156 | 4156 | $link = $matches[0]; |
| 4157 | 4157 | $newBaseUrl = $this->getNewBaseUrl($matches); |
| 4158 | 4158 | if ($newBaseUrl !== NULL) { |
| 4159 | - $id = $matches[3]; |
|
| 4160 | - $link = "{$newBaseUrl}task/{$id}"; |
|
| 4159 | + $id = $matches[3]; |
|
| 4160 | + $link = "{$newBaseUrl}task/{$id}"; |
|
| 4161 | 4161 | } |
| 4162 | 4162 | return $link; |
| 4163 | - } |
|
| 4163 | + } |
|
| 4164 | 4164 | |
| 4165 | - function transformHostResultsLinks($matches) { |
|
| 4165 | + function transformHostResultsLinks($matches) { |
|
| 4166 | 4166 | $link = $matches[0]; |
| 4167 | 4167 | $newBaseUrl = $this->getNewBaseUrl($matches); |
| 4168 | 4168 | if ($newBaseUrl !== NULL) { |
| 4169 | - $id = $matches[3]; |
|
| 4170 | - $link = "{$newBaseUrl}host/{$id}/tasks"; |
|
| 4169 | + $id = $matches[3]; |
|
| 4170 | + $link = "{$newBaseUrl}host/{$id}/tasks"; |
|
| 4171 | 4171 | } |
| 4172 | 4172 | return $link; |
| 4173 | - } |
|
| 4173 | + } |
|
| 4174 | 4174 | |
| 4175 | - function transformUserResultsLinks($matches) { |
|
| 4175 | + function transformUserResultsLinks($matches) { |
|
| 4176 | 4176 | $link = $matches[0]; |
| 4177 | 4177 | $newBaseUrl = $this->getNewBaseUrl($matches); |
| 4178 | 4178 | if ($newBaseUrl !== NULL) { |
| 4179 | - $link = "{$newBaseUrl}account/tasks"; |
|
| 4179 | + $link = "{$newBaseUrl}account/tasks"; |
|
| 4180 | 4180 | } |
| 4181 | 4181 | return $link; |
| 4182 | - } |
|
| 4182 | + } |
|
| 4183 | 4183 | |
| 4184 | - function transformHostLinks($matches) { |
|
| 4184 | + function transformHostLinks($matches) { |
|
| 4185 | 4185 | $link = $matches[0]; |
| 4186 | 4186 | $newBaseUrl = $this->getNewBaseUrl($matches); |
| 4187 | 4187 | if ($newBaseUrl !== NULL) { |
| 4188 | - $id = $matches[3]; |
|
| 4189 | - $link = "{$newBaseUrl}host/{$id}"; |
|
| 4188 | + $id = $matches[3]; |
|
| 4189 | + $link = "{$newBaseUrl}host/{$id}"; |
|
| 4190 | 4190 | } |
| 4191 | 4191 | return $link; |
| 4192 | - } |
|
| 4192 | + } |
|
| 4193 | 4193 | |
| 4194 | - function transformUserHostsLinks($matches) { |
|
| 4194 | + function transformUserHostsLinks($matches) { |
|
| 4195 | 4195 | $link = $matches[0]; |
| 4196 | 4196 | $newBaseUrl = $this->getNewBaseUrl($matches); |
| 4197 | 4197 | if ($newBaseUrl !== NULL) { |
| 4198 | - $uid = boincuser_lookup_uid($matches[3]); |
|
| 4199 | - if ($uid) { |
|
| 4198 | + $uid = boincuser_lookup_uid($matches[3]); |
|
| 4199 | + if ($uid) { |
|
| 4200 | 4200 | $link = "{$newBaseUrl}account/{$uid}/computers"; |
| 4201 | - } |
|
| 4201 | + } |
|
| 4202 | 4202 | } |
| 4203 | 4203 | return $link; |
| 4204 | - } |
|
| 4204 | + } |
|
| 4205 | 4205 | |
| 4206 | - function transformForumIndexLinks($matches) { |
|
| 4206 | + function transformForumIndexLinks($matches) { |
|
| 4207 | 4207 | $link = $matches[0]; |
| 4208 | 4208 | $newBaseUrl = $this->getNewBaseUrl($matches); |
| 4209 | 4209 | if ($newBaseUrl !== NULL) { |
| 4210 | - $link = "{$newBaseUrl}community/forum"; |
|
| 4210 | + $link = "{$newBaseUrl}community/forum"; |
|
| 4211 | 4211 | } |
| 4212 | 4212 | return $link; |
| 4213 | - } |
|
| 4213 | + } |
|
| 4214 | 4214 | |
| 4215 | 4215 | } |
@@ -2,9 +2,9 @@ discard block |
||
| 2 | 2 | // $Id$ |
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | - * @file |
|
| 6 | - * Enable BOINC features related to processing work and credit. |
|
| 7 | - */ |
|
| 5 | + * @file |
|
| 6 | + * Enable BOINC features related to processing work and credit. |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | |
| 10 | 10 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -21,70 +21,70 @@ discard block |
||
| 21 | 21 | * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | - * Implementation of hook_menu(). |
|
| 25 | - */ |
|
| 24 | + * Implementation of hook_menu(). |
|
| 25 | + */ |
|
| 26 | 26 | function boincwork_menu() { |
| 27 | - require_boinc('util'); |
|
| 28 | - $items['account/prefs'] = array( |
|
| 27 | + require_boinc('util'); |
|
| 28 | + $items['account/prefs'] = array( |
|
| 29 | 29 | 'title' => 'Computing', |
| 30 | 30 | 'description' => '', |
| 31 | 31 | 'page callback' => 'generalprefs_page', |
| 32 | 32 | 'access callback' => 'user_is_logged_in', |
| 33 | 33 | 'type' => MENU_NORMAL_ITEM |
| 34 | - ); |
|
| 35 | - $items['account/prefs/computing'] = array( |
|
| 34 | + ); |
|
| 35 | + $items['account/prefs/computing'] = array( |
|
| 36 | 36 | 'title' => 'Computing', |
| 37 | 37 | 'page callback' => 'generalprefs_page', |
| 38 | 38 | 'access callback' => 'user_is_logged_in', |
| 39 | 39 | 'type' => MENU_DEFAULT_LOCAL_TASK, |
| 40 | 40 | 'weight' => 0 |
| 41 | - ); |
|
| 42 | - $items['account/prefs/project'] = array( |
|
| 41 | + ); |
|
| 42 | + $items['account/prefs/project'] = array( |
|
| 43 | 43 | 'title' => 'Project', |
| 44 | 44 | 'page callback' => 'projectprefs_page', |
| 45 | 45 | 'access callback' => 'user_is_logged_in', |
| 46 | 46 | 'type' => MENU_LOCAL_TASK, |
| 47 | 47 | 'weight' => 5 |
| 48 | - ); |
|
| 49 | - $items['account/prefs/community'] = array( |
|
| 48 | + ); |
|
| 49 | + $items['account/prefs/community'] = array( |
|
| 50 | 50 | 'title' => 'Community', |
| 51 | 51 | 'page callback' => 'communityprefs_page', |
| 52 | 52 | 'access callback' => 'user_is_logged_in', |
| 53 | 53 | 'type' => MENU_LOCAL_TASK, |
| 54 | 54 | 'weight' => 10 |
| 55 | - ); |
|
| 56 | - $items['account/prefs/privacy'] = array( |
|
| 55 | + ); |
|
| 56 | + $items['account/prefs/privacy'] = array( |
|
| 57 | 57 | 'title' => 'Privacy', |
| 58 | 58 | 'page callback' => 'privacyprefs_page', |
| 59 | 59 | 'access callback' => 'user_is_logged_in', |
| 60 | 60 | 'type' => MENU_LOCAL_TASK, |
| 61 | 61 | 'weight' => 15 |
| 62 | - ); |
|
| 63 | - if (module_exists('ignore_user')) { |
|
| 62 | + ); |
|
| 63 | + if (module_exists('ignore_user')) { |
|
| 64 | 64 | $items['account/prefs/privacy/ignore_user/add'] = array( |
| 65 | - 'title' => 'Add from ignore list', |
|
| 66 | - 'description' => 'Add user that you with to ignore to your ignore list.', |
|
| 67 | - 'page callback' => 'boincwork_ignore_user_add_user', |
|
| 68 | - 'access callback' => 'user_access', |
|
| 69 | - 'access arguments' => array('ignore user'), |
|
| 70 | - 'type' => MENU_CALLBACK, |
|
| 65 | + 'title' => 'Add from ignore list', |
|
| 66 | + 'description' => 'Add user that you with to ignore to your ignore list.', |
|
| 67 | + 'page callback' => 'boincwork_ignore_user_add_user', |
|
| 68 | + 'access callback' => 'user_access', |
|
| 69 | + 'access arguments' => array('ignore user'), |
|
| 70 | + 'type' => MENU_CALLBACK, |
|
| 71 | 71 | ); |
| 72 | 72 | $items['account/prefs/privacy/ignore_user/remove'] = array( |
| 73 | - 'title' => 'Remove from ignore list', |
|
| 74 | - 'description' => 'Remove user from your ignore list.', |
|
| 75 | - 'page callback' => 'boincwork_ignore_user_remove_user', |
|
| 76 | - 'access callback' => 'user_access', |
|
| 77 | - 'access arguments' => array('ignore user'), |
|
| 78 | - 'type' => MENU_CALLBACK, |
|
| 73 | + 'title' => 'Remove from ignore list', |
|
| 74 | + 'description' => 'Remove user from your ignore list.', |
|
| 75 | + 'page callback' => 'boincwork_ignore_user_remove_user', |
|
| 76 | + 'access callback' => 'user_access', |
|
| 77 | + 'access arguments' => array('ignore user'), |
|
| 78 | + 'type' => MENU_CALLBACK, |
|
| 79 | 79 | ); |
| 80 | - }// endif module_exists |
|
| 81 | - $items['account/certs'] = array( |
|
| 80 | + }// endif module_exists |
|
| 81 | + $items['account/certs'] = array( |
|
| 82 | 82 | 'title' =>'Account certificate', |
| 83 | 83 | 'page callback' => 'boincwork_certificates', |
| 84 | 84 | 'access arguments' => array('access content'), |
| 85 | 85 | 'type' => MENU_CALLBACK |
| 86 | - ); |
|
| 87 | - $items['admin/boinc/prefs/general'] = array( |
|
| 86 | + ); |
|
| 87 | + $items['admin/boinc/prefs/general'] = array( |
|
| 88 | 88 | 'title' => 'Preferences: General', |
| 89 | 89 | 'description' => 'Set options for BOINC preference set pages', |
| 90 | 90 | 'page callback' => 'drupal_get_form', |
@@ -92,16 +92,16 @@ discard block |
||
| 92 | 92 | 'access arguments' => array('administer site configuration'), |
| 93 | 93 | 'type' => MENU_NORMAL_ITEM, |
| 94 | 94 | 'file' => 'boincwork.admin.inc' |
| 95 | - ); |
|
| 96 | - $items['admin/boinc/prefs/presets'] = array( |
|
| 95 | + ); |
|
| 96 | + $items['admin/boinc/prefs/presets'] = array( |
|
| 97 | 97 | 'title' => 'Preferences: Presets', |
| 98 | 98 | 'description' => 'Set values for BOINC preference set presets.', |
| 99 | 99 | 'page callback' => 'boincwork_admin_prefs_presets_page', |
| 100 | 100 | 'access arguments' => array('administer site configuration'), |
| 101 | 101 | 'type' => MENU_NORMAL_ITEM, |
| 102 | 102 | 'file' => 'boincwork.admin.inc' |
| 103 | - ); |
|
| 104 | - $items['admin/boinc/prefs/upload'] = array( |
|
| 103 | + ); |
|
| 104 | + $items['admin/boinc/prefs/upload'] = array( |
|
| 105 | 105 | 'title' => 'Preferences: Project-specific XML upload', |
| 106 | 106 | 'description' => 'Upload XML configuration for project specific preferences.', |
| 107 | 107 | 'page callback' => 'drupal_get_form', |
@@ -109,153 +109,153 @@ discard block |
||
| 109 | 109 | 'access arguments' => array('administer site configuration'), |
| 110 | 110 | 'type' => MENU_NORMAL_ITEM, |
| 111 | 111 | 'file' => 'boincwork.admin.inc' |
| 112 | - ); |
|
| 113 | - $items['host/%/delete'] = array( |
|
| 112 | + ); |
|
| 113 | + $items['host/%/delete'] = array( |
|
| 114 | 114 | 'title' => 'Delete host', |
| 115 | 115 | 'page callback' => 'boincwork_host_delete', |
| 116 | 116 | 'page arguments' => array(1), |
| 117 | 117 | 'access callback' => 'user_is_logged_in', |
| 118 | 118 | 'type' => MENU_CALLBACK, |
| 119 | - ); |
|
| 120 | - $items['host/%/log'] = array( |
|
| 119 | + ); |
|
| 120 | + $items['host/%/log'] = array( |
|
| 121 | 121 | 'title' => 'Host log', |
| 122 | 122 | 'page callback' => 'boincwork_host_log', |
| 123 | 123 | 'page arguments' => array(1), |
| 124 | 124 | 'access callback' => 'user_is_logged_in', |
| 125 | 125 | 'type' => MENU_CALLBACK, |
| 126 | - ); |
|
| 127 | - $items['host/%/merge'] = array( |
|
| 126 | + ); |
|
| 127 | + $items['host/%/merge'] = array( |
|
| 128 | 128 | 'title' => 'Merge computer', |
| 129 | 129 | 'page callback' => 'drupal_get_form', |
| 130 | 130 | 'page arguments' => array('boincwork_host_merge_form', 1), |
| 131 | 131 | 'access callback' => 'user_is_logged_in', |
| 132 | 132 | 'type' => MENU_CALLBACK, |
| 133 | - ); |
|
| 134 | - $items['host/%/set-venue/%'] = array( |
|
| 133 | + ); |
|
| 134 | + $items['host/%/set-venue/%'] = array( |
|
| 135 | 135 | 'title' => 'Set host venue', |
| 136 | 136 | 'page callback' => 'boincwork_host_set_venue', |
| 137 | 137 | 'page arguments' => array(1,3), |
| 138 | 138 | 'access callback' => 'user_is_logged_in', |
| 139 | 139 | 'type' => MENU_CALLBACK, |
| 140 | - ); |
|
| 141 | - $items['user/%/mobile'] = array( |
|
| 140 | + ); |
|
| 141 | + $items['user/%/mobile'] = array( |
|
| 142 | 142 | 'title' => 'Mobile stats', |
| 143 | 143 | 'page callback' => 'boincwork_mobile_stats', |
| 144 | 144 | 'page arguments' => array(1), |
| 145 | 145 | 'access callback' => 'user_is_logged_in', |
| 146 | 146 | 'type' => MENU_CALLBACK |
| 147 | - ); |
|
| 148 | - $items['server_status.php'] = array( |
|
| 147 | + ); |
|
| 148 | + $items['server_status.php'] = array( |
|
| 149 | 149 | 'title' => 'Server status', |
| 150 | 150 | 'page callback' => 'boincwork_server_status', |
| 151 | 151 | 'access arguments' => array('access content'), |
| 152 | 152 | 'type' => MENU_CALLBACK |
| 153 | - ); |
|
| 154 | - $items['job_file.php'] = array( |
|
| 153 | + ); |
|
| 154 | + $items['job_file.php'] = array( |
|
| 155 | 155 | 'title' => 'Job file input', |
| 156 | 156 | 'page callback' => 'boincwork_job_file', |
| 157 | 157 | 'access arguments' => array('access content'), |
| 158 | 158 | 'type' => MENU_CALLBACK |
| 159 | - ); |
|
| 160 | - $items['get_output.php'] = array( |
|
| 159 | + ); |
|
| 160 | + $items['get_output.php'] = array( |
|
| 161 | 161 | 'title' => 'Get output file', |
| 162 | 162 | 'page callback' => 'boincwork_get_output', |
| 163 | 163 | 'access arguments' => array('access content'), |
| 164 | 164 | 'type' => MENU_CALLBACK |
| 165 | - ); |
|
| 166 | - $items['get_project_config.php'] = array( |
|
| 165 | + ); |
|
| 166 | + $items['get_project_config.php'] = array( |
|
| 167 | 167 | 'title' => 'Project config', |
| 168 | 168 | 'page callback' => 'boincwork_get_project_config', |
| 169 | 169 | 'access arguments' => array('access content'), |
| 170 | 170 | 'type' => MENU_CALLBACK |
| 171 | - ); |
|
| 172 | - $items['submit_rpc_handler.php'] = array( |
|
| 171 | + ); |
|
| 172 | + $items['submit_rpc_handler.php'] = array( |
|
| 173 | 173 | 'title' => 'Remote job submission', |
| 174 | 174 | 'page callback' => 'boincwork_submit_rpc_handler', |
| 175 | 175 | 'access arguments' => array('access content'), |
| 176 | 176 | 'type' => MENU_CALLBACK |
| 177 | - ); |
|
| 178 | - $items['userw.php'] = array( |
|
| 177 | + ); |
|
| 178 | + $items['userw.php'] = array( |
|
| 179 | 179 | 'title' => 'User WAP', |
| 180 | 180 | 'page callback' => 'boincwork_user_wap', |
| 181 | 181 | 'access arguments' => array('access content'), |
| 182 | 182 | 'type' => MENU_CALLBACK |
| 183 | - ); |
|
| 184 | - $items['account/tasks/%/%'] = array( |
|
| 183 | + ); |
|
| 184 | + $items['account/tasks/%/%'] = array( |
|
| 185 | 185 | 'title' => 'Account Tasks Table', |
| 186 | 186 | 'description' => '', |
| 187 | 187 | 'page callback' => 'boincwork_account_task_table', |
| 188 | 188 | 'page arguments' => array(2,3), |
| 189 | 189 | 'access arguments' => array('access content'), |
| 190 | 190 | 'type' => MENU_CALLBACK, |
| 191 | - ); |
|
| 192 | - $items['host/%/tasks/%/%'] = array( |
|
| 191 | + ); |
|
| 192 | + $items['host/%/tasks/%/%'] = array( |
|
| 193 | 193 | 'title' => 'Host Tasks Table', |
| 194 | 194 | 'description' => '', |
| 195 | 195 | 'page callback' => 'boincwork_host_task_table', |
| 196 | 196 | 'page arguments' => array(1,3,4), |
| 197 | 197 | 'access arguments' => array('access content'), |
| 198 | 198 | 'type' => MENU_CALLBACK, |
| 199 | - ); |
|
| 200 | - // Workunit task table disabled |
|
| 201 | - //$items['workunit/%/tasks/%/%'] = array( |
|
| 202 | - // 'title' => 'Workunit Tasks Table', |
|
| 203 | - // 'description' => '', |
|
| 204 | - // 'page callback' => 'boincwork_workunit_task_table', |
|
| 205 | - // 'page arguments' => array(1,3,4), |
|
| 206 | - // 'access arguments' => array('access content'), |
|
| 207 | - // 'type' => MENU_CALLBACK, |
|
| 208 | - //); |
|
| 209 | - return $items; |
|
| 199 | + ); |
|
| 200 | + // Workunit task table disabled |
|
| 201 | + //$items['workunit/%/tasks/%/%'] = array( |
|
| 202 | + // 'title' => 'Workunit Tasks Table', |
|
| 203 | + // 'description' => '', |
|
| 204 | + // 'page callback' => 'boincwork_workunit_task_table', |
|
| 205 | + // 'page arguments' => array(1,3,4), |
|
| 206 | + // 'access arguments' => array('access content'), |
|
| 207 | + // 'type' => MENU_CALLBACK, |
|
| 208 | + //); |
|
| 209 | + return $items; |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
| 213 | 213 | * Implementation of hook_theme(). |
| 214 | 214 | */ |
| 215 | 215 | function boincwork_theme() { |
| 216 | - return array( |
|
| 216 | + return array( |
|
| 217 | 217 | 'boincwork_privacyprefs_form' => array( |
| 218 | - 'arguments' => array('form'), |
|
| 218 | + 'arguments' => array('form'), |
|
| 219 | 219 | ), |
| 220 | - ); |
|
| 220 | + ); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | /** |
| 224 | 224 | * Implementation of hook_views_api(). |
| 225 | 225 | */ |
| 226 | 226 | function boincwork_views_api() { |
| 227 | - return array( |
|
| 227 | + return array( |
|
| 228 | 228 | 'api' => 2.0, |
| 229 | 229 | 'path' => drupal_get_path('module', 'boincwork') |
| 230 | - ); |
|
| 230 | + ); |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | /** |
| 234 | 234 | * Implementation of hook_locale(). |
| 235 | 235 | */ |
| 236 | 236 | function boincwork_locale($op = 'groups', $group = NULL) { |
| 237 | - switch ($op) { |
|
| 237 | + switch ($op) { |
|
| 238 | 238 | case 'groups': |
| 239 | 239 | return array('project' => bts('Project')); |
| 240 | 240 | case 'info': |
| 241 | 241 | $info['project']['refresh callback'] = 'boincwork_locale_refresh'; |
| 242 | - $info['project']['format'] = FALSE; |
|
| 243 | - return $info; |
|
| 244 | - } |
|
| 242 | + $info['project']['format'] = FALSE; |
|
| 243 | + return $info; |
|
| 244 | + } |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | /** |
| 248 | 248 | * Refresh strings. |
| 249 | 249 | */ |
| 250 | 250 | function boincwork_locale_refresh() { |
| 251 | - // Mimic process of adding project specific prefs to the project preferences |
|
| 252 | - // form -- this parses the prefs XML and calls i18nstrings_update() |
|
| 253 | - $form = array(); |
|
| 254 | - $prefs = array( |
|
| 251 | + // Mimic process of adding project specific prefs to the project preferences |
|
| 252 | + // form -- this parses the prefs XML and calls i18nstrings_update() |
|
| 253 | + $form = array(); |
|
| 254 | + $prefs = array( |
|
| 255 | 255 | 'project_specific' => array(), |
| 256 | - ); |
|
| 257 | - boincwork_add_project_specific_prefs($form, $prefs); |
|
| 258 | - return TRUE; // Meaning it completed with no issues |
|
| 256 | + ); |
|
| 257 | + boincwork_add_project_specific_prefs($form, $prefs); |
|
| 258 | + return TRUE; // Meaning it completed with no issues |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | |
@@ -264,43 +264,43 @@ discard block |
||
| 264 | 264 | */ |
| 265 | 265 | |
| 266 | 266 | function boincwork_privatemsg_message_view_alter(&$vars) { |
| 267 | - global $user; |
|
| 267 | + global $user; |
|
| 268 | 268 | |
| 269 | - $author = $vars['message']['author']; |
|
| 270 | - if (!isset($vars['message']['thread_id'])) { |
|
| 269 | + $author = $vars['message']['author']; |
|
| 270 | + if (!isset($vars['message']['thread_id'])) { |
|
| 271 | 271 | // No thread id, this is probably only a preview |
| 272 | 272 | return; |
| 273 | - } |
|
| 274 | - $thread_id = $vars['message']['thread_id']; |
|
| 273 | + } |
|
| 274 | + $thread_id = $vars['message']['thread_id']; |
|
| 275 | 275 | |
| 276 | - if ($user->uid != $author->uid) { |
|
| 276 | + if ($user->uid != $author->uid) { |
|
| 277 | 277 | if ($vars['message']['is_blocked']) { |
| 278 | - $vars['message_actions']['unignore_user'] = array( |
|
| 278 | + $vars['message_actions']['unignore_user'] = array( |
|
| 279 | 279 | 'title' => bts('Stop Ignoring User', array(), NULL, 'boinc:ignore-user-remove'), |
| 280 | 280 | 'href' => 'account/prefs/privacy/ignore_user/remove/'. $author->uid, |
| 281 | 281 | 'query' => 'destination=messages/view/' . $thread_id, |
| 282 | - ); |
|
| 282 | + ); |
|
| 283 | 283 | } |
| 284 | 284 | else { |
| 285 | - $vars['message_actions']['ignore_user'] = array( |
|
| 285 | + $vars['message_actions']['ignore_user'] = array( |
|
| 286 | 286 | 'title' => bts('Ignore User', array(), NULL, 'boinc:ignore-user-add'), |
| 287 | 287 | 'href' => 'account/prefs/privacy/ignore_user/add/'. $author->uid, |
| 288 | 288 | 'query' => 'destination=messages/view/' . $thread_id, |
| 289 | - ); |
|
| 289 | + ); |
|
| 290 | + } |
|
| 290 | 291 | } |
| 291 | - } |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | /** |
| 295 | 295 | * Implementation of hook_cron() |
| 296 | 296 | */ |
| 297 | 297 | function boincwork_cron() { |
| 298 | - // Delete expired hosts in the BOINC database, host_delete table. |
|
| 299 | - require_boinc('boinc_db'); |
|
| 300 | - $num_deleted = BoincHostDeleted::delete_expired(); |
|
| 301 | - if ($num_deleted>0) { |
|
| 298 | + // Delete expired hosts in the BOINC database, host_delete table. |
|
| 299 | + require_boinc('boinc_db'); |
|
| 300 | + $num_deleted = BoincHostDeleted::delete_expired(); |
|
| 301 | + if ($num_deleted>0) { |
|
| 302 | 302 | watchdog('boincwork', "Deleted ${num_deleted} hosts from host_deleted table", WATCHDOG_NOTICE); |
| 303 | - } |
|
| 303 | + } |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -308,41 +308,41 @@ discard block |
||
| 308 | 308 | * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
| 309 | 309 | |
| 310 | 310 | /** |
| 311 | - * General preferences menu callback. |
|
| 312 | - * Called when user goes to edit preferences page |
|
| 313 | - */ |
|
| 311 | + * General preferences menu callback. |
|
| 312 | + * Called when user goes to edit preferences page |
|
| 313 | + */ |
|
| 314 | 314 | function generalprefs_page($action = null, $venue = null, $advanced = FALSE) { |
| 315 | 315 | |
| 316 | - // Keep the venue selected across preference pages |
|
| 317 | - boincwork_select_venue($venue); |
|
| 316 | + // Keep the venue selected across preference pages |
|
| 317 | + boincwork_select_venue($venue); |
|
| 318 | 318 | |
| 319 | - $pref_sets = array('generic', 'home', 'school', 'work'); |
|
| 320 | - $output = null; |
|
| 321 | - // Set the page title |
|
| 322 | - $title = 'Computing'; |
|
| 323 | - drupal_set_title($title); |
|
| 319 | + $pref_sets = array('generic', 'home', 'school', 'work'); |
|
| 320 | + $output = null; |
|
| 321 | + // Set the page title |
|
| 322 | + $title = 'Computing'; |
|
| 323 | + drupal_set_title($title); |
|
| 324 | 324 | |
| 325 | - switch ($action) { |
|
| 325 | + switch ($action) { |
|
| 326 | 326 | |
| 327 | - case 'clear': |
|
| 327 | + case 'clear': |
|
| 328 | 328 | // Remove settings from this preference set |
| 329 | 329 | if ($venue AND $venue != 'generic') { |
| 330 | - boincwork_save_prefs(NULL, 'general', $venue); |
|
| 331 | - drupal_set_message(t('Settings for the "@name" preference set have been |
|
| 330 | + boincwork_save_prefs(NULL, 'general', $venue); |
|
| 331 | + drupal_set_message(t('Settings for the "@name" preference set have been |
|
| 332 | 332 | cleared', array('@name' => ucfirst($venue)))); |
| 333 | - // Set the generic preference set as active |
|
| 334 | - $_SESSION['prefs venue'] = 'generic'; |
|
| 333 | + // Set the generic preference set as active |
|
| 334 | + $_SESSION['prefs venue'] = 'generic'; |
|
| 335 | 335 | } |
| 336 | 336 | drupal_goto(); |
| 337 | 337 | break; |
| 338 | 338 | |
| 339 | - case 'combined': |
|
| 339 | + case 'combined': |
|
| 340 | 340 | // Compare preference sets; tabular view |
| 341 | 341 | |
| 342 | 342 | foreach ($pref_sets as $pref_set) { |
| 343 | - $form_state = array(); |
|
| 344 | - $prefs[$pref_set] = drupal_retrieve_form('boincwork_generalprefs_form', $form_state, $pref_set); |
|
| 345 | - drupal_prepare_form('boincwork_generalprefs_form', $prefs[$pref_set], $form_state); |
|
| 343 | + $form_state = array(); |
|
| 344 | + $prefs[$pref_set] = drupal_retrieve_form('boincwork_generalprefs_form', $form_state, $pref_set); |
|
| 345 | + drupal_prepare_form('boincwork_generalprefs_form', $prefs[$pref_set], $form_state); |
|
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | $output .= '<p>' . bts('These apply to all BOINC projects in which you participate.', array(), NULL, 'boinc:account-preferences-computing') . '<br/>'; |
@@ -355,29 +355,29 @@ discard block |
||
| 355 | 355 | $prefs_table = boincwork_make_prefs_table($prefs['generic']['prefs']['advanced']); |
| 356 | 356 | |
| 357 | 357 | foreach ($prefs_table as $category => $section) { |
| 358 | - $output .= '<tr class="section-heading">'; |
|
| 359 | - $output .= "<td>{$section['name']}</td>"; |
|
| 360 | - foreach ($pref_sets as $pref_set) { |
|
| 358 | + $output .= '<tr class="section-heading">'; |
|
| 359 | + $output .= "<td>{$section['name']}</td>"; |
|
| 360 | + foreach ($pref_sets as $pref_set) { |
|
| 361 | 361 | $output .= '<td>' . $pref_set . '</td>'; |
| 362 | - } |
|
| 363 | - $output .= '</tr>'; |
|
| 364 | - foreach ($section['elements'] as $name => $setting) { |
|
| 362 | + } |
|
| 363 | + $output .= '</tr>'; |
|
| 364 | + foreach ($section['elements'] as $name => $setting) { |
|
| 365 | 365 | // Output the setting name and description, with an ugly exception |
| 366 | 366 | // made for preferences with special formatting |
| 367 | 367 | $special_map = array( |
| 368 | - 'start_hour' => 'end_hour', |
|
| 369 | - 'net_start_hour'=> 'net_end_hour', |
|
| 370 | - 'daily_xfer_limit_mb' => 'daily_xfer_period_days', |
|
| 368 | + 'start_hour' => 'end_hour', |
|
| 369 | + 'net_start_hour'=> 'net_end_hour', |
|
| 370 | + 'daily_xfer_limit_mb' => 'daily_xfer_period_days', |
|
| 371 | 371 | ); |
| 372 | 372 | $special_delimiter = array( |
| 373 | - 'start_hour' => bts('and', array(), NULL, 'boinc:account-preference'), |
|
| 374 | - 'net_start_hour'=> bts('and', array(), NULL, 'boinc:account-preference'), |
|
| 375 | - 'daily_xfer_limit_mb' => bts('every', array(), NULL, 'boinc:account-preference'), |
|
| 373 | + 'start_hour' => bts('and', array(), NULL, 'boinc:account-preference'), |
|
| 374 | + 'net_start_hour'=> bts('and', array(), NULL, 'boinc:account-preference'), |
|
| 375 | + 'daily_xfer_limit_mb' => bts('every', array(), NULL, 'boinc:account-preference'), |
|
| 376 | 376 | ); |
| 377 | 377 | $special = isset($special_map[$name]); |
| 378 | 378 | $very_special = in_array($name, $special_map); |
| 379 | 379 | if ($very_special) { |
| 380 | - continue; |
|
| 380 | + continue; |
|
| 381 | 381 | } |
| 382 | 382 | $output .= '<tr>'; |
| 383 | 383 | $output .= '<td>'; |
@@ -387,35 +387,35 @@ discard block |
||
| 387 | 387 | // Output values for each preference set, again with ugly hacks for |
| 388 | 388 | // time range preferences |
| 389 | 389 | foreach ($pref_sets as $pref_set) { |
| 390 | - if (($prefs[$pref_set]) AND |
|
| 390 | + if (($prefs[$pref_set]) AND |
|
| 391 | 391 | $prefs[$pref_set]['#established'] AND |
| 392 | 392 | isset($prefs[$pref_set]['prefs']['advanced'][$category])) { |
| 393 | 393 | $pref_setting = $prefs[$pref_set]['prefs']['advanced'][$category][$name]; |
| 394 | 394 | $value = isset($pref_setting['#options']) ? $pref_setting['#options'][$pref_setting['#default_value']] : $pref_setting['#default_value']; |
| 395 | 395 | if ($value == '') { |
| 396 | - $value = '---'; |
|
| 396 | + $value = '---'; |
|
| 397 | 397 | } |
| 398 | 398 | if (!isset($pref_setting['#field_suffix'])) { |
| 399 | - $pref_setting['#field_suffix'] = ''; |
|
| 399 | + $pref_setting['#field_suffix'] = ''; |
|
| 400 | 400 | } |
| 401 | 401 | if (!$special) { |
| 402 | - $output .= "<td>{$value} {$pref_setting['#field_suffix']}</td>"; |
|
| 402 | + $output .= "<td>{$value} {$pref_setting['#field_suffix']}</td>"; |
|
| 403 | 403 | } |
| 404 | 404 | else { |
| 405 | - // The "very special" case where we merge two prefs |
|
| 406 | - $second_pref = $special_map[$name]; |
|
| 407 | - $second_pref_setting = $prefs[$pref_set]['prefs']['advanced'][$category][$second_pref]; |
|
| 408 | - $second_value = isset($second_pref_setting['#options']) ? $second_pref_setting['#options'][$second_pref_setting['#default_value']] : $second_pref_setting['#default_value']; |
|
| 409 | - $output .= "<td>{$value} {$pref_setting['#field_suffix']} {$special_delimiter[$name]}" . |
|
| 405 | + // The "very special" case where we merge two prefs |
|
| 406 | + $second_pref = $special_map[$name]; |
|
| 407 | + $second_pref_setting = $prefs[$pref_set]['prefs']['advanced'][$category][$second_pref]; |
|
| 408 | + $second_value = isset($second_pref_setting['#options']) ? $second_pref_setting['#options'][$second_pref_setting['#default_value']] : $second_pref_setting['#default_value']; |
|
| 409 | + $output .= "<td>{$value} {$pref_setting['#field_suffix']} {$special_delimiter[$name]}" . |
|
| 410 | 410 | " {$second_value} {$second_pref_setting['#field_suffix']} </td>"; |
| 411 | 411 | } |
| 412 | - } |
|
| 413 | - else { |
|
| 412 | + } |
|
| 413 | + else { |
|
| 414 | 414 | $output .= '<td>---</td>'; |
| 415 | - } |
|
| 415 | + } |
|
| 416 | 416 | } |
| 417 | 417 | $output .= '</tr>'; |
| 418 | - } |
|
| 418 | + } |
|
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | // Empty line above action links... :/ |
@@ -431,24 +431,24 @@ discard block |
||
| 431 | 431 | $output .= '<tr>'; |
| 432 | 432 | $output .= '<td></td>'; |
| 433 | 433 | foreach ($pref_sets as $pref_set) { |
| 434 | - $action_text = ($prefs[$pref_set]['#established']) ? bts('Edit', array(), NULL, 'boinc:form-edit') : bts('Add', array(), NULL, 'boinc:form-add'); |
|
| 435 | - $output .= '<td><ul class="tab-list"><li class="first tab">'; |
|
| 436 | - $output .= l($action_text, "account/prefs/computing/edit/{$pref_set}/1", |
|
| 434 | + $action_text = ($prefs[$pref_set]['#established']) ? bts('Edit', array(), NULL, 'boinc:form-edit') : bts('Add', array(), NULL, 'boinc:form-add'); |
|
| 435 | + $output .= '<td><ul class="tab-list"><li class="first tab">'; |
|
| 436 | + $output .= l($action_text, "account/prefs/computing/edit/{$pref_set}/1", |
|
| 437 | 437 | array('fragment' => "") |
| 438 | - ); |
|
| 439 | - // Show Clear links for established preference sets |
|
| 440 | - if ($pref_set != 'generic' AND $prefs[$pref_set]['#established']) { |
|
| 438 | + ); |
|
| 439 | + // Show Clear links for established preference sets |
|
| 440 | + if ($pref_set != 'generic' AND $prefs[$pref_set]['#established']) { |
|
| 441 | 441 | $output .= ' </li><li class="tab"> ' . l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/computing/clear/{$pref_set}", |
| 442 | - array( |
|
| 442 | + array( |
|
| 443 | 443 | 'query' => drupal_get_destination(), |
| 444 | 444 | 'attributes' => array( |
| 445 | - 'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the "@name" preference set. Are you sure?', |
|
| 445 | + 'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the "@name" preference set. Are you sure?', |
|
| 446 | 446 | array('@name' => ucfirst($pref_set)), NULL, 'boinc:account-computing-preferences') . '\')' |
| 447 | 447 | ) |
| 448 | - ) |
|
| 448 | + ) |
|
| 449 | 449 | ); |
| 450 | - } |
|
| 451 | - $output .= '</li></ul></td>'; |
|
| 450 | + } |
|
| 451 | + $output .= '</li></ul></td>'; |
|
| 452 | 452 | } |
| 453 | 453 | $output .= '</tr>'; |
| 454 | 454 | |
@@ -456,28 +456,28 @@ discard block |
||
| 456 | 456 | |
| 457 | 457 | break; |
| 458 | 458 | |
| 459 | - case 'edit': |
|
| 459 | + case 'edit': |
|
| 460 | 460 | default: |
| 461 | 461 | |
| 462 | 462 | // Return the HTML generated from the $form data structure. |
| 463 | 463 | if (function_exists('jump_quickly')) { |
| 464 | - $path = 'account/prefs/computing/edit'; |
|
| 465 | - $venues = array( |
|
| 464 | + $path = 'account/prefs/computing/edit'; |
|
| 465 | + $venues = array( |
|
| 466 | 466 | "{$path}/generic" => bts('Generic', array(), NULL, 'boinc:account-preferences-location'), |
| 467 | 467 | "{$path}/home" => bts('Home', array(), NULL, 'boinc:account-preferences-location:-1:ignoreoverwrite'), |
| 468 | 468 | "{$path}/school" => bts('School', array(), NULL, 'boinc:account-preferences-location'), |
| 469 | 469 | "{$path}/work" => bts('Work', array(), NULL, 'boinc:account-preferences-location') |
| 470 | - ); |
|
| 471 | - variable_set('jump_use_js_venues-Array', 1); |
|
| 472 | - drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js'); |
|
| 473 | - drupal_add_js(drupal_get_path('theme', 'boinc') . '/js/prefs.js', 'theme'); |
|
| 474 | - |
|
| 475 | - $output .= '<div id="venue-selector" class="simple-form-controls">'; |
|
| 476 | - $output .= ' <div class="form-item venue">'; |
|
| 477 | - $output .= ' <label>Preference set:</label>'; |
|
| 478 | - $output .= jump_quickly($venues, 'venues', 1, "{$path}/{$venue}"); |
|
| 479 | - $output .= ' </div>'; |
|
| 480 | - $output .= '</div>'; |
|
| 470 | + ); |
|
| 471 | + variable_set('jump_use_js_venues-Array', 1); |
|
| 472 | + drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js'); |
|
| 473 | + drupal_add_js(drupal_get_path('theme', 'boinc') . '/js/prefs.js', 'theme'); |
|
| 474 | + |
|
| 475 | + $output .= '<div id="venue-selector" class="simple-form-controls">'; |
|
| 476 | + $output .= ' <div class="form-item venue">'; |
|
| 477 | + $output .= ' <label>Preference set:</label>'; |
|
| 478 | + $output .= jump_quickly($venues, 'venues', 1, "{$path}/{$venue}"); |
|
| 479 | + $output .= ' </div>'; |
|
| 480 | + $output .= '</div>'; |
|
| 481 | 481 | } |
| 482 | 482 | $output .= drupal_get_form('boincwork_generalprefs_form', $venue, NULL, $advanced); |
| 483 | 483 | |
@@ -488,54 +488,54 @@ discard block |
||
| 488 | 488 | drupal_prepare_form('boincwork_generalprefs_form', $current_set, $form_state); |
| 489 | 489 | |
| 490 | 490 | if (!$current_set['#established']) { |
| 491 | - drupal_set_message(bts( |
|
| 492 | - "No preferences found for set '@venue'. Click SAVE CHANGES below to save the following preferences to your account.", |
|
| 493 | - array( '@venue' => $venue, ), |
|
| 494 | - NULL, 'boinc:account-preferences'), 'status'); |
|
| 491 | + drupal_set_message(bts( |
|
| 492 | + "No preferences found for set '@venue'. Click SAVE CHANGES below to save the following preferences to your account.", |
|
| 493 | + array( '@venue' => $venue, ), |
|
| 494 | + NULL, 'boinc:account-preferences'), 'status'); |
|
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | break; |
| 498 | - } |
|
| 498 | + } |
|
| 499 | 499 | |
| 500 | - return $output; |
|
| 500 | + return $output; |
|
| 501 | 501 | } |
| 502 | 502 | |
| 503 | 503 | /** |
| 504 | - * Project preferences menu callback |
|
| 505 | - * Called when user goes to edit project preferences page. |
|
| 506 | - */ |
|
| 504 | + * Project preferences menu callback |
|
| 505 | + * Called when user goes to edit project preferences page. |
|
| 506 | + */ |
|
| 507 | 507 | function projectprefs_page($action = null, $venue = null) { |
| 508 | 508 | |
| 509 | - // Keep the venue selected across preference pages |
|
| 510 | - boincwork_select_venue($venue); |
|
| 509 | + // Keep the venue selected across preference pages |
|
| 510 | + boincwork_select_venue($venue); |
|
| 511 | 511 | |
| 512 | - require_boinc(array('util', 'prefs')); |
|
| 513 | - global $project_has_beta; |
|
| 514 | - $pref_sets = array('generic', 'home', 'school', 'work'); |
|
| 515 | - $output = null; |
|
| 512 | + require_boinc(array('util', 'prefs')); |
|
| 513 | + global $project_has_beta; |
|
| 514 | + $pref_sets = array('generic', 'home', 'school', 'work'); |
|
| 515 | + $output = null; |
|
| 516 | 516 | |
| 517 | - $title = 'Project'; |
|
| 518 | - drupal_set_title($title); |
|
| 517 | + $title = 'Project'; |
|
| 518 | + drupal_set_title($title); |
|
| 519 | 519 | |
| 520 | - switch ($action) { |
|
| 520 | + switch ($action) { |
|
| 521 | 521 | |
| 522 | - case 'clear': |
|
| 522 | + case 'clear': |
|
| 523 | 523 | // Remove settings from this preference set |
| 524 | 524 | if ($venue AND $venue != 'generic') { |
| 525 | - boincwork_save_prefs(NULL, 'project', $venue); |
|
| 526 | - drupal_set_message(t('Settings for the "@name" preference set have been |
|
| 525 | + boincwork_save_prefs(NULL, 'project', $venue); |
|
| 526 | + drupal_set_message(t('Settings for the "@name" preference set have been |
|
| 527 | 527 | cleared', array('@name' => ucfirst($venue)))); |
| 528 | 528 | |
| 529 | - // Set the generic preference set as active |
|
| 530 | - $_SESSION['prefs venue'] = 'generic'; |
|
| 529 | + // Set the generic preference set as active |
|
| 530 | + $_SESSION['prefs venue'] = 'generic'; |
|
| 531 | 531 | |
| 532 | - // If the user has removed their default preference set, make it generic |
|
| 533 | - boincwork_set_default_venue(); |
|
| 532 | + // If the user has removed their default preference set, make it generic |
|
| 533 | + boincwork_set_default_venue(); |
|
| 534 | 534 | } |
| 535 | 535 | drupal_goto(); |
| 536 | 536 | break; |
| 537 | 537 | |
| 538 | - case 'combined': |
|
| 538 | + case 'combined': |
|
| 539 | 539 | |
| 540 | 540 | // Compare preference sets; tabular view |
| 541 | 541 | |
@@ -544,9 +544,9 @@ discard block |
||
| 544 | 544 | $boincuser = BoincUser::lookup_id($account->boincuser_id); |
| 545 | 545 | |
| 546 | 546 | foreach ($pref_sets as $pref_set) { |
| 547 | - $form_state = array(); |
|
| 548 | - $prefs[$pref_set] = drupal_retrieve_form('boincwork_projectprefs_form', $form_state, $pref_set); |
|
| 549 | - drupal_prepare_form('boincwork_projectprefs_form', $prefs[$pref_set], $form_state); |
|
| 547 | + $form_state = array(); |
|
| 548 | + $prefs[$pref_set] = drupal_retrieve_form('boincwork_projectprefs_form', $form_state, $pref_set); |
|
| 549 | + drupal_prepare_form('boincwork_projectprefs_form', $prefs[$pref_set], $form_state); |
|
| 550 | 550 | } |
| 551 | 551 | |
| 552 | 552 | $output .= '<p>' . bts('Preferences last modified: @mod_time', array('@mod_time' => pretty_time_str($prefs['generic']['modified']['#value'])), NULL, 'boinc:account-preferences') . '</p>'; |
@@ -557,20 +557,20 @@ discard block |
||
| 557 | 557 | $prefs_table = boincwork_make_prefs_table($prefs['generic']); |
| 558 | 558 | |
| 559 | 559 | foreach ($prefs_table as $category => $section) { |
| 560 | - $output .= '<tr class="section-heading">'; |
|
| 561 | - $output .= "<td>{$section['name']}</td>"; |
|
| 562 | - foreach ($pref_sets as $pref_set) { |
|
| 560 | + $output .= '<tr class="section-heading">'; |
|
| 561 | + $output .= "<td>{$section['name']}</td>"; |
|
| 562 | + foreach ($pref_sets as $pref_set) { |
|
| 563 | 563 | $output .= '<td>' . $pref_set . '</td>'; |
| 564 | - } |
|
| 565 | - $output .= '</tr>'; |
|
| 566 | - foreach ($section['elements'] as $name => $setting) { |
|
| 564 | + } |
|
| 565 | + $output .= '</tr>'; |
|
| 566 | + foreach ($section['elements'] as $name => $setting) { |
|
| 567 | 567 | $output .= '<tr>'; |
| 568 | 568 | $output .= '<td>'; |
| 569 | 569 | $output .= "<div class=\"title\">{$setting['name']}</div>"; |
| 570 | 570 | $output .= "<div class=\"description\">{$setting['description']}</div>"; |
| 571 | 571 | $output .= '</td>'; |
| 572 | 572 | foreach ($pref_sets as $pref_set) { |
| 573 | - if (($prefs[$pref_set]) AND |
|
| 573 | + if (($prefs[$pref_set]) AND |
|
| 574 | 574 | $prefs[$pref_set]['#established'] AND |
| 575 | 575 | isset($prefs[$pref_set][$category])) { |
| 576 | 576 | $pref_setting = $prefs[$pref_set][$category][$name]; |
@@ -578,10 +578,10 @@ discard block |
||
| 578 | 578 | if ($value == '') $value = '---'; |
| 579 | 579 | if (!isset($pref_setting['#field_suffix'])) $pref_setting['#field_suffix'] = ''; |
| 580 | 580 | $output .= "<td>{$value} {$pref_setting['#field_suffix']}</td>"; |
| 581 | - } else $output .= '<td>---</td>'; |
|
| 581 | + } else $output .= '<td>---</td>'; |
|
| 582 | 582 | } |
| 583 | 583 | $output .= '</tr>'; |
| 584 | - } |
|
| 584 | + } |
|
| 585 | 585 | } |
| 586 | 586 | |
| 587 | 587 | // Empty line above action links... :/ |
@@ -597,29 +597,29 @@ discard block |
||
| 597 | 597 | $output .= '<tr>'; |
| 598 | 598 | $output .= '<td></td>'; |
| 599 | 599 | foreach ($pref_sets as $pref_set) { |
| 600 | - $action_text = ($prefs[$pref_set]['#established']) ? bts('Edit', array(), NULL, 'boinc:form-edit') : bts('Add', array(), NULL, 'boinc:form-add'); |
|
| 601 | - $output .= '<td><ul class="tab-list"><li class="first tab">'; |
|
| 602 | - $output .= l($action_text, "account/prefs/project/edit/{$pref_set}"); |
|
| 603 | - // Show Clear links for established preference sets |
|
| 604 | - if ($pref_set != 'generic' AND $prefs[$pref_set]['#established']) { |
|
| 600 | + $action_text = ($prefs[$pref_set]['#established']) ? bts('Edit', array(), NULL, 'boinc:form-edit') : bts('Add', array(), NULL, 'boinc:form-add'); |
|
| 601 | + $output .= '<td><ul class="tab-list"><li class="first tab">'; |
|
| 602 | + $output .= l($action_text, "account/prefs/project/edit/{$pref_set}"); |
|
| 603 | + // Show Clear links for established preference sets |
|
| 604 | + if ($pref_set != 'generic' AND $prefs[$pref_set]['#established']) { |
|
| 605 | 605 | $output .= ' </li><li class="tab"> ' . l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/project/clear/{$pref_set}", |
| 606 | - array( |
|
| 606 | + array( |
|
| 607 | 607 | 'query' => drupal_get_destination(), |
| 608 | 608 | 'attributes' => array( |
| 609 | - 'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the "@name" preference set. Are you sure?', |
|
| 609 | + 'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the "@name" preference set. Are you sure?', |
|
| 610 | 610 | array('@name' => ucfirst($pref_set)), NULL, 'boinc:account-preferences-project') . '\')' |
| 611 | 611 | ) |
| 612 | - ) |
|
| 612 | + ) |
|
| 613 | 613 | ); |
| 614 | - } |
|
| 615 | - $output .= '</li></ul></td>'; |
|
| 614 | + } |
|
| 615 | + $output .= '</li></ul></td>'; |
|
| 616 | 616 | } |
| 617 | 617 | |
| 618 | 618 | $output .= '</table>'; |
| 619 | 619 | |
| 620 | 620 | break; |
| 621 | 621 | |
| 622 | - case 'set-default': |
|
| 622 | + case 'set-default': |
|
| 623 | 623 | // Set this preference set as the one to use for any new hosts attached |
| 624 | 624 | // to the user account |
| 625 | 625 | boincwork_set_default_venue($venue); |
@@ -627,30 +627,30 @@ discard block |
||
| 627 | 627 | drupal_goto('account/prefs/project/combined'); |
| 628 | 628 | break; |
| 629 | 629 | |
| 630 | - case 'edit': |
|
| 630 | + case 'edit': |
|
| 631 | 631 | default: |
| 632 | 632 | |
| 633 | 633 | // Return the HTML generated from the $form data structure. |
| 634 | 634 | require_boinc('util'); |
| 635 | 635 | |
| 636 | 636 | if (function_exists('jump_quickly')) { |
| 637 | - $path = 'account/prefs/project/edit'; |
|
| 638 | - $venues = array( |
|
| 637 | + $path = 'account/prefs/project/edit'; |
|
| 638 | + $venues = array( |
|
| 639 | 639 | "{$path}/generic" => bts('Generic', array(), NULL, 'boinc:account-preferences-location'), |
| 640 | 640 | "{$path}/home" => bts('Home', array(), NULL, 'boinc:account-preferences-location:-1:ignoreoverwrite'), |
| 641 | 641 | "{$path}/school" => bts('School', array(), NULL, 'boinc:account-preferences-location'), |
| 642 | 642 | "{$path}/work" => bts('Work', array(), NULL, 'boinc:account-preferences-location') |
| 643 | - ); |
|
| 644 | - variable_set('jump_use_js_venues-Array', 1); |
|
| 645 | - drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js'); |
|
| 646 | - drupal_add_js(drupal_get_path('theme', 'boinc') . '/js/prefs.js', 'theme'); |
|
| 647 | - |
|
| 648 | - $output .= '<div id="venue-selector" class="simple-form-controls">'; |
|
| 649 | - $output .= ' <div class="form-item venue">'; |
|
| 650 | - $output .= ' <label>Preference set:</label>'; |
|
| 651 | - $output .= jump_quickly($venues, 'venues', 1, "{$path}/{$venue}"); |
|
| 652 | - $output .= ' </div>'; |
|
| 653 | - $output .= '</div>'; |
|
| 643 | + ); |
|
| 644 | + variable_set('jump_use_js_venues-Array', 1); |
|
| 645 | + drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js'); |
|
| 646 | + drupal_add_js(drupal_get_path('theme', 'boinc') . '/js/prefs.js', 'theme'); |
|
| 647 | + |
|
| 648 | + $output .= '<div id="venue-selector" class="simple-form-controls">'; |
|
| 649 | + $output .= ' <div class="form-item venue">'; |
|
| 650 | + $output .= ' <label>Preference set:</label>'; |
|
| 651 | + $output .= jump_quickly($venues, 'venues', 1, "{$path}/{$venue}"); |
|
| 652 | + $output .= ' </div>'; |
|
| 653 | + $output .= '</div>'; |
|
| 654 | 654 | } |
| 655 | 655 | $output .= drupal_get_form('boincwork_projectprefs_form', $venue); |
| 656 | 656 | |
@@ -661,63 +661,63 @@ discard block |
||
| 661 | 661 | drupal_prepare_form('boincwork_projectprefs_form', $current_set, $form_state); |
| 662 | 662 | |
| 663 | 663 | if (!$current_set['#established']) { |
| 664 | - drupal_set_message(bts( |
|
| 665 | - "No preferences found for set '@venue'. Click SAVE CHANGES below to save the following preferences to your account.", |
|
| 666 | - array( '@venue' => $venue, ), |
|
| 667 | - NULL, 'boinc:account-preferences'), 'status'); |
|
| 664 | + drupal_set_message(bts( |
|
| 665 | + "No preferences found for set '@venue'. Click SAVE CHANGES below to save the following preferences to your account.", |
|
| 666 | + array( '@venue' => $venue, ), |
|
| 667 | + NULL, 'boinc:account-preferences'), 'status'); |
|
| 668 | 668 | } |
| 669 | 669 | |
| 670 | 670 | break; |
| 671 | 671 | |
| 672 | - } |
|
| 673 | - return $output; |
|
| 672 | + } |
|
| 673 | + return $output; |
|
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | /** |
| 677 | - * Community preferences menu callback |
|
| 678 | - * Called when user goes to edit community preferences page. |
|
| 679 | - */ |
|
| 677 | + * Community preferences menu callback |
|
| 678 | + * Called when user goes to edit community preferences page. |
|
| 679 | + */ |
|
| 680 | 680 | function communityprefs_page($action = null) { |
| 681 | 681 | |
| 682 | - require_boinc(array('util', 'prefs')); |
|
| 683 | - $output = null; |
|
| 682 | + require_boinc(array('util', 'prefs')); |
|
| 683 | + $output = null; |
|
| 684 | 684 | |
| 685 | - $title = 'Community'; |
|
| 686 | - drupal_set_title($title); |
|
| 685 | + $title = 'Community'; |
|
| 686 | + drupal_set_title($title); |
|
| 687 | 687 | |
| 688 | - //$output .= '<h2>Community preferences</h2>'; |
|
| 688 | + //$output .= '<h2>Community preferences</h2>'; |
|
| 689 | 689 | |
| 690 | - $output .= drupal_get_form('communityprefs_form'); |
|
| 690 | + $output .= drupal_get_form('communityprefs_form'); |
|
| 691 | 691 | |
| 692 | - return $output; |
|
| 692 | + return $output; |
|
| 693 | 693 | } |
| 694 | 694 | |
| 695 | 695 | /** |
| 696 | - * Privacy preferences menu callback |
|
| 697 | - * Called when user goes to edit privacy preferences page. |
|
| 698 | - */ |
|
| 696 | + * Privacy preferences menu callback |
|
| 697 | + * Called when user goes to edit privacy preferences page. |
|
| 698 | + */ |
|
| 699 | 699 | function privacyprefs_page($action = null) { |
| 700 | 700 | |
| 701 | - require_boinc(array('util', 'prefs')); |
|
| 702 | - $output = null; |
|
| 703 | - $title = 'Privacy'; |
|
| 704 | - drupal_set_title($title); |
|
| 701 | + require_boinc(array('util', 'prefs')); |
|
| 702 | + $output = null; |
|
| 703 | + $title = 'Privacy'; |
|
| 704 | + drupal_set_title($title); |
|
| 705 | 705 | |
| 706 | - switch ($action) { |
|
| 707 | - case 'view': |
|
| 706 | + switch ($action) { |
|
| 707 | + case 'view': |
|
| 708 | 708 | $form_state = array(); |
| 709 | 709 | $prefs = drupal_retrieve_form('boincwork_privacyprefs_form', $form_state); |
| 710 | 710 | drupal_prepare_form('boincwork_privacyprefs_form', $prefs, $form_state); |
| 711 | 711 | $output .= '<table>'; |
| 712 | 712 | |
| 713 | 713 | $sections = array( |
| 714 | - 'privacy' => $prefs['privacy'] |
|
| 714 | + 'privacy' => $prefs['privacy'] |
|
| 715 | 715 | ); |
| 716 | 716 | |
| 717 | 717 | foreach ($sections as $section) { |
| 718 | - $output .= '<tr class="section-heading">'; |
|
| 719 | - $output .= "<td>{$section['#title']}</td></tr>"; |
|
| 720 | - foreach ($section as $name => $setting) { |
|
| 718 | + $output .= '<tr class="section-heading">'; |
|
| 719 | + $output .= "<td>{$section['#title']}</td></tr>"; |
|
| 720 | + foreach ($section as $name => $setting) { |
|
| 721 | 721 | if ($name{0} == '#') continue; |
| 722 | 722 | $value = isset($setting['#default_value']) ? $setting['#default_value'] : ''; |
| 723 | 723 | if ($value AND isset($setting['#options'])) $value = $setting['#options'][$value]; |
@@ -729,7 +729,7 @@ discard block |
||
| 729 | 729 | $output .= "<td>{$setting['#title']}<br/>{$setting['#description']}</td>"; |
| 730 | 730 | $output .= "<td>{$value} {$setting['#field_suffix']}</td>"; |
| 731 | 731 | $output .= '</tr>'; |
| 732 | - } |
|
| 732 | + } |
|
| 733 | 733 | } |
| 734 | 734 | |
| 735 | 735 | // Edit preferences link |
@@ -742,33 +742,33 @@ discard block |
||
| 742 | 742 | |
| 743 | 743 | break; |
| 744 | 744 | |
| 745 | - case 'edit': |
|
| 745 | + case 'edit': |
|
| 746 | 746 | default: |
| 747 | 747 | require_boinc('util'); |
| 748 | 748 | // Return the HTML generated from the $form data structure. |
| 749 | 749 | $output .= drupal_get_form('boincwork_privacyprefs_form'); |
| 750 | 750 | break; |
| 751 | 751 | |
| 752 | - } |
|
| 752 | + } |
|
| 753 | 753 | |
| 754 | - return $output; |
|
| 754 | + return $output; |
|
| 755 | 755 | } |
| 756 | 756 | |
| 757 | 757 | /** |
| 758 | - * Certificates menu callback |
|
| 759 | - * Called when user goes to account certificate pages |
|
| 760 | - */ |
|
| 758 | + * Certificates menu callback |
|
| 759 | + * Called when user goes to account certificate pages |
|
| 760 | + */ |
|
| 761 | 761 | function boincwork_certificates($type = null, $border = null) { |
| 762 | - global $user; |
|
| 763 | - $drupuser = user_load($user->uid); |
|
| 764 | - // Load BOINC account and pre-authenticate with BOINC code |
|
| 765 | - require_boinc(array('util', 'cert')); |
|
| 766 | - $boincuser = BoincUser::lookup_id($drupuser->boincuser_id); |
|
| 767 | - //global $g_logged_in_user; |
|
| 768 | - //$g_logged_in_user = $boincuser; |
|
| 769 | - //print_r($boincuser); exit; |
|
| 770 | - switch ($type) { |
|
| 771 | - case 'all': |
|
| 762 | + global $user; |
|
| 763 | + $drupuser = user_load($user->uid); |
|
| 764 | + // Load BOINC account and pre-authenticate with BOINC code |
|
| 765 | + require_boinc(array('util', 'cert')); |
|
| 766 | + $boincuser = BoincUser::lookup_id($drupuser->boincuser_id); |
|
| 767 | + //global $g_logged_in_user; |
|
| 768 | + //$g_logged_in_user = $boincuser; |
|
| 769 | + //print_r($boincuser); exit; |
|
| 770 | + switch ($type) { |
|
| 771 | + case 'all': |
|
| 772 | 772 | //include_boinc('user/cert_all.php'); |
| 773 | 773 | require_boinc(array('util','cert','user')); |
| 774 | 774 | |
@@ -838,7 +838,7 @@ discard block |
||
| 838 | 838 | "; |
| 839 | 839 | break; |
| 840 | 840 | |
| 841 | - case 'account': |
|
| 841 | + case 'account': |
|
| 842 | 842 | default: |
| 843 | 843 | //include_boinc('user/cert1.php'); |
| 844 | 844 | require_boinc(array('util','cert')); |
@@ -914,7 +914,7 @@ discard block |
||
| 914 | 914 | echo " |
| 915 | 915 | </td><tr></table> |
| 916 | 916 | "; |
| 917 | - } |
|
| 917 | + } |
|
| 918 | 918 | } |
| 919 | 919 | |
| 920 | 920 | /** |
@@ -922,42 +922,42 @@ discard block |
||
| 922 | 922 | * Called when user selects to delete a host |
| 923 | 923 | */ |
| 924 | 924 | function boincwork_host_delete($host_id) { |
| 925 | - // Verify that host has no tasks |
|
| 926 | - if (boincwork_host_user_is_owner($host_id)) { |
|
| 925 | + // Verify that host has no tasks |
|
| 926 | + if (boincwork_host_user_is_owner($host_id)) { |
|
| 927 | 927 | if (!boincwork_host_get_task_count($host_id)) { |
| 928 | - // Delete the host record |
|
| 929 | - db_set_active('boinc_rw'); |
|
| 930 | - $host_deleted = db_query( |
|
| 928 | + // Delete the host record |
|
| 929 | + db_set_active('boinc_rw'); |
|
| 930 | + $host_deleted = db_query( |
|
| 931 | 931 | "DELETE FROM {host} WHERE id = '%d'", |
| 932 | 932 | $host_id |
| 933 | - ); |
|
| 934 | - db_set_active('default'); |
|
| 935 | - if ($host_deleted) { |
|
| 933 | + ); |
|
| 934 | + db_set_active('default'); |
|
| 935 | + if ($host_deleted) { |
|
| 936 | 936 | drupal_set_message(t('Host @id has been removed from your account.', |
| 937 | - array('@id' => $host_id))); |
|
| 937 | + array('@id' => $host_id))); |
|
| 938 | 938 | drupal_goto('account/computers'); |
| 939 | - } |
|
| 940 | - else { |
|
| 939 | + } |
|
| 940 | + else { |
|
| 941 | 941 | drupal_set_message(t('Host @id could not be deleted. Not sure why...', |
| 942 | - array('@id' => $host_id)), 'error' |
|
| 942 | + array('@id' => $host_id)), 'error' |
|
| 943 | 943 | ); |
| 944 | - } |
|
| 944 | + } |
|
| 945 | 945 | } |
| 946 | 946 | else { |
| 947 | - drupal_set_message(t('Host @id cannot be deleted because it still has |
|
| 947 | + drupal_set_message(t('Host @id cannot be deleted because it still has |
|
| 948 | 948 | tasks associated with it. These tasks should be processed within the |
| 949 | 949 | next few days, after which the host can be deleted.', |
| 950 | 950 | array('@id' => $host_id)), 'warning' |
| 951 | - ); |
|
| 951 | + ); |
|
| 952 | + } |
|
| 952 | 953 | } |
| 953 | - } |
|
| 954 | - else { |
|
| 954 | + else { |
|
| 955 | 955 | drupal_set_message(t('You are not the owner of host @id, so you cannot |
| 956 | 956 | delete it.', |
| 957 | - array('@id' => $host_id)), 'error' |
|
| 957 | + array('@id' => $host_id)), 'error' |
|
| 958 | 958 | ); |
| 959 | - } |
|
| 960 | - drupal_goto("host/{$host_id}"); |
|
| 959 | + } |
|
| 960 | + drupal_goto("host/{$host_id}"); |
|
| 961 | 961 | } |
| 962 | 962 | |
| 963 | 963 | /** |
@@ -965,55 +965,55 @@ discard block |
||
| 965 | 965 | * Called when user accesses the log for a host |
| 966 | 966 | */ |
| 967 | 967 | function boincwork_host_log($host_id = null) { |
| 968 | - $root_log_dir = variable_get('boinc_host_sched_logs_dir', ''); |
|
| 969 | - $log = ''; |
|
| 970 | - if ($root_log_dir AND $host_id) { |
|
| 968 | + $root_log_dir = variable_get('boinc_host_sched_logs_dir', ''); |
|
| 969 | + $log = ''; |
|
| 970 | + if ($root_log_dir AND $host_id) { |
|
| 971 | 971 | $subdir = substr($host_id, 0, -3) OR $subdir = 0; |
| 972 | 972 | $log = implode('/', array($root_log_dir, $subdir, $host_id)); |
| 973 | - } |
|
| 974 | - if ($log AND file_exists($log)) { |
|
| 973 | + } |
|
| 974 | + if ($log AND file_exists($log)) { |
|
| 975 | 975 | header('Content-type: text/plain'); |
| 976 | 976 | include($log); |
| 977 | - } |
|
| 977 | + } |
|
| 978 | 978 | } |
| 979 | 979 | |
| 980 | 980 | function boincwork_host_set_venue($host_id = NULL, $venue = NULL) { |
| 981 | - global $user; |
|
| 982 | - $account = user_load($user->uid); |
|
| 983 | - db_set_active('boinc_ro'); |
|
| 984 | - // Verify that this is my host |
|
| 985 | - $host_owner = db_result(db_query( |
|
| 981 | + global $user; |
|
| 982 | + $account = user_load($user->uid); |
|
| 983 | + db_set_active('boinc_ro'); |
|
| 984 | + // Verify that this is my host |
|
| 985 | + $host_owner = db_result(db_query( |
|
| 986 | 986 | "SELECT userid FROM {host} WHERE id = '%d'", |
| 987 | 987 | $host_id |
| 988 | - )); |
|
| 989 | - db_set_active('default'); |
|
| 990 | - if ($host_owner AND $host_owner == $account->boincuser_id) { |
|
| 988 | + )); |
|
| 989 | + db_set_active('default'); |
|
| 990 | + if ($host_owner AND $host_owner == $account->boincuser_id) { |
|
| 991 | 991 | db_set_active('boinc_rw'); |
| 992 | 992 | $updated = db_query( |
| 993 | - "UPDATE {host} SET venue = '%s' WHERE id = '%d'", |
|
| 994 | - $venue, $host_id |
|
| 993 | + "UPDATE {host} SET venue = '%s' WHERE id = '%d'", |
|
| 994 | + $venue, $host_id |
|
| 995 | 995 | ); |
| 996 | 996 | db_set_active('default'); |
| 997 | 997 | if ($updated) { |
| 998 | - drupal_set_message( |
|
| 998 | + drupal_set_message( |
|
| 999 | 999 | bts('The location for this host has been updated.', array(), NULL, 'boinc:account-host-details') |
| 1000 | 1000 | . bts('This will take effect next time the host contacts the project.', array(), NULL, 'boinc:account-host-details') |
| 1001 | - ); |
|
| 1001 | + ); |
|
| 1002 | 1002 | } |
| 1003 | 1003 | else { |
| 1004 | - drupal_set_message( |
|
| 1004 | + drupal_set_message( |
|
| 1005 | 1005 | bts('Unable to save changes to this host for some reason!', array(), NULL, 'boinc:account-host-details'), |
| 1006 | 1006 | 'error' |
| 1007 | - ); |
|
| 1007 | + ); |
|
| 1008 | 1008 | } |
| 1009 | - } |
|
| 1010 | - else { |
|
| 1009 | + } |
|
| 1010 | + else { |
|
| 1011 | 1011 | drupal_set_message( |
| 1012 | - bts('You are not allowed to make changes to this host.', array(), NULL, 'boinc:account-host-details'), |
|
| 1013 | - 'warning' |
|
| 1012 | + bts('You are not allowed to make changes to this host.', array(), NULL, 'boinc:account-host-details'), |
|
| 1013 | + 'warning' |
|
| 1014 | 1014 | ); |
| 1015 | - } |
|
| 1016 | - drupal_goto("host/{$host_id}"); |
|
| 1015 | + } |
|
| 1016 | + drupal_goto("host/{$host_id}"); |
|
| 1017 | 1017 | } |
| 1018 | 1018 | |
| 1019 | 1019 | /** |
@@ -1021,8 +1021,8 @@ discard block |
||
| 1021 | 1021 | * Called when user accesses cell phone stats |
| 1022 | 1022 | */ |
| 1023 | 1023 | function boincwork_mobile_stats($userid = null) { |
| 1024 | - $_GET['id'] = $userid; |
|
| 1025 | - include_boinc('user/userw.php'); |
|
| 1024 | + $_GET['id'] = $userid; |
|
| 1025 | + include_boinc('user/userw.php'); |
|
| 1026 | 1026 | } |
| 1027 | 1027 | |
| 1028 | 1028 | /** |
@@ -1030,7 +1030,7 @@ discard block |
||
| 1030 | 1030 | * Called to build the server status page |
| 1031 | 1031 | */ |
| 1032 | 1032 | function boincwork_server_status() { |
| 1033 | - include_boinc('user/server_status.php'); |
|
| 1033 | + include_boinc('user/server_status.php'); |
|
| 1034 | 1034 | } |
| 1035 | 1035 | |
| 1036 | 1036 | /** |
@@ -1038,7 +1038,7 @@ discard block |
||
| 1038 | 1038 | * RPC for managing job input files |
| 1039 | 1039 | */ |
| 1040 | 1040 | function boincwork_job_file() { |
| 1041 | - include_boinc('user/job_file.php'); |
|
| 1041 | + include_boinc('user/job_file.php'); |
|
| 1042 | 1042 | } |
| 1043 | 1043 | |
| 1044 | 1044 | /** |
@@ -1046,7 +1046,7 @@ discard block |
||
| 1046 | 1046 | * Get output file from remote job submission |
| 1047 | 1047 | */ |
| 1048 | 1048 | function boincwork_get_output() { |
| 1049 | - include_boinc('user/get_output.php'); |
|
| 1049 | + include_boinc('user/get_output.php'); |
|
| 1050 | 1050 | } |
| 1051 | 1051 | |
| 1052 | 1052 | /** |
@@ -1054,28 +1054,28 @@ discard block |
||
| 1054 | 1054 | * Get the project configuration XML; used by client software |
| 1055 | 1055 | */ |
| 1056 | 1056 | function boincwork_get_project_config() { |
| 1057 | - ob_start(); |
|
| 1058 | - include_boinc('user/get_project_config.php'); |
|
| 1059 | - $xml = ob_get_clean(); |
|
| 1060 | - $xml = load_configuration($xml); |
|
| 1061 | - |
|
| 1062 | - // obtain Drupal variables |
|
| 1063 | - $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
| 1064 | - $overrideboinctou = variable_get('boinc_weboptions_overrideboinctou', FALSE); |
|
| 1065 | - |
|
| 1066 | - // If terms of use string exists and override is true, set terms-of-use |
|
| 1067 | - // to Drupal varaible. |
|
| 1068 | - if ( (!empty($termsofuse) && ($overrideboinctou)) ) { |
|
| 1057 | + ob_start(); |
|
| 1058 | + include_boinc('user/get_project_config.php'); |
|
| 1059 | + $xml = ob_get_clean(); |
|
| 1060 | + $xml = load_configuration($xml); |
|
| 1061 | + |
|
| 1062 | + // obtain Drupal variables |
|
| 1063 | + $termsofuse = variable_get('boinc_weboptions_termsofuse', ''); |
|
| 1064 | + $overrideboinctou = variable_get('boinc_weboptions_overrideboinctou', FALSE); |
|
| 1065 | + |
|
| 1066 | + // If terms of use string exists and override is true, set terms-of-use |
|
| 1067 | + // to Drupal varaible. |
|
| 1068 | + if ( (!empty($termsofuse) && ($overrideboinctou)) ) { |
|
| 1069 | 1069 | if (!empty($xml['project_config']['terms_of_use'])) { |
| 1070 | - // Remove any existing terms of use |
|
| 1071 | - unset($xml['project_config']['terms_of_use']); |
|
| 1070 | + // Remove any existing terms of use |
|
| 1071 | + unset($xml['project_config']['terms_of_use']); |
|
| 1072 | 1072 | } |
| 1073 | 1073 | |
| 1074 | 1074 | // Add terms of use from Drupal |
| 1075 | 1075 | $xml['project_config']['terms_of_use']['@value'] = $termsofuse; |
| 1076 | - } |
|
| 1076 | + } |
|
| 1077 | 1077 | |
| 1078 | - print save_configuration($xml); |
|
| 1078 | + print save_configuration($xml); |
|
| 1079 | 1079 | } |
| 1080 | 1080 | |
| 1081 | 1081 | |
@@ -1083,16 +1083,16 @@ discard block |
||
| 1083 | 1083 | * Page callback for the remote job submission RPC (submit_rpc_handler.php). |
| 1084 | 1084 | */ |
| 1085 | 1085 | function boincwork_submit_rpc_handler() { |
| 1086 | - include_boinc('user/submit_rpc_handler.php'); |
|
| 1086 | + include_boinc('user/submit_rpc_handler.php'); |
|
| 1087 | 1087 | } |
| 1088 | 1088 | |
| 1089 | 1089 | /** |
| 1090 | 1090 | * Page callback for user WAP (userw.php). |
| 1091 | 1091 | */ |
| 1092 | 1092 | function boincwork_user_wap() { |
| 1093 | - // Remove q from the GET request or BOINC will panic |
|
| 1094 | - unset($_GET['q']); |
|
| 1095 | - include_boinc('user/userw.php'); |
|
| 1093 | + // Remove q from the GET request or BOINC will panic |
|
| 1094 | + unset($_GET['q']); |
|
| 1095 | + include_boinc('user/userw.php'); |
|
| 1096 | 1096 | } |
| 1097 | 1097 | |
| 1098 | 1098 | |
@@ -1100,44 +1100,44 @@ discard block |
||
| 1100 | 1100 | * Page callback for user account task table |
| 1101 | 1101 | */ |
| 1102 | 1102 | function boincwork_account_task_table($tselect = NULL, $app_id = NULL) { |
| 1103 | - $title = bts('Tasks for your account', array(), NULL, 'boinc:account-task-table'); |
|
| 1104 | - drupal_set_title($title); |
|
| 1103 | + $title = bts('Tasks for your account', array(), NULL, 'boinc:account-task-table'); |
|
| 1104 | + drupal_set_title($title); |
|
| 1105 | 1105 | |
| 1106 | - global $user; |
|
| 1107 | - $account = user_load($user->uid); |
|
| 1108 | - return boincwork_tasktable(0, $account->boincuser_id, $tselect, $app_id); |
|
| 1106 | + global $user; |
|
| 1107 | + $account = user_load($user->uid); |
|
| 1108 | + return boincwork_tasktable(0, $account->boincuser_id, $tselect, $app_id); |
|
| 1109 | 1109 | } |
| 1110 | 1110 | |
| 1111 | 1111 | /** |
| 1112 | 1112 | * Page callback for host task table |
| 1113 | 1113 | */ |
| 1114 | 1114 | function boincwork_host_task_table($host_id = NULL, $tselect = NULL, $app_id = NULL) { |
| 1115 | - require_boinc( array('util', 'result') ); |
|
| 1115 | + require_boinc( array('util', 'result') ); |
|
| 1116 | 1116 | |
| 1117 | - $title = bts('Tasks for computer @host_id', array('@host_id' => $host_id), NULL, 'boinc:host-task-table'); |
|
| 1118 | - drupal_set_title($title); |
|
| 1117 | + $title = bts('Tasks for computer @host_id', array('@host_id' => $host_id), NULL, 'boinc:host-task-table'); |
|
| 1118 | + drupal_set_title($title); |
|
| 1119 | 1119 | |
| 1120 | - if (is_null($host_id)) { |
|
| 1120 | + if (is_null($host_id)) { |
|
| 1121 | 1121 | drupal_set_message(bts('ERROR: Invalid host ID', array(), NULL, 'boinc:host-task-table'), 'error'); |
| 1122 | 1122 | return ''; |
| 1123 | - } |
|
| 1123 | + } |
|
| 1124 | 1124 | |
| 1125 | - return boincwork_tasktable(2, $host_id, $tselect, $app_id); |
|
| 1125 | + return boincwork_tasktable(2, $host_id, $tselect, $app_id); |
|
| 1126 | 1126 | } |
| 1127 | 1127 | |
| 1128 | 1128 | /** |
| 1129 | 1129 | * Page callback for workunit task table |
| 1130 | 1130 | */ |
| 1131 | 1131 | function boincwork_workunit_task_table($workunit_id = NULL, $tselect = NULL, $app_id = NULL) { |
| 1132 | - $title = bts('Tasks for workunit @workunit_id', array('@workunit_id' => $workunit_id), NULL, 'boinc:workunit-task-table'); |
|
| 1133 | - drupal_set_title($title); |
|
| 1132 | + $title = bts('Tasks for workunit @workunit_id', array('@workunit_id' => $workunit_id), NULL, 'boinc:workunit-task-table'); |
|
| 1133 | + drupal_set_title($title); |
|
| 1134 | 1134 | |
| 1135 | - if (is_null($workunit_id)) { |
|
| 1135 | + if (is_null($workunit_id)) { |
|
| 1136 | 1136 | drupal_set_message(bts('ERROR: Invalid workunit ID', array(), NULL, 'boinc:workunit-task-table'), 'error'); |
| 1137 | 1137 | return ''; |
| 1138 | - } |
|
| 1138 | + } |
|
| 1139 | 1139 | |
| 1140 | - return boincwork_tasktable(1, $workunit_id, $tselect, $app_id); |
|
| 1140 | + return boincwork_tasktable(1, $workunit_id, $tselect, $app_id); |
|
| 1141 | 1141 | } |
| 1142 | 1142 | |
| 1143 | 1143 | /** |
@@ -1145,8 +1145,8 @@ discard block |
||
| 1145 | 1145 | * Take a node ID and render that node as a page |
| 1146 | 1146 | */ |
| 1147 | 1147 | function boincwork_view_page($nid) { |
| 1148 | - $node = node_load($nid); |
|
| 1149 | - return node_page_view($node); |
|
| 1148 | + $node = node_load($nid); |
|
| 1149 | + return node_page_view($node); |
|
| 1150 | 1150 | } |
| 1151 | 1151 | |
| 1152 | 1152 | |
@@ -1158,16 +1158,16 @@ discard block |
||
| 1158 | 1158 | * Determine which venue should be selected |
| 1159 | 1159 | */ |
| 1160 | 1160 | function boincwork_select_venue(&$venue) { |
| 1161 | - if (!$venue) { |
|
| 1161 | + if (!$venue) { |
|
| 1162 | 1162 | $active_venue = isset($_SESSION['prefs venue']) ? $_SESSION['prefs venue'] : NULL; |
| 1163 | 1163 | if ($active_venue) { |
| 1164 | - $venue = $active_venue; |
|
| 1165 | - //unset($_SESSION['prefs venue']); |
|
| 1164 | + $venue = $active_venue; |
|
| 1165 | + //unset($_SESSION['prefs venue']); |
|
| 1166 | + } |
|
| 1166 | 1167 | } |
| 1167 | - } |
|
| 1168 | - else { |
|
| 1168 | + else { |
|
| 1169 | 1169 | // Set the active venue to keep it selected between computing and project |
| 1170 | 1170 | // preference pages |
| 1171 | 1171 | $_SESSION['prefs venue'] = $venue; |
| 1172 | - } |
|
| 1172 | + } |
|
| 1173 | 1173 | } |
@@ -11,19 +11,19 @@ discard block |
||
| 11 | 11 | * that was selected |
| 12 | 12 | */ |
| 13 | 13 | function boincwork_ahah_helper_venue_submit($form, &$form_state) { |
| 14 | - $form_state['storage']['prefs']['preset'] = null; |
|
| 15 | - ahah_helper_generic_submit($form, $form_state); |
|
| 14 | + $form_state['storage']['prefs']['preset'] = null; |
|
| 15 | + ahah_helper_generic_submit($form, $form_state); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Get a predetermined set of preferences |
| 20 | 20 | */ |
| 21 | 21 | function boincwork_get_preset_prefs($preset = null) { |
| 22 | - $saved_state = variable_get('boincwork_preset_prefs', null); |
|
| 22 | + $saved_state = variable_get('boincwork_preset_prefs', null); |
|
| 23 | 23 | |
| 24 | - // If not configured yet, use these values as for inital |
|
| 25 | - // computing/general preferences. |
|
| 26 | - if (!$saved_state) { |
|
| 24 | + // If not configured yet, use these values as for inital |
|
| 25 | + // computing/general preferences. |
|
| 26 | + if (!$saved_state) { |
|
| 27 | 27 | // Get BOINC project disk space configurations from config.xml to |
| 28 | 28 | // fill in initial preference values. |
| 29 | 29 | require_boinc(array('db', 'prefs')); |
@@ -160,88 +160,88 @@ discard block |
||
| 160 | 160 | <dont_verify_images>0</dont_verify_images> |
| 161 | 161 | </preset> |
| 162 | 162 | </general_preferences>'; |
| 163 | - } |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | - // Convert XML data to array format |
|
| 166 | - $preset_prefs = load_configuration($saved_state); |
|
| 165 | + // Convert XML data to array format |
|
| 166 | + $preset_prefs = load_configuration($saved_state); |
|
| 167 | 167 | |
| 168 | - if ($preset) { |
|
| 168 | + if ($preset) { |
|
| 169 | 169 | // Load preset from configuration |
| 170 | 170 | $preset_prefs = (array) $preset_prefs['general_preferences']; |
| 171 | 171 | if (isset($preset_prefs['preset'])) { |
| 172 | - if (!is_numeric(key($preset_prefs['preset']))) { |
|
| 172 | + if (!is_numeric(key($preset_prefs['preset']))) { |
|
| 173 | 173 | $preset_prefs['preset'] = array($preset_prefs['preset']); |
| 174 | - } |
|
| 175 | - foreach ($preset_prefs['preset'] as $key => $prefs) { |
|
| 174 | + } |
|
| 175 | + foreach ($preset_prefs['preset'] as $key => $prefs) { |
|
| 176 | 176 | if (isset($prefs['@attributes']['name']) AND $prefs['@attributes']['name'] == $preset) { |
| 177 | - return $preset_prefs['preset'][$key]; |
|
| 177 | + return $preset_prefs['preset'][$key]; |
|
| 178 | + } |
|
| 178 | 179 | } |
| 179 | - } |
|
| 180 | 180 | } |
| 181 | - } |
|
| 182 | - return $preset_prefs; |
|
| 181 | + } |
|
| 182 | + return $preset_prefs; |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | /** |
| 186 | 186 | * Load (and validate) the project specific configuration XML |
| 187 | 187 | */ |
| 188 | 188 | function boincwork_get_project_specific_config() { |
| 189 | - $raw_config_data = variable_get('boinc_project_specific_prefs_config', ''); |
|
| 189 | + $raw_config_data = variable_get('boinc_project_specific_prefs_config', ''); |
|
| 190 | 190 | |
| 191 | - $xsd = './' . drupal_get_path('module', 'boincwork') . '/includes/projectprefs.xsd'; |
|
| 192 | - libxml_use_internal_errors(true); |
|
| 191 | + $xsd = './' . drupal_get_path('module', 'boincwork') . '/includes/projectprefs.xsd'; |
|
| 192 | + libxml_use_internal_errors(true); |
|
| 193 | 193 | |
| 194 | - $xml = new DomDocument(); |
|
| 195 | - $xml->loadXML($raw_config_data, LIBXML_NOBLANKS); |
|
| 196 | - if (!$xml->schemaValidate($xsd)) { |
|
| 194 | + $xml = new DomDocument(); |
|
| 195 | + $xml->loadXML($raw_config_data, LIBXML_NOBLANKS); |
|
| 196 | + if (!$xml->schemaValidate($xsd)) { |
|
| 197 | 197 | $errors = libxml_get_errors(); |
| 198 | 198 | $lines = explode("\r", $raw_config_data); |
| 199 | 199 | drupal_set_message("{$errors[0]->message} at line {$errors[0]->line}" . |
| 200 | - ': <br/>' . htmlentities($lines[$errors[0]->line - 1]), 'error'); |
|
| 200 | + ': <br/>' . htmlentities($lines[$errors[0]->line - 1]), 'error'); |
|
| 201 | 201 | return NULL; |
| 202 | - } |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | - // Convert XML to array for validation |
|
| 205 | - $xml = load_configuration($raw_config_data); |
|
| 206 | - return $xml; |
|
| 204 | + // Convert XML to array for validation |
|
| 205 | + $xml = load_configuration($raw_config_data); |
|
| 206 | + return $xml; |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | /** |
| 210 | 210 | * Get rules by which to validate project specific data |
| 211 | 211 | */ |
| 212 | 212 | function boincwork_get_project_specific_config_validation_rules($xml = array()) { |
| 213 | - $rules = array(); |
|
| 214 | - if (!$xml) { |
|
| 213 | + $rules = array(); |
|
| 214 | + if (!$xml) { |
|
| 215 | 215 | // Read the config XML |
| 216 | 216 | $xml = boincwork_get_project_specific_config(); |
| 217 | 217 | $xml = $xml['project_specific_preferences']; |
| 218 | - } |
|
| 219 | - foreach ($xml as $type => $elements) { |
|
| 218 | + } |
|
| 219 | + foreach ($xml as $type => $elements) { |
|
| 220 | 220 | if (is_array($elements) AND !is_numeric(key($elements))) { |
| 221 | - $elements = array($elements); |
|
| 221 | + $elements = array($elements); |
|
| 222 | 222 | } |
| 223 | 223 | switch ($type) { |
| 224 | 224 | case 'compound': |
| 225 | 225 | foreach ($elements as $element) { |
| 226 | 226 | $name = $element['@attributes']['name']; |
| 227 | 227 | $rules[$name] = boincwork_get_project_specific_config_validation_rules($element['attributes']); |
| 228 | - } |
|
| 229 | - break; |
|
| 228 | + } |
|
| 229 | + break; |
|
| 230 | 230 | |
| 231 | 231 | case 'text': |
| 232 | 232 | foreach ($elements as $element) { |
| 233 | 233 | $name = $element['@attributes']['name']; |
| 234 | 234 | $rules[$name] = array( |
| 235 | - 'datatype' => $element['@attributes']['datatype'] |
|
| 235 | + 'datatype' => $element['@attributes']['datatype'] |
|
| 236 | 236 | ); |
| 237 | 237 | if (isset($element['@attributes']['min'])) { |
| 238 | - $rules[$name]['min'] = $element['@attributes']['min']; |
|
| 238 | + $rules[$name]['min'] = $element['@attributes']['min']; |
|
| 239 | 239 | } |
| 240 | 240 | if (isset($element['@attributes']['max'])) { |
| 241 | - $rules[$name]['max'] = $element['@attributes']['max']; |
|
| 241 | + $rules[$name]['max'] = $element['@attributes']['max']; |
|
| 242 | 242 | } |
| 243 | - } |
|
| 244 | - break; |
|
| 243 | + } |
|
| 244 | + break; |
|
| 245 | 245 | /* |
| 246 | 246 | case 'radio': |
| 247 | 247 | case 'dropdown': |
@@ -265,24 +265,24 @@ discard block |
||
| 265 | 265 | $rules['apps'] = array( |
| 266 | 266 | 'minimum selected' => 1, |
| 267 | 267 | 'list' => array() |
| 268 | - ); |
|
| 269 | - foreach ($elements as $element) { |
|
| 268 | + ); |
|
| 269 | + foreach ($elements as $element) { |
|
| 270 | 270 | foreach ($element['app'] as $app) { |
| 271 | - $name = "app_{$app['@attributes']['id']}"; |
|
| 272 | - $rules['apps']['list'][] = $name; |
|
| 273 | - //$rules[$name] = array( |
|
| 274 | - // 'options' => $options |
|
| 275 | - //); |
|
| 271 | + $name = "app_{$app['@attributes']['id']}"; |
|
| 272 | + $rules['apps']['list'][] = $name; |
|
| 273 | + //$rules[$name] = array( |
|
| 274 | + // 'options' => $options |
|
| 275 | + //); |
|
| 276 | 276 | } |
| 277 | - } |
|
| 278 | - break; |
|
| 277 | + } |
|
| 278 | + break; |
|
| 279 | 279 | |
| 280 | 280 | case 'group': |
| 281 | 281 | foreach ($elements as $element) { |
| 282 | 282 | $name = $element['@attributes']['name']; |
| 283 | 283 | $rules += boincwork_get_project_specific_config_validation_rules($element); |
| 284 | - } |
|
| 285 | - break; |
|
| 284 | + } |
|
| 285 | + break; |
|
| 286 | 286 | /* |
| 287 | 287 | case 'boolean': |
| 288 | 288 | // Shouldn't need to validate boolean... |
@@ -290,39 +290,39 @@ discard block |
||
| 290 | 290 | */ |
| 291 | 291 | default: |
| 292 | 292 | } |
| 293 | - } |
|
| 294 | - return $rules; |
|
| 293 | + } |
|
| 294 | + return $rules; |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | /** |
| 298 | 298 | * Define how project specific settings should be saved |
| 299 | 299 | */ |
| 300 | 300 | function boincwork_format_project_specific_prefs_data($values, $xml = array()) { |
| 301 | - $defaults = array(); |
|
| 302 | - if (!$xml) { |
|
| 301 | + $defaults = array(); |
|
| 302 | + if (!$xml) { |
|
| 303 | 303 | // Read the config XML |
| 304 | 304 | $xml = boincwork_get_project_specific_config(); |
| 305 | 305 | $xml = $xml['project_specific_preferences']; |
| 306 | - } |
|
| 307 | - foreach ($xml as $type => $elements) { |
|
| 306 | + } |
|
| 307 | + foreach ($xml as $type => $elements) { |
|
| 308 | 308 | $structure_data = array(); |
| 309 | 309 | if (is_array($elements) AND !is_numeric(key($elements))) { |
| 310 | - $elements = array($elements); |
|
| 310 | + $elements = array($elements); |
|
| 311 | 311 | } |
| 312 | 312 | switch ($type) { |
| 313 | 313 | case 'compound': |
| 314 | 314 | foreach ($elements as $element) { |
| 315 | 315 | $name = $element['@attributes']['name']; |
| 316 | 316 | $default[$name]['@attributes'] = boincwork_format_project_specific_prefs_data($values[$name], $element['attributes']); |
| 317 | - } |
|
| 318 | - $defaults += $default; |
|
| 319 | - break; |
|
| 317 | + } |
|
| 318 | + $defaults += $default; |
|
| 319 | + break; |
|
| 320 | 320 | |
| 321 | 321 | case 'group': |
| 322 | 322 | foreach ($elements as $element) { |
| 323 | 323 | $defaults += boincwork_format_project_specific_prefs_data($values, $element); |
| 324 | - } |
|
| 325 | - break; |
|
| 324 | + } |
|
| 325 | + break; |
|
| 326 | 326 | |
| 327 | 327 | case 'text': |
| 328 | 328 | case 'radio': |
@@ -331,315 +331,315 @@ discard block |
||
| 331 | 331 | foreach ($elements as $element) { |
| 332 | 332 | $name = $element['@attributes']['name']; |
| 333 | 333 | if (isset($element['@attributes']['entitytype']) AND $element['@attributes']['entitytype'] == 'attribute') { |
| 334 | - $defaults['@attributes'][$name] = $values[$name]; |
|
| 334 | + $defaults['@attributes'][$name] = $values[$name]; |
|
| 335 | 335 | } |
| 336 | 336 | else { |
| 337 | - $defaults[$name] = $values[$name]; |
|
| 337 | + $defaults[$name] = $values[$name]; |
|
| 338 | 338 | } |
| 339 | - } |
|
| 340 | - break; |
|
| 339 | + } |
|
| 340 | + break; |
|
| 341 | 341 | |
| 342 | 342 | case 'apps': |
| 343 | 343 | foreach ($elements as $element) { |
| 344 | 344 | $defaults['app_id'] = array(); |
| 345 | 345 | foreach ($element['app'] as $app) { |
| 346 | - $app_id = $app['@attributes']['id']; |
|
| 347 | - if ($values['applications']["app_{$app_id}"]) { |
|
| 346 | + $app_id = $app['@attributes']['id']; |
|
| 347 | + if ($values['applications']["app_{$app_id}"]) { |
|
| 348 | 348 | $defaults['app_id'][] = $app_id; |
| 349 | - } |
|
| 349 | + } |
|
| 350 | 350 | } |
| 351 | - } |
|
| 352 | - break; |
|
| 351 | + } |
|
| 352 | + break; |
|
| 353 | 353 | |
| 354 | 354 | default: |
| 355 | 355 | } |
| 356 | - } |
|
| 357 | - return $defaults; |
|
| 356 | + } |
|
| 357 | + return $defaults; |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | /** |
| 361 | 361 | * Add an element to the form based on its definition |
| 362 | 362 | */ |
| 363 | 363 | function boincwork_generate_prefs_element(&$form, $type, $elements, $user_prefs = null) { |
| 364 | - switch ($type) { |
|
| 365 | - case 'text': |
|
| 364 | + switch ($type) { |
|
| 365 | + case 'text': |
|
| 366 | 366 | if (!is_numeric(key($elements))) { |
| 367 | - $elements = array($elements); |
|
| 367 | + $elements = array($elements); |
|
| 368 | 368 | } |
| 369 | 369 | foreach ($elements as $element) { |
| 370 | - $name = $element['@attributes']['name']; |
|
| 371 | - $default = $element['@attributes']['default']; |
|
| 372 | - $title = is_array($element['title']) ? $element['title']['@value'] : $element['title']; |
|
| 373 | - $description = ''; |
|
| 374 | - if (isset($element['description'])) { |
|
| 370 | + $name = $element['@attributes']['name']; |
|
| 371 | + $default = $element['@attributes']['default']; |
|
| 372 | + $title = is_array($element['title']) ? $element['title']['@value'] : $element['title']; |
|
| 373 | + $description = ''; |
|
| 374 | + if (isset($element['description'])) { |
|
| 375 | 375 | $description = is_array($element['description']) ? $element['description']['@value'] : $element['description']; |
| 376 | - } |
|
| 376 | + } |
|
| 377 | 377 | |
| 378 | - $value = $default; |
|
| 379 | - $user_pref = $user_prefs; |
|
| 380 | - $entitytype = isset($element['@attributes']['entitytype']) ? $element['@attributes']['entitytype'] : 'element'; |
|
| 381 | - if ($entitytype == 'attribute') { |
|
| 378 | + $value = $default; |
|
| 379 | + $user_pref = $user_prefs; |
|
| 380 | + $entitytype = isset($element['@attributes']['entitytype']) ? $element['@attributes']['entitytype'] : 'element'; |
|
| 381 | + if ($entitytype == 'attribute') { |
|
| 382 | 382 | $user_pref = $user_prefs['@attributes']; |
| 383 | - } |
|
| 384 | - if (isset($user_pref[$name])) { |
|
| 383 | + } |
|
| 384 | + if (isset($user_pref[$name])) { |
|
| 385 | 385 | if (is_array($user_pref[$name]) AND isset($user_pref[$name]['@value'])) { |
| 386 | - $value = $user_pref[$name]['@value']; |
|
| 386 | + $value = $user_pref[$name]['@value']; |
|
| 387 | 387 | } |
| 388 | 388 | else { |
| 389 | - $value = $user_pref[$name]; |
|
| 389 | + $value = $user_pref[$name]; |
|
| 390 | + } |
|
| 390 | 391 | } |
| 391 | - } |
|
| 392 | 392 | |
| 393 | - // Use appropriate datatype |
|
| 394 | - if (isset($element['@attributes']['datatype'])) { |
|
| 393 | + // Use appropriate datatype |
|
| 394 | + if (isset($element['@attributes']['datatype'])) { |
|
| 395 | 395 | switch($element['@attributes']['datatype']) { |
| 396 | 396 | case 'integer': |
| 397 | 397 | $value = (int) $value; |
| 398 | - break; |
|
| 398 | + break; |
|
| 399 | 399 | |
| 400 | 400 | case 'float': |
| 401 | 401 | $value = number_format((float) $value, 2); |
| 402 | - break; |
|
| 402 | + break; |
|
| 403 | 403 | |
| 404 | 404 | default: |
| 405 | 405 | } |
| 406 | - } |
|
| 406 | + } |
|
| 407 | 407 | |
| 408 | - // Translate elements as appropriate |
|
| 409 | - if ($title) { |
|
| 408 | + // Translate elements as appropriate |
|
| 409 | + if ($title) { |
|
| 410 | 410 | i18nstrings_update('project:prefs_xml', _boinctranslate_supertrim($title)); |
| 411 | 411 | $title = i18nstrings('project:prefs_xml', _boinctranslate_supertrim($title)); |
| 412 | - } |
|
| 413 | - if ($description) { |
|
| 412 | + } |
|
| 413 | + if ($description) { |
|
| 414 | 414 | i18nstrings_update('project:prefs_xml', _boinctranslate_supertrim($description)); |
| 415 | 415 | $description = i18nstrings('project:prefs_xml', _boinctranslate_supertrim($description)); |
| 416 | - } |
|
| 416 | + } |
|
| 417 | 417 | |
| 418 | - $form[$name] = array( |
|
| 418 | + $form[$name] = array( |
|
| 419 | 419 | '#title' => $title, |
| 420 | 420 | '#type' => 'textfield', |
| 421 | 421 | '#default_value' => $value, |
| 422 | 422 | '#size' => 5, |
| 423 | 423 | '#description' => $description . bts(' Default value: @default', array('@default' => $default), NULL, 'boinc:account-preferences-project') |
| 424 | - ); |
|
| 424 | + ); |
|
| 425 | 425 | } |
| 426 | 426 | break; |
| 427 | 427 | |
| 428 | - case 'boolean': |
|
| 428 | + case 'boolean': |
|
| 429 | 429 | if (!is_numeric(key($elements))) { |
| 430 | - $elements = array($elements); |
|
| 430 | + $elements = array($elements); |
|
| 431 | 431 | } |
| 432 | 432 | foreach ($elements as $element) { |
| 433 | - $name = $element['@attributes']['name']; |
|
| 434 | - $title = is_array($element['title']) ? $element['title']['@value'] : $element['title']; |
|
| 435 | - $default = (isset($element['@attributes']['selected']) AND $element['@attributes']['selected'] == 'true') ? 1 : 0; |
|
| 436 | - $description = ''; |
|
| 437 | - if (isset($element['description'])) { |
|
| 433 | + $name = $element['@attributes']['name']; |
|
| 434 | + $title = is_array($element['title']) ? $element['title']['@value'] : $element['title']; |
|
| 435 | + $default = (isset($element['@attributes']['selected']) AND $element['@attributes']['selected'] == 'true') ? 1 : 0; |
|
| 436 | + $description = ''; |
|
| 437 | + if (isset($element['description'])) { |
|
| 438 | 438 | $description = is_array($element['description']) ? $element['description']['@value'] : $element['description']; |
| 439 | - } |
|
| 439 | + } |
|
| 440 | 440 | |
| 441 | - $value = $default; |
|
| 442 | - $user_pref = $user_prefs; |
|
| 443 | - $entitytype = isset($element['@attributes']['entitytype']) ? $element['@attributes']['entitytype'] : 'element'; |
|
| 444 | - if ($entitytype == 'attribute') { |
|
| 441 | + $value = $default; |
|
| 442 | + $user_pref = $user_prefs; |
|
| 443 | + $entitytype = isset($element['@attributes']['entitytype']) ? $element['@attributes']['entitytype'] : 'element'; |
|
| 444 | + if ($entitytype == 'attribute') { |
|
| 445 | 445 | $user_pref = $user_prefs['@attributes']; |
| 446 | - } |
|
| 447 | - if (isset($user_pref[$name])) { |
|
| 446 | + } |
|
| 447 | + if (isset($user_pref[$name])) { |
|
| 448 | 448 | if (is_array($user_pref[$name]) AND isset($user_pref[$name]['@value'])) { |
| 449 | - $value = $user_pref[$name]['@value']; |
|
| 449 | + $value = $user_pref[$name]['@value']; |
|
| 450 | 450 | } |
| 451 | 451 | else { |
| 452 | - $value = $user_pref[$name]; |
|
| 452 | + $value = $user_pref[$name]; |
|
| 453 | + } |
|
| 453 | 454 | } |
| 454 | - } |
|
| 455 | 455 | |
| 456 | - // Translate elements as appropriate |
|
| 457 | - if ($title) { |
|
| 456 | + // Translate elements as appropriate |
|
| 457 | + if ($title) { |
|
| 458 | 458 | i18nstrings_update('project:prefs_xml', _boinctranslate_supertrim($title)); |
| 459 | 459 | $title = i18nstrings('project:prefs_xml', _boinctranslate_supertrim($title)); |
| 460 | - } |
|
| 461 | - if ($description) { |
|
| 460 | + } |
|
| 461 | + if ($description) { |
|
| 462 | 462 | i18nstrings_update('project:prefs_xml', _boinctranslate_supertrim($description)); |
| 463 | 463 | $description = i18nstrings('project:prefs_xml', _boinctranslate_supertrim($description)); |
| 464 | - } |
|
| 464 | + } |
|
| 465 | 465 | |
| 466 | - $form[$name] = array( |
|
| 466 | + $form[$name] = array( |
|
| 467 | 467 | '#title' => $title, |
| 468 | 468 | '#type' => 'radios', |
| 469 | 469 | '#options' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')), |
| 470 | 470 | '#attributes' => array('class' => 'fancy'), |
| 471 | 471 | '#default_value' => $value, |
| 472 | 472 | '#description' => $description |
| 473 | - ); |
|
| 473 | + ); |
|
| 474 | 474 | } |
| 475 | 475 | break; |
| 476 | 476 | |
| 477 | - case 'radio': |
|
| 477 | + case 'radio': |
|
| 478 | 478 | case 'dropdown': |
| 479 | 479 | |
| 480 | 480 | if (!is_numeric(key($elements))) { |
| 481 | - $elements = array($elements); |
|
| 481 | + $elements = array($elements); |
|
| 482 | 482 | } |
| 483 | 483 | foreach ($elements as $element) { |
| 484 | - $name = $element['@attributes']['name']; |
|
| 485 | - $default = null; |
|
| 486 | - $options = array(); |
|
| 487 | - foreach($element['items']['item'] as $item) { |
|
| 484 | + $name = $element['@attributes']['name']; |
|
| 485 | + $default = null; |
|
| 486 | + $options = array(); |
|
| 487 | + foreach($element['items']['item'] as $item) { |
|
| 488 | 488 | if (is_array($item)) { |
| 489 | - $value = $item['@value']; |
|
| 490 | - if ($default === NULL AND |
|
| 489 | + $value = $item['@value']; |
|
| 490 | + if ($default === NULL AND |
|
| 491 | 491 | isset($item['@attributes']) AND |
| 492 | 492 | isset($item['@attributes']['selected'])) { |
| 493 | 493 | $default = ($item['@attributes']['selected'] == 'true') ? $item['@value'] : null; |
| 494 | - } |
|
| 494 | + } |
|
| 495 | 495 | } |
| 496 | 496 | else { |
| 497 | - $value = $item; |
|
| 497 | + $value = $item; |
|
| 498 | 498 | } |
| 499 | 499 | $options[$value] = $value; |
| 500 | - } |
|
| 501 | - $title = is_array($element['title']) ? $element['title']['@value'] : $element['title']; |
|
| 502 | - $description = ''; |
|
| 503 | - if (isset($element['description'])) { |
|
| 500 | + } |
|
| 501 | + $title = is_array($element['title']) ? $element['title']['@value'] : $element['title']; |
|
| 502 | + $description = ''; |
|
| 503 | + if (isset($element['description'])) { |
|
| 504 | 504 | $description = is_array($element['description']) ? $element['description']['@value'] : $element['description']; |
| 505 | - } |
|
| 506 | - $user_pref = $user_prefs; |
|
| 507 | - $entitytype = isset($element['@attributes']['entitytype']) ? $element['@attributes']['entitytype'] : 'element'; |
|
| 508 | - if ($entitytype == 'attribute') { |
|
| 505 | + } |
|
| 506 | + $user_pref = $user_prefs; |
|
| 507 | + $entitytype = isset($element['@attributes']['entitytype']) ? $element['@attributes']['entitytype'] : 'element'; |
|
| 508 | + if ($entitytype == 'attribute') { |
|
| 509 | 509 | $user_pref = $user_prefs['@attributes']; |
| 510 | - } |
|
| 511 | - $value = isset($user_pref[$name]) ? $user_pref[$name] : $default; |
|
| 510 | + } |
|
| 511 | + $value = isset($user_pref[$name]) ? $user_pref[$name] : $default; |
|
| 512 | 512 | |
| 513 | - // Translate elements as appropriate |
|
| 514 | - if ($title) { |
|
| 513 | + // Translate elements as appropriate |
|
| 514 | + if ($title) { |
|
| 515 | 515 | i18nstrings_update('project:prefs_xml', _boinctranslate_supertrim($title)); |
| 516 | 516 | $title = i18nstrings('project:prefs_xml', _boinctranslate_supertrim($title)); |
| 517 | - } |
|
| 518 | - if ($description) { |
|
| 517 | + } |
|
| 518 | + if ($description) { |
|
| 519 | 519 | i18nstrings_update('project:prefs_xml', _boinctranslate_supertrim($description)); |
| 520 | 520 | $description = i18nstrings('project:prefs_xml', _boinctranslate_supertrim($description)); |
| 521 | - } |
|
| 521 | + } |
|
| 522 | 522 | |
| 523 | - $form[$name] = array( |
|
| 523 | + $form[$name] = array( |
|
| 524 | 524 | '#title' => $title, |
| 525 | 525 | '#type' => ($type == 'radio') ? 'radios' : 'select', |
| 526 | 526 | '#options' => $options, |
| 527 | 527 | '#attributes' => array('class' => 'fancy'), |
| 528 | 528 | '#default_value' => $value, |
| 529 | 529 | '#description' => $description . bts(' Default value: @default', array('@default' =>$default), NULL, 'boinc:account-preferences-project') |
| 530 | - ); |
|
| 530 | + ); |
|
| 531 | 531 | } |
| 532 | 532 | break; |
| 533 | 533 | |
| 534 | - case 'apps': |
|
| 534 | + case 'apps': |
|
| 535 | 535 | $title = is_array($elements['title']) ? $elements['title']['@value'] : $elements['title']; |
| 536 | 536 | |
| 537 | - // Translate elements as appropriate |
|
| 538 | - if ($title) { |
|
| 537 | + // Translate elements as appropriate |
|
| 538 | + if ($title) { |
|
| 539 | 539 | i18nstrings_update('project:prefs_xml', _boinctranslate_supertrim($title)); |
| 540 | 540 | $title = i18nstrings('project:prefs_xml', _boinctranslate_supertrim($title)); |
| 541 | - } |
|
| 541 | + } |
|
| 542 | 542 | |
| 543 | 543 | $form['applications'] = array( |
| 544 | - '#title' => bts('Applications', array(), NULL, 'boinc:account-preferences'), |
|
| 545 | - '#type' => 'fieldset', |
|
| 546 | - '#description' => $title, |
|
| 547 | - '#collapsible' => TRUE, |
|
| 548 | - '#collapsed' => FALSE |
|
| 544 | + '#title' => bts('Applications', array(), NULL, 'boinc:account-preferences'), |
|
| 545 | + '#type' => 'fieldset', |
|
| 546 | + '#description' => $title, |
|
| 547 | + '#collapsible' => TRUE, |
|
| 548 | + '#collapsed' => FALSE |
|
| 549 | 549 | ); |
| 550 | 550 | $applications = array(); |
| 551 | 551 | if (!is_array($user_prefs['app_id'])) { |
| 552 | - $user_prefs['app_id'] = array($user_prefs['app_id']); |
|
| 552 | + $user_prefs['app_id'] = array($user_prefs['app_id']); |
|
| 553 | 553 | } |
| 554 | 554 | foreach ($user_prefs['app_id'] as $app) { |
| 555 | - if (!$app) continue; |
|
| 556 | - if (is_array($app) AND isset($app['@value'])) { |
|
| 555 | + if (!$app) continue; |
|
| 556 | + if (is_array($app) AND isset($app['@value'])) { |
|
| 557 | 557 | $app = $app['@value']; |
| 558 | - } |
|
| 559 | - $applications[] = $app; |
|
| 558 | + } |
|
| 559 | + $applications[] = $app; |
|
| 560 | 560 | } |
| 561 | 561 | foreach ($elements['app'] as $app) { |
| 562 | - $app_id = $app['@attributes']['id']; |
|
| 563 | - $app_name = $app['@value']; |
|
| 564 | - $app_enabled = TRUE; |
|
| 565 | - if (isset($app['@attributes']['enabled']) AND |
|
| 562 | + $app_id = $app['@attributes']['id']; |
|
| 563 | + $app_name = $app['@value']; |
|
| 564 | + $app_enabled = TRUE; |
|
| 565 | + if (isset($app['@attributes']['enabled']) AND |
|
| 566 | 566 | $app['@attributes']['enabled'] == 'false') { |
| 567 | 567 | $app_enabled = FALSE; |
| 568 | - } |
|
| 569 | - if ($applications) { |
|
| 568 | + } |
|
| 569 | + if ($applications) { |
|
| 570 | 570 | $checked = in_array($app_id, $applications); |
| 571 | - } else { |
|
| 571 | + } else { |
|
| 572 | 572 | $checked = TRUE; |
| 573 | 573 | if (isset($app['@attributes']['selected']) AND |
| 574 | 574 | $app['@attributes']['selected'] == 'false') { |
| 575 | - $checked = FALSE; |
|
| 575 | + $checked = FALSE; |
|
| 576 | 576 | } |
| 577 | - } |
|
| 578 | - $form['applications']["app_{$app_id}"] = array( |
|
| 577 | + } |
|
| 578 | + $form['applications']["app_{$app_id}"] = array( |
|
| 579 | 579 | '#title' => $app_name, |
| 580 | 580 | '#type' => 'checkbox', |
| 581 | 581 | '#default_value' => ($checked) ? 'x' : false, |
| 582 | 582 | '#disabled' => !$app_enabled |
| 583 | - ); |
|
| 583 | + ); |
|
| 584 | 584 | } |
| 585 | 585 | |
| 586 | 586 | break; |
| 587 | 587 | |
| 588 | - case 'group': |
|
| 588 | + case 'group': |
|
| 589 | 589 | if (!is_numeric(key($elements))) { |
| 590 | - $elements = array($elements); |
|
| 590 | + $elements = array($elements); |
|
| 591 | 591 | } |
| 592 | 592 | foreach ($elements as $key => $element) { |
| 593 | - $title = is_array($element['title']) ? $element['title']['@value'] : $element['title']; |
|
| 594 | - $name = str_replace(' ','_',strtolower($title)); |
|
| 595 | - $name = "group_{$name}"; |
|
| 593 | + $title = is_array($element['title']) ? $element['title']['@value'] : $element['title']; |
|
| 594 | + $name = str_replace(' ','_',strtolower($title)); |
|
| 595 | + $name = "group_{$name}"; |
|
| 596 | 596 | |
| 597 | - // Translate elements as appropriate |
|
| 598 | - if ($title) { |
|
| 597 | + // Translate elements as appropriate |
|
| 598 | + if ($title) { |
|
| 599 | 599 | i18nstrings_update('project:prefs_xml', _boinctranslate_supertrim($title)); |
| 600 | 600 | $title = i18nstrings('project:prefs_xml', _boinctranslate_supertrim($title)); |
| 601 | - } |
|
| 601 | + } |
|
| 602 | 602 | |
| 603 | - $form[$name] = array( |
|
| 604 | - '#title' => $title, |
|
| 605 | - '#type' => 'fieldset', |
|
| 606 | - '#tree' => FALSE, |
|
| 607 | - //'#description' => t('Notes about this group of fields'), |
|
| 608 | - '#collapsible' => TRUE, |
|
| 609 | - '#collapsed' => FALSE |
|
| 610 | - ); |
|
| 611 | - // Recursively populate the compound element |
|
| 612 | - foreach ($element as $child_type => $child) { |
|
| 603 | + $form[$name] = array( |
|
| 604 | + '#title' => $title, |
|
| 605 | + '#type' => 'fieldset', |
|
| 606 | + '#tree' => FALSE, |
|
| 607 | + //'#description' => t('Notes about this group of fields'), |
|
| 608 | + '#collapsible' => TRUE, |
|
| 609 | + '#collapsed' => FALSE |
|
| 610 | + ); |
|
| 611 | + // Recursively populate the compound element |
|
| 612 | + foreach ($element as $child_type => $child) { |
|
| 613 | 613 | boincwork_generate_prefs_element($form[$name], $child_type, $child, $user_prefs); |
| 614 | - } |
|
| 614 | + } |
|
| 615 | 615 | } |
| 616 | 616 | break; |
| 617 | 617 | |
| 618 | - case 'compound': |
|
| 618 | + case 'compound': |
|
| 619 | 619 | if (!is_numeric(key($elements))) { |
| 620 | - $elements = array($elements); |
|
| 620 | + $elements = array($elements); |
|
| 621 | 621 | } |
| 622 | 622 | foreach ($elements as $element) { |
| 623 | - $name = $element['@attributes']['name']; |
|
| 624 | - $title = is_array($element['title']) ? $element['title']['@value'] : $element['title']; |
|
| 623 | + $name = $element['@attributes']['name']; |
|
| 624 | + $title = is_array($element['title']) ? $element['title']['@value'] : $element['title']; |
|
| 625 | 625 | |
| 626 | - // Translate elements as appropriate |
|
| 627 | - if ($title) { |
|
| 626 | + // Translate elements as appropriate |
|
| 627 | + if ($title) { |
|
| 628 | 628 | i18nstrings_update('project:prefs_xml', _boinctranslate_supertrim($title)); |
| 629 | 629 | $title = i18nstrings('project:prefs_xml', _boinctranslate_supertrim($title)); |
| 630 | - } |
|
| 630 | + } |
|
| 631 | 631 | |
| 632 | - $form[$name] = array( |
|
| 633 | - '#title' => $title, |
|
| 634 | - '#type' => 'fieldset', |
|
| 635 | - //'#description' => t('Notes about this group of fields'), |
|
| 636 | - '#collapsible' => TRUE, |
|
| 637 | - '#collapsed' => FALSE |
|
| 638 | - ); |
|
| 639 | - // Recursively populate the compound element |
|
| 640 | - foreach ($element['attributes'] as $child_type => $child) { |
|
| 632 | + $form[$name] = array( |
|
| 633 | + '#title' => $title, |
|
| 634 | + '#type' => 'fieldset', |
|
| 635 | + //'#description' => t('Notes about this group of fields'), |
|
| 636 | + '#collapsible' => TRUE, |
|
| 637 | + '#collapsed' => FALSE |
|
| 638 | + ); |
|
| 639 | + // Recursively populate the compound element |
|
| 640 | + foreach ($element['attributes'] as $child_type => $child) { |
|
| 641 | 641 | boincwork_generate_prefs_element($form[$name], $child_type, $child, $user_prefs[$name]['@attributes']); |
| 642 | - } |
|
| 642 | + } |
|
| 643 | 643 | } |
| 644 | 644 | break; |
| 645 | 645 | |
@@ -655,24 +655,24 @@ discard block |
||
| 655 | 655 | */ |
| 656 | 656 | function boincwork_make_prefs_table($prefs, $top_level = TRUE) { |
| 657 | 657 | |
| 658 | - $prefs_table = array(); |
|
| 659 | - $uncategorized = array(); |
|
| 658 | + $prefs_table = array(); |
|
| 659 | + $uncategorized = array(); |
|
| 660 | 660 | |
| 661 | - // Parse the project preferences form |
|
| 662 | - foreach ($prefs as $key => $element) { |
|
| 661 | + // Parse the project preferences form |
|
| 662 | + foreach ($prefs as $key => $element) { |
|
| 663 | 663 | |
| 664 | 664 | // Determine which type of element this is and act accordingly |
| 665 | 665 | $element_type = NULL; |
| 666 | 666 | if (is_array($element) AND isset($element['#type'])) { |
| 667 | - $element_type = $element['#type']; |
|
| 667 | + $element_type = $element['#type']; |
|
| 668 | 668 | } |
| 669 | 669 | switch ($element_type) { |
| 670 | 670 | case 'fieldset': |
| 671 | 671 | $prefs_table[$key] = array( |
| 672 | 672 | 'name' => $element['#title'], |
| 673 | 673 | 'elements' => boincwork_make_prefs_table($element, FALSE), |
| 674 | - ); |
|
| 675 | - break; |
|
| 674 | + ); |
|
| 675 | + break; |
|
| 676 | 676 | case 'textfield': |
| 677 | 677 | case 'radios': |
| 678 | 678 | case 'checkbox': |
@@ -682,45 +682,45 @@ discard block |
||
| 682 | 682 | switch ($key) { |
| 683 | 683 | case 'start_hour': |
| 684 | 684 | $element['#title'] = bts('Compute only between:', array(), NULL, 'boinc:account-preferences-computing'); |
| 685 | - break; |
|
| 685 | + break; |
|
| 686 | 686 | case 'net_start_hour': |
| 687 | 687 | $element['#title'] = bts('Transfer files only between:', array(), NULL, 'boinc:account-preferences-comuting'); |
| 688 | - break; |
|
| 688 | + break; |
|
| 689 | 689 | default: |
| 690 | 690 | } |
| 691 | - } |
|
| 692 | - $prefs_element = array( |
|
| 691 | + } |
|
| 692 | + $prefs_element = array( |
|
| 693 | 693 | 'name' => (isset($element['#title'])) ? $element['#title'] : '', |
| 694 | 694 | 'description' => (isset($element['#description'])) ? $element['#description'] : '', |
| 695 | 695 | 'default_value' => (isset($element['#default_value'])) ? $element['#default_value'] : NULL, |
| 696 | - ); |
|
| 697 | - if ($top_level) { |
|
| 696 | + ); |
|
| 697 | + if ($top_level) { |
|
| 698 | 698 | $uncategorized[$key] = $prefs_element; |
| 699 | - } |
|
| 700 | - else { |
|
| 699 | + } |
|
| 700 | + else { |
|
| 701 | 701 | $prefs_table[$key] = $prefs_element; |
| 702 | - } |
|
| 703 | - break; |
|
| 702 | + } |
|
| 703 | + break; |
|
| 704 | 704 | default: |
| 705 | 705 | } |
| 706 | - } |
|
| 706 | + } |
|
| 707 | 707 | |
| 708 | - if ($prefs_table AND $uncategorized) { |
|
| 708 | + if ($prefs_table AND $uncategorized) { |
|
| 709 | 709 | // Throw any settings that don't fit elsewhere into "other" |
| 710 | 710 | $prefs_table['other'] = array( |
| 711 | - 'name' => bts('Other settings', array(), NULL, 'boinc:account-preferences'), |
|
| 712 | - 'elements' => $uncategorized, |
|
| 711 | + 'name' => bts('Other settings', array(), NULL, 'boinc:account-preferences'), |
|
| 712 | + 'elements' => $uncategorized, |
|
| 713 | 713 | ); |
| 714 | - } |
|
| 715 | - elseif ($uncategorized) { |
|
| 714 | + } |
|
| 715 | + elseif ($uncategorized) { |
|
| 716 | 716 | // If nothing is categorized, output all prefs under a general "settings" |
| 717 | 717 | $prefs_table['settings'] = array( |
| 718 | - 'name' => bts('Settings', array(), NULL, 'boinc:account-preferences'), |
|
| 719 | - 'elements' => $uncategorized, |
|
| 718 | + 'name' => bts('Settings', array(), NULL, 'boinc:account-preferences'), |
|
| 719 | + 'elements' => $uncategorized, |
|
| 720 | 720 | ); |
| 721 | - } |
|
| 721 | + } |
|
| 722 | 722 | |
| 723 | - return $prefs_table; |
|
| 723 | + return $prefs_table; |
|
| 724 | 724 | } |
| 725 | 725 | |
| 726 | 726 | /** |
@@ -728,33 +728,33 @@ discard block |
||
| 728 | 728 | */ |
| 729 | 729 | function boincwork_load_prefs($type = 'general', $venue = null, $account = null) { |
| 730 | 730 | |
| 731 | - require_boinc(array('user')); |
|
| 731 | + require_boinc(array('user')); |
|
| 732 | 732 | |
| 733 | - // Load the BOINC user object |
|
| 734 | - if (!$account) { |
|
| 733 | + // Load the BOINC user object |
|
| 734 | + if (!$account) { |
|
| 735 | 735 | global $user; |
| 736 | 736 | $account = $user; |
| 737 | - } |
|
| 738 | - $account = user_load($account->uid); |
|
| 739 | - $boincuser = BoincUser::lookup_id($account->boincuser_id); |
|
| 737 | + } |
|
| 738 | + $account = user_load($account->uid); |
|
| 739 | + $boincuser = BoincUser::lookup_id($account->boincuser_id); |
|
| 740 | 740 | |
| 741 | - // Load the desired preferences for the user |
|
| 742 | - $main_prefs = array(); |
|
| 743 | - if ($type == 'project') { |
|
| 741 | + // Load the desired preferences for the user |
|
| 742 | + $main_prefs = array(); |
|
| 743 | + if ($type == 'project') { |
|
| 744 | 744 | if ($boincuser->project_prefs) { |
| 745 | - $main_prefs = load_configuration($boincuser->project_prefs); |
|
| 746 | - $main_prefs = (array) $main_prefs['project_preferences']; |
|
| 745 | + $main_prefs = load_configuration($boincuser->project_prefs); |
|
| 746 | + $main_prefs = (array) $main_prefs['project_preferences']; |
|
| 747 | 747 | } |
| 748 | - } |
|
| 749 | - else { |
|
| 748 | + } |
|
| 749 | + else { |
|
| 750 | 750 | if ($boincuser->global_prefs) { |
| 751 | - $main_prefs = load_configuration($boincuser->global_prefs); |
|
| 752 | - $main_prefs = (array) $main_prefs['global_preferences']; |
|
| 751 | + $main_prefs = load_configuration($boincuser->global_prefs); |
|
| 752 | + $main_prefs = (array) $main_prefs['global_preferences']; |
|
| 753 | + } |
|
| 753 | 754 | } |
| 754 | - } |
|
| 755 | 755 | |
| 756 | - // Return general preferences or a subset based on venue |
|
| 757 | - if (!$venue OR $venue == 'generic') { |
|
| 756 | + // Return general preferences or a subset based on venue |
|
| 757 | + if (!$venue OR $venue == 'generic') { |
|
| 758 | 758 | unset($main_prefs['venue']); |
| 759 | 759 | // Use the length of the $main_prefs array as a condition as to |
| 760 | 760 | // whether the preferences have already been set. This is |
@@ -762,23 +762,23 @@ discard block |
||
| 762 | 762 | if (count($main_prefs) < 3) |
| 763 | 763 | $main_prefs['@attributes'] = array('cleared' => 1); |
| 764 | 764 | return $main_prefs; |
| 765 | - } |
|
| 766 | - else { |
|
| 765 | + } |
|
| 766 | + else { |
|
| 767 | 767 | if (isset($main_prefs['venue'])) { |
| 768 | - if (!is_numeric(key($main_prefs['venue']))) { |
|
| 768 | + if (!is_numeric(key($main_prefs['venue']))) { |
|
| 769 | 769 | $main_prefs['venue'] = array($main_prefs['venue']); |
| 770 | - } |
|
| 771 | - foreach ($main_prefs['venue'] as $key => $prefs_venue) { |
|
| 770 | + } |
|
| 771 | + foreach ($main_prefs['venue'] as $key => $prefs_venue) { |
|
| 772 | 772 | if (isset($prefs_venue['@attributes']['name']) AND $prefs_venue['@attributes']['name'] == $venue) { |
| 773 | - return $main_prefs['venue'][$key]; |
|
| 773 | + return $main_prefs['venue'][$key]; |
|
| 774 | + } |
|
| 774 | 775 | } |
| 775 | - } |
|
| 776 | 776 | } |
| 777 | - } |
|
| 777 | + } |
|
| 778 | 778 | |
| 779 | - return array( |
|
| 779 | + return array( |
|
| 780 | 780 | '@attributes' => array('name' => $venue, 'cleared' => 1) |
| 781 | - ); |
|
| 781 | + ); |
|
| 782 | 782 | } |
| 783 | 783 | |
| 784 | 784 | /** |
@@ -786,104 +786,104 @@ discard block |
||
| 786 | 786 | */ |
| 787 | 787 | function boincwork_save_prefs($prefs, $type = 'general', $venue = null, $account = null) { |
| 788 | 788 | |
| 789 | - require_boinc(array('user')); |
|
| 789 | + require_boinc(array('user')); |
|
| 790 | 790 | |
| 791 | - // Load existing project prefs from the BOINC user object |
|
| 792 | - if (!$account) { |
|
| 791 | + // Load existing project prefs from the BOINC user object |
|
| 792 | + if (!$account) { |
|
| 793 | 793 | global $user; |
| 794 | 794 | $account = $user; |
| 795 | - } |
|
| 796 | - $account = user_load($account->uid); |
|
| 797 | - $boincuser = BoincUser::lookup_id($account->boincuser_id); |
|
| 795 | + } |
|
| 796 | + $account = user_load($account->uid); |
|
| 797 | + $boincuser = BoincUser::lookup_id($account->boincuser_id); |
|
| 798 | 798 | |
| 799 | - // Load the specified preferences for the user |
|
| 800 | - $main_prefs = array(); |
|
| 801 | - if ($type == 'project') { |
|
| 799 | + // Load the specified preferences for the user |
|
| 800 | + $main_prefs = array(); |
|
| 801 | + if ($type == 'project') { |
|
| 802 | 802 | if ($boincuser->project_prefs) { |
| 803 | - $main_prefs = load_configuration($boincuser->project_prefs); |
|
| 804 | - $main_prefs = (array) $main_prefs['project_preferences']; |
|
| 803 | + $main_prefs = load_configuration($boincuser->project_prefs); |
|
| 804 | + $main_prefs = (array) $main_prefs['project_preferences']; |
|
| 805 | 805 | } |
| 806 | - } |
|
| 807 | - else { |
|
| 806 | + } |
|
| 807 | + else { |
|
| 808 | 808 | if ($boincuser->global_prefs) { |
| 809 | - $main_prefs = load_configuration($boincuser->global_prefs); |
|
| 810 | - $main_prefs = (array) $main_prefs['global_preferences']; |
|
| 809 | + $main_prefs = load_configuration($boincuser->global_prefs); |
|
| 810 | + $main_prefs = (array) $main_prefs['global_preferences']; |
|
| 811 | + } |
|
| 811 | 812 | } |
| 812 | - } |
|
| 813 | 813 | |
| 814 | - // Save all preferences or a subset based on venue |
|
| 815 | - //drupal_set_message('<pre>' . print_r($main_prefs, true) . '</pre>'); |
|
| 816 | - $new_venue = true; |
|
| 817 | - if (!$venue OR $venue == 'generic') { |
|
| 814 | + // Save all preferences or a subset based on venue |
|
| 815 | + //drupal_set_message('<pre>' . print_r($main_prefs, true) . '</pre>'); |
|
| 816 | + $new_venue = true; |
|
| 817 | + if (!$venue OR $venue == 'generic') { |
|
| 818 | 818 | //$main_prefs = $prefs; |
| 819 | 819 | $main_prefs = $prefs + $main_prefs; |
| 820 | - } |
|
| 821 | - else { |
|
| 820 | + } |
|
| 821 | + else { |
|
| 822 | 822 | if (isset($main_prefs['venue'])) { |
| 823 | - if (!is_numeric(key($main_prefs['venue']))) { |
|
| 823 | + if (!is_numeric(key($main_prefs['venue']))) { |
|
| 824 | 824 | $main_prefs['venue'] = array($main_prefs['venue']); |
| 825 | - } |
|
| 826 | - foreach ($main_prefs['venue'] as $key => $prefs_venue) { |
|
| 825 | + } |
|
| 826 | + foreach ($main_prefs['venue'] as $key => $prefs_venue) { |
|
| 827 | 827 | if (isset($prefs_venue['@attributes']['name']) AND $prefs_venue['@attributes']['name'] == $venue) { |
| 828 | - if ($prefs) { |
|
| 828 | + if ($prefs) { |
|
| 829 | 829 | $main_prefs['venue'][$key] = $prefs; |
| 830 | - } |
|
| 831 | - else { |
|
| 830 | + } |
|
| 831 | + else { |
|
| 832 | 832 | // If prefs is null, clear out this preference set |
| 833 | 833 | unset($main_prefs['venue'][$key]); |
| 834 | 834 | if (count($main_prefs['venue']) == 0) { |
| 835 | - // If that was the only preference set configured, unset the |
|
| 836 | - // venue tag altogether |
|
| 837 | - unset($main_prefs['venue']); |
|
| 835 | + // If that was the only preference set configured, unset the |
|
| 836 | + // venue tag altogether |
|
| 837 | + unset($main_prefs['venue']); |
|
| 838 | 838 | } |
| 839 | - } |
|
| 840 | - $new_venue = false; |
|
| 841 | - break; |
|
| 839 | + } |
|
| 840 | + $new_venue = false; |
|
| 841 | + break; |
|
| 842 | + } |
|
| 842 | 843 | } |
| 843 | - } |
|
| 844 | 844 | } |
| 845 | 845 | if ($new_venue) { |
| 846 | - $main_prefs['venue'][] = $prefs; |
|
| 846 | + $main_prefs['venue'][] = $prefs; |
|
| 847 | + } |
|
| 847 | 848 | } |
| 848 | - } |
|
| 849 | 849 | |
| 850 | - // Set modified time |
|
| 851 | - if ($type == 'project') { |
|
| 850 | + // Set modified time |
|
| 851 | + if ($type == 'project') { |
|
| 852 | 852 | if (!isset($main_prefs['modified'])) { |
| 853 | - $main_prefs = array_merge(array('modified' => 0), $main_prefs); |
|
| 853 | + $main_prefs = array_merge(array('modified' => 0), $main_prefs); |
|
| 854 | 854 | } |
| 855 | 855 | $main_prefs['modified'] = time(); |
| 856 | - } else { |
|
| 856 | + } else { |
|
| 857 | 857 | if (!isset($main_prefs['mod_time'])) { |
| 858 | - $main_prefs = array_merge(array('mod_time' => 0), $main_prefs); |
|
| 858 | + $main_prefs = array_merge(array('mod_time' => 0), $main_prefs); |
|
| 859 | 859 | } |
| 860 | 860 | $main_prefs['mod_time'] = time(); |
| 861 | 861 | // unset source information, the Client will fill this in again |
| 862 | 862 | if (isset($main_prefs['source_project'])) { |
| 863 | - unset($main_prefs['source_project']); |
|
| 863 | + unset($main_prefs['source_project']); |
|
| 864 | 864 | } |
| 865 | 865 | if (isset($main_prefs['source_scheduler'])) { |
| 866 | - unset($main_prefs['source_scheduler']); |
|
| 866 | + unset($main_prefs['source_scheduler']); |
|
| 867 | + } |
|
| 867 | 868 | } |
| 868 | - } |
|
| 869 | 869 | |
| 870 | - // Convert prefs back to XML and save to database |
|
| 871 | - $result = null; |
|
| 872 | - if ($type == 'project') { |
|
| 870 | + // Convert prefs back to XML and save to database |
|
| 871 | + $result = null; |
|
| 872 | + if ($type == 'project') { |
|
| 873 | 873 | $main_prefs = array('project_preferences' => $main_prefs); |
| 874 | 874 | $boincuser->project_prefs = save_configuration($main_prefs); |
| 875 | 875 | db_set_active('boinc_rw'); |
| 876 | 876 | $result = db_query("UPDATE user SET project_prefs = '{$boincuser->project_prefs}' WHERE id = '{$boincuser->id}'"); |
| 877 | 877 | db_set_active('default'); |
| 878 | - } |
|
| 879 | - else { |
|
| 878 | + } |
|
| 879 | + else { |
|
| 880 | 880 | $main_prefs = array('global_preferences' => $main_prefs); |
| 881 | 881 | $boincuser->global_prefs = save_configuration($main_prefs); |
| 882 | 882 | db_set_active('boinc_rw'); |
| 883 | 883 | $result = db_query("UPDATE user SET global_prefs = '{$boincuser->global_prefs}' WHERE id = '{$boincuser->id}'"); |
| 884 | 884 | db_set_active('default'); |
| 885 | - } |
|
| 886 | - return $result; |
|
| 885 | + } |
|
| 886 | + return $result; |
|
| 887 | 887 | } |
| 888 | 888 | |
| 889 | 889 | |
@@ -900,9 +900,9 @@ discard block |
||
| 900 | 900 | *username. Called from privacy preference form. |
| 901 | 901 | */ |
| 902 | 902 | function boincwork_ignore_user_add_user_username($name = NULL) { |
| 903 | - global $user; |
|
| 903 | + global $user; |
|
| 904 | 904 | |
| 905 | - if (isset($name)) { |
|
| 905 | + if (isset($name)) { |
|
| 906 | 906 | // Get the BOINC ID from the name string, and lookup the |
| 907 | 907 | // corresponding drupal user. |
| 908 | 908 | $boincname = substr($name, 0, strrpos($name, '_')); |
@@ -911,84 +911,84 @@ discard block |
||
| 911 | 911 | $iuid = get_drupal_id($boincid); |
| 912 | 912 | |
| 913 | 913 | if ($user->uid == $iuid) { |
| 914 | - drupal_set_message(bts('You can\'t add yourself to your own ignore list.', array(), NULL, 'boinc:ignore-user-error-message'), 'error'); |
|
| 915 | - drupal_goto('account/prefs/privacy'); |
|
| 914 | + drupal_set_message(bts('You can\'t add yourself to your own ignore list.', array(), NULL, 'boinc:ignore-user-error-message'), 'error'); |
|
| 915 | + drupal_goto('account/prefs/privacy'); |
|
| 916 | 916 | } |
| 917 | 917 | |
| 918 | 918 | if (is_numeric($iuid) && $iuid > 0) { |
| 919 | - if (!db_result(db_query('SELECT COUNT(iuid) FROM {ignore_user} WHERE uid = %d AND iuid = %d', $user->uid, $iuid))) { |
|
| 919 | + if (!db_result(db_query('SELECT COUNT(iuid) FROM {ignore_user} WHERE uid = %d AND iuid = %d', $user->uid, $iuid))) { |
|
| 920 | 920 | db_query('INSERT INTO {ignore_user} (uid, iuid) VALUES (%d, %d)', $user->uid, $iuid); |
| 921 | - }// endif db_result |
|
| 921 | + }// endif db_result |
|
| 922 | 922 | |
| 923 | - if (module_exists('pm_block_user')) { |
|
| 923 | + if (module_exists('pm_block_user')) { |
|
| 924 | 924 | if (!db_result(db_query('SELECT COUNT(recipient) FROM {pm_block_user} WHERE author = %d AND recipient = %d', $iuid, $user->uid))) { |
| 925 | - db_query('INSERT INTO {pm_block_user} (author, recipient) VALUES (%d, %d)', $iuid, $user->uid); |
|
| 925 | + db_query('INSERT INTO {pm_block_user} (author, recipient) VALUES (%d, %d)', $iuid, $user->uid); |
|
| 926 | 926 | }// endif db_result |
| 927 | - }// endif module_exists('pm_block_user') |
|
| 927 | + }// endif module_exists('pm_block_user') |
|
| 928 | 928 | |
| 929 | 929 | }// endif $iuid |
| 930 | - } |
|
| 930 | + } |
|
| 931 | 931 | } |
| 932 | 932 | |
| 933 | 933 | /** |
| 934 | 934 | * Add another user's UID to the current user's ignore list. |
| 935 | 935 | */ |
| 936 | 936 | function boincwork_ignore_user_add_user($iuid = NULL) { |
| 937 | - global $user; |
|
| 937 | + global $user; |
|
| 938 | 938 | |
| 939 | - if ($user->uid == $iuid) { |
|
| 939 | + if ($user->uid == $iuid) { |
|
| 940 | 940 | drupal_set_message(bts('You can\'t add yourself to your own ignore list.', array(), NULL, 'boinc:ignore-user-error-message'), 'error'); |
| 941 | 941 | drupal_goto(); |
| 942 | - } |
|
| 942 | + } |
|
| 943 | 943 | |
| 944 | - $otheraccount = user_load($iuid); |
|
| 944 | + $otheraccount = user_load($iuid); |
|
| 945 | 945 | |
| 946 | - if (is_numeric($iuid) && $iuid > 0) { |
|
| 946 | + if (is_numeric($iuid) && $iuid > 0) { |
|
| 947 | 947 | if (!db_result(db_query('SELECT COUNT(iuid) FROM {ignore_user} WHERE uid = %d AND iuid = %d', $user->uid, $iuid))) { |
| 948 | - db_query('INSERT INTO {ignore_user} (uid, iuid) VALUES (%d, %d)', $user->uid, $iuid); |
|
| 948 | + db_query('INSERT INTO {ignore_user} (uid, iuid) VALUES (%d, %d)', $user->uid, $iuid); |
|
| 949 | 949 | }// endif db_result |
| 950 | 950 | |
| 951 | 951 | if (module_exists('pm_block_user')) { |
| 952 | - if (!db_result(db_query('SELECT COUNT(recipient) FROM {pm_block_user} WHERE author = %d AND recipient = %d', $iuid, $user->uid))) { |
|
| 952 | + if (!db_result(db_query('SELECT COUNT(recipient) FROM {pm_block_user} WHERE author = %d AND recipient = %d', $iuid, $user->uid))) { |
|
| 953 | 953 | db_query('INSERT INTO {pm_block_user} (author, recipient) VALUES (%d, %d)', $iuid, $user->uid); |
| 954 | - }// endif db_result |
|
| 954 | + }// endif db_result |
|
| 955 | 955 | }// endif module_exists('pm_block_user') |
| 956 | 956 | |
| 957 | 957 | drupal_set_message( |
| 958 | - bts('@username has been added to your ignore list. See your !privacy_preferences for more details.', |
|
| 958 | + bts('@username has been added to your ignore list. See your !privacy_preferences for more details.', |
|
| 959 | 959 | array( |
| 960 | - '@username' => $otheraccount->boincuser_name, |
|
| 961 | - '!privacy_preferences' => l(bts('privacy preferences', array(), NULL, 'boinc:ignore-user-add'), 'account/prefs/privacy'), |
|
| 960 | + '@username' => $otheraccount->boincuser_name, |
|
| 961 | + '!privacy_preferences' => l(bts('privacy preferences', array(), NULL, 'boinc:ignore-user-add'), 'account/prefs/privacy'), |
|
| 962 | 962 | ), |
| 963 | 963 | NULL, 'boinc:ignore-user-add'), |
| 964 | - 'status'); |
|
| 964 | + 'status'); |
|
| 965 | 965 | drupal_goto(); |
| 966 | - } |
|
| 967 | - else { |
|
| 966 | + } |
|
| 967 | + else { |
|
| 968 | 968 | drupal_not_found(); |
| 969 | - }// endif iuid |
|
| 969 | + }// endif iuid |
|
| 970 | 970 | } |
| 971 | 971 | |
| 972 | 972 | /** |
| 973 | 973 | * Remove user from user's ignore list. |
| 974 | 974 | */ |
| 975 | 975 | function boincwork_ignore_user_remove_user($iuid = NULL) { |
| 976 | - global $user; |
|
| 977 | - $otheraccount = user_load($iuid); |
|
| 976 | + global $user; |
|
| 977 | + $otheraccount = user_load($iuid); |
|
| 978 | 978 | |
| 979 | - db_query('DELETE FROM {ignore_user} WHERE uid = %d AND iuid = %d', $user->uid, $iuid); |
|
| 980 | - if (module_exists('pm_block_user')) { |
|
| 979 | + db_query('DELETE FROM {ignore_user} WHERE uid = %d AND iuid = %d', $user->uid, $iuid); |
|
| 980 | + if (module_exists('pm_block_user')) { |
|
| 981 | 981 | db_query('DELETE FROM {pm_block_user} WHERE author = %d AND recipient = %d', $iuid, $user->uid); |
| 982 | - }// endif module_exists |
|
| 983 | - drupal_set_message( |
|
| 982 | + }// endif module_exists |
|
| 983 | + drupal_set_message( |
|
| 984 | 984 | bts('@username has been removed from your ignore list. See your !privacy_preferences for more details.', |
| 985 | - array( |
|
| 985 | + array( |
|
| 986 | 986 | '@username' => $otheraccount->boincuser_name, |
| 987 | 987 | '!privacy_preferences' => l(bts('privacy preferences', array(), NULL, 'boinc:ignore-user-add'), 'account/prefs/privacy'), |
| 988 | - ), |
|
| 989 | - NULL, 'boinc:ignore-user-add'), |
|
| 988 | + ), |
|
| 989 | + NULL, 'boinc:ignore-user-add'), |
|
| 990 | 990 | 'status'); |
| 991 | - drupal_goto('account/prefs/privacy'); |
|
| 991 | + drupal_goto('account/prefs/privacy'); |
|
| 992 | 992 | } |
| 993 | 993 | |
| 994 | 994 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -1002,18 +1002,18 @@ discard block |
||
| 1002 | 1002 | */ |
| 1003 | 1003 | function boincwork_load_privacyconsenttypes() { |
| 1004 | 1004 | |
| 1005 | - db_set_active('boinc_rw'); |
|
| 1006 | - $db_result = db_query("SELECT id,shortname,description FROM consent_type WHERE enabled=1 AND privacypref=1 ORDER by project_specific ASC"); |
|
| 1007 | - db_set_active('drupal'); |
|
| 1005 | + db_set_active('boinc_rw'); |
|
| 1006 | + $db_result = db_query("SELECT id,shortname,description FROM consent_type WHERE enabled=1 AND privacypref=1 ORDER by project_specific ASC"); |
|
| 1007 | + db_set_active('drupal'); |
|
| 1008 | 1008 | |
| 1009 | - if ($db_result) { |
|
| 1009 | + if ($db_result) { |
|
| 1010 | 1010 | $consent_types = array(); |
| 1011 | 1011 | while ($result = db_fetch_array($db_result)) { |
| 1012 | - $consent_types[] = $result; |
|
| 1012 | + $consent_types[] = $result; |
|
| 1013 | 1013 | } |
| 1014 | 1014 | return $consent_types; |
| 1015 | - } |
|
| 1016 | - return array(); |
|
| 1015 | + } |
|
| 1016 | + return array(); |
|
| 1017 | 1017 | } |
| 1018 | 1018 | |
| 1019 | 1019 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -1025,94 +1025,94 @@ discard block |
||
| 1025 | 1025 | */ |
| 1026 | 1026 | function boincwork_set_default_venue($venue = '') { |
| 1027 | 1027 | |
| 1028 | - global $user; |
|
| 1029 | - $account = user_load($user->uid); |
|
| 1028 | + global $user; |
|
| 1029 | + $account = user_load($user->uid); |
|
| 1030 | 1030 | |
| 1031 | - if ($venue == 'generic') { |
|
| 1031 | + if ($venue == 'generic') { |
|
| 1032 | 1032 | $venue = ''; |
| 1033 | - } |
|
| 1033 | + } |
|
| 1034 | 1034 | |
| 1035 | - db_set_active('boinc_rw'); |
|
| 1036 | - db_query(" |
|
| 1035 | + db_set_active('boinc_rw'); |
|
| 1036 | + db_query(" |
|
| 1037 | 1037 | UPDATE user |
| 1038 | 1038 | SET venue = '%s' |
| 1039 | 1039 | WHERE id = %d", |
| 1040 | 1040 | $venue, $account->boincuser_id |
| 1041 | - ); |
|
| 1042 | - db_set_active('default'); |
|
| 1041 | + ); |
|
| 1042 | + db_set_active('default'); |
|
| 1043 | 1043 | } |
| 1044 | 1044 | |
| 1045 | 1045 | /** |
| 1046 | 1046 | * Recursively validate submitted form values against a set of rules |
| 1047 | 1047 | */ |
| 1048 | 1048 | function boincwork_validate_form($validation_rules, $values, $path = array()) { |
| 1049 | - foreach ($validation_rules as $field => $rules) { |
|
| 1049 | + foreach ($validation_rules as $field => $rules) { |
|
| 1050 | 1050 | $parents = $path; |
| 1051 | 1051 | if (is_array($values[$field])) { |
| 1052 | - // Process nested form elements |
|
| 1053 | - $parents[] = $field; |
|
| 1054 | - boincwork_validate_form($rules, $values[$field], $parents); |
|
| 1052 | + // Process nested form elements |
|
| 1053 | + $parents[] = $field; |
|
| 1054 | + boincwork_validate_form($rules, $values[$field], $parents); |
|
| 1055 | 1055 | } |
| 1056 | 1056 | else { |
| 1057 | - if ($parents) { |
|
| 1057 | + if ($parents) { |
|
| 1058 | 1058 | // form_set_error() identifies nested form elements with '][' as a |
| 1059 | 1059 | // delimiter between each parent and child element |
| 1060 | 1060 | $parents[] = $field; |
| 1061 | 1061 | $form_field = implode('][', $parents); |
| 1062 | - } |
|
| 1063 | - else { |
|
| 1062 | + } |
|
| 1063 | + else { |
|
| 1064 | 1064 | $form_field = $field; |
| 1065 | - } |
|
| 1066 | - if (isset($rules['datatype']) AND !boincwork_validate_datatype($values[$field], $rules['datatype'])) { |
|
| 1065 | + } |
|
| 1066 | + if (isset($rules['datatype']) AND !boincwork_validate_datatype($values[$field], $rules['datatype'])) { |
|
| 1067 | 1067 | form_set_error($form_field, bts('Invalid data type for @field', array('@field' => $field), NULL, 'boinc:account-preferences')); |
| 1068 | - } |
|
| 1069 | - if (isset($rules['min']) AND $values[$field] < $rules['min']) { |
|
| 1068 | + } |
|
| 1069 | + if (isset($rules['min']) AND $values[$field] < $rules['min']) { |
|
| 1070 | 1070 | form_set_error($form_field, bts('Minimum value not met for @field', array('@field' => $field), NULL, 'boinc:account-preferences')); |
| 1071 | - } |
|
| 1072 | - if (isset($rules['max']) AND $values[$field] > $rules['max']) { |
|
| 1071 | + } |
|
| 1072 | + if (isset($rules['max']) AND $values[$field] > $rules['max']) { |
|
| 1073 | 1073 | form_set_error($form_field, bts('Maximum value exceeded for @field', array('@field' => $field), NULL, 'boinc:account-preferences')); |
| 1074 | - } |
|
| 1074 | + } |
|
| 1075 | + } |
|
| 1075 | 1076 | } |
| 1076 | - } |
|
| 1077 | 1077 | } |
| 1078 | 1078 | |
| 1079 | 1079 | /** |
| 1080 | 1080 | * Check that numeric data conforms to specifications |
| 1081 | 1081 | */ |
| 1082 | 1082 | function boincwork_validate_datatype($data, $datatype = NULL) { |
| 1083 | - switch ($datatype) { |
|
| 1084 | - case 'float': |
|
| 1083 | + switch ($datatype) { |
|
| 1084 | + case 'float': |
|
| 1085 | 1085 | if (!is_numeric($data)) { |
| 1086 | - return FALSE; |
|
| 1086 | + return FALSE; |
|
| 1087 | 1087 | } |
| 1088 | 1088 | $data += 0.0; |
| 1089 | 1089 | if (!is_float($data)) { |
| 1090 | - return FALSE; |
|
| 1090 | + return FALSE; |
|
| 1091 | 1091 | } |
| 1092 | 1092 | break; |
| 1093 | 1093 | |
| 1094 | - case 'integer': |
|
| 1094 | + case 'integer': |
|
| 1095 | 1095 | if (!is_numeric($data)) { |
| 1096 | - return FALSE; |
|
| 1096 | + return FALSE; |
|
| 1097 | 1097 | } |
| 1098 | 1098 | $data += 0; |
| 1099 | 1099 | if (!is_int($data)) { |
| 1100 | - return FALSE; |
|
| 1100 | + return FALSE; |
|
| 1101 | 1101 | } |
| 1102 | 1102 | break; |
| 1103 | 1103 | |
| 1104 | - case 'text': |
|
| 1104 | + case 'text': |
|
| 1105 | 1105 | default: |
| 1106 | 1106 | |
| 1107 | 1107 | } |
| 1108 | - return TRUE; |
|
| 1108 | + return TRUE; |
|
| 1109 | 1109 | } |
| 1110 | 1110 | |
| 1111 | 1111 | /** |
| 1112 | 1112 | * Format a number to be displayed using a maximum number of digits |
| 1113 | 1113 | */ |
| 1114 | 1114 | function boincwork_format_stats($number, $max_digits = 4) { |
| 1115 | - $suffix = array( |
|
| 1115 | + $suffix = array( |
|
| 1116 | 1116 | 0 => '', |
| 1117 | 1117 | 1 => 'k', |
| 1118 | 1118 | 2 => 'M', |
@@ -1122,94 +1122,94 @@ discard block |
||
| 1122 | 1122 | 6 => 'E', |
| 1123 | 1123 | 7 => 'Z', |
| 1124 | 1124 | 8 => 'Y' |
| 1125 | - ); |
|
| 1126 | - if (!is_numeric($number)) $number = 0; |
|
| 1125 | + ); |
|
| 1126 | + if (!is_numeric($number)) $number = 0; |
|
| 1127 | 1127 | |
| 1128 | - $digits = floor(log($number, 10)) + 1; |
|
| 1129 | - $magnitude = 0; |
|
| 1130 | - $precision = 0; |
|
| 1131 | - if ($digits > $max_digits) { |
|
| 1128 | + $digits = floor(log($number, 10)) + 1; |
|
| 1129 | + $magnitude = 0; |
|
| 1130 | + $precision = 0; |
|
| 1131 | + if ($digits > $max_digits) { |
|
| 1132 | 1132 | $magnitude = floor(($digits - ($max_digits - 3)) / 3); |
| 1133 | 1133 | $precision = $max_digits - ($digits - ($magnitude * 3) + 1); |
| 1134 | 1134 | $number = round($number / pow(1000, $magnitude), $precision); |
| 1135 | - } |
|
| 1136 | - $number = number_format($number, $precision) . (($magnitude) ? "{$suffix[$magnitude]}" : ''); |
|
| 1135 | + } |
|
| 1136 | + $number = number_format($number, $precision) . (($magnitude) ? "{$suffix[$magnitude]}" : ''); |
|
| 1137 | 1137 | |
| 1138 | - return $number; |
|
| 1138 | + return $number; |
|
| 1139 | 1139 | } |
| 1140 | 1140 | |
| 1141 | - //------------------------------------------------------------------------------------------------ |
|
| 1142 | - // load_configuration(): Convert structured text/xml to array |
|
| 1143 | - //------------------------------------------------------------------------------------------------ |
|
| 1141 | + //------------------------------------------------------------------------------------------------ |
|
| 1142 | + // load_configuration(): Convert structured text/xml to array |
|
| 1143 | + //------------------------------------------------------------------------------------------------ |
|
| 1144 | 1144 | |
| 1145 | - function load_configuration($text) |
|
| 1146 | - { |
|
| 1147 | - if (preg_match('/^\<\?xml .*\?\>$/i', $text)) return null; |
|
| 1148 | - if ($xml = text_to_xml($text)) return xml_to_array($xml); |
|
| 1149 | - return false; |
|
| 1150 | - } |
|
| 1145 | + function load_configuration($text) |
|
| 1146 | + { |
|
| 1147 | + if (preg_match('/^\<\?xml .*\?\>$/i', $text)) return null; |
|
| 1148 | + if ($xml = text_to_xml($text)) return xml_to_array($xml); |
|
| 1149 | + return false; |
|
| 1150 | + } |
|
| 1151 | 1151 | |
| 1152 | - //------------------------------------------------------------------------------------------------ |
|
| 1153 | - // save_configuration(): Convert array to structured text/xml |
|
| 1154 | - //------------------------------------------------------------------------------------------------ |
|
| 1152 | + //------------------------------------------------------------------------------------------------ |
|
| 1153 | + // save_configuration(): Convert array to structured text/xml |
|
| 1154 | + //------------------------------------------------------------------------------------------------ |
|
| 1155 | 1155 | |
| 1156 | - function save_configuration($array) |
|
| 1157 | - { |
|
| 1158 | - if ($xml = array_to_xml($array)) return xml_to_text($xml, false, true); |
|
| 1159 | - return false; |
|
| 1160 | - } |
|
| 1156 | + function save_configuration($array) |
|
| 1157 | + { |
|
| 1158 | + if ($xml = array_to_xml($array)) return xml_to_text($xml, false, true); |
|
| 1159 | + return false; |
|
| 1160 | + } |
|
| 1161 | 1161 | |
| 1162 | - //------------------------------------------------------------------------------------------------ |
|
| 1163 | - // array_to_xml(): Take a multidimensional array and convert it to a structured |
|
| 1164 | - // DOM XML object |
|
| 1165 | - //------------------------------------------------------------------------------------------------ |
|
| 1162 | + //------------------------------------------------------------------------------------------------ |
|
| 1163 | + // array_to_xml(): Take a multidimensional array and convert it to a structured |
|
| 1164 | + // DOM XML object |
|
| 1165 | + //------------------------------------------------------------------------------------------------ |
|
| 1166 | 1166 | |
| 1167 | - function array_to_xml($array, $dom = false, $parent_node = false) { |
|
| 1167 | + function array_to_xml($array, $dom = false, $parent_node = false) { |
|
| 1168 | 1168 | $is_root = false; |
| 1169 | 1169 | if (!$dom) $dom = new DomDocument('1.0'); |
| 1170 | 1170 | if (!$parent_node) { |
| 1171 | - $parent_node = $dom; |
|
| 1172 | - $is_root = true; |
|
| 1171 | + $parent_node = $dom; |
|
| 1172 | + $is_root = true; |
|
| 1173 | 1173 | } |
| 1174 | 1174 | // Created an intermediate array to attempt to sort by @position |
| 1175 | 1175 | $ordered_array = array(); |
| 1176 | 1176 | $unordered_array = array(); |
| 1177 | 1177 | foreach ($array as $name => $value) { |
| 1178 | - if ($is_root) { |
|
| 1178 | + if ($is_root) { |
|
| 1179 | 1179 | $unordered_array[] = $array; |
| 1180 | 1180 | break; |
| 1181 | - } |
|
| 1182 | - if (is_array($value)) { |
|
| 1181 | + } |
|
| 1182 | + if (is_array($value)) { |
|
| 1183 | 1183 | if (is_numeric(key($value))) { |
| 1184 | - foreach ($value as $item) { |
|
| 1184 | + foreach ($value as $item) { |
|
| 1185 | 1185 | if (is_array($item) AND isset($item['@position'])) { |
| 1186 | - $ordered_array[$item['@position']] = array( |
|
| 1186 | + $ordered_array[$item['@position']] = array( |
|
| 1187 | 1187 | $name => $item |
| 1188 | - ); |
|
| 1188 | + ); |
|
| 1189 | 1189 | } |
| 1190 | 1190 | else { |
| 1191 | - $unordered_array[] = array( |
|
| 1191 | + $unordered_array[] = array( |
|
| 1192 | 1192 | $name => $item |
| 1193 | - ); |
|
| 1193 | + ); |
|
| 1194 | + } |
|
| 1194 | 1195 | } |
| 1195 | - } |
|
| 1196 | 1196 | } |
| 1197 | 1197 | elseif (isset($value['@position'])) { |
| 1198 | - $ordered_array[$value['@position']] = array( |
|
| 1198 | + $ordered_array[$value['@position']] = array( |
|
| 1199 | 1199 | $name => $value |
| 1200 | - ); |
|
| 1200 | + ); |
|
| 1201 | 1201 | } |
| 1202 | 1202 | else { |
| 1203 | - $unordered_array[] = array( |
|
| 1203 | + $unordered_array[] = array( |
|
| 1204 | 1204 | $name => $value |
| 1205 | - ); |
|
| 1205 | + ); |
|
| 1206 | 1206 | } |
| 1207 | - } |
|
| 1208 | - else { |
|
| 1207 | + } |
|
| 1208 | + else { |
|
| 1209 | 1209 | $unordered_array[] = array( |
| 1210 | - $name => $value |
|
| 1210 | + $name => $value |
|
| 1211 | 1211 | ); |
| 1212 | - } |
|
| 1212 | + } |
|
| 1213 | 1213 | } |
| 1214 | 1214 | |
| 1215 | 1215 | // Now append items without explicit positions at the end |
@@ -1217,39 +1217,39 @@ discard block |
||
| 1217 | 1217 | |
| 1218 | 1218 | // Convert to XML... |
| 1219 | 1219 | foreach ($primed_array as $item) { |
| 1220 | - list($name, $value) = each($item); |
|
| 1221 | - if (strcmp($name, '@attributes') == 0) { |
|
| 1220 | + list($name, $value) = each($item); |
|
| 1221 | + if (strcmp($name, '@attributes') == 0) { |
|
| 1222 | 1222 | if (!is_array($value)) continue; |
| 1223 | 1223 | foreach ($value as $attributeName => $attributeValue) { |
| 1224 | - $parent_node->setAttribute($attributeName, $attributeValue); |
|
| 1224 | + $parent_node->setAttribute($attributeName, $attributeValue); |
|
| 1225 | 1225 | } |
| 1226 | - } elseif (strcmp($name, '@value') == 0) { |
|
| 1226 | + } elseif (strcmp($name, '@value') == 0) { |
|
| 1227 | 1227 | if (isset($value)) $parent_node->nodeValue = $value; |
| 1228 | - } elseif (strcmp($name, '@position') == 0) { |
|
| 1228 | + } elseif (strcmp($name, '@position') == 0) { |
|
| 1229 | 1229 | continue; |
| 1230 | - } else { |
|
| 1230 | + } else { |
|
| 1231 | 1231 | if (is_numeric($name)) { |
| 1232 | - $name = $parent_node->tagName; |
|
| 1232 | + $name = $parent_node->tagName; |
|
| 1233 | 1233 | } |
| 1234 | 1234 | $current_item = $dom->createElement($name); |
| 1235 | 1235 | if (is_array($value)) { |
| 1236 | - if (is_numeric(key($value))) { |
|
| 1236 | + if (is_numeric(key($value))) { |
|
| 1237 | 1237 | $current_node = $parent_node->appendChild($current_item); |
| 1238 | 1238 | $current_node = array_to_xml($value, $dom, $current_node); |
| 1239 | 1239 | $child_count = $current_node->childNodes->length; |
| 1240 | 1240 | for ($i = 0; $i < $child_count; $i++) { |
| 1241 | - $parent_node->appendChild($current_node->childNodes->item(0)); |
|
| 1241 | + $parent_node->appendChild($current_node->childNodes->item(0)); |
|
| 1242 | 1242 | } |
| 1243 | 1243 | $parent_node->removeChild($current_node); |
| 1244 | - } else { |
|
| 1244 | + } else { |
|
| 1245 | 1245 | $current_node = $dom->appendChild($current_item); |
| 1246 | 1246 | $parent_node->appendChild(array_to_xml($value, $dom, $current_node)); |
| 1247 | - } |
|
| 1247 | + } |
|
| 1248 | 1248 | } else { |
| 1249 | - if (isset($value)) $current_item->nodeValue = $value; |
|
| 1250 | - $parent_node->appendChild($current_item); |
|
| 1249 | + if (isset($value)) $current_item->nodeValue = $value; |
|
| 1250 | + $parent_node->appendChild($current_item); |
|
| 1251 | + } |
|
| 1251 | 1252 | } |
| 1252 | - } |
|
| 1253 | 1253 | } |
| 1254 | 1254 | /* |
| 1255 | 1255 | foreach ($array as $name => $value) { |
@@ -1285,114 +1285,114 @@ discard block |
||
| 1285 | 1285 | } |
| 1286 | 1286 | }*/ |
| 1287 | 1287 | return $parent_node; |
| 1288 | - } |
|
| 1288 | + } |
|
| 1289 | 1289 | |
| 1290 | - //------------------------------------------------------------------------------------------------ |
|
| 1291 | - // xml_to_text(): Convert an XML DOM object to string format |
|
| 1292 | - //------------------------------------------------------------------------------------------------ |
|
| 1290 | + //------------------------------------------------------------------------------------------------ |
|
| 1291 | + // xml_to_text(): Convert an XML DOM object to string format |
|
| 1292 | + //------------------------------------------------------------------------------------------------ |
|
| 1293 | 1293 | |
| 1294 | - function xml_to_text($xml, $include_xml_declaration = true, $add_carriage_returns = false) |
|
| 1295 | - { |
|
| 1296 | - $xml->formatOutput = true; |
|
| 1297 | - $text = $xml->saveXML(); |
|
| 1298 | - if (!$include_xml_declaration) { |
|
| 1294 | + function xml_to_text($xml, $include_xml_declaration = true, $add_carriage_returns = false) |
|
| 1295 | + { |
|
| 1296 | + $xml->formatOutput = true; |
|
| 1297 | + $text = $xml->saveXML(); |
|
| 1298 | + if (!$include_xml_declaration) { |
|
| 1299 | 1299 | $text = preg_replace('/<\?xml version=.*\?>\s*/i', '', $text, 1); |
| 1300 | - } |
|
| 1301 | - if ($add_carriage_returns) {; |
|
| 1300 | + } |
|
| 1301 | + if ($add_carriage_returns) {; |
|
| 1302 | 1302 | $text = preg_replace('/\n/i', "\r\n", $text); |
| 1303 | - } |
|
| 1304 | - return trim($text); |
|
| 1305 | - } |
|
| 1303 | + } |
|
| 1304 | + return trim($text); |
|
| 1305 | + } |
|
| 1306 | 1306 | |
| 1307 | - //------------------------------------------------------------------------------------------------ |
|
| 1308 | - // text_to_xml(): Convert an XML DOM object to string format |
|
| 1309 | - //------------------------------------------------------------------------------------------------ |
|
| 1307 | + //------------------------------------------------------------------------------------------------ |
|
| 1308 | + // text_to_xml(): Convert an XML DOM object to string format |
|
| 1309 | + //------------------------------------------------------------------------------------------------ |
|
| 1310 | 1310 | |
| 1311 | - function text_to_xml($text) { |
|
| 1311 | + function text_to_xml($text) { |
|
| 1312 | 1312 | $xml = new DomDocument(); |
| 1313 | 1313 | if ( !($xml->loadXML($text)) ) return false; |
| 1314 | 1314 | return $xml; |
| 1315 | - } |
|
| 1315 | + } |
|
| 1316 | 1316 | |
| 1317 | 1317 | |
| 1318 | - //------------------------------------------------------------------------------------------------ |
|
| 1319 | - // xml_to_array(): Convert an XML DOM object to array format |
|
| 1320 | - //------------------------------------------------------------------------------------------------ |
|
| 1318 | + //------------------------------------------------------------------------------------------------ |
|
| 1319 | + // xml_to_array(): Convert an XML DOM object to array format |
|
| 1320 | + //------------------------------------------------------------------------------------------------ |
|
| 1321 | 1321 | |
| 1322 | - function xml_to_array($xml) { |
|
| 1323 | - $node = $xml->firstChild; //$xml->first_child(); |
|
| 1324 | - $result = ''; |
|
| 1325 | - $index = 1; |
|
| 1326 | - $position = 0; |
|
| 1327 | - while (!is_null($node)) { |
|
| 1328 | - switch ($node->nodeType) { |
|
| 1329 | - case XML_TEXT_NODE: |
|
| 1322 | + function xml_to_array($xml) { |
|
| 1323 | + $node = $xml->firstChild; //$xml->first_child(); |
|
| 1324 | + $result = ''; |
|
| 1325 | + $index = 1; |
|
| 1326 | + $position = 0; |
|
| 1327 | + while (!is_null($node)) { |
|
| 1328 | + switch ($node->nodeType) { |
|
| 1329 | + case XML_TEXT_NODE: |
|
| 1330 | 1330 | if (trim($node->nodeValue) != '') $result = $node->nodeValue; |
| 1331 | - break; |
|
| 1332 | - case XML_ELEMENT_NODE: |
|
| 1331 | + break; |
|
| 1332 | + case XML_ELEMENT_NODE: |
|
| 1333 | 1333 | $node_name = $node->nodeName; |
| 1334 | - $parent = $node->parentNode; |
|
| 1335 | - $sibling = $node->nextSibling; |
|
| 1336 | - |
|
| 1337 | - // Determine if this node forms a set with siblings (share a node name) |
|
| 1338 | - while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->nextSibling; |
|
| 1339 | - if (!$sibling) { |
|
| 1340 | - $sibling = $node->previousSibling; |
|
| 1341 | - while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->previousSibling; |
|
| 1342 | - } |
|
| 1343 | - |
|
| 1344 | - if ($sibling) { |
|
| 1345 | - $result[$node_name][$index] = ''; |
|
| 1346 | - if ($node->childNodes) { |
|
| 1347 | - $result[$node_name][$index] = xml_to_array($node) ; |
|
| 1348 | - } |
|
| 1349 | - if ($node->hasAttributes()) { |
|
| 1350 | - $attributes = $node->attributes; |
|
| 1351 | - if ($result[$node_name][$index] !== '' AND !is_array($result[$node_name][$index])) { |
|
| 1352 | - $result[$node_name][$index] = array('@value' => $result[$node_name][$index]); |
|
| 1353 | - } |
|
| 1354 | - foreach ($attributes as $key => $attribute) { |
|
| 1355 | - $result[$node_name][$index]['@attributes'][$attribute->name] = $attribute->value; |
|
| 1356 | - } |
|
| 1357 | - } |
|
| 1358 | - // Retain the position of the element |
|
| 1359 | - if (!is_array($result[$node_name][$index])) { |
|
| 1334 | + $parent = $node->parentNode; |
|
| 1335 | + $sibling = $node->nextSibling; |
|
| 1336 | + |
|
| 1337 | + // Determine if this node forms a set with siblings (share a node name) |
|
| 1338 | + while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->nextSibling; |
|
| 1339 | + if (!$sibling) { |
|
| 1340 | + $sibling = $node->previousSibling; |
|
| 1341 | + while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->previousSibling; |
|
| 1342 | + } |
|
| 1343 | + |
|
| 1344 | + if ($sibling) { |
|
| 1345 | + $result[$node_name][$index] = ''; |
|
| 1346 | + if ($node->childNodes) { |
|
| 1347 | + $result[$node_name][$index] = xml_to_array($node) ; |
|
| 1348 | + } |
|
| 1349 | + if ($node->hasAttributes()) { |
|
| 1350 | + $attributes = $node->attributes; |
|
| 1351 | + if ($result[$node_name][$index] !== '' AND !is_array($result[$node_name][$index])) { |
|
| 1352 | + $result[$node_name][$index] = array('@value' => $result[$node_name][$index]); |
|
| 1353 | + } |
|
| 1354 | + foreach ($attributes as $key => $attribute) { |
|
| 1355 | + $result[$node_name][$index]['@attributes'][$attribute->name] = $attribute->value; |
|
| 1356 | + } |
|
| 1357 | + } |
|
| 1358 | + // Retain the position of the element |
|
| 1359 | + if (!is_array($result[$node_name][$index])) { |
|
| 1360 | 1360 | $result[$node_name][$index] = array( |
| 1361 | - '@value' => $result[$node_name][$index] |
|
| 1361 | + '@value' => $result[$node_name][$index] |
|
| 1362 | 1362 | ); |
| 1363 | - } |
|
| 1364 | - $result[$node_name][$index]['@position'] = $position; |
|
| 1365 | - $position++; |
|
| 1366 | - $index++; |
|
| 1367 | - } else { |
|
| 1368 | - $result[$node_name] = ''; |
|
| 1369 | - if ($node->childNodes) { |
|
| 1370 | - $result[$node_name] = xml_to_array($node) ; |
|
| 1371 | - } |
|
| 1372 | - if ($node->hasAttributes()) { |
|
| 1373 | - $attributes = $node->attributes; |
|
| 1374 | - if ($result[$node_name] !== '' AND !is_array($result[$node_name])) { |
|
| 1375 | - $result[$node_name] = array('@value' => $result[$node_name]); |
|
| 1376 | - } |
|
| 1377 | - foreach($attributes as $key => $attribute) { |
|
| 1378 | - $result[$node_name]['@attributes'][$attribute->name] = $attribute->value; |
|
| 1379 | - } |
|
| 1380 | - } |
|
| 1381 | - // Retain the position of the element |
|
| 1382 | - if (!is_array($result[$node_name])) { |
|
| 1363 | + } |
|
| 1364 | + $result[$node_name][$index]['@position'] = $position; |
|
| 1365 | + $position++; |
|
| 1366 | + $index++; |
|
| 1367 | + } else { |
|
| 1368 | + $result[$node_name] = ''; |
|
| 1369 | + if ($node->childNodes) { |
|
| 1370 | + $result[$node_name] = xml_to_array($node) ; |
|
| 1371 | + } |
|
| 1372 | + if ($node->hasAttributes()) { |
|
| 1373 | + $attributes = $node->attributes; |
|
| 1374 | + if ($result[$node_name] !== '' AND !is_array($result[$node_name])) { |
|
| 1375 | + $result[$node_name] = array('@value' => $result[$node_name]); |
|
| 1376 | + } |
|
| 1377 | + foreach($attributes as $key => $attribute) { |
|
| 1378 | + $result[$node_name]['@attributes'][$attribute->name] = $attribute->value; |
|
| 1379 | + } |
|
| 1380 | + } |
|
| 1381 | + // Retain the position of the element |
|
| 1382 | + if (!is_array($result[$node_name])) { |
|
| 1383 | 1383 | $result[$node_name] = array( |
| 1384 | - '@value' => $result[$node_name] |
|
| 1384 | + '@value' => $result[$node_name] |
|
| 1385 | 1385 | ); |
| 1386 | - } |
|
| 1387 | - $result[$node_name]['@position'] = $position; |
|
| 1388 | - $position++; |
|
| 1389 | - } |
|
| 1390 | - break; |
|
| 1391 | - } |
|
| 1392 | - $node = $node->nextSibling; |
|
| 1393 | - } |
|
| 1394 | - return $result; |
|
| 1395 | - } |
|
| 1386 | + } |
|
| 1387 | + $result[$node_name]['@position'] = $position; |
|
| 1388 | + $position++; |
|
| 1389 | + } |
|
| 1390 | + break; |
|
| 1391 | + } |
|
| 1392 | + $node = $node->nextSibling; |
|
| 1393 | + } |
|
| 1394 | + return $result; |
|
| 1395 | + } |
|
| 1396 | 1396 | |
| 1397 | 1397 | |
| 1398 | 1398 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -1400,172 +1400,172 @@ discard block |
||
| 1400 | 1400 | * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
| 1401 | 1401 | |
| 1402 | 1402 | /** |
| 1403 | - * Determine output for host list views when no hosts are found. |
|
| 1404 | - */ |
|
| 1403 | + * Determine output for host list views when no hosts are found. |
|
| 1404 | + */ |
|
| 1405 | 1405 | function boincwork_views_host_list_empty_text($context = NULL) { |
| 1406 | 1406 | |
| 1407 | - // Pull the BOINC user ID from the view arguments to get show_hosts |
|
| 1408 | - // preference for that user |
|
| 1409 | - require_boinc('boinc_db'); |
|
| 1410 | - $view = views_get_current_view(); |
|
| 1411 | - $account = user_load($view->args[0]); |
|
| 1412 | - $boincuser = BoincUser::lookup_id($account->boincuser_id); |
|
| 1407 | + // Pull the BOINC user ID from the view arguments to get show_hosts |
|
| 1408 | + // preference for that user |
|
| 1409 | + require_boinc('boinc_db'); |
|
| 1410 | + $view = views_get_current_view(); |
|
| 1411 | + $account = user_load($view->args[0]); |
|
| 1412 | + $boincuser = BoincUser::lookup_id($account->boincuser_id); |
|
| 1413 | 1413 | |
| 1414 | - // Determine if hosts are associated at all or just hidden |
|
| 1415 | - $output = ''; |
|
| 1416 | - if ($boincuser->show_hosts) { |
|
| 1414 | + // Determine if hosts are associated at all or just hidden |
|
| 1415 | + $output = ''; |
|
| 1416 | + if ($boincuser->show_hosts) { |
|
| 1417 | 1417 | switch($context) { |
| 1418 | 1418 | case 'active': |
| 1419 | 1419 | $output .= '<h2>' . bts('No active computers', array(), NULL, 'boinc:host-list') . '</h2>'; |
| 1420 | - $output .= '<p>' . bts('This user has no computers that have been' |
|
| 1421 | - . ' active in the last 30 days.', array(), NULL, 'boinc:host-list') . '</p>'; |
|
| 1422 | - break; |
|
| 1420 | + $output .= '<p>' . bts('This user has no computers that have been' |
|
| 1421 | + . ' active in the last 30 days.', array(), NULL, 'boinc:host-list') . '</p>'; |
|
| 1422 | + break; |
|
| 1423 | 1423 | |
| 1424 | 1424 | case 'preferences': |
| 1425 | 1425 | $output .= '<h2>' . bts('No computers', array(), NULL, 'boinc:host-list') . '</h2>'; |
| 1426 | - $output .= '<p>' . bts('There are no computers assigned to this' |
|
| 1427 | - . ' preference set.', array(), NULL, 'boinc:host-list') . '</p>'; |
|
| 1428 | - break; |
|
| 1426 | + $output .= '<p>' . bts('There are no computers assigned to this' |
|
| 1427 | + . ' preference set.', array(), NULL, 'boinc:host-list') . '</p>'; |
|
| 1428 | + break; |
|
| 1429 | 1429 | |
| 1430 | 1430 | default: |
| 1431 | 1431 | $output .= '<h2>' . bts('Computers pending', array(), NULL, 'boinc:host-list') . '</h2>'; |
| 1432 | - $output .= '<p>' . bts('This user does not yet have any associated' |
|
| 1433 | - . ' computers. Computers will be displayed when they have earned their' |
|
| 1434 | - . ' first credits.', array(), NULL, 'boinc:host-list') . '</p>'; |
|
| 1432 | + $output .= '<p>' . bts('This user does not yet have any associated' |
|
| 1433 | + . ' computers. Computers will be displayed when they have earned their' |
|
| 1434 | + . ' first credits.', array(), NULL, 'boinc:host-list') . '</p>'; |
|
| 1435 | 1435 | } |
| 1436 | - } |
|
| 1437 | - else { |
|
| 1436 | + } |
|
| 1437 | + else { |
|
| 1438 | 1438 | $output .= '<h2>' . bts('Computers hidden', array(), NULL, 'boinc:host-list') . '</h2>'; |
| 1439 | 1439 | $output .= '<p>' . bts('This user has chosen not to show information' |
| 1440 | 1440 | . ' about their computers.', array(), NULL, 'boinc:host-list') . '</p>'; |
| 1441 | - } |
|
| 1442 | - return $output; |
|
| 1441 | + } |
|
| 1442 | + return $output; |
|
| 1443 | 1443 | } |
| 1444 | 1444 | |
| 1445 | 1445 | /** |
| 1446 | - * Determine output for task list views when no tasks are found. |
|
| 1447 | - */ |
|
| 1446 | + * Determine output for task list views when no tasks are found. |
|
| 1447 | + */ |
|
| 1448 | 1448 | function boincwork_views_task_list_empty_text($context = NULL) { |
| 1449 | 1449 | |
| 1450 | - // |
|
| 1451 | - $output = ''; |
|
| 1452 | - switch($context) { |
|
| 1453 | - default: |
|
| 1450 | + // |
|
| 1451 | + $output = ''; |
|
| 1452 | + switch($context) { |
|
| 1453 | + default: |
|
| 1454 | 1454 | $output .= '<h2>' . bts('No @type tasks', array('@type' => $context), NULL, 'boinc:task-list') |
| 1455 | 1455 | . '</h2>'; |
| 1456 | 1456 | $output .= '<p>' . bts('There are no tasks of this type on record', array(), NULL, 'boinc:task-list') |
| 1457 | 1457 | . '</p>'; |
| 1458 | - } |
|
| 1459 | - return $output; |
|
| 1458 | + } |
|
| 1459 | + return $output; |
|
| 1460 | 1460 | } |
| 1461 | 1461 | |
| 1462 | 1462 | /** |
| 1463 | - * Output links to perform host actions |
|
| 1464 | - */ |
|
| 1463 | + * Output links to perform host actions |
|
| 1464 | + */ |
|
| 1465 | 1465 | function boincwork_host_action_links($host_id) { |
| 1466 | - $output = ''; |
|
| 1467 | - if (boincwork_host_user_is_owner($host_id)) { |
|
| 1466 | + $output = ''; |
|
| 1467 | + if (boincwork_host_user_is_owner($host_id)) { |
|
| 1468 | 1468 | // Show merge hosts option |
| 1469 | 1469 | $output = '<ul class="tab-list"><li class="first tab">'; |
| 1470 | 1470 | $output .= l(bts('Merge', array(), NULL, 'boinc:form-merge'), "host/{$host_id}/merge"); |
| 1471 | 1471 | $output .= '</li>'; |
| 1472 | 1472 | // If host has no tasks, allow the host to be deleted |
| 1473 | 1473 | if (!boincwork_host_get_task_count($host_id)) { |
| 1474 | - $output .= '<li class="tab">'; |
|
| 1475 | - $output .= l(bts('Delete', array(), NULL, 'boinc:form-delete'), "host/{$host_id}/delete", |
|
| 1474 | + $output .= '<li class="tab">'; |
|
| 1475 | + $output .= l(bts('Delete', array(), NULL, 'boinc:form-delete'), "host/{$host_id}/delete", |
|
| 1476 | 1476 | array( |
| 1477 | - 'attributes' => array( |
|
| 1477 | + 'attributes' => array( |
|
| 1478 | 1478 | 'onclick' => 'return confirm(\'' . bts('This will delete host @id' |
| 1479 | - . ' from your account forever. Are you sure this is OK?', |
|
| 1480 | - array('@id' => $host_id), |
|
| 1481 | - NULL, 'boinc:account-host-delete') . '\')' |
|
| 1482 | - ) |
|
| 1479 | + . ' from your account forever. Are you sure this is OK?', |
|
| 1480 | + array('@id' => $host_id), |
|
| 1481 | + NULL, 'boinc:account-host-delete') . '\')' |
|
| 1482 | + ) |
|
| 1483 | 1483 | ) |
| 1484 | - ); |
|
| 1485 | - $output .= '</li>'; |
|
| 1484 | + ); |
|
| 1485 | + $output .= '</li>'; |
|
| 1486 | 1486 | } |
| 1487 | 1487 | $output .= '</ul>'; |
| 1488 | - } |
|
| 1489 | - return $output; |
|
| 1488 | + } |
|
| 1489 | + return $output; |
|
| 1490 | 1490 | } |
| 1491 | 1491 | |
| 1492 | 1492 | /** |
| 1493 | 1493 | * Get details for a given host |
| 1494 | 1494 | */ |
| 1495 | 1495 | function boincwork_host_get_info($host_id) { |
| 1496 | - db_set_active('boinc_ro'); |
|
| 1497 | - $host = db_fetch_object(db_query( |
|
| 1496 | + db_set_active('boinc_ro'); |
|
| 1497 | + $host = db_fetch_object(db_query( |
|
| 1498 | 1498 | "SELECT * FROM {host} WHERE id = '%d'", |
| 1499 | 1499 | $host_id |
| 1500 | - )); |
|
| 1501 | - db_set_active('default'); |
|
| 1502 | - return $host; |
|
| 1500 | + )); |
|
| 1501 | + db_set_active('default'); |
|
| 1502 | + return $host; |
|
| 1503 | 1503 | } |
| 1504 | 1504 | |
| 1505 | 1505 | /** |
| 1506 | 1506 | * Get the number of tasks associated with a given host |
| 1507 | 1507 | */ |
| 1508 | 1508 | function boincwork_host_get_task_count($host_id) { |
| 1509 | - db_set_active('boinc_ro'); |
|
| 1510 | - $count = db_result(db_query( |
|
| 1509 | + db_set_active('boinc_ro'); |
|
| 1510 | + $count = db_result(db_query( |
|
| 1511 | 1511 | "SELECT COUNT(*) FROM {result} WHERE hostid = '%d'", |
| 1512 | 1512 | $host_id |
| 1513 | - )); |
|
| 1514 | - db_set_active('default'); |
|
| 1515 | - return $count; |
|
| 1513 | + )); |
|
| 1514 | + db_set_active('default'); |
|
| 1515 | + return $count; |
|
| 1516 | 1516 | } |
| 1517 | 1517 | |
| 1518 | 1518 | /** |
| 1519 | 1519 | * Check whether a user is the owner of a host |
| 1520 | 1520 | */ |
| 1521 | 1521 | function boincwork_host_user_is_owner($host_id, $uid = NULL) { |
| 1522 | - if (!$uid) { |
|
| 1522 | + if (!$uid) { |
|
| 1523 | 1523 | global $user; |
| 1524 | 1524 | $uid = $user->uid; |
| 1525 | - } |
|
| 1526 | - $account = user_load($uid); |
|
| 1527 | - // Get host owner |
|
| 1528 | - db_set_active('boinc_ro'); |
|
| 1529 | - $owner = db_result(db_query( |
|
| 1525 | + } |
|
| 1526 | + $account = user_load($uid); |
|
| 1527 | + // Get host owner |
|
| 1528 | + db_set_active('boinc_ro'); |
|
| 1529 | + $owner = db_result(db_query( |
|
| 1530 | 1530 | "SELECT userid FROM {host} WHERE id = '%d'", |
| 1531 | 1531 | $host_id |
| 1532 | - )); |
|
| 1533 | - db_set_active('default'); |
|
| 1534 | - return ($account->boincuser_id === $owner); |
|
| 1532 | + )); |
|
| 1533 | + db_set_active('default'); |
|
| 1534 | + return ($account->boincuser_id === $owner); |
|
| 1535 | 1535 | } |
| 1536 | 1536 | |
| 1537 | 1537 | /** |
| 1538 | - * Determine output for host last contact time |
|
| 1539 | - */ |
|
| 1538 | + * Determine output for host last contact time |
|
| 1539 | + */ |
|
| 1540 | 1540 | function boincwork_host_last_contact($timestamp, $host_id = NULL, $context = NULL) { |
| 1541 | - $output = '---'; |
|
| 1542 | - $root_log_dir = variable_get('boinc_host_sched_logs_dir', ''); |
|
| 1543 | - $log = ''; |
|
| 1544 | - if ($timestamp) { |
|
| 1541 | + $output = '---'; |
|
| 1542 | + $root_log_dir = variable_get('boinc_host_sched_logs_dir', ''); |
|
| 1543 | + $log = ''; |
|
| 1544 | + if ($timestamp) { |
|
| 1545 | 1545 | $output = date('j M Y G:i:s T', $timestamp); |
| 1546 | - } |
|
| 1547 | - if ($root_log_dir AND $host_id) { |
|
| 1546 | + } |
|
| 1547 | + if ($root_log_dir AND $host_id) { |
|
| 1548 | 1548 | $subdir = substr($host_id, 0, -3) OR $subdir = 0; |
| 1549 | 1549 | $log = implode('/', array($root_log_dir, $subdir, $host_id)); |
| 1550 | - } |
|
| 1551 | - if ($log AND file_exists($log)) { |
|
| 1550 | + } |
|
| 1551 | + if ($log AND file_exists($log)) { |
|
| 1552 | 1552 | $output = l($output, "host/{$host_id}/log"); |
| 1553 | - } |
|
| 1554 | - return $output; |
|
| 1553 | + } |
|
| 1554 | + return $output; |
|
| 1555 | 1555 | } |
| 1556 | 1556 | |
| 1557 | 1557 | /** |
| 1558 | 1558 | * |
| 1559 | 1559 | */ |
| 1560 | 1560 | function boincwork_host_venue_selector($host_id) { |
| 1561 | - $output = ''; |
|
| 1562 | - if (function_exists('jump_quickly')) { |
|
| 1561 | + $output = ''; |
|
| 1562 | + if (function_exists('jump_quickly')) { |
|
| 1563 | 1563 | $path = "host/{$host_id}/set-venue"; |
| 1564 | 1564 | $venues = array( |
| 1565 | - "{$path}/generic" => bts('Generic', array(), NULL, 'boinc:account-preferences-location'), |
|
| 1566 | - "{$path}/home" => bts('Home', array(), NULL, 'boinc:account-preferences-location:-1:ignoreoverwrite'), |
|
| 1567 | - "{$path}/work" => bts('Work', array(), NULL, 'boinc:account-preferences-location'), |
|
| 1568 | - "{$path}/school" => bts('School', array(), NULL, 'boinc:account-preferences-location') |
|
| 1565 | + "{$path}/generic" => bts('Generic', array(), NULL, 'boinc:account-preferences-location'), |
|
| 1566 | + "{$path}/home" => bts('Home', array(), NULL, 'boinc:account-preferences-location:-1:ignoreoverwrite'), |
|
| 1567 | + "{$path}/work" => bts('Work', array(), NULL, 'boinc:account-preferences-location'), |
|
| 1568 | + "{$path}/school" => bts('School', array(), NULL, 'boinc:account-preferences-location') |
|
| 1569 | 1569 | ); |
| 1570 | 1570 | variable_set('jump_use_js_venues-Array', 1); |
| 1571 | 1571 | drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js'); |
@@ -1573,34 +1573,34 @@ discard block |
||
| 1573 | 1573 | // Get current venue |
| 1574 | 1574 | db_set_active('boinc_ro'); |
| 1575 | 1575 | $venue = db_result(db_query( |
| 1576 | - "SELECT venue FROM {host} WHERE id = '%d'", |
|
| 1577 | - $host_id |
|
| 1576 | + "SELECT venue FROM {host} WHERE id = '%d'", |
|
| 1577 | + $host_id |
|
| 1578 | 1578 | )); |
| 1579 | 1579 | db_set_active('default'); |
| 1580 | 1580 | $output .= jump_quickly($venues, 'venues', 1, "{$path}/{$venue}"); |
| 1581 | - } |
|
| 1582 | - return $output; |
|
| 1581 | + } |
|
| 1582 | + return $output; |
|
| 1583 | 1583 | } |
| 1584 | 1584 | |
| 1585 | 1585 | /** |
| 1586 | - * Determine output for task reported time / deadline |
|
| 1587 | - */ |
|
| 1586 | + * Determine output for task reported time / deadline |
|
| 1587 | + */ |
|
| 1588 | 1588 | function boincwork_task_time_reported($received_time = NULL, $deadline = NULL, $context = NULL) { |
| 1589 | - $output = '---'; |
|
| 1590 | - if ($received_time OR $deadline) { |
|
| 1589 | + $output = '---'; |
|
| 1590 | + if ($received_time OR $deadline) { |
|
| 1591 | 1591 | $timestamp = ($received_time) ? $received_time : $deadline; |
| 1592 | 1592 | $output = date('j M Y G:i:s T', $timestamp); |
| 1593 | 1593 | // Add a wrapper to deadline text |
| 1594 | 1594 | if (!$received_time) { |
| 1595 | - if (time() < $deadline) { |
|
| 1595 | + if (time() < $deadline) { |
|
| 1596 | 1596 | $output = '<span class="on-time">' . $output . '</span>'; |
| 1597 | - } |
|
| 1598 | - else { |
|
| 1597 | + } |
|
| 1598 | + else { |
|
| 1599 | 1599 | $output = '<span class="past-due">' . $output . '</span>'; |
| 1600 | - } |
|
| 1600 | + } |
|
| 1601 | 1601 | } |
| 1602 | - } |
|
| 1603 | - return $output; |
|
| 1602 | + } |
|
| 1603 | + return $output; |
|
| 1604 | 1604 | } |
| 1605 | 1605 | |
| 1606 | 1606 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -1631,345 +1631,345 @@ discard block |
||
| 1631 | 1631 | * Number of table row to display per page. Defaults to 20. |
| 1632 | 1632 | */ |
| 1633 | 1633 | function boincwork_tasktable($category = 0, $queryid = 1, $tselect = NULL, $app_id = 0, $tablerows = 20) { |
| 1634 | - // Check type parameter, if not (0,2) then return an error. |
|
| 1635 | - if ( ($category!=0) AND ($category!=1) AND ($category!=2) ) { |
|
| 1634 | + // Check type parameter, if not (0,2) then return an error. |
|
| 1635 | + if ( ($category!=0) AND ($category!=1) AND ($category!=2) ) { |
|
| 1636 | 1636 | watchdog('boincwork', 'task table called with invalid category = %category', array('%category' => $category), WATCHDOG_WARNING); |
| 1637 | 1637 | return ''; |
| 1638 | - } |
|
| 1638 | + } |
|
| 1639 | 1639 | |
| 1640 | - require_boinc( array('util', 'result') ); |
|
| 1640 | + require_boinc( array('util', 'result') ); |
|
| 1641 | 1641 | |
| 1642 | - global $language; |
|
| 1643 | - $locality=$language->language; |
|
| 1644 | - $nf = new NumberFormatter($locality, NumberFormatter::DECIMAL); |
|
| 1645 | - $nf->setAttribute(NumberFormatter::MIN_FRACTION_DIGITS, 0); |
|
| 1646 | - $nf->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, 0); |
|
| 1642 | + global $language; |
|
| 1643 | + $locality=$language->language; |
|
| 1644 | + $nf = new NumberFormatter($locality, NumberFormatter::DECIMAL); |
|
| 1645 | + $nf->setAttribute(NumberFormatter::MIN_FRACTION_DIGITS, 0); |
|
| 1646 | + $nf->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, 0); |
|
| 1647 | 1647 | |
| 1648 | - $output = ''; |
|
| 1648 | + $output = ''; |
|
| 1649 | 1649 | |
| 1650 | - $state_hnames = array( |
|
| 1650 | + $state_hnames = array( |
|
| 1651 | 1651 | STATE_ALL => 'All', |
| 1652 | 1652 | STATE_IN_PROGRESS => 'In progress', |
| 1653 | 1653 | STATE_PENDING => 'Pending', |
| 1654 | 1654 | STATE_VALID => 'Valid', |
| 1655 | 1655 | STATE_INVALID => 'Invalid', |
| 1656 | 1656 | STATE_ERROR => 'Error', |
| 1657 | - ); |
|
| 1658 | - // Array (hash) to count total number of results/tasks, and their states. |
|
| 1659 | - $taskstates = array( |
|
| 1657 | + ); |
|
| 1658 | + // Array (hash) to count total number of results/tasks, and their states. |
|
| 1659 | + $taskstates = array( |
|
| 1660 | 1660 | STATE_ALL => 0, |
| 1661 | 1661 | STATE_IN_PROGRESS => 0, |
| 1662 | 1662 | STATE_PENDING => 0, |
| 1663 | 1663 | STATE_VALID => 0, |
| 1664 | 1664 | STATE_INVALID => 0, |
| 1665 | 1665 | STATE_ERROR => 0, |
| 1666 | - ); |
|
| 1667 | - // Array to hold pretty-print result data to be displayed in a table. |
|
| 1668 | - $resultdata = array(); |
|
| 1669 | - // Arrays for applications. Form below uses $applications as parameter. |
|
| 1670 | - $application_map = array(); |
|
| 1671 | - $application_select_count = array(); |
|
| 1672 | - $applications = array(); |
|
| 1673 | - |
|
| 1674 | - // BOINC DB queries for results, application names |
|
| 1675 | - db_set_active('boinc_ro'); |
|
| 1676 | - |
|
| 1677 | - // Query to retreive all results, in order to calculate status for a |
|
| 1678 | - // host with application names for each result. |
|
| 1679 | - $sqlall = "SELECT user_friendly_name," |
|
| 1680 | - ."r.appid as appid," |
|
| 1681 | - ."r.server_state AS server_state," |
|
| 1682 | - ."r.outcome AS outcome," |
|
| 1683 | - ."r.client_state AS client_state," |
|
| 1684 | - ."r.validate_state AS validate_state," |
|
| 1685 | - ."r.exit_status AS exit_status " |
|
| 1686 | - ."FROM {result} AS r " |
|
| 1687 | - ."INNER JOIN {app} AS a " |
|
| 1688 | - ."ON r.appid=a.id "; |
|
| 1689 | - |
|
| 1690 | - // Use userid, hostid, or workunitid |
|
| 1691 | - if ($category==0) { |
|
| 1666 | + ); |
|
| 1667 | + // Array to hold pretty-print result data to be displayed in a table. |
|
| 1668 | + $resultdata = array(); |
|
| 1669 | + // Arrays for applications. Form below uses $applications as parameter. |
|
| 1670 | + $application_map = array(); |
|
| 1671 | + $application_select_count = array(); |
|
| 1672 | + $applications = array(); |
|
| 1673 | + |
|
| 1674 | + // BOINC DB queries for results, application names |
|
| 1675 | + db_set_active('boinc_ro'); |
|
| 1676 | + |
|
| 1677 | + // Query to retreive all results, in order to calculate status for a |
|
| 1678 | + // host with application names for each result. |
|
| 1679 | + $sqlall = "SELECT user_friendly_name," |
|
| 1680 | + ."r.appid as appid," |
|
| 1681 | + ."r.server_state AS server_state," |
|
| 1682 | + ."r.outcome AS outcome," |
|
| 1683 | + ."r.client_state AS client_state," |
|
| 1684 | + ."r.validate_state AS validate_state," |
|
| 1685 | + ."r.exit_status AS exit_status " |
|
| 1686 | + ."FROM {result} AS r " |
|
| 1687 | + ."INNER JOIN {app} AS a " |
|
| 1688 | + ."ON r.appid=a.id "; |
|
| 1689 | + |
|
| 1690 | + // Use userid, hostid, or workunitid |
|
| 1691 | + if ($category==0) { |
|
| 1692 | 1692 | $sqlall .= " WHERE r.userid='%s' "; |
| 1693 | - } |
|
| 1694 | - elseif ($category==1) { |
|
| 1693 | + } |
|
| 1694 | + elseif ($category==1) { |
|
| 1695 | 1695 | $sqlall .= " WHERE r.workunitid='%s' "; |
| 1696 | - } |
|
| 1697 | - elseif ($category==2) { |
|
| 1696 | + } |
|
| 1697 | + elseif ($category==2) { |
|
| 1698 | 1698 | $sqlall .= " WHERE r.hostid='%s' "; |
| 1699 | - } |
|
| 1700 | - $sqlall .= " ORDER BY user_friendly_name"; |
|
| 1701 | - $dbres_all = db_query($sqlall, $queryid); |
|
| 1702 | - db_set_active('default'); |
|
| 1699 | + } |
|
| 1700 | + $sqlall .= " ORDER BY user_friendly_name"; |
|
| 1701 | + $dbres_all = db_query($sqlall, $queryid); |
|
| 1702 | + db_set_active('default'); |
|
| 1703 | 1703 | |
| 1704 | - // Loop 1 of DB results |
|
| 1705 | - if ($dbres_all) { |
|
| 1704 | + // Loop 1 of DB results |
|
| 1705 | + if ($dbres_all) { |
|
| 1706 | 1706 | while ($result = db_fetch_object($dbres_all)) { |
| 1707 | - $mystate = state_num($result); |
|
| 1708 | - if ( ($result->appid==$app_id) OR ($app_id==0) OR ($app_id==-1) ) { |
|
| 1707 | + $mystate = state_num($result); |
|
| 1708 | + if ( ($result->appid==$app_id) OR ($app_id==0) OR ($app_id==-1) ) { |
|
| 1709 | 1709 | $taskstates[STATE_ALL]++; |
| 1710 | 1710 | switch ($mystate) { |
| 1711 | 1711 | case STATE_IN_PROGRESS: |
| 1712 | 1712 | $taskstates[STATE_IN_PROGRESS]++; |
| 1713 | - break; |
|
| 1713 | + break; |
|
| 1714 | 1714 | case STATE_PENDING: |
| 1715 | 1715 | $taskstates[STATE_PENDING]++; |
| 1716 | - break; |
|
| 1716 | + break; |
|
| 1717 | 1717 | case STATE_VALID: |
| 1718 | 1718 | $taskstates[STATE_VALID]++; |
| 1719 | - break; |
|
| 1719 | + break; |
|
| 1720 | 1720 | case STATE_INVALID: |
| 1721 | 1721 | $taskstates[STATE_INVALID]++; |
| 1722 | - break; |
|
| 1722 | + break; |
|
| 1723 | 1723 | case STATE_ERROR: |
| 1724 | 1724 | $taskstates[STATE_ERROR]++; |
| 1725 | - break; |
|
| 1725 | + break; |
|
| 1726 | 1726 | } |
| 1727 | - }// if app_id |
|
| 1727 | + }// if app_id |
|
| 1728 | 1728 | |
| 1729 | - //map holds a map between app ids and user friendly names for all applications. |
|
| 1730 | - $application_map[$result->appid] = $result->user_friendly_name; |
|
| 1731 | - if ( ($mystate == $tselect) OR ($tselect==STATE_ALL) ) { |
|
| 1729 | + //map holds a map between app ids and user friendly names for all applications. |
|
| 1730 | + $application_map[$result->appid] = $result->user_friendly_name; |
|
| 1731 | + if ( ($mystate == $tselect) OR ($tselect==STATE_ALL) ) { |
|
| 1732 | 1732 | //count of appids in the results. |
| 1733 | 1733 | $application_select_count[$result->appid]++; |
| 1734 | - }// if mystate |
|
| 1734 | + }// if mystate |
|
| 1735 | 1735 | |
| 1736 | 1736 | }// while |
| 1737 | - } |
|
| 1738 | - else { |
|
| 1739 | - } |
|
| 1737 | + } |
|
| 1738 | + else { |
|
| 1739 | + } |
|
| 1740 | 1740 | |
| 1741 | - // Entry for all applications. |
|
| 1742 | - $allcount = $application_select_count ? array_sum($application_select_count) : 0; |
|
| 1743 | - $applications[-1] = bts('Application', array(), NULL, 'boinc:task-table'); |
|
| 1744 | - $applications[0] = bts('All applications', array(), NULL, 'boinc:task-table') . ' (' . $allcount . ')'; |
|
| 1745 | - // Create application filter from application_map and application_select_count. |
|
| 1746 | - foreach($application_map as $akey => $aname) { |
|
| 1741 | + // Entry for all applications. |
|
| 1742 | + $allcount = $application_select_count ? array_sum($application_select_count) : 0; |
|
| 1743 | + $applications[-1] = bts('Application', array(), NULL, 'boinc:task-table'); |
|
| 1744 | + $applications[0] = bts('All applications', array(), NULL, 'boinc:task-table') . ' (' . $allcount . ')'; |
|
| 1745 | + // Create application filter from application_map and application_select_count. |
|
| 1746 | + foreach($application_map as $akey => $aname) { |
|
| 1747 | 1747 | $acount = 0; |
| 1748 | 1748 | if ( $application_select_count and array_key_exists($akey, $application_select_count) ) { |
| 1749 | - $acount = $application_select_count[$akey]; |
|
| 1749 | + $acount = $application_select_count[$akey]; |
|
| 1750 | 1750 | } |
| 1751 | 1751 | $applications[$akey] = $aname . ' ('. $acount . ')'; |
| 1752 | - } |
|
| 1753 | - // Header array for (sub) results table. |
|
| 1754 | - $resultheader = array( |
|
| 1752 | + } |
|
| 1753 | + // Header array for (sub) results table. |
|
| 1754 | + $resultheader = array( |
|
| 1755 | 1755 | array( |
| 1756 | - 'data' => bts('Task ID', array(), NULL, 'boinc:task-table'), |
|
| 1757 | - 'field' => 'id', |
|
| 1756 | + 'data' => bts('Task ID', array(), NULL, 'boinc:task-table'), |
|
| 1757 | + 'field' => 'id', |
|
| 1758 | 1758 | ), |
| 1759 | 1759 | array( |
| 1760 | - 'data' => bts('Workunit ID', array(), NULL, 'boinc:task-table'), |
|
| 1761 | - 'field' => 'workunitid', |
|
| 1760 | + 'data' => bts('Workunit ID', array(), NULL, 'boinc:task-table'), |
|
| 1761 | + 'field' => 'workunitid', |
|
| 1762 | 1762 | ), |
| 1763 | 1763 | array( |
| 1764 | - 'data' => bts('Computer', array(), NULL, 'boinc:task-table'), |
|
| 1765 | - 'field' => 'hostid', |
|
| 1764 | + 'data' => bts('Computer', array(), NULL, 'boinc:task-table'), |
|
| 1765 | + 'field' => 'hostid', |
|
| 1766 | 1766 | ), |
| 1767 | 1767 | array( |
| 1768 | - 'data' => bts('Sent', array(), NULL, 'boinc:task-table'), |
|
| 1769 | - 'field' => 'sent_time', |
|
| 1768 | + 'data' => bts('Sent', array(), NULL, 'boinc:task-table'), |
|
| 1769 | + 'field' => 'sent_time', |
|
| 1770 | 1770 | ), |
| 1771 | 1771 | array( |
| 1772 | - 'data' => bts('Time Reported or Deadline', array(), NULL, 'boinc:task-table') |
|
| 1772 | + 'data' => bts('Time Reported or Deadline', array(), NULL, 'boinc:task-table') |
|
| 1773 | 1773 | ), |
| 1774 | 1774 | array( |
| 1775 | - 'data' => bts('Status', array(), NULL, 'boinc:task-table') |
|
| 1775 | + 'data' => bts('Status', array(), NULL, 'boinc:task-table') |
|
| 1776 | 1776 | ), |
| 1777 | 1777 | array( |
| 1778 | - 'data' => bts('Run time', array(), NULL, 'boinc:task-table'), |
|
| 1779 | - 'field' => 'elapsed_time', |
|
| 1778 | + 'data' => bts('Run time', array(), NULL, 'boinc:task-table'), |
|
| 1779 | + 'field' => 'elapsed_time', |
|
| 1780 | 1780 | ), |
| 1781 | 1781 | array( |
| 1782 | - 'data' => bts('CPU time', array(), NULL, 'boinc:task-table'), |
|
| 1783 | - 'field' => 'cpu_time', |
|
| 1782 | + 'data' => bts('CPU time', array(), NULL, 'boinc:task-table'), |
|
| 1783 | + 'field' => 'cpu_time', |
|
| 1784 | 1784 | ), |
| 1785 | 1785 | array( |
| 1786 | - 'data' => bts('Granted Credit', array(), NULL, 'boinc:task-table'), |
|
| 1787 | - 'field' => 'granted_credit', |
|
| 1786 | + 'data' => bts('Granted Credit', array(), NULL, 'boinc:task-table'), |
|
| 1787 | + 'field' => 'granted_credit', |
|
| 1788 | 1788 | ), |
| 1789 | 1789 | // Application is a column, but won't be added until after tablesort_sql(). |
| 1790 | - ); |
|
| 1791 | - |
|
| 1792 | - // Query to retreive a subset of the total results for the results table. |
|
| 1793 | - db_set_active('boinc_ro'); |
|
| 1794 | - $sqlsub = "SELECT r.id AS id," |
|
| 1795 | - ."r.name AS name," |
|
| 1796 | - ."r.workunitid AS workunitid," |
|
| 1797 | - ."r.hostid as hostid," |
|
| 1798 | - ."r.sent_time AS sent_time," |
|
| 1799 | - ."r.received_time AS received_time," |
|
| 1800 | - ."r.report_deadline AS report_deadline," |
|
| 1801 | - ."r.server_state AS server_state," |
|
| 1802 | - ."r.outcome AS outcome," |
|
| 1803 | - ."r.client_state AS client_state," |
|
| 1804 | - ."r.validate_state AS validate_state," |
|
| 1805 | - ."r.exit_status AS exit_status," |
|
| 1806 | - ."r.elapsed_time AS elapsed_time," |
|
| 1807 | - ."r.cpu_time AS cpu_time," |
|
| 1808 | - ."r.granted_credit AS granted_credit," |
|
| 1809 | - ."r.appid AS appid," |
|
| 1810 | - ."r.app_version_id AS app_version_id," |
|
| 1811 | - ."a.user_friendly_name," |
|
| 1812 | - ."av.version_num AS version_number," |
|
| 1813 | - ."av.plan_class AS plan_class," |
|
| 1814 | - ."pl.name AS platform " |
|
| 1815 | - ."FROM {result} AS r " |
|
| 1816 | - ."INNER JOIN {app} AS a " |
|
| 1817 | - ."ON r.appid=a.id " |
|
| 1818 | - ."LEFT JOIN {app_version} AS av " |
|
| 1819 | - ."ON r.app_version_id=av.id " |
|
| 1820 | - ."LEFT JOIN {platform} AS pl " |
|
| 1821 | - ."ON av.platformid=pl.id "; |
|
| 1822 | - |
|
| 1823 | - // Build an array for the WHERE clauses. The individual clauses are |
|
| 1824 | - // placed into an array, and implode() is used to combine them into |
|
| 1825 | - // a WHERE statement for the sql query. If no such clauses are added |
|
| 1826 | - // to the array, then no WHERE statement will be included. |
|
| 1827 | - $sqlwhere = array(); |
|
| 1828 | - |
|
| 1829 | - // Use userid, hostid, or workunitid |
|
| 1830 | - if ($category==0) { |
|
| 1790 | + ); |
|
| 1791 | + |
|
| 1792 | + // Query to retreive a subset of the total results for the results table. |
|
| 1793 | + db_set_active('boinc_ro'); |
|
| 1794 | + $sqlsub = "SELECT r.id AS id," |
|
| 1795 | + ."r.name AS name," |
|
| 1796 | + ."r.workunitid AS workunitid," |
|
| 1797 | + ."r.hostid as hostid," |
|
| 1798 | + ."r.sent_time AS sent_time," |
|
| 1799 | + ."r.received_time AS received_time," |
|
| 1800 | + ."r.report_deadline AS report_deadline," |
|
| 1801 | + ."r.server_state AS server_state," |
|
| 1802 | + ."r.outcome AS outcome," |
|
| 1803 | + ."r.client_state AS client_state," |
|
| 1804 | + ."r.validate_state AS validate_state," |
|
| 1805 | + ."r.exit_status AS exit_status," |
|
| 1806 | + ."r.elapsed_time AS elapsed_time," |
|
| 1807 | + ."r.cpu_time AS cpu_time," |
|
| 1808 | + ."r.granted_credit AS granted_credit," |
|
| 1809 | + ."r.appid AS appid," |
|
| 1810 | + ."r.app_version_id AS app_version_id," |
|
| 1811 | + ."a.user_friendly_name," |
|
| 1812 | + ."av.version_num AS version_number," |
|
| 1813 | + ."av.plan_class AS plan_class," |
|
| 1814 | + ."pl.name AS platform " |
|
| 1815 | + ."FROM {result} AS r " |
|
| 1816 | + ."INNER JOIN {app} AS a " |
|
| 1817 | + ."ON r.appid=a.id " |
|
| 1818 | + ."LEFT JOIN {app_version} AS av " |
|
| 1819 | + ."ON r.app_version_id=av.id " |
|
| 1820 | + ."LEFT JOIN {platform} AS pl " |
|
| 1821 | + ."ON av.platformid=pl.id "; |
|
| 1822 | + |
|
| 1823 | + // Build an array for the WHERE clauses. The individual clauses are |
|
| 1824 | + // placed into an array, and implode() is used to combine them into |
|
| 1825 | + // a WHERE statement for the sql query. If no such clauses are added |
|
| 1826 | + // to the array, then no WHERE statement will be included. |
|
| 1827 | + $sqlwhere = array(); |
|
| 1828 | + |
|
| 1829 | + // Use userid, hostid, or workunitid |
|
| 1830 | + if ($category==0) { |
|
| 1831 | 1831 | $sqlwhere[] = "r.userid = '%s'"; |
| 1832 | - } |
|
| 1833 | - elseif ($category==1) { |
|
| 1832 | + } |
|
| 1833 | + elseif ($category==1) { |
|
| 1834 | 1834 | $sqlwhere[] = "r.workunitid = '%s'"; |
| 1835 | - } |
|
| 1836 | - elseif ($category==2) { |
|
| 1835 | + } |
|
| 1836 | + elseif ($category==2) { |
|
| 1837 | 1837 | $sqlwhere[] = "r.hostid = '%s'"; |
| 1838 | - } |
|
| 1838 | + } |
|
| 1839 | 1839 | |
| 1840 | - // Append additional where clauses based on task selection. |
|
| 1841 | - switch ($tselect) { |
|
| 1842 | - case STATE_IN_PROGRESS: |
|
| 1840 | + // Append additional where clauses based on task selection. |
|
| 1841 | + switch ($tselect) { |
|
| 1842 | + case STATE_IN_PROGRESS: |
|
| 1843 | 1843 | $sqlwhere[] = "r.server_state = 4"; |
| 1844 | 1844 | break; |
| 1845 | - case STATE_PENDING: |
|
| 1845 | + case STATE_PENDING: |
|
| 1846 | 1846 | $sqlwhere[] = "(r.server_state = 5) AND (r.outcome = 1) AND (r.validate_state >= 0) AND (r.validate_state <= 0 OR r.validate_state >= 4) AND (r.validate_state <= 4)"; |
| 1847 | 1847 | break; |
| 1848 | - case STATE_VALID: |
|
| 1848 | + case STATE_VALID: |
|
| 1849 | 1849 | $sqlwhere[] = "(r.server_state = 5) AND (r.outcome = 1) AND (r.validate_state = 1)"; |
| 1850 | 1850 | break; |
| 1851 | - case STATE_INVALID: |
|
| 1851 | + case STATE_INVALID: |
|
| 1852 | 1852 | $sqlwhere[] = "(r.server_state = 5) AND ((r.outcome = 6) OR ((r.outcome = 1) AND ((r.validate_state = 2) OR (r.validate_state = 3) OR (r.validate_state = 5))))"; |
| 1853 | 1853 | break; |
| 1854 | - case STATE_ERROR: |
|
| 1854 | + case STATE_ERROR: |
|
| 1855 | 1855 | $sqlwhere[] = "(r.server_state = 5) AND (r.outcome >= 3) AND (r.outcome <= 4 OR r.outcome >= 7) AND (r.outcome <= 7)"; |
| 1856 | 1856 | break; |
| 1857 | - default: |
|
| 1857 | + default: |
|
| 1858 | 1858 | } |
| 1859 | 1859 | |
| 1860 | - if (is_numeric($app_id) AND $app_id>0 ) { |
|
| 1860 | + if (is_numeric($app_id) AND $app_id>0 ) { |
|
| 1861 | 1861 | $sqlwhere[] = "r.appid = '%s'"; |
| 1862 | 1862 | if ($sqlwhere) $sqlsub .= " WHERE " . implode(' AND ', $sqlwhere); |
| 1863 | 1863 | $dbres_sub = pager_query( $sqlsub . tablesort_sql($resultheader), $tablerows, 0, NULL, $queryid, $app_id); |
| 1864 | - } |
|
| 1865 | - else { |
|
| 1864 | + } |
|
| 1865 | + else { |
|
| 1866 | 1866 | if ($sqlwhere) $sqlsub .= " WHERE " . implode(' AND ', $sqlwhere); |
| 1867 | 1867 | $dbres_sub = pager_query( $sqlsub . tablesort_sql($resultheader), $tablerows, 0, NULL, $queryid); |
| 1868 | - } |
|
| 1869 | - db_set_active('default'); |
|
| 1868 | + } |
|
| 1869 | + db_set_active('default'); |
|
| 1870 | 1870 | |
| 1871 | - // Loop 2 over DB results. |
|
| 1872 | - if ($dbres_sub) { |
|
| 1871 | + // Loop 2 over DB results. |
|
| 1872 | + if ($dbres_sub) { |
|
| 1873 | 1873 | while ($result = db_fetch_object($dbres_sub)) { |
| 1874 | - // state_num() function changes $result object, clone $result |
|
| 1875 | - // object for use in state_num() |
|
| 1876 | - // check if state matches selection |
|
| 1877 | - if ( (state_num(clone $result) == $tselect) OR ($tselect==STATE_ALL) ) { |
|
| 1874 | + // state_num() function changes $result object, clone $result |
|
| 1875 | + // object for use in state_num() |
|
| 1876 | + // check if state matches selection |
|
| 1877 | + if ( (state_num(clone $result) == $tselect) OR ($tselect==STATE_ALL) ) { |
|
| 1878 | 1878 | // create pretty result row |
| 1879 | 1879 | $prettyresult = array( |
| 1880 | - array( |
|
| 1880 | + array( |
|
| 1881 | 1881 | 'data' => l($result->name, "task/{$result->id}"), |
| 1882 | 1882 | 'class' => 'task-name', |
| 1883 | - ), |
|
| 1884 | - l($result->workunitid, "workunit/{$result->workunitid}"), |
|
| 1885 | - l($result->hostid, "host/{$result->hostid}"), |
|
| 1886 | - date('j M Y G:i:s T', $result->sent_time), |
|
| 1887 | - boincwork_task_time_reported($result->received_time, $result->report_deadline), |
|
| 1888 | - state_string($result), |
|
| 1889 | - $nf->format($result->elapsed_time), |
|
| 1890 | - $nf->format($result->cpu_time), |
|
| 1891 | - $nf->format($result->granted_credit), |
|
| 1892 | - array( |
|
| 1883 | + ), |
|
| 1884 | + l($result->workunitid, "workunit/{$result->workunitid}"), |
|
| 1885 | + l($result->hostid, "host/{$result->hostid}"), |
|
| 1886 | + date('j M Y G:i:s T', $result->sent_time), |
|
| 1887 | + boincwork_task_time_reported($result->received_time, $result->report_deadline), |
|
| 1888 | + state_string($result), |
|
| 1889 | + $nf->format($result->elapsed_time), |
|
| 1890 | + $nf->format($result->cpu_time), |
|
| 1891 | + $nf->format($result->granted_credit), |
|
| 1892 | + array( |
|
| 1893 | 1893 | 'data' => $result->user_friendly_name . " " . pretty_application_version($result->app_version_id,$result->version_number, $result->plan_class, $result->platform), |
| 1894 | 1894 | 'class' => 'task-app', |
| 1895 | - ), |
|
| 1895 | + ), |
|
| 1896 | 1896 | ); |
| 1897 | 1897 | $resultdata[] = array_values($prettyresult); |
| 1898 | - } |
|
| 1898 | + } |
|
| 1899 | 1899 | }// while |
| 1900 | - } |
|
| 1901 | - else { |
|
| 1902 | - } |
|
| 1903 | - // Begin result navigation |
|
| 1900 | + } |
|
| 1901 | + else { |
|
| 1902 | + } |
|
| 1903 | + // Begin result navigation |
|
| 1904 | 1904 | |
| 1905 | - // Set pathprefix based on type |
|
| 1906 | - if ($category==0) { |
|
| 1905 | + // Set pathprefix based on type |
|
| 1906 | + if ($category==0) { |
|
| 1907 | 1907 | $pathprefix = 'account/tasks'; |
| 1908 | - } |
|
| 1909 | - elseif ($category==1) { |
|
| 1908 | + } |
|
| 1909 | + elseif ($category==1) { |
|
| 1910 | 1910 | $pathprefix = 'workunit/' . $queryid . '/tasks'; |
| 1911 | - } |
|
| 1912 | - elseif ($category==2) { |
|
| 1911 | + } |
|
| 1912 | + elseif ($category==2) { |
|
| 1913 | 1913 | $pathprefix = 'host/' . $queryid . '/tasks'; |
| 1914 | - } |
|
| 1915 | - // Need an "All" tab as well, maps to app_id of zero. |
|
| 1916 | - $application_map[0] = bts('All', array(), NULL, 'boinc:task-table'); |
|
| 1917 | - $stitems = array(); |
|
| 1918 | - foreach ($taskstates as $state => $numstates) { |
|
| 1914 | + } |
|
| 1915 | + // Need an "All" tab as well, maps to app_id of zero. |
|
| 1916 | + $application_map[0] = bts('All', array(), NULL, 'boinc:task-table'); |
|
| 1917 | + $stitems = array(); |
|
| 1918 | + foreach ($taskstates as $state => $numstates) { |
|
| 1919 | 1919 | $mypath = $pathprefix . '/' . $state . '/' . $app_id; |
| 1920 | 1920 | if ($state==STATE_ALL) { |
| 1921 | - $ltext = '<span class="tab task-app-name">' . bts('All', array(), NULL, 'boinc:task-table') . ' (' . $numstates . ')</span>'; |
|
| 1921 | + $ltext = '<span class="tab task-app-name">' . bts('All', array(), NULL, 'boinc:task-table') . ' (' . $numstates . ')</span>'; |
|
| 1922 | 1922 | } |
| 1923 | 1923 | else { |
| 1924 | - $ltext = '<span class="tab">' . bts($state_hnames[$state], array(), NULL, 'boinc:task-table') . ' (' . $numstates . ')</span>'; |
|
| 1924 | + $ltext = '<span class="tab">' . bts($state_hnames[$state], array(), NULL, 'boinc:task-table') . ' (' . $numstates . ')</span>'; |
|
| 1925 | 1925 | } |
| 1926 | 1926 | $myitem = array( |
| 1927 | - 'data' => l($ltext, $mypath, array('html' => TRUE) ), |
|
| 1927 | + 'data' => l($ltext, $mypath, array('html' => TRUE) ), |
|
| 1928 | 1928 | ); |
| 1929 | 1929 | if ($state==$tselect) { |
| 1930 | - $myitem['class'] = 'active'; |
|
| 1930 | + $myitem['class'] = 'active'; |
|
| 1931 | 1931 | } |
| 1932 | 1932 | $stitems[] = $myitem; |
| 1933 | - } |
|
| 1934 | - // Add reset button |
|
| 1935 | - $mypath = $pathprefix . '/0/0'; |
|
| 1936 | - $ltext = '<span class="tab">' . bts('Reset', array(), NULL, 'boinc:task-table') . '</span>'; |
|
| 1937 | - $stitems[] = array( 'data' => l($ltext, $mypath, array('html' => TRUE) ) ); |
|
| 1933 | + } |
|
| 1934 | + // Add reset button |
|
| 1935 | + $mypath = $pathprefix . '/0/0'; |
|
| 1936 | + $ltext = '<span class="tab">' . bts('Reset', array(), NULL, 'boinc:task-table') . '</span>'; |
|
| 1937 | + $stitems[] = array( 'data' => l($ltext, $mypath, array('html' => TRUE) ) ); |
|
| 1938 | 1938 | |
| 1939 | - $output .= theme_item_list($stitems, NULL, 'ul' . ' class="tabs secondary clearfix"'); |
|
| 1939 | + $output .= theme_item_list($stitems, NULL, 'ul' . ' class="tabs secondary clearfix"'); |
|
| 1940 | 1940 | |
| 1941 | - // Application select-drop down form |
|
| 1942 | - // Hack to place Application form into header |
|
| 1943 | - // App ID of zero maps to "-1" for drop-down box. |
|
| 1944 | - if ($app_id==0) { |
|
| 1941 | + // Application select-drop down form |
|
| 1942 | + // Hack to place Application form into header |
|
| 1943 | + // App ID of zero maps to "-1" for drop-down box. |
|
| 1944 | + if ($app_id==0) { |
|
| 1945 | 1945 | $app_id=-1; |
| 1946 | - } |
|
| 1947 | - $resultheader[] = drupal_get_form('boincwork_selectapp_form', $applications, $app_id); |
|
| 1946 | + } |
|
| 1947 | + $resultheader[] = drupal_get_form('boincwork_selectapp_form', $applications, $app_id); |
|
| 1948 | 1948 | |
| 1949 | - // Begin table of results |
|
| 1950 | - if ( is_array($resultheader) AND is_array($resultdata) ) { |
|
| 1949 | + // Begin table of results |
|
| 1950 | + if ( is_array($resultheader) AND is_array($resultdata) ) { |
|
| 1951 | 1951 | |
| 1952 | 1952 | // Take advantage of the fact that $category is the same as the row/column we want to remove. |
| 1953 | 1953 | if ( ($category==1) OR ($category==2) ) { |
| 1954 | - unset($resultheader[$category]); |
|
| 1955 | - delete_col($resultdata, $category); |
|
| 1954 | + unset($resultheader[$category]); |
|
| 1955 | + delete_col($resultdata, $category); |
|
| 1956 | 1956 | } |
| 1957 | 1957 | |
| 1958 | 1958 | $output .= theme_table($resultheader, $resultdata); |
| 1959 | 1959 | if (count($resultdata) > 0) { |
| 1960 | - $output .= theme('pager'); |
|
| 1960 | + $output .= theme('pager'); |
|
| 1961 | 1961 | } |
| 1962 | - } |
|
| 1963 | - return $output; |
|
| 1962 | + } |
|
| 1963 | + return $output; |
|
| 1964 | 1964 | } |
| 1965 | 1965 | |
| 1966 | 1966 | /** |
| 1967 | 1967 | * Function to delete a column from an array. |
| 1968 | 1968 | */ |
| 1969 | 1969 | function delete_col(&$array, $offset) { |
| 1970 | - return array_walk($array, function (&$v) use ($offset) { |
|
| 1971 | - array_splice($v, $offset, 1); |
|
| 1972 | - }); |
|
| 1970 | + return array_walk($array, function (&$v) use ($offset) { |
|
| 1971 | + array_splice($v, $offset, 1); |
|
| 1972 | + }); |
|
| 1973 | 1973 | } |
| 1974 | 1974 | |
| 1975 | 1975 | /** |
@@ -1989,7 +1989,7 @@ discard block |
||
| 1989 | 1989 | * platform name, may be NULL |
| 1990 | 1990 | */ |
| 1991 | 1991 | function pretty_application_version($appverid, $vernum, $plan_class, $plfm) { |
| 1992 | - switch ($appverid) { |
|
| 1992 | + switch ($appverid) { |
|
| 1993 | 1993 | case ANON_PLATFORM_UNKNOWN: |
| 1994 | 1994 | return "Anonymous platform"; |
| 1995 | 1995 | case ANON_PLATFORM_CPU: |
@@ -2008,11 +2008,11 @@ discard block |
||
| 2008 | 2008 | // that is not handled by the above case statements. |
| 2009 | 2009 | if ($appverid < 0) { |
| 2010 | 2010 | return "Unknown Anonymous platform"; |
| 2011 | - } |
|
| 2012 | - else { |
|
| 2011 | + } |
|
| 2012 | + else { |
|
| 2013 | 2013 | $prettyv = sprintf("%d.%02d", $vernum/100, $vernum%100); |
| 2014 | 2014 | $prettyc = ($plan_class) ? "($av->plan_class)" : ''; |
| 2015 | 2015 | return "v$prettyv $prettyc $plfm"; |
| 2016 | - } |
|
| 2017 | - } |
|
| 2016 | + } |
|
| 2017 | + } |
|
| 2018 | 2018 | } |
@@ -13,1660 +13,1660 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | function boincwork_views_data() { |
| 15 | 15 | |
| 16 | - // ----------------------------------------------------------------------------------------------- |
|
| 17 | - // Definition for host table |
|
| 18 | - // ----------------------------------------------------------------------------------------------- |
|
| 16 | + // ----------------------------------------------------------------------------------------------- |
|
| 17 | + // Definition for host table |
|
| 18 | + // ----------------------------------------------------------------------------------------------- |
|
| 19 | 19 | |
| 20 | - $data['host']['table']['group'] = t('BOINC'); |
|
| 20 | + $data['host']['table']['group'] = t('BOINC'); |
|
| 21 | 21 | |
| 22 | - $data['host']['table']['base'] = array( |
|
| 23 | - 'field' => 'id', |
|
| 24 | - 'title' => t('BOINC host'), |
|
| 25 | - 'help' => t('Computers attached to BOINC'), |
|
| 26 | - 'database' => 'boinc_ro' |
|
| 27 | - ); |
|
| 22 | + $data['host']['table']['base'] = array( |
|
| 23 | + 'field' => 'id', |
|
| 24 | + 'title' => t('BOINC host'), |
|
| 25 | + 'help' => t('Computers attached to BOINC'), |
|
| 26 | + 'database' => 'boinc_ro' |
|
| 27 | + ); |
|
| 28 | 28 | |
| 29 | - // This table references the {user} table. |
|
| 30 | - // This join creates an 'implicit' relationship to the user table, so that when |
|
| 31 | - // "User" is the base table, the fields are automatically available. |
|
| 29 | + // This table references the {user} table. |
|
| 30 | + // This join creates an 'implicit' relationship to the user table, so that when |
|
| 31 | + // "User" is the base table, the fields are automatically available. |
|
| 32 | 32 | |
| 33 | - // Index this array by the table name to which this table refers. |
|
| 34 | - // 'left_field' is the primary key in the referenced table. |
|
| 35 | - // 'field' is the foreign key in this table. |
|
| 33 | + // Index this array by the table name to which this table refers. |
|
| 34 | + // 'left_field' is the primary key in the referenced table. |
|
| 35 | + // 'field' is the foreign key in this table. |
|
| 36 | 36 | |
| 37 | - $data['host']['table']['join'] = array( |
|
| 37 | + $data['host']['table']['join'] = array( |
|
| 38 | 38 | 'user' => array( |
| 39 | - 'left_field' => 'id', |
|
| 40 | - 'field' => 'userid', |
|
| 39 | + 'left_field' => 'id', |
|
| 40 | + 'field' => 'userid', |
|
| 41 | 41 | ) |
| 42 | - ); |
|
| 42 | + ); |
|
| 43 | 43 | |
| 44 | - // Describe each of the individual fields in this table to Views. For |
|
| 45 | - // each field, you may define what field, sort, argument, and/or filter |
|
| 46 | - // handlers it supports. This will determine where in the Views interface you |
|
| 47 | - // may use the field. |
|
| 44 | + // Describe each of the individual fields in this table to Views. For |
|
| 45 | + // each field, you may define what field, sort, argument, and/or filter |
|
| 46 | + // handlers it supports. This will determine where in the Views interface you |
|
| 47 | + // may use the field. |
|
| 48 | 48 | |
| 49 | - // Primary keys allowed as arguments |
|
| 49 | + // Primary keys allowed as arguments |
|
| 50 | 50 | |
| 51 | - $data['host']['id'] = array( |
|
| 51 | + $data['host']['id'] = array( |
|
| 52 | 52 | 'title' => bts('Computer ID', array(), NULL, 'boinc:host-list'), |
| 53 | 53 | 'help' => t('The ID number of this host.'), |
| 54 | 54 | 'field' => array( |
| 55 | - 'handler' => 'views_handler_field_numeric', |
|
| 56 | - 'click sortable' => TRUE |
|
| 55 | + 'handler' => 'views_handler_field_numeric', |
|
| 56 | + 'click sortable' => TRUE |
|
| 57 | 57 | ), |
| 58 | 58 | 'argument' => array( |
| 59 | - 'handler' => 'views_handler_argument', |
|
| 60 | - 'name field' => 'title', |
|
| 61 | - 'numeric' => TRUE, |
|
| 62 | - 'validate type' => 'id' |
|
| 59 | + 'handler' => 'views_handler_argument', |
|
| 60 | + 'name field' => 'title', |
|
| 61 | + 'numeric' => TRUE, |
|
| 62 | + 'validate type' => 'id' |
|
| 63 | 63 | ), |
| 64 | 64 | 'filter' => array( |
| 65 | - 'handler' => 'views_handler_filter_numeric' |
|
| 65 | + 'handler' => 'views_handler_filter_numeric' |
|
| 66 | 66 | ), |
| 67 | 67 | 'sort' => array( |
| 68 | - 'handler' => 'views_handler_sort_numeric' |
|
| 68 | + 'handler' => 'views_handler_sort_numeric' |
|
| 69 | 69 | ) |
| 70 | - ); |
|
| 71 | - $data['host']['venue'] = array( |
|
| 70 | + ); |
|
| 71 | + $data['host']['venue'] = array( |
|
| 72 | 72 | 'title' => bts('Location', array(), NULL, 'boinc:host-list'), |
| 73 | 73 | 'help' => t('The name of the preference set assigned to this host.'), |
| 74 | 74 | 'field' => array( |
| 75 | - 'handler' => 'views_handler_field', |
|
| 76 | - 'click sortable' => TRUE |
|
| 75 | + 'handler' => 'views_handler_field', |
|
| 76 | + 'click sortable' => TRUE |
|
| 77 | 77 | ), |
| 78 | 78 | 'argument' => array( |
| 79 | - 'handler' => 'views_handler_argument', |
|
| 80 | - 'name field' => 'title' |
|
| 79 | + 'handler' => 'views_handler_argument', |
|
| 80 | + 'name field' => 'title' |
|
| 81 | 81 | ), |
| 82 | 82 | 'filter' => array( |
| 83 | - 'handler' => 'views_handler_filter_string' |
|
| 83 | + 'handler' => 'views_handler_filter_string' |
|
| 84 | 84 | ), |
| 85 | 85 | 'sort' => array( |
| 86 | - 'handler' => 'views_handler_sort_string' |
|
| 86 | + 'handler' => 'views_handler_sort_string' |
|
| 87 | 87 | ) |
| 88 | - ); |
|
| 88 | + ); |
|
| 89 | 89 | |
| 90 | - // Foreign key fields |
|
| 90 | + // Foreign key fields |
|
| 91 | 91 | |
| 92 | - $data['host']['userid'] = array( |
|
| 92 | + $data['host']['userid'] = array( |
|
| 93 | 93 | 'title' => bts('User ID', array(), NULL, 'boinc:user-details'), |
| 94 | 94 | 'help' => t('The owner of this host.'), |
| 95 | 95 | // Because this is a foreign key to the {user} table. This allows us to |
| 96 | 96 | // have, when the view is configured with this relationship, all the fields |
| 97 | 97 | // for the related node available. |
| 98 | 98 | 'argument' => array( |
| 99 | - 'handler' => 'views_handler_argument_boincuser_id', |
|
| 100 | - 'name field' => 'title', |
|
| 101 | - 'numeric' => TRUE, |
|
| 102 | - 'validate type' => 'id' |
|
| 99 | + 'handler' => 'views_handler_argument_boincuser_id', |
|
| 100 | + 'name field' => 'title', |
|
| 101 | + 'numeric' => TRUE, |
|
| 102 | + 'validate type' => 'id' |
|
| 103 | 103 | ), |
| 104 | 104 | 'relationship' => array( |
| 105 | - 'base' => 'user', |
|
| 106 | - 'field' => 'userid', |
|
| 107 | - 'handler' => 'views_handler_relationship', |
|
| 108 | - 'label' => t('User') |
|
| 105 | + 'base' => 'user', |
|
| 106 | + 'field' => 'userid', |
|
| 107 | + 'handler' => 'views_handler_relationship', |
|
| 108 | + 'label' => t('User') |
|
| 109 | 109 | ), |
| 110 | 110 | 'field' => array( |
| 111 | - 'handler' => 'views_handler_field_numeric', |
|
| 112 | - 'click sortable' => TRUE |
|
| 111 | + 'handler' => 'views_handler_field_numeric', |
|
| 112 | + 'click sortable' => TRUE |
|
| 113 | 113 | ), |
| 114 | 114 | 'filter' => array( |
| 115 | - 'handler' => 'views_handler_filter_numeric' |
|
| 115 | + 'handler' => 'views_handler_filter_numeric' |
|
| 116 | 116 | ), |
| 117 | 117 | 'sort' => array( |
| 118 | - 'handler' => 'views_handler_sort_numeric' |
|
| 118 | + 'handler' => 'views_handler_sort_numeric' |
|
| 119 | 119 | ) |
| 120 | - ); |
|
| 120 | + ); |
|
| 121 | 121 | |
| 122 | - // Descriptions of general host fields (alphabetized) |
|
| 122 | + // Descriptions of general host fields (alphabetized) |
|
| 123 | 123 | |
| 124 | - $data['host']['active_frac'] = array( |
|
| 124 | + $data['host']['active_frac'] = array( |
|
| 125 | 125 | 'title' => bts('While BOINC running, % of time work is allowed', array(), NULL, 'boinc:host-details'), |
| 126 | 126 | 'help' => t('The percentage of time that work is allowed.'), |
| 127 | 127 | 'field' => array( |
| 128 | - 'handler' => 'views_handler_field_numeric', |
|
| 129 | - 'click sortable' => TRUE, |
|
| 130 | - 'float' => TRUE |
|
| 128 | + 'handler' => 'views_handler_field_numeric', |
|
| 129 | + 'click sortable' => TRUE, |
|
| 130 | + 'float' => TRUE |
|
| 131 | 131 | ), |
| 132 | 132 | 'filter' => array( |
| 133 | - 'handler' => 'views_handler_filter_numeric' |
|
| 133 | + 'handler' => 'views_handler_filter_numeric' |
|
| 134 | 134 | ), |
| 135 | 135 | 'sort' => array( |
| 136 | - 'handler' => 'views_handler_sort_numeric' |
|
| 136 | + 'handler' => 'views_handler_sort_numeric' |
|
| 137 | 137 | ) |
| 138 | - ); |
|
| 139 | - $data['host']['avg_turnaround'] = array( |
|
| 138 | + ); |
|
| 139 | + $data['host']['avg_turnaround'] = array( |
|
| 140 | 140 | 'title' => bts('Average turnaround time', array(), NULL, 'boinc:host-details'), |
| 141 | 141 | 'help' => t('The average time required for work to be completed.'), |
| 142 | 142 | 'field' => array( |
| 143 | - 'handler' => 'views_handler_field_numeric', |
|
| 144 | - 'click sortable' => TRUE, |
|
| 145 | - 'float' => TRUE |
|
| 143 | + 'handler' => 'views_handler_field_numeric', |
|
| 144 | + 'click sortable' => TRUE, |
|
| 145 | + 'float' => TRUE |
|
| 146 | 146 | ), |
| 147 | 147 | 'filter' => array( |
| 148 | - 'handler' => 'views_handler_filter_numeric' |
|
| 148 | + 'handler' => 'views_handler_filter_numeric' |
|
| 149 | 149 | ), |
| 150 | 150 | 'sort' => array( |
| 151 | - 'handler' => 'views_handler_sort_numeric' |
|
| 151 | + 'handler' => 'views_handler_sort_numeric' |
|
| 152 | 152 | ) |
| 153 | - ); |
|
| 154 | - $data['host']['create_time'] = array( |
|
| 153 | + ); |
|
| 154 | + $data['host']['create_time'] = array( |
|
| 155 | 155 | 'title' => bts('Created', array(), NULL, 'boinc:host-details'), |
| 156 | 156 | 'help' => t('The time the host record was created.'), |
| 157 | 157 | 'field' => array( |
| 158 | - 'handler' => 'views_handler_field_date', |
|
| 159 | - 'click sortable' => TRUE |
|
| 158 | + 'handler' => 'views_handler_field_date', |
|
| 159 | + 'click sortable' => TRUE |
|
| 160 | 160 | ), |
| 161 | 161 | 'filter' => array( |
| 162 | - 'handler' => 'views_handler_filter_date' |
|
| 162 | + 'handler' => 'views_handler_filter_date' |
|
| 163 | 163 | ), |
| 164 | 164 | 'sort' => array( |
| 165 | - 'handler' => 'views_handler_sort_date' |
|
| 165 | + 'handler' => 'views_handler_sort_date' |
|
| 166 | 166 | ) |
| 167 | - ); |
|
| 168 | - $data['host']['connected_frac'] = array( |
|
| 167 | + ); |
|
| 168 | + $data['host']['connected_frac'] = array( |
|
| 169 | 169 | 'title' => bts('While BOINC running, % of time host has an Internet connection', array(), NULL, 'boinc:host-details'), |
| 170 | 170 | 'help' => t('The percentage of time that the host has an Internet connection.'), |
| 171 | 171 | 'field' => array( |
| 172 | - 'handler' => 'views_handler_field_numeric', |
|
| 173 | - 'click sortable' => TRUE, |
|
| 174 | - 'float' => TRUE |
|
| 172 | + 'handler' => 'views_handler_field_numeric', |
|
| 173 | + 'click sortable' => TRUE, |
|
| 174 | + 'float' => TRUE |
|
| 175 | 175 | ), |
| 176 | 176 | 'filter' => array( |
| 177 | - 'handler' => 'views_handler_filter_numeric' |
|
| 177 | + 'handler' => 'views_handler_filter_numeric' |
|
| 178 | 178 | ), |
| 179 | 179 | 'sort' => array( |
| 180 | - 'handler' => 'views_handler_sort_numeric' |
|
| 180 | + 'handler' => 'views_handler_sort_numeric' |
|
| 181 | 181 | ) |
| 182 | - ); |
|
| 183 | - $data['host']['cpu_efficiency'] = array( |
|
| 182 | + ); |
|
| 183 | + $data['host']['cpu_efficiency'] = array( |
|
| 184 | 184 | 'title' => bts('Average CPU efficiency', array(), NULL, 'boinc:host-details'), |
| 185 | 185 | 'help' => t('The average efficiency of the host CPU.'), |
| 186 | 186 | 'field' => array( |
| 187 | - 'handler' => 'views_handler_field_numeric', |
|
| 188 | - 'click sortable' => TRUE, |
|
| 189 | - 'float' => TRUE |
|
| 187 | + 'handler' => 'views_handler_field_numeric', |
|
| 188 | + 'click sortable' => TRUE, |
|
| 189 | + 'float' => TRUE |
|
| 190 | 190 | ), |
| 191 | 191 | 'filter' => array( |
| 192 | - 'handler' => 'views_handler_filter_numeric' |
|
| 192 | + 'handler' => 'views_handler_filter_numeric' |
|
| 193 | 193 | ), |
| 194 | 194 | 'sort' => array( |
| 195 | - 'handler' => 'views_handler_sort_numeric' |
|
| 195 | + 'handler' => 'views_handler_sort_numeric' |
|
| 196 | 196 | ) |
| 197 | - ); |
|
| 198 | - $data['host']['d_free'] = array( |
|
| 197 | + ); |
|
| 198 | + $data['host']['d_free'] = array( |
|
| 199 | 199 | 'title' => bts('Free disk space', array(), NULL, 'boinc:host-details'), |
| 200 | 200 | 'help' => t('The amount of disk space that is not in use.'), |
| 201 | 201 | 'field' => array( |
| 202 | - 'handler' => 'views_handler_field_numeric', |
|
| 203 | - 'click sortable' => TRUE |
|
| 202 | + 'handler' => 'views_handler_field_numeric', |
|
| 203 | + 'click sortable' => TRUE |
|
| 204 | 204 | ), |
| 205 | 205 | 'filter' => array( |
| 206 | - 'handler' => 'views_handler_filter_numeric' |
|
| 206 | + 'handler' => 'views_handler_filter_numeric' |
|
| 207 | 207 | ), |
| 208 | 208 | 'sort' => array( |
| 209 | - 'handler' => 'views_handler_sort_numeric' |
|
| 209 | + 'handler' => 'views_handler_sort_numeric' |
|
| 210 | 210 | ) |
| 211 | - ); |
|
| 212 | - $data['host']['d_total'] = array( |
|
| 211 | + ); |
|
| 212 | + $data['host']['d_total'] = array( |
|
| 213 | 213 | 'title' => bts('Total disk space', array(), NULL, 'boinc:host-details'), |
| 214 | 214 | 'help' => t('The size of the disk on which BOINC is installed.'), |
| 215 | 215 | 'field' => array( |
| 216 | - 'handler' => 'views_handler_field_numeric', |
|
| 217 | - 'click sortable' => TRUE |
|
| 216 | + 'handler' => 'views_handler_field_numeric', |
|
| 217 | + 'click sortable' => TRUE |
|
| 218 | 218 | ), |
| 219 | 219 | 'filter' => array( |
| 220 | - 'handler' => 'views_handler_filter_numeric' |
|
| 220 | + 'handler' => 'views_handler_filter_numeric' |
|
| 221 | 221 | ), |
| 222 | 222 | 'sort' => array( |
| 223 | - 'handler' => 'views_handler_sort_numeric' |
|
| 223 | + 'handler' => 'views_handler_sort_numeric' |
|
| 224 | 224 | ) |
| 225 | - ); |
|
| 226 | - $data['host']['domain_name'] = array( |
|
| 225 | + ); |
|
| 226 | + $data['host']['domain_name'] = array( |
|
| 227 | 227 | 'title' => bts('Name', array(), NULL, 'boinc:details:-1:name-of-the-host-or-task-or-workunit-etc-being-viewed-ignoreoverwrite'), |
| 228 | 228 | 'help' => t('The name of the host.'), |
| 229 | 229 | 'field' => array( |
| 230 | - 'handler' => 'views_handler_field', |
|
| 231 | - 'click sortable' => TRUE |
|
| 230 | + 'handler' => 'views_handler_field', |
|
| 231 | + 'click sortable' => TRUE |
|
| 232 | 232 | ), |
| 233 | 233 | 'filter' => array( |
| 234 | - 'handler' => 'views_handler_filter_string' |
|
| 234 | + 'handler' => 'views_handler_filter_string' |
|
| 235 | 235 | ), |
| 236 | 236 | 'sort' => array( |
| 237 | - 'handler' => 'views_handler_sort_string' |
|
| 237 | + 'handler' => 'views_handler_sort_string' |
|
| 238 | 238 | ) |
| 239 | - ); |
|
| 240 | - $data['host']['duration_correction_factor'] = array( |
|
| 239 | + ); |
|
| 240 | + $data['host']['duration_correction_factor'] = array( |
|
| 241 | 241 | 'title' => bts('Task duration correction factor', array(), NULL, 'boinc:host-details'), |
| 242 | 242 | 'help' => t('Task duration correction factor.'), |
| 243 | 243 | 'field' => array( |
| 244 | - 'handler' => 'views_handler_field_numeric', |
|
| 245 | - 'click sortable' => TRUE, |
|
| 246 | - 'float' => TRUE |
|
| 244 | + 'handler' => 'views_handler_field_numeric', |
|
| 245 | + 'click sortable' => TRUE, |
|
| 246 | + 'float' => TRUE |
|
| 247 | 247 | ), |
| 248 | 248 | 'filter' => array( |
| 249 | - 'handler' => 'views_handler_filter_numeric' |
|
| 249 | + 'handler' => 'views_handler_filter_numeric' |
|
| 250 | 250 | ), |
| 251 | 251 | 'sort' => array( |
| 252 | - 'handler' => 'views_handler_sort_numeric' |
|
| 252 | + 'handler' => 'views_handler_sort_numeric' |
|
| 253 | 253 | ) |
| 254 | - ); |
|
| 255 | - $data['host']['expavg_credit'] = array( |
|
| 254 | + ); |
|
| 255 | + $data['host']['expavg_credit'] = array( |
|
| 256 | 256 | 'title' => bts('Avg. credit', array(), NULL, 'boinc:host-details'), |
| 257 | 257 | 'help' => t('A decaying average of credit per day.'), |
| 258 | 258 | 'field' => array( |
| 259 | - 'handler' => 'views_handler_field_numeric', |
|
| 260 | - 'click sortable' => TRUE, |
|
| 261 | - 'float' => TRUE |
|
| 259 | + 'handler' => 'views_handler_field_numeric', |
|
| 260 | + 'click sortable' => TRUE, |
|
| 261 | + 'float' => TRUE |
|
| 262 | 262 | ), |
| 263 | 263 | 'filter' => array( |
| 264 | - 'handler' => 'views_handler_filter_numeric' |
|
| 264 | + 'handler' => 'views_handler_filter_numeric' |
|
| 265 | 265 | ), |
| 266 | 266 | 'sort' => array( |
| 267 | - 'handler' => 'views_handler_sort_numeric' |
|
| 267 | + 'handler' => 'views_handler_sort_numeric' |
|
| 268 | 268 | ) |
| 269 | - ); |
|
| 270 | - $data['host']['external_ip_addr'] = array( |
|
| 269 | + ); |
|
| 270 | + $data['host']['external_ip_addr'] = array( |
|
| 271 | 271 | 'title' => bts('External IP address', array(), NULL, 'boinc:host-details'), |
| 272 | 272 | 'help' => t('The IP address from which the host last communicated.'), |
| 273 | 273 | 'field' => array( |
| 274 | - 'handler' => 'views_handler_field', |
|
| 275 | - 'click sortable' => TRUE |
|
| 274 | + 'handler' => 'views_handler_field', |
|
| 275 | + 'click sortable' => TRUE |
|
| 276 | 276 | ), |
| 277 | 277 | 'filter' => array( |
| 278 | - 'handler' => 'views_handler_filter_string' |
|
| 278 | + 'handler' => 'views_handler_filter_string' |
|
| 279 | 279 | ), |
| 280 | 280 | 'sort' => array( |
| 281 | - 'handler' => 'views_handler_sort_string' |
|
| 281 | + 'handler' => 'views_handler_sort_string' |
|
| 282 | 282 | ) |
| 283 | - ); |
|
| 284 | - $data['host']['host_cpid'] = array( |
|
| 283 | + ); |
|
| 284 | + $data['host']['host_cpid'] = array( |
|
| 285 | 285 | 'title' => bts('Cross project ID', array(), NULL, 'boinc:host-details'), |
| 286 | 286 | 'help' => t('The consistent identifier of the host across projects.'), |
| 287 | 287 | 'field' => array( |
| 288 | - 'handler' => 'views_handler_field', |
|
| 289 | - 'click sortable' => TRUE |
|
| 288 | + 'handler' => 'views_handler_field', |
|
| 289 | + 'click sortable' => TRUE |
|
| 290 | 290 | ), |
| 291 | 291 | 'filter' => array( |
| 292 | - 'handler' => 'views_handler_filter_string' |
|
| 292 | + 'handler' => 'views_handler_filter_string' |
|
| 293 | 293 | ), |
| 294 | 294 | 'sort' => array( |
| 295 | - 'handler' => 'views_handler_sort_string' |
|
| 295 | + 'handler' => 'views_handler_sort_string' |
|
| 296 | 296 | ) |
| 297 | - ); |
|
| 298 | - $data['host']['last_ip_addr'] = array( |
|
| 297 | + ); |
|
| 298 | + $data['host']['last_ip_addr'] = array( |
|
| 299 | 299 | 'title' => bts('Last IP address', array(), NULL, 'boinc:host-details'), |
| 300 | 300 | 'help' => t('The IP address of the host at last communication.'), |
| 301 | 301 | 'field' => array( |
| 302 | - 'handler' => 'views_handler_field', |
|
| 303 | - 'click sortable' => TRUE |
|
| 302 | + 'handler' => 'views_handler_field', |
|
| 303 | + 'click sortable' => TRUE |
|
| 304 | 304 | ), |
| 305 | 305 | 'filter' => array( |
| 306 | - 'handler' => 'views_handler_filter_string' |
|
| 306 | + 'handler' => 'views_handler_filter_string' |
|
| 307 | 307 | ), |
| 308 | 308 | 'sort' => array( |
| 309 | - 'handler' => 'views_handler_sort_string' |
|
| 309 | + 'handler' => 'views_handler_sort_string' |
|
| 310 | 310 | ) |
| 311 | - ); |
|
| 312 | - $data['host']['m_cache'] = array( |
|
| 311 | + ); |
|
| 312 | + $data['host']['m_cache'] = array( |
|
| 313 | 313 | 'title' => bts('Cache', array(), NULL, 'boinc:host-details'), |
| 314 | 314 | 'help' => t('The amount of cache on the processor(s).'), |
| 315 | 315 | 'field' => array( |
| 316 | - 'handler' => 'views_handler_field_numeric', |
|
| 317 | - 'click sortable' => TRUE |
|
| 316 | + 'handler' => 'views_handler_field_numeric', |
|
| 317 | + 'click sortable' => TRUE |
|
| 318 | 318 | ), |
| 319 | 319 | 'filter' => array( |
| 320 | - 'handler' => 'views_handler_filter_numeric' |
|
| 320 | + 'handler' => 'views_handler_filter_numeric' |
|
| 321 | 321 | ), |
| 322 | 322 | 'sort' => array( |
| 323 | - 'handler' => 'views_handler_sort_numeric' |
|
| 323 | + 'handler' => 'views_handler_sort_numeric' |
|
| 324 | 324 | ) |
| 325 | - ); |
|
| 326 | - $data['host']['m_nbytes'] = array( |
|
| 325 | + ); |
|
| 326 | + $data['host']['m_nbytes'] = array( |
|
| 327 | 327 | 'title' => bts('Memory', array(), NULL, 'boinc:host-details'), |
| 328 | 328 | 'help' => t('The amount of memory installed.'), |
| 329 | 329 | 'field' => array( |
| 330 | - 'handler' => 'views_handler_field_numeric', |
|
| 331 | - 'click sortable' => TRUE |
|
| 330 | + 'handler' => 'views_handler_field_numeric', |
|
| 331 | + 'click sortable' => TRUE |
|
| 332 | 332 | ), |
| 333 | 333 | 'filter' => array( |
| 334 | - 'handler' => 'views_handler_filter_numeric' |
|
| 334 | + 'handler' => 'views_handler_filter_numeric' |
|
| 335 | 335 | ), |
| 336 | 336 | 'sort' => array( |
| 337 | - 'handler' => 'views_handler_sort_numeric' |
|
| 337 | + 'handler' => 'views_handler_sort_numeric' |
|
| 338 | 338 | ) |
| 339 | - ); |
|
| 340 | - $data['host']['m_swap'] = array( |
|
| 339 | + ); |
|
| 340 | + $data['host']['m_swap'] = array( |
|
| 341 | 341 | 'title' => bts('Swap space', array(), NULL, 'boinc:host-details'), |
| 342 | 342 | 'help' => t('The amount of swap space configured.'), |
| 343 | 343 | 'field' => array( |
| 344 | - 'handler' => 'views_handler_field_numeric', |
|
| 345 | - 'click sortable' => TRUE |
|
| 344 | + 'handler' => 'views_handler_field_numeric', |
|
| 345 | + 'click sortable' => TRUE |
|
| 346 | 346 | ), |
| 347 | 347 | 'filter' => array( |
| 348 | - 'handler' => 'views_handler_filter_numeric' |
|
| 348 | + 'handler' => 'views_handler_filter_numeric' |
|
| 349 | 349 | ), |
| 350 | 350 | 'sort' => array( |
| 351 | - 'handler' => 'views_handler_sort_numeric' |
|
| 351 | + 'handler' => 'views_handler_sort_numeric' |
|
| 352 | 352 | ) |
| 353 | - ); |
|
| 354 | - $data['host']['max_results_day'] = array( |
|
| 353 | + ); |
|
| 354 | + $data['host']['max_results_day'] = array( |
|
| 355 | 355 | 'title' => bts('Maximum daily WU quota per CPU', array(), NULL, 'boinc:host-details'), |
| 356 | 356 | 'help' => t('The maximum number of workunits to be allocated per CPU.'), |
| 357 | 357 | 'field' => array( |
| 358 | - 'handler' => 'views_handler_field_numeric', |
|
| 359 | - 'click sortable' => TRUE |
|
| 358 | + 'handler' => 'views_handler_field_numeric', |
|
| 359 | + 'click sortable' => TRUE |
|
| 360 | 360 | ), |
| 361 | 361 | 'filter' => array( |
| 362 | - 'handler' => 'views_handler_filter_numeric' |
|
| 362 | + 'handler' => 'views_handler_filter_numeric' |
|
| 363 | 363 | ), |
| 364 | 364 | 'sort' => array( |
| 365 | - 'handler' => 'views_handler_sort_numeric' |
|
| 365 | + 'handler' => 'views_handler_sort_numeric' |
|
| 366 | 366 | ) |
| 367 | - ); |
|
| 368 | - $data['host']['n_bwdown'] = array( |
|
| 367 | + ); |
|
| 368 | + $data['host']['n_bwdown'] = array( |
|
| 369 | 369 | 'title' => bts('Average download rate', array(), NULL, 'boinc:host-details'), |
| 370 | 370 | 'help' => t('The average rate at which new work is downloaded.'), |
| 371 | 371 | 'field' => array( |
| 372 | - 'handler' => 'views_handler_field_numeric', |
|
| 373 | - 'click sortable' => TRUE, |
|
| 374 | - 'float' => TRUE |
|
| 372 | + 'handler' => 'views_handler_field_numeric', |
|
| 373 | + 'click sortable' => TRUE, |
|
| 374 | + 'float' => TRUE |
|
| 375 | 375 | ), |
| 376 | 376 | 'filter' => array( |
| 377 | - 'handler' => 'views_handler_filter_numeric' |
|
| 377 | + 'handler' => 'views_handler_filter_numeric' |
|
| 378 | 378 | ), |
| 379 | 379 | 'sort' => array( |
| 380 | - 'handler' => 'views_handler_sort_numeric' |
|
| 380 | + 'handler' => 'views_handler_sort_numeric' |
|
| 381 | 381 | ) |
| 382 | - ); |
|
| 383 | - $data['host']['n_bwup'] = array( |
|
| 382 | + ); |
|
| 383 | + $data['host']['n_bwup'] = array( |
|
| 384 | 384 | 'title' => bts('Average upload rate', array(), NULL, 'boinc:host-details'), |
| 385 | 385 | 'help' => t('The average rate at which completed work is uploaded.'), |
| 386 | 386 | 'field' => array( |
| 387 | - 'handler' => 'views_handler_field_numeric', |
|
| 388 | - 'click sortable' => TRUE, |
|
| 389 | - 'float' => TRUE |
|
| 387 | + 'handler' => 'views_handler_field_numeric', |
|
| 388 | + 'click sortable' => TRUE, |
|
| 389 | + 'float' => TRUE |
|
| 390 | 390 | ), |
| 391 | 391 | 'filter' => array( |
| 392 | - 'handler' => 'views_handler_filter_numeric' |
|
| 392 | + 'handler' => 'views_handler_filter_numeric' |
|
| 393 | 393 | ), |
| 394 | 394 | 'sort' => array( |
| 395 | - 'handler' => 'views_handler_sort_numeric' |
|
| 395 | + 'handler' => 'views_handler_sort_numeric' |
|
| 396 | 396 | ) |
| 397 | - ); |
|
| 398 | - $data['host']['nsame_ip_addr'] = array( |
|
| 397 | + ); |
|
| 398 | + $data['host']['nsame_ip_addr'] = array( |
|
| 399 | 399 | 'title' => bts('Same IP address count', array(), NULL, 'boinc:host-details'), |
| 400 | 400 | 'help' => t('The number of times the last IP address.'), |
| 401 | 401 | 'field' => array( |
| 402 | - 'handler' => 'views_handler_field', |
|
| 403 | - 'click sortable' => TRUE |
|
| 402 | + 'handler' => 'views_handler_field', |
|
| 403 | + 'click sortable' => TRUE |
|
| 404 | 404 | ), |
| 405 | 405 | 'filter' => array( |
| 406 | - 'handler' => 'views_handler_filter_string' |
|
| 406 | + 'handler' => 'views_handler_filter_string' |
|
| 407 | 407 | ), |
| 408 | 408 | 'sort' => array( |
| 409 | - 'handler' => 'views_handler_sort_string' |
|
| 409 | + 'handler' => 'views_handler_sort_string' |
|
| 410 | 410 | ) |
| 411 | - ); |
|
| 412 | - $data['host']['on_frac'] = array( |
|
| 411 | + ); |
|
| 412 | + $data['host']['on_frac'] = array( |
|
| 413 | 413 | 'title' => bts('% of time BOINC client is running', array(), NULL, 'boinc:host-details'), |
| 414 | 414 | 'help' => t('The percentage of time that the BOINC client is running.'), |
| 415 | 415 | 'field' => array( |
| 416 | - 'handler' => 'views_handler_field_numeric', |
|
| 417 | - 'click sortable' => TRUE, |
|
| 418 | - 'float' => TRUE |
|
| 416 | + 'handler' => 'views_handler_field_numeric', |
|
| 417 | + 'click sortable' => TRUE, |
|
| 418 | + 'float' => TRUE |
|
| 419 | 419 | ), |
| 420 | 420 | 'filter' => array( |
| 421 | - 'handler' => 'views_handler_filter_numeric' |
|
| 421 | + 'handler' => 'views_handler_filter_numeric' |
|
| 422 | 422 | ), |
| 423 | 423 | 'sort' => array( |
| 424 | - 'handler' => 'views_handler_sort_numeric' |
|
| 424 | + 'handler' => 'views_handler_sort_numeric' |
|
| 425 | 425 | ) |
| 426 | - ); |
|
| 427 | - $data['host']['os_name'] = array( |
|
| 426 | + ); |
|
| 427 | + $data['host']['os_name'] = array( |
|
| 428 | 428 | 'title' => bts('Operating system', array(), NULL, 'boinc:host-details'), |
| 429 | 429 | 'help' => t('The name of the host operating system.'), |
| 430 | 430 | 'field' => array( |
| 431 | - 'handler' => 'views_handler_field', |
|
| 432 | - 'click sortable' => TRUE |
|
| 431 | + 'handler' => 'views_handler_field', |
|
| 432 | + 'click sortable' => TRUE |
|
| 433 | 433 | ), |
| 434 | 434 | 'filter' => array( |
| 435 | - 'handler' => 'views_handler_filter_string' |
|
| 435 | + 'handler' => 'views_handler_filter_string' |
|
| 436 | 436 | ), |
| 437 | 437 | 'sort' => array( |
| 438 | - 'handler' => 'views_handler_sort_string' |
|
| 438 | + 'handler' => 'views_handler_sort_string' |
|
| 439 | 439 | ) |
| 440 | - ); |
|
| 441 | - $data['host']['os_version'] = array( |
|
| 440 | + ); |
|
| 441 | + $data['host']['os_version'] = array( |
|
| 442 | 442 | 'title' => bts('Operating system version', array(), NULL, 'boinc:host-details'), |
| 443 | 443 | 'help' => t('The version of the host operating system.'), |
| 444 | 444 | 'field' => array( |
| 445 | - 'handler' => 'views_handler_field', |
|
| 446 | - 'click sortable' => TRUE |
|
| 445 | + 'handler' => 'views_handler_field', |
|
| 446 | + 'click sortable' => TRUE |
|
| 447 | 447 | ), |
| 448 | 448 | 'filter' => array( |
| 449 | - 'handler' => 'views_handler_filter_string' |
|
| 449 | + 'handler' => 'views_handler_filter_string' |
|
| 450 | 450 | ), |
| 451 | 451 | 'sort' => array( |
| 452 | - 'handler' => 'views_handler_sort_string' |
|
| 452 | + 'handler' => 'views_handler_sort_string' |
|
| 453 | 453 | ) |
| 454 | - ); |
|
| 455 | - $data['host']['p_fpops'] = array( |
|
| 454 | + ); |
|
| 455 | + $data['host']['p_fpops'] = array( |
|
| 456 | 456 | 'title' => bts('Measured floating point speed', array(), NULL, 'boinc:host-details'), |
| 457 | 457 | 'help' => t('The capability of the host in floating point operations per second.'), |
| 458 | 458 | 'field' => array( |
| 459 | - 'handler' => 'views_handler_field_numeric', |
|
| 460 | - 'click sortable' => TRUE, |
|
| 461 | - 'float' => TRUE |
|
| 459 | + 'handler' => 'views_handler_field_numeric', |
|
| 460 | + 'click sortable' => TRUE, |
|
| 461 | + 'float' => TRUE |
|
| 462 | 462 | ), |
| 463 | 463 | 'filter' => array( |
| 464 | - 'handler' => 'views_handler_filter_numeric' |
|
| 464 | + 'handler' => 'views_handler_filter_numeric' |
|
| 465 | 465 | ), |
| 466 | 466 | 'sort' => array( |
| 467 | - 'handler' => 'views_handler_sort_numeric' |
|
| 467 | + 'handler' => 'views_handler_sort_numeric' |
|
| 468 | 468 | ) |
| 469 | - ); |
|
| 470 | - $data['host']['p_iops'] = array( |
|
| 469 | + ); |
|
| 470 | + $data['host']['p_iops'] = array( |
|
| 471 | 471 | 'title' => bts('Measured integer speed', array(), NULL, 'boinc:host-details'), |
| 472 | 472 | 'help' => t('The capability of the host in integer operations per second.'), |
| 473 | 473 | 'field' => array( |
| 474 | - 'handler' => 'views_handler_field_numeric', |
|
| 475 | - 'click sortable' => TRUE, |
|
| 476 | - 'float' => TRUE |
|
| 474 | + 'handler' => 'views_handler_field_numeric', |
|
| 475 | + 'click sortable' => TRUE, |
|
| 476 | + 'float' => TRUE |
|
| 477 | 477 | ), |
| 478 | 478 | 'filter' => array( |
| 479 | - 'handler' => 'views_handler_filter_numeric' |
|
| 479 | + 'handler' => 'views_handler_filter_numeric' |
|
| 480 | 480 | ), |
| 481 | 481 | 'sort' => array( |
| 482 | - 'handler' => 'views_handler_sort_numeric' |
|
| 482 | + 'handler' => 'views_handler_sort_numeric' |
|
| 483 | 483 | ) |
| 484 | - ); |
|
| 485 | - $data['host']['p_model'] = array( |
|
| 484 | + ); |
|
| 485 | + $data['host']['p_model'] = array( |
|
| 486 | 486 | 'title' => bts('CPU model', array(), NULL, 'boinc:host-details'), |
| 487 | 487 | 'help' => t('The model of the CPU in the host.'), |
| 488 | 488 | 'field' => array( |
| 489 | - 'handler' => 'views_handler_field', |
|
| 490 | - 'click sortable' => TRUE |
|
| 489 | + 'handler' => 'views_handler_field', |
|
| 490 | + 'click sortable' => TRUE |
|
| 491 | 491 | ), |
| 492 | 492 | 'filter' => array( |
| 493 | - 'handler' => 'views_handler_filter_string' |
|
| 493 | + 'handler' => 'views_handler_filter_string' |
|
| 494 | 494 | ), |
| 495 | 495 | 'sort' => array( |
| 496 | - 'handler' => 'views_handler_sort_string' |
|
| 496 | + 'handler' => 'views_handler_sort_string' |
|
| 497 | 497 | ) |
| 498 | - ); |
|
| 499 | - $data['host']['p_ncpus'] = array( |
|
| 498 | + ); |
|
| 499 | + $data['host']['p_ncpus'] = array( |
|
| 500 | 500 | 'title' => bts('Number of processors', array(), NULL, 'boinc:host-details'), |
| 501 | 501 | 'help' => t('The count of CPU cores in the system.'), |
| 502 | 502 | 'field' => array( |
| 503 | - 'handler' => 'views_handler_field', |
|
| 504 | - 'click sortable' => TRUE |
|
| 503 | + 'handler' => 'views_handler_field', |
|
| 504 | + 'click sortable' => TRUE |
|
| 505 | 505 | ), |
| 506 | 506 | 'filter' => array( |
| 507 | - 'handler' => 'views_handler_filter_string' |
|
| 507 | + 'handler' => 'views_handler_filter_string' |
|
| 508 | 508 | ), |
| 509 | 509 | 'sort' => array( |
| 510 | - 'handler' => 'views_handler_sort_string' |
|
| 510 | + 'handler' => 'views_handler_sort_string' |
|
| 511 | 511 | ) |
| 512 | - ); |
|
| 513 | - $data['host']['p_vendor'] = array( |
|
| 512 | + ); |
|
| 513 | + $data['host']['p_vendor'] = array( |
|
| 514 | 514 | 'title' => bts('CPU', array(), NULL, 'boinc:host-details'), |
| 515 | 515 | 'help' => t('The manufacturer of the CPU in the host.'), |
| 516 | 516 | 'field' => array( |
| 517 | - 'handler' => 'views_handler_field', |
|
| 518 | - 'click sortable' => TRUE |
|
| 517 | + 'handler' => 'views_handler_field', |
|
| 518 | + 'click sortable' => TRUE |
|
| 519 | 519 | ), |
| 520 | 520 | 'filter' => array( |
| 521 | - 'handler' => 'views_handler_filter_string' |
|
| 521 | + 'handler' => 'views_handler_filter_string' |
|
| 522 | 522 | ), |
| 523 | 523 | 'sort' => array( |
| 524 | - 'handler' => 'views_handler_sort_string' |
|
| 524 | + 'handler' => 'views_handler_sort_string' |
|
| 525 | 525 | ) |
| 526 | - ); |
|
| 527 | - $data['host']['rpc_seqno'] = array( |
|
| 526 | + ); |
|
| 527 | + $data['host']['rpc_seqno'] = array( |
|
| 528 | 528 | 'title' => bts('Number of times client has contacted server', array(), NULL, 'boinc:host-details'), |
| 529 | 529 | 'help' => t('The number of times the client has contacted the server.'), |
| 530 | 530 | 'field' => array( |
| 531 | - 'handler' => 'views_handler_field_numeric', |
|
| 532 | - 'click sortable' => TRUE |
|
| 531 | + 'handler' => 'views_handler_field_numeric', |
|
| 532 | + 'click sortable' => TRUE |
|
| 533 | 533 | ), |
| 534 | 534 | 'filter' => array( |
| 535 | - 'handler' => 'views_handler_filter_numeric' |
|
| 535 | + 'handler' => 'views_handler_filter_numeric' |
|
| 536 | 536 | ), |
| 537 | 537 | 'sort' => array( |
| 538 | - 'handler' => 'views_handler_sort_numeric' |
|
| 538 | + 'handler' => 'views_handler_sort_numeric' |
|
| 539 | 539 | ) |
| 540 | - ); |
|
| 541 | - $data['host']['rpc_time'] = array( |
|
| 540 | + ); |
|
| 541 | + $data['host']['rpc_time'] = array( |
|
| 542 | 542 | 'title' => bts('Last contact', array(), NULL, 'boinc:host-details'), |
| 543 | 543 | 'help' => t('The time of the last RPC contact with the host.'), |
| 544 | 544 | 'field' => array( |
| 545 | - 'handler' => 'views_handler_field_date', |
|
| 546 | - 'click sortable' => TRUE |
|
| 545 | + 'handler' => 'views_handler_field_date', |
|
| 546 | + 'click sortable' => TRUE |
|
| 547 | 547 | ), |
| 548 | 548 | 'filter' => array( |
| 549 | - 'handler' => 'views_handler_filter_date' |
|
| 549 | + 'handler' => 'views_handler_filter_date' |
|
| 550 | 550 | ), |
| 551 | 551 | 'sort' => array( |
| 552 | - 'handler' => 'views_handler_sort_date' |
|
| 552 | + 'handler' => 'views_handler_sort_date' |
|
| 553 | 553 | ) |
| 554 | - ); |
|
| 555 | - $data['host']['serialnum'] = array( |
|
| 554 | + ); |
|
| 555 | + $data['host']['serialnum'] = array( |
|
| 556 | 556 | 'title' => bts('Serial number', array(), NULL, 'boinc:host-details'), |
| 557 | 557 | 'help' => t('Contains the release number of the BOINC application in use and the GPU of the host.'), |
| 558 | 558 | 'field' => array( |
| 559 | - 'handler' => 'views_handler_field', |
|
| 560 | - 'click sortable' => TRUE |
|
| 559 | + 'handler' => 'views_handler_field', |
|
| 560 | + 'click sortable' => TRUE |
|
| 561 | 561 | ), |
| 562 | 562 | 'filter' => array( |
| 563 | - 'handler' => 'views_handler_filter_string' |
|
| 563 | + 'handler' => 'views_handler_filter_string' |
|
| 564 | 564 | ), |
| 565 | 565 | 'sort' => array( |
| 566 | - 'handler' => 'views_handler_sort_string' |
|
| 566 | + 'handler' => 'views_handler_sort_string' |
|
| 567 | 567 | ) |
| 568 | - ); |
|
| 569 | - $data['host']['timezone'] = array( |
|
| 568 | + ); |
|
| 569 | + $data['host']['timezone'] = array( |
|
| 570 | 570 | 'title' => bts('Timezone', array(), NULL, 'boinc:host-details'), |
| 571 | 571 | 'help' => t('The UTC offset of the local time.'), |
| 572 | 572 | 'field' => array( |
| 573 | - 'handler' => 'views_handler_field_numeric', |
|
| 574 | - 'click sortable' => TRUE |
|
| 573 | + 'handler' => 'views_handler_field_numeric', |
|
| 574 | + 'click sortable' => TRUE |
|
| 575 | 575 | ), |
| 576 | 576 | 'filter' => array( |
| 577 | - 'handler' => 'views_handler_filter_numeric' |
|
| 577 | + 'handler' => 'views_handler_filter_numeric' |
|
| 578 | 578 | ), |
| 579 | 579 | 'sort' => array( |
| 580 | - 'handler' => 'views_handler_sort_numeric' |
|
| 580 | + 'handler' => 'views_handler_sort_numeric' |
|
| 581 | 581 | ) |
| 582 | - ); |
|
| 583 | - $data['host']['total_credit'] = array( |
|
| 582 | + ); |
|
| 583 | + $data['host']['total_credit'] = array( |
|
| 584 | 584 | 'title' => bts('Total credit', array(), NULL, 'boinc:user-or-team-total-credits'), |
| 585 | 585 | 'help' => t('The total accumulated BOINC credit for a host.'), |
| 586 | 586 | 'field' => array( |
| 587 | - 'handler' => 'views_handler_field_numeric', |
|
| 588 | - 'click sortable' => TRUE, |
|
| 589 | - 'float' => TRUE |
|
| 587 | + 'handler' => 'views_handler_field_numeric', |
|
| 588 | + 'click sortable' => TRUE, |
|
| 589 | + 'float' => TRUE |
|
| 590 | 590 | ), |
| 591 | 591 | 'filter' => array( |
| 592 | - 'handler' => 'views_handler_filter_numeric' |
|
| 592 | + 'handler' => 'views_handler_filter_numeric' |
|
| 593 | 593 | ), |
| 594 | 594 | 'sort' => array( |
| 595 | - 'handler' => 'views_handler_sort_numeric' |
|
| 595 | + 'handler' => 'views_handler_sort_numeric' |
|
| 596 | 596 | ) |
| 597 | - ); |
|
| 597 | + ); |
|
| 598 | 598 | |
| 599 | - // ------------------------------------------------------------------------------------------------ |
|
| 600 | - // Definition for platform table |
|
| 601 | - // ------------------------------------------------------------------------------------------------ |
|
| 599 | + // ------------------------------------------------------------------------------------------------ |
|
| 600 | + // Definition for platform table |
|
| 601 | + // ------------------------------------------------------------------------------------------------ |
|
| 602 | 602 | |
| 603 | - $data['platform']['table']['group'] = t('BOINC'); |
|
| 604 | - $data['platform']['table']['base'] = array( |
|
| 605 | - 'field' => 'id', |
|
| 606 | - 'title' => t('BOINC platform'), |
|
| 607 | - 'help' => t('Operating system platforms'), |
|
| 608 | - 'database' => 'boinc_ro' |
|
| 609 | - ); |
|
| 603 | + $data['platform']['table']['group'] = t('BOINC'); |
|
| 604 | + $data['platform']['table']['base'] = array( |
|
| 605 | + 'field' => 'id', |
|
| 606 | + 'title' => t('BOINC platform'), |
|
| 607 | + 'help' => t('Operating system platforms'), |
|
| 608 | + 'database' => 'boinc_ro' |
|
| 609 | + ); |
|
| 610 | 610 | |
| 611 | - // Primary keys allowed as arguments |
|
| 611 | + // Primary keys allowed as arguments |
|
| 612 | 612 | |
| 613 | - $data['platform']['id'] = array( |
|
| 613 | + $data['platform']['id'] = array( |
|
| 614 | 614 | 'title' => bts('Platform ID', array(), NULL, 'boinc:platform-details'), |
| 615 | 615 | 'help' => t('The ID number of the platform.'), |
| 616 | 616 | 'field' => array( |
| 617 | - 'handler' => 'views_handler_field_numeric', |
|
| 618 | - 'click sortable' => TRUE |
|
| 617 | + 'handler' => 'views_handler_field_numeric', |
|
| 618 | + 'click sortable' => TRUE |
|
| 619 | 619 | ), |
| 620 | 620 | 'argument' => array( |
| 621 | - 'handler' => 'views_handler_argument', |
|
| 622 | - 'name field' => 'title', |
|
| 623 | - 'numeric' => TRUE, |
|
| 624 | - 'validate type' => 'id' |
|
| 621 | + 'handler' => 'views_handler_argument', |
|
| 622 | + 'name field' => 'title', |
|
| 623 | + 'numeric' => TRUE, |
|
| 624 | + 'validate type' => 'id' |
|
| 625 | 625 | ), |
| 626 | 626 | 'filter' => array( |
| 627 | - 'handler' => 'views_handler_filter_numeric' |
|
| 627 | + 'handler' => 'views_handler_filter_numeric' |
|
| 628 | 628 | ), |
| 629 | 629 | 'sort' => array( |
| 630 | - 'handler' => 'views_handler_sort_numeric' |
|
| 630 | + 'handler' => 'views_handler_sort_numeric' |
|
| 631 | 631 | ) |
| 632 | - ); |
|
| 632 | + ); |
|
| 633 | 633 | |
| 634 | - // Descriptions of app fields (alphabetized) |
|
| 634 | + // Descriptions of app fields (alphabetized) |
|
| 635 | 635 | |
| 636 | - $data['platform']['name'] = array( |
|
| 636 | + $data['platform']['name'] = array( |
|
| 637 | 637 | 'title' => bts('Name', array(), NULL, 'boinc:details:-1:name-of-the-host-or-task-or-workunit-etc-being-viewed-ignoreoverwrite'), |
| 638 | 638 | 'help' => t('The name of the platform.'), |
| 639 | 639 | 'field' => array( |
| 640 | - 'handler' => 'views_handler_field', |
|
| 641 | - 'click sortable' => TRUE |
|
| 640 | + 'handler' => 'views_handler_field', |
|
| 641 | + 'click sortable' => TRUE |
|
| 642 | 642 | ), |
| 643 | 643 | 'filter' => array( |
| 644 | - 'handler' => 'views_handler_filter_string' |
|
| 644 | + 'handler' => 'views_handler_filter_string' |
|
| 645 | 645 | ), |
| 646 | 646 | 'sort' => array( |
| 647 | - 'handler' => 'views_handler_sort_string' |
|
| 647 | + 'handler' => 'views_handler_sort_string' |
|
| 648 | 648 | ) |
| 649 | - ); |
|
| 649 | + ); |
|
| 650 | 650 | |
| 651 | - // ------------------------------------------------------------------------------------------------ |
|
| 652 | - // Definition for result (task) table |
|
| 653 | - // ------------------------------------------------------------------------------------------------ |
|
| 651 | + // ------------------------------------------------------------------------------------------------ |
|
| 652 | + // Definition for result (task) table |
|
| 653 | + // ------------------------------------------------------------------------------------------------ |
|
| 654 | 654 | |
| 655 | - $data['result']['table']['group'] = t('BOINC'); |
|
| 656 | - $data['result']['table']['base'] = array( |
|
| 657 | - 'field' => 'id', |
|
| 658 | - 'title' => t('BOINC result'), |
|
| 659 | - 'help' => t('Results produced by BOINC'), |
|
| 660 | - 'database' => 'boinc_ro' |
|
| 661 | - ); |
|
| 655 | + $data['result']['table']['group'] = t('BOINC'); |
|
| 656 | + $data['result']['table']['base'] = array( |
|
| 657 | + 'field' => 'id', |
|
| 658 | + 'title' => t('BOINC result'), |
|
| 659 | + 'help' => t('Results produced by BOINC'), |
|
| 660 | + 'database' => 'boinc_ro' |
|
| 661 | + ); |
|
| 662 | 662 | |
| 663 | - // Create implicit relationships to the user, workunit, and host tables |
|
| 663 | + // Create implicit relationships to the user, workunit, and host tables |
|
| 664 | 664 | |
| 665 | - $data['result']['table']['join'] = array( |
|
| 665 | + $data['result']['table']['join'] = array( |
|
| 666 | 666 | 'user' => array( |
| 667 | - 'left_field' => 'id', |
|
| 668 | - 'field' => 'userid' |
|
| 667 | + 'left_field' => 'id', |
|
| 668 | + 'field' => 'userid' |
|
| 669 | 669 | ), |
| 670 | 670 | 'workunit' => array( |
| 671 | - 'left_field' => 'id', |
|
| 672 | - 'field' => 'workunitid' |
|
| 671 | + 'left_field' => 'id', |
|
| 672 | + 'field' => 'workunitid' |
|
| 673 | 673 | ), |
| 674 | 674 | 'host' => array( |
| 675 | - 'left_field' => 'id', |
|
| 676 | - 'field' => 'hostid' |
|
| 675 | + 'left_field' => 'id', |
|
| 676 | + 'field' => 'hostid' |
|
| 677 | 677 | ) |
| 678 | - ); |
|
| 678 | + ); |
|
| 679 | 679 | |
| 680 | - // Primary keys allowed as arguments |
|
| 680 | + // Primary keys allowed as arguments |
|
| 681 | 681 | |
| 682 | - $data['result']['id'] = array( |
|
| 682 | + $data['result']['id'] = array( |
|
| 683 | 683 | 'title' => bts('Task ID', array(), NULL, 'boinc:task-details'), |
| 684 | 684 | 'help' => t('The ID number of this result.'), |
| 685 | 685 | 'field' => array( |
| 686 | - 'handler' => 'views_handler_field_numeric', |
|
| 687 | - 'click sortable' => TRUE |
|
| 686 | + 'handler' => 'views_handler_field_numeric', |
|
| 687 | + 'click sortable' => TRUE |
|
| 688 | 688 | ), |
| 689 | 689 | 'argument' => array( |
| 690 | - 'handler' => 'views_handler_argument', |
|
| 691 | - 'name field' => 'title', |
|
| 692 | - 'numeric' => TRUE, |
|
| 693 | - 'validate type' => 'id' |
|
| 690 | + 'handler' => 'views_handler_argument', |
|
| 691 | + 'name field' => 'title', |
|
| 692 | + 'numeric' => TRUE, |
|
| 693 | + 'validate type' => 'id' |
|
| 694 | 694 | ), |
| 695 | 695 | 'filter' => array( |
| 696 | - 'handler' => 'views_handler_filter_numeric' |
|
| 696 | + 'handler' => 'views_handler_filter_numeric' |
|
| 697 | 697 | ), |
| 698 | 698 | 'sort' => array( |
| 699 | - 'handler' => 'views_handler_sort_numeric' |
|
| 699 | + 'handler' => 'views_handler_sort_numeric' |
|
| 700 | 700 | ) |
| 701 | - ); |
|
| 701 | + ); |
|
| 702 | 702 | |
| 703 | - // Foreign key fields |
|
| 703 | + // Foreign key fields |
|
| 704 | 704 | |
| 705 | - $data['result']['userid'] = array( |
|
| 705 | + $data['result']['userid'] = array( |
|
| 706 | 706 | 'title' => bts('User ID', array(), NULL, 'boinc:user-details'), |
| 707 | 707 | 'help' => t('The owner of this result.'), |
| 708 | 708 | // Foreign key to the {user} table |
| 709 | 709 | 'argument' => array( |
| 710 | - 'handler' => 'views_handler_argument_boincuser_id', |
|
| 711 | - 'name field' => 'title', |
|
| 712 | - 'numeric' => TRUE, |
|
| 713 | - 'validate type' => 'id' |
|
| 710 | + 'handler' => 'views_handler_argument_boincuser_id', |
|
| 711 | + 'name field' => 'title', |
|
| 712 | + 'numeric' => TRUE, |
|
| 713 | + 'validate type' => 'id' |
|
| 714 | 714 | ), |
| 715 | 715 | 'relationship' => array( |
| 716 | - 'base' => 'user', |
|
| 717 | - 'field' => 'userid', |
|
| 718 | - 'handler' => 'views_handler_relationship', |
|
| 719 | - 'label' => t('User') |
|
| 716 | + 'base' => 'user', |
|
| 717 | + 'field' => 'userid', |
|
| 718 | + 'handler' => 'views_handler_relationship', |
|
| 719 | + 'label' => t('User') |
|
| 720 | 720 | ) |
| 721 | - ); |
|
| 722 | - $data['result']['workunitid'] = array( |
|
| 721 | + ); |
|
| 722 | + $data['result']['workunitid'] = array( |
|
| 723 | 723 | 'title' => bts('Workunit ID', array(), NULL, 'boinc:workunit-details'), |
| 724 | 724 | 'help' => t('The workunit associated with this result.'), |
| 725 | 725 | // Foreign key to the {workunit} table |
| 726 | 726 | 'argument' => array( |
| 727 | - 'handler' => 'views_handler_argument', |
|
| 728 | - 'name field' => 'title', |
|
| 729 | - 'numeric' => TRUE, |
|
| 730 | - 'validate type' => 'id' |
|
| 727 | + 'handler' => 'views_handler_argument', |
|
| 728 | + 'name field' => 'title', |
|
| 729 | + 'numeric' => TRUE, |
|
| 730 | + 'validate type' => 'id' |
|
| 731 | 731 | ), |
| 732 | 732 | 'relationship' => array( |
| 733 | - 'base' => 'workunit', |
|
| 734 | - 'field' => 'workunitid', |
|
| 735 | - 'handler' => 'views_handler_relationship', |
|
| 736 | - 'label' => t('Workunit') |
|
| 733 | + 'base' => 'workunit', |
|
| 734 | + 'field' => 'workunitid', |
|
| 735 | + 'handler' => 'views_handler_relationship', |
|
| 736 | + 'label' => t('Workunit') |
|
| 737 | 737 | ), |
| 738 | 738 | 'field' => array( |
| 739 | - 'handler' => 'views_handler_field_numeric', |
|
| 740 | - 'click sortable' => TRUE |
|
| 739 | + 'handler' => 'views_handler_field_numeric', |
|
| 740 | + 'click sortable' => TRUE |
|
| 741 | 741 | ), |
| 742 | 742 | 'filter' => array( |
| 743 | - 'handler' => 'views_handler_filter_numeric' |
|
| 743 | + 'handler' => 'views_handler_filter_numeric' |
|
| 744 | 744 | ), |
| 745 | 745 | 'sort' => array( |
| 746 | - 'handler' => 'views_handler_sort_numeric' |
|
| 746 | + 'handler' => 'views_handler_sort_numeric' |
|
| 747 | 747 | ) |
| 748 | - ); |
|
| 749 | - $data['result']['hostid'] = array( |
|
| 748 | + ); |
|
| 749 | + $data['result']['hostid'] = array( |
|
| 750 | 750 | 'title' => bts('Host ID', array(), NULL, 'boinc:task-details'), |
| 751 | 751 | 'help' => t('The host associated with this result.'), |
| 752 | 752 | // Foreign key to the {host} table |
| 753 | 753 | 'argument' => array( |
| 754 | - 'handler' => 'views_handler_argument', |
|
| 755 | - 'name field' => 'title', |
|
| 756 | - 'numeric' => TRUE, |
|
| 757 | - 'validate type' => 'id' |
|
| 754 | + 'handler' => 'views_handler_argument', |
|
| 755 | + 'name field' => 'title', |
|
| 756 | + 'numeric' => TRUE, |
|
| 757 | + 'validate type' => 'id' |
|
| 758 | 758 | ), |
| 759 | 759 | 'relationship' => array( |
| 760 | - 'base' => 'host', |
|
| 761 | - 'field' => 'hostid', |
|
| 762 | - 'handler' => 'views_handler_relationship', |
|
| 763 | - 'label' => t('Host') |
|
| 760 | + 'base' => 'host', |
|
| 761 | + 'field' => 'hostid', |
|
| 762 | + 'handler' => 'views_handler_relationship', |
|
| 763 | + 'label' => t('Host') |
|
| 764 | 764 | ), |
| 765 | 765 | 'field' => array( |
| 766 | - 'handler' => 'views_handler_field_numeric', |
|
| 767 | - 'click sortable' => TRUE |
|
| 766 | + 'handler' => 'views_handler_field_numeric', |
|
| 767 | + 'click sortable' => TRUE |
|
| 768 | 768 | ), |
| 769 | 769 | 'filter' => array( |
| 770 | - 'handler' => 'views_handler_filter_numeric' |
|
| 770 | + 'handler' => 'views_handler_filter_numeric' |
|
| 771 | 771 | ), |
| 772 | 772 | 'sort' => array( |
| 773 | - 'handler' => 'views_handler_sort_numeric' |
|
| 773 | + 'handler' => 'views_handler_sort_numeric' |
|
| 774 | 774 | ) |
| 775 | - ); |
|
| 775 | + ); |
|
| 776 | 776 | |
| 777 | - // Descriptions of result fields (alphabetized) |
|
| 777 | + // Descriptions of result fields (alphabetized) |
|
| 778 | 778 | |
| 779 | - $data['result']['appid'] = array( |
|
| 779 | + $data['result']['appid'] = array( |
|
| 780 | 780 | 'title' => bts('Application ID', array(), NULL, 'boinc:application-details'), |
| 781 | 781 | 'help' => t('The ID number of the application.'), |
| 782 | 782 | 'field' => array( |
| 783 | - 'handler' => 'views_handler_field_numeric', |
|
| 784 | - 'click sortable' => TRUE |
|
| 783 | + 'handler' => 'views_handler_field_numeric', |
|
| 784 | + 'click sortable' => TRUE |
|
| 785 | 785 | ), |
| 786 | 786 | 'filter' => array( |
| 787 | - 'handler' => 'views_handler_filter_numeric' |
|
| 787 | + 'handler' => 'views_handler_filter_numeric' |
|
| 788 | 788 | ), |
| 789 | 789 | 'sort' => array( |
| 790 | - 'handler' => 'views_handler_sort_numeric' |
|
| 790 | + 'handler' => 'views_handler_sort_numeric' |
|
| 791 | 791 | ) |
| 792 | - ); |
|
| 793 | - $data['result']['app_version_id'] = array( |
|
| 792 | + ); |
|
| 793 | + $data['result']['app_version_id'] = array( |
|
| 794 | 794 | 'title' => bts('Application version', array(), NULL, 'boinc:task-details'), |
| 795 | 795 | 'help' => t('The version number of the application.'), |
| 796 | 796 | 'field' => array( |
| 797 | - 'handler' => 'views_handler_field_numeric', |
|
| 798 | - 'click sortable' => TRUE |
|
| 797 | + 'handler' => 'views_handler_field_numeric', |
|
| 798 | + 'click sortable' => TRUE |
|
| 799 | 799 | ), |
| 800 | 800 | 'filter' => array( |
| 801 | - 'handler' => 'views_handler_filter_numeric' |
|
| 801 | + 'handler' => 'views_handler_filter_numeric' |
|
| 802 | 802 | ), |
| 803 | 803 | 'sort' => array( |
| 804 | - 'handler' => 'views_handler_sort_numeric' |
|
| 804 | + 'handler' => 'views_handler_sort_numeric' |
|
| 805 | 805 | ) |
| 806 | - ); |
|
| 807 | - $data['result']['claimed_credit'] = array( |
|
| 806 | + ); |
|
| 807 | + $data['result']['claimed_credit'] = array( |
|
| 808 | 808 | 'title' => bts('Claimed credit', array(), NULL, 'boinc:task-details'), |
| 809 | 809 | 'help' => t('The credit claimed for this result.'), |
| 810 | 810 | 'field' => array( |
| 811 | - 'handler' => 'views_handler_field_numeric', |
|
| 812 | - 'click sortable' => TRUE, |
|
| 813 | - 'float' => TRUE |
|
| 811 | + 'handler' => 'views_handler_field_numeric', |
|
| 812 | + 'click sortable' => TRUE, |
|
| 813 | + 'float' => TRUE |
|
| 814 | 814 | ), |
| 815 | 815 | 'filter' => array( |
| 816 | - 'handler' => 'views_handler_filter_numeric' |
|
| 816 | + 'handler' => 'views_handler_filter_numeric' |
|
| 817 | 817 | ), |
| 818 | 818 | 'sort' => array( |
| 819 | - 'handler' => 'views_handler_sort_numeric' |
|
| 819 | + 'handler' => 'views_handler_sort_numeric' |
|
| 820 | 820 | ) |
| 821 | - ); |
|
| 822 | - $data['result']['client_state'] = array( |
|
| 821 | + ); |
|
| 822 | + $data['result']['client_state'] = array( |
|
| 823 | 823 | 'title' => bts('Client state', array(), NULL, 'boinc:task-details'), |
| 824 | 824 | 'help' => t('The state of the task on the client side.'), |
| 825 | 825 | 'field' => array( |
| 826 | - 'handler' => 'views_handler_field_numeric', |
|
| 827 | - 'click sortable' => TRUE |
|
| 826 | + 'handler' => 'views_handler_field_numeric', |
|
| 827 | + 'click sortable' => TRUE |
|
| 828 | 828 | ), |
| 829 | 829 | 'filter' => array( |
| 830 | - 'handler' => 'views_handler_filter_numeric' |
|
| 830 | + 'handler' => 'views_handler_filter_numeric' |
|
| 831 | 831 | ), |
| 832 | 832 | 'sort' => array( |
| 833 | - 'handler' => 'views_handler_sort_numeric' |
|
| 833 | + 'handler' => 'views_handler_sort_numeric' |
|
| 834 | 834 | ) |
| 835 | - ); |
|
| 836 | - $data['result']['cpu_time'] = array( |
|
| 835 | + ); |
|
| 836 | + $data['result']['cpu_time'] = array( |
|
| 837 | 837 | 'title' => bts('CPU time', array(), NULL, 'boinc:task-details'), |
| 838 | 838 | 'help' => t('The CPU time spent on the task.'), |
| 839 | 839 | 'field' => array( |
| 840 | - 'handler' => 'views_handler_field_numeric', |
|
| 841 | - 'click sortable' => TRUE, |
|
| 842 | - 'float' => TRUE |
|
| 840 | + 'handler' => 'views_handler_field_numeric', |
|
| 841 | + 'click sortable' => TRUE, |
|
| 842 | + 'float' => TRUE |
|
| 843 | 843 | ), |
| 844 | 844 | 'filter' => array( |
| 845 | - 'handler' => 'views_handler_filter_numeric' |
|
| 845 | + 'handler' => 'views_handler_filter_numeric' |
|
| 846 | 846 | ), |
| 847 | 847 | 'sort' => array( |
| 848 | - 'handler' => 'views_handler_sort_numeric' |
|
| 848 | + 'handler' => 'views_handler_sort_numeric' |
|
| 849 | 849 | ) |
| 850 | - ); |
|
| 851 | - $data['result']['create_time'] = array( |
|
| 850 | + ); |
|
| 851 | + $data['result']['create_time'] = array( |
|
| 852 | 852 | 'title' => bts('Created', array(), NULL, 'boinc:task-details:-1:ignoreoverwrite'), |
| 853 | 853 | 'help' => t('The time that the task was created.'), |
| 854 | 854 | 'field' => array( |
| 855 | - 'handler' => 'views_handler_field_date', |
|
| 856 | - 'click sortable' => TRUE |
|
| 855 | + 'handler' => 'views_handler_field_date', |
|
| 856 | + 'click sortable' => TRUE |
|
| 857 | 857 | ), |
| 858 | 858 | 'filter' => array( |
| 859 | - 'handler' => 'views_handler_filter_date' |
|
| 859 | + 'handler' => 'views_handler_filter_date' |
|
| 860 | 860 | ), |
| 861 | 861 | 'sort' => array( |
| 862 | - 'handler' => 'views_handler_sort_date' |
|
| 862 | + 'handler' => 'views_handler_sort_date' |
|
| 863 | 863 | ) |
| 864 | - ); |
|
| 865 | - $data['result']['elapsed_time'] = array( |
|
| 864 | + ); |
|
| 865 | + $data['result']['elapsed_time'] = array( |
|
| 866 | 866 | 'title' => bts('Run time', array(), NULL, 'boinc:task-details'), |
| 867 | 867 | 'help' => t('The run time of the task.'), |
| 868 | 868 | 'field' => array( |
| 869 | - 'handler' => 'views_handler_field_numeric', |
|
| 870 | - 'click sortable' => TRUE, |
|
| 871 | - 'float' => TRUE |
|
| 869 | + 'handler' => 'views_handler_field_numeric', |
|
| 870 | + 'click sortable' => TRUE, |
|
| 871 | + 'float' => TRUE |
|
| 872 | 872 | ), |
| 873 | 873 | 'filter' => array( |
| 874 | - 'handler' => 'views_handler_filter_numeric' |
|
| 874 | + 'handler' => 'views_handler_filter_numeric' |
|
| 875 | 875 | ), |
| 876 | 876 | 'sort' => array( |
| 877 | - 'handler' => 'views_handler_sort_numeric' |
|
| 877 | + 'handler' => 'views_handler_sort_numeric' |
|
| 878 | 878 | ) |
| 879 | - ); |
|
| 880 | - $data['result']['exit_status'] = array( |
|
| 879 | + ); |
|
| 880 | + $data['result']['exit_status'] = array( |
|
| 881 | 881 | 'title' => bts('Exit status', array(), NULL, 'boinc:task-details'), |
| 882 | 882 | 'help' => t('The exit code of the task.'), |
| 883 | 883 | 'field' => array( |
| 884 | - 'handler' => 'views_handler_field_numeric', |
|
| 885 | - 'click sortable' => TRUE |
|
| 884 | + 'handler' => 'views_handler_field_numeric', |
|
| 885 | + 'click sortable' => TRUE |
|
| 886 | 886 | ), |
| 887 | 887 | 'filter' => array( |
| 888 | - 'handler' => 'views_handler_filter_numeric' |
|
| 888 | + 'handler' => 'views_handler_filter_numeric' |
|
| 889 | 889 | ), |
| 890 | 890 | 'sort' => array( |
| 891 | - 'handler' => 'views_handler_sort_numeric' |
|
| 891 | + 'handler' => 'views_handler_sort_numeric' |
|
| 892 | 892 | ) |
| 893 | - ); |
|
| 894 | - $data['result']['granted_credit'] = array( |
|
| 893 | + ); |
|
| 894 | + $data['result']['granted_credit'] = array( |
|
| 895 | 895 | 'title' => bts('Granted credit', array(), NULL, 'boinc:task-details'), |
| 896 | 896 | 'help' => t('The credit granted for this result.'), |
| 897 | 897 | 'field' => array( |
| 898 | - 'handler' => 'views_handler_field_numeric', |
|
| 899 | - 'click sortable' => TRUE, |
|
| 900 | - 'float' => TRUE |
|
| 898 | + 'handler' => 'views_handler_field_numeric', |
|
| 899 | + 'click sortable' => TRUE, |
|
| 900 | + 'float' => TRUE |
|
| 901 | 901 | ), |
| 902 | 902 | 'filter' => array( |
| 903 | - 'handler' => 'views_handler_filter_numeric' |
|
| 903 | + 'handler' => 'views_handler_filter_numeric' |
|
| 904 | 904 | ), |
| 905 | 905 | 'sort' => array( |
| 906 | - 'handler' => 'views_handler_sort_numeric' |
|
| 906 | + 'handler' => 'views_handler_sort_numeric' |
|
| 907 | 907 | ) |
| 908 | - ); |
|
| 909 | - $data['result']['name'] = array( |
|
| 908 | + ); |
|
| 909 | + $data['result']['name'] = array( |
|
| 910 | 910 | 'title' => bts('Name', array(), NULL, 'boinc:details:-1:name-of-the-host-or-task-or-workunit-etc-being-viewed-ignoreoverwrite'), |
| 911 | 911 | 'help' => t('The name of the task.'), |
| 912 | 912 | 'field' => array( |
| 913 | - 'handler' => 'views_handler_field', |
|
| 914 | - 'click sortable' => TRUE |
|
| 913 | + 'handler' => 'views_handler_field', |
|
| 914 | + 'click sortable' => TRUE |
|
| 915 | 915 | ), |
| 916 | 916 | 'filter' => array( |
| 917 | - 'handler' => 'views_handler_filter_string' |
|
| 917 | + 'handler' => 'views_handler_filter_string' |
|
| 918 | 918 | ), |
| 919 | 919 | 'sort' => array( |
| 920 | - 'handler' => 'views_handler_sort_string' |
|
| 920 | + 'handler' => 'views_handler_sort_string' |
|
| 921 | 921 | ) |
| 922 | - ); |
|
| 923 | - $data['result']['outcome'] = array( |
|
| 922 | + ); |
|
| 923 | + $data['result']['outcome'] = array( |
|
| 924 | 924 | 'title' => bts('Outcome', array(), NULL, 'boinc:task-details'), |
| 925 | 925 | 'help' => t('The outcome of the task.'), |
| 926 | 926 | 'field' => array( |
| 927 | - 'handler' => 'views_handler_field_numeric', |
|
| 928 | - 'click sortable' => TRUE |
|
| 927 | + 'handler' => 'views_handler_field_numeric', |
|
| 928 | + 'click sortable' => TRUE |
|
| 929 | 929 | ), |
| 930 | 930 | 'filter' => array( |
| 931 | - 'handler' => 'views_handler_filter_numeric' |
|
| 931 | + 'handler' => 'views_handler_filter_numeric' |
|
| 932 | 932 | ), |
| 933 | 933 | 'sort' => array( |
| 934 | - 'handler' => 'views_handler_sort_numeric' |
|
| 934 | + 'handler' => 'views_handler_sort_numeric' |
|
| 935 | 935 | ) |
| 936 | - ); |
|
| 937 | - $data['result']['received_time'] = array( |
|
| 936 | + ); |
|
| 937 | + $data['result']['received_time'] = array( |
|
| 938 | 938 | 'title' => bts('Received time', array(), NULL, 'boinc:task-details'), |
| 939 | 939 | 'help' => t('The time that the result was received.'), |
| 940 | 940 | 'field' => array( |
| 941 | - 'handler' => 'views_handler_field_date', |
|
| 942 | - 'click sortable' => TRUE |
|
| 941 | + 'handler' => 'views_handler_field_date', |
|
| 942 | + 'click sortable' => TRUE |
|
| 943 | 943 | ), |
| 944 | 944 | 'filter' => array( |
| 945 | - 'handler' => 'views_handler_filter_date' |
|
| 945 | + 'handler' => 'views_handler_filter_date' |
|
| 946 | 946 | ), |
| 947 | 947 | 'sort' => array( |
| 948 | - 'handler' => 'views_handler_sort_date' |
|
| 948 | + 'handler' => 'views_handler_sort_date' |
|
| 949 | 949 | ) |
| 950 | - ); |
|
| 951 | - $data['result']['report_deadline'] = array( |
|
| 950 | + ); |
|
| 951 | + $data['result']['report_deadline'] = array( |
|
| 952 | 952 | 'title' => bts('Report deadline', array(), NULL, 'boinc:task-details'), |
| 953 | 953 | 'help' => t('The deadline for the task.'), |
| 954 | 954 | 'field' => array( |
| 955 | - 'handler' => 'views_handler_field_date', |
|
| 956 | - 'click sortable' => TRUE |
|
| 955 | + 'handler' => 'views_handler_field_date', |
|
| 956 | + 'click sortable' => TRUE |
|
| 957 | 957 | ), |
| 958 | 958 | 'filter' => array( |
| 959 | - 'handler' => 'views_handler_filter_date' |
|
| 959 | + 'handler' => 'views_handler_filter_date' |
|
| 960 | 960 | ), |
| 961 | 961 | 'sort' => array( |
| 962 | - 'handler' => 'views_handler_sort_date' |
|
| 962 | + 'handler' => 'views_handler_sort_date' |
|
| 963 | 963 | ) |
| 964 | - ); |
|
| 965 | - $data['result']['sent_time'] = array( |
|
| 964 | + ); |
|
| 965 | + $data['result']['sent_time'] = array( |
|
| 966 | 966 | 'title' => bts('Sent', array(), NULL, 'boinc:task-details'), |
| 967 | 967 | 'help' => t('The time that the task was sent.'), |
| 968 | 968 | 'field' => array( |
| 969 | - 'handler' => 'views_handler_field_date', |
|
| 970 | - 'click sortable' => TRUE |
|
| 969 | + 'handler' => 'views_handler_field_date', |
|
| 970 | + 'click sortable' => TRUE |
|
| 971 | 971 | ), |
| 972 | 972 | 'filter' => array( |
| 973 | - 'handler' => 'views_handler_filter_date' |
|
| 973 | + 'handler' => 'views_handler_filter_date' |
|
| 974 | 974 | ), |
| 975 | 975 | 'sort' => array( |
| 976 | - 'handler' => 'views_handler_sort_date' |
|
| 976 | + 'handler' => 'views_handler_sort_date' |
|
| 977 | 977 | ) |
| 978 | - ); |
|
| 979 | - $data['result']['server_state'] = array( |
|
| 978 | + ); |
|
| 979 | + $data['result']['server_state'] = array( |
|
| 980 | 980 | 'title' => bts('Server state', array(), NULL, 'boinc:task-details'), |
| 981 | 981 | 'help' => t('The state of task on the server side.'), |
| 982 | 982 | 'field' => array( |
| 983 | - 'handler' => 'views_handler_field_numeric', |
|
| 984 | - 'click sortable' => TRUE |
|
| 983 | + 'handler' => 'views_handler_field_numeric', |
|
| 984 | + 'click sortable' => TRUE |
|
| 985 | 985 | ), |
| 986 | 986 | 'filter' => array( |
| 987 | - 'handler' => 'views_handler_filter_numeric' |
|
| 987 | + 'handler' => 'views_handler_filter_numeric' |
|
| 988 | 988 | ), |
| 989 | 989 | 'sort' => array( |
| 990 | - 'handler' => 'views_handler_sort_numeric' |
|
| 990 | + 'handler' => 'views_handler_sort_numeric' |
|
| 991 | 991 | ) |
| 992 | - ); |
|
| 993 | - $data['result']['stderr_out'] = array( |
|
| 992 | + ); |
|
| 993 | + $data['result']['stderr_out'] = array( |
|
| 994 | 994 | 'title' => bts('Stderr out', array(), NULL, 'boinc:task-details'), |
| 995 | 995 | 'help' => t('The output to standard error.'), |
| 996 | 996 | 'field' => array( |
| 997 | - 'handler' => 'views_handler_field', |
|
| 998 | - 'click sortable' => TRUE |
|
| 997 | + 'handler' => 'views_handler_field', |
|
| 998 | + 'click sortable' => TRUE |
|
| 999 | 999 | ), |
| 1000 | 1000 | 'filter' => array( |
| 1001 | - 'handler' => 'views_handler_filter_string' |
|
| 1001 | + 'handler' => 'views_handler_filter_string' |
|
| 1002 | 1002 | ), |
| 1003 | 1003 | 'sort' => array( |
| 1004 | - 'handler' => 'views_handler_sort_string' |
|
| 1004 | + 'handler' => 'views_handler_sort_string' |
|
| 1005 | 1005 | ) |
| 1006 | - ); |
|
| 1007 | - $data['result']['validate_state'] = array( |
|
| 1006 | + ); |
|
| 1007 | + $data['result']['validate_state'] = array( |
|
| 1008 | 1008 | 'title' => bts('Validation state', array(), NULL, 'boinc:task-details'), |
| 1009 | 1009 | 'help' => t('The state of validation of this result.'), |
| 1010 | 1010 | 'field' => array( |
| 1011 | - 'handler' => 'views_handler_field_numeric', |
|
| 1012 | - 'click sortable' => TRUE |
|
| 1011 | + 'handler' => 'views_handler_field_numeric', |
|
| 1012 | + 'click sortable' => TRUE |
|
| 1013 | 1013 | ), |
| 1014 | 1014 | 'filter' => array( |
| 1015 | - 'handler' => 'views_handler_filter_numeric' |
|
| 1015 | + 'handler' => 'views_handler_filter_numeric' |
|
| 1016 | 1016 | ), |
| 1017 | 1017 | 'sort' => array( |
| 1018 | - 'handler' => 'views_handler_sort_numeric' |
|
| 1018 | + 'handler' => 'views_handler_sort_numeric' |
|
| 1019 | 1019 | ) |
| 1020 | - ); |
|
| 1021 | - $data['result']['peak_working_set_size'] = array( |
|
| 1020 | + ); |
|
| 1021 | + $data['result']['peak_working_set_size'] = array( |
|
| 1022 | 1022 | 'title' => bts('Peak working set size', array(), NULL, 'boinc:task-details'), |
| 1023 | 1023 | 'help' => t('Peak working set size.'), |
| 1024 | 1024 | 'field' => array( |
| 1025 | - 'handler' => 'views_handler_field_numeric', |
|
| 1026 | - 'click sortable' => TRUE |
|
| 1025 | + 'handler' => 'views_handler_field_numeric', |
|
| 1026 | + 'click sortable' => TRUE |
|
| 1027 | 1027 | ), |
| 1028 | 1028 | 'filter' => array( |
| 1029 | - 'handler' => 'views_handler_filter_numeric' |
|
| 1029 | + 'handler' => 'views_handler_filter_numeric' |
|
| 1030 | 1030 | ), |
| 1031 | 1031 | 'sort' => array( |
| 1032 | - 'handler' => 'views_handler_sort_numeric' |
|
| 1032 | + 'handler' => 'views_handler_sort_numeric' |
|
| 1033 | 1033 | ) |
| 1034 | - ); |
|
| 1035 | - $data['result']['peak_swap_size'] = array( |
|
| 1034 | + ); |
|
| 1035 | + $data['result']['peak_swap_size'] = array( |
|
| 1036 | 1036 | 'title' => bts('Peak swap size', array(), NULL, 'boinc:task-details'), |
| 1037 | 1037 | 'help' => t('Peak swap size.'), |
| 1038 | 1038 | 'field' => array( |
| 1039 | - 'handler' => 'views_handler_field_numeric', |
|
| 1040 | - 'click sortable' => TRUE |
|
| 1039 | + 'handler' => 'views_handler_field_numeric', |
|
| 1040 | + 'click sortable' => TRUE |
|
| 1041 | 1041 | ), |
| 1042 | 1042 | 'filter' => array( |
| 1043 | - 'handler' => 'views_handler_filter_numeric' |
|
| 1043 | + 'handler' => 'views_handler_filter_numeric' |
|
| 1044 | 1044 | ), |
| 1045 | 1045 | 'sort' => array( |
| 1046 | - 'handler' => 'views_handler_sort_numeric' |
|
| 1046 | + 'handler' => 'views_handler_sort_numeric' |
|
| 1047 | 1047 | ) |
| 1048 | - ); |
|
| 1048 | + ); |
|
| 1049 | 1049 | $data['result']['peak_disk_usage'] = array( |
| 1050 | 1050 | 'title' => bts('Peak disk usage', array(), NULL, 'boinc:task-details'), |
| 1051 | 1051 | 'help' => t('Peak disk usage.'), |
| 1052 | 1052 | 'field' => array( |
| 1053 | - 'handler' => 'views_handler_field_numeric', |
|
| 1054 | - 'click sortable' => TRUE |
|
| 1053 | + 'handler' => 'views_handler_field_numeric', |
|
| 1054 | + 'click sortable' => TRUE |
|
| 1055 | 1055 | ), |
| 1056 | 1056 | 'filter' => array( |
| 1057 | - 'handler' => 'views_handler_filter_numeric' |
|
| 1057 | + 'handler' => 'views_handler_filter_numeric' |
|
| 1058 | 1058 | ), |
| 1059 | 1059 | 'sort' => array( |
| 1060 | - 'handler' => 'views_handler_sort_numeric' |
|
| 1060 | + 'handler' => 'views_handler_sort_numeric' |
|
| 1061 | 1061 | ) |
| 1062 | - ); |
|
| 1062 | + ); |
|
| 1063 | 1063 | |
| 1064 | 1064 | |
| 1065 | - // ------------------------------------------------------------------------------------------------ |
|
| 1066 | - // Definition for workunit table |
|
| 1067 | - // ------------------------------------------------------------------------------------------------ |
|
| 1065 | + // ------------------------------------------------------------------------------------------------ |
|
| 1066 | + // Definition for workunit table |
|
| 1067 | + // ------------------------------------------------------------------------------------------------ |
|
| 1068 | 1068 | |
| 1069 | - $data['workunit']['table']['group'] = t('BOINC'); |
|
| 1070 | - $data['workunit']['table']['base'] = array( |
|
| 1071 | - 'field' => 'id', |
|
| 1072 | - 'title' => t('BOINC workunit'), |
|
| 1073 | - 'help' => t('Workunits produced by BOINC'), |
|
| 1074 | - 'database' => 'boinc_ro' |
|
| 1075 | - ); |
|
| 1069 | + $data['workunit']['table']['group'] = t('BOINC'); |
|
| 1070 | + $data['workunit']['table']['base'] = array( |
|
| 1071 | + 'field' => 'id', |
|
| 1072 | + 'title' => t('BOINC workunit'), |
|
| 1073 | + 'help' => t('Workunits produced by BOINC'), |
|
| 1074 | + 'database' => 'boinc_ro' |
|
| 1075 | + ); |
|
| 1076 | 1076 | |
| 1077 | - // Create implicit relationship to the app table |
|
| 1077 | + // Create implicit relationship to the app table |
|
| 1078 | 1078 | |
| 1079 | - $data['workunit']['table']['join'] = array( |
|
| 1079 | + $data['workunit']['table']['join'] = array( |
|
| 1080 | 1080 | 'app' => array( |
| 1081 | - 'left_field' => 'id', |
|
| 1082 | - 'field' => 'appid' |
|
| 1081 | + 'left_field' => 'id', |
|
| 1082 | + 'field' => 'appid' |
|
| 1083 | 1083 | ) |
| 1084 | - ); |
|
| 1084 | + ); |
|
| 1085 | 1085 | |
| 1086 | - // Primary keys allowed as arguments |
|
| 1086 | + // Primary keys allowed as arguments |
|
| 1087 | 1087 | |
| 1088 | - $data['workunit']['id'] = array( |
|
| 1088 | + $data['workunit']['id'] = array( |
|
| 1089 | 1089 | 'title' => bts('Workunit ID', array(), NULL, 'boinc:workunit-details'), |
| 1090 | 1090 | 'help' => t('The ID number of this workunit.'), |
| 1091 | 1091 | 'field' => array( |
| 1092 | - 'handler' => 'views_handler_field_numeric', |
|
| 1093 | - 'click sortable' => TRUE |
|
| 1092 | + 'handler' => 'views_handler_field_numeric', |
|
| 1093 | + 'click sortable' => TRUE |
|
| 1094 | 1094 | ), |
| 1095 | 1095 | 'argument' => array( |
| 1096 | - 'handler' => 'views_handler_argument', |
|
| 1097 | - 'name field' => 'title', |
|
| 1098 | - 'numeric' => TRUE, |
|
| 1099 | - 'validate type' => 'id' |
|
| 1096 | + 'handler' => 'views_handler_argument', |
|
| 1097 | + 'name field' => 'title', |
|
| 1098 | + 'numeric' => TRUE, |
|
| 1099 | + 'validate type' => 'id' |
|
| 1100 | 1100 | ), |
| 1101 | 1101 | 'filter' => array( |
| 1102 | - 'handler' => 'views_handler_filter_numeric' |
|
| 1102 | + 'handler' => 'views_handler_filter_numeric' |
|
| 1103 | 1103 | ), |
| 1104 | 1104 | 'sort' => array( |
| 1105 | - 'handler' => 'views_handler_sort_numeric' |
|
| 1105 | + 'handler' => 'views_handler_sort_numeric' |
|
| 1106 | 1106 | ) |
| 1107 | - ); |
|
| 1107 | + ); |
|
| 1108 | 1108 | |
| 1109 | - // Foreign key fields |
|
| 1109 | + // Foreign key fields |
|
| 1110 | 1110 | |
| 1111 | - $data['workunit']['appid'] = array( |
|
| 1111 | + $data['workunit']['appid'] = array( |
|
| 1112 | 1112 | 'title' => bts('Application ID', array(), NULL, 'boinc:application-details'), |
| 1113 | 1113 | 'help' => t('The application associated with this workunit.'), |
| 1114 | 1114 | 'argument' => array( // foreign key to the {app} table |
| 1115 | - 'handler' => 'views_handler_argument', |
|
| 1116 | - 'name field' => 'title', |
|
| 1117 | - 'numeric' => TRUE, |
|
| 1118 | - 'validate type' => 'id' |
|
| 1115 | + 'handler' => 'views_handler_argument', |
|
| 1116 | + 'name field' => 'title', |
|
| 1117 | + 'numeric' => TRUE, |
|
| 1118 | + 'validate type' => 'id' |
|
| 1119 | 1119 | ), |
| 1120 | 1120 | 'relationship' => array( |
| 1121 | - 'base' => 'app', |
|
| 1122 | - 'field' => 'appid', |
|
| 1123 | - 'handler' => 'views_handler_relationship', |
|
| 1124 | - 'label' => t('Application') |
|
| 1121 | + 'base' => 'app', |
|
| 1122 | + 'field' => 'appid', |
|
| 1123 | + 'handler' => 'views_handler_relationship', |
|
| 1124 | + 'label' => t('Application') |
|
| 1125 | 1125 | ), |
| 1126 | 1126 | 'field' => array( |
| 1127 | - 'handler' => 'views_handler_field_numeric', |
|
| 1128 | - 'click sortable' => TRUE |
|
| 1127 | + 'handler' => 'views_handler_field_numeric', |
|
| 1128 | + 'click sortable' => TRUE |
|
| 1129 | 1129 | ), |
| 1130 | 1130 | 'filter' => array( |
| 1131 | - 'handler' => 'views_handler_filter_numeric' |
|
| 1131 | + 'handler' => 'views_handler_filter_numeric' |
|
| 1132 | 1132 | ), |
| 1133 | 1133 | 'sort' => array( |
| 1134 | - 'handler' => 'views_handler_sort_numeric' |
|
| 1134 | + 'handler' => 'views_handler_sort_numeric' |
|
| 1135 | 1135 | ) |
| 1136 | - ); |
|
| 1136 | + ); |
|
| 1137 | 1137 | |
| 1138 | - // Descriptions of workunit fields (alphabetized) |
|
| 1138 | + // Descriptions of workunit fields (alphabetized) |
|
| 1139 | 1139 | |
| 1140 | - $data['workunit']['canonical_credit'] = array( |
|
| 1140 | + $data['workunit']['canonical_credit'] = array( |
|
| 1141 | 1141 | 'title' => bts('Canonical credit', array(), NULL, 'boinc:workunit-details'), |
| 1142 | 1142 | 'help' => t('The canonical credit of the workunit.'), |
| 1143 | 1143 | 'field' => array( |
| 1144 | - 'handler' => 'views_handler_field_numeric', |
|
| 1145 | - 'click sortable' => TRUE, |
|
| 1146 | - 'float' => TRUE |
|
| 1144 | + 'handler' => 'views_handler_field_numeric', |
|
| 1145 | + 'click sortable' => TRUE, |
|
| 1146 | + 'float' => TRUE |
|
| 1147 | 1147 | ), |
| 1148 | 1148 | 'filter' => array( |
| 1149 | - 'handler' => 'views_handler_filter_numeric' |
|
| 1149 | + 'handler' => 'views_handler_filter_numeric' |
|
| 1150 | 1150 | ), |
| 1151 | 1151 | 'sort' => array( |
| 1152 | - 'handler' => 'views_handler_sort_numeric' |
|
| 1152 | + 'handler' => 'views_handler_sort_numeric' |
|
| 1153 | 1153 | ) |
| 1154 | - ); |
|
| 1155 | - $data['workunit']['canonical_resultid'] = array( |
|
| 1154 | + ); |
|
| 1155 | + $data['workunit']['canonical_resultid'] = array( |
|
| 1156 | 1156 | 'title' => bts('Canonical result ID', array(), NULL, 'boinc:workunit-details'), |
| 1157 | 1157 | 'help' => t('The ID of the canonical result associated with the workunit.'), |
| 1158 | 1158 | 'field' => array( |
| 1159 | - 'handler' => 'views_handler_field_numeric', |
|
| 1160 | - 'click sortable' => TRUE |
|
| 1159 | + 'handler' => 'views_handler_field_numeric', |
|
| 1160 | + 'click sortable' => TRUE |
|
| 1161 | 1161 | ), |
| 1162 | 1162 | 'filter' => array( |
| 1163 | - 'handler' => 'views_handler_filter_numeric' |
|
| 1163 | + 'handler' => 'views_handler_filter_numeric' |
|
| 1164 | 1164 | ), |
| 1165 | 1165 | 'sort' => array( |
| 1166 | - 'handler' => 'views_handler_sort_numeric' |
|
| 1166 | + 'handler' => 'views_handler_sort_numeric' |
|
| 1167 | 1167 | ) |
| 1168 | - ); |
|
| 1169 | - $data['workunit']['create_time'] = array( |
|
| 1168 | + ); |
|
| 1169 | + $data['workunit']['create_time'] = array( |
|
| 1170 | 1170 | 'title' => bts('Created time', array(), NULL, 'boinc:workunit-details'), |
| 1171 | 1171 | 'help' => t('The time that the workunit was created.'), |
| 1172 | 1172 | 'field' => array( |
| 1173 | - 'handler' => 'views_handler_field_date', |
|
| 1174 | - 'click sortable' => TRUE |
|
| 1173 | + 'handler' => 'views_handler_field_date', |
|
| 1174 | + 'click sortable' => TRUE |
|
| 1175 | 1175 | ), |
| 1176 | 1176 | 'filter' => array( |
| 1177 | - 'handler' => 'views_handler_filter_date' |
|
| 1177 | + 'handler' => 'views_handler_filter_date' |
|
| 1178 | 1178 | ), |
| 1179 | 1179 | 'sort' => array( |
| 1180 | - 'handler' => 'views_handler_sort_date' |
|
| 1180 | + 'handler' => 'views_handler_sort_date' |
|
| 1181 | 1181 | ) |
| 1182 | - ); |
|
| 1183 | - $data['workunit']['error_mask'] = array( |
|
| 1182 | + ); |
|
| 1183 | + $data['workunit']['error_mask'] = array( |
|
| 1184 | 1184 | 'title' => bts('Error mask', array(), NULL, 'boinc:workunit-details'), |
| 1185 | 1185 | 'help' => t('Error mask of the workunit.'), |
| 1186 | 1186 | 'field' => array( |
| 1187 | - 'handler' => 'views_handler_field_numeric', |
|
| 1188 | - 'click sortable' => TRUE |
|
| 1187 | + 'handler' => 'views_handler_field_numeric', |
|
| 1188 | + 'click sortable' => TRUE |
|
| 1189 | 1189 | ), |
| 1190 | 1190 | 'filter' => array( |
| 1191 | - 'handler' => 'views_handler_filter_numeric' |
|
| 1191 | + 'handler' => 'views_handler_filter_numeric' |
|
| 1192 | 1192 | ), |
| 1193 | 1193 | 'sort' => array( |
| 1194 | - 'handler' => 'views_handler_sort_numeric' |
|
| 1194 | + 'handler' => 'views_handler_sort_numeric' |
|
| 1195 | 1195 | ) |
| 1196 | - ); |
|
| 1197 | - $data['workunit']['min_quorum'] = array( |
|
| 1196 | + ); |
|
| 1197 | + $data['workunit']['min_quorum'] = array( |
|
| 1198 | 1198 | 'title' => bts('Minimum quorum', array(), NULL, 'boinc:workunit-details'), |
| 1199 | 1199 | 'help' => t('Minimum quorum of the workunit.'), |
| 1200 | 1200 | 'field' => array( |
| 1201 | - 'handler' => 'views_handler_field_numeric', |
|
| 1202 | - 'click sortable' => TRUE |
|
| 1201 | + 'handler' => 'views_handler_field_numeric', |
|
| 1202 | + 'click sortable' => TRUE |
|
| 1203 | 1203 | ), |
| 1204 | 1204 | 'filter' => array( |
| 1205 | - 'handler' => 'views_handler_filter_numeric' |
|
| 1205 | + 'handler' => 'views_handler_filter_numeric' |
|
| 1206 | 1206 | ), |
| 1207 | 1207 | 'sort' => array( |
| 1208 | - 'handler' => 'views_handler_sort_numeric' |
|
| 1208 | + 'handler' => 'views_handler_sort_numeric' |
|
| 1209 | 1209 | ) |
| 1210 | - ); |
|
| 1211 | - $data['workunit']['name'] = array( |
|
| 1210 | + ); |
|
| 1211 | + $data['workunit']['name'] = array( |
|
| 1212 | 1212 | 'title' => bts('Name', array(), NULL, 'boinc:details:-1:name-of-the-host-or-task-or-workunit-etc-being-viewed-ignoreovewrite'), |
| 1213 | 1213 | 'help' => t('The name of the workunit.'), |
| 1214 | 1214 | 'field' => array( |
| 1215 | - 'handler' => 'views_handler_field', |
|
| 1216 | - 'click sortable' => TRUE |
|
| 1215 | + 'handler' => 'views_handler_field', |
|
| 1216 | + 'click sortable' => TRUE |
|
| 1217 | 1217 | ), |
| 1218 | 1218 | 'filter' => array( |
| 1219 | - 'handler' => 'views_handler_filter_string' |
|
| 1219 | + 'handler' => 'views_handler_filter_string' |
|
| 1220 | 1220 | ), |
| 1221 | 1221 | 'sort' => array( |
| 1222 | - 'handler' => 'views_handler_sort_string' |
|
| 1222 | + 'handler' => 'views_handler_sort_string' |
|
| 1223 | 1223 | ) |
| 1224 | - ); |
|
| 1225 | - $data['workunit']['max_error_results'] = array( |
|
| 1224 | + ); |
|
| 1225 | + $data['workunit']['max_error_results'] = array( |
|
| 1226 | 1226 | 'title' => bts('Max error tasks', array(), NULL, 'boinc:workunit-details'), |
| 1227 | 1227 | 'help' => t('The maximum number of error tasks in the workunit.'), |
| 1228 | 1228 | 'field' => array( |
| 1229 | - 'handler' => 'views_handler_field_numeric', |
|
| 1230 | - 'click sortable' => TRUE |
|
| 1229 | + 'handler' => 'views_handler_field_numeric', |
|
| 1230 | + 'click sortable' => TRUE |
|
| 1231 | 1231 | ), |
| 1232 | 1232 | 'filter' => array( |
| 1233 | - 'handler' => 'views_handler_filter_numeric' |
|
| 1233 | + 'handler' => 'views_handler_filter_numeric' |
|
| 1234 | 1234 | ), |
| 1235 | 1235 | 'sort' => array( |
| 1236 | - 'handler' => 'views_handler_sort_numeric' |
|
| 1236 | + 'handler' => 'views_handler_sort_numeric' |
|
| 1237 | 1237 | ) |
| 1238 | - ); |
|
| 1239 | - $data['workunit']['max_success_results'] = array( |
|
| 1238 | + ); |
|
| 1239 | + $data['workunit']['max_success_results'] = array( |
|
| 1240 | 1240 | 'title' => bts('Max success tasks', array(), NULL, 'boinc:workunit-details'), |
| 1241 | 1241 | 'help' => t('The maximum number of successful tasks in the workunit.'), |
| 1242 | 1242 | 'field' => array( |
| 1243 | - 'handler' => 'views_handler_field_numeric', |
|
| 1244 | - 'click sortable' => TRUE |
|
| 1243 | + 'handler' => 'views_handler_field_numeric', |
|
| 1244 | + 'click sortable' => TRUE |
|
| 1245 | 1245 | ), |
| 1246 | 1246 | 'filter' => array( |
| 1247 | - 'handler' => 'views_handler_filter_numeric' |
|
| 1247 | + 'handler' => 'views_handler_filter_numeric' |
|
| 1248 | 1248 | ), |
| 1249 | 1249 | 'sort' => array( |
| 1250 | - 'handler' => 'views_handler_sort_numeric' |
|
| 1250 | + 'handler' => 'views_handler_sort_numeric' |
|
| 1251 | 1251 | ) |
| 1252 | - ); |
|
| 1253 | - $data['workunit']['max_total_results'] = array( |
|
| 1252 | + ); |
|
| 1253 | + $data['workunit']['max_total_results'] = array( |
|
| 1254 | 1254 | 'title' => bts('Max total tasks', array(), NULL, 'boinc:workunit-details'), |
| 1255 | 1255 | 'help' => t('The maximum number of total tasks in the workunit.'), |
| 1256 | 1256 | 'field' => array( |
| 1257 | - 'handler' => 'views_handler_field_numeric', |
|
| 1258 | - 'click sortable' => TRUE |
|
| 1257 | + 'handler' => 'views_handler_field_numeric', |
|
| 1258 | + 'click sortable' => TRUE |
|
| 1259 | 1259 | ), |
| 1260 | 1260 | 'filter' => array( |
| 1261 | - 'handler' => 'views_handler_filter_numeric' |
|
| 1261 | + 'handler' => 'views_handler_filter_numeric' |
|
| 1262 | 1262 | ), |
| 1263 | 1263 | 'sort' => array( |
| 1264 | - 'handler' => 'views_handler_sort_numeric' |
|
| 1264 | + 'handler' => 'views_handler_sort_numeric' |
|
| 1265 | 1265 | ) |
| 1266 | - ); |
|
| 1267 | - $data['workunit']['need_validate'] = array( |
|
| 1266 | + ); |
|
| 1267 | + $data['workunit']['need_validate'] = array( |
|
| 1268 | 1268 | 'title' => bts('Needs validation', array(), NULL, 'boinc:workunit-details'), |
| 1269 | 1269 | 'help' => t('Whether or not a workunit needs validation.'), |
| 1270 | 1270 | 'field' => array( |
| 1271 | - 'handler' => 'views_handler_field_numeric', |
|
| 1272 | - 'click sortable' => TRUE |
|
| 1271 | + 'handler' => 'views_handler_field_numeric', |
|
| 1272 | + 'click sortable' => TRUE |
|
| 1273 | 1273 | ), |
| 1274 | 1274 | 'filter' => array( |
| 1275 | - 'handler' => 'views_handler_filter_numeric' |
|
| 1275 | + 'handler' => 'views_handler_filter_numeric' |
|
| 1276 | 1276 | ), |
| 1277 | 1277 | 'sort' => array( |
| 1278 | - 'handler' => 'views_handler_sort_numeric' |
|
| 1278 | + 'handler' => 'views_handler_sort_numeric' |
|
| 1279 | 1279 | ) |
| 1280 | - ); |
|
| 1281 | - $data['workunit']['target_nresults'] = array( |
|
| 1280 | + ); |
|
| 1281 | + $data['workunit']['target_nresults'] = array( |
|
| 1282 | 1282 | 'title' => bts('Initial replication', array(), NULL, 'boinc:workunit-details'), |
| 1283 | 1283 | 'help' => t('The target number of results for the workunit.'), |
| 1284 | 1284 | 'field' => array( |
| 1285 | - 'handler' => 'views_handler_field_numeric', |
|
| 1286 | - 'click sortable' => TRUE |
|
| 1285 | + 'handler' => 'views_handler_field_numeric', |
|
| 1286 | + 'click sortable' => TRUE |
|
| 1287 | 1287 | ), |
| 1288 | 1288 | 'filter' => array( |
| 1289 | - 'handler' => 'views_handler_filter_numeric' |
|
| 1289 | + 'handler' => 'views_handler_filter_numeric' |
|
| 1290 | 1290 | ), |
| 1291 | 1291 | 'sort' => array( |
| 1292 | - 'handler' => 'views_handler_sort_numeric' |
|
| 1292 | + 'handler' => 'views_handler_sort_numeric' |
|
| 1293 | 1293 | ) |
| 1294 | - ); |
|
| 1294 | + ); |
|
| 1295 | 1295 | |
| 1296 | - // ------------------------------------------------------------------------------------------------ |
|
| 1297 | - // Definition for app table |
|
| 1298 | - // ------------------------------------------------------------------------------------------------ |
|
| 1296 | + // ------------------------------------------------------------------------------------------------ |
|
| 1297 | + // Definition for app table |
|
| 1298 | + // ------------------------------------------------------------------------------------------------ |
|
| 1299 | 1299 | |
| 1300 | - $data['app']['table']['group'] = t('BOINC'); |
|
| 1301 | - $data['app']['table']['base'] = array( |
|
| 1302 | - 'field' => 'id', |
|
| 1303 | - 'title' => t('BOINC app'), |
|
| 1304 | - 'help' => t('Research applications run by BOINC'), |
|
| 1305 | - 'database' => 'boinc_ro' |
|
| 1306 | - ); |
|
| 1300 | + $data['app']['table']['group'] = t('BOINC'); |
|
| 1301 | + $data['app']['table']['base'] = array( |
|
| 1302 | + 'field' => 'id', |
|
| 1303 | + 'title' => t('BOINC app'), |
|
| 1304 | + 'help' => t('Research applications run by BOINC'), |
|
| 1305 | + 'database' => 'boinc_ro' |
|
| 1306 | + ); |
|
| 1307 | 1307 | |
| 1308 | - // Primary keys allowed as arguments |
|
| 1308 | + // Primary keys allowed as arguments |
|
| 1309 | 1309 | |
| 1310 | - $data['app']['id'] = array( |
|
| 1310 | + $data['app']['id'] = array( |
|
| 1311 | 1311 | 'title' => bts('Application ID', array(), NULL, 'boinc:application-details'), |
| 1312 | 1312 | 'help' => t('The ID number of this application.'), |
| 1313 | 1313 | 'field' => array( |
| 1314 | - 'handler' => 'views_handler_field_numeric', |
|
| 1315 | - 'click sortable' => TRUE |
|
| 1314 | + 'handler' => 'views_handler_field_numeric', |
|
| 1315 | + 'click sortable' => TRUE |
|
| 1316 | 1316 | ), |
| 1317 | 1317 | 'argument' => array( |
| 1318 | - 'handler' => 'views_handler_argument', |
|
| 1319 | - 'name field' => 'title', |
|
| 1320 | - 'numeric' => TRUE, |
|
| 1321 | - 'validate type' => 'id' |
|
| 1318 | + 'handler' => 'views_handler_argument', |
|
| 1319 | + 'name field' => 'title', |
|
| 1320 | + 'numeric' => TRUE, |
|
| 1321 | + 'validate type' => 'id' |
|
| 1322 | 1322 | ), |
| 1323 | 1323 | 'filter' => array( |
| 1324 | - 'handler' => 'views_handler_filter_numeric' |
|
| 1324 | + 'handler' => 'views_handler_filter_numeric' |
|
| 1325 | 1325 | ), |
| 1326 | 1326 | 'sort' => array( |
| 1327 | - 'handler' => 'views_handler_sort_numeric' |
|
| 1327 | + 'handler' => 'views_handler_sort_numeric' |
|
| 1328 | 1328 | ) |
| 1329 | - ); |
|
| 1329 | + ); |
|
| 1330 | 1330 | |
| 1331 | - // Descriptions of app fields (alphabetized) |
|
| 1331 | + // Descriptions of app fields (alphabetized) |
|
| 1332 | 1332 | |
| 1333 | - $data['app']['target_nresults'] = array( |
|
| 1333 | + $data['app']['target_nresults'] = array( |
|
| 1334 | 1334 | 'title' => bts('Target number of results', array(), NULL, 'boinc:application-details'), |
| 1335 | 1335 | 'help' => t('The number of times to replicate tasks in this application.'), |
| 1336 | 1336 | 'field' => array( |
| 1337 | - 'handler' => 'views_handler_field_numeric', |
|
| 1338 | - 'click sortable' => TRUE |
|
| 1337 | + 'handler' => 'views_handler_field_numeric', |
|
| 1338 | + 'click sortable' => TRUE |
|
| 1339 | 1339 | ), |
| 1340 | 1340 | 'filter' => array( |
| 1341 | - 'handler' => 'views_handler_filter_numeric' |
|
| 1341 | + 'handler' => 'views_handler_filter_numeric' |
|
| 1342 | 1342 | ), |
| 1343 | 1343 | 'sort' => array( |
| 1344 | - 'handler' => 'views_handler_sort_numeric' |
|
| 1344 | + 'handler' => 'views_handler_sort_numeric' |
|
| 1345 | 1345 | ) |
| 1346 | - ); |
|
| 1347 | - $data['app']['user_friendly_name'] = array( |
|
| 1346 | + ); |
|
| 1347 | + $data['app']['user_friendly_name'] = array( |
|
| 1348 | 1348 | 'title' => bts('Name', array(), NULL, 'boinc:details:-1:name-of-the-host-or-task-or-workunit-etc-being-viewed-ignoreoverwrite'), |
| 1349 | 1349 | 'help' => t('The user friendly name of the application.'), |
| 1350 | 1350 | 'field' => array( |
| 1351 | - 'handler' => 'views_handler_field', |
|
| 1352 | - 'click sortable' => TRUE |
|
| 1351 | + 'handler' => 'views_handler_field', |
|
| 1352 | + 'click sortable' => TRUE |
|
| 1353 | 1353 | ), |
| 1354 | 1354 | 'filter' => array( |
| 1355 | - 'handler' => 'views_handler_filter_string' |
|
| 1355 | + 'handler' => 'views_handler_filter_string' |
|
| 1356 | 1356 | ), |
| 1357 | 1357 | 'sort' => array( |
| 1358 | - 'handler' => 'views_handler_sort_string' |
|
| 1358 | + 'handler' => 'views_handler_sort_string' |
|
| 1359 | 1359 | ) |
| 1360 | - ); |
|
| 1360 | + ); |
|
| 1361 | 1361 | |
| 1362 | - // ------------------------------------------------------------------------------------------------ |
|
| 1363 | - // Definition for app_version table |
|
| 1364 | - // ------------------------------------------------------------------------------------------------ |
|
| 1362 | + // ------------------------------------------------------------------------------------------------ |
|
| 1363 | + // Definition for app_version table |
|
| 1364 | + // ------------------------------------------------------------------------------------------------ |
|
| 1365 | 1365 | |
| 1366 | - $data['app_version']['table']['group'] = t('BOINC'); |
|
| 1367 | - $data['app_version']['table']['base'] = array( |
|
| 1368 | - 'field' => 'id', |
|
| 1369 | - 'title' => t('BOINC app version'), |
|
| 1370 | - 'help' => t('Versions of research applications run by BOINC'), |
|
| 1371 | - 'database' => 'boinc_ro' |
|
| 1372 | - ); |
|
| 1366 | + $data['app_version']['table']['group'] = t('BOINC'); |
|
| 1367 | + $data['app_version']['table']['base'] = array( |
|
| 1368 | + 'field' => 'id', |
|
| 1369 | + 'title' => t('BOINC app version'), |
|
| 1370 | + 'help' => t('Versions of research applications run by BOINC'), |
|
| 1371 | + 'database' => 'boinc_ro' |
|
| 1372 | + ); |
|
| 1373 | 1373 | |
| 1374 | - // Primary keys allowed as arguments |
|
| 1374 | + // Primary keys allowed as arguments |
|
| 1375 | 1375 | |
| 1376 | - $data['app_version']['id'] = array( |
|
| 1376 | + $data['app_version']['id'] = array( |
|
| 1377 | 1377 | 'title' => bts('Application version ID', array(), NULL, 'boinc:application-details'), |
| 1378 | 1378 | 'help' => t('The ID number of this application version.'), |
| 1379 | 1379 | 'field' => array( |
| 1380 | - 'handler' => 'views_handler_field_numeric', |
|
| 1381 | - 'click sortable' => TRUE |
|
| 1380 | + 'handler' => 'views_handler_field_numeric', |
|
| 1381 | + 'click sortable' => TRUE |
|
| 1382 | 1382 | ), |
| 1383 | 1383 | 'argument' => array( |
| 1384 | - 'handler' => 'views_handler_argument', |
|
| 1385 | - 'name field' => 'title', |
|
| 1386 | - 'numeric' => TRUE, |
|
| 1387 | - 'validate type' => 'id' |
|
| 1384 | + 'handler' => 'views_handler_argument', |
|
| 1385 | + 'name field' => 'title', |
|
| 1386 | + 'numeric' => TRUE, |
|
| 1387 | + 'validate type' => 'id' |
|
| 1388 | 1388 | ), |
| 1389 | 1389 | 'filter' => array( |
| 1390 | - 'handler' => 'views_handler_filter_numeric' |
|
| 1390 | + 'handler' => 'views_handler_filter_numeric' |
|
| 1391 | 1391 | ), |
| 1392 | 1392 | 'sort' => array( |
| 1393 | - 'handler' => 'views_handler_sort_numeric' |
|
| 1393 | + 'handler' => 'views_handler_sort_numeric' |
|
| 1394 | 1394 | ) |
| 1395 | - ); |
|
| 1395 | + ); |
|
| 1396 | 1396 | |
| 1397 | - // Foreign key fields |
|
| 1397 | + // Foreign key fields |
|
| 1398 | 1398 | |
| 1399 | - $data['app_version']['appid'] = array( |
|
| 1399 | + $data['app_version']['appid'] = array( |
|
| 1400 | 1400 | 'title' => bts('Application ID', array(), NULL, 'boinc:application-details'), |
| 1401 | 1401 | 'help' => t('The application ID associated with this app version.'), |
| 1402 | 1402 | // Because this is a foreign key to the {app} table. This allows us to |
| 1403 | 1403 | // have, when the view is configured with this relationship, all the fields |
| 1404 | 1404 | // for the related node available. |
| 1405 | 1405 | 'argument' => array( |
| 1406 | - 'handler' => 'views_handler_argument_numeric', |
|
| 1407 | - 'name field' => 'title', |
|
| 1408 | - 'numeric' => TRUE, |
|
| 1409 | - 'validate type' => 'id' |
|
| 1406 | + 'handler' => 'views_handler_argument_numeric', |
|
| 1407 | + 'name field' => 'title', |
|
| 1408 | + 'numeric' => TRUE, |
|
| 1409 | + 'validate type' => 'id' |
|
| 1410 | 1410 | ), |
| 1411 | 1411 | 'relationship' => array( |
| 1412 | - 'base' => 'app', |
|
| 1413 | - 'field' => 'id', |
|
| 1414 | - 'handler' => 'views_handler_relationship', |
|
| 1415 | - 'label' => t('App ID') |
|
| 1412 | + 'base' => 'app', |
|
| 1413 | + 'field' => 'id', |
|
| 1414 | + 'handler' => 'views_handler_relationship', |
|
| 1415 | + 'label' => t('App ID') |
|
| 1416 | 1416 | ), |
| 1417 | 1417 | 'field' => array( |
| 1418 | - 'handler' => 'views_handler_field_numeric', |
|
| 1419 | - 'click sortable' => TRUE |
|
| 1418 | + 'handler' => 'views_handler_field_numeric', |
|
| 1419 | + 'click sortable' => TRUE |
|
| 1420 | 1420 | ), |
| 1421 | 1421 | 'filter' => array( |
| 1422 | - 'handler' => 'views_handler_filter_numeric' |
|
| 1422 | + 'handler' => 'views_handler_filter_numeric' |
|
| 1423 | 1423 | ), |
| 1424 | 1424 | 'sort' => array( |
| 1425 | - 'handler' => 'views_handler_sort_numeric' |
|
| 1425 | + 'handler' => 'views_handler_sort_numeric' |
|
| 1426 | 1426 | ) |
| 1427 | - ); |
|
| 1427 | + ); |
|
| 1428 | 1428 | |
| 1429 | - $data['app_version']['platformid'] = array( |
|
| 1429 | + $data['app_version']['platformid'] = array( |
|
| 1430 | 1430 | 'title' => bts('Platform ID', array(), NULL, 'boinc:platform-details'), |
| 1431 | 1431 | 'help' => t('The platform ID associated with this app version.'), |
| 1432 | 1432 | // Because this is a foreign key to the {platform} table. This allows us to |
| 1433 | 1433 | // have, when the view is configured with this relationship, all the fields |
| 1434 | 1434 | // for the related node available. |
| 1435 | 1435 | 'argument' => array( |
| 1436 | - 'handler' => 'views_handler_argument_numeric', |
|
| 1437 | - 'name field' => 'title', |
|
| 1438 | - 'numeric' => TRUE, |
|
| 1439 | - 'validate type' => 'id' |
|
| 1436 | + 'handler' => 'views_handler_argument_numeric', |
|
| 1437 | + 'name field' => 'title', |
|
| 1438 | + 'numeric' => TRUE, |
|
| 1439 | + 'validate type' => 'id' |
|
| 1440 | 1440 | ), |
| 1441 | 1441 | 'relationship' => array( |
| 1442 | - 'base' => 'platform', |
|
| 1443 | - 'field' => 'id', |
|
| 1444 | - 'handler' => 'views_handler_relationship', |
|
| 1445 | - 'label' => t('Platform ID') |
|
| 1442 | + 'base' => 'platform', |
|
| 1443 | + 'field' => 'id', |
|
| 1444 | + 'handler' => 'views_handler_relationship', |
|
| 1445 | + 'label' => t('Platform ID') |
|
| 1446 | 1446 | ), |
| 1447 | 1447 | 'field' => array( |
| 1448 | - 'handler' => 'views_handler_field_numeric', |
|
| 1449 | - 'click sortable' => TRUE |
|
| 1448 | + 'handler' => 'views_handler_field_numeric', |
|
| 1449 | + 'click sortable' => TRUE |
|
| 1450 | 1450 | ), |
| 1451 | 1451 | 'filter' => array( |
| 1452 | - 'handler' => 'views_handler_filter_numeric' |
|
| 1452 | + 'handler' => 'views_handler_filter_numeric' |
|
| 1453 | 1453 | ), |
| 1454 | 1454 | 'sort' => array( |
| 1455 | - 'handler' => 'views_handler_sort_numeric' |
|
| 1455 | + 'handler' => 'views_handler_sort_numeric' |
|
| 1456 | 1456 | ) |
| 1457 | - ); |
|
| 1457 | + ); |
|
| 1458 | 1458 | |
| 1459 | - // Descriptions of app fields (alphabetized) |
|
| 1459 | + // Descriptions of app fields (alphabetized) |
|
| 1460 | 1460 | |
| 1461 | - $data['app_version']['plan_class'] = array( |
|
| 1461 | + $data['app_version']['plan_class'] = array( |
|
| 1462 | 1462 | 'title' => bts('Plan class', array(), NULL, 'boinc:application-details'), |
| 1463 | 1463 | 'help' => t('App version plan class.'), |
| 1464 | 1464 | 'field' => array( |
| 1465 | - 'handler' => 'views_handler_field', |
|
| 1466 | - 'click sortable' => TRUE |
|
| 1465 | + 'handler' => 'views_handler_field', |
|
| 1466 | + 'click sortable' => TRUE |
|
| 1467 | 1467 | ), |
| 1468 | 1468 | 'filter' => array( |
| 1469 | - 'handler' => 'views_handler_filter_string' |
|
| 1469 | + 'handler' => 'views_handler_filter_string' |
|
| 1470 | 1470 | ), |
| 1471 | 1471 | 'sort' => array( |
| 1472 | - 'handler' => 'views_handler_sort_string' |
|
| 1472 | + 'handler' => 'views_handler_sort_string' |
|
| 1473 | 1473 | ) |
| 1474 | - ); |
|
| 1475 | - $data['app_version']['version_num'] = array( |
|
| 1474 | + ); |
|
| 1475 | + $data['app_version']['version_num'] = array( |
|
| 1476 | 1476 | 'title' => bts('Version number', array(), NULL, 'boinc:application-details'), |
| 1477 | 1477 | 'help' => t('The application version number.'), |
| 1478 | 1478 | 'field' => array( |
| 1479 | - 'handler' => 'views_handler_field_boincwork_app_version_number', |
|
| 1480 | - 'click sortable' => TRUE, |
|
| 1481 | - 'float' => TRUE, |
|
| 1479 | + 'handler' => 'views_handler_field_boincwork_app_version_number', |
|
| 1480 | + 'click sortable' => TRUE, |
|
| 1481 | + 'float' => TRUE, |
|
| 1482 | 1482 | ), |
| 1483 | 1483 | 'filter' => array( |
| 1484 | - 'handler' => 'views_handler_filter_numeric' |
|
| 1484 | + 'handler' => 'views_handler_filter_numeric' |
|
| 1485 | 1485 | ), |
| 1486 | 1486 | 'sort' => array( |
| 1487 | - 'handler' => 'views_handler_sort_numeric' |
|
| 1487 | + 'handler' => 'views_handler_sort_numeric' |
|
| 1488 | 1488 | ) |
| 1489 | - ); |
|
| 1489 | + ); |
|
| 1490 | 1490 | |
| 1491 | - // ------------------------------------------------------------------------------------------------ |
|
| 1492 | - // Definition for host_app_version table |
|
| 1493 | - // ------------------------------------------------------------------------------------------------ |
|
| 1491 | + // ------------------------------------------------------------------------------------------------ |
|
| 1492 | + // Definition for host_app_version table |
|
| 1493 | + // ------------------------------------------------------------------------------------------------ |
|
| 1494 | 1494 | |
| 1495 | - $data['host_app_version']['table']['group'] = t('BOINC'); |
|
| 1495 | + $data['host_app_version']['table']['group'] = t('BOINC'); |
|
| 1496 | 1496 | |
| 1497 | - // This table references the {host} table. |
|
| 1498 | - // This join creates an 'implicit' relationship to the host table, so that when |
|
| 1499 | - // "Host" is the base table, the fields are automatically available. |
|
| 1497 | + // This table references the {host} table. |
|
| 1498 | + // This join creates an 'implicit' relationship to the host table, so that when |
|
| 1499 | + // "Host" is the base table, the fields are automatically available. |
|
| 1500 | 1500 | |
| 1501 | - // Index this array by the table name to which this table refers. |
|
| 1502 | - // 'left_field' is the primary key in the referenced table. |
|
| 1503 | - // 'field' is the foreign key in this table. |
|
| 1501 | + // Index this array by the table name to which this table refers. |
|
| 1502 | + // 'left_field' is the primary key in the referenced table. |
|
| 1503 | + // 'field' is the foreign key in this table. |
|
| 1504 | 1504 | |
| 1505 | - $data['host_app_version']['table']['join'] = array( |
|
| 1505 | + $data['host_app_version']['table']['join'] = array( |
|
| 1506 | 1506 | 'host' => array( |
| 1507 | - 'left_field' => 'id', |
|
| 1508 | - 'field' => 'host_id', |
|
| 1507 | + 'left_field' => 'id', |
|
| 1508 | + 'field' => 'host_id', |
|
| 1509 | 1509 | ) |
| 1510 | - ); |
|
| 1510 | + ); |
|
| 1511 | 1511 | |
| 1512 | - // Primary keys allowed as arguments |
|
| 1512 | + // Primary keys allowed as arguments |
|
| 1513 | 1513 | |
| 1514 | - $data['host_app_version']['host_id'] = array( |
|
| 1514 | + $data['host_app_version']['host_id'] = array( |
|
| 1515 | 1515 | 'title' => bts('Computer', array(), NULL, 'boinc:host-details'), |
| 1516 | 1516 | 'help' => t('The host ID connected to this app version data.'), |
| 1517 | 1517 | 'field' => array( |
| 1518 | - 'handler' => 'views_handler_field_numeric', |
|
| 1519 | - 'click sortable' => TRUE |
|
| 1518 | + 'handler' => 'views_handler_field_numeric', |
|
| 1519 | + 'click sortable' => TRUE |
|
| 1520 | 1520 | ), |
| 1521 | 1521 | 'argument' => array( |
| 1522 | - 'handler' => 'views_handler_argument', |
|
| 1523 | - 'name field' => 'title', |
|
| 1524 | - 'numeric' => TRUE, |
|
| 1525 | - 'validate type' => 'id' |
|
| 1522 | + 'handler' => 'views_handler_argument', |
|
| 1523 | + 'name field' => 'title', |
|
| 1524 | + 'numeric' => TRUE, |
|
| 1525 | + 'validate type' => 'id' |
|
| 1526 | 1526 | ), |
| 1527 | 1527 | 'filter' => array( |
| 1528 | - 'handler' => 'views_handler_filter_numeric' |
|
| 1528 | + 'handler' => 'views_handler_filter_numeric' |
|
| 1529 | 1529 | ), |
| 1530 | 1530 | 'sort' => array( |
| 1531 | - 'handler' => 'views_handler_sort_numeric' |
|
| 1531 | + 'handler' => 'views_handler_sort_numeric' |
|
| 1532 | 1532 | ) |
| 1533 | - ); |
|
| 1533 | + ); |
|
| 1534 | 1534 | |
| 1535 | - // Foreign key fields |
|
| 1535 | + // Foreign key fields |
|
| 1536 | 1536 | |
| 1537 | - $data['host_app_version']['app_version_id'] = array( |
|
| 1537 | + $data['host_app_version']['app_version_id'] = array( |
|
| 1538 | 1538 | 'title' => bts('App version ID', array(), NULL, 'boinc:application-details'), |
| 1539 | 1539 | 'help' => t('The app version ID connected to this host data.'), |
| 1540 | 1540 | // Because this is a foreign key to the {host} table. This allows us to |
| 1541 | 1541 | // have, when the view is configured with this relationship, all the fields |
| 1542 | 1542 | // for the related node available. |
| 1543 | 1543 | 'argument' => array( |
| 1544 | - 'handler' => 'views_handler_argument_numeric', |
|
| 1545 | - 'name field' => 'title', |
|
| 1546 | - 'numeric' => TRUE, |
|
| 1547 | - 'validate type' => 'id' |
|
| 1544 | + 'handler' => 'views_handler_argument_numeric', |
|
| 1545 | + 'name field' => 'title', |
|
| 1546 | + 'numeric' => TRUE, |
|
| 1547 | + 'validate type' => 'id' |
|
| 1548 | 1548 | ), |
| 1549 | 1549 | 'relationship' => array( |
| 1550 | - 'base' => 'app_version', |
|
| 1551 | - 'field' => 'id', |
|
| 1552 | - 'handler' => 'views_handler_relationship', |
|
| 1553 | - 'label' => t('App version') |
|
| 1550 | + 'base' => 'app_version', |
|
| 1551 | + 'field' => 'id', |
|
| 1552 | + 'handler' => 'views_handler_relationship', |
|
| 1553 | + 'label' => t('App version') |
|
| 1554 | 1554 | ), |
| 1555 | 1555 | 'field' => array( |
| 1556 | - 'handler' => 'views_handler_field_numeric', |
|
| 1557 | - 'click sortable' => TRUE |
|
| 1556 | + 'handler' => 'views_handler_field_numeric', |
|
| 1557 | + 'click sortable' => TRUE |
|
| 1558 | 1558 | ), |
| 1559 | 1559 | 'filter' => array( |
| 1560 | - 'handler' => 'views_handler_filter_numeric' |
|
| 1560 | + 'handler' => 'views_handler_filter_numeric' |
|
| 1561 | 1561 | ), |
| 1562 | 1562 | 'sort' => array( |
| 1563 | - 'handler' => 'views_handler_sort_numeric' |
|
| 1563 | + 'handler' => 'views_handler_sort_numeric' |
|
| 1564 | 1564 | ) |
| 1565 | - ); |
|
| 1565 | + ); |
|
| 1566 | 1566 | |
| 1567 | - // Descriptions of host_app_version fields (alphabetized) |
|
| 1567 | + // Descriptions of host_app_version fields (alphabetized) |
|
| 1568 | 1568 | |
| 1569 | - $data['host_app_version']['consecutive_valid'] = array( |
|
| 1569 | + $data['host_app_version']['consecutive_valid'] = array( |
|
| 1570 | 1570 | 'title' => bts('Consecutive valid tasks', array(), NULL, 'boinc:application-details'), |
| 1571 | 1571 | 'help' => t('The number of consecutive valid tasks for this app and by this host.'), |
| 1572 | 1572 | 'field' => array( |
| 1573 | - 'handler' => 'views_handler_field_numeric', |
|
| 1574 | - 'click sortable' => TRUE |
|
| 1573 | + 'handler' => 'views_handler_field_numeric', |
|
| 1574 | + 'click sortable' => TRUE |
|
| 1575 | 1575 | ), |
| 1576 | 1576 | 'filter' => array( |
| 1577 | - 'handler' => 'views_handler_filter_numeric' |
|
| 1577 | + 'handler' => 'views_handler_filter_numeric' |
|
| 1578 | 1578 | ), |
| 1579 | 1579 | 'sort' => array( |
| 1580 | - 'handler' => 'views_handler_sort_numeric' |
|
| 1580 | + 'handler' => 'views_handler_sort_numeric' |
|
| 1581 | 1581 | ) |
| 1582 | - ); |
|
| 1583 | - $data['host_app_version']['et_avg'] = array( |
|
| 1582 | + ); |
|
| 1583 | + $data['host_app_version']['et_avg'] = array( |
|
| 1584 | 1584 | 'title' => t('Average processing rate'), |
| 1585 | 1585 | 'help' => t('The "et_avg" for this app and by this host.'), |
| 1586 | 1586 | 'field' => array( |
| 1587 | - 'handler' => 'views_handler_field_boincwork_host_app_et_avg', |
|
| 1588 | - 'click sortable' => TRUE |
|
| 1587 | + 'handler' => 'views_handler_field_boincwork_host_app_et_avg', |
|
| 1588 | + 'click sortable' => TRUE |
|
| 1589 | 1589 | ), |
| 1590 | 1590 | 'filter' => array( |
| 1591 | - 'handler' => 'views_handler_filter_numeric' |
|
| 1591 | + 'handler' => 'views_handler_filter_numeric' |
|
| 1592 | 1592 | ), |
| 1593 | 1593 | 'sort' => array( |
| 1594 | - 'handler' => 'views_handler_sort_numeric' |
|
| 1594 | + 'handler' => 'views_handler_sort_numeric' |
|
| 1595 | 1595 | ) |
| 1596 | - ); |
|
| 1597 | - $data['host_app_version']['et_n'] = array( |
|
| 1596 | + ); |
|
| 1597 | + $data['host_app_version']['et_n'] = array( |
|
| 1598 | 1598 | 'title' => bts('Number of tasks completed', array(), NULL, 'boinc:application-details'), |
| 1599 | 1599 | 'help' => t('The tasks completed for this app and by this host.'), |
| 1600 | 1600 | 'field' => array( |
| 1601 | - 'handler' => 'views_handler_field_numeric', |
|
| 1602 | - 'click sortable' => TRUE |
|
| 1601 | + 'handler' => 'views_handler_field_numeric', |
|
| 1602 | + 'click sortable' => TRUE |
|
| 1603 | 1603 | ), |
| 1604 | 1604 | 'filter' => array( |
| 1605 | - 'handler' => 'views_handler_filter_numeric' |
|
| 1605 | + 'handler' => 'views_handler_filter_numeric' |
|
| 1606 | 1606 | ), |
| 1607 | 1607 | 'sort' => array( |
| 1608 | - 'handler' => 'views_handler_sort_numeric' |
|
| 1608 | + 'handler' => 'views_handler_sort_numeric' |
|
| 1609 | 1609 | ) |
| 1610 | - ); |
|
| 1611 | - $data['host_app_version']['max_jobs_per_day'] = array( |
|
| 1610 | + ); |
|
| 1611 | + $data['host_app_version']['max_jobs_per_day'] = array( |
|
| 1612 | 1612 | 'title' => bts('Max tasks per day', array(), NULL, 'boinc:application-details'), |
| 1613 | 1613 | 'help' => t('The maximum tasks per day for this app and by this host.'), |
| 1614 | 1614 | 'field' => array( |
| 1615 | - 'handler' => 'views_handler_field_numeric', |
|
| 1616 | - 'click sortable' => TRUE |
|
| 1615 | + 'handler' => 'views_handler_field_numeric', |
|
| 1616 | + 'click sortable' => TRUE |
|
| 1617 | 1617 | ), |
| 1618 | 1618 | 'filter' => array( |
| 1619 | - 'handler' => 'views_handler_filter_numeric' |
|
| 1619 | + 'handler' => 'views_handler_filter_numeric' |
|
| 1620 | 1620 | ), |
| 1621 | 1621 | 'sort' => array( |
| 1622 | - 'handler' => 'views_handler_sort_numeric' |
|
| 1622 | + 'handler' => 'views_handler_sort_numeric' |
|
| 1623 | 1623 | ) |
| 1624 | - ); |
|
| 1625 | - $data['host_app_version']['n_jobs_today'] = array( |
|
| 1624 | + ); |
|
| 1625 | + $data['host_app_version']['n_jobs_today'] = array( |
|
| 1626 | 1626 | 'title' => bts('Number of tasks today', array(), NULL, 'boinc:application-details'), |
| 1627 | 1627 | 'help' => t('The number of tasks today for this app and by this host.'), |
| 1628 | 1628 | 'field' => array( |
| 1629 | - 'handler' => 'views_handler_field_numeric', |
|
| 1630 | - 'click sortable' => TRUE |
|
| 1629 | + 'handler' => 'views_handler_field_numeric', |
|
| 1630 | + 'click sortable' => TRUE |
|
| 1631 | 1631 | ), |
| 1632 | 1632 | 'filter' => array( |
| 1633 | - 'handler' => 'views_handler_filter_numeric' |
|
| 1633 | + 'handler' => 'views_handler_filter_numeric' |
|
| 1634 | 1634 | ), |
| 1635 | 1635 | 'sort' => array( |
| 1636 | - 'handler' => 'views_handler_sort_numeric' |
|
| 1636 | + 'handler' => 'views_handler_sort_numeric' |
|
| 1637 | 1637 | ) |
| 1638 | - ); |
|
| 1639 | - $data['host_app_version']['turnaround_avg'] = array( |
|
| 1638 | + ); |
|
| 1639 | + $data['host_app_version']['turnaround_avg'] = array( |
|
| 1640 | 1640 | 'title' => bts('Average turnaround time', array(), NULL, 'boinc:application-details:-1:ignoreoverwrite'), |
| 1641 | 1641 | 'help' => t('The average turnaround time per task for this app and by this host.'), |
| 1642 | 1642 | 'field' => array( |
| 1643 | - 'handler' => 'views_handler_field_boincwork_host_app_turnaround_avg', |
|
| 1644 | - 'click sortable' => TRUE, |
|
| 1645 | - 'float' => TRUE, |
|
| 1643 | + 'handler' => 'views_handler_field_boincwork_host_app_turnaround_avg', |
|
| 1644 | + 'click sortable' => TRUE, |
|
| 1645 | + 'float' => TRUE, |
|
| 1646 | 1646 | ), |
| 1647 | 1647 | 'filter' => array( |
| 1648 | - 'handler' => 'views_handler_filter_numeric' |
|
| 1648 | + 'handler' => 'views_handler_filter_numeric' |
|
| 1649 | 1649 | ), |
| 1650 | 1650 | 'sort' => array( |
| 1651 | - 'handler' => 'views_handler_sort_numeric' |
|
| 1651 | + 'handler' => 'views_handler_sort_numeric' |
|
| 1652 | 1652 | ) |
| 1653 | - ); |
|
| 1654 | - $data['host_app_version']['user_friendly_name'] = array( |
|
| 1653 | + ); |
|
| 1654 | + $data['host_app_version']['user_friendly_name'] = array( |
|
| 1655 | 1655 | 'title' => bts('Name', array(), NULL, 'boinc:details:-1:name-of-the-host-or-task-or-workunit-etc-being-viewed-ignoreoverwrite'), |
| 1656 | 1656 | 'help' => t('The user friendly name of the application.'), |
| 1657 | 1657 | 'field' => array( |
| 1658 | - 'handler' => 'views_handler_field', |
|
| 1659 | - 'click sortable' => TRUE |
|
| 1658 | + 'handler' => 'views_handler_field', |
|
| 1659 | + 'click sortable' => TRUE |
|
| 1660 | 1660 | ), |
| 1661 | 1661 | 'filter' => array( |
| 1662 | - 'handler' => 'views_handler_filter_string' |
|
| 1662 | + 'handler' => 'views_handler_filter_string' |
|
| 1663 | 1663 | ), |
| 1664 | 1664 | 'sort' => array( |
| 1665 | - 'handler' => 'views_handler_sort_string' |
|
| 1665 | + 'handler' => 'views_handler_sort_string' |
|
| 1666 | 1666 | ) |
| 1667 | - ); |
|
| 1667 | + ); |
|
| 1668 | 1668 | |
| 1669 | - return $data; |
|
| 1669 | + return $data; |
|
| 1670 | 1670 | } |
| 1671 | 1671 | |
| 1672 | 1672 | /* |
@@ -1678,23 +1678,23 @@ discard block |
||
| 1678 | 1678 | |
| 1679 | 1679 | function boincwork_views_handlers() { |
| 1680 | 1680 | |
| 1681 | - return array( |
|
| 1681 | + return array( |
|
| 1682 | 1682 | 'info' => array( |
| 1683 | - 'path' => drupal_get_path('module', 'boincwork') . '/views', |
|
| 1683 | + 'path' => drupal_get_path('module', 'boincwork') . '/views', |
|
| 1684 | 1684 | ), |
| 1685 | 1685 | 'handlers' => array( |
| 1686 | - 'views_handler_argument_boincuser_id' => array( |
|
| 1686 | + 'views_handler_argument_boincuser_id' => array( |
|
| 1687 | 1687 | 'parent' => 'views_handler_argument_numeric' |
| 1688 | - ), |
|
| 1689 | - 'views_handler_field_boincwork_app_version_number' => array( |
|
| 1688 | + ), |
|
| 1689 | + 'views_handler_field_boincwork_app_version_number' => array( |
|
| 1690 | 1690 | 'parent' => 'views_handler_field_numeric' |
| 1691 | - ), |
|
| 1692 | - 'views_handler_field_boincwork_host_app_et_avg' => array( |
|
| 1691 | + ), |
|
| 1692 | + 'views_handler_field_boincwork_host_app_et_avg' => array( |
|
| 1693 | 1693 | 'parent' => 'views_handler_field_numeric' |
| 1694 | - ), |
|
| 1695 | - 'views_handler_field_boincwork_host_app_turnaround_avg' => array( |
|
| 1694 | + ), |
|
| 1695 | + 'views_handler_field_boincwork_host_app_turnaround_avg' => array( |
|
| 1696 | 1696 | 'parent' => 'views_handler_field_numeric' |
| 1697 | - ), |
|
| 1697 | + ), |
|
| 1698 | 1698 | ) |
| 1699 | - ); |
|
| 1699 | + ); |
|
| 1700 | 1700 | } |