protected function _actionRead(KCommandContext $context) { $template = parent::_actionRead($context); if (isset($template->name)) { JFactory::getLanguage()->load('tpl_' . $template->name, JPATH_ADMINISTRATOR); } return $template; }
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); }
/** * 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); }
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; }
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(); } } }