/**
  * Method to get the field options for category
  * Use the extension attribute in a form to specify the.specific extension for
  * which categories should be displayed.
  * Use the show_root attribute to specify whether to show the global category root in the list.
  *
  * @return  array    The field option objects.
  *
  * @since   11.1
  */
 protected function getOptions()
 {
     $options = array();
     $extension = $this->element['extension'] ? (string) $this->element['extension'] : (string) $this->element['scope'];
     $published = (string) $this->element['published'];
     // Load the category options for a given extension.
     if (!empty($extension)) {
         // Filter over published state or not depending upon if it is present.
         if ($published) {
             $options = JHtml::_('category.options', $extension, array('filter.published' => explode(',', $published)));
         } else {
             $options = JHtml::_('category.options', $extension);
         }
         $componentParams = AgendaDirigentesHelper::getParams();
         $restrictionType = $this->getAttribute('restrictType', 'cargos');
         $restrictedList = $componentParams->get('restricted_list_' . $restrictionType, 0);
         if ($restrictedList == 1 && !AgendaDirigentesHelper::isSuperUser()) {
             $input = JFactory::getApplication()->input;
             $id = $input->getInt('id', 0);
             if (empty($id)) {
                 foreach ($options as $i => $option) {
                     $canCreate = AgendaDirigentesHelper::getGranularPermissions($restrictionType, $option->value, 'create');
                     if (!$canCreate) {
                         unset($options[$i]);
                     }
                 }
             } else {
                 foreach ($options as $i => $option) {
                     list($canManage, $canChange) = AgendaDirigentesHelper::getGranularPermissions($restrictionType, $option->value, 'manage');
                     if (!$canManage) {
                         unset($options[$i]);
                     }
                 }
             }
         } else {
             if ((string) $this->element['action']) {
                 // Get the current user object.
                 $user = JFactory::getUser();
                 foreach ($options as $i => $option) {
                     /*
                      * To take save or create in a category you need to have create rights for that category
                      * unless the item is already in that category.
                      * Unset the option if the user isn't authorised for it. In this field assets are always categories.
                      */
                     if ($user->authorise('core.create', $extension . '.category.' . $option->value) != true) {
                         unset($options[$i]);
                     }
                 }
             }
         }
         if (isset($this->element['show_root'])) {
             array_unshift($options, JHtml::_('select.option', '0', JText::_('JGLOBAL_ROOT')));
         }
     } else {
         JLog::add(JText::_('JLIB_FORM_ERROR_FIELDS_CATEGORY_ERROR_EXTENSION_EMPTY'), JLog::WARNING, 'jerror');
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Exemplo n.º 2
0
 /**
  * Method to build an SQL query to load the list data.
  *
  * @return      string  An SQL query
  */
 protected function getListQuery()
 {
     // Create a new query object.
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     $query->select($db->quoteName('dir.id') . ', ' . $db->quoteName('dir.name') . ', ' . $db->quoteName('dir.cargo_id') . ', ' . $db->quoteName('dir.state') . ', ' . $db->quoteName('dir.interino') . ', ' . $db->quoteName('dir.em_atividade') . ', ' . $db->quoteName('dir.sexo') . ', ' . $db->quoteName('car.catid') . ', ' . $db->quoteName('car.name', 'cargo') . ', ' . $db->quoteName('car.name_f', 'cargo_f') . ', ' . $db->quoteName('cat.title', 'categoria') . ', ' . $db->quoteName('cat.title', 'categoria'))->from($db->quoteName('#__agendadirigentes_dirigentes', 'dir'))->join('LEFT', $db->quoteName('#__agendadirigentes_cargos', 'car') . ' ON (' . $db->quoteName('car.id') . ' = ' . $db->quoteName('dir.cargo_id') . ')')->join('INNER', $db->quoteName('#__categories', 'cat') . ' ON (' . $db->quoteName('cat.id') . ' = ' . $db->quoteName('car.catid') . ')');
     // Filter by state
     $state = $this->state->get('filter.state');
     if (is_numeric($state)) {
         $query->where('dir.state = ' . (int) $state);
     } elseif ($state === '') {
         $query->where('(dir.state IN (0, 1))');
     }
     // Filter by category.
     $catid = $this->getState('filter.catid');
     if (is_numeric($catid)) {
         $query->where('car.catid = ' . (int) $catid);
     }
     // Filter by cargo.
     $cargo_id = $this->getState('filter.cargo_id');
     if (is_numeric($cargo_id)) {
         $query->where('dir.cargo_id = ' . (int) $cargo_id);
     }
     // Filter by search in title
     $search = $this->getState('filter.search');
     if (!empty($search)) {
         if (stripos($search, 'id:') === 0) {
             $query->where('dir.id = ' . (int) substr($search, 3));
         } else {
             $search = $db->quote('%' . $db->escape($search, true) . '%');
             $query->where('(dir.name LIKE ' . $search . ')');
         }
     }
     //restringir de acordo com as permissoes de usuario
     if ($this->state->get('params')->get('restricted_list_dirigentes', 0) == 1 && !AgendaDirigentesHelper::isSuperUser()) {
         $formatedToGetPermissions = true;
         $categories = $this->getCategories($formatedToGetPermissions);
         $allowed_categories = array();
         for ($i = 0, $limit = count($categories); $i < $limit; $i++) {
             list($canManage, $canChange) = AgendaDirigentesHelper::getGranularPermissions('dirigentes', $categories[$i]);
             if ($canManage || $canChange) {
                 $allowed_categories[] = $categories[$i]->catid;
             }
         }
         if (count($allowed_categories)) {
             $allowed_categories = implode(', ', $allowed_categories);
             $query->where($db->quoteName('car.catid') . ' IN (' . $allowed_categories . ')');
         } else {
             $allowed_categories = 0;
             $query->where($db->quoteName('car.catid') . ' IN (' . $allowed_categories . ')');
         }
     }
     // Add the list ordering clause.
     $orderCol = $this->state->get('list.ordering', 'dir.name');
     $orderDirn = $this->state->get('list.direction', 'ASC');
     $query->order($db->escape($orderCol . ' ' . $orderDirn));
     // echo $query->dump();die();
     return $query;
 }
Exemplo n.º 3
0
 protected function canEditState($item)
 {
     list($canManage, $canChange) = AgendaDirigentesHelper::getGranularPermissions('cargos', $item, 'manage');
     if ($canChange) {
         return true;
     }
     return false;
 }
Exemplo n.º 4
0
 /**
  * Method to build an SQL query to load the list data.
  *
  * @return      string  An SQL query
  */
 protected function getListQuery()
 {
     // Create a new query object.
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     // Select some fields from the cargos table
     $query->select('DISTINCT a.id, a.name, a.name_f, a.catid, a.published, a.featured, b.title AS titleCategory, a.ordering, a.permitir_sobreposicao')->from($db->quoteName('#__agendadirigentes_cargos', 'a'))->join('INNER', $db->quoteName('#__categories', 'b') . ' ON (' . $db->quoteName('b.id') . ' = ' . $db->quoteName('a.catid') . ')');
     // Filter by published state
     $published = $this->state->get('filter.published');
     if (is_numeric($published)) {
         $query->where('a.published = ' . (int) $published);
     } elseif ($published === '') {
         $query->where('(a.published IN (0, 1))');
     }
     // Filter by category.
     $catid = $this->getState('filter.catid');
     if (is_numeric($catid)) {
         $query->where('a.catid = ' . (int) $catid);
     }
     // Filter by search in title
     $search = $this->getState('filter.search');
     if (!empty($search)) {
         if (stripos($search, 'id:') === 0) {
             $query->where('a.id = ' . (int) substr($search, 3));
         } else {
             $search = $db->quote('%' . $db->escape($search, true) . '%');
             $query->where('(a.name LIKE ' . $search . ')');
         }
     }
     //restringir de acordo com as permissoes de usuario
     if ($this->state->get('params')->get('restricted_list_cargos', 0) == 1 && !AgendaDirigentesHelper::isSuperUser()) {
         $formatedToGetPermissions = true;
         $categories = $this->getCategories($formatedToGetPermissions);
         $allowed_categories = array();
         for ($i = 0, $limit = count($categories); $i < $limit; $i++) {
             list($canManage, $canChange) = AgendaDirigentesHelper::getGranularPermissions('cargos', $categories[$i]);
             if ($canManage || $canChange) {
                 $allowed_categories[] = $categories[$i]->catid;
             }
         }
         if (count($allowed_categories)) {
             $allowed_categories = implode(', ', $allowed_categories);
             $query->where($db->quoteName('a.catid') . ' IN (' . $allowed_categories . ')');
         } else {
             $allowed_categories = 0;
             $query->where($db->quoteName('a.catid') . ' IN (' . $allowed_categories . ')');
         }
     }
     // Add the list ordering clause.
     $orderCol = $this->state->get('list.ordering', 'a.id');
     $orderDirn = $this->state->get('list.direction', 'DESC');
     $query->order($db->escape($orderCol . ' ' . $orderDirn));
     return $query;
 }
Exemplo n.º 5
0
 /**
  * Implement to allow edit or not
  * Overwrites: JControllerForm::allowEdit
  *
  * @param array $data
  * @param string $key
  * @return bool
  */
 protected function allowEdit($data = array(), $key = 'id')
 {
     $id = isset($data[$key]) ? $data[$key] : 0;
     if (!empty($id)) {
         $model = $this->getModel();
         $item = $model->getTable();
         $item->load($id);
         list($canManage, $canChange) = AgendaDirigentesHelper::getGranularPermissions('dirigentes', $item, 'manage');
         return $canManage;
     }
     return true;
 }
Exemplo n.º 6
0
 /**
  * display method of Compromisso
  * @return void
  */
 public function display($tpl = null)
 {
     // get the Data
     $this->form = $this->get('Form');
     $this->item = $this->get('Item');
     $this->script = $this->get('Script');
     $this->isNew = $this->item->id == 0;
     $app = JFactory::getApplication();
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode('<br />', $errors));
         return false;
     }
     $this->canDo = JHelperContent::getActions('com_agendadirigentes');
     $this->canCreate = $this->canDo->get('core.create');
     if ($this->isNew) {
         if (!$this->canCreate) {
             JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
             $app->redirect('index.php');
         }
         $this->canManage = $this->canDo->get('core.edit') || $this->canDo->get('core.edit.own');
         $this->canChange = $this->canDo->get('core.edit.state');
     } else {
         list($canManage, $canChange) = AgendaDirigentesHelper::getGranularPermissions('compromissos', $this->item, 'manage');
         $this->canManage = $canManage;
         $this->canChange = $canChange;
         if (!$this->canManage) {
             JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
             $app->redirect('index.php');
         }
     }
     $isSuperUser = AgendaDirigentesHelper::isSuperUser();
     $params = JComponentHelper::getParams('com_agendadirigentes');
     $allowFeature = $params->get('allowFeature', 'state');
     $this->showFeatured = $allowFeature == 'state' && $this->canChange || $allowFeature == 'edit' && $this->canManage || $allowFeature == 'superuser' && $isSuperUser;
     $this->permitir_participantes_locais = $params->get('permitir_participantes_locais', 1);
     $this->permitir_participantes_externos = $params->get('permitir_participantes_externos', 1);
     // Set the toolbar
     $this->addToolBar();
     // Display the template
     parent::display($tpl);
     // Set the document
     $this->setDocument();
 }
