Source for file view.html.php

Documentation is available at view.html.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_users
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  8.  */
  9.  
  10. defined('_JEXEC'or die;
  11.  
  12. /**
  13.  * User note edit view
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_users
  17.  * @since       2.5
  18.  */
  19. class UsersViewNote extends JViewLegacy
  20. {
  21.     /**
  22.      * The edit form.
  23.      *
  24.      * @var    JForm 
  25.      * @since  2.5
  26.      */
  27.     protected $form;
  28.  
  29.     /**
  30.      * The item data.
  31.      *
  32.      * @var    object 
  33.      * @since  2.5
  34.      */
  35.     protected $item;
  36.  
  37.     /**
  38.      * The model state.
  39.      *
  40.      * @var    JObject 
  41.      * @since  2.5
  42.      */
  43.     protected $state;
  44.  
  45.     /**
  46.      * Override the display method for the view.
  47.      *
  48.      * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  49.      *
  50.      * @return  mixed  A string if successful, otherwise a JError object.
  51.      *
  52.      * @since   2.5
  53.      */
  54.     public function display($tpl null)
  55.     {
  56.         // Initialise view variables.
  57.         $this->state = $this->get('State');
  58.         $this->item = $this->get('Item');
  59.         $this->form = $this->get('Form');
  60.  
  61.         // Check for errors.
  62.         if (count($errors $this->get('Errors')))
  63.         {
  64.             throw new Exception(implode("\n"$errors)500);
  65.         }
  66.  
  67.         // Get the component HTML helpers
  68.         JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
  69.  
  70.         parent::display($tpl);
  71.         $this->addToolbar();
  72.     }
  73.  
  74.     /**
  75.      * Display the toolbar.
  76.      *
  77.      * @return  void 
  78.      *
  79.      * @since   2.5
  80.      */
  81.     protected function addToolbar()
  82.     {
  83.         $input JFactory::getApplication()->input;
  84.         $input->set('hidemainmenu'1);
  85.  
  86.         $user        JFactory::getUser();
  87.         $isNew        ($this->item->id == 0);
  88.         $checkedOut    !($this->item->checked_out == || $this->item->checked_out == $user->get('id'));
  89.         $canDo        UsersHelper::getActions($this->state->get('filter.category_id')$this->item->id);
  90.  
  91.         JToolbarHelper::title(JText::_('COM_USERS_NOTES')'users user');
  92.  
  93.         // If not checked out, can save the item.
  94.         if (!$checkedOut && ($canDo->get('core.edit'|| (count($user->getAuthorisedCategories('com_users''core.create')))))
  95.         {
  96.             JToolbarHelper::apply('note.apply');
  97.             JToolbarHelper::save('note.save');
  98.         }
  99.  
  100.         if (!$checkedOut && (count($user->getAuthorisedCategories('com_users''core.create'))))
  101.         {
  102.             JToolbarHelper::save2new('note.save2new');
  103.         }
  104.  
  105.         // If an existing item, can save to a copy.
  106.         if (!$isNew && (count($user->getAuthorisedCategories('com_users''core.create')) 0))
  107.         {
  108.             JToolbarHelper::save2copy('note.save2copy');
  109.         }
  110.         if (empty($this->item->id))
  111.         {
  112.             JToolbarHelper::cancel('note.cancel');
  113.         }
  114.         else
  115.         {
  116.             if ($this->state->params->get('save_history'0&& $user->authorise('core.edit'))
  117.             {
  118.                 JToolbarHelper::versions('com_users.note'$this->item->id);
  119.             }
  120.  
  121.             JToolbarHelper::cancel('note.cancel''JTOOLBAR_CLOSE');
  122.         }
  123.  
  124.         JToolbarHelper::divider();
  125.         JToolbarHelper::help('JHELP_USERS_USER_NOTES_EDIT');
  126.     }
  127. }

Documentation generated on Tue, 19 Nov 2013 15:18:10 +0100 by phpDocumentor 1.4.3