/** * 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); } }
/** * 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); }
/** * Load model class for data manipulation * * @param string $elementName Element name * @param SimpleXMLElement $configuration Configuration for current action * * @return mixed Model class for data manipulation * * @since 1.2 */ public function loadModel($elementName, $configuration) { $this->setOptionViewName($elementName, $configuration); $isAdmin = RApiHalHelper::isAttributeTrue($configuration, 'isAdminClass'); $this->addModelIncludePaths($isAdmin, $this->optionName); $this->loadExtensionLanguage($this->optionName, $isAdmin ? JPATH_ADMINISTRATOR : JPATH_SITE); $this->triggerFunction('loadExtensionLibrary', $this->optionName); $dataMode = strtolower(RApiHalHelper::attributeToString($configuration, 'dataMode', 'model')); if ($dataMode == 'helper') { return $this->getHelperObject(); } if ($dataMode == 'table') { return $this->getDynamicModelObject($configuration); } if (!empty($configuration['modelClassName'])) { $modelClass = (string) $configuration['modelClassName']; if (!empty($configuration['modelClassPath'])) { require_once JPATH_SITE . '/' . $configuration['modelClassPath']; if (class_exists($modelClass)) { return new $modelClass(); } } else { $componentName = ucfirst(strtolower(substr($this->optionName, 4))); $prefix = $componentName . 'Model'; $model = RModel::getInstance($modelClass, $prefix); if ($model) { return $model; } } } if (!empty($this->viewName)) { $elementName = $this->viewName; } if ($isAdmin) { return RModel::getAdminInstance($elementName, array(), $this->optionName); } return RModel::getFrontInstance($elementName, array(), $this->optionName); }