TicketCommentEdit.php

Go to the documentation of this file.
00001 <?php
00003 // {{{ license
00004 
00005 // +----------------------------------------------------------------------+
00006 // | FastFrame Application Framework                                      |
00007 // +----------------------------------------------------------------------+
00008 // | Copyright (c) 2002-2006 The Codejanitor Group                        |
00009 // +----------------------------------------------------------------------+
00010 // | This source file is subject to the GNU Lesser Public License (LGPL), |
00011 // | that is bundled with this package in the file LICENSE, and is        |
00012 // | available at through the world-wide-web at                           |
00013 // | http://www.fsf.org/copyleft/lesser.html                              |
00014 // | If you did not receive a copy of the LGPL and are unable to          |
00015 // | obtain it through the world-wide-web, you can get it by writing the  |
00016 // | Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
00017 // | MA 02111-1307, USA.                                                  |
00018 // +----------------------------------------------------------------------+
00019 // | Authors: Jason Rust <jrust@codejanitor.com>                          |
00020 // +----------------------------------------------------------------------+
00021 
00022 // }}}
00023 // {{{ requires
00024 
00025 require_once FASTFRAME_ROOT . 'lib/FastFrame/Action.php';
00026 require_once dirname(__FILE__) . '/../Model/TicketComment.php';
00027 
00028 // }}}
00029 // {{{ class FF_Action_TicketCommentEdit
00030 
00040 // }}}
00041 class FF_Action_TicketCommentEdit extends FF_Action {
00042     // {{{ run()
00043 
00050     function run()
00051     {
00052         if (!$this->o_model->fillById(FF_Request::getParam('ticketId', 'g'))) {
00053             $this->o_output->setMessage(sprintf(_('Mayday #%s is invalid.'), FF_Request::getParam('ticktId', 'g')),
00054                     FASTFRAME_ERROR_MESSAGE);
00055             return $this->o_nextAction;
00056         }
00057 
00058         if (!$this->o_perms->hasPerm('can_edit_ticket_comments') ||
00059             !$this->o_perms->hasObjectPerm($this->o_model->getCategoryId(), PERMS_EDIT, 'Category', $this->o_model->getReporterId())) {
00060             $this->o_output->setMessage(_('You do not have permission to edit comments on this Mayday.'), FASTFRAME_ERROR_MESSAGE);
00061             return $this->o_nextAction;
00062         }
00063 
00064         $s_id = FF_Request::getParam('commentId', 'g');
00065         $o_comment =& new FF_Model_TicketComment();
00066         $o_comment->setId($s_id);
00067         $o_comment->setTicketId(FF_Request::getParam('ticketId', 'g'));
00068         $o_comment->setComment(FF_Request::getParam('text', 'g'));
00069         $s_priv = $this->o_perms->hasPerm('can_add_private_comment') ? FF_Request::getParam('isPrivate', 'g') : false;
00070         $o_comment->setIsPrivate($s_priv);
00071         $o_comment->setCreatorId(FF_Auth::getCredential('userId'));
00072         $o_result =& $o_comment->save($s_id != 0);
00073         if (!$o_result->isSuccess()) {
00074             $this->o_output->setMessage($o_result->getMessages(), FASTFRAME_ERROR_MESSAGE);
00075         }
00076         else {
00077             // More to do on an add
00078             if ($s_id == 0) {
00079                 if ($o_comment->getIsPrivate()) {
00080                     $this->o_model->setLastAction('new_private_comment');
00081                 }
00082                 else {
00083                     $this->o_model->setLastAction('new_public_comment');
00084                     require_once dirname(__FILE__) . '/../Model/TicketWatchlist.php';
00085                     $o_watchlist =& new FF_Model_TicketWatchlist();
00086                     $this->o_model->email($o_watchlist->getWatchlistEmailsByTicketId($this->o_model->getId()));
00087                 }
00088 
00089                 $this->o_model->save(true);
00090                 require_once dirname(__FILE__) . '/../Output/Mayday.php';
00091                 $o_maydayOutput = new FF_Output_Mayday();
00092                 $this->o_output->addNode('comment', $o_maydayOutput->getFormattedComments($this->o_model, true, true, true, false, true));
00093                 $this->o_output->addNode('id', $o_comment->getId());
00094             }
00095 
00096             $this->o_model->markRead(FF_Auth::getCredential('userId'));
00097         }
00098 
00099         return $this->o_nextAction; 
00100     }
00101 
00102     // }}}
00103 }
00104 ?>

Generated on Fri Jun 23 11:38:18 2006 for FastFrame by  doxygen 1.4.4