? LICENSE.txt ? batchy_patchy.patch ? fakeadd ? generate ? p_i_p.patch ? scripts ? search_index ? theme ? translations ? views Index: issue.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/project_issue/issue.inc,v retrieving revision 1.354 diff -u -p -r1.354 issue.inc --- issue.inc 18 Jun 2009 03:28:55 -0000 1.354 +++ issue.inc 16 Feb 2010 00:04:44 -0000 @@ -236,7 +236,13 @@ function project_issue_default_states() } function project_issue_priority($priority = 0) { - $priorities = array(1 => t('critical'), t('normal'), t('minor')); + static $priorities; + if (!isset($priorities)) { + $result = db_query('SELECT priority, name FROM {project_issue_priorities} ORDER BY weight'); + while ($object = db_fetch_object($result)) { + $priorities[$object->priority] = $object->name; + } + } return $priority ? $priorities[$priority] : $priorities; } Index: project_issue.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/project_issue/project_issue.install,v retrieving revision 1.64 diff -u -p -r1.64 project_issue.install --- project_issue.install 21 Aug 2009 22:51:31 -0000 1.64 +++ project_issue.install 16 Feb 2010 00:04:44 -0000 @@ -117,6 +117,13 @@ function project_issue_schema() { 'not null' => TRUE, 'default' => 0, ), + 'priority_weight' => array( + 'description' => 'The weight of the priority for this issue.', + 'type' => 'int', + 'size' => 'tiny', + 'not null' => TRUE, + 'default' => 0, + ), 'rid' => array( 'description' => 'The {project_release_nodes}.rid (version identifier) for this issue (only used in conjunction with the project_release module).', 'type' => 'int', @@ -249,6 +256,32 @@ function project_issue_schema() { ), ); + $schema['project_issue_priorities'] = array( + 'description' => 'The issue priorities.', + 'fields' => array( + 'priority' => array( + 'description' => 'The priority for this issue after this comment was made.', + 'type' => 'serial', + 'not null' => TRUE, + ), + 'name' => array( + 'description' => 'Display-friendly name for this priority.', + 'type' => 'varchar', + 'length' => 64, + 'not null' => TRUE, + 'default' => '', + ), + 'weight' => array( + 'description' => 'Weight for this priority, used when ordering priorities.', + 'type' => 'int', + 'size' => 'tiny', + 'not null' => TRUE, + 'default' => 0, + ), + ), + 'primary key' => array('priority'), + ); + $schema['project_subscriptions'] = array( 'description' => 'Table keeping track of per-user project_issue subscriptions.', 'fields' => array( @@ -364,6 +397,9 @@ function project_issue_install() { variable_set('comment_upload_project_issue', 1); // Enable file attachments for issues. variable_set('upload_project_issue', 1); + db_query("INSERT INTO {project_issue_priorities} (priority, name, weight) VALUES (1, 'critical', 1)"); + db_query("INSERT INTO {project_issue_priorities} (priority, name, weight) VALUES (2, 'normal', 2)"); + db_query("INSERT INTO {project_issue_priorities} (priority, name, weight) VALUES (3, 'minor', 3)"); } /** @@ -446,3 +482,49 @@ function project_issue_update_6002() { return $ret; } +function project_issue_update_6003() { + $ret = array(); + $table = array( + 'description' => 'The issue priorities.', + 'fields' => array( + 'priority' => array( + 'description' => 'The priority for this issue after this comment was made.', + 'type' => 'serial', + 'not null' => TRUE, + ), + 'name' => array( + 'description' => 'Display-friendly name for this priority.', + 'type' => 'varchar', + 'length' => 64, + 'not null' => TRUE, + 'default' => '', + ), + 'weight' => array( + 'description' => 'Weight for this priority, used when ordering priorities.', + 'type' => 'int', + 'size' => 'tiny', + 'not null' => TRUE, + 'default' => 0, + ), + ), + 'primary key' => array('priority'), + ); + db_create_table($ret, 'project_issue_priorities', $table); + db_query("INSERT INTO {project_issue_priorities} (priority, name, weight) VALUES (1, 'critical', 1)"); + db_query("INSERT INTO {project_issue_priorities} (priority, name, weight) VALUES (2, 'normal', 2)"); + db_query("INSERT INTO {project_issue_priorities} (priority, name, weight) VALUES (3, 'minor', 3)"); + return $ret; +} + +function project_issue_update_6004(&$sandbox) { + $ret = array(); + // Reconstruct a batch context. + $context = array('sandbox' => &$sandbox); + // Load the include. + drupal_get_path('module', 'project_issue') .'/includes/admin.inc'; + // Call the batch upgrade which will set its variables in the sandbox. + _project_issue_priorities_update('UPDATE project_issues SET priority_weight = priority WHERE nid BETWEEN %d AND %d', array(), $context); + // Pass back progress. + $ret['#finished'] = $context['finished']; + return $ret; +} Index: project_issue.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/project_issue/project_issue.module,v retrieving revision 1.174 diff -u -p -r1.174 project_issue.module --- project_issue.module 6 Aug 2009 23:35:34 -0000 1.174 +++ project_issue.module 16 Feb 2010 00:04:45 -0000 @@ -101,6 +101,27 @@ function project_issue_menu() { 'file' => 'includes/admin.settings.inc', ); + // Administrative pages + $items['admin/project/project-issue-priority'] = array( + 'title' => 'Project issue priorities', + 'description' => 'Configure what issue priorities should be used on your site.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('project_issue_admin_priorities_form'), + 'access arguments' => array('administer projects'), + 'weight' => 1, + 'type' => MENU_NORMAL_ITEM, + 'file' => 'includes/admin.inc', + ); + $items['admin/project/project-issue-priority/delete'] = array( + 'title' => 'Delete', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('project_issue_delete_state_confirm', 'priority', 'project_issue_priorities', 'priority', 'priority', 4), + 'access arguments' => array('administer projects'), + 'type' => MENU_CALLBACK, + 'file' => 'includes/admin.inc' + ); + + // Administer issue status settings $items['admin/project/project-issue-status'] = array( 'title' => 'Project issue status options', @@ -110,15 +131,15 @@ function project_issue_menu() { 'access arguments' => array('administer projects'), 'type' => MENU_NORMAL_ITEM, 'weight' => 1, - 'file' => 'includes/admin.issue_status.inc' + 'file' => 'includes/admin.inc' ); $items['admin/project/project-issue-status/delete'] = array( 'title' => 'Delete', 'page callback' => 'drupal_get_form', - 'page arguments' => array('project_issue_delete_state_confirm', 4), + 'page arguments' => array('project_issue_delete_state_confirm', 'state', 'project_issue_state', 'sid', 'state', 4), 'access arguments' => array('administer projects'), 'type' => MENU_CALLBACK, - 'file' => 'includes/admin.issue_status.inc' + 'file' => 'includes/admin.inc' ); // Issues subtab on project node edit tab. @@ -320,7 +341,13 @@ function project_issue_theme() { ), ), 'project_issue_admin_states_form' => array( - 'file' => 'includes/admin.issue_status.inc', + 'file' => 'includes/admin.inc', + 'arguments' => array( + 'form' => NULL, + ), + ), + 'project_issue_admin_priorities_form' => array( + 'file' => 'includes/admin.inc', 'arguments' => array( 'form' => NULL, ), @@ -527,7 +554,7 @@ function project_issue_access($op, $node * Helper to trim all elements in an array. */ function project_issue_trim(&$item, $key) { - $item = trim($item); + $item = trim($item); } /** @@ -621,7 +648,7 @@ function project_issue_add_auto_followup * ); * * @return - * TRUE if the comment was successfully added to the requested issue, + * TRUE if the comment was successfully added to the requested issue, * otherwise FALSE. */ function project_issue_add_followup($changes) { @@ -1760,4 +1787,3 @@ function project_issue_project_page_link $links['development']['links'] = $patches + $links['development']['links']; } } - Index: includes/admin.inc =================================================================== RCS file: includes/admin.inc diff -N includes/admin.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ includes/admin.inc 16 Feb 2010 00:04:45 -0000 @@ -0,0 +1,385 @@ + t('ID')), + array('data' => t('Name')), + array('data' => t('Weight')), + array('data' => t('Author may set')), + array('data' => t('In default queries')), + array('data' => t('Default status')), + array('data' => t('Operations')) + ); + foreach (element_children($form['status']) as $key) { + $rows[] = array( + 'class' => 'draggable', + 'data' => array( + drupal_render($form['status'][$key]['sid']), + 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( + 'class' => 'draggable', + 'data' => 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, array('id' => 'project-issue-status-admin-table')) . '
'; + $output .= drupal_render($form); + return $output; +} + +function project_issue_admin_states_form(&$form_state) { + $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] = ''; + $form['status'][$state->sid]['sid'] = array( + '#type' => 'markup', + '#value' => $state->sid, + ); + $form['status'][$state->sid]['name'] = array( + '#type' => 'textfield', + '#default_value' => $state->name, + '#size' => 20, + '#maxlength' => 255, + ); + $form['status'][$state->sid]['weight'] = array( + '#type' => 'weight', + '#default_value' => $state->weight, + '#delta' => 15, + '#attributes' => array('class' => 'project-issue-status-weight'), + ); + $form['status'][$state->sid]['author_has'] = array( + '#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', + '#value' => $del_link, + ); + } + $form['default_state'] = array( + '#type' => 'radios', + '#options' => $options, + '#default_value' => $default_state, + ); + $form['status_add']['name'] = array( + '#type' => 'textfield', + '#size' => 20, + '#maxlength' => 255, + ); + $form['status_add']['weight'] = array( + '#type' => 'weight', + '#default_value' => 0, + '#delta' => 15, + '#attributes' => array('class' => 'project-issue-status-weight'), + ); + $form['status_add']['author_has'] = array( + '#type' => 'checkbox', + ); + $form['status_add']['default_query'] = array( + '#type' => 'checkbox', + ); + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Save'), + ); + $form['#tree'] = TRUE; + return $form; +} + +/** + * Submit handler for project_issue_admin_states_form. + */ +function project_issue_admin_states_form_submit($form, &$form_state) { + // Check for and apply changes or additions to project issue status options. + if (isset($form_state['values']['default_state'])) { + variable_set('project_issue_default_state', $form_state['values']['default_state']); + } + // Update existing status options. + if($form_state['values']['status']) { + foreach ($form_state['values']['status'] as $sid => $value) { + $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']) || ($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); + } + } + } + // Add any new status options. + if (isset($form_state['values']['status_add']) && !empty($form_state['values']['status_add']['name'])) { + // Check to see whether the state already exists: + $issue_state = db_result(db_query("SELECT COUNT(*) FROM {project_issue_state} WHERE name = '%s'", $form_state['values']['status_add']['name'])); + if (empty($issue_state)) { + db_query("INSERT INTO {project_issue_state} (name, weight, author_has, default_query) VALUES ('%s', %d, %d, %d)", $form_state['values']['status_add']['name'], $form_state['values']['status_add']['weight'], $form_state['values']['status_add']['author_has'], $form_state['values']['status_add']['default_query']); + } + else { + drupal_set_message(t('Status %status already exists.', array ('%status' => $form_state['values']['status_add']['name'])), 'error'); + } + } +} + +function project_issue_delete_state_confirm(&$form_state, $function, $table, $column, $property, $sid) { + // Helper functions are in issue.inc + require_once drupal_get_path('module', 'project_issue') .'/issue.inc'; + $function = "project_issue_$function"; + $schema = drupal_get_schema('project_issues'); + if (!function_exists($function) || !isset($schema['fields'][$column]) || !db_table_exists($table)) { + drupal_access_denied(); + return; + } + $states = $function(); + $name = $states[$sid]; + unset($states[$sid]); + + // $column is verified to exist + $total = db_result(db_query("SELECT COUNT(nid) AS total FROM {project_issues} WHERE $column = %d", $sid)); + if ($total > 0) { + $form['new_sid'] = array( + '#type' => 'select', + '#title' => t('Reassign @property', array('@property' => $property)), + '#default_value' => $sid, + '#options' => $states, + '#description' => t('There are !total existing issues with @name @property. Please select a new @property for these issues.', array('!total' => $total, '@name' => $name, '@property' => $property)), + ); + } + $form['sid'] = array( + '#type' => 'value', + '#value' => $sid, + ); + $form['name'] = array( + '#type' => 'hidden', + '#value' => $name, + ); + $form['#column'] = $column; + $form['#table'] = $table; + return confirm_form( + $form, + t('Are you sure you want to delete the status option %name?', array('%name' => $name)), + 'admin/project/project-issue-status', + t('This action cannot be undone.'), + t('Delete'), t('Cancel') + ); +} + +function project_issue_delete_state_confirm_submit($form, &$form_state) { + // Column has been verified in project_issue_delete_state_confirm(). + $column = $form['#column']; + db_query('DELETE FROM {' . $form['#table'] . "} WHERE $column = %d", $form_state['values']['sid']); + $form_state['redirect'] ='admin/project/' . arg(2); + drupal_set_message(t('Project issue status %issue deleted.', array('%issue' => $name))); + if ($form_state['values']['new_sid']) { + $arguments = array($form_state['values']['new_sid'], $form_state['values']['sid']); + $update_sql = "UPDATE {project_issues} SET $column = %d WHERE $column = %d AND nid BETWEEN %d AND %d"; + $batch = array( + 'operations' => array( + array('_project_issue_priorities_update', array($update_sql, $arguments)), + ), + 'title' => t('Processing'), + // We use a single multi-pass operation, so the default + // 'Remaining x of y operations' message will be confusing here. + 'progress_message' => '', + 'error_message' => t('The update has encountered an error.'), + // The operations do not live in the .module file, so we need to + // tell the batch engine which file to load before calling them. + 'file' => drupal_get_path('module', 'project_issue') .'/includes/admin.inc', + ); + batch_set($batch); + } +} + +/** + * @file + * Code for the issue priorities admin configuration form. + */ + +function project_issue_admin_priorities_form(&$form_state) { + $result = db_query('SELECT priority, name, weight FROM {project_issue_priorities} ORDER BY weight'); + $max = 15; + while ($priority = db_fetch_object($result)) { + // We need to ensure the weight options include the maximum existing + // weight. + $max = max($delta, $priority->weight); + $form['priority'][$priority->priority]['name'] = array( + '#type' => 'textfield', + '#default_value' => $priority->name, + '#size' => 20, + '#maxlength' => 255, + ); + $form['priority'][$priority->priority]['weight'] = array( + '#type' => 'weight', + '#default_value' => $priority->weight, + '#delta' => &$delta, + '#attributes' => array('class' => 'project-issue-priority-weight'), + ); + $form['delete'][$priority->priority]['#value'] = l(t('Delete'), 'admin/project/project-issue-priority/delete/'. $priority->priority); + } + $delta = $max; + $form['priority'][0]['name'] = array( + '#type' => 'textfield', + '#default_value' => '', + '#size' => 20, + '#maxlength' => 255, + ); + $form['priority'][0]['weight'] = array( + '#type' => 'weight', + '#default_value' => $delta, + '#delta' => $delta, + '#attributes' => array('class' => 'project-issue-priority-weight'), + ); + $form['delete'][0]['#value'] = ''; + + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Save'), + ); + $form['#tree'] = TRUE; + return $form; +} + +/** + * Submit handler for project_issue_admin_states_form. + */ +function project_issue_admin_priorities_form_submit($form, &$form_state) { + $offset = 0; + foreach ($form_state['values']['priority'] as $priority_id => $value) { + $offset = min($offset, $value['weight']); + } + // $offset at this point contains the smallest weight. If that's below zero, + // then adding it to every weight will result in unsigned weights. Otherwise + // such addition is not necessary. + $offset = $offset < 0 ? -$offset : 0; + // Update existing priorities. + $update_expression = ''; + $weights = array(); + foreach ($form_state['values']['priority'] as $priority_id => $value) { + $weight = $value['weight'] + $offset; + $form_state['values']['priority'][$priority_id]['weight'] = $weight; + // Update existing. + if ($priority_id) { + $priority = db_fetch_object(db_query('SELECT priority, name, weight FROM {project_issue_priorities} WHERE priority = %d', $priority_id)); + $update = $priority->name !== $value['name']; + // Check to see whether the record needs updating. We love PHP and '0'. + if ((string)$priority->weight !== (string)$weight) { + $update_expression .= " WHEN %d THEN %d"; + $weights[] = $priority->priority; + $weights[] = $weight; + $update = TRUE; + } + if ($update) { + db_query("UPDATE {project_issue_priorities} SET name = '%s', weight = %d WHERE priority = %d", $value['name'], $weight, $priority_id); + } + } + // Add new priority. + elseif ($value['name']) { + // Check to see whether the state already exists: + $issue_state = db_result(db_query("SELECT COUNT(*) FROM {project_issue_priorities} WHERE name = '%s'", $value['name'])); + if (empty($issue_state)) { + db_query("INSERT INTO {project_issue_priorities} (name, weight) VALUES ('%s', %d)", $value['name'], $weight); + } + else { + drupal_set_message(t('Priority %priority already exists.', array ('%priority' => $value['name'])), 'error'); + } + } + } + if ($weights) { + $weight_sql = "UPDATE {project_issues} SET priority_weight = CASE priority $update_expression ELSE priority_weight END WHERE nid BETWEEN %d AND %d"; + $batch = array( + 'operations' => array( + array('_project_issue_priorities_update', array($weight_sql, $weights)), + ), + 'title' => t('Processing'), + // We use a single multi-pass operation, so the default + // 'Remaining x of y operations' message will be confusing here. + 'progress_message' => '', + 'error_message' => t('The update has encountered an error.'), + // The operations do not live in the .module file, so we need to + // tell the batch engine which file to load before calling them. + 'file' => drupal_get_path('module', 'project_issue') .'/includes/admin.inc', + ); + batch_set($batch); + } +} + +/** + * Mass update batch operation + */ +function _project_issue_priorities_update($sql, $base_arguments, &$context) { + if (!isset($context['sandbox']['min'])) { + // Avoid COUNT(*) like hell. + $context['sandbox']['max'] = db_result(db_query('SELECT MAX(nid) FROM {project_issues}')); + // We will use > so use - 1 when choosing the smallest nid. + $context['sandbox']['min'] = db_result(db_query('SELECT MIN(nid) - 1 FROM {project_issues}')); + $context['sandbox']['current'] = $context['sandbox']['min']; + } + $arguments = $base_arguments; + // MySQL does not support LIMIT & IN/ALL/ANY/SOME subquery so we do the hard + // work ourselves: find 100 nids and record the first and the last. + $results = db_query_range('SELECT nid FROM {project_issues} WHERE nid > %d ORDER BY nid ASC', $context['sandbox']['current'], 0, 100); + while ($node = db_fetch_object($results)) { + if (!isset($first_nid)) { + $first_nid = $node->nid; + } + $last_nid = $node->nid; + } + $arguments[] = $first_nid; + $arguments[] = $last_nid; + db_query($sql, $arguments); + // Note that we do not count exactly as there can be holes. That's still + // better than running COUNT() on large datasets. + if ($last_nid < $context['sandbox']['max']) { + $context['finished'] = ($last_nid - $context['sandbox']['min']) / ($context['sandbox']['max'] - $context['sandbox']['min']); + $context['sandbox']['current'] = $last_nid; + } + else { + $context['sandbox']['progress'] = 1; + } +} + +function theme_project_issue_admin_priorities_form($form) { + drupal_add_tabledrag('project-issue-admin-priority-table', 'order', 'self', 'project-issue-priority-weight'); + $header = array( + t('Priority'), + t('Weight'), + t('Operations'), + ); + foreach (element_children($form['priority']) as $key) { + $rows[] = array( + 'class' => 'draggable', + 'data' => array( + drupal_render($form['priority'][$key]['name']), + drupal_render($form['priority'][$key]['weight']), + drupal_render($form['delete'][$key]), + ), + ); + } + $output = '
' . theme('table', $header, $rows, array('id' => 'project-issue-admin-priority-table')) . '
'; + $output .= drupal_render($form); + return $output; +} Index: includes/admin.issue_status.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/project_issue/includes/admin.issue_status.inc,v retrieving revision 1.1 diff -u -p -r1.1 admin.issue_status.inc --- includes/admin.issue_status.inc 4 Apr 2009 07:03:28 -0000 1.1 +++ includes/admin.issue_status.inc 16 Feb 2010 00:04:45 -0000 @@ -1,193 +0,0 @@ - t('ID')), - array('data' => t('Name')), - array('data' => t('Weight')), - array('data' => t('Author may set')), - array('data' => t('In default queries')), - array('data' => t('Default status')), - array('data' => t('Operations')) - ); - foreach (element_children($form['status']) as $key) { - $rows[] = array( - 'class' => 'draggable', - 'data' => array( - drupal_render($form['status'][$key]['sid']), - 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( - 'class' => 'draggable', - 'data' => 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, array('id' => 'project-issue-status-admin-table')) . '
'; - $output .= drupal_render($form); - return $output; -} - -function project_issue_admin_states_form(&$form_state) { - $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] = ''; - $form['status'][$state->sid]['sid'] = array( - '#type' => 'markup', - '#value' => $state->sid, - ); - $form['status'][$state->sid]['name'] = array( - '#type' => 'textfield', - '#default_value' => $state->name, - '#size' => 20, - '#maxlength' => 255, - ); - $form['status'][$state->sid]['weight'] = array( - '#type' => 'weight', - '#default_value' => $state->weight, - '#delta' => 15, - '#attributes' => array('class' => 'project-issue-status-weight'), - ); - $form['status'][$state->sid]['author_has'] = array( - '#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', - '#value' => $del_link, - ); - } - $form['default_state'] = array( - '#type' => 'radios', - '#options' => $options, - '#default_value' => $default_state, - ); - $form['status_add']['name'] = array( - '#type' => 'textfield', - '#size' => 20, - '#maxlength' => 255, - ); - $form['status_add']['weight'] = array( - '#type' => 'weight', - '#default_value' => 0, - '#delta' => 15, - '#attributes' => array('class' => 'project-issue-status-weight'), - ); - $form['status_add']['author_has'] = array( - '#type' => 'checkbox', - ); - $form['status_add']['default_query'] = array( - '#type' => 'checkbox', - ); - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Save'), - ); - $form['#tree'] = TRUE; - return $form; -} - -/** - * Submit handler for project_issue_admin_states_form. - */ -function project_issue_admin_states_form_submit($form, &$form_state) { - // Check for and apply changes or additions to project issue status options. - if (isset($form_state['values']['default_state'])) { - variable_set('project_issue_default_state', $form_state['values']['default_state']); - } - // Update existing status options. - if($form_state['values']['status']) { - foreach ($form_state['values']['status'] as $sid => $value) { - $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']) || ($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); - } - } - } - // Add any new status options. - if (isset($form_state['values']['status_add']) && !empty($form_state['values']['status_add']['name'])) { - // Check to see whether the state already exists: - $issue_state = db_result(db_query("SELECT COUNT(*) FROM {project_issue_state} WHERE name = '%s'", $form_state['values']['status_add']['name'])); - if (empty($issue_state)) { - db_query("INSERT INTO {project_issue_state} (name, weight, author_has, default_query) VALUES ('%s', %d, %d, %d)", $form_state['values']['status_add']['name'], $form_state['values']['status_add']['weight'], $form_state['values']['status_add']['author_has'], $form_state['values']['status_add']['default_query']); - } - else { - drupal_set_message(t('Status %status already exists.', array ('%status' => $form_state['values']['status_add']['name'])), 'error'); - } - } -} - -function project_issue_delete_state_confirm(&$form_state, $sid) { - $states = project_issue_state(); - $name = $states[$sid]; - - $total = db_result(db_query('SELECT COUNT(nid) AS total FROM {project_issues} WHERE sid = %d', $sid)); - if ($total > 0) { - $form['new_sid'] = array( - '#type' => 'select', - '#title' => t('Reassign status'), - '#default_value' => $sid, - '#options' => $states, - '#description' => t('There are !total existing issues with the status of @name. Please select a new status for these issues.', array('!total' => $total, '@name' => $name)), - ); - } - $form['sid'] = array( - '#type' => 'value', - '#value' => $sid, - ); - $form['name'] = array( - '#type' => 'hidden', - '#value' => $name, - ); - return confirm_form( - $form, - t('Are you sure you want to delete the status option %name?', array('%name' => $name)), - 'admin/project/project-issue-status', - t('This action cannot be undone.'), - t('Delete'), t('Cancel') - ); -} - -function project_issue_delete_state_confirm_validate($form, &$form_state) { - if ($form_state['values']['new_sid'] == $form_state['values']['sid']) { - form_set_error('new_sid', t('Choose a new issue status for existing issues of status %name.', array('%name' => $form_state['values']['name']))); - } -} - -function project_issue_delete_state_confirm_submit($form, &$form_state) { - if ($form_state['values']['new_sid']) { - db_query('UPDATE {project_issues} SET sid = %d WHERE sid = %d', $form_state['values']['new_sid'], $form_state['values']['sid']); - } - db_query('DELETE FROM {project_issue_state} WHERE sid = %d', $form_state['values']['sid']); - drupal_set_message(t('Project issue status %issue deleted.', array('%issue' => $form_state['values']['name']))); - $form_state['redirect'] ='admin/project/project-issue-status'; -} - Index: includes/comment.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/project_issue/includes/comment.inc,v retrieving revision 1.155 diff -u -p -r1.155 comment.inc --- includes/comment.inc 23 Sep 2009 00:27:05 -0000 1.155 +++ includes/comment.inc 16 Feb 2010 00:04:45 -0000 @@ -83,7 +83,7 @@ function project_issue_comment(&$arg, $o // We should also invalidate the block cache for whatever project is now // used for this issue, since we might be deleting a comment that moved // an issue from one project to another. - $affected_projects[$current_data->pid] = 1; + $affected_projects[$current_data->pid] = 1; break; case 'view': Index: includes/issue_node_form.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/project_issue/includes/issue_node_form.inc,v retrieving revision 1.5 diff -u -p -r1.5 issue_node_form.inc --- includes/issue_node_form.inc 8 Oct 2009 23:36:16 -0000 1.5 +++ includes/issue_node_form.inc 16 Feb 2010 00:04:45 -0000 @@ -238,6 +238,7 @@ function _project_issue_form($node, $for ); } + $priority = $node->project_issue['priority'] ? $node->project_issue['priority'] : variable_get('project_issue_priority_default', 2); if ($allow_metadata_changes) { $form['project_info'] = array( '#type' => 'fieldset', @@ -286,7 +287,7 @@ function _project_issue_form($node, $for $form['issue_info']['priority'] = array( '#type' => 'select', '#title' => t('Priority'), - '#default_value' => $node->project_issue['priority'] ? $node->project_issue['priority'] : 2, + '#default_value' => $priority, '#options' => $priorities, ); $form['issue_info']['assigned'] = array( @@ -340,7 +341,7 @@ function _project_issue_form($node, $for ); $form['project_issue']['priority'] = array( '#type' => 'value', - '#value' => $node->project_issue['priority'], + '#value' => $priority, ); $form['project_issue']['assigned'] = array( '#type' => 'value', @@ -351,6 +352,10 @@ function _project_issue_form($node, $for '#value' => $node->project_issue['sid'], ); } + $form['project_issue']['priority_weight'] = array( + '#type' => 'value', + '#value' => db_result(db_query('SELECT weight FROM {project_issue_priorities} WHERE priority = %d', $priority)), + ); $form['issue_details'] = array( '#type' => 'fieldset', @@ -481,4 +486,3 @@ function _project_issue_insert($node) { // new issue will have altered the summary totals. cache_clear_all('project_issue_cockpit_block:'. $node->pid, 'cache'); } -