From 7b382cbcdf5c90cad72eb3267989721d7c8592fb Mon Sep 17 00:00:00 2001 From: Tristan Olive Date: Wed, 10 Apr 2013 16:25:29 -0400 Subject: [PATCH] Convert user stats to views pane Replaced custom content panes with views panes for user account stats widgets. This allows the stats_charts feature to provide the stats pane and all dependencies. --- .../boinc_standard.features.inc | 4 +- .../boinc_standard/boinc_standard.info | 1 - .../boinc_standard.input_formats.inc | 1 + .../boinc_standard.pages_default.inc | 25 +- .../stats_charts.views_default.inc | 321 +++++++++++++++++- .../modules/boincstats/boincstats.module | 16 +- ...boinc-account-stats--panel-pane-1.tpl.php} | 0 7 files changed, 341 insertions(+), 27 deletions(-) rename drupal/sites/default/boinc/themes/boinc/templates/{views-view-fields--boinc-account-stats.tpl.php => views-view-fields--boinc-account-stats--panel-pane-1.tpl.php} (100%) diff --git a/drupal/sites/all/features/boinc_standard/boinc_standard.features.inc b/drupal/sites/all/features/boinc_standard/boinc_standard.features.inc index d8355f21b2..299c11d5b1 100644 --- a/drupal/sites/all/features/boinc_standard/boinc_standard.features.inc +++ b/drupal/sites/all/features/boinc_standard/boinc_standard.features.inc @@ -31,7 +31,7 @@ function boinc_standard_flag_default_flags() { $flags['abuse_comment'] = array( 'content_type' => 'comment', 'title' => 'Comment Abuse', - 'global' => FALSE, + 'global' => '0', 'types' => array( '0' => 'news', '1' => 'forum', @@ -65,7 +65,7 @@ function boinc_standard_flag_default_flags() { $flags['abuse_node'] = array( 'content_type' => 'node', 'title' => 'Node Abuse', - 'global' => FALSE, + 'global' => '0', 'types' => array( '0' => 'profile', '1' => 'forum', diff --git a/drupal/sites/all/features/boinc_standard/boinc_standard.info b/drupal/sites/all/features/boinc_standard/boinc_standard.info index 7f2483993f..2ac90821f5 100644 --- a/drupal/sites/all/features/boinc_standard/boinc_standard.info +++ b/drupal/sites/all/features/boinc_standard/boinc_standard.info @@ -203,4 +203,3 @@ features[variable][] = "user_pictures" features[variable][] = "user_register" features[variable][] = "user_registration_help" features[variable][] = "user_signatures" -features[wysiwyg][] = "rich_text" diff --git a/drupal/sites/all/features/boinc_standard/boinc_standard.input_formats.inc b/drupal/sites/all/features/boinc_standard/boinc_standard.input_formats.inc index a4bf398912..8664a91d25 100644 --- a/drupal/sites/all/features/boinc_standard/boinc_standard.input_formats.inc +++ b/drupal/sites/all/features/boinc_standard/boinc_standard.input_formats.inc @@ -15,6 +15,7 @@ function boinc_standard_input_formats() { ); $input_format->filters = array( 'php' => array( + // Delta => Weight for: PHP evaluator '0' => '0', ), ); diff --git a/drupal/sites/all/features/boinc_standard/boinc_standard.pages_default.inc b/drupal/sites/all/features/boinc_standard/boinc_standard.pages_default.inc index 05ef517d04..e22ba6ac8f 100644 --- a/drupal/sites/all/features/boinc_standard/boinc_standard.pages_default.inc +++ b/drupal/sites/all/features/boinc_standard/boinc_standard.pages_default.inc @@ -12,7 +12,10 @@ function boinc_standard_default_page_manager_pages() { $page->admin_title = 'About Us'; $page->admin_description = ''; $page->path = 'about.fail'; - $page->access = array(); + $page->access = array( + 'type' => 'none', + 'settings' => NULL, + ); $page->menu = array(); $page->arguments = array(); $page->conf = array(); @@ -41,6 +44,8 @@ function boinc_standard_default_page_manager_pages() { ), ), 'logic' => 'and', + 'type' => 'none', + 'settings' => NULL, ); $page->menu = array( 'type' => 'none', @@ -309,16 +314,13 @@ function boinc_standard_default_page_manager_pages() { $pane = new stdClass; $pane->pid = 'new-2'; $pane->panel = 'sidebar_first'; - $pane->type = 'custom'; - $pane->subtype = 'custom'; + $pane->type = 'views_panes'; + $pane->subtype = 'boinc_account_stats-panel_pane_2'; $pane->shown = TRUE; $pane->access = array(); $pane->configuration = array( - 'admin_title' => 'User stats overview', - 'title' => '%user:display-name\'s stats', - 'body' => '', - 'format' => '3', - 'substitute' => 1, + 'override_title' => 1, + 'override_title_text' => '%user:display-name\'s stats', ); $pane->cache = array(); $pane->style = array( @@ -371,7 +373,7 @@ function boinc_standard_default_page_manager_pages() { $display->content['new-3'] = $pane; $display->panels['sidebar_first'][1] = 'new-3'; $display->hide_title = PANELS_TITLE_NONE; - $display->title_pane = 'new-2'; + $display->title_pane = '0'; $handler->conf['display'] = $display; $page->default_handlers[$handler->name] = $handler; $pages['boinc_user'] = $page; @@ -384,7 +386,10 @@ function boinc_standard_default_page_manager_pages() { $page->admin_title = 'Home page'; $page->admin_description = ''; $page->path = 'home'; - $page->access = array(); + $page->access = array( + 'type' => 'none', + 'settings' => NULL, + ); $page->menu = array( 'type' => 'normal', 'title' => 'Home', diff --git a/drupal/sites/all/features/stats_charts/stats_charts.views_default.inc b/drupal/sites/all/features/stats_charts/stats_charts.views_default.inc index b722e2d523..50007c0cd1 100644 --- a/drupal/sites/all/features/stats_charts/stats_charts.views_default.inc +++ b/drupal/sites/all/features/stats_charts/stats_charts.views_default.inc @@ -324,6 +324,7 @@ function stats_charts_views_default_views() { $handler->override_option('cache', array( 'type' => 'none', )); + $handler->override_option('css_class', 'stats'); $handler->override_option('header_format', '1'); $handler->override_option('header_empty', 0); $handler->override_option('style_options', array( @@ -683,9 +684,8 @@ else return FALSE;', 'relationship' => 'none', ), )); - $handler->override_option('css_class', 'stats'); $handler->override_option('style_options', array()); - $handler->override_option('pane_title', ''); + $handler->override_option('pane_title', 'BOINC account stats detail'); $handler->override_option('pane_description', ''); $handler->override_option('pane_category', array( 'name' => 'View panes', @@ -705,6 +705,323 @@ else return FALSE;', $handler->override_option('argument_input', array()); $handler->override_option('link_to_view', 0); $handler->override_option('inherit_panels_path', 0); + $handler = $view->new_display('panel_pane', 'User overview', 'panel_pane_2'); + $handler->override_option('fields', array( + 'id' => array( + 'label' => 'User ID', + 'alter' => array( + 'alter_text' => 0, + 'text' => '', + 'make_link' => 0, + 'path' => '', + 'absolute' => 0, + 'link_class' => '', + 'alt' => '', + 'rel' => '', + 'prefix' => '', + 'suffix' => '', + 'target' => '', + 'help' => '', + 'trim' => 0, + 'max_length' => '', + 'word_boundary' => 1, + 'ellipsis' => 1, + 'html' => 0, + 'strip_tags' => 0, + ), + 'empty' => '', + 'hide_empty' => 0, + 'empty_zero' => 0, + 'hide_alter_empty' => 1, + 'set_precision' => FALSE, + 'precision' => 0, + 'decimal' => '.', + 'separator' => '', + 'format_plural' => 0, + 'format_plural_singular' => '1', + 'format_plural_plural' => '@count', + 'prefix' => '', + 'suffix' => '', + 'exclude' => 1, + 'id' => 'id', + 'table' => 'user', + 'field' => 'id', + 'relationship' => 'none', + 'override' => array( + 'button' => 'Use default', + ), + ), + 'total_credit' => array( + 'label' => 'Total credit', + 'alter' => array( + 'alter_text' => 0, + 'text' => '', + 'make_link' => 0, + 'path' => '', + 'link_class' => '', + 'alt' => '', + 'prefix' => '', + 'suffix' => '', + 'target' => '', + 'help' => '', + 'trim' => 0, + 'max_length' => '', + 'word_boundary' => 1, + 'ellipsis' => 1, + 'html' => 0, + 'strip_tags' => 0, + ), + 'empty' => '', + 'hide_empty' => 0, + 'empty_zero' => 0, + 'set_precision' => 1, + 'precision' => '0', + 'decimal' => '.', + 'separator' => ',', + 'prefix' => '', + 'suffix' => '', + 'exclude' => 0, + 'id' => 'total_credit', + 'table' => 'user', + 'field' => 'total_credit', + 'relationship' => 'none', + ), + 'expavg_credit' => array( + 'label' => 'Avg credit', + 'alter' => array( + 'alter_text' => 0, + 'text' => '', + 'make_link' => 0, + 'path' => '', + 'absolute' => 0, + 'link_class' => '', + 'alt' => '', + 'rel' => '', + 'prefix' => '', + 'suffix' => '', + 'target' => '', + 'help' => '', + 'trim' => 0, + 'max_length' => '', + 'word_boundary' => 1, + 'ellipsis' => 1, + 'html' => 0, + 'strip_tags' => 0, + ), + 'empty' => '', + 'hide_empty' => 0, + 'empty_zero' => 0, + 'hide_alter_empty' => 1, + 'set_precision' => 1, + 'precision' => '2', + 'decimal' => '.', + 'separator' => ',', + 'format_plural' => 0, + 'format_plural_singular' => '1', + 'format_plural_plural' => '@count', + 'prefix' => '', + 'suffix' => '', + 'exclude' => 0, + 'id' => 'expavg_credit', + 'table' => 'user', + 'field' => 'expavg_credit', + 'relationship' => 'none', + 'override' => array( + 'button' => 'Use default', + ), + ), + 'cross_project_id' => array( + 'label' => 'Cross-project statistics', + 'alter' => array( + 'alter_text' => 0, + 'text' => '', + 'make_link' => 0, + 'path' => '', + 'link_class' => '', + 'alt' => '', + 'prefix' => '', + 'suffix' => '', + 'target' => '', + 'help' => '', + 'trim' => 0, + 'max_length' => '', + 'word_boundary' => 1, + 'ellipsis' => 1, + 'html' => 0, + 'strip_tags' => 0, + ), + 'empty' => '', + 'hide_empty' => 0, + 'empty_zero' => 0, + 'exclude' => 1, + 'id' => 'cross_project_id', + 'table' => 'user', + 'field' => 'cross_project_id', + 'relationship' => 'none', + 'override' => array( + 'button' => 'Override', + ), + ), + 'phpcode' => array( + 'label' => '', + 'alter' => array( + 'alter_text' => 0, + 'text' => '', + 'make_link' => 0, + 'path' => '', + 'absolute' => 0, + 'link_class' => '', + 'alt' => '', + 'rel' => '', + 'prefix' => '', + 'suffix' => '', + 'target' => '', + 'help' => '', + 'trim' => 0, + 'max_length' => '', + 'word_boundary' => 1, + 'ellipsis' => 1, + 'html' => 0, + 'strip_tags' => 0, + ), + 'empty' => '', + 'hide_empty' => 0, + 'empty_zero' => 0, + 'hide_alter_empty' => 1, + 'value' => ' +id)); ?> +
boincuser_cpid}/small"; ?>" />
', + 'exclude' => 0, + 'id' => 'phpcode', + 'table' => 'customfield', + 'field' => 'phpcode', + 'override' => array( + 'button' => 'Use default', + ), + 'relationship' => 'none', + ), + )); + $handler->override_option('arguments', array( + 'id' => array( + 'default_action' => 'default', + 'style_plugin' => 'default_summary', + 'style_options' => array(), + 'wildcard' => 'all', + 'wildcard_substitution' => 'All', + 'title' => '', + 'breadcrumb' => '', + 'default_argument_type' => 'current_user', + 'default_argument' => '', + 'validate_type' => 'user', + 'validate_fail' => 'not found', + 'break_phrase' => 0, + 'not' => 0, + 'id' => 'id', + 'table' => 'user', + 'field' => 'id', + 'validate_user_argument_type' => 'either', + 'validate_user_roles' => array( + 2 => 0, + 4 => 0, + 5 => 0, + 3 => 0, + 6 => 0, + ), + 'relationship' => 'none', + 'default_options_div_prefix' => '', + 'default_argument_fixed' => '', + 'default_argument_user' => 0, + 'default_argument_php' => '', + 'validate_argument_node_type' => array( + 'page' => 0, + 'profile' => 0, + 'forum' => 0, + 'panel' => 0, + 'story' => 0, + ), + 'validate_argument_node_access' => 0, + 'validate_argument_nid_type' => 'nid', + 'validate_argument_vocabulary' => array( + 1 => 0, + 2 => 0, + ), + 'validate_argument_type' => 'tid', + 'validate_argument_transform' => 0, + 'validate_user_restrict_roles' => 0, + 'validate_argument_php' => '', + 'override' => array( + 'button' => 'Use default', + ), + 'me_redirect' => 0, + 'me_validate_user_argument_type' => 'uid', + 'me_validate_user_roles' => array( + 2 => 0, + 4 => 0, + 5 => 0, + 3 => 0, + 6 => 0, + ), + 'default_taxonomy_tid_term_page' => 0, + 'default_taxonomy_tid_node' => 0, + 'default_taxonomy_tid_limit' => 0, + 'default_taxonomy_tid_vids' => array( + 1 => 0, + 2 => 0, + ), + 'validate_argument_node_flag_name' => '*relationship*', + 'validate_argument_node_flag_test' => 'flaggable', + 'validate_argument_node_flag_id_type' => 'id', + 'validate_argument_user_flag_name' => '*relationship*', + 'validate_argument_user_flag_test' => 'flaggable', + 'validate_argument_user_flag_id_type' => 'id', + 'me_validate_user_restrict_roles' => 0, + ), + )); + $handler->override_option('title', 'User\'s stats'); + $handler->override_option('row_plugin', 'panels_fields'); + $handler->override_option('row_options', array( + 'inline' => array(), + 'separator' => '', + 'hide_empty' => 0, + 'layout' => 'onecol', + 'change' => 'Change', + 'regions' => array( + 'id' => 'middle', + 'total_credit' => 'middle', + 'expavg_credit' => 'middle', + 'cross_project_id' => 'middle', + 'phpcode' => 'middle', + ), + )); + $handler->override_option('pane_title', 'BOINC account stats overview'); + $handler->override_option('pane_description', ''); + $handler->override_option('pane_category', array( + 'name' => 'View panes', + 'weight' => 0, + )); + $handler->override_option('allow', array( + 'use_pager' => 0, + 'items_per_page' => 0, + 'offset' => 0, + 'link_to_view' => 0, + 'more_link' => 0, + 'path_override' => 0, + 'title_override' => 'title_override', + 'exposed_form' => 0, + 'fields_override' => 0, + )); + $handler->override_option('argument_input', array( + 'id' => array( + 'type' => 'panel', + 'context' => 'node_edit_form.author-mail-raw', + 'context_optional' => 0, + 'panel' => '0', + 'fixed' => '', + 'label' => 'BOINC: Id', + ), + )); + $handler->override_option('link_to_view', 0); + $handler->override_option('inherit_panels_path', 0); $views[$view->name] = $view; diff --git a/drupal/sites/default/boinc/modules/boincstats/boincstats.module b/drupal/sites/default/boinc/modules/boincstats/boincstats.module index ec899d564b..e2808230e4 100644 --- a/drupal/sites/default/boinc/modules/boincstats/boincstats.module +++ b/drupal/sites/default/boinc/modules/boincstats/boincstats.module @@ -422,18 +422,6 @@ function boincstats_credit_to_flops($credit, $prefix = 0) { * Data access support functions * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -function boincstats_get_user_stats_overview($uid) { - global $base_path; - $account = user_load($uid); - $output = ''; - $output .= '
' . number_format($account->boincuser_total_credit) . '
' . "\n"; - $output .= '
' . number_format($account->boincuser_expavg_credit) . '
' . "\n"; - //$output .= '
' . t('Pending credits') . '
' . "\n"; - $output .= '
' . "\n"; - - return $output; -} - function boincstats_get_project_stats_overview() { global $base_path; $output = ''; @@ -446,6 +434,10 @@ function boincstats_get_project_stats_overview() { } +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Miscellaneous support functions + * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + /* * Check that the stats system is configured, report if it isn't */ diff --git a/drupal/sites/default/boinc/themes/boinc/templates/views-view-fields--boinc-account-stats.tpl.php b/drupal/sites/default/boinc/themes/boinc/templates/views-view-fields--boinc-account-stats--panel-pane-1.tpl.php similarity index 100% rename from drupal/sites/default/boinc/themes/boinc/templates/views-view-fields--boinc-account-stats.tpl.php rename to drupal/sites/default/boinc/themes/boinc/templates/views-view-fields--boinc-account-stats--panel-pane-1.tpl.php