cvs diff: Diffing .
Index: issue.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project_issue/issue.inc,v
retrieving revision 1.322
diff -u -p -r1.322 issue.inc
--- issue.inc	15 Jan 2009 00:29:36 -0000	1.322
+++ issue.inc	15 Jan 2009 05:24:58 -0000
@@ -1,78 +1,6 @@
 <?php
 // $Id: issue.inc,v 1.322 2009/01/15 00:29:36 dww Exp $
 
-function project_issue_page() {
-  global $user;
-
-  switch (!empty($_POST['op']) ? $_POST['op'] : arg(2)) {
-    case 'rss':
-      $project = project_project_retrieve(arg(3));
-      if ($project->nid && node_access('view', $project)) {
-        $query = new StdClass();
-        $query->projects = array($project->nid);
-
-        project_issue_query_result($query, 'rss');
-      }
-      else {
-        project_issue_query_result(NULL, 'rss');
-      }
-      break;
-    case 'add':
-      $project = project_project_retrieve(arg(3));
-      // We assume that a user may create issues for projects that he may view.
-      if ($project->nid && node_access('view', $project)) {
-        drupal_goto("node/add/project-issue/". $project->project['uri']);
-      }
-      else {
-        drupal_goto("node/add/project-issue");
-      }
-      break;
-    case 'statistics':
-      $project = project_project_retrieve(arg(3));
-      if ($project->nid && node_access('view', $project)) {
-        return project_issue_statistics($project);
-      }
-      else {
-        return project_issue_statistics();
-      }
-      break;
-    case t('Subscribe'):
-    case 'subscribe':
-    case 'subscribe-mail':
-      if ($user->uid) {
-        if (valid_email_address($user->mail)) {
-          $project = project_project_retrieve(arg(3));
-          if ($project->nid && node_access('view', $project)) {
-            return drupal_get_form('project_issue_subscribe', $project);
-          }
-          else {
-            return drupal_get_form('project_issue_subscribe');
-          }
-        }
-        else {
-          return t('You must have a valid e-mail address in order to subscribe to issues. Please <a href="@update">update your account</a>.', array('@update' => url('user/'. $user->uid .'/edit', drupal_get_destination())));
-        }
-      }
-      else {
-        $destination = drupal_get_destination();
-        return t('Please <a href="@login">login</a> or <a href="@register">register</a> in order to subscribe to issues.', array('@login' => url('user/login', $destination), '@register' => url('user/register', $destination)));
-      }
-      break;
-    case 'user':
-       $_GET['participated'] = $GLOBALS['user']->uid;
-    default:
-      $project = project_issue_build_form_url(arg(2));
-      if ($project->nid && node_access('view', $project)) {
-        $query = new StdClass();
-        $query->projects = array($project->nid);
-
-        return project_issue_query_result($query);
-      }
-      else {
-        return project_issue_query_result();
-      }
-  }
-}
 
 /**
  * JS callback method to return updated elements on the issue form.
@@ -198,137 +126,6 @@ function project_issue_update_project($p
   exit();
 }
 
-/**
- * Decides what to do with search page request.
- *
- * - if this is not a POST, just return project_project_retrieve()
- * - if this is a POST, dispatch to handler function based on form id
- *
- * @param $url_arg
- *   Value returned from arg(2)
- */
-function project_issue_build_form_url($url_arg) {
-  $adv_filters = array('text', 'attachment', 'components', 'submitted', 'assigned', 'versions', 'participated', 'projects', 'states', 'categories', 'priorities');
-  $filters = array_slice($adv_filters, 6);
-  // Remember this is a request for "my issues"
-  if ($url_arg == 'user') {
-    $_REQUEST['participated'] = $GLOBALS['user']->uid;
-  }
-
-  // this isn't a POST, just return project
-  if (empty($_POST)) {
-    if ($url_arg == 'user') {
-      // If this is the "my issues" page, don't query the DB for a
-      // project that matches "user", just return and display all
-      // matching issues regardless of project.
-      return;
-    }
-    else {
-      return project_project_retrieve($url_arg);
-    }
-  }
-
-  // dispatch to hanlders based on value of $_POST['form_id']
-  if ($_POST['form_id'] == 'project_issue_query_result_quick_search') {
-    return project_issue_quick_search($url_arg, $filters);
-  }
-  else if ($_POST['form_id'] == 'project_issue_query') {
-    return project_issue_advanced_search($url_arg, $adv_filters);
-  }
-}
-
-/**
- * Handles quick search form
- *
- * @param $url_arg
- *   Value returned from arg(2)
- * @param $filters
- *   Search filters
- */
-function project_issue_quick_search($url_arg, $filters) {
-  if ($url_arg == 'user') {
-    // My issues query, so stay on the same page
-    $destination = 'project/issues/user';
-  }
-  elseif ($_POST['projects'] == 0 || strpos($_POST['projects'], ',') !== FALSE) {
-    // search is for all/multiple projects, so just send to project/issues
-    $destination = 'project/issues';
-  }
-  else {
-    // try to find the project, and 404 if not found
-    if (!$project = project_project_retrieve($_POST['projects'])) {
-      drupal_not_found();
-      exit;
-    }
-    $destination = 'project/issues/'. $project->project['uri'];
-  }
-
-  // if 'q' is the only thing in $_GET, and it == destination, don't redirect
-  if (count($_GET) == 1 && isset($_GET['q']) && $_GET['q'] == $destination) {
-
-    // put $_POST where pager will see them
-    foreach ($filters as $filter) {
-      if (!empty($_POST[$filter])) {
-        $_REQUEST[$filter] = $_POST[$filter];
-      }
-    }
-
-    // unset $_REQUEST['edit'] so the pager links aren't full of cruft
-    unset($_REQUEST['edit']);
-    unset($_REQUEST['op']);
-    return isset($project) ? $project : NULL;
-  }
-
-  // redirecting, so put filters in session
-  foreach ($filters as $filter) {
-    if (!empty($_POST[$filter])) {
-      $issue_filters[$filter] = $_POST[$filter];
-    }
-  }
-  drupal_goto($destination, drupal_query_string_encode($issue_filters));
-}
-
-/**
- * handles the advanced search form
- */
-function project_issue_advanced_search($url_arg, $filters) {
-  // Figure out what issue filters are in place for the query we're showing
-  foreach ($filters as $filter) {
-    if (!empty($_POST[$filter])) {
-      if (is_array($_POST[$filter])) {
-        $issue_filters[$filter] = implode(',', $_POST[$filter]);
-      }
-      else {
-        $issue_filters[$filter] = $_POST[$filter];
-      }
-    }
-  }
-
-  // do we have just one project to search for?
-  if (isset($_POST['projects']) && count($_POST['projects']) == 1) {
-    // try to find the project, and 404 if not found
-    if (!$project = project_project_retrieve($_POST['projects'][0])) {
-      drupal_not_found();
-      exit;
-    }
-    $destination = 'project/issues/'. $project->project['uri'];
-    drupal_goto($destination, drupal_query_string_encode($issue_filters));
-  }
-
-  // Put the issue filters where the pager links can find them.
-  if (isset($issue_filters)) {
-    foreach ($issue_filters as $name => $val) {
-      $_REQUEST[$name] = $val;
-    }
-  }
-  // unset $_REQUEST['edit'] so the pager links aren't full of cruft
-  unset($_REQUEST['edit']);
-  // Get rid of the silly 'op', since it's not a filter.
-  unset($_REQUEST['op']);
-
-  return project_project_retrieve($url_arg);
-}
-
 function project_issue_statistics($project = 0) {
   $states = project_issue_state();
   if ($project->nid) {
@@ -1348,209 +1145,6 @@ function project_issue_count($pid) {
   return $state;
 }
 
-function project_issue_search_page($project_name = NULL, $query = NULL) {
-  $project = project_project_retrieve($project_name);
-  if (isset($project) && $project->nid && node_access('view', $project)) {
-    return drupal_get_form('project_issue_query', $project, $query);
-  }
-  else {
-    return drupal_get_form('project_issue_query', 0, $query);
-  }
-}
-
-function project_issue_query($project = 0, $query = NULL) {
-  $categories = project_issue_category();
-  $projects = array();
-  $components = array();
-  if (!empty($project->nid)) {
-    drupal_set_title(t('Search issues for %name', array('%name' => $project->title)));
-    project_project_set_breadcrumb($project, TRUE);
-    foreach ($project->project_issue['components'] as $component) {
-      $component = check_plain($component);
-      $components[$component] = $component;
-    }
-    if (module_exists('project_release')) {
-      $versions = project_release_get_releases($project, 0);
-    }
-  }
-  else {
-    $uris = NULL;
-    $projects = project_projects_select_options($uris);
-    drupal_set_title(t('Search issues for all projects'));
-  }
-  if (is_null($query)) {
-    $query = (object) array(
-      'projects' => '',
-      'summary' => '',
-      'attachment' => '',
-      'versions' => '',
-      'components' => '',
-      'categories' => '',
-      'priorities' => '',
-      'states' => '',
-      'submitted' => '',
-      'assigned' => '',
-      'users' => '',
-    );
-  }
-  $states = project_issue_state();
-  $priorities = project_issue_priority();
-
-  $form['#action'] = url(isset($project->project['uri']) ? 'project/issues/'. $project->project['uri'] : 'project/issues');
-  $form['text'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Search for'),
-    '#default_value' => $query->summary,
-    '#maxlength' => 255,
-  );
-  $form['attachment'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Has attachment.'),
-    '#default_value' => $query->attachment,
-  );
-
-  if ($projects) {
-    $form['projects'] = array(
-      '#type' => 'select',
-      '#title' => t('Projects'),
-      '#default_value' => $query->projects,
-      '#options' => $projects,
-      '#attributes' => array('size' => 5),
-      '#multiple' => TRUE,
-    );
-    $form['categories'] = array(
-      '#type' => 'select',
-      '#title' => t('Categories'),
-      '#default_value' => $query->categories,
-      '#options' => $categories,
-      '#attributes' => array('size' => 5),
-      '#multiple' => TRUE,
-    );
-  }
-  else {
-    if (!empty($versions)) {
-      $form['versions'] = array(
-        '#type' => 'select',
-        '#title' => t('Versions'),
-        '#default_value' => $query->versions,
-        '#options' => $versions,
-        '#attributes' => array('size' => 5),
-        '#multiple' => TRUE,
-      );
-    }
-    $form['components'] = array(
-      '#type' => 'select',
-      '#title' => t('Components'),
-      '#default_value' => $query->components,
-      '#options' => $components,
-      '#attributes' => array('size' => 5),
-      '#multiple' => TRUE,
-    );
-    $form['categories'] = array(
-      '#type' => 'select',
-      '#title' => t('Categories'),
-      '#default_value' => $query->categories,
-      '#options' => $categories,
-      '#attributes' => array('size' => 5),
-      '#multiple' => TRUE,
-    );
-  }
-  $form['priorities'] = array(
-    '#type' => 'select',
-    '#title' => t('Priorities'),
-    '#default_value' => $query->priorities,
-    '#options' => $priorities,
-    '#attributes' => array('size' => 5),
-    '#multiple' => TRUE,
-  );
-  $form['states'] = array(
-    '#type' => 'select',
-    '#title' => t('Status'),
-    '#options' => $states,
-    '#default_value' => ($query->states) ? $query->states : project_issue_default_states(),
-    '#attributes' => array('size' => 5),
-    '#multiple' => TRUE,
-  );
-  $form['submitted'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Submitted by'),
-    '#default_value' => $query->submitted,
-    '#autocomplete_path' => 'user/autocomplete',
-    '#size' => 20,
-    '#maxlength' => 255,
-  );
-  $form['assigned'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Assigned'),
-    '#default_value' => $query->assigned,
-    '#autocomplete_path' => 'user/autocomplete',
-    '#size' => 20,
-    '#maxlength' => 255,
-  );
-  $form['participated'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Participant'),
-    '#default_value' => $query->users,
-    '#autocomplete_path' => 'user/autocomplete',
-    '#size' => 20,
-    '#maxlength' => 255,
-  );
-  $form['submit'] = array(
-    '#type' => 'button',
-    '#value' => t('Search'),
-  );
-  return $form;
-}
-
-function theme_project_issue_query($form) {
-
-  $rows[] = array(
-    array('data' => drupal_render($form['text']), 'colspan' => 3)
-  );
-  $rows[] = array(
-    array('data' => drupal_render($form['attachment']), 'colspan' => 3)
-  );
-  if (isset($form['projects'])) {
-    $rows[] = array(
-      drupal_render($form['projects']),
-      drupal_render($form['categories']),
-      NULL,
-    );
-  }
-  elseif (isset($form['versions'])) {
-    $rows[] = array(
-      drupal_render($form['versions']),
-      drupal_render($form['components']),
-      drupal_render($form['categories']),
-    );
-  }
-  else {
-    $rows[] = array(
-      array('data' => drupal_render($form['components'])),
-      array('data' => drupal_render($form['categories']), 'colspan' => 2)
-    );
-  }
-  $rows[] = array(
-    array('data' => drupal_render($form['priorities'])),
-    array('data' => drupal_render($form['states']), 'colspan' => 2)
-  );
-  $rows[] = array(
-    drupal_render($form['submitted']),
-    drupal_render($form['assigned']),
-    drupal_render($form['participated'])
-  );
-  $rows[] = array(
-    array('data' => drupal_render($form['submit']), 'colspan' => 3)
-  );
-
-  $output = '<div class="project-issue">';
-  $output .= theme('table', array(), $rows);
-  $output .= '</div>';
-  $output .= drupal_render($form);
-
-  return $output;
-}
-
 function theme_project_issue_admin_states_form($form) {
   $header = array(
     array('data' => t('ID')),
@@ -1726,285 +1320,6 @@ function project_issue_delete_state_conf
   }
 }
 
-function project_issue_query_result($query = NULL, $format = 'html', $show_search = true, $set_title = true) {
-  global $user;
-  $query = project_issue_query_parse($query);
-  // $query must have a real value now, or the rest of this function fails.
-
-  $uris = NULL;
-  $projects = array(0 => t('<all>')) + project_projects_select_options($uris);
-  $states = array(implode(',', array_keys(project_issue_state())) => t('<all>')) + project_issue_state();
-  $priorities = array(0 => t('<all>')) + project_issue_priority();
-
-  // Load active project
-  if (count($query->projects) == 1) {
-    $project = node_load(array('nid' => (int) $query->projects[0], 'type' => 'project_project'));
-  }
-
-  if ($project) {
-    if ($set_title) {
-      drupal_set_title(t('Issues for %name', array('%name' => $project->title)));
-      project_project_set_breadcrumb($project, TRUE);
-    }
-    if (module_exists('project_release')) {
-      $releases = project_release_get_releases($project, 0);
-    }
-    $query->projects = $project->nid;
-    $links = array();
-    if (node_access('create', 'project_issue')) {
-      $links['create'] = array(
-        'title' => t('Create'),
-        'href' => 'node/add/project-issue/'. $project->project['uri'],
-        'attributes' => array('title' => t('Create a new issue for @project.', array('@project' => $project->project['uri']))),
-      );
-    }
-    else {
-      $links['create'] = array(
-        'title' => theme('project_issue_create_forbidden', $project->project['uri']),
-        'html'  => TRUE,
-      );
-    }
-    $links['statistics'] = array(
-      'title' => t('Statistics'),
-      'href' => 'project/issues/statistics/'. $project->project['uri'],
-      'attributes' => array('title' => t('See statistics about @project issues.', array('@project' => $project->project['uri']))),
-    );
-    if ($user->uid) {
-      $links['subscribe'] = array(
-        'title' => t('Subscribe'),
-        'href' => 'project/issues/subscribe-mail/'. $project->project['uri'],
-        'attributes' => array('title' => t('Receive email updates about @project issues.', array('@project' => $project->project['uri']))),
-      );
-    }
-    $links['search'] = array(
-      'title' => t('Advanced search'),
-      'href' => 'project/issues/search/'. $project->project['uri'],
-      'attributes' => array('title' => t('Use the advanced search page to find @project issues.', array('@project' => $project->project['uri']))),
-    );
-  }
-  else {
-    // only set a more descriptive title if we're not looking at "my
-    // issues" or "my projects", since those set their own title already.
-    if (!isset($_GET['q']) || !strpos($_GET['q'], '/user')) {
-      drupal_set_title(t('Issues for all projects'));
-    }
-    $links = array();
-    if (node_access('create', 'project_issue')) {
-      $links['create'] = array(
-        'title' => t('Create'),
-        'href' => "node/add/project-issue",
-        'attributes' => array('title' => t('Create a new issue.')),
-      );
-    }
-    else {
-      $links['create'] = array(
-        'title' => theme('project_issue_create_forbidden', $project->project['uri']),
-        'html'  => TRUE,
-      );
-    }
-    $links['statistics'] = array(
-      'title' => t('Statistics'),
-      'href' => "project/issues/statistics",
-      'attributes' => array('title' => t('See statistics about issues.')),
-    );
-    if ($user->uid) {
-      $links['subscribe'] = array(
-        'title' => t('Subscribe'),
-        'href' => "project/issues/subscribe-mail",
-        'attributes' => array('title' => t('Receive email updates about issues.')),
-      );
-    }
-    $links['search'] = array(
-      'title' => t('Advanced search'),
-      'href' => "project/issues/search/",
-      'attributes' => array('title' => t('Use the advanced search page for finding issues.')),
-    );
-  }
-
-  $issues_per_page = variable_get('project_issues_per_page', PROJECT_ISSUES_PER_PAGE);
-
-  $header = array();
-  if (!$project->nid) {
-    $header[] = array('data' => t('Project'), 'field' => 'p.pid');
-  }
-  $header[] = array('data' => t('Summary'), 'field' => 'n.title');
-  $header[] = array('data' => t('Status'), 'field' => 'p.sid');
-  $header[] = array('data' => t('Priority'), 'field' => 'p.priority');
-  $header[] = array('data' => t('Category'), 'field' => 'p.category');
-  if (!empty($releases)) {
-    $header[] = array('data' => t('Version'), 'field' => 'p.rid');
-  }
-  $header[] = array('data' => t('Last updated'), 'field' => 'n.changed', 'sort' => 'desc');
-  $header[] = array('data' => t('Assigned to'), 'field' => 'u.name');
-
-  $sql = project_issue_query_sql($query);
-  $result = pager_query($sql['sql'] . tablesort_sql($header), $issues_per_page, 0, $sql['count']);
-
-  $search = '';
-  if ($show_search) {
-    // Action links:
-    $search .= theme('project_issue_query_result_links', $links);
-    $search .= drupal_get_form('project_issue_query_result_quick_search', $query, $projects, $states, $priorities);
-  }
-
-  $rows = array();
-
-  // For the rest of this function, we need $projects to be a flat
-  // array to map pids to project names. If we're using the project
-  // taxonomy, it will really be an array of arrays, where each
-  // project type is itself an array. So, we flatten the array once
-  // and then can use it safely in the rest of this method.
-  if (project_use_taxonomy()) {
-    $flat_projects = array();
-    foreach ($projects as $tmp) {
-      if (is_array($tmp)) {
-        $flat_projects += $tmp;
-      }
-    }
-    $projects = $flat_projects;
-  }
-
-  $rss = '';
-  $link = '';
-  if ($format == 'rss') {
-    project_issue_query_rss($result, $project);
-  }
-  elseif (db_num_rows($result)) {
-    while ($node = db_fetch_object($result)) {
-      $node = node_load($node->nid);
-      $row = array();
-      $class = "state-". $node->project_issue['sid'];
-      if (!$project->nid) {
-        $row[] = l($projects[$node->project_issue['pid']], "project/issues/". $node->project_issue['pid']);
-      }
-      if (strlen($node->title) > 50) {
-        $title = l(drupal_substr($node->title, 0, 50), "node/$node->nid", array('title' => $node->title));
-      }
-      else {
-        $title = l($node->title, "node/$node->nid");
-      }
-      $row[] = $title . theme('mark', node_mark($node->nid, $node->changed));
-      $row[] = check_plain($states[$node->project_issue['sid']]);
-      $row[] = $priorities[$node->project_issue['priority']];
-      $row[] = project_issue_category($node->project_issue['category'], 0);
-      if (count($releases)) {
-        $row[] = $releases[$node->project_issue['rid']];
-      }
-      $row[] = array('data' => format_interval(time() - $node->changed, 2), 'align' => 'right');
-      $row[] = ($node->project_issue['assigned']) ? theme('username', user_load(array('uid' => $node->project_issue['assigned']))) : '';
-
-      $row = array('data' => $row, 'class' => $class);
-
-      $rows[] = $row;
-    }
-    $query = project_issue_query_pager($query);
-
-    drupal_add_feed(url('project/issues/rss', project_issue_query_url($query)), t('Issues'));
-    $link = l(t('#'), 'project/issues', array('title' => t('Permalink to search query.')), project_issue_query_url($query));
-    if ($pager = theme('pager', NULL, $issues_per_page, 0)) {
-      $rows[] = array(array('data' => $pager, 'colspan' => count($header)));
-    }
-  }
-  else {
-    $rows[] = array(array('data' => t('No issues found.'), 'colspan'=> 8));
-  }
-
-  $output = '<div class="project-issue">';
-  $output .= '<div class="quick-search">';
-  $output .= $search;
-
-  $output .= '</div>';
-  $output .= theme('table', $header, $rows);
-  $output .= $link;
-
-  $output .= '</div>';
-  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('<all>')) + project_issue_category();
-
-  // Convert array fields to single select form items.
-  $fields = array('projects', 'states', 'priorities', 'categories', 'users');
-  foreach ($fields as $field) {
-    if (!isset($query->$field)) {
-      $query->$field = '';
-    }
-    elseif (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 <all>
-      if (!isset(${$field}[$query->$field])) {
-        ${$field}[$query->$field] = implode(',', $option);
-      }
-    }
-  }
-
-  // special case for states - we always want the defaults
-  $default_states = project_issue_default_states();
-  if ($query->states != implode(',', $default_states)) {
-    foreach ($default_states 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;
-}
-
 /**
  * Return the HTML to use for the links at the top of issue query pages.
  *
@@ -2018,209 +1333,6 @@ function theme_project_issue_query_resul
   return theme('links', $links);
 }
 
-function theme_project_issue_query_result_quick_search($form) {
-  $rows[] = array(
-    drupal_render($form['projects']),
-    drupal_render($form['states']),
-    drupal_render($form['categories']),
-    drupal_render($form['priorities']),
-    drupal_render($form['users']) . drupal_render($form['submit']),
-  );
-  $output = theme('table', array(), $rows);
-  $output .= drupal_render($form);
-  return $output;
-}
-
-function project_issue_query_url($query = 0) {
-  static $url = NULL;
-
-  if (is_array($query) && $url === NULL) {
-    foreach ($query as $key => $value) {
-      $url[] = "$key=$value";
-    }
-    $url = implode('&', $url);
-  }
-  return $url;
-}
-
-/**
- * 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
- * exists and contains some data. If the query was otherwise going to
- * be empty, this function will automatically add the default set of
- * issue states (active, fixed, patch needs work, etc).
- *
- * @param $query
- *   The existing query object we're adding to. (This should probably
- *   be a reference, instead of returning the object again).
- *
- * @return
- *   An object that describes what kind of query we're doing.
- *
- * @see project_issue_query_result()
- */
-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)) {
-    foreach ($_POST as $key => $value) {
-      if (!empty($value) && in_array($key, $fields)) {
-        $query->$key = !is_array($value) ? explode(',', $value) : $value;
-      }
-    }
-  }
-  else {
-    foreach ($_GET as $key => $value) {
-      if (!empty($value) && in_array($key, $fields)) {
-        $query->$key = explode(',', $value);
-      }
-    }
-  }
-
-  if (empty($query->states)) {
-    $query->states = project_issue_default_states();
-  }
-  if ($query->states[0] == 'all') {
-    $query->states = array_keys(project_issue_state());
-  }
-  if (!empty($_REQUEST['participated']) && empty($query->participated)) {
-    $query->participated = (int)$_REQUEST['participated'];
-  }
-
-  return $query;
-}
-
-function project_issue_query_sql_field($field, $values, $like = 0, $operator = ' OR ', $callback = 0) {
-  $sql = array();
-  if (!is_array($values)) {
-    $values = array($values);
-  }
-  foreach ($values as $value) {
-    $value = db_escape_string($value);
-    if ($callback) {
-      $value = $callback($value);
-    }
-    $sql[] = ($like && $field != 'p.pid') ? "$field LIKE '". str_replace('%', '%%', "%$value%") ."'" : "$field = '$value'";
-  }
-  if ($sql) {
-    return '('. implode($operator, $sql) .')';
-  }
-}
-
-function project_issue_query_pager($query) {
-  $get = array();
-  if (count($query)) {
-    foreach ($query as $key => $value) {
-      $get[$key] = (is_array($value)) ? implode(',', $value) : $value;
-    }
-  }
-  return $get;
-}
-
-function project_issue_query_sql($query) {
-  $comments = 0;
-  foreach ($query as $key => $value) {
-    switch ($key) {
-      case 'projects':
-        $sql[] = project_issue_query_sql_field('p.pid', $value, 1);
-        break;
-      case 'text':
-        $comments = 1;
-        foreach (preg_split('/\s+/', $value[0]) as $word) {
-          $sql[] = '('. project_issue_query_sql_field('n.title', $word, 1) .' OR '. project_issue_query_sql_field('r.body', $word, 1) .' OR '. project_issue_query_sql_field('c.comment', $word, 1) .')';
-        }
-        break;
-      case 'attachment':
-        $comments = 1;
-        $sql[] = "(f.filepath <> '' OR cu.filepath <> '')";
-        break;
-      case 'summary':
-        $sql[] = '('. project_issue_query_sql_field('n.title', $value, 1) .' OR '. project_issue_query_sql_field('r.body', $value, 1) .')';
-        break;
-      case 'comment':
-        $comments = 1;
-        $sql[] = project_issue_query_sql_field('c.comment', $value, 1);
-        break;
-      case 'categories':
-        $sql[] = project_issue_query_sql_field('p.category', $value);
-        break;
-      case 'components':
-        $sql[] = project_issue_query_sql_field('p.component', $value);
-        break;
-      case 'versions':
-        $sql[] = project_issue_query_sql_field('p.rid', $value);
-        break;
-      case 'states':
-        $sql[] = project_issue_query_sql_field('p.sid', $value);
-        break;
-      case 'priorities':
-        $sql[] = project_issue_query_sql_field('p.priority', $value);
-        break;
-      case 'users':
-        $_sql = array(
-          project_issue_query_sql_field('n.uid', $value, 0, ' OR ', 'project_issue_query_user'),
-          project_issue_query_sql_field('p.assigned', $value, 0, ' OR ', 'project_issue_query_user')
-        );
-        $sql[] = '('. implode(' OR ', $_sql) .')';
-        break;
-      case 'participated':
-        $comments = 1;
-        $_sql = array(
-          project_issue_query_sql_field('n.uid', $value, 0, ' OR ', 'project_issue_query_user'),
-          project_issue_query_sql_field('p.assigned', $value, 0, ' OR ', 'project_issue_query_user'),
-          project_issue_query_sql_field('c.uid', $value, 0, ' OR ', 'project_issue_query_user')
-        );
-        $sql[] = '('. implode(' OR ', $_sql) .')';
-        break;
-      case 'assigned':
-        $sql[] = project_issue_query_sql_field('p.assigned', $value, 0, ' OR ', 'project_issue_query_user');
-        break;
-      case 'submitted':
-        $sql[] = project_issue_query_sql_field('n.uid', $value, 0, ' OR ', 'project_issue_query_user');
-        break;
-    }
-  }
-
-  if (!$comments) {
-    return array(
-      'sql' => db_rewrite_sql('SELECT n.nid FROM {node} n INNER JOIN {project_issues} p ON p.nid = n.nid INNER JOIN {node_revisions} r ON r.vid = n.vid INNER JOIN {users} u ON p.assigned = u.uid WHERE n.status = 1 AND ('. implode(') AND (', $sql) .')'),
-      'count' => db_rewrite_sql('SELECT COUNT(n.nid) FROM {node} n INNER JOIN {project_issues} p ON p.nid = n.nid INNER JOIN {node_revisions} r ON r.vid = n.vid INNER JOIN {users} u ON p.assigned = u.uid WHERE n.status = 1 AND ('. implode(') AND (', $sql) .')')
-    );
-  }
-  else {
-    return array(
-      'sql' => db_rewrite_sql('SELECT DISTINCT(n.nid), n.changed FROM {node} n INNER JOIN {project_issues} p ON p.nid = n.nid INNER JOIN {node_revisions} r ON r.vid = n.vid INNER JOIN {users} u ON p.assigned = u.uid LEFT JOIN {comments} c ON c.nid = p.nid LEFT JOIN {comment_upload_files} cu ON p.nid = cu.nid LEFT JOIN {files} f ON n.nid = f.nid WHERE n.status = 1 AND ('. implode(') AND (', $sql) .')'),
-      'count' => db_rewrite_sql('SELECT COUNT(DISTINCT(n.nid)) FROM {node} n INNER JOIN  {project_issues} p ON p.nid = n.nid INNER JOIN {node_revisions} r ON r.vid = n.vid INNER JOIN {users} u ON p.assigned = u.uid LEFT JOIN {comments} c ON c.nid = p.nid LEFT JOIN {comment_upload_files} cu ON p.nid = cu.nid LEFT JOIN {files} f ON n.nid = f.nid WHERE n.status = 1 AND ('. implode(') AND (', $sql) .')')
-    );
-  }
-}
-
-function project_issue_query_user($value) {
-  if (is_numeric($value)) {
-    return $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' => $value)), 'error');
-    }
-    return $uid;
-  }
-}
-
-function project_issue_query_rss($result, $project) {
-  if ($project) {
-    $channel['title'] = variable_get('site_name', 'drupal') .' - '. t('issues for !name', array('!name' => $project->title));
-  }
-  else {
-    $channel['title'] = variable_get('site_name', 'drupal') .' - '. t('issues');
-  }
-  $channel['link'] = url('project/issues', NULL, NULL, TRUE); // not 100% correct
-
-  node_feed($result, $channel);
-}
-
 /**
  * Provide an array of project issue summary fields.
  * @param $context
Index: project_issue.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project_issue/project_issue.module,v
retrieving revision 1.100
diff -u -p -r1.100 project_issue.module
--- project_issue.module	15 Jan 2009 00:29:36 -0000	1.100
+++ project_issue.module	15 Jan 2009 05:24:59 -0000
@@ -4,8 +4,6 @@
 // issue nodes      -> project_issues
 // issue comments   -> project_issue_comments
 
-/// How many issues should be displayed per page by default.
-define('PROJECT_ISSUES_PER_PAGE', 20);
 /// Default age in days of issues to auto close.
 define('PROJECT_ISSUE_AUTO_CLOSE_DAYS', 14);
 /// Project issue state = fixed.
@@ -13,12 +11,13 @@ define('PROJECT_ISSUE_STATE_FIXED', 2);
 /// Project issue state = closed.
 define('PROJECT_ISSUE_STATE_CLOSED', 7);
 
-if (function_exists('drupal_get_path')) {
+/**
+ * Implementation of hook_init().
+ */
+function project_issue_init() {
   $path = drupal_get_path('module', 'project_issue');
-  if (file_exists("$path/issue.inc")) {
-    require_once "$path/issue.inc";
-    require_once "$path/comment.inc";
-    require_once "$path/mail.inc";
+  foreach (array('issue', 'comment', 'mail') as $file) {
+    require_once "$path/$file.inc";
   }
 }
 
@@ -53,6 +52,16 @@ function project_issue_help($section) {
 }
 
 /**
+ * Implementation of hook_views_api().
+ */
+function project_issue_views_api() {
+  return array(
+    'api' => 2.0,
+    'path' => drupal_get_path('module', 'project_issue') .'/views',
+  );
+}
+
+/**
  * Implementation of hook_form_alter.
  */
 function project_issue_form_alter($form_id, &$form) {
@@ -173,17 +182,6 @@ function project_issue_perm() {
  * Callback for the main settings page.
  */
 function project_issue_settings_form() {
-
-  $form['project_issues_per_page'] = array(
-    '#title' => t('Issues per page'),
-    '#type' => 'textfield',
-    '#default_value' => variable_get('project_issues_per_page', PROJECT_ISSUES_PER_PAGE),
-    '#size' => 4,
-    '#maxlength' => 10,
-    '#description' => t('Number of issues to display on a single page when viewing the issue queues.'),
-    '#validate' => array('project_issue_validate_issues_per_page' => array()),
-  );
-
   $form['project_directory_issues']  = array(
     '#type' => 'textfield',
     '#title' => t('Issue directory'),
@@ -461,14 +459,6 @@ function project_issue_menu($may_cache) 
 
     // Issues
     $items[] = array(
-      'path' => 'project/issues',
-      'title' => t('Issues'),
-      'callback' => 'project_issue_page',
-      'access' => $access,
-      'type' => MENU_NORMAL_ITEM,
-      'weight' => -50,
-    );
-    $items[] = array(
       'path' => 'project/issues/add',
       'title' => t('Create'),
       'callback' => 'project_issue_page',
@@ -523,14 +513,6 @@ function project_issue_menu($may_cache) 
       'weight' => -49,
     );
 
-    $items[] = array(
-      'path' => 'project/issues/user',
-      'title' => t('My issues'),
-      'callback' => 'project_issue_page',
-      'access' => $user->uid && $access,
-      'type' => MENU_NORMAL_ITEM,
-    );
-
     // Administrative pages
     $items[] = array(
       'path' => 'admin/project/project-issue-settings',
@@ -1019,7 +1001,7 @@ function project_issue_user_page($arg = 
   $output = theme('table', $header, $rows, array('class' => 'projects'));
   $output .= l('#', "project/user/$user->name");
 
-  $output .= theme('box', t('Issues'), project_issue_query_result($query, 'html', false, false));
+  /// @todo Embed a view here.
 
   return $output;
 }
@@ -1136,39 +1118,6 @@ function project_issue_link_alter(&$node
   }
 }
 
-/**
- * @defgroup project_issue_views Views-integration hooks
- */
-
-/**
- * Implementation of hook_views_tables.
- * @ingroup project_issue_views
- * @see _project_issue_views_tables
- */
-function project_issue_views_tables() {
-  require_once(drupal_get_path('module', 'project_issue') .'/project_issue.views.inc');
-  return _project_issue_views_tables();
-}
-
-/**
- * Implementation of hook_views_default_views.
- * @ingroup project_issue_views
- * @see _project_issue_views_default_views
- */
-function project_issue_views_default_views() {
-  require_once(drupal_get_path('module', 'project_issue') .'/project_issue.views.inc');
-  return _project_issue_views_default_views();
-}
-
-/**
- * Implementation of hook_views_arguments.
- * @ingroup project_issue_views
- * @see _project_issue_views_arguments()
- */
-function project_issue_views_arguments() {
-  require_once(drupal_get_path('module', 'project_issue') .'/project_issue.views.inc');
-  return _project_issue_views_arguments();
-}
 
 /**
  * @defgroup project_issue_filter Project Issue number to link filter.
cvs diff: project_issue.views.inc was removed, no comparison available
