- md5
- cc7075e14083d5393eab47458f5cbd41
- sha1
- 0fcab1e00da45bbd16f92d33035c42d07cb53e03
- sha256
- e264802f11e9d3af850903761bf618a3bab7f1ceb67ddb4202e39f83828ef85e
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
<?php
/**
* @package Joomla.Site
* @subpackage com_users
*
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Users\Site\View\Profile;
\defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\GenericDataException;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Object\CMSObject;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Router\Route;
use Joomla\CMS\User\User;
use Joomla\Component\Users\Administrator\Helper\UsersHelper;
use Joomla\Database\DatabaseDriver;
/**
* Profile view class for Users.
*
* @since 1.6
*/
class HtmlView extends BaseHtmlView
{
/**
* Profile form data for the user
*
* @var User
*/
protected $data;
/**
* The Form object
*
* @var \Joomla\CMS\Form\Form
*/
protected $form;
/**
* The page parameters
*
* @var \Joomla\Registry\Registry|null
*/
protected $params;
/**
* The model state
*
* @var CMSObject
*/
protected $state;
/**
* An instance of DatabaseDriver.
*
* @var DatabaseDriver
* @since 3.6.3
*/
protected $db;
/**
* Configuration forms for all two-factor authentication methods.
*
* @var array
* @since 4.0.0
*/
protected $twofactorform;
/**
* List of two factor authentication methods available.
*
* @var array
* @since 4.0.0
*/
protected $twofactormethods;
/**
* One time password (OTP) – a.k.a. two factor authentication – configuration for the user.
*
* @var \stdClass
* @since 4.0.0
*/
protected $otpConfig;
/**
* The page class suffix
*
* @var string
* @since 4.0.0
*/
protected $pageclass_sfx = '';
/**
* Execute and display a template script.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return void|boolean
*
* @since 1.6
* @throws \Exception
*/
public function display($tpl = null)
{
$user = Factory::getUser();
// Get the view data.
$this->data = $this->get('Data');
$this->form = $this->getModel()->getForm(new CMSObject(array('id' => $user->id)));
$this->state = $this->get('State');
$this->params = $this->state->get('params');
$this->twofactorform = $this->get('Twofactorform');
$this->twofactormethods = UsersHelper::getTwoFactorMethods();
$this->otpConfig = $this->get('OtpConfig');
$this->db = Factory::getDbo();
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new GenericDataException(implode("\n", $errors), 500);
}
// View also takes responsibility for checking if the user logged in with remember me.
$cookieLogin = $user->get('cookieLogin');
if (!empty($cookieLogin))
{
// If so, the user must login to edit the password and other data.
// What should happen here? Should we force a logout which destroys the cookies?
$app = Factory::getApplication();
$app->enqueueMessage(Text::_('JGLOBAL_REMEMBER_MUST_LOGIN'), 'message');
$app->redirect(Route::_('index.php?option=com_users&view=login', false));
return false;
}
// Check if a user was found.
if (!$this->data->id)
{
throw new \Exception(Text::_('JERROR_USERS_PROFILE_NOT_FOUND'), 404);
}
PluginHelper::importPlugin('content');
$this->data->text = '';
Factory::getApplication()->triggerEvent('onContentPrepare', array ('com_users.user', &$this->data, &$this->data->params, 0));
unset($this->data->text);
// Check for layout from menu item.
$query = Factory::getApplication()->getMenu()->getActive()->query;
if (isset($query['layout']) && isset($query['option']) && $query['option'] === 'com_users'
&& isset($query['view']) && $query['view'] === 'profile')
{
$this->setLayout($query['layout']);
}
// Escape strings for HTML output
$this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx', ''));
$this->prepareDocument();
parent::display($tpl);
}
/**
* Prepares the document
*
* @return void
*
* @since 1.6
* @throws \Exception
*/
protected function prepareDocument()
{
// Because the application sets a default page title,
// we need to get it from the menu item itself
$menu = Factory::getApplication()->getMenu()->getActive();
if ($menu)
{
$this->params->def('page_heading', $this->params->get('page_title', Factory::getUser()->name));
}
else
{
$this->params->def('page_heading', Text::_('COM_USERS_PROFILE'));
}
$this->setDocumentTitle($this->params->get('page_title', ''));
if ($this->params->get('menu-meta_description'))
{
$this->document->setDescription($this->params->get('menu-meta_description'));
}
if ($this->params->get('robots'))
{
$this->document->setMetaData('robots', $this->params->get('robots'));
}
}
}
The same content is in 22 releases, Joomla 4.0.6-rc1 to 4.2.0-alpha1. See them all, or every version of this file.