@git Get Bible @github Get Bible @support Get Bible @copyright Copyright (C) 2015. All Rights Reserved @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ // No direct access to this file defined('_JEXEC') or die('Restricted access'); // import the list field type jimport('joomla.form.helper'); JFormHelper::loadFieldClass('list'); /** * Prompts Form Field class for the Getbible component */ class JFormFieldPrompts extends JFormFieldList { /** * The prompts field type. * * @var string */ public $type = 'prompts'; /** * Method to get a list of options for a list input. * * @return array An array of JHtml options. */ protected function getOptions() { // Get the user object. $user = JFactory::getUser(); // Get the databse object. $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->select($db->quoteName(array('a.guid','a.name'),array('guid','prompt_name'))); $query->from($db->quoteName('#__getbible_prompt', 'a')); $query->order('a.name ASC'); // Implement View Level Access (if set in table) if (!$user->authorise('core.options', 'com_getbible')) { $columns = $db->getTableColumns('#__getbible_prompt'); if(isset($columns['access'])) { $groups = implode(',', $user->getAuthorisedViewLevels()); $query->where('a.access IN (' . $groups . ')'); } } $db->setQuery((string)$query); $items = $db->loadObjectList(); $options = array(); if ($items) { if ($this->multiple === false) { $options[] = JHtml::_('select.option', '', JText::_('COM_GETBIBLE_SELECT_AN_OPTION')); } foreach($items as $item) { $options[] = JHtml::_('select.option', $item->guid, $item->prompt_name . ' (' . $item->guid . ')'); } } return $options; } }