Example #1
0
 public function postSaveHook(JModelLegacy $model, $validData = array())
 {
     $item = $model->getItem();
     $sport_id = $item->get('id');
     $this->saveconfigs($sport_id);
     $this->setRedirect(JRoute::_('index.php?option=com_htraininglogs&view=cfgsport&layout=edit&id=' . $sport_id, false));
 }
Example #2
0
 public function postSaveHook(JModelLegacy $model, $validData = array())
 {
     $item = $model->getItem();
     $map_id = $item->get('id');
     $mapimage = $item->get('mapimage');
     $this->prepare_fileupload($map_id, $mapimage);
     //in case new HR file added
     $this->setRedirect(JRoute::_('index.php?option=com_htraininglogs&view=omap&layout=edit&id=' . $map_id, false));
 }
Example #3
0
 public function postSaveHook(JModelLegacy $model, $validData = array())
 {
     $item = $model->getItem();
     $sub_id = $item->get('id');
     $sport_id = $item->get('sport_id');
     $this->saveomap();
     $split_id = $this->prepare_fileupload($sub_id, $sport_id);
     //in case new HR file added
     $this->setRedirect(JRoute::_('index.php?option=com_htraininglogs&view=session&layout=edit&sub_id=' . $sub_id . '&split_id=' . $split_id, false));
 }
Example #4
0
 public function postSaveHook(JModelLegacy $model, $validData = array())
 {
     $item = $model->getItem();
     $media_id = $item->get('id');
     $mediafile = JRequest::getVar('filename');
     $model->storeimage($mediafile, $media_id);
     $this->prepare_fileupload($media_id, $mediafile);
     //in case new m fedia file added
     //$this->setRedirect(JRoute::_('index.php?option=com_htraininglogs&view=media&layout=edit&id='.$media_id, false));
 }
Example #5
0
 protected function postSaveHook(JModelLegacy $model, $validData = array())
 {
     $item = $model->getItem();
     $id = $item->get('id');
     if ($id) {
         if ($validData['saveresult'] == 1) {
             //Create a new datatable if it doesn't allready exist
             if (!$model->createDataTables($id)) {
                 $this->setMessage($model->getError());
             }
         }
     }
 }
Example #6
0
 protected function postSaveHook(JModelLegacy $model, $validData = array())
 {
     $item = $model->getItem();
     $id = $item->get('id');
     $fid = $item->get('fid');
     if ($fid && $id) {
         $db = JFactory::getDbo();
         // Test if data must be saved in DB for this form
         $query = ' SELECT * from #__visforms c where c.id=' . $fid . ' ';
         $db->setQuery($query);
         $forms = $db->loadObjectList();
         if (count($forms) > 0) {
             $rowTable = $forms[0];
             if ($rowTable->saveresult == 1) {
                 $model->createDataTableFields($fid, $id);
             }
         }
     }
 }
Example #7
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   3.1
  */
 protected function postSaveHook(JModelLegacy $model, $validData = array())
 {
     $task = $this->getTask();
     $item = $model->getItem();
     if (isset($item->params) && is_array($item->params)) {
         $registry = new JRegistry();
         $registry->loadArray($item->params);
         $item->params = (string) $registry;
     }
     if (isset($item->metadata) && is_array($item->metadata)) {
         $registry = new JRegistry();
         $registry->loadArray($item->metadata);
         $item->metadata = (string) $registry;
     }
     $id = $item->id;
     return;
 }
