[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Administrator 5 * @subpackage com_users 6 * 7 * @copyright (C) 2011 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\Administrator\View\Note; 12 13 use Joomla\CMS\Component\ComponentHelper; 14 use Joomla\CMS\Factory; 15 use Joomla\CMS\Helper\ContentHelper; 16 use Joomla\CMS\Language\Text; 17 use Joomla\CMS\MVC\View\GenericDataException; 18 use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; 19 use Joomla\CMS\Object\CMSObject; 20 use Joomla\CMS\Toolbar\ToolbarHelper; 21 22 // phpcs:disable PSR1.Files.SideEffects 23 \defined('_JEXEC') or die; 24 // phpcs:enable PSR1.Files.SideEffects 25 26 /** 27 * User note edit view 28 * 29 * @since 2.5 30 */ 31 class HtmlView extends BaseHtmlView 32 { 33 /** 34 * The edit form. 35 * 36 * @var \Joomla\CMS\Form\Form 37 * 38 * @since 2.5 39 */ 40 protected $form; 41 42 /** 43 * The item data. 44 * 45 * @var object 46 * @since 2.5 47 */ 48 protected $item; 49 50 /** 51 * The model state. 52 * 53 * @var CMSObject 54 * @since 2.5 55 */ 56 protected $state; 57 58 /** 59 * Override the display method for the view. 60 * 61 * @param string $tpl The name of the template file to parse; automatically searches through the template paths. 62 * 63 * @return void 64 * 65 * @since 2.5 66 * @throws \Exception 67 */ 68 public function display($tpl = null) 69 { 70 // Initialise view variables. 71 $this->state = $this->get('State'); 72 $this->item = $this->get('Item'); 73 $this->form = $this->get('Form'); 74 75 // Check for errors. 76 if (count($errors = $this->get('Errors'))) { 77 throw new GenericDataException(implode("\n", $errors), 500); 78 } 79 80 parent::display($tpl); 81 $this->addToolbar(); 82 } 83 84 /** 85 * Display the toolbar. 86 * 87 * @return void 88 * 89 * @since 2.5 90 * @throws \Exception 91 */ 92 protected function addToolbar() 93 { 94 $input = Factory::getApplication()->input; 95 $input->set('hidemainmenu', 1); 96 97 $user = $this->getCurrentUser(); 98 $isNew = ($this->item->id == 0); 99 $checkedOut = !(is_null($this->item->checked_out) || $this->item->checked_out == $user->get('id')); 100 101 // Since we don't track these assets at the item level, use the category id. 102 $canDo = ContentHelper::getActions('com_users', 'category', $this->item->catid); 103 104 ToolbarHelper::title(Text::_('COM_USERS_NOTES'), 'users user'); 105 106 $toolbarButtons = []; 107 108 // If not checked out, can save the item. 109 if (!$checkedOut && ($canDo->get('core.edit') || count($user->getAuthorisedCategories('com_users', 'core.create')))) { 110 ToolbarHelper::apply('note.apply'); 111 $toolbarButtons[] = ['save', 'note.save']; 112 } 113 114 if (!$checkedOut && count($user->getAuthorisedCategories('com_users', 'core.create'))) { 115 $toolbarButtons[] = ['save2new', 'note.save2new']; 116 } 117 118 // If an existing item, can save to a copy. 119 if (!$isNew && (count($user->getAuthorisedCategories('com_users', 'core.create')) > 0)) { 120 $toolbarButtons[] = ['save2copy', 'note.save2copy']; 121 } 122 123 ToolbarHelper::saveGroup( 124 $toolbarButtons, 125 'btn-success' 126 ); 127 128 if (empty($this->item->id)) { 129 ToolbarHelper::cancel('note.cancel'); 130 } else { 131 ToolbarHelper::cancel('note.cancel', 'JTOOLBAR_CLOSE'); 132 133 if (ComponentHelper::isEnabled('com_contenthistory') && $this->state->params->get('save_history', 0) && $canDo->get('core.edit')) { 134 ToolbarHelper::versions('com_users.note', $this->item->id); 135 } 136 } 137 138 ToolbarHelper::divider(); 139 ToolbarHelper::help('User_Notes:_New_or_Edit'); 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 |