Example #1
0
 /**
  * Processes the form data and decides what action to take
  *
  * @return  bool  false if one of the plugins returns an error otherwise true
  */
 public function process()
 {
     $profiler = JProfiler::getInstance('Application');
     JDEBUG ? $profiler->mark('process: start') : null;
     $input = $this->app->input;
     error_reporting(error_reporting() ^ (E_WARNING | E_NOTICE));
     @set_time_limit(300);
     require_once COM_FABRIK_FRONTEND . '/helpers/uploader.php';
     $form = $this->getForm();
     $pluginManager = FabrikWorker::getPluginManager();
     $sessionModel = JModelLegacy::getInstance('Formsession', 'FabrikFEModel');
     $sessionModel->setFormId($this->getId());
     $sessionModel->setRowId($this->rowId);
     /* $$$ rob rowId can be updated by jUser plugin so plugin can use check (for new/edit)
      * now looks at origRowId
      */
     $this->origRowId = $this->rowId;
     JDEBUG ? $profiler->mark('process, getGroupsHiarachy: start') : null;
     $this->getGroupsHiarachy();
     if ($form->record_in_database == '1') {
         JDEBUG ? $profiler->mark('process, setOrigData: start') : null;
         $this->setOrigData();
     }
     /*
      * $$$ hugh - we do this prior to processToDb(), but turns out we need formDataWithTableName in
      * some plugins, like 'php', which run $formModel->getProcessData().  But it's kind of a chicken
      * and egg, because those same plugins my change $formData.  Anyway, only solution for now is
      * set up $this->formDataWithTaleName here, so they at least have the posted data to work with,
      * then do it again after all the plugins have run.  So, rule of thumb ... plugins running onBeforeProcess
      * or onBeforeStore need to modify formData, not formDataWithTableName.
      */
     $this->formDataWithTableName = $this->formData;
     JDEBUG ? $profiler->mark('process, onBeforeProcess plugins: start') : null;
     if (in_array(false, $pluginManager->runPlugins('onBeforeProcess', $this))) {
         return false;
     }
     $this->removeEmptyNoneJoinedGroupData($this->formData);
     JDEBUG ? $profiler->mark('process, setFormData: start') : null;
     $this->setFormData();
     JDEBUG ? $profiler->mark('process, _doUpload: start') : null;
     if (!$this->_doUpload()) {
         return false;
     }
     /** $$$ rob 27/10/2011 - moved above _doUpload as code in there is trying to update formData which is not yet set
      * this->setFormData();
      */
     JDEBUG ? $profiler->mark('process, onBeforeStore plugins: start') : null;
     if (in_array(false, $pluginManager->runPlugins('onBeforeStore', $this))) {
         return false;
     }
     $this->formDataWithTableName = $this->formData;
     if ($form->record_in_database == '1') {
         $this->processToDB();
     }
     // Clean the cache.
     $cache = JFactory::getCache($input->get('option'));
     $cache->clean();
     // $$$rob run this before as well as after onAfterProcess (ONLY for redirect plugin)
     // so that any redirect urls are available for the plugin (e.g twitter)
     JDEBUG ? $profiler->mark('process, onLastProcess plugins: start') : null;
     $pluginManager->runPlugins('onLastProcess', $this);
     JDEBUG ? $profiler->mark('process, onAfterProcess plugins: start') : null;
     if (in_array(false, $pluginManager->runPlugins('onAfterProcess', $this))) {
         // $$$ rob this no longer stops default redirect (not needed any more)
         // returning false here stops the default redirect occurring
         return false;
     }
     // Need to remove the form session before redirect plugins occur
     $sessionModel->remove();
     // $$$rob used ONLY for redirect plugins
     JDEBUG ? $profiler->mark('process, onLastProcess plugins: start') : null;
     if (in_array(false, $pluginManager->runPlugins('onLastProcess', $this))) {
         // $$$ rob this no longer stops default redirect (not needed any more)
         // returning false here stops the default redirect occurring
         return false;
     }
     // Clean both admin and front end cache.
     parent::cleanCache('com_' . $this->package, 1);
     parent::cleanCache('com_' . $this->package, 0);
     JDEBUG ? $profiler->mark('process: end') : null;
     return true;
 }
Example #2
0
 /**
  * Processes the form data and decides what action to take
  *
  * @return  bool  false if one of the plugins returns an error otherwise true
  */
 public function process()
 {
     $app = JFactory::getApplication();
     $input = $app->input;
     error_reporting(error_reporting() ^ (E_WARNING | E_NOTICE));
     @set_time_limit(300);
     require_once COM_FABRIK_FRONTEND . '/helpers/uploader.php';
     $form = $this->getForm();
     $pluginManager = FabrikWorker::getPluginManager();
     $params = $this->getParams();
     $sessionModel = JModelLegacy::getInstance('Formsession', 'FabrikFEModel');
     $sessionModel->setFormId($this->getId());
     $sessionModel->setRowId($this->rowId);
     /* $$$ rob rowId can be updated by juser plugin so plugin can use check (for new/edit)
      * now looks at origRowId
      */
     $this->origRowId = $this->rowId;
     $this->getGroupsHiarachy();
     if ($form->record_in_database == '1') {
         $this->setOrigData();
     }
     if (in_array(false, $pluginManager->runPlugins('onBeforeProcess', $this))) {
         return false;
     }
     $this->removeEmptyNoneJoinedGroupData($this->formData);
     $this->setFormData();
     if (!$this->_doUpload()) {
         return false;
     }
     /** $$$ rob 27/10/2011 - moved above _doUpload as code in there is trying to update formData which is not yet set
      * this->setFormData();
      */
     if (in_array(false, $pluginManager->runPlugins('onBeforeStore', $this))) {
         return false;
     }
     $this->formDataWithTableName = $this->formData;
     if ($form->record_in_database == '1') {
         $this->processToDB();
     }
     // Clean the cache.
     $cache = JFactory::getCache($input->get('option'));
     $cache->clean();
     // $$$rob run this before as well as after onAfterProcess (ONLY for redirect plugin)
     // so that any redirect urls are available for the plugin (e.g twitter)
     $pluginManager->runPlugins('onLastProcess', $this);
     if (in_array(false, $pluginManager->runPlugins('onAfterProcess', $this))) {
         // $$$ rob this no longer stops default redirect (not needed any more)
         // returning false here stops the default redirect occurring
         return false;
     }
     // Need to remove the form session before redirect plugins occur
     $sessionModel->remove();
     // $$$rob used ONLY for redirect plugins
     if (in_array(false, $pluginManager->runPlugins('onLastProcess', $this))) {
         // $$$ rob this no longer stops default redirect (not needed any more)
         // returning false here stops the default redirect occurring
         return false;
     }
     $package = $app->getUserState('com_fabrik.package', 'fabrik');
     // Clean both admin and front end cache.
     parent::cleanCache('com_' . $package, 1);
     parent::cleanCache('com_' . $package, 0);
     return true;
 }