@@ -12,33 +12,33 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | |
| 15 | - require_once('./includes/bootstrap.inc'); |
|
| 16 | - drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); |
|
| 17 | - require_boinc('db'); |
|
| 15 | + require_once('./includes/bootstrap.inc'); |
|
| 16 | + drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); |
|
| 17 | + require_boinc('db'); |
|
| 18 | 18 | |
| 19 | - // Parse arguments |
|
| 20 | - $record_offset = isset($argv[1]) ? $argv[1] : 0; |
|
| 21 | - $chunk_size = isset($argv[2]) ? $argv[2] : 100; |
|
| 19 | + // Parse arguments |
|
| 20 | + $record_offset = isset($argv[1]) ? $argv[1] : 0; |
|
| 21 | + $chunk_size = isset($argv[2]) ? $argv[2] : 100; |
|
| 22 | 22 | |
| 23 | - // Construct sql conditions |
|
| 24 | - $limit = sprintf('LIMIT %d,%d', $record_offset, $chunk_size); |
|
| 23 | + // Construct sql conditions |
|
| 24 | + $limit = sprintf('LIMIT %d,%d', $record_offset, $chunk_size); |
|
| 25 | 25 | |
| 26 | - $total_count = 0; |
|
| 26 | + $total_count = 0; |
|
| 27 | 27 | |
| 28 | - // Get the users with subscriptions to import |
|
| 29 | - db_set_active('boinc_rw'); |
|
| 30 | - $subscribed_boinc_users = db_query(" |
|
| 28 | + // Get the users with subscriptions to import |
|
| 29 | + db_set_active('boinc_rw'); |
|
| 30 | + $subscribed_boinc_users = db_query(" |
|
| 31 | 31 | SELECT DISTINCT userid FROM {subscriptions} |
| 32 | 32 | ORDER BY userid ASC %s", $limit |
| 33 | - ); |
|
| 34 | - db_set_active('default'); |
|
| 33 | + ); |
|
| 34 | + db_set_active('default'); |
|
| 35 | 35 | |
| 36 | - // Import subscriptions |
|
| 37 | - while ($boinc_subscription = db_fetch_object($subscribed_boinc_users)) { |
|
| 36 | + // Import subscriptions |
|
| 37 | + while ($boinc_subscription = db_fetch_object($subscribed_boinc_users)) { |
|
| 38 | 38 | $uid = get_drupal_id($boinc_subscription->userid); |
| 39 | 39 | $count = boincuser_pull_subscriptions($uid); |
| 40 | 40 | $total_count += $count; |
| 41 | 41 | echo "\nuser: {$uid}; boinc_id: {$boinc_subscription->userid}; {$count} subscriptions"; |
| 42 | - } |
|
| 43 | - echo "\n"; |
|
| 44 | - echo $total_count; |
|
| 42 | + } |
|
| 43 | + echo "\n"; |
|
| 44 | + echo $total_count; |
|
@@ -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 | - } |
|
| 75 | + } |
|
| 76 | 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) { |
|
| 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 | |
@@ -12,26 +12,26 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | |
| 15 | - require_once('./includes/bootstrap.inc'); |
|
| 16 | - drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); |
|
| 17 | - require_boinc('db'); |
|
| 15 | + require_once('./includes/bootstrap.inc'); |
|
| 16 | + drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); |
|
| 17 | + require_boinc('db'); |
|
| 18 | 18 | |
| 19 | - // Parse arguments |
|
| 20 | - $import_lurkers = isset($argv[1]) ? $argv[1] : false; |
|
| 21 | - $record_offset = isset($argv[2]) ? $argv[2] : 0; |
|
| 22 | - $chunk_size = isset($argv[3]) ? $argv[3] : 100; |
|
| 19 | + // Parse arguments |
|
| 20 | + $import_lurkers = isset($argv[1]) ? $argv[1] : false; |
|
| 21 | + $record_offset = isset($argv[2]) ? $argv[2] : 0; |
|
| 22 | + $chunk_size = isset($argv[3]) ? $argv[3] : 100; |
|
| 23 | 23 | |
| 24 | - // Construct sql conditions |
|
| 25 | - $limit = sprintf('LIMIT %d,%d', $record_offset, $chunk_size); |
|
| 24 | + // Construct sql conditions |
|
| 25 | + $limit = sprintf('LIMIT %d,%d', $record_offset, $chunk_size); |
|
| 26 | 26 | |
| 27 | - $count = 0; |
|
| 27 | + $count = 0; |
|
| 28 | 28 | |
| 29 | - db_set_active('boinc_rw'); |
|
| 30 | - if ($import_lurkers) { |
|
| 29 | + db_set_active('boinc_rw'); |
|
| 30 | + if ($import_lurkers) { |
|
| 31 | 31 | $boinc_accounts = db_query('SELECT id FROM user ORDER BY id %s', $limit); |
| 32 | - } |
|
| 33 | - //else $boinc_accounts = db_query('SELECT DISTINCT user AS boinc_id FROM post ORDER BY boinc_id %s', $limit); |
|
| 34 | - else { |
|
| 32 | + } |
|
| 33 | + //else $boinc_accounts = db_query('SELECT DISTINCT user AS boinc_id FROM post ORDER BY boinc_id %s', $limit); |
|
| 34 | + else { |
|
| 35 | 35 | // Need to import any user who is currently ignored in order to keep them |
| 36 | 36 | // ignored... not particularly clean (ignored users are stored in a string) |
| 37 | 37 | $ignored_user_list = array(); |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | ORDER BY userid ASC" |
| 43 | 43 | ); |
| 44 | 44 | while ($ignoring_user = db_fetch_object($ignoring_users)) { |
| 45 | - $ignored_user_list = $ignored_user_list + array_fill_keys(explode('|', trim($ignoring_user->ignorelist, '|')), 1); |
|
| 45 | + $ignored_user_list = $ignored_user_list + array_fill_keys(explode('|', trim($ignoring_user->ignorelist, '|')), 1); |
|
| 46 | 46 | } |
| 47 | 47 | $ignored_user_list = array_keys($ignored_user_list); |
| 48 | 48 | $boinc_accounts = db_query(" |
@@ -58,14 +58,14 @@ discard block |
||
| 58 | 58 | (SELECT DISTINCT senderid FROM {private_messages}) |
| 59 | 59 | ) AS usersToImport ORDER BY id ASC %s", implode(',', $ignored_user_list), $limit |
| 60 | 60 | ); |
| 61 | - } |
|
| 62 | - db_set_active('default'); |
|
| 61 | + } |
|
| 62 | + db_set_active('default'); |
|
| 63 | 63 | |
| 64 | - while ($boinc_account = db_fetch_object($boinc_accounts)) { |
|
| 64 | + while ($boinc_account = db_fetch_object($boinc_accounts)) { |
|
| 65 | 65 | // Grab the BOINC user object and create a Drupal user from it |
| 66 | 66 | if (boincuser_register_make_drupal_user($boinc_account->id)) { |
| 67 | - $count++; |
|
| 67 | + $count++; |
|
| 68 | + } |
|
| 68 | 69 | } |
| 69 | - } |
|
| 70 | 70 | |
| 71 | - echo $count; |
|
| 71 | + echo $count; |
|
@@ -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,258 +188,258 @@ 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 | set_time_limit(variable_get('boincimport_time_limit', 0)); |
| 246 | - } |
|
| 246 | + } |
|
| 247 | 247 | |
| 248 | - // Check for a lock on the import process |
|
| 249 | - if (variable_get('boincimport_process_locked', 0)) { |
|
| 248 | + // Check for a lock on the import process |
|
| 249 | + if (variable_get('boincimport_process_locked', 0)) { |
|
| 250 | 250 | drupal_set_message(t('The import process is locked. If you are sure that |
| 251 | 251 | it is no longer running, you may !unlock_it', |
| 252 | - array('!unlock_it' => l(t('release the lock'), |
|
| 252 | + array('!unlock_it' => l(t('release the lock'), |
|
| 253 | 253 | 'admin/boinc/import/unlock') |
| 254 | - )), 'warning'); |
|
| 254 | + )), 'warning'); |
|
| 255 | 255 | watchdog('boincimport', 'The import process is locked. If you are sure that |
| 256 | 256 | it is no longer running, you may !unlock_it', |
| 257 | - array('!unlock_it' => l(t('release the lock'), |
|
| 257 | + array('!unlock_it' => l(t('release the lock'), |
|
| 258 | 258 | 'admin/boinc/import/unlock') |
| 259 | - ), WATCHDOG_WARNING); |
|
| 260 | - } |
|
| 261 | - else { |
|
| 259 | + ), WATCHDOG_WARNING); |
|
| 260 | + } |
|
| 261 | + else { |
|
| 262 | 262 | $boincimport_functions = array( |
| 263 | - 'users' => t('Import users'), |
|
| 264 | - 'teams' => t('Import teams'), |
|
| 265 | - 'friends' => t('Import friendships'), |
|
| 266 | - 'preferences' => t('Import user preferences'), |
|
| 267 | - 'private messages' => t('Import private messages'), |
|
| 268 | - 'categories' => t('Import forum containers'), |
|
| 269 | - 'topics' => t('Import topics'), |
|
| 270 | - 'posts' => t('Import posts'), |
|
| 271 | - 'team forums' => t('Import team forums'), |
|
| 272 | - 'team topics' => t('Import team topics'), |
|
| 273 | - 'team posts' => t('Import team posts'), |
|
| 274 | - 'url' => t('Transform URLs'), |
|
| 263 | + 'users' => t('Import users'), |
|
| 264 | + 'teams' => t('Import teams'), |
|
| 265 | + 'friends' => t('Import friendships'), |
|
| 266 | + 'preferences' => t('Import user preferences'), |
|
| 267 | + 'private messages' => t('Import private messages'), |
|
| 268 | + 'categories' => t('Import forum containers'), |
|
| 269 | + 'topics' => t('Import topics'), |
|
| 270 | + 'posts' => t('Import posts'), |
|
| 271 | + 'team forums' => t('Import team forums'), |
|
| 272 | + 'team topics' => t('Import team topics'), |
|
| 273 | + 'team posts' => t('Import team posts'), |
|
| 274 | + 'url' => t('Transform URLs'), |
|
| 275 | 275 | ); |
| 276 | 276 | |
| 277 | 277 | $form['import'] = array( |
| 278 | - '#type' => 'select', |
|
| 279 | - '#title' => t('Next import to perform'), |
|
| 280 | - '#default_value' => $_SESSION['boincimport_stage_selected'], |
|
| 281 | - '#options' => $boincimport_functions, |
|
| 278 | + '#type' => 'select', |
|
| 279 | + '#title' => t('Next import to perform'), |
|
| 280 | + '#default_value' => $_SESSION['boincimport_stage_selected'], |
|
| 281 | + '#options' => $boincimport_functions, |
|
| 282 | 282 | ); |
| 283 | 283 | $form[] = array( |
| 284 | - '#type' => 'submit', |
|
| 285 | - '#value' => t('Import'), |
|
| 284 | + '#type' => 'submit', |
|
| 285 | + '#value' => t('Import'), |
|
| 286 | 286 | ); |
| 287 | - } |
|
| 288 | - return $form; |
|
| 287 | + } |
|
| 288 | + return $form; |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | function boincimport_process_form_submit($form, $form_state) { |
| 292 | 292 | |
| 293 | - // Lock the import process |
|
| 294 | - if (!variable_get('boincimport_process_locked', 0)) { |
|
| 293 | + // Lock the import process |
|
| 294 | + if (!variable_get('boincimport_process_locked', 0)) { |
|
| 295 | 295 | variable_set('boincimport_process_locked', 1); |
| 296 | - } |
|
| 297 | - else { |
|
| 296 | + } |
|
| 297 | + else { |
|
| 298 | 298 | watchdog('boincimport', 'The import process is locked, but another process |
| 299 | 299 | is trying to access it...', array(), WATCHDOG_WARNING); |
| 300 | - } |
|
| 300 | + } |
|
| 301 | 301 | |
| 302 | - switch ($form_state['values']['import']) { |
|
| 302 | + switch ($form_state['values']['import']) { |
|
| 303 | 303 | case 'users': |
| 304 | 304 | boincimport_users(); |
| 305 | - break; |
|
| 305 | + break; |
|
| 306 | 306 | |
| 307 | 307 | case 'teams': |
| 308 | 308 | boincimport_teams(); |
| 309 | - if (!variable_get('boincimport_import_team_successful', 0)) { |
|
| 309 | + if (!variable_get('boincimport_import_team_successful', 0)) { |
|
| 310 | 310 | $_SESSION['boincimport_stage_selected'] = 'teams'; |
| 311 | - } |
|
| 312 | - else { |
|
| 311 | + } |
|
| 312 | + else { |
|
| 313 | 313 | $_SESSION['boincimport_stage_selected'] = 'friends'; |
| 314 | - } |
|
| 315 | - break; |
|
| 314 | + } |
|
| 315 | + break; |
|
| 316 | 316 | |
| 317 | 317 | case 'friends': |
| 318 | 318 | boincimport_friends(); |
| 319 | - if (!variable_get('boincimport_import_friend_successful', 0)) { |
|
| 319 | + if (!variable_get('boincimport_import_friend_successful', 0)) { |
|
| 320 | 320 | $_SESSION['boincimport_stage_selected'] = 'friends'; |
| 321 | - } |
|
| 322 | - else { |
|
| 321 | + } |
|
| 322 | + else { |
|
| 323 | 323 | $_SESSION['boincimport_stage_selected'] = 'preferences'; |
| 324 | - } |
|
| 325 | - break; |
|
| 324 | + } |
|
| 325 | + break; |
|
| 326 | 326 | |
| 327 | 327 | case 'preferences': |
| 328 | 328 | boincimport_preferences(); |
| 329 | - if (!variable_get('boincimport_import_preferences_successful', 0)) { |
|
| 329 | + if (!variable_get('boincimport_import_preferences_successful', 0)) { |
|
| 330 | 330 | $_SESSION['boincimport_stage_selected'] = 'preferences'; |
| 331 | - } |
|
| 332 | - else { |
|
| 331 | + } |
|
| 332 | + else { |
|
| 333 | 333 | $_SESSION['boincimport_stage_selected'] = 'private messages'; |
| 334 | - } |
|
| 335 | - break; |
|
| 334 | + } |
|
| 335 | + break; |
|
| 336 | 336 | |
| 337 | 337 | case 'private messages': |
| 338 | 338 | boincimport_private_msgs(); |
| 339 | - if (!variable_get('boincimport_import_private_msg_successful', 0)) { |
|
| 339 | + if (!variable_get('boincimport_import_private_msg_successful', 0)) { |
|
| 340 | 340 | $_SESSION['boincimport_stage_selected'] = 'private messages'; |
| 341 | - } |
|
| 342 | - else { |
|
| 341 | + } |
|
| 342 | + else { |
|
| 343 | 343 | $_SESSION['boincimport_stage_selected'] = 'categories'; |
| 344 | - } |
|
| 345 | - break; |
|
| 344 | + } |
|
| 345 | + break; |
|
| 346 | 346 | |
| 347 | 347 | case 'categories': |
| 348 | 348 | boincimport_forum_categories(); |
| 349 | - if (!variable_get('boincimport_import_category_successful', 0)) { |
|
| 349 | + if (!variable_get('boincimport_import_category_successful', 0)) { |
|
| 350 | 350 | $_SESSION['boincimport_stage_selected'] = 'categories'; |
| 351 | - } |
|
| 352 | - else { |
|
| 351 | + } |
|
| 352 | + else { |
|
| 353 | 353 | $_SESSION['boincimport_stage_selected'] = 'topics'; |
| 354 | - } |
|
| 355 | - break; |
|
| 354 | + } |
|
| 355 | + break; |
|
| 356 | 356 | |
| 357 | 357 | case 'topics': |
| 358 | 358 | boincimport_forum_topics(); |
| 359 | - if (!variable_get('boincimport_import_topic_successful', 0)) { |
|
| 359 | + if (!variable_get('boincimport_import_topic_successful', 0)) { |
|
| 360 | 360 | $_SESSION['boincimport_stage_selected'] = 'topics'; |
| 361 | - } |
|
| 362 | - else { |
|
| 361 | + } |
|
| 362 | + else { |
|
| 363 | 363 | $_SESSION['boincimport_stage_selected'] = 'posts'; |
| 364 | - } |
|
| 365 | - break; |
|
| 364 | + } |
|
| 365 | + break; |
|
| 366 | 366 | |
| 367 | 367 | case 'posts': |
| 368 | 368 | boincimport_forum_posts(); |
| 369 | - if (!variable_get('boincimport_import_post_successful', 0)) { |
|
| 369 | + if (!variable_get('boincimport_import_post_successful', 0)) { |
|
| 370 | 370 | $_SESSION['boincimport_stage_selected'] = 'posts'; |
| 371 | - } |
|
| 372 | - else { |
|
| 371 | + } |
|
| 372 | + else { |
|
| 373 | 373 | $_SESSION['boincimport_stage_selected'] = 'url'; |
| 374 | - } |
|
| 375 | - break; |
|
| 374 | + } |
|
| 375 | + break; |
|
| 376 | 376 | |
| 377 | 377 | case 'team forums': |
| 378 | 378 | boincimport_team_forums(); |
| 379 | - if (!variable_get('boincimport_team_forum_successful', 0)) { |
|
| 379 | + if (!variable_get('boincimport_team_forum_successful', 0)) { |
|
| 380 | 380 | $_SESSION['boincimport_stage_selected'] = 'team forums'; |
| 381 | - } |
|
| 382 | - else { |
|
| 381 | + } |
|
| 382 | + else { |
|
| 383 | 383 | $_SESSION['boincimport_stage_selected'] = 'team topics'; |
| 384 | - } |
|
| 385 | - break; |
|
| 384 | + } |
|
| 385 | + break; |
|
| 386 | 386 | |
| 387 | 387 | case 'team topics': |
| 388 | 388 | boincimport_team_forum_topics(); |
| 389 | - if (!variable_get('boincimport_team_topic_successful', 0)) { |
|
| 389 | + if (!variable_get('boincimport_team_topic_successful', 0)) { |
|
| 390 | 390 | $_SESSION['boincimport_stage_selected'] = 'team topics'; |
| 391 | - } |
|
| 392 | - else { |
|
| 391 | + } |
|
| 392 | + else { |
|
| 393 | 393 | $_SESSION['boincimport_stage_selected'] = 'team posts'; |
| 394 | - } |
|
| 395 | - break; |
|
| 394 | + } |
|
| 395 | + break; |
|
| 396 | 396 | |
| 397 | 397 | case 'team posts': |
| 398 | 398 | boincimport_team_forum_posts(); |
| 399 | - if (!variable_get('boincimport_team_post_successful', 0)) { |
|
| 399 | + if (!variable_get('boincimport_team_post_successful', 0)) { |
|
| 400 | 400 | $_SESSION['boincimport_stage_selected'] = 'team posts'; |
| 401 | - } |
|
| 402 | - else { |
|
| 401 | + } |
|
| 402 | + else { |
|
| 403 | 403 | $_SESSION['boincimport_stage_selected'] = 'url'; |
| 404 | - } |
|
| 405 | - break; |
|
| 404 | + } |
|
| 405 | + break; |
|
| 406 | 406 | |
| 407 | 407 | case 'url': |
| 408 | 408 | boincimport_replace_urls(); |
| 409 | - if (!variable_get('boincimport_replace_url_successful', 0)) { |
|
| 409 | + if (!variable_get('boincimport_replace_url_successful', 0)) { |
|
| 410 | 410 | $_SESSION['boincimport_stage_selected'] = 'url'; |
| 411 | - } |
|
| 412 | - else { |
|
| 411 | + } |
|
| 412 | + else { |
|
| 413 | 413 | drupal_set_message('Congratulations. Import Finished'); |
| 414 | 414 | drupal_set_message('Please visit the '. l('Post migration configuration', 'admin/boinc/import/post_configuration') .' page'); |
| 415 | 415 | watchdog('boincimport', 'Import process is complete', array(), WATCHDOG_INFO); |
| 416 | 416 | unset($_SESSION['boincimport_stage_selected']); |
| 417 | - } |
|
| 418 | - break; |
|
| 417 | + } |
|
| 418 | + break; |
|
| 419 | 419 | default: |
| 420 | 420 | $_SESSION['boincimport_stage_selected'] = 'users'; |
| 421 | - break; |
|
| 422 | - } |
|
| 421 | + break; |
|
| 422 | + } |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | function boincimport_complete($section) { |
| 426 | - switch ($section) { |
|
| 427 | - case 'users': |
|
| 426 | + switch ($section) { |
|
| 427 | + case 'users': |
|
| 428 | 428 | // Set the user import successful flag in the variable table |
| 429 | 429 | variable_set('boincimport_import_user_successful', '1'); |
| 430 | 430 | $_SESSION['boincimport_stage_selected'] = 'teams'; |
| 431 | 431 | break; |
| 432 | - case 'teams': |
|
| 432 | + case 'teams': |
|
| 433 | 433 | |
| 434 | 434 | break; |
| 435 | 435 | |
| 436 | - default: |
|
| 436 | + default: |
|
| 437 | 437 | } |
| 438 | 438 | |
| 439 | - // Release the lock on the import process |
|
| 440 | - variable_del('boincimport_process_locked'); |
|
| 439 | + // Release the lock on the import process |
|
| 440 | + variable_del('boincimport_process_locked'); |
|
| 441 | 441 | |
| 442 | - drupal_goto('admin/boinc/import/process'); |
|
| 442 | + drupal_goto('admin/boinc/import/process'); |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | |
@@ -451,26 +451,26 @@ discard block |
||
| 451 | 451 | * Import users (at least those required for further data import) |
| 452 | 452 | */ |
| 453 | 453 | function boincimport_users() { |
| 454 | - // Check whether the user table has been successfully imported already |
|
| 455 | - if (variable_get('boincimport_import_user_successful', 0)) { |
|
| 454 | + // Check whether the user table has been successfully imported already |
|
| 455 | + if (variable_get('boincimport_import_user_successful', 0)) { |
|
| 456 | 456 | drupal_set_message(t('Note: user import has already run successfully')); |
| 457 | 457 | watchdog( |
| 458 | - 'boincimport', 'Note: user import has already run successfully', |
|
| 459 | - array(), WATCHDOG_INFO |
|
| 458 | + 'boincimport', 'Note: user import has already run successfully', |
|
| 459 | + array(), WATCHDOG_INFO |
|
| 460 | 460 | ); |
| 461 | - } |
|
| 461 | + } |
|
| 462 | 462 | |
| 463 | - if (!variable_get('boincimport_import_user_started', 0)) { |
|
| 463 | + if (!variable_get('boincimport_import_user_started', 0)) { |
|
| 464 | 464 | // Could prepare database tables, if new fields are necessary, etc. |
| 465 | 465 | variable_set('boincimport_import_user_started', 1); |
| 466 | - } |
|
| 466 | + } |
|
| 467 | 467 | |
| 468 | - $pre = variable_get('boincimport_table_prefix', ''); |
|
| 469 | - $import_lurkers = variable_get('boincimport_import_lurkers', 1); |
|
| 468 | + $pre = variable_get('boincimport_table_prefix', ''); |
|
| 469 | + $import_lurkers = variable_get('boincimport_import_lurkers', 1); |
|
| 470 | 470 | |
| 471 | - // Determine which users need to be processed |
|
| 472 | - db_set_active('boinc_rw'); |
|
| 473 | - if ($import_lurkers) { |
|
| 471 | + // Determine which users need to be processed |
|
| 472 | + db_set_active('boinc_rw'); |
|
| 473 | + if ($import_lurkers) { |
|
| 474 | 474 | // Import all users, even those who have no community participation; other |
| 475 | 475 | // users will be imported when they first try to log into the drupal site |
| 476 | 476 | $boinc_accounts = db_query(' |
@@ -478,8 +478,8 @@ discard block |
||
| 478 | 478 | ORDER BY id ASC' |
| 479 | 479 | ); |
| 480 | 480 | $user_count = mysql_num_rows($boinc_accounts); |
| 481 | - } |
|
| 482 | - else { |
|
| 481 | + } |
|
| 482 | + else { |
|
| 483 | 483 | // Need to import any user who is currently ignored in order to keep them |
| 484 | 484 | // ignored... not particularly clean (ignored users are stored in a string) |
| 485 | 485 | $ignored_user_list = array(0); |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | ORDER BY userid ASC" |
| 491 | 491 | ); |
| 492 | 492 | while ($ignoring_user = db_fetch_object($ignoring_users)) { |
| 493 | - $ignored_user_list = $ignored_user_list + array_fill_keys(explode('|', trim($ignoring_user->ignorelist, '|')), 1); |
|
| 493 | + $ignored_user_list = $ignored_user_list + array_fill_keys(explode('|', trim($ignoring_user->ignorelist, '|')), 1); |
|
| 494 | 494 | } |
| 495 | 495 | $ignored_user_list = array_keys($ignored_user_list); |
| 496 | 496 | // Get IDs for all users who will need to be imported now |
@@ -506,86 +506,86 @@ discard block |
||
| 506 | 506 | (SELECT DISTINCT userid FROM {private_messages}) UNION |
| 507 | 507 | (SELECT DISTINCT senderid FROM {private_messages}) |
| 508 | 508 | ) AS usersToImport", |
| 509 | - implode(',', $ignored_user_list) |
|
| 509 | + implode(',', $ignored_user_list) |
|
| 510 | 510 | ); |
| 511 | 511 | $user_count = mysql_num_rows($boinc_accounts); |
| 512 | - } |
|
| 513 | - db_set_active('default'); |
|
| 512 | + } |
|
| 513 | + db_set_active('default'); |
|
| 514 | 514 | |
| 515 | - if (!$user_count) { |
|
| 515 | + if (!$user_count) { |
|
| 516 | 516 | drupal_set_message( |
| 517 | - t('There were no users found: Aborting script'), 'error' |
|
| 517 | + t('There were no users found: Aborting script'), 'error' |
|
| 518 | 518 | ); |
| 519 | 519 | watchdog('boincimport', |
| 520 | - 'There were no users found: Aborting script', array(), WATCHDOG_INFO |
|
| 520 | + 'There were no users found: Aborting script', array(), WATCHDOG_INFO |
|
| 521 | 521 | ); |
| 522 | 522 | // Release the lock on the import process |
| 523 | 523 | variable_del('boincimport_process_locked'); |
| 524 | 524 | return t('There were no users found: Aborting script.'); |
| 525 | - } |
|
| 525 | + } |
|
| 526 | 526 | |
| 527 | - watchdog('boincimport', |
|
| 527 | + watchdog('boincimport', |
|
| 528 | 528 | 'Found %user_count users: Beginning import', |
| 529 | 529 | array('%user_count' => $user_count), WATCHDOG_INFO |
| 530 | - ); |
|
| 531 | - |
|
| 532 | - // User import relies on Drupal and BOINC APIs to manage data being read |
|
| 533 | - // from one database and saved to the other. This approach keeps things |
|
| 534 | - // clean and simple, but since a sizable user base will wreak havoc on system |
|
| 535 | - // resources, the job is broken into batches here and each batch is processed |
|
| 536 | - // by a separate process. |
|
| 537 | - |
|
| 538 | - //$batch_size = variable_get('boincimport_user_batch_size', 50); |
|
| 539 | - //$batch_count = $user_count - ($user_count % $batch_size) + $batch_size; |
|
| 540 | - $operations = array(); |
|
| 541 | - $existing_users = array(); |
|
| 542 | - $duplicates = array(); |
|
| 543 | - |
|
| 544 | - // Get the list of users already in Drupal to be sure we're not importing |
|
| 545 | - // any twice |
|
| 546 | - $result = db_query(' |
|
| 530 | + ); |
|
| 531 | + |
|
| 532 | + // User import relies on Drupal and BOINC APIs to manage data being read |
|
| 533 | + // from one database and saved to the other. This approach keeps things |
|
| 534 | + // clean and simple, but since a sizable user base will wreak havoc on system |
|
| 535 | + // resources, the job is broken into batches here and each batch is processed |
|
| 536 | + // by a separate process. |
|
| 537 | + |
|
| 538 | + //$batch_size = variable_get('boincimport_user_batch_size', 50); |
|
| 539 | + //$batch_count = $user_count - ($user_count % $batch_size) + $batch_size; |
|
| 540 | + $operations = array(); |
|
| 541 | + $existing_users = array(); |
|
| 542 | + $duplicates = array(); |
|
| 543 | + |
|
| 544 | + // Get the list of users already in Drupal to be sure we're not importing |
|
| 545 | + // any twice |
|
| 546 | + $result = db_query(' |
|
| 547 | 547 | SELECT uid, boinc_id FROM {boincuser}' |
| 548 | - ); |
|
| 549 | - while ($row = db_fetch_object($result)) { |
|
| 548 | + ); |
|
| 549 | + while ($row = db_fetch_object($result)) { |
|
| 550 | 550 | $existing_users[$row->boinc_id] = $row->uid; |
| 551 | - } |
|
| 551 | + } |
|
| 552 | 552 | |
| 553 | - // Create batches to process |
|
| 554 | - while ($boinc_account = db_fetch_object($boinc_accounts)) { |
|
| 555 | - if (isset($existing_users[$boinc_account->id])) { |
|
| 556 | - // This user has already been imported |
|
| 557 | - $duplicates[] = $boinc_account->id; |
|
| 553 | + // Create batches to process |
|
| 554 | + while ($boinc_account = db_fetch_object($boinc_accounts)) { |
|
| 555 | + if (isset($existing_users[$boinc_account->id])) { |
|
| 556 | + // This user has already been imported |
|
| 557 | + $duplicates[] = $boinc_account->id; |
|
| 558 | 558 | } |
| 559 | 559 | else { |
| 560 | - $operations[] = array( |
|
| 560 | + $operations[] = array( |
|
| 561 | 561 | 'boincimport_users_op', array( |
| 562 | - $boinc_account->id |
|
| 562 | + $boinc_account->id |
|
| 563 | 563 | ) |
| 564 | - ); |
|
| 564 | + ); |
|
| 565 | + } |
|
| 565 | 566 | } |
| 566 | - } |
|
| 567 | 567 | |
| 568 | - if ($duplicates) { |
|
| 568 | + if ($duplicates) { |
|
| 569 | 569 | drupal_set_message(t( |
| 570 | - 'Skipped @count accounts that were already imported', |
|
| 571 | - array('@count' => count($duplicates)) |
|
| 570 | + 'Skipped @count accounts that were already imported', |
|
| 571 | + array('@count' => count($duplicates)) |
|
| 572 | 572 | )); |
| 573 | 573 | watchdog('boincimport', |
| 574 | - 'Skipped @count accounts that were already imported', |
|
| 575 | - array('@count' => count($duplicates)), WATCHDOG_INFO |
|
| 574 | + 'Skipped @count accounts that were already imported', |
|
| 575 | + array('@count' => count($duplicates)), WATCHDOG_INFO |
|
| 576 | 576 | ); |
| 577 | - } |
|
| 577 | + } |
|
| 578 | 578 | |
| 579 | - $batch = array( |
|
| 579 | + $batch = array( |
|
| 580 | 580 | 'operations' => $operations, |
| 581 | 581 | 'finished' => 'boincimport_users_finished', |
| 582 | 582 | 'title' => t('Importing users'), |
| 583 | 583 | 'init_message' => t('Beginning user import...'), |
| 584 | 584 | 'progress_message' => t('Processed @current out of @total users.'), |
| 585 | 585 | 'error_message' => t('User import has encountered an error.'), |
| 586 | - ); |
|
| 586 | + ); |
|
| 587 | 587 | |
| 588 | - batch_set($batch); |
|
| 588 | + batch_set($batch); |
|
| 589 | 589 | } |
| 590 | 590 | |
| 591 | 591 | /** |
@@ -593,81 +593,81 @@ discard block |
||
| 593 | 593 | */ |
| 594 | 594 | function boincimport_users_op($boinc_id, &$context) { |
| 595 | 595 | |
| 596 | - // Use the $context['sandbox'] to store information needed to track progress |
|
| 597 | - // between successive calls. |
|
| 598 | - if (!isset($context['sandbox']['progress'])) { |
|
| 596 | + // Use the $context['sandbox'] to store information needed to track progress |
|
| 597 | + // between successive calls. |
|
| 598 | + if (!isset($context['sandbox']['progress'])) { |
|
| 599 | 599 | $context['sandbox']['progress'] = 0; |
| 600 | 600 | $context['sandbox']['current_user'] = 0; |
| 601 | 601 | $context['sandbox']['max'] = 1; |
| 602 | - } |
|
| 602 | + } |
|
| 603 | 603 | |
| 604 | - // Note about batch size: When a batch is processed, the batch update engine |
|
| 605 | - // determines whether it should continue processing in the same request or |
|
| 606 | - // provide progress feedback to the user and wait for the next request. |
|
| 604 | + // Note about batch size: When a batch is processed, the batch update engine |
|
| 605 | + // determines whether it should continue processing in the same request or |
|
| 606 | + // provide progress feedback to the user and wait for the next request. |
|
| 607 | 607 | |
| 608 | - // Grab the BOINC user object and create a Drupal user from it |
|
| 609 | - $account = boincuser_register_make_drupal_user($boinc_id); |
|
| 610 | - $message = ''; |
|
| 611 | - if ($account) { |
|
| 608 | + // Grab the BOINC user object and create a Drupal user from it |
|
| 609 | + $account = boincuser_register_make_drupal_user($boinc_id); |
|
| 610 | + $message = ''; |
|
| 611 | + if ($account) { |
|
| 612 | 612 | // Store some result for post-processing in the finished callback. |
| 613 | 613 | $context['results']['success'][] = $boinc_id; |
| 614 | 614 | $message = "Successfully imported user {$boinc_id}"; |
| 615 | - } |
|
| 616 | - else { |
|
| 615 | + } |
|
| 616 | + else { |
|
| 617 | 617 | $context['results']['failure'][] = $boinc_id; |
| 618 | 618 | $message = "Failed to import user {$boinc_id}!"; |
| 619 | 619 | watchdog('boincimport', |
| 620 | - 'Failed to import user @id!', |
|
| 621 | - array('@id' => $boinc_id), WATCHDOG_WARNING |
|
| 620 | + 'Failed to import user @id!', |
|
| 621 | + array('@id' => $boinc_id), WATCHDOG_WARNING |
|
| 622 | 622 | ); |
| 623 | - } |
|
| 623 | + } |
|
| 624 | 624 | |
| 625 | - // Update our progress information. |
|
| 626 | - $context['sandbox']['progress']++; |
|
| 627 | - $context['sandbox']['current_user'] = $boinc_id; |
|
| 628 | - $context['message'] = $message; |
|
| 625 | + // Update our progress information. |
|
| 626 | + $context['sandbox']['progress']++; |
|
| 627 | + $context['sandbox']['current_user'] = $boinc_id; |
|
| 628 | + $context['message'] = $message; |
|
| 629 | 629 | |
| 630 | - // Update the progress for the batch engine |
|
| 631 | - if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 630 | + // Update the progress for the batch engine |
|
| 631 | + if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 632 | 632 | $context['finished'] = 1; |
| 633 | - } |
|
| 634 | - else { |
|
| 633 | + } |
|
| 634 | + else { |
|
| 635 | 635 | $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
| 636 | - } |
|
| 636 | + } |
|
| 637 | 637 | } |
| 638 | 638 | |
| 639 | 639 | /** |
| 640 | 640 | * Batch 'finished' callback |
| 641 | 641 | */ |
| 642 | 642 | function boincimport_users_finished($success, $results, $operations) { |
| 643 | - if ($success) { |
|
| 643 | + if ($success) { |
|
| 644 | 644 | // Let's count our successes |
| 645 | 645 | $total_imported = count($results['success']); |
| 646 | 646 | $total_failures = count($results['failure']); |
| 647 | 647 | $message = t( |
| 648 | - 'Successfully imported @count users (@fail_count failures)', |
|
| 649 | - array('@count' => $total_imported, '@fail_count' => $total_failures) |
|
| 648 | + 'Successfully imported @count users (@fail_count failures)', |
|
| 649 | + array('@count' => $total_imported, '@fail_count' => $total_failures) |
|
| 650 | 650 | ); |
| 651 | 651 | watchdog('boincimport', |
| 652 | - 'Successfully imported @count users (@fail_count failures).', |
|
| 653 | - array('@count' => $total_imported, '@fail_count' => $total_failures), |
|
| 654 | - WATCHDOG_INFO |
|
| 652 | + 'Successfully imported @count users (@fail_count failures).', |
|
| 653 | + array('@count' => $total_imported, '@fail_count' => $total_failures), |
|
| 654 | + WATCHDOG_INFO |
|
| 655 | 655 | ); |
| 656 | 656 | // Set the user import successful flag in the variable table |
| 657 | 657 | variable_set('boincimport_import_user_successful', '1'); |
| 658 | 658 | $_SESSION['boincimport_stage_selected'] = 'teams'; |
| 659 | - } |
|
| 660 | - else { |
|
| 659 | + } |
|
| 660 | + else { |
|
| 661 | 661 | // An error occurred. |
| 662 | 662 | // $operations contains the operations that remained unprocessed. |
| 663 | 663 | $error_operation = reset($operations); |
| 664 | 664 | $message = 'An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE); |
| 665 | - } |
|
| 666 | - drupal_set_message($message); |
|
| 665 | + } |
|
| 666 | + drupal_set_message($message); |
|
| 667 | 667 | |
| 668 | - // Release the lock on the import process |
|
| 669 | - variable_del('boincimport_process_locked'); |
|
| 670 | - drupal_goto('admin/boinc/import/process'); |
|
| 668 | + // Release the lock on the import process |
|
| 669 | + variable_del('boincimport_process_locked'); |
|
| 670 | + drupal_goto('admin/boinc/import/process'); |
|
| 671 | 671 | } |
| 672 | 672 | |
| 673 | 673 | |
@@ -680,23 +680,23 @@ discard block |
||
| 680 | 680 | */ |
| 681 | 681 | function boincimport_teams() { |
| 682 | 682 | |
| 683 | - // Check whether the team table has been successfully imported already |
|
| 684 | - if (variable_get('boincimport_import_team_successful', 0)) { |
|
| 683 | + // Check whether the team table has been successfully imported already |
|
| 684 | + if (variable_get('boincimport_import_team_successful', 0)) { |
|
| 685 | 685 | drupal_set_message(t('Note: team import has already run successfully')); |
| 686 | 686 | watchdog( |
| 687 | - 'boincimport', 'Note: team import has already run successfully', |
|
| 688 | - array(), WATCHDOG_INFO |
|
| 687 | + 'boincimport', 'Note: team import has already run successfully', |
|
| 688 | + array(), WATCHDOG_INFO |
|
| 689 | 689 | ); |
| 690 | - } |
|
| 690 | + } |
|
| 691 | 691 | |
| 692 | - if (!variable_get('boincimport_import_team_started', 0)) { |
|
| 692 | + if (!variable_get('boincimport_import_team_started', 0)) { |
|
| 693 | 693 | // Could prepare database tables, if new fields are necessary, etc. |
| 694 | 694 | variable_set('boincimport_import_team_started', 1); |
| 695 | - } |
|
| 695 | + } |
|
| 696 | 696 | |
| 697 | - // Initialize the map of BOINC team types to taxonomy IDs, if needed |
|
| 698 | - $team_type_map = variable_get('boincimport_team_types', array()); |
|
| 699 | - if (!$team_type_map) { |
|
| 697 | + // Initialize the map of BOINC team types to taxonomy IDs, if needed |
|
| 698 | + $team_type_map = variable_get('boincimport_team_types', array()); |
|
| 699 | + if (!$team_type_map) { |
|
| 700 | 700 | // Import team types from BOINC to a Drupal vocabulary |
| 701 | 701 | require_boinc('team_types'); |
| 702 | 702 | global $team_types; |
@@ -704,112 +704,112 @@ discard block |
||
| 704 | 704 | // Create vocabulary if it isn't set |
| 705 | 705 | $team_vid = db_result(db_query('SELECT vid FROM {vocabulary} WHERE name="%s"', 'Teams')); |
| 706 | 706 | if (!$team_vid) { |
| 707 | - $team_vocab = array( |
|
| 707 | + $team_vocab = array( |
|
| 708 | 708 | 'name' => t('Teams'), |
| 709 | 709 | 'description' => t('Types of BOINC teams'), |
| 710 | - ); |
|
| 711 | - taxonomy_save_vocabulary($team_vocab); |
|
| 712 | - $team_vid = db_result(db_query('SELECT vid FROM {vocabulary} WHERE name="%s"', 'Teams')); |
|
| 710 | + ); |
|
| 711 | + taxonomy_save_vocabulary($team_vocab); |
|
| 712 | + $team_vid = db_result(db_query('SELECT vid FROM {vocabulary} WHERE name="%s"', 'Teams')); |
|
| 713 | 713 | } |
| 714 | 714 | |
| 715 | 715 | foreach ($team_types as $boinc_type_id => $name) { |
| 716 | - // Check for an existing term in the vocabulary |
|
| 717 | - $team_type_id = db_result(db_query("SELECT tid FROM {term_data} WHERE vid = '{$team_vid}' AND LOWER(name) = LOWER('%s')", trim($name))); |
|
| 718 | - if ($team_type_id) { |
|
| 716 | + // Check for an existing term in the vocabulary |
|
| 717 | + $team_type_id = db_result(db_query("SELECT tid FROM {term_data} WHERE vid = '{$team_vid}' AND LOWER(name) = LOWER('%s')", trim($name))); |
|
| 718 | + if ($team_type_id) { |
|
| 719 | 719 | $team_type = array( |
| 720 | - 'tid' => $team_type_id |
|
| 720 | + 'tid' => $team_type_id |
|
| 721 | 721 | ); |
| 722 | - } |
|
| 723 | - else { |
|
| 722 | + } |
|
| 723 | + else { |
|
| 724 | 724 | if (!$name) continue; |
| 725 | 725 | $team_type = array( |
| 726 | - 'name' => strip_tags($name), |
|
| 727 | - 'vid' => $team_vid, |
|
| 728 | - 'description' => '', |
|
| 729 | - 'parent' => 0 |
|
| 726 | + 'name' => strip_tags($name), |
|
| 727 | + 'vid' => $team_vid, |
|
| 728 | + 'description' => '', |
|
| 729 | + 'parent' => 0 |
|
| 730 | 730 | ); |
| 731 | 731 | taxonomy_save_term($team_type); |
| 732 | - } |
|
| 733 | - // Note the taxonomy ID for mapping forums to categories |
|
| 734 | - $team_type_map[$boinc_type_id] = $team_type['tid']; |
|
| 732 | + } |
|
| 733 | + // Note the taxonomy ID for mapping forums to categories |
|
| 734 | + $team_type_map[$boinc_type_id] = $team_type['tid']; |
|
| 735 | 735 | } |
| 736 | 736 | variable_set('boincimport_team_types', $team_type_map); |
| 737 | - } |
|
| 737 | + } |
|
| 738 | 738 | |
| 739 | - $pre = variable_get('boincimport_table_prefix', ''); |
|
| 739 | + $pre = variable_get('boincimport_table_prefix', ''); |
|
| 740 | 740 | |
| 741 | - // Get the list of teams to import |
|
| 742 | - db_set_active('boinc_rw'); |
|
| 743 | - $boinc_teams = db_query(' |
|
| 741 | + // Get the list of teams to import |
|
| 742 | + db_set_active('boinc_rw'); |
|
| 743 | + $boinc_teams = db_query(' |
|
| 744 | 744 | SELECT id, name, description, userid, create_time |
| 745 | 745 | FROM %steam', |
| 746 | 746 | $pre |
| 747 | - ); |
|
| 748 | - $team_count = mysql_num_rows($boinc_teams); |
|
| 749 | - db_set_active('default'); |
|
| 747 | + ); |
|
| 748 | + $team_count = mysql_num_rows($boinc_teams); |
|
| 749 | + db_set_active('default'); |
|
| 750 | 750 | |
| 751 | - if (!$team_count) { |
|
| 751 | + if (!$team_count) { |
|
| 752 | 752 | drupal_set_message( |
| 753 | - t('There were no teams found: Aborting script'), 'error' |
|
| 753 | + t('There were no teams found: Aborting script'), 'error' |
|
| 754 | 754 | ); |
| 755 | 755 | watchdog('boincimport', |
| 756 | - 'There were no teams found: Aborting script', array(), WATCHDOG_INFO |
|
| 756 | + 'There were no teams found: Aborting script', array(), WATCHDOG_INFO |
|
| 757 | 757 | ); |
| 758 | 758 | // Release the lock on the import process |
| 759 | 759 | variable_del('boincimport_process_locked'); |
| 760 | 760 | return t('There were no teams found: Aborting script.'); |
| 761 | - } |
|
| 761 | + } |
|
| 762 | 762 | |
| 763 | - watchdog('boincimport', |
|
| 763 | + watchdog('boincimport', |
|
| 764 | 764 | 'Found %team_count teams: Beginning Import', |
| 765 | 765 | array('%team_count' => $team_count), WATCHDOG_INFO |
| 766 | - ); |
|
| 766 | + ); |
|
| 767 | 767 | |
| 768 | - $operations = array(); |
|
| 769 | - $existing_teams = array(); |
|
| 770 | - $duplicates = array(); |
|
| 768 | + $operations = array(); |
|
| 769 | + $existing_teams = array(); |
|
| 770 | + $duplicates = array(); |
|
| 771 | 771 | |
| 772 | - // Get the list of teams already in Drupal to be sure we're not importing |
|
| 773 | - // any twice |
|
| 774 | - $result = db_query(' |
|
| 772 | + // Get the list of teams already in Drupal to be sure we're not importing |
|
| 773 | + // any twice |
|
| 774 | + $result = db_query(' |
|
| 775 | 775 | SELECT nid, team_id FROM {boincteam}' |
| 776 | - ); |
|
| 777 | - while ($row = db_fetch_object($result)) { |
|
| 776 | + ); |
|
| 777 | + while ($row = db_fetch_object($result)) { |
|
| 778 | 778 | $existing_teams[$row->team_id] = $row->nid; |
| 779 | - } |
|
| 779 | + } |
|
| 780 | 780 | |
| 781 | - // Create batches to process |
|
| 782 | - while ($boinc_team = db_fetch_object($boinc_teams)) { |
|
| 783 | - if (isset($existing_teams[$boinc_team->id])) { |
|
| 784 | - // This team has already been imported |
|
| 785 | - $duplicates[] = $boinc_team->id; |
|
| 781 | + // Create batches to process |
|
| 782 | + while ($boinc_team = db_fetch_object($boinc_teams)) { |
|
| 783 | + if (isset($existing_teams[$boinc_team->id])) { |
|
| 784 | + // This team has already been imported |
|
| 785 | + $duplicates[] = $boinc_team->id; |
|
| 786 | 786 | } |
| 787 | 787 | else { |
| 788 | - $operations[] = array( |
|
| 788 | + $operations[] = array( |
|
| 789 | 789 | 'boincimport_teams_op', array( |
| 790 | - $boinc_team |
|
| 790 | + $boinc_team |
|
| 791 | 791 | ) |
| 792 | - ); |
|
| 792 | + ); |
|
| 793 | + } |
|
| 793 | 794 | } |
| 794 | - } |
|
| 795 | 795 | |
| 796 | - if ($duplicates) { |
|
| 796 | + if ($duplicates) { |
|
| 797 | 797 | drupal_set_message(t( |
| 798 | - 'Skipped @count teams that were already imported', |
|
| 799 | - array('@count' => count($duplicates)) |
|
| 798 | + 'Skipped @count teams that were already imported', |
|
| 799 | + array('@count' => count($duplicates)) |
|
| 800 | 800 | )); |
| 801 | - } |
|
| 801 | + } |
|
| 802 | 802 | |
| 803 | - $batch = array( |
|
| 803 | + $batch = array( |
|
| 804 | 804 | 'operations' => $operations, |
| 805 | 805 | 'finished' => 'boincimport_teams_finished', |
| 806 | 806 | 'title' => t('Importing teams'), |
| 807 | 807 | 'init_message' => t('Beginning team import...'), |
| 808 | 808 | 'progress_message' => t('Processed @current out of @total teams.'), |
| 809 | 809 | 'error_message' => t('Team import has encountered an error.'), |
| 810 | - ); |
|
| 810 | + ); |
|
| 811 | 811 | |
| 812 | - batch_set($batch); |
|
| 812 | + batch_set($batch); |
|
| 813 | 813 | } |
| 814 | 814 | |
| 815 | 815 | /** |
@@ -818,67 +818,67 @@ discard block |
||
| 818 | 818 | */ |
| 819 | 819 | function boincimport_teams_op($boincteam, &$context) { |
| 820 | 820 | |
| 821 | - $success = boincteam_import($boincteam); |
|
| 821 | + $success = boincteam_import($boincteam); |
|
| 822 | 822 | |
| 823 | - $message = ''; |
|
| 824 | - if ($success) { |
|
| 823 | + $message = ''; |
|
| 824 | + if ($success) { |
|
| 825 | 825 | // Store some result for post-processing in the finished callback. |
| 826 | 826 | $context['results']['success'][] = $boincteam->id; |
| 827 | 827 | $message = "Successfully imported team {$boincteam->id}"; |
| 828 | - } |
|
| 829 | - else { |
|
| 828 | + } |
|
| 829 | + else { |
|
| 830 | 830 | $context['results']['failure'][] = $boincteam->id; |
| 831 | 831 | $message = "Failed to import team {$boincteam->id}!"; |
| 832 | 832 | watchdog('boincimport', |
| 833 | - 'Failed to import team @id!', |
|
| 834 | - array('@id' => $boincteam->id), WATCHDOG_WARNING |
|
| 833 | + 'Failed to import team @id!', |
|
| 834 | + array('@id' => $boincteam->id), WATCHDOG_WARNING |
|
| 835 | 835 | ); |
| 836 | - } |
|
| 836 | + } |
|
| 837 | 837 | |
| 838 | - // Update our progress information. |
|
| 839 | - $context['sandbox']['progress']++; |
|
| 840 | - $context['sandbox']['current_team'] = $boincteam->id; |
|
| 841 | - $context['message'] = $message; |
|
| 838 | + // Update our progress information. |
|
| 839 | + $context['sandbox']['progress']++; |
|
| 840 | + $context['sandbox']['current_team'] = $boincteam->id; |
|
| 841 | + $context['message'] = $message; |
|
| 842 | 842 | |
| 843 | - // Update the progress for the batch engine |
|
| 844 | - if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 843 | + // Update the progress for the batch engine |
|
| 844 | + if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 845 | 845 | $context['finished'] = 1; |
| 846 | - } |
|
| 847 | - else { |
|
| 846 | + } |
|
| 847 | + else { |
|
| 848 | 848 | $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
| 849 | - } |
|
| 849 | + } |
|
| 850 | 850 | } |
| 851 | 851 | |
| 852 | 852 | /** |
| 853 | 853 | * Batch 'finished' callback |
| 854 | 854 | */ |
| 855 | 855 | function boincimport_teams_finished($success, $results, $operations) { |
| 856 | - if ($success) { |
|
| 856 | + if ($success) { |
|
| 857 | 857 | // Let's count our successes |
| 858 | 858 | $total_imported = count($results['success']); |
| 859 | 859 | $message = t( |
| 860 | - 'Successfully imported @count teams', |
|
| 861 | - array('@count' => $total_imported) |
|
| 860 | + 'Successfully imported @count teams', |
|
| 861 | + array('@count' => $total_imported) |
|
| 862 | 862 | ); |
| 863 | 863 | watchdog('boincimport', |
| 864 | - 'Successfully imported @count teams.', |
|
| 865 | - array('@count' => $total_imported), WATCHDOG_INFO |
|
| 864 | + 'Successfully imported @count teams.', |
|
| 865 | + array('@count' => $total_imported), WATCHDOG_INFO |
|
| 866 | 866 | ); |
| 867 | 867 | // Set the team import successful flag in the variable table |
| 868 | 868 | variable_set('boincimport_import_team_successful', '1'); |
| 869 | 869 | $_SESSION['boincimport_stage_selected'] = 'friends'; |
| 870 | - } |
|
| 871 | - else { |
|
| 870 | + } |
|
| 871 | + else { |
|
| 872 | 872 | // An error occurred. |
| 873 | 873 | // $operations contains the operations that remained unprocessed. |
| 874 | 874 | $error_operation = reset($operations); |
| 875 | 875 | $message = 'An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE); |
| 876 | - } |
|
| 877 | - drupal_set_message($message); |
|
| 876 | + } |
|
| 877 | + drupal_set_message($message); |
|
| 878 | 878 | |
| 879 | - // Release the lock on the import process |
|
| 880 | - variable_del('boincimport_process_locked'); |
|
| 881 | - drupal_goto('admin/boinc/import/process'); |
|
| 879 | + // Release the lock on the import process |
|
| 880 | + variable_del('boincimport_process_locked'); |
|
| 881 | + drupal_goto('admin/boinc/import/process'); |
|
| 882 | 882 | } |
| 883 | 883 | |
| 884 | 884 | |
@@ -891,25 +891,25 @@ discard block |
||
| 891 | 891 | */ |
| 892 | 892 | function boincimport_friends() { |
| 893 | 893 | |
| 894 | - // Check whether friendships have been successfully imported already |
|
| 895 | - if (variable_get('boincimport_import_friend_successful', 0)) { |
|
| 894 | + // Check whether friendships have been successfully imported already |
|
| 895 | + if (variable_get('boincimport_import_friend_successful', 0)) { |
|
| 896 | 896 | drupal_set_message(t('Note: Friends import has already run successfully')); |
| 897 | 897 | watchdog( |
| 898 | - 'boincimport', 'Note: Friends import has already run successfully', |
|
| 899 | - array(), WATCHDOG_INFO |
|
| 898 | + 'boincimport', 'Note: Friends import has already run successfully', |
|
| 899 | + array(), WATCHDOG_INFO |
|
| 900 | 900 | ); |
| 901 | - } |
|
| 901 | + } |
|
| 902 | 902 | |
| 903 | - if (!variable_get('boincimport_import_friend_started', 0)) { |
|
| 903 | + if (!variable_get('boincimport_import_friend_started', 0)) { |
|
| 904 | 904 | // Could prepare database tables, if new fields are necessary, etc. |
| 905 | 905 | variable_set('boincimport_import_friend_started', 1); |
| 906 | - } |
|
| 906 | + } |
|
| 907 | 907 | |
| 908 | - $pre = variable_get('boincimport_table_prefix', ''); |
|
| 908 | + $pre = variable_get('boincimport_table_prefix', ''); |
|
| 909 | 909 | |
| 910 | - // Get stuff to import |
|
| 911 | - db_set_active('boinc_rw'); |
|
| 912 | - $friendships = db_query(' |
|
| 910 | + // Get stuff to import |
|
| 911 | + db_set_active('boinc_rw'); |
|
| 912 | + $friendships = db_query(' |
|
| 913 | 913 | SELECT |
| 914 | 914 | f1.user_src, |
| 915 | 915 | f1.user_dest, |
@@ -923,51 +923,51 @@ discard block |
||
| 923 | 923 | AND (f2.user_src IS NULL OR f1.create_time < f2.create_time) |
| 924 | 924 | ORDER BY create_time', |
| 925 | 925 | $pre, $pre |
| 926 | - ); |
|
| 927 | - $friendship_count = mysql_num_rows($friendships); |
|
| 928 | - db_set_active('default'); |
|
| 926 | + ); |
|
| 927 | + $friendship_count = mysql_num_rows($friendships); |
|
| 928 | + db_set_active('default'); |
|
| 929 | 929 | |
| 930 | - if (!$friendship_count) { |
|
| 930 | + if (!$friendship_count) { |
|
| 931 | 931 | drupal_set_message( |
| 932 | - t('There were no friendships found: Aborting script'), 'error' |
|
| 932 | + t('There were no friendships found: Aborting script'), 'error' |
|
| 933 | 933 | ); |
| 934 | 934 | watchdog('boincimport', |
| 935 | - 'There were no friendships found: Aborting script', array(), WATCHDOG_INFO |
|
| 935 | + 'There were no friendships found: Aborting script', array(), WATCHDOG_INFO |
|
| 936 | 936 | ); |
| 937 | 937 | // Release the lock on the import process |
| 938 | 938 | variable_del('boincimport_process_locked'); |
| 939 | 939 | return t('There were no friendships found: Aborting script.'); |
| 940 | - } |
|
| 940 | + } |
|
| 941 | 941 | |
| 942 | - watchdog('boincimport', |
|
| 942 | + watchdog('boincimport', |
|
| 943 | 943 | 'Found %count friend relationships: Beginning Import', |
| 944 | 944 | array('%count' => $friendship_count), WATCHDOG_INFO |
| 945 | - ); |
|
| 945 | + ); |
|
| 946 | 946 | |
| 947 | - $operations = array(); |
|
| 947 | + $operations = array(); |
|
| 948 | 948 | |
| 949 | - // It doesn't matter if a friend relationship has already been imported, just |
|
| 950 | - // do it again if so |
|
| 949 | + // It doesn't matter if a friend relationship has already been imported, just |
|
| 950 | + // do it again if so |
|
| 951 | 951 | |
| 952 | - // Create batches to process |
|
| 953 | - while ($friendship = db_fetch_object($friendships)) { |
|
| 952 | + // Create batches to process |
|
| 953 | + while ($friendship = db_fetch_object($friendships)) { |
|
| 954 | 954 | $operations[] = array( |
| 955 | - 'boincimport_friends_op', array( |
|
| 955 | + 'boincimport_friends_op', array( |
|
| 956 | 956 | $friendship |
| 957 | - ) |
|
| 957 | + ) |
|
| 958 | 958 | ); |
| 959 | - } |
|
| 959 | + } |
|
| 960 | 960 | |
| 961 | - $batch = array( |
|
| 961 | + $batch = array( |
|
| 962 | 962 | 'operations' => $operations, |
| 963 | 963 | 'finished' => 'boincimport_friends_finished', |
| 964 | 964 | 'title' => t('Importing friend relationships'), |
| 965 | 965 | 'init_message' => t('Beginning friend import...'), |
| 966 | 966 | 'progress_message' => t('Processed @current out of @total friendships.'), |
| 967 | 967 | 'error_message' => t('Friend import has encountered an error.'), |
| 968 | - ); |
|
| 968 | + ); |
|
| 969 | 969 | |
| 970 | - batch_set($batch); |
|
| 970 | + batch_set($batch); |
|
| 971 | 971 | } |
| 972 | 972 | |
| 973 | 973 | /** |
@@ -976,83 +976,83 @@ discard block |
||
| 976 | 976 | */ |
| 977 | 977 | function boincimport_friends_op($friendship, &$context) { |
| 978 | 978 | |
| 979 | - $input_format = variable_get('boincimport_input_format', 0); |
|
| 980 | - $success = FALSE; |
|
| 981 | - $message = ''; |
|
| 979 | + $input_format = variable_get('boincimport_input_format', 0); |
|
| 980 | + $success = FALSE; |
|
| 981 | + $message = ''; |
|
| 982 | 982 | |
| 983 | - // Convert BOINC friends to Drupal friends |
|
| 984 | - $uid = boincuser_lookup_uid($friendship->user_src); |
|
| 985 | - $friend_uid = boincuser_lookup_uid($friendship->user_dest); |
|
| 986 | - if ($uid AND $friend_uid) { |
|
| 983 | + // Convert BOINC friends to Drupal friends |
|
| 984 | + $uid = boincuser_lookup_uid($friendship->user_src); |
|
| 985 | + $friend_uid = boincuser_lookup_uid($friendship->user_dest); |
|
| 986 | + if ($uid AND $friend_uid) { |
|
| 987 | 987 | $success = db_query(" |
| 988 | 988 | INSERT IGNORE INTO {flag_friend} |
| 989 | 989 | SET uid = '%d', friend_uid = '%d', created = '%d'", |
| 990 | - $uid, $friend_uid, $friendship->create_time |
|
| 990 | + $uid, $friend_uid, $friendship->create_time |
|
| 991 | 991 | ); |
| 992 | - } |
|
| 993 | - else { |
|
| 992 | + } |
|
| 993 | + else { |
|
| 994 | 994 | $boinc_id = ($uid) ? $friendship->user_dest : $friendship->user_src; |
| 995 | 995 | $message = "No Drupal account exists for BOINC user {$boinc_id}!"; |
| 996 | - } |
|
| 996 | + } |
|
| 997 | 997 | |
| 998 | - if ($success) { |
|
| 998 | + if ($success) { |
|
| 999 | 999 | // Store some result for post-processing in the finished callback. |
| 1000 | 1000 | $context['results']['success'][] = $uid; |
| 1001 | 1001 | $message = "Successfully made users {$uid} and {$friend_uid} friends"; |
| 1002 | - } |
|
| 1003 | - else { |
|
| 1002 | + } |
|
| 1003 | + else { |
|
| 1004 | 1004 | $context['results']['failure'][] = $uid; |
| 1005 | 1005 | if (!$message) { |
| 1006 | - $message = "Failed to make users {$uid} and {$friend_uid} friends!"; |
|
| 1006 | + $message = "Failed to make users {$uid} and {$friend_uid} friends!"; |
|
| 1007 | 1007 | } |
| 1008 | 1008 | watchdog('boincimport', $message, array(), WATCHDOG_WARNING); |
| 1009 | - } |
|
| 1009 | + } |
|
| 1010 | 1010 | |
| 1011 | - // Update our progress information. |
|
| 1012 | - $context['sandbox']['progress']++; |
|
| 1013 | - $context['sandbox']['current_user'] = $uid; |
|
| 1014 | - $context['message'] = $message; |
|
| 1011 | + // Update our progress information. |
|
| 1012 | + $context['sandbox']['progress']++; |
|
| 1013 | + $context['sandbox']['current_user'] = $uid; |
|
| 1014 | + $context['message'] = $message; |
|
| 1015 | 1015 | |
| 1016 | - // Update the progress for the batch engine |
|
| 1017 | - if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 1016 | + // Update the progress for the batch engine |
|
| 1017 | + if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 1018 | 1018 | $context['finished'] = 1; |
| 1019 | - } |
|
| 1020 | - else { |
|
| 1019 | + } |
|
| 1020 | + else { |
|
| 1021 | 1021 | $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
| 1022 | - } |
|
| 1022 | + } |
|
| 1023 | 1023 | } |
| 1024 | 1024 | |
| 1025 | 1025 | /** |
| 1026 | 1026 | * Batch 'finished' callback |
| 1027 | 1027 | */ |
| 1028 | 1028 | function boincimport_friends_finished($success, $results, $operations) { |
| 1029 | - if ($success) { |
|
| 1029 | + if ($success) { |
|
| 1030 | 1030 | // Let's count our successes |
| 1031 | 1031 | $total_imported = count($results['success']); |
| 1032 | 1032 | $failures = count($results['failure']); |
| 1033 | 1033 | $message = t( |
| 1034 | - 'Successfully imported @count friendships (@failed failures)', |
|
| 1035 | - array( |
|
| 1034 | + 'Successfully imported @count friendships (@failed failures)', |
|
| 1035 | + array( |
|
| 1036 | 1036 | '@count' => $total_imported, |
| 1037 | 1037 | '@failed' => $failures, |
| 1038 | - ) |
|
| 1038 | + ) |
|
| 1039 | 1039 | ); |
| 1040 | 1040 | watchdog('boincimport', $message, array(), WATCHDOG_INFO); |
| 1041 | 1041 | // Set the friend import successful flag in the variable table |
| 1042 | 1042 | variable_set('boincimport_import_friend_successful', '1'); |
| 1043 | 1043 | $_SESSION['boincimport_stage_selected'] = 'preferences'; |
| 1044 | - } |
|
| 1045 | - else { |
|
| 1044 | + } |
|
| 1045 | + else { |
|
| 1046 | 1046 | // An error occurred. |
| 1047 | 1047 | // $operations contains the operations that remained unprocessed. |
| 1048 | 1048 | $error_operation = reset($operations); |
| 1049 | 1049 | $message = 'An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE); |
| 1050 | - } |
|
| 1051 | - drupal_set_message($message); |
|
| 1050 | + } |
|
| 1051 | + drupal_set_message($message); |
|
| 1052 | 1052 | |
| 1053 | - // Release the lock on the import process |
|
| 1054 | - variable_del('boincimport_process_locked'); |
|
| 1055 | - drupal_goto('admin/boinc/import/process'); |
|
| 1053 | + // Release the lock on the import process |
|
| 1054 | + variable_del('boincimport_process_locked'); |
|
| 1055 | + drupal_goto('admin/boinc/import/process'); |
|
| 1056 | 1056 | } |
| 1057 | 1057 | |
| 1058 | 1058 | |
@@ -1065,78 +1065,78 @@ discard block |
||
| 1065 | 1065 | */ |
| 1066 | 1066 | function boincimport_preferences() { |
| 1067 | 1067 | |
| 1068 | - // Check whether preferences have been successfully imported already |
|
| 1069 | - if (variable_get('boincimport_import_preferences_successful', 0)) { |
|
| 1068 | + // Check whether preferences have been successfully imported already |
|
| 1069 | + if (variable_get('boincimport_import_preferences_successful', 0)) { |
|
| 1070 | 1070 | drupal_set_message(t('Note: preferences import has already run successfully')); |
| 1071 | 1071 | watchdog( |
| 1072 | - 'boincimport', 'Note: preferences import has already run successfully', |
|
| 1073 | - array(), WATCHDOG_INFO |
|
| 1072 | + 'boincimport', 'Note: preferences import has already run successfully', |
|
| 1073 | + array(), WATCHDOG_INFO |
|
| 1074 | 1074 | ); |
| 1075 | - } |
|
| 1075 | + } |
|
| 1076 | 1076 | |
| 1077 | - if (!variable_get('boincimport_import_preferences_started', 0)) { |
|
| 1077 | + if (!variable_get('boincimport_import_preferences_started', 0)) { |
|
| 1078 | 1078 | // Could prepare database tables, if new fields are necessary, etc. |
| 1079 | 1079 | variable_set('boincimport_import_preferences_started', 1); |
| 1080 | - } |
|
| 1080 | + } |
|
| 1081 | 1081 | |
| 1082 | - $pre = variable_get('boincimport_table_prefix', ''); |
|
| 1082 | + $pre = variable_get('boincimport_table_prefix', ''); |
|
| 1083 | 1083 | |
| 1084 | - // Currently the only preferences being imported are BOINC "filtered users" |
|
| 1085 | - // This concept of users blocking other users when they don't get along maps |
|
| 1086 | - // to the Drupal ignore users module |
|
| 1084 | + // Currently the only preferences being imported are BOINC "filtered users" |
|
| 1085 | + // This concept of users blocking other users when they don't get along maps |
|
| 1086 | + // to the Drupal ignore users module |
|
| 1087 | 1087 | |
| 1088 | - // Find users who are involved in quarrels |
|
| 1089 | - db_set_active('boinc_rw'); |
|
| 1090 | - $quarrelers = db_query(" |
|
| 1088 | + // Find users who are involved in quarrels |
|
| 1089 | + db_set_active('boinc_rw'); |
|
| 1090 | + $quarrelers = db_query(" |
|
| 1091 | 1091 | SELECT userid, ignorelist |
| 1092 | 1092 | FROM %sforum_preferences |
| 1093 | 1093 | WHERE ignorelist <> ''", |
| 1094 | 1094 | $pre |
| 1095 | - ); |
|
| 1096 | - $quarreler_count = mysql_num_rows($quarrelers); |
|
| 1097 | - db_set_active('default'); |
|
| 1095 | + ); |
|
| 1096 | + $quarreler_count = mysql_num_rows($quarrelers); |
|
| 1097 | + db_set_active('default'); |
|
| 1098 | 1098 | |
| 1099 | - if (!$quarreler_count) { |
|
| 1099 | + if (!$quarreler_count) { |
|
| 1100 | 1100 | drupal_set_message( |
| 1101 | - t('There were no quarrels found: Moving on...') |
|
| 1101 | + t('There were no quarrels found: Moving on...') |
|
| 1102 | 1102 | ); |
| 1103 | 1103 | watchdog('boincimport', |
| 1104 | - 'There were no quarrels found: Moving on...', array(), WATCHDOG_INFO |
|
| 1104 | + 'There were no quarrels found: Moving on...', array(), WATCHDOG_INFO |
|
| 1105 | 1105 | ); |
| 1106 | 1106 | // Release the lock on the import process |
| 1107 | 1107 | variable_del('boincimport_process_locked'); |
| 1108 | 1108 | return t('There were no quarrels found: Moving on...'); |
| 1109 | - } |
|
| 1109 | + } |
|
| 1110 | 1110 | |
| 1111 | - watchdog('boincimport', |
|
| 1111 | + watchdog('boincimport', |
|
| 1112 | 1112 | 'Found %count quarreling users: Beginning Import', |
| 1113 | 1113 | array('%count' => $quarreler_count), WATCHDOG_INFO |
| 1114 | - ); |
|
| 1114 | + ); |
|
| 1115 | 1115 | |
| 1116 | - $operations = array(); |
|
| 1116 | + $operations = array(); |
|
| 1117 | 1117 | |
| 1118 | - // It doesn't matter if a filtered user preference has already been imported, |
|
| 1119 | - // just do it again if so |
|
| 1118 | + // It doesn't matter if a filtered user preference has already been imported, |
|
| 1119 | + // just do it again if so |
|
| 1120 | 1120 | |
| 1121 | - // Create batches to process |
|
| 1122 | - while ($quarreler = db_fetch_object($quarrelers)) { |
|
| 1121 | + // Create batches to process |
|
| 1122 | + while ($quarreler = db_fetch_object($quarrelers)) { |
|
| 1123 | 1123 | $operations[] = array( |
| 1124 | - 'boincimport_quarrels_op', array( |
|
| 1124 | + 'boincimport_quarrels_op', array( |
|
| 1125 | 1125 | $quarreler |
| 1126 | - ) |
|
| 1126 | + ) |
|
| 1127 | 1127 | ); |
| 1128 | - } |
|
| 1128 | + } |
|
| 1129 | 1129 | |
| 1130 | - $batch = array( |
|
| 1130 | + $batch = array( |
|
| 1131 | 1131 | 'operations' => $operations, |
| 1132 | 1132 | 'finished' => 'boincimport_preferences_finished', |
| 1133 | 1133 | 'title' => t('Importing preferences'), |
| 1134 | 1134 | 'init_message' => t('Beginning preference import...'), |
| 1135 | 1135 | 'progress_message' => t('Processed @current out of @total preferences.'), |
| 1136 | 1136 | 'error_message' => t('Preference import has encountered an error.'), |
| 1137 | - ); |
|
| 1137 | + ); |
|
| 1138 | 1138 | |
| 1139 | - batch_set($batch); |
|
| 1139 | + batch_set($batch); |
|
| 1140 | 1140 | } |
| 1141 | 1141 | |
| 1142 | 1142 | /** |
@@ -1145,99 +1145,99 @@ discard block |
||
| 1145 | 1145 | */ |
| 1146 | 1146 | function boincimport_quarrels_op($boinc_user, &$context) { |
| 1147 | 1147 | |
| 1148 | - $success = FALSE; |
|
| 1149 | - $uid = boincuser_lookup_uid($boinc_user->userid); |
|
| 1150 | - $ignored_users = explode('|', trim($boinc_user->ignorelist, '|')); |
|
| 1151 | - foreach ($ignored_users as $ignored_user) { |
|
| 1148 | + $success = FALSE; |
|
| 1149 | + $uid = boincuser_lookup_uid($boinc_user->userid); |
|
| 1150 | + $ignored_users = explode('|', trim($boinc_user->ignorelist, '|')); |
|
| 1151 | + foreach ($ignored_users as $ignored_user) { |
|
| 1152 | 1152 | $ignored_user_uid = boincuser_lookup_uid($ignored_user); |
| 1153 | 1153 | if (!$ignored_user_uid) { |
| 1154 | - $context['results']['warning'][] = "{$uid}:{$ignored_user_uid}"; |
|
| 1155 | - watchdog('boincimport', |
|
| 1154 | + $context['results']['warning'][] = "{$uid}:{$ignored_user_uid}"; |
|
| 1155 | + watchdog('boincimport', |
|
| 1156 | 1156 | 'Error adding to ignore list of user @uid: No Drupal ID found for BOINC user @boinc_id', |
| 1157 | 1157 | array('@boinc_id' => $ignored_user, '@uid' => $uid), |
| 1158 | 1158 | WATCHDOG_WARNING |
| 1159 | - ); |
|
| 1160 | - continue; |
|
| 1159 | + ); |
|
| 1160 | + continue; |
|
| 1161 | 1161 | } |
| 1162 | 1162 | $user_ignored = db_query(" |
| 1163 | 1163 | INSERT IGNORE INTO {ignore_user} |
| 1164 | 1164 | SET uid = '%d', iuid = '%d'", |
| 1165 | - $uid, $ignored_user_uid |
|
| 1165 | + $uid, $ignored_user_uid |
|
| 1166 | 1166 | ); |
| 1167 | 1167 | if ($user_ignored) { |
| 1168 | - $success = TRUE; |
|
| 1168 | + $success = TRUE; |
|
| 1169 | 1169 | } |
| 1170 | 1170 | else { |
| 1171 | - $context['results']['warning'][] = "{$uid}:{$ignored_user_uid}"; |
|
| 1172 | - watchdog('boincimport', |
|
| 1171 | + $context['results']['warning'][] = "{$uid}:{$ignored_user_uid}"; |
|
| 1172 | + watchdog('boincimport', |
|
| 1173 | 1173 | 'Could not add user @ignored_uid to the ignore list of user @uid', |
| 1174 | 1174 | array('@ignored_uid' => $ignored_user_uid, '@uid' => $uid), |
| 1175 | 1175 | WATCHDOG_WARNING |
| 1176 | - ); |
|
| 1176 | + ); |
|
| 1177 | + } |
|
| 1177 | 1178 | } |
| 1178 | - } |
|
| 1179 | 1179 | |
| 1180 | - $message = ''; |
|
| 1181 | - if ($success) { |
|
| 1180 | + $message = ''; |
|
| 1181 | + if ($success) { |
|
| 1182 | 1182 | // Store some result for post-processing in the finished callback. |
| 1183 | 1183 | $context['results']['success'][] = $uid; |
| 1184 | 1184 | $message = "Successfully imported ignored users for user {$uid}"; |
| 1185 | - } |
|
| 1186 | - else { |
|
| 1185 | + } |
|
| 1186 | + else { |
|
| 1187 | 1187 | $context['results']['failure'][] = $uid; |
| 1188 | 1188 | $message = "Failed to import any user filter preferences for user {$uid}!"; |
| 1189 | 1189 | watchdog('boincimport', |
| 1190 | - 'Failed to import any user filter preferences for user @id!', |
|
| 1191 | - array('@id' => $uid), WATCHDOG_WARNING |
|
| 1190 | + 'Failed to import any user filter preferences for user @id!', |
|
| 1191 | + array('@id' => $uid), WATCHDOG_WARNING |
|
| 1192 | 1192 | ); |
| 1193 | - } |
|
| 1193 | + } |
|
| 1194 | 1194 | |
| 1195 | - // Update our progress information. |
|
| 1196 | - $context['sandbox']['progress']++; |
|
| 1197 | - $context['sandbox']['current_user'] = $uid; |
|
| 1198 | - $context['message'] = $message; |
|
| 1195 | + // Update our progress information. |
|
| 1196 | + $context['sandbox']['progress']++; |
|
| 1197 | + $context['sandbox']['current_user'] = $uid; |
|
| 1198 | + $context['message'] = $message; |
|
| 1199 | 1199 | |
| 1200 | - // Update the progress for the batch engine |
|
| 1201 | - if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 1200 | + // Update the progress for the batch engine |
|
| 1201 | + if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 1202 | 1202 | $context['finished'] = 1; |
| 1203 | - } |
|
| 1204 | - else { |
|
| 1203 | + } |
|
| 1204 | + else { |
|
| 1205 | 1205 | $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
| 1206 | - } |
|
| 1206 | + } |
|
| 1207 | 1207 | } |
| 1208 | 1208 | |
| 1209 | 1209 | /** |
| 1210 | 1210 | * Batch 'finished' callback |
| 1211 | 1211 | */ |
| 1212 | 1212 | function boincimport_preferences_finished($success, $results, $operations) { |
| 1213 | - if ($success) { |
|
| 1213 | + if ($success) { |
|
| 1214 | 1214 | // Let's count our successes |
| 1215 | 1215 | $total_imported = count($results['success']); |
| 1216 | 1216 | $total_warnings = count($results['warning']); |
| 1217 | 1217 | $message = t( |
| 1218 | - 'Successfully imported preferences for @count users (with @warn warnings)', |
|
| 1219 | - array('@count' => $total_imported, '@warn' => $total_warnings) |
|
| 1218 | + 'Successfully imported preferences for @count users (with @warn warnings)', |
|
| 1219 | + array('@count' => $total_imported, '@warn' => $total_warnings) |
|
| 1220 | 1220 | ); |
| 1221 | 1221 | watchdog('boincimport', |
| 1222 | - 'Successfully imported preferences for @count users (with @warn warnings)', |
|
| 1223 | - array('@count' => $total_imported, '@warn' => $total_warnings), |
|
| 1224 | - WATCHDOG_INFO |
|
| 1222 | + 'Successfully imported preferences for @count users (with @warn warnings)', |
|
| 1223 | + array('@count' => $total_imported, '@warn' => $total_warnings), |
|
| 1224 | + WATCHDOG_INFO |
|
| 1225 | 1225 | ); |
| 1226 | 1226 | // Set the preference import successful flag in the variable table |
| 1227 | 1227 | variable_set('boincimport_import_preferences_successful', '1'); |
| 1228 | 1228 | $_SESSION['boincimport_stage_selected'] = 'private messages'; |
| 1229 | - } |
|
| 1230 | - else { |
|
| 1229 | + } |
|
| 1230 | + else { |
|
| 1231 | 1231 | // An error occurred. |
| 1232 | 1232 | // $operations contains the operations that remained unprocessed. |
| 1233 | 1233 | $error_operation = reset($operations); |
| 1234 | 1234 | $message = 'An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE); |
| 1235 | - } |
|
| 1236 | - drupal_set_message($message); |
|
| 1235 | + } |
|
| 1236 | + drupal_set_message($message); |
|
| 1237 | 1237 | |
| 1238 | - // Release the lock on the import process |
|
| 1239 | - variable_del('boincimport_process_locked'); |
|
| 1240 | - drupal_goto('admin/boinc/import/process'); |
|
| 1238 | + // Release the lock on the import process |
|
| 1239 | + variable_del('boincimport_process_locked'); |
|
| 1240 | + drupal_goto('admin/boinc/import/process'); |
|
| 1241 | 1241 | } |
| 1242 | 1242 | |
| 1243 | 1243 | |
@@ -1250,74 +1250,74 @@ discard block |
||
| 1250 | 1250 | */ |
| 1251 | 1251 | function boincimport_private_msgs() { |
| 1252 | 1252 | |
| 1253 | - // Check whether private messages have been successfully imported already |
|
| 1254 | - if (variable_get('boincimport_import_private_msg_successful', 0)) { |
|
| 1253 | + // Check whether private messages have been successfully imported already |
|
| 1254 | + if (variable_get('boincimport_import_private_msg_successful', 0)) { |
|
| 1255 | 1255 | drupal_set_message(t('Private message import has already run successfully -- repeating this process could result in duplicate messages!'), 'warning'); |
| 1256 | 1256 | watchdog( |
| 1257 | - 'boincimport', 'Private message import has already run successfully', |
|
| 1258 | - array(), WATCHDOG_WARNING |
|
| 1257 | + 'boincimport', 'Private message import has already run successfully', |
|
| 1258 | + array(), WATCHDOG_WARNING |
|
| 1259 | 1259 | ); |
| 1260 | 1260 | return; |
| 1261 | - } |
|
| 1261 | + } |
|
| 1262 | 1262 | |
| 1263 | - if (!variable_get('boincimport_import_private_msg_started', 0)) { |
|
| 1263 | + if (!variable_get('boincimport_import_private_msg_started', 0)) { |
|
| 1264 | 1264 | // Could prepare database tables, if new fields are necessary, etc. |
| 1265 | 1265 | variable_set('boincimport_import_private_msg_started', 1); |
| 1266 | - } |
|
| 1266 | + } |
|
| 1267 | 1267 | |
| 1268 | - $pre = variable_get('boincimport_table_prefix', ''); |
|
| 1268 | + $pre = variable_get('boincimport_table_prefix', ''); |
|
| 1269 | 1269 | |
| 1270 | - // Get stuff to import |
|
| 1271 | - db_set_active('boinc_rw'); |
|
| 1272 | - $boinc_private_msgs = db_query(' |
|
| 1270 | + // Get stuff to import |
|
| 1271 | + db_set_active('boinc_rw'); |
|
| 1272 | + $boinc_private_msgs = db_query(' |
|
| 1273 | 1273 | SELECT id, subject, content, userid, senderid, date, opened |
| 1274 | 1274 | FROM %sprivate_messages', |
| 1275 | 1275 | $pre |
| 1276 | - ); |
|
| 1277 | - $private_msg_count = mysql_num_rows($boinc_private_msgs); |
|
| 1278 | - db_set_active('default'); |
|
| 1276 | + ); |
|
| 1277 | + $private_msg_count = mysql_num_rows($boinc_private_msgs); |
|
| 1278 | + db_set_active('default'); |
|
| 1279 | 1279 | |
| 1280 | - if (!$private_msg_count) { |
|
| 1280 | + if (!$private_msg_count) { |
|
| 1281 | 1281 | drupal_set_message( |
| 1282 | - t('There were no private messages found: Moving on...') |
|
| 1282 | + t('There were no private messages found: Moving on...') |
|
| 1283 | 1283 | ); |
| 1284 | 1284 | watchdog('boincimport', |
| 1285 | - 'There were no private messages found: Moving on...', array(), WATCHDOG_INFO |
|
| 1285 | + 'There were no private messages found: Moving on...', array(), WATCHDOG_INFO |
|
| 1286 | 1286 | ); |
| 1287 | 1287 | // Release the lock on the import process |
| 1288 | 1288 | variable_del('boincimport_process_locked'); |
| 1289 | 1289 | return t('There were no private messages found: Moving on...'); |
| 1290 | - } |
|
| 1290 | + } |
|
| 1291 | 1291 | |
| 1292 | - watchdog('boincimport', |
|
| 1292 | + watchdog('boincimport', |
|
| 1293 | 1293 | 'Found %count private messages: Beginning Import', |
| 1294 | 1294 | array('%count' => $private_msg_count), WATCHDOG_INFO |
| 1295 | - ); |
|
| 1295 | + ); |
|
| 1296 | 1296 | |
| 1297 | - $operations = array(); |
|
| 1297 | + $operations = array(); |
|
| 1298 | 1298 | |
| 1299 | - // We don't know if a given private message has been imported already or not; |
|
| 1300 | - // if this is needed, a relation table must be added to the Drupal DB |
|
| 1299 | + // We don't know if a given private message has been imported already or not; |
|
| 1300 | + // if this is needed, a relation table must be added to the Drupal DB |
|
| 1301 | 1301 | |
| 1302 | - // Create batches to process |
|
| 1303 | - while ($boinc_private_msg = db_fetch_object($boinc_private_msgs)) { |
|
| 1302 | + // Create batches to process |
|
| 1303 | + while ($boinc_private_msg = db_fetch_object($boinc_private_msgs)) { |
|
| 1304 | 1304 | $operations[] = array( |
| 1305 | - 'boincimport_private_msgs_op', array( |
|
| 1305 | + 'boincimport_private_msgs_op', array( |
|
| 1306 | 1306 | $boinc_private_msg |
| 1307 | - ) |
|
| 1307 | + ) |
|
| 1308 | 1308 | ); |
| 1309 | - } |
|
| 1309 | + } |
|
| 1310 | 1310 | |
| 1311 | - $batch = array( |
|
| 1311 | + $batch = array( |
|
| 1312 | 1312 | 'operations' => $operations, |
| 1313 | 1313 | 'finished' => 'boincimport_private_msgs_finished', |
| 1314 | 1314 | 'title' => t('Importing private messages'), |
| 1315 | 1315 | 'init_message' => t('Beginning private message import...'), |
| 1316 | 1316 | 'progress_message' => t('Processed @current out of @total private messages.'), |
| 1317 | 1317 | 'error_message' => t('Private message import has encountered an error.'), |
| 1318 | - ); |
|
| 1318 | + ); |
|
| 1319 | 1319 | |
| 1320 | - batch_set($batch); |
|
| 1320 | + batch_set($batch); |
|
| 1321 | 1321 | } |
| 1322 | 1322 | |
| 1323 | 1323 | /** |
@@ -1326,95 +1326,95 @@ discard block |
||
| 1326 | 1326 | */ |
| 1327 | 1327 | function boincimport_private_msgs_op($pm, &$context) { |
| 1328 | 1328 | |
| 1329 | - $input_format = variable_get('boincimport_input_format', 0); |
|
| 1329 | + $input_format = variable_get('boincimport_input_format', 0); |
|
| 1330 | 1330 | |
| 1331 | - $uid = boincuser_lookup_uid($pm->userid); |
|
| 1332 | - $sender_uid = boincuser_lookup_uid($pm->senderid); |
|
| 1331 | + $uid = boincuser_lookup_uid($pm->userid); |
|
| 1332 | + $sender_uid = boincuser_lookup_uid($pm->senderid); |
|
| 1333 | 1333 | |
| 1334 | - $pm->content = _boincimport_strip_bbcode($pm->content); |
|
| 1335 | - $pm->content = _boincimport_text_sanitize($pm->content); |
|
| 1334 | + $pm->content = _boincimport_strip_bbcode($pm->content); |
|
| 1335 | + $pm->content = _boincimport_text_sanitize($pm->content); |
|
| 1336 | 1336 | |
| 1337 | - // First save the message |
|
| 1338 | - $message_added = db_query(" |
|
| 1337 | + // First save the message |
|
| 1338 | + $message_added = db_query(" |
|
| 1339 | 1339 | INSERT INTO {pm_message} (subject, author, body, format, timestamp) |
| 1340 | 1340 | VALUES ('%s', %d, '%s', %d, %d)", |
| 1341 | 1341 | $pm->subject, $sender_uid, $pm->content, $input_format, $pm->date |
| 1342 | - ); |
|
| 1343 | - $mid = db_last_insert_id('pm_message', 'mid'); |
|
| 1342 | + ); |
|
| 1343 | + $mid = db_last_insert_id('pm_message', 'mid'); |
|
| 1344 | 1344 | |
| 1345 | - // Then attach recipients and set status (note that threads are not a BOINC |
|
| 1346 | - // feature, so just consider every message to be a new thread) |
|
| 1347 | - $recipient_added = db_query(" |
|
| 1345 | + // Then attach recipients and set status (note that threads are not a BOINC |
|
| 1346 | + // feature, so just consider every message to be a new thread) |
|
| 1347 | + $recipient_added = db_query(" |
|
| 1348 | 1348 | INSERT INTO {pm_index} (mid, thread_id, uid, is_new, deleted) |
| 1349 | 1349 | VALUES (%d, %d, %d, %d, 0)", |
| 1350 | 1350 | $mid, $mid, $uid, !$pm->opened |
| 1351 | - ); |
|
| 1352 | - // In Drupal, the sender should be attached as well |
|
| 1353 | - $sender_added = db_query(" |
|
| 1351 | + ); |
|
| 1352 | + // In Drupal, the sender should be attached as well |
|
| 1353 | + $sender_added = db_query(" |
|
| 1354 | 1354 | INSERT INTO {pm_index} (mid, thread_id, uid, is_new, deleted) |
| 1355 | 1355 | VALUES (%d, %d, %d, %d, 0)", |
| 1356 | 1356 | $mid, $mid, $sender_uid, 0 |
| 1357 | - ); |
|
| 1357 | + ); |
|
| 1358 | 1358 | |
| 1359 | - $message = ''; |
|
| 1360 | - if ($message_added AND $recipient_added AND $sender_added) { |
|
| 1359 | + $message = ''; |
|
| 1360 | + if ($message_added AND $recipient_added AND $sender_added) { |
|
| 1361 | 1361 | // Store some result for post-processing in the finished callback. |
| 1362 | 1362 | $context['results']['success'][] = $pm->id; |
| 1363 | 1363 | $message = "Successfully imported private message {$pm->id}"; |
| 1364 | - } |
|
| 1365 | - else { |
|
| 1364 | + } |
|
| 1365 | + else { |
|
| 1366 | 1366 | $context['results']['failure'][] = $pm->id; |
| 1367 | 1367 | $message = "Failed to import private message {$pm->id}!"; |
| 1368 | 1368 | watchdog('boincimport', |
| 1369 | - 'Failed to import private message @id!', |
|
| 1370 | - array('@id' => $pm->id), WATCHDOG_WARNING |
|
| 1369 | + 'Failed to import private message @id!', |
|
| 1370 | + array('@id' => $pm->id), WATCHDOG_WARNING |
|
| 1371 | 1371 | ); |
| 1372 | - } |
|
| 1372 | + } |
|
| 1373 | 1373 | |
| 1374 | - // Update our progress information. |
|
| 1375 | - $context['sandbox']['progress']++; |
|
| 1376 | - $context['sandbox']['current_pm'] = $pm->id; |
|
| 1377 | - $context['message'] = $message; |
|
| 1374 | + // Update our progress information. |
|
| 1375 | + $context['sandbox']['progress']++; |
|
| 1376 | + $context['sandbox']['current_pm'] = $pm->id; |
|
| 1377 | + $context['message'] = $message; |
|
| 1378 | 1378 | |
| 1379 | - // Update the progress for the batch engine |
|
| 1380 | - if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 1379 | + // Update the progress for the batch engine |
|
| 1380 | + if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 1381 | 1381 | $context['finished'] = 1; |
| 1382 | - } |
|
| 1383 | - else { |
|
| 1382 | + } |
|
| 1383 | + else { |
|
| 1384 | 1384 | $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
| 1385 | - } |
|
| 1385 | + } |
|
| 1386 | 1386 | } |
| 1387 | 1387 | |
| 1388 | 1388 | /** |
| 1389 | 1389 | * Batch 'finished' callback |
| 1390 | 1390 | */ |
| 1391 | 1391 | function boincimport_private_msgs_finished($success, $results, $operations) { |
| 1392 | - if ($success) { |
|
| 1392 | + if ($success) { |
|
| 1393 | 1393 | // Let's count our successes |
| 1394 | 1394 | $total_imported = count($results['success']); |
| 1395 | 1395 | $message = t( |
| 1396 | - 'Successfully imported @count private messages', |
|
| 1397 | - array('@count' => $total_imported) |
|
| 1396 | + 'Successfully imported @count private messages', |
|
| 1397 | + array('@count' => $total_imported) |
|
| 1398 | 1398 | ); |
| 1399 | 1399 | watchdog('boincimport', |
| 1400 | - 'Successfully imported @count private messages.', |
|
| 1401 | - array('@count' => $total_imported), WATCHDOG_INFO |
|
| 1400 | + 'Successfully imported @count private messages.', |
|
| 1401 | + array('@count' => $total_imported), WATCHDOG_INFO |
|
| 1402 | 1402 | ); |
| 1403 | 1403 | // Set the private message import successful flag in the variable table |
| 1404 | 1404 | variable_set('boincimport_import_private_msg_successful', '1'); |
| 1405 | 1405 | $_SESSION['boincimport_stage_selected'] = 'categories'; |
| 1406 | - } |
|
| 1407 | - else { |
|
| 1406 | + } |
|
| 1407 | + else { |
|
| 1408 | 1408 | // An error occurred. |
| 1409 | 1409 | // $operations contains the operations that remained unprocessed. |
| 1410 | 1410 | $error_operation = reset($operations); |
| 1411 | 1411 | $message = 'An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE); |
| 1412 | - } |
|
| 1413 | - drupal_set_message($message); |
|
| 1412 | + } |
|
| 1413 | + drupal_set_message($message); |
|
| 1414 | 1414 | |
| 1415 | - // Release the lock on the import process |
|
| 1416 | - variable_del('boincimport_process_locked'); |
|
| 1417 | - drupal_goto('admin/boinc/import/process'); |
|
| 1415 | + // Release the lock on the import process |
|
| 1416 | + variable_del('boincimport_process_locked'); |
|
| 1417 | + drupal_goto('admin/boinc/import/process'); |
|
| 1418 | 1418 | } |
| 1419 | 1419 | |
| 1420 | 1420 | |
@@ -1427,196 +1427,196 @@ discard block |
||
| 1427 | 1427 | */ |
| 1428 | 1428 | function boincimport_forum_categories() { |
| 1429 | 1429 | |
| 1430 | - // Check whether forums have been successfully imported already |
|
| 1431 | - if (variable_get('boincimport_import_forum_category_successful', 0)) { |
|
| 1430 | + // Check whether forums have been successfully imported already |
|
| 1431 | + if (variable_get('boincimport_import_forum_category_successful', 0)) { |
|
| 1432 | 1432 | drupal_set_message(t('Note: forum container import has already run successfully')); |
| 1433 | 1433 | watchdog( |
| 1434 | - 'boincimport', 'Note: forum container import has already run successfully', |
|
| 1435 | - array(), WATCHDOG_INFO |
|
| 1434 | + 'boincimport', 'Note: forum container import has already run successfully', |
|
| 1435 | + array(), WATCHDOG_INFO |
|
| 1436 | 1436 | ); |
| 1437 | - } |
|
| 1437 | + } |
|
| 1438 | 1438 | |
| 1439 | - if (!variable_get('boincimport_import_forum_category_started', 0)) { |
|
| 1439 | + if (!variable_get('boincimport_import_forum_category_started', 0)) { |
|
| 1440 | 1440 | // Could prepare database tables, if new fields are necessary, etc. |
| 1441 | 1441 | variable_set('boincimport_import_forum_category_started', 1); |
| 1442 | - } |
|
| 1442 | + } |
|
| 1443 | 1443 | |
| 1444 | - $pre = variable_get('boincimport_table_prefix', ''); |
|
| 1444 | + $pre = variable_get('boincimport_table_prefix', ''); |
|
| 1445 | 1445 | |
| 1446 | - // Retrieve the vocabulary vid named "Forums" |
|
| 1447 | - //$forum_vid = variable_get('forum_nav_vocabulary', 0); |
|
| 1448 | - $forum_vid = db_result(db_query(' |
|
| 1446 | + // Retrieve the vocabulary vid named "Forums" |
|
| 1447 | + //$forum_vid = variable_get('forum_nav_vocabulary', 0); |
|
| 1448 | + $forum_vid = db_result(db_query(' |
|
| 1449 | 1449 | SELECT vid FROM {vocabulary} |
| 1450 | 1450 | WHERE name="%s"', |
| 1451 | 1451 | 'Forums' |
| 1452 | - )); |
|
| 1453 | - if (!$forum_vid) { |
|
| 1452 | + )); |
|
| 1453 | + if (!$forum_vid) { |
|
| 1454 | 1454 | $forum_vocab = array( |
| 1455 | - 'name' => t('Forums'), |
|
| 1456 | - 'description' => t('The different forum categories / containers'), |
|
| 1455 | + 'name' => t('Forums'), |
|
| 1456 | + 'description' => t('The different forum categories / containers'), |
|
| 1457 | 1457 | ); |
| 1458 | 1458 | taxonomy_save_vocabulary($forum_vocab); |
| 1459 | 1459 | $forum_vid = db_result(db_query(' |
| 1460 | 1460 | SELECT vid FROM {vocabulary} |
| 1461 | 1461 | WHERE name="%s"', |
| 1462 | - 'Forums' |
|
| 1462 | + 'Forums' |
|
| 1463 | 1463 | )); |
| 1464 | - } |
|
| 1464 | + } |
|
| 1465 | 1465 | |
| 1466 | - // Get both categories and forums from BOINC |
|
| 1467 | - db_set_active('boinc_rw'); |
|
| 1468 | - $boinc_forum_categories = db_query(' |
|
| 1466 | + // Get both categories and forums from BOINC |
|
| 1467 | + db_set_active('boinc_rw'); |
|
| 1468 | + $boinc_forum_categories = db_query(' |
|
| 1469 | 1469 | SELECT id, name |
| 1470 | 1470 | FROM %scategory |
| 1471 | 1471 | ORDER BY orderID', |
| 1472 | 1472 | $pre |
| 1473 | - ); |
|
| 1474 | - $forum_category_count = mysql_num_rows($boinc_forum_categories); |
|
| 1475 | - $boinc_forums = db_query(' |
|
| 1473 | + ); |
|
| 1474 | + $forum_category_count = mysql_num_rows($boinc_forum_categories); |
|
| 1475 | + $boinc_forums = db_query(' |
|
| 1476 | 1476 | SELECT id, category, title, description, orderID |
| 1477 | 1477 | FROM %sforum |
| 1478 | 1478 | WHERE parent_type = 0 |
| 1479 | 1479 | ORDER BY category', |
| 1480 | 1480 | $pre |
| 1481 | - ); |
|
| 1482 | - $forum_count = mysql_num_rows($boinc_forums); |
|
| 1483 | - db_set_active('default'); |
|
| 1481 | + ); |
|
| 1482 | + $forum_count = mysql_num_rows($boinc_forums); |
|
| 1483 | + db_set_active('default'); |
|
| 1484 | 1484 | |
| 1485 | - if (!$forum_category_count) { |
|
| 1485 | + if (!$forum_category_count) { |
|
| 1486 | 1486 | drupal_set_message( |
| 1487 | - t('There were no forum containers found: Aborting script'), 'warning' |
|
| 1487 | + t('There were no forum containers found: Aborting script'), 'warning' |
|
| 1488 | 1488 | ); |
| 1489 | 1489 | watchdog('boincimport', |
| 1490 | - 'There were no forum containers found: Aborting script', array(), WATCHDOG_WARNING |
|
| 1490 | + 'There were no forum containers found: Aborting script', array(), WATCHDOG_WARNING |
|
| 1491 | 1491 | ); |
| 1492 | 1492 | // Release the lock on the import process |
| 1493 | 1493 | variable_del('boincimport_process_locked'); |
| 1494 | 1494 | return t('There were no forum containers found: Aborting script.'); |
| 1495 | - } |
|
| 1496 | - if (!$forum_count) { |
|
| 1495 | + } |
|
| 1496 | + if (!$forum_count) { |
|
| 1497 | 1497 | drupal_set_message( |
| 1498 | - t('There were no forums found: Aborting script'), 'warning' |
|
| 1498 | + t('There were no forums found: Aborting script'), 'warning' |
|
| 1499 | 1499 | ); |
| 1500 | 1500 | watchdog('boincimport', |
| 1501 | - 'There were no forums found: Aborting script', array(), WATCHDOG_WARNING |
|
| 1501 | + 'There were no forums found: Aborting script', array(), WATCHDOG_WARNING |
|
| 1502 | 1502 | ); |
| 1503 | 1503 | // Release the lock on the import process |
| 1504 | 1504 | variable_del('boincimport_process_locked'); |
| 1505 | 1505 | return t('There were no forums found: Aborting script.'); |
| 1506 | - } |
|
| 1506 | + } |
|
| 1507 | 1507 | |
| 1508 | - watchdog('boincimport', |
|
| 1508 | + watchdog('boincimport', |
|
| 1509 | 1509 | 'Found %forum_count forums in %category_count containers: Beginning Import', |
| 1510 | 1510 | array( |
| 1511 | - '%forum_count' => $forum_count, |
|
| 1512 | - '%category_count' => $forum_category_count, |
|
| 1511 | + '%forum_count' => $forum_count, |
|
| 1512 | + '%category_count' => $forum_category_count, |
|
| 1513 | 1513 | ), WATCHDOG_INFO |
| 1514 | - ); |
|
| 1515 | - |
|
| 1516 | - $operations = array(); |
|
| 1517 | - $existing_categories = array(); |
|
| 1518 | - $existing_forums = array(); |
|
| 1519 | - $duplicate_categories = array(); |
|
| 1520 | - $duplicate_forums = array(); |
|
| 1521 | - $category_map = array(); |
|
| 1522 | - |
|
| 1523 | - // Get the list of categories already in Drupal so as not to import any twice |
|
| 1524 | - $category_tree = taxonomy_get_tree($forum_vid, 0, -1, 1); |
|
| 1525 | - foreach ($category_tree as $term) { |
|
| 1514 | + ); |
|
| 1515 | + |
|
| 1516 | + $operations = array(); |
|
| 1517 | + $existing_categories = array(); |
|
| 1518 | + $existing_forums = array(); |
|
| 1519 | + $duplicate_categories = array(); |
|
| 1520 | + $duplicate_forums = array(); |
|
| 1521 | + $category_map = array(); |
|
| 1522 | + |
|
| 1523 | + // Get the list of categories already in Drupal so as not to import any twice |
|
| 1524 | + $category_tree = taxonomy_get_tree($forum_vid, 0, -1, 1); |
|
| 1525 | + foreach ($category_tree as $term) { |
|
| 1526 | 1526 | $existing_categories[] = $term->name; |
| 1527 | - } |
|
| 1527 | + } |
|
| 1528 | 1528 | |
| 1529 | - // Get the list of forums already in Drupal |
|
| 1530 | - $result = db_query(' |
|
| 1529 | + // Get the list of forums already in Drupal |
|
| 1530 | + $result = db_query(' |
|
| 1531 | 1531 | SELECT forum_id, tid FROM {boincimport_temp_forum}' |
| 1532 | - ); |
|
| 1533 | - while ($row = db_fetch_object($result)) { |
|
| 1532 | + ); |
|
| 1533 | + while ($row = db_fetch_object($result)) { |
|
| 1534 | 1534 | $existing_forums[$row->forum_id] = $row->tid; |
| 1535 | - } |
|
| 1535 | + } |
|
| 1536 | 1536 | |
| 1537 | - // Create batches to process |
|
| 1537 | + // Create batches to process |
|
| 1538 | 1538 | |
| 1539 | - // Set up the "hidden" category, if necessary |
|
| 1540 | - // This is to support automatic hiding of empty categories |
|
| 1541 | - $hidden_forum_tid = db_result(db_query(' |
|
| 1539 | + // Set up the "hidden" category, if necessary |
|
| 1540 | + // This is to support automatic hiding of empty categories |
|
| 1541 | + $hidden_forum_tid = db_result(db_query(' |
|
| 1542 | 1542 | SELECT tid FROM {term_data} |
| 1543 | 1543 | WHERE vid = %d |
| 1544 | 1544 | AND name = "%s"', |
| 1545 | 1545 | $forum_vid, 'Hidden' |
| 1546 | - )); |
|
| 1547 | - if (!$hidden_forum_tid) { |
|
| 1546 | + )); |
|
| 1547 | + if (!$hidden_forum_tid) { |
|
| 1548 | 1548 | $operations[] = array( |
| 1549 | - 'boincimport_forum_categories_op', array( |
|
| 1549 | + 'boincimport_forum_categories_op', array( |
|
| 1550 | 1550 | NULL, $forum_vid, $pre, TRUE |
| 1551 | - ) |
|
| 1551 | + ) |
|
| 1552 | 1552 | ); |
| 1553 | - } |
|
| 1553 | + } |
|
| 1554 | 1554 | |
| 1555 | - // Import categories |
|
| 1556 | - while ($boinc_forum_category = db_fetch_object($boinc_forum_categories)) { |
|
| 1555 | + // Import categories |
|
| 1556 | + while ($boinc_forum_category = db_fetch_object($boinc_forum_categories)) { |
|
| 1557 | 1557 | if (in_array($boinc_forum_category->name, $existing_categories)) { |
| 1558 | - // This category has already been imported |
|
| 1559 | - $duplicate_categories[] = $boinc_forum_category->name; |
|
| 1558 | + // This category has already been imported |
|
| 1559 | + $duplicate_categories[] = $boinc_forum_category->name; |
|
| 1560 | 1560 | } |
| 1561 | 1561 | else { |
| 1562 | - $operations[] = array( |
|
| 1562 | + $operations[] = array( |
|
| 1563 | 1563 | 'boincimport_forum_categories_op', array( |
| 1564 | - $boinc_forum_category, $forum_vid, $pre, FALSE |
|
| 1564 | + $boinc_forum_category, $forum_vid, $pre, FALSE |
|
| 1565 | 1565 | ) |
| 1566 | - ); |
|
| 1566 | + ); |
|
| 1567 | + } |
|
| 1567 | 1568 | } |
| 1568 | - } |
|
| 1569 | 1569 | |
| 1570 | - // Import forums |
|
| 1571 | - while ($boinc_forum = db_fetch_object($boinc_forums)) { |
|
| 1572 | - if (isset($existing_forums[$boinc_forum->id])) { |
|
| 1573 | - // This forum has already been imported |
|
| 1574 | - $duplicates[] = $boinc_forum->id; |
|
| 1570 | + // Import forums |
|
| 1571 | + while ($boinc_forum = db_fetch_object($boinc_forums)) { |
|
| 1572 | + if (isset($existing_forums[$boinc_forum->id])) { |
|
| 1573 | + // This forum has already been imported |
|
| 1574 | + $duplicates[] = $boinc_forum->id; |
|
| 1575 | 1575 | } |
| 1576 | 1576 | else { |
| 1577 | - $operations[] = array( |
|
| 1577 | + $operations[] = array( |
|
| 1578 | 1578 | 'boincimport_forums_op', array( |
| 1579 | - $boinc_forum, $forum_vid, $pre |
|
| 1579 | + $boinc_forum, $forum_vid, $pre |
|
| 1580 | 1580 | ) |
| 1581 | - ); |
|
| 1581 | + ); |
|
| 1582 | + } |
|
| 1582 | 1583 | } |
| 1583 | - } |
|
| 1584 | 1584 | |
| 1585 | - // Report any duplicates that were skipped |
|
| 1586 | - $skipped_message = array(); |
|
| 1587 | - $categories_skipped = count($duplicate_categories); |
|
| 1588 | - $forums_skipped = count($duplicate_forums); |
|
| 1589 | - if ($categories_skipped) { |
|
| 1585 | + // Report any duplicates that were skipped |
|
| 1586 | + $skipped_message = array(); |
|
| 1587 | + $categories_skipped = count($duplicate_categories); |
|
| 1588 | + $forums_skipped = count($duplicate_forums); |
|
| 1589 | + if ($categories_skipped) { |
|
| 1590 | 1590 | $skipped_message[] = format_plural( |
| 1591 | - $categories_skipped, |
|
| 1592 | - '1 container', |
|
| 1593 | - '@count containers' |
|
| 1591 | + $categories_skipped, |
|
| 1592 | + '1 container', |
|
| 1593 | + '@count containers' |
|
| 1594 | 1594 | ); |
| 1595 | - } |
|
| 1596 | - if ($forums_skipped) { |
|
| 1595 | + } |
|
| 1596 | + if ($forums_skipped) { |
|
| 1597 | 1597 | $skipped_message[] = format_plural( |
| 1598 | - $forums_skipped, |
|
| 1599 | - '1 forum', |
|
| 1600 | - '@count forums' |
|
| 1598 | + $forums_skipped, |
|
| 1599 | + '1 forum', |
|
| 1600 | + '@count forums' |
|
| 1601 | 1601 | ); |
| 1602 | - } |
|
| 1603 | - if ($skipped_message) { |
|
| 1602 | + } |
|
| 1603 | + if ($skipped_message) { |
|
| 1604 | 1604 | drupal_set_message(t('Skipped @forums that were already imported', |
| 1605 | - array('@forums' => implode(' and ', $skipped_message)) |
|
| 1605 | + array('@forums' => implode(' and ', $skipped_message)) |
|
| 1606 | 1606 | )); |
| 1607 | - } |
|
| 1607 | + } |
|
| 1608 | 1608 | |
| 1609 | - // Create and run the batch |
|
| 1610 | - $batch = array( |
|
| 1609 | + // Create and run the batch |
|
| 1610 | + $batch = array( |
|
| 1611 | 1611 | 'operations' => $operations, |
| 1612 | 1612 | 'finished' => 'boincimport_forums_finished', |
| 1613 | 1613 | 'title' => t('Importing forums'), |
| 1614 | 1614 | 'init_message' => t('Beginning forum import...'), |
| 1615 | 1615 | 'progress_message' => t('Processed @current out of @total forums.'), |
| 1616 | 1616 | 'error_message' => t('Forum import has encountered an error.'), |
| 1617 | - ); |
|
| 1617 | + ); |
|
| 1618 | 1618 | |
| 1619 | - batch_set($batch); |
|
| 1619 | + batch_set($batch); |
|
| 1620 | 1620 | } |
| 1621 | 1621 | |
| 1622 | 1622 | /** |
@@ -1625,92 +1625,92 @@ discard block |
||
| 1625 | 1625 | */ |
| 1626 | 1626 | function boincimport_forum_categories_op($category, $forum_vid, $pre, $create_hidden, &$context) { |
| 1627 | 1627 | |
| 1628 | - // Set term parameters for categories |
|
| 1629 | - $forum_id = 0; |
|
| 1630 | - $parent_id = 0; |
|
| 1631 | - $description = ''; |
|
| 1632 | - $weight = 0; |
|
| 1633 | - $hidden = FALSE; |
|
| 1628 | + // Set term parameters for categories |
|
| 1629 | + $forum_id = 0; |
|
| 1630 | + $parent_id = 0; |
|
| 1631 | + $description = ''; |
|
| 1632 | + $weight = 0; |
|
| 1633 | + $hidden = FALSE; |
|
| 1634 | 1634 | |
| 1635 | - $category_map = variable_get('boincimport_forum_category_map', array()); |
|
| 1635 | + $category_map = variable_get('boincimport_forum_category_map', array()); |
|
| 1636 | 1636 | |
| 1637 | - if (!$category AND $create_hidden) { |
|
| 1637 | + if (!$category AND $create_hidden) { |
|
| 1638 | 1638 | // Create the special "hidden" container |
| 1639 | 1639 | $category = new stdClass(); |
| 1640 | 1640 | $category->name = 'Hidden'; |
| 1641 | 1641 | $category->id = 0; |
| 1642 | 1642 | $hidden = TRUE; |
| 1643 | - } |
|
| 1644 | - else { |
|
| 1643 | + } |
|
| 1644 | + else { |
|
| 1645 | 1645 | // If this container is empty, put it into the hidden container |
| 1646 | 1646 | db_set_active('boinc_rw'); |
| 1647 | 1647 | $forums_contained = db_result(db_query(' |
| 1648 | 1648 | SELECT count(*) FROM %sforum |
| 1649 | 1649 | WHERE parent_type = 0 |
| 1650 | 1650 | AND category = %d', |
| 1651 | - $pre, $category->id)); |
|
| 1651 | + $pre, $category->id)); |
|
| 1652 | 1652 | db_set_active('default'); |
| 1653 | 1653 | if (!$forums_contained) { |
| 1654 | - $parent_id = $category_map[0]; |
|
| 1655 | - $hidden = TRUE; |
|
| 1654 | + $parent_id = $category_map[0]; |
|
| 1655 | + $hidden = TRUE; |
|
| 1656 | + } |
|
| 1656 | 1657 | } |
| 1657 | - } |
|
| 1658 | 1658 | |
| 1659 | - $forum = array( |
|
| 1659 | + $forum = array( |
|
| 1660 | 1660 | 'name' => $category->name, |
| 1661 | 1661 | 'vid' => $forum_vid, |
| 1662 | 1662 | 'description' => $description, |
| 1663 | 1663 | 'parent' => $parent_id, |
| 1664 | 1664 | 'weight' => $weight, |
| 1665 | - ); |
|
| 1666 | - $forum['description'] = strip_tags($forum['description']); |
|
| 1665 | + ); |
|
| 1666 | + $forum['description'] = strip_tags($forum['description']); |
|
| 1667 | 1667 | |
| 1668 | - taxonomy_save_term($forum); |
|
| 1669 | - $success = isset($forum['tid']); |
|
| 1668 | + taxonomy_save_term($forum); |
|
| 1669 | + $success = isset($forum['tid']); |
|
| 1670 | 1670 | |
| 1671 | - // Serialize the forum containers |
|
| 1672 | - $containers = variable_get('forum_containers', array()); |
|
| 1673 | - $containers[] = $forum['tid']; |
|
| 1674 | - variable_set('forum_containers', $containers); |
|
| 1671 | + // Serialize the forum containers |
|
| 1672 | + $containers = variable_get('forum_containers', array()); |
|
| 1673 | + $containers[] = $forum['tid']; |
|
| 1674 | + variable_set('forum_containers', $containers); |
|
| 1675 | 1675 | |
| 1676 | - // Note the taxonomy ID for mapping forums to categories |
|
| 1677 | - $category_map[$category->id] = $forum['tid']; |
|
| 1678 | - variable_set('boincimport_forum_category_map', $category_map); |
|
| 1676 | + // Note the taxonomy ID for mapping forums to categories |
|
| 1677 | + $category_map[$category->id] = $forum['tid']; |
|
| 1678 | + variable_set('boincimport_forum_category_map', $category_map); |
|
| 1679 | 1679 | |
| 1680 | - boincimport_forum_set_permissions($forum, $hidden); |
|
| 1680 | + boincimport_forum_set_permissions($forum, $hidden); |
|
| 1681 | 1681 | |
| 1682 | - $message = ''; |
|
| 1683 | - if ($success) { |
|
| 1682 | + $message = ''; |
|
| 1683 | + if ($success) { |
|
| 1684 | 1684 | // Store some result for post-processing in the finished callback. |
| 1685 | 1685 | if (!$category AND $create_hidden) { |
| 1686 | - $message = "Created special hidden container"; |
|
| 1686 | + $message = "Created special hidden container"; |
|
| 1687 | 1687 | } |
| 1688 | 1688 | else { |
| 1689 | - $context['results']['categories']['success'][] = $category->id; |
|
| 1690 | - $message = "Successfully imported container {$category->id}"; |
|
| 1689 | + $context['results']['categories']['success'][] = $category->id; |
|
| 1690 | + $message = "Successfully imported container {$category->id}"; |
|
| 1691 | 1691 | } |
| 1692 | - } |
|
| 1693 | - else { |
|
| 1692 | + } |
|
| 1693 | + else { |
|
| 1694 | 1694 | $context['results']['categories']['failure'][] = $category->id; |
| 1695 | 1695 | $message = "Failed to import container {$category->id}!"; |
| 1696 | 1696 | watchdog('boincimport', |
| 1697 | - 'Failed to import container @id!', |
|
| 1698 | - array('@id' => $category->id), WATCHDOG_WARNING |
|
| 1697 | + 'Failed to import container @id!', |
|
| 1698 | + array('@id' => $category->id), WATCHDOG_WARNING |
|
| 1699 | 1699 | ); |
| 1700 | - } |
|
| 1700 | + } |
|
| 1701 | 1701 | |
| 1702 | - // Update our progress information. |
|
| 1703 | - $context['sandbox']['progress']++; |
|
| 1704 | - $context['sandbox']['current_category'] = $category->id; |
|
| 1705 | - $context['message'] = $message; |
|
| 1702 | + // Update our progress information. |
|
| 1703 | + $context['sandbox']['progress']++; |
|
| 1704 | + $context['sandbox']['current_category'] = $category->id; |
|
| 1705 | + $context['message'] = $message; |
|
| 1706 | 1706 | |
| 1707 | - // Update the progress for the batch engine |
|
| 1708 | - if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 1707 | + // Update the progress for the batch engine |
|
| 1708 | + if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 1709 | 1709 | $context['finished'] = 1; |
| 1710 | - } |
|
| 1711 | - else { |
|
| 1710 | + } |
|
| 1711 | + else { |
|
| 1712 | 1712 | $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
| 1713 | - } |
|
| 1713 | + } |
|
| 1714 | 1714 | } |
| 1715 | 1715 | |
| 1716 | 1716 | /** |
@@ -1719,40 +1719,40 @@ discard block |
||
| 1719 | 1719 | */ |
| 1720 | 1720 | function boincimport_forums_op($boincforum, $forum_vid, $pre = '', &$context) { |
| 1721 | 1721 | |
| 1722 | - $hidden_forum = FALSE; |
|
| 1723 | - $open_forum = FALSE; |
|
| 1724 | - $category_map = variable_get('boincimport_forum_category_map', array()); |
|
| 1725 | - |
|
| 1726 | - // Set term parameters for forums |
|
| 1727 | - $forum_id = $boincforum->id; |
|
| 1728 | - $parent_id = isset($category_map[$boincforum->category]) ? $category_map[$boincforum->category] : $category_map[0]; |
|
| 1729 | - $name = $boincforum->title; |
|
| 1730 | - $description = $boincforum->description; |
|
| 1731 | - $weight = $boincforum->orderID; |
|
| 1732 | - if ($parent_id == $category_map[0]) { |
|
| 1722 | + $hidden_forum = FALSE; |
|
| 1723 | + $open_forum = FALSE; |
|
| 1724 | + $category_map = variable_get('boincimport_forum_category_map', array()); |
|
| 1725 | + |
|
| 1726 | + // Set term parameters for forums |
|
| 1727 | + $forum_id = $boincforum->id; |
|
| 1728 | + $parent_id = isset($category_map[$boincforum->category]) ? $category_map[$boincforum->category] : $category_map[0]; |
|
| 1729 | + $name = $boincforum->title; |
|
| 1730 | + $description = $boincforum->description; |
|
| 1731 | + $weight = $boincforum->orderID; |
|
| 1732 | + if ($parent_id == $category_map[0]) { |
|
| 1733 | 1733 | // If this forum is hidden, flag for appropriate access controls |
| 1734 | 1734 | $hidden_forum = TRUE; |
| 1735 | - } |
|
| 1736 | - if ($name == 'Getting Started') { |
|
| 1735 | + } |
|
| 1736 | + if ($name == 'Getting Started') { |
|
| 1737 | 1737 | // Must allow users to post in this forum even if they have no credit! |
| 1738 | 1738 | $open_forum = TRUE; |
| 1739 | - } |
|
| 1739 | + } |
|
| 1740 | 1740 | |
| 1741 | - // Try to detect a BOINC news forum and flag it so that news can be |
|
| 1742 | - // imported into a Drupal news content type later |
|
| 1743 | - if ($name == 'News') { |
|
| 1741 | + // Try to detect a BOINC news forum and flag it so that news can be |
|
| 1742 | + // imported into a Drupal news content type later |
|
| 1743 | + if ($name == 'News') { |
|
| 1744 | 1744 | // Save the ID of the News forum for later import |
| 1745 | 1745 | variable_set('boincimport_news_forum_id', $forum_id); |
| 1746 | 1746 | $success = TRUE; |
| 1747 | - } |
|
| 1748 | - else { |
|
| 1747 | + } |
|
| 1748 | + else { |
|
| 1749 | 1749 | // Save all other forums as taxonomy terms |
| 1750 | 1750 | $forum = array( |
| 1751 | - 'name' => $name, |
|
| 1752 | - 'vid' => $forum_vid, |
|
| 1753 | - 'description' => $description, |
|
| 1754 | - 'parent' => $parent_id, |
|
| 1755 | - 'weight' => $weight, |
|
| 1751 | + 'name' => $name, |
|
| 1752 | + 'vid' => $forum_vid, |
|
| 1753 | + 'description' => $description, |
|
| 1754 | + 'parent' => $parent_id, |
|
| 1755 | + 'weight' => $weight, |
|
| 1756 | 1756 | ); |
| 1757 | 1757 | $forum['description'] = strip_tags($forum['description']); |
| 1758 | 1758 | |
@@ -1764,31 +1764,31 @@ discard block |
||
| 1764 | 1764 | |
| 1765 | 1765 | // Set access controls |
| 1766 | 1766 | boincimport_forum_set_permissions($forum, $hidden_forum, $open_forum); |
| 1767 | - } |
|
| 1767 | + } |
|
| 1768 | 1768 | |
| 1769 | - $message = ''; |
|
| 1770 | - if ($success) { |
|
| 1769 | + $message = ''; |
|
| 1770 | + if ($success) { |
|
| 1771 | 1771 | // Store some result for post-processing in the finished callback. |
| 1772 | 1772 | $context['results']['forums']['success'][] = $forum_id; |
| 1773 | 1773 | $message = "Successfully imported forum {$forum_id}"; |
| 1774 | - } |
|
| 1775 | - else { |
|
| 1774 | + } |
|
| 1775 | + else { |
|
| 1776 | 1776 | $context['results']['forums']['failure'][] = $forum_id; |
| 1777 | 1777 | $message = "Failed to import forum {$forum_id}!"; |
| 1778 | - } |
|
| 1778 | + } |
|
| 1779 | 1779 | |
| 1780 | - // Update our progress information. |
|
| 1781 | - $context['sandbox']['progress']++; |
|
| 1782 | - $context['sandbox']['current_forum'] = $forum_id; |
|
| 1783 | - $context['message'] = $message; |
|
| 1780 | + // Update our progress information. |
|
| 1781 | + $context['sandbox']['progress']++; |
|
| 1782 | + $context['sandbox']['current_forum'] = $forum_id; |
|
| 1783 | + $context['message'] = $message; |
|
| 1784 | 1784 | |
| 1785 | - // Update the progress for the batch engine |
|
| 1786 | - if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 1785 | + // Update the progress for the batch engine |
|
| 1786 | + if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 1787 | 1787 | $context['finished'] = 1; |
| 1788 | - } |
|
| 1789 | - else { |
|
| 1788 | + } |
|
| 1789 | + else { |
|
| 1790 | 1790 | $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
| 1791 | - } |
|
| 1791 | + } |
|
| 1792 | 1792 | } |
| 1793 | 1793 | |
| 1794 | 1794 | /** |
@@ -1796,46 +1796,46 @@ discard block |
||
| 1796 | 1796 | */ |
| 1797 | 1797 | function boincimport_forum_set_permissions($forum, $hidden = FALSE, $open = FALSE) { |
| 1798 | 1798 | |
| 1799 | - // Set access controls |
|
| 1800 | - $forum_perms = array(); |
|
| 1801 | - $role_map = array_flip(user_roles()); |
|
| 1802 | - $forum_perms[$role_map['anonymous user']] = array( |
|
| 1799 | + // Set access controls |
|
| 1800 | + $forum_perms = array(); |
|
| 1801 | + $role_map = array_flip(user_roles()); |
|
| 1802 | + $forum_perms[$role_map['anonymous user']] = array( |
|
| 1803 | 1803 | 'view' => (int) !$hidden, |
| 1804 | 1804 | 'update' => 0, |
| 1805 | 1805 | 'delete' => 0, |
| 1806 | 1806 | 'create' => 0, |
| 1807 | - ); |
|
| 1808 | - $forum_perms[$role_map['authenticated user']] = array( |
|
| 1807 | + ); |
|
| 1808 | + $forum_perms[$role_map['authenticated user']] = array( |
|
| 1809 | 1809 | 'view' => (int) !$hidden, |
| 1810 | 1810 | 'update' => 0, |
| 1811 | 1811 | 'delete' => 0, |
| 1812 | 1812 | 'create' => 0, |
| 1813 | - ); |
|
| 1814 | - $forum_perms[$role_map['community member']] = array( |
|
| 1813 | + ); |
|
| 1814 | + $forum_perms[$role_map['community member']] = array( |
|
| 1815 | 1815 | 'view' => (int) !$hidden, |
| 1816 | 1816 | 'update' => 0, |
| 1817 | 1817 | 'delete' => 0, |
| 1818 | 1818 | 'create' => (int) $open, |
| 1819 | - ); |
|
| 1820 | - $forum_perms[$role_map['verified contributor']] = array( |
|
| 1819 | + ); |
|
| 1820 | + $forum_perms[$role_map['verified contributor']] = array( |
|
| 1821 | 1821 | 'view' => (int) !$hidden, |
| 1822 | 1822 | 'update' => 0, |
| 1823 | 1823 | 'delete' => 0, |
| 1824 | 1824 | 'create' => (int) !$hidden, |
| 1825 | - ); |
|
| 1826 | - $forum_perms[$role_map['moderator']] = array( |
|
| 1825 | + ); |
|
| 1826 | + $forum_perms[$role_map['moderator']] = array( |
|
| 1827 | 1827 | 'view' => (int) !$hidden, |
| 1828 | 1828 | 'update' => (int) !$hidden, |
| 1829 | 1829 | 'delete' => 0, |
| 1830 | 1830 | 'create' => (int) !$hidden, |
| 1831 | - ); |
|
| 1832 | - $forum_perms[$role_map['administrator']] = array( |
|
| 1831 | + ); |
|
| 1832 | + $forum_perms[$role_map['administrator']] = array( |
|
| 1833 | 1833 | 'view' => 1, |
| 1834 | 1834 | 'update' => 1, |
| 1835 | 1835 | 'delete' => 1, |
| 1836 | 1836 | 'create' => 1, |
| 1837 | - ); |
|
| 1838 | - foreach ($forum_perms as $role => $perm) { |
|
| 1837 | + ); |
|
| 1838 | + foreach ($forum_perms as $role => $perm) { |
|
| 1839 | 1839 | db_query(' |
| 1840 | 1840 | INSERT INTO {forum_access} |
| 1841 | 1841 | SET tid = %d, rid = %d, |
@@ -1844,61 +1844,61 @@ discard block |
||
| 1844 | 1844 | ON DUPLICATE KEY UPDATE |
| 1845 | 1845 | grant_view = %d, grant_update = %d, |
| 1846 | 1846 | grant_delete = %d, grant_create = %d', |
| 1847 | - $forum['tid'], $role, |
|
| 1848 | - $perm['view'], $perm['update'], |
|
| 1849 | - $perm['delete'], $perm['create'], |
|
| 1850 | - $perm['view'], $perm['update'], |
|
| 1851 | - $perm['delete'], $perm['create']); |
|
| 1852 | - } |
|
| 1847 | + $forum['tid'], $role, |
|
| 1848 | + $perm['view'], $perm['update'], |
|
| 1849 | + $perm['delete'], $perm['create'], |
|
| 1850 | + $perm['view'], $perm['update'], |
|
| 1851 | + $perm['delete'], $perm['create']); |
|
| 1852 | + } |
|
| 1853 | 1853 | } |
| 1854 | 1854 | |
| 1855 | 1855 | /** |
| 1856 | 1856 | * Batch 'finished' callback |
| 1857 | 1857 | */ |
| 1858 | 1858 | function boincimport_forums_finished($success, $results, $operations) { |
| 1859 | - if ($success) { |
|
| 1859 | + if ($success) { |
|
| 1860 | 1860 | // Let's count our successes |
| 1861 | 1861 | $categories_imported = count($results['categories']['success']); |
| 1862 | 1862 | $forums_imported = count($results['forums']['success']); |
| 1863 | 1863 | |
| 1864 | 1864 | $success_message = array(); |
| 1865 | 1865 | if ($categories_imported) { |
| 1866 | - $success_message[] = format_plural( |
|
| 1866 | + $success_message[] = format_plural( |
|
| 1867 | 1867 | $categories_imported, |
| 1868 | 1868 | '1 container', |
| 1869 | 1869 | '@count containers' |
| 1870 | - ); |
|
| 1870 | + ); |
|
| 1871 | 1871 | } |
| 1872 | 1872 | if ($forums_imported) { |
| 1873 | - $success_message[] = format_plural( |
|
| 1873 | + $success_message[] = format_plural( |
|
| 1874 | 1874 | $forums_imported, |
| 1875 | 1875 | '1 forum', |
| 1876 | 1876 | '@count forums' |
| 1877 | - ); |
|
| 1877 | + ); |
|
| 1878 | 1878 | } |
| 1879 | 1879 | $message = t( |
| 1880 | - 'Successfully imported @forums', |
|
| 1881 | - array('@forums' => implode(' and ', $success_message)) |
|
| 1880 | + 'Successfully imported @forums', |
|
| 1881 | + array('@forums' => implode(' and ', $success_message)) |
|
| 1882 | 1882 | ); |
| 1883 | 1883 | watchdog('boincimport', |
| 1884 | - 'Successfully imported @forums', |
|
| 1885 | - array('@forums' => implode(' and ', $success_message)), WATCHDOG_INFO |
|
| 1884 | + 'Successfully imported @forums', |
|
| 1885 | + array('@forums' => implode(' and ', $success_message)), WATCHDOG_INFO |
|
| 1886 | 1886 | ); |
| 1887 | 1887 | // Set the forum import successful flag in the variable table |
| 1888 | 1888 | variable_set('boincimport_import_forum_successful', '1'); |
| 1889 | 1889 | $_SESSION['boincimport_stage_selected'] = 'topics'; |
| 1890 | - } |
|
| 1891 | - else { |
|
| 1890 | + } |
|
| 1891 | + else { |
|
| 1892 | 1892 | // An error occurred. |
| 1893 | 1893 | // $operations contains the operations that remained unprocessed. |
| 1894 | 1894 | $error_operation = reset($operations); |
| 1895 | 1895 | $message = 'An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE); |
| 1896 | - } |
|
| 1897 | - drupal_set_message($message); |
|
| 1896 | + } |
|
| 1897 | + drupal_set_message($message); |
|
| 1898 | 1898 | |
| 1899 | - // Release the lock on the import process |
|
| 1900 | - variable_del('boincimport_process_locked'); |
|
| 1901 | - drupal_goto('admin/boinc/import/process'); |
|
| 1899 | + // Release the lock on the import process |
|
| 1900 | + variable_del('boincimport_process_locked'); |
|
| 1901 | + drupal_goto('admin/boinc/import/process'); |
|
| 1902 | 1902 | } |
| 1903 | 1903 | |
| 1904 | 1904 | |
@@ -1910,82 +1910,82 @@ discard block |
||
| 1910 | 1910 | */ |
| 1911 | 1911 | function boincimport_forum_topics() { |
| 1912 | 1912 | |
| 1913 | - // Check whether topics have been successfully imported already |
|
| 1914 | - if (variable_get('boincimport_import_topic_successful', 0)) { |
|
| 1913 | + // Check whether topics have been successfully imported already |
|
| 1914 | + if (variable_get('boincimport_import_topic_successful', 0)) { |
|
| 1915 | 1915 | drupal_set_message(t('Topic import has already run successfully'), 'warning'); |
| 1916 | 1916 | watchdog( |
| 1917 | - 'boincimport', 'Topic import has already run successfully', |
|
| 1918 | - array(), WATCHDOG_WARNING |
|
| 1917 | + 'boincimport', 'Topic import has already run successfully', |
|
| 1918 | + array(), WATCHDOG_WARNING |
|
| 1919 | 1919 | ); |
| 1920 | 1920 | // Release the lock on the import process |
| 1921 | 1921 | variable_del('boincimport_process_locked'); |
| 1922 | 1922 | return; |
| 1923 | - } |
|
| 1923 | + } |
|
| 1924 | 1924 | |
| 1925 | - if (!variable_get('boincimport_import_topic_started', 0)) { |
|
| 1925 | + if (!variable_get('boincimport_import_topic_started', 0)) { |
|
| 1926 | 1926 | // Could prepare database tables, if new fields are necessary, etc. |
| 1927 | 1927 | variable_set('boincimport_import_topic_started', 1); |
| 1928 | - } |
|
| 1928 | + } |
|
| 1929 | 1929 | |
| 1930 | - $pre = variable_get('boincimport_table_prefix', ''); |
|
| 1930 | + $pre = variable_get('boincimport_table_prefix', ''); |
|
| 1931 | 1931 | |
| 1932 | - // Get the count of non-team topics to import |
|
| 1933 | - db_set_active('boinc_rw'); |
|
| 1934 | - $topic_count = db_result(db_query(' |
|
| 1932 | + // Get the count of non-team topics to import |
|
| 1933 | + db_set_active('boinc_rw'); |
|
| 1934 | + $topic_count = db_result(db_query(' |
|
| 1935 | 1935 | SELECT COUNT(DISTINCT t.id) |
| 1936 | 1936 | FROM %sthread t |
| 1937 | 1937 | JOIN %sforum f ON f.id = t.forum |
| 1938 | 1938 | JOIN %spost p ON p.thread = t.id |
| 1939 | 1939 | WHERE f.parent_type = 0', |
| 1940 | 1940 | $pre, $pre, $pre |
| 1941 | - )); |
|
| 1942 | - db_set_active('default'); |
|
| 1941 | + )); |
|
| 1942 | + db_set_active('default'); |
|
| 1943 | 1943 | |
| 1944 | - if (!$topic_count) { |
|
| 1944 | + if (!$topic_count) { |
|
| 1945 | 1945 | drupal_set_message( |
| 1946 | - t('There were no topics found: Aborting script'), 'warning' |
|
| 1946 | + t('There were no topics found: Aborting script'), 'warning' |
|
| 1947 | 1947 | ); |
| 1948 | 1948 | watchdog('boincimport', |
| 1949 | - 'There were no topics found: Aborting script', array(), WATCHDOG_WARNING |
|
| 1949 | + 'There were no topics found: Aborting script', array(), WATCHDOG_WARNING |
|
| 1950 | 1950 | ); |
| 1951 | 1951 | // Release the lock on the import process |
| 1952 | 1952 | variable_del('boincimport_process_locked'); |
| 1953 | 1953 | return t('There were no topics found: Aborting script.'); |
| 1954 | - } |
|
| 1954 | + } |
|
| 1955 | 1955 | |
| 1956 | - watchdog('boincimport', |
|
| 1956 | + watchdog('boincimport', |
|
| 1957 | 1957 | 'Found %count topics: Beginning Import', |
| 1958 | 1958 | array('%count' => $topic_count), WATCHDOG_INFO |
| 1959 | - ); |
|
| 1959 | + ); |
|
| 1960 | 1960 | |
| 1961 | - $operations = array(); |
|
| 1962 | - $batch_size = 100; |
|
| 1961 | + $operations = array(); |
|
| 1962 | + $batch_size = 100; |
|
| 1963 | 1963 | |
| 1964 | - // Create batches to process |
|
| 1965 | - for ($offset = 0; $offset < $topic_count; $offset+=$batch_size) { |
|
| 1964 | + // Create batches to process |
|
| 1965 | + for ($offset = 0; $offset < $topic_count; $offset+=$batch_size) { |
|
| 1966 | 1966 | $topics_per_batch = $batch_size; |
| 1967 | 1967 | if ($offset + $batch_size > $topic_count) { |
| 1968 | - $topics_per_batch = $topic_count - $offset; |
|
| 1968 | + $topics_per_batch = $topic_count - $offset; |
|
| 1969 | 1969 | } |
| 1970 | 1970 | $operations[] = array( |
| 1971 | - 'boincimport_topics_op', array( |
|
| 1971 | + 'boincimport_topics_op', array( |
|
| 1972 | 1972 | $offset, $topics_per_batch, $pre |
| 1973 | - ) |
|
| 1973 | + ) |
|
| 1974 | 1974 | ); |
| 1975 | - } |
|
| 1975 | + } |
|
| 1976 | 1976 | |
| 1977 | - $batch = array( |
|
| 1977 | + $batch = array( |
|
| 1978 | 1978 | 'operations' => $operations, |
| 1979 | 1979 | 'finished' => 'boincimport_topics_finished', |
| 1980 | 1980 | 'title' => t('Importing topics'), |
| 1981 | 1981 | 'init_message' => t('Beginning topic import...'), |
| 1982 | 1982 | 'progress_message' => t('Processed @current out of @total batches (@size topics per batch).', array( |
| 1983 | - '@size' => $batch_size, |
|
| 1983 | + '@size' => $batch_size, |
|
| 1984 | 1984 | )), |
| 1985 | 1985 | 'error_message' => t('Topic import has encountered an error.'), |
| 1986 | - ); |
|
| 1986 | + ); |
|
| 1987 | 1987 | |
| 1988 | - batch_set($batch); |
|
| 1988 | + batch_set($batch); |
|
| 1989 | 1989 | } |
| 1990 | 1990 | |
| 1991 | 1991 | /** |
@@ -1993,18 +1993,18 @@ discard block |
||
| 1993 | 1993 | * Create a Drupal node from the given BOINC topic object |
| 1994 | 1994 | */ |
| 1995 | 1995 | function boincimport_topics_op($offset, $batch_size, $pre = '', &$context) { |
| 1996 | - // Initialize the batch, if needed |
|
| 1997 | - if (!isset($context['sandbox']['progress'])) { |
|
| 1996 | + // Initialize the batch, if needed |
|
| 1997 | + if (!isset($context['sandbox']['progress'])) { |
|
| 1998 | 1998 | $context['sandbox']['progress'] = 0; |
| 1999 | 1999 | $context['sandbox']['max'] = $batch_size; |
| 2000 | - } |
|
| 2000 | + } |
|
| 2001 | 2001 | |
| 2002 | - $input_format = variable_get('boincimport_input_format', 0); |
|
| 2003 | - $news_forum_id = variable_get('boincimport_news_forum_id', 0); |
|
| 2002 | + $input_format = variable_get('boincimport_input_format', 0); |
|
| 2003 | + $news_forum_id = variable_get('boincimport_news_forum_id', 0); |
|
| 2004 | 2004 | |
| 2005 | - // Get the topic to import |
|
| 2006 | - db_set_active('boinc_rw'); |
|
| 2007 | - $topics = db_query(' |
|
| 2005 | + // Get the topic to import |
|
| 2006 | + db_set_active('boinc_rw'); |
|
| 2007 | + $topics = db_query(' |
|
| 2008 | 2008 | SELECT DISTINCT t.id, t.title, t.owner, t.forum, t.locked, t.hidden, |
| 2009 | 2009 | t.sticky, t.timestamp, t.create_time |
| 2010 | 2010 | FROM %sthread t |
@@ -2014,10 +2014,10 @@ discard block |
||
| 2014 | 2014 | ORDER BY t.id ASC |
| 2015 | 2015 | LIMIT %d,%d', |
| 2016 | 2016 | $pre, $pre, $pre, $offset, $batch_size |
| 2017 | - ); |
|
| 2018 | - db_set_active('default'); |
|
| 2017 | + ); |
|
| 2018 | + db_set_active('default'); |
|
| 2019 | 2019 | |
| 2020 | - while ($topic = db_fetch_object($topics)) { |
|
| 2020 | + while ($topic = db_fetch_object($topics)) { |
|
| 2021 | 2021 | |
| 2022 | 2022 | $error_detail = ''; |
| 2023 | 2023 | |
@@ -2030,52 +2030,52 @@ discard block |
||
| 2030 | 2030 | WHERE thread = %d |
| 2031 | 2031 | ORDER BY timestamp ASC |
| 2032 | 2032 | LIMIT 1', |
| 2033 | - $pre, $topic->id |
|
| 2033 | + $pre, $topic->id |
|
| 2034 | 2034 | )); |
| 2035 | 2035 | db_set_active('default'); |
| 2036 | 2036 | |
| 2037 | 2037 | $duplicate = db_result(db_query(' |
| 2038 | 2038 | SELECT COUNT(*) FROM {boincimport_temp_topic} |
| 2039 | 2039 | WHERE topic_id = %d', |
| 2040 | - $topic->id |
|
| 2040 | + $topic->id |
|
| 2041 | 2041 | )); |
| 2042 | 2042 | |
| 2043 | 2043 | if ($duplicate OR !$post) { |
| 2044 | - $success = FALSE; |
|
| 2044 | + $success = FALSE; |
|
| 2045 | 2045 | } |
| 2046 | 2046 | |
| 2047 | 2047 | else { |
| 2048 | - // Get the user and term IDs along with other data to define the topic |
|
| 2049 | - $uid = boincuser_lookup_uid($topic->owner); |
|
| 2050 | - $tid = db_result(db_query(' |
|
| 2048 | + // Get the user and term IDs along with other data to define the topic |
|
| 2049 | + $uid = boincuser_lookup_uid($topic->owner); |
|
| 2050 | + $tid = db_result(db_query(' |
|
| 2051 | 2051 | SELECT tid FROM {boincimport_temp_forum} |
| 2052 | 2052 | WHERE forum_id = %d', |
| 2053 | 2053 | $topic->forum |
| 2054 | - )); |
|
| 2055 | - if (!$topic->owner) { |
|
| 2054 | + )); |
|
| 2055 | + if (!$topic->owner) { |
|
| 2056 | 2056 | $uid = 0; |
| 2057 | - } |
|
| 2057 | + } |
|
| 2058 | 2058 | |
| 2059 | - $node_type = 'forum'; |
|
| 2060 | - $promote = 0; |
|
| 2061 | - $comment = ($topic->locked) ? 1 : 2; |
|
| 2059 | + $node_type = 'forum'; |
|
| 2060 | + $promote = 0; |
|
| 2061 | + $comment = ($topic->locked) ? 1 : 2; |
|
| 2062 | 2062 | |
| 2063 | - $post->content = _boincimport_strip_bbcode($post->content); |
|
| 2064 | - $post->content = _boincimport_text_sanitize($post->content); |
|
| 2065 | - $teaser = node_teaser($post->content); |
|
| 2063 | + $post->content = _boincimport_strip_bbcode($post->content); |
|
| 2064 | + $post->content = _boincimport_text_sanitize($post->content); |
|
| 2065 | + $teaser = node_teaser($post->content); |
|
| 2066 | 2066 | |
| 2067 | - if ($topic->timestamp < $topic->create_time) { |
|
| 2067 | + if ($topic->timestamp < $topic->create_time) { |
|
| 2068 | 2068 | $topic->timestamp = $topic->create_time; |
| 2069 | - } |
|
| 2069 | + } |
|
| 2070 | 2070 | |
| 2071 | - // If dealing with a News topic, be sure it is imported as such |
|
| 2072 | - if ($news_forum_id AND $topic->forum == $news_forum_id) { |
|
| 2071 | + // If dealing with a News topic, be sure it is imported as such |
|
| 2072 | + if ($news_forum_id AND $topic->forum == $news_forum_id) { |
|
| 2073 | 2073 | $node_type = 'news'; |
| 2074 | 2074 | $promote = 1; |
| 2075 | - } |
|
| 2075 | + } |
|
| 2076 | 2076 | |
| 2077 | - // Construct the thread as a forum topic node |
|
| 2078 | - $node = array( |
|
| 2077 | + // Construct the thread as a forum topic node |
|
| 2078 | + $node = array( |
|
| 2079 | 2079 | 'type' => $node_type, |
| 2080 | 2080 | 'title' => $topic->title, |
| 2081 | 2081 | 'uid' => $uid, |
@@ -2089,61 +2089,61 @@ discard block |
||
| 2089 | 2089 | 'sticky' => $topic->sticky, |
| 2090 | 2090 | 'format' => $input_format, |
| 2091 | 2091 | 'teaser' => $teaser, |
| 2092 | - ); |
|
| 2093 | - $node['tid'] = $tid; |
|
| 2092 | + ); |
|
| 2093 | + $node['tid'] = $tid; |
|
| 2094 | 2094 | |
| 2095 | - // Save the topic node |
|
| 2096 | - $node = (object) $node; // node_save requires an object form |
|
| 2097 | - node_save($node); |
|
| 2098 | - taxonomy_node_save($node, array($tid)); |
|
| 2099 | - $success = ($node->nid) ? TRUE : FALSE; |
|
| 2100 | - if ($success) { |
|
| 2095 | + // Save the topic node |
|
| 2096 | + $node = (object) $node; // node_save requires an object form |
|
| 2097 | + node_save($node); |
|
| 2098 | + taxonomy_node_save($node, array($tid)); |
|
| 2099 | + $success = ($node->nid) ? TRUE : FALSE; |
|
| 2100 | + if ($success) { |
|
| 2101 | 2101 | $success = db_query(' |
| 2102 | 2102 | INSERT INTO {boincimport_temp_topic} (topic_id, post_id, nid) |
| 2103 | 2103 | VALUES (%d, %d, %d)', $topic->id, $post->id, $node->nid |
| 2104 | 2104 | ); |
| 2105 | 2105 | if ($success) { |
| 2106 | - // Hack to keep the topics in correct order |
|
| 2107 | - $success = db_query('UPDATE {node_comment_statistics} SET last_comment_timestamp = %d WHERE nid = %d', $node->created, $node->nid); |
|
| 2108 | - if (!$success) { |
|
| 2106 | + // Hack to keep the topics in correct order |
|
| 2107 | + $success = db_query('UPDATE {node_comment_statistics} SET last_comment_timestamp = %d WHERE nid = %d', $node->created, $node->nid); |
|
| 2108 | + if (!$success) { |
|
| 2109 | 2109 | $error_detail = 'topic imported, but failed to set last comment timestamp'; |
| 2110 | - } |
|
| 2110 | + } |
|
| 2111 | 2111 | } |
| 2112 | 2112 | else { |
| 2113 | - $error_detail = 'topic node saved, but failed to link in boincimport_temp_topic table'; |
|
| 2113 | + $error_detail = 'topic node saved, but failed to link in boincimport_temp_topic table'; |
|
| 2114 | 2114 | } |
| 2115 | - } |
|
| 2116 | - else { |
|
| 2115 | + } |
|
| 2116 | + else { |
|
| 2117 | 2117 | $error_detail = 'failed to save topic node to database'; |
| 2118 | - } |
|
| 2118 | + } |
|
| 2119 | 2119 | } |
| 2120 | 2120 | |
| 2121 | 2121 | // See if the import worked |
| 2122 | 2122 | $message = ''; |
| 2123 | 2123 | if ($success) { |
| 2124 | - // Store some result for post-processing in the finished callback. |
|
| 2125 | - $context['results']['success'][] = $topic->id; |
|
| 2126 | - $message = "Successfully imported topic {$topic->id}"; |
|
| 2124 | + // Store some result for post-processing in the finished callback. |
|
| 2125 | + $context['results']['success'][] = $topic->id; |
|
| 2126 | + $message = "Successfully imported topic {$topic->id}"; |
|
| 2127 | 2127 | } |
| 2128 | 2128 | elseif ($duplicate) { |
| 2129 | - $context['results']['duplicate'][] = $topic->id; |
|
| 2130 | - $message = "Topic {$topic->id} was already imported"; |
|
| 2129 | + $context['results']['duplicate'][] = $topic->id; |
|
| 2130 | + $message = "Topic {$topic->id} was already imported"; |
|
| 2131 | 2131 | } |
| 2132 | 2132 | elseif (!$post) { |
| 2133 | - $context['results']['empty'][] = $topic->id; |
|
| 2134 | - $message = "Skipping topic {$topic->id} as empty"; |
|
| 2133 | + $context['results']['empty'][] = $topic->id; |
|
| 2134 | + $message = "Skipping topic {$topic->id} as empty"; |
|
| 2135 | 2135 | } |
| 2136 | 2136 | else { |
| 2137 | - $context['results']['failure'][] = $topic->id; |
|
| 2138 | - $message = "Failed to import topic {$topic->id}!"; |
|
| 2139 | - watchdog('boincimport', |
|
| 2137 | + $context['results']['failure'][] = $topic->id; |
|
| 2138 | + $message = "Failed to import topic {$topic->id}!"; |
|
| 2139 | + watchdog('boincimport', |
|
| 2140 | 2140 | 'Failed to import topic @id! (@error)', |
| 2141 | 2141 | array( |
| 2142 | - '@id' => $topic->id, |
|
| 2143 | - '@error' => $error_detail, |
|
| 2142 | + '@id' => $topic->id, |
|
| 2143 | + '@error' => $error_detail, |
|
| 2144 | 2144 | ), |
| 2145 | 2145 | WATCHDOG_WARNING |
| 2146 | - ); |
|
| 2146 | + ); |
|
| 2147 | 2147 | } |
| 2148 | 2148 | |
| 2149 | 2149 | // Update our progress information. |
@@ -2153,54 +2153,54 @@ discard block |
||
| 2153 | 2153 | |
| 2154 | 2154 | // Update the progress for the batch engine |
| 2155 | 2155 | if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
| 2156 | - $context['finished'] = 1; |
|
| 2156 | + $context['finished'] = 1; |
|
| 2157 | 2157 | } |
| 2158 | 2158 | else { |
| 2159 | - $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
|
| 2159 | + $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
|
| 2160 | + } |
|
| 2160 | 2161 | } |
| 2161 | - } |
|
| 2162 | 2162 | } |
| 2163 | 2163 | |
| 2164 | 2164 | /** |
| 2165 | 2165 | * Batch 'finished' callback |
| 2166 | 2166 | */ |
| 2167 | 2167 | function boincimport_topics_finished($success, $results, $operations) { |
| 2168 | - if ($success) { |
|
| 2168 | + if ($success) { |
|
| 2169 | 2169 | // Let's count our successes |
| 2170 | 2170 | $total_imported = count($results['success']); |
| 2171 | 2171 | $duplicates = count($results['duplicate']); |
| 2172 | 2172 | $empty_topics = count($results['empty']); |
| 2173 | 2173 | $message = t( |
| 2174 | - 'Successfully imported @count topics (skipped @duplicates already imported, @abandoned empty topics)', |
|
| 2175 | - array( |
|
| 2174 | + 'Successfully imported @count topics (skipped @duplicates already imported, @abandoned empty topics)', |
|
| 2175 | + array( |
|
| 2176 | 2176 | '@count' => $total_imported, |
| 2177 | 2177 | '@duplicates' => $duplicates, |
| 2178 | 2178 | '@abandoned' => $empty_topics, |
| 2179 | - ) |
|
| 2179 | + ) |
|
| 2180 | 2180 | ); |
| 2181 | 2181 | watchdog('boincimport', |
| 2182 | - 'Successfully imported @count topics (skipped @duplicates already imported, @abandoned empty topics).', |
|
| 2183 | - array( |
|
| 2182 | + 'Successfully imported @count topics (skipped @duplicates already imported, @abandoned empty topics).', |
|
| 2183 | + array( |
|
| 2184 | 2184 | '@count' => $total_imported, |
| 2185 | 2185 | '@duplicates' => $duplicates, |
| 2186 | 2186 | '@abandoned' => $empty_topics, |
| 2187 | - ), WATCHDOG_INFO |
|
| 2187 | + ), WATCHDOG_INFO |
|
| 2188 | 2188 | ); |
| 2189 | 2189 | // Set the topic import successful flag in the variable table |
| 2190 | 2190 | variable_set('boincimport_import_topic_successful', '1'); |
| 2191 | 2191 | $_SESSION['boincimport_stage_selected'] = 'posts'; |
| 2192 | - } |
|
| 2193 | - else { |
|
| 2192 | + } |
|
| 2193 | + else { |
|
| 2194 | 2194 | // An error occurred. |
| 2195 | 2195 | // $operations contains the operations that remained unprocessed. |
| 2196 | 2196 | $error_operation = reset($operations); |
| 2197 | 2197 | $message = 'An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE); |
| 2198 | - } |
|
| 2199 | - drupal_set_message($message); |
|
| 2198 | + } |
|
| 2199 | + drupal_set_message($message); |
|
| 2200 | 2200 | |
| 2201 | - // Release the lock on the import process |
|
| 2202 | - variable_del('boincimport_process_locked'); |
|
| 2203 | - drupal_goto('admin/boinc/import/process'); |
|
| 2201 | + // Release the lock on the import process |
|
| 2202 | + variable_del('boincimport_process_locked'); |
|
| 2203 | + drupal_goto('admin/boinc/import/process'); |
|
| 2204 | 2204 | } |
| 2205 | 2205 | |
| 2206 | 2206 | |
@@ -2213,91 +2213,91 @@ discard block |
||
| 2213 | 2213 | */ |
| 2214 | 2214 | function boincimport_forum_posts() { |
| 2215 | 2215 | |
| 2216 | - // Check whether forum posts have been successfully imported already |
|
| 2217 | - if (variable_get('boincimport_import_post_successful', 0)) { |
|
| 2216 | + // Check whether forum posts have been successfully imported already |
|
| 2217 | + if (variable_get('boincimport_import_post_successful', 0)) { |
|
| 2218 | 2218 | drupal_set_message(t('Forum post import has already run successfully'), 'warning'); |
| 2219 | 2219 | watchdog( |
| 2220 | - 'boincimport', 'Forum post import has already run successfully', |
|
| 2221 | - array(), WATCHDOG_WARNING |
|
| 2220 | + 'boincimport', 'Forum post import has already run successfully', |
|
| 2221 | + array(), WATCHDOG_WARNING |
|
| 2222 | 2222 | ); |
| 2223 | 2223 | // Release the lock on the import process |
| 2224 | 2224 | variable_del('boincimport_process_locked'); |
| 2225 | 2225 | return; |
| 2226 | - } |
|
| 2226 | + } |
|
| 2227 | 2227 | |
| 2228 | - if (!variable_get('boincimport_import_post_started', 0)) { |
|
| 2228 | + if (!variable_get('boincimport_import_post_started', 0)) { |
|
| 2229 | 2229 | // Could prepare database tables, if new fields are necessary, etc. |
| 2230 | 2230 | variable_set('boincimport_import_post_started', 1); |
| 2231 | - } |
|
| 2231 | + } |
|
| 2232 | 2232 | |
| 2233 | - $pre = variable_get('boincimport_table_prefix', ''); |
|
| 2233 | + $pre = variable_get('boincimport_table_prefix', ''); |
|
| 2234 | 2234 | |
| 2235 | - // Get the BOINC threads and get a count of posts to import |
|
| 2236 | - db_set_active('boinc_rw'); |
|
| 2237 | - $topic_count = db_result(db_query(" |
|
| 2235 | + // Get the BOINC threads and get a count of posts to import |
|
| 2236 | + db_set_active('boinc_rw'); |
|
| 2237 | + $topic_count = db_result(db_query(" |
|
| 2238 | 2238 | SELECT COUNT(DISTINCT t.id) FROM %sthread t |
| 2239 | 2239 | JOIN %sforum f ON f.id = t.forum |
| 2240 | 2240 | JOIN %spost p ON p.thread = t.id |
| 2241 | 2241 | WHERE f.parent_type = 0", $pre, $pre, $pre |
| 2242 | - )); |
|
| 2243 | - $total_post_count = db_result(db_query(" |
|
| 2242 | + )); |
|
| 2243 | + $total_post_count = db_result(db_query(" |
|
| 2244 | 2244 | SELECT COUNT(p.id) FROM %spost p |
| 2245 | 2245 | JOIN %sthread t ON t.id = p.thread |
| 2246 | 2246 | JOIN %sforum f ON f.id = t.forum |
| 2247 | 2247 | WHERE f.parent_type = 0", $pre, $pre, $pre |
| 2248 | - )); |
|
| 2249 | - $post_count = $total_post_count - $topic_count; |
|
| 2250 | - db_set_active('default'); |
|
| 2248 | + )); |
|
| 2249 | + $post_count = $total_post_count - $topic_count; |
|
| 2250 | + db_set_active('default'); |
|
| 2251 | 2251 | |
| 2252 | - if ($post_count <= 0) { |
|
| 2252 | + if ($post_count <= 0) { |
|
| 2253 | 2253 | drupal_set_message( |
| 2254 | - t('There were no posts found: Aborting script'), 'warning' |
|
| 2254 | + t('There were no posts found: Aborting script'), 'warning' |
|
| 2255 | 2255 | ); |
| 2256 | 2256 | watchdog('boincimport', |
| 2257 | - 'There were no posts found: Aborting script', array(), WATCHDOG_WARNING |
|
| 2257 | + 'There were no posts found: Aborting script', array(), WATCHDOG_WARNING |
|
| 2258 | 2258 | ); |
| 2259 | 2259 | // Release the lock on the import process |
| 2260 | 2260 | variable_del('boincimport_process_locked'); |
| 2261 | 2261 | return t('There were no posts found: Aborting script.'); |
| 2262 | - } |
|
| 2262 | + } |
|
| 2263 | 2263 | |
| 2264 | - watchdog('boincimport', |
|
| 2264 | + watchdog('boincimport', |
|
| 2265 | 2265 | 'Found %count posts: Beginning Import', |
| 2266 | 2266 | array('%count' => $post_count), WATCHDOG_INFO |
| 2267 | - ); |
|
| 2267 | + ); |
|
| 2268 | 2268 | |
| 2269 | - $operations = array(); |
|
| 2270 | - $batch_size = 100; |
|
| 2269 | + $operations = array(); |
|
| 2270 | + $batch_size = 100; |
|
| 2271 | 2271 | |
| 2272 | - // Create batches to process |
|
| 2273 | - for ($offset = 0; $offset < $topic_count; $offset+=$batch_size) { |
|
| 2272 | + // Create batches to process |
|
| 2273 | + for ($offset = 0; $offset < $topic_count; $offset+=$batch_size) { |
|
| 2274 | 2274 | $topics_per_batch = $batch_size; |
| 2275 | 2275 | if ($offset + $batch_size > $topic_count) { |
| 2276 | - $topics_per_batch = $topic_count - $offset; |
|
| 2276 | + $topics_per_batch = $topic_count - $offset; |
|
| 2277 | 2277 | } |
| 2278 | 2278 | $operations[] = array( |
| 2279 | - 'boincimport_posts_op', array( |
|
| 2279 | + 'boincimport_posts_op', array( |
|
| 2280 | 2280 | $offset, $topics_per_batch |
| 2281 | - ) |
|
| 2281 | + ) |
|
| 2282 | 2282 | ); |
| 2283 | - } |
|
| 2283 | + } |
|
| 2284 | 2284 | |
| 2285 | - $batch = array( |
|
| 2285 | + $batch = array( |
|
| 2286 | 2286 | 'operations' => $operations, |
| 2287 | 2287 | 'finished' => 'boincimport_posts_finished', |
| 2288 | 2288 | 'title' => t('Importing posts'), |
| 2289 | 2289 | 'init_message' => t('Beginning post import...'), |
| 2290 | 2290 | 'progress_message' => t( |
| 2291 | - 'Processed posts in @current out of @total batches (@size topics per batch).', |
|
| 2292 | - array( |
|
| 2291 | + 'Processed posts in @current out of @total batches (@size topics per batch).', |
|
| 2292 | + array( |
|
| 2293 | 2293 | '@size' => $batch_size, |
| 2294 | 2294 | // @current and @total are managed by the batch API |
| 2295 | - ) |
|
| 2295 | + ) |
|
| 2296 | 2296 | ), |
| 2297 | 2297 | 'error_message' => t('Post import has encountered an error.'), |
| 2298 | - ); |
|
| 2298 | + ); |
|
| 2299 | 2299 | |
| 2300 | - batch_set($batch); |
|
| 2300 | + batch_set($batch); |
|
| 2301 | 2301 | } |
| 2302 | 2302 | |
| 2303 | 2303 | /** |
@@ -2305,17 +2305,17 @@ discard block |
||
| 2305 | 2305 | * Create a Drupal comment from the given BOINC post object |
| 2306 | 2306 | */ |
| 2307 | 2307 | function boincimport_posts_op($offset, $batch_size, &$context) { |
| 2308 | - // Initialize the batch, if needed |
|
| 2309 | - if (!isset($context['sandbox']['progress'])) { |
|
| 2308 | + // Initialize the batch, if needed |
|
| 2309 | + if (!isset($context['sandbox']['progress'])) { |
|
| 2310 | 2310 | $context['sandbox']['progress'] = 0; |
| 2311 | 2311 | $context['sandbox']['max'] = $batch_size; |
| 2312 | - } |
|
| 2312 | + } |
|
| 2313 | 2313 | |
| 2314 | - $input_format = variable_get('boincimport_input_format', 0); |
|
| 2314 | + $input_format = variable_get('boincimport_input_format', 0); |
|
| 2315 | 2315 | |
| 2316 | - // Get the topics with posts to import |
|
| 2317 | - db_set_active('boinc_rw'); |
|
| 2318 | - $boinc_topic_ids = db_query(' |
|
| 2316 | + // Get the topics with posts to import |
|
| 2317 | + db_set_active('boinc_rw'); |
|
| 2318 | + $boinc_topic_ids = db_query(' |
|
| 2319 | 2319 | SELECT DISTINCT t.id FROM %sthread t |
| 2320 | 2320 | JOIN %sforum f ON f.id = t.forum |
| 2321 | 2321 | JOIN %spost p ON p.thread = t.id |
@@ -2323,10 +2323,10 @@ discard block |
||
| 2323 | 2323 | ORDER BY t.id |
| 2324 | 2324 | LIMIT %d,%d', |
| 2325 | 2325 | $pre, $pre, $pre, $offset, $batch_size |
| 2326 | - ); |
|
| 2327 | - db_set_active('default'); |
|
| 2326 | + ); |
|
| 2327 | + db_set_active('default'); |
|
| 2328 | 2328 | |
| 2329 | - while ($boinc_topic = db_fetch_object($boinc_topic_ids)) { |
|
| 2329 | + while ($boinc_topic = db_fetch_object($boinc_topic_ids)) { |
|
| 2330 | 2330 | // Get the posts in this topic |
| 2331 | 2331 | db_set_active('boinc_rw'); |
| 2332 | 2332 | $boinc_posts = db_query(' |
@@ -2344,29 +2344,29 @@ discard block |
||
| 2344 | 2344 | |
| 2345 | 2345 | while ($post = db_fetch_object($boinc_posts)) { |
| 2346 | 2346 | |
| 2347 | - // Skip the first post as it has already been imported as a topic |
|
| 2348 | - if ($first_post) { |
|
| 2347 | + // Skip the first post as it has already been imported as a topic |
|
| 2348 | + if ($first_post) { |
|
| 2349 | 2349 | $first_post = false; |
| 2350 | 2350 | continue; |
| 2351 | - } |
|
| 2351 | + } |
|
| 2352 | 2352 | |
| 2353 | - // Making it this far confirms that there are posts to import |
|
| 2354 | - $topic_has_responses = TRUE; |
|
| 2353 | + // Making it this far confirms that there are posts to import |
|
| 2354 | + $topic_has_responses = TRUE; |
|
| 2355 | 2355 | |
| 2356 | - $is_duplicate = db_result(db_query(' |
|
| 2356 | + $is_duplicate = db_result(db_query(' |
|
| 2357 | 2357 | SELECT COUNT(*) FROM {boincimport_temp_post} |
| 2358 | 2358 | WHERE post_id = %d', |
| 2359 | 2359 | $post->id |
| 2360 | - )); |
|
| 2361 | - if ($is_duplicate) { |
|
| 2360 | + )); |
|
| 2361 | + if ($is_duplicate) { |
|
| 2362 | 2362 | // This post has already been imported |
| 2363 | 2363 | $context['results']['posts']['duplicate'][] = $post->id; |
| 2364 | 2364 | $duplicate_posts++; |
| 2365 | 2365 | continue; |
| 2366 | - } |
|
| 2366 | + } |
|
| 2367 | 2367 | |
| 2368 | - // Make sure the post is valid |
|
| 2369 | - if ($post->content) { |
|
| 2368 | + // Make sure the post is valid |
|
| 2369 | + if ($post->content) { |
|
| 2370 | 2370 | |
| 2371 | 2371 | // Get user, node, and parent IDs for the post and sanitize |
| 2372 | 2372 | $uid = boincuser_lookup_uid($post->user); |
@@ -2375,14 +2375,14 @@ discard block |
||
| 2375 | 2375 | FROM {boincimport_temp_topic} btt |
| 2376 | 2376 | LEFT JOIN {node_revisions} AS nr ON btt.nid = nr.nid |
| 2377 | 2377 | WHERE btt.topic_id = %d', |
| 2378 | - $post->thread |
|
| 2378 | + $post->thread |
|
| 2379 | 2379 | )); |
| 2380 | 2380 | $nid = $node->nid; |
| 2381 | 2381 | $pid = db_result(db_query(' |
| 2382 | 2382 | SELECT cid |
| 2383 | 2383 | FROM {boincimport_temp_post} |
| 2384 | 2384 | WHERE post_id = %d', |
| 2385 | - $post->parent_post)); |
|
| 2385 | + $post->parent_post)); |
|
| 2386 | 2386 | if (is_null($pid)) $pid = 0; |
| 2387 | 2387 | if (!$uid) $uid = 0; |
| 2388 | 2388 | |
@@ -2393,85 +2393,85 @@ discard block |
||
| 2393 | 2393 | SELECT COUNT(*) |
| 2394 | 2394 | FROM {comments} |
| 2395 | 2395 | WHERE nid = %d', |
| 2396 | - $nid |
|
| 2396 | + $nid |
|
| 2397 | 2397 | )); |
| 2398 | 2398 | $post_reply = $pid; |
| 2399 | 2399 | |
| 2400 | 2400 | if ($post_reply OR $topic_reply) { |
| 2401 | - // Create a subject for the post from the post content. The body may be in |
|
| 2402 | - // any format, so we: |
|
| 2403 | - // 1) Filter it into HTML |
|
| 2404 | - // 2) Strip out all HTML tags |
|
| 2405 | - // 3) Convert entities back to plain-text. |
|
| 2406 | - // Note: format is checked by check_markup(). |
|
| 2407 | - $subject = truncate_utf8(trim(decode_entities(strip_tags(check_markup($post->content, $input_format)))), 29, TRUE); |
|
| 2408 | - // Replace "Quote:" with "RE:" |
|
| 2409 | - $subject = str_replace('Quote:', 'RE: ', $subject); |
|
| 2410 | - // Fringe cases where the comment body is populated only by HTML tags |
|
| 2411 | - // will require a default subject... |
|
| 2412 | - if ($subject === '') |
|
| 2401 | + // Create a subject for the post from the post content. The body may be in |
|
| 2402 | + // any format, so we: |
|
| 2403 | + // 1) Filter it into HTML |
|
| 2404 | + // 2) Strip out all HTML tags |
|
| 2405 | + // 3) Convert entities back to plain-text. |
|
| 2406 | + // Note: format is checked by check_markup(). |
|
| 2407 | + $subject = truncate_utf8(trim(decode_entities(strip_tags(check_markup($post->content, $input_format)))), 29, TRUE); |
|
| 2408 | + // Replace "Quote:" with "RE:" |
|
| 2409 | + $subject = str_replace('Quote:', 'RE: ', $subject); |
|
| 2410 | + // Fringe cases where the comment body is populated only by HTML tags |
|
| 2411 | + // will require a default subject... |
|
| 2412 | + if ($subject === '') |
|
| 2413 | 2413 | $subject = "RE: {$node->title}"; |
| 2414 | 2414 | } else { |
| 2415 | - // This is the first post in the topic |
|
| 2416 | - $subject = $node->title; |
|
| 2415 | + // This is the first post in the topic |
|
| 2416 | + $subject = $node->title; |
|
| 2417 | 2417 | } |
| 2418 | 2418 | |
| 2419 | 2419 | // Construct the post as a Drupal comment |
| 2420 | 2420 | $comment = array( |
| 2421 | - 'pid' => $pid, |
|
| 2422 | - 'nid' => $nid, |
|
| 2423 | - 'uid' => $uid, |
|
| 2424 | - 'subject' => $subject, |
|
| 2425 | - 'comment' => $post->content, |
|
| 2426 | - 'timestamp' => $post->timestamp, |
|
| 2427 | - 'status' => $post->hidden, |
|
| 2428 | - 'format' => $input_format |
|
| 2421 | + 'pid' => $pid, |
|
| 2422 | + 'nid' => $nid, |
|
| 2423 | + 'uid' => $uid, |
|
| 2424 | + 'subject' => $subject, |
|
| 2425 | + 'comment' => $post->content, |
|
| 2426 | + 'timestamp' => $post->timestamp, |
|
| 2427 | + 'status' => $post->hidden, |
|
| 2428 | + 'format' => $input_format |
|
| 2429 | 2429 | ); |
| 2430 | 2430 | |
| 2431 | 2431 | // Save the comment |
| 2432 | 2432 | if (boincimport_forum_comment_save($comment)) { |
| 2433 | - $success = db_query(' |
|
| 2433 | + $success = db_query(' |
|
| 2434 | 2434 | INSERT INTO {boincimport_temp_post} (post_id, cid) |
| 2435 | 2435 | VALUES (%d, %d)', |
| 2436 | 2436 | $post->id, $comment['cid'] |
| 2437 | - ); |
|
| 2438 | - if ($success) { |
|
| 2437 | + ); |
|
| 2438 | + if ($success) { |
|
| 2439 | 2439 | $posts_imported++; |
| 2440 | 2440 | $context['results']['posts']['success'][] = $post->id; |
| 2441 | - } |
|
| 2442 | - else { |
|
| 2441 | + } |
|
| 2442 | + else { |
|
| 2443 | 2443 | $context['results']['posts']['failure'][] = $post->id; |
| 2444 | 2444 | $error_posts++; |
| 2445 | - } |
|
| 2445 | + } |
|
| 2446 | 2446 | } |
| 2447 | 2447 | else { |
| 2448 | - $context['results']['posts']['failure'][] = $post->id; |
|
| 2449 | - $error_posts++; |
|
| 2448 | + $context['results']['posts']['failure'][] = $post->id; |
|
| 2449 | + $error_posts++; |
|
| 2450 | + } |
|
| 2450 | 2451 | } |
| 2451 | - } |
|
| 2452 | - else { |
|
| 2452 | + else { |
|
| 2453 | 2453 | $context['results']['posts']['empty'][] = $post->id; |
| 2454 | 2454 | $empty_posts++; |
| 2455 | - } |
|
| 2455 | + } |
|
| 2456 | 2456 | } |
| 2457 | 2457 | |
| 2458 | 2458 | $message = ''; |
| 2459 | 2459 | if ($success OR !$topic_has_responses) { |
| 2460 | - // Store some result for post-processing in the finished callback. |
|
| 2461 | - $context['results']['success'][] = $boinc_topic->id; |
|
| 2462 | - $message = "Imported {$posts_imported} post(s) for topic {$boinc_topic->id}"; |
|
| 2460 | + // Store some result for post-processing in the finished callback. |
|
| 2461 | + $context['results']['success'][] = $boinc_topic->id; |
|
| 2462 | + $message = "Imported {$posts_imported} post(s) for topic {$boinc_topic->id}"; |
|
| 2463 | 2463 | } |
| 2464 | 2464 | else { |
| 2465 | - $context['results']['failure'][] = $boinc_topic->id; |
|
| 2466 | - $message = "Failed to import any posts for topic {$boinc_topic->id} (excluded {$error_posts} errors, {$duplicate_posts} duplicates, and {$empty_posts} empty)"; |
|
| 2467 | - watchdog('boincimport', 'Failed to import any posts for topic @id (excluded @error_posts errors, @duplicate_posts duplicates, and @empty_posts empty)', |
|
| 2465 | + $context['results']['failure'][] = $boinc_topic->id; |
|
| 2466 | + $message = "Failed to import any posts for topic {$boinc_topic->id} (excluded {$error_posts} errors, {$duplicate_posts} duplicates, and {$empty_posts} empty)"; |
|
| 2467 | + watchdog('boincimport', 'Failed to import any posts for topic @id (excluded @error_posts errors, @duplicate_posts duplicates, and @empty_posts empty)', |
|
| 2468 | 2468 | array( |
| 2469 | - '@id' => $boinc_topic->id, |
|
| 2470 | - '@error_posts' => $error_posts, |
|
| 2471 | - '@duplicate_posts' => $duplicate_posts, |
|
| 2472 | - '@empty_posts' => $empty_posts, |
|
| 2469 | + '@id' => $boinc_topic->id, |
|
| 2470 | + '@error_posts' => $error_posts, |
|
| 2471 | + '@duplicate_posts' => $duplicate_posts, |
|
| 2472 | + '@empty_posts' => $empty_posts, |
|
| 2473 | 2473 | ), WATCHDOG_WARNING |
| 2474 | - ); |
|
| 2474 | + ); |
|
| 2475 | 2475 | } |
| 2476 | 2476 | |
| 2477 | 2477 | // Update our progress information. |
@@ -2481,19 +2481,19 @@ discard block |
||
| 2481 | 2481 | |
| 2482 | 2482 | // Update the progress for the batch engine |
| 2483 | 2483 | if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
| 2484 | - $context['finished'] = 1; |
|
| 2484 | + $context['finished'] = 1; |
|
| 2485 | 2485 | } |
| 2486 | 2486 | else { |
| 2487 | - $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
|
| 2487 | + $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
|
| 2488 | + } |
|
| 2488 | 2489 | } |
| 2489 | - } |
|
| 2490 | 2490 | } |
| 2491 | 2491 | |
| 2492 | 2492 | /** |
| 2493 | 2493 | * Batch 'finished' callback |
| 2494 | 2494 | */ |
| 2495 | 2495 | function boincimport_posts_finished($success, $results, $operations) { |
| 2496 | - if ($success) { |
|
| 2496 | + if ($success) { |
|
| 2497 | 2497 | // Let's count our successes |
| 2498 | 2498 | $posts_imported = count($results['posts']['success']); |
| 2499 | 2499 | $topic_count = count($results['success']); |
@@ -2502,39 +2502,39 @@ discard block |
||
| 2502 | 2502 | $empty_posts = count($results['posts']['empty']); |
| 2503 | 2503 | $failed_posts = count($results['posts']['failure']); |
| 2504 | 2504 | $message = t( |
| 2505 | - 'Successfully imported @post_count posts in @topic_count topics ' . |
|
| 2506 | - '(@skipped topics either had no replies or all replies were already imported, ' . |
|
| 2507 | - '@duplicates posts were skipped as already imported, ' . |
|
| 2508 | - '@empty_posts had no content, ' . |
|
| 2509 | - 'and @error_posts encountered errors during import)', |
|
| 2510 | - array( |
|
| 2505 | + 'Successfully imported @post_count posts in @topic_count topics ' . |
|
| 2506 | + '(@skipped topics either had no replies or all replies were already imported, ' . |
|
| 2507 | + '@duplicates posts were skipped as already imported, ' . |
|
| 2508 | + '@empty_posts had no content, ' . |
|
| 2509 | + 'and @error_posts encountered errors during import)', |
|
| 2510 | + array( |
|
| 2511 | 2511 | '@post_count' => $posts_imported, |
| 2512 | 2512 | '@topic_count' => $topic_count, |
| 2513 | 2513 | '@skipped' => $topics_skipped, |
| 2514 | 2514 | '@duplicates' => $duplicates, |
| 2515 | 2515 | '@empty_posts' => $empty_posts, |
| 2516 | 2516 | '@error_posts' => $failed_posts, |
| 2517 | - ) |
|
| 2517 | + ) |
|
| 2518 | 2518 | ); |
| 2519 | 2519 | watchdog('boincimport', |
| 2520 | - $message, |
|
| 2521 | - array(), WATCHDOG_INFO |
|
| 2520 | + $message, |
|
| 2521 | + array(), WATCHDOG_INFO |
|
| 2522 | 2522 | ); |
| 2523 | 2523 | // Set the post import successful flag in the variable table |
| 2524 | 2524 | variable_set('boincimport_import_post_successful', '1'); |
| 2525 | 2525 | $_SESSION['boincimport_stage_selected'] = 'team forums'; |
| 2526 | - } |
|
| 2527 | - else { |
|
| 2526 | + } |
|
| 2527 | + else { |
|
| 2528 | 2528 | // An error occurred. |
| 2529 | 2529 | // $operations contains the operations that remained unprocessed. |
| 2530 | 2530 | $error_operation = reset($operations); |
| 2531 | 2531 | $message = 'An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE); |
| 2532 | - } |
|
| 2533 | - drupal_set_message($message); |
|
| 2532 | + } |
|
| 2533 | + drupal_set_message($message); |
|
| 2534 | 2534 | |
| 2535 | - // Release the lock on the import process |
|
| 2536 | - variable_del('boincimport_process_locked'); |
|
| 2537 | - drupal_goto('admin/boinc/import/process'); |
|
| 2535 | + // Release the lock on the import process |
|
| 2536 | + variable_del('boincimport_process_locked'); |
|
| 2537 | + drupal_goto('admin/boinc/import/process'); |
|
| 2538 | 2538 | } |
| 2539 | 2539 | |
| 2540 | 2540 | |
@@ -2547,97 +2547,97 @@ discard block |
||
| 2547 | 2547 | */ |
| 2548 | 2548 | function boincimport_team_forums() { |
| 2549 | 2549 | |
| 2550 | - // Check whether team forums have been successfully imported already |
|
| 2551 | - if (variable_get('boincimport_import_team_forum_successful', 0)) { |
|
| 2550 | + // Check whether team forums have been successfully imported already |
|
| 2551 | + if (variable_get('boincimport_import_team_forum_successful', 0)) { |
|
| 2552 | 2552 | drupal_set_message(t('Team forum import has already run successfully'), 'warning'); |
| 2553 | 2553 | watchdog( |
| 2554 | - 'boincimport', 'Team forum import has already run successfully', |
|
| 2555 | - array(), WATCHDOG_WARNING |
|
| 2554 | + 'boincimport', 'Team forum import has already run successfully', |
|
| 2555 | + array(), WATCHDOG_WARNING |
|
| 2556 | 2556 | ); |
| 2557 | - } |
|
| 2557 | + } |
|
| 2558 | 2558 | |
| 2559 | - if (!variable_get('boincimport_import_team_forum_started', 0)) { |
|
| 2559 | + if (!variable_get('boincimport_import_team_forum_started', 0)) { |
|
| 2560 | 2560 | // Could prepare database tables, if new fields are necessary, etc. |
| 2561 | 2561 | variable_set('boincimport_import_team_forum_started', 1); |
| 2562 | - } |
|
| 2562 | + } |
|
| 2563 | 2563 | |
| 2564 | - $pre = variable_get('boincimport_table_prefix', ''); |
|
| 2564 | + $pre = variable_get('boincimport_table_prefix', ''); |
|
| 2565 | 2565 | |
| 2566 | - // Get team forums from BOINC database |
|
| 2567 | - db_set_active('boinc_rw'); |
|
| 2568 | - $boincteam_forums = db_query(' |
|
| 2566 | + // Get team forums from BOINC database |
|
| 2567 | + db_set_active('boinc_rw'); |
|
| 2568 | + $boincteam_forums = db_query(' |
|
| 2569 | 2569 | SELECT id, title, description, category, timestamp, post_min_interval, |
| 2570 | 2570 | post_min_total_credit, post_min_expavg_credit |
| 2571 | 2571 | FROM %sforum |
| 2572 | 2572 | WHERE parent_type = 1 |
| 2573 | 2573 | ORDER BY id ASC', |
| 2574 | 2574 | $pre |
| 2575 | - ); |
|
| 2576 | - $team_forum_count = mysql_num_rows($boincteam_forums); |
|
| 2577 | - db_set_active('default'); |
|
| 2575 | + ); |
|
| 2576 | + $team_forum_count = mysql_num_rows($boincteam_forums); |
|
| 2577 | + db_set_active('default'); |
|
| 2578 | 2578 | |
| 2579 | - if (!$team_forum_count) { |
|
| 2579 | + if (!$team_forum_count) { |
|
| 2580 | 2580 | drupal_set_message( |
| 2581 | - t('There were no team forums found: Aborting script'), 'warning' |
|
| 2581 | + t('There were no team forums found: Aborting script'), 'warning' |
|
| 2582 | 2582 | ); |
| 2583 | 2583 | watchdog('boincimport', |
| 2584 | - 'There were no team forums found: Aborting script', array(), WATCHDOG_WARNING |
|
| 2584 | + 'There were no team forums found: Aborting script', array(), WATCHDOG_WARNING |
|
| 2585 | 2585 | ); |
| 2586 | 2586 | // Release the lock on the import process |
| 2587 | 2587 | variable_del('boincimport_process_locked'); |
| 2588 | 2588 | return t('There were no BLAH found: Aborting script.'); |
| 2589 | - } |
|
| 2589 | + } |
|
| 2590 | 2590 | |
| 2591 | - watchdog('boincimport', |
|
| 2591 | + watchdog('boincimport', |
|
| 2592 | 2592 | 'Found %count team forums: Beginning Import', |
| 2593 | 2593 | array('%count' => $team_forum_count), WATCHDOG_INFO |
| 2594 | - ); |
|
| 2594 | + ); |
|
| 2595 | 2595 | |
| 2596 | - $operations = array(); |
|
| 2597 | - $existing_team_forums = array(); |
|
| 2598 | - $duplicates = array(); |
|
| 2596 | + $operations = array(); |
|
| 2597 | + $existing_team_forums = array(); |
|
| 2598 | + $duplicates = array(); |
|
| 2599 | 2599 | |
| 2600 | - // Get the list of team forums already in Drupal to be sure we're not |
|
| 2601 | - // importing any twice |
|
| 2602 | - $result = db_query(' |
|
| 2600 | + // Get the list of team forums already in Drupal to be sure we're not |
|
| 2601 | + // importing any twice |
|
| 2602 | + $result = db_query(' |
|
| 2603 | 2603 | SELECT nid, boinc_id FROM {boincteam_forum}' |
| 2604 | - ); |
|
| 2605 | - while ($row = db_fetch_object($result)) { |
|
| 2604 | + ); |
|
| 2605 | + while ($row = db_fetch_object($result)) { |
|
| 2606 | 2606 | $existing_team_forums[$row->boinc_id] = $row->nid; |
| 2607 | - } |
|
| 2607 | + } |
|
| 2608 | 2608 | |
| 2609 | - // Create batches to process |
|
| 2610 | - while ($boincteam_forum = db_fetch_object($boincteam_forums)) { |
|
| 2611 | - if (isset($existing_team_forums[$boincteam_forum->id])) { |
|
| 2612 | - // This team has already been imported |
|
| 2613 | - $duplicates[] = $boincteam_forum->id; |
|
| 2609 | + // Create batches to process |
|
| 2610 | + while ($boincteam_forum = db_fetch_object($boincteam_forums)) { |
|
| 2611 | + if (isset($existing_team_forums[$boincteam_forum->id])) { |
|
| 2612 | + // This team has already been imported |
|
| 2613 | + $duplicates[] = $boincteam_forum->id; |
|
| 2614 | 2614 | } |
| 2615 | 2615 | else { |
| 2616 | - $operations[] = array( |
|
| 2616 | + $operations[] = array( |
|
| 2617 | 2617 | 'boincimport_team_forums_op', array( |
| 2618 | - $boincteam_forum |
|
| 2618 | + $boincteam_forum |
|
| 2619 | 2619 | ) |
| 2620 | - ); |
|
| 2620 | + ); |
|
| 2621 | + } |
|
| 2621 | 2622 | } |
| 2622 | - } |
|
| 2623 | 2623 | |
| 2624 | - if ($duplicates) { |
|
| 2624 | + if ($duplicates) { |
|
| 2625 | 2625 | drupal_set_message(t( |
| 2626 | - 'Skipped @count team forums that were already imported', |
|
| 2627 | - array('@count' => count($duplicates)) |
|
| 2626 | + 'Skipped @count team forums that were already imported', |
|
| 2627 | + array('@count' => count($duplicates)) |
|
| 2628 | 2628 | )); |
| 2629 | - } |
|
| 2629 | + } |
|
| 2630 | 2630 | |
| 2631 | - $batch = array( |
|
| 2631 | + $batch = array( |
|
| 2632 | 2632 | 'operations' => $operations, |
| 2633 | 2633 | 'finished' => 'boincimport_team_forums_finished', |
| 2634 | 2634 | 'title' => t('Importing team forums'), |
| 2635 | 2635 | 'init_message' => t('Beginning team forum import...'), |
| 2636 | 2636 | 'progress_message' => t('Processed @current out of @total team forums.'), |
| 2637 | 2637 | 'error_message' => t('Team forum import has encountered an error.'), |
| 2638 | - ); |
|
| 2638 | + ); |
|
| 2639 | 2639 | |
| 2640 | - batch_set($batch); |
|
| 2640 | + batch_set($batch); |
|
| 2641 | 2641 | } |
| 2642 | 2642 | |
| 2643 | 2643 | /** |
@@ -2647,15 +2647,15 @@ discard block |
||
| 2647 | 2647 | */ |
| 2648 | 2648 | function boincimport_team_forums_op($boincteam_forum, &$context) { |
| 2649 | 2649 | |
| 2650 | - $input_format = variable_get('boincimport_input_format', 0); |
|
| 2650 | + $input_format = variable_get('boincimport_input_format', 0); |
|
| 2651 | 2651 | |
| 2652 | - // Set term parameters for forums |
|
| 2653 | - $forum_id = $boincteam_forum->id; |
|
| 2654 | - $team_id = boincteam_lookup_nid($boincteam_forum->category); |
|
| 2655 | - $name = $boincteam_forum->title; |
|
| 2656 | - $description = strip_tags($boincteam_forum->description); |
|
| 2652 | + // Set term parameters for forums |
|
| 2653 | + $forum_id = $boincteam_forum->id; |
|
| 2654 | + $team_id = boincteam_lookup_nid($boincteam_forum->category); |
|
| 2655 | + $name = $boincteam_forum->title; |
|
| 2656 | + $description = strip_tags($boincteam_forum->description); |
|
| 2657 | 2657 | |
| 2658 | - $success = db_query(" |
|
| 2658 | + $success = db_query(" |
|
| 2659 | 2659 | INSERT INTO {boincteam_forum} SET |
| 2660 | 2660 | boinc_id = %d, |
| 2661 | 2661 | nid = %d, |
@@ -2671,67 +2671,67 @@ discard block |
||
| 2671 | 2671 | time(), 0, $boincteam_forum->post_min_interval, |
| 2672 | 2672 | $boincteam_forum->post_min_total_credit, |
| 2673 | 2673 | $boincteam_forum->post_min_expavg_credit |
| 2674 | - ); |
|
| 2674 | + ); |
|
| 2675 | 2675 | |
| 2676 | - $message = ''; |
|
| 2677 | - if ($success) { |
|
| 2676 | + $message = ''; |
|
| 2677 | + if ($success) { |
|
| 2678 | 2678 | // Store some result for post-processing in the finished callback. |
| 2679 | 2679 | $context['results']['success'][] = $forum_id; |
| 2680 | 2680 | $message = "Successfully imported team forum {$forum_id}"; |
| 2681 | - } |
|
| 2682 | - else { |
|
| 2681 | + } |
|
| 2682 | + else { |
|
| 2683 | 2683 | $context['results']['failure'][] = $forum_id; |
| 2684 | 2684 | $message = "Failed to import team forum {$forum_id}!"; |
| 2685 | 2685 | watchdog('boincimport', |
| 2686 | - 'Failed to import team forum @id!', |
|
| 2687 | - array('@id' => $forum_id), WATCHDOG_WARNING |
|
| 2686 | + 'Failed to import team forum @id!', |
|
| 2687 | + array('@id' => $forum_id), WATCHDOG_WARNING |
|
| 2688 | 2688 | ); |
| 2689 | - } |
|
| 2689 | + } |
|
| 2690 | 2690 | |
| 2691 | - // Update our progress information. |
|
| 2692 | - $context['sandbox']['progress']++; |
|
| 2693 | - $context['sandbox']['current_forum'] = $forum_id; |
|
| 2694 | - $context['message'] = $message; |
|
| 2691 | + // Update our progress information. |
|
| 2692 | + $context['sandbox']['progress']++; |
|
| 2693 | + $context['sandbox']['current_forum'] = $forum_id; |
|
| 2694 | + $context['message'] = $message; |
|
| 2695 | 2695 | |
| 2696 | - // Update the progress for the batch engine |
|
| 2697 | - if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 2696 | + // Update the progress for the batch engine |
|
| 2697 | + if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 2698 | 2698 | $context['finished'] = 1; |
| 2699 | - } |
|
| 2700 | - else { |
|
| 2699 | + } |
|
| 2700 | + else { |
|
| 2701 | 2701 | $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
| 2702 | - } |
|
| 2702 | + } |
|
| 2703 | 2703 | } |
| 2704 | 2704 | |
| 2705 | 2705 | /** |
| 2706 | 2706 | * Batch 'finished' callback |
| 2707 | 2707 | */ |
| 2708 | 2708 | function boincimport_team_forums_finished($success, $results, $operations) { |
| 2709 | - if ($success) { |
|
| 2709 | + if ($success) { |
|
| 2710 | 2710 | // Let's count our successes |
| 2711 | 2711 | $total_imported = count($results['success']); |
| 2712 | 2712 | $message = t( |
| 2713 | - 'Successfully imported @count team forums', |
|
| 2714 | - array('@count' => $total_imported) |
|
| 2713 | + 'Successfully imported @count team forums', |
|
| 2714 | + array('@count' => $total_imported) |
|
| 2715 | 2715 | ); |
| 2716 | 2716 | watchdog('boincimport', |
| 2717 | - 'Successfully imported @count team forums.', |
|
| 2718 | - array('@count' => $total_imported), WATCHDOG_INFO |
|
| 2717 | + 'Successfully imported @count team forums.', |
|
| 2718 | + array('@count' => $total_imported), WATCHDOG_INFO |
|
| 2719 | 2719 | ); |
| 2720 | 2720 | // Set the team forum import successful flag in the variable table |
| 2721 | 2721 | variable_set('boincimport_import_team_forum_successful', '1'); |
| 2722 | 2722 | $_SESSION['boincimport_stage_selected'] = 'team topics'; |
| 2723 | - } |
|
| 2724 | - else { |
|
| 2723 | + } |
|
| 2724 | + else { |
|
| 2725 | 2725 | // An error occurred. |
| 2726 | 2726 | // $operations contains the operations that remained unprocessed. |
| 2727 | 2727 | $error_operation = reset($operations); |
| 2728 | 2728 | $message = 'An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE); |
| 2729 | - } |
|
| 2730 | - drupal_set_message($message); |
|
| 2729 | + } |
|
| 2730 | + drupal_set_message($message); |
|
| 2731 | 2731 | |
| 2732 | - // Release the lock on the import process |
|
| 2733 | - variable_del('boincimport_process_locked'); |
|
| 2734 | - drupal_goto('admin/boinc/import/process'); |
|
| 2732 | + // Release the lock on the import process |
|
| 2733 | + variable_del('boincimport_process_locked'); |
|
| 2734 | + drupal_goto('admin/boinc/import/process'); |
|
| 2735 | 2735 | } |
| 2736 | 2736 | |
| 2737 | 2737 | |
@@ -2744,25 +2744,25 @@ discard block |
||
| 2744 | 2744 | */ |
| 2745 | 2745 | function boincimport_team_forum_topics() { |
| 2746 | 2746 | |
| 2747 | - // Check whether team forum topics have been successfully imported already |
|
| 2748 | - if (variable_get('boincimport_import_team_topic_successful', 0)) { |
|
| 2747 | + // Check whether team forum topics have been successfully imported already |
|
| 2748 | + if (variable_get('boincimport_import_team_topic_successful', 0)) { |
|
| 2749 | 2749 | drupal_set_message(t('Team topic import has already run successfully'), 'warning'); |
| 2750 | 2750 | watchdog( |
| 2751 | - 'boincimport', 'Team topic import has already run successfully', |
|
| 2752 | - array(), WATCHDOG_WARNING |
|
| 2751 | + 'boincimport', 'Team topic import has already run successfully', |
|
| 2752 | + array(), WATCHDOG_WARNING |
|
| 2753 | 2753 | ); |
| 2754 | - } |
|
| 2754 | + } |
|
| 2755 | 2755 | |
| 2756 | - if (!variable_get('boincimport_import_team_topic_started', 0)) { |
|
| 2756 | + if (!variable_get('boincimport_import_team_topic_started', 0)) { |
|
| 2757 | 2757 | // Could prepare database tables, if new fields are necessary, etc. |
| 2758 | 2758 | variable_set('boincimport_import_team_topic_started', 1); |
| 2759 | - } |
|
| 2759 | + } |
|
| 2760 | 2760 | |
| 2761 | - $pre = variable_get('boincimport_table_prefix', ''); |
|
| 2761 | + $pre = variable_get('boincimport_table_prefix', ''); |
|
| 2762 | 2762 | |
| 2763 | - // Get all team topics to import from BOINC |
|
| 2764 | - db_set_active('boinc_rw'); |
|
| 2765 | - $boincteam_topics = db_query(' |
|
| 2763 | + // Get all team topics to import from BOINC |
|
| 2764 | + db_set_active('boinc_rw'); |
|
| 2765 | + $boincteam_topics = db_query(' |
|
| 2766 | 2766 | SELECT DISTINCT t.id, t.title, t.owner, t.forum, t.locked, t.hidden, |
| 2767 | 2767 | t.sticky, t.timestamp, t.create_time |
| 2768 | 2768 | FROM %sthread t |
@@ -2771,78 +2771,78 @@ discard block |
||
| 2771 | 2771 | WHERE f.parent_type = 1 |
| 2772 | 2772 | ORDER BY id', |
| 2773 | 2773 | $pre, $pre, $pre |
| 2774 | - ); |
|
| 2775 | - $boincteam_topic_count = mysql_num_rows($boincteam_topics); |
|
| 2776 | - $total_team_topic_count = db_result(db_query(' |
|
| 2774 | + ); |
|
| 2775 | + $boincteam_topic_count = mysql_num_rows($boincteam_topics); |
|
| 2776 | + $total_team_topic_count = db_result(db_query(' |
|
| 2777 | 2777 | SELECT COUNT(*) FROM %sthread t |
| 2778 | 2778 | JOIN %sforum f ON f.id = t.forum |
| 2779 | 2779 | WHERE f.parent_type = 1', $pre, $pre |
| 2780 | - )); |
|
| 2781 | - $empty_topic_count = $total_team_topic_count - $boincteam_topic_count; |
|
| 2782 | - db_set_active('default'); |
|
| 2780 | + )); |
|
| 2781 | + $empty_topic_count = $total_team_topic_count - $boincteam_topic_count; |
|
| 2782 | + db_set_active('default'); |
|
| 2783 | 2783 | |
| 2784 | - if (!$boincteam_topic_count) { |
|
| 2784 | + if (!$boincteam_topic_count) { |
|
| 2785 | 2785 | drupal_set_message( |
| 2786 | - t('There were no team topics found: Aborting script'), 'warning' |
|
| 2786 | + t('There were no team topics found: Aborting script'), 'warning' |
|
| 2787 | 2787 | ); |
| 2788 | 2788 | watchdog('boincimport', |
| 2789 | - 'There were no team topics found: Aborting script', array(), WATCHDOG_WARNING |
|
| 2789 | + 'There were no team topics found: Aborting script', array(), WATCHDOG_WARNING |
|
| 2790 | 2790 | ); |
| 2791 | 2791 | // Release the lock on the import process |
| 2792 | 2792 | variable_del('boincimport_process_locked'); |
| 2793 | 2793 | return t('There were no team topics found: Aborting script.'); |
| 2794 | - } |
|
| 2794 | + } |
|
| 2795 | 2795 | |
| 2796 | - watchdog('boincimport', |
|
| 2796 | + watchdog('boincimport', |
|
| 2797 | 2797 | 'Found %count team topics: Beginning Import', |
| 2798 | 2798 | array('%count' => $boincteam_topic_count), WATCHDOG_INFO |
| 2799 | - ); |
|
| 2799 | + ); |
|
| 2800 | 2800 | |
| 2801 | - $operations = array(); |
|
| 2802 | - $existing_team_topics = array(); |
|
| 2803 | - $duplicates = array(); |
|
| 2801 | + $operations = array(); |
|
| 2802 | + $existing_team_topics = array(); |
|
| 2803 | + $duplicates = array(); |
|
| 2804 | 2804 | |
| 2805 | - // Get the list of team topics already in Drupal to be sure we're not |
|
| 2806 | - // importing any twice |
|
| 2807 | - $result = db_query(' |
|
| 2805 | + // Get the list of team topics already in Drupal to be sure we're not |
|
| 2806 | + // importing any twice |
|
| 2807 | + $result = db_query(' |
|
| 2808 | 2808 | SELECT nid, topic_id FROM {boincimport_temp_topic}' |
| 2809 | - ); |
|
| 2810 | - while ($row = db_fetch_object($result)) { |
|
| 2809 | + ); |
|
| 2810 | + while ($row = db_fetch_object($result)) { |
|
| 2811 | 2811 | $existing_team_topics[$row->topic_id] = $row->nid; |
| 2812 | - } |
|
| 2812 | + } |
|
| 2813 | 2813 | |
| 2814 | - // Create batches to process |
|
| 2815 | - while ($boincteam_topic = db_fetch_object($boincteam_topics)) { |
|
| 2816 | - if (isset($existing_team_topics[$boincteam_topic->id])) { |
|
| 2817 | - // This team topic has already been imported |
|
| 2818 | - $duplicates[] = $boincteam_topic->id; |
|
| 2814 | + // Create batches to process |
|
| 2815 | + while ($boincteam_topic = db_fetch_object($boincteam_topics)) { |
|
| 2816 | + if (isset($existing_team_topics[$boincteam_topic->id])) { |
|
| 2817 | + // This team topic has already been imported |
|
| 2818 | + $duplicates[] = $boincteam_topic->id; |
|
| 2819 | 2819 | } |
| 2820 | 2820 | else { |
| 2821 | - $operations[] = array( |
|
| 2821 | + $operations[] = array( |
|
| 2822 | 2822 | 'boincimport_team_topics_op', array( |
| 2823 | - $boincteam_topic |
|
| 2823 | + $boincteam_topic |
|
| 2824 | 2824 | ) |
| 2825 | - ); |
|
| 2825 | + ); |
|
| 2826 | + } |
|
| 2826 | 2827 | } |
| 2827 | - } |
|
| 2828 | 2828 | |
| 2829 | - if ($duplicates) { |
|
| 2829 | + if ($duplicates) { |
|
| 2830 | 2830 | drupal_set_message(t( |
| 2831 | - 'Skipped @count team topics that were already imported', |
|
| 2832 | - array('@count' => count($duplicates)) |
|
| 2831 | + 'Skipped @count team topics that were already imported', |
|
| 2832 | + array('@count' => count($duplicates)) |
|
| 2833 | 2833 | )); |
| 2834 | - } |
|
| 2834 | + } |
|
| 2835 | 2835 | |
| 2836 | - $batch = array( |
|
| 2836 | + $batch = array( |
|
| 2837 | 2837 | 'operations' => $operations, |
| 2838 | 2838 | 'finished' => 'boincimport_team_topics_finished', |
| 2839 | 2839 | 'title' => t('Importing team topics'), |
| 2840 | 2840 | 'init_message' => t('Beginning team topic import...'), |
| 2841 | 2841 | 'progress_message' => t('Processed @current out of @total team topics.'), |
| 2842 | 2842 | 'error_message' => t('Team topic import has encountered an error.'), |
| 2843 | - ); |
|
| 2843 | + ); |
|
| 2844 | 2844 | |
| 2845 | - batch_set($batch); |
|
| 2845 | + batch_set($batch); |
|
| 2846 | 2846 | } |
| 2847 | 2847 | |
| 2848 | 2848 | /** |
@@ -2851,21 +2851,21 @@ discard block |
||
| 2851 | 2851 | */ |
| 2852 | 2852 | function boincimport_team_topics_op($topic, &$context) { |
| 2853 | 2853 | |
| 2854 | - $input_format = variable_get('boincimport_input_format', 0); |
|
| 2855 | - $success = FALSE; |
|
| 2856 | - $missing_parent = array(); |
|
| 2857 | - $empty_topics = array(); |
|
| 2854 | + $input_format = variable_get('boincimport_input_format', 0); |
|
| 2855 | + $success = FALSE; |
|
| 2856 | + $missing_parent = array(); |
|
| 2857 | + $empty_topics = array(); |
|
| 2858 | 2858 | |
| 2859 | - // Verify that the team forum container has been imported |
|
| 2860 | - $team_forum_id = db_result(db_query(" |
|
| 2859 | + // Verify that the team forum container has been imported |
|
| 2860 | + $team_forum_id = db_result(db_query(" |
|
| 2861 | 2861 | SELECT tfid FROM {boincteam_forum} |
| 2862 | 2862 | WHERE boinc_id = %d", |
| 2863 | 2863 | $topic->forum |
| 2864 | - )); |
|
| 2865 | - if (!$team_forum_id) { |
|
| 2864 | + )); |
|
| 2865 | + if (!$team_forum_id) { |
|
| 2866 | 2866 | $missing_parent[] = $topic->id; |
| 2867 | - } |
|
| 2868 | - else { |
|
| 2867 | + } |
|
| 2868 | + else { |
|
| 2869 | 2869 | // Get the content of the post that started the topic |
| 2870 | 2870 | db_set_active('boinc_rw'); |
| 2871 | 2871 | $query = db_query(' |
@@ -2874,36 +2874,36 @@ discard block |
||
| 2874 | 2874 | WHERE thread = %d |
| 2875 | 2875 | ORDER BY timestamp ASC |
| 2876 | 2876 | LIMIT 1', |
| 2877 | - $pre, $topic->id); |
|
| 2877 | + $pre, $topic->id); |
|
| 2878 | 2878 | db_set_active('default'); |
| 2879 | 2879 | |
| 2880 | 2880 | // Skip this topic if there are no posts |
| 2881 | 2881 | if (!$post = db_fetch_object($query)) { |
| 2882 | - // Empty topics should have already been filtered out of the import, so |
|
| 2883 | - // consider this an error condition |
|
| 2884 | - $empty_topics[] = $topic->id; |
|
| 2882 | + // Empty topics should have already been filtered out of the import, so |
|
| 2883 | + // consider this an error condition |
|
| 2884 | + $empty_topics[] = $topic->id; |
|
| 2885 | 2885 | } |
| 2886 | 2886 | else { |
| 2887 | - // Get the user ID along with other data to define the topic |
|
| 2888 | - $uid = boincuser_lookup_uid($topic->owner); |
|
| 2889 | - if (!$topic->owner) { |
|
| 2887 | + // Get the user ID along with other data to define the topic |
|
| 2888 | + $uid = boincuser_lookup_uid($topic->owner); |
|
| 2889 | + if (!$topic->owner) { |
|
| 2890 | 2890 | $uid = 0; |
| 2891 | - } |
|
| 2891 | + } |
|
| 2892 | 2892 | |
| 2893 | - $node_type = 'team_forum'; |
|
| 2894 | - $promote = 0; |
|
| 2895 | - $comment = ($topic->locked) ? 1 : 2; |
|
| 2893 | + $node_type = 'team_forum'; |
|
| 2894 | + $promote = 0; |
|
| 2895 | + $comment = ($topic->locked) ? 1 : 2; |
|
| 2896 | 2896 | |
| 2897 | - $post->content = _boincimport_strip_bbcode($post->content); |
|
| 2898 | - $post->content = _boincimport_text_sanitize($post->content); |
|
| 2899 | - $teaser = node_teaser($post->content); |
|
| 2897 | + $post->content = _boincimport_strip_bbcode($post->content); |
|
| 2898 | + $post->content = _boincimport_text_sanitize($post->content); |
|
| 2899 | + $teaser = node_teaser($post->content); |
|
| 2900 | 2900 | |
| 2901 | - if ($topic->timestamp < $topic->create_time) { |
|
| 2901 | + if ($topic->timestamp < $topic->create_time) { |
|
| 2902 | 2902 | $topic->timestamp = $topic->create_time; |
| 2903 | - } |
|
| 2903 | + } |
|
| 2904 | 2904 | |
| 2905 | - // Construct the thread as a team_forum topic node |
|
| 2906 | - $node = array( |
|
| 2905 | + // Construct the thread as a team_forum topic node |
|
| 2906 | + $node = array( |
|
| 2907 | 2907 | 'type' => $node_type, |
| 2908 | 2908 | 'title' => $topic->title, |
| 2909 | 2909 | 'uid' => $uid, |
@@ -2918,89 +2918,89 @@ discard block |
||
| 2918 | 2918 | 'format' => $input_format, |
| 2919 | 2919 | 'teaser' => $teaser, |
| 2920 | 2920 | 'tfid' => $team_forum_id, |
| 2921 | - ); |
|
| 2921 | + ); |
|
| 2922 | 2922 | |
| 2923 | - // Save the team topic node |
|
| 2924 | - $node = (object) $node; // node_save requires an object form |
|
| 2925 | - node_save($node); |
|
| 2923 | + // Save the team topic node |
|
| 2924 | + $node = (object) $node; // node_save requires an object form |
|
| 2925 | + node_save($node); |
|
| 2926 | 2926 | |
| 2927 | - if ($node->nid) { |
|
| 2927 | + if ($node->nid) { |
|
| 2928 | 2928 | db_query(' |
| 2929 | 2929 | INSERT INTO {boincimport_temp_topic} (topic_id, post_id, nid) |
| 2930 | 2930 | VALUES (%d, %d, %d)', |
| 2931 | - $topic->id, $post->id, $node->nid |
|
| 2931 | + $topic->id, $post->id, $node->nid |
|
| 2932 | 2932 | ); |
| 2933 | 2933 | // Hack to keep the topics in correct order |
| 2934 | 2934 | db_query(' |
| 2935 | 2935 | UPDATE {node_comment_statistics} |
| 2936 | 2936 | SET last_comment_timestamp = %d |
| 2937 | 2937 | WHERE nid = %d', |
| 2938 | - $node->created, $node->nid |
|
| 2938 | + $node->created, $node->nid |
|
| 2939 | 2939 | ); |
| 2940 | 2940 | $success = TRUE; |
| 2941 | - } |
|
| 2941 | + } |
|
| 2942 | + } |
|
| 2942 | 2943 | } |
| 2943 | - } |
|
| 2944 | 2944 | |
| 2945 | - $message = ''; |
|
| 2946 | - if ($success) { |
|
| 2945 | + $message = ''; |
|
| 2946 | + if ($success) { |
|
| 2947 | 2947 | // Store some result for post-processing in the finished callback. |
| 2948 | 2948 | $context['results']['success'][] = $topic->id; |
| 2949 | 2949 | $message = "Successfully imported team topic {$topic->id}"; |
| 2950 | - } |
|
| 2951 | - else { |
|
| 2950 | + } |
|
| 2951 | + else { |
|
| 2952 | 2952 | $context['results']['failure'][] = $topic->id; |
| 2953 | 2953 | $message = "Failed to import team topic {$topic->id}!"; |
| 2954 | 2954 | watchdog('boincimport', |
| 2955 | - 'Failed to import team topic @id!', |
|
| 2956 | - array('@id' => $topic->id), WATCHDOG_WARNING |
|
| 2955 | + 'Failed to import team topic @id!', |
|
| 2956 | + array('@id' => $topic->id), WATCHDOG_WARNING |
|
| 2957 | 2957 | ); |
| 2958 | - } |
|
| 2958 | + } |
|
| 2959 | 2959 | |
| 2960 | - // Update our progress information. |
|
| 2961 | - $context['sandbox']['progress']++; |
|
| 2962 | - $context['sandbox']['current_topic'] = $topic->id; |
|
| 2963 | - $context['message'] = $message; |
|
| 2960 | + // Update our progress information. |
|
| 2961 | + $context['sandbox']['progress']++; |
|
| 2962 | + $context['sandbox']['current_topic'] = $topic->id; |
|
| 2963 | + $context['message'] = $message; |
|
| 2964 | 2964 | |
| 2965 | - // Update the progress for the batch engine |
|
| 2966 | - if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 2965 | + // Update the progress for the batch engine |
|
| 2966 | + if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 2967 | 2967 | $context['finished'] = 1; |
| 2968 | - } |
|
| 2969 | - else { |
|
| 2968 | + } |
|
| 2969 | + else { |
|
| 2970 | 2970 | $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
| 2971 | - } |
|
| 2971 | + } |
|
| 2972 | 2972 | } |
| 2973 | 2973 | |
| 2974 | 2974 | /** |
| 2975 | 2975 | * Batch 'finished' callback |
| 2976 | 2976 | */ |
| 2977 | 2977 | function boincimport_team_topics_finished($success, $results, $operations) { |
| 2978 | - if ($success) { |
|
| 2978 | + if ($success) { |
|
| 2979 | 2979 | // Let's count our successes |
| 2980 | 2980 | $total_imported = count($results['success']); |
| 2981 | 2981 | $message = t( |
| 2982 | - 'Successfully imported @count team topics', |
|
| 2983 | - array('@count' => $total_imported) |
|
| 2982 | + 'Successfully imported @count team topics', |
|
| 2983 | + array('@count' => $total_imported) |
|
| 2984 | 2984 | ); |
| 2985 | 2985 | watchdog('boincimport', |
| 2986 | - 'Successfully imported @count team topics.', |
|
| 2987 | - array('@count' => $total_imported), WATCHDOG_INFO |
|
| 2986 | + 'Successfully imported @count team topics.', |
|
| 2987 | + array('@count' => $total_imported), WATCHDOG_INFO |
|
| 2988 | 2988 | ); |
| 2989 | 2989 | // Set the BLAH import successful flag in the variable table |
| 2990 | 2990 | variable_set('boincimport_import_team_topic_successful', '1'); |
| 2991 | 2991 | $_SESSION['boincimport_stage_selected'] = 'team posts'; |
| 2992 | - } |
|
| 2993 | - else { |
|
| 2992 | + } |
|
| 2993 | + else { |
|
| 2994 | 2994 | // An error occurred. |
| 2995 | 2995 | // $operations contains the operations that remained unprocessed. |
| 2996 | 2996 | $error_operation = reset($operations); |
| 2997 | 2997 | $message = 'An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE); |
| 2998 | - } |
|
| 2999 | - drupal_set_message($message); |
|
| 2998 | + } |
|
| 2999 | + drupal_set_message($message); |
|
| 3000 | 3000 | |
| 3001 | - // Release the lock on the import process |
|
| 3002 | - variable_del('boincimport_process_locked'); |
|
| 3003 | - drupal_goto('admin/boinc/import/process'); |
|
| 3001 | + // Release the lock on the import process |
|
| 3002 | + variable_del('boincimport_process_locked'); |
|
| 3003 | + drupal_goto('admin/boinc/import/process'); |
|
| 3004 | 3004 | } |
| 3005 | 3005 | |
| 3006 | 3006 | |
@@ -3013,81 +3013,81 @@ discard block |
||
| 3013 | 3013 | */ |
| 3014 | 3014 | function boincimport_team_forum_posts() { |
| 3015 | 3015 | |
| 3016 | - // Check whether team forum posts have been successfully imported already |
|
| 3017 | - if (variable_get('boincimport_import_team_post_successful', 0)) { |
|
| 3016 | + // Check whether team forum posts have been successfully imported already |
|
| 3017 | + if (variable_get('boincimport_import_team_post_successful', 0)) { |
|
| 3018 | 3018 | drupal_set_message(t('Team forum post import has already run successfully'), 'warning'); |
| 3019 | 3019 | watchdog( |
| 3020 | - 'boincimport', 'Team forum post import has already run successfully', |
|
| 3021 | - array(), WATCHDOG_WARNING |
|
| 3020 | + 'boincimport', 'Team forum post import has already run successfully', |
|
| 3021 | + array(), WATCHDOG_WARNING |
|
| 3022 | 3022 | ); |
| 3023 | 3023 | // Release the lock on the import process |
| 3024 | 3024 | variable_del('boincimport_process_locked'); |
| 3025 | 3025 | return; |
| 3026 | - } |
|
| 3026 | + } |
|
| 3027 | 3027 | |
| 3028 | - if (!variable_get('boincimport_import_team_post_started', 0)) { |
|
| 3028 | + if (!variable_get('boincimport_import_team_post_started', 0)) { |
|
| 3029 | 3029 | // Could prepare database tables, if new fields are necessary, etc. |
| 3030 | 3030 | variable_set('boincimport_import_team_post_started', 1); |
| 3031 | - } |
|
| 3031 | + } |
|
| 3032 | 3032 | |
| 3033 | - $pre = variable_get('boincimport_table_prefix', ''); |
|
| 3033 | + $pre = variable_get('boincimport_table_prefix', ''); |
|
| 3034 | 3034 | |
| 3035 | - // Get the BOINC threads and get a count of team posts to import |
|
| 3036 | - db_set_active('boinc_rw'); |
|
| 3037 | - $team_topic_ids = db_query(' |
|
| 3035 | + // Get the BOINC threads and get a count of team posts to import |
|
| 3036 | + db_set_active('boinc_rw'); |
|
| 3037 | + $team_topic_ids = db_query(' |
|
| 3038 | 3038 | SELECT DISTINCT t.id FROM %sthread t |
| 3039 | 3039 | JOIN %sforum f ON f.id = t.forum |
| 3040 | 3040 | JOIN %spost p ON p.thread = t.id |
| 3041 | 3041 | WHERE f.parent_type = 1 |
| 3042 | 3042 | ORDER BY id', $pre, $pre |
| 3043 | - ); |
|
| 3044 | - $team_topic_count = db_result(db_query(" |
|
| 3043 | + ); |
|
| 3044 | + $team_topic_count = db_result(db_query(" |
|
| 3045 | 3045 | SELECT COUNT(DISTINCT t.id) FROM %sthread t |
| 3046 | 3046 | JOIN %sforum f ON f.id = t.forum |
| 3047 | 3047 | JOIN %spost p ON p.thread = t.id |
| 3048 | 3048 | WHERE f.parent_type = 1", $pre, $pre, $pre |
| 3049 | - )); |
|
| 3050 | - $total_team_post_count = db_result(db_query(" |
|
| 3049 | + )); |
|
| 3050 | + $total_team_post_count = db_result(db_query(" |
|
| 3051 | 3051 | SELECT COUNT(p.id) FROM %spost p |
| 3052 | 3052 | JOIN %sthread t ON t.id = p.thread |
| 3053 | 3053 | JOIN %sforum f ON f.id = t.forum |
| 3054 | 3054 | WHERE f.parent_type = 1", $pre, $pre, $pre |
| 3055 | - )); |
|
| 3056 | - $team_post_count = $total_team_post_count - $team_topic_count; |
|
| 3057 | - db_set_active('default'); |
|
| 3055 | + )); |
|
| 3056 | + $team_post_count = $total_team_post_count - $team_topic_count; |
|
| 3057 | + db_set_active('default'); |
|
| 3058 | 3058 | |
| 3059 | - if ($team_post_count <= 0) { |
|
| 3059 | + if ($team_post_count <= 0) { |
|
| 3060 | 3060 | drupal_set_message( |
| 3061 | - t('There were no team posts found: Aborting script'), 'warning' |
|
| 3061 | + t('There were no team posts found: Aborting script'), 'warning' |
|
| 3062 | 3062 | ); |
| 3063 | 3063 | watchdog('boincimport', |
| 3064 | - 'There were no team posts found: Aborting script', array(), WATCHDOG_WARNING |
|
| 3064 | + 'There were no team posts found: Aborting script', array(), WATCHDOG_WARNING |
|
| 3065 | 3065 | ); |
| 3066 | 3066 | // Release the lock on the import process |
| 3067 | 3067 | variable_del('boincimport_process_locked'); |
| 3068 | 3068 | return t('There were no posts found: Aborting script.'); |
| 3069 | - } |
|
| 3069 | + } |
|
| 3070 | 3070 | |
| 3071 | - watchdog('boincimport', |
|
| 3071 | + watchdog('boincimport', |
|
| 3072 | 3072 | 'Found %count team posts: Beginning Import', |
| 3073 | 3073 | array('%count' => $team_post_count), WATCHDOG_INFO |
| 3074 | - ); |
|
| 3074 | + ); |
|
| 3075 | 3075 | |
| 3076 | - $operations = array(); |
|
| 3077 | - $existing_posts = array(); |
|
| 3078 | - $duplicates = array(); |
|
| 3076 | + $operations = array(); |
|
| 3077 | + $existing_posts = array(); |
|
| 3078 | + $duplicates = array(); |
|
| 3079 | 3079 | |
| 3080 | - // Get the list of team posts already in Drupal to be sure we're not |
|
| 3081 | - // importing any twice |
|
| 3082 | - $result = db_query(' |
|
| 3080 | + // Get the list of team posts already in Drupal to be sure we're not |
|
| 3081 | + // importing any twice |
|
| 3082 | + $result = db_query(' |
|
| 3083 | 3083 | SELECT cid, post_id FROM {boincimport_temp_post}' |
| 3084 | - ); |
|
| 3085 | - while ($row = db_fetch_object($result)) { |
|
| 3084 | + ); |
|
| 3085 | + while ($row = db_fetch_object($result)) { |
|
| 3086 | 3086 | $existing_posts[$row->post_id] = $row->cid; |
| 3087 | - } |
|
| 3087 | + } |
|
| 3088 | 3088 | |
| 3089 | - // Create batches to process |
|
| 3090 | - while ($boincteam_topic = db_fetch_object($team_topic_ids)) { |
|
| 3089 | + // Create batches to process |
|
| 3090 | + while ($boincteam_topic = db_fetch_object($team_topic_ids)) { |
|
| 3091 | 3091 | |
| 3092 | 3092 | db_set_active('boinc_rw'); |
| 3093 | 3093 | $boincteam_posts = db_query(' |
@@ -3095,7 +3095,7 @@ discard block |
||
| 3095 | 3095 | FROM %spost |
| 3096 | 3096 | WHERE thread = %d |
| 3097 | 3097 | ORDER BY timestamp ASC', |
| 3098 | - $pre, $boincteam_topic->id |
|
| 3098 | + $pre, $boincteam_topic->id |
|
| 3099 | 3099 | ); |
| 3100 | 3100 | db_set_active('default'); |
| 3101 | 3101 | |
@@ -3103,43 +3103,43 @@ discard block |
||
| 3103 | 3103 | |
| 3104 | 3104 | while ($boincteam_post = db_fetch_object($boincteam_posts)) { |
| 3105 | 3105 | |
| 3106 | - // Skip the first post as it has already been imported as a topic |
|
| 3107 | - if ($first_post) { |
|
| 3106 | + // Skip the first post as it has already been imported as a topic |
|
| 3107 | + if ($first_post) { |
|
| 3108 | 3108 | $first_post = false; |
| 3109 | 3109 | continue; |
| 3110 | - } |
|
| 3110 | + } |
|
| 3111 | 3111 | |
| 3112 | - if (isset($existing_posts[$boincteam_post->id])) { |
|
| 3112 | + if (isset($existing_posts[$boincteam_post->id])) { |
|
| 3113 | 3113 | // This post has already been imported |
| 3114 | 3114 | $duplicates[] = $boincteam_post->id; |
| 3115 | - } |
|
| 3116 | - else { |
|
| 3115 | + } |
|
| 3116 | + else { |
|
| 3117 | 3117 | $operations[] = array( |
| 3118 | - 'boincimport_team_posts_op', array( |
|
| 3118 | + 'boincimport_team_posts_op', array( |
|
| 3119 | 3119 | $boincteam_post |
| 3120 | - ) |
|
| 3120 | + ) |
|
| 3121 | 3121 | ); |
| 3122 | - } |
|
| 3122 | + } |
|
| 3123 | + } |
|
| 3123 | 3124 | } |
| 3124 | - } |
|
| 3125 | 3125 | |
| 3126 | - if ($duplicates) { |
|
| 3126 | + if ($duplicates) { |
|
| 3127 | 3127 | drupal_set_message(t( |
| 3128 | - 'Skipped @count team posts that were already imported', |
|
| 3129 | - array('@count' => count($duplicates)) |
|
| 3128 | + 'Skipped @count team posts that were already imported', |
|
| 3129 | + array('@count' => count($duplicates)) |
|
| 3130 | 3130 | )); |
| 3131 | - } |
|
| 3131 | + } |
|
| 3132 | 3132 | |
| 3133 | - $batch = array( |
|
| 3133 | + $batch = array( |
|
| 3134 | 3134 | 'operations' => $operations, |
| 3135 | 3135 | 'finished' => 'boincimport_team_posts_finished', |
| 3136 | 3136 | 'title' => t('Importing team posts'), |
| 3137 | 3137 | 'init_message' => t('Beginning team post import...'), |
| 3138 | 3138 | 'progress_message' => t('Processed @current out of @total team posts.'), |
| 3139 | 3139 | 'error_message' => t('Team post import has encountered an error.'), |
| 3140 | - ); |
|
| 3140 | + ); |
|
| 3141 | 3141 | |
| 3142 | - batch_set($batch); |
|
| 3142 | + batch_set($batch); |
|
| 3143 | 3143 | } |
| 3144 | 3144 | |
| 3145 | 3145 | /** |
@@ -3148,11 +3148,11 @@ discard block |
||
| 3148 | 3148 | */ |
| 3149 | 3149 | function boincimport_team_posts_op($post, &$context) { |
| 3150 | 3150 | |
| 3151 | - $input_format = variable_get('boincimport_input_format', 0); |
|
| 3152 | - $success = FALSE; |
|
| 3151 | + $input_format = variable_get('boincimport_input_format', 0); |
|
| 3152 | + $success = FALSE; |
|
| 3153 | 3153 | |
| 3154 | - // Make sure the post is valid |
|
| 3155 | - if ($post->content) { |
|
| 3154 | + // Make sure the post is valid |
|
| 3155 | + if ($post->content) { |
|
| 3156 | 3156 | |
| 3157 | 3157 | // Get user, node, and parent IDs for the post and sanitize |
| 3158 | 3158 | $uid = boincuser_lookup_uid($post->user); |
@@ -3161,14 +3161,14 @@ discard block |
||
| 3161 | 3161 | FROM {boincimport_temp_topic} btt |
| 3162 | 3162 | LEFT JOIN {node_revisions} AS nr ON btt.nid = nr.nid |
| 3163 | 3163 | WHERE btt.topic_id = %d', |
| 3164 | - $post->thread |
|
| 3164 | + $post->thread |
|
| 3165 | 3165 | )); |
| 3166 | 3166 | $nid = $node->nid; |
| 3167 | 3167 | $pid = db_result(db_query(' |
| 3168 | 3168 | SELECT cid |
| 3169 | 3169 | FROM {boincimport_temp_post} |
| 3170 | 3170 | WHERE post_id = %d', |
| 3171 | - $post->parent_post)); |
|
| 3171 | + $post->parent_post)); |
|
| 3172 | 3172 | if (is_null($pid)) $pid = 0; |
| 3173 | 3173 | if (!$uid) $uid = 0; |
| 3174 | 3174 | |
@@ -3179,110 +3179,110 @@ discard block |
||
| 3179 | 3179 | SELECT COUNT(*) |
| 3180 | 3180 | FROM {comments} |
| 3181 | 3181 | WHERE nid = %d', |
| 3182 | - $nid |
|
| 3182 | + $nid |
|
| 3183 | 3183 | )); |
| 3184 | 3184 | $post_reply = $pid; |
| 3185 | 3185 | |
| 3186 | 3186 | if ($post_reply OR $topic_reply) { |
| 3187 | - // Create a subject for the post from the post content. The body may be in |
|
| 3188 | - // any format, so we: |
|
| 3189 | - // 1) Filter it into HTML |
|
| 3190 | - // 2) Strip out all HTML tags |
|
| 3191 | - // 3) Convert entities back to plain-text. |
|
| 3192 | - // Note: format is checked by check_markup(). |
|
| 3193 | - $subject = truncate_utf8(trim(decode_entities(strip_tags(check_markup($post->content, $input_format)))), 29, TRUE); |
|
| 3194 | - // Replace "Quote:" with "RE:" |
|
| 3195 | - $subject = str_replace('Quote:', 'RE: ', $subject); |
|
| 3196 | - // Fringe cases where the comment body is populated only by HTML tags |
|
| 3197 | - // will require a default subject... |
|
| 3198 | - if ($subject === '') |
|
| 3187 | + // Create a subject for the post from the post content. The body may be in |
|
| 3188 | + // any format, so we: |
|
| 3189 | + // 1) Filter it into HTML |
|
| 3190 | + // 2) Strip out all HTML tags |
|
| 3191 | + // 3) Convert entities back to plain-text. |
|
| 3192 | + // Note: format is checked by check_markup(). |
|
| 3193 | + $subject = truncate_utf8(trim(decode_entities(strip_tags(check_markup($post->content, $input_format)))), 29, TRUE); |
|
| 3194 | + // Replace "Quote:" with "RE:" |
|
| 3195 | + $subject = str_replace('Quote:', 'RE: ', $subject); |
|
| 3196 | + // Fringe cases where the comment body is populated only by HTML tags |
|
| 3197 | + // will require a default subject... |
|
| 3198 | + if ($subject === '') |
|
| 3199 | 3199 | $subject = "RE: {$node->title}"; |
| 3200 | 3200 | } else { |
| 3201 | - // This is the first post in the topic |
|
| 3202 | - $subject = $node->title; |
|
| 3201 | + // This is the first post in the topic |
|
| 3202 | + $subject = $node->title; |
|
| 3203 | 3203 | } |
| 3204 | 3204 | |
| 3205 | 3205 | // Construct the post as a Drupal comment |
| 3206 | 3206 | $comment = array( |
| 3207 | - 'pid' => $pid, |
|
| 3208 | - 'nid' => $nid, |
|
| 3209 | - 'uid' => $uid, |
|
| 3210 | - 'subject' => $subject, |
|
| 3211 | - 'comment' => $post->content, |
|
| 3212 | - 'timestamp' => $post->timestamp, |
|
| 3213 | - 'status' => $post->hidden, |
|
| 3214 | - 'format' => $input_format |
|
| 3207 | + 'pid' => $pid, |
|
| 3208 | + 'nid' => $nid, |
|
| 3209 | + 'uid' => $uid, |
|
| 3210 | + 'subject' => $subject, |
|
| 3211 | + 'comment' => $post->content, |
|
| 3212 | + 'timestamp' => $post->timestamp, |
|
| 3213 | + 'status' => $post->hidden, |
|
| 3214 | + 'format' => $input_format |
|
| 3215 | 3215 | ); |
| 3216 | 3216 | |
| 3217 | 3217 | // Save the comment |
| 3218 | 3218 | if (boincimport_forum_comment_save($comment)) { |
| 3219 | - $success = db_query(' |
|
| 3219 | + $success = db_query(' |
|
| 3220 | 3220 | INSERT INTO {boincimport_temp_post} (post_id, cid) |
| 3221 | 3221 | VALUES (%d, %d)', |
| 3222 | 3222 | $post->id, $comment['cid'] |
| 3223 | - ); |
|
| 3223 | + ); |
|
| 3224 | + } |
|
| 3224 | 3225 | } |
| 3225 | - } |
|
| 3226 | 3226 | |
| 3227 | - $message = ''; |
|
| 3228 | - if ($success) { |
|
| 3227 | + $message = ''; |
|
| 3228 | + if ($success) { |
|
| 3229 | 3229 | // Store some result for post-processing in the finished callback. |
| 3230 | 3230 | $context['results']['success'][] = $post->id; |
| 3231 | 3231 | $message = "Successfully imported team post {$post->id}"; |
| 3232 | - } |
|
| 3233 | - else { |
|
| 3232 | + } |
|
| 3233 | + else { |
|
| 3234 | 3234 | $context['results']['failure'][] = $post->id; |
| 3235 | 3235 | $message = "Failed to import team post {$post->id}!"; |
| 3236 | 3236 | watchdog('boincimport', |
| 3237 | - 'Failed to import team post @id!', |
|
| 3238 | - array('@id' => $post->id), WATCHDOG_WARNING |
|
| 3237 | + 'Failed to import team post @id!', |
|
| 3238 | + array('@id' => $post->id), WATCHDOG_WARNING |
|
| 3239 | 3239 | ); |
| 3240 | - } |
|
| 3240 | + } |
|
| 3241 | 3241 | |
| 3242 | - // Update our progress information. |
|
| 3243 | - $context['sandbox']['progress']++; |
|
| 3244 | - $context['sandbox']['current_post'] = $post->id; |
|
| 3245 | - $context['message'] = $message; |
|
| 3242 | + // Update our progress information. |
|
| 3243 | + $context['sandbox']['progress']++; |
|
| 3244 | + $context['sandbox']['current_post'] = $post->id; |
|
| 3245 | + $context['message'] = $message; |
|
| 3246 | 3246 | |
| 3247 | - // Update the progress for the batch engine |
|
| 3248 | - if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 3247 | + // Update the progress for the batch engine |
|
| 3248 | + if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 3249 | 3249 | $context['finished'] = 1; |
| 3250 | - } |
|
| 3251 | - else { |
|
| 3250 | + } |
|
| 3251 | + else { |
|
| 3252 | 3252 | $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
| 3253 | - } |
|
| 3253 | + } |
|
| 3254 | 3254 | } |
| 3255 | 3255 | |
| 3256 | 3256 | /** |
| 3257 | 3257 | * Batch 'finished' callback |
| 3258 | 3258 | */ |
| 3259 | 3259 | function boincimport_team_posts_finished($success, $results, $operations) { |
| 3260 | - if ($success) { |
|
| 3260 | + if ($success) { |
|
| 3261 | 3261 | // Let's count our successes |
| 3262 | 3262 | $total_imported = count($results['success']); |
| 3263 | 3263 | $message = t( |
| 3264 | - 'Successfully imported @count team posts', |
|
| 3265 | - array('@count' => $total_imported) |
|
| 3264 | + 'Successfully imported @count team posts', |
|
| 3265 | + array('@count' => $total_imported) |
|
| 3266 | 3266 | ); |
| 3267 | 3267 | watchdog('boincimport', |
| 3268 | - 'Successfully imported @count team posts.', |
|
| 3269 | - array('@count' => $total_imported), WATCHDOG_INFO |
|
| 3268 | + 'Successfully imported @count team posts.', |
|
| 3269 | + array('@count' => $total_imported), WATCHDOG_INFO |
|
| 3270 | 3270 | ); |
| 3271 | 3271 | // Set the team post import successful flag in the variable table |
| 3272 | 3272 | variable_set('boincimport_import_team_post_successful', '1'); |
| 3273 | 3273 | $_SESSION['boincimport_stage_selected'] = 'url'; |
| 3274 | - } |
|
| 3275 | - else { |
|
| 3274 | + } |
|
| 3275 | + else { |
|
| 3276 | 3276 | // An error occurred. |
| 3277 | 3277 | // $operations contains the operations that remained unprocessed. |
| 3278 | 3278 | $error_operation = reset($operations); |
| 3279 | 3279 | $message = 'An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE); |
| 3280 | - } |
|
| 3281 | - drupal_set_message($message); |
|
| 3280 | + } |
|
| 3281 | + drupal_set_message($message); |
|
| 3282 | 3282 | |
| 3283 | - // Release the lock on the import process |
|
| 3284 | - variable_del('boincimport_process_locked'); |
|
| 3285 | - drupal_goto('admin/boinc/import/process'); |
|
| 3283 | + // Release the lock on the import process |
|
| 3284 | + variable_del('boincimport_process_locked'); |
|
| 3285 | + drupal_goto('admin/boinc/import/process'); |
|
| 3286 | 3286 | } |
| 3287 | 3287 | |
| 3288 | 3288 | |
@@ -3295,71 +3295,71 @@ discard block |
||
| 3295 | 3295 | */ |
| 3296 | 3296 | function boincimport_subscriptions() { |
| 3297 | 3297 | |
| 3298 | - // Check whether subscriptions have been successfully imported already |
|
| 3299 | - if (variable_get('boincimport_import_subscription_successful', 0)) { |
|
| 3298 | + // Check whether subscriptions have been successfully imported already |
|
| 3299 | + if (variable_get('boincimport_import_subscription_successful', 0)) { |
|
| 3300 | 3300 | drupal_set_message(t('Subscription import has already run successfully'), 'warning'); |
| 3301 | 3301 | watchdog( |
| 3302 | - 'boincimport', 'Subscription import has already run successfully', |
|
| 3303 | - array(), WATCHDOG_WARNING |
|
| 3302 | + 'boincimport', 'Subscription import has already run successfully', |
|
| 3303 | + array(), WATCHDOG_WARNING |
|
| 3304 | 3304 | ); |
| 3305 | - } |
|
| 3305 | + } |
|
| 3306 | 3306 | |
| 3307 | - if (!variable_get('boincimport_import_subscription_started', 0)) { |
|
| 3307 | + if (!variable_get('boincimport_import_subscription_started', 0)) { |
|
| 3308 | 3308 | // Could prepare database tables, if new fields are necessary, etc. |
| 3309 | 3309 | variable_set('boincimport_import_subscription_started', 1); |
| 3310 | - } |
|
| 3310 | + } |
|
| 3311 | 3311 | |
| 3312 | - $pre = variable_get('boincimport_table_prefix', ''); |
|
| 3312 | + $pre = variable_get('boincimport_table_prefix', ''); |
|
| 3313 | 3313 | |
| 3314 | - // Get users with subscriptions to import |
|
| 3315 | - db_set_active('boinc_rw'); |
|
| 3316 | - $users_with_subscriptions = db_query(' |
|
| 3314 | + // Get users with subscriptions to import |
|
| 3315 | + db_set_active('boinc_rw'); |
|
| 3316 | + $users_with_subscriptions = db_query(' |
|
| 3317 | 3317 | SELECT DISTINCT userid |
| 3318 | 3318 | FROM %ssubscriptions |
| 3319 | 3319 | ORDER BY userid ASC', |
| 3320 | 3320 | $pre |
| 3321 | - ); |
|
| 3322 | - $user_count = mysql_num_rows($users_with_subscriptions); |
|
| 3323 | - db_set_active('default'); |
|
| 3321 | + ); |
|
| 3322 | + $user_count = mysql_num_rows($users_with_subscriptions); |
|
| 3323 | + db_set_active('default'); |
|
| 3324 | 3324 | |
| 3325 | - if (!$user_count) { |
|
| 3325 | + if (!$user_count) { |
|
| 3326 | 3326 | drupal_set_message( |
| 3327 | - t('There were no subscriptions found: Aborting script'), 'warning' |
|
| 3327 | + t('There were no subscriptions found: Aborting script'), 'warning' |
|
| 3328 | 3328 | ); |
| 3329 | 3329 | watchdog('boincimport', |
| 3330 | - 'There were no subscriptions found: Aborting script', array(), WATCHDOG_WARNING |
|
| 3330 | + 'There were no subscriptions found: Aborting script', array(), WATCHDOG_WARNING |
|
| 3331 | 3331 | ); |
| 3332 | 3332 | // Release the lock on the import process |
| 3333 | 3333 | variable_del('boincimport_process_locked'); |
| 3334 | 3334 | return t('There were no subscriptions found: Aborting script.'); |
| 3335 | - } |
|
| 3335 | + } |
|
| 3336 | 3336 | |
| 3337 | - watchdog('boincimport', |
|
| 3337 | + watchdog('boincimport', |
|
| 3338 | 3338 | 'Found %count users with subscriptions: Beginning import', |
| 3339 | 3339 | array('%count' => $user_count), WATCHDOG_INFO |
| 3340 | - ); |
|
| 3340 | + ); |
|
| 3341 | 3341 | |
| 3342 | - $operations = array(); |
|
| 3342 | + $operations = array(); |
|
| 3343 | 3343 | |
| 3344 | - // Create batches to process |
|
| 3345 | - while ($subscribed_user = db_fetch_object($users_with_subscriptions)) { |
|
| 3344 | + // Create batches to process |
|
| 3345 | + while ($subscribed_user = db_fetch_object($users_with_subscriptions)) { |
|
| 3346 | 3346 | $operations[] = array( |
| 3347 | - 'boincimport_subscriptions_op', array( |
|
| 3347 | + 'boincimport_subscriptions_op', array( |
|
| 3348 | 3348 | $subscribed_user->userid |
| 3349 | - ) |
|
| 3349 | + ) |
|
| 3350 | 3350 | ); |
| 3351 | - } |
|
| 3351 | + } |
|
| 3352 | 3352 | |
| 3353 | - $batch = array( |
|
| 3353 | + $batch = array( |
|
| 3354 | 3354 | 'operations' => $operations, |
| 3355 | 3355 | 'finished' => 'boincimport_subscriptions_finished', |
| 3356 | 3356 | 'title' => t('Importing subscriptions'), |
| 3357 | 3357 | 'init_message' => t('Beginning subscription import...'), |
| 3358 | 3358 | 'progress_message' => t('Processed @current out of @total subscriptions.'), |
| 3359 | 3359 | 'error_message' => t('Subscription import has encountered an error.'), |
| 3360 | - ); |
|
| 3360 | + ); |
|
| 3361 | 3361 | |
| 3362 | - batch_set($batch); |
|
| 3362 | + batch_set($batch); |
|
| 3363 | 3363 | } |
| 3364 | 3364 | |
| 3365 | 3365 | /** |
@@ -3368,72 +3368,72 @@ discard block |
||
| 3368 | 3368 | */ |
| 3369 | 3369 | function boincimport_subscriptions_op($boincuser_id, &$context) { |
| 3370 | 3370 | |
| 3371 | - // Get the drupal user and pull subscriptions |
|
| 3372 | - $uid = get_drupal_id($boincuser_id); |
|
| 3373 | - $count = boincuser_pull_subscriptions($uid); |
|
| 3371 | + // Get the drupal user and pull subscriptions |
|
| 3372 | + $uid = get_drupal_id($boincuser_id); |
|
| 3373 | + $count = boincuser_pull_subscriptions($uid); |
|
| 3374 | 3374 | |
| 3375 | - $message = ''; |
|
| 3376 | - if ($count) { |
|
| 3375 | + $message = ''; |
|
| 3376 | + if ($count) { |
|
| 3377 | 3377 | // Store some result for post-processing in the finished callback. |
| 3378 | 3378 | $context['results']['success'][] = $boincuser_id; |
| 3379 | 3379 | $context['results']['subscriptions'][$boincuser_id] = $count; |
| 3380 | 3380 | $message = "Successfully imported {$count} subscriptions for user {$boincuser_id}"; |
| 3381 | - } |
|
| 3382 | - else { |
|
| 3381 | + } |
|
| 3382 | + else { |
|
| 3383 | 3383 | $context['results']['failure'][] = $boincuser_id; |
| 3384 | 3384 | $message = "Failed to import subscriptions for user {$boincuser_id}!"; |
| 3385 | 3385 | watchdog('boincimport', |
| 3386 | - 'Failed to import subscriptions for user @id!', |
|
| 3387 | - array('@id' => $boincuser_id), WATCHDOG_WARNING |
|
| 3386 | + 'Failed to import subscriptions for user @id!', |
|
| 3387 | + array('@id' => $boincuser_id), WATCHDOG_WARNING |
|
| 3388 | 3388 | ); |
| 3389 | - } |
|
| 3389 | + } |
|
| 3390 | 3390 | |
| 3391 | - // Update our progress information. |
|
| 3392 | - $context['sandbox']['progress']++; |
|
| 3393 | - $context['sandbox']['current_user'] = $boincuser_id; |
|
| 3394 | - $context['message'] = $message; |
|
| 3391 | + // Update our progress information. |
|
| 3392 | + $context['sandbox']['progress']++; |
|
| 3393 | + $context['sandbox']['current_user'] = $boincuser_id; |
|
| 3394 | + $context['message'] = $message; |
|
| 3395 | 3395 | |
| 3396 | - // Update the progress for the batch engine |
|
| 3397 | - if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 3396 | + // Update the progress for the batch engine |
|
| 3397 | + if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 3398 | 3398 | $context['finished'] = 1; |
| 3399 | - } |
|
| 3400 | - else { |
|
| 3399 | + } |
|
| 3400 | + else { |
|
| 3401 | 3401 | $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
| 3402 | - } |
|
| 3402 | + } |
|
| 3403 | 3403 | } |
| 3404 | 3404 | |
| 3405 | 3405 | /** |
| 3406 | 3406 | * Batch 'finished' callback |
| 3407 | 3407 | */ |
| 3408 | 3408 | function boincimport_subscriptions_finished($success, $results, $operations) { |
| 3409 | - if ($success) { |
|
| 3409 | + if ($success) { |
|
| 3410 | 3410 | // Let's count our successes |
| 3411 | 3411 | $user_count = count($results['success']); |
| 3412 | 3412 | $subscriptions_imported = array_sum($results['subscriptions']); |
| 3413 | 3413 | $message = t( |
| 3414 | - 'Successfully imported @count subscriptions for @distinct users', |
|
| 3415 | - array('@count' => $subscriptions_imported, '@distinct' => $user_count) |
|
| 3414 | + 'Successfully imported @count subscriptions for @distinct users', |
|
| 3415 | + array('@count' => $subscriptions_imported, '@distinct' => $user_count) |
|
| 3416 | 3416 | ); |
| 3417 | 3417 | watchdog('boincimport', |
| 3418 | - 'Successfully imported @count subscriptions for @distinct users.', |
|
| 3419 | - array('@count' => $subscriptions_imported, '@distinct' => $user_count), |
|
| 3420 | - WATCHDOG_INFO |
|
| 3418 | + 'Successfully imported @count subscriptions for @distinct users.', |
|
| 3419 | + array('@count' => $subscriptions_imported, '@distinct' => $user_count), |
|
| 3420 | + WATCHDOG_INFO |
|
| 3421 | 3421 | ); |
| 3422 | 3422 | // Set the subscription import successful flag in the variable table |
| 3423 | 3423 | variable_set('boincimport_import_subscription_successful', '1'); |
| 3424 | 3424 | $_SESSION['boincimport_stage_selected'] = 'url'; |
| 3425 | - } |
|
| 3426 | - else { |
|
| 3425 | + } |
|
| 3426 | + else { |
|
| 3427 | 3427 | // An error occurred. |
| 3428 | 3428 | // $operations contains the operations that remained unprocessed. |
| 3429 | 3429 | $error_operation = reset($operations); |
| 3430 | 3430 | $message = 'An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE); |
| 3431 | - } |
|
| 3432 | - drupal_set_message($message); |
|
| 3431 | + } |
|
| 3432 | + drupal_set_message($message); |
|
| 3433 | 3433 | |
| 3434 | - // Release the lock on the import process |
|
| 3435 | - variable_del('boincimport_process_locked'); |
|
| 3436 | - drupal_goto('admin/boinc/import/process'); |
|
| 3434 | + // Release the lock on the import process |
|
| 3435 | + variable_del('boincimport_process_locked'); |
|
| 3436 | + drupal_goto('admin/boinc/import/process'); |
|
| 3437 | 3437 | } |
| 3438 | 3438 | |
| 3439 | 3439 | |
@@ -3445,112 +3445,112 @@ discard block |
||
| 3445 | 3445 | */ |
| 3446 | 3446 | function boincimport_replace_urls() { |
| 3447 | 3447 | |
| 3448 | - // Check whether URLs have already been fixed |
|
| 3449 | - if (variable_get('boincimport_replace_url_successful', 0)) { |
|
| 3448 | + // Check whether URLs have already been fixed |
|
| 3449 | + if (variable_get('boincimport_replace_url_successful', 0)) { |
|
| 3450 | 3450 | drupal_set_message(t('URLs have already been updated'), 'warning'); |
| 3451 | 3451 | watchdog( |
| 3452 | - 'boincimport', 'URLs have already been updated', |
|
| 3453 | - array(), WATCHDOG_WARNING |
|
| 3452 | + 'boincimport', 'URLs have already been updated', |
|
| 3453 | + array(), WATCHDOG_WARNING |
|
| 3454 | 3454 | ); |
| 3455 | - } |
|
| 3455 | + } |
|
| 3456 | 3456 | |
| 3457 | - if (!variable_get('boincimport_replace_url_started', 0)) { |
|
| 3457 | + if (!variable_get('boincimport_replace_url_started', 0)) { |
|
| 3458 | 3458 | // Could prepare database tables, if new fields are necessary, etc. |
| 3459 | 3459 | variable_set('boincimport_replace_url_started', 1); |
| 3460 | - } |
|
| 3460 | + } |
|
| 3461 | 3461 | |
| 3462 | - // Get the count of nodes and comments to process for URL updates |
|
| 3463 | - $node_count = db_result(db_query(' |
|
| 3462 | + // Get the count of nodes and comments to process for URL updates |
|
| 3463 | + $node_count = db_result(db_query(' |
|
| 3464 | 3464 | SELECT COUNT(DISTINCT btt.nid) |
| 3465 | 3465 | FROM {boincimport_temp_topic} AS btt |
| 3466 | 3466 | LEFT JOIN {node_revisions} AS nr ON btt.nid = nr.nid' |
| 3467 | - )); |
|
| 3467 | + )); |
|
| 3468 | 3468 | |
| 3469 | - $comment_count = db_result(db_query(' |
|
| 3469 | + $comment_count = db_result(db_query(' |
|
| 3470 | 3470 | SELECT COUNT(c.cid) |
| 3471 | 3471 | FROM {boincimport_temp_post} AS p |
| 3472 | 3472 | LEFT JOIN {comments} AS c ON p.cid = c.cid' |
| 3473 | - )); |
|
| 3473 | + )); |
|
| 3474 | 3474 | |
| 3475 | - $pm_count = db_result(db_query(' |
|
| 3475 | + $pm_count = db_result(db_query(' |
|
| 3476 | 3476 | SELECT COUNT(*) |
| 3477 | 3477 | FROM {pm_message} pm' |
| 3478 | - )); |
|
| 3478 | + )); |
|
| 3479 | 3479 | |
| 3480 | - if (!$node_count AND !$comment_count AND !$pm_count) { |
|
| 3480 | + if (!$node_count AND !$comment_count AND !$pm_count) { |
|
| 3481 | 3481 | drupal_set_message( |
| 3482 | - t('There were no nodes, comments, or private messages found: Aborting script'), 'warning' |
|
| 3482 | + t('There were no nodes, comments, or private messages found: Aborting script'), 'warning' |
|
| 3483 | 3483 | ); |
| 3484 | 3484 | watchdog('boincimport', |
| 3485 | - 'There were no nodes,comments, or private messages found: Aborting script', array(), WATCHDOG_WARNING |
|
| 3485 | + 'There were no nodes,comments, or private messages found: Aborting script', array(), WATCHDOG_WARNING |
|
| 3486 | 3486 | ); |
| 3487 | 3487 | // Release the lock on the import process |
| 3488 | 3488 | variable_del('boincimport_process_locked'); |
| 3489 | 3489 | return t('There were no nodes, comments, or private messages found: Aborting script.'); |
| 3490 | - } |
|
| 3490 | + } |
|
| 3491 | 3491 | |
| 3492 | - watchdog('boincimport', |
|
| 3492 | + watchdog('boincimport', |
|
| 3493 | 3493 | 'Found %node_count nodes, %comment_count comments, and %pm_count private messages: Updating URLs...', |
| 3494 | 3494 | array( |
| 3495 | - '%node_count' => $node_count, |
|
| 3496 | - '%comment_count' => $comment_count, |
|
| 3497 | - '%pm_count' => $pm_count, |
|
| 3495 | + '%node_count' => $node_count, |
|
| 3496 | + '%comment_count' => $comment_count, |
|
| 3497 | + '%pm_count' => $pm_count, |
|
| 3498 | 3498 | ), |
| 3499 | 3499 | WATCHDOG_INFO |
| 3500 | - ); |
|
| 3500 | + ); |
|
| 3501 | 3501 | |
| 3502 | - $operations = array(); |
|
| 3503 | - $batch_size = 100; |
|
| 3502 | + $operations = array(); |
|
| 3503 | + $batch_size = 100; |
|
| 3504 | 3504 | |
| 3505 | - // Create node batches to process |
|
| 3506 | - for ($offset = 0; $offset < $node_count; $offset+=$batch_size) { |
|
| 3505 | + // Create node batches to process |
|
| 3506 | + for ($offset = 0; $offset < $node_count; $offset+=$batch_size) { |
|
| 3507 | 3507 | $nodes_per_batch = $batch_size; |
| 3508 | 3508 | if ($offset + $batch_size > $node_count) { |
| 3509 | - $nodes_per_batch = $node_count - $offset; |
|
| 3509 | + $nodes_per_batch = $node_count - $offset; |
|
| 3510 | 3510 | } |
| 3511 | 3511 | $operations[] = array( |
| 3512 | - 'boincimport_replace_urls_node_op', array( |
|
| 3512 | + 'boincimport_replace_urls_node_op', array( |
|
| 3513 | 3513 | $offset, $nodes_per_batch |
| 3514 | - ) |
|
| 3514 | + ) |
|
| 3515 | 3515 | ); |
| 3516 | - } |
|
| 3517 | - // Add comment batches |
|
| 3518 | - for ($offset = 0; $offset < $comment_count; $offset+=$batch_size) { |
|
| 3516 | + } |
|
| 3517 | + // Add comment batches |
|
| 3518 | + for ($offset = 0; $offset < $comment_count; $offset+=$batch_size) { |
|
| 3519 | 3519 | $comments_per_batch = $batch_size; |
| 3520 | 3520 | if ($offset + $batch_size > $comment_count) { |
| 3521 | - $comments_per_batch = $comment_count - $offset; |
|
| 3521 | + $comments_per_batch = $comment_count - $offset; |
|
| 3522 | 3522 | } |
| 3523 | 3523 | $operations[] = array( |
| 3524 | - 'boincimport_replace_urls_comment_op', array( |
|
| 3524 | + 'boincimport_replace_urls_comment_op', array( |
|
| 3525 | 3525 | $offset, $comments_per_batch |
| 3526 | - ) |
|
| 3526 | + ) |
|
| 3527 | 3527 | ); |
| 3528 | - } |
|
| 3529 | - // And don't forget to process private messages |
|
| 3530 | - for ($offset = 0; $offset < $pm_count; $offset+=$batch_size) { |
|
| 3528 | + } |
|
| 3529 | + // And don't forget to process private messages |
|
| 3530 | + for ($offset = 0; $offset < $pm_count; $offset+=$batch_size) { |
|
| 3531 | 3531 | $messages_per_batch = $batch_size; |
| 3532 | 3532 | if ($offset + $batch_size > $pm_count) { |
| 3533 | - $messages_per_batch = $pm_count - $offset; |
|
| 3533 | + $messages_per_batch = $pm_count - $offset; |
|
| 3534 | 3534 | } |
| 3535 | 3535 | $operations[] = array( |
| 3536 | - 'boincimport_replace_urls_pm_op', array( |
|
| 3536 | + 'boincimport_replace_urls_pm_op', array( |
|
| 3537 | 3537 | $offset, $messages_per_batch |
| 3538 | - ) |
|
| 3538 | + ) |
|
| 3539 | 3539 | ); |
| 3540 | - } |
|
| 3540 | + } |
|
| 3541 | 3541 | |
| 3542 | - $batch = array( |
|
| 3542 | + $batch = array( |
|
| 3543 | 3543 | 'operations' => $operations, |
| 3544 | 3544 | 'finished' => 'boincimport_replace_urls_finished', |
| 3545 | 3545 | 'title' => t('Updating URLs...'), |
| 3546 | 3546 | 'init_message' => t('Beginning URL update...'), |
| 3547 | 3547 | 'progress_message' => t('Processed URLs in @current out of @total batches (@size items per batch).', array( |
| 3548 | - '@size' => $batch_size, |
|
| 3548 | + '@size' => $batch_size, |
|
| 3549 | 3549 | )), |
| 3550 | 3550 | 'error_message' => t('URL update has encountered an error.'), |
| 3551 | - ); |
|
| 3551 | + ); |
|
| 3552 | 3552 | |
| 3553 | - batch_set($batch); |
|
| 3553 | + batch_set($batch); |
|
| 3554 | 3554 | } |
| 3555 | 3555 | |
| 3556 | 3556 | /** |
@@ -3558,27 +3558,27 @@ discard block |
||
| 3558 | 3558 | * Find URLs for the old system and update them with Drupal paths |
| 3559 | 3559 | */ |
| 3560 | 3560 | function boincimport_replace_urls_node_op($offset, $batch_size, &$context) { |
| 3561 | - // Initialize the batch, if needed |
|
| 3562 | - if (!isset($context['sandbox']['progress'])) { |
|
| 3561 | + // Initialize the batch, if needed |
|
| 3562 | + if (!isset($context['sandbox']['progress'])) { |
|
| 3563 | 3563 | $context['sandbox']['progress'] = 0; |
| 3564 | 3564 | $context['sandbox']['max'] = $batch_size; |
| 3565 | - } |
|
| 3565 | + } |
|
| 3566 | 3566 | |
| 3567 | - $input_format = variable_get('boincimport_input_format', 0); |
|
| 3567 | + $input_format = variable_get('boincimport_input_format', 0); |
|
| 3568 | 3568 | |
| 3569 | - // Since topics have just been imported, there should be only one vid for |
|
| 3570 | - // each nid, so we can update node_revisions by nid |
|
| 3571 | - // Get nodes to process |
|
| 3572 | - $nodes = db_query(' |
|
| 3569 | + // Since topics have just been imported, there should be only one vid for |
|
| 3570 | + // each nid, so we can update node_revisions by nid |
|
| 3571 | + // Get nodes to process |
|
| 3572 | + $nodes = db_query(' |
|
| 3573 | 3573 | SELECT btt.nid, nr.body, nr.teaser |
| 3574 | 3574 | FROM {boincimport_temp_topic} AS btt |
| 3575 | 3575 | LEFT JOIN {node_revisions} AS nr ON btt.nid = nr.nid |
| 3576 | 3576 | ORDER BY btt.nid |
| 3577 | 3577 | LIMIT %d,%d', |
| 3578 | 3578 | $offset, $batch_size |
| 3579 | - ); |
|
| 3579 | + ); |
|
| 3580 | 3580 | |
| 3581 | - while ($node = db_fetch_object($nodes)) { |
|
| 3581 | + while ($node = db_fetch_object($nodes)) { |
|
| 3582 | 3582 | $updated = FALSE; |
| 3583 | 3583 | |
| 3584 | 3584 | // Update URLs in node contents |
@@ -3587,23 +3587,23 @@ discard block |
||
| 3587 | 3587 | $node->body = _boincimport_replace_links($node->body); |
| 3588 | 3588 | $node->teaser = _boincimport_replace_links($node->teaser); |
| 3589 | 3589 | if ($node->body != $original_body OR $node->teaser != $original_teaser) { |
| 3590 | - $updated = db_query(" |
|
| 3590 | + $updated = db_query(" |
|
| 3591 | 3591 | UPDATE {node_revisions} |
| 3592 | 3592 | SET body= '%s', teaser = '%s' |
| 3593 | 3593 | WHERE nid = %d", |
| 3594 | 3594 | $node->body, $node->teaser, $node->nid |
| 3595 | - ); |
|
| 3595 | + ); |
|
| 3596 | 3596 | } |
| 3597 | 3597 | |
| 3598 | 3598 | $message = ''; |
| 3599 | 3599 | $context['results']['success'][] = $node->nid; |
| 3600 | 3600 | if ($updated) { |
| 3601 | - // Store some result for post-processing in the finished callback. |
|
| 3602 | - $context['results']['nodes']['updated'][] = $node->nid; |
|
| 3603 | - $message = "Successfully updated node {$node->nid}"; |
|
| 3601 | + // Store some result for post-processing in the finished callback. |
|
| 3602 | + $context['results']['nodes']['updated'][] = $node->nid; |
|
| 3603 | + $message = "Successfully updated node {$node->nid}"; |
|
| 3604 | 3604 | } |
| 3605 | 3605 | else { |
| 3606 | - $message = "No changes made to node {$node->nid}!"; |
|
| 3606 | + $message = "No changes made to node {$node->nid}!"; |
|
| 3607 | 3607 | } |
| 3608 | 3608 | |
| 3609 | 3609 | // Update our progress information. |
@@ -3613,12 +3613,12 @@ discard block |
||
| 3613 | 3613 | |
| 3614 | 3614 | // Update the progress for the batch engine |
| 3615 | 3615 | if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
| 3616 | - $context['finished'] = 1; |
|
| 3616 | + $context['finished'] = 1; |
|
| 3617 | 3617 | } |
| 3618 | 3618 | else { |
| 3619 | - $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
|
| 3619 | + $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
|
| 3620 | + } |
|
| 3620 | 3621 | } |
| 3621 | - } |
|
| 3622 | 3622 | } |
| 3623 | 3623 | |
| 3624 | 3624 | /** |
@@ -3626,48 +3626,48 @@ discard block |
||
| 3626 | 3626 | * Find URLs for the old system and update them with Drupal paths |
| 3627 | 3627 | */ |
| 3628 | 3628 | function boincimport_replace_urls_comment_op($offset, $batch_size, &$context) { |
| 3629 | - // Initialize the batch, if needed |
|
| 3630 | - if (!isset($context['sandbox']['progress'])) { |
|
| 3629 | + // Initialize the batch, if needed |
|
| 3630 | + if (!isset($context['sandbox']['progress'])) { |
|
| 3631 | 3631 | $context['sandbox']['progress'] = 0; |
| 3632 | 3632 | $context['sandbox']['max'] = $batch_size; |
| 3633 | - } |
|
| 3633 | + } |
|
| 3634 | 3634 | |
| 3635 | - $input_format = variable_get('boincimport_input_format', 0); |
|
| 3635 | + $input_format = variable_get('boincimport_input_format', 0); |
|
| 3636 | 3636 | |
| 3637 | - // Get comments to process |
|
| 3638 | - $comments = db_query(' |
|
| 3637 | + // Get comments to process |
|
| 3638 | + $comments = db_query(' |
|
| 3639 | 3639 | SELECT c.cid, c.comment |
| 3640 | 3640 | FROM {boincimport_temp_post} AS p |
| 3641 | 3641 | LEFT JOIN {comments} AS c ON p.cid = c.cid |
| 3642 | 3642 | ORDER BY c.cid |
| 3643 | 3643 | LIMIT %d,%d', |
| 3644 | 3644 | $offset, $batch_size |
| 3645 | - ); |
|
| 3645 | + ); |
|
| 3646 | 3646 | |
| 3647 | - while ($comment = db_fetch_object($comments)) { |
|
| 3647 | + while ($comment = db_fetch_object($comments)) { |
|
| 3648 | 3648 | $updated = FALSE; |
| 3649 | 3649 | |
| 3650 | 3650 | // Update URLs in comment contents |
| 3651 | 3651 | $original_comment = $comment->comment; |
| 3652 | 3652 | $comment->comment = _boincimport_replace_links($comment->comment); |
| 3653 | 3653 | if ($comment->comment != $original_comment) { |
| 3654 | - $updated = db_query(" |
|
| 3654 | + $updated = db_query(" |
|
| 3655 | 3655 | UPDATE {comments} |
| 3656 | 3656 | SET comment= '%s' |
| 3657 | 3657 | WHERE cid = %d", |
| 3658 | 3658 | $comment->comment, $comment->cid |
| 3659 | - ); |
|
| 3659 | + ); |
|
| 3660 | 3660 | } |
| 3661 | 3661 | |
| 3662 | 3662 | $message = ''; |
| 3663 | 3663 | $context['results']['success'][] = $comment->cid; |
| 3664 | 3664 | if ($updated) { |
| 3665 | - // Store some result for post-processing in the finished callback. |
|
| 3666 | - $context['results']['comments']['updated'][] = $comment->cid; |
|
| 3667 | - $message = "Successfully updated comment {$comment->cid}"; |
|
| 3665 | + // Store some result for post-processing in the finished callback. |
|
| 3666 | + $context['results']['comments']['updated'][] = $comment->cid; |
|
| 3667 | + $message = "Successfully updated comment {$comment->cid}"; |
|
| 3668 | 3668 | } |
| 3669 | 3669 | else { |
| 3670 | - $message = "No changes made to comment {$comment->cid}!"; |
|
| 3670 | + $message = "No changes made to comment {$comment->cid}!"; |
|
| 3671 | 3671 | } |
| 3672 | 3672 | |
| 3673 | 3673 | // Update our progress information. |
@@ -3677,12 +3677,12 @@ discard block |
||
| 3677 | 3677 | |
| 3678 | 3678 | // Update the progress for the batch engine |
| 3679 | 3679 | if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
| 3680 | - $context['finished'] = 1; |
|
| 3680 | + $context['finished'] = 1; |
|
| 3681 | 3681 | } |
| 3682 | 3682 | else { |
| 3683 | - $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
|
| 3683 | + $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
|
| 3684 | + } |
|
| 3684 | 3685 | } |
| 3685 | - } |
|
| 3686 | 3686 | } |
| 3687 | 3687 | |
| 3688 | 3688 | /** |
@@ -3690,47 +3690,47 @@ discard block |
||
| 3690 | 3690 | * Find URLs for the old system and update them with Drupal paths |
| 3691 | 3691 | */ |
| 3692 | 3692 | function boincimport_replace_urls_pm_op($offset, $batch_size, &$context) { |
| 3693 | - // Initialize the batch, if needed |
|
| 3694 | - if (!isset($context['sandbox']['progress'])) { |
|
| 3693 | + // Initialize the batch, if needed |
|
| 3694 | + if (!isset($context['sandbox']['progress'])) { |
|
| 3695 | 3695 | $context['sandbox']['progress'] = 0; |
| 3696 | 3696 | $context['sandbox']['max'] = $batch_size; |
| 3697 | - } |
|
| 3697 | + } |
|
| 3698 | 3698 | |
| 3699 | - $input_format = variable_get('boincimport_input_format', 0); |
|
| 3699 | + $input_format = variable_get('boincimport_input_format', 0); |
|
| 3700 | 3700 | |
| 3701 | - // Get private messages to process |
|
| 3702 | - $messages = db_query(' |
|
| 3701 | + // Get private messages to process |
|
| 3702 | + $messages = db_query(' |
|
| 3703 | 3703 | SELECT pm.mid, pm.body |
| 3704 | 3704 | FROM {pm_message} pm |
| 3705 | 3705 | ORDER BY pm.mid |
| 3706 | 3706 | LIMIT %d,%d', |
| 3707 | 3707 | $offset, $batch_size |
| 3708 | - ); |
|
| 3708 | + ); |
|
| 3709 | 3709 | |
| 3710 | - while ($pm = db_fetch_object($messages)) { |
|
| 3710 | + while ($pm = db_fetch_object($messages)) { |
|
| 3711 | 3711 | $updated = FALSE; |
| 3712 | 3712 | |
| 3713 | 3713 | // Update URLs in private message body |
| 3714 | 3714 | $original_pm_body = $pm->body; |
| 3715 | 3715 | $pm->body = _boincimport_replace_links($pm->body); |
| 3716 | 3716 | if ($pm->body != $original_pm_body) { |
| 3717 | - $updated = db_query(" |
|
| 3717 | + $updated = db_query(" |
|
| 3718 | 3718 | UPDATE {pm_message} |
| 3719 | 3719 | SET body= '%s' |
| 3720 | 3720 | WHERE mid = %d", |
| 3721 | 3721 | $pm->body, $pm->mid |
| 3722 | - ); |
|
| 3722 | + ); |
|
| 3723 | 3723 | } |
| 3724 | 3724 | |
| 3725 | 3725 | $message = ''; |
| 3726 | 3726 | $context['results']['success'][] = $pm->mid; |
| 3727 | 3727 | if ($updated) { |
| 3728 | - // Store some result for post-processing in the finished callback. |
|
| 3729 | - $context['results']['pm']['updated'][] = $pm->mid; |
|
| 3730 | - $message = "Successfully updated private message {$pm->mid}"; |
|
| 3728 | + // Store some result for post-processing in the finished callback. |
|
| 3729 | + $context['results']['pm']['updated'][] = $pm->mid; |
|
| 3730 | + $message = "Successfully updated private message {$pm->mid}"; |
|
| 3731 | 3731 | } |
| 3732 | 3732 | else { |
| 3733 | - $message = "No changes made to private message {$pm->mid}!"; |
|
| 3733 | + $message = "No changes made to private message {$pm->mid}!"; |
|
| 3734 | 3734 | } |
| 3735 | 3735 | |
| 3736 | 3736 | // Update our progress information. |
@@ -3740,85 +3740,85 @@ discard block |
||
| 3740 | 3740 | |
| 3741 | 3741 | // Update the progress for the batch engine |
| 3742 | 3742 | if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
| 3743 | - $context['finished'] = 1; |
|
| 3743 | + $context['finished'] = 1; |
|
| 3744 | 3744 | } |
| 3745 | 3745 | else { |
| 3746 | - $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
|
| 3746 | + $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
|
| 3747 | + } |
|
| 3747 | 3748 | } |
| 3748 | - } |
|
| 3749 | 3749 | } |
| 3750 | 3750 | |
| 3751 | 3751 | /** |
| 3752 | 3752 | * Batch 'finished' callback |
| 3753 | 3753 | */ |
| 3754 | 3754 | function boincimport_replace_urls_finished($success, $results, $operations) { |
| 3755 | - if ($success) { |
|
| 3755 | + if ($success) { |
|
| 3756 | 3756 | // Let's count our successes |
| 3757 | 3757 | $total_processed = count($results['success']); |
| 3758 | 3758 | $nodes_updated = count($results['nodes']['updated']); |
| 3759 | 3759 | $comments_updated = count($results['comments']['updated']); |
| 3760 | 3760 | $private_messages_updated = count($results['pm']['updated']); |
| 3761 | 3761 | $message = t( |
| 3762 | - 'Successfully processed @count nodes, comments, and private messages (@nodes_updated nodes, @comments_updated comments, and @pm_updated private messages were updated)', |
|
| 3763 | - array( |
|
| 3762 | + 'Successfully processed @count nodes, comments, and private messages (@nodes_updated nodes, @comments_updated comments, and @pm_updated private messages were updated)', |
|
| 3763 | + array( |
|
| 3764 | 3764 | '@count' => $total_processed, |
| 3765 | 3765 | '@nodes_updated' => $nodes_updated, |
| 3766 | 3766 | '@comments_updated' => $comments_updated, |
| 3767 | 3767 | '@pm_updated' => $private_messages_updated, |
| 3768 | - ) |
|
| 3768 | + ) |
|
| 3769 | 3769 | ); |
| 3770 | 3770 | if ($private_messages_updated) { |
| 3771 | - watchdog('boincimport', |
|
| 3771 | + watchdog('boincimport', |
|
| 3772 | 3772 | 'Updated URLs in these private_messages: @mid_list', |
| 3773 | 3773 | array( |
| 3774 | - '@mid_list' => implode(', ', $results['pm']['updated']), |
|
| 3774 | + '@mid_list' => implode(', ', $results['pm']['updated']), |
|
| 3775 | 3775 | ), |
| 3776 | 3776 | WATCHDOG_INFO |
| 3777 | - ); |
|
| 3777 | + ); |
|
| 3778 | 3778 | } |
| 3779 | 3779 | if ($comments_updated) { |
| 3780 | - watchdog('boincimport', |
|
| 3780 | + watchdog('boincimport', |
|
| 3781 | 3781 | 'Updated URLs in these comments: @cid_list', |
| 3782 | 3782 | array( |
| 3783 | - '@cid_list' => implode(', ', $results['comments']['updated']), |
|
| 3783 | + '@cid_list' => implode(', ', $results['comments']['updated']), |
|
| 3784 | 3784 | ), |
| 3785 | 3785 | WATCHDOG_INFO |
| 3786 | - ); |
|
| 3786 | + ); |
|
| 3787 | 3787 | } |
| 3788 | 3788 | if ($nodes_updated) { |
| 3789 | - watchdog('boincimport', |
|
| 3789 | + watchdog('boincimport', |
|
| 3790 | 3790 | 'Updated URLs in these nodes: @nid_list', |
| 3791 | 3791 | array( |
| 3792 | - '@nid_list' => implode(', ', $results['nodes']['updated']), |
|
| 3792 | + '@nid_list' => implode(', ', $results['nodes']['updated']), |
|
| 3793 | 3793 | ), |
| 3794 | 3794 | WATCHDOG_INFO |
| 3795 | - ); |
|
| 3795 | + ); |
|
| 3796 | 3796 | } |
| 3797 | 3797 | watchdog('boincimport', |
| 3798 | - 'Successfully processed @count nodes, comments, and private messages (@nodes_updated nodes, @comments_updated comments, and @pm_updated private messages were updated)', |
|
| 3799 | - array( |
|
| 3798 | + 'Successfully processed @count nodes, comments, and private messages (@nodes_updated nodes, @comments_updated comments, and @pm_updated private messages were updated)', |
|
| 3799 | + array( |
|
| 3800 | 3800 | '@count' => $total_processed, |
| 3801 | 3801 | '@nodes_updated' => $nodes_updated, |
| 3802 | 3802 | '@comments_updated' => $comments_updated, |
| 3803 | 3803 | '@pm_updated' => $private_messages_updated, |
| 3804 | - ), |
|
| 3805 | - WATCHDOG_INFO |
|
| 3804 | + ), |
|
| 3805 | + WATCHDOG_INFO |
|
| 3806 | 3806 | ); |
| 3807 | 3807 | // Set the replace URLs successful flag in the variable table |
| 3808 | 3808 | variable_set('boincimport_replace_urls_successful', '1'); |
| 3809 | 3809 | $_SESSION['boincimport_stage_selected'] = 'users'; |
| 3810 | - } |
|
| 3811 | - else { |
|
| 3810 | + } |
|
| 3811 | + else { |
|
| 3812 | 3812 | // An error occurred. |
| 3813 | 3813 | // $operations contains the operations that remained unprocessed. |
| 3814 | 3814 | $error_operation = reset($operations); |
| 3815 | 3815 | $message = 'An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE); |
| 3816 | - } |
|
| 3817 | - drupal_set_message($message); |
|
| 3816 | + } |
|
| 3817 | + drupal_set_message($message); |
|
| 3818 | 3818 | |
| 3819 | - // Release the lock on the import process |
|
| 3820 | - variable_del('boincimport_process_locked'); |
|
| 3821 | - drupal_goto('admin/boinc/import/process'); |
|
| 3819 | + // Release the lock on the import process |
|
| 3820 | + variable_del('boincimport_process_locked'); |
|
| 3821 | + drupal_goto('admin/boinc/import/process'); |
|
| 3822 | 3822 | } |
| 3823 | 3823 | |
| 3824 | 3824 | |
@@ -3830,43 +3830,43 @@ discard block |
||
| 3830 | 3830 | * Remove temporary variables, clear caches, etc. |
| 3831 | 3831 | */ |
| 3832 | 3832 | function boincimport_process_cleanup() { |
| 3833 | - db_set_active('default'); |
|
| 3834 | - |
|
| 3835 | - variable_del('boincimport_base_url_boinc'); |
|
| 3836 | - variable_del('boincimport_base_url_drupal'); |
|
| 3837 | - variable_del('boincimport_import_user_successful'); |
|
| 3838 | - variable_del('boincimport_import_user_started'); |
|
| 3839 | - variable_del('boincimport_import_team_successful'); |
|
| 3840 | - variable_del('boincimport_import_team_started'); |
|
| 3841 | - variable_del('boincimport_import_category_successful'); |
|
| 3842 | - variable_del('boincimport_replace_url_successful'); |
|
| 3843 | - variable_del('boincimport_import_category_started'); |
|
| 3844 | - variable_del('boincimport_import_topic_successful'); |
|
| 3845 | - variable_del('boincimport_import_topic_started'); |
|
| 3846 | - variable_del('boincimport_import_post_successful'); |
|
| 3847 | - variable_del('boincimport_import_post_started'); |
|
| 3848 | - variable_del('boincimport_team_forum_successful'); |
|
| 3849 | - variable_del('boincimport_team_topic_successful'); |
|
| 3850 | - variable_del('boincimport_team_post_successful'); |
|
| 3851 | - variable_del('boincimport_team_post_started'); |
|
| 3852 | - variable_del('boincimport_ready'); |
|
| 3853 | - variable_del('boincimport_db_url'); |
|
| 3854 | - variable_del('boincimport_tested'); |
|
| 3855 | - variable_del('boincimport_db_configured'); |
|
| 3856 | - variable_del('boincimport_table_prefix'); |
|
| 3857 | - variable_del('boincimport_team_types'); |
|
| 3858 | - variable_del('boincimport_time_limit'); |
|
| 3859 | - variable_del('boincimport_import_lurkers'); |
|
| 3860 | - variable_del('boincimport_import_polls'); |
|
| 3861 | - variable_del('boincimport_import_poll_started'); |
|
| 3862 | - variable_del('boincimport_import_poll_successful'); |
|
| 3863 | - variable_del('boincimport_import_pm_successful'); |
|
| 3864 | - variable_del('boincimport_encode'); |
|
| 3865 | - variable_del('boincimport_encoding_phpbb'); |
|
| 3866 | - variable_del('boincimport_encoding_drupal'); |
|
| 3867 | - variable_del('boincimport_version'); |
|
| 3868 | - |
|
| 3869 | - db_query('DELETE FROM {cache}'); |
|
| 3833 | + db_set_active('default'); |
|
| 3834 | + |
|
| 3835 | + variable_del('boincimport_base_url_boinc'); |
|
| 3836 | + variable_del('boincimport_base_url_drupal'); |
|
| 3837 | + variable_del('boincimport_import_user_successful'); |
|
| 3838 | + variable_del('boincimport_import_user_started'); |
|
| 3839 | + variable_del('boincimport_import_team_successful'); |
|
| 3840 | + variable_del('boincimport_import_team_started'); |
|
| 3841 | + variable_del('boincimport_import_category_successful'); |
|
| 3842 | + variable_del('boincimport_replace_url_successful'); |
|
| 3843 | + variable_del('boincimport_import_category_started'); |
|
| 3844 | + variable_del('boincimport_import_topic_successful'); |
|
| 3845 | + variable_del('boincimport_import_topic_started'); |
|
| 3846 | + variable_del('boincimport_import_post_successful'); |
|
| 3847 | + variable_del('boincimport_import_post_started'); |
|
| 3848 | + variable_del('boincimport_team_forum_successful'); |
|
| 3849 | + variable_del('boincimport_team_topic_successful'); |
|
| 3850 | + variable_del('boincimport_team_post_successful'); |
|
| 3851 | + variable_del('boincimport_team_post_started'); |
|
| 3852 | + variable_del('boincimport_ready'); |
|
| 3853 | + variable_del('boincimport_db_url'); |
|
| 3854 | + variable_del('boincimport_tested'); |
|
| 3855 | + variable_del('boincimport_db_configured'); |
|
| 3856 | + variable_del('boincimport_table_prefix'); |
|
| 3857 | + variable_del('boincimport_team_types'); |
|
| 3858 | + variable_del('boincimport_time_limit'); |
|
| 3859 | + variable_del('boincimport_import_lurkers'); |
|
| 3860 | + variable_del('boincimport_import_polls'); |
|
| 3861 | + variable_del('boincimport_import_poll_started'); |
|
| 3862 | + variable_del('boincimport_import_poll_successful'); |
|
| 3863 | + variable_del('boincimport_import_pm_successful'); |
|
| 3864 | + variable_del('boincimport_encode'); |
|
| 3865 | + variable_del('boincimport_encoding_phpbb'); |
|
| 3866 | + variable_del('boincimport_encoding_drupal'); |
|
| 3867 | + variable_del('boincimport_version'); |
|
| 3868 | + |
|
| 3869 | + db_query('DELETE FROM {cache}'); |
|
| 3870 | 3870 | } |
| 3871 | 3871 | |
| 3872 | 3872 | /** |
@@ -3874,15 +3874,15 @@ discard block |
||
| 3874 | 3874 | */ |
| 3875 | 3875 | |
| 3876 | 3876 | function boincimport_forum_comment_save(&$edit) { |
| 3877 | - // Here we are building the thread field. See the comment in comment_render(). |
|
| 3878 | - if ($edit['pid'] == 0) { |
|
| 3877 | + // Here we are building the thread field. See the comment in comment_render(). |
|
| 3878 | + if ($edit['pid'] == 0) { |
|
| 3879 | 3879 | // This is a comment with no parent comment (depth 0): we start by retrieving |
| 3880 | 3880 | // the maximum thread level. |
| 3881 | 3881 | $max = db_result(db_query('SELECT MAX(thread) FROM {comments} WHERE nid = %d', $edit['nid'])); |
| 3882 | 3882 | // Strip the "/" from the end of the thread. |
| 3883 | 3883 | $max = rtrim($max, '/'); |
| 3884 | 3884 | $thread = int2vancode(vancode2int($max)+1) .'/'; |
| 3885 | - } else { |
|
| 3885 | + } else { |
|
| 3886 | 3886 | // This is comment with a parent comment: we increase the part of the thread |
| 3887 | 3887 | // value at the proper depth. |
| 3888 | 3888 | $parent = db_fetch_object(db_query('SELECT * FROM {comments} WHERE cid = %d', $edit['pid'])); |
@@ -3891,71 +3891,71 @@ discard block |
||
| 3891 | 3891 | // Get the max value in _this_ thread. |
| 3892 | 3892 | $max = db_result(db_query("SELECT MAX(thread) FROM {comments} WHERE thread LIKE '%s.%%' AND nid = %d", $parent->thread, $edit['nid'])); |
| 3893 | 3893 | if ($max == '') { |
| 3894 | - // First child of this parent. |
|
| 3895 | - $thread = $parent->thread .'.'. int2vancode(1) .'/'; |
|
| 3894 | + // First child of this parent. |
|
| 3895 | + $thread = $parent->thread .'.'. int2vancode(1) .'/'; |
|
| 3896 | 3896 | } else { |
| 3897 | - // Strip the "/" at the end of the thread. |
|
| 3898 | - $max = rtrim($max, '/'); |
|
| 3899 | - // We need to get the value at the correct depth. |
|
| 3900 | - $parts = explode('.', $max); |
|
| 3901 | - $parent_depth = count(explode('.', $parent->thread)); |
|
| 3902 | - $last = $parts[$parent_depth]; |
|
| 3903 | - // Finally, build the thread field for this new comment. |
|
| 3904 | - $thread = $parent->thread .'.'. int2vancode(vancode2int($last) + 1) .'/'; |
|
| 3897 | + // Strip the "/" at the end of the thread. |
|
| 3898 | + $max = rtrim($max, '/'); |
|
| 3899 | + // We need to get the value at the correct depth. |
|
| 3900 | + $parts = explode('.', $max); |
|
| 3901 | + $parent_depth = count(explode('.', $parent->thread)); |
|
| 3902 | + $last = $parts[$parent_depth]; |
|
| 3903 | + // Finally, build the thread field for this new comment. |
|
| 3904 | + $thread = $parent->thread .'.'. int2vancode(vancode2int($last) + 1) .'/'; |
|
| 3905 | + } |
|
| 3905 | 3906 | } |
| 3906 | - } |
|
| 3907 | 3907 | |
| 3908 | - $status = 0; // 1 - not published, 0 - published |
|
| 3909 | - $format = variable_get('boincimport_input_format', 0); |
|
| 3910 | - $score = 0; // 0 default value, comments get higher score depending on the author's roles |
|
| 3911 | - $users = serialize(array(0 => 1)); // default value for everybody!! |
|
| 3908 | + $status = 0; // 1 - not published, 0 - published |
|
| 3909 | + $format = variable_get('boincimport_input_format', 0); |
|
| 3910 | + $score = 0; // 0 default value, comments get higher score depending on the author's roles |
|
| 3911 | + $users = serialize(array(0 => 1)); // default value for everybody!! |
|
| 3912 | 3912 | |
| 3913 | - if ($edit['uid'] === $user->uid) { // '===' because we want to modify anonymous users too |
|
| 3913 | + if ($edit['uid'] === $user->uid) { // '===' because we want to modify anonymous users too |
|
| 3914 | 3914 | $edit['name'] = $user->name; |
| 3915 | - } |
|
| 3915 | + } |
|
| 3916 | 3916 | |
| 3917 | - $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']); |
|
| 3918 | - if ($success) { |
|
| 3917 | + $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']); |
|
| 3918 | + if ($success) { |
|
| 3919 | 3919 | $edit['cid'] = db_last_insert_id('comments', 'cid'); |
| 3920 | 3920 | _comment_update_node_statistics($edit['nid']); |
| 3921 | - } |
|
| 3922 | - return $success; |
|
| 3921 | + } |
|
| 3922 | + return $success; |
|
| 3923 | 3923 | } |
| 3924 | 3924 | |
| 3925 | 3925 | /** |
| 3926 | 3926 | * Strips text of extra phpbb3 markup and if requested, also strips all bbcode from text. |
| 3927 | 3927 | */ |
| 3928 | 3928 | function _boincimport_strip_bbcode($text) { |
| 3929 | - // Strip the text of extra markup - regular expressions taken from phpbb3 includes/function.php, function get_preg_expression(). |
|
| 3930 | - $match = array( |
|
| 3929 | + // Strip the text of extra markup - regular expressions taken from phpbb3 includes/function.php, function get_preg_expression(). |
|
| 3930 | + $match = array( |
|
| 3931 | 3931 | '#<!\-\- e \-\-><a href="mailto:(.*?)">.*?</a><!\-\- e \-\->#', |
| 3932 | 3932 | '#<!\-\- l \-\-><a (?:class="[\w-]+" )?href="(.*?)(?:(&|\?)sid=[0-9a-f]{32})?">.*?</a><!\-\- l \-\->#', |
| 3933 | 3933 | '#<!\-\- ([mw]) \-\-><a (?:class="[\w-]+" )?href="(.*?)">.*?</a><!\-\- \1 \-\->#', |
| 3934 | 3934 | '#<!\-\- s(.*?) \-\-><img src="\{SMILIES_PATH\}\/.*? \/><!\-\- s\1 \-\->#', |
| 3935 | 3935 | '#<!\-\- .*? \-\->#s', |
| 3936 | 3936 | '#<.*?>#s', |
| 3937 | - ); |
|
| 3938 | - $replace = array('$1', '$1', '$2', '$1', '', ''); |
|
| 3939 | - $text = preg_replace($match, $replace, $text); |
|
| 3937 | + ); |
|
| 3938 | + $replace = array('$1', '$1', '$2', '$1', '', ''); |
|
| 3939 | + $text = preg_replace($match, $replace, $text); |
|
| 3940 | 3940 | |
| 3941 | - // If BBcode conversion to has been selected, the following will convert the |
|
| 3942 | - // BBcode to normal html |
|
| 3943 | - if (variable_get('boincimport_bbcode', 0)) { |
|
| 3941 | + // If BBcode conversion to has been selected, the following will convert the |
|
| 3942 | + // BBcode to normal html |
|
| 3943 | + if (variable_get('boincimport_bbcode', 0)) { |
|
| 3944 | 3944 | $input_format = variable_get('boincimport_input_format', 0); |
| 3945 | 3945 | $text = bbcode_filter('process', 0 , $input_format, $text); |
| 3946 | - } |
|
| 3947 | - return $text; |
|
| 3946 | + } |
|
| 3947 | + return $text; |
|
| 3948 | 3948 | } |
| 3949 | 3949 | |
| 3950 | 3950 | /** |
| 3951 | 3951 | * Function to properly encode strings. |
| 3952 | 3952 | */ |
| 3953 | 3953 | function _boincimport_text_sanitize($text) { |
| 3954 | - $input_format = variable_get('boincimport_input_format', 0); |
|
| 3955 | - $text = html_entity_decode($text, ENT_QUOTES, 'utf-8'); |
|
| 3956 | - // Be sure the text is filtered for the default input format |
|
| 3957 | - $text = check_markup($text, $input_format); |
|
| 3958 | - return $text; |
|
| 3954 | + $input_format = variable_get('boincimport_input_format', 0); |
|
| 3955 | + $text = html_entity_decode($text, ENT_QUOTES, 'utf-8'); |
|
| 3956 | + // Be sure the text is filtered for the default input format |
|
| 3957 | + $text = check_markup($text, $input_format); |
|
| 3958 | + return $text; |
|
| 3959 | 3959 | } |
| 3960 | 3960 | |
| 3961 | 3961 | |
@@ -3964,25 +3964,25 @@ discard block |
||
| 3964 | 3964 | */ |
| 3965 | 3965 | function _boincimport_replace_links($html) { |
| 3966 | 3966 | |
| 3967 | - $transformer = new BoincImportUrlTransformer(); |
|
| 3968 | - |
|
| 3969 | - // Update links to posts, threads, and forums |
|
| 3970 | - $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)forum_thread\.php\?id=(\d+)&postid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformPostLinks'), $html); |
|
| 3971 | - $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)forum_thread\.php\?id=(\d+)(&\w+=\w*)*?(#(\d+)?)}i', array($transformer, 'transformOldPostLinks'), $html); |
|
| 3972 | - $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)forum_thread\.php\?id=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformTopicLinks'), $html); |
|
| 3973 | - $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)forum_forum\.php\?id=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformForumLinks'), $html); |
|
| 3974 | - $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)show_user\.php\?userid=(\d+)((&\w+=\w*)+)?}i', array($transformer, 'transformUserLinks'), $html); |
|
| 3975 | - $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)workunit\.php\?wuid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformWorkUnitLinks'), $html); |
|
| 3976 | - $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)result\.php\?resultid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformResultLinks'), $html); |
|
| 3977 | - $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)results\.php\?userid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformUserResultsLinks'), $html); |
|
| 3978 | - $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)results\.php\?hostid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformHostResultsLinks'), $html); |
|
| 3979 | - $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)show_host_detail\.php\?hostid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformHostLinks'), $html); |
|
| 3980 | - $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)hosts_user\.php\?userid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformUserHostsLinks'), $html); |
|
| 3981 | - |
|
| 3982 | - // Update any links to the top level index |
|
| 3983 | - $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)forum_index.php}i', array($transformer, 'transformForumIndexLinks'), $html); |
|
| 3984 | - |
|
| 3985 | - return $html; |
|
| 3967 | + $transformer = new BoincImportUrlTransformer(); |
|
| 3968 | + |
|
| 3969 | + // Update links to posts, threads, and forums |
|
| 3970 | + $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)forum_thread\.php\?id=(\d+)&postid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformPostLinks'), $html); |
|
| 3971 | + $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)forum_thread\.php\?id=(\d+)(&\w+=\w*)*?(#(\d+)?)}i', array($transformer, 'transformOldPostLinks'), $html); |
|
| 3972 | + $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)forum_thread\.php\?id=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformTopicLinks'), $html); |
|
| 3973 | + $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)forum_forum\.php\?id=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformForumLinks'), $html); |
|
| 3974 | + $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)show_user\.php\?userid=(\d+)((&\w+=\w*)+)?}i', array($transformer, 'transformUserLinks'), $html); |
|
| 3975 | + $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)workunit\.php\?wuid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformWorkUnitLinks'), $html); |
|
| 3976 | + $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)result\.php\?resultid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformResultLinks'), $html); |
|
| 3977 | + $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)results\.php\?userid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformUserResultsLinks'), $html); |
|
| 3978 | + $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)results\.php\?hostid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformHostResultsLinks'), $html); |
|
| 3979 | + $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)show_host_detail\.php\?hostid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformHostLinks'), $html); |
|
| 3980 | + $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)hosts_user\.php\?userid=(\d+)(&\w+=\w*)*?}i', array($transformer, 'transformUserHostsLinks'), $html); |
|
| 3981 | + |
|
| 3982 | + // Update any links to the top level index |
|
| 3983 | + $html = preg_replace_callback('{(?:(http|https)://([^\s]*?)|href="(?:/)?)forum_index.php}i', array($transformer, 'transformForumIndexLinks'), $html); |
|
| 3984 | + |
|
| 3985 | + return $html; |
|
| 3986 | 3986 | } |
| 3987 | 3987 | |
| 3988 | 3988 | /** |
@@ -3990,14 +3990,14 @@ discard block |
||
| 3990 | 3990 | */ |
| 3991 | 3991 | class BoincImportUrlTransformer { |
| 3992 | 3992 | |
| 3993 | - var $basePath; |
|
| 3994 | - var $boincDomain; |
|
| 3995 | - var $drupalDomain; |
|
| 3993 | + var $basePath; |
|
| 3994 | + var $boincDomain; |
|
| 3995 | + var $drupalDomain; |
|
| 3996 | 3996 | |
| 3997 | - /** |
|
| 3998 | - * Constructor |
|
| 3999 | - */ |
|
| 4000 | - function BoincImportUrlTransformer() { |
|
| 3997 | + /** |
|
| 3998 | + * Constructor |
|
| 3999 | + */ |
|
| 4000 | + function BoincImportUrlTransformer() { |
|
| 4001 | 4001 | global $base_url; |
| 4002 | 4002 | global $base_path; |
| 4003 | 4003 | $boinc_base_urls = variable_get('boincimport_base_url_boinc', ''); |
@@ -4007,203 +4007,203 @@ discard block |
||
| 4007 | 4007 | $this->boincDomains = array(); |
| 4008 | 4008 | $boinc_base_urls = preg_split('/\s+/', $boinc_base_urls); |
| 4009 | 4009 | foreach ($boinc_base_urls as $url) { |
| 4010 | - $domain = parse_url($url, PHP_URL_HOST); |
|
| 4011 | - if ($domain) { |
|
| 4010 | + $domain = parse_url($url, PHP_URL_HOST); |
|
| 4011 | + if ($domain) { |
|
| 4012 | 4012 | $this->boincDomains[$domain] = TRUE; |
| 4013 | - } |
|
| 4013 | + } |
|
| 4014 | 4014 | } |
| 4015 | 4015 | if (!$this->boincDomains) { |
| 4016 | - watchdog('boincimport', 'No valid BOINC base URLs found to transform!', |
|
| 4016 | + watchdog('boincimport', 'No valid BOINC base URLs found to transform!', |
|
| 4017 | 4017 | array(), WATCHDOG_WARNING); |
| 4018 | 4018 | } |
| 4019 | - } |
|
| 4019 | + } |
|
| 4020 | 4020 | |
| 4021 | - /** |
|
| 4022 | - * Get what the new base URL should be (needed for every transformation) |
|
| 4023 | - */ |
|
| 4024 | - function getNewBaseUrl($matches) { |
|
| 4021 | + /** |
|
| 4022 | + * Get what the new base URL should be (needed for every transformation) |
|
| 4023 | + */ |
|
| 4024 | + function getNewBaseUrl($matches) { |
|
| 4025 | 4025 | $http = $matches[1]; |
| 4026 | 4026 | $domain = trim($matches[2], '/'); |
| 4027 | 4027 | if ($http) { |
| 4028 | - if (isset($this->boincDomains[$domain])) { |
|
| 4028 | + if (isset($this->boincDomains[$domain])) { |
|
| 4029 | 4029 | // This is a URL configured to be transformed |
| 4030 | 4030 | return "{$http}://{$this->drupalDomain}{$this->basePath}"; |
| 4031 | - } |
|
| 4032 | - else { |
|
| 4031 | + } |
|
| 4032 | + else { |
|
| 4033 | 4033 | // This URL should not be transformed |
| 4034 | 4034 | return NULL; |
| 4035 | - } |
|
| 4035 | + } |
|
| 4036 | 4036 | } |
| 4037 | 4037 | else { |
| 4038 | - // This is a relative URL |
|
| 4039 | - return $this->basePath; |
|
| 4038 | + // This is a relative URL |
|
| 4039 | + return $this->basePath; |
|
| 4040 | + } |
|
| 4040 | 4041 | } |
| 4041 | - } |
|
| 4042 | 4042 | |
| 4043 | - /** |
|
| 4044 | - * Replace links to specific posts. If the given post is the first in the |
|
| 4045 | - * thread, it is a topic node in Drupal, not a comment. |
|
| 4046 | - */ |
|
| 4047 | - function transformPostLinks($matches) { |
|
| 4043 | + /** |
|
| 4044 | + * Replace links to specific posts. If the given post is the first in the |
|
| 4045 | + * thread, it is a topic node in Drupal, not a comment. |
|
| 4046 | + */ |
|
| 4047 | + function transformPostLinks($matches) { |
|
| 4048 | 4048 | $link = $matches[0]; |
| 4049 | 4049 | $newBaseUrl = $this->getNewBaseUrl($matches); |
| 4050 | 4050 | if ($newBaseUrl !== NULL) { |
| 4051 | - $id = db_result(db_query(' |
|
| 4051 | + $id = db_result(db_query(' |
|
| 4052 | 4052 | SELECT p.cid |
| 4053 | 4053 | FROM {boincimport_temp_post} p |
| 4054 | 4054 | WHERE p.post_id = %d', |
| 4055 | 4055 | $matches[4] |
| 4056 | - )); |
|
| 4057 | - if ($id) { |
|
| 4056 | + )); |
|
| 4057 | + if ($id) { |
|
| 4058 | 4058 | $link = "{$newBaseUrl}goto/comment/{$id}"; |
| 4059 | - } |
|
| 4060 | - else { |
|
| 4059 | + } |
|
| 4060 | + else { |
|
| 4061 | 4061 | // This post is not in the post import table, so it's probably a topic |
| 4062 | 4062 | $link = $this->transformTopicLinks($matches); |
| 4063 | - } |
|
| 4063 | + } |
|
| 4064 | 4064 | } |
| 4065 | 4065 | return $link; |
| 4066 | - } |
|
| 4066 | + } |
|
| 4067 | 4067 | |
| 4068 | - /** |
|
| 4069 | - * Replace links that include anchors to specific posts. If the given post is |
|
| 4070 | - * the first in the thread, it is a topic node in Drupal, not a comment. |
|
| 4071 | - */ |
|
| 4072 | - function transformOldPostLinks($matches) { |
|
| 4068 | + /** |
|
| 4069 | + * Replace links that include anchors to specific posts. If the given post is |
|
| 4070 | + * the first in the thread, it is a topic node in Drupal, not a comment. |
|
| 4071 | + */ |
|
| 4072 | + function transformOldPostLinks($matches) { |
|
| 4073 | 4073 | $link = $matches[0]; |
| 4074 | 4074 | $newBaseUrl = $this->getNewBaseUrl($matches); |
| 4075 | 4075 | if ($newBaseUrl !== NULL) { |
| 4076 | - $id = db_result(db_query(' |
|
| 4076 | + $id = db_result(db_query(' |
|
| 4077 | 4077 | SELECT p.cid |
| 4078 | 4078 | FROM {boincimport_temp_post} p |
| 4079 | 4079 | WHERE p.post_id = %d', |
| 4080 | 4080 | $matches[6] |
| 4081 | - )); |
|
| 4082 | - if ($id) { |
|
| 4081 | + )); |
|
| 4082 | + if ($id) { |
|
| 4083 | 4083 | $link = "{$newBaseUrl}goto/comment/{$id}"; |
| 4084 | - } |
|
| 4085 | - else { |
|
| 4084 | + } |
|
| 4085 | + else { |
|
| 4086 | 4086 | // This post is not in the post import table, so it's probably a topic |
| 4087 | 4087 | $link = $this->transformTopicLinks($matches); |
| 4088 | - } |
|
| 4088 | + } |
|
| 4089 | 4089 | } |
| 4090 | 4090 | return $link; |
| 4091 | - } |
|
| 4091 | + } |
|
| 4092 | 4092 | |
| 4093 | - function transformTopicLinks($matches) { |
|
| 4093 | + function transformTopicLinks($matches) { |
|
| 4094 | 4094 | $link = $matches[0]; |
| 4095 | 4095 | $newBaseUrl = $this->getNewBaseUrl($matches); |
| 4096 | 4096 | if ($newBaseUrl !== NULL) { |
| 4097 | - $id = db_result(db_query(' |
|
| 4097 | + $id = db_result(db_query(' |
|
| 4098 | 4098 | SELECT nid |
| 4099 | 4099 | FROM {boincimport_temp_topic} |
| 4100 | 4100 | WHERE topic_id = %d', |
| 4101 | 4101 | $matches[3] |
| 4102 | - )); |
|
| 4103 | - $link = "{$newBaseUrl}node/{$id}"; |
|
| 4102 | + )); |
|
| 4103 | + $link = "{$newBaseUrl}node/{$id}"; |
|
| 4104 | 4104 | } |
| 4105 | 4105 | return $link; |
| 4106 | - } |
|
| 4106 | + } |
|
| 4107 | 4107 | |
| 4108 | - function transformForumLinks($matches) { |
|
| 4108 | + function transformForumLinks($matches) { |
|
| 4109 | 4109 | $link = $matches[0]; |
| 4110 | 4110 | $newBaseUrl = $this->getNewBaseUrl($matches); |
| 4111 | 4111 | if ($newBaseUrl !== NULL) { |
| 4112 | - $forum = db_fetch_object(db_query(' |
|
| 4112 | + $forum = db_fetch_object(db_query(' |
|
| 4113 | 4113 | SELECT tid |
| 4114 | 4114 | FROM {boincimport_temp_forum} |
| 4115 | 4115 | WHERE forum_id = %d', |
| 4116 | 4116 | $matches[3] |
| 4117 | - )); |
|
| 4118 | - $link = "{$newBaseUrl}community/forum/{$forum->tid}"; |
|
| 4117 | + )); |
|
| 4118 | + $link = "{$newBaseUrl}community/forum/{$forum->tid}"; |
|
| 4119 | 4119 | } |
| 4120 | 4120 | return $link; |
| 4121 | - } |
|
| 4121 | + } |
|
| 4122 | 4122 | |
| 4123 | - function transformUserLinks($matches) { |
|
| 4123 | + function transformUserLinks($matches) { |
|
| 4124 | 4124 | $link = $matches[0]; |
| 4125 | 4125 | $newBaseUrl = $this->getNewBaseUrl($matches); |
| 4126 | 4126 | if ($newBaseUrl !== NULL) { |
| 4127 | - // Make sure this isn't an RPC link (no need to transform those) |
|
| 4128 | - if (!$matches[5]) { |
|
| 4127 | + // Make sure this isn't an RPC link (no need to transform those) |
|
| 4128 | + if (!$matches[5]) { |
|
| 4129 | 4129 | // TODO: This regex doesn't seem to capture the format=xml part of the |
| 4130 | 4130 | // URL, making it impossible to distinguish if this is an RPC or not... |
| 4131 | 4131 | //watchdog('DEBUG', 'matches: @m', array('@m' => print_r($matches,true)), WATCHDOG_DEBUG); |
| 4132 | 4132 | $uid = boincuser_lookup_uid($matches[3]); |
| 4133 | 4133 | $link = "{$newBaseUrl}account/{$uid}"; |
| 4134 | - } |
|
| 4134 | + } |
|
| 4135 | 4135 | } |
| 4136 | 4136 | return $link; |
| 4137 | - } |
|
| 4137 | + } |
|
| 4138 | 4138 | |
| 4139 | - function transformWorkUnitLinks($matches) { |
|
| 4139 | + function transformWorkUnitLinks($matches) { |
|
| 4140 | 4140 | $link = $matches[0]; |
| 4141 | 4141 | $newBaseUrl = $this->getNewBaseUrl($matches); |
| 4142 | 4142 | if ($newBaseUrl !== NULL) { |
| 4143 | - $id = $matches[3]; |
|
| 4144 | - $link = "{$newBaseUrl}workunit/{$id}"; |
|
| 4143 | + $id = $matches[3]; |
|
| 4144 | + $link = "{$newBaseUrl}workunit/{$id}"; |
|
| 4145 | 4145 | } |
| 4146 | 4146 | return $link; |
| 4147 | - } |
|
| 4147 | + } |
|
| 4148 | 4148 | |
| 4149 | - function transformResultLinks($matches) { |
|
| 4149 | + function transformResultLinks($matches) { |
|
| 4150 | 4150 | $link = $matches[0]; |
| 4151 | 4151 | $newBaseUrl = $this->getNewBaseUrl($matches); |
| 4152 | 4152 | if ($newBaseUrl !== NULL) { |
| 4153 | - $id = $matches[3]; |
|
| 4154 | - $link = "{$newBaseUrl}task/{$id}"; |
|
| 4153 | + $id = $matches[3]; |
|
| 4154 | + $link = "{$newBaseUrl}task/{$id}"; |
|
| 4155 | 4155 | } |
| 4156 | 4156 | return $link; |
| 4157 | - } |
|
| 4157 | + } |
|
| 4158 | 4158 | |
| 4159 | - function transformHostResultsLinks($matches) { |
|
| 4159 | + function transformHostResultsLinks($matches) { |
|
| 4160 | 4160 | $link = $matches[0]; |
| 4161 | 4161 | $newBaseUrl = $this->getNewBaseUrl($matches); |
| 4162 | 4162 | if ($newBaseUrl !== NULL) { |
| 4163 | - $id = $matches[3]; |
|
| 4164 | - $link = "{$newBaseUrl}host/{$id}/tasks"; |
|
| 4163 | + $id = $matches[3]; |
|
| 4164 | + $link = "{$newBaseUrl}host/{$id}/tasks"; |
|
| 4165 | 4165 | } |
| 4166 | 4166 | return $link; |
| 4167 | - } |
|
| 4167 | + } |
|
| 4168 | 4168 | |
| 4169 | - function transformUserResultsLinks($matches) { |
|
| 4169 | + function transformUserResultsLinks($matches) { |
|
| 4170 | 4170 | $link = $matches[0]; |
| 4171 | 4171 | $newBaseUrl = $this->getNewBaseUrl($matches); |
| 4172 | 4172 | if ($newBaseUrl !== NULL) { |
| 4173 | - $link = "{$newBaseUrl}account/tasks"; |
|
| 4173 | + $link = "{$newBaseUrl}account/tasks"; |
|
| 4174 | 4174 | } |
| 4175 | 4175 | return $link; |
| 4176 | - } |
|
| 4176 | + } |
|
| 4177 | 4177 | |
| 4178 | - function transformHostLinks($matches) { |
|
| 4178 | + function transformHostLinks($matches) { |
|
| 4179 | 4179 | $link = $matches[0]; |
| 4180 | 4180 | $newBaseUrl = $this->getNewBaseUrl($matches); |
| 4181 | 4181 | if ($newBaseUrl !== NULL) { |
| 4182 | - $id = $matches[3]; |
|
| 4183 | - $link = "{$newBaseUrl}host/{$id}"; |
|
| 4182 | + $id = $matches[3]; |
|
| 4183 | + $link = "{$newBaseUrl}host/{$id}"; |
|
| 4184 | 4184 | } |
| 4185 | 4185 | return $link; |
| 4186 | - } |
|
| 4186 | + } |
|
| 4187 | 4187 | |
| 4188 | - function transformUserHostsLinks($matches) { |
|
| 4188 | + function transformUserHostsLinks($matches) { |
|
| 4189 | 4189 | $link = $matches[0]; |
| 4190 | 4190 | $newBaseUrl = $this->getNewBaseUrl($matches); |
| 4191 | 4191 | if ($newBaseUrl !== NULL) { |
| 4192 | - $uid = boincuser_lookup_uid($matches[3]); |
|
| 4193 | - if ($uid) { |
|
| 4192 | + $uid = boincuser_lookup_uid($matches[3]); |
|
| 4193 | + if ($uid) { |
|
| 4194 | 4194 | $link = "{$newBaseUrl}account/{$uid}/computers"; |
| 4195 | - } |
|
| 4195 | + } |
|
| 4196 | 4196 | } |
| 4197 | 4197 | return $link; |
| 4198 | - } |
|
| 4198 | + } |
|
| 4199 | 4199 | |
| 4200 | - function transformForumIndexLinks($matches) { |
|
| 4200 | + function transformForumIndexLinks($matches) { |
|
| 4201 | 4201 | $link = $matches[0]; |
| 4202 | 4202 | $newBaseUrl = $this->getNewBaseUrl($matches); |
| 4203 | 4203 | if ($newBaseUrl !== NULL) { |
| 4204 | - $link = "{$newBaseUrl}community/forum"; |
|
| 4204 | + $link = "{$newBaseUrl}community/forum"; |
|
| 4205 | 4205 | } |
| 4206 | 4206 | return $link; |
| 4207 | - } |
|
| 4207 | + } |
|
| 4208 | 4208 | |
| 4209 | 4209 | } |
@@ -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 | } |
@@ -114,10 +114,10 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | require_once('dbconfig.php'); |
| 116 | 116 | if (!isset($dbserver) || empty($dbserver)) |
| 117 | - $dbserver='localhost'; |
|
| 117 | + $dbserver='localhost'; |
|
| 118 | 118 | $db_url = array( |
| 119 | - 'default' => "{$dbtype}://{$dbuser}:".urlencode($dbpass)."@{$dbserver}/{$dbname}", |
|
| 120 | - 'boinc_rw' => "{$boinc_rw_dbtype}://{$boinc_rw_dbuser}:".urlencode($boinc_rw_dbpass)."@{$boinc_rw_dbserver}/{$boinc_rw_dbname}" |
|
| 119 | + 'default' => "{$dbtype}://{$dbuser}:".urlencode($dbpass)."@{$dbserver}/{$dbname}", |
|
| 120 | + 'boinc_rw' => "{$boinc_rw_dbtype}://{$boinc_rw_dbuser}:".urlencode($boinc_rw_dbpass)."@{$boinc_rw_dbserver}/{$boinc_rw_dbname}" |
|
| 121 | 121 | ); |
| 122 | 122 | $db_prefix = ''; |
| 123 | 123 | |
@@ -125,10 +125,10 @@ discard block |
||
| 125 | 125 | // 'boinc_rw' entry as 'boinc_ro'. |
| 126 | 126 | |
| 127 | 127 | if (isset($boinc_ro_dbtype) && isset($boinc_ro_dbuser) && isset($boinc_ro_dbpass) && isset($boinc_ro_dbserver) && isset($boinc_ro_dbname)) { |
| 128 | - $db_url['boinc_ro'] = "{$boinc_ro_dbtype}://{$boinc_ro_dbuser}:".urlencode($boinc_ro_dbpass)."@{$boinc_ro_dbserver}/{$boinc_ro_dbname}"; |
|
| 128 | + $db_url['boinc_ro'] = "{$boinc_ro_dbtype}://{$boinc_ro_dbuser}:".urlencode($boinc_ro_dbpass)."@{$boinc_ro_dbserver}/{$boinc_ro_dbname}"; |
|
| 129 | 129 | } |
| 130 | 130 | else { |
| 131 | - $db_url['boinc_ro'] = $db_url['boinc_rw']; |
|
| 131 | + $db_url['boinc_ro'] = $db_url['boinc_rw']; |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
@@ -216,5 +216,5 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | |
| 218 | 218 | if (stream_resolve_include_path('settings.local.php')) { |
| 219 | - include 'settings.local.php'; |
|
| 219 | + include 'settings.local.php'; |
|
| 220 | 220 | } |
@@ -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 | } |
@@ -17,15 +17,15 @@ discard block |
||
| 17 | 17 | * Utility Form to delete teams suspected of being spammers. |
| 18 | 18 | */ |
| 19 | 19 | function boincteam_utility_delete(&$form_state) { |
| 20 | - $form = array(); |
|
| 20 | + $form = array(); |
|
| 21 | 21 | |
| 22 | - $form['help'] = array( |
|
| 22 | + $form['help'] = array( |
|
| 23 | 23 | '#type' => 'fieldset', |
| 24 | 24 | '#title' => t('Help'), |
| 25 | 25 | '#collapsible' => TRUE, |
| 26 | - ); |
|
| 26 | + ); |
|
| 27 | 27 | |
| 28 | - $form['help']['text'] = array( |
|
| 28 | + $form['help']['text'] = array( |
|
| 29 | 29 | '#type' => 'item', |
| 30 | 30 | '#description' => t('This utility page will help in identifying BOINC teams created by SPAMMERs which can be deleted. The search will find BOINC teams that meet the following criteria. |
| 31 | 31 | <ul> |
@@ -38,19 +38,19 @@ discard block |
||
| 38 | 38 | <p> <i>How teams are deleted</i>: Select the teams to be deleted from the table below. Click "Delete Selected Teams" button to begin a batch operation to delete the teams. If you select teams, and then page through to another page of the table, your selections will be lost. I.e., only the teams select on the current page will be deleted. |
| 39 | 39 | <p> The site must be offline/in maintenance mode before searching for and deleting teams. If not, the delete button below is disabled. |
| 40 | 40 | '), |
| 41 | - ); |
|
| 41 | + ); |
|
| 42 | 42 | |
| 43 | - // This variable name has been changed for Drupal 7/8. |
|
| 44 | - $maintenance_mode = variable_get('site_offline'); |
|
| 45 | - if (!$maintenance_mode) { |
|
| 43 | + // This variable name has been changed for Drupal 7/8. |
|
| 44 | + $maintenance_mode = variable_get('site_offline'); |
|
| 45 | + if (!$maintenance_mode) { |
|
| 46 | 46 | drupal_set_message(t('WARNING: Site is online (not in maintenance mode)! Deleting teams is only allowed when site is offline. Change this setting in ') . l(t('Site maintenance'), '/admin/settings/site-maintenance'), 'warning'); |
| 47 | - } |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - $form['teamdelete'] = array( |
|
| 49 | + $form['teamdelete'] = array( |
|
| 50 | 50 | '#type' => 'fieldset', |
| 51 | 51 | '#title' => t('Teams to delete'), |
| 52 | - ); |
|
| 53 | - $form['teamdelete']['deleteall'] = array( |
|
| 52 | + ); |
|
| 53 | + $form['teamdelete']['deleteall'] = array( |
|
| 54 | 54 | '#type' => 'submit', |
| 55 | 55 | '#disabled' => !($maintenance_mode), |
| 56 | 56 | '#value' => t('Delete Selected Teams'), |
@@ -58,101 +58,101 @@ discard block |
||
| 58 | 58 | '#attributes' => array( |
| 59 | 59 | 'onclick' => 'return confirm(\'' . t('You are about to delete the selected teams suspected of being SPAM. Do you want to continue?') . '\')', |
| 60 | 60 | ), |
| 61 | - ); |
|
| 62 | - $form['teamdelete']['results_table'] = array( |
|
| 61 | + ); |
|
| 62 | + $form['teamdelete']['results_table'] = array( |
|
| 63 | 63 | '#value' => drupal_get_form('boincteam_utility_team_table'), |
| 64 | - ); |
|
| 64 | + ); |
|
| 65 | 65 | |
| 66 | - return $form; |
|
| 66 | + return $form; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | function boincteam_utility_team_table() { |
| 70 | 70 | |
| 71 | - $limit=50; |
|
| 72 | - $sql = "SELECT team.id AS id, team.name AS name, team.nusers AS nusers FROM {team} WHERE team.nusers<2 AND team.total_credit=0 AND team.seti_id=0 AND team.description REGEXP '<a href'"; |
|
| 71 | + $limit=50; |
|
| 72 | + $sql = "SELECT team.id AS id, team.name AS name, team.nusers AS nusers FROM {team} WHERE team.nusers<2 AND team.total_credit=0 AND team.seti_id=0 AND team.description REGEXP '<a href'"; |
|
| 73 | 73 | |
| 74 | - // @todo - add bts() or t() |
|
| 75 | - $resultheader = array( |
|
| 74 | + // @todo - add bts() or t() |
|
| 75 | + $resultheader = array( |
|
| 76 | 76 | array( |
| 77 | - 'data' => 'Team ID', |
|
| 78 | - 'field' => 'id', |
|
| 79 | - 'sort' => 'asc', |
|
| 77 | + 'data' => 'Team ID', |
|
| 78 | + 'field' => 'id', |
|
| 79 | + 'sort' => 'asc', |
|
| 80 | 80 | ), |
| 81 | 81 | array( |
| 82 | - 'data' => 'Team Name', |
|
| 83 | - 'field' => 'name', |
|
| 82 | + 'data' => 'Team Name', |
|
| 83 | + 'field' => 'name', |
|
| 84 | 84 | ), |
| 85 | 85 | array( |
| 86 | - 'data' => 'Num Users', |
|
| 87 | - 'field' => 'nusers', |
|
| 86 | + 'data' => 'Num Users', |
|
| 87 | + 'field' => 'nusers', |
|
| 88 | 88 | ), |
| 89 | 89 | array( |
| 90 | - 'data' => 'Link to Team', |
|
| 91 | - 'field' => 'link', |
|
| 90 | + 'data' => 'Link to Team', |
|
| 91 | + 'field' => 'link', |
|
| 92 | 92 | ), |
| 93 | - ); |
|
| 93 | + ); |
|
| 94 | 94 | |
| 95 | - $tablesort = tablesort_sql($resultheader); |
|
| 96 | - db_set_active('boinc_rw'); |
|
| 97 | - $db_res = pager_query($sql . $tablesort, $limit); |
|
| 98 | - db_set_active('default'); |
|
| 95 | + $tablesort = tablesort_sql($resultheader); |
|
| 96 | + db_set_active('boinc_rw'); |
|
| 97 | + $db_res = pager_query($sql . $tablesort, $limit); |
|
| 98 | + db_set_active('default'); |
|
| 99 | 99 | |
| 100 | - $form = array(); |
|
| 101 | - $form['options'] = array(); |
|
| 102 | - $checkboxes = array(); |
|
| 103 | - if ($db_res) { |
|
| 100 | + $form = array(); |
|
| 101 | + $form['options'] = array(); |
|
| 102 | + $checkboxes = array(); |
|
| 103 | + if ($db_res) { |
|
| 104 | 104 | while ($result = db_fetch_object($db_res)) { |
| 105 | - $drupalnid = boincteam_lookup_nid($result->id); |
|
| 106 | - if ($drupalnid) { |
|
| 105 | + $drupalnid = boincteam_lookup_nid($result->id); |
|
| 106 | + if ($drupalnid) { |
|
| 107 | 107 | $tlink = l($result->name, '/community/teams/' . $drupalnid); |
| 108 | - } |
|
| 109 | - else { |
|
| 108 | + } |
|
| 109 | + else { |
|
| 110 | 110 | $tlink = ''; |
| 111 | - } |
|
| 112 | - // only keys no values |
|
| 113 | - $checkboxes[$result->id] = ''; |
|
| 111 | + } |
|
| 112 | + // only keys no values |
|
| 113 | + $checkboxes[$result->id] = ''; |
|
| 114 | 114 | |
| 115 | - $form['id'][$result->id] = array( |
|
| 115 | + $form['id'][$result->id] = array( |
|
| 116 | 116 | '#value' => $result->id, |
| 117 | - ); |
|
| 118 | - $form['name'][$result->id] = array( |
|
| 117 | + ); |
|
| 118 | + $form['name'][$result->id] = array( |
|
| 119 | 119 | '#value' => $result->name, |
| 120 | - ); |
|
| 121 | - $form['nusers'][$result->id] = array( |
|
| 120 | + ); |
|
| 121 | + $form['nusers'][$result->id] = array( |
|
| 122 | 122 | '#value' => $result->nusers, |
| 123 | - ); |
|
| 124 | - $form['link'][$result->id] = array( |
|
| 123 | + ); |
|
| 124 | + $form['link'][$result->id] = array( |
|
| 125 | 125 | '#value' => $tlink, |
| 126 | - ); |
|
| 126 | + ); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | $form['checkboxes'] = array('#type' => 'checkboxes', '#options' => $checkboxes); |
| 130 | 130 | $form['pager'] = array('#value' => theme('pager', NULL, $limit, 0)); |
| 131 | 131 | |
| 132 | 132 | return $form; |
| 133 | - } |
|
| 134 | - return "<p>No teams matched the criteria for a SPAM team.</p>"; |
|
| 133 | + } |
|
| 134 | + return "<p>No teams matched the criteria for a SPAM team.</p>"; |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
| 138 | 138 | * Submit handler - also creates the batch job to delete the teams. |
| 139 | 139 | */ |
| 140 | 140 | function boincteam_utility_delete_team($form, &$form_state) { |
| 141 | - $checkedteamids = $form_state['clicked_button']['#post']['checkboxes']; |
|
| 142 | - // Use batch to delete teams |
|
| 143 | - $operations = array(); |
|
| 144 | - foreach ($checkedteamids as $id) { |
|
| 141 | + $checkedteamids = $form_state['clicked_button']['#post']['checkboxes']; |
|
| 142 | + // Use batch to delete teams |
|
| 143 | + $operations = array(); |
|
| 144 | + foreach ($checkedteamids as $id) { |
|
| 145 | 145 | $operations[] = array('boincteam_utility_batch_process', array($id)); |
| 146 | - } |
|
| 147 | - $batch = array( |
|
| 146 | + } |
|
| 147 | + $batch = array( |
|
| 148 | 148 | 'title' => t('Processing BOINC Teams'), |
| 149 | 149 | 'operations' => $operations, |
| 150 | 150 | 'init_message' => t('Starting team deletion'), |
| 151 | 151 | 'finished' => 'boincteam_utility_batch_finished', |
| 152 | 152 | 'file' => drupal_get_path('module', 'boincteam') . '/boincteam.admin.inc', |
| 153 | - ); |
|
| 154 | - batch_set($batch); |
|
| 155 | - //batch_process('/admin/boinc/utility-team-delete'); |
|
| 153 | + ); |
|
| 154 | + batch_set($batch); |
|
| 155 | + //batch_process('/admin/boinc/utility-team-delete'); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /* |
@@ -163,37 +163,37 @@ discard block |
||
| 163 | 163 | * Input form (table) |
| 164 | 164 | */ |
| 165 | 165 | function theme_boincteam_utility_team_table($form) { |
| 166 | - //define table header |
|
| 167 | - $header = array( |
|
| 166 | + //define table header |
|
| 167 | + $header = array( |
|
| 168 | 168 | theme('table_select_header_cell'), //using that previously empty field |
| 169 | 169 | array('data' => t('Team ID'), 'field' => 'id', 'sort' => 'asc'), |
| 170 | 170 | array('data' => t('Name'), 'field' => 'name'), |
| 171 | 171 | array('data' => t('Num Users'), 'field' => 'nusers'), |
| 172 | 172 | array('data' => t('Link to Team'), 'field' => 'link'), |
| 173 | - ); |
|
| 174 | - $rows = array(); |
|
| 175 | - $output = ""; |
|
| 176 | - if(!empty($form['checkboxes']['#options'])) { |
|
| 173 | + ); |
|
| 174 | + $rows = array(); |
|
| 175 | + $output = ""; |
|
| 176 | + if(!empty($form['checkboxes']['#options'])) { |
|
| 177 | 177 | foreach (element_children($form['id']) as $key) { |
| 178 | - $rows[] = array( |
|
| 178 | + $rows[] = array( |
|
| 179 | 179 | drupal_render($form['checkboxes'][$key]), |
| 180 | 180 | drupal_render($form['id'][$key]), |
| 181 | 181 | drupal_render($form['name'][$key]), |
| 182 | 182 | drupal_render($form['nusers'][$key]), |
| 183 | 183 | drupal_render($form['link'][$key]), |
| 184 | - ); |
|
| 184 | + ); |
|
| 185 | + } |
|
| 185 | 186 | } |
| 186 | - } |
|
| 187 | - else { |
|
| 187 | + else { |
|
| 188 | 188 | $rows[] = array(array('data' => '<div class="error">No teams found</div>', 'colspan' => 5)); |
| 189 | - } |
|
| 190 | - $output .= theme('table', $header, $rows); |
|
| 191 | - if ($form['pager']['#value']) { |
|
| 189 | + } |
|
| 190 | + $output .= theme('table', $header, $rows); |
|
| 191 | + if ($form['pager']['#value']) { |
|
| 192 | 192 | $output .= drupal_render($form['pager']); |
| 193 | - } |
|
| 193 | + } |
|
| 194 | 194 | |
| 195 | - $output .= drupal_render($form); |
|
| 196 | - return $output; |
|
| 195 | + $output .= drupal_render($form); |
|
| 196 | + return $output; |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | /** |
@@ -202,26 +202,26 @@ discard block |
||
| 202 | 202 | * table. It also removes the team's drupal page (node) if found. |
| 203 | 203 | */ |
| 204 | 204 | function boincteam_utility_batch_process($id, &$context) { |
| 205 | - $boincteam = boincteam_load($id); |
|
| 206 | - $drupalid = boincteam_lookup_nid($id); |
|
| 205 | + $boincteam = boincteam_load($id); |
|
| 206 | + $drupalid = boincteam_lookup_nid($id); |
|
| 207 | 207 | |
| 208 | - // Delete entry in team table |
|
| 209 | - db_set_active('boinc_rw'); |
|
| 210 | - $sql1='DELETE FROM {team} WHERE id=%d'; |
|
| 211 | - $db_res = db_query($sql1, $id); |
|
| 212 | - db_set_active('default'); |
|
| 208 | + // Delete entry in team table |
|
| 209 | + db_set_active('boinc_rw'); |
|
| 210 | + $sql1='DELETE FROM {team} WHERE id=%d'; |
|
| 211 | + $db_res = db_query($sql1, $id); |
|
| 212 | + db_set_active('default'); |
|
| 213 | 213 | |
| 214 | - // Delete entry in boincteam table |
|
| 215 | - $sql2='DELETE FROM {boincteam} WHERE id=%d'; |
|
| 216 | - $db_res = db_query($sql2, $id); |
|
| 214 | + // Delete entry in boincteam table |
|
| 215 | + $sql2='DELETE FROM {boincteam} WHERE id=%d'; |
|
| 216 | + $db_res = db_query($sql2, $id); |
|
| 217 | 217 | |
| 218 | - // Delete the drupal node (if present) |
|
| 219 | - if ($drupalid) { |
|
| 218 | + // Delete the drupal node (if present) |
|
| 219 | + if ($drupalid) { |
|
| 220 | 220 | node_delete($drupalid); |
| 221 | - } |
|
| 221 | + } |
|
| 222 | 222 | |
| 223 | - $context['results'][] = $id . ' : ' . check_plain($boincteam->name); |
|
| 224 | - $context['message'] = t('Processing team @name', array('@name' => $boincteam->name)); |
|
| 223 | + $context['results'][] = $id . ' : ' . check_plain($boincteam->name); |
|
| 224 | + $context['message'] = t('Processing team @name', array('@name' => $boincteam->name)); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | /** |
@@ -229,15 +229,15 @@ discard block |
||
| 229 | 229 | * or failure. |
| 230 | 230 | */ |
| 231 | 231 | function boincteam_utility_batch_finished($success, $results, $operations) { |
| 232 | - if ($success) { |
|
| 232 | + if ($success) { |
|
| 233 | 233 | $message = 'Info: Delete SPAM Teams utility- ' . count($results) . ' team(s) deleted.'; |
| 234 | 234 | drupal_set_message($message, 'info'); |
| 235 | - } |
|
| 236 | - else { |
|
| 235 | + } |
|
| 236 | + else { |
|
| 237 | 237 | // An error occurred. |
| 238 | 238 | // $operations contains the operations that remained unprocessed. |
| 239 | 239 | $error_operation = reset($operations); |
| 240 | 240 | $message = 'Error: An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE); |
| 241 | 241 | drupal_set_message($message, 'error'); |
| 242 | - } |
|
| 242 | + } |
|
| 243 | 243 | } |
| 244 | 244 | \ No newline at end of file |
@@ -15,30 +15,30 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | function boinctranslate_initialize_languages() { |
| 17 | 17 | |
| 18 | - require_once(getcwd() . '/includes/locale.inc'); |
|
| 18 | + require_once(getcwd() . '/includes/locale.inc'); |
|
| 19 | 19 | |
| 20 | - $api_base_url = 'https://www.transifex.com/api/2'; |
|
| 21 | - $project_name = variable_get( |
|
| 20 | + $api_base_url = 'https://www.transifex.com/api/2'; |
|
| 21 | + $project_name = variable_get( |
|
| 22 | 22 | 'boinc_translate_transifex_project_name', '' |
| 23 | - ); |
|
| 24 | - $operations = array(); |
|
| 23 | + ); |
|
| 24 | + $operations = array(); |
|
| 25 | 25 | |
| 26 | - if ($project_name) { |
|
| 26 | + if ($project_name) { |
|
| 27 | 27 | // Get all languages configured for this project at Transifex |
| 28 | 28 | $path = "project/{$project_name}/languages"; |
| 29 | 29 | $response = boinctranslate_transifex_request($path); |
| 30 | 30 | |
| 31 | 31 | if ($response == '404 NOT FOUND') { |
| 32 | - drupal_set_message( |
|
| 32 | + drupal_set_message( |
|
| 33 | 33 | t('Unable to get languages for %project.', |
| 34 | - array( |
|
| 34 | + array( |
|
| 35 | 35 | '%project' => $project_name, |
| 36 | - ) |
|
| 36 | + ) |
|
| 37 | 37 | ), 'warning' |
| 38 | - ); |
|
| 38 | + ); |
|
| 39 | 39 | } |
| 40 | 40 | elseif ($response) { |
| 41 | - if (is_array($response)) { |
|
| 41 | + if (is_array($response)) { |
|
| 42 | 42 | |
| 43 | 43 | $installed_languages = language_list(); |
| 44 | 44 | $available_languages = _locale_get_predefined_list(); |
@@ -48,13 +48,13 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | // Set up Transifex languages in Drupal |
| 50 | 50 | foreach ($response as $language) { |
| 51 | - $posix_code = $language['language_code']; |
|
| 52 | - $rfc_code = strtolower(str_replace('_', '-', $posix_code)); |
|
| 53 | - $transifex_languages[$rfc_code] = $language; |
|
| 54 | - if (!isset($installed_languages[$rfc_code])) { |
|
| 51 | + $posix_code = $language['language_code']; |
|
| 52 | + $rfc_code = strtolower(str_replace('_', '-', $posix_code)); |
|
| 53 | + $transifex_languages[$rfc_code] = $language; |
|
| 54 | + if (!isset($installed_languages[$rfc_code])) { |
|
| 55 | 55 | // See if this language can be installed from a predefined list |
| 56 | 56 | if (isset($available_languages[$rfc_code])) { |
| 57 | - locale_add_language( |
|
| 57 | + locale_add_language( |
|
| 58 | 58 | $rfc_code, |
| 59 | 59 | NULL, |
| 60 | 60 | NULL, |
@@ -62,30 +62,30 @@ discard block |
||
| 62 | 62 | NULL, |
| 63 | 63 | NULL, |
| 64 | 64 | FALSE |
| 65 | - ); |
|
| 66 | - drupal_set_message( |
|
| 65 | + ); |
|
| 66 | + drupal_set_message( |
|
| 67 | 67 | 'Added predefined language: '.$available_languages[$rfc_code][0] |
| 68 | - ); |
|
| 69 | - db_query("UPDATE {languages} SET enabled = 1 WHERE language = '%s'", $rfc_code); |
|
| 68 | + ); |
|
| 69 | + db_query("UPDATE {languages} SET enabled = 1 WHERE language = '%s'", $rfc_code); |
|
| 70 | 70 | } |
| 71 | 71 | else { |
| 72 | - // Retrieve language details from Transifex |
|
| 73 | - $path = "language/{$posix_code}"; |
|
| 74 | - $response = boinctranslate_transifex_request($path); |
|
| 72 | + // Retrieve language details from Transifex |
|
| 73 | + $path = "language/{$posix_code}"; |
|
| 74 | + $response = boinctranslate_transifex_request($path); |
|
| 75 | 75 | |
| 76 | - if ($response == '404 NOT FOUND') { |
|
| 76 | + if ($response == '404 NOT FOUND') { |
|
| 77 | 77 | drupal_set_message( |
| 78 | - t('Unable to get details for language %code.', |
|
| 78 | + t('Unable to get details for language %code.', |
|
| 79 | 79 | array( |
| 80 | - '%code' => $posix_code, |
|
| 80 | + '%code' => $posix_code, |
|
| 81 | 81 | ) |
| 82 | - ), 'warning' |
|
| 82 | + ), 'warning' |
|
| 83 | 83 | ); |
| 84 | - } |
|
| 85 | - elseif ($response) { |
|
| 84 | + } |
|
| 85 | + elseif ($response) { |
|
| 86 | 86 | if (!empty($response['name'])) { |
| 87 | - // Add a custom language to Drupal and enable |
|
| 88 | - locale_add_language( |
|
| 87 | + // Add a custom language to Drupal and enable |
|
| 88 | + locale_add_language( |
|
| 89 | 89 | $rfc_code, |
| 90 | 90 | $response['name'], |
| 91 | 91 | $response['name'], |
@@ -93,362 +93,362 @@ discard block |
||
| 93 | 93 | NULL, |
| 94 | 94 | NULL, |
| 95 | 95 | TRUE |
| 96 | - ); |
|
| 97 | - drupal_set_message( |
|
| 96 | + ); |
|
| 97 | + drupal_set_message( |
|
| 98 | 98 | 'Added new language: '.$response['name'] |
| 99 | - ); |
|
| 99 | + ); |
|
| 100 | 100 | } |
| 101 | 101 | else { |
| 102 | - $variables = array( |
|
| 102 | + $variables = array( |
|
| 103 | 103 | '%code' => $posix_code, |
| 104 | - ); |
|
| 105 | - drupal_set_message( |
|
| 104 | + ); |
|
| 105 | + drupal_set_message( |
|
| 106 | 106 | t('Unable to get details for language %code.', $variables), |
| 107 | 107 | 'error' |
| 108 | - ); |
|
| 109 | - watchdog( |
|
| 108 | + ); |
|
| 109 | + watchdog( |
|
| 110 | 110 | 'boinctranslate', |
| 111 | 111 | 'Unable to get details for language %code.', |
| 112 | 112 | $variables, |
| 113 | 113 | WATCHDOG_ERROR |
| 114 | - ); |
|
| 114 | + ); |
|
| 115 | + } |
|
| 115 | 116 | } |
| 116 | - } |
|
| 117 | - else { |
|
| 118 | - $variables = array( |
|
| 119 | - '%code' => $posix_code, |
|
| 117 | + else { |
|
| 118 | + $variables = array( |
|
| 119 | + '%code' => $posix_code, |
|
| 120 | 120 | ); |
| 121 | 121 | drupal_set_message( |
| 122 | - t('Invalid response while getting details for language %code.', $variables), |
|
| 123 | - 'error' |
|
| 122 | + t('Invalid response while getting details for language %code.', $variables), |
|
| 123 | + 'error' |
|
| 124 | 124 | ); |
| 125 | 125 | watchdog( |
| 126 | - 'boinctranslate', |
|
| 127 | - 'Invalid response while getting details for language %code.', |
|
| 128 | - $variables, |
|
| 129 | - WATCHDOG_ERROR |
|
| 126 | + 'boinctranslate', |
|
| 127 | + 'Invalid response while getting details for language %code.', |
|
| 128 | + $variables, |
|
| 129 | + WATCHDOG_ERROR |
|
| 130 | 130 | ); |
| 131 | - } |
|
| 131 | + } |
|
| 132 | 132 | } |
| 133 | 133 | // Import any language files for the newly added language |
| 134 | 134 | if ($batch = locale_batch_by_language($rfc_code, '_locale_batch_language_finished')) { |
| 135 | - $operations = array_merge($operations, $batch['operations']); |
|
| 136 | - $process_batches = TRUE; |
|
| 135 | + $operations = array_merge($operations, $batch['operations']); |
|
| 136 | + $process_batches = TRUE; |
|
| 137 | + } |
|
| 137 | 138 | } |
| 138 | - } |
|
| 139 | 139 | } |
| 140 | 140 | drupal_set_message('Finished installing official BOINC languages.'); |
| 141 | 141 | // Disable languages that are not in Transifex |
| 142 | 142 | foreach ($installed_languages as $langcode => $language) { |
| 143 | - if (!isset($transifex_languages[$langcode])) { |
|
| 143 | + if (!isset($transifex_languages[$langcode])) { |
|
| 144 | 144 | $disabled_languages[$langcode] = $langcode; |
| 145 | 145 | db_query("UPDATE {languages} SET enabled = 0 WHERE language = '%s'", $langcode); |
| 146 | - } |
|
| 146 | + } |
|
| 147 | 147 | } |
| 148 | 148 | if ($disabled_languages) { |
| 149 | - drupal_set_message('The following languages were not found in Transifex and were disabled: ' . implode(' ', $disabled_languages)); |
|
| 149 | + drupal_set_message('The following languages were not found in Transifex and were disabled: ' . implode(' ', $disabled_languages)); |
|
| 150 | 150 | } |
| 151 | 151 | if ($process_batches) { |
| 152 | - $batch = array( |
|
| 152 | + $batch = array( |
|
| 153 | 153 | 'operations' => $operations, |
| 154 | - ); |
|
| 155 | - batch_set($batch); |
|
| 156 | - batch_process('admin/boinc/translation'); |
|
| 154 | + ); |
|
| 155 | + batch_set($batch); |
|
| 156 | + batch_process('admin/boinc/translation'); |
|
| 157 | + } |
|
| 157 | 158 | } |
| 158 | - } |
|
| 159 | - else { |
|
| 159 | + else { |
|
| 160 | 160 | $variables = array( |
| 161 | - '%project' => $project_name, |
|
| 161 | + '%project' => $project_name, |
|
| 162 | 162 | ); |
| 163 | 163 | drupal_set_message( |
| 164 | - t('No languages found for %project. (Does the configured account have sufficient privileges at Transifex?)', $variables), |
|
| 165 | - 'error' |
|
| 164 | + t('No languages found for %project. (Does the configured account have sufficient privileges at Transifex?)', $variables), |
|
| 165 | + 'error' |
|
| 166 | 166 | ); |
| 167 | 167 | watchdog( |
| 168 | - 'boinctranslate', |
|
| 169 | - 'No languages found for %project. (Does the configured account have sufficient privileges at Transifex?)', |
|
| 170 | - $variables, |
|
| 171 | - WATCHDOG_ERROR |
|
| 168 | + 'boinctranslate', |
|
| 169 | + 'No languages found for %project. (Does the configured account have sufficient privileges at Transifex?)', |
|
| 170 | + $variables, |
|
| 171 | + WATCHDOG_ERROR |
|
| 172 | 172 | ); |
| 173 | - } |
|
| 173 | + } |
|
| 174 | 174 | } |
| 175 | 175 | else { |
| 176 | - $variables = array( |
|
| 176 | + $variables = array( |
|
| 177 | 177 | '%project' => $project_name, |
| 178 | - ); |
|
| 179 | - drupal_set_message( |
|
| 178 | + ); |
|
| 179 | + drupal_set_message( |
|
| 180 | 180 | t('Invalid response while getting languages for %project.', $variables), |
| 181 | 181 | 'error' |
| 182 | - ); |
|
| 183 | - watchdog( |
|
| 182 | + ); |
|
| 183 | + watchdog( |
|
| 184 | 184 | 'boinctranslate', |
| 185 | 185 | 'Invalid response while getting languages for %project.', |
| 186 | 186 | $variables, |
| 187 | 187 | WATCHDOG_ERROR |
| 188 | - ); |
|
| 188 | + ); |
|
| 189 | 189 | } |
| 190 | - } |
|
| 191 | - drupal_goto('admin/boinc/translation'); |
|
| 190 | + } |
|
| 191 | + drupal_goto('admin/boinc/translation'); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | /** |
| 195 | 195 | * |
| 196 | 196 | */ |
| 197 | 197 | function boinctranslate_export_translations() { |
| 198 | - require_once(getcwd() . '/includes/locale.inc'); |
|
| 199 | - $project_name = variable_get( |
|
| 198 | + require_once(getcwd() . '/includes/locale.inc'); |
|
| 199 | + $project_name = variable_get( |
|
| 200 | 200 | 'boinc_translate_transifex_project_name', '' |
| 201 | - ); |
|
| 202 | - // Get resource names from local config |
|
| 203 | - $resource_config = (variable_get( |
|
| 201 | + ); |
|
| 202 | + // Get resource names from local config |
|
| 203 | + $resource_config = (variable_get( |
|
| 204 | 204 | 'boinc_translate_transifex_project_resources', '' |
| 205 | - )); |
|
| 206 | - $resource_names = boinctranslate_parse_resources($resource_config); |
|
| 207 | - $primary_resource = reset($resource_names); |
|
| 205 | + )); |
|
| 206 | + $resource_names = boinctranslate_parse_resources($resource_config); |
|
| 207 | + $primary_resource = reset($resource_names); |
|
| 208 | 208 | |
| 209 | - if ($project_name AND $primary_resource) { |
|
| 209 | + if ($project_name AND $primary_resource) { |
|
| 210 | 210 | // Create or update the translation source, if needed |
| 211 | 211 | $source_exists = FALSE; |
| 212 | 212 | $path = "project/{$project_name}/resources"; |
| 213 | 213 | $resources = boinctranslate_transifex_request($path); |
| 214 | 214 | if ($resources AND is_array($resources)) { |
| 215 | - foreach ($resources as $resource) { |
|
| 215 | + foreach ($resources as $resource) { |
|
| 216 | 216 | if ($resource['slug'] == $primary_resource) { |
| 217 | - $source_exists = TRUE; |
|
| 218 | - break; |
|
| 217 | + $source_exists = TRUE; |
|
| 218 | + break; |
|
| 219 | 219 | } |
| 220 | - } |
|
| 221 | - if (!$source_exists) { |
|
| 220 | + } |
|
| 221 | + if (!$source_exists) { |
|
| 222 | 222 | // Create the source |
| 223 | 223 | $path = "project/{$project_name}/resources"; |
| 224 | 224 | $post = array( |
| 225 | - 'slug' => $primary_resource, |
|
| 226 | - 'name' => 'Drupal-Project', |
|
| 227 | - 'i18n_type' => 'PO', |
|
| 228 | - 'category' => 'Drupal', |
|
| 229 | - 'content' => boinctranslate_get_po('en', 'project'), |
|
| 225 | + 'slug' => $primary_resource, |
|
| 226 | + 'name' => 'Drupal-Project', |
|
| 227 | + 'i18n_type' => 'PO', |
|
| 228 | + 'category' => 'Drupal', |
|
| 229 | + 'content' => boinctranslate_get_po('en', 'project'), |
|
| 230 | 230 | ); |
| 231 | 231 | $result = boinctranslate_transifex_request($path, $post); |
| 232 | - } |
|
| 233 | - else { |
|
| 232 | + } |
|
| 233 | + else { |
|
| 234 | 234 | // Update the source |
| 235 | 235 | $path = "project/{$project_name}/resource/{$primary_resource}/content"; |
| 236 | 236 | $post = array( |
| 237 | - 'content' => boinctranslate_get_po('en', 'project') |
|
| 237 | + 'content' => boinctranslate_get_po('en', 'project') |
|
| 238 | 238 | ); |
| 239 | 239 | $result = boinctranslate_transifex_request($path, $post, TRUE, TRUE); |
| 240 | - } |
|
| 240 | + } |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | if (is_array($result) OR substr($result, 0, 6) != 'ERROR:') { |
| 244 | - $enabled_languages = locale_language_list(); |
|
| 245 | - if ($source_exists) { |
|
| 244 | + $enabled_languages = locale_language_list(); |
|
| 245 | + if ($source_exists) { |
|
| 246 | 246 | drupal_set_message('Updated source translation strings at Transifex'); |
| 247 | - } |
|
| 248 | - else { |
|
| 247 | + } |
|
| 248 | + else { |
|
| 249 | 249 | drupal_set_message('Established new translation resource at Transifex'); |
| 250 | - } |
|
| 251 | - // Try to export translations for all enabled languages |
|
| 252 | - foreach ($enabled_languages as $langcode => $language_name) { |
|
| 250 | + } |
|
| 251 | + // Try to export translations for all enabled languages |
|
| 252 | + foreach ($enabled_languages as $langcode => $language_name) { |
|
| 253 | 253 | if ($langcode == 'en') { |
| 254 | - continue; |
|
| 254 | + continue; |
|
| 255 | 255 | } |
| 256 | 256 | $po_file = boinctranslate_get_po($langcode, 'project'); |
| 257 | 257 | if ($po_file) { |
| 258 | - $path = "project/{$project_name}/resource/{$primary_resource}/translation/{$langcode}"; |
|
| 259 | - $post = array( |
|
| 258 | + $path = "project/{$project_name}/resource/{$primary_resource}/translation/{$langcode}"; |
|
| 259 | + $post = array( |
|
| 260 | 260 | 'content' => $po_file, |
| 261 | - ); |
|
| 262 | - $result = boinctranslate_transifex_request($path, $post, TRUE, TRUE); |
|
| 263 | - if (!is_array($result) |
|
| 261 | + ); |
|
| 262 | + $result = boinctranslate_transifex_request($path, $post, TRUE, TRUE); |
|
| 263 | + if (!is_array($result) |
|
| 264 | 264 | AND substr($result, 0, 6) == 'ERROR:') { |
| 265 | 265 | drupal_set_message( |
| 266 | - "Unable to update {$language_name} translations: {$result}", |
|
| 267 | - 'warning' |
|
| 266 | + "Unable to update {$language_name} translations: {$result}", |
|
| 267 | + 'warning' |
|
| 268 | 268 | ); |
| 269 | - } |
|
| 270 | - else { |
|
| 269 | + } |
|
| 270 | + else { |
|
| 271 | 271 | drupal_set_message("Updated {$language_name} translations"); |
| 272 | 272 | //drupal_set_message('DEBUG: <pre>'.print_r($result,1).'</pre>'); |
| 273 | - } |
|
| 273 | + } |
|
| 274 | 274 | } |
| 275 | 275 | else { |
| 276 | - drupal_set_message("No translations to export for {$language_name}"); |
|
| 276 | + drupal_set_message("No translations to export for {$language_name}"); |
|
| 277 | + } |
|
| 277 | 278 | } |
| 278 | - } |
|
| 279 | 279 | } |
| 280 | 280 | else { |
| 281 | - drupal_set_message( |
|
| 281 | + drupal_set_message( |
|
| 282 | 282 | "Unable to update the translation source: {$result}", |
| 283 | 283 | 'warning' |
| 284 | - ); |
|
| 284 | + ); |
|
| 285 | 285 | } |
| 286 | - } |
|
| 287 | - else { |
|
| 286 | + } |
|
| 287 | + else { |
|
| 288 | 288 | drupal_set_message( |
| 289 | - 'Failed to export translations: Transifex settings are not intiailized.', |
|
| 290 | - 'error' |
|
| 289 | + 'Failed to export translations: Transifex settings are not intiailized.', |
|
| 290 | + 'error' |
|
| 291 | 291 | ); |
| 292 | - } |
|
| 293 | - drupal_goto('admin/boinc/translation'); |
|
| 292 | + } |
|
| 293 | + drupal_goto('admin/boinc/translation'); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | /** |
| 297 | 297 | * |
| 298 | 298 | */ |
| 299 | 299 | function boinctranslate_update_official_boinc_translations() { |
| 300 | - require_once(getcwd() . '/includes/locale.inc'); |
|
| 301 | - $project_name = variable_get( |
|
| 300 | + require_once(getcwd() . '/includes/locale.inc'); |
|
| 301 | + $project_name = variable_get( |
|
| 302 | 302 | 'boinc_translate_transifex_standard_name', '' |
| 303 | - ); |
|
| 304 | - $drupal_resource = variable_get( |
|
| 303 | + ); |
|
| 304 | + $drupal_resource = variable_get( |
|
| 305 | 305 | 'boinc_translate_transifex_boinc_drupal_resource', '' |
| 306 | - ); |
|
| 306 | + ); |
|
| 307 | 307 | |
| 308 | - if ($project_name AND $drupal_resource) { |
|
| 308 | + if ($project_name AND $drupal_resource) { |
|
| 309 | 309 | // Create or update the translation source, if needed |
| 310 | 310 | $source_exists = FALSE; |
| 311 | 311 | $path = "project/{$project_name}/resources"; |
| 312 | 312 | $resources = boinctranslate_transifex_request($path); |
| 313 | 313 | if ($resources AND is_array($resources)) { |
| 314 | - foreach ($resources as $resource) { |
|
| 314 | + foreach ($resources as $resource) { |
|
| 315 | 315 | if ($resource['slug'] == $drupal_resource) { |
| 316 | - $source_exists = TRUE; |
|
| 317 | - break; |
|
| 316 | + $source_exists = TRUE; |
|
| 317 | + break; |
|
| 318 | + } |
|
| 318 | 319 | } |
| 319 | - } |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | if ($source_exists) { |
| 323 | - $enabled_languages = locale_language_list(); |
|
| 324 | - // Try to export translations for all enabled languages |
|
| 325 | - foreach ($enabled_languages as $langcode => $language_name) { |
|
| 323 | + $enabled_languages = locale_language_list(); |
|
| 324 | + // Try to export translations for all enabled languages |
|
| 325 | + foreach ($enabled_languages as $langcode => $language_name) { |
|
| 326 | 326 | if ($langcode == 'en') { |
| 327 | - continue; |
|
| 327 | + continue; |
|
| 328 | 328 | } |
| 329 | 329 | $po_file = boinctranslate_get_po($langcode, 'boinc'); |
| 330 | 330 | if ($po_file) { |
| 331 | - $path = "project/{$project_name}/resource/{$drupal_resource}/translation/{$langcode}"; |
|
| 332 | - $post = array( |
|
| 331 | + $path = "project/{$project_name}/resource/{$drupal_resource}/translation/{$langcode}"; |
|
| 332 | + $post = array( |
|
| 333 | 333 | 'content' => $po_file, |
| 334 | - ); |
|
| 335 | - $result = boinctranslate_transifex_request($path, $post, TRUE, TRUE); |
|
| 334 | + ); |
|
| 335 | + $result = boinctranslate_transifex_request($path, $post, TRUE, TRUE); |
|
| 336 | 336 | |
| 337 | - if (!is_array($result)) { |
|
| 337 | + if (!is_array($result)) { |
|
| 338 | 338 | if (substr($result, 0, 6) == 'ERROR:') { |
| 339 | - drupal_set_message( |
|
| 339 | + drupal_set_message( |
|
| 340 | 340 | "Unable to update {$language_name} official BOINC translations: {$result}", |
| 341 | 341 | 'warning' |
| 342 | - ); |
|
| 342 | + ); |
|
| 343 | 343 | } |
| 344 | 344 | elseif ($result == '401 UNAUTHORIZED') { |
| 345 | - drupal_set_message( |
|
| 345 | + drupal_set_message( |
|
| 346 | 346 | 'Not authorized to update official BOINC translations', |
| 347 | 347 | 'warning' |
| 348 | - ); |
|
| 349 | - break; |
|
| 348 | + ); |
|
| 349 | + break; |
|
| 350 | 350 | } |
| 351 | 351 | elseif ($result == 'success') { |
| 352 | - drupal_set_message("Updated {$language_name} official BOINC translations"); |
|
| 352 | + drupal_set_message("Updated {$language_name} official BOINC translations"); |
|
| 353 | 353 | } |
| 354 | 354 | else { |
| 355 | - drupal_set_message( |
|
| 355 | + drupal_set_message( |
|
| 356 | 356 | "Unexpected response for {$language_name}: {$result}", |
| 357 | 357 | 'warning' |
| 358 | - ); |
|
| 358 | + ); |
|
| 359 | 359 | } |
| 360 | - } |
|
| 361 | - else { |
|
| 360 | + } |
|
| 361 | + else { |
|
| 362 | 362 | drupal_set_message("Updated {$language_name} official BOINC translations"); |
| 363 | 363 | //drupal_set_message('DEBUG: <pre>'.print_r($result,1).'</pre>'); |
| 364 | - } |
|
| 364 | + } |
|
| 365 | 365 | } |
| 366 | 366 | else { |
| 367 | - drupal_set_message("No official BOINC translations to export for {$language_name}"); |
|
| 367 | + drupal_set_message("No official BOINC translations to export for {$language_name}"); |
|
| 368 | + } |
|
| 368 | 369 | } |
| 369 | - } |
|
| 370 | 370 | } |
| 371 | 371 | else { |
| 372 | - drupal_set_message( |
|
| 372 | + drupal_set_message( |
|
| 373 | 373 | "The {$drupal_resource} resource does not exist in the {$project_name} project at Transifex", |
| 374 | 374 | 'warning' |
| 375 | - ); |
|
| 375 | + ); |
|
| 376 | 376 | } |
| 377 | - } |
|
| 378 | - else { |
|
| 377 | + } |
|
| 378 | + else { |
|
| 379 | 379 | drupal_set_message( |
| 380 | - 'Failed to export official BOINC translations: Transifex settings are not intiailized.', |
|
| 381 | - 'error' |
|
| 380 | + 'Failed to export official BOINC translations: Transifex settings are not intiailized.', |
|
| 381 | + 'error' |
|
| 382 | 382 | ); |
| 383 | - } |
|
| 384 | - drupal_goto('admin/boinc/translation'); |
|
| 383 | + } |
|
| 384 | + drupal_goto('admin/boinc/translation'); |
|
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | /** |
| 388 | 388 | * |
| 389 | 389 | */ |
| 390 | 390 | function boinctranslate_download_pot($type = 'boinc') { |
| 391 | - $po = boinctranslate_get_po(NULL, $type); |
|
| 392 | - _locale_export_po(NULL, $po); |
|
| 391 | + $po = boinctranslate_get_po(NULL, $type); |
|
| 392 | + _locale_export_po(NULL, $po); |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | /** |
| 396 | 396 | * |
| 397 | 397 | */ |
| 398 | 398 | function boinctranslate_transifex_request($path, $post = NULL, $json = TRUE, $use_put = FALSE, $username = '', $password = '') { |
| 399 | - $debug_mode = variable_get('boinc_debug_mode', 0); |
|
| 399 | + $debug_mode = variable_get('boinc_debug_mode', 0); |
|
| 400 | 400 | |
| 401 | - // Transifex details |
|
| 402 | - $api_base_url = 'https://www.transifex.com/api/2'; |
|
| 403 | - if (!$username) $username = variable_get('boinc_translate_transifex_user', ''); |
|
| 404 | - if (!$password) $password = variable_get('boinc_translate_transifex_pass', ''); |
|
| 401 | + // Transifex details |
|
| 402 | + $api_base_url = 'https://www.transifex.com/api/2'; |
|
| 403 | + if (!$username) $username = variable_get('boinc_translate_transifex_user', ''); |
|
| 404 | + if (!$password) $password = variable_get('boinc_translate_transifex_pass', ''); |
|
| 405 | 405 | |
| 406 | - $url = "{$api_base_url}/{$path}"; |
|
| 407 | - $headers = array( |
|
| 406 | + $url = "{$api_base_url}/{$path}"; |
|
| 407 | + $headers = array( |
|
| 408 | 408 | 'Authorization' => 'Basic ' . base64_encode($username . ":" . $password), |
| 409 | - ); |
|
| 410 | - $data = NULL; |
|
| 409 | + ); |
|
| 410 | + $data = NULL; |
|
| 411 | 411 | |
| 412 | - if ($post) { |
|
| 412 | + if ($post) { |
|
| 413 | 413 | if ($json) { |
| 414 | - $headers['Content-Type'] = 'application/json'; |
|
| 415 | - $data = json_encode($post); |
|
| 414 | + $headers['Content-Type'] = 'application/json'; |
|
| 415 | + $data = json_encode($post); |
|
| 416 | 416 | } |
| 417 | 417 | else { |
| 418 | - $data = drupal_query_string_encode($post); |
|
| 418 | + $data = drupal_query_string_encode($post); |
|
| 419 | 419 | } |
| 420 | 420 | $method = ($use_put) ? 'PUT' : 'POST'; |
| 421 | - } |
|
| 422 | - else { |
|
| 421 | + } |
|
| 422 | + else { |
|
| 423 | 423 | $method = 'GET'; |
| 424 | - } |
|
| 424 | + } |
|
| 425 | 425 | |
| 426 | - $response = drupal_http_request($url, $headers, $method, $data, 1, 10); |
|
| 426 | + $response = drupal_http_request($url, $headers, $method, $data, 1, 10); |
|
| 427 | 427 | |
| 428 | - switch ($response->code) { |
|
| 429 | - case 200: |
|
| 428 | + switch ($response->code) { |
|
| 429 | + case 200: |
|
| 430 | 430 | case 304: |
| 431 | 431 | if ($json) { |
| 432 | - // Process as JSON |
|
| 433 | - return json_decode($response->data, TRUE); |
|
| 432 | + // Process as JSON |
|
| 433 | + return json_decode($response->data, TRUE); |
|
| 434 | 434 | } |
| 435 | 435 | else { |
| 436 | - return (string) $response->data; |
|
| 436 | + return (string) $response->data; |
|
| 437 | 437 | } |
| 438 | 438 | break; |
| 439 | - case 404: |
|
| 439 | + case 404: |
|
| 440 | 440 | return '404 NOT FOUND'; |
| 441 | - case 401: |
|
| 441 | + case 401: |
|
| 442 | 442 | return '401 UNAUTHORIZED'; |
| 443 | - case 400: |
|
| 443 | + case 400: |
|
| 444 | 444 | if ($debug_mode) watchdog('boinctranslate', "The following response was received when trying to communicate with the Transifex system: \n{$response}", array(), WATCHDOG_WARNING); |
| 445 | 445 | return "ERROR: {$response->data}"; |
| 446 | - case 405: |
|
| 446 | + case 405: |
|
| 447 | 447 | if ($debug_mode) watchdog('boinctranslate', "The following response was received when trying to communicate with the Transifex system: \n{$response}", array(), WATCHDOG_WARNING); |
| 448 | 448 | return "ERROR: User not allowed to perform this action"; |
| 449 | - } |
|
| 449 | + } |
|
| 450 | 450 | |
| 451 | - return NULL; |
|
| 451 | + return NULL; |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | /** |
@@ -456,58 +456,58 @@ discard block |
||
| 456 | 456 | */ |
| 457 | 457 | function boinctranslate_get_po($langcode, $type = 'standard') { |
| 458 | 458 | |
| 459 | - require_once(getcwd() . '/includes/locale.inc'); |
|
| 459 | + require_once(getcwd() . '/includes/locale.inc'); |
|
| 460 | 460 | |
| 461 | - $all_languages = language_list(); |
|
| 462 | - $language = $langcode ? $all_languages[$langcode] : NULL; |
|
| 463 | - $textgroups = array(); |
|
| 464 | - $strings = array(); |
|
| 461 | + $all_languages = language_list(); |
|
| 462 | + $language = $langcode ? $all_languages[$langcode] : NULL; |
|
| 463 | + $textgroups = array(); |
|
| 464 | + $strings = array(); |
|
| 465 | 465 | |
| 466 | - switch ($type) { |
|
| 467 | - case 'standard': |
|
| 466 | + switch ($type) { |
|
| 467 | + case 'standard': |
|
| 468 | 468 | $textgroups = array( |
| 469 | - 'default', |
|
| 470 | - 'taxonomy', |
|
| 471 | - 'views', |
|
| 469 | + 'default', |
|
| 470 | + 'taxonomy', |
|
| 471 | + 'views', |
|
| 472 | 472 | ); |
| 473 | 473 | break; |
| 474 | - case 'boinc': |
|
| 474 | + case 'boinc': |
|
| 475 | 475 | $textgroups = array( |
| 476 | - 'boinc', |
|
| 476 | + 'boinc', |
|
| 477 | 477 | ); |
| 478 | 478 | break; |
| 479 | - case 'project': |
|
| 479 | + case 'project': |
|
| 480 | 480 | $textgroups = array( |
| 481 | - 'blocks', |
|
| 482 | - 'menu', |
|
| 483 | - 'project', |
|
| 481 | + 'blocks', |
|
| 482 | + 'menu', |
|
| 483 | + 'project', |
|
| 484 | 484 | ); |
| 485 | 485 | break; |
| 486 | - default: |
|
| 486 | + default: |
|
| 487 | 487 | } |
| 488 | 488 | |
| 489 | - // Merge textgroup strings together for export as one file |
|
| 490 | - foreach ($textgroups as $textgroup) { |
|
| 489 | + // Merge textgroup strings together for export as one file |
|
| 490 | + foreach ($textgroups as $textgroup) { |
|
| 491 | 491 | $strings += _locale_export_get_strings($language, $textgroup); |
| 492 | - } |
|
| 493 | - ksort($strings); |
|
| 494 | - foreach ($strings as $id => $string) { |
|
| 492 | + } |
|
| 493 | + ksort($strings); |
|
| 494 | + foreach ($strings as $id => $string) { |
|
| 495 | 495 | // Set the string context |
| 496 | 496 | $strings[$id]['context'] = trim($string['comment']); |
| 497 | - } |
|
| 498 | - if ($langcode AND $langcode != 'en') { |
|
| 497 | + } |
|
| 498 | + if ($langcode AND $langcode != 'en') { |
|
| 499 | 499 | // If not the source language, remove untranslated strings from the ouput |
| 500 | 500 | foreach ($strings as $i => $string) { |
| 501 | - if (!$string['translation']) { |
|
| 501 | + if (!$string['translation']) { |
|
| 502 | 502 | unset($strings[$i]); |
| 503 | - } |
|
| 503 | + } |
|
| 504 | 504 | } |
| 505 | - } |
|
| 506 | - if ($strings) { |
|
| 505 | + } |
|
| 506 | + if ($strings) { |
|
| 507 | 507 | return boinctranslate_export_po_generate($language, $strings, NULL, $type); |
| 508 | - } |
|
| 508 | + } |
|
| 509 | 509 | |
| 510 | - return NULL; |
|
| 510 | + return NULL; |
|
| 511 | 511 | } |
| 512 | 512 | |
| 513 | 513 | /** |
@@ -515,21 +515,21 @@ discard block |
||
| 515 | 515 | */ |
| 516 | 516 | function boinctranslate_export_po_generate($language = NULL, $strings = array(), $header = NULL, $type = NULL) { |
| 517 | 517 | |
| 518 | - require_once(getcwd() . '/includes/locale.inc'); |
|
| 519 | - global $user; |
|
| 518 | + require_once(getcwd() . '/includes/locale.inc'); |
|
| 519 | + global $user; |
|
| 520 | 520 | |
| 521 | - // unset $language to indicate template creation |
|
| 522 | - if (isset($language) && $language->language == "en") { |
|
| 521 | + // unset $language to indicate template creation |
|
| 522 | + if (isset($language) && $language->language == "en") { |
|
| 523 | 523 | $language = NULL; |
| 524 | - } |
|
| 524 | + } |
|
| 525 | 525 | |
| 526 | - if (!isset($header)) { |
|
| 526 | + if (!isset($header)) { |
|
| 527 | 527 | if (isset($type) && $type == "project") { |
| 528 | - $header = "# ".variable_get('site_name', 'Drupal-BOINC')." drupal localization template\n"; |
|
| 529 | - $header .= "# Copyright (C) ".date("Y")." ".variable_get('site_name', 'Drupal-BOINC')."\n"; |
|
| 528 | + $header = "# ".variable_get('site_name', 'Drupal-BOINC')." drupal localization template\n"; |
|
| 529 | + $header .= "# Copyright (C) ".date("Y")." ".variable_get('site_name', 'Drupal-BOINC')."\n"; |
|
| 530 | 530 | } else { |
| 531 | - $header = "# BOINC drupal localization template\n"; |
|
| 532 | - $header .= "# Copyright (C) ".date("Y")." University of California\n"; |
|
| 531 | + $header = "# BOINC drupal localization template\n"; |
|
| 532 | + $header .= "# Copyright (C) ".date("Y")." University of California\n"; |
|
| 533 | 533 | } |
| 534 | 534 | $header .= '# Generated by ' . $user->name . ' <' . $user->mail . ">\n"; |
| 535 | 535 | $header .= "#\n"; |
@@ -538,201 +538,201 @@ discard block |
||
| 538 | 538 | $header .= "msgid \"\"\n"; |
| 539 | 539 | $header .= "msgstr \"\"\n"; |
| 540 | 540 | if (isset($type) && $type == "project") { |
| 541 | - $header .= "\"Project-Id-Version: ".variable_get('site_name', 'Drupal-BOINC')." ".date("Y-m-d-H:iO")."\\n\"\n"; |
|
| 541 | + $header .= "\"Project-Id-Version: ".variable_get('site_name', 'Drupal-BOINC')." ".date("Y-m-d-H:iO")."\\n\"\n"; |
|
| 542 | 542 | } else { |
| 543 | - $header .= "\"Project-Id-Version: BOINC unknown\\n\"\n"; // TODO: add SHA1 of source checkout here |
|
| 543 | + $header .= "\"Project-Id-Version: BOINC unknown\\n\"\n"; // TODO: add SHA1 of source checkout here |
|
| 544 | 544 | } |
| 545 | 545 | $header .= "\"Report-Msgid-Bugs-To: BOINC translation team <[email protected]>\\n\"\n"; |
| 546 | 546 | $header .= "\"POT-Creation-Date: " . date("Y-m-d H:iO") . "\\n\"\n"; |
| 547 | 547 | if (isset($language)) { |
| 548 | - $header .= "\"PO-Revision-Date: " . date("Y-m-d H:iO") . "\\n\"\n"; |
|
| 548 | + $header .= "\"PO-Revision-Date: " . date("Y-m-d H:iO") . "\\n\"\n"; |
|
| 549 | 549 | } |
| 550 | 550 | $header .= "\"Last-Translator: Generated automatically from Drupal translate interface\\n\"\n"; |
| 551 | 551 | $header .= "\"MIME-Version: 1.0\\n\"\n"; |
| 552 | 552 | $header .= "\"Content-Type: text/plain; charset=utf-8\\n\"\n"; |
| 553 | 553 | $header .= "\"Content-Transfer-Encoding: 8bit\\n\"\n"; |
| 554 | 554 | if (isset($language)) { |
| 555 | - $header .= "\"Language: ".$language->language."\\n\""; |
|
| 556 | - if ($language->formula && $language->plurals) { |
|
| 555 | + $header .= "\"Language: ".$language->language."\\n\""; |
|
| 556 | + if ($language->formula && $language->plurals) { |
|
| 557 | 557 | $header .= "\"Plural-Forms: nplurals=" . $language->plurals . "; plural=" . strtr($language->formula, array('$' => '')) . ";\\n\"\n"; |
| 558 | - } |
|
| 558 | + } |
|
| 559 | 559 | } |
| 560 | 560 | $header .= "\"X-Poedit-SourceCharset: utf-8\\n\"\n"; |
| 561 | - } |
|
| 561 | + } |
|
| 562 | 562 | |
| 563 | - $output = $header . "\n"; |
|
| 563 | + $output = $header . "\n"; |
|
| 564 | 564 | |
| 565 | - foreach ($strings as $lid => $string) { |
|
| 565 | + foreach ($strings as $lid => $string) { |
|
| 566 | 566 | // Only process non-children, children are output below their parent. |
| 567 | 567 | if (!isset($string['child'])) { |
| 568 | - if ($string['comment']) { |
|
| 568 | + if ($string['comment']) { |
|
| 569 | 569 | $output .= '#: ' . $string['comment'] . "\n"; |
| 570 | - } |
|
| 571 | - if ($string['context']) { |
|
| 570 | + } |
|
| 571 | + if ($string['context']) { |
|
| 572 | 572 | $output .= 'msgctxt "' . $string['context'] . "\"\n"; |
| 573 | - } |
|
| 574 | - $output .= 'msgid ' . _locale_export_string($string['source']); |
|
| 575 | - if (!empty($string['plural'])) { |
|
| 573 | + } |
|
| 574 | + $output .= 'msgid ' . _locale_export_string($string['source']); |
|
| 575 | + if (!empty($string['plural'])) { |
|
| 576 | 576 | $plural = $string['plural']; |
| 577 | 577 | $output .= 'msgid_plural ' . _locale_export_string($strings[$plural]['source']); |
| 578 | 578 | if (isset($language)) { |
| 579 | - $translation = $string['translation']; |
|
| 580 | - for ($i = 0; $i < $language->plurals; $i++) { |
|
| 579 | + $translation = $string['translation']; |
|
| 580 | + for ($i = 0; $i < $language->plurals; $i++) { |
|
| 581 | 581 | $output .= 'msgstr[' . $i . '] ' . _locale_export_string($translation); |
| 582 | 582 | if ($plural) { |
| 583 | - $translation = _locale_export_remove_plural($strings[$plural]['translation']); |
|
| 584 | - $plural = isset($strings[$plural]['plural']) ? $strings[$plural]['plural'] : 0; |
|
| 583 | + $translation = _locale_export_remove_plural($strings[$plural]['translation']); |
|
| 584 | + $plural = isset($strings[$plural]['plural']) ? $strings[$plural]['plural'] : 0; |
|
| 585 | 585 | } |
| 586 | 586 | else { |
| 587 | - $translation = ''; |
|
| 587 | + $translation = ''; |
|
| 588 | + } |
|
| 588 | 589 | } |
| 589 | - } |
|
| 590 | 590 | } |
| 591 | 591 | else { |
| 592 | - $output .= 'msgstr[0] ""' . "\n"; |
|
| 593 | - $output .= 'msgstr[1] ""' . "\n"; |
|
| 592 | + $output .= 'msgstr[0] ""' . "\n"; |
|
| 593 | + $output .= 'msgstr[1] ""' . "\n"; |
|
| 594 | + } |
|
| 594 | 595 | } |
| 595 | - } |
|
| 596 | - else { |
|
| 596 | + else { |
|
| 597 | 597 | $output .= 'msgstr ' . _locale_export_string($string['translation']); |
| 598 | - } |
|
| 599 | - $output .= "\n"; |
|
| 598 | + } |
|
| 599 | + $output .= "\n"; |
|
| 600 | 600 | } |
| 601 | - } |
|
| 602 | - return $output; |
|
| 601 | + } |
|
| 602 | + return $output; |
|
| 603 | 603 | } |
| 604 | 604 | |
| 605 | 605 | /** |
| 606 | 606 | * |
| 607 | 607 | */ |
| 608 | 608 | function boinctranslate_refresh_translations() { |
| 609 | - require_once(getcwd() . '/includes/locale.inc'); |
|
| 610 | - $errors = array(); |
|
| 611 | - $languages = locale_language_list(); |
|
| 612 | - $translation_resources = array(); |
|
| 613 | - $operations = array(); |
|
| 614 | - $debug_mode = variable_get('boinc_debug_mode', 0); |
|
| 615 | - |
|
| 616 | - $boinc_name = variable_get( |
|
| 609 | + require_once(getcwd() . '/includes/locale.inc'); |
|
| 610 | + $errors = array(); |
|
| 611 | + $languages = locale_language_list(); |
|
| 612 | + $translation_resources = array(); |
|
| 613 | + $operations = array(); |
|
| 614 | + $debug_mode = variable_get('boinc_debug_mode', 0); |
|
| 615 | + |
|
| 616 | + $boinc_name = variable_get( |
|
| 617 | 617 | 'boinc_translate_transifex_standard_name', '' |
| 618 | - ); |
|
| 619 | - $boinc_resources = boinctranslate_parse_resources( |
|
| 618 | + ); |
|
| 619 | + $boinc_resources = boinctranslate_parse_resources( |
|
| 620 | 620 | variable_get('boinc_translate_transifex_standard_resources', array()) |
| 621 | - ); |
|
| 622 | - // Add the Official BOINC resource to the list of BOINC resources; |
|
| 623 | - // The official resource overrides any additional resources provided, so it |
|
| 624 | - // should be added to the end so as to be processed last |
|
| 625 | - $drupal_resource = variable_get( |
|
| 621 | + ); |
|
| 622 | + // Add the Official BOINC resource to the list of BOINC resources; |
|
| 623 | + // The official resource overrides any additional resources provided, so it |
|
| 624 | + // should be added to the end so as to be processed last |
|
| 625 | + $drupal_resource = variable_get( |
|
| 626 | 626 | 'boinc_translate_transifex_boinc_drupal_resource', '' |
| 627 | - ); |
|
| 628 | - $boinc_resources[] = $drupal_resource; |
|
| 629 | - if ($boinc_name AND $boinc_resources) { |
|
| 627 | + ); |
|
| 628 | + $boinc_resources[] = $drupal_resource; |
|
| 629 | + if ($boinc_name AND $boinc_resources) { |
|
| 630 | 630 | $translation_resources[$boinc_name] = array( |
| 631 | - 'resources' => $boinc_resources, |
|
| 632 | - 'textgroups' => array( |
|
| 631 | + 'resources' => $boinc_resources, |
|
| 632 | + 'textgroups' => array( |
|
| 633 | 633 | 'boinc', |
| 634 | 634 | 'default', |
| 635 | 635 | 'taxonomy', |
| 636 | 636 | 'views', |
| 637 | - ), |
|
| 637 | + ), |
|
| 638 | 638 | ); |
| 639 | - } |
|
| 640 | - $project_name = variable_get( |
|
| 639 | + } |
|
| 640 | + $project_name = variable_get( |
|
| 641 | 641 | 'boinc_translate_transifex_project_name', '' |
| 642 | - ); |
|
| 643 | - $project_resources = boinctranslate_parse_resources( |
|
| 642 | + ); |
|
| 643 | + $project_resources = boinctranslate_parse_resources( |
|
| 644 | 644 | variable_get('boinc_translate_transifex_project_resources', array()) |
| 645 | - ); |
|
| 646 | - if ($project_name AND $project_resources) { |
|
| 645 | + ); |
|
| 646 | + if ($project_name AND $project_resources) { |
|
| 647 | 647 | $translation_resources[$project_name] = array( |
| 648 | - 'resources' => $project_resources, |
|
| 649 | - 'textgroups' => array( |
|
| 648 | + 'resources' => $project_resources, |
|
| 649 | + 'textgroups' => array( |
|
| 650 | 650 | 'blocks', |
| 651 | 651 | 'menu', |
| 652 | 652 | 'project', |
| 653 | - ), |
|
| 653 | + ), |
|
| 654 | 654 | ); |
| 655 | 655 | // Be sure any strings from the override file are added to the boinc group |
| 656 | 656 | $override_file = './' . drupal_get_path('module', 'boinctranslate') . '/includes/other-boinc-translation-strings.txt'; |
| 657 | 657 | $other_strings = file($override_file); |
| 658 | 658 | if ($other_strings) { |
| 659 | - foreach ($other_strings as $string) { |
|
| 659 | + foreach ($other_strings as $string) { |
|
| 660 | 660 | $string = trim($string); |
| 661 | 661 | if ($string) { |
| 662 | - // Ignore lines starting with '#' i.e., comments. |
|
| 663 | - if ($string[0] === "#") |
|
| 662 | + // Ignore lines starting with '#' i.e., comments. |
|
| 663 | + if ($string[0] === "#") |
|
| 664 | 664 | continue; |
| 665 | 665 | |
| 666 | - // Use '|' as delimiter to split string and context info. |
|
| 667 | - $line = explode("|", $string); |
|
| 668 | - if ($line) { |
|
| 666 | + // Use '|' as delimiter to split string and context info. |
|
| 667 | + $line = explode("|", $string); |
|
| 668 | + if ($line) { |
|
| 669 | 669 | if (count($line)==1) { |
| 670 | - $tl0 = trim($line[0]); |
|
| 671 | - if ($tl0) { |
|
| 670 | + $tl0 = trim($line[0]); |
|
| 671 | + if ($tl0) { |
|
| 672 | 672 | bts($tl0); |
| 673 | - } |
|
| 673 | + } |
|
| 674 | 674 | } |
| 675 | 675 | elseif (count($line)>1) { |
| 676 | - $tl0 = trim($line[0]); |
|
| 677 | - $tl1 = trim($line[1]); |
|
| 678 | - if ($tl0 and $tl1) { |
|
| 676 | + $tl0 = trim($line[0]); |
|
| 677 | + $tl1 = trim($line[1]); |
|
| 678 | + if ($tl0 and $tl1) { |
|
| 679 | 679 | bts($tl0, array(), NULL, $tl1); |
| 680 | - } |
|
| 680 | + } |
|
| 681 | 681 | } |
| 682 | - }// if ($line) |
|
| 682 | + }// if ($line) |
|
| 683 | 683 | |
| 684 | 684 | }// if ($string) |
| 685 | - }// foreach |
|
| 685 | + }// foreach |
|
| 686 | 686 | }// if ($other_strings) |
| 687 | - } |
|
| 687 | + } |
|
| 688 | 688 | |
| 689 | - foreach ($languages as $langcode => $language) { |
|
| 689 | + foreach ($languages as $langcode => $language) { |
|
| 690 | 690 | if ($langcode == 'en') { |
| 691 | - continue; |
|
| 691 | + continue; |
|
| 692 | 692 | } |
| 693 | 693 | |
| 694 | 694 | $import_stats = array( |
| 695 | - 'new' => 0, |
|
| 696 | - 'updated' => 0, |
|
| 697 | - 'deleted' => 0, |
|
| 698 | - 'skipped' => 0, |
|
| 695 | + 'new' => 0, |
|
| 696 | + 'updated' => 0, |
|
| 697 | + 'deleted' => 0, |
|
| 698 | + 'skipped' => 0, |
|
| 699 | 699 | ); |
| 700 | 700 | |
| 701 | 701 | foreach ($translation_resources as $project => $translation) { |
| 702 | - foreach ($translation['resources'] as $resource) { |
|
| 702 | + foreach ($translation['resources'] as $resource) { |
|
| 703 | 703 | |
| 704 | 704 | // Add this language to the batch operations |
| 705 | 705 | $operations[] = array( |
| 706 | - 'boinctranslate_refresh_translations_op', |
|
| 707 | - array( |
|
| 706 | + 'boinctranslate_refresh_translations_op', |
|
| 707 | + array( |
|
| 708 | 708 | $project, $resource, $langcode, $language, $translation['textgroups'], $debug_mode |
| 709 | - ), |
|
| 709 | + ), |
|
| 710 | 710 | ); |
| 711 | - } |
|
| 711 | + } |
|
| 712 | 712 | } |
| 713 | 713 | if ($batch = locale_batch_by_language($langcode)) { |
| 714 | - foreach ($batch['operations'] as $op) { |
|
| 714 | + foreach ($batch['operations'] as $op) { |
|
| 715 | 715 | $operations[] = array( |
| 716 | - 'boinctranslate_refresh_translations_op', |
|
| 717 | - array( |
|
| 716 | + 'boinctranslate_refresh_translations_op', |
|
| 717 | + array( |
|
| 718 | 718 | NULL, $op[1][0], $langcode, $language, array('default'), $debug_mode |
| 719 | - ), |
|
| 719 | + ), |
|
| 720 | 720 | ); |
| 721 | - } |
|
| 721 | + } |
|
| 722 | + } |
|
| 722 | 723 | } |
| 723 | - } |
|
| 724 | 724 | |
| 725 | - $batch = array( |
|
| 725 | + $batch = array( |
|
| 726 | 726 | 'operations' => $operations, |
| 727 | 727 | 'finished' => 'boinctranslate_refresh_translations_finished', |
| 728 | 728 | 'title' => t('Importing translations'), |
| 729 | 729 | 'init_message' => t('Beginning translation import...'), |
| 730 | 730 | 'progress_message' => t('Applied @current out of @total translation updates.'), |
| 731 | 731 | 'error_message' => t('Translation import has encountered an error.'), |
| 732 | - ); |
|
| 732 | + ); |
|
| 733 | 733 | |
| 734 | - batch_set($batch); |
|
| 735 | - batch_process(); |
|
| 734 | + batch_set($batch); |
|
| 735 | + batch_process(); |
|
| 736 | 736 | } |
| 737 | 737 | |
| 738 | 738 | |
@@ -741,18 +741,18 @@ discard block |
||
| 741 | 741 | */ |
| 742 | 742 | function boinctranslate_refresh_translations_op($project, $resource, $langcode, $language, $textgroups, $debug_mode, &$context) { |
| 743 | 743 | |
| 744 | - require_once(getcwd() . '/includes/locale.inc'); |
|
| 744 | + require_once(getcwd() . '/includes/locale.inc'); |
|
| 745 | 745 | |
| 746 | - if ($debug_mode) { |
|
| 746 | + if ($debug_mode) { |
|
| 747 | 747 | watchdog( |
| 748 | - 'boinctranslate', |
|
| 749 | - 'Checking for @language updates in @project:@resource', |
|
| 750 | - array('@language' => $language, '@project' => $project, '@resource' => $resource), |
|
| 751 | - WATCHDOG_INFO |
|
| 748 | + 'boinctranslate', |
|
| 749 | + 'Checking for @language updates in @project:@resource', |
|
| 750 | + array('@language' => $language, '@project' => $project, '@resource' => $resource), |
|
| 751 | + WATCHDOG_INFO |
|
| 752 | 752 | ); |
| 753 | - } |
|
| 753 | + } |
|
| 754 | 754 | |
| 755 | - if ($project) { |
|
| 755 | + if ($project) { |
|
| 756 | 756 | // Import the configured resources |
| 757 | 757 | $success = FALSE; |
| 758 | 758 | $message = ''; |
@@ -760,10 +760,10 @@ discard block |
||
| 760 | 760 | $response = boinctranslate_transifex_request($path); |
| 761 | 761 | |
| 762 | 762 | if ($response == '404 NOT FOUND') { |
| 763 | - $message = "Project resource {$project}:{$resource} not found in {$language}."; |
|
| 763 | + $message = "Project resource {$project}:{$resource} not found in {$language}."; |
|
| 764 | 764 | } |
| 765 | 765 | elseif ($response) { |
| 766 | - if (!empty($response['content'])) { |
|
| 766 | + if (!empty($response['content'])) { |
|
| 767 | 767 | $po_text = $response['content']; |
| 768 | 768 | |
| 769 | 769 | // Write the translation file to a temporary location |
@@ -771,163 +771,163 @@ discard block |
||
| 771 | 771 | $file->filepath = file_save_data($po_text, NULL); |
| 772 | 772 | $file->filename = basename($file->filepath); |
| 773 | 773 | if (!$file->filepath) { |
| 774 | - $message = 'Unable to create temporary file in ' |
|
| 774 | + $message = 'Unable to create temporary file in ' |
|
| 775 | 775 | . file_directory_temp() . " for {$language} translation " |
| 776 | 776 | . "resource {$project}:{$resource}"; |
| 777 | 777 | } |
| 778 | 778 | |
| 779 | 779 | foreach ($textgroups as $textgroup) { |
| 780 | - // Import the translations from the file to each related textgroup |
|
| 781 | - if (!$results = _boinctranslate_locale_import_po($file, $langcode, LOCALE_IMPORT_OVERWRITE, $textgroup)) { |
|
| 780 | + // Import the translations from the file to each related textgroup |
|
| 781 | + if (!$results = _boinctranslate_locale_import_po($file, $langcode, LOCALE_IMPORT_OVERWRITE, $textgroup)) { |
|
| 782 | 782 | $message = "The {$language} translation import of" |
| 783 | - . " {$project}:{$resource} failed."; |
|
| 783 | + . " {$project}:{$resource} failed."; |
|
| 784 | 784 | $success = FALSE; |
| 785 | 785 | break; |
| 786 | - } |
|
| 787 | - else { |
|
| 786 | + } |
|
| 787 | + else { |
|
| 788 | 788 | $success = TRUE; |
| 789 | - } |
|
| 789 | + } |
|
| 790 | + } |
|
| 790 | 791 | } |
| 791 | - } |
|
| 792 | - else { |
|
| 792 | + else { |
|
| 793 | 793 | $message = "Unable to read response for {$language} translation import" |
| 794 | - . " of {$project}:{$resource}."; |
|
| 795 | - } |
|
| 794 | + . " of {$project}:{$resource}."; |
|
| 795 | + } |
|
| 796 | 796 | } |
| 797 | 797 | else { |
| 798 | - $message = "Translation data not found in response for {$language}" |
|
| 798 | + $message = "Translation data not found in response for {$language}" |
|
| 799 | 799 | . " translation import of {$project}:{$resource}."; |
| 800 | 800 | } |
| 801 | - } |
|
| 802 | - else { |
|
| 801 | + } |
|
| 802 | + else { |
|
| 803 | 803 | // If project isn't specified, import as a local Drupal resource |
| 804 | 804 | $project = 'drupal.local'; |
| 805 | 805 | $file = new stdClass(); |
| 806 | 806 | $file->filepath = $resource; |
| 807 | 807 | $file->filename = basename($file->filepath); |
| 808 | 808 | if (!$results = _boinctranslate_locale_import_po($file, $langcode, LOCALE_IMPORT_OVERWRITE, $textgroup)) { |
| 809 | - $message = "The {$language} translation import of" |
|
| 809 | + $message = "The {$language} translation import of" |
|
| 810 | 810 | . " local file {$resource} failed."; |
| 811 | - $success = FALSE; |
|
| 811 | + $success = FALSE; |
|
| 812 | 812 | } |
| 813 | 813 | else { |
| 814 | - $success = TRUE; |
|
| 814 | + $success = TRUE; |
|
| 815 | + } |
|
| 815 | 816 | } |
| 816 | - } |
|
| 817 | 817 | |
| 818 | - if ($success) { |
|
| 818 | + if ($success) { |
|
| 819 | 819 | // Store some result for post-processing in the finished callback. |
| 820 | 820 | $context['results']['success'][] = "{$langcode}:{$textgroup}"; |
| 821 | 821 | $message = "Imported {$language} translations in {$project}:{$resource} ({$results['new']} added, {$results['updated']} refreshed, {$results['deleted']} removed)"; |
| 822 | 822 | |
| 823 | 823 | if ($debug_mode) { |
| 824 | - watchdog( |
|
| 824 | + watchdog( |
|
| 825 | 825 | 'boinctranslate', |
| 826 | 826 | $message, |
| 827 | 827 | array(), |
| 828 | 828 | WATCHDOG_INFO |
| 829 | - ); |
|
| 829 | + ); |
|
| 830 | 830 | } |
| 831 | - } |
|
| 832 | - else { |
|
| 831 | + } |
|
| 832 | + else { |
|
| 833 | 833 | $context['results']['failure'][] = "{$langcode}:{$textgroup}"; |
| 834 | 834 | watchdog( |
| 835 | - 'boinctranslate', |
|
| 836 | - $message, |
|
| 837 | - array(), |
|
| 838 | - WATCHDOG_WARNING |
|
| 835 | + 'boinctranslate', |
|
| 836 | + $message, |
|
| 837 | + array(), |
|
| 838 | + WATCHDOG_WARNING |
|
| 839 | 839 | ); |
| 840 | - } |
|
| 840 | + } |
|
| 841 | 841 | |
| 842 | - // Update our progress information. |
|
| 843 | - $context['sandbox']['progress']++; |
|
| 844 | - $context['sandbox']['language'] = $langcode; |
|
| 845 | - $context['message'] = $message; |
|
| 842 | + // Update our progress information. |
|
| 843 | + $context['sandbox']['progress']++; |
|
| 844 | + $context['sandbox']['language'] = $langcode; |
|
| 845 | + $context['message'] = $message; |
|
| 846 | 846 | |
| 847 | - // Update the progress for the batch engine |
|
| 848 | - if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 847 | + // Update the progress for the batch engine |
|
| 848 | + if ($context['sandbox']['progress'] >= $context['sandbox']['max']) { |
|
| 849 | 849 | $context['finished'] = 1; |
| 850 | - } |
|
| 851 | - else { |
|
| 850 | + } |
|
| 851 | + else { |
|
| 852 | 852 | $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; |
| 853 | - } |
|
| 853 | + } |
|
| 854 | 854 | } |
| 855 | 855 | |
| 856 | 856 | /** |
| 857 | 857 | * Batch 'finished' callback |
| 858 | 858 | */ |
| 859 | 859 | function boinctranslate_refresh_translations_finished($success, $results, $operations) { |
| 860 | - if ($success) { |
|
| 860 | + if ($success) { |
|
| 861 | 861 | // Let's count our successes |
| 862 | 862 | $count = count($results['success']); |
| 863 | 863 | $message = "Successfully completed {$count} import operations"; |
| 864 | 864 | watchdog( |
| 865 | - 'boinctranslate', |
|
| 866 | - 'Successfully completed @count import operations.', |
|
| 867 | - array('@count' => $count), |
|
| 868 | - WATCHDOG_INFO |
|
| 865 | + 'boinctranslate', |
|
| 866 | + 'Successfully completed @count import operations.', |
|
| 867 | + array('@count' => $count), |
|
| 868 | + WATCHDOG_INFO |
|
| 869 | 869 | ); |
| 870 | - } |
|
| 871 | - else { |
|
| 870 | + } |
|
| 871 | + else { |
|
| 872 | 872 | // An error occurred. |
| 873 | 873 | // $operations contains the operations that remained unprocessed. |
| 874 | 874 | $error_operation = reset($operations); |
| 875 | 875 | $message = 'An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE); |
| 876 | 876 | watchdog( |
| 877 | - 'boinctranslate', |
|
| 878 | - $message, |
|
| 879 | - array(), |
|
| 880 | - WATCHDOG_WARNING |
|
| 877 | + 'boinctranslate', |
|
| 878 | + $message, |
|
| 879 | + array(), |
|
| 880 | + WATCHDOG_WARNING |
|
| 881 | 881 | ); |
| 882 | - } |
|
| 883 | - drupal_set_message($message); |
|
| 884 | - drupal_goto('admin/boinc/translation'); |
|
| 882 | + } |
|
| 883 | + drupal_set_message($message); |
|
| 884 | + drupal_goto('admin/boinc/translation'); |
|
| 885 | 885 | } |
| 886 | 886 | |
| 887 | 887 | /** |
| 888 | 888 | * |
| 889 | 889 | */ |
| 890 | 890 | function _boinctranslate_locale_import_po($file, $langcode, $mode, $group = NULL) { |
| 891 | - // Try to allocate enough time to parse and import the data. |
|
| 892 | - if (function_exists('set_time_limit')) { |
|
| 891 | + // Try to allocate enough time to parse and import the data. |
|
| 892 | + if (function_exists('set_time_limit')) { |
|
| 893 | 893 | @set_time_limit(240); |
| 894 | - } |
|
| 894 | + } |
|
| 895 | 895 | |
| 896 | - require_once(getcwd() . '/includes/locale.inc'); |
|
| 896 | + require_once(getcwd() . '/includes/locale.inc'); |
|
| 897 | 897 | |
| 898 | - // Check if we have the language already in the database. |
|
| 899 | - if (!db_fetch_object(db_query("SELECT language FROM {languages} WHERE language = '%s'", $langcode))) { |
|
| 898 | + // Check if we have the language already in the database. |
|
| 899 | + if (!db_fetch_object(db_query("SELECT language FROM {languages} WHERE language = '%s'", $langcode))) { |
|
| 900 | 900 | drupal_set_message(t('The language selected for import is not supported.'), 'error'); |
| 901 | 901 | return FALSE; |
| 902 | - } |
|
| 902 | + } |
|
| 903 | 903 | |
| 904 | - // Get strings from file (returns on failure after a partial import, or on success) |
|
| 905 | - $status = _boinctranslate_locale_import_read_po('db-store', $file, $mode, $langcode, $group); |
|
| 906 | - if ($status === FALSE) { |
|
| 904 | + // Get strings from file (returns on failure after a partial import, or on success) |
|
| 905 | + $status = _boinctranslate_locale_import_read_po('db-store', $file, $mode, $langcode, $group); |
|
| 906 | + if ($status === FALSE) { |
|
| 907 | 907 | // Error messages are set in _locale_import_read_po(). |
| 908 | 908 | return FALSE; |
| 909 | - } |
|
| 909 | + } |
|
| 910 | 910 | |
| 911 | - // Get status information on import process. |
|
| 912 | - list($headerdone, $additions, $updates, $deletes, $skips) = _boinctranslate_locale_import_one_string('db-report'); |
|
| 911 | + // Get status information on import process. |
|
| 912 | + list($headerdone, $additions, $updates, $deletes, $skips) = _boinctranslate_locale_import_one_string('db-report'); |
|
| 913 | 913 | |
| 914 | - if (!$headerdone) { |
|
| 914 | + if (!$headerdone) { |
|
| 915 | 915 | drupal_set_message(t('The translation file %filename appears to have a missing or malformed header.', array('%filename' => $file->filename)), 'error'); |
| 916 | - } |
|
| 916 | + } |
|
| 917 | 917 | |
| 918 | - // Clear cache and force refresh of JavaScript translations. |
|
| 919 | - _locale_invalidate_js($langcode); |
|
| 920 | - cache_clear_all('locale:', 'cache', TRUE); |
|
| 918 | + // Clear cache and force refresh of JavaScript translations. |
|
| 919 | + _locale_invalidate_js($langcode); |
|
| 920 | + cache_clear_all('locale:', 'cache', TRUE); |
|
| 921 | 921 | |
| 922 | - // Rebuild the menu, strings may have changed. |
|
| 923 | - menu_rebuild(); |
|
| 922 | + // Rebuild the menu, strings may have changed. |
|
| 923 | + menu_rebuild(); |
|
| 924 | 924 | |
| 925 | - return array( |
|
| 925 | + return array( |
|
| 926 | 926 | 'new' => $additions, |
| 927 | 927 | 'updated' => $updates, |
| 928 | 928 | 'deleted' => $deletes, |
| 929 | 929 | 'skipped' => $skips, |
| 930 | - ); |
|
| 930 | + ); |
|
| 931 | 931 | } |
| 932 | 932 | |
| 933 | 933 | /** |
@@ -935,253 +935,253 @@ discard block |
||
| 935 | 935 | */ |
| 936 | 936 | function _boinctranslate_locale_import_read_po($op, $file, $mode = NULL, $lang = NULL, $group = 'default') { |
| 937 | 937 | |
| 938 | - require_once(getcwd() . '/includes/locale.inc'); |
|
| 938 | + require_once(getcwd() . '/includes/locale.inc'); |
|
| 939 | 939 | |
| 940 | - $fd = fopen($file->filepath, "rb"); // File will get closed by PHP on return |
|
| 941 | - if (!$fd) { |
|
| 940 | + $fd = fopen($file->filepath, "rb"); // File will get closed by PHP on return |
|
| 941 | + if (!$fd) { |
|
| 942 | 942 | watchdog( |
| 943 | - 'boinctranslate', |
|
| 944 | - 'The translation import for %lang failed, because %filename could not be read.', |
|
| 945 | - array('%lang' => $lang, '%filename' => $file->filename), |
|
| 946 | - WATCHDOG_WARNING |
|
| 943 | + 'boinctranslate', |
|
| 944 | + 'The translation import for %lang failed, because %filename could not be read.', |
|
| 945 | + array('%lang' => $lang, '%filename' => $file->filename), |
|
| 946 | + WATCHDOG_WARNING |
|
| 947 | 947 | ); |
| 948 | 948 | _locale_import_message('The translation import failed, because the file %filename could not be read.', $file); |
| 949 | 949 | return FALSE; |
| 950 | - } |
|
| 950 | + } |
|
| 951 | 951 | |
| 952 | - $context = "COMMENT"; // Parser context: COMMENT, MSGID, MSGID_PLURAL, MSGSTR and MSGSTR_ARR |
|
| 953 | - $current = array(); // Current entry being read |
|
| 954 | - $plural = 0; // Current plural form |
|
| 955 | - $lineno = 0; // Current line |
|
| 952 | + $context = "COMMENT"; // Parser context: COMMENT, MSGID, MSGID_PLURAL, MSGSTR and MSGSTR_ARR |
|
| 953 | + $current = array(); // Current entry being read |
|
| 954 | + $plural = 0; // Current plural form |
|
| 955 | + $lineno = 0; // Current line |
|
| 956 | 956 | |
| 957 | - while (!feof($fd)) { |
|
| 957 | + while (!feof($fd)) { |
|
| 958 | 958 | $line = fgets($fd, 10 * 1024); // A line should not be this long |
| 959 | 959 | if ($lineno == 0) { |
| 960 | - // The first line might come with a UTF-8 BOM, which should be removed. |
|
| 961 | - $line = str_replace("\xEF\xBB\xBF", '', $line); |
|
| 960 | + // The first line might come with a UTF-8 BOM, which should be removed. |
|
| 961 | + $line = str_replace("\xEF\xBB\xBF", '', $line); |
|
| 962 | 962 | } |
| 963 | 963 | $lineno++; |
| 964 | 964 | $line = trim(strtr($line, array("\\\n" => ""))); |
| 965 | 965 | |
| 966 | 966 | if (!strncmp("#", $line, 1)) { // A comment |
| 967 | - if ($context == "COMMENT") { // Already in comment context: add |
|
| 967 | + if ($context == "COMMENT") { // Already in comment context: add |
|
| 968 | 968 | $current["#"][] = substr($line, 1); |
| 969 | - } |
|
| 970 | - elseif (($context == "MSGSTR") || ($context == "MSGSTR_ARR")) { // End current entry, start a new one |
|
| 969 | + } |
|
| 970 | + elseif (($context == "MSGSTR") || ($context == "MSGSTR_ARR")) { // End current entry, start a new one |
|
| 971 | 971 | _boinctranslate_locale_import_one_string($op, $current, $mode, $lang, $file, $group); |
| 972 | 972 | $current = array(); |
| 973 | 973 | $current["#"][] = substr($line, 1); |
| 974 | 974 | $context = "COMMENT"; |
| 975 | - } |
|
| 976 | - else { // Parse error |
|
| 975 | + } |
|
| 976 | + else { // Parse error |
|
| 977 | 977 | watchdog( |
| 978 | - 'boinctranslate', |
|
| 979 | - 'The translation file %filename for %lang contains an error: "msgstr" was expected but not found on line %line.', |
|
| 980 | - array('%filename' => $file->filename, '%lang' => $lang, '%line' => $lineno), |
|
| 981 | - WATCHDOG_WARNING |
|
| 978 | + 'boinctranslate', |
|
| 979 | + 'The translation file %filename for %lang contains an error: "msgstr" was expected but not found on line %line.', |
|
| 980 | + array('%filename' => $file->filename, '%lang' => $lang, '%line' => $lineno), |
|
| 981 | + WATCHDOG_WARNING |
|
| 982 | 982 | ); |
| 983 | 983 | _locale_import_message('The translation file %filename contains an error: "msgstr" was expected but not found on line %line.', $file, $lineno); |
| 984 | 984 | return FALSE; |
| 985 | - } |
|
| 985 | + } |
|
| 986 | 986 | } |
| 987 | 987 | elseif (!strncmp("msgctxt", $line, 7)) { |
| 988 | - if (($context == "MSGSTR") || ($context == "MSGSTR_ARR")) { // End current entry, start a new one |
|
| 988 | + if (($context == "MSGSTR") || ($context == "MSGSTR_ARR")) { // End current entry, start a new one |
|
| 989 | 989 | _boinctranslate_locale_import_one_string($op, $current, $mode, $lang, $file, $group); |
| 990 | 990 | $current = array(); |
| 991 | - } |
|
| 992 | - elseif (($context == "MSGID") || ($context == "MSGCTXT")) { // Already in this context? Parse error |
|
| 991 | + } |
|
| 992 | + elseif (($context == "MSGID") || ($context == "MSGCTXT")) { // Already in this context? Parse error |
|
| 993 | 993 | watchdog( |
| 994 | - 'boinctranslate', |
|
| 995 | - 'The translation file %filename for %lang contains an error: "msgctxt" is unexpected on line %line.', |
|
| 996 | - array('%filename' => $file->filename, '%lang' => $lang, '%line' => $lineno), |
|
| 997 | - WATCHDOG_WARNING |
|
| 994 | + 'boinctranslate', |
|
| 995 | + 'The translation file %filename for %lang contains an error: "msgctxt" is unexpected on line %line.', |
|
| 996 | + array('%filename' => $file->filename, '%lang' => $lang, '%line' => $lineno), |
|
| 997 | + WATCHDOG_WARNING |
|
| 998 | 998 | ); |
| 999 | 999 | _locale_import_message('The translation file %filename contains an error: "msgid" is unexpected on line %line.', $file, $lineno); |
| 1000 | 1000 | return FALSE; |
| 1001 | - } |
|
| 1002 | - $line = trim(substr($line, 7)); |
|
| 1003 | - $quoted = _locale_import_parse_quoted($line); |
|
| 1004 | - if ($quoted === FALSE) { |
|
| 1001 | + } |
|
| 1002 | + $line = trim(substr($line, 7)); |
|
| 1003 | + $quoted = _locale_import_parse_quoted($line); |
|
| 1004 | + if ($quoted === FALSE) { |
|
| 1005 | 1005 | watchdog( |
| 1006 | - 'boinctranslate', |
|
| 1007 | - 'The translation file %filename for language %lang contains a syntax error on line %line.', |
|
| 1008 | - array('%filename' => $file->filename, '%lang' => $lang, '%line' => $lineno), |
|
| 1009 | - WATCHDOG_WARNING |
|
| 1006 | + 'boinctranslate', |
|
| 1007 | + 'The translation file %filename for language %lang contains a syntax error on line %line.', |
|
| 1008 | + array('%filename' => $file->filename, '%lang' => $lang, '%line' => $lineno), |
|
| 1009 | + WATCHDOG_WARNING |
|
| 1010 | 1010 | ); |
| 1011 | 1011 | _locale_import_message('The translation file %filename contains a syntax error on line %line.', $file, $lineno); |
| 1012 | 1012 | return FALSE; |
| 1013 | - } |
|
| 1014 | - $current["msgctxt"] = $quoted; |
|
| 1015 | - $context = "MSGCTXT"; |
|
| 1013 | + } |
|
| 1014 | + $current["msgctxt"] = $quoted; |
|
| 1015 | + $context = "MSGCTXT"; |
|
| 1016 | 1016 | } |
| 1017 | 1017 | elseif (!strncmp("msgid_plural", $line, 12)) { |
| 1018 | - if ($context != "MSGID") { // Must be plural form for current entry |
|
| 1018 | + if ($context != "MSGID") { // Must be plural form for current entry |
|
| 1019 | 1019 | watchdog( |
| 1020 | - 'boinctranslate', |
|
| 1021 | - 'The translation file %filename for %lang contains an error: "msgid_plural" was expected but not found on line %line.', |
|
| 1022 | - array('%filename' => $file->filename, '%lang' => $lang, '%line' => $lineno), |
|
| 1023 | - WATCHDOG_WARNING |
|
| 1020 | + 'boinctranslate', |
|
| 1021 | + 'The translation file %filename for %lang contains an error: "msgid_plural" was expected but not found on line %line.', |
|
| 1022 | + array('%filename' => $file->filename, '%lang' => $lang, '%line' => $lineno), |
|
| 1023 | + WATCHDOG_WARNING |
|
| 1024 | 1024 | ); |
| 1025 | 1025 | _locale_import_message('The translation file %filename contains an error: "msgid_plural" was expected but not found on line %line.', $file, $lineno); |
| 1026 | 1026 | return FALSE; |
| 1027 | - } |
|
| 1028 | - $line = trim(substr($line, 12)); |
|
| 1029 | - $quoted = _locale_import_parse_quoted($line); |
|
| 1030 | - if ($quoted === FALSE) { |
|
| 1027 | + } |
|
| 1028 | + $line = trim(substr($line, 12)); |
|
| 1029 | + $quoted = _locale_import_parse_quoted($line); |
|
| 1030 | + if ($quoted === FALSE) { |
|
| 1031 | 1031 | watchdog( |
| 1032 | - 'boinctranslate', |
|
| 1033 | - 'The translation file %filename for language %lang contains a syntax error on line %line.', |
|
| 1034 | - array('%filename' => $file->filename, '%lang' => $lang, '%line' => $lineno), |
|
| 1035 | - WATCHDOG_WARNING |
|
| 1032 | + 'boinctranslate', |
|
| 1033 | + 'The translation file %filename for language %lang contains a syntax error on line %line.', |
|
| 1034 | + array('%filename' => $file->filename, '%lang' => $lang, '%line' => $lineno), |
|
| 1035 | + WATCHDOG_WARNING |
|
| 1036 | 1036 | ); |
| 1037 | 1037 | _locale_import_message('The translation file %filename contains a syntax error on line %line.', $file, $lineno); |
| 1038 | 1038 | return FALSE; |
| 1039 | - } |
|
| 1040 | - $current["msgid"] = $current["msgid"] . "\0" . $quoted; |
|
| 1041 | - $context = "MSGID_PLURAL"; |
|
| 1039 | + } |
|
| 1040 | + $current["msgid"] = $current["msgid"] . "\0" . $quoted; |
|
| 1041 | + $context = "MSGID_PLURAL"; |
|
| 1042 | 1042 | } |
| 1043 | 1043 | elseif (!strncmp("msgid", $line, 5)) { |
| 1044 | - if (($context == "MSGSTR") || ($context == "MSGSTR_ARR")) { // End current entry, start a new one |
|
| 1044 | + if (($context == "MSGSTR") || ($context == "MSGSTR_ARR")) { // End current entry, start a new one |
|
| 1045 | 1045 | _boinctranslate_locale_import_one_string($op, $current, $mode, $lang, $file, $group); |
| 1046 | 1046 | $current = array(); |
| 1047 | - } |
|
| 1048 | - elseif ($context == "MSGID") { // Already in this context? Parse error |
|
| 1047 | + } |
|
| 1048 | + elseif ($context == "MSGID") { // Already in this context? Parse error |
|
| 1049 | 1049 | watchdog( |
| 1050 | - 'boinctranslate', |
|
| 1051 | - 'The translation file %filename for %lang contains an error: "msgid" is unexpected on line %line.', |
|
| 1052 | - array('%filename' => $file->filename, '%lang' => $lang, '%line' => $lineno), |
|
| 1053 | - WATCHDOG_WARNING |
|
| 1050 | + 'boinctranslate', |
|
| 1051 | + 'The translation file %filename for %lang contains an error: "msgid" is unexpected on line %line.', |
|
| 1052 | + array('%filename' => $file->filename, '%lang' => $lang, '%line' => $lineno), |
|
| 1053 | + WATCHDOG_WARNING |
|
| 1054 | 1054 | ); |
| 1055 | 1055 | _locale_import_message('The translation file %filename contains an error: "msgid" is unexpected on line %line.', $file, $lineno); |
| 1056 | 1056 | return FALSE; |
| 1057 | - } |
|
| 1058 | - $line = trim(substr($line, 5)); |
|
| 1059 | - $quoted = _locale_import_parse_quoted($line); |
|
| 1060 | - if ($quoted === FALSE) { |
|
| 1057 | + } |
|
| 1058 | + $line = trim(substr($line, 5)); |
|
| 1059 | + $quoted = _locale_import_parse_quoted($line); |
|
| 1060 | + if ($quoted === FALSE) { |
|
| 1061 | 1061 | watchdog( |
| 1062 | - 'boinctranslate', |
|
| 1063 | - 'The translation file %filename for language %lang contains a syntax error on line %line.', |
|
| 1064 | - array('%filename' => $file->filename, '%lang' => $lang, '%line' => $lineno), |
|
| 1065 | - WATCHDOG_WARNING |
|
| 1062 | + 'boinctranslate', |
|
| 1063 | + 'The translation file %filename for language %lang contains a syntax error on line %line.', |
|
| 1064 | + array('%filename' => $file->filename, '%lang' => $lang, '%line' => $lineno), |
|
| 1065 | + WATCHDOG_WARNING |
|
| 1066 | 1066 | ); |
| 1067 | 1067 | _locale_import_message('The translation file %filename contains a syntax error on line %line.', $file, $lineno); |
| 1068 | 1068 | return FALSE; |
| 1069 | - } |
|
| 1070 | - $current["msgid"] = $quoted; |
|
| 1071 | - $context = "MSGID"; |
|
| 1069 | + } |
|
| 1070 | + $current["msgid"] = $quoted; |
|
| 1071 | + $context = "MSGID"; |
|
| 1072 | 1072 | } |
| 1073 | 1073 | elseif (!strncmp("msgstr[", $line, 7)) { |
| 1074 | - if (($context != "MSGID") && ($context != "MSGID_PLURAL") && ($context != "MSGSTR_ARR")) { // Must come after msgid, msgid_plural, or msgstr[] |
|
| 1074 | + if (($context != "MSGID") && ($context != "MSGID_PLURAL") && ($context != "MSGSTR_ARR")) { // Must come after msgid, msgid_plural, or msgstr[] |
|
| 1075 | 1075 | watchdog( |
| 1076 | - 'boinctranslate', |
|
| 1077 | - 'The translation file %filename for %lang contains an error: "msgstr[]" is unexpected on line %line.', |
|
| 1078 | - array('%filename' => $file->filename, '%lang' => $lang, '%line' => $lineno), |
|
| 1079 | - WATCHDOG_WARNING |
|
| 1076 | + 'boinctranslate', |
|
| 1077 | + 'The translation file %filename for %lang contains an error: "msgstr[]" is unexpected on line %line.', |
|
| 1078 | + array('%filename' => $file->filename, '%lang' => $lang, '%line' => $lineno), |
|
| 1079 | + WATCHDOG_WARNING |
|
| 1080 | 1080 | ); |
| 1081 | 1081 | _locale_import_message('The translation file %filename contains an error: "msgstr[]" is unexpected on line %line.', $file, $lineno); |
| 1082 | 1082 | return FALSE; |
| 1083 | - } |
|
| 1084 | - if (strpos($line, "]") === FALSE) { |
|
| 1083 | + } |
|
| 1084 | + if (strpos($line, "]") === FALSE) { |
|
| 1085 | 1085 | watchdog( |
| 1086 | - 'boinctranslate', |
|
| 1087 | - 'The translation file %filename for language %lang contains a syntax error on line %line.', |
|
| 1088 | - array('%filename' => $file->filename, '%lang' => $lang, '%line' => $lineno), |
|
| 1089 | - WATCHDOG_WARNING |
|
| 1086 | + 'boinctranslate', |
|
| 1087 | + 'The translation file %filename for language %lang contains a syntax error on line %line.', |
|
| 1088 | + array('%filename' => $file->filename, '%lang' => $lang, '%line' => $lineno), |
|
| 1089 | + WATCHDOG_WARNING |
|
| 1090 | 1090 | ); |
| 1091 | 1091 | _locale_import_message('The translation file %filename contains a syntax error on line %line.', $file, $lineno); |
| 1092 | 1092 | return FALSE; |
| 1093 | - } |
|
| 1094 | - $frombracket = strstr($line, "["); |
|
| 1095 | - $plural = substr($frombracket, 1, strpos($frombracket, "]") - 1); |
|
| 1096 | - $line = trim(strstr($line, " ")); |
|
| 1097 | - $quoted = _locale_import_parse_quoted($line); |
|
| 1098 | - if ($quoted === FALSE) { |
|
| 1093 | + } |
|
| 1094 | + $frombracket = strstr($line, "["); |
|
| 1095 | + $plural = substr($frombracket, 1, strpos($frombracket, "]") - 1); |
|
| 1096 | + $line = trim(strstr($line, " ")); |
|
| 1097 | + $quoted = _locale_import_parse_quoted($line); |
|
| 1098 | + if ($quoted === FALSE) { |
|
| 1099 | 1099 | watchdog( |
| 1100 | - 'boinctranslate', |
|
| 1101 | - 'The translation file %filename for language %lang contains a syntax error on line %line.', |
|
| 1102 | - array('%filename' => $file->filename, '%lang' => $lang, '%line' => $lineno), |
|
| 1103 | - WATCHDOG_WARNING |
|
| 1100 | + 'boinctranslate', |
|
| 1101 | + 'The translation file %filename for language %lang contains a syntax error on line %line.', |
|
| 1102 | + array('%filename' => $file->filename, '%lang' => $lang, '%line' => $lineno), |
|
| 1103 | + WATCHDOG_WARNING |
|
| 1104 | 1104 | ); |
| 1105 | 1105 | _locale_import_message('The translation file %filename contains a syntax error on line %line.', $file, $lineno); |
| 1106 | 1106 | return FALSE; |
| 1107 | - } |
|
| 1108 | - $current["msgstr"][$plural] = $quoted; |
|
| 1109 | - $context = "MSGSTR_ARR"; |
|
| 1107 | + } |
|
| 1108 | + $current["msgstr"][$plural] = $quoted; |
|
| 1109 | + $context = "MSGSTR_ARR"; |
|
| 1110 | 1110 | } |
| 1111 | 1111 | elseif (!strncmp("msgstr", $line, 6)) { |
| 1112 | - if ($context != "MSGID") { // Should come just after a msgid block |
|
| 1112 | + if ($context != "MSGID") { // Should come just after a msgid block |
|
| 1113 | 1113 | watchdog( |
| 1114 | - 'boinctranslate', |
|
| 1115 | - 'The translation file %filename for %lang contains an error: "msgstr" is unexpected on line %line.', |
|
| 1116 | - array('%filename' => $file->filename, '%lang' => $lang, '%line' => $lineno), |
|
| 1117 | - WATCHDOG_WARNING |
|
| 1114 | + 'boinctranslate', |
|
| 1115 | + 'The translation file %filename for %lang contains an error: "msgstr" is unexpected on line %line.', |
|
| 1116 | + array('%filename' => $file->filename, '%lang' => $lang, '%line' => $lineno), |
|
| 1117 | + WATCHDOG_WARNING |
|
| 1118 | 1118 | ); |
| 1119 | 1119 | _locale_import_message('The translation file %filename contains an error: "msgstr" is unexpected on line %line.', $file, $lineno); |
| 1120 | 1120 | return FALSE; |
| 1121 | - } |
|
| 1122 | - $line = trim(substr($line, 6)); |
|
| 1123 | - $quoted = _locale_import_parse_quoted($line); |
|
| 1124 | - if ($quoted === FALSE) { |
|
| 1121 | + } |
|
| 1122 | + $line = trim(substr($line, 6)); |
|
| 1123 | + $quoted = _locale_import_parse_quoted($line); |
|
| 1124 | + if ($quoted === FALSE) { |
|
| 1125 | 1125 | watchdog( |
| 1126 | - 'boinctranslate', |
|
| 1127 | - 'The translation file %filename for language %lang contains a syntax error on line %line.', |
|
| 1128 | - array('%filename' => $file->filename, '%lang' => $lang, '%line' => $lineno), |
|
| 1129 | - WATCHDOG_WARNING |
|
| 1126 | + 'boinctranslate', |
|
| 1127 | + 'The translation file %filename for language %lang contains a syntax error on line %line.', |
|
| 1128 | + array('%filename' => $file->filename, '%lang' => $lang, '%line' => $lineno), |
|
| 1129 | + WATCHDOG_WARNING |
|
| 1130 | 1130 | ); |
| 1131 | 1131 | _locale_import_message('The translation file %filename contains a syntax error on line %line.', $file, $lineno); |
| 1132 | 1132 | return FALSE; |
| 1133 | - } |
|
| 1134 | - $current["msgstr"] = $quoted; |
|
| 1135 | - $context = "MSGSTR"; |
|
| 1133 | + } |
|
| 1134 | + $current["msgstr"] = $quoted; |
|
| 1135 | + $context = "MSGSTR"; |
|
| 1136 | 1136 | } |
| 1137 | 1137 | elseif ($line != "") { |
| 1138 | - $quoted = _locale_import_parse_quoted($line); |
|
| 1139 | - if ($quoted === FALSE) { |
|
| 1138 | + $quoted = _locale_import_parse_quoted($line); |
|
| 1139 | + if ($quoted === FALSE) { |
|
| 1140 | 1140 | watchdog( |
| 1141 | - 'boinctranslate', |
|
| 1142 | - 'The translation file %filename for language %lang contains a syntax error on line %line.', |
|
| 1143 | - array('%filename' => $file->filename, '%lang' => $lang, '%line' => $lineno), |
|
| 1144 | - WATCHDOG_WARNING |
|
| 1141 | + 'boinctranslate', |
|
| 1142 | + 'The translation file %filename for language %lang contains a syntax error on line %line.', |
|
| 1143 | + array('%filename' => $file->filename, '%lang' => $lang, '%line' => $lineno), |
|
| 1144 | + WATCHDOG_WARNING |
|
| 1145 | 1145 | ); |
| 1146 | 1146 | _locale_import_message('The translation file %filename contains a syntax error on line %line.', $file, $lineno); |
| 1147 | 1147 | return FALSE; |
| 1148 | - } |
|
| 1149 | - if (($context == "MSGID") || ($context == "MSGID_PLURAL")) { |
|
| 1148 | + } |
|
| 1149 | + if (($context == "MSGID") || ($context == "MSGID_PLURAL")) { |
|
| 1150 | 1150 | $current["msgid"] .= $quoted; |
| 1151 | - } |
|
| 1152 | - elseif ($context == "MSGSTR") { |
|
| 1151 | + } |
|
| 1152 | + elseif ($context == "MSGSTR") { |
|
| 1153 | 1153 | $current["msgstr"] .= $quoted; |
| 1154 | - } |
|
| 1155 | - elseif ($context == "MSGSTR_ARR") { |
|
| 1154 | + } |
|
| 1155 | + elseif ($context == "MSGSTR_ARR") { |
|
| 1156 | 1156 | $current["msgstr"][$plural] .= $quoted; |
| 1157 | - } |
|
| 1158 | - else { |
|
| 1157 | + } |
|
| 1158 | + else { |
|
| 1159 | 1159 | watchdog( |
| 1160 | - 'boinctranslate', |
|
| 1161 | - 'The translation file %filename for %lang contains an error: there is an unexpected string on line %line.', |
|
| 1162 | - array('%filename' => $file->filename, '%lang' => $lang, '%line' => $lineno), |
|
| 1163 | - WATCHDOG_WARNING |
|
| 1160 | + 'boinctranslate', |
|
| 1161 | + 'The translation file %filename for %lang contains an error: there is an unexpected string on line %line.', |
|
| 1162 | + array('%filename' => $file->filename, '%lang' => $lang, '%line' => $lineno), |
|
| 1163 | + WATCHDOG_WARNING |
|
| 1164 | 1164 | ); |
| 1165 | 1165 | _locale_import_message('The translation file %filename contains an error: there is an unexpected string on line %line.', $file, $lineno); |
| 1166 | 1166 | return FALSE; |
| 1167 | - } |
|
| 1167 | + } |
|
| 1168 | + } |
|
| 1168 | 1169 | } |
| 1169 | - } |
|
| 1170 | 1170 | |
| 1171 | - // End of PO file, flush last entry |
|
| 1172 | - if (($context == "MSGSTR") || ($context == "MSGSTR_ARR")) { |
|
| 1171 | + // End of PO file, flush last entry |
|
| 1172 | + if (($context == "MSGSTR") || ($context == "MSGSTR_ARR")) { |
|
| 1173 | 1173 | _boinctranslate_locale_import_one_string($op, $current, $mode, $lang, $file, $group); |
| 1174 | - } |
|
| 1175 | - elseif ($context != "COMMENT") { |
|
| 1174 | + } |
|
| 1175 | + elseif ($context != "COMMENT") { |
|
| 1176 | 1176 | watchdog( |
| 1177 | - 'boinctranslate', |
|
| 1178 | - 'The translation file %filename for %lang ended unexpectedly at line %line.', |
|
| 1179 | - array('%filename' => $file->filename, '%lang' => $lang, '%line' => $lineno), |
|
| 1180 | - WATCHDOG_WARNING |
|
| 1177 | + 'boinctranslate', |
|
| 1178 | + 'The translation file %filename for %lang ended unexpectedly at line %line.', |
|
| 1179 | + array('%filename' => $file->filename, '%lang' => $lang, '%line' => $lineno), |
|
| 1180 | + WATCHDOG_WARNING |
|
| 1181 | 1181 | ); |
| 1182 | 1182 | _locale_import_message('The translation file %filename ended unexpectedly at line %line.', $file, $lineno); |
| 1183 | 1183 | return FALSE; |
| 1184 | - } |
|
| 1184 | + } |
|
| 1185 | 1185 | |
| 1186 | 1186 | } |
| 1187 | 1187 | |
@@ -1190,28 +1190,28 @@ discard block |
||
| 1190 | 1190 | */ |
| 1191 | 1191 | function _boinctranslate_locale_import_one_string($op, $value = NULL, $mode = NULL, $lang = NULL, $file = NULL, $group = 'default') { |
| 1192 | 1192 | |
| 1193 | - require_once(getcwd() . '/includes/locale.inc'); |
|
| 1193 | + require_once(getcwd() . '/includes/locale.inc'); |
|
| 1194 | 1194 | |
| 1195 | - static $report = array( |
|
| 1195 | + static $report = array( |
|
| 1196 | 1196 | 'additions' => 0, |
| 1197 | 1197 | 'updates' => 0, |
| 1198 | 1198 | 'deletes' => 0, |
| 1199 | 1199 | 'skips' => 0, |
| 1200 | - ); |
|
| 1201 | - static $headerdone = FALSE; |
|
| 1202 | - static $strings = array(); |
|
| 1200 | + ); |
|
| 1201 | + static $headerdone = FALSE; |
|
| 1202 | + static $strings = array(); |
|
| 1203 | 1203 | |
| 1204 | - switch ($op) { |
|
| 1204 | + switch ($op) { |
|
| 1205 | 1205 | // Return stored strings |
| 1206 | 1206 | case 'mem-report': |
| 1207 | 1207 | return $strings; |
| 1208 | 1208 | |
| 1209 | - // Store string in memory (only supports single strings) |
|
| 1209 | + // Store string in memory (only supports single strings) |
|
| 1210 | 1210 | case 'mem-store': |
| 1211 | 1211 | $strings[$value['msgid']] = $value['msgstr']; |
| 1212 | - return; |
|
| 1212 | + return; |
|
| 1213 | 1213 | |
| 1214 | - // Called at end of import to inform the user |
|
| 1214 | + // Called at end of import to inform the user |
|
| 1215 | 1215 | case 'db-report': |
| 1216 | 1216 | return array( |
| 1217 | 1217 | $headerdone, |
@@ -1219,57 +1219,57 @@ discard block |
||
| 1219 | 1219 | $report['updates'], |
| 1220 | 1220 | $report['deletes'], |
| 1221 | 1221 | $report['skips'], |
| 1222 | - ); |
|
| 1222 | + ); |
|
| 1223 | 1223 | |
| 1224 | - // Store the string we got in the database. |
|
| 1224 | + // Store the string we got in the database. |
|
| 1225 | 1225 | case 'db-store': |
| 1226 | 1226 | // We got header information. |
| 1227 | 1227 | if ($value['msgid'] == '') { |
| 1228 | 1228 | $languages = language_list(); |
| 1229 | 1229 | if (($mode != LOCALE_IMPORT_KEEP) || empty($languages[$lang]->plurals)) { |
| 1230 | - // Since we only need to parse the header if we ought to update the |
|
| 1231 | - // plural formula, only run this if we don't need to keep existing |
|
| 1232 | - // data untouched or if we don't have an existing plural formula. |
|
| 1233 | - $header = _locale_import_parse_header($value['msgstr']); |
|
| 1230 | + // Since we only need to parse the header if we ought to update the |
|
| 1231 | + // plural formula, only run this if we don't need to keep existing |
|
| 1232 | + // data untouched or if we don't have an existing plural formula. |
|
| 1233 | + $header = _locale_import_parse_header($value['msgstr']); |
|
| 1234 | 1234 | |
| 1235 | - // Get and store the plural formula if available. |
|
| 1236 | - if (isset($header["Plural-Forms"]) && $p = _locale_import_parse_plural_forms($header["Plural-Forms"], $file->filename)) { |
|
| 1235 | + // Get and store the plural formula if available. |
|
| 1236 | + if (isset($header["Plural-Forms"]) && $p = _locale_import_parse_plural_forms($header["Plural-Forms"], $file->filename)) { |
|
| 1237 | 1237 | list($nplurals, $plural) = $p; |
| 1238 | 1238 | db_query("UPDATE {languages} SET plurals = %d, formula = '%s' WHERE language = '%s'", $nplurals, $plural, $lang); |
| 1239 | - } |
|
| 1239 | + } |
|
| 1240 | 1240 | } |
| 1241 | 1241 | $headerdone = TRUE; |
| 1242 | - } |
|
| 1242 | + } |
|
| 1243 | 1243 | |
| 1244 | - else { |
|
| 1244 | + else { |
|
| 1245 | 1245 | // Some real string to import. |
| 1246 | 1246 | $comments = _locale_import_shorten_comments(empty($value['#']) ? array() : $value['#']); |
| 1247 | 1247 | |
| 1248 | 1248 | if (strpos($value['msgid'], "\0")) { |
| 1249 | - // This string has plural versions. |
|
| 1250 | - $english = explode("\0", $value['msgid'], 2); |
|
| 1251 | - $entries = array_keys($value['msgstr']); |
|
| 1252 | - for ($i = 3; $i <= count($entries); $i++) { |
|
| 1249 | + // This string has plural versions. |
|
| 1250 | + $english = explode("\0", $value['msgid'], 2); |
|
| 1251 | + $entries = array_keys($value['msgstr']); |
|
| 1252 | + for ($i = 3; $i <= count($entries); $i++) { |
|
| 1253 | 1253 | $english[] = $english[1]; |
| 1254 | - } |
|
| 1255 | - $translation = array_map('_locale_import_append_plural', $value['msgstr'], $entries); |
|
| 1256 | - $english = array_map('_locale_import_append_plural', $english, $entries); |
|
| 1257 | - foreach ($translation as $key => $trans) { |
|
| 1254 | + } |
|
| 1255 | + $translation = array_map('_locale_import_append_plural', $value['msgstr'], $entries); |
|
| 1256 | + $english = array_map('_locale_import_append_plural', $english, $entries); |
|
| 1257 | + foreach ($translation as $key => $trans) { |
|
| 1258 | 1258 | if ($key == 0) { |
| 1259 | - $plid = 0; |
|
| 1259 | + $plid = 0; |
|
| 1260 | 1260 | } |
| 1261 | 1261 | $plid = _boinctranslate_locale_import_one_string_db($report, $lang, $english[$key], $trans, $group, $comments, $mode, $plid, $key); |
| 1262 | - } |
|
| 1262 | + } |
|
| 1263 | 1263 | } |
| 1264 | 1264 | |
| 1265 | 1265 | else { |
| 1266 | - // A simple string to import. |
|
| 1267 | - $english = $value['msgid']; |
|
| 1268 | - $translation = $value['msgstr']; |
|
| 1269 | - _boinctranslate_locale_import_one_string_db($report, $lang, $english, $translation, $group, $comments, $mode); |
|
| 1266 | + // A simple string to import. |
|
| 1267 | + $english = $value['msgid']; |
|
| 1268 | + $translation = $value['msgstr']; |
|
| 1269 | + _boinctranslate_locale_import_one_string_db($report, $lang, $english, $translation, $group, $comments, $mode); |
|
| 1270 | 1270 | } |
| 1271 | - } |
|
| 1272 | - } // end of db-store operation |
|
| 1271 | + } |
|
| 1272 | + } // end of db-store operation |
|
| 1273 | 1273 | } |
| 1274 | 1274 | |
| 1275 | 1275 | /** |
@@ -1286,15 +1286,15 @@ discard block |
||
| 1286 | 1286 | */ |
| 1287 | 1287 | function _boinctranslate_locale_import_one_string_db(&$report, $langcode, $source, $translation, $textgroup, $location, $mode, $plid = NULL, $plural = NULL) { |
| 1288 | 1288 | |
| 1289 | - $ignoreoverwrite = FALSE; |
|
| 1290 | - $lid = 0; |
|
| 1289 | + $ignoreoverwrite = FALSE; |
|
| 1290 | + $lid = 0; |
|
| 1291 | 1291 | |
| 1292 | - // Use different DB query depending on the textgroup. |
|
| 1293 | - $uselocation = array("boinc", "project"); |
|
| 1294 | - if (in_array($textgroup, $uselocation)) { |
|
| 1292 | + // Use different DB query depending on the textgroup. |
|
| 1293 | + $uselocation = array("boinc", "project"); |
|
| 1294 | + if (in_array($textgroup, $uselocation)) { |
|
| 1295 | 1295 | $resource = db_query("SELECT lid FROM {locales_source} WHERE location = '%s' AND source = '%s' AND textgroup = '%s'", $location, $source, $textgroup); |
| 1296 | - } |
|
| 1297 | - else { |
|
| 1296 | + } |
|
| 1297 | + else { |
|
| 1298 | 1298 | $resource = db_query("SELECT lid FROM {locales_source} WHERE source = '%s' AND textgroup = '%s'", $source, $textgroup); |
| 1299 | 1299 | |
| 1300 | 1300 | // Parse the location string for the string ignoreoverwrite, which |
@@ -1303,61 +1303,61 @@ discard block |
||
| 1303 | 1303 | // location string. |
| 1304 | 1304 | $parts = explode(':', $location); |
| 1305 | 1305 | if (!empty($parts[2])) { |
| 1306 | - if (preg_match('/(ignoreoverwrite)/', $parts[2])) { |
|
| 1306 | + if (preg_match('/(ignoreoverwrite)/', $parts[2])) { |
|
| 1307 | 1307 | $ignoreoverwrite = TRUE; |
| 1308 | - } |
|
| 1308 | + } |
|
| 1309 | 1309 | } |
| 1310 | - }// if (in_array($textgroup, $uselocation)) |
|
| 1310 | + }// if (in_array($textgroup, $uselocation)) |
|
| 1311 | 1311 | |
| 1312 | - if (!empty($translation)) { |
|
| 1312 | + if (!empty($translation)) { |
|
| 1313 | 1313 | // Skip this string unless it passes a check for dangerous code. |
| 1314 | 1314 | // Text groups other than default still can contain HTML tags |
| 1315 | 1315 | // (i.e. translatable blocks). |
| 1316 | 1316 | if ($textgroup == "default" && !locale_string_is_safe($translation)) { |
| 1317 | - $report['skips']++; |
|
| 1318 | - $lid = 0; |
|
| 1317 | + $report['skips']++; |
|
| 1318 | + $lid = 0; |
|
| 1319 | 1319 | } |
| 1320 | 1320 | elseif ($resource) { |
| 1321 | - // We have this source string saved already. Loop over the db results from locales_source table. |
|
| 1322 | - while ($row = db_fetch_array($resource)) { |
|
| 1321 | + // We have this source string saved already. Loop over the db results from locales_source table. |
|
| 1322 | + while ($row = db_fetch_array($resource)) { |
|
| 1323 | 1323 | |
| 1324 | 1324 | $lid = $row['lid']; |
| 1325 | 1325 | // Check of if one or more translations exist for this lid in locales_target table. |
| 1326 | 1326 | $exists = (bool) db_result(db_query("SELECT lid FROM {locales_target} WHERE lid = %d AND language = '%s'", $lid, $langcode)); |
| 1327 | 1327 | if (!$exists) { |
| 1328 | - // No translation in this language, insert translation into locales_target table. |
|
| 1329 | - db_query("INSERT INTO {locales_target} (lid, language, translation, plid, plural) VALUES (%d, '%s', '%s', %d, %d)", $lid, $langcode, $translation, $plid, $plural); |
|
| 1330 | - $report['additions']++; |
|
| 1328 | + // No translation in this language, insert translation into locales_target table. |
|
| 1329 | + db_query("INSERT INTO {locales_target} (lid, language, translation, plid, plural) VALUES (%d, '%s', '%s', %d, %d)", $lid, $langcode, $translation, $plid, $plural); |
|
| 1330 | + $report['additions']++; |
|
| 1331 | 1331 | } |
| 1332 | 1332 | else if ( ($mode == LOCALE_IMPORT_OVERWRITE) and (!$ignoreoverwrite) ) { |
| 1333 | - // Translation exists, only overwrite if instructed. |
|
| 1334 | - db_query("UPDATE {locales_target} SET translation = '%s', plid = %d, plural = %d WHERE language = '%s' AND lid = %d", $translation, $plid, $plural, $langcode, $lid); |
|
| 1335 | - $report['updates']++; |
|
| 1333 | + // Translation exists, only overwrite if instructed. |
|
| 1334 | + db_query("UPDATE {locales_target} SET translation = '%s', plid = %d, plural = %d WHERE language = '%s' AND lid = %d", $translation, $plid, $plural, $langcode, $lid); |
|
| 1335 | + $report['updates']++; |
|
| 1336 | 1336 | } |
| 1337 | 1337 | else { |
| 1338 | - $report['skips']++; |
|
| 1338 | + $report['skips']++; |
|
| 1339 | 1339 | }// end if !$exists |
| 1340 | 1340 | |
| 1341 | - }// while |
|
| 1341 | + }// while |
|
| 1342 | 1342 | } |
| 1343 | - } |
|
| 1344 | - elseif ($mode == LOCALE_IMPORT_OVERWRITE AND $resource) { |
|
| 1343 | + } |
|
| 1344 | + elseif ($mode == LOCALE_IMPORT_OVERWRITE AND $resource) { |
|
| 1345 | 1345 | // Loop over db results from locales_source table. |
| 1346 | 1346 | while ($row = db_fetch_array($resource)) { |
| 1347 | - $lid = $row['lid']; |
|
| 1348 | - $exists = (bool) db_result(db_query("SELECT lid FROM {locales_target} WHERE lid = %d AND language = '%s'", $lid, $langcode)); |
|
| 1349 | - if ($exists) { |
|
| 1347 | + $lid = $row['lid']; |
|
| 1348 | + $exists = (bool) db_result(db_query("SELECT lid FROM {locales_target} WHERE lid = %d AND language = '%s'", $lid, $langcode)); |
|
| 1349 | + if ($exists) { |
|
| 1350 | 1350 | // Empty translation, remove existing if instructed. |
| 1351 | 1351 | db_query("DELETE FROM {locales_target} WHERE language = '%s' AND lid = %d AND plid = %d AND plural = %d", $langcode, $lid, $plid, $plural); |
| 1352 | 1352 | $report['deletes']++; |
| 1353 | - }// if $exists |
|
| 1353 | + }// if $exists |
|
| 1354 | 1354 | }// while |
| 1355 | - } |
|
| 1356 | - else { |
|
| 1355 | + } |
|
| 1356 | + else { |
|
| 1357 | 1357 | $report['skips']++; |
| 1358 | - } |
|
| 1358 | + } |
|
| 1359 | 1359 | |
| 1360 | - return $lid; |
|
| 1360 | + return $lid; |
|
| 1361 | 1361 | } |
| 1362 | 1362 | |
| 1363 | 1363 | |
@@ -1366,17 +1366,17 @@ discard block |
||
| 1366 | 1366 | * Parse valid resources out of configuration |
| 1367 | 1367 | */ |
| 1368 | 1368 | function boinctranslate_parse_resources($resource_text) { |
| 1369 | - $resources = array(); |
|
| 1370 | - $resource_array = explode( |
|
| 1369 | + $resources = array(); |
|
| 1370 | + $resource_array = explode( |
|
| 1371 | 1371 | "\n", $resource_text |
| 1372 | - ); |
|
| 1373 | - foreach ($resource_array as $resource) { |
|
| 1372 | + ); |
|
| 1373 | + foreach ($resource_array as $resource) { |
|
| 1374 | 1374 | $resource = trim($resource); |
| 1375 | 1375 | if ($resource AND $resource[0] != '#') { |
| 1376 | - $resources[] = $resource; |
|
| 1376 | + $resources[] = $resource; |
|
| 1377 | 1377 | } |
| 1378 | - } |
|
| 1379 | - return $resources; |
|
| 1378 | + } |
|
| 1379 | + return $resources; |
|
| 1380 | 1380 | } |
| 1381 | 1381 | |
| 1382 | 1382 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -1403,5 +1403,5 @@ discard block |
||
| 1403 | 1403 | * database. |
| 1404 | 1404 | */ |
| 1405 | 1405 | function _boinctranslate_supertrim($instr) { |
| 1406 | - return implode("\n", array_map('trim', preg_split('/\r\n|\r|\n/', $instr) ) ); |
|
| 1406 | + return implode("\n", array_map('trim', preg_split('/\r\n|\r|\n/', $instr) ) ); |
|
| 1407 | 1407 | } |