コード例 #1
0
ファイル: template.php プロジェクト: JuhaSointusalo/boinc
function boinc_preprocess_views_view(&$vars, $hook)
{
    switch ($vars['name']) {
        case 'boinc_account_computers':
            switch ($vars['display_id']) {
                case 'page_1':
                case 'panel_pane_1':
                    $vars['empty'] = boincwork_views_host_list_empty_text();
                    break;
                case 'page_2':
                    $vars['empty'] = boincwork_views_host_list_empty_text('active');
                    break;
                case 'block_1':
                    $vars['empty'] = boincwork_views_host_list_empty_text('preferences');
                    break;
                default:
            }
            break;
        case 'boinc_account_tasks_all':
            $vars['empty'] = boincwork_views_task_list_empty_text();
            break;
        case 'boinc_friends':
            if ($vars['display_id'] == 'block_1') {
                $vars['header'] = boincuser_views_friends_block_header();
            }
            break;
        case 'boinc_host_list':
            if ($vars['display_id'] == 'page_2') {
                $vars['empty'] = boincwork_views_host_list_empty_text();
            } elseif ($vars['display_id'] == 'page_1') {
                $vars['empty'] = boincwork_views_host_list_empty_text('active');
            }
            break;
        case 'boinc_task':
            // Load view object (view data is not available in header / footer); execute view query
            $view = views_get_current_view();
            $view->execute();
            $result = reset($view->result);
            // Display the stderr output in the footer
            $vars['footer'] = '<h3>' . bts('Stderr output') . '</h3>';
            $vars['footer'] .= '<pre>' . htmlspecialchars($result->result_stderr_out) . '</pre>';
            break;
        case 'boinc_teams':
            if ($vars['display_id'] == 'panel_pane_3') {
                $team_id = arg(2);
                $vars['header'] = boincteam_manage_admins_panel_header($team_id);
            }
            break;
        case 'boinc_workunit':
            ob_start();
            // Get the workunit ID from the URL
            $result_id = arg(1);
            require_boinc(array('util', 'boinc_db'));
            $wu = BoincWorkunit::lookup_id($result_id);
            project_workunit($wu);
            // Output of project_workunit() gets caught in the buffer
            $vars['footer'] = ob_get_clean();
        default:
    }
}
コード例 #2
0
<?php

// $Id$
/**
 * @file
 * A special, detachable routine for importing subscriptions.
 *
 * The process of importing subscriptions relies on Drupal API calls that may
 * not be intended for large batch processing. This script is intended to be
 * called via exec() by a higher level import routine to handle a small subset
 * of Drupal user objects at a time and avoid exhausting memory.
 */
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
require_boinc('db');
// Parse arguments
$record_offset = isset($argv[1]) ? $argv[1] : 0;
$chunk_size = isset($argv[2]) ? $argv[2] : 100;
// Construct sql conditions
$limit = sprintf('LIMIT %d,%d', $record_offset, $chunk_size);
$total_count = 0;
// Get the users with subscriptions to import
db_set_active('boinc');
$subscribed_boinc_users = db_query("\n    SELECT DISTINCT userid FROM {subscriptions}\n    ORDER BY userid ASC %s", $limit);
db_set_active('default');
// Import subscriptions
while ($boinc_subscription = db_fetch_object($subscribed_boinc_users)) {
    $uid = get_drupal_id($boinc_subscription->userid);
    $count = boincuser_pull_subscriptions($uid);
    $total_count += $count;
    echo "\nuser: {$uid}; boinc_id: {$boinc_subscription->userid}; {$count} subscriptions";