diff --git a/admin/models/fields/preachers.php b/admin/models/fields/preachers.php
index 58fa7b79..d72d72f1 100644
--- a/admin/models/fields/preachers.php
+++ b/admin/models/fields/preachers.php
@@ -1,4 +1,4 @@
-
+ @author Llewellyn van der Merwe
@copyright Copyright (C) 2015. All Rights Reserved
- @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
-
- A sermon distributor that links to Dropbox.
-
+ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
+
+ A sermon distributor that links to Dropbox.
+
/----------------------------------------------------------------------------------------------------------------------------------*/
// No direct access to this file
@@ -48,23 +48,25 @@ class JFormFieldPreachers extends JFormFieldList
*/
protected function getOptions()
{
- $db = JFactory::getDBO();
- $query = $db->getQuery(true);
- $query->select($db->quoteName(array('a.id','a.name'),array('id','preacher_request_id_name')));
- $query->from($db->quoteName('#__sermondistributor_preacher', 'a'));
- $query->where($db->quoteName('a.published') . ' = 1');
- $query->order('a.name ASC');
- $db->setQuery((string)$query);
- $items = $db->loadObjectList();
- $options = array();
- if ($items)
- {
- $options[] = JHtml::_('select.option', '', 'Select a preacher');
- foreach($items as $item)
- {
- $options[] = JHtml::_('select.option', $item->id, $item->preacher_request_id_name);
- }
- }
+ $db = JFactory::getDBO();
+ $query = $db->getQuery(true);
+ $query->select($db->quoteName(array('a.id','a.name'),array('id','preacher_request_id_name')));
+ $query->from($db->quoteName('#__sermondistributor_preacher', 'a'));
+ $query->where($db->quoteName('a.published') . ' = 1');
+ $query->order('a.name ASC');
+ $db->setQuery((string)$query);
+ $items = $db->loadObjectList();
+ $options = array();
+ if ($items)
+ {
+ if ($this->multiple === false) {
+ $options[] = JHtml::_('select.option', '', 'Select a preacher');
+ }
+ foreach($items as $item)
+ {
+ $options[] = JHtml::_('select.option', $item->id, $item->preacher_request_id_name);
+ }
+ }
return $options;
}
}
diff --git a/admin/models/forms/filter_sermons.xml b/admin/models/forms/filter_sermons.xml
new file mode 100644
index 00000000..036f2455
--- /dev/null
+++ b/admin/models/forms/filter_sermons.xml
@@ -0,0 +1,150 @@
+
+
diff --git a/admin/models/sermons.php b/admin/models/sermons.php
index ddd509bc..6a656312 100644
--- a/admin/models/sermons.php
+++ b/admin/models/sermons.php
@@ -1,81 +1,82 @@
- @copyright Copyright (C) 2015. All Rights Reserved
- @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
-
- A sermon distributor that links to Dropbox.
-
-/----------------------------------------------------------------------------------------------------------------------------------*/
-
-// No direct access to this file
-defined('_JEXEC') or die('Restricted access');
-
-use Joomla\Utilities\ArrayHelper;
-
-/**
- * Sermons Model
- */
-class SermondistributorModelSermons extends JModelList
-{
- public function __construct($config = array())
- {
- if (empty($config['filter_fields']))
- {
- $config['filter_fields'] = array(
+/*-------------------------------------------------------------------------------------------------------------| www.vdm.io |------/
+ ____ ____ __ __ __
+/\ _`\ /\ _`\ __ /\ \__ __/\ \ /\ \__
+\ \,\L\_\ __ _ __ ___ ___ ___ ___ \ \ \/\ \/\_\ ____\ \ ,_\ _ __ /\_\ \ \____ __ __\ \ ,_\ ___ _ __
+ \/_\__ \ /'__`\/\`'__\/' __` __`\ / __`\ /' _ `\ \ \ \ \ \/\ \ /',__\\ \ \/ /\`'__\/\ \ \ '__`\/\ \/\ \\ \ \/ / __`\/\`'__\
+ /\ \L\ \/\ __/\ \ \/ /\ \/\ \/\ \/\ \L\ \/\ \/\ \ \ \ \_\ \ \ \/\__, `\\ \ \_\ \ \/ \ \ \ \ \L\ \ \ \_\ \\ \ \_/\ \L\ \ \ \/
+ \ `\____\ \____\\ \_\ \ \_\ \_\ \_\ \____/\ \_\ \_\ \ \____/\ \_\/\____/ \ \__\\ \_\ \ \_\ \_,__/\ \____/ \ \__\ \____/\ \_\
+ \/_____/\/____/ \/_/ \/_/\/_/\/_/\/___/ \/_/\/_/ \/___/ \/_/\/___/ \/__/ \/_/ \/_/\/___/ \/___/ \/__/\/___/ \/_/
+
+/------------------------------------------------------------------------------------------------------------------------------------/
+
+ @version 2.0.x
+ @created 22nd October, 2015
+ @package Sermon Distributor
+ @subpackage sermons.php
+ @author Llewellyn van der Merwe
+ @copyright Copyright (C) 2015. All Rights Reserved
+ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
+
+ A sermon distributor that links to Dropbox.
+
+/----------------------------------------------------------------------------------------------------------------------------------*/
+
+// No direct access to this file
+defined('_JEXEC') or die('Restricted access');
+
+use Joomla\Utilities\ArrayHelper;
+
+/**
+ * Sermons Model
+ */
+class SermondistributorModelSermons extends JModelList
+{
+ public function __construct($config = array())
+ {
+ if (empty($config['filter_fields']))
+ {
+ $config['filter_fields'] = array(
'a.id','id',
'a.published','published',
'a.ordering','ordering',
'a.created_by','created_by',
'a.modified_by','modified_by',
+ 'a.access','access',
'a.name','name',
- 'g.name',
- 'h.name',
+ 'g.name','preacher',
+ 'h.name','series',
'a.short_description','short_description',
'c.title','category_title',
'c.id', 'category_id',
'a.catid', 'catid',
'a.link_type','link_type',
- 'a.source','source'
- );
- }
-
- parent::__construct($config);
- }
-
- /**
- * Method to auto-populate the model state.
- *
- * @return void
- */
- protected function populateState($ordering = null, $direction = null)
- {
- $app = JFactory::getApplication();
-
- // Adjust the context to support modal layouts.
- if ($layout = $app->input->get('layout'))
- {
- $this->context .= '.' . $layout;
- }
+ 'a.source','source'
+ );
+ }
+
+ parent::__construct($config);
+ }
+
+ /**
+ * Method to auto-populate the model state.
+ *
+ * @return void
+ */
+ protected function populateState($ordering = null, $direction = null)
+ {
+ $app = JFactory::getApplication();
+
+ // Adjust the context to support modal layouts.
+ if ($layout = $app->input->get('layout'))
+ {
+ $this->context .= '.' . $layout;
+ }
$name = $this->getUserStateFromRequest($this->context . '.filter.name', 'filter_name');
$this->setState('filter.name', $name);
- $preacher = $this->getUserStateFromRequest($this->context . '.filter.preacher', 'filter_preacher');
- $this->setState('filter.preacher', $preacher);
+// $preacher = $this->getUserStateFromRequest($this->context . '.filter.preacher', 'filter_preacher');
+// $this->setState('filter.preacher', $preacher);
$series = $this->getUserStateFromRequest($this->context . '.filter.series', 'filter_series');
$this->setState('filter.series', $series);
@@ -86,8 +87,8 @@ class SermondistributorModelSermons extends JModelList
$category = $app->getUserStateFromRequest($this->context . '.filter.category', 'filter_category');
$this->setState('filter.category', $category);
- $categoryId = $this->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_category_id');
- $this->setState('filter.category_id', $categoryId);
+// $categoryId = $this->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_category_id');
+// $this->setState('filter.category_id', $categoryId);
$catid = $app->getUserStateFromRequest($this->context . '.filter.catid', 'filter_catid');
$this->setState('filter.catid', $catid);
@@ -96,41 +97,58 @@ class SermondistributorModelSermons extends JModelList
$this->setState('filter.link_type', $link_type);
$source = $this->getUserStateFromRequest($this->context . '.filter.source', 'filter_source');
- $this->setState('filter.source', $source);
-
- $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int');
- $this->setState('filter.sorting', $sorting);
-
- $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int');
- $this->setState('filter.access', $access);
-
- $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
- $this->setState('filter.search', $search);
-
- $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', '');
- $this->setState('filter.published', $published);
-
- $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', '');
- $this->setState('filter.created_by', $created_by);
-
- $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created');
- $this->setState('filter.created', $created);
-
- // List state information.
- parent::populateState($ordering, $direction);
- }
-
- /**
- * Method to get an array of data items.
- *
- * @return mixed An array of data items on success, false on failure.
- */
- public function getItems()
+ $this->setState('filter.source', $source);
+
+ $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int');
+ $this->setState('filter.sorting', $sorting);
+
+ $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int');
+ $this->setState('filter.access', $access);
+
+ $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
+ $this->setState('filter.search', $search);
+
+ $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', '');
+ $this->setState('filter.published', $published);
+
+ $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', '');
+ $this->setState('filter.created_by', $created_by);
+
+ $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created');
+ $this->setState('filter.created', $created);
+
+ // Handle multiple fields -> original code commented above
+ $formSubmited = $app->input->post->get('form_submited');
+ $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access');
+ $categoryId = $this->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_category_id');
+ $preacher = $this->getUserStateFromRequest($this->context . '.filter.preacher', 'filter_preacher');
+ if ($formSubmited)
+ {
+ $access = $app->input->post->get('access');
+ $this->setState('filter.access', $access);
+
+ $categoryId = $app->input->post->get('category_id');
+ $this->setState('filter.category_id', $categoryId);
+
+ $preacher = $app->input->post->get('preacher');
+ $this->setState('filter.preacher', $preacher);
+ }
+
+ // List state information.
+ parent::populateState($ordering, $direction);
+ }
+
+ /**
+ * Method to get an array of data items.
+ *
+ * @return mixed An array of data items on success, false on failure.
+ */
+ public function getItems()
{
// check in items
$this->checkInNow();
-
- // load parent items
+
+ // load parent items
$items = parent::getItems();
// Set values to display correctly.
@@ -165,10 +183,10 @@ class SermondistributorModelSermons extends JModelList
$item->source = $this->selectionTranslation($item->source, 'source');
}
}
-
-
- // return items
- return $items;
+
+
+ // return items
+ return $items;
}
/**
@@ -207,15 +225,15 @@ class SermondistributorModelSermons extends JModelList
}
}
return $value;
- }
-
- /**
- * Method to build an SQL query to load the list data.
- *
- * @return string An SQL query
- */
- protected function getListQuery()
- {
+ }
+
+ /**
+ * Method to build an SQL query to load the list data.
+ *
+ * @return string An SQL query
+ */
+ protected function getListQuery()
+ {
// Get the user object.
$user = JFactory::getUser();
// Create a new query object.
@@ -253,10 +271,19 @@ class SermondistributorModelSermons extends JModelList
$query->select('ag.title AS access_level');
$query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');
// Filter by access level.
- if ($access = $this->getState('filter.access'))
+ $access = $this->getState('filter.access');
+
+ if (is_numeric($access))
{
$query->where('a.access = ' . (int) $access);
}
+ elseif (is_array($access))
+ {
+ $access = ArrayHelper::toInteger($access);
+ $access = implode(',', $access);
+ $query->where('a.access IN (' . $access . ')');
+ }
+
// Implement View Level Access
if (!$user->authorise('core.options', 'com_sermondistributor'))
{
@@ -279,9 +306,17 @@ class SermondistributorModelSermons extends JModelList
}
// Filter by preacher.
- if ($preacher = $this->getState('filter.preacher'))
+ $preacher = $this->getState('filter.preacher');
+
+ if (is_numeric($preacher))
{
- $query->where('a.preacher = ' . $db->quote($db->escape($preacher)));
+ $query->where('a.preacher = ' . (int) $preacher);
+ }
+ elseif (is_array($preacher))
+ {
+ $preacher = ArrayHelper::toInteger($preacher);
+ $preacher = implode(',', $preacher);
+ $query->where('a.preacher IN (' . $preacher . ')');
}
// Filter by series.
if ($series = $this->getState('filter.series'))
@@ -294,9 +329,17 @@ class SermondistributorModelSermons extends JModelList
$query->where('a.link_type = ' . $db->quote($db->escape($link_type)));
}
// Filter by Source.
- if ($source = $this->getState('filter.source'))
+ $source = $this->getState('filter.source');
+
+ if (is_numeric($source))
{
- $query->where('a.source = ' . $db->quote($db->escape($source)));
+ $query->where('a.source = ' . (int) $source);
+ }
+ elseif (is_array($source))
+ {
+ $source = ArrayHelper::toInteger($source);
+ $source = implode(',', $source);
+ $query->where('a.source IN (' . $source . ')');
}
// Filter by a single or group of categories.
@@ -317,7 +360,7 @@ class SermondistributorModelSermons extends JModelList
{
ArrayHelper::toInteger($categoryId);
$categoryId = implode(',', $categoryId);
- $query->where('a.category IN (' . $categoryId . ')');
+ $query->where('a.catid IN (' . $categoryId . ')');
}
@@ -329,7 +372,7 @@ class SermondistributorModelSermons extends JModelList
$query->order($db->escape($orderCol . ' ' . $orderDirn));
}
- return $query;
+ return $query;
}
/**
@@ -435,16 +478,16 @@ class SermondistributorModelSermons extends JModelList
return $headers;
}
return false;
- }
-
- /**
- * Method to get a store id based on model configuration state.
- *
- * @return string A store id.
- *
- */
- protected function getStoreId($id = '')
- {
+ }
+
+ /**
+ * Method to get a store id based on model configuration state.
+ *
+ * @return string A store id.
+ *
+ */
+ protected function getStoreId($id = '')
+ {
// Compile the store id.
$id .= ':' . $this->getState('filter.id');
$id .= ':' . $this->getState('filter.search');
@@ -460,9 +503,9 @@ class SermondistributorModelSermons extends JModelList
$id .= ':' . $this->getState('filter.category_id');
$id .= ':' . $this->getState('filter.catid');
$id .= ':' . $this->getState('filter.link_type');
- $id .= ':' . $this->getState('filter.source');
-
- return parent::getStoreId($id);
+ $id .= ':' . $this->getState('filter.source');
+
+ return parent::getStoreId($id);
}
/**
@@ -502,12 +545,12 @@ class SermondistributorModelSermons extends JModelList
// Conditions for which records should be updated.
$conditions = array(
- $db->quoteName('checked_out') . '!=0',
+ $db->quoteName('checked_out') . '!=0',
$db->quoteName('checked_out_time') . '<\''.$date.'\''
);
// Check table
- $query->update($db->quoteName('#__sermondistributor_sermon'))->set($fields)->where($conditions);
+ $query->update($db->quoteName('#__sermondistributor_sermon'))->set($fields)->where($conditions);
$db->setQuery($query);
@@ -516,5 +559,5 @@ class SermondistributorModelSermons extends JModelList
}
return false;
- }
-}
+ }
+}
diff --git a/admin/views/sermons/tmpl/default.php b/admin/views/sermons/tmpl/default.php
index a4e5b232..a35e6eb0 100644
--- a/admin/views/sermons/tmpl/default.php
+++ b/admin/views/sermons/tmpl/default.php
@@ -1,4 +1,4 @@
-
+ @author Llewellyn van der Merwe
@copyright Copyright (C) 2015. All Rights Reserved
- @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
-
- A sermon distributor that links to Dropbox.
-
+ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
+
+ A sermon distributor that links to Dropbox.
+
/----------------------------------------------------------------------------------------------------------------------------------*/
// No direct access to this file
-defined('_JEXEC') or die('Restricted access');
+defined('_JEXEC') or die('Restricted access');
// load tooltip behavior
JHtml::_('behavior.tooltip');
JHtml::_('behavior.multiselect');
JHtml::_('dropdown.init');
+JHtml::_('formbehavior.chosen', '.multipleCategories', null, array('placeholder_text_multiple' => JText::_('JOPTION_SELECT_CATEGORY')));
+JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => JText::_('JOPTION_SELECT_ACCESS')));
+JHtml::_('formbehavior.chosen', '.multiplePreachers', null, array('placeholder_text_multiple' => JText::_('Select preachers')));
+JHtml::_('formbehavior.chosen', '.multipleSource', null, array('placeholder_text_multiple' => JText::_('Select source')));
JHtml::_('formbehavior.chosen', 'select');
if ($this->saveOrder)
@@ -38,23 +42,6 @@ if ($this->saveOrder)
}
?>
-