public function setModel($model) { $model = parent::setModel($model); $model->package = 'categories'; return $model; }
public function getRequest() { $request = parent::getRequest(); $request->enabled = 1; $request->sort = 'date_start'; return $request; }
public function __construct(KConfig $config) { parent::__construct($config); // TODO To be removed as soon as the problem with language files loading on HMVC calls is solved JFactory::getLanguage()->load('com_activities', JPATH_ADMINISTRATOR); $this->registerCallback('before.add', array($this, 'setIp')); }
public function setModel($model) { $model = parent::setModel($model); $model->package = KInflector::pluralize($this->_identifier->name); return $model; }
public function _initialize(KConfig $config) { $this->mixin($this->getService('com://admin/kutafuta.controller.behavior.indexable')); $this->mixin($this->getService('com://admin/moyo.controller.behavior.copyable')); $config->append(array('behaviors' => array('com://admin/cck.controller.behavior.autosavable'))); parent::_initialize($config); }
public function setRequest($request) { if (isset($request['e_name'])) { $request['editor'] = $request['e_name']; } parent::setRequest($request); }
public function getRequest() { $request = parent::getRequest(); //Force the site //$request->site = JFactory::getApplication()->getSite(); return $request; }
protected function _initialize($config) { $config->append(array('request' => array('sort' => 'created_on', 'direction' => 'desc'))); if (KRequest::method() != 'GET') { $config->request->append(array('id' => KRequest::get('post.id', 'int'))); } parent::_initialize($config); }
protected function _initialize(KConfig $config) { $config->append(array( 'behaviors' => array('aclable', 'image') )); parent::_initialize($config); }
protected function _actionRead(KCommandContext $context) { $name = ucfirst($this->getView()->getName()); if (!$this->getModel()->getState()->isUnique()) { $context->setError(new KControllerException($name . ' Not Found', KHttpResponse::NOT_FOUND)); } return parent::_actionRead($context); }
public function getRequest() { $request = parent::getRequest(); $request->enabled = 1; $request->limit = 25; $request->sort = 'title'; return $request; }
protected function _initialize(KConfig $config) { $config->append(array( 'model' => 'documents' )); parent::_initialize($config); }
public function __construct(KConfig $config) { //show only enabled posts in the posts view if (KInflector::isPlural(KRequest::get('get.view', 'string'))) { $config->request->enabled = 1; } parent::__construct($config); }
protected function _actionRead(KCommandContext $context) { $template = parent::_actionRead($context); if (isset($template->name)) { JFactory::getLanguage()->load('tpl_' . $template->name, JPATH_ADMINISTRATOR); } return $template; }
public function getRequest() { $request = parent::getRequest(); $request->sort = 'fish'; $request->direction = 'ASC'; $request->limit = '100'; return $request; }
/** * Constructor * * @param object An optional KConfig object with configuration options */ public function __construct(KConfig $config) { $config->persistent = false; parent::__construct($config); // Register apis Jloader::register('JInstaller', JPATH_LIBRARIES . '/joomla/installer/installer.php'); Jloader::register('JArchive', JPATH_LIBRARIES . '/joomla/filesystem/archive.php'); Jloader::register('JFile', JPATH_LIBRARIES . '/joomla/filesystem/file.php'); }
/** * Overridden method to be able to use it with both resource and service controllers */ protected function _actionGet(KCommandContext $context) { if ($this->getIdentifier()->name == 'image' || $this->getIdentifier()->name == 'file' && $this->getRequest()->format == 'html') { $this->getService('translator')->getTranslator($this->getIdentifier())->loadLanguageFiles(); $result = $this->getView()->display(); return $result; } return parent::_actionGet($context); }
public function getRequest() { $request = parent::getRequest(); //Force the site $request->site = KFactory::get('joomla:application')->getSite(); return $request; }
/** * _actionGet here we will check if the we access a singular or a plural, * when plural the action will return true if singular we will check if the requested tile exists. * * @param KCommandContext $context * @return bool|KDatabaseRow */ protected function _actionGet(KCommandContext $context) { if (KInflector::isSingular($this->_request->view) && !$this->_request->type) { if (!file_exists(JPATH_FILES . '/' . $this->_request->path) || is_dir(JPATH_FILES . '/' . $this->_request->path)) { return false; } } return parent::_actionGet($context); }
/** * Overriden read action in order to set a id on the contact form */ protected function _actionRead(KCommandContext $context) { // if the is the contact layout and we have no id then check to see if we only have one record and use that if ($this->getView()->getLayout() == 'contact') { if (!$this->getRequest()->id && $this->getModel()->getTotal() == 1) { return $this->getModel()->getList()->top(); } } return parent::_actionRead($context); }
protected function _initialize(KConfig $config) { $config->append(array( 'model' => 'results', 'view' => 'results', 'readonly' => true )); parent::_initialize($config); }
public function getRequest() { $request = parent::getRequest(); KFactory::get('com://admin/files.model.configs') ->set($request) ->getItem(); return $request; }
protected function _actionDelete(KCommandContext $context) { $rowset = parent::_actionDelete($context); $list = KFactory::get('com://admin/users.model.sessions') ->set('username', $rowset->username) ->getList() ->delete(); return $rowset; }
/** * Avoid getting redirected to the configs view. It doesn't exist. */ public function setRedirect($url, $msg = null, $type = 'message') { if ($url) { $url = $this->getService('koowa:http.url', array('url' => $url)); $query = $url->getQuery(true); if (isset($query['view']) && $query['view'] === 'configs') { $query['view'] = 'documents'; } $url->setQuery($query); } return parent::setRedirect($url, $msg, $type); }
public function _actionRead(KCommandContext $context) { $weblink = parent::_actionRead($context); // Redirect the user if the request doesn't include layout=form if ($this->_request->format == 'html') { if ($weblink->url) { JFactory::getApplication()->redirect($weblink->url); } return true; } return $weblink; }
public function _actionRead(KCommandContext $context) { $banner = parent::_actionRead($context); // Redirect the user if the banner has a url if ($banner->clickurl) { // Increase hit counter if ($banner->isHittable()) { $banner->hit(); } JFactory::getApplication()->redirect($banner->clickurl); return true; } return $banner; }
public function getRequest() { $request = parent::getRequest(); /* * If there is a storage_path array in the post, set it as a GET parameter * * This is used to circumvent the URL size exceeding problem (after 2k bytes) * that happens in "create documents" screen */ if (KRequest::has('post.storage_path')) { $paths = KRequest::get('post.storage_path', 'raw'); if (is_array($paths)) { $request->storage_path = $paths; } } return $request; }
protected function _actionGet(KCommandContext $context) { $view = $this->getView(); //Set the layout if ($view instanceof KViewTemplate) { if (KInflector::isPlural($view->getName())) { $view->getIdentifier()->path[1] = 'taxonomies'; } else { $view->getIdentifier()->path[1] = 'taxonomy'; } $layout = clone $view->getIdentifier(); $layout->package = 'taxonomy'; $layout->name = $view->getLayout(); //Force re-creation of the filepath to load the category templates $layout->filepath = ''; $view->setLayout($layout); } return parent::_actionGet($context); }
protected function _actionAdd(KCommandContext $context) { $parameters = JComponentHelper::getParams('com_users'); if (!($group_name = $parameters->get('new_usertype'))) { $group_name = 'Registered'; } $context->data->id = 0; $context->data->group_name = $group_name; $context->data->users_group_id = JFactory::getAcl()->get_group_id('', $group_name, 'ARO'); $context->data->registered_on = JFactory::getDate()->toMySQL(); if ($parameters->get('useractivation') == '1') { $password = $this->getService('com://site/users.helper.password'); $context->data->activation = $password->getHash($password->getRandom(32)); $context->data->enabled = 0; $message = JText::_('REG_COMPLETE_ACTIVATE'); } else { $message = JText::_('REG_COMPLETE'); } return parent::_actionAdd($context); }
protected function _actionRead() { $layout = KRequest::get('get.layout', 'string'); if ($layout == 'authorize') { $consumer_key = KRequest::get('get.client_id', 'string'); $redirect_uri = KRequest::get('get.redirect_uri', 'url'); $consumer = KFactory::get('site::com.oauthserver.model.consumers')->set('consumer_key', $consumer_key)->getItem(); if ($consumer->redirect_uri == $redirect_uri) { $oauthserver_consumer_id = KFactory::get('site::com.oauthserver.model.consumers')->set('consumer_key', $consumer_key)->getItem()->id; if (KFactory::get('site::com.oauthserver.model.authorizations')->set('userid', KFactory::get('lib.joomla.user')->id)->set('oauthserver_consumer_id', $oauthserver_consumer_id)->getTotal()) { $returnCode = 'ri2ri3jirj23'; $code = KFactory::get('site::com.oauthserver.model.codes') ->getItem() ->set('oauthserver_consumer_id', $oauthserver_consumer_id) ->set('code', $returnCode) ->save(); KFactory::tmp('lib.joomla.application')->redirect($redirect_uri.(strpbrk($model->accessTokenURL(), '?') ? '&' : '?').'code='.$returnCode); } else { //resource owner must authorize the client KFactory::tmp('lib.joomla.application')->redirect('index.php?option=com_oauthserver&view=token&layout=default&client_id='.$consumer_key.'&redirect_uri='.urlencode($redirect_uri)); } } else { echo 'ERRORCODE redirect_uri_mismatch'; exit(); } } elseif ($layout == 'accesstoken') { $consumer_key = KRequest::get('get.client_id', 'string'); $redirect_uri = KRequest::get('get.redirect_uri', 'url'); $consumer_secret = KRequest::get('get.client_secret', 'string'); $code= KRequest::get('get.code', 'string'); $oauthserver_consumer_id = KFactory::get('site::com.oauthserver.model.consumers')->set('consumer_key', $consumer_key)->getItem()->id; if ($oauthserver_consumer_id) { $isThereTheStoredCode = KFactory::get('site::com.oauthserver.model.codes') ->set('oauthserver_consumer_id', $oauthserver_consumer_id) ->set('code', $code) ->getTotal(); //TODO: check that the authorization code is not expired (e.g. 3 minutes old) //TODO: purge old authorization codes if ($isThereTheStoredCode) { $codeRow = KFactory::get('site::com.oauthserver.model.codes') ->set('oauthserver_consumer_id', $oauthserver_consumer_id) ->set('code', $code) ->getItem(); $accessToken = rand(); KFactory::get('site::com.oauthserver.model.tokens') ->getItem() ->set('oauthserver_consumer_id', $oauthserver_consumer_id) ->set('access_token', $accessToken) ->set('created_by', $codeRow->created_by) ->save(); echo 'access_token='.$accessToken; exit(); } else { echo 'ERRORCODE invalid_request'; exit(); } } else { echo 'ERRORCODE invalid_client'; exit(); } } else { $consumer_key = KRequest::get('get.client_id', 'string', 'null'); if (KFactory::get('site::com.oauthserver.model.consumers')->set('consumer_key', $consumer_key)->getTotal()) { parent::_actionRead(); } else { echo 'ERRORCODE invalid_client'; exit(); } } }