[ Index ]

PHP Cross Reference of Eventum

title

Body

[close]

/ -> view.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: view.php 3258 2007-02-14 23:25:56Z 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.time_tracking.php");
  35  require_once (APP_INC_PATH . "class.note.php");
  36  require_once (APP_INC_PATH . "class.impact_analysis.php");
  37  require_once (APP_INC_PATH . "class.support.php");
  38  require_once (APP_INC_PATH . "class.notification.php");
  39  require_once (APP_INC_PATH . "class.attachment.php");
  40  require_once (APP_INC_PATH . "class.custom_field.php");
  41  require_once (APP_INC_PATH . "class.phone_support.php");
  42  require_once (APP_INC_PATH . "class.scm.php");
  43  require_once (APP_INC_PATH . "class.draft.php");
  44  require_once (APP_INC_PATH . "db_access.php");
  45  
  46  $tpl = new Template_API();
  47  $tpl->setTemplate("view.tpl.html");
  48  
  49  Auth::checkAuthentication(APP_COOKIE);
  50  
  51  $prj_id = Auth::getCurrentProject();
  52  $usr_id = Auth::getUserID();
  53  $role_id = Auth::getCurrentRole();
  54  
  55  $associated_projects = @array_keys(Project::getAssocList($usr_id));
  56  
  57  @$issue_id = $_POST["issue_id"] ? $_POST["issue_id"] : $_GET["id"];
  58  $tpl->assign("extra_title", "Issue #$issue_id Details");
  59  
  60  // check if the requested issue is a part of the 'current' project. If it doesn't
  61  // check if issue exists in another project and if it does, switch projects
  62  $iss_prj_id = Issue::getProjectID($issue_id);
  63  $auto_switched_from = false;
  64  if ((!empty($iss_prj_id)) && ($iss_prj_id != $prj_id) && (in_array($iss_prj_id, $associated_projects))) {
  65      $cookie = Auth::getCookieInfo(APP_PROJECT_COOKIE);
  66      Auth::setCurrentProject($iss_prj_id, $cookie["remember"], true);
  67      $auto_switched_from = $prj_id;
  68      $prj_id = $iss_prj_id;
  69  }
  70  
  71  $details = Issue::getDetails($issue_id);
  72  $tpl->assign("issue", $details);
  73  
  74  // in the case of a customer user, also need to check if that customer has access to this issue
  75  if (($role_id == User::getRoleID('customer')) && (User::getCustomerID($usr_id) != $details['iss_customer_id'])) {
  76      $tpl->assign("auth_customer", 'denied');
  77  } elseif (!Issue::canAccess($issue_id, $usr_id)) {
  78      $tpl->assign("auth_user", 'denied');
  79  } else {
  80      $associated_projects = @array_keys(Project::getAssocList($usr_id));
  81      if ((empty($details)) || ($details['iss_prj_id'] != $prj_id)) {
  82          $tpl->assign('issue', '');
  83      } else {
  84          // check if the requested issue is a part of one of the projects
  85          // associated with this user
  86          if (!@in_array($details['iss_prj_id'], $associated_projects)) {
  87              $tpl->assign("auth_customer", 'denied');
  88          } else {
  89              $options = Issue::saveSearchParams();
  90              $sides = Issue::getSides($issue_id, $options);
  91  
  92              // check if scheduled release should be displayed
  93              $releases = Release::getAssocList($prj_id);
  94              if (count($releases) > 0) {
  95                  $show_releases = 1;
  96              } else {
  97                  $show_releases = 0;
  98              }
  99  
 100              // get if categories should be displayed
 101              $cats = Category::getList($prj_id);
 102              if (count($cats) > 0) {
 103                  $show_category = 1;
 104              } else {
 105                  $show_category = 0;
 106              }
 107  
 108              $cookie = Auth::getCookieInfo(APP_PROJECT_COOKIE);
 109              if (!empty($auto_switched_from)) {
 110                  $tpl->assign(array(
 111                      "project_auto_switched" =>  1,
 112                      "old_project"   =>  Project::getName($auto_switched_from)
 113                  ));
 114              }
 115              $setup = Setup::load();
 116              $tpl->assign("allow_unassigned_issues", @$setup["allow_unassigned_issues"]);
 117  
 118              $tpl->assign(array(
 119                  'next_issue'          => @$sides['next'],
 120                  'previous_issue'      => @$sides['previous'],
 121                  'subscribers'         => Notification::getSubscribers($issue_id),
 122                  'custom_fields'       => Custom_Field::getListByIssue($prj_id, $issue_id),
 123                  'files'               => Attachment::getList($issue_id),
 124                  'emails'              => Support::getEmailsByIssue($issue_id),
 125                  'zones'               => Date_API::getTimezoneList(),
 126                  'users'               => Project::getUserAssocList($prj_id, 'active', User::getRoleID('Customer')),
 127                  'ema_id'              => Email_Account::getEmailAccount(),
 128                  'max_attachment_size' => Attachment::getMaxAttachmentSize(),
 129                  'show_releases'       => $show_releases,
 130                  'show_category'       => $show_category,
 131                  'quarantine'          => Issue::getQuarantineInfo($issue_id)
 132              ));
 133  
 134              if ($role_id != User::getRoleID('customer')) {
 135                  if (@$_REQUEST['show_all_drafts'] == 1) {
 136                      $show_all_drafts = true;
 137                  } else {
 138                      $show_all_drafts = false;
 139                  }
 140  
 141                  if (Workflow::hasWorkflowIntegration($prj_id)) {
 142                      $statuses = Workflow::getAllowedStatuses($prj_id, $issue_id);
 143                      // if currently selected release is not on list, go ahead and add it.
 144                  } else {
 145                      $statuses = Status::getAssocStatusList($prj_id, false);
 146                  }
 147                  if ((!empty($details['iss_sta_id'])) && (empty($statuses[$details['iss_sta_id']]))) {
 148                      $statuses[$details['iss_sta_id']] = Status::getStatusTitle($details['iss_sta_id']);
 149                  }
 150  
 151                  $time_entries = Time_Tracking::getListing($issue_id);
 152                  $tpl->assign(array(
 153                      'notes'              => Note::getListing($issue_id),
 154                      'is_user_assigned'   => Issue::isAssignedToUser($issue_id, $usr_id),
 155                      'is_user_authorized' => Authorized_Replier::isUserAuthorizedReplier($issue_id, $usr_id),
 156                      'phone_entries'      => Phone_Support::getListing($issue_id),
 157                      'phone_categories'   => Phone_Support::getCategoryAssocList($prj_id),
 158                      'checkins'           => SCM::getCheckinList($issue_id),
 159                      'time_categories'    => Time_Tracking::getAssocCategories(),
 160                      'time_entries'       => $time_entries['list'],
 161                      'total_time_spent'   => $time_entries['total_time_spent'],
 162                      'impacts'            => Impact_Analysis::getListing($issue_id),
 163                      'statuses'           => $statuses,
 164                      'drafts'             => Draft::getList($issue_id, $show_all_drafts),
 165                      'groups'             => Group::getAssocList($prj_id)
 166                  ));
 167              }
 168          }
 169      }
 170  }
 171  
 172  $tpl->displayTemplate();


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