[ Index ]

PHP Cross Reference of Eventum

title

Body

[close]

/ -> post_note.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: post_note.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.user.php");
  34  require_once (APP_INC_PATH . "class.note.php");
  35  require_once (APP_INC_PATH . "db_access.php");
  36  
  37  $tpl = new Template_API();
  38  $tpl->setTemplate("post_note.tpl.html");
  39  
  40  Auth::checkAuthentication(APP_COOKIE, 'index.php?err=5', true);
  41  
  42  $prj_id = Auth::getCurrentProject();
  43  $usr_id = Auth::getUserID();
  44  
  45  @$issue_id = $_GET["issue_id"] ? $_GET["issue_id"] : $_POST["issue_id"];
  46  $details = Issue::getDetails($issue_id);
  47  $tpl->assign("issue_id", $issue_id);
  48  $tpl->assign("issue", $details);
  49  
  50  if ((!Issue::canAccess($issue_id, $usr_id)) || (Auth::getCurrentRole() <= User::getRoleID("Customer"))) {
  51      $tpl->setTemplate("permission_denied.tpl.html");
  52      $tpl->displayTemplate();
  53      exit;
  54  }
  55  
  56  if (@$_POST["cat"] == "post_note") {
  57      // change status
  58      if (!@empty($_POST['new_status'])) {
  59          $res = Issue::setStatus($issue_id, $_POST['new_status']);
  60          if ($res != -1) {
  61              $new_status = Status::getStatusTitle($_POST['new_status']);
  62              History::add($issue_id, $usr_id, History::getTypeID('status_changed'), "Status changed to '$new_status' by " . User::getFullName($usr_id));
  63          }
  64      }
  65  
  66      $res = Note::insert($usr_id, $issue_id);
  67      $tpl->assign("post_result", $res);
  68      // enter the time tracking entry about this phone support entry
  69      if (!empty($_POST['time_spent'])) {
  70          $_POST['issue_id'] = $issue_id;
  71          $_POST['category'] = $_POST['time_category'];
  72          $_POST['summary'] = 'Time entry inserted when sending an internal note.';
  73          Time_Tracking::insertEntry();
  74      }
  75  } elseif (@$_GET["cat"] == "reply") {
  76      if (!@empty($_GET["id"])) {
  77          $note = Note::getDetails($_GET["id"]);
  78          $date = Misc::formatReplyDate($note["timestamp"]);
  79          $header = "\n\n\nOn $date, " . $note["not_from"] . " wrote:\n>\n";
  80          $note["not_body"] = $header . Misc::formatReply($note["not_note"]);
  81          $tpl->bulkAssign(array(
  82              "note"           => $note,
  83              "parent_note_id" => $_GET["id"]
  84          ));
  85          $reply_subject = Mail_API::removeExcessRe($note['not_title']);
  86      }
  87  }
  88  if (empty($reply_subject)) {
  89      $reply_subject = 'Re: ' . $details['iss_summary'];
  90  }
  91  
  92  
  93  $tpl->assign(array(
  94      'from'               => User::getFromHeader($usr_id),
  95      'users'              => Project::getUserAssocList($prj_id, 'active', User::getRoleID('Customer')),
  96      'current_user_prefs' => Prefs::get($usr_id),
  97      'subscribers'        => Notification::getSubscribers($issue_id, false, User::getRoleID("Standard User")),
  98      'statuses'           => Status::getAssocStatusList($prj_id, false),
  99      'current_issue_status'  =>  Issue::getStatusID($issue_id),
 100      'time_categories'    => Time_Tracking::getAssocCategories(),
 101      'note_category_id'   => Time_Tracking::getCategoryID('Note Discussion'),
 102      'reply_subject'      => $reply_subject
 103  ));
 104  
 105  $tpl->displayTemplate();


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