public function save() { if (!isset($this->timestamp) || $this->timestamp === '') { $this->timestamp = date('Y-m-d H:i:s'); } return parent::save(); }
/** * Copy project rounds from one project to the other * * @param int $source source project id * @param int $destination destination project id * * @return void */ protected function copyProjectRounds($source, $destination) { $query = $this->_db->getQuery(true)->select('id')->from('#__tracks_projects_rounds')->where('project_id = ' . $source); $this->_db->setQuery($query); $projectRoundIds = $this->_db->loadColumn(); if ($projectRoundIds) { $model = RModel::getAdminInstance('Projectround'); $model->copy($projectRoundIds, $destination); } }
/** * Override delete method * Delete topic itself and all it's comments, ratings, and view counter */ public function delete() { $tid = $this->id; // delete view counter Counter::where("[entityId] = ? AND [entityTypeId] = ?", [$tid, Topic::ENTITY_TYPE])->delete(); Rating::where("[entityId] = ? AND [entityType] = ?", [$tid, Topic::ENTITY_TYPE])->delete(); RatingStatistic::where("[entityId] = ? AND [entityType] = ?", [$tid, Topic::ENTITY_TYPE])->delete(); Comment::where("[topicId] = ?", $tid)->delete(); parent::delete(); }
/** * Method called to save a model state * * @return void */ public function saveModelState() { $app = JFactory::getApplication(); $input = $app->input; $returnUrl = $input->get('return', '', 'Base64'); $returnUrl = $returnUrl ? base64_decode($returnUrl) : 'index.php'; if ($model = $input->get('model', null)) { $context = $input->getCmd('context', ''); $model = RModel::getAdminInstance(ucfirst($model), array('context' => $context)); $state = $model->getState(); } $app->redirect($returnUrl); }
/** * Service for get username when they forgot username. * * @param string $email Email of user account * * @return boolean True on success. False otherwise. */ public function forgotUsername($email) { // Load language from com_users $language = JFactory::getLanguage(); $language->load('com_users'); // Load stuff from com_users jimport('joomla.application.component.model'); JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_users/models'); JForm::addFormPath(JPATH_SITE . '/components/com_users/models/forms'); JForm::addFieldPath(JPATH_SITE . '/components/com_users/models/fields'); JLoader::import('route', JPATH_SITE . '/components/com_users/helpers'); $model = RModel::getFrontInstance('Remind', array('ignore_request' => true), 'com_users'); $data = array('email' => $email); // Submit the password reset request. $return = $model->processRemindRequest($data); return (bool) $return; }
/** * Constructor * * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). */ public function __construct($config = array()) { parent::__construct($config); $project = JFactory::getApplication()->input->getInt('p', 0); $this->setProjectId($project); }
/** * Add include paths for model class * * @param boolean $isAdmin Is client admin or site * @param string $optionName Option name * * @return void * * @since 1.3 */ public function addModelIncludePaths($isAdmin, $optionName) { if ($isAdmin) { $this->loadExtensionLanguage($optionName, JPATH_ADMINISTRATOR); $path = JPATH_ADMINISTRATOR . '/components/' . $optionName; RModel::addIncludePath($path . '/models'); JTable::addIncludePath($path . '/tables'); RForm::addFormPath($path . '/models/forms'); RForm::addFieldPath($path . '/models/fields'); } else { $this->loadExtensionLanguage($optionName); $path = JPATH_SITE . '/components/' . $optionName; RModel::addIncludePath($path . '/models'); JTable::addIncludePath($path . '/tables'); JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/' . $optionName . '/tables'); RForm::addFormPath($path . '/models/forms'); RForm::addFieldPath($path . '/models/fields'); } if (!defined('JPATH_COMPONENT')) { define('JPATH_COMPONENT', $path); } }