Example #8
0
 protected function postSaveHook(JModelLegacy $model, $validData = array())
 {
     //A: inform log table about the new issue
     if ($validData['id'] == 0) {
         $log = JTable::getInstance('Log', 'ImcTable', array());
         $catTitle = ImcFrontendHelper::getCategoryNameByCategoryId($validData['catid']);
         $data2['id'] = 0;
         $data2['state'] = 1;
         $data2['action'] = JText::_('COM_IMC_LOGS_ACTION_INITIAL_COMMIT');
         $data2['issueid'] = $model->getItem()->get('id');
         $data2['stepid'] = $validData['stepid'];
         $data2['description'] = JText::_('COM_IMC_LOGS_ACTION_INITIAL_COMMIT') . ' ' . JText::_('COM_IMC_LOGS_AT_CATEGORY') . ' ' . $catTitle;
         $data2['created'] = $validData['created'];
         $data2['created_by'] = $validData['created_by'];
         $data2['updated'] = $validData['created'];
         $data2['language'] = $validData['language'];
         $data2['rules'] = $validData['rules'];
         if (!$log->bind($data2)) {
             JFactory::getApplication()->enqueueMessage('Cannot bind data to log table', 'error');
         }
         if (!$log->save($data2)) {
             JFactory::getApplication()->enqueueMessage('Cannot save data to log table', 'error');
         }
         try {
             $dispatcher = JEventDispatcher::getInstance();
             $results = $dispatcher->trigger('onAfterNewIssueAdded', array($model, $validData));
             // Check the returned results. This is for plugins that don't throw
             // exceptions when they encounter serious errors.
             if (in_array(false, $results)) {
                 throw new Exception($dispatcher->getError(), 500);
             }
         } catch (Exception $e) {
             // Handle a caught exception.
             throw $e;
         }
     } else {
         //a. check for step modification
         if (isset($validData['is_step_modified']) && $validData['is_step_modified'] === 'true') {
             $user = JFactory::getUser();
             $log = JTable::getInstance('Log', 'ImcTable', array());
             $data2['id'] = 0;
             $data2['state'] = 1;
             $data2['action'] = JText::_('COM_IMC_LOGS_ACTION_STEP_MODIFIED');
             $data2['issueid'] = $validData['id'];
             $data2['stepid'] = $validData['stepid'];
             $data2['description'] = $validData['step_modified_description'];
             $data2['created'] = $validData['updated'];
             $data2['created_by'] = $user->id;
             $data2['updated'] = $validData['updated'];
             $data2['language'] = $validData['language'];
             $data2['rules'] = $validData['rules'];
             if (!$log->bind($data2)) {
                 JFactory::getApplication()->enqueueMessage('Cannot bind data to log table', 'error');
             }
             if (!$log->save($data2)) {
                 JFactory::getApplication()->enqueueMessage('Cannot save data to log table', 'error');
             }
             $dispatcher = JEventDispatcher::getInstance();
             $dispatcher->trigger('onAfterStepModified', array($model, $validData));
         }
         //b. check for category modification
         if (isset($validData['is_category_modified']) && $validData['is_category_modified'] === 'true') {
             $user = JFactory::getUser();
             $log = JTable::getInstance('Log', 'ImcTable', array());
             $data2['id'] = 0;
             $data2['state'] = 1;
             $data2['action'] = JText::_('COM_IMC_LOGS_ACTION_CATEGORY_MODIFIED');
             $data2['issueid'] = $validData['id'];
             $data2['stepid'] = $validData['stepid'];
             $data2['description'] = $validData['category_modified_description'];
             $data2['created'] = $validData['updated'];
             $data2['created_by'] = $user->id;
             $data2['updated'] = $validData['updated'];
             $data2['language'] = $validData['language'];
             $data2['rules'] = $validData['rules'];
             if (!$log->bind($data2)) {
                 JFactory::getApplication()->enqueueMessage('Cannot bind data to log table', 'error');
             }
             if (!$log->save($data2)) {
                 JFactory::getApplication()->enqueueMessage('Cannot save data to log table', 'error');
             }
             $dispatcher = JEventDispatcher::getInstance();
             $dispatcher->trigger('onAfterCategoryModified', array($model, $validData));
         }
     }
     //B: move any images only if record is new
     if ($validData['id'] == 0) {
         //check if any files uploaded
         $obj = json_decode($validData['photo']);
         if (empty($obj->files)) {
             return;
         }
         $srcDir = JPATH_ROOT . '/' . $obj->imagedir . '/' . $obj->id;
         $dstDir = JPATH_ROOT . '/' . $obj->imagedir . '/' . $model->getItem()->get('id');
         $success = rename($srcDir, $dstDir);
         if ($success) {
             //update photo json isnew, id
             unset($obj->isnew);
             $obj->id = $model->getItem()->get('id');
             $photo = json_encode($obj);
             // Create an object for the record we are going to update.
             $object = new stdClass();
             $object->id = $model->getItem()->get('id');
             $object->photo = $photo;
             // Update photo
             $result = JFactory::getDbo()->updateObject('#__imc_issues', $object, 'id');
         } else {
             JFactory::getApplication()->enqueueMessage('Cannot move ' . $srcDir . ' to ' . $dstDir . '. Check folder rights', 'error');
         }
     }
 }
Example #9
0
 public function getItem($pk = null)
 {
     $item = parent::getItem($pk);
     return $item;
 }
Example #10
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   3.1
  */
 protected function postSaveHook(JModelLegacy $model, $validData = array())
 {
     $item = $model->getItem();
     if (isset($item->params) && is_array($item->params)) {
         $registry = new Registry($item->params);
         $item->params = (string) $registry;
     }
     if (isset($item->metadata) && is_array($item->metadata)) {
         $registry = new Registry($item->metadata);
         $item->metadata = (string) $registry;
     }
 }
Example #11
0
 /**
  * Executes after the row is saved and saves the category relationship info
  *
  * @param   JModelLegacy  $model  - the model
  * @param   array         $data   - the valid data
  *
  * @return bool
  */
 public function onAfterSave($model, $data)
 {
     $db = JFactory::getDbo();
     $cats = $data['catid'];
     $item = $model->getItem();
     /**
      * Let's wipe out the customfield-category table
      * I always have to do that, otherwise I could have some problems when
      * a field changes from 'all' to 'category'
      */
     $query = $db->getQuery(true)->delete('#__compojoom_customfields_cats')->where('compojoom_customfields_id = ' . $item->id);
     if (!$db->setQuery($query)->execute()) {
         $this->setError(JText::_('COM_HOTSPOTS_CUSTOMFIELDS_ERR_DELETE_CATS'));
         return false;
     }
     if ($cats && $data['show'] == 'category') {
         $query = $db->getQuery(true)->insert('#__compojoom_customfields_cats')->columns('compojoom_customfields_id, catid');
         foreach ($cats as $cat) {
             if (!$cat) {
                 continue;
             }
             $query->values($item->id . ', ' . $cat);
         }
         if (!$db->setQuery($query)->execute()) {
             $this->setError(JText::_('COM_HOTSPOTS_CUSTOMFIELDS_ERR_INSERT_CATS'));
             return false;
         }
     }
     return true;
 }
Example #12
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())
 {
     $task = $this->getTask();
     $item = $model->getItem();
     if (!$model->getsports($item->user_id)) {
         $model->createsports($item->user_id);
         $model->createportlets($item->user_id);
         $model->createmediadirs($item->user_id);
     }
     //print_r($item);print_r($task);exit;
     if ($task == 'save') {
         $this->setRedirect(JRoute::_('index.php?option=com_htraininglogs&view=htraininglogs', false));
     }
 }