- md5
- 7bc78a73ecbf7e830c2d622354d11c38
- sha1
- 614e952a4cfcccf0b55a1a217aec4ad4fa292746
- sha256
- 40906975602648cc50451ed58bb2ee36a21b1809da0c0e2dbc511888463a5400
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Users\Administrator\View\User;
\defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Helper\ContentHelper;
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\Toolbar\ToolbarHelper;
/**
* User view class.
*
* @since 1.5
*/
class HtmlView extends BaseHtmlView
{
/**
* The \JForm object
*
* @var \JForm
*/
protected $form;
/**
* The active item
*
* @var object
*/
protected $item;
/**
* Gets the available groups
*
* @var array
*/
protected $grouplist;
/**
* The groups this user is assigned to
*
* @var array
* @since 1.6
*/
protected $groups;
/**
* The model state
*
* @var CMSObject
*/
protected $state;
/**
* Configuration forms for all two-factor authentication methods
*
* @var array
* @since 3.2
*/
protected $tfaform;
/**
* Returns the one time password (OTP) – a.k.a. two factor authentication –
* configuration for the user.
*
* @var \stdClass
* @since 3.2
*/
protected $otpConfig;
/**
* Display the view
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return void
*
* @since 1.5
*/
public function display($tpl = null)
{
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->state = $this->get('State');
$this->tfaform = $this->get('Twofactorform');
$this->otpConfig = $this->get('otpConfig');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new GenericDataException(implode("\n", $errors), 500);
}
// Prevent user from modifying own group(s)
$user = Factory::getUser();
if ((int) $user->id != (int) $this->item->id || $user->authorise('core.admin'))
{
$this->grouplist = $this->get('Groups');
$this->groups = $this->get('AssignedGroups');
}
$this->form->setValue('password', null);
$this->form->setValue('password2', null);
parent::display($tpl);
$this->addToolbar();
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.6
* @throws \Exception
*/
protected function addToolbar()
{
Factory::getApplication()->input->set('hidemainmenu', true);
$user = Factory::getUser();
$canDo = ContentHelper::getActions('com_users');
$isNew = ($this->item->id == 0);
$isProfile = $this->item->id == $user->id;
ToolbarHelper::title(
Text::_(
$isNew ? 'COM_USERS_VIEW_NEW_USER_TITLE' : ($isProfile ? 'COM_USERS_VIEW_EDIT_PROFILE_TITLE' : 'COM_USERS_VIEW_EDIT_USER_TITLE')
),
'user ' . ($isNew ? 'user-add' : ($isProfile ? 'user-profile' : 'user-edit'))
);
$toolbarButtons = [];
if ($canDo->get('core.edit') || $canDo->get('core.create'))
{
ToolbarHelper::apply('user.apply');
$toolbarButtons[] = ['save', 'user.save'];
}
if ($canDo->get('core.create') && $canDo->get('core.manage'))
{
$toolbarButtons[] = ['save2new', 'user.save2new'];
}
ToolbarHelper::saveGroup(
$toolbarButtons,
'btn-success'
);
if (empty($this->item->id))
{
ToolbarHelper::cancel('user.cancel');
}
else
{
ToolbarHelper::cancel('user.cancel', 'JTOOLBAR_CLOSE');
}
ToolbarHelper::divider();
ToolbarHelper::help('JHELP_USERS_USER_MANAGER_EDIT');
}
}
The same content is in 5 releases, Joomla 4.0.0-beta to 4.0.0-beta5. See them all, or every version of this file.