Exemplo n.º 7
0
 /**
  * display method of Dirigente
  * @return void
  */
 public function display($tpl = null)
 {
     // get the Data
     $this->form = $this->get('Form');
     $this->item = $this->get('Item');
     if (empty($this->item)) {
         $this->item = new StdClass();
         $this->item->id = 0;
     }
     $this->isNew = $this->item->id == 0;
     $app = JFactory::getApplication();
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode('<br />', $errors));
         return false;
     }
     $this->canDo = JHelperContent::getActions('com_agendadirigentes');
     $this->canCreate = $this->canDo->get('dirigentes.create');
     if ($this->isNew) {
         if (!$this->canCreate) {
             JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
             $app->redirect('index.php');
         }
         $this->canChange = $this->canDo->get('dirigentes.edit.state');
     } else {
         list($canManage, $canChange) = AgendaDirigentesHelper::getGranularPermissions('dirigentes', $this->item, 'manage');
         $this->canManage = $canManage;
         $this->canChange = $canChange;
         if (!$this->canManage) {
             JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
             $app->redirect('index.php');
         }
     }
     // Set the toolbar
     $this->addToolBar();
     // Display the template
     parent::display($tpl);
     // Set the document
     $this->setDocument();
 }
Exemplo n.º 8
0
<?php

