';
// Issue lifetime
$header = array(t('Category'), t('Overall'), t('Last month'));
@@ -323,7 +323,7 @@ function project_issue_subscribe($projec
$form['options']['#tree'] = TRUE;
$form['options'][$project->nid] = array(
'#type' => 'radios',
- '#title' => t('Subscribe to %project issues', array('%project' => check_plain($project->title))),
+ '#title' => t('Subscribe to @project issues', array('@project' => $project->title)),
'#default_value' => $level,
'#options' => $levels,
);
@@ -380,7 +380,7 @@ function project_issue_subscribe($projec
'#type' => 'submit',
'#value' => t('Subscribe'),
);
- return drupal_get_form('project_issue_subscribe', $form);
+ return $form;
}
function theme_project_issue_subscribe($form) {
@@ -415,7 +415,7 @@ function theme_project_issue_subscribe($
/**
* Implementation of hook_form().
*/
-function project_issue_form(&$node, &$param) {
+function project_issue_form($node, $param) {
global $user;
$default_state = variable_get('project_issue_default_state', 1);
@@ -427,10 +427,10 @@ function project_issue_form(&$node, &$pa
$form['page'] = array(
'#type' => 'hidden',
- '#value' => isset($_POST['edit']['page']) ? $_POST['edit']['page'] : 1,
+ '#value' => isset($_POST['page']) ? $_POST['page'] : 1,
);
- $form['#prefix'] = '
';
+ $form['#prefix'] = '
';
$form['#suffix'] = '
';
// Fetch a list of all projects to make swapping simpler
@@ -446,7 +446,7 @@ function project_issue_form(&$node, &$pa
$node->pid = db_result(db_query(db_rewrite_sql("SELECT p.nid FROM {project_projects} p WHERE p.uri = '%s'", 'p'), $arg), 0);
}
}
- $pid = $node->pid ? $node->pid : $_POST['edit']['pid'];
+ $pid = $node->pid ? $node->pid : $_POST['pid'];
if ($pid) {
// Load the project and initialize some support arrays.
$project = node_load(array('nid' => $pid, 'type' => 'project_project'));
@@ -603,7 +603,7 @@ function project_issue_form_pre_render($
// have a value for 'Project' (via a submit with project in the
// URL), we'll already be on page 2 of the form and must increment
// our page or we'll display the wrong buttons.
- if (!form_get_errors() && $form['page']['#value'] < 2 && (isset($_POST['edit']['page']) || isset($form['project_info']['pid']['#value']))) {
+ if (!form_get_errors() && $form['page']['#value'] < 2 && (isset($_POST['page']) || isset($form['project_info']['pid']['#value']))) {
$form['page']['#value'] = $form['page']['#value'] + 1;
}
@@ -664,7 +664,7 @@ function _project_issue_form_add_require
function project_issue_node_form_validate($form_id, $form) {
global $form_values;
- $edit = $_POST['edit'];
+ $edit = $_POST;
if (!$form_values['pid']) {
form_set_error('pid', t('You have to specify a valid project.'));
@@ -762,16 +762,19 @@ function project_issue_comment_validate(
return $node;
}
-function project_issue_view(&$node, $teaser = false, $page = false) {
+function project_issue_view($node, $teaser = false, $page = false) {
$node = node_prepare($node, $teaser);
if (!$teaser && $page) {
+
+ $node->content['#prefix'] = '
';
+ $node->content['#suffix'] = '
';
+
$project = node_load(array('nid' => $node->pid, 'type' => 'project_project'));
$release->nid = $node->rid;
$release = project_release_load($release);
$assigned = ($node->assigned && ($account = user_load(array('uid' => $node->assigned))) ? $account->name : t('Unassigned'));
- $output = '
';
$rows = array();
$rows[] = array('Project:', check_plain($project->title));
if ($release->version) {
@@ -785,13 +788,18 @@ function project_issue_view(&$node, $tea
if ($node->file_path && file_exists($node->file_path)) {
$rows[] = array(t('Attachment:'), '
'. basename($node->file_path) .' ('. format_size($node->file_size) .')');
}
- $output .= '
'. theme('table', array(), $rows) .'
';
-
- $output .= '
'. t('Description') .'
';
- $output .= '
'. $node->body .'
';
- $output .= '
';
-
- $node->body = $output;
+ $node->content['project_issue_summary'] = array(
+ '#value' => '
'. theme('table', array(), $rows) .'
',
+ '#weight' => -5,
+ );
+ $node->content['project_issue_header'] = array(
+ '#value' => '
'. t('Description') .'
',
+ '#weight' => -3,
+ );
+ $node->content['project_issue_comments'] = array(
+ '#value' => project_comment_view($node),
+ '#weight' => 2,
+ );
// Breadcrumb navigation
$breadcrumb[] = array('path' => 'project', 'title' => t('projects'));
@@ -804,9 +812,8 @@ function project_issue_view(&$node, $tea
$breadcrumb[] = array('path' => 'project/issues/'. $project->uri, 'title' => t('issues'));
$breadcrumb[] = array('path' => 'node/'. $node->nid);
menu_set_location($breadcrumb);
-
- $node->body .= project_comment_view($node);
}
+ return $node;
}
function project_issue_load($node) {
@@ -910,10 +917,10 @@ function project_issue_count($pid) {
function project_issue_search_page($project_name = NULL, $query = NULL) {
$project = project_project_retrieve($project_name);
if ($project->nid && node_access('view', $project)) {
- return project_issue_query($project, $query);
+ return drupal_get_form('project_issue_query', $project, $query);
}
else {
- return project_issue_query(0, $query);
+ return drupal_get_form('project_issue_query', 0, $query);
}
}
@@ -921,7 +928,7 @@ function project_issue_query($project =
$categories = project_issue_category();
$components = array();
if ($project->nid) {
- drupal_set_title(t('search issues for %name', array('%name' => theme('placeholder', $project->title))));
+ drupal_set_title(t('search issues for %name', array('%name' => $project->title)));
foreach ($project->components as $component) {
$components[$component] = $component;
}
@@ -1042,11 +1049,9 @@ function project_issue_query($project =
'#type' => 'button',
'#value' => t('Search'),
);
-
- return drupal_get_form('project_issue_query', $form);
+ return $form;
}
-
function theme_project_issue_query($form) {
$rows[] = array(
@@ -1088,7 +1093,7 @@ function theme_project_issue_query($form
array('data' => drupal_render($form['submit']), 'colspan' => 3)
);
- $output = '
';
+ $output = '
';
$output .= theme('table', array(), $rows);
$output .= '
';
$output .= drupal_render($form);
@@ -1096,7 +1101,7 @@ function theme_project_issue_query($form
return $output;
}
-function theme_project_issue_admin_states_page($form) {
+function theme_project_issue_admin_states_form($form) {
$header = array(
array('data' => t('ID')),
array('data' => t('Name')),
@@ -1113,89 +1118,80 @@ function theme_project_issue_admin_state
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']), NULL, NULL, NULL);
+ $rows[] = array(NULL, drupal_render($form['status_add']['name']), drupal_render($form['status_add']['weight']), drupal_render($form['status_add']['author_has']), NULL, NULL);
$output = '
' . theme('table', $header, $rows) . '
';
$output .= drupal_render($form);
return $output;
}
-function project_issue_admin_states_page() {
- switch ($_POST['op'] ? $_POST['op'] : arg(4)) {
- case 'save':
- case t('Save'):
- project_issue_admin_save_states();
- break;
- case 'delete':
- case t('Delete'):
- return project_issue_admin_delete_state_confirm();
- break;
- default:
- $result = db_query('SELECT * FROM {project_issue_state} ORDER BY weight');
- $default_state = variable_get('project_issue_default_state', 1);
- $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,
- );
- $form['status'][$state->sid]['author_has'] = array(
- '#type' => 'checkbox',
- '#default_value' => $state->author_has,
- );
- $form['delete'][$state->sid] = array(
- '#type' => 'markup',
- '#value' => ($state->sid != $default_state) ?
- l(t('delete'), 'admin/settings/project_issue/status/delete/'. $state->sid) :
- '',
- );
- }
- $form['default_state'] = array(
- '#type' => 'radios',
- '#options' => $options,
- '#default_value' => $default_state,
- );
- $form['status_add']['#tree'] = TRUE;
- $form['status_add']['name'] = array(
- '#type' => 'textfield',
- '#size' => 20,
- '#maxlength' => 255,
- );
- $form['status_add']['weight'] = array(
- '#type' => 'weight',
- '#default_value' => 0,
- '#delta' => 15,
- );
- $form['submit'] = array(
- '#type' => 'button',
- '#value' => t('Save'),
- );
-
- return drupal_get_form('project_issue_admin_states_page', $form);
- break;
+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);
+ $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,
+ );
+ $form['status'][$state->sid]['author_has'] = array(
+ '#type' => 'checkbox',
+ '#default_value' => $state->author_has,
+ );
+ $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,
+ );
+ $form['status_add']['author_has'] = array(
+ '#type' => 'checkbox',
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Save'),
+ );
+ $form['#tree'] = TRUE;
+ return $form;
}
-function project_issue_admin_save_states() {
+/**
+ * Submit handler for project_issue_admin_states_form.
+ */
+function project_issue_admin_states_form_submit($form_id, $form_values) {
// Check for and apply changes or additions to project issue status options.
- $edit = $_POST['edit'];
- if (isset($edit['default_state'])) {
- variable_set('project_issue_default_state', $edit['default_state']);
+ if (isset($form_values['default_state'])) {
+ variable_set('project_issue_default_state', $form_values['default_state']);
}
// Update existing status options.
- if($edit['status']) {
- foreach ($edit['status'] as $sid => $value) {
+ 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));
// Check to see whether the record needs updating.
if (($state->name != $value['name']) || ($state->weight != $value['weight']) || ($state->author_has != $value['author_has'])) {
@@ -1204,23 +1200,20 @@ function project_issue_admin_save_states
}
}
// Add any new status options.
- if($edit['status_add']) {
- if($edit['status_add']['name']) {
- // Check to see whether the state already exists:
- $name = db_result(db_query("SELECT name FROM {project_issue_state} WHERE name = '%s'", $edit['status_add']['name']));
- if (!db_num_rows($name)) {
- db_query("INSERT INTO {project_issue_state} SET name = '%s', weight = %d, author_has = %d", $edit['status_add']['name'], $edit['status_add']['weight'], $edit['status_add']['author_has']);
- }
- else {
- drupal_set_message (t('Status %status already exists.', array ('%status' => theme('placeholder', $edit['status_add']['name']))));
- }
+ if (isset($form_values['status_add']) && !empty($form_values['status_add']['name'])) {
+ // 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']);
+ }
+ else {
+ drupal_set_message(t('Status %status already exists.', array ('%status' => $form_values['status_add']['name'])));
}
}
- drupal_goto('admin/settings/project_issue/status');
}
-function project_issue_admin_delete_state_confirm() {
- $sid = arg(5);
+function project_issue_delete_state_confirm($sid) {
+ $sid = arg(4);
$states = project_issue_state();
$name = $states[$sid];
@@ -1231,39 +1224,37 @@ function project_issue_admin_delete_stat
'#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' => check_plain($name))),
+ '#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(
- 'project_issue_admin_delete_state',
- $form,
- t('Are you sure you want to delete the status option %name?', array('%name' => theme('placeholder', $name))),
- 'admin/settings/project_issue/status',
- t('This action cannot be undone.'),
- t('Delete'),
- t('Cancel')
- );
+ $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_admin_delete_state_submit($form_id, $form_values) {
+function project_issue_delete_state_confirm_submit($form_id, $form_values) {
if($form_values['new_sid'] == $form_values['sid']) {
form_set_error('new_sid', t('Choose a new issue status for
- existing issues of status %name.', array('%name' => theme('placeholder', $form_values['name']))));
+ existing issues of status %name.', array('%name' => $form_values['name'])));
} else {
if ($form_values['new_sid']) {
db_query('UPDATE {project_issues} SET sid = %d WHERE sid = %d', $form_values['new_sid'], $form_values['sid']);
}
db_query('DELETE FROM {project_issue_state} WHERE sid = %d', $form_values['sid']);
- drupal_set_message(t('Project issue status %issue deleted.', array('%issue' => theme('placeholder', $form_values['name']))));
- drupal_goto('admin/settings/project_issue/status');
+ drupal_set_message(t('Project issue status %issue deleted.', array('%issue' => $form_values['name'])));
+ drupal_goto('admin/project/project-issue-status');
}
}
@@ -1272,11 +1263,10 @@ function project_issue_query_result($que
$query = project_issue_query_parse($query);
// $query must have a real value now, or the rest of this function fails.
- $categories = array(0 => t('
')) + project_issue_category();
+ $uris = NULL;
+ $projects = array(0 => t('')) + project_projects_select_options($uris);
$states = array(implode(',', array_keys(project_issue_state())) => t('')) + project_issue_state();
$priorities = array(0 => t('')) + project_issue_priority();
- $project_urls = array();
- $projects = array(0 => t('')) + project_projects_select_options($project_urls);
// Load active project
if (count($query->projects) == 1) {
@@ -1284,18 +1274,37 @@ function project_issue_query_result($que
}
if ($project) {
- drupal_set_title(t('issues for %name', array('%name' => theme('placeholder', $project->title))));
+ drupal_set_title(t('issues for %name', array('%name' => $project->title)));
$releases = project_release_get_releases($project, 0);
$query->projects = $project->nid;
$links = array();
if (user_access('create project issues')) {
- $links[] = l(t('submit'), "node/add/project_issue/$project->uri", array('title' => t('Submit a new issue for %project.', array('%project' => check_plain($project->uri)))));
+ $links[] = array(
+ 'title' => t('Submit'),
+ 'href' => "node/add/project-issue/$project->uri",
+ 'attributes' => array('title' => t('Submit a new issue for @project.', array('@project' => $project->uri))),
+ );
}
- $links[] = l(t('statistics'), "project/issues/statistics/$project->uri", array('title' => t('See statistics about %project issues.', array('%project' => check_plain($project->uri)))));
+ $links[] = array(
+ 'title' => t('Statistics'),
+ 'href' => "project/issues/statistics/$project->uri",
+ 'attributes' => array('title' => t('See statistics about @project issues.', array('@project' => $project->uri))),
+ );
if ($user->uid) {
- $links[] = l(t('subscribe'), "project/issues/subscribe/$project->uri", array('title' => t('Receive email updates about issues for %project.', array('%project' => check_plain($project->uri)))));
+ $links[] = array(
+ 'title' => t('Subscribe'),
+ 'href' => "project/issues/subscribe/$project->uri",
+ 'attributes' => array('title' => t('Receive email updates about @project issues.', array('@project' => $project->uri))),
+ );
+ }
+ $links[] = array(
+ 'title' => t('Advanced search'),
+ 'href' => "project/issues/search/$project->uri",
+ 'attributes' => array('title' => t('Use the advanced search page to find @project issues.', array('@project' => $project->uri))),
+ );
+ if (user_access('create project issues')) {
+
}
- $links[] = l(t('advanced search'), "project/issues/search/$project->uri", array('title' => t('Use the advanced search page to find %project issues.', array('%project' => check_plain($project->uri)))));
}
else {
// only set a more descriptive title if we're not looking at "my
@@ -1305,13 +1314,29 @@ function project_issue_query_result($que
}
$links = array();
if (user_access('create project issues')) {
- $links[] = l(t('submit'), "node/add/project_issue", array('title' => t('Submit a new issue.')));
+ $links[] = array(
+ 'title' => t('Submit'),
+ 'href' => "node/add/project-issue",
+ 'attributes' => array('title' => t('Submit a new issue.')),
+ );
}
- $links[] = l(t('statistics'), "project/issues/statistics", array('title' => t('See statistics about issues.')));
+ $links[] = array(
+ 'title' => t('Statistics'),
+ 'href' => "project/issues/statistics",
+ 'attributes' => array('title' => t('See statistics about issues.')),
+ );
if ($user->uid) {
- $links[] = l(t('subscribe'), "project/issues/subscribe", array('title' => t('Receive email updates about issues.')));
+ $links[] = array(
+ 'title' => t('Subscribe'),
+ 'href' => "project/issues/subscribe",
+ 'attributes' => array('title' => t('Receive email updates about issues.')),
+ );
}
- $links[] = l(t('advanced search'), "project/issues/search/", array('title' => t('Use the advanced search page for finding issues.')));
+ $links[] = array(
+ 'title' => t('Advanced search'),
+ 'href' => "project/issues/search/",
+ 'attributes' => array('title' => t('Use the advanced search page for finding issues.')),
+ );
}
$header = array();
@@ -1327,7 +1352,6 @@ function project_issue_query_result($que
}
$header[] = array('data' => t('Last updated'), 'field' => 'n.changed', 'sort' => 'desc');
$header[] = array('data' => t('Assigned to'), 'field' => 'u.name');
- #$header[] = array('data' => t('submitted by'), 'field' => 'n.uid');
$sql = project_issue_query_sql($query);
$result = pager_query($sql['sql'] . tablesort_sql($header), 20, 0, $sql['count']);
@@ -1335,79 +1359,7 @@ function project_issue_query_result($que
if ($search) {
// Action links:
$group = theme('links', $links);
-
- // Convert array fields to single select form items.
- $fields = array('projects', 'states', 'priorities', 'categories', 'users');
- foreach ($fields as $field) {
- if (is_array($query->$field)) {
- $option = array();
-
- // $query is untrusted, user submitted data
- foreach ($query->$field as $key => $value) {
- if (isset(${$field}[$value])) {
- $option[] = ${$field}[$value];
- }
- else {
- unset($query->$field[$key]);
- }
- }
- $query->$field = implode(',', $query->$field);
-
- // special case for 'states' so we don't lose
- if (!isset(${$field}[$query->$field])) {
- ${$field}[$query->$field] = implode(',', $option);
- }
- }
- }
-
- // 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) {
- $options[] = $state;
- $values[] = $states[$state];
- }
- $options = implode(',', $options);
- $states[$options] = implode(',', $values);
- }
-
- // Make quick search form:
- $form['projects'] = array(
- '#type'=> 'select',
- '#title' => t('Project'),
- '#default_value' => $query->projects,
- '#options' => $projects,
- );
- $form['states'] = array(
- '#type'=> 'select',
- '#title' => t('Status'),
- '#default_value' => $query->states,
- '#options' => $states,
- );
- $form['categories'] = array(
- '#type'=> 'select',
- '#title' => t('Category'),
- '#default_value' => $query->categories,
- '#options' => $categories,
- );
- $form['priorities'] = array(
- '#type'=> 'select',
- '#title' => t('Priority'),
- '#default_value' => $query->priorities,
- '#options' => $priorities,
- );
- $form['users'] = array(
- '#type'=> 'hidden',
- '#value' => $query->users,
- );
- $form['js'] = array(
- '#type'=> 'hidden',
- '#value' => '0',
- );
- $form['submit'] = array(
- '#type' => 'button',
- '#value' => t('Search'),
- );
- $group .= drupal_get_form('project_issue_query_result_quick_search', $form);
+ $group .= drupal_get_form('project_issue_query_result_quick_search', $query, $projects, $states, $priorities);
}
$rows = array();
@@ -1465,7 +1417,7 @@ function project_issue_query_result($que
$rows[] = array(array('data' => t('No issues found.'), 'colspan'=> 8));
}
- $output = '';
+ $output = '
';
$output .= '
';
$output .= $group;
$output .= '
';
@@ -1475,6 +1427,86 @@ function project_issue_query_result($que
return $output;
}
+/**
+ * Form builder for the quick-search form when filtering issues on the
+ * issue query result pages.
+ */
+function project_issue_query_result_quick_search($query, $projects, $states, $priorities) {
+ $categories = array(0 => t('
')) + project_issue_category();
+
+ // Convert array fields to single select form items.
+ $fields = array('projects', 'states', 'priorities', 'categories', 'users');
+ foreach ($fields as $field) {
+ if (is_array($query->$field)) {
+ $option = array();
+
+ // $query is untrusted, user submitted data
+ foreach ($query->$field as $key => $value) {
+ if (isset(${$field}[$value])) {
+ $option[] = ${$field}[$value];
+ }
+ else {
+ unset($query->$field[$key]);
+ }
+ }
+ $query->$field = implode(',', $query->$field);
+
+ // special case for 'states' so we don't lose
+ if (!isset(${$field}[$query->$field])) {
+ ${$field}[$query->$field] = implode(',', $option);
+ }
+ }
+ }
+
+ // 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) {
+ $options[] = $state;
+ $values[] = $states[$state];
+ }
+ $options = implode(',', $options);
+ $states[$options] = implode(',', $values);
+ }
+
+ $form['projects'] = array(
+ '#type'=> 'select',
+ '#title' => t('Project'),
+ '#default_value' => $query->projects,
+ '#options' => $projects,
+ );
+ $form['states'] = array(
+ '#type'=> 'select',
+ '#title' => t('Status'),
+ '#default_value' => $query->states,
+ '#options' => $states,
+ );
+ $form['categories'] = array(
+ '#type'=> 'select',
+ '#title' => t('Category'),
+ '#default_value' => $query->categories,
+ '#options' => $categories,
+ );
+ $form['priorities'] = array(
+ '#type'=> 'select',
+ '#title' => t('Priority'),
+ '#default_value' => $query->priorities,
+ '#options' => $priorities,
+ );
+ $form['users'] = array(
+ '#type'=> 'hidden',
+ '#value' => $query->users,
+ );
+ $form['js'] = array(
+ '#type'=> 'hidden',
+ '#value' => '0',
+ );
+ $form['submit'] = array(
+ '#type' => 'button',
+ '#value' => t('Search'),
+ );
+ return $form;
+}
+
function theme_project_issue_query_result_quick_search($form) {
$rows[] = array(
drupal_render($form['projects']),
@@ -1501,7 +1533,7 @@ function project_issue_query_url($query
}
/**
- * Parses $_POST['edit'] or $_GET and creates the appropriate query
+ * Parses $_POST or $_GET and creates the appropriate query
* object based on whatever choices a user has made to filter the
* issue queue. This function *MUST* return a valid $query object,
* since the rest of project_issue_query_result() assumes that $query
@@ -1520,8 +1552,8 @@ function project_issue_query_url($query
*/
function project_issue_query_parse($query = NULL) {
$fields = array('projects', 'text', 'attachment', 'summary', 'comment', 'categories', 'components', 'versions', 'states', 'priorities', 'users', 'assigned', 'submitted', 'participated');
- if ($_SERVER['REQUEST_METHOD'] == 'POST' && is_array($_POST['edit'])) {
- foreach ($_POST['edit'] as $key => $value) {
+ if ($_SERVER['REQUEST_METHOD'] == 'POST' && is_array($_POST)) {
+ foreach ($_POST as $key => $value) {
if (!empty($value) && in_array($key, $fields)) {
$query->$key = !is_array($value) ? explode(',', $value) : $value;
}
@@ -1654,7 +1686,7 @@ function project_issue_query_user($value
else {
$uid = db_result(db_query("SELECT uid FROM {users} WHERE name = '%s'", $value));
if (!$uid) {
- drupal_set_message(t("Username '%user' not found.", array('%user' => check_plain($value))), 'error');
+ drupal_set_message(t("Username '@user' not found.", array('@user' => $value)), 'error');
}
return $uid;
}
Index: modules/project_issue/mail.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project_issue/mail.inc,v
retrieving revision 1.65
diff -u -p -r1.65 mail.inc
--- modules/project_issue/mail.inc 18 Dec 2006 09:11:08 -0000 1.65
+++ modules/project_issue/mail.inc 22 Dec 2006 19:18:09 -0000
@@ -111,7 +111,7 @@ function project_issue_mailhandler($node
$body .= "\n * $field: $text";
}
- user_mail($mailto, t('Email submission to %sn failed - %subj', array ('%sn' => variable_get('site_name', 'Drupal'), '%subj' => $header->subject)), $body, $headers);
+ drupal_mail('project_issue_mailhandler_error', $mailto, t('Email submission to !sn failed - !subj', array('!sn' => variable_get('site_name', 'Drupal'), '!subj' => $header->subject)), $body, $headers);
}
// Return a NULL result so mailhandler doesn't save the node using the default methods.
@@ -237,8 +237,8 @@ function project_mail_notify($node) {
}
// Create link to related node
- $links = t('Issue status update for %link', array('%link' => "\n". url("node/$node->nid", NULL, NULL, 1))) ."\n";
- $links .= t('Post a follow up: %link', array('%link' => "\n". url("project/comments/add/$node->nid", NULL, NULL, 1))) ."\n";
+ $links = t('Issue status update for !link', array('!link' => "\n". url("node/$node->nid", NULL, NULL, 1))) ."\n";
+ $links .= t('Post a follow up: !link', array('!link' => "\n". url("project/comments/add/$node->nid", NULL, NULL, 1))) ."\n";
// Mail summary (status values)
foreach ($fields as $field => $text) {
@@ -319,7 +319,7 @@ function project_mail_notify($node) {
$node->title = "[$project->title " . t("$node->category") ."] $node->title";
while ($recipient = db_fetch_object($result)) {
- user_mail($recipient->mail, $node->title, $body, implode("\n", $header));
+ drupal_mail('project_issue_update', $recipient->mail, $node->title, $body, implode("\n", $header));
}
if (is_array($project->mail_copy_filter) && count(array_filter($project->mail_copy_filter)) && !$project->mail_copy_filter[$node->category]) {
@@ -331,7 +331,7 @@ function project_mail_notify($node) {
}
if ($project->mail_copy) {
- user_mail($project->mail_copy, $node->title, $body, implode("\n", $header));
+ drupal_mail('project_issue_update', $project->mail_copy, $node->title, $body, implode("\n", $header));
}
}
@@ -361,7 +361,7 @@ function project_mail_reminder() {
'List-Archive: <'. url('project', NULL, NULL, 1) .'>',
);
- user_mail($mail, t('Your submitted bugs for %date', array('%date' => date('F d, Y', time()))), $body, implode("\n", $header));
+ drupal_mail('project_issue_reminder', $mail, t('Your submitted bugs for !date', array('!date' => date('F d, Y', time()))), $body, implode("\n", $header));
$body = '';
}
@@ -420,6 +420,6 @@ function project_mail_digest() {
$header['from'] = "From: $mailto";
$header['return-path'] = "Return-Path: <$mailto>";
- user_mail($mailto, t('Release critical bugs for %date', array('%date' => date('F d, Y', time()))), $text, implode("\n", $header));
+ drupal_mail('project_issue_critical_summary', $mailto, t('Release critical bugs for !date', array('!date' => date('F d, Y', time()))), $text, implode("\n", $header));
}
}
Index: modules/project_issue/project_issue.css
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project_issue/project_issue.css,v
retrieving revision 1.6
diff -u -p -r1.6 project_issue.css
--- modules/project_issue/project_issue.css 18 Dec 2006 09:11:08 -0000 1.6
+++ modules/project_issue/project_issue.css 22 Dec 2006 19:18:09 -0000
@@ -6,13 +6,13 @@
padding-top: 0.5em;
}
-.node-form .project .options fieldset .form-item {
+.project-issue .node-form .options fieldset .form-item {
float: left;
padding-right: 0.8em;
margin: 0.05em 0.1em;
}
-.node-form .project fieldset:after {
+.project-issue .node-form fieldset:after {
content: ".";
display: block;
height: 0;
@@ -20,7 +20,7 @@
visibility: hidden;
}
-.node-form .project .options fieldset {display: inline-table;}
+.project-issue .node-form .options fieldset {display: inline-table;}
table.projects {
width: 100%;
Index: modules/project_issue/project_issue.info
===================================================================
RCS file: modules/project_issue/project_issue.info
diff -N modules/project_issue/project_issue.info
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ modules/project_issue/project_issue.info 22 Dec 2006 19:18:09 -0000
@@ -0,0 +1,6 @@
+; $Id$
+name = Project issue tracking
+description = Provides issue tracking for the project.module.
+dependencies = project project_release
+package = Project
+version = "$Name$"
Index: modules/project_issue/project_issue.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project_issue/project_issue.install,v
retrieving revision 1.5
diff -u -p -r1.5 project_issue.install
--- modules/project_issue/project_issue.install 20 Dec 2006 01:38:01 -0000 1.5
+++ modules/project_issue/project_issue.install 22 Dec 2006 19:18:09 -0000
@@ -149,6 +149,8 @@ function project_issue_install() {
db_query("INSERT INTO {project_issue_state} VALUES (13, 'patch (code needs work)', -6, 0)");
db_query("INSERT INTO {project_issue_state} VALUES (14, 'patch (ready to commit)', -2, 0)");
}
+
+ db_query("UPDATE {system} SET weight = 2 WHERE name = 'project_issue'");
}
/**
@@ -186,3 +188,17 @@ function project_issue_update_1() {
$ret[] = array('success' => TRUE, 'query' => "Repaired $fixed comments");
return $ret;
}
+
+/**
+ * Updates specific to Drupal 5.x are 500 and up...
+ */
+
+/**
+ * Need to set the system weight so the admin/project menu links work
+ * properly (project_issue must come after project).
+ */
+function project_issue_update_500() {
+ $ret = array();
+ $ret[] = update_sql("UPDATE {system} SET weight = 2 WHERE name = 'project_issue'");
+ 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.11
diff -u -p -r1.11 project_issue.module
--- modules/project_issue/project_issue.module 22 Dec 2006 18:34:25 -0000 1.11
+++ modules/project_issue/project_issue.module 22 Dec 2006 19:18:10 -0000
@@ -14,8 +14,6 @@ if (file_exists("$path/issue.inc")) {
function project_issue_help($section) {
switch ($section) {
- case 'admin/modules#description':
- return t('Provides issues tracking for the project.module.');
case 'admin/help#project_issue':
$help = t('Mailhandler support
'.
'Basic mail format:
'.
@@ -33,7 +31,7 @@ function project_issue_help($section) {
return $help;
case 'node/add#project_issue':
return t('Add a new issue (bug report, feature request, etc) to an existing project.');
- case 'admin/settings/project_issue/status':
+ case 'admin/project/project-issue-status':
return t('Use this page to add new status options for project issues or to change or delete existing options.
- Adding
- To add a new status option, put its name in one of the blank places at the bottom of the form and assign it a weight.
- Updating
- When renaming existing issues, keep in mind that issues with the existing name will receive the new one.
@@ -48,7 +46,11 @@ function project_issue_help($section) {
function project_issue_node_info() {
return array(
- 'project_issue' => array('name' => t('issue'), 'base' => 'project_issue'),
+ 'project_issue' => array(
+ 'name' => t('Issue'),
+ 'module' => 'project_issue',
+ 'description' => t('An issue that can be tracked, such as a bug report, feature request, or task.'),
+ ),
);
}
@@ -69,7 +71,7 @@ function project_issue_perm() {
/**
* Callback for the main settings page.
*/
-function project_issue_settings() {
+function project_issue_settings_form() {
$project_directory = file_create_path(variable_get('project_directory_issues', 'issues'));
if (!file_check_directory($project_directory)) {
$error['project_directory_issues'] = theme('error', t('Directory does not exist, or is not writable.'));
@@ -81,10 +83,10 @@ function project_issue_settings() {
'#default_value' => variable_get('project_directory_issues', 'issues'),
'#size' => 30,
'#maxlength' => 255,
- '#description' => t("Subdirectory in the directory '%dir' where attachment to issues will be stored.", array('%dir' => variable_get('file_directory_path', 'files') . '/')),
+ '#description' => t("Subdirectory in the directory '%dir' where attachments to issues will be stored.", array('%dir' => variable_get('file_directory_path', 'files') . '/')),
);
- if (module_exist('mailhandler')) {
+ if (module_exists('mailhandler')) {
// TODO: move this stuff to mailhandler.module ?
$items = array(t(''));
$result = db_query('SELECT mail FROM {mailhandler} ORDER BY mail');
@@ -98,7 +100,7 @@ function project_issue_settings() {
'#options' => $items,
);
}
- return $form;
+ return system_settings_form($form);
}
function project_issue_cron() {
@@ -128,7 +130,10 @@ function project_issue_link($type, $node
case 'node':
if ($node->type == 'project_issue') {
if (user_access('create project issues')) {
- $links[] = l(t('follow up'), "project/comments/add/$node->nid");
+ $links['project_issue_follow_up'] = array(
+ 'title' => t('Follow up'),
+ 'href' => "project/comments/add/$node->nid",
+ );
}
}
break;
@@ -141,136 +146,164 @@ function project_issue_menu($may_cache)
global $user;
if ($may_cache) {
- // Authenticated user pages:
+ // Anonymous user pages:
// Issues
$access = user_access('access project issues');
$items[] = array(
'path' => 'project/issues',
- 'title' => t('issues'),
+ 'title' => t('Issues'),
'callback' => 'project_issue_page',
'access' => $access,
'type' => MENU_NORMAL_ITEM,
);
$items[] = array(
- 'path' => 'project/issues/user',
- 'title' => t('my issues'),
- 'callback' => 'project_issue_page',
- 'access' => $GLOBALS['user']->uid && $access,
- 'type' => MENU_NORMAL_ITEM,
- );
- $items[] = array(
- 'path' => 'project/issues/subscribe',
- 'title' => t('subscribe'),
- 'callback' => 'project_issue_page',
- 'access' => $GLOBALS['user']->uid && $access,
- 'type' => MENU_NORMAL_ITEM,
- );
- $items[] = array(
'path' => 'project/issues/add',
- 'title' => t('submit'),
+ 'title' => t('Submit'),
'callback' => 'project_issue_page',
'access' => $access,
'type' => MENU_NORMAL_ITEM,
);
$items[] = array(
'path' => 'project/issues/statistics',
- 'title' => t('statistics'),
+ 'title' => t('Statistics'),
'callback' => 'project_issue_page',
'access' => $access,
'type' => MENU_NORMAL_ITEM,
);
$items[] = array(
'path' => 'project/issues/search',
- 'title' => t('search'),
+ 'title' => t('Search'),
'callback' => 'project_issue_search_page',
'access' => $access,
'type' => MENU_NORMAL_ITEM,
);
- if (module_exist('search')) {
+ if (module_exists('search')) {
$items[] = array(
'path' => 'search/issues',
- 'title' => t('issues'),
+ 'title' => t('Issues'),
'callback' => 'project_issue_search_page',
'access' => $access,
'type' => MENU_LOCAL_TASK,
'weight' => 4,
);
}
+ $items[] = array(
+ 'path' => 'project/issues/subscribe',
+ 'title' => t('Subscribe'),
+ 'callback' => 'project_issue_page',
+ 'access' => $GLOBALS['user']->uid && $access,
+ 'type' => MENU_NORMAL_ITEM,
+ );
// "My projects" page (which shows all issues for all your projects)
$items[] = array(
'path' => 'project/user',
- 'title' => t('my projects'),
+ 'title' => t('My projects'),
'callback' => 'project_issue_user_page',
'access' => $user->uid && $access,
'type' => MENU_NORMAL_ITEM,
);
- // Create issues
$access = user_access('create project issues');
+ // Backwards-compatibility menu item so node/add/project_issue
+ // still works, even though the official type is "project-issue"
$items[] = array(
'path' => 'node/add/project_issue',
- 'title' => t('issue'),
- 'callback' => 'node_page',
- 'access' => $access,
- 'type' => MENU_NORMAL_ITEM,
- 'weight' => 1,
- );
-
- // Administer issue status settings
- $access = user_access('administer projects');
- $items[] = array(
- 'path' => 'admin/settings/project_issue/status',
- 'title' => t('status options'),
- 'callback' => 'project_issue_admin_states_page',
- 'access' => $access,
- 'type' => MENU_NORMAL_ITEM,
- );
- $items[] = array(
- 'path' => 'admin/settings/project_issue/status/save',
- 'title' => t('save'),
- 'callback' => 'project_issue_admin_states_page',
- 'access' => $access,
- 'type' => MENU_CALLBACK,
- );
- $items[] = array(
- 'path' => 'admin/settings/project_issue/status/delete',
- 'title' => t('delete'),
- 'callback' => 'project_issue_admin_states_page',
+ 'title' => t('Issue'),
+ 'callback' => 'project_issue_add_page',
'access' => $access,
'type' => MENU_CALLBACK,
+ 'weight' => 1,
);
- // Comments
- $access = user_access('create project issues');
+ // Reply to issues
$items[] = array(
'path' => 'project/comments',
- 'title' => t('comments'),
+ 'title' => t('Comments'),
'callback' => 'project_comment_page',
'access' => $access,
'type' => MENU_CALLBACK,
);
}
else {
+ // Authenticated users
+
+ $items[] = array(
+ 'path' => 'project/issues/user',
+ 'title' => t('My issues'),
+ 'callback' => 'project_issue_page',
+ 'access' => $GLOBALS['user']->uid && $access,
+ 'type' => MENU_NORMAL_ITEM,
+ );
+
// Issues subtab on project node edit tab.
if (arg(0) == 'node' && is_numeric(arg(1))) {
$node = node_load(arg(1));
if ($node->type == 'project_project' && node_access('update', $node)) {
$items[] = array(
'path' => 'node/'. arg(1) .'/edit/issues',
- 'title' => t('issues'),
+ 'title' => t('Issues'),
'callback' => 'project_issue_project_edit_issues',
'type' => MENU_LOCAL_TASK,
);
}
}
- theme_add_style(drupal_get_path('module', 'project_issue') .'/project_issue.css');
+
+ // Administrative pages
+ $access = user_access('administer projects');
+ $items[] = array(
+ 'path' => 'admin/project/project-issue-settings',
+ 'title' => t('Project issue settings'),
+ 'description' => t('Specify where attachments to issues should be stored on your site.'),
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('project_issue_settings_form'),
+ 'type' => MENU_NORMAL_ITEM,
+ 'weight' => 1,
+ 'access' => $access,
+ );
+
+ // Administer issue status settings
+ $items[] = array(
+ 'path' => 'admin/project/project-issue-status',
+ 'title' => t('Project issue status options'),
+ 'description' => t('Configure what issue status values should be used on your site.'),
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('project_issue_admin_states_form'),
+ 'weight' => 1,
+ 'access' => $access,
+ 'type' => MENU_NORMAL_ITEM,
+ );
+ $items[] = array(
+ 'path' => 'admin/project/project-issue-status/delete',
+ 'title' => t('Delete'),
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('project_issue_delete_state_confirm'),
+ 'access' => $access,
+ 'type' => MENU_CALLBACK,
+ );
+
+ drupal_add_css(drupal_get_path('module', 'project_issue') .'/project_issue.css');
}
return $items;
}
/**
+ * Backwards compatbility menu callback so node/add/project_issue
+ * still works, even though the default is now "project-issue".
+ */
+function project_issue_add_page($project = NULL, $category = NULL) {
+ $url = 'node/add/project-issue';
+ if (!empty($project)) {
+ $url .= '/' . $project;
+ }
+ if (!empty($category)) {
+ $url .= '/' . $category;
+ }
+ drupal_goto(check_url($url));
+}
+
+/**
* Adds the issues subtab to the edit tab on project nodes.
*/
function project_issue_project_edit_issues() {
@@ -281,7 +314,13 @@ function project_issue_project_edit_issu
if (is_array($node->components)) {
$node->components = implode("\n", $node->components);
}
+ return drupal_get_form('project_issue_project_edit_form', $node);
+}
+/**
+ * Form builder for the issues subtab on the edit tab for project nodes.
+ */
+function project_issue_project_edit_form($node) {
/* Issue properties */
$form['issue'] = array(
'#type' => 'fieldset',
@@ -389,7 +428,7 @@ function project_issue_project_edit_issu
'#weight' => 45,
);
- return drupal_get_form('project_issue_project_edit_form', $form);
+ return $form;
}
/**
@@ -439,7 +478,7 @@ function project_issue_issue_nodeapi(&$n
// or if user is original issue poster and poster is granted access.
// If none of these is true, set error.
if (!(user_access('set issue status '. str_replace("'", "", $state->name)) || ($node->sid == variable_get('project_issue_default_state', 1)) || ($state->author_has && ($user->uid == $node->uid)))) {
- form_set_error('sid', t('Invalid issue status %status: you do not have permission to set this status', array('%status' => theme('placeholder', $state))));
+ form_set_error('sid', t('Invalid issue status %status: you do not have permission to set this status', array('%status' => $state)));
}
break;
}
@@ -457,7 +496,7 @@ function project_issue_user_page($arg =
}
$user = db_fetch_object(db_query("SELECT uid, name FROM {users} WHERE $where", $arg));
if ($user) {
- drupal_set_title(t('Projects by %user', array('%user' => check_plain($user->name))));
+ drupal_set_title(t('Projects by @user', array('@user' => $user->name)));
}
}
@@ -508,16 +547,31 @@ function project_issue_user_page($arg =
}
foreach ($projects as $node) {
$issue_links = array(
- l(t('view'), "project/issues/$node->nid"),
- l(t('search'), "project/issues/search/$node->nid"),
- l(t('submit'), "node/add/project_issue/$node->nid"),
+ array(
+ 'title' => t('View'),
+ 'href' => "project/issues/$node->nid"
+ ),
+ array(
+ 'title' => t('Search'),
+ 'href' => "project/issues/search/$node->nid",
+ ),
+ array(
+ 'title' => t('Submit'),
+ 'href' => "node/add/project-issue/$node->nid",
+ ),
);
if ($node->is_admin) {
$project_links = array(
- l(t('edit'), "node/$node->nid/edit"),
+ array(
+ 'title' => t('Edit'),
+ 'href' => "node/$node->nid/edit",
+ ),
);
- if (module_exist('project_release')) {
- $project_links[] = l(t('add release'), "node/add/project_release/$node->nid");
+ if (module_exists('project_release')) {
+ $project_links[] = array(
+ 'title' => t('Add release'),
+ 'href' => "node/add/project-release/$node->nid",
+ );
}
}
$row = array(