[ Index ]

PHP Cross Reference of Eventum

title

Body

[close]

/ -> update.php (source)

   1  <?php
   2  /* vim: set expandtab tabstop=4 shiftwidth=4 encoding=utf-8: */
   3  // +----------------------------------------------------------------------+
   4  // | Eventum - Issue Tracking System                                      |
   5  // +----------------------------------------------------------------------+
   6  // | Copyright (c) 2003, 2004, 2005, 2006, 2007 MySQL AB                  |
   7  // |                                                                      |
   8  // | This program is free software; you can redistribute it and/or modify |
   9  // | it under the terms of the GNU General Public License as published by |
  10  // | the Free Software Foundation; either version 2 of the License, or    |
  11  // | (at your option) any later version.                                  |
  12  // |                                                                      |
  13  // | This program is distributed in the hope that it will be useful,      |
  14  // | but WITHOUT ANY WARRANTY; without even the implied warranty of       |
  15  // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        |
  16  // | GNU General Public License for more details.                         |
  17  // |                                                                      |
  18  // | You should have received a copy of the GNU General Public License    |
  19  // | along with this program; if not, write to:                           |
  20  // |                                                                      |
  21  // | Free Software Foundation, Inc.                                       |
  22  // | 59 Temple Place - Suite 330                                          |
  23  // | Boston, MA 02111-1307, USA.                                          |
  24  // +----------------------------------------------------------------------+
  25  // | Authors: João Prado Maia <jpm@mysql.com>                             |
  26  // +----------------------------------------------------------------------+
  27  //
  28  // @(#) $Id: update.php 3437 2007-11-10 00:52:16Z glen $
  29  
  30  require_once(dirname(__FILE__) . "/init.php");
  31  require_once (APP_INC_PATH . "class.template.php");
  32  require_once (APP_INC_PATH . "class.auth.php");
  33  require_once (APP_INC_PATH . "class.issue.php");
  34  require_once (APP_INC_PATH . "class.category.php");
  35  require_once (APP_INC_PATH . "class.priority.php");
  36  require_once (APP_INC_PATH . "class.project.php");
  37  require_once (APP_INC_PATH . "class.release.php");
  38  require_once (APP_INC_PATH . "class.misc.php");
  39  require_once (APP_INC_PATH . "class.notification.php");
  40  require_once (APP_INC_PATH . "class.status.php");
  41  require_once (APP_INC_PATH . "class.group.php");
  42  require_once (APP_INC_PATH . "db_access.php");
  43  
  44  $prj_id = Auth::getCurrentProject();
  45  $usr_id = Auth::getUserID();
  46  $role_id = Auth::getCurrentRole();
  47  
  48  $associated_projects = @array_keys(Project::getAssocList($usr_id));
  49  
  50  $tpl = new Template_API();
  51  $tpl->setTemplate("update.tpl.html");
  52  
  53  Auth::checkAuthentication(APP_COOKIE);
  54  
  55  $issue_id = @$_POST["issue_id"] ? $_POST["issue_id"] : @$_GET["id"];
  56  
  57  if (empty($issue_id)) {
  58      $tpl->displayTemplate();
  59      exit;
  60  }
  61  
  62  // check if the requested issue is a part of the 'current' project. If it doesn't
  63  // check if issue exists in another project and if it does, switch projects
  64  $iss_prj_id = Issue::getProjectID($issue_id);
  65  $auto_switched_from = false;
  66  if ((!empty($iss_prj_id)) && ($iss_prj_id != $prj_id) && (in_array($iss_prj_id, $associated_projects))) {
  67      $cookie = Auth::getCookieInfo(APP_PROJECT_COOKIE);
  68      Auth::setCurrentProject($iss_prj_id, $cookie["remember"], true);
  69      $auto_switched_from = $iss_prj_id;
  70      $prj_id = $iss_prj_id;
  71  }
  72  
  73  $details = Issue::getDetails($issue_id);
  74  $tpl->assign("issue", $details);
  75  $tpl->assign("extra_title", ev_gettext('Update Issue #%1$s', $issue_id));
  76  
  77  if (($role_id == User::getRoleID('customer')) && (User::getCustomerID($usr_id) != $details['iss_customer_id'])) {
  78      $tpl->assign("auth_customer", 'denied');
  79  } elseif (!Issue::canAccess($issue_id, $usr_id)) {
  80      $tpl->assign("auth_customer", 'denied');
  81  } else {
  82      $new_prj_id = Issue::getProjectID($issue_id);
  83      if (@$_POST["cat"] == "update") {
  84          $res = Issue::update($_POST["issue_id"]);
  85          $tpl->assign("update_result", $res);
  86          $tpl->assign("errors", $errors);
  87          if (Issue::hasDuplicates($_POST["issue_id"])) {
  88              $tpl->assign("has_duplicates", "yes");
  89          }
  90      }
  91  
  92      $prj_id = Auth::getCurrentProject();
  93  
  94      $setup = Setup::load();
  95      $tpl->assign("allow_unassigned_issues", @$setup["allow_unassigned_issues"]);
  96  
  97      // if currently selected release is in the past, manually add it to list
  98      $releases = Release::getAssocList($prj_id);
  99      if ($details["iss_pre_id"] != 0 && empty($releases[$details["iss_pre_id"]])){
 100          $releases = array($details["iss_pre_id"] => $details["pre_title"]) + $releases;
 101      }
 102  
 103      if (Workflow::hasWorkflowIntegration($prj_id)) {
 104          $statuses = Workflow::getAllowedStatuses($prj_id, $issue_id);
 105          // if currently selected release is not on list, go ahead and add it.
 106      } else {
 107          $statuses = Status::getAssocStatusList($prj_id, false);
 108      }
 109      if ((!empty($details['iss_sta_id'])) && (empty($statuses[$details['iss_sta_id']]))) {
 110          $statuses[$details['iss_sta_id']] = Status::getStatusTitle($details['iss_sta_id']);
 111      }
 112  
 113      $tpl->assign(array(
 114          "subscribers"  => Notification::getSubscribers($issue_id),
 115          "notify_list"  => Notification::getLastNotifiedAddresses($issue_id),
 116          "categories"   => Category::getAssocList($prj_id),
 117          "priorities"   => Priority::getAssocList($prj_id),
 118          "status"       => $statuses,
 119          "releases"     => $releases,
 120          "resolutions"  => Resolution::getAssocList(),
 121          "users"        => Project::getUserAssocList($prj_id, 'active', User::getRoleID('Customer')),
 122          "issues"       => Issue::getColList("iss_id <> $issue_id"),
 123          "one_week_ts"  => time() + (7 * DAY),
 124          "allow_unassigned_issues"   =>  @$setup["allow_unassigned_issues"],
 125          "groups"       => Group::getAssocList($prj_id),
 126          'current_year' =>   date('Y'),
 127      ));
 128  
 129      $cookie = Auth::getCookieInfo(APP_PROJECT_COOKIE);
 130      if (!empty($cookie['auto_switched_from'])) {
 131          $tpl->assign(array(
 132              "project_auto_switched" =>  1,
 133              "old_project"   =>  Project::getName($cookie['auto_switched_from'])
 134          ));
 135      }
 136  }
 137  $tpl->assign("usr_role_id", User::getRoleByUser($usr_id, $prj_id));
 138  $tpl->displayTemplate();


Generated: Wed Dec 19 21:21:33 2007 Cross-referenced by PHPXref 0.7