public function actionView($productId) { $categories = array(); $categories = Platform::getPlatformList(); $product = Products::getProductById($productId); $productId = $product['id']; $platform = Platform::getPlatformById($product['platform_id']); $comments = Comment::getCommentsByProductId($productId); //COMMENTS if (isset($_POST['submit'])) { $userComment = $_POST['message']; $errors = false; if (!Comment::validateMessage($userComment)) { $errors[] = "Введите собщение"; } if (User::isGuest()) { $userName = $_POST['name']; $userEmail = $_POST['email']; if (!User::validateUsername($userName)) { $errors[] = "Неверное имя"; } if (!User::validateEmail($userEmail)) { $errors[] = "Неверный Email"; } $userId = false; } else { $userId = User::validateLogged(); $user = User::getUserById($userId); $userName = $user['name']; } Comment::addComment($userComment, $userId, $userName, $productId); } require_once ROOT . '/views/product/view.php'; return true; }
/** * Method to catch the onAfterRoute event. * * @return boolean */ public function onAfterRoute() { $task = Request::getVar('task', 'none'); if (User::isGuest() || !App::isSite() || $task == 'user.logout') { return false; } $menuId = $this->params->get('menuId', 0); if (!$menuId) { return false; } $menu = App::get('menu'); $activeMenu = $menu->getActive(); $defaultMenu = $menu->getDefault(); // If routing to the home page... if ($activeMenu == $defaultMenu) { // Reset the active menu item and // overwrite request vars $menu->setActive($menuId); $menu->setDefault($menuId, $defaultMenu->language); $item = $menu->getItem($menuId); $vars = $item->query; $vars['Itemid'] = $menuId; foreach ($vars as $key => $var) { Request::setVar($key, $var); } } return true; }
/** * Sets the currently logged in user. * @param User $user The user to set. * @param string $password The password of the user, just to be sure. */ public static function setUser(User $user, $password) { // Let's first issue a new session token to null out any old forms Session::issueToken(); // Make sure the user isn't a guest and the password works if ($user == null || $user->isGuest() || !$user->isPassword($password)) { // Delete the cookies Cookie::delete('userid'); Cookie::delete('sid'); // Set the user to a guest self::$user = User::guest(); return; } // Make sure this isn't already the signed in user if (self::$user != null && self::$user->getUserId() == $user->getUserId()) { return; } // Set the cookies Cookie::set('userid', $user->getUserId()); Cookie::set('sid', $user->getCookiePassword()); // Update the user's visit times $user->updateVisitInfo(); // Let's now set the local version self::$user = $user; }
/** * Constructor * * @return boolean */ public function onAfterRoute() { $task = Request::getVar('task', 'none'); if (User::isGuest() || !App::isSite() || $task == 'user.logout') { return false; } /*$ignoredURLs = (string) $this->params->get('ignore_urls', ''); if ($ignoredURLs) { $ignoredURLArray = explode("\r\n",$ignoredURLs); $fullURL = Request::current(); foreach ($ignoredURLArray as $str) { $pos = strpos($fullURL, $str); if ($pos !== false) { return false; } } } $ignoredOptions = (string) $this->params->get('ignore_options', ''); if ($ignoredOptions) { $option = Request::getCmd('option', ''); $ignoredOptionsArray = explode("\r\n", $ignoredOptions); foreach ($ignoredOptionsArray as $str) { if ($str == $option) { return false; } } }*/ $menuId = $this->params->get('menuId', 0); if (!$menuId) { return false; } $menu = App::get('menu'); $activeMenu = $menu->getActive(); $defaultMenu = $menu->getDefault(); if ($activeMenu == $defaultMenu) { $menu->setActive($menuId); $menu->setDefault($menuId, $defaultMenu->language); $item = $menu->getItem($menuId); $vars = $item->query; $vars['Itemid'] = $menuId; foreach ($vars as $key => $var) { Request::setVar($key, $var); } //Request::set($vars, 'method', true); //App::redirect(Route::url('index.php?Itemid=' . $menuId, false)); } return true; }
/** * Hook for after parsing route * * @return void */ public function onAfterRoute() { if (User::isGuest()) { $current = Request::getWord('option', ''); $current .= ($controller = Request::getWord('controller', false)) ? '.' . $controller : ''; $current .= ($task = Request::getWord('task', false)) ? '.' . $task : ''; $current .= ($view = Request::getWord('view', false)) ? '.' . $view : ''; if (App::isSite()) { $pages = ['com_users.login']; $granted = Session::get('user_consent', false); if (in_array($current, $pages) && !$granted) { Request::setVar('option', 'com_users'); Request::setVar('view', 'userconsent'); } } else { if (App::isAdmin()) { $exceptions = ['com_login.grantconsent']; $granted = Session::get('user_consent', false); if (!in_array($current, $exceptions) && !$granted) { Request::setVar('option', 'com_login'); Request::setVar('task', 'consent'); } } } } }
/** * Return data on a publication view (this will be some form of HTML) * * @param object $publication * @param string $option * @param array $areas * @param string $rtrn * @param string $version * @param boolean $extended * @return array */ public function onPublication($publication, $option, $areas, $rtrn = 'all', $version = 'default', $extended = true) { $arr = array('html' => '', 'metadata' => '', 'name' => 'share'); // Hide if version not published if (!$extended || in_array($publication->state, array(4, 5, 6))) { return $arr; } $sef = Route::url('index.php?option=' . $option . '&id=' . $publication->id); $sef = rtrim($sef, '/') . '/?v=' . $publication->version_number; $url = Request::base() . ltrim($sef, '/'); $mediaUrl = Request::base() . trim($sef, '/') . '/' . $publication->version_id . '/Image:master'; // Incoming action $sharewith = Request::getVar('sharewith', ''); if ($sharewith) { if (!User::isGuest()) { // Log the activity Event::trigger('system.logActivity', ['activity' => ['action' => 'shared', 'scope' => 'publication', 'scope_id' => $publication->id, 'description' => Lang::txt('PLG_PUBLICATIONS_SHARE_ENTRY_SHARED', '<a href="' . $sef . '">' . $publication->title . '</a>', $sharewith), 'details' => array('with' => $sharewith, 'title' => $publication->title, 'url' => $sef, 'version' => $publication->version_number)], 'recipients' => [['publication', $publication->id], ['user', $publication->created_by], ['user', User::get('id')]]]); } return $this->share($sharewith, $url, $mediaUrl, $publication, $version); } // Build the HTML meant for the "about" tab's metadata overview if ($rtrn == 'all' || $rtrn == 'metadata') { // Instantiate a view $view = $this->view('default', 'options')->set('option', $option)->set('publication', $publication)->set('version', $version)->set('_params', $this->params)->set('url', $url)->setErrors($this->getErrors()); // Return the output $arr['metadata'] = $view->loadTemplate(); } return $arr; }
/** * Hook for after parsing route * * @return void */ public function onAfterRoute() { // First, check for presence of subject dn, which is the minimum required field if (!isset($_SERVER['SSL_CLIENT_S_DN']) || !$_SERVER['SSL_CLIENT_S_DN']) { \App::redirect($this->params->get('failure_location', '/invalidcert.php')); return; } if (\User::isGuest()) { // If so, redirect to login Request::setVar('option', 'com_users'); Request::setVar('task', 'user.login'); Request::setVar('authenticator', 'certificate'); Request::setVar('return', base64_encode(\Request::current())); return; } // Check if user is registered and if current session is linked to cert identity $hzad = \Hubzero\Auth\Domain::getInstance('authentication', 'certificate', $_SERVER['SSL_CLIENT_I_DN_CN']); if ($link = \Hubzero\Auth\Link::getInstance($hzad->id, $_SERVER['SSL_CLIENT_S_DN_CN'])) { if ($link->user_id == \User::get('id')) { // All clear...return nothing return; } } // Otherwise, we have a cert-based user that doesn't match the current user Request::setVar('option', 'com_users'); Request::setVar('task', 'user.logout'); $this->event->stop(); }
/** * Hook for after parsing route * * @return void */ public function onAfterRoute() { if (App::isSite() && !User::isGuest()) { $exceptions = ['com_users.logout', 'com_users.userlogout', 'com_support.tickets.save.index', 'com_members.changepassword', 'com_members.media.download.profiles']; $current = Request::getWord('option', ''); $current .= ($controller = Request::getWord('controller', false)) ? '.' . $controller : ''; $current .= ($task = Request::getWord('task', false)) ? '.' . $task : ''; $current .= ($view = Request::getWord('view', false)) ? '.' . $view : ''; $badpassword = Session::get('badpassword', false); $expiredpassword = Session::get('expiredpassword', false); // If guest, proceed as normal and they'll land on the login page if (!in_array($current, $exceptions) && ($badpassword || $expiredpassword)) { Request::setVar('option', 'com_members'); Request::setVar('task', 'changepassword'); Request::setVar('id', 0); if ($badpassword) { Request::setVar('Your password does not meet current site requirements. Please change your password now.'); } if ($expiredpassword) { Request::setVar('Your password has expired. Please change your password now.'); } $this->event->stop(); } } }
/** * Generate macro output * * @return string */ public function render() { // check if we can render if (!parent::canRender()) { return \Lang::txt('[This macro is designed for Groups only]'); } // get args $args = $this->getArgs(); //array of filters $filters = array('limit' => count($args) == 1 && is_numeric($args[0]) ? $args[0] : 12); // get members $members = $this->getGroupMembers($this->group, $filters); //are we a group member $isMember = in_array(\User::get('id'), $this->group->get('members')) ? true : false; //get the members plugin access for this group $memberAccess = \Hubzero\User\Group\Helper::getPluginAccess($this->group, 'members'); // make sure we can actually display for the current user if ($memberAccess == 'anyone' || $memberAccess == 'registered' && !\User::isGuest() || $memberAccess == 'members' && $isMember) { $html = $this->renderMembers($this->group, $members); } else { $html = ''; } //return rendered events return $html; }
/** * Return data on a resource view (this will be some form of HTML) * * @param object $resource Current resource * @param string $option Name of the component * @param array $areas Active area(s) * @param string $rtrn Data to be returned * @return array */ public function onResources($model, $option, $areas, $rtrn = 'all') { if (!$model->type->params->get('plg_share')) { return; } $arr = array('area' => $this->_name, 'html' => '', 'metadata' => ''); $resource = $model->resource; $sef = Route::url('index.php?option=com_resources&' . ($resource->alias ? 'alias=' . $resource->alias : 'id=' . $resource->id)); $url = Request::base() . ltrim($sef, '/'); // Incoming action $sharewith = Request::getVar('sharewith', ''); if ($sharewith) { // Log the activity if (!User::isGuest()) { Event::trigger('system.logActivity', ['activity' => ['action' => 'shared', 'scope' => 'resource', 'scope_id' => $resource->id, 'description' => Lang::txt('PLG_RESOURCES_SHARE_ENTRY_SHARED', '<a href="' . $sef . '">' . $resource->title . '</a>', $sharewith), 'details' => array('with' => $sharewith, 'title' => $resource->title, 'url' => $sef)], 'recipients' => [['resource', $resource->id], ['user', $resource->created_by], ['user', User::get('id')]]]); } // Email form if ($sharewith == 'email') { // Instantiate a view $view = $this->view('email', 'options')->set('option', $option)->set('resource', $resource)->set('_params', $this->params)->set('url', $url)->setErrors($this->getErrors()); // Return the output $view->display(); exit; } return $this->share($sharewith, $url, $resource); } // Build the HTML meant for the "about" tab's metadata overview if ($rtrn == 'all' || $rtrn == 'metadata') { // Instantiate a view $view = $this->view('default', 'options')->set('option', $option)->set('resource', $resource)->set('_params', $this->params)->set('url', $url)->setErrors($this->getErrors()); // Return the output $arr['metadata'] = $view->loadTemplate(); } return $arr; }
/** * Hook for after parsing route * * @return void */ public function onAfterRoute() { if (in_array(App::get('client')->id, $this->params->get('clients', [1]))) { $exceptions = ['com_login.logout', 'com_users.logout']; $current = Request::getWord('option', ''); $current .= ($task = Request::getWord('task', false)) ? '.' . $task : ''; $current .= ($view = Request::getWord('view', false)) ? '.' . $view : ''; // If guest, proceed as normal and they'll land on the login page if (!User::isGuest() && !in_array($current, $exceptions)) { // Get factor status $status = App::get('session')->get('authfactors.status', null); if ($status === false) { // If not a guest, and auth factors checks are done and have failed, // log out so we start over $logout = 'logout' . ucfirst(App::get('client')->alias); self::$logout(); } else { if ($status === null) { // If not a guest, but no factor verification has been completed, // procede with auth factor checks as applicable $factors = 'factors' . ucfirst(App::get('client')->alias); self::$factors(); } } } } }
/** * Prepares the document * * @since 1.6 */ protected function prepareDocument() { $menus = \App::get('menu'); $login = User::isGuest() ? true : false; $title = null; // Because the application sets a default page title, // we need to get it from the menu item itself $menu = $menus->getActive(); if ($menu) { $this->params->def('page_heading', $this->params->get('page_title', User::get('name'))); } else { $this->params->def('page_heading', Lang::txt('COM_USERS_PROFILE')); } $title = $this->params->get('page_title', ''); if (empty($title)) { $title = Config::get('sitename'); } elseif (Config::get('sitename_pagetitles', 0) == 1) { $title = Lang::txt('JPAGETITLE', Config::get('sitename'), $title); } elseif (Config::get('sitename_pagetitles', 0) == 2) { $title = Lang::txt('JPAGETITLE', $title, Config::get('sitename')); } $this->document->setTitle($title); if ($this->params->get('menu-meta_description')) { $this->document->setDescription($this->params->get('menu-meta_description')); } if ($this->params->get('menu-meta_keywords')) { $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); } if ($this->params->get('robots')) { $this->document->setMetadata('robots', $this->params->get('robots')); } }
/** * Action для страницы "Оформление покупки" */ public function actionCheckout() { $productsInCart = Cart::getProducts(); if ($productsInCart == false) { header("Location: /"); } $categories = Category::getCategoriesList(); // Находим общую стоимость $productsIds = array_keys($productsInCart); $products = Product::getProdustsByIds($productsIds); $totalPrice = Cart::getTotalPrice($products); // Количество товаров $totalQuantity = Cart::countItems(); $userName = false; $userPhone = false; $userComment = false; $result = false; if (!User::isGuest()) { // Если пользователь не гость // Получаем информацию о пользователе из БД $userId = User::checkLogged(); $user = User::getUserById($userId); $userName = $user['name']; } else { // Если гость, поля формы останутся пустыми $userId = false; } if (isset($_POST['submit'])) { $userName = $_POST['userName']; $userPhone = $_POST['userPhone']; $userComment = $_POST['userComment']; // Флаг ошибок $errors = false; if (!User::checkName($userName)) { $errors[] = 'Неправильное имя'; } if (!User::checkPhone($userPhone)) { $errors[] = 'Неправильный телефон'; } if ($errors == false) { // Если ошибок нет // Сохраняем заказ в базе данных $result = Order::save($userName, $userPhone, $userComment, $userId, $productsInCart); if ($result) { // Если заказ успешно сохранен // Оповещаем администратора о новом заказе по почте $adminEmail = '*****@*****.**'; $message = '<a href="localhost/admin/orders">Список заказов</a>'; $subject = 'Новый заказ!'; mail($adminEmail, $subject, $message); // Очищаем корзину Cart::clear(); } } } // Подключаем вид require_once ROOT . '/views/cart/checkout.php'; return true; }
/** * Reset a password * @param string[32+32] user_id + authKey uuid without '-' inverted * @return void * @access public */ function reset_password($token = null) { if (User::isGuest()) { $this->layout = 'login'; $this->Auth->resetPassword($token); $this->set('token', $token); } }
/** * Constructor * * @param object &$subject Event observer * @param array $config Optional config values * @return void */ public function plgSupportCaptcha(&$subject, $config) { parent::__construct($subject, $config); $this->loadLanguage(); if (!User::isGuest()) { if (User::get('activation') == 1 || User::get('activation') == 3) { $this->_verified = true; } } }
/** * Pull a list of records that were created within the time frame ($period) * * @param object $period Time period to pull results for * @param mixed $limit Number of records to pull * @param integer $limitstart Start of records to pull * @param array $areas Active area(s) * @param array $tagids Array of tag IDs * @return array */ public function onWhatsnew($period, $limit = 0, $limitstart = 0, $areas = null, $tagids = array()) { if (is_array($areas) && $limit) { if (!isset($areas[$this->_name]) && !in_array($this->_name, $areas)) { return array(); } } // Do we have a time period? if (!is_object($period)) { return array(); } $database = App::get('db'); include_once PATH_CORE . DS . 'components' . DS . 'com_wiki' . DS . 'tables' . DS . 'page.php'; // Instantiate some needed objects $wp = new \Components\Wiki\Tables\Page($database); // Build query $filters = array(); $filters['startdate'] = $period->cStartDate; $filters['enddate'] = $period->cEndDate; $filters['sortby'] = 'date'; $filters['authorized'] = false; if (!User::isGuest()) { $filters['authorized'] = true; } if (count($tagids) > 0) { $filters['tags'] = $tagids; } if (!$limit) { // Get a count $filters['select'] = 'count'; $database->setQuery($wp->buildPluginQuery($filters)); return $database->loadResult(); } else { // Get results $filters['select'] = 'records'; $filters['limit'] = $limit; $filters['limitstart'] = $limitstart; $database->setQuery($wp->buildPluginQuery($filters)); $rows = $database->loadObjectList(); if ($rows) { foreach ($rows as $key => $row) { if ($row->area != '' && $row->category != '') { $rows[$key]->href = Route::url('index.php?option=com_groups&scope=' . $row->category . '&pagename=' . $row->alias); } else { $rows[$key]->href = Route::url('index.php?option=com_wiki&scope=' . $row->category . '&pagename=' . $row->alias); } $rows[$key]->text = strip_tags($rows[$key]->itext); if ($row->title == '') { $rows[$key]->title = $rows[$key]->alias; } } } return $rows; } }
public function onAfterInitialise() { // No remember me for admin if (!App::isSite()) { return; } if (User::isGuest()) { $hash = App::hash('JLOGIN_REMEMBER'); if ($str = Request::getString($hash, '', 'cookie', 1 | 2)) { $credentials = array(); $goodCookie = true; $filter = JFilterInput::getInstance(); // Create the encryption key, apply extra hardening using the user agent string. // Since we're decoding, no UA validity check is required. $privateKey = App::hash(@$_SERVER['HTTP_USER_AGENT']); $crypt = new \Hubzero\Encryption\Encrypter(new \Hubzero\Encryption\Cipher\Simple(), new \Hubzero\Encryption\Key('simple', $privateKey, $privateKey)); try { $str = $crypt->decrypt($str); if (!is_string($str)) { throw new Exception('Decoded cookie is not a string.'); } $cookieData = json_decode($str); if (null === $cookieData) { throw new Exception('JSON could not be docoded.'); } if (!is_object($cookieData)) { throw new Exception('Decoded JSON is not an object.'); } // json_decoded cookie could be any object structure, so make sure the // credentials are well structured and only have user and password. if (isset($cookieData->username) && is_string($cookieData->username)) { $credentials['username'] = $filter->clean($cookieData->username, 'username'); } else { throw new Exception('Malformed username.'); } if (isset($cookieData->password) && is_string($cookieData->password)) { $credentials['password'] = $filter->clean($cookieData->password, 'string'); } else { throw new Exception('Malformed password.'); } // We're only doing this for the site app, so we explicitly set the action here $return = App::get('auth')->login($credentials, array('silent' => true, 'action' => 'core.login.site')); if (!$return) { throw new Exception('Log-in failed.'); } } catch (Exception $e) { $cookie_domain = Config::get('cookie_domain', ''); $cookie_path = Config::get('cookie_path', '/'); // Clear the remember me cookie setcookie(App::hash('JLOGIN_REMEMBER'), false, time() - 86400, $cookie_path, $cookie_domain); Log::warning('A remember me cookie was unset for the following reason: ' . $e->getMessage()); } } } }
/** * Constructor * * @return void */ public function __construct() { if (\User::isGuest()) { $this->groups = array(); return; } $this->uid = \User::get('id'); if (\User::get('usertype') == 'Super Administrator') { $this->super_admin = true; } }
/** * Constructor * * @param object &$subject Event observer * @param array $config Optional config values * @return void */ public function plgSupportCaptcha(&$subject, $config) { parent::__construct($subject, $config); $this->loadLanguage(); if (!User::isGuest()) { $profile = \Hubzero\User\Profile::getInstance(User::get('id')); if ($profile->get('emailConfirmed') == 1 || $profile->get('emailConfirmed') == 3) { $this->_verified = true; } } }
/** * Determines task being called and attempts to execute it * * @return void */ public function execute() { if (User::isGuest()) { App::abort(403, Lang::txt('You must be logged in to access.')); return; } // Load the com_resources component config $rconfig = Component::params('com_resources'); $this->rconfig = $rconfig; parent::execute(); }
/** * Execute function * * @return void */ public function execute() { // Force login if user isn't already if (User::isGuest()) { $task = isset($this->_task) && !empty($this->_task) ? '&task=' . $this->_task : ''; // Set the redirect App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . $task))), Lang::txt('COM_TIME_ERROR_LOGIN_REQUIRED'), 'warning'); return; } // Set up permissions model $this->permissions = new Permissions($this->_option); // Execute the task parent::execute(); }
/** * Retrieve records for items tagged with specific tags * * @param array $tags Tags to match records against * @param mixed $limit SQL record limit * @param integer $limitstart SQL record limit start * @param string $sort The field to sort records by * @param mixed $areas An array or string of areas that should retrieve records * @return mixed Returns integer when counting records, array when retrieving records */ public function onTagView($tags, $limit = 0, $limitstart = 0, $sort = '', $areas = null) { $response = array('name' => $this->_name, 'title' => Lang::txt('PLG_TAGS_BLOGS'), 'total' => 0, 'results' => null, 'sql' => ''); if (empty($tags)) { return $response; } $database = App::get('db'); $ids = array(); foreach ($tags as $tag) { $ids[] = $tag->get('id'); } $ids = implode(',', $ids); $now = Date::toSql(); // Build the query $e_count = "SELECT COUNT(f.id) FROM (SELECT e.id, COUNT(DISTINCT t.tagid) AS uniques"; $e_fields = "SELECT e.id, e.title, e.alias, NULL AS itext, e.content AS ftext, e.state, e.created, e.created_by,\n\t\t\t\t\tNULL AS modified, e.publish_up, e.publish_down, CONCAT('index.php?option=com_blog&task=view&id=', e.id) AS href,\n\t\t\t\t\t'blogs' AS section, COUNT(DISTINCT t.tagid) AS uniques, e.params, e.scope AS rcount, u.name AS data1,\n\t\t\t\t\te.scope_id AS data2, NULL AS data3 "; $e_from = " FROM #__blog_entries AS e, #__tags_object AS t, #__users AS u"; $e_where = " WHERE e.created_by=u.id AND t.objectid=e.id AND t.tbl='blog' AND t.tagid IN ({$ids})"; if (User::isGuest()) { $e_where .= " AND e.state=1"; } else { $e_where .= " AND e.state>0"; } $e_where .= " AND (e.publish_up = '0000-00-00 00:00:00' OR e.publish_up <= " . $database->quote($now) . ") "; $e_where .= " AND (e.publish_down = '0000-00-00 00:00:00' OR e.publish_down >= " . $database->quote($now) . ") "; $e_where .= " GROUP BY e.id HAVING uniques=" . count($tags); $order_by = " ORDER BY "; switch ($sort) { case 'title': $order_by .= 'title ASC, publish_up'; break; case 'id': $order_by .= "id DESC"; break; case 'date': default: $order_by .= 'publish_up DESC, title'; break; } $order_by .= $limit != 'all' ? " LIMIT {$limitstart},{$limit}" : ""; $database->setQuery($e_count . $e_from . $e_where . ") AS f"); $response['total'] = $database->loadResult(); if ($areas && $areas == $response['name']) { $database->setQuery($e_fields . $e_from . $e_where . $order_by); $response['results'] = $database->loadObjectList(); } else { $response['sql'] = $e_fields . $e_from . $e_where; } return $response; }
/** * Return data on a course view (this will be some form of HTML) * * @param object $course Current course * @param string $active Current active area * @return array */ public function onCourseView($course, $active = null) { // Check that there are any offerings to show if ($course->offerings(array('state' => 1, 'sort_Dir' => 'ASC'), true)->total() <= 0) { return; } // Can this plugin respond, based on the current access settings? $respond = false; switch ($this->params->get('plugin_access', 'anyone')) { case 'managers': $memberships = $course->offering()->membership(); if (count($memberships) > 0) { foreach ($memberships as $membership) { if (!$membership->get('student')) { $respond = true; break; } } } break; case 'members': if (count($course->offering()->membership()) > 0) { $respond = true; } break; case 'registered': if (!User::isGuest()) { $respond = true; } break; case 'anyone': default: $respond = true; break; } if (!$respond) { return; } // Prepare response $response = with(new \Hubzero\Base\Object())->set('name', $this->_name)->set('title', Lang::txt('PLG_COURSES_' . strtoupper($this->_name))); // Check if our area is in the array of areas we want to return results for if ($response->get('name') == $active) { $view = $this->view('default', 'overview'); $view->set('option', Request::getCmd('option', 'com_courses'))->set('controller', Request::getWord('controller', 'course'))->set('course', $course)->set('name', $this->_name); $response->set('html', $view->loadTemplate()); } // Return the output return $response; }
/** * Determines task being called and attempts to execute it * * @return void */ public function execute() { $this->registerTask('start', 'display'); // Incoming $defaultSection = $this->_task == 'edit' ? 'info' : ''; $this->section = Request::getVar('active', $defaultSection); $this->group = NULL; // Login required if (User::isGuest()) { $this->_msg = $this->_task == 'edit' || !$this->_task ? Lang::txt('COM_PROJECTS_LOGIN_PRIVATE_PROJECT_AREA') : Lang::txt('COM_PROJECTS_LOGIN_SETUP'); $this->_login(); return; } parent::execute(); }
/** * Default component view * * @return void */ public function displayTask() { if (User::isGuest()) { $rtrn = Request::getVar('REQUEST_URI', Route::url('index.php?option=' . $this->_option . '&task=' . $this->_task), 'server'); App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($rtrn)), Lang::txt('COM_FEEDAGGREGATOR_LOGIN_NOTICE'), 'warning'); } $authlevel = User::getAuthorisedViewLevels(); $access_level = 3; //author_level if (!in_array($access_level, $authlevel)) { App::redirect(Route::url('index.php?option=com_feedaggregator'), Lang::txt('COM_FEEDAGGREGATOR_NOT_AUTH'), 'warning'); } $feeds = Feed::all()->rows(); $this->view->set('title', Lang::txt('COM_FEEDAGGREGATOR'))->set('feeds', $feeds)->display(); }
/** * Hook for after parsing route * * @return void */ public function onAfterRoute() { if (App::isSite() && !User::isGuest()) { $exceptions = ['com_users.logout', 'com_support.tickets.save.index', 'com_members.media.download.profiles']; $current = Request::getWord('option', ''); $current .= ($controller = Request::getWord('controller', false)) ? '.' . $controller : ''; $current .= ($task = Request::getWord('task', false)) ? '.' . $task : ''; $current .= ($view = Request::getWord('view', false)) ? '.' . $view : ''; // If guest, proceed as normal and they'll land on the login page if (!in_array($current, $exceptions) && User::getInstance()->reputation->isJailed()) { Request::setVar('option', 'com_users'); Request::setVar('view', 'spamjail'); } } }
/** * Hook for after parsing route * * @return void */ public function onAfterRoute() { if (App::isSite() && !User::isGuest()) { $exceptions = ['com_users.logout', 'com_users.userlogout', 'com_support.tickets.save.index', 'com_support.tickets.new.index', 'com_members.media.download.profiles', 'com_members.register.unconfirmed.profiles', 'com_members.register.change.profiles', 'com_members.register.resend.profiles', 'com_members.register.resend', 'com_members.register.confirm.profiles', 'com_members.register.confirm', 'com_members.save.profiles', 'com_members.profiles.save', 'com_members.profiles.save.profiles', 'com_members.changepassword']; $current = Request::getWord('option', ''); $current .= ($controller = Request::getWord('controller', false)) ? '.' . $controller : ''; $current .= ($task = Request::getWord('task', false)) ? '.' . $task : ''; $current .= ($view = Request::getWord('view', false)) ? '.' . $view : ''; if (User::get('id') && User::get('activation') != 1 && User::get('activation') != 3 && !in_array($current, $exceptions)) { Request::setVar('option', 'com_members'); Request::setVar('controller', 'register'); Request::setVar('task', 'unconfirmed'); $this->event->stop(); } } }
/** * Hook for after parsing route * * @return void */ public function onAfterRoute() { if (App::isSite() && !User::isGuest()) { $exceptions = ['com_users.logout', 'com_users.userlogout', 'com_support.tickets.save.index', 'com_support.tickets.new.index', 'com_members.media.download.profiles']; $current = Request::getWord('option', ''); $current .= ($controller = Request::getWord('controller', false)) ? '.' . $controller : ''; $current .= ($task = Request::getWord('task', false)) ? '.' . $task : ''; $current .= ($view = Request::getWord('view', false)) ? '.' . $view : ''; // If guest, proceed as normal and they'll land on the login page if (!in_array($current, $exceptions) && !User::get('approved')) { Request::setVar('option', 'com_users'); Request::setVar('view', 'unapproved'); $this->event->stop(); } } }
/** * Execute a task * * @return void */ public function execute() { // Get the task $this->_task = Request::getVar('task', ''); if (empty($this->_task)) { $this->_task = 'checkout'; $this->registerTask('__default', $this->_task); } $this->user = User::getRoot(); // Check if they're logged in if (User::isGuest()) { $this->login('Please login to continue'); return; } parent::execute(); }
/** * Retrieve records for items tagged with specific tags * * @param array $tags Tags to match records against * @param mixed $limit SQL record limit * @param integer $limitstart SQL record limit start * @param string $sort The field to sort records by * @param mixed $areas An array or string of areas that should retrieve records * @return mixed Returns integer when counting records, array when retrieving records */ public function onTagView($tags, $limit = 0, $limitstart = 0, $sort = '', $areas = null) { $response = array('name' => $this->_name, 'title' => Lang::txt('PLG_TAGS_COLLECTIONS'), 'total' => 0, 'results' => null, 'sql' => ''); if (empty($tags)) { return $response; } $database = \App::get('db'); $ids = array(); foreach ($tags as $tag) { $ids[] = $tag->get('id'); } $ids = implode(',', $ids); // Build the query $e_count = "SELECT COUNT(f.id) FROM (SELECT p.id, COUNT(DISTINCT t.tagid) AS uniques"; $e_fields = "SELECT p.id, i.title, c.alias, NULL AS itext,\n\t\t\t\t\tCASE WHEN (p.description!='' AND p.description IS NOT NULL) THEN p.description ELSE i.description END AS ftext,\n\t\t\t\t\ti.state,\n\t\t\t\t\tp.created,\n\t\t\t\t\tp.created_by,\n\t\t\t\t\tNULL AS modified,\n\t\t\t\t\tp.created AS publish_up,\n\t\t\t\t\tNULL AS publish_down,\n\t\t\t\t\tconcat('index.php?option=com_collections&controller=posts&post=', p.id) AS href,\n\t\t\t\t\t'collections' AS section,\n\t\t\t\t\tCOUNT(DISTINCT t.tagid) AS uniques,\n\t\t\t\t\tc.object_type AS params,\n\t\t\t\t\tc.object_id AS rcount,\n\t\t\t\t\ti.type AS data1,\n\t\t\t\t\ti.object_id AS data2,\n\t\t\t\t\tNULL AS data3 "; $e_from = " FROM #__collections_posts AS p\n\t\t\tINNER JOIN #__collections AS c ON c.id=p.collection_id\n\t\t\tINNER JOIN #__collections_items AS i ON p.item_id=i.id\n\t\t\tINNER JOIN #__tags_object AS t"; $e_where = " WHERE i.state=1 AND c.state=1 AND t.objectid=p.item_id AND t.tbl='bulletinboard' AND t.tagid IN ({$ids})"; if (User::isGuest()) { $e_where .= " AND i.access=0 AND c.access=0"; } else { $e_where .= " AND i.access IN (0, 1) AND c.access IN (0, 1)"; } $e_where .= " GROUP BY p.id HAVING uniques=" . count($tags); $order_by = " ORDER BY "; switch ($sort) { case 'title': $order_by .= 'i.title ASC'; break; case 'id': $order_by .= "p.id DESC"; break; case 'date': default: $order_by .= 'p.created'; break; } $order_by .= $limit != 'all' ? " LIMIT {$limitstart},{$limit}" : ""; $database->setQuery($e_count . $e_from . $e_where . ") AS f"); $response['total'] = $database->loadResult(); if ($areas && $areas == $response['name']) { $database->setQuery($e_fields . $e_from . $e_where . $order_by); $response['results'] = $database->loadObjectList(); } else { $response['sql'] = $e_fields . $e_from . $e_where; } return $response; }