/**
* @package PortalPadrao
* @subpackage com_agendadirigentes
*
* @copyright Copyright (C) 2005 - 2014 Joomla Calango. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// impedir acesso direto ao arquivo
defined('_JEXEC') or die;
foreach ($this->items as $i => $item) {
    list($canManage, $canChange) = AgendaDirigentesHelper::getGranularPermissions('dirigentes', $item);
    ?>
        <tr class="row<?php 
    echo $i % 2;
    ?>
">
                <td>
                    <?php 
    if ($canManage) {
        ?>
                        <?php 
        echo $item->id;
        ?>
                    <?php 
    }
    ?>
                </td>
                <td>
                    <?php 
Exemplo n.º 9
0
 /**
  * Method to build an SQL query to load the list data.
  *
  * @return      string  An SQL query
  */
 protected function getListQuery()
 {
     // Create a new query object.
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     // Select some fields from the compromissos table
     $query->select(' comp.id, comp.checked_out, comp.title, comp.data_inicial')->select(' comp.data_final, comp.horario_inicio, comp.horario_fim, comp.description, comp.local')->select(' comp.params, comp.featured, comp.created_by')->select(' comp.state, comp.dia_todo')->select(' dc.sobreposto, dc.owner, dc.sobreposto_por')->select(' dir.name AS nameOwner, dir.id AS idOwner')->select(' car.name AS cargoOwner, car.catid')->from($db->quoteName('#__agendadirigentes_compromissos', 'comp'));
     $participante_id = $this->getState('filter.participante_id');
     if (is_numeric($participante_id)) {
         $query->where('dc.dirigente_id = ' . (int) $participante_id);
         $this->setState('list.status_dono_compromisso', 0);
     }
     $status_dono_compromisso = $this->getState('list.status_dono_compromisso', 1);
     if ($status_dono_compromisso == 0) {
         $query->join('LEFT', $db->quoteName('#__agendadirigentes_dirigentes_compromissos', 'dc') . ' ON (' . $db->quoteName('comp.id') . ' = ' . $db->quoteName('dc.compromisso_id') . ')');
     } else {
         $query->join('LEFT', $db->quoteName('#__agendadirigentes_dirigentes_compromissos', 'dc') . ' ON (' . $db->quoteName('comp.id') . ' = ' . $db->quoteName('dc.compromisso_id') . ' AND dc.owner = 1)');
     }
     $query->join('LEFT', $db->quoteName('#__agendadirigentes_dirigentes', 'dir') . ' ON (' . $db->quoteName('dc.dirigente_id') . ' = ' . $db->quoteName('dir.id') . ')')->join('LEFT', $db->quoteName('#__agendadirigentes_cargos', 'car') . ' ON (' . $db->quoteName('dir.cargo_id') . ' = ' . $db->quoteName('car.id') . ')');
     // Filter by state
     $state = $this->state->get('filter.state');
     if (is_numeric($state)) {
         $query->where('comp.state = ' . (int) $state);
     } elseif ($state === '') {
         $query->where('(comp.state IN (0, 1))');
     }
     // Filter by category.
     $catid = $this->getState('filter.catid');
     if (is_numeric($catid)) {
         $query->where('car.catid = ' . (int) $catid);
     }
     // Filter by cargo.
     $cargo_id = $this->getState('filter.cargo_id');
     if (is_numeric($cargo_id)) {
         $query->where('dir.cargo_id = ' . (int) $cargo_id);
     }
     // Filter by dia todo.
     $dia_todo = $this->getState('filter.dia_todo');
     if (is_numeric($dia_todo)) {
         $query->where('comp.dia_todo = ' . (int) $dia_todo);
     }
     //filter by 1 dia ou mais de compromisso
     $duracao = $this->getState('filter.duracao');
     if (intval($duracao) == 1) {
         $query->where($db->quoteName('data_inicial') . ' = ' . $db->quoteName('data_final'));
     } elseif (intval($duracao) == 2) {
         $query->where($db->quoteName('data_inicial') . ' <> ' . $db->quoteName('data_final'));
     }
     // Filter by dirigente.
     $dirigente_id = $this->getState('filter.dirigente_id');
     if (is_numeric($dirigente_id)) {
         $query->where('dir.id = ' . (int) $dirigente_id);
     }
     $featured = $this->getState('filter.featured', '');
     if ($featured != '') {
         $query->where('comp.featured = ' . (int) $featured);
     }
     // Filter by data inicial | data final.
     $data_inicial = $this->getState('dates.data_inicial');
     $data_final = $this->getState('dates.data_final');
     if (!empty($data_inicial) || !empty($data_final)) {
         require_once JPATH_COMPONENT . '/models/rules/databrasil.php';
         $dateVerify = new JFormRuleDataBrasil();
         if (preg_match($dateVerify->getRegex(), $data_inicial)) {
             $data_inicial = $this->format_date_mysql($data_inicial);
             $clause = $db->quoteName('data_inicial') . ' >= ' . $db->Quote($data_inicial);
             $query->where($clause);
         }
         if (preg_match($dateVerify->getRegex(), $data_final)) {
             $data_final = $this->format_date_mysql($data_final);
             $clause = '(' . $db->quoteName('data_final') . ' <= ' . $db->Quote($data_final);
             $clause .= ' OR ';
             $clause .= $db->quoteName('data_final') . ' = ' . $db->Quote('0000-00-00') . ')';
             $query->where($clause);
         }
     }
     // Filter by search in title
     $search = $this->getState('filter.search');
     if (!empty($search)) {
         if (stripos($search, 'id:') === 0) {
             $query->where('comp.id = ' . (int) substr($search, 3));
         } else {
             $search = $db->quote('%' . $db->escape($search, true) . '%');
             $query->where('(comp.title LIKE ' . $search . ')');
         }
     }
     //restringir de acordo com as permissoes de usuario
     if ($this->state->get('params')->get('restricted_list_compromissos', 0) == 1 && !AgendaDirigentesHelper::isSuperUser()) {
         $formatedToGetPermissions = true;
         $categories = $this->getCategories($formatedToGetPermissions);
         $allowed_categories = array();
         for ($i = 0, $limit = count($categories); $i < $limit; $i++) {
             list($canManage, $canChange) = AgendaDirigentesHelper::getGranularPermissions('compromissos', $categories[$i]);
             if ($canManage || $canChange) {
                 $allowed_categories[] = $categories[$i]->catid;
             }
         }
         if (count($allowed_categories)) {
             $allowed_categories = implode(', ', $allowed_categories);
             $query->where($db->quoteName('car.catid') . ' IN (' . $allowed_categories . ')');
         } else {
             $allowed_categories = 0;
             $query->where($db->quoteName('car.catid') . ' IN (' . $allowed_categories . ')');
         }
     }
     // Add the list ordering clause.
     $orderCol = $this->state->get('list.ordering', 'comp.id');
     $orderDirn = $this->state->get('list.direction', 'DESC');
     if ($orderCol == 'comp.data_inicial' || $orderCol == 'comp.data_final') {
         $ordering = $db->escape($orderCol . ' ' . $orderDirn . ', comp.horario_inicio ASC');
     } else {
         $ordering = $db->escape($orderCol . ' ' . $orderDirn);
     }
     $query->order($ordering);
     return $query;
 }
