Index: issue.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/project_issue/issue.inc,v retrieving revision 1.172.2.16 diff --unified -r1.172.2.16 issue.inc --- issue.inc 8 Aug 2006 22:19:17 -0000 1.172.2.16 +++ issue.inc 9 Aug 2006 10:40:41 -0000 @@ -49,7 +49,7 @@ case 'user': $_GET['participated'] = $GLOBALS['user']->uid; default: - $project = project_project_retrieve(arg(2)); + $project = project_issue_build_form_url(arg(2)); if ($project->nid && node_access('view', $project)) { $query = new StdClass(); $query->projects = array($project->nid); @@ -62,6 +62,46 @@ } } +/** + * this function aims to make sure that the url for a given search + * is *always* consistent with the POST'ed search filters. yep, that + * means it will redirect on every request, and rebuild the query + * string for the search. + * + * given this new scheme, might be worth posting the project uri + * back, so there's no need to do the search before the redirect. + */ +function project_issue_build_form_url($url_arg) { + // if this isn't a POST, return the project + if (empty($_POST)) { + return project_project_retrieve($url_arg); + } + + // search is for all projects + if ($_POST['edit']['projects'] == 0) { + $destination = 'project/issues'; + } + else { + if (!$project = project_project_retrieve($_POST['edit']['projects'])) { + drupal_not_found(); + exit; + } + $destination = 'project/issues/'. $project->uri; + } + + // now, we need to catch anything else from the POST and put it in the url + $query_parts = array(); + foreach (array('states', 'categories', 'priorities') as $filter) { + if (isset($_POST['edit'][$filter])) { + $query_parts[] = $filter .'='. $_POST['edit'][$filter]; + } + } + $query_string = count($query_parts) ? '?'. implode('&', $query_parts) : ''; + + $_REQUEST['destination'] = $destination . $query_string; + drupal_goto(); +} + function project_issue_statistics($project = 0) { if ($project->nid) { $breadcrumb = array( @@ -1300,8 +1340,8 @@ $rss = theme('feed_icon', url('project/issues/rss', project_issue_query_url($query))); $link = l(t('#'), 'project/issues', array('title' => t('Permalink to search query.')), project_issue_query_url($query)); - - if ($pager = theme('pager', NULL, 20, 0, $query)) { + + if ($pager = theme('pager', NULL, 20, 0)) { $rows[] = array(array('data' => $pager, 'colspan' => count($header))); } } @@ -1368,10 +1408,8 @@ foreach ($_POST['edit'] as $key => $value) { if (!empty($value) && in_array($key, $fields)) { $query->$key = !is_array($value) ? explode(',', $value) : $value; - $_POST[$key] = is_array($value) ? implode(',', $value) : $value; } } - unset($_POST['edit'], $_POST['op']); } else { foreach ($_GET as $key => $value) {