/** * Gets a list of the actions that can be performed. * * @return JObject * * @since 1.6 * @todo Refactor to work with notes */ public static function getActions() { if (empty(self::$actions)) { $user = JFactory::getUser(); self::$actions = new JObject(); $actions = JAccess::getActions('com_englishconcept'); foreach ($actions as $action) { self::$actions->set($action->name, $user->authorise($action->name, 'com_englishconcept')); } } return self::$actions; }
public function addToolbar() { $canDo = EnglishConceptHelper::getActions(); JToolbarHelper::title(JText::_('COM_ENGLISHCONCEPT_TITLE')); JToolbarHelper::addNew('book.add'); JToolbarHelper::editList('book.edit'); JToolbarHelper::trash('book.trash'); JToolbarHelper::deleteList('Do you want to delete it?', 'book.delete'); if ($canDo->get('core.admin')) { //JToolbarHelper::preferences('com_englisconcept'); //JToolbarHelper::divider(); } }
/** * Display function */ public function display($tpl = null) { $this->state = $this->get('State'); $this->item = $this->get('Item'); $this->form = $this->get('Form'); if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $results = EnglishConceptHelper::getGrammarOption($this->item->id); if (count($results) > 0) { if (is_null($this->item->id)) { // Grammar new $options = ''; foreach ($results as $result) { $options .= '<option value="' . $result->lesson_id . '">' . $result->keystruct_no . '</option>'; } $this->options = $options; } else { // Usage already have reference if (!empty($results[0]->keystruct_ref)) { $ksArr = explode(',', $results[0]->keystruct_ref); $options = ''; foreach ($ksArr as $ks) { $options .= '<option selected="selected" value="' . $ks . '">KS.' . $ks . '</option>'; } } else { $results = EnglishConceptHelper::getGrammarOption(); $options = ''; foreach ($results as $result) { $options .= '<option value="' . $result->lesson_id . '">' . $result->keystruct_no . '</option>'; } } $this->options = $options; } } else { $this->options = '<option></option>'; } // Set the tool bar $this->addToolbar(); // Display the template parent::display($tpl); // Set the documents $this->setDocument(); }