cvs diff: Diffing modules/project_issue Index: modules/project_issue/issue.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/project_issue/issue.inc,v retrieving revision 1.221 diff -u -p -r1.221 issue.inc --- modules/project_issue/issue.inc 23 Jan 2007 23:51:12 -0000 1.221 +++ modules/project_issue/issue.inc 26 Jan 2007 07:14:05 -0000 @@ -997,7 +997,26 @@ function project_issue_access($op, $node } // Support stuff -function project_issue_state($sid = 0, $restrict = false, $is_author = false) { + +/** + * Return information about project issue state values. + * + * @param $sid + * Integer state id to return information about, or 0 for all states. + * @param $restrict + * Boolean to determine if states should be restricted based on the + * permissions of the current user. + * @param $is_author + * Boolean that indicates if the current user is the author of the + * issue, which can potentially grant a wider selection of states. + * @param $defaults + * Boolean to request the states used for default issue queries. + * + * @return + * An array of states (sid as key, name as value) that match the + * given filters, or the name of the requested state. + */ +function project_issue_state($sid = 0, $restrict = false, $is_author = false, $defaults = false) { static $options; if (!$options) { @@ -1015,6 +1034,11 @@ function project_issue_state($sid = 0, $ $states[$state->sid] = $state->name; } } + else if ($defaults) { + if ($state->default_query) { + $states[$state->sid] = $state->name; + } + } else { $states[$state->sid] = $state->name; } @@ -1023,6 +1047,18 @@ function project_issue_state($sid = 0, $ return $sid ? $states[$sid] : $states; } +/** + * Return an array of state ids that should be used for default queries. + */ +function project_issue_default_states() { + static $defaults; + if (empty($defaults)) { + $states = project_issue_state(0, false, false, true); + $defaults = !empty($states) ? array_keys($states) : array(1, 2, 4); + } + return $defaults; +} + function project_issue_priority($priority = 0) { $priorities = array(1 => 'critical', 'normal', 'minor'); return $priority ? $priorities[$priority] : $priorities; @@ -1152,8 +1188,8 @@ function project_issue_query($project = $form['states'] = array( '#type' => 'select', '#title' => t('Status'), - '#default_value' => ($query->states) ? $query->states : array(1, 2, 8, 13, 14), '#options' => $states, + '#default_value' => ($query->states) ? $query->states : project_issue_default_states(), '#attributes' => array('size' => 5), '#multiple' => TRUE, ); @@ -1243,7 +1279,8 @@ function theme_project_issue_admin_state array('data' => t('Name')), array('data' => t('Weight')), array('data' => t('Author may set')), - array('data' => t('Default')), + array('data' => t('In default queries')), + array('data' => t('Default status')), array('data' => t('Operations')) ); foreach (element_children($form['status']) as $key) { @@ -1251,10 +1288,11 @@ function theme_project_issue_admin_state drupal_render($form['status'][$key]['name']), drupal_render($form['status'][$key]['weight']), drupal_render($form['status'][$key]['author_has']), + drupal_render($form['status'][$key]['default_query']), drupal_render($form['default_state'][$key]), drupal_render($form['delete'][$key])); } - $rows[] = array(NULL, drupal_render($form['status_add']['name']), drupal_render($form['status_add']['weight']), drupal_render($form['status_add']['author_has']), NULL, NULL); + $rows[] = array(NULL, drupal_render($form['status_add']['name']), drupal_render($form['status_add']['weight']), drupal_render($form['status_add']['author_has']), drupal_render($form['status_add']['default_query']), NULL, NULL); $output = '
' . theme('table', $header, $rows) . '
'; $output .= drupal_render($form); return $output; @@ -1263,6 +1301,7 @@ function theme_project_issue_admin_state function project_issue_admin_states_form() { $result = db_query('SELECT * FROM {project_issue_state} ORDER BY weight'); $default_state = variable_get('project_issue_default_state', 1); + $default_states = project_issue_default_states(); $form['status']['#tree'] = TRUE; while ($state = db_fetch_object($result)) { $options[$state->sid] = ''; @@ -1285,6 +1324,10 @@ function project_issue_admin_states_form '#type' => 'checkbox', '#default_value' => $state->author_has, ); + $form['status'][$state->sid]['default_query'] = array( + '#type' => 'checkbox', + '#default_value' => in_array($state->sid, $default_states), + ); $del_link = ($state->sid != $default_state) ? l(t('Delete'), 'admin/project/project-issue-status/delete/'. $state->sid) : ''; $form['delete'][$state->sid] = array( '#type' => 'markup', @@ -1309,6 +1352,9 @@ function project_issue_admin_states_form $form['status_add']['author_has'] = array( '#type' => 'checkbox', ); + $form['status_add']['default_query'] = array( + '#type' => 'checkbox', + ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Save'), @@ -1328,10 +1374,10 @@ function project_issue_admin_states_form // Update existing status options. if($form_values['status']) { foreach ($form_values['status'] as $sid => $value) { - $state = db_fetch_object(db_query('SELECT name, weight, author_has FROM {project_issue_state} WHERE sid = %d', $sid)); + $state = db_fetch_object(db_query('SELECT name, weight, author_has, default_query FROM {project_issue_state} WHERE sid = %d', $sid)); // Check to see whether the record needs updating. - if (($state->name != $value['name']) || ($state->weight != $value['weight']) || ($state->author_has != $value['author_has'])) { - db_query("UPDATE {project_issue_state} SET name = '%s', weight = %d, author_has = %d WHERE sid = %d", $value['name'], $value['weight'], $value['author_has'], $sid); + if (($state->name != $value['name']) || ($state->weight != $value['weight']) || ($state->author_has != $value['author_has']) || ($state->default_query != $value['default_query'])) { + db_query("UPDATE {project_issue_state} SET name = '%s', weight = %d, author_has = %d, default_query = %d WHERE sid = %d", $value['name'], $value['weight'], $value['author_has'], $value['default_query'], $sid); } } } @@ -1340,7 +1386,7 @@ function project_issue_admin_states_form // Check to see whether the state already exists: $query = db_query("SELECT name FROM {project_issue_state} WHERE name = '%s'", $form_values['status_add']['name']); if (!db_num_rows($query)) { - db_query("INSERT INTO {project_issue_state} SET name = '%s', weight = %d, author_has = %d", $form_values['status_add']['name'], $form_values['status_add']['weight'], $form_values['status_add']['author_has']); + db_query("INSERT INTO {project_issue_state} SET name = '%s', weight = %d, author_has = %d, default_query = %d", $form_values['status_add']['name'], $form_values['status_add']['weight'], $form_values['status_add']['author_has'], $form_values['status_add']['default_query']); } else { drupal_set_message(t('Status %status already exists.', array ('%status' => $form_values['status_add']['name']))); @@ -1598,8 +1644,9 @@ function project_issue_query_result_quic } // special case for states - we always want the defaults - if ($query->states != '1,2,8,13,14,4') { - foreach (array(1, 2, 8, 13, 14, 4) as $state) { + $default_states = project_issue_default_states(); + if ($query->states != implode(',', $default_states)) { + foreach ($default_states as $state) { $options[] = $state; $values[] = $states[$state]; } @@ -1707,7 +1754,7 @@ function project_issue_query_parse($quer } if (empty($query->states)) { - $query->states = array(1, 2, 8, 13, 14, 4); + $query->states = project_issue_default_states(); } if (!empty($_REQUEST['participated']) && empty($query->participated)) { $query->participated = (int)$_REQUEST['participated']; Index: modules/project_issue/project_issue.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/project_issue/project_issue.install,v retrieving revision 1.6 diff -u -p -r1.6 project_issue.install --- modules/project_issue/project_issue.install 22 Dec 2006 23:54:14 -0000 1.6 +++ modules/project_issue/project_issue.install 26 Jan 2007 07:14:05 -0000 @@ -66,6 +66,7 @@ function project_issue_install() { name varchar(32) NOT NULL default '', weight tinyint(2) DEFAULT '0' NOT NULL, author_has tinyint(2) DEFAULT '0' NOT NULL, + default_query tinyint(2) DEFAULT '0' NOT NULL, PRIMARY KEY (sid) ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;"); @@ -131,6 +132,7 @@ function project_issue_install() { name varchar(32) NOT NULL default '', weight smallint DEFAULT '0' NOT NULL, author_has smallint DEFAULT '0' NOT NULL, + default_query smallint DEFAULT '0' NOT NULL, PRIMARY KEY (sid) );"); } @@ -202,3 +204,17 @@ function project_issue_update_500() { $ret[] = update_sql("UPDATE {system} SET weight = 2 WHERE name = 'project_issue'"); return $ret; } + +function project_issue_update_501() { + $ret = array(); + switch ($GLOBALS['db_type']) { + case 'mysql': + case 'mysqli': + $ret[] = update_sql('ALTER TABLE {project_issue_state} ADD default_query tinyint NOT NULL'); + break; + case 'pgsql': + $ret[] = update_sql('ALTER TABLE {project_issue_state} ADD default_query smallint'); + break; + } + return $ret; +} Index: modules/project_issue/project_issue.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/project_issue/project_issue.module,v retrieving revision 1.19 diff -u -p -r1.19 project_issue.module --- modules/project_issue/project_issue.module 23 Jan 2007 23:51:12 -0000 1.19 +++ modules/project_issue/project_issue.module 26 Jan 2007 07:14:06 -0000 @@ -38,7 +38,8 @@ function project_issue_help($section) {
Deleting
If you delete an existing issue status, you will be prompted for a new status to assign to existing issues with the deleted status.
Weight
The weight of an issue determines the order it appears in lists, like in the select box where users designate a status for their issue.
Author may set
Check this option to give the original poster of an issue the right to set a status option, even if she or he isn\'t part of a role with this permission. You may wish, for example, to allow issue authors to close their own issues.
-
Default
The default status option will be used for new issues, and all users with the permission to create issues will automatically have permission to set this status. The default issue status cannot be deleted. If you wish to delete this status, first set a different status to default.
+
In default queries
There are a number of pages that display a list of issues based on a certain query. For all of these views of the issue queues, if no status options are explicitly selected, a certain set of defaults will be used to construct the query.
+
Default status
The default status option will be used for new issues, and all users with the permission to create issues will automatically have permission to set this status. The default issue status cannot be deleted. If you wish to delete this status, first set a different status to default.

