public function onBeforeDispatcherDispatch(KEvent $event) { $application = JFactory::getApplication(); if ($application->getName() != 'site') { return; } //var_dump($_SERVER); exit(); // check if SSO header is set $personnumber = KRequest::get('server.HTTP_P_SSO_IDENTIFIER', 'alnum'); if (empty($personnumber) || !preg_match('/P\\d+/is', $personnumber)) { // TODO set proper http response throw new KException('Access not allowed'); } // check if user is already logged in $user = JFactory::getUser(); // make sure personnumber is still the same if (!$user->guest && $user->username != $personnumber) { $application->logout(); $application->redirect(KRequest::url()); } if ($user->guest) { $credentials = array('username' => $personnumber, 'password' => $personnumber); $result = $application->login($credentials, array()); if (JError::isError($result)) { // TODO set proper http response throw new KException($result->getError()); } else { $application->redirect('index.php'); } } }
public function display() { //Set the document link $this->_document->link = $this->createRoute('format=html&view=posts&blog_blog_id=' . KRequest::get('get.id', 'int')); //Get the list of posts $posts = KFactory::get($this->getModel())->getList(); foreach ($posts as $post) { // strip html from feed item title $title = html_entity_decode($post->title); // url link to article $link = $this->createRoute('format=html&view=post&slug=' . $post->slug); // generate the description as a hcard $description = $post->text; // load individual item creator class $item = new JFeedItem(); $item->title = $title; $item->link = $link; $item->description = $description; $item->date = date('r', strtotime($post->created_on)); $item->category = ''; // loads item info into rss array $doc =& JFactory::getDocument(); $doc->addItem($item); } return $this; }
public function beforeAdd(KCommandContext $context) { if (!$context->data->file) { $context->data->file = KRequest::get('files.file.tmp_name', 'raw'); $context->data->path = KRequest::get('files.file.name', 'koowa:filter.filename'); } }
/** * Upload the users avatar * * @param KCommandContext A command context object * @return void */ public function uploadAvatar(KCommandContext $context) { $avatar = KRequest::get('files.avatar', 'raw'); if (!$avatar['name']) { return; } //Prepare MediaHelper JLoader::register('MediaHelper', JPATH_ROOT . '/components/com_media/helpers/media.php'); // is it an image if (!MediaHelper::isImage($avatar['name'])) { JError::raiseWarning(21, sprintf(JText::_("%s failed to upload because it's not an image."), $avatar['name'])); return; } // are we allowed to upload this filetype if (!MediaHelper::canUpload($avatar, $error)) { JError::raiseWarning(21, sprintf(JText::_("%s failed to upload because %s"), $avatar['name'], lcfirst($error))); return; } // @todo put in some max file size checks $path = 'images/com_portfolio/avatars/' . $context->data->user_id . '/'; $ext = JFile::getExt($avatar['name']); $name = JFile::makeSafe($this->getService('koowa:filter.slug')->sanitize($context->data->title) . '.' . $ext); JFile::upload($avatar['tmp_name'], JPATH_ROOT . '/' . $path . $name); $context->data->avatar = $path . $name; }
public function display() { $this->assign('params', KFactory::get('admin::com.ninjaboard.model.settings')->getParams()); $me = KFactory::get('admin::com.ninjaboard.model.people')->getMe(); $this->showtopics = false; if (isset($this->params['view_settings']['displayed_elements']) && $me->topic_permissions > 0) { if (in_array('showtopics', $this->params['view_settings']['displayed_elements'])) { $this->showtopics = true; //$state = KFactory::get($this->getModel())->getState(); /*$this->limit = KRequest::get('get.limit', 'int', 10); $this->offset = KRequest::get('get.offset', 'int', 0); $topicsmodel = KFactory::tmp('site::com.ninjaboard.model.topics') ->limit($this->limit) ->offset($this->offset) ->sort('last_post_date') ->direction('desc'); $this->total = $topicsmodel->getTotal(); $this->length = KFactory::tmp('site::com.ninjaboard.model.topics')->getTotal(); $this->assign('pagination', KFactory::get('site::com.ninjaboard.template.helper.paginator', array('name' => 'topics')) ->pagination($this->total, $this->offset, $this->limit, 4) );*/ $this->limit = KRequest::get('get.limit', 'int', 10); $this->offset = KRequest::get('get.offset', 'int', 0); $this->total = KFactory::get('site::com.ninjaboard.model.topics')->getTotal(); $this->assign('topics', KFactory::get('site::com.ninjaboard.controller.topic')->setView(KFactory::get('site::com.ninjaboard.view.topics.html'))->direction('desc')->sort('last_post_on')->limit($this->limit)->offset($this->offset)->layout('list')->display()); $this->assign('pagination', KFactory::get('site::com.ninjaboard.template.helper.paginator', array('name' => 'topics'))->pagination($this->total, $this->offset, $this->limit, 4, false)); } } return parent::display(); }
public function getOnClick() { $id = KRequest::get('get.id', 'int'); $token = JUtility::getToken(); $json = "{method:'post', url:'index.php?option=com_create&view=component&id={$id}', formelem:'adminForm', params:{action:'generate', _token:'{$token}'}}"; return 'new KForm(' . $json . ').submit();'; }
public function display() { $params = KFactory::get('admin::com.ninjaboard.model.settings')->getParams(); $this->assign('params', $params); $person = KFactory::get($this->getModel())->getItem(); if (KFactory::get('lib.joomla.user')->guest && (!$person->id || $this->getlayout() == 'form')) { $this->mixin(KFactory::get('admin::com.ninja.view.user.mixin')); $this->setLoginLayout(); return parent::display(); } if ($this->getLayout() != 'form') { $controller = KFactory::get('site::com.ninjaboard.controller.topic')->setView(KFactory::get('site::com.ninjaboard.view.topics.html'))->direction('desc')->sort('last_post_on')->limit(KRequest::get('get.limit', 'int', 10))->offset(KRequest::get('get.offset', 'int', 0))->at($this->getModel()->getItem()->id); $model = $controller->getModel(); $state = $model->getState(); $this->assign('topics', $this->render($controller->layout('list')->display(), JText::_('Latest Topics'), $params['module'])); $this->assign('pagination', KFactory::get('site::com.ninjaboard.template.helper.paginator', array('name' => 'topics'))->pagination($model->getTotal(), $state->offset, $state->limit, 4, false)); $me = KFactory::get($this->getModel())->getMe(); $this->me = $me; if ($me->id === $person->id) { $this->edit_button = str_replace(array('$title', '$link'), array(JText::_('Edit Profile'), $this->createRoute('view=person&id=' . $person->id . '&layout=form')), $this->params['tmpl']['new_topic_button']); } else { $this->edit_button = false; } $this->message_button = $me->id && $this->params['messaging_settings']['enable_messaging']; $this->watch_button = $me->id && $this->params['email_notification_settings']['enable_email_notification']; $title = sprintf(JText::_("%s's profile"), $person->display_name); } else { $title = sprintf(JText::_("%s's settings"), $person->display_name); $this->save_button = str_replace('$title', JText::_('Save'), $this->params['tmpl']['create_topic_button']); $this->save_button = str_replace('$link', '#', $this->save_button); } $this->_subtitle = $title; $this->assign('title', $title); return parent::display(); }
/** * Logs in a user. * * @param array $user The user as an array * @param bool $remember Flag to whether remember the user or not * * @return bool */ public function login(array $user, $remember = false) { $session =& JFactory::getSession(); // we fork the session to prevent session fixation issues $session->fork(); JFactory::getApplication()->_createSession($session->getId()); // Import the user plugin group JPluginHelper::importPlugin('user'); $options = array(); $results = JFactory::getApplication()->triggerEvent('onLoginUser', array($user, $options)); foreach ($results as $result) { if ($result instanceof JException || $result instanceof Exception || $result === false) { return false; } } //if remember is true, create a remember cookie that contains the ecrypted username and password if ($remember) { // Set the remember me cookie if enabled jimport('joomla.utilities.simplecrypt'); jimport('joomla.utilities.utility'); $key = JUtility::getHash(KRequest::get('server.HTTP_USER_AGENT', 'raw')); if ($key) { $crypt = new JSimpleCrypt($key); $cookie = $crypt->encrypt(serialize(array('username' => $user['username'], 'password' => $user['password']))); $lifetime = time() + 365 * 24 * 3600; setcookie(JUtility::getHash('JLOGIN_REMEMBER'), $cookie, $lifetime, '/'); } } return true; }
/** * Generic function for setting the permissions * * @return void */ public function setPermissions($context) { //Temp fix if (KInflector::isPlural(KRequest::get('get.view', 'cmd')) || KRequest::type() == 'AJAX') { return; } $model = KFactory::get($this->getModel()); $table = KFactory::tmp(KFactory::get(KFactory::get('admin::com.ninja.helper.access')->models->assets)->getTable()); $query = $table->getDatabase()->getQuery(); $item = $model->getItem(); $identifier = $this->getIdentifier(); $id = $identifier->type . '_' . $identifier->package . '.' . $identifier->name . '.' . $item->id . '.'; $permissions = (array) KRequest::get('post.permissions', 'int'); $editable = KRequest::get('post.editpermissions', 'boolean', false); if (!$permissions && $editable) { $query->where('tbl.name', 'LIKE', $id . '%'); $table->select($query)->delete(); } $safe = array(); $query = $table->getDatabase()->getQuery()->where('name', 'like', $id . '%'); foreach ((array) KRequest::get('post.params.permissions', 'raw') as $group => $other) { $safe[] = $id . $group; } if ($safe) { $query->where('name', 'not in', $safe); } $table->select($query, KDatabase::FETCH_ROWSET)->delete(); foreach ($permissions as $usergroup => $rules) { foreach ($rules as $name => $permission) { KFactory::tmp(KFactory::get('admin::com.ninja.helper.access')->models->assets)->name($id . $usergroup . '.' . $name)->getItem()->setData(array('name' => $id . $usergroup . '.' . $name, 'level' => $permission))->save(); } } }
/** * Helper for creating DOM element ids used by javascript behaviors * * If no type and package identifiers were supplied, * uses the current option $_GET variable, and changing com_foo_bar to com-foo_bar. * '-' are used as separators, and in our javascript used to parse identifier strings. * If a form got the id com-foo_bar-people, * then we can assume that the toolbar will have the id toolbar-people, * * @author Stian Didriksen <*****@*****.**> * @param array | int $parts * @return string */ public function id($parts = array()) { if (!is_array($parts) && is_int($parts)) { $parts['id'] = (int) $parts; } // If we pass a string, set $parts back as an array in order to proceed. if (!is_array($parts)) { settype($parts, 'array'); } // Set the defaults, if needed $defaults = array(); if (!isset($parts['type.package'])) { // We only want to replace the first underscore, not the rest. $defaults['type_package'] = str_replace('com_', 'com-', KRequest::get('get.option', 'cmd')); } if (!isset($parts['view'])) { $view = KRequest::get('get.view', 'cmd'); // The view part always needs to be plural to allow ajax BREAD. if (KInflector::isSingular($view)) { $view = KInflector::pluralize($view); } $defaults['view'] = $view; } if (!isset($parts['id']) && KRequest::has('get.id', 'int')) { $defaults['id'] = KRequest::get('get.id', 'int'); } // Filter away parts that are unset on purpose using a null value, or a negative boolean. return implode('-', array_filter(array_merge($defaults, $parts))); }
public function display() { $category = $this->getService('com://site/weblinks.model.categories')->getItem(); $items = $this->getService('com://site/weblinks.model.weblinks')->catid(KRequest::get('get.id', 'int'))->getList(); $xml = '<?xml version="1.0" encoding="utf-8"?>' . PHP_EOL; $xml .= '<rss version="2.0">' . PHP_EOL; $xml .= '<channel>' . PHP_EOL; $xml .= ' <title>' . $category->title . '</title>' . PHP_EOL; $xml .= ' <description><![CDATA[' . $category->description . ']]></description>' . PHP_EOL; $xml .= ' <link>' . KRequest::url() . '</link>' . PHP_EOL; $xml .= ' <lastBuildDate>' . date('r') . '</lastBuildDate>' . PHP_EOL; $xml .= ' <generator>' . JURI::base() . '</generator>' . PHP_EOL; $xml .= ' <language>' . JFactory::getLanguage()->getTag() . '</language>' . PHP_EOL; foreach ($items as $item) { $xml .= ' <item>' . PHP_EOL; $xml .= ' <title>' . htmlspecialchars($item->title) . '</title>' . PHP_EOL; $xml .= ' <link>' . JURI::base() . JRoute::_('index.php?option=com_weblinks&view=weblink&id=' . $item->id) . '</link>' . PHP_EOL; $xml .= ' <guid>' . JURI::base() . JRoute::_('index.php?option=com_weblinks&view=weblink&id=' . $item->id) . '</guid>' . PHP_EOL; $xml .= ' <description><![CDATA[' . htmlspecialchars($item->description) . ']]></description>' . PHP_EOL; $xml .= ' <category>' . $category->title . '</category>' . PHP_EOL; $xml .= ' <pubDate>' . date('r', strtotime($item->date)) . '</pubDate>' . PHP_EOL; $xml .= ' </item>' . PHP_EOL; } $xml .= '</channel>' . PHP_EOL; $xml .= '</rss>'; $this->output = $xml; return parent::display(); }
public function translations($config = array()) { $config = new KConfig($config); $config->append(array('row' => null, 'table' => '')); // First for our knowledge we get the original language (if exists.) $original = $this->_getOriginalLanguage($config->row, $config->table); $html = '<style src="media://com_translations/css/translations.css" />'; $view = KInflector::singularize(KRequest::get('get.view', 'string')); foreach ($this->_getLanguages() as $language) { $relation = $this->_getLanguage($config, $language->lang_code); if ($language->lang_code == $original->iso_code) { $html .= ' <a href="' . $this->getTemplate()->getView()->createRoute('view=' . $view . '&id=' . $config->row . '&backendlanguage=' . $language->lang_code) . '"><div class="badge badge-info">' . strtoupper(substr($language->lang_code, 0, 2)) . '</a></div>'; } else { if ($relation->translated) { $html .= ' <a href="' . $this->getTemplate()->getView()->createRoute('view=' . $view . '&id=' . $config->row . '&backendlanguage=' . $language->lang_code) . '"><div class="badge badge-success">' . strtoupper(substr($language->lang_code, 0, 2)) . '</a></div>'; } else { if (strtotime('+ 2 weeks', strtotime($original->created_on)) > strtotime(date('d-m-Y H:i:s'))) { $html .= ' <a href="' . $this->getTemplate()->getView()->createRoute('view=' . $view . '&id=' . $config->row . '&backendlanguage=' . $language->lang_code) . '"><div class="badge badge-warning">' . strtoupper(substr($language->lang_code, 0, 2)) . '</a></div>'; } else { if (strtotime('+ 2 weeks', strtotime($original->created_on)) < strtotime(date('d-m-Y H:i:s'))) { $html .= ' <a href="' . $this->getTemplate()->getView()->createRoute('view=' . $view . '&id=' . $config->row . '&backendlanguage=' . $language->lang_code) . '"><div class="badge badge-important">' . strtoupper(substr($language->lang_code, 0, 2)) . '</a></div>'; } } } } } return $html; }
/** * Constructor * * @param object An optional KConfig object with configuration options. */ public function __construct(KConfig $config) { parent::__construct($config); if (KRequest::get('get.action', 'cmd') == 'update') { $this->setAction('update'); } }
public function render() { $name = $this->getName(); $img = KTemplateAbstract::loadHelper('admin::com.ninja.helper.default.img', '/32/' . $name . '.png'); if ($img) { KTemplateAbstract::loadHelper('admin::com.ninja.helper.default.css', '.toolbar .icon-32-' . $name . ' { background-image: url(' . $img . '); }'); } $text = JText::_($this->_options['text']); $view = KRequest::get('get.view', 'cmd'); $link = ' href="' . JRoute::_($this->getLink()) . '"'; $html = array(); // Sanitize the url since we can't trust the server var $url = KFactory::get('lib.koowa.filter.url')->sanitize($this->getLink()); // Create the URI object $uri = KFactory::tmp('lib.koowa.http.uri', array('uri' => $url)); $query = $uri->getQuery(1); $html[] = '<td class="button" id="' . $this->getId() . '">'; $active = $view == KInflector::variablize(KInflector::pluralize($query['view'])) || $view == KInflector::variablize(KInflector::singularize($query['view'])); $hide = !KInflector::isPlural($view); if ($active || $hide || !$this->modal) { $html[] = '<a class="toolbar inactive">'; } else { $html[] = '<a' . $link . ' onclick="' . $this->getOnClick() . '" class="toolbar">'; } $html[] = '<span class="' . $this->getClass() . '" title="' . $text . '">'; $html[] = '</span>'; $html[] = $text; if (!$active && !$hide || $this->modal) { $html[] = '</a>'; } else { $html[] = '</a>'; } $html[] = '</td>'; return implode(PHP_EOL, $html); }
/** * Upload an icon for a work * * @param KCommandContext A command context object * @return void */ public function uploadIcon(KCommandContext $context) { $icon = KRequest::get('files.icon', 'raw'); if (!$icon['name']) { return; } //Prepare MediaHelper JLoader::register('MediaHelper', JPATH_ROOT . '/components/com_media/helpers/media.php'); // is it an image if (!MediaHelper::isImage($icon['name'])) { JError::raiseWarning(21, sprintf(JText::_("%s failed to upload because it's not an image."), $icon['name'])); return; } // are we allowed to upload this filetype if (!MediaHelper::canUpload($icon, $error)) { JError::raiseWarning(21, sprintf(JText::_("%s failed to upload because %s"), $icon['name'], lcfirst($error))); return; } $slug = $this->getService('koowa:filter.slug'); $path = 'images/com_portfolio/work/' . $slug->sanitize($context->data->title) . '/icon/'; $ext = JFile::getExt($icon['name']); $name = JFile::makeSafe($slug->sanitize($context->data->title) . '.' . $ext); JFile::upload($icon['tmp_name'], JPATH_ROOT . '/' . $path . $name); $context->data->icon = $path . $name; }
public function display() { $targets = KFactory::tmp('site::com.stream.model.targets')->getList()->getData(); $thing = reset($targets); $string = substr($thing['title'], 3); $option = strtolower(substr($string, 0, stripos($string, 'controller'))); $view = strtolower(substr($string, stripos($string, 'controller') + 10)); $model = KInflector::pluralize($view); $list = KFactory::tmp('site::com.' . $option . '.model.' . $model)->getList()->getData(); $array = array(); foreach ($list as $item) { $array[] = $item['id']; } //Get the list of posts $activities = KFactory::get($this->getModel())->set('parent_target_id', KRequest::get('get.parent_target_id', 'int'))->getList(); $myactivities = array(); foreach (@$activities as $activity) { if (!in_array($activity->parent_target_id, $array)) { continue; } else { $myactivities[] = $activity; } } $this->assign('myactivities', $myactivities); $this->assign('pagination', KFactory::get($this->getModel())->getState()->pagination); return parent::display(); }
public function _actionEdit(KCommandContext $context) { $data = $context->data; $model = $this->getModel(); $table = $model->getTable(); $query = KFactory::tmp('lib.koowa.database.query'); $ids = array(); foreach ($data['group'] as $joomla => $ninjaboard) { $ids[] = $joomla; } $table->getDatabase()->execute('TRUNCATE TABLE `#__ninjaboard_joomla_user_group_maps`'); foreach ($ids as $id) { $table->getDatabase()->execute('INSERT INTO `#__ninjaboard_joomla_user_group_maps` (`joomla_gid`, `ninjaboard_gid`) VALUES (' . $id . ', ' . (int) $data['group'][$id] . ')'); //$table->insert(array('joomla_gid' => $id, 'ninjaboard_gid' => $data['group'][$id])); } $tmpl = false; if (KRequest::get('post.tmpl', 'cmd') == 'component') { $tmpl = '&tmpl=component'; } $this->_redirect = 'index.php?option=com_ninjaboard&view=joomlausergroupmaps' . $tmpl; if ($tmpl) { $this->_redirect_message = '<script type="text/javascript">window.parent.document.getElementById("sbox-btn-close").fireEvent("click")</script>'; } // @TODO this is a temporary workaround, find out why the proper way, using setRedirect(), stopped working. echo $this->_redirect_message; //$this->setRedirect('view=joomlausergroupmaps'.$tmpl, $tmpl ? '<script type="text/javascript">window.parent.document.getElementById("sbox-btn-close").fireEvent("click")</script>' : null); return $this->getModel()->getList(); }
/** * @param KCommandContext $context */ public function _actionCopy(KCommandContext $context) { foreach (KRequest::get('get.id', 'raw') as $item_id) { $this->count = 1; $items = array(); $languages = JLanguageHelper::getLanguages(); $model_identifier = clone $context->caller->getIdentifier(); $model_identifier->path = array('model'); $model_identifier->name = KInflector::pluralize($model_identifier->name); $isTranslatable = KService::get($model_identifier)->getTable()->hasBehavior('translatable'); if ($isTranslatable) { foreach ($languages as $language) { JFactory::getLanguage()->setLanguage($language->lang_code); $item = $this->getService($model_identifier)->id($item_id)->getItem(); if ($item->original) { $this->original_language = $language->lang_code; $original = $item; } else { $items[$language->lang_code] = $item; } } } JFactory::getLanguage()->setLanguage($this->original_language); $id = $this->_copyOriginal($original); if ($isTranslatable) { $this->_updateLanguages($id, $items); } } }
/** * Method to upload and Add a photo. * * @param KCommandContext $context */ protected function _actionAdd($context) { $data = $context->data; $file = KRequest::get('files.file', 'raw'); $content = @file_get_contents($file['tmp_name']); $filesize = strlen($content); $uploadlimit = $this->_max_upload_limit * 1024 * 1024; $exif = function_exists('exif_read_data') ? @exif_read_data($file['tmp_name']) : array(); if ($filesize == 0) { throw new LibBaseControllerExceptionBadRequest('File is missing'); return; } if ($filesize > $uploadlimit) { throw new LibBaseControllerExceptionBadRequest('Exceed maximum size'); return; } $orientation = 0; if (!empty($exif) && isset($exif['Orientation'])) { $orientation = $exif['Orientation']; } $data['portrait'] = array('data' => $content, 'rotation' => $orientation, 'mimetype' => isset($file['type']) ? $file['type'] : null); $photo = $this->actor->photos->addNew($data); $photo->setExifData($exif); $photo->save(); $this->setItem($photo); $this->getResponse()->status = KHttpResponse::CREATED; if ($photo->body && preg_match('/\\S/', $photo->body)) { $context->append(array('story' => array('body' => $photo->body))); } return $photo; }
public function display() { $topic = $this->getModel()->getItem(); $this->forum = KFactory::get('site::com.ninjaboard.model.forums')->id($topic->forum_id)->getItem(); $this->user = KFactory::get('lib.joomla.user'); $me = KFactory::get('admin::com.ninjaboard.model.people')->getMe(); $this->watch_button = $me->id && $this->forum->params['email_notification_settings']['enable_email_notification']; //Assign forum permissions to topic $topic->forum_permissions = $this->forum->forum_permissions; $topic->topic_permissions = $this->forum->topic_permissions; $topic->post_permissions = $this->forum->post_permissions; $topic->attachment_permissions = $this->forum->attachment_permissions; if ((!$this->forum->id || !$topic->id || $topic->topic_permissions < 1) && KFactory::tmp('lib.joomla.user')->guest) { $this->mixin(KFactory::get('admin::com.ninja.view.user.mixin')); $this->setLoginLayout(); return parent::display(); } elseif (!$topic->id) { JError::raiseError(404, JText::_("Topic not found.")); return; } elseif (!$this->forum->id) { JError::raiseError(404, JText::_("Forum not found.")); return; } $this->_subtitle = $topic->title; //if($topic->id && !KRequest::get('get.layout', 'cmd', false)) $this->setLayout('default'); $state = $this->getModel()->getState(); $limit = $state->limit ? $state->limit : 6; $offset = KFactory::tmp('site::com.ninjaboard.model.posts')->topic($topic->id)->post($state->post)->limit($limit)->getOffset(); $offset = KRequest::get('get.offset', 'int', $offset); //This is used to set the canonical link correctly in the topic controller after.read //@TODO move all this logic out of the view in 1.2 $this->getModel()->set(array('limit' => $limit, 'offset' => $offset)); $this->assign('posts', KFactory::tmp('site::com.ninjaboard.controller.post')->setView(KFactory::tmp('site::com.ninjaboard.view.posts.html'))->setModel(KFactory::get('site::com.ninjaboard.model.posts')->setAcl(false))->sort('created_on')->limit($limit)->offset($offset)->post(false)->topic($topic->id)->layout('default')->display()); if ($this->forum->params['view_settings']['new_topic_button'] == 'topic') { $this->new_topic_button = '<div class="new-topic">' . str_replace(array('$title', '$link'), array(JText::_('New Topic'), $this->createRoute('view=post&forum=' . $this->forum->id)), $this->forum->params['tmpl']['new_topic_button']) . '</div>'; } $button = false; if (KFactory::get('lib.joomla.user')->guest || $this->forum->post_permissions > 1) { $button = str_replace(array('$title', '$link'), array(JText::_('Reply topic'), $this->createRoute('view=post&topic=' . $topic->id)), $this->forum->params['tmpl']['new_topic_button']); } //$this->reply_topic_button = $this->forum->post_permissions > 1 ? $button : null; $this->reply_topic_button = $button; $this->lock_topic_button = null; $this->move_topic_button = null; $this->delete_topic_button = null; if ($this->forum->topic_permissions > 2) { $this->lock_topic_button = $this->_createActionButton('lock', 'Lock topic', $topic->id, 'lock'); $this->move_topic_button = str_replace(array('$title', '$link'), array(JText::_('Move topic'), $this->createRoute('view=topic&layout=move&id=' . $topic->id)), $this->forum->params['tmpl']['new_topic_button']); $this->delete_topic_button = $this->_createActionButton('delete', 'Delete topic', $topic->id, 'trash'); } $output = parent::display(); //@TODO move this to the controller $hit = KRequest::get('session.' . KFactory::get('admin::com.ninja.helper.default')->formid($topic->id), 'boolean'); if (!$hit && $topic->created_user_id != $me->id) { $topic->hit(); KRequest::set('session.' . KFactory::get('admin::com.ninja.helper.default')->formid($topic->id), true); } return $output; }
public function display() { $path = base64_decode(KRequest::get('get.path', 'base64')); $container = $this->getService('com://admin/files.model.containers')->slug('downloads-downloads')->getItem(); $this->path = $container->path . DS . $path; $this->filename = basename($path); return parent::display(); }
/** * Can login * * @return boolean */ public function canLogin() { $subscriber_id = KRequest::get('session.subscriber_id', 'cmd'); if ($subscriber_id) { $this->person = $this->getService('repos://site/people')->find($subscriber_id); } return !is_null($this->person); }
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) { // TODO: Remove this workaround if SEF bug was fixed. if (KRequest::get('get.view', 'cmd', 'news') == 'news') { JFactory::getApplication()->redirect('index.php?option=com_news&view=articles'); } parent::_initialize($config); }
public function getOnClick() { $option = KRequest::get('get.option', 'cmd'); $view = KInflector::singularize(KRequest::get('get.view', 'cmd')); $json = "{method:'get', url:'index.php', params:{option:'{$option}',view:'{$view}',id:id}}"; $msg = JText::_('Please select an item from the list'); return 'var id = Koowa.Grid.getFirstSelected();' . 'if(id){new Koowa.Form(' . $json . ').submit();} ' . 'else { alert(\'' . $msg . '\'); return false; }'; }
public function render() { $option = KRequest::get('get.option', 'cmd'); $view = KInflector::singularize(KRequest::get('get.view', 'cmd')); $link = 'index.php?option=' . $option . '&view=' . $view; $this->attribs->set(array('class' => 'toolbar', 'href' => $this->_parent->createRoute($link))); return parent::render(); }
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); }
/** * Returns the url login for a service * * @param string $service * @return string */ public function url($service) { $url = 'index.php?option=com_connect&view=login&server=' . $service; if (KRequest::get('get.return', 'cmd')) { $url .= '&return=' . KRequest::get('get.return', 'raw'); } return JRoute::_($url); }
/** * Restores a state for an action * * @param string $action * @return void */ public function restoreState($action) { //Built the session identifier based on the action $identifier = $this->_mixer->getIdentifier() . '.' . $action; $state = KRequest::get('session.' . $identifier, 'raw', array()); //Append the data to the request object $this->getState()->append($state); }
public function getOnClick() { $option = KRequest::get('get.option', 'cmd'); $view = KRequest::get('get.view', 'cmd'); $id = KRequest::get('get.id', 'int'); $token = JUtility::getToken(); $json = "{method:'post', url:'index.php?option={$option}&view={$view}&id={$id}', element:'adminForm', params:{action:'save', _token:'{$token}'}}"; return 'new Koowa.Form(' . $json . ').submit();'; }