QuickAssign.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/TicketHistory.php';
00027 
00028 // }}}
00029 // {{{ class FF_Action_QuickAssign
00030 
00041 // }}}
00042 class FF_Action_QuickAssign extends FF_Action {
00043     // {{{ run()
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->hasObjectPerm($this->o_model->getCategoryId(), PERMS_EDIT, 'Category', $this->o_model->getReporterId())) {
00064             $this->o_output->setMessage(_('You do not have permission to change the owner of this Mayday.'),
00065                     FASTFRAME_ERROR_MESSAGE);
00066             if (!IS_AJAX) {
00067                 $this->o_nextAction->setNextActionId(FF_Request::getParam('returnActionId', 'g'));
00068             }
00069 
00070             return $this->o_nextAction;
00071         }
00072 
00073         $o_origModel = clone($this->o_model);
00074         $this->o_model->setHandlerId(FF_Request::getParam('handlerId', 'g'));
00075         $s_name = $this->o_model->getHandlerName(true);
00076         if (empty($s_name)) {
00077             $this->o_output->setMessage(_('The selected user is invalid.'), FASTFRAME_ERROR_MESSAGE);
00078             if (!IS_AJAX) {
00079                 $this->o_nextAction->setNextActionId(FF_Request::getParam('returnActionId', 'g'));
00080             }
00081 
00082             return $this->o_nextAction;
00083         }
00084 
00085         $b_result = $this->o_model->changeHandler(FF_Request::getParam('objectId', 'g'), FF_Request::getParam('handlerId', 'g'));
00086         $o_ticketHistory =& new FF_Model_TicketHistory();
00087         $o_ticketHistory->save($o_origModel, $this->o_model, FF_Auth::getCredential('userId'));
00088         if ($b_result) {
00089             $this->o_output->setMessage(sprintf(_('Successfully gave %s ownership of the Mayday.'), $s_name));
00090         }
00091         else {
00092             $this->o_output->setMessage(_('There was a problem changing ownership of the Mayday.'), FASTFRAME_ERROR_MESSAGE);
00093         }
00094 
00095         if (!IS_AJAX) {
00096             $this->o_nextAction->setNextActionId(FF_Request::getParam('returnActionId', 'g'));
00097         }
00098 
00099         return $this->o_nextAction; 
00100     }
00101 
00102     // }}}
00103 }
00104 ?>

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