/**
  * Update the ordered items in post save hook
  */
 protected function postSaveHook(JModelLegacy $model, $validData = array())
 {
     $order_id = $model->getState($model->getName() . '.id');
     $data = JFactory::getApplication()->input->post->getArray(array('jform' => array('ordered' => 'array', 'deleted' => 'array')));
     // We add order items right on order edit view
     foreach ($data['jform']['ordered'] as $item) {
         $item['order_id'] = $order_id;
         $model = JModelLegacy::getInstance('OrderItem', 'DZProductModel');
         $form = $model->getForm($item, false);
         if (!$form) {
             continue;
         }
         $validItem = $model->validate($form, $item);
         if ($validItem === false) {
             continue;
         }
         if (!$model->save($validItem)) {
             continue;
         }
     }
     // Make sure the submitted deleted ids are all integer
     JArrayHelper::toInteger($data['jform']['deleted']);
     // Remove items
     $model = JModelLegacy::getInstance('OrderItem', 'DZProductModel');
     $model->delete($data['jform']['deleted']);
 }
Example #2
0
 /**
  * Overridden method to get model state variables.
  *
  * @param	string	$property	Optional parameter name.
  * @param	mixed	$default	The default value to use if no state property exists by name.
  * @return	object	The property where specified, the state object where omitted.
  * @since	1.6
  */
 public function getState($property = null, $default = null)
 {
     // if the model state is uninitialized lets set some values we will need from the request.
     if ($this->__state_set === false) {
         $this->__state_set = true;
     }
     $value = parent::getState($property);
     return is_null($value) ? $default : $value;
 }
Example #3
0
 /**
  * Tests the getState method.
  *
  * @since   12.3
  *
  * @return  void
  */
 public function testGetState()
 {
     $state = $this->fixture->getState();
     $this->assertTrue($state instanceof JObject);
     $stateSet = TestReflection::getValue($this->fixture, '__state_set');
     $this->assertTrue($stateSet === true);
     $this->fixture->setState('foo.bar', 'baz');
     $this->assertEquals('baz', $this->fixture->getState('foo.bar'));
     $this->assertEquals('defaultVal', $this->fixture->getState('non.existent', 'defaultVal'));
     $this->assertNull($this->fixture->getState('non.existent'));
 }
Example #4
0
	function getState($property = null, $default = null) {
		static $set;

		if (!$set) {
			$folder = JFactory::getApplication()->input->get('folder', '');
			$this->setState('folder', $folder);

			$set = true;
		}
		return parent::getState($property);
	}
Example #5
0
 public function getState($property = null, $default = null)
 {
     static $set;
     if (!$set) {
         $input = JFactory::getApplication()->input;
         $fieldid = $input->get('fieldid', '');
         $this->setState('field.id', $fieldid);
         $set = true;
     }
     return parent::getState($property, $default);
 }
Example #6
0
 function getState($property = null, $default = null)
 {
     static $set;
     if (!$set) {
         $folder = JRequest::getVar('folder', '', '', 'path');
         $this->setState('folder', $folder);
         $parent = str_replace("\\", "/", dirname($folder));
         $parent = $parent == '.' ? null : $parent;
         $this->setState('parent', $parent);
         $set = true;
     }
     return parent::getState($property, $default);
 }
Example #7
0
 public function getState($property = null, $default = null)
 {
     static $set;
     if (!$set) {
         $input = JFactory::getApplication()->input;
         $folder = $input->get('folder', '', 'path');
         $this->setState('folder', $folder);
         $parent = str_replace("\\", "/", dirname($folder));
         $parent = $parent == '.' ? null : $parent;
         $this->setState('parent', $parent);
         $set = true;
     }
     return parent::getState($property, $default);
 }
 /**
  * Function that allows child controller access to model data after the data has been saved.
  *
  * @param   JModelLegacy  $model      The data model object.
  * @param   array         $validData  The validated data.
  *
  * @return  void
  *
  * @since   1.6
  */
 protected function postSaveHook(JModelLegacy $model, $validData = array())
 {
     $app = JFactory::getApplication();
     $task = $this->getTask();
     switch ($task) {
         case 'save2new':
             $app->setUserState('com_modules.add.module.extension_id', $model->getState('module.extension_id'));
             break;
         default:
             $app->setUserState('com_modules.add.module.extension_id', null);
             break;
     }
     $app->setUserState('com_modules.add.module.params', null);
 }