'); break; } @@ -554,8 +555,8 @@ function project_issue_user_page($arg = 'class' => 'project-project-updated', ), ); - - $result = db_query(db_rewrite_sql("SELECT n.nid, n.title, n.changed, COUNT(p.nid) AS count, MAX(ni.changed) AS max_issue_changed FROM {node} n LEFT JOIN {project_issues} p ON n.nid = p.pid AND p.sid IN (1,2,8,13,14) LEFT JOIN {node} ni ON ni.nid = p.nid WHERE n.type = 'project_project' AND n.status = 1 AND n.uid = %d GROUP BY n.nid, n.title, n.changed") . tablesort_sql($header), $user->uid); + $default_states = project_issue_default_states(FALSE); + $result = db_query(db_rewrite_sql("SELECT n.nid, n.title, n.changed, COUNT(p.nid) AS count, MAX(ni.changed) AS max_issue_changed FROM {node} n LEFT JOIN {project_issues} p ON n.nid = p.pid AND p.sid IN ($default_states) LEFT JOIN {node} ni ON ni.nid = p.nid WHERE n.type = 'project_project' AND n.status = 1 AND n.uid = %d GROUP BY n.nid, n.title, n.changed") . tablesort_sql($header), $user->uid); if (!db_num_rows($result)) { return ($current_user ? t('You have no projects.') : t('This user has no projects.'));