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
00026 require_once FASTFRAME_ROOT . 'lib/FastFrame/Action/FormSubmit.php';
00027
00028
00029
00030
00042
00043 class FF_Action_FormSubmit_Group extends FF_Action_FormSubmit {
00044
00045
00053 function doMultiPageForm()
00054 {
00055 $s_nextActionId = ACTION_SELECT;
00056 if (FF_Request::getParam('selectCategory_x', 'p', false) !== false) {
00057 $s_nextModule = 'Category';
00058 }
00059 elseif (FF_Request::getParam('selectItem_x', 'p', false) !== false) {
00060 $s_nextModule = 'Item';
00061 }
00062 else {
00063 $s_nextActionId = false;
00064 }
00065
00066 if ($s_nextActionId) {
00067 FF_Request::setParam('returnModel', $this->o_model->exportToArray(), 's');
00068 if ($this->currentActionId == ACTION_EDIT_SUBMIT) {
00069 FF_Request::setParam('returnActionId', ACTION_EDIT, 's');
00070 }
00071 else {
00072 FF_Request::setParam('returnActionId', ACTION_ADD, 's');
00073 }
00074
00075 FF_Request::setParam('returnObjectId', $this->o_model->getId(), 's');
00076 FF_Request::setParam('returnModule', 'Group', 's');
00077 $this->o_nextAction->setNextActionId(ACTION_SELECT);
00078 $this->o_nextAction->setNextModuleId($s_nextModule);
00079 return true;
00080 }
00081 else {
00082 return false;
00083 }
00084 }
00085
00086
00087
00088
00095 function fillModelWithSubmitData()
00096 {
00097 $this->o_model->setId(FF_Request::getParam('objectId', 'p'));
00098 $this->o_model->setName(FF_Request::getParam('name', 'p'));
00099 $this->o_model->setDescription(FF_Request::getParam('description', 'p'));
00100 $this->o_model->setCategoryId(FF_Request::getParam('category_id', 'p'));
00101 $this->o_model->setStoreId(FF_Request::getParam('store_id', 'p'));
00102 $this->o_model->setShopperViewable(FF_Request::getParam('shopper_viewable', 'p'));
00103 $this->o_model->setIsKit(FF_Request::getParam('is_kit', 'p'));
00104 $this->o_model->setItemsByBarcode(FF_Request::getParam('newItems', 'p'));
00105 $this->o_model->setItemsToRemove(FF_Request::getParam('toRemove', 'p'));
00106 $this->o_model->setRules(FF_Request::getParam('rules', 'p'));
00107 }
00108
00109
00110
00111
00118 function save()
00119 {
00120 $o_result =& $this->o_model->save($this->isUpdate());
00121 if ($o_result->isSuccess()) {
00122 $o_fileCache =& FF_FileCache::singleton();
00123 if (FF_Request::getParam('imageRemove', 'p', false)) {
00124 FF_Request::setParam('imageRemove', null, 'p');
00125 $o_fileCache->remove(array('subdir' => 'group_images', 'name' => $this->o_model->getId()), true);
00126 }
00127
00128 $tmp_result =& $o_fileCache->saveUploadedFile(FF_Request::getParam('image', 'f'),
00129 array('subdir' => 'group_images', 'name' => $this->o_model->getId()),
00130 $this->o_registry->getConfigParam('borrower/max_image_size'),
00131 array('image/png', 'image/gif', 'image/jpeg', 'image/pjpeg'), true);
00132 if (!$tmp_result->isSuccess()) {
00133
00134 $o_result->addMessage($tmp_result->getMessages());
00135 }
00136
00137 $o_fileCache->makeViewableFromWeb(array('subdir' => 'group_images', 'name' => $this->o_model->getId()), true);
00138 }
00139
00140 return $o_result;
00141 }
00142
00143
00144
00145
00152 function validateInput()
00153 {
00154 require_once dirname(__FILE__) . '/../Validate/Group.php';
00155 $o_validate =& new FF_Validate_Group($this->o_model, $this->isUpdate());
00156 return $o_validate->validate();
00157 }
00158
00159
00160
00161
00168 function getSingularText()
00169 {
00170 return _('group');
00171 }
00172
00173
00174
00175
00182 function setSuccessActionId()
00183 {
00184 $this->o_nextAction->setNextActionId(ACTION_GROUP_LIST);
00185 $this->o_nextAction->setNextModuleId('Item');
00186 }
00187
00188
00189
00190
00197 function checkPerms()
00198 {
00199 switch ($this->currentActionId) {
00200 case ACTION_EDIT_SUBMIT:
00201 if (($this->o_perms->hasPerm('can_edit_group'))) {
00202 return true;
00203 }
00204 else {
00205 $this->o_nextAction->setNextActionId(ACTION_PROBLEM);
00206 $this->o_output->setMessage(_('You do not have permission to edit groups'), FASTFRAME_ERROR_MESSAGE);
00207 return false;
00208 }
00209 break;
00210 case ACTION_ADD_SUBMIT:
00211 if (($this->o_perms->hasPerm('can_add_group'))) {
00212 return true;
00213 }
00214 else {
00215 $this->o_nextAction->setNextActionId(ACTION_PROBLEM);
00216 $this->o_output->setMessage(_('You do not have permission to add groups'), FASTFRAME_ERROR_MESSAGE);
00217 return false;
00218 }
00219 break;
00220 default:
00221 $this->o_nextAction->setNextActionId(ACTION_PROBLEM);
00222 $this->o_output->setMessage(_('Could not determine the intended action'), FASTFRAME_ERROR_MESSAGE);
00223 return false;
00224 break;
00225 }
00226 }
00227
00228
00229 }
00230 ?>