[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Site 5 * @subpackage com_users 6 * 7 * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 */ 10 11 namespace Joomla\Component\Users\Site\Controller; 12 13 use Joomla\CMS\Component\ComponentHelper; 14 use Joomla\CMS\MVC\Controller\BaseController; 15 use Joomla\CMS\Router\Route; 16 17 // phpcs:disable PSR1.Files.SideEffects 18 \defined('_JEXEC') or die; 19 // phpcs:enable PSR1.Files.SideEffects 20 21 /** 22 * Base controller class for Users. 23 * 24 * @since 1.5 25 */ 26 class DisplayController extends BaseController 27 { 28 /** 29 * Method to display a view. 30 * 31 * @param boolean $cachable If true, the view output will be cached 32 * @param array|boolean $urlparams An array of safe URL parameters and their variable types, 33 * for valid values see {@link \Joomla\CMS\Filter\InputFilter::clean()}. 34 * 35 * @return void 36 * 37 * @since 1.5 38 * @throws \Exception 39 */ 40 public function display($cachable = false, $urlparams = false) 41 { 42 // Get the document object. 43 $document = $this->app->getDocument(); 44 45 // Set the default view name and format from the Request. 46 $vName = $this->input->getCmd('view', 'login'); 47 $vFormat = $document->getType(); 48 $lName = $this->input->getCmd('layout', 'default'); 49 50 if ($view = $this->getView($vName, $vFormat)) { 51 // Do any specific processing by view. 52 switch ($vName) { 53 case 'registration': 54 // If the user is already logged in, redirect to the profile page. 55 $user = $this->app->getIdentity(); 56 57 if ($user->get('guest') != 1) { 58 // Redirect to profile page. 59 $this->setRedirect(Route::_('index.php?option=com_users&view=profile', false)); 60 61 return; 62 } 63 64 // Check if user registration is enabled 65 if (ComponentHelper::getParams('com_users')->get('allowUserRegistration') == 0) { 66 // Registration is disabled - Redirect to login page. 67 $this->setRedirect(Route::_('index.php?option=com_users&view=login', false)); 68 69 return; 70 } 71 72 // The user is a guest, load the registration model and show the registration page. 73 $model = $this->getModel('Registration'); 74 break; 75 76 // Handle view specific models. 77 case 'profile': 78 // If the user is a guest, redirect to the login page. 79 $user = $this->app->getIdentity(); 80 81 if ($user->get('guest') == 1) { 82 // Redirect to login page. 83 $this->setRedirect(Route::_('index.php?option=com_users&view=login', false)); 84 85 return; 86 } 87 88 $model = $this->getModel($vName); 89 break; 90 91 // Handle the default views. 92 case 'login': 93 $model = $this->getModel($vName); 94 break; 95 96 case 'remind': 97 case 'reset': 98 // If the user is already logged in, redirect to the profile page. 99 $user = $this->app->getIdentity(); 100 101 if ($user->get('guest') != 1) { 102 // Redirect to profile page. 103 $this->setRedirect(Route::_('index.php?option=com_users&view=profile', false)); 104 105 return; 106 } 107 108 $model = $this->getModel($vName); 109 break; 110 111 case 'captive': 112 case 'methods': 113 case 'method': 114 $controller = $this->factory->createController($vName, 'Site', [], $this->app, $this->input); 115 $task = $this->input->get('task', ''); 116 117 return $controller->execute($task); 118 119 break; 120 121 default: 122 $model = $this->getModel('Login'); 123 break; 124 } 125 126 // Make sure we don't send a referer 127 if (in_array($vName, array('remind', 'reset'))) { 128 $this->app->setHeader('Referrer-Policy', 'no-referrer', true); 129 } 130 131 // Push the model into the view (as default). 132 $view->setModel($model, true); 133 $view->setLayout($lName); 134 135 // Push document object into the view. 136 $view->document = $document; 137 138 $view->display(); 139 } 140 } 141 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |