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/TicketHistory.php';
00027
00028
00029
00030
00041
00042 class FF_Action_QuickPoints extends FF_Action {
00043
00044
00051 function run()
00052 {
00053 if (!$this->o_model->fillById(FF_Request::getParam('objectId', 'g'))) {
00054 $this->o_output->setMessage(sprintf(_('Mayday #%s is invalid.'), FF_Request::getParam('objectId', 'g')),
00055 FASTFRAME_ERROR_MESSAGE);
00056 if (!IS_AJAX) {
00057 $this->o_nextAction->setNextActionId(FF_Request::getParam('returnActionId', 'g'));
00058 }
00059
00060 return $this->o_nextAction;
00061 }
00062
00063 if (!$this->o_perms->hasPerm('can_edit_ticket_priority') ||
00064 !$this->o_perms->hasObjectPerm($this->o_model->getCategoryId(), PERMS_EDIT, 'Category', $this->o_model->getReporterId())) {
00065 $this->o_output->setMessage(_('You do not have permission to change the priority of this Mayday'),
00066 FASTFRAME_ERROR_MESSAGE);
00067 if (!IS_AJAX) {
00068 $this->o_nextAction->setNextActionId(FF_Request::getParam('returnActionId', 'g'));
00069 }
00070
00071 return $this->o_nextAction;
00072 }
00073
00074 $o_origModel = clone($this->o_model);
00075 list($o_result, $s_name) = $this->o_model->changePoints(($this->currentActionId == ACTION_INCREASE_POINTS));
00076 $o_ticketHistory =& new FF_Model_TicketHistory();
00077 $o_ticketHistory->save($o_origModel, $this->o_model, FF_Auth::getCredential('userId'));
00078 if ($o_result->isSuccess()) {
00079 $this->o_output->setMessage($o_result->getMessages(), FASTFRAME_SUCCESS_MESSAGE);
00080 if (IS_AJAX) {
00081 $this->o_output->addNode('points', $this->o_model->getPoints());
00082 $this->o_output->addNode('title', $s_name);
00083 }
00084 }
00085 else {
00086 $this->o_output->setMessage($o_result->getMessages(), FASTFRAME_ERROR_MESSAGE);
00087 }
00088
00089 if (!IS_AJAX) {
00090 $this->o_nextAction->setNextActionId(FF_Request::getParam('returnActionId', 'g'));
00091 }
00092
00093 return $this->o_nextAction;
00094 }
00095
00096
00097 }
00098 ?>