Example #1
0
 /**
  * Add the page title and toolbar.
  */
 protected function addToolbar()
 {
     $canDo = JfoobarsHelper::getActions($this->state->get('filter.category_id'));
     $user = JFactory::getUser();
     JToolBarHelper::title(JText::_('COM_JFOOBARS_JFOOBARS_TITLE'), 'jfoobar.png');
     if ($canDo->get('core.create') || count($user->getAuthorisedCategories('com_jfoobars', 'core.create')) > 0) {
         JToolBarHelper::addNew('jfoobar.add');
     }
     if ($canDo->get('core.edit') || $canDo->get('core.edit.own')) {
         JToolBarHelper::editList('jfoobar.edit');
     }
     if ($canDo->get('core.edit.state')) {
         JToolBarHelper::divider();
         JToolBarHelper::publish('jfoobars.publish', 'JTOOLBAR_PUBLISH', true);
         JToolBarHelper::unpublish('jfoobars.unpublish', 'JTOOLBAR_UNPUBLISH', true);
         JToolBarHelper::divider();
         JToolBarHelper::checkin('jfoobars.checkin');
     }
     if ($this->state->get('filter.published') == -2 && $canDo->get('core.delete')) {
         JToolBarHelper::deleteList('', 'jfoobars.delete', 'JTOOLBAR_EMPTY_TRASH');
         JToolBarHelper::divider();
     } else {
         if ($canDo->get('core.edit.state')) {
             JToolBarHelper::trash('jfoobars.trash');
             JToolBarHelper::divider();
         }
     }
     if ($canDo->get('core.admin')) {
         JToolBarHelper::preferences('com_jfoobars');
         JToolBarHelper::divider();
     }
 }
Example #2
0
 /**
  * Method to display a view.
  *
  * @param	boolean			$cachable	If true, the view output will be cached
  * @param	array			$urlparams	An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  *
  * @return	JController		This object to support chaining.
  * @since	1.5
  */
 public function display($cachable = false, $urlparams = false)
 {
     require_once JPATH_COMPONENT . '/helpers/jfoobars.php';
     JfoobarsHelper::addSubmenu(JRequest::getCmd('view', 'jfoobars'));
     $view = JRequest::getCmd('view', 'jfoobars');
     JRequest::setVar('view', $view);
     parent::display();
     return $this;
 }
Example #3
0
 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     JRequest::setVar('hidemainmenu', true);
     $user = JFactory::getUser();
     $userId = $user->get('id');
     $isNew = $this->item->id == 0;
     $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $userId);
     $canDo = JfoobarsHelper::getActions($this->state->get('filter.category_id'), $this->item->id);
     JToolBarHelper::title(JText::_('COM_JFOOBARS_PAGE_' . ($checkedOut ? 'VIEW_JFOOBAR' : ($isNew ? 'ADD_JFOOBAR' : 'EDIT_JFOOBAR'))), 'jfoobar-add.png');
     // Built the actions for new and existing records.
     // For new records, check the create permission.
     if ($isNew && count($user->getAuthorisedCategories('com_jfoobars', 'core.create')) > 0) {
         JToolBarHelper::apply('jfoobar.apply');
         JToolBarHelper::save('jfoobar.save');
         JToolBarHelper::save2new('jfoobar.save2new');
         JToolBarHelper::cancel('jfoobar.cancel');
     } else {
         // Can't save the record if it's checked out.
         if (!$checkedOut) {
             // Since it's an existing record, check the edit permission, or fall back to edit own if the owner.
             if ($canDo->get('core.edit') || $canDo->get('core.edit.own') && $this->item->created_by == $userId) {
                 JToolBarHelper::apply('jfoobar.apply');
                 JToolBarHelper::save('jfoobar.save');
                 // We can save this record, but check the create permission to see if we can return to make a new one.
                 if ($canDo->get('core.create')) {
                     JToolBarHelper::save2new('jfoobar.save2new');
                 }
             }
         }
         // If checked out, we can still save
         if ($canDo->get('core.create')) {
             JToolBarHelper::save2copy('jfoobar.save2copy');
         }
         JToolBarHelper::cancel('jfoobar.cancel', 'JTOOLBAR_CLOSE');
     }
 }