diff --git a/README.md b/README.md index b986ee1e..2c1eb13d 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ The best way to see all your options is to install this component on you Joomla + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Name*: [Sermon Distributor](https://www.vdm.io/) + *First Build*: 22nd October, 2015 -+ *Last Build*: 28th June, 2018 ++ *Last Build*: 6th September, 2018 + *Version*: 2.0.x + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html @@ -36,7 +36,7 @@ due to [Automated Component Builder](https://www.vdm.io/joomla-component-builder > (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**, > never making one mistake or taking any coffee break.) -+ *Line count*: **66731** ++ *Line count*: **66852** + *File count*: **445** + *Folder count*: **93** diff --git a/admin/README.txt b/admin/README.txt index b986ee1e..2c1eb13d 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -23,7 +23,7 @@ The best way to see all your options is to install this component on you Joomla + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Name*: [Sermon Distributor](https://www.vdm.io/) + *First Build*: 22nd October, 2015 -+ *Last Build*: 28th June, 2018 ++ *Last Build*: 6th September, 2018 + *Version*: 2.0.x + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html @@ -36,7 +36,7 @@ due to [Automated Component Builder](https://www.vdm.io/joomla-component-builder > (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**, > never making one mistake or taking any coffee break.) -+ *Line count*: **66731** ++ *Line count*: **66852** + *File count*: **445** + *Folder count*: **93** diff --git a/admin/controller.php b/admin/controller.php index c64f75de..209368f8 100644 --- a/admin/controller.php +++ b/admin/controller.php @@ -25,9 +25,6 @@ // No direct access to this file defined('_JEXEC') or die('Restricted access'); -// import Joomla controller library -jimport('joomla.application.component.controller'); - /** * General Controller of Sermondistributor component */ diff --git a/admin/controllers/ajax.json.php b/admin/controllers/ajax.json.php index aab716eb..ccf0da46 100644 --- a/admin/controllers/ajax.json.php +++ b/admin/controllers/ajax.json.php @@ -25,9 +25,6 @@ // No direct access to this file defined('_JEXEC') or die('Restricted access'); -// import Joomla controllerform library -jimport('joomla.application.component.controller'); - /** * Sermondistributor Ajax Controller */ diff --git a/admin/controllers/external_source.php b/admin/controllers/external_source.php index ae89b95b..6470dd6e 100644 --- a/admin/controllers/external_source.php +++ b/admin/controllers/external_source.php @@ -25,9 +25,6 @@ // No direct access to this file defined('_JEXEC') or die('Restricted access'); -// import Joomla controllerform library -jimport('joomla.application.component.controllerform'); - /** * External_source Controller */ @@ -42,6 +39,13 @@ class SermondistributorControllerExternal_source extends JControllerForm */ protected $task; + /** + * Class constructor. + * + * @param array $config A named array of configuration variables. + * + * @since 1.6 + */ public function __construct($config = array()) { $this->view_list = 'External_sources'; // safeguard for setting the return view listing to the main view. @@ -201,14 +205,17 @@ class SermondistributorControllerExternal_source extends JControllerForm */ protected function allowAdd($data = array()) { + // Get user object. + $user = JFactory::getUser(); // Access check. - $access = JFactory::getUser()->authorise('external_source.access', 'com_sermondistributor'); + $access = $user->authorise('external_source.access', 'com_sermondistributor'); if (!$access) { return false; } + // In the absense of better information, revert to the component permissions. - return JFactory::getUser()->authorise('external_source.create', $this->option); + return $user->authorise('external_source.create', $this->option); } /** @@ -282,42 +289,25 @@ class SermondistributorControllerExternal_source extends JControllerForm * * @return string The arguments to append to the redirect URL. * - * @since 12.2 + * @since 1.6 */ protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') { - $tmpl = $this->input->get('tmpl'); - $layout = $this->input->get('layout', 'edit', 'string'); + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); - // Setup redirect info. - - $append = ''; - - if ($refid) + // set the referral options + if ($refid && $ref) { - $append .= '&ref='.(string)$ref.'&refid='.(int)$refid; + $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; } elseif ($ref) { - $append .= '&ref='.(string)$ref; - } - - if ($tmpl) - { - $append .= '&tmpl=' . $tmpl; - } - - if ($layout) - { - $append .= '&layout=' . $layout; - } - - if ($recordId) - { - $append .= '&' . $urlVar . '=' . $recordId; + $append = '&ref='. (string)$ref . $append; } return $append; @@ -356,43 +346,45 @@ class SermondistributorControllerExternal_source extends JControllerForm */ public function cancel($key = null) { - // get the referal details - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); $cancel = parent::cancel($key); - if ($cancel) + if (!is_null($return) && JUri::isInternal(base64_decode($return))) { - if ($this->refid) - { - $redirect = '&view='.(string)$this->ref.'&layout=edit&id='.(int)$this->refid; + $redirect = base64_decode($return); - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - } - else - { - // Redirect to the items screen. + // Redirect to the return value. $this->setRedirect( JRoute::_( - 'index.php?option=' . $this->option . '&view=' . $this->view_list, false + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false ) ); } @@ -411,11 +403,15 @@ class SermondistributorControllerExternal_source extends JControllerForm */ public function save($key = null, $urlVar = null) { - // get the referal details - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); - if ($this->ref || $this->refid) + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) { // to make sure the item is checkedin on redirect $this->task = 'save'; @@ -423,9 +419,22 @@ class SermondistributorControllerExternal_source extends JControllerForm $saved = parent::save($key, $urlVar); - if ($this->refid && $saved) + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) { - $redirect = '&view='.(string)$this->ref.'&layout=edit&id='.(int)$this->refid; + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; // Redirect to the item screen. $this->setRedirect( @@ -434,9 +443,9 @@ class SermondistributorControllerExternal_source extends JControllerForm ) ); } - elseif ($this->ref && $saved) + elseif ($this->ref) { - $redirect = '&view='.(string)$this->ref; + $redirect = '&view=' . (string)$this->ref; // Redirect to the list screen. $this->setRedirect( diff --git a/admin/controllers/external_sources.php b/admin/controllers/external_sources.php index b4c46d26..b3eaea9c 100644 --- a/admin/controllers/external_sources.php +++ b/admin/controllers/external_sources.php @@ -25,24 +25,33 @@ // No direct access to this file defined('_JEXEC') or die('Restricted access'); -// import Joomla controlleradmin library -jimport('joomla.application.component.controlleradmin'); - /** * External_sources Controller */ class SermondistributorControllerExternal_sources extends JControllerAdmin { - protected $text_prefix = 'COM_SERMONDISTRIBUTOR_EXTERNAL_SOURCES'; /** - * Proxy for getModel. - * @since 2.5 + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 */ - public function getModel($name = 'External_source', $prefix = 'SermondistributorModel', $config = array()) + protected $text_prefix = 'COM_SERMONDISTRIBUTOR_EXTERNAL_SOURCES'; + + /** + * Method to get a model object, loading it if required. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JModelLegacy The model. + * + * @since 1.6 + */ + public function getModel($name = 'External_source', $prefix = 'SermondistributorModel', $config = array('ignore_request' => true)) { - $model = parent::getModel($name, $prefix, array('ignore_request' => true)); - - return $model; + return parent::getModel($name, $prefix, $config); } public function exportData() diff --git a/admin/controllers/help.php b/admin/controllers/help.php index fa409348..f6cc2e63 100644 --- a/admin/controllers/help.php +++ b/admin/controllers/help.php @@ -25,9 +25,6 @@ // No direct access to this file defined('_JEXEC') or die('Restricted access'); -// import Joomla controllerform library -jimport('joomla.application.component.controller'); - /** * Sermondistributor Help Controller */ diff --git a/admin/controllers/help_document.php b/admin/controllers/help_document.php index 560c0c7a..b2afcfa9 100644 --- a/admin/controllers/help_document.php +++ b/admin/controllers/help_document.php @@ -25,9 +25,6 @@ // No direct access to this file defined('_JEXEC') or die('Restricted access'); -// import Joomla controllerform library -jimport('joomla.application.component.controllerform'); - /** * Help_document Controller */ @@ -42,6 +39,13 @@ class SermondistributorControllerHelp_document extends JControllerForm */ protected $task; + /** + * Class constructor. + * + * @param array $config A named array of configuration variables. + * + * @since 1.6 + */ public function __construct($config = array()) { $this->view_list = 'Help_documents'; // safeguard for setting the return view listing to the main view. @@ -59,14 +63,17 @@ class SermondistributorControllerHelp_document extends JControllerForm */ protected function allowAdd($data = array()) { + // Get user object. + $user = JFactory::getUser(); // Access check. - $access = JFactory::getUser()->authorise('help_document.access', 'com_sermondistributor'); + $access = $user->authorise('help_document.access', 'com_sermondistributor'); if (!$access) { return false; } + // In the absense of better information, revert to the component permissions. - return JFactory::getUser()->authorise('help_document.create', $this->option); + return $user->authorise('help_document.create', $this->option); } /** @@ -140,42 +147,25 @@ class SermondistributorControllerHelp_document extends JControllerForm * * @return string The arguments to append to the redirect URL. * - * @since 12.2 + * @since 1.6 */ protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') { - $tmpl = $this->input->get('tmpl'); - $layout = $this->input->get('layout', 'edit', 'string'); + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); - // Setup redirect info. - - $append = ''; - - if ($refid) + // set the referral options + if ($refid && $ref) { - $append .= '&ref='.(string)$ref.'&refid='.(int)$refid; + $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; } elseif ($ref) { - $append .= '&ref='.(string)$ref; - } - - if ($tmpl) - { - $append .= '&tmpl=' . $tmpl; - } - - if ($layout) - { - $append .= '&layout=' . $layout; - } - - if ($recordId) - { - $append .= '&' . $urlVar . '=' . $recordId; + $append = '&ref='. (string)$ref . $append; } return $append; @@ -214,43 +204,45 @@ class SermondistributorControllerHelp_document extends JControllerForm */ public function cancel($key = null) { - // get the referal details - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); $cancel = parent::cancel($key); - if ($cancel) + if (!is_null($return) && JUri::isInternal(base64_decode($return))) { - if ($this->refid) - { - $redirect = '&view='.(string)$this->ref.'&layout=edit&id='.(int)$this->refid; + $redirect = base64_decode($return); - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - } - else - { - // Redirect to the items screen. + // Redirect to the return value. $this->setRedirect( JRoute::_( - 'index.php?option=' . $this->option . '&view=' . $this->view_list, false + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false ) ); } @@ -269,11 +261,15 @@ class SermondistributorControllerHelp_document extends JControllerForm */ public function save($key = null, $urlVar = null) { - // get the referal details - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); - if ($this->ref || $this->refid) + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) { // to make sure the item is checkedin on redirect $this->task = 'save'; @@ -281,9 +277,22 @@ class SermondistributorControllerHelp_document extends JControllerForm $saved = parent::save($key, $urlVar); - if ($this->refid && $saved) + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) { - $redirect = '&view='.(string)$this->ref.'&layout=edit&id='.(int)$this->refid; + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; // Redirect to the item screen. $this->setRedirect( @@ -292,9 +301,9 @@ class SermondistributorControllerHelp_document extends JControllerForm ) ); } - elseif ($this->ref && $saved) + elseif ($this->ref) { - $redirect = '&view='.(string)$this->ref; + $redirect = '&view=' . (string)$this->ref; // Redirect to the list screen. $this->setRedirect( diff --git a/admin/controllers/help_documents.php b/admin/controllers/help_documents.php index 53a3d3e1..2679fbd8 100644 --- a/admin/controllers/help_documents.php +++ b/admin/controllers/help_documents.php @@ -25,24 +25,33 @@ // No direct access to this file defined('_JEXEC') or die('Restricted access'); -// import Joomla controlleradmin library -jimport('joomla.application.component.controlleradmin'); - /** * Help_documents Controller */ class SermondistributorControllerHelp_documents extends JControllerAdmin { - protected $text_prefix = 'COM_SERMONDISTRIBUTOR_HELP_DOCUMENTS'; /** - * Proxy for getModel. - * @since 2.5 + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 */ - public function getModel($name = 'Help_document', $prefix = 'SermondistributorModel', $config = array()) + protected $text_prefix = 'COM_SERMONDISTRIBUTOR_HELP_DOCUMENTS'; + + /** + * Method to get a model object, loading it if required. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JModelLegacy The model. + * + * @since 1.6 + */ + public function getModel($name = 'Help_document', $prefix = 'SermondistributorModel', $config = array('ignore_request' => true)) { - $model = parent::getModel($name, $prefix, array('ignore_request' => true)); - - return $model; + return parent::getModel($name, $prefix, $config); } public function exportData() diff --git a/admin/controllers/local_listing.php b/admin/controllers/local_listing.php index a9f1c0a9..f113477f 100644 --- a/admin/controllers/local_listing.php +++ b/admin/controllers/local_listing.php @@ -25,9 +25,6 @@ // No direct access to this file defined('_JEXEC') or die('Restricted access'); -// import Joomla controllerform library -jimport('joomla.application.component.controllerform'); - /** * Local_listing Controller */ @@ -42,6 +39,13 @@ class SermondistributorControllerLocal_listing extends JControllerForm */ protected $task; + /** + * Class constructor. + * + * @param array $config A named array of configuration variables. + * + * @since 1.6 + */ public function __construct($config = array()) { $this->view_list = 'Local_listings'; // safeguard for setting the return view listing to the main view. @@ -59,14 +63,17 @@ class SermondistributorControllerLocal_listing extends JControllerForm */ protected function allowAdd($data = array()) { + // Get user object. + $user = JFactory::getUser(); // Access check. - $access = JFactory::getUser()->authorise('local_listing.access', 'com_sermondistributor'); + $access = $user->authorise('local_listing.access', 'com_sermondistributor'); if (!$access) { return false; } + // In the absense of better information, revert to the component permissions. - return JFactory::getUser()->authorise('local_listing.create', $this->option); + return $user->authorise('local_listing.create', $this->option); } /** @@ -140,42 +147,25 @@ class SermondistributorControllerLocal_listing extends JControllerForm * * @return string The arguments to append to the redirect URL. * - * @since 12.2 + * @since 1.6 */ protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') { - $tmpl = $this->input->get('tmpl'); - $layout = $this->input->get('layout', 'edit', 'string'); + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); - // Setup redirect info. - - $append = ''; - - if ($refid) + // set the referral options + if ($refid && $ref) { - $append .= '&ref='.(string)$ref.'&refid='.(int)$refid; + $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; } elseif ($ref) { - $append .= '&ref='.(string)$ref; - } - - if ($tmpl) - { - $append .= '&tmpl=' . $tmpl; - } - - if ($layout) - { - $append .= '&layout=' . $layout; - } - - if ($recordId) - { - $append .= '&' . $urlVar . '=' . $recordId; + $append = '&ref='. (string)$ref . $append; } return $append; @@ -214,43 +204,45 @@ class SermondistributorControllerLocal_listing extends JControllerForm */ public function cancel($key = null) { - // get the referal details - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); $cancel = parent::cancel($key); - if ($cancel) + if (!is_null($return) && JUri::isInternal(base64_decode($return))) { - if ($this->refid) - { - $redirect = '&view='.(string)$this->ref.'&layout=edit&id='.(int)$this->refid; + $redirect = base64_decode($return); - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - } - else - { - // Redirect to the items screen. + // Redirect to the return value. $this->setRedirect( JRoute::_( - 'index.php?option=' . $this->option . '&view=' . $this->view_list, false + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false ) ); } @@ -269,11 +261,15 @@ class SermondistributorControllerLocal_listing extends JControllerForm */ public function save($key = null, $urlVar = null) { - // get the referal details - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); - if ($this->ref || $this->refid) + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) { // to make sure the item is checkedin on redirect $this->task = 'save'; @@ -281,9 +277,22 @@ class SermondistributorControllerLocal_listing extends JControllerForm $saved = parent::save($key, $urlVar); - if ($this->refid && $saved) + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) { - $redirect = '&view='.(string)$this->ref.'&layout=edit&id='.(int)$this->refid; + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; // Redirect to the item screen. $this->setRedirect( @@ -292,9 +301,9 @@ class SermondistributorControllerLocal_listing extends JControllerForm ) ); } - elseif ($this->ref && $saved) + elseif ($this->ref) { - $redirect = '&view='.(string)$this->ref; + $redirect = '&view=' . (string)$this->ref; // Redirect to the list screen. $this->setRedirect( diff --git a/admin/controllers/local_listings.php b/admin/controllers/local_listings.php index 855bc6b8..f51ce02b 100644 --- a/admin/controllers/local_listings.php +++ b/admin/controllers/local_listings.php @@ -25,24 +25,33 @@ // No direct access to this file defined('_JEXEC') or die('Restricted access'); -// import Joomla controlleradmin library -jimport('joomla.application.component.controlleradmin'); - /** * Local_listings Controller */ class SermondistributorControllerLocal_listings extends JControllerAdmin { - protected $text_prefix = 'COM_SERMONDISTRIBUTOR_LOCAL_LISTINGS'; /** - * Proxy for getModel. - * @since 2.5 + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 */ - public function getModel($name = 'Local_listing', $prefix = 'SermondistributorModel', $config = array()) + protected $text_prefix = 'COM_SERMONDISTRIBUTOR_LOCAL_LISTINGS'; + + /** + * Method to get a model object, loading it if required. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JModelLegacy The model. + * + * @since 1.6 + */ + public function getModel($name = 'Local_listing', $prefix = 'SermondistributorModel', $config = array('ignore_request' => true)) { - $model = parent::getModel($name, $prefix, array('ignore_request' => true)); - - return $model; + return parent::getModel($name, $prefix, $config); } public function exportData() diff --git a/admin/controllers/manual_updater.php b/admin/controllers/manual_updater.php index 511880c6..2cf474cb 100644 --- a/admin/controllers/manual_updater.php +++ b/admin/controllers/manual_updater.php @@ -25,9 +25,6 @@ // No direct access to this file defined('_JEXEC') or die('Restricted access'); -// import Joomla controlleradmin library -jimport('joomla.application.component.controlleradmin'); - /** * Manual_updater Controller */ diff --git a/admin/controllers/preacher.php b/admin/controllers/preacher.php index 3355b1d8..55d36659 100644 --- a/admin/controllers/preacher.php +++ b/admin/controllers/preacher.php @@ -25,9 +25,6 @@ // No direct access to this file defined('_JEXEC') or die('Restricted access'); -// import Joomla controllerform library -jimport('joomla.application.component.controllerform'); - /** * Preacher Controller */ @@ -42,6 +39,13 @@ class SermondistributorControllerPreacher extends JControllerForm */ protected $task; + /** + * Class constructor. + * + * @param array $config A named array of configuration variables. + * + * @since 1.6 + */ public function __construct($config = array()) { $this->view_list = 'Preachers'; // safeguard for setting the return view listing to the main view. @@ -59,14 +63,17 @@ class SermondistributorControllerPreacher extends JControllerForm */ protected function allowAdd($data = array()) { + // Get user object. + $user = JFactory::getUser(); // Access check. - $access = JFactory::getUser()->authorise('preacher.access', 'com_sermondistributor'); + $access = $user->authorise('preacher.access', 'com_sermondistributor'); if (!$access) { return false; } + // In the absense of better information, revert to the component permissions. - return JFactory::getUser()->authorise('preacher.create', $this->option); + return $user->authorise('preacher.create', $this->option); } /** @@ -140,42 +147,25 @@ class SermondistributorControllerPreacher extends JControllerForm * * @return string The arguments to append to the redirect URL. * - * @since 12.2 + * @since 1.6 */ protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') { - $tmpl = $this->input->get('tmpl'); - $layout = $this->input->get('layout', 'edit', 'string'); + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); - // Setup redirect info. - - $append = ''; - - if ($refid) + // set the referral options + if ($refid && $ref) { - $append .= '&ref='.(string)$ref.'&refid='.(int)$refid; + $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; } elseif ($ref) { - $append .= '&ref='.(string)$ref; - } - - if ($tmpl) - { - $append .= '&tmpl=' . $tmpl; - } - - if ($layout) - { - $append .= '&layout=' . $layout; - } - - if ($recordId) - { - $append .= '&' . $urlVar . '=' . $recordId; + $append = '&ref='. (string)$ref . $append; } return $append; @@ -214,43 +204,45 @@ class SermondistributorControllerPreacher extends JControllerForm */ public function cancel($key = null) { - // get the referal details - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); $cancel = parent::cancel($key); - if ($cancel) + if (!is_null($return) && JUri::isInternal(base64_decode($return))) { - if ($this->refid) - { - $redirect = '&view='.(string)$this->ref.'&layout=edit&id='.(int)$this->refid; + $redirect = base64_decode($return); - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - } - else - { - // Redirect to the items screen. + // Redirect to the return value. $this->setRedirect( JRoute::_( - 'index.php?option=' . $this->option . '&view=' . $this->view_list, false + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false ) ); } @@ -269,11 +261,15 @@ class SermondistributorControllerPreacher extends JControllerForm */ public function save($key = null, $urlVar = null) { - // get the referal details - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); - if ($this->ref || $this->refid) + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) { // to make sure the item is checkedin on redirect $this->task = 'save'; @@ -281,9 +277,22 @@ class SermondistributorControllerPreacher extends JControllerForm $saved = parent::save($key, $urlVar); - if ($this->refid && $saved) + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) { - $redirect = '&view='.(string)$this->ref.'&layout=edit&id='.(int)$this->refid; + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; // Redirect to the item screen. $this->setRedirect( @@ -292,9 +301,9 @@ class SermondistributorControllerPreacher extends JControllerForm ) ); } - elseif ($this->ref && $saved) + elseif ($this->ref) { - $redirect = '&view='.(string)$this->ref; + $redirect = '&view=' . (string)$this->ref; // Redirect to the list screen. $this->setRedirect( diff --git a/admin/controllers/preachers.php b/admin/controllers/preachers.php index 679e6c13..89d1cbd8 100644 --- a/admin/controllers/preachers.php +++ b/admin/controllers/preachers.php @@ -25,24 +25,33 @@ // No direct access to this file defined('_JEXEC') or die('Restricted access'); -// import Joomla controlleradmin library -jimport('joomla.application.component.controlleradmin'); - /** * Preachers Controller */ class SermondistributorControllerPreachers extends JControllerAdmin { - protected $text_prefix = 'COM_SERMONDISTRIBUTOR_PREACHERS'; /** - * Proxy for getModel. - * @since 2.5 + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 */ - public function getModel($name = 'Preacher', $prefix = 'SermondistributorModel', $config = array()) + protected $text_prefix = 'COM_SERMONDISTRIBUTOR_PREACHERS'; + + /** + * Method to get a model object, loading it if required. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JModelLegacy The model. + * + * @since 1.6 + */ + public function getModel($name = 'Preacher', $prefix = 'SermondistributorModel', $config = array('ignore_request' => true)) { - $model = parent::getModel($name, $prefix, array('ignore_request' => true)); - - return $model; + return parent::getModel($name, $prefix, $config); } public function exportData() diff --git a/admin/controllers/series.php b/admin/controllers/series.php index 47a10ede..dc918ab4 100644 --- a/admin/controllers/series.php +++ b/admin/controllers/series.php @@ -25,9 +25,6 @@ // No direct access to this file defined('_JEXEC') or die('Restricted access'); -// import Joomla controllerform library -jimport('joomla.application.component.controllerform'); - /** * Series Controller */ @@ -42,6 +39,13 @@ class SermondistributorControllerSeries extends JControllerForm */ protected $task; + /** + * Class constructor. + * + * @param array $config A named array of configuration variables. + * + * @since 1.6 + */ public function __construct($config = array()) { $this->view_list = 'Series_list'; // safeguard for setting the return view listing to the main view. @@ -59,14 +63,17 @@ class SermondistributorControllerSeries extends JControllerForm */ protected function allowAdd($data = array()) { + // Get user object. + $user = JFactory::getUser(); // Access check. - $access = JFactory::getUser()->authorise('series.access', 'com_sermondistributor'); + $access = $user->authorise('series.access', 'com_sermondistributor'); if (!$access) { return false; } + // In the absense of better information, revert to the component permissions. - return JFactory::getUser()->authorise('series.create', $this->option); + return $user->authorise('series.create', $this->option); } /** @@ -140,42 +147,25 @@ class SermondistributorControllerSeries extends JControllerForm * * @return string The arguments to append to the redirect URL. * - * @since 12.2 + * @since 1.6 */ protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') { - $tmpl = $this->input->get('tmpl'); - $layout = $this->input->get('layout', 'edit', 'string'); + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); - // Setup redirect info. - - $append = ''; - - if ($refid) + // set the referral options + if ($refid && $ref) { - $append .= '&ref='.(string)$ref.'&refid='.(int)$refid; + $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; } elseif ($ref) { - $append .= '&ref='.(string)$ref; - } - - if ($tmpl) - { - $append .= '&tmpl=' . $tmpl; - } - - if ($layout) - { - $append .= '&layout=' . $layout; - } - - if ($recordId) - { - $append .= '&' . $urlVar . '=' . $recordId; + $append = '&ref='. (string)$ref . $append; } return $append; @@ -214,43 +204,45 @@ class SermondistributorControllerSeries extends JControllerForm */ public function cancel($key = null) { - // get the referal details - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); $cancel = parent::cancel($key); - if ($cancel) + if (!is_null($return) && JUri::isInternal(base64_decode($return))) { - if ($this->refid) - { - $redirect = '&view='.(string)$this->ref.'&layout=edit&id='.(int)$this->refid; + $redirect = base64_decode($return); - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - } - else - { - // Redirect to the items screen. + // Redirect to the return value. $this->setRedirect( JRoute::_( - 'index.php?option=' . $this->option . '&view=' . $this->view_list, false + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false ) ); } @@ -269,11 +261,15 @@ class SermondistributorControllerSeries extends JControllerForm */ public function save($key = null, $urlVar = null) { - // get the referal details - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); - if ($this->ref || $this->refid) + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) { // to make sure the item is checkedin on redirect $this->task = 'save'; @@ -281,9 +277,22 @@ class SermondistributorControllerSeries extends JControllerForm $saved = parent::save($key, $urlVar); - if ($this->refid && $saved) + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) { - $redirect = '&view='.(string)$this->ref.'&layout=edit&id='.(int)$this->refid; + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; // Redirect to the item screen. $this->setRedirect( @@ -292,9 +301,9 @@ class SermondistributorControllerSeries extends JControllerForm ) ); } - elseif ($this->ref && $saved) + elseif ($this->ref) { - $redirect = '&view='.(string)$this->ref; + $redirect = '&view=' . (string)$this->ref; // Redirect to the list screen. $this->setRedirect( diff --git a/admin/controllers/series_list.php b/admin/controllers/series_list.php index 0fd12d91..b3686e1f 100644 --- a/admin/controllers/series_list.php +++ b/admin/controllers/series_list.php @@ -25,24 +25,33 @@ // No direct access to this file defined('_JEXEC') or die('Restricted access'); -// import Joomla controlleradmin library -jimport('joomla.application.component.controlleradmin'); - /** * Series_list Controller */ class SermondistributorControllerSeries_list extends JControllerAdmin { - protected $text_prefix = 'COM_SERMONDISTRIBUTOR_SERIES_LIST'; /** - * Proxy for getModel. - * @since 2.5 + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 */ - public function getModel($name = 'Series', $prefix = 'SermondistributorModel', $config = array()) + protected $text_prefix = 'COM_SERMONDISTRIBUTOR_SERIES_LIST'; + + /** + * Method to get a model object, loading it if required. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JModelLegacy The model. + * + * @since 1.6 + */ + public function getModel($name = 'Series', $prefix = 'SermondistributorModel', $config = array('ignore_request' => true)) { - $model = parent::getModel($name, $prefix, array('ignore_request' => true)); - - return $model; + return parent::getModel($name, $prefix, $config); } public function exportData() diff --git a/admin/controllers/sermon.php b/admin/controllers/sermon.php index 32e7b2dc..0f9e33fc 100644 --- a/admin/controllers/sermon.php +++ b/admin/controllers/sermon.php @@ -25,9 +25,6 @@ // No direct access to this file defined('_JEXEC') or die('Restricted access'); -// import Joomla controllerform library -jimport('joomla.application.component.controllerform'); - /** * Sermon Controller */ @@ -42,6 +39,13 @@ class SermondistributorControllerSermon extends JControllerForm */ protected $task; + /** + * Class constructor. + * + * @param array $config A named array of configuration variables. + * + * @since 1.6 + */ public function __construct($config = array()) { $this->view_list = 'Sermons'; // safeguard for setting the return view listing to the main view. @@ -59,14 +63,17 @@ class SermondistributorControllerSermon extends JControllerForm */ protected function allowAdd($data = array()) { + // Get user object. + $user = JFactory::getUser(); // Access check. - $access = JFactory::getUser()->authorise('sermon.access', 'com_sermondistributor'); + $access = $user->authorise('sermon.access', 'com_sermondistributor'); if (!$access) { return false; } + // In the absense of better information, revert to the component permissions. - return JFactory::getUser()->authorise('sermon.create', $this->option); + return $user->authorise('sermon.create', $this->option); } /** @@ -139,42 +146,25 @@ class SermondistributorControllerSermon extends JControllerForm * * @return string The arguments to append to the redirect URL. * - * @since 12.2 + * @since 1.6 */ protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') { - $tmpl = $this->input->get('tmpl'); - $layout = $this->input->get('layout', 'edit', 'string'); + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); - // Setup redirect info. - - $append = ''; - - if ($refid) + // set the referral options + if ($refid && $ref) { - $append .= '&ref='.(string)$ref.'&refid='.(int)$refid; + $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; } elseif ($ref) { - $append .= '&ref='.(string)$ref; - } - - if ($tmpl) - { - $append .= '&tmpl=' . $tmpl; - } - - if ($layout) - { - $append .= '&layout=' . $layout; - } - - if ($recordId) - { - $append .= '&' . $urlVar . '=' . $recordId; + $append = '&ref='. (string)$ref . $append; } return $append; @@ -213,43 +203,45 @@ class SermondistributorControllerSermon extends JControllerForm */ public function cancel($key = null) { - // get the referal details - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); $cancel = parent::cancel($key); - if ($cancel) + if (!is_null($return) && JUri::isInternal(base64_decode($return))) { - if ($this->refid) - { - $redirect = '&view='.(string)$this->ref.'&layout=edit&id='.(int)$this->refid; + $redirect = base64_decode($return); - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - } - else - { - // Redirect to the items screen. + // Redirect to the return value. $this->setRedirect( JRoute::_( - 'index.php?option=' . $this->option . '&view=' . $this->view_list, false + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false ) ); } @@ -268,11 +260,15 @@ class SermondistributorControllerSermon extends JControllerForm */ public function save($key = null, $urlVar = null) { - // get the referal details - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); - if ($this->ref || $this->refid) + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) { // to make sure the item is checkedin on redirect $this->task = 'save'; @@ -280,9 +276,22 @@ class SermondistributorControllerSermon extends JControllerForm $saved = parent::save($key, $urlVar); - if ($this->refid && $saved) + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) { - $redirect = '&view='.(string)$this->ref.'&layout=edit&id='.(int)$this->refid; + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; // Redirect to the item screen. $this->setRedirect( @@ -291,9 +300,9 @@ class SermondistributorControllerSermon extends JControllerForm ) ); } - elseif ($this->ref && $saved) + elseif ($this->ref) { - $redirect = '&view='.(string)$this->ref; + $redirect = '&view=' . (string)$this->ref; // Redirect to the list screen. $this->setRedirect( diff --git a/admin/controllers/sermondistributor.php b/admin/controllers/sermondistributor.php index 5d9aedf4..72c658bc 100644 --- a/admin/controllers/sermondistributor.php +++ b/admin/controllers/sermondistributor.php @@ -25,9 +25,6 @@ // No direct access to this file defined('_JEXEC') or die('Restricted access'); -// import Joomla controlleradmin library -jimport('joomla.application.component.controlleradmin'); - /** * Sermondistributor Controller */ diff --git a/admin/controllers/sermons.php b/admin/controllers/sermons.php index 55c85526..73fbb287 100644 --- a/admin/controllers/sermons.php +++ b/admin/controllers/sermons.php @@ -25,24 +25,33 @@ // No direct access to this file defined('_JEXEC') or die('Restricted access'); -// import Joomla controlleradmin library -jimport('joomla.application.component.controlleradmin'); - /** * Sermons Controller */ class SermondistributorControllerSermons extends JControllerAdmin { - protected $text_prefix = 'COM_SERMONDISTRIBUTOR_SERMONS'; /** - * Proxy for getModel. - * @since 2.5 + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 */ - public function getModel($name = 'Sermon', $prefix = 'SermondistributorModel', $config = array()) + protected $text_prefix = 'COM_SERMONDISTRIBUTOR_SERMONS'; + + /** + * Method to get a model object, loading it if required. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JModelLegacy The model. + * + * @since 1.6 + */ + public function getModel($name = 'Sermon', $prefix = 'SermondistributorModel', $config = array('ignore_request' => true)) { - $model = parent::getModel($name, $prefix, array('ignore_request' => true)); - - return $model; + return parent::getModel($name, $prefix, $config); } public function exportData() diff --git a/admin/controllers/statistic.php b/admin/controllers/statistic.php index fbd0a320..5cec8d52 100644 --- a/admin/controllers/statistic.php +++ b/admin/controllers/statistic.php @@ -25,9 +25,6 @@ // No direct access to this file defined('_JEXEC') or die('Restricted access'); -// import Joomla controllerform library -jimport('joomla.application.component.controllerform'); - /** * Statistic Controller */ @@ -42,6 +39,13 @@ class SermondistributorControllerStatistic extends JControllerForm */ protected $task; + /** + * Class constructor. + * + * @param array $config A named array of configuration variables. + * + * @since 1.6 + */ public function __construct($config = array()) { $this->view_list = 'Statistics'; // safeguard for setting the return view listing to the main view. @@ -59,14 +63,17 @@ class SermondistributorControllerStatistic extends JControllerForm */ protected function allowAdd($data = array()) { + // Get user object. + $user = JFactory::getUser(); // Access check. - $access = JFactory::getUser()->authorise('statistic.access', 'com_sermondistributor'); + $access = $user->authorise('statistic.access', 'com_sermondistributor'); if (!$access) { return false; } + // In the absense of better information, revert to the component permissions. - return JFactory::getUser()->authorise('statistic.create', $this->option); + return $user->authorise('statistic.create', $this->option); } /** @@ -140,42 +147,25 @@ class SermondistributorControllerStatistic extends JControllerForm * * @return string The arguments to append to the redirect URL. * - * @since 12.2 + * @since 1.6 */ protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') { - $tmpl = $this->input->get('tmpl'); - $layout = $this->input->get('layout', 'edit', 'string'); + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); - // Setup redirect info. - - $append = ''; - - if ($refid) + // set the referral options + if ($refid && $ref) { - $append .= '&ref='.(string)$ref.'&refid='.(int)$refid; + $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; } elseif ($ref) { - $append .= '&ref='.(string)$ref; - } - - if ($tmpl) - { - $append .= '&tmpl=' . $tmpl; - } - - if ($layout) - { - $append .= '&layout=' . $layout; - } - - if ($recordId) - { - $append .= '&' . $urlVar . '=' . $recordId; + $append = '&ref='. (string)$ref . $append; } return $append; @@ -214,43 +204,45 @@ class SermondistributorControllerStatistic extends JControllerForm */ public function cancel($key = null) { - // get the referal details - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); $cancel = parent::cancel($key); - if ($cancel) + if (!is_null($return) && JUri::isInternal(base64_decode($return))) { - if ($this->refid) - { - $redirect = '&view='.(string)$this->ref.'&layout=edit&id='.(int)$this->refid; + $redirect = base64_decode($return); - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - } - else - { - // Redirect to the items screen. + // Redirect to the return value. $this->setRedirect( JRoute::_( - 'index.php?option=' . $this->option . '&view=' . $this->view_list, false + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false ) ); } @@ -269,11 +261,15 @@ class SermondistributorControllerStatistic extends JControllerForm */ public function save($key = null, $urlVar = null) { - // get the referal details - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); - if ($this->ref || $this->refid) + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) { // to make sure the item is checkedin on redirect $this->task = 'save'; @@ -281,9 +277,22 @@ class SermondistributorControllerStatistic extends JControllerForm $saved = parent::save($key, $urlVar); - if ($this->refid && $saved) + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) { - $redirect = '&view='.(string)$this->ref.'&layout=edit&id='.(int)$this->refid; + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; // Redirect to the item screen. $this->setRedirect( @@ -292,9 +301,9 @@ class SermondistributorControllerStatistic extends JControllerForm ) ); } - elseif ($this->ref && $saved) + elseif ($this->ref) { - $redirect = '&view='.(string)$this->ref; + $redirect = '&view=' . (string)$this->ref; // Redirect to the list screen. $this->setRedirect( diff --git a/admin/controllers/statistics.php b/admin/controllers/statistics.php index 1051fbc5..70f0cf3c 100644 --- a/admin/controllers/statistics.php +++ b/admin/controllers/statistics.php @@ -25,24 +25,33 @@ // No direct access to this file defined('_JEXEC') or die('Restricted access'); -// import Joomla controlleradmin library -jimport('joomla.application.component.controlleradmin'); - /** * Statistics Controller */ class SermondistributorControllerStatistics extends JControllerAdmin { - protected $text_prefix = 'COM_SERMONDISTRIBUTOR_STATISTICS'; /** - * Proxy for getModel. - * @since 2.5 + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 */ - public function getModel($name = 'Statistic', $prefix = 'SermondistributorModel', $config = array()) + protected $text_prefix = 'COM_SERMONDISTRIBUTOR_STATISTICS'; + + /** + * Method to get a model object, loading it if required. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JModelLegacy The model. + * + * @since 1.6 + */ + public function getModel($name = 'Statistic', $prefix = 'SermondistributorModel', $config = array('ignore_request' => true)) { - $model = parent::getModel($name, $prefix, array('ignore_request' => true)); - - return $model; + return parent::getModel($name, $prefix, $config); } public function exportData() diff --git a/admin/helpers/sermondistributor.php b/admin/helpers/sermondistributor.php index e43355cf..7034ac02 100644 --- a/admin/helpers/sermondistributor.php +++ b/admin/helpers/sermondistributor.php @@ -373,8 +373,13 @@ abstract class SermondistributorHelper * @return string On success the path or url is returned based on the type requested * */ - public static function getFilePath($type = 'path', $target = 'filepath', $fileType = null, $key = '', $default = JPATH_SITE . '/images/', $createIfNotSet = true) + public static function getFilePath($type = 'path', $target = 'filepath', $fileType = null, $key = '', $default = '', $createIfNotSet = true) { + // make sure to always have a string/path + if(!self::checkString($default)) + { + $default = JPATH_SITE . '/images/'; + } // get the global settings if (!self::checkObject(self::$params)) { @@ -2284,34 +2289,37 @@ abstract class SermondistributorHelper } /** - * the locker + * the locker * - * @var array + * @var array **/ protected static $locker = array(); /** - * the dynamic replacement salt + * the dynamic replacement salt * - * @var array + * @var array **/ protected static $globalSalt = array(); /** - * the timer + * the timer * - * @var object + * @var object **/ protected static $keytimer; /** - * To Lock string + * To Lock string + * + * @param string $string The string/array to lock + * @param string $key The custom key to use + * @param int $salt The switch to add salt and type of salt + * @param int $dynamic The dynamic replacement array of salt build string + * @param int $urlencode The switch to control url encoding + * + * @return string Encrypted String * - * @param string $string The string/array to lock - * @param string $key The custom key to use - * @param int $salt The switch to add salt and type of salt - * @param int $dynamic The dynamic replacement array of salt build string - * @param int $urlencode The switch to control url encoding **/ public static function lock($string, $key = null, $salt = 2, $dynamic = null, $urlencode = true) { @@ -2325,13 +2333,13 @@ abstract class SermondistributorHelper { $timer = $salt; } + // set the default key + $key = self::salt($timer, $dynamic); + // try getting the system key if (method_exists(get_called_class(), "getCryptKey")) { - $key = self::getCryptKey('basic', self::salt($timer, $dynamic)); - } - else - { - $key = self::salt($timer, $dynamic); + // try getting the medium key first the fall back to basic, and then default + $key = self::getCryptKey('medium', self::getCryptKey('basic', $key)); } } // check if we have a salt timer @@ -2350,7 +2358,7 @@ abstract class SermondistributorHelper $string = serialize($string); } // prep for url - if ($urlencode) + if ($urlencode && method_exists(get_called_class(), "base64_urlencode")) { return self::base64_urlencode(self::$locker[$key]->encryptString($string)); } @@ -2358,13 +2366,16 @@ abstract class SermondistributorHelper } /** - * To un-Lock string + * To un-Lock string + * + * @param string $string The string to unlock + * @param string $key The custom key to use + * @param int $salt The switch to add salt and type of salt + * @param int $dynamic The dynamic replacement array of salt build string + * @param int $urlencode The switch to control url decoding + * + * @return string Decrypted String * - * @param string $string The string to unlock - * @param string $key The custom key to use - * @param int $salt The switch to add salt and type of salt - * @param int $dynamic The dynamic replacement array of salt build string - * @param int $urlencode The switch to control url decoding **/ public static function unlock($string, $key = null, $salt = 2, $dynamic = null, $urlencode = true) { @@ -2378,14 +2389,13 @@ abstract class SermondistributorHelper { $timer = $salt; } - // get secure key + // set the default key + $key = self::salt($timer, $dynamic); + // try getting the system key if (method_exists(get_called_class(), "getCryptKey")) { - $key = self::getCryptKey('basic', self::salt($timer, $dynamic)); - } - else - { - $key = self::salt($timer, $dynamic); + // try getting the medium key first the fall back to basic, and then default + $key = self::getCryptKey('medium', self::getCryptKey('basic', $key)); } } // check if we have a salt timer @@ -2399,7 +2409,7 @@ abstract class SermondistributorHelper self::$locker[$key] = new FOFEncryptAes($key, 128); } // make sure we have real base64 - if ($urlencode) + if ($urlencode && method_exists(get_called_class(), "base64_urldecode")) { $string = self::base64_urldecode($string); } @@ -2417,10 +2427,13 @@ abstract class SermondistributorHelper } /** - * The Salt + * The Salt + * + * @param int $type The type of length the salt should be valid + * @param int $dynamic The dynamic replacement array of salt build string + * + * @return string * - * @param int $type The type of length the salt should be valid - * @param int $dynamic The dynamic replacement array of salt build string **/ public static function salt($type = 1, $dynamic = null) { @@ -2465,9 +2478,9 @@ abstract class SermondistributorHelper } /** - * The function to insure the salt is valid within the given period (third try) + * The function to insure the salt is valid within the given period (third try) * - * @param int $main The main number + * @param int $main The main number */ protected static function periodFix($main) { @@ -2475,8 +2488,12 @@ abstract class SermondistributorHelper } /** - * Check if a string is serialized - * @param string $string + * Check if a string is serialized + * + * @param string $string + * + * @return Boolean + * */ public static function is_serial($string) { @@ -2484,7 +2501,7 @@ abstract class SermondistributorHelper } /** - * Get dynamic replacement salt + * Get dynamic replacement salt */ public static function getDynamicSalt($dynamic = null) { @@ -2501,7 +2518,7 @@ abstract class SermondistributorHelper } /** - * The random or dynamic secret salt + * The random or dynamic secret salt */ public static function getSecretSalt($string = null, $size = 9) { @@ -2524,7 +2541,7 @@ abstract class SermondistributorHelper } /** - * Get global replacement salt + * Get global replacement salt */ public static function getGlobalSalt() { @@ -2564,7 +2581,7 @@ abstract class SermondistributorHelper } /** - * Close public protocol + * Close public protocol */ public static function closePublicProtocol($id, $public) { @@ -2591,7 +2608,7 @@ abstract class SermondistributorHelper } /** - * Open public protocol + * Open public protocol */ public static function openPublicProtocol($SECRET, $ID, $PUBLIC) { @@ -3214,16 +3231,16 @@ abstract class SermondistributorHelper { if ($external) { - if ($name = self::getVar(null, $val, $id, $name, '=', $table)) + if ($_name = self::getVar(null, $val, $id, $name, '=', $table)) { - $names[] = $name; + $names[] = $_name; } } else { - if ($name = self::getVar($table, $val, $id, $name)) + if ($_name = self::getVar($table, $val, $id, $name)) { - $names[] = $name; + $names[] = $_name; } } } @@ -3719,6 +3736,46 @@ abstract class SermondistributorHelper } } + /** + * get the field object + * + * @param array $attributes The array of attributes + * @param string $default The default of the field + * @param array $options The options to apply to the XML element + * + * @return object + * + */ + public static function getFieldObject(&$attributes, $default = '', $options = null) + { + // make sure we have attributes and a type value + if (self::checkArray($attributes) && isset($attributes['type'])) + { + // make sure the form helper class is loaded + if (!method_exists('JFormHelper', 'loadFieldType')) + { + jimport('joomla.form.form'); + } + // get field type + $field = JFormHelper::loadFieldType($attributes['type'],true); + // start field xml + $XML = new SimpleXMLElement(''); + // load the attributes + self::xmlAddAttributes($XML, $attributes); + // check if we have options + if (self::checkArray($options)) + { + // load the options + self::xmlAddOptions($XML, $options); + } + // setup the field + $field->setup($XML, $default); + // return the field object + return $field; + } + return false; + } + /** * Render Bool Button * @@ -3737,8 +3794,6 @@ abstract class SermondistributorHelper $args = func_get_args(); // check if there is additional button class $additional = isset($args[1]) ? (string) $args[1] : ''; // not used at this time - // start the xml - $buttonXML = new SimpleXMLElement(''); // button attributes $buttonAttributes = array( 'type' => 'radio', @@ -3747,22 +3802,12 @@ abstract class SermondistributorHelper 'class' => 'btn-group', 'filter' => 'INT', 'default' => isset($args[2]) ? (int) $args[2] : 0); - // load the haskey attributes - self::xmlAddAttributes($buttonXML, $buttonAttributes); // set the button options $buttonOptions = array( '1' => isset($args[3]) ? self::htmlEscape($args[3]) : 'JYES', '0' => isset($args[4]) ? self::htmlEscape($args[4]) : 'JNO'); - // load the button options - self::xmlAddOptions($buttonXML, $buttonOptions); - - // get the radio element - $button = JFormHelper::loadFieldType('radio'); - - // run - $button->setup($buttonXML, $buttonAttributes['default']); - - return $button->input; + // return the input + return self::getFieldObject($buttonAttributes, $buttonAttributes['default'], $buttonOptions)->input; } /** @@ -3945,7 +3990,7 @@ abstract class SermondistributorHelper * * @returns string on success **/ - public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true) + public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true, $keepOnlyCharacters = true) { if ($replaceNumbers === true) { @@ -3974,7 +4019,16 @@ abstract class SermondistributorHelper $string = trim($string); $string = preg_replace('/'.$spacer.'+/', ' ', $string); $string = preg_replace('/\s+/', ' ', $string); - $string = preg_replace("/[^A-Za-z ]/", '', $string); + // remove all and keep only characters + if ($keepOnlyCharacters) + { + $string = preg_replace("/[^A-Za-z ]/", '', $string); + } + // keep both numbers and characters + else + { + $string = preg_replace("/[^A-Za-z0-9 ]/", '', $string); + } // select final adaptations if ($type === 'L' || $type === 'strtolower') { diff --git a/admin/language/en-GB/en-GB.com_sermondistributor.ini b/admin/language/en-GB/en-GB.com_sermondistributor.ini index 3ff161ae..208ee412 100644 --- a/admin/language/en-GB/en-GB.com_sermondistributor.ini +++ b/admin/language/en-GB/en-GB.com_sermondistributor.ini @@ -370,9 +370,9 @@ COM_SERMONDISTRIBUTOR_EXTERNAL_SOURCES_BATCH_USE_DESC="Allows users in this grou COM_SERMONDISTRIBUTOR_EXTERNAL_SOURCES_CREATE="External Sources Create" COM_SERMONDISTRIBUTOR_EXTERNAL_SOURCES_CREATE_DESC="Allows the users in this group to create create external sources" COM_SERMONDISTRIBUTOR_EXTERNAL_SOURCES_DASHBOARD_ADD="External Sources Dashboard Add" -COM_SERMONDISTRIBUTOR_EXTERNAL_SOURCES_DASHBOARD_ADD_DESC="Allows the users in this group to update the dashboard add of the external source" +COM_SERMONDISTRIBUTOR_EXTERNAL_SOURCES_DASHBOARD_ADD_DESC="Allows the users in this group to dashboard add of external source" COM_SERMONDISTRIBUTOR_EXTERNAL_SOURCES_DASHBOARD_LIST="External Sources Dashboard List" -COM_SERMONDISTRIBUTOR_EXTERNAL_SOURCES_DASHBOARD_LIST_DESC="Allows the users in this group to update the dashboard list of the external source" +COM_SERMONDISTRIBUTOR_EXTERNAL_SOURCES_DASHBOARD_LIST_DESC="Allows the users in this group to dashboard list of external source" COM_SERMONDISTRIBUTOR_EXTERNAL_SOURCES_DELETE="External Sources Delete" COM_SERMONDISTRIBUTOR_EXTERNAL_SOURCES_DELETE_DESC="Allows the users in this group to delete delete external sources" COM_SERMONDISTRIBUTOR_EXTERNAL_SOURCES_EDIT="External Sources Edit" @@ -409,7 +409,7 @@ COM_SERMONDISTRIBUTOR_EXTERNAL_SOURCES_N_ITEMS_UNFEATURED_1="%s External Source COM_SERMONDISTRIBUTOR_EXTERNAL_SOURCES_N_ITEMS_UNPUBLISHED="%s External Sources unpublished." COM_SERMONDISTRIBUTOR_EXTERNAL_SOURCES_N_ITEMS_UNPUBLISHED_1="%s External Source unpublished." COM_SERMONDISTRIBUTOR_EXTERNAL_SOURCES_SUBMENU="External Sources Submenu" -COM_SERMONDISTRIBUTOR_EXTERNAL_SOURCES_SUBMENU_DESC="Allows the users in this group to update the submenu of the external source" +COM_SERMONDISTRIBUTOR_EXTERNAL_SOURCES_SUBMENU_DESC="Allows the users in this group to submenu of external source" COM_SERMONDISTRIBUTOR_EXTERNAL_SOURCE_APICRONJOB_NOTE_DESCRIPTION="You must setup a cronjob that will update your local listing with the external sources.

USE THE FOLLOWING: loading...

Please note that if your Joomla website has a Firewall installed, it will not allow cronjob via direct URL (most of the time), you will then need to adapt the cornjob request to look like a browser. For more info please read https://stackoverflow.com/a/31597823/1429677