- md5
- 3beea7089c987591b513a61385cae27c
- sha1
- 47d09bcd1e0eb5078014958f31c64c860bdecba9
- sha256
- 93c60cb4741788376141bd03ba36d6652fdf9b75a163dbfdcc79293a058c7e60
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
<?php
/**
* @package Joomla.Administrator
* @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\Administrator\View\Level;
\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;
/**
* View to edit a user view level.
*
* @since 1.6
*/
class HtmlView extends BaseHtmlView
{
/**
* The \JForm object
*
* @var \JForm
*/
protected $form;
/**
* The item data.
*
* @var object
* @since 1.6
*/
protected $item;
/**
* The model state.
*
* @var CMSObject
* @since 1.6
*/
protected $state;
/**
* Display the view
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return void
*/
public function display($tpl = null)
{
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->state = $this->get('State');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new GenericDataException(implode("\n", $errors), 500);
}
$this->addToolbar();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.6
* @throws \Exception
*/
protected function addToolbar()
{
Factory::getApplication()->input->set('hidemainmenu', true);
$isNew = ($this->item->id == 0);
$canDo = ContentHelper::getActions('com_users');
ToolbarHelper::title(Text::_($isNew ? 'COM_USERS_VIEW_NEW_LEVEL_TITLE' : 'COM_USERS_VIEW_EDIT_LEVEL_TITLE'), 'user-lock levels-add');
$toolbarButtons = [];
if ($canDo->get('core.edit') || $canDo->get('core.create'))
{
ToolbarHelper::apply('level.apply');
$toolbarButtons[] = ['save', 'level.save'];
}
if ($canDo->get('core.create'))
{
$toolbarButtons[] = ['save2new', 'level.save2new'];
}
// If an existing item, can save to a copy.
if (!$isNew && $canDo->get('core.create'))
{
$toolbarButtons[] = ['save2copy', 'level.save2copy'];
}
ToolbarHelper::saveGroup(
$toolbarButtons,
'btn-success'
);
if (empty($this->item->id))
{
ToolbarHelper::cancel('level.cancel');
}
else
{
ToolbarHelper::cancel('level.cancel', 'JTOOLBAR_CLOSE');
}
ToolbarHelper::divider();
ToolbarHelper::help('JHELP_USERS_ACCESS_LEVELS_EDIT');
}
}
The same content is in 13 releases, Joomla 4.0.0-beta6 to 4.0.3. See them all, or every version of this file.