AssignmentFormSubmit.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/FormSubmit.php';
00026 
00027 // }}}
00028 // {{{ class FF_Action_FormSubmit_Assignment
00029 
00040 // }}}
00041 class FF_Action_FormSubmit_Assignment extends FF_Action_FormSubmit {
00042     // {{{ fillModelWithSubmitData()
00043 
00050     function fillModelWithSubmitData()
00051     {
00052         $this->o_model->setId(FF_Request::getParam('objectId', 'p'));
00053         $this->o_model->setName(FF_Request::getParam('name', 'p'));
00054         $this->o_model->setOpenTime($this->_dateSelectToTimestamp(FF_Request::getParam('open_time', 'p')));
00055         $this->o_model->setLateTime($this->_dateSelectToTimestamp(FF_Request::getParam('late_time', 'p')));
00056         $this->o_model->setCloseTime($this->_dateSelectToTimestamp(FF_Request::getParam('close_time', 'p')));
00057         $this->o_model->setSession(FF_Request::getParam('session', 'p'));
00058         $this->o_model->setCourseCode(FF_Request::getParam('course_code', 'p'));
00059         $this->o_model->setOwnerId(FF_Auth::getCredential('userId'));
00060     }
00061 
00062     // }}}
00063     // {{{ getSingularText()
00064 
00071     function getSingularText()
00072     {
00073         return _('Assignment');
00074     }
00075 
00076     // }}}
00077     // {{{ validateInput()
00078 
00085     function validateInput()
00086     {
00087         require_once dirname(__FILE__) . '/../Validate/Assignment.php';
00088         $o_validate =& new FF_Validate_Assignment($this->o_model, $this->isUpdate());
00089         return $o_validate->validate(false);
00090     }
00091 
00092     // }}}
00093     // {{{ checkPerms()
00094 
00101     function checkPerms()
00102     {
00103         if (!$this->o_perms->hasPerm('can_use_homework') ||
00104             $this->o_model->getOwnerId() != FF_Auth::getCredential('userId')) {
00105             $this->o_nextAction->setNextActionId(ACTION_PROBLEM);
00106             $this->o_output->setMessage(_('You cannot edit this assignment.'), FASTFRAME_ERROR_MESSAGE);
00107             return false;
00108         }
00109 
00110         return true;
00111     }
00112 
00113     // }}}
00114     // {{{ setSuccessActionId()
00115 
00122     function setSuccessActionId()
00123     {
00124         if ($this->isUpdate()) {
00125             $this->o_nextAction->setNextActionId(ACTION_LIST);
00126         }
00127         else {
00128             $this->o_nextAction->setNextActionId(ACTION_ADD);
00129         }
00130     }
00131 
00132     // }}}
00133     // {{{ _dateSelectToTimestamp()
00134     
00143     function _dateSelectToTimestamp($in_dates)
00144     {
00145         // Need to make sure they aren't setting a partial date
00146         $b_hasVal = false;
00147         $b_hasEmpty = false;
00148         foreach ($in_dates as $s_val) {
00149             if ($s_val == '') {
00150                 $b_hasEmpty = true;
00151             }
00152             else {
00153                 $b_hasVal = true;
00154             }
00155         }
00156 
00157         if ($b_hasVal && $b_hasEmpty) {
00158             return false;
00159         }
00160         elseif ($b_hasEmpty) {
00161             return null;
00162         }
00163         else {
00164             return mktime($in_dates['H'], $in_dates['i'], 0, $in_dates['M'], $in_dates['d'], $in_dates['Y']);
00165         }
00166     }
00167 
00168     // }}}
00169 }
00170 ?>

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