Exemplo n.º 10
0
 /**
  * Method to toggle the featured setting of a list of compromissos.
  *
  * @return  void
  * @since   1.6
  */
 public function featured()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $user = JFactory::getUser();
     $isSuperUser = AgendaDirigentesHelper::isSuperUser();
     $ids = $this->input->get('cid', array(), 'array');
     $values = array('featured' => 1, 'unfeatured' => 0);
     $task = $this->getTask();
     $value = JArrayHelper::getValue($values, $task, 0, 'int');
     $model = $this->getModel();
     $fields = array('car.catid', 'comp.id', 'comp.created_by');
     $dataFromIds = $model->getDataFromIds($ids, $fields);
     $params = JComponentHelper::getParams($this->option);
     $allowFeature = $params->get('allowFeature', 'state');
     if (empty($ids)) {
         JError::raiseWarning(500, JText::_('JERROR_NO_ITEMS_SELECTED'));
     }
     foreach ($ids as $i => $id) {
         $item = $dataFromIds[$id];
         if (!isset($item->catid)) {
             unset($ids[$i]);
             continue;
         }
         if ($allowFeature == 'superuser') {
             if ($isSuperUser) {
                 continue;
             } else {
                 $ids = NULL;
                 JError::raiseNotice(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
                 break;
             }
         }
         if ($allowFeature == 'state') {
             list($canManage, $canChange) = AgendaDirigentesHelper::getGranularPermissions('compromissos', $item);
             if (!$canChange) {
                 unset($ids[$i]);
                 JError::raiseNotice(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
             }
         } else {
             if ($allowFeature == 'edit') {
                 //informacao canManage eh sobreposta por permissoes de edicao de proprios itens e a linha abaixo nao
                 if (!$user->authorise("core.edit", "com_agendadirigentes.category." . $item->catid)) {
                     unset($ids[$i]);
                     JError::raiseNotice(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
                 }
             }
         }
     }
     if (empty($ids)) {
         JError::raiseWarning(500, JText::_('JERROR_NO_ITEMS_SELECTED'));
     } else {
         // Get the model.
         $model = $this->getModel();
         // Publish compromissos.
         if (!$model->featured($ids, $value)) {
             JError::raiseWarning(500, $model->getError());
         }
     }
     $this->setRedirect('index.php?option=com_agendadirigentes&view=compromissos');
 }
Exemplo n.º 11
0
 /**
  * Method to get a list of tags
  *
  * @return  array  The field option objects.
  *
  * @since   3.1
  */
 protected function getOptions()
 {
     $input = JFactory::getApplication()->input;
     $componentParams = AgendaDirigentesHelper::getParams();
     $published = $this->element['published'] ? $this->element['published'] : array(0, 1);
     $db = JFactory::getDbo();
     $attr_name = $this->getAttribute('name', '');
     //inicializando variavel para receber opcoes do combo
     $options = array();
     //bloqueio para restringir lista de usuarios ao dono do evento selecionado.
     if ($attr_name != 'owner' && $attr_name != 'autoridade') {
         $compromisso_id = $input->getInt('id', 0);
         if ($compromisso_id == 0 && $componentParams->get('permitir_participantes_locais', 1) == 1) {
             $options[0] = new StdClass();
             $options[0]->value = "";
             $options[0]->path = "";
             $options[0]->level = 1;
             $options[0]->published = 0;
             $options[0]->text = JText::_('COM_AGENDADIRIGENTES_FIELD_DIRTAGS_CHOOSE_OWNER');
             $options = JHelperTags::convertPathsToNames($options);
             return $options;
         } else {
             if ($componentParams->get('permitir_participantes_locais', 1) == 1) {
                 $ownerData = $this->getOwnerDataFromCompromissoId($compromisso_id);
                 $valid_catid_list = $this->getCategoriesScope($ownerData);
             } else {
                 $valid_catid_list = array();
             }
         }
         if ((count($valid_catid_list) == 1 && @$valid_catid_list[0] == 0 || is_null($valid_catid_list)) && $componentParams->get('permitir_participantes_externos', 1) == 0) {
             $options[0] = new StdClass();
             $options[0]->value = "";
             $options[0]->path = "";
             $options[0]->level = 1;
             $options[0]->published = 0;
             $options[0]->text = JText::_('COM_AGENDADIRIGENTES_FIELD_DIRTAGS_NO_ENOUGH_PERMISSIONS');
             $options = JHelperTags::convertPathsToNames($options);
             return $options;
         }
     }
     //se componente configurado para inclusao de participantes cadastrados no sistema e por isso locais (do mesmo orgao)
     //ou se nome do campo equivale a owner (responsavel pelo compromisso ou dono)
     // entao busque por dirigentes para povoar as opcoes do combo...
     if ($componentParams->get('permitir_participantes_locais', 1) == 1 || $attr_name == 'owner' || $attr_name == 'autoridade') {
         $query = $db->getQuery(true);
         if ($this->getAttribute('show_category', 1) == 1) {
             $query->select('a.id AS value, CONCAT(c.title, " - ", b.name, " - " ,a.name) AS text, \'\' AS path, 1 AS level, a.state AS published, b.catid');
             $query->order('c.title, b.name, a.name');
         } else {
             $query->select('a.id AS value, CONCAT(b.name, " - " ,a.name) AS text, \'\' AS path, 1 AS level, a.state AS published, b.catid');
             $query->order('b.name, a.name');
         }
         $query->from($db->quoteName('#__agendadirigentes_dirigentes', 'a'))->join('INNER', $db->quoteName('#__agendadirigentes_cargos', 'b') . ' ON (' . $db->quoteName('a.cargo_id') . ' = ' . $db->quoteName('b.id') . ')')->join('INNER', $db->quoteName('#__categories', 'c') . ' ON (' . $db->quoteName('b.catid') . ' = ' . $db->quoteName('c.id') . ')');
         // Filter on the published state
         if (is_numeric($published)) {
             $query->where('a.state = ' . (int) $published);
         } elseif (is_array($published)) {
             JArrayHelper::toInteger($published);
             $query->where('a.state IN (' . implode(',', $published) . ')');
         }
         //se esta permitida a inclusao de participantes locais e o campo
         //nao se refere ao campo de escolha do dono do compromisso, entao flag permitir_sobreposicao = 1
         if ($attr_name != 'owner' && $attr_name != 'autoridade') {
             $query->where('b.permitir_sobreposicao = 1');
             if ($valid_catid_list != '*') {
                 if (is_null($valid_catid_list)) {
                     $valid_catid_list = array(0);
                     JFactory::getApplication()->enqueueMessage(JText::_('COM_AGENDADIRIGENTES_FIELD_DIRTAGS_INVALID_CATEGORY_LIST'), 'Warning');
                 }
                 $query->where('b.catid IN (' . implode(', ', $valid_catid_list) . ')');
             }
         }
         // Get the options.
         $db->setQuery((string) $query);
         $categories = $db->loadObjectList();
     } else {
         $categories = array();
     }
     //se campo == owner, incluir primeira opcao vazia
     if ($attr_name == 'owner' || $attr_name == 'autoridade') {
         $options[0] = new StdClass();
         $options[0]->value = "";
         $options[0]->path = "";
         $options[0]->level = 1;
         $options[0]->published = 1;
         $options[0]->text = " - Selecione - ";
         //restringir de acordo com as permissoes de usuario, para que a escolha do owner respeite o que foi cadastrado como permissao
         //so ocorre se componente configurado para restringir ou usuario nao for superuser
         if ($componentParams->get('restricted_list_compromissos', 0) == 1 && !AgendaDirigentesHelper::isSuperUser() && $attr_name == 'owner') {
             $allowedCategories = array();
             $id = $input->getInt('id', 0);
             if (empty($id)) {
                 for ($i = 0, $limit = count($categories); $i < $limit; $i++) {
                     $canCreate = AgendaDirigentesHelper::getGranularPermissions('compromissos', $categories[$i], 'create');
                     if ($canCreate) {
                         $allowedCategories[] = $categories[$i];
                     }
                 }
             } else {
                 for ($i = 0, $limit = count($categories); $i < $limit; $i++) {
                     list($canManage, $canChange) = AgendaDirigentesHelper::getGranularPermissions('compromissos', $categories[$i], 'manage');
                     if ($canManage || $canChange) {
                         $allowedCategories[] = $categories[$i];
                     }
                 }
             }
             $categories = $allowedCategories;
         }
         //fim restricao de acordo com as permissoes de usuario
     }
     // fim se campo == owner
     try {
         $options = array_merge($options, $categories);
     } catch (RuntimeException $e) {
         return false;
     }
     //se incluir participantes externos = true na configuracao do field
     //e se for possivel permitir participantes externos = 1 na configuracao do componente
     //e se nome do campo for diferente de owner, entao leia campo de participantes externos
     //e os inclua
     if ($this->getAttribute('add_participantes_externos', false) == true && $componentParams->get('permitir_participantes_externos', 1) == 1 && $attr_name != 'owner' && $attr_name != 'autoridade') {
         $input = JFactory::getApplication()->input;
         $id = $input->get('id', 0, 'int');
         $query = $db->getQuery(true)->select($db->quoteName('participantes_externos'))->from($db->quoteName('#__agendadirigentes_compromissos'))->where($db->quoteName('id') . ' = ' . $id);
         $db->setQuery((string) $query);
         $participantes_externos = $db->loadResult();
         $participantes_externos = explode(';', $participantes_externos);
         $opt_externos = array();
         for ($i = 0, $limit = count($participantes_externos); $i < $limit; $i++) {
             $opt_externos[$i] = new StdClass();
             $opt_externos[$i]->value = trim($participantes_externos[$i]);
             $opt_externos[$i]->text = trim($participantes_externos[$i]);
             $opt_externos[$i]->path = "";
             $opt_externos[$i]->level = 1;
             $opt_externos[$i]->published = 1;
         }
         try {
             $options = array_merge($options, $opt_externos);
         } catch (RuntimeException $e) {
             return false;
         }
     }
     $options = JHelperTags::convertPathsToNames($options);
     return $options;
 }