00001 <?php
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 require_once FASTFRAME_ROOT . 'lib/FastFrame/Action.php';
00026 require_once dirname(__FILE__) . '/../Model/TicketComment.php';
00027
00028
00029
00030
00040
00041 class FF_Action_TicketCommentEdit extends FF_Action {
00042
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
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 ?>