Example #9
0
 /**
  * Overridden method to get model state variables.
  *
  * @param	string	$property	Optional parameter name.
  * @param	mixed	$default	The default value to use if no state property exists by name.
  * @return	object	The property where specified, the state object where omitted.
  * @since	1.6
  */
 public function getState($property = null, $default = null)
 {
     // if the model state is uninitialized lets set some values we will need from the request.
     if ($this->__state_set === false) {
         $app = JFactory::getApplication();
         $this->setState('action', $step = $app->getUserState('com_kunena.install.action', null));
         $this->setState('step', $step = $app->getUserState('com_kunena.install.step', 0));
         $this->setState('task', $task = $app->getUserState('com_kunena.install.task', 0));
         $this->setState('version', $task = $app->getUserState('com_kunena.install.version', null));
         if ($step == 0) {
             $app->setUserState('com_kunena.install.status', array());
         }
         $this->setState('status', $app->getUserState('com_kunena.install.status'));
         $this->__state_set = true;
     }
     $value = parent::getState($property);
     return is_null($value) ? $default : $value;
 }
Example #10
0
 /**
  *Tests the getState method.
  *
  * @since   12.3
  *
  * @return  void
  *
  * @testdox getState() returns default value
  */
 public function testGetStateReturnsDefaultValue()
 {
     $this->assertEquals('defaultVal', $this->fixture->getState('non.existent', 'defaultVal'));
     $this->assertNull($this->fixture->getState('non.existent'));
 }
Example #11
0
 /**
  * Function that allows child controller access to model data after the data has been saved.
  *
  * @param   JModelLegacy  $model  The data model object.
  * @param   array         $validData   The validated data.
  *
  * @return  void
  *
  * @since   1.6
  */
 protected function postSaveHook(JModelLegacy $model, $validData = array())
 {
     $authority = $model->getState('request.authority');
     //$id = $model->getState('form.id');
     if ($validData['payment']['payment_type'] == 'ACCELERATION_CARDS' && $authority) {
         $this->setMessage(JText::_('COM_SIBDIET_REQUEST_SAVED_ONLINE_PAYMENT'));
         //$this->setRedirect(JRoute::_('index.php?&option=com_sibdiet&view=onlinepayment&id=' . $id, false));
         $this->setRedirect('https://www.zarinpal.com/pg/StartPay/' . $authority);
     } elseif ($validData['payment']['payment_type'] == '') {
         $this->setMessage(JText::_('COM_SIBDIET_REQUEST_SAVED_NO_PAYMENT'));
         $this->setRedirect(JRoute::_('index.php?option=com_sibdiet&view=requests', false));
     } else {
         $this->setMessage(JText::_('COM_SIBDIET_REQUEST_SAVED'));
         $this->setRedirect(JRoute::_('index.php?option=com_sibdiet&view=requests', false));
     }
     $this->redirect();
 }
Example #12
0
 protected function postSaveHook(JModelLegacy $model, $validData = array())
 {
     $task = $this->getTask();
     if ($task == 'save' || $task == 'apply') {
         $isNew = $model->getState('editevent.new');
         $id = $model->getState('editevent.id');
         $enabled = JPluginHelper::isEnabled('jem', 'mailer');
         if ($enabled) {
             JPluginHelper::importPlugin('jem', 'mailer');
             $dispatcher = JEventDispatcher::getInstance();
             $dispatcher->trigger('onEventEdited', array($id, $isNew));
         } else {
             JError::raiseNotice(100, JText::_('COM_JEM_GLOBAL_MAILERPLUGIN_DISABLED'));
         }
     }
 }
Example #13
0
 /**
  * Function that allows child controller access to model data after the data has been saved.
  *
  * @param     jmodel    $model    The data model object.
  * @param     array     $data     The validated data.
  *
  * @return    void
  */
 protected function postSaveHook(JModelLegacy $model, $data = array())
 {
     $task = $this->getTask();
     $id = (int) $model->getState('form.id');
     switch ($task) {
         case 'save2copy':
         case 'save2new':
             // No redirect because its already set
             break;
         case 'save2tasklist':
             $link = JRoute::_(PFtasksHelperRoute::getTasksRoute() . '&task=tasklistform.add&milestone_id=' . $id);
             $this->setRedirect($link);
             break;
         case 'save2task':
             $link = JRoute::_(PFtasksHelperRoute::getTasksRoute() . '&task=taskform.add&milestone_id=' . $id);
             $this->setRedirect($link);
             break;
         default:
             $this->setRedirect(JRoute::_($this->getReturnPage()));
             break;
     }
 }