/** * This method runs before the $data is saved to the $table. Return false to * stop saving. * * @param array &$data Param * @param JTable &$table Param * * @return bool */ protected function onBeforeSave(&$data, &$table) { $data['params'] = EForm::paramsToString($data); $data['postdate'] = EParameter::convertLocalUTC($data['postdate']); // Cleaning annoying spaces $data = array_map('trim', $data); return parent::onBeforeSave($data, $table); }
/** * applyAjaxOwnAction * * @return void */ public function applyAjaxOwnAction() { try { // CSRF prevention if ($this->csrfProtection) { $this->_csrfProtection(); } $data = $this->_getAjaxData(); // On Before Save $data['params'] = EForm::paramsToString($data); if (array_key_exists('publish_up', $data)) { $data['publish_up'] = EParameter::convertLocalUTC($data['publish_up']); } else { $data['publish_up'] = JFactory::getDate()->toSql(); } // Cleaning annoying spaces $data = array_map('trim', $data); // Ready to Save require_once JPATH_PLUGINS . '/autotweet/autotweetpost/autotweetpost.php'; $plugin = JPluginHelper::getPlugin('autotweet', 'autotweetpost'); $className = 'plgAutotweet' . $plugin->name; if (!class_exists($className)) { throw new Exception(JText::_('COM_AUTOTWEET_COMPOSER_DISABLED_ERROR')); } $dispatcher = JDispatcher::getInstance(); $plugin = new $className($dispatcher, (array) $plugin); $status = $plugin->postArticle($data); $id = null; if ($status !== false) { $id = $status; $status = true; } $message = json_encode(array('status' => $status, 'request_id' => $id, 'message' => $status ? JText::_('COM_AUTOTWEET_COMPOSER_MESSAGE_SAVED') : 'Unable to addAjaxAction.', 'messageType' => $status ? 'success' : 'error', 'hash' => AutotweetBaseHelper::getHash())); } catch (Exception $e) { $message = json_encode(array('status' => false, 'message' => $e->getMessage(), 'messageType' => 'error', 'hash' => AutotweetBaseHelper::getHash())); } echo EJSON_START . $message . EJSON_END; }
/** * This method runs before the $data is saved to the $table. Return false to * stop saving. * * @param array &$data Param * @param JTable &$table Param * * @return bool */ protected function onBeforeSave(&$data, &$table) { $data['params'] = EForm::paramsToString($data); if (array_key_exists('publish_up', $data)) { $data['publish_up'] = EParameter::convertLocalUTC($data['publish_up']); } else { $data['publish_up'] = JFactory::getDate()->toSql(); } // Cleaning annoying spaces $data = array_map('trim', $data); if (array_key_exists('autotweet_advanced_attrs', $data)) { $this->advanced_attrs = AdvancedattrsHelper::retrieveAdvancedAttrs($data['autotweet_advanced_attrs']); } return parent::onBeforeSave($data, $table); }