/** * Setting the toolbar */ protected function addToolBar() { $canDo = ZhYandexMapHelper::getMarkerActions(); JToolBarHelper::title(JText::_('COM_ZHYANDEXMAP_MAPMARKER_MANAGER'), 'mapmarker'); if ($canDo->get('core.create')) { JToolBarHelper::addNew('mapmarker.add', 'JTOOLBAR_NEW'); } if ($canDo->get('core.edit') || $canDo->get('core.edit.own')) { JToolBarHelper::editList('mapmarker.edit', 'JTOOLBAR_EDIT'); } if ($canDo->get('core.edit.state')) { JToolBarHelper::divider(); JToolBarHelper::publish('mapmarkers.publish', 'JTOOLBAR_PUBLISH', true); JToolBarHelper::unpublish('mapmarkers.unpublish', 'JTOOLBAR_UNPUBLISH', true); JToolBarHelper::divider(); } if ($canDo->get('core.delete')) { JToolBarHelper::deleteList('', 'mapmarkers.delete', 'JTOOLBAR_DELETE'); } if ($canDo->get('core.admin')) { JToolBarHelper::divider(); JToolBarHelper::preferences('com_zhyandexmap'); } JHtmlSidebar::setAction('index.php?option=com_zhyandexmap'); JHtmlSidebar::addFilter(JText::_('COM_ZHYANDEXMAP_MAPMARKER_FILTER_MAP'), 'filter_mapid', JHtml::_('select.options', $this->mapList, 'value', 'text', $this->state->get('filter.mapid'))); JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_published', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), 'value', 'text', $this->state->get('filter.published'), true)); JHtmlSidebar::addFilter(JText::_('COM_ZHYANDEXMAP_MAP_USER_IMAGESELECT'), 'filter_icontype', JHtml::_('select.options', $this->iconList, 'value', 'text', $this->state->get('filter.icontype'))); JHtmlSidebar::addFilter(JText::_('COM_ZHYANDEXMAP_MAPMARKER_FILTER_PLACEMARK_GROUP'), 'filter_markergroup', JHtml::_('select.options', $this->groupList, 'value', 'text', $this->state->get('filter.markergroup'))); JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_CATEGORY'), 'filter_category_id', JHtml::_('select.options', JHtml::_('category.options', 'com_zhyandexmap'), 'value', 'text', $this->state->get('filter.category_id'))); JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_ACCESS'), 'filter_access', JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text', $this->state->get('filter.access'))); JHtmlSidebar::addFilter(JText::_('COM_ZHYANDEXMAP_MAPMARKER_FILTER_USER'), 'filter_createdbyuser', JHtml::_('select.options', $this->userList, 'value', 'text', $this->state->get('filter.createdbyuser'))); $this->sidebar = JHtmlSidebar::render(); }
/** * Setting the toolbar */ protected function addToolBar() { JRequest::setVar('hidemainmenu', true); $user = JFactory::getUser(); $userId = $user->id; $isNew = $this->item->id == 0; $canDo = ZhYandexMapHelper::getMarkerActions($this->item->id); JToolBarHelper::title($isNew ? JText::_('COM_ZHYANDEXMAP_MAPMARKER_NEW') : JText::_('COM_ZHYANDEXMAP_MAPMARKER_EDIT'), 'mapmarker'); // Built the actions for new and existing records. if ($isNew) { // For new records, check the create permission. if ($canDo->get('core.create')) { JToolBarHelper::apply('mapmarker.apply', 'JTOOLBAR_APPLY'); JToolBarHelper::save('mapmarker.save', 'JTOOLBAR_SAVE'); JToolBarHelper::custom('mapmarker.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); } JToolBarHelper::cancel('mapmarker.cancel', 'JTOOLBAR_CANCEL'); } else { if ($canDo->get('core.edit') || $canDo->get('core.edit.own') && $this->item->createdbyuser == $userId) { // We can save the new record JToolBarHelper::apply('mapmarker.apply', 'JTOOLBAR_APPLY'); JToolBarHelper::save('mapmarker.save', 'JTOOLBAR_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::custom('mapmarker.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); } } if ($canDo->get('core.create')) { JToolBarHelper::custom('mapmarker.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); } JToolBarHelper::cancel('mapmarker.cancel', 'JTOOLBAR_CLOSE'); } }
/** * Method override to check if you can edit an existing record. * * @param array $data An array of input data. * @param string $key The name of the key for the primary key. * * @return boolean * * @since 1.6 */ protected function allowEdit($data = array(), $key = 'id') { $recordId = (int) isset($data[$key]) ? $data[$key] : 0; $user = JFactory::getUser(); $userId = $user->get('id'); $canDo = ZhYandexMapHelper::getMarkerActions($recordId); $canEdit = $canDo->get('core.edit'); $isEnabledEditOwn = $canDo->get('core.edit.own'); if ($canEdit || $canEditOwn) { } // Check general edit permission first. if ($canEdit) { return true; } // Fallback on edit.own. // First test if the permission is available. if ($isEnabledEditOwn) { // Now test the owner is the user. $ownerId = (int) isset($data['createdbyuser']) ? $data['createdbyuser'] : 0; if (empty($ownerId) && $recordId) { // Need to do a lookup from the model. $record = $this->getModel()->getItem($recordId); if (empty($record)) { return false; } $ownerId = $record->createdbyuser; } // If the owner matches 'me' then do the test. if ($ownerId == $userId) { return true; } } // Since there is no asset tracking, revert to the component permissions. return parent::allowEdit($data, $key); }