Index: project_issue_voting.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/project_issue_voting/project_issue_voting.install,v retrieving revision 1.1 diff -u -p -r1.1 project_issue_voting.install --- project_issue_voting.install 15 Aug 2008 23:06:02 -0000 1.1 +++ project_issue_voting.install 31 Oct 2008 20:43:16 -0000 @@ -1,6 +1,7 @@ '. t('This module is used to add a simple voting widget to Project issue node types.') .'

'; + case 'user/'. arg(1) .'/project-issue-votes': return '

'. t('This page shows a summary of voting for project issues. Total votes used is listed at the top, then the table shows how many votes were used for each issue. A user can reclaim all votes from an issue (to be used for voting on other issues) by clicking the Reclaim votes link.') .'

'; } @@ -51,8 +52,8 @@ function project_issue_voting_admin_sett // Add limit by project type if we're using taxonomy. if (project_use_taxonomy()) { - $vid = _project_get_vid(); - $tree = taxonomy_get_tree($vid, 0, -1, 1); + $vid = _project_get_vid(); + $tree = taxonomy_get_tree($vid, 0, -1, 1); $options = array(); foreach ($tree as $term) { $options[$term->tid] = $term->name; @@ -91,7 +92,7 @@ function project_issue_voting_admin_sett 'disabled' => t('Disabled'), 'teaser' => t('Teaser view'), 'full' => t('Full-page view'), - 'teaser-full' => t('Teasers and full-page view') + 'teaser-full' => t('Teasers and full-page view'), ); $form['vote_widget_settings_node']['project_issue_voting_widget_node'] = array( '#type' => 'select', @@ -143,8 +144,8 @@ function project_issue_voting_admin_sett function project_issue_voting_menu($may_cache) { $items = array(); - $vote_access = user_access('vote on issues'); - $view_votes_access = user_access('view issue votes'); + $vote_access = user_access('vote on issues'); + $view_votes_access = user_access('view issue votes'); $admin_votes_access = user_access('administer issue voting'); $types = node_get_types(); @@ -163,7 +164,7 @@ function project_issue_voting_menu($may_ 'path' => 'project-issue-voting-vote', 'callback' => 'project_issue_voting_vote', 'access' => $vote_access, - 'type' => MENU_CALLBACK + 'type' => MENU_CALLBACK, ); $items[] = array( 'path' => 'project/issues/votes', @@ -190,7 +191,7 @@ function project_issue_voting_menu($may_ 'callback arguments' => array($node), 'access' => $view_votes_access, 'weight' => 5, - 'type' => MENU_LOCAL_TASK + 'type' => MENU_LOCAL_TASK, ); drupal_add_css(drupal_get_path('module', 'project_issue_voting') .'/project_issue_voting.css'); drupal_add_js(drupal_get_path('module', 'project_issue_voting') .'/project_issue_voting.js'); @@ -202,7 +203,6 @@ function project_issue_voting_menu($may_ 'setting' ); } - } if (arg(0) == 'user' && is_numeric(arg(1))) { $account = user_load(array('uid' => arg(1))); @@ -213,14 +213,13 @@ function project_issue_voting_menu($may_ 'callback arguments' => array($account), 'access' => $view_votes_access, 'weight' => 5, - 'type' => MENU_LOCAL_TASK + 'type' => MENU_LOCAL_TASK, ); } if (module_exists('views')) { drupal_add_css(drupal_get_path('module', 'project_issue_voting') .'/project_issue_voting.views.css'); } } - return $items; } @@ -237,6 +236,7 @@ function project_issue_voting_nodeapi(&$ ); } break; + case 'delete': project_issue_voting_delete_votes($node); break; @@ -252,8 +252,8 @@ function project_issue_voting_link($type case 'node': if (project_issue_voting_check_issue_for_voting($node) && user_access('view issue votes')) { $user_votes = project_issue_voting_get_issue_user_votes($node->nid); - // Users get a reclaim link if it's enabled and they have - // any votes on the issue. + // Users get a reclaim link if it's enabled and they have any votes on + // the issue. if ($user_votes !== FALSE) { if (variable_get('project_issue_voting_reset_votes', 0) && user_access('vote on issues')) { $token = project_issue_voting_get_token(); @@ -261,7 +261,7 @@ function project_issue_voting_link($type 'title' => t('Reclaim votes'), 'href' => "project-issue-voting-vote/$node->nid/0/$token", 'attributes' => array('title' => t('Reset your votes on this issue to zero.')), - 'query' => drupal_get_destination() + 'query' => drupal_get_destination(), ); } } @@ -276,11 +276,10 @@ function project_issue_voting_link($type } break; } - return $links; } -/* +/** * Menu callback; Handles main project issue voting page. * * This just prints out all the visible menu items in the subtree @@ -288,8 +287,8 @@ function project_issue_voting_link($type * (e.g. via views and/or panels) they will show up automatically. */ function project_issue_voting_page() { - $mid = menu_get_active_item(); - $menu = menu_get_menu(); + $mid = menu_get_active_item(); + $menu = menu_get_menu(); $items = array(); foreach ($menu['visible'][$mid]['children'] as $child_mid) { $item = menu_get_item($child_mid); @@ -298,11 +297,10 @@ function project_issue_voting_page() { return theme('item_list', $items); } -/* - * Users votes page for the project_issue_voting data +/** + * Users votes page for the project_issue_voting data. */ function project_issue_voting_users_votes() { - $issue_states = array_filter(variable_get('project_issue_voting_issue_states', array())); $placeholders = implode(',', array_fill(0, count($issue_states), '%d')); $sql = "SELECT COUNT(v.value) AS number_votes, SUM(v.value) AS total_votes, v.tag, u.uid, u.name FROM {votingapi_vote} v INNER JOIN {users} u on v.uid = u.uid INNER JOIN {project_issues} pi ON pi.nid = v.content_id WHERE v.content_type = '%s' AND v.tag = '%s' AND pi.sid IN ($placeholders) GROUP BY u.name, u.uid, v.tag"; @@ -333,14 +331,14 @@ function project_issue_voting_users_vote return $output; } -/* +/** * Menu callback; display all votes for an issue node. */ function project_issue_voting_issue_votes($node) { $header = array( array('data' => t('User')), array('data' => t('Votes')), - array('data' => t('Date')) + array('data' => t('Date')), ); $votes = votingapi_get_content_votes('node', $node->nid); $args = array_keys($votes); @@ -352,16 +350,14 @@ function project_issue_voting_issue_vote $rows[] = array( theme('username', $user), check_plain($vote->value), - array('data' => format_date($vote->timestamp, 'small'), 'class' => 'nowrap') + array('data' => format_date($vote->timestamp, 'small'), 'class' => 'nowrap'), ); } drupal_set_title(check_plain($node->title)); - $output = theme('table', $header, $rows); - - return $output; + return theme('table', $header, $rows); } -/* +/** * Menu callback; display all votes for a user. */ function project_issue_voting_user_votes($account) { @@ -370,7 +366,6 @@ function project_issue_voting_user_votes $output = ''; if (!empty($account)) { if (($account->uid == $user->uid && $account->status == 1) || user_access('administer issue voting')) { - $votes_used = project_issue_voting_get_total_user_votes($account->uid); $allowed_votes = variable_get('project_issue_voting_allowed_user_votes', 20); $output .= theme('project_issue_voting_user_votes_summary', $votes_used, $allowed_votes); @@ -379,7 +374,7 @@ function project_issue_voting_user_votes array('data' => t('Issue'), 'field' => 'title', 'sort' => 'asc'), array('data' => t('Status'), 'field' => 'sid'), array('data' => t('Votes'), 'field' => 'value'), - array('data' => t('Operations')) + array('data' => t('Operations')), ); $sql = db_rewrite_sql("SELECT n.nid, n.title, pi.sid, v.value FROM {node} n INNER JOIN {project_issues} pi ON n.nid = pi.nid INNER JOIN {votingapi_vote} v ON n.nid = v.content_id WHERE v.uid = %d AND v.tag = '%s' AND v.content_type = 'node' AND n.status = 1". tablesort_sql($header)); $result = pager_query($sql, 25, 0, NULL, $account->uid, variable_get('project_issue_voting_tag', 'issue')); @@ -401,24 +396,22 @@ function project_issue_voting_user_votes return $output; } else { - drupal_access_denied(); + return drupal_access_denied(); } } else { - drupal_not_found(); + return drupal_not_found(); } } /** - * A voting get handler with AJAX support + * A voting get handler with AJAX support. */ function project_issue_voting_vote($nid, $value, $token = '', $ajax = FALSE) { if (is_numeric($nid) && is_numeric($value) && project_issue_voting_valid_token($token)) { - $node = node_load($nid); if (($uid = _project_issue_voting_get_uid()) && project_issue_voting_check_issue_for_voting($node) && user_access('vote on issues')) { - // Sanity-check the incoming values. if ($value > 0) { $vote->value = 1; @@ -434,7 +427,7 @@ function project_issue_voting_vote($nid, $current_votes = votingapi_get_user_votes('node', $nid, $uid); // Increment or decrement the user's votes as necessary. if ($vote->value != 0 && isset($current_votes[0])) { - $vote->value = $current_votes[0]->value + $vote->value; + $vote->value = $current_votes[0]->value + $vote->value; } // Make sure users can't set an issue's total points to a negative value. elseif ($vote->value < 1) { @@ -493,8 +486,7 @@ function project_issue_voting_vote($nid, } /** - * Returns the voting widget display and total issue - * votes if neccessary. + * Return the voting widget display and total issue votes if neccessary. */ function project_issue_voting_interface($node) { global $user; @@ -545,7 +537,6 @@ function project_issue_voting_interface( * The CSS class for decreasing a vote, should be 'act' or 'inact'. */ function theme_project_issue_voting_widget($nid, $total_user_votes_used, $issue_user_votes, $total_user_votes, $up_class, $down_class) { - $token = project_issue_voting_get_token(); $output = ''; @@ -559,8 +550,7 @@ function theme_project_issue_voting_widg } /** - * Themes the users voting display on a project issue node, - * including a summary of their overall voting values. + * Return HTML for the users voting display on a project issue node, including a summary of their overall voting values. * * @param $nid * Issue node ID. @@ -599,6 +589,7 @@ function theme_project_issue_voting_widg /** * Wrapper for the user voting widget on project issue nodes. + * * NOTE: This display is commented out by default, because * there's already a total vote count in the issue metadata * table. It's been left here in case anybody wants to uncomment @@ -611,18 +602,18 @@ function theme_project_issue_voting_widg * across all users. */ function theme_project_issue_voting_issue_total_votes_wrapper($nid, $issue_total_votes) { - $output = ''; - - // $output .= '
'; - // $output .= theme('project_issue_voting_issue_total_votes', $nid, $issue_total_votes); - // $output .= '
'; - +/* + $output .= '
'; + $output .= theme('project_issue_voting_issue_total_votes', $nid, $issue_total_votes); + $output .= '
'; +*/ return $output; } /** - * Themes the user voting widget on project issue nodes. + * Return HTML for the user voting widget on project issue nodes. + * * NOTE: This display is disabled by default, because * there's already a total vote count in the issue metadata * table. It's been left here in case anybody wants to uncomment @@ -635,19 +626,17 @@ function theme_project_issue_voting_issu * across all users. */ function theme_project_issue_voting_issue_total_votes($nid, $issue_total_votes) { - $output = ''; $output .= '
'; $output .= '
'. t('Total issue votes') .'
'; $output .= '
'. check_plain($issue_total_votes) .'
'; $output .= '
'. format_plural($issue_total_votes, 'vote', 'votes') .'
'; $output .= '
'; - return $output; } /** - * Themes the users's overall voting summary + * Return HTML for the users's overall voting summary. * * @param $votes_used * The total votes a user has used across all issues. @@ -655,14 +644,11 @@ function theme_project_issue_voting_issu * The total votes that a user has to allocate across all issues. */ function theme_project_issue_voting_user_votes_summary($votes_used, $allowed_votes) { - $output = ''; - $output .= '

'. t('Total votes used') .': '. check_plain("$votes_used/$allowed_votes") .'

'; - - return $output; + return '

'. t('Total votes used') .': '. check_plain("$votes_used/$allowed_votes") .'

'; } /** - * Get a uid for anonymous vs. registered voting + * Get a uid for anonymous vs. registered voting. */ function _project_issue_voting_get_uid() { global $user; @@ -682,21 +668,21 @@ function _project_issue_voting_get_uid() else { $uid = FALSE; } - return $uid; } /** * Checks an issue node to determine if it's enabled for voting. + * * Since the function is called multiple times, cache the test results. * * @param $node * The issue node. + * * @return * TRUE if the issue node is enabled for voting, FALSE otherwise. */ function project_issue_voting_check_issue_for_voting($node) { - static $state_check = array(); if (isset($state_check[$node->nid])) { @@ -728,7 +714,7 @@ function project_issue_voting_check_issu $current_project_terms = db_query("SELECT tid FROM {term_node} WHERE tid IN($placeholders) AND nid = %d", $args); $project_terms = array(); while ($project_term = db_fetch_object($current_project_terms)) { - $project_terms[] = $project_term->tid; + $project_terms[] = $project_term->tid; } // Check if any of the issue's categories are enabled for voting. @@ -759,8 +745,7 @@ function project_issue_voting_check_issu } /** - * Return the number of votes a specified user has placed - * on a specified issue. + * Return the number of votes a specified user has placed on a specified issue. * * @param $nid * The issue node ID. @@ -802,14 +787,13 @@ function project_issue_voting_get_total_ * Validate that the entered value is a number. */ function project_issue_voting_validate_numeric($form) { - if (!is_numeric($form['#value'])) { - form_error($form, t('@element_name must be a number.', array('@element_name' => $form['#title']))); - } + if (!is_numeric($form['#value'])) { + form_error($form, t('@element_name must be a number.', array('@element_name' => $form['#title']))); + } } /** - * Return the number of total votes a user has cast across - * all issues. + * Return the number of total votes a user has cast across all issues. * * @param $uid * The user ID. @@ -836,8 +820,7 @@ function project_issue_voting_get_total_ } /** - * Check to see if a specified user has available votes - * to assign. + * Check to see if a specified user has available votes to assign. * * @param $uid * The user ID. @@ -877,41 +860,42 @@ function project_issue_voting_project_is 'current' => ''. check_plain($total_issue_votes) .'', ); } - break; } } /** * Implementation of hook_views_default_views. + * * @see _project_issue_voting_views_default_views */ function project_issue_voting_views_default_views() { - require_once(drupal_get_path('module', 'project_issue_voting') .'/project_issue_voting.views.inc'); + require_once drupal_get_path('module', 'project_issue_voting') .'/project_issue_voting.views.inc'; return _project_issue_voting_views_default_views(); } /** * Implementation of hook_panels_default_panel_views. + * * @see _project_issue_voting_default_panel_views() */ function project_issue_voting_default_panel_views() { - require_once(drupal_get_path('module', 'project_issue_voting') .'/project_issue_voting.panels.inc'); + require_once drupal_get_path('module', 'project_issue_voting') .'/project_issue_voting.panels.inc'; return _project_issue_voting_default_panel_views(); } /** * Implementation of hook_panels_default_panel_views. + * * @see _project_issue_voting_panels_default_panel_pages() */ function project_issue_voting_default_panel_pages() { - require_once(drupal_get_path('module', 'project_issue_voting') .'/project_issue_voting.panels.inc'); + require_once drupal_get_path('module', 'project_issue_voting') .'/project_issue_voting.panels.inc'; return _project_issue_voting_default_panel_pages(); } /** - * Determine if the specified voting type should be - * displayed on the current page. + * Determine if the specified voting type should be displayed on the current page. * * @param $type * The type of display we're checking. Can be 'node' or 'link'. @@ -923,6 +907,7 @@ function project_issue_voting_display($t case 'node': $display_type = variable_get('project_issue_voting_widget_node', 'full'); break; + case 'link': $display_type = variable_get('project_issue_voting_link_node', 'teaser'); break; @@ -938,7 +923,6 @@ function project_issue_voting_display($t $display = TRUE; } } - return $display; } @@ -953,3 +937,4 @@ function project_issue_voting_delete_vot votingapi_recalculate_results('node', $node->nid, TRUE); } } + Index: project_issue_voting.panels.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/project_issue_voting/project_issue_voting.panels.inc,v retrieving revision 1.2 diff -u -p -r1.2 project_issue_voting.panels.inc --- project_issue_voting.panels.inc 16 Aug 2008 09:41:50 -0000 1.2 +++ project_issue_voting.panels.inc 31 Oct 2008 20:47:24 -0000 @@ -1,6 +1,7 @@ did = 'new'; $display->layout = 'onecol'; - $display->layout_settings = array ( + $display->layout_settings = array( 'plain' => 0, ); - $display->panel_settings = array ( + $display->panel_settings = array( 'style' => 'default', 'style_settings' => array(), 'edit_style' => 'Edit style settings', 'individual' => 0, - 'panel' => array ( - 'middle' => array ( + 'panel' => array( + 'middle' => array( 'style' => '', 'edit_style' => 'Edit style settings', ), @@ -64,14 +65,14 @@ function _project_issue_voting_default_p $pane->type = 'views2'; $pane->subtype = 'project_issue_votes_by_category'; $pane->access = array(); - $pane->configuration = array ( + $pane->configuration = array( 'override_title' => 0, 'override_title_text' => '', 'css_id' => '', 'css_class' => '', 'title' => 'Issue votes by category', 'name' => 'project_issue_votes_by_category', - 'arguments' => array ( + 'arguments' => array( 0 => 'feature', ), ); @@ -85,14 +86,14 @@ function _project_issue_voting_default_p $pane->type = 'views2'; $pane->subtype = 'project_issue_votes_by_category'; $pane->access = array(); - $pane->configuration = array ( + $pane->configuration = array( 'override_title' => 0, 'override_title_text' => '', 'css_id' => '', 'css_class' => '', 'title' => 'Issue votes by category', 'name' => 'project_issue_votes_by_category', - 'arguments' => array ( + 'arguments' => array( 0 => 'bug', ), ); @@ -106,14 +107,14 @@ function _project_issue_voting_default_p $pane->type = 'views2'; $pane->subtype = 'project_issue_votes_by_category'; $pane->access = array(); - $pane->configuration = array ( + $pane->configuration = array( 'override_title' => 0, 'override_title_text' => '', 'css_id' => '', 'css_class' => '', 'title' => 'Issue votes by category', 'name' => 'project_issue_votes_by_category', - 'arguments' => array ( + 'arguments' => array( 0 => 'task', ), ); @@ -127,14 +128,14 @@ function _project_issue_voting_default_p $pane->type = 'views2'; $pane->subtype = 'project_issue_votes_by_category'; $pane->access = array(); - $pane->configuration = array ( + $pane->configuration = array( 'override_title' => 0, 'override_title_text' => '', 'css_id' => '', 'css_class' => '', 'title' => 'Issue votes by category', 'name' => 'project_issue_votes_by_category', - 'arguments' => array ( + 'arguments' => array( 0 => 'support', ), ); @@ -177,8 +178,8 @@ function _project_issue_voting_default_p $panel_view->url_override = '0'; $panel_view->url = ''; $panel_view->url_from_panel = '0'; - $panel_view->contexts = array ( - 0 => array ( + $panel_view->contexts = array( + 0 => array( 'type' => 'user', 'context' => 'any', 'panel' => '0', @@ -201,3 +202,4 @@ function _project_issue_voting_default_p return $panel_views; } + Index: project_issue_voting.views.css =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/project_issue_voting/project_issue_voting.views.css,v retrieving revision 1.1 diff -u -p -r1.1 project_issue_voting.views.css --- project_issue_voting.views.css 16 Aug 2008 01:36:59 -0000 1.1 +++ project_issue_voting.views.css 31 Oct 2008 21:00:12 -0000 @@ -1,6 +1,8 @@ /* $Id: project_issue_voting.views.css,v 1.1 2008/08/16 01:36:59 dww Exp $ */ -/* CSS for the default views */ +/** + * CSS for the default views. + */ /* Project selector */ .view-project-issue-votes-by-category #edit-filter0 { Index: project_issue_voting.views.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/project_issue_voting/project_issue_voting.views.inc,v retrieving revision 1.5 diff -u -p -r1.5 project_issue_voting.views.inc --- project_issue_voting.views.inc 16 Aug 2008 12:34:01 -0000 1.5 +++ project_issue_voting.views.inc 31 Oct 2008 20:48:28 -0000 @@ -1,6 +1,7 @@ name = 'project_issue_votes_by_category'; $view->description = 'View issue votes for a particular category (bug, feature, etc)'; - $view->access = array ( -); + $view->access = array(); $view->page = TRUE; $view->page_title = ''; $view->page_header = ""; @@ -55,10 +55,9 @@ function _project_issue_voting_views_def $view->block_use_page_header = FALSE; $view->block_use_page_footer = FALSE; $view->block_use_page_empty = TRUE; - $view->sort = array ( - ); - $view->argument = array ( - array ( + $view->sort = array(); + $view->argument = array( + array( 'type' => 'project_issue_category', 'argdefault' => '4', 'title' => 'Top voted %1', @@ -67,8 +66,8 @@ function _project_issue_voting_views_def 'wildcard_substitution' => '', ), ); - $view->field = array ( - array ( + $view->field = array( + array( 'tablename' => 'votingapi_cache_issue_points_sum', 'field' => 'value', 'label' => 'Votes', @@ -76,7 +75,7 @@ function _project_issue_voting_views_def 'sortable' => '1', 'defaultsort' => 'DESC', ), - array ( + array( 'tablename' => 'project_issue_project_node', 'field' => 'title', 'label' => 'Project', @@ -84,7 +83,7 @@ function _project_issue_voting_views_def 'sortable' => '1', 'options' => 'link', ), - array ( + array( 'tablename' => 'node', 'field' => 'title', 'label' => 'Summary', @@ -92,79 +91,77 @@ function _project_issue_voting_views_def 'sortable' => '1', 'options' => 'link', ), - array ( + array( 'tablename' => 'project_issues', 'field' => 'sid', 'label' => 'Status', 'sortable' => '1', ), - array ( + array( 'tablename' => 'project_issues', 'field' => 'priority', 'label' => 'Priority', 'sortable' => '1', ), - array ( + array( 'tablename' => 'project_issues', 'field' => 'rid', 'label' => 'Version', 'sortable' => '1', 'options' => 'project_issue_rid_allow_hide', ), - array ( + array( 'tablename' => 'node', 'field' => 'changed', 'label' => 'Last updated', 'handler' => 'views_handler_field_since', 'sortable' => '1', ), - array ( + array( 'tablename' => 'pi_users', 'field' => 'name', 'label' => 'Assigned to', 'sortable' => '1', ), - array ( + array( 'tablename' => 'project_issue_project_projects', 'field' => 'uri', 'label' => 'Short name', 'options' => 'project_issue_nodisplay', ), ); - $view->filter = array ( - array ( + $view->filter = array( + array( 'tablename' => 'node', 'field' => 'status', 'operator' => '=', 'options' => '', 'value' => '1', ), - array ( + array( 'tablename' => 'project_issues', 'field' => 'sid', 'operator' => 'OR', 'options' => '', - 'value' => array ( - 0 => 'defaults', -), + 'value' => array( + 0 => 'defaults', + ), ), - array ( + array( 'tablename' => 'project_issue_project_node', 'field' => 'nid', 'operator' => 'OR', 'options' => '', - 'value' => array ( -), + 'value' => array(), ), - array ( + array( 'tablename' => 'project_issues', 'field' => 'priority', 'operator' => 'OR', 'options' => '', - 'value' => array ( -), + 'value' => array(), ), - array ( + array( 'tablename' => 'votingapi_cache_issue_points_sum', 'field' => 'value', 'operator' => '>', @@ -172,8 +169,8 @@ function _project_issue_voting_views_def 'value' => '0', ), ); - $view->exposed_filter = array ( - array ( + $view->exposed_filter = array( + array( 'tablename' => 'project_issue_project_node', 'field' => 'nid', 'label' => 'Project', @@ -182,7 +179,7 @@ function _project_issue_voting_views_def 'operator' => '1', 'single' => '1', ), - array ( + array( 'tablename' => 'project_issues', 'field' => 'sid', 'label' => 'Status', @@ -191,7 +188,7 @@ function _project_issue_voting_views_def 'operator' => '1', 'single' => '1', ), - array ( + array( 'tablename' => 'project_issues', 'field' => 'priority', 'label' => 